fix(cli): run core codemods before loading config in upgrade (with dry-run guidance)#3295
Merged
ejhammond merged 1 commit intoJun 30, 2026
Conversation
…y-run guidance) upgrade loaded astryx.config strictly before running any codemods, so a consumer whose config still had the legacy layout.components key — exactly what the v0.1.3 config codemod migrate-layout-components-to-experimental repairs — got rejected at load and the codemod that would fix it never ran. Reorder the pipeline so core codemods (config + code) run before Project.load. In --apply the config codemod writes the repaired config to disk, then the strict load succeeds. In dry-run, a config that fails validation but is fixable by a pending core config codemod no longer aborts: it reports the fixable error and the exact --codemod ... --apply command to repair it, then finishes the dry-run cleanly (integrations are processed on the --apply run). Strictness is unchanged; a genuine config error or a throwing transform still aborts.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
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.
Problem
astryx upgradecalledProject.load(process.cwd())up front, before running any codemods.Project.loadstrict-validatesastryx.config.*(unknown keys rejected) and throws on failure. This created a chicken-and-egg:A consumer whose config still has the legacy
layout.componentskey — exactly what the v0.1.3 codemodmigrate-layout-components-to-experimentalexists to fix — gets their config rejected at load, so the upgrade aborts and the codemod that would repair it never runs.Fix
Reorder the upgrade pipeline so core codemods run before the config is loaded:
getTransformsBetween→runCodemods). Config codemods readastryx.config.*directly viarunConfigCodemod; code codemods scan--path. Neither needs the loaded config. In--applythe config codemod writes the repaired config; in dry-run it only previews.Project.load(strict validation unchanged), now wrapped in a graceful dry-run catch:astryx upgrade --from <from> --codemod <name> --applycommand to repair it, and finish the dry-run cleanly (exit 0). Integrations are skipped for the preview and noted as deferred to the--applyrun.Config strictness is not loosened. The codemod-execution-error gate still aborts on a throwing transform.
Tests
New
upgrade.config-ordering.test.mjs(repo-local temp project + chdir):layout.components→ reports the fixable status + suggested--codemod ... --applycommand; exit 0; config not written; integrations skipped.--applywith the same config → core config codemod rewrites it toexperimental.xle.components, strict load then succeeds, upgrade completes.integrations: 5) and no fixing codemod → still aborts (exit nonzero).All existing upgrade/runner/integration tests stay green.
Before / after (manual smoke)
Config
export default { layout: { components: { KpiCard: '@/components/KpiCard' } } }:astryx upgrade --from 0.1.2(dry-run): previews the fix, prints the fixable-config guidance + suggested command, exit 0 (no crash on the legacy key).astryx upgrade --from 0.1.2 --apply: rewrites the config toexperimental.xle.components, completes.