Repository navigation
fix(cli): skip non-codemod files during integration codemod discovery - #4980
abu-abdullah22 wants to merge 1 commit into
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
PR Analysis Report
Generated by PR Enrichment workflow | View current CI run |
There was a problem hiding this comment.
Approval is waiting on a maintainer decision for the codemod classification in this change.
This patch would treat conventional test paths (__tests__/, *.test.*, *.spec.*) and every module with no default export as non-codemods, while a present but invalid default export still fails. That direction needs a maintainer to provide or identify the governing spec for it — in particular whether a codemod that forgets its default export should be silently ignored, and whether non-codemods are excluded from all codemod identity bookkeeping. I have asked for that decision; please do not treat the current behaviour as approved until it is settled.
Independent fixes are also needed regardless of that decision:
- Modules with no default export are currently entered into duplicate-ID bookkeeping before they are skipped, so the same helper stem in two versions (or shared with a real codemod) can still throw and drop the whole integration. Move that registration after the skip and add a cross-version regression test, or narrow the claimed scope.
- The file header still describes the old loader and says a missing default export is a hard error, and the changeset claims all shared helpers are excluded even though a helper that fails to import is not. Align both with the behaviour that is actually adopted and implemented.
- The new tests cover the common single-version test-file and helper cases, and malformed present defaults correctly still throw.
[Automated review]
|
(Posted by Cindy's agent.) Hi @abu-abdullah22, thanks for this PR. |
Fixes #4975
Summary
astryx upgrade's integration-codemod discovery threw a hard error — silentlydropping an entire integration's codemods for that run — whenever a
codemods/<version>/directory contained conventional test files or sharedhelper modules alongside real codemods. Confirmed two distinct failure modes:
__tests__/*.test.mjsfiles importvitest, which fails at module-loadtime since
vitestisn't a dependency of consumer apps.*.transform.mjs, named exports only) loadfine but have no default export, so
parseCodemodreceivesundefinedand Zod rejects it.
The core codemods still ran, so
astryx upgradereported success whilesilently skipping the integration's real migrations.
Approach
Chose the most conservative of the options discussed in the issue — does NOT
introduce any new file-naming convention or manifest format:
(
__tests__/,*.test.*,*.spec.*) during file collection.per this file's own doc comment, every codemod module must default-export
an envelope, so a module with zero default export was never attempting to
be one.
throws exactly as before — the "fail loudly on genuinely broken codemod"
contract is fully preserved.
Changes
packages/cli/assets/codemods/integration-discovery.mjs: updatedcollectCodemodFiles()to skip conventional test paths, and updated theloading loop to skip modules with no default export before calling
parseCodemod.packages/cli/assets/codemods/integration-discovery.test.mjs: added twotests covering both skip cases, and confirmed the existing
"malformed codemod still throws" test continues to pass.
Testing
Ran the full test file directly via
vitest— all 8 tests pass, includingthe two new ones and the pre-existing "fails discovery when default export
is not a codemod envelope" test (confirming genuinely broken codemods still
fail loudly).