Cross a major version
A new major of the framework shipped and you want to know what it will rewrite before you let it.
Goal
Read the plan for a major, run it, and finish the parts no codemod could do.
A break that ships without a way across is a break the framework has pushed onto you, so every major carries its codemods — and states what it could not codemod.
Prerequisites
A workspace on the previous major, a clean working tree (the codemods rewrite files in place), and a minute to read The workspace and versioning if the currency preamble is new to you.
Steps
1. Read the plan first
--dry-run reads the target's codemods out of its published tarball and installs
nothing:
concrete upgrade --dry-runconcrete upgrade: moving this workspace from <installed> to <target>
@homepages/concrete ^<installed major> -> ^<target major>
concrete upgrade: codemods, in the order they run:
<target>
<codemod>
by hand: <a step the codemod could not take>Three things are in that plan. The range rewrite your package.json will
take; the codemods, oldest release first; and the by hand: lines — the
steps no codemod could take, which are the real content of the upgrade. Read
those before anything else: they are what the changeset that shipped the break
said it could not do for you.
2. Run it
concrete upgradeconcrete upgrade: moving this workspace from <installed> to <target>
@homepages/concrete ^<installed major> -> ^<target major>
concrete upgrade: running codemods, in order:
<target> <codemod>
rewrote sections/hero.tsx
concrete upgrade: still to do by hand — no codemod could make these changes:
<target>: <a step the codemod could not take>
concrete upgrade: done — this workspace is on <target>. Commit package.json, package-lock.json and every rewritten file together.A major with no codemod prints no running codemods block: the package moves, and
its by-hand steps follow.
The install comes first and the codemods second, and that order is forced: the codemods to run ship inside the version being moved to, so they are on disk only once it is installed. Every file each codemod rewrote is printed, as is every file it could not and why.
Two failure shapes worth knowing. A failed install puts package.json back the
way it was and runs no codemod. A codemod that fails stops the chain — the ones
after it were written against the tree it was meant to leave — and says which
ones did not run; restore from version control and re-run rather than finishing
half-ported.
3. Do the by-hand steps
Nothing enforces them at the moment the upgrade exits, and a step left undone
usually surfaces as a rule in concrete check.
4. Review the diff, then check
The codemods rewrote real files. Read the diff the way you would read a colleague's: a rewrite can be correct and still worth looking at.
Some rewrites are large. Crossing into the major where fixtures are data, the
fixtures-are-data codemod evaluates each TypeScript fixture one last time and
writes it out as a JSON content fixture on a property document, listed in
fixtures/index.json; a property made by spreading another becomes a copied
property of its own, printed with its size, so you can drop the ones a playground
edit would show you as well.
git diff
concrete checktypecheck/error is the usual first finding on a major that changed a type, and
dependencies/lockfile-stale means the lockfile did not travel with
package.json — commit the two together.
5. Pin or step, when you need to
concrete upgrade --to <version> # one exact version instead of the published latestCodemods run forward only: moving to an older version moves the package and runs none. Stepping one major at a time is never wrong — the chain is measured from the version you were on, so crossing two at once runs both sets in order anyway.
Verify
concrete check green, and the diff read. Then concrete dev over your fixtures:
a major that changed rendering shows up there and not in the report.
