Repository navigation
fix(cli): skip test and fixture files when loading integration codemods - #6230
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
AI review status for this pull request.
|
PR Analysis Report
No new or modified components detected. Bundle Size SummaryNo component packages changed. Accessibility AuditStatus: 36 accessibility violation(s) found — 2 critical, 34 serious. Button pattern - 1 issue(s)
ChatComposer - 1 issue(s)
ChatComposerInput - 1 issue(s)
ChatReasoning - 1 issue(s)
ChatToolCalls - 1 issue(s)
Checkbox pattern - 1 issue(s)
CheckboxList - 1 issue(s)
ClickableCard - 1 issue(s)
CodeEditor - 1 issue(s)
CodeEditorPerf - 1 issue(s)
CodeEditorTheme - 1 issue(s)
CodeTheme - 1 issue(s)
DateRangeInput - 1 issue(s)
FileInput - 1 issue(s)
GridMasonry - 1 issue(s)
Heading - 1 issue(s)
Icon - 1 issue(s)
LogStream - 1 issue(s)
MediaTheme Auto - 1 issue(s)
PowerSearch - 1 issue(s)
ProgressBar - 1 issue(s)
Radio group pattern - 1 issue(s)
RadioList - 1 issue(s)
RichTextEditor - 2 issue(s)
SelectableCard - 1 issue(s)
Stepper - 1 issue(s)
TableGroupedRows - 1 issue(s)
TableTree - 1 issue(s)
Text - 1 issue(s)
Theme - 1 issue(s)
PopArt - 1 issue(s)
Thumbnail - 1 issue(s)
Timestamp - 1 issue(s)
Token - 1 issue(s)
Tokenizer - 1 issue(s)
Visual Regression19 of 422 shot(s) changed. A change here is a question, not a failure: check whether the after is the
Generated by PR Enrichment workflow | View full report |
cf7e843 to
6e9f050
Compare
There was a problem hiding this comment.
This change looks well-implemented, but approval is waiting on a maintainer spec decision.
The implementation adds two ways to disable only autolinked integrations — ASTRYX_NO_AUTOLINK in the environment and {"astryx": {"autolink": false}} in package.json — while leaving configured integrations loaded, and it stops test and fixture files and __tests__/__fixtures__ directories under a codemod version folder being loaded as codemods. Targeted tests for both behaviours pass, with lint and diff checks clean, and no concrete code defect was found.
What a maintainer must settle: please provide or identify the governing spec with current authority (or update and approve the CLI surface record) for those exact semantics — the environment parsing (any non-empty value except 0/false), the package.json false-only opt-out and configured-integration exemption, and the reserved codemod names (*.test.*, *.spec.*, *.fixture.*, __tests__, __fixtures__). The record currently describing the switches is draft, so it cannot settle them on its own. Once that authority is in place, this review's implementation evidence supports proceeding; if the settled semantics differ, the implementation should be conformed to them.
[Automated review]
Autolinking loads an installed integration a project never named, which is
the point — it fixes the apps that have the dependency and no config. But
until now there was no way to stop it. A consumer resolves the CLI from its
own lockfile, so a fix that ships in a version reaches the fleet on each
app's upgrade schedule rather than ours, and an integration behaving badly
had no faster answer than editing every consumer's package.json.
Two switches, for two different emergencies. `ASTRYX_NO_AUTOLINK` in the
environment needs no change to any repo, which is what a fleet-wide stop
requires. `{"astryx": {"autolink": false}}` in package.json is the durable
per-project answer, and lives there rather than in astryx.config for the
reason `astryx.inheritDebug` already does: an unknown config key is a hard
error on an older CLI, while an `astryx` block in package.json is inert to
every version that does not look for it.
Neither switch touches a CONFIGURED integration. Naming one is asking for
it, and a kill switch that silently dropped a declaration would be a second
silent failure in a system that already has too many.
Also: test and fixture files under `codemods/<version>/` are no longer
loaded as codemods. Every js/ts/mjs file under a version folder was loaded
and validated, so a test colocated with its transform failed validation
and — a definition error being a hard error — took every codemod in that
version with it, while `upgrade` applied nothing and reported success.
Core never hit this because its own codemods are enumerated in a registry
rather than found by walking a directory; only integrations carry the
landmine, and only a loader fix reaches the ones already published.
Drop both autolink switches (ASTRYX_NO_AUTOLINK env var and the package.json astryx.autolink key) — FR19 requires evidence of a case where automatic behavior produces the wrong result, and the switch had none. Keep the codemod loader fix: test and fixture files colocated under a version folder are now skipped automatically. Reserved names (*.test.*, *.spec.*, *.fixture.*, __tests__/, __fixtures__/) are documented in the consumer integrations guide (FR14).
6e9f050 to
37026d6
Compare
There was a problem hiding this comment.
This change looks good to approve.
The codemod loader now skips test and fixture files (*.test.*, *.spec.*, *.fixture.*, and anything under __tests__/ or __fixtures__/) instead of loading them as codemods — so a test colocated with a transform can no longer fail validation, take every codemod in its version with it, and leave astryx upgrade applying nothing while reporting success. The reserved names are documented in the integrations guide with an example, the patch changeset matches the non-breaking nature of the fix (those files were never valid codemods), and regression tests cover all five reserved patterns plus a nested-helper case that still loads — the discovery suite passes 13/13 locally.
Worth noting for authors: a real codemod must not use a reserved name or live under __tests__//__fixtures__/ — that constraint is now documented in the guide. The earlier autolink switches are no longer part of this PR, which keeps the change to the single restorative fix.
[Automated review]
Proposes RFC option 1 from meta#4975: identify codemods by shape rather than treating every module under codemods/<version>/ as a codemod. Builds on meta#6230, which already skips test/spec/fixture paths in the walk. On top of that, a module counts as a codemod only when it default-exports an object; a co-located helper (named exports only, or a default-exported function) is skipped instead of being fed to parseCodemod. A module that does default-export an object is still validated at the load boundary, so a genuinely broken codemod (missing field, no type) still fails loudly. Contract change: a module with no codemod default export was previously a hard error; it is now treated as a co-located helper and skipped. This is the crux meta#4975 defers to the team, so this stays a draft for discussion. Refs meta#4975
User impact
An integration that keeps a test next to its codemod ships a broken upgrade. Every
.ts,.mjs, and.jsfile under a codemod version folder was loaded and validated as a codemod, so the colocated test failed validation. A definition error is a hard error, so that one file took every codemod in the version with it, andastryx upgradeapplied nothing while still reporting success.Problem and solution fit
The integration codemod collector walked the whole version folder and treated every script as a transform. Core's own codemods come from a registry rather than a directory walk, so only integration codemods hit this, and only a loader change reaches integrations that are already published.
The collector now skips reserved names:
*.test.*,*.spec.*,*.fixture.*, and anything under__tests__/or__fixtures__/.Expected behavior and authority
spec:AST-017FR14 requires automatic CLI behavior to be documented and discoverable. The reserved names are documented in the integrations guide (astryx docs cli-integrations, Codemods section), with a directory example.This PR started as an autolink kill switch (
ASTRYX_NO_AUTOLINKandastryx.autolinkin package.json). Both switches are removed: FR14 rules out Astryx-owned environment variables, and FR19 admits a new configuration key only with a reproduced detection failure, which we don't have. If that evidence shows up, the switch can come back as its own proposal.Smallest restoration
Skip the reserved test and fixture names in the codemod collector. Nothing else about codemod discovery changes.
Evidence
integration-discovery.test.mjscover all five reserved patterns.Scope
Testing
pnpm exec vitest run packages/cli/foundation/integrations packages/cli/foundation/config/project.test.mjs(136 passed)pnpm -F @astryxdesign/cli exec tsc --project tsconfig.api-dts.jsonpnpm check:knowledgepnpm check:changesetsgit diff --check