Repository navigation
feat(migrate): add 'trokky migrate' to upgrade v0.1.x projects to v2 - #1
Merged
Merged
Conversation
…packages Rewrites @trokky/* specifiers (longest match first), updates package.json dependencies in place, and reports internal imports, Astro build-time TROKKY_API_URL inlining and structure/schema singleton divergence. Dry-run by default; --write refuses a dirty git tree unless --force.
Both would have passed for success on a real site.
The singleton check only ran when the structure lived in a file named
structure.{ts,js,mjs} or trokky.config.{ts,js,mjs}. Anything else was never
fed to the check, and the report then printed the same "No warnings." line it
prints when a project is genuinely clean. Reviewed by mutation: moving IGF's
structure.ts to structure/index.ts and stripping the flags took the output from
16 divergence warnings to zero, with nothing to tell the operator that nothing
had been examined. Splitting a structure across a directory is not exotic —
FUCEC's is already 500+ lines. Any source file containing a singleton entry is
now treated as a structure source, and a file may be both a structure and a
schema source rather than only whichever the switch matched first.
The report now always states what was examined ("Singleton check: 24 entries
across 2 structure file(s), against 39 schema file(s)") and says so explicitly
when it found no entries at all. "No warnings" alone cannot be told apart from
"never looked", and only one of those is safe to restore over.
A package.json whose dependency block is written on one line matched no
section, so the file came back byte-identical with no error: sources rewritten,
manifest still asking for packages that no longer exist, install failing later
on the deploy host. The line scan is now cross-checked against the parsed JSON
and refuses the file with an actionable message instead of doing nothing.
Also reports stale @Trokky pins in resolutions/overrides, which are deliberately
not rewritten but must not pass unmentioned.
Verified against both real sites, dry run only: IGF 16 entries over 2 structure
files against 22 schemas, FUCEC 24 over 2 against 39, no divergence on either —
now demonstrably checked rather than merely silent.
amenophis1er
added a commit
that referenced
this pull request
Sep 9, 2026
) * feat(migrate): add 'trokky migrate' to upgrade v0.1.x projects to v2 packages Rewrites @trokky/* specifiers (longest match first), updates package.json dependencies in place, and reports internal imports, Astro build-time TROKKY_API_URL inlining and structure/schema singleton divergence. Dry-run by default; --write refuses a dirty git tree unless --force. * docs(readme): document trokky migrate, its mapping table and warnings * fix(migrate): close two silent failures review found Both would have passed for success on a real site. The singleton check only ran when the structure lived in a file named structure.{ts,js,mjs} or trokky.config.{ts,js,mjs}. Anything else was never fed to the check, and the report then printed the same "No warnings." line it prints when a project is genuinely clean. Reviewed by mutation: moving a real project's structure.ts to structure/index.ts and stripping the flags took the output from 16 divergence warnings to zero, with nothing to tell the operator that nothing had been examined. Splitting a structure across a directory is not exotic — one production project's is already 500+ lines. Any source file containing a singleton entry is now treated as a structure source, and a file may be both a structure and a schema source rather than only whichever the switch matched first. The report now always states what was examined ("Singleton check: 24 entries across 2 structure file(s), against 39 schema file(s)") and says so explicitly when it found no entries at all. "No warnings" alone cannot be told apart from "never looked", and only one of those is safe to restore over. A package.json whose dependency block is written on one line matched no section, so the file came back byte-identical with no error: sources rewritten, manifest still asking for packages that no longer exist, install failing later on the deploy host. The line scan is now cross-checked against the parsed JSON and refuses the file with an actionable message instead of doing nothing. Also reports stale @Trokky pins in resolutions/overrides, which are deliberately not rewritten but must not pass unmentioned. Verified against two real sites, dry run only: 16 entries over 2 structure files against 22 schemas on one, 24 over 2 against 39 on the other, no divergence on either — now demonstrably checked rather than merely silent. --------- Co-authored-by: Amen <2668333+amenophis1er@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Turns the throwaway codemod used to migrate a real site by hand into a real, tested command. Production sites still have to be migrated with it.
Rewrites import/export specifiers,
require()and dynamicimport()across.ts/.tsx/.js/.mjs/.astro, updatespackage.jsondependencies to the v2 packages, and reports what it could not fix.Safety
Dry run is the default;
--writerefuses a dirty git tree unless--force, so there is always a diff to revert to. Review confirmed a dry run leaves a full copy of a real project byte-identical by tree hash, and that a second run is a provable no-op.Rewriting is safe by construction, not by map ordering: a specifier matches only on equality or
prefix + "/", so@trokky/corecan never match inside@trokky/core-extras, nor@trokky/mailinside@trokky/mail-adapter-console.Warnings
Three detectors, the third being the point of the exercise:
@trokky/*/src/…, which v2 does not ship.import.meta.env.TROKKY_API_URLin an Astro project — inlined at build time, so it must be set for the site build and not only the server process, or every media request 404s.trokky restoretakes an id-preserving PUT only for schema-level singletons, so without the flag it regenerates the document ids and the structure points at documents that no longer exist.What review caught
Two silent failures, both fixed in the last commit.
structure.tstostructure/index.tstook the output from 16 divergence warnings to zero — printing the sameNo warnings.as a genuinely clean project. Splitting a long structure across a directory is a normal thing to do. Any file containing a singleton entry now counts, and the report always states what it examined:Singleton check: N entries across M structure file(s), against K schema file(s).package.jsonwith a one-line dependency block matched no section and came back byte-identical with no error — sources rewritten, manifest still asking for deleted packages, install failing later on the deploy host. Now cross-checked against the parsed JSON and refused with an actionable message.Also reports stale
@trokkypins inresolutions/overrides, which are deliberately not rewritten.Verification
Exercised dry-run against real projects of both shapes (single package and monorepo), plus an end-to-end fixture: rewrite correctness, warning output, byte-identical dry runs and idempotent re-runs.
Note for monorepos: run it at the repo root so it sees every workspace, not at a single package directory.
go vet ./...andgo test ./...green.