Upgrading crouton
Upgrading crouton
During 0.x, resource.json stays at schemaVersion: 1 and its $schema URL stays https://ghentcdh.github.io/crouton/schema/v1/resource.schema.json. Breaking changes are described in a per-release migration guide at the repository root, with the rule and a before/after example:
- migrate-to-0.2.0.md β
0.1.0β0.2.0(hooks, filter coercion, generated Prisma client layout, frontend renderers). - migrate-to-next-alpha.md β historical
0.0.1-alpha.Nβ0.1.0upgrade.
crouton migrate applies the resource.json codemods for you. See Versioning for what a release may change.
Steps
Bump every
@ghentcdh/crouton-*package to the same new version, then work through the matching migration guide for changes the codemods cannot make. For0.2.0, follow migrate-to-0.2.0.md.Preview, then apply the codemods:
pnpm crouton migrate --dry-run # lists, per file (sub-resources included), which rules apply pnpm crouton migrate # asks once, then rewrites the filesEvery rule keeps the rendered result the same (positions become layout order, table defaults are spelled out when a layout has to be added, β¦). A file is only written when the result validates; the others are listed with the reason and left untouched. Running it again is a no-op.
Validate every resource:
pnpm crouton validateFix what is left by hand β the message names the guide section to follow. Repeat until it exits
0.Review the diff and commit the changed
resource.jsonfiles.
| Command | Rewrites |
|---|---|
crouton migrate resources | Every rule in the guide: root keys β source / openapi / operations, relation config, spellings, layout nodes, column presentation β layout items, $schema + schemaVersion. |
crouton migrate layout | Layout nodes only: controls β items, actions β rowActions, table search/filter fields β operations.findAll. |
crouton migrate | Both, in that order (the layout pass is then a no-op). |
All three take --cwd, -p/--project, --dry-run and -y.
Not covered by the codemods
Changes in application code (json_schema/ui_schema β data/ui, applyResourceTagDescriptions, the CustomRepository row type) and unknown/misspelled column keys still need a manual edit β crouton validate and the guide point them out.
Versioned migrations
The engine for future schemaVersion bumps also exists (runResourceMigrations in @ghentcdh/crouton-core, auto-applied in dev β see Versioning), but no step is registered: within 0.x the file stays at version 1. crouton migrate runs its codemods regardless of the version, so it works on any 0.x file.