Repository navigation
fix(cli): a theme family checks its compiled registries as plain Node loads them - #13358
josephfarina wants to merge 4 commits into
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
AI review status for this pull request.
|
PR Analysis Report🔎 Preview ·
|
There was a problem hiding this comment.
Changes requested: the family build now accepts local TypeScript and JSX registries as a single build does, and the new tests prove it, but --check lost a check it had on main.
--checkno longer imports compiled registries (packages/cli/api/theme/build/build.mjs:2718), so after an installed dependency of a local.tsregistry drops the export the registry imports,--checkreports the family up to date (exit 0) whiletheme build --familyrefuses and the committed module throws on import; under--check, import each compiled registry from the committed<family-key>.modules/copy when it matches this build's bytes, and add a test for that case.
Main's --check exits 1 on the same family, naming the registry. Everything else in the change checks out.
Claims and files checked
Review mode: full; reason: no-earlier-review
- Claim: a family builds a member's local TypeScript or JSX registry and compiles it into the family's modules folder. Verified: the new CLI-process tests pass here and fail on main.
- Claim: the build imports each compiled copy before writing outputs, and
--checkonly reads it. Verified (build.mjs:2712-2741,:7201-7202). - Claim: main stopped on
.tsxand.jsxregistries, on.tsbefore Node 22.18, and on extensionless local imports. Verified for.tsx,.jsxand extensionless imports by running the new tests on main; the Node 22.18 boundary was not run. - Claim: a registry whose imports plain Node cannot load still stops the build, names the file, and writes nothing. Verified (
build.self-contained.test.mjs:221-300). - Claim: the check folder sits beside the modules folder at the same depth and is always removed. Verified (
build.mjs:2720-2740). - Claim: the check runs after the output checks, so a build refused outside the working directory writes nothing. Verified (
build.mjs:7188-7202, test at:340-366). - Claim:
--checkwrites nothing, and the comparison reports a stale or missing module. Verified; it also no longer imports compiled registries (the finding above). - Claim: uncompiled registries are checked from source as before, and the static walk is unchanged. Verified (
build.mjs:2683-2688,:2717-2719). - Claim: the doc sentence is true, and the two search counts each rise by one with nothing else moving. Verified; the golden tests pass.
- Claim: the three registry tests fail on main and the package tests pass on main. Verified by running them on main; the remarks about alternative implementations were not checked.
- Claim: test totals and strict typecheck. Verified: the totals match, and the typecheck is clean with the theme package built.
- File
.changeset/family-build-compiled-registry-check.md: clear. - File
packages/cli/api/theme/build/build.mjs: finding at line 2718. - File
packages/cli/api/theme/build/build.self-contained.test.mjs: clear. - File
packages/cli/assets/docs/author-a-theme.doc.mjs: clear. - Files
packages/cli/test/__golden__/no-icon-set/search-icon-set.json,search-icon-set.txt,search-icon.json,search-icon.txt: clear.
There was a problem hiding this comment.
Changes requested: the family build now accepts local TypeScript and JSX registries, and --check again catches a dependency that drops an export, but --check now fails on exactly the families the build newly accepts.
--checkimports each registry's source (packages/cli/api/theme/build/build.mjs:2717), so right after a successful family build with a local.tsx,.jsxor extensionless-import registry,theme build --family … --checkexits 1 withCannot import family registryinstead of comparing the outputs asspec:AST-034FR8 requires; under--check, import the committed<family-key>.modules/copy when it matches this build's bytes (a read, no write), leave a stale or missing copy to the comparison, and add a CLI-process test that runs--checkafter a.tsxfamily build.
The earlier finding about a dropped dependency export is fixed. A single theme build --check of the same member reports it up to date, so family mode is the one place this check breaks.
Claims and files checked
Review mode: incremental; reason: none
- changed rules (0): none
- Claim: the family build imported registry sources, while a single build compiles them into its modules folder. Verified.
- Claim: main stopped on
.tsxand.jsxregistries, on extensionless local imports, and on.tsbefore Node 22.18. Verified on main for the first three; the Node 22.18 boundary was not run. - Claim: the build writes its compiled modules to a temporary folder beside the modules folder at the same depth, imports each compiled registry from there, writes outputs only when all pass, and always removes the folder. Verified (
build.mjs:2719-2739). - Claim: the check runs after the output checks, so a build refused outside the working directory writes nothing. Verified (
build.mjs:7187-7201, test atbuild.self-contained.test.mjs:459-485). - Claim:
--checkwrites nothing and checks registries from their source, as on main. Verified (build.mjs:2717); it then fails on the newly supported families (the finding above). - Claim: registries that are not compiled are checked from source, and the static walk is unchanged. Verified (
build.mjs:2683-2688,:2715-2716). - Claim: local
.tsx,.jsxand extensionless-import registries build, and a registry whose imports plain Node cannot load still stops the build, naming the file. Verified for the build (tests at:290-338,:340-419). - Claim: the docs sentence on the family's modules folder is true. Verified for the build.
- Claim: the
iconandicon setsearch counts each rise by one and nothing else moves. Verified; the golden tests pass. - Claim: the new registry tests fail on main and the package tests pass on main. Verified with the same cases on main; the remarks about alternative implementations were not checked.
- Claim: the listed test run passes and the strict typecheck shows only errors from an unbuilt theme package. Verified: 812 pass and 2 skip, the one failure needs a git checkout, and the typecheck is clean with the themes built.
- Claim (release note): a family builds a member's local TypeScript or JSX registry as a single build does, and
--checkchecks registries as before. Verified for the build;--checkis the finding above. - File
.changeset/family-build-compiled-registry-check.md: clear. - File
packages/cli/api/theme/build/build.mjs: finding at line 2717. - File
packages/cli/api/theme/build/build.self-contained.test.mjs: clear; no test runs--checkon a TypeScript or JSX registry family (part of the finding). - File
packages/cli/assets/docs/author-a-theme.doc.mjs: clear. - Files
packages/cli/test/__golden__/no-icon-set/search-icon-set.json,search-icon-set.txt,search-icon.json,search-icon.txt: clear.
There was a problem hiding this comment.
Changes requested: the family build now accepts local TypeScript and JSX registries as a single build does, and the new CLI tests prove it, but --check still fails on exactly the families the build newly accepts.
--checkimports each registry's source (packages/cli/api/theme/build/build.mjs:2717), so right after a successfultheme build --familywith a local.tsx,.jsxor extensionless-import registry it exits 1 withCannot import family registry …instead of comparing the outputs, whichspec:AST-034FR8 and FR2 require.
Next: under --check, import a compiled registry from the committed <family-key>.modules/ copy when its bytes match this build's (a read, no write), leave a stale or missing copy to the comparison, and add a CLI-process --check test after a .tsx family build. The dependency-drop case from the earlier review stays fixed.
Claims and files checked
Review mode: incremental; reason: none
- changed rules (0): none
- Claim: The family check imported each registry's source, while a single build compiles local registries into a modules folder: verified (main's registry check imports the source file; a single
--checkhere checksocean-calm.modules/icons.tsx.js). - Claim: Main's family build stopped on a
.tsxor.jsxregistry, a.tsone before Node 22.18, or an extensionless local import: verified for.tsx,.jsxand the extensionless import (the three new CLI tests fail on main withCannot import family registry); the Node 22.18 boundary was not run. - Claim: Before writing, the compiled modules go to a sibling folder at the same depth, each compiled registry is imported from there, outputs are written only when all pass, and the folder is always removed: verified (
build.mjs:2711-2740; test:377-419finds no folder left). - Claim: The check runs after the output checks, so a build refused outside cwd writes nothing: verified (
build.mjs:7186-7201; test:459-485). - Claim:
--checkwrites nothing and checks registries from their source, as on main: verified (build.mjs:2717,:7137; test:443-457); its consequence is the blocking finding. - Claim: A registry that is not compiled (a package, or
--icons-specifier) is checked from its source, and the static walk is unchanged: verified (build.mjs:2715-2718,:2683-2691,:6749-6755). - Claim: The check gives plain Node's verdict: local
.tsx/.jsxand extensionless imports pass, and imports Node cannot load still stop the build, naming the file: verified for the build (tests:290-419); false for--check(the finding). - Claim: "Author a theme" gains a sentence on the family's modules folder: verified (
author-a-theme.doc.mjs:158), accurate for the build. - Claim: The
iconandicon setgoldens each count one more match and nothing else moves: verified (the diff, and the golden tests pass). - Claim: The three registry tests fail on main and the two package tests pass on main: verified by running this head's test file on main's code (3 fail, the rest pass).
- Claim: The second package test fails on a loader-by-path approach, and the
--checkand outside-cwd tests fail on a version that writes the check folder first: not checked; they describe other implementations, not this code. - Claim: The release note's account of the build, the compiled-copy check and main's failures: verified for the build;
--checkdiffers (the finding). - Claim: The named suites give 813 passing and 2 skipped: 812 pass and 2 skip here; the one other test fails only because it lists files with git in a tree that has no git history.
- Claim: The strict CLI typecheck shows only the two errors main shows when the neutral theme is unbuilt: consistent; it passes with 0 errors once the themes are built.
- File:
.changeset/family-build-compiled-registry-check.md: clear. - File:
packages/cli/api/theme/build/build.mjs: blocking finding at:2717. - File:
packages/cli/api/theme/build/build.self-contained.test.mjs: clear; no test runs--checkon a TypeScript or JSX registry family (part of the finding). - File:
packages/cli/assets/docs/author-a-theme.doc.mjs: clear. - File:
packages/cli/test/__golden__/no-icon-set/search-icon.json,search-icon.txt,search-icon-set.json,search-icon-set.txt: clear.
| // from its source, as before. | ||
| const written = new Set(writes.map(write => write.dest)); | ||
| registries = registries.map(({compiledCopy, ...registry}) => (compiledCopy && written.has(compiledCopy) ? {...registry, compiledCopy} : registry)); | ||
| if (check) return validateRegistryGraphs(registries.map(({specifier, exportName}) => ({specifier, exportName})), aggregatePath); |
There was a problem hiding this comment.
Under --check each registry reaches validateRegistryGraphs without its compiled copy, so its source is imported with Node. Right after a successful family build with a local icons.tsx (or .jsx, or a .ts that imports ./size), --check exits 1 with Cannot import family registry …: Unknown file extension ".tsx" and never compares the outputs, while a single build's --check reports the same member up to date (spec:AST-034 FR8). Import the committed <family-key>.modules/ copy when it matches this build's bytes (a read, no write), and leave a stale or missing copy to the comparison.
… loads them theme build --family checked each member's registry by importing its source with Node, so a family stopped on a local .tsx or .jsx registry, on a .ts one before Node 22.18, or on a local import without its extension, while a single build of the same member compiles it. A family build now writes the modules it compiles to a folder beside the modules folder, at the same depth, imports each compiled registry from there with Node, as the family module will, and only then writes its outputs; the folder is always removed. The check runs after the output checks, so a build refused for writing outside cwd writes nothing, and --check writes nothing: it reads a compiled registry, and the comparison of the committed modules reports any stale or missing one. A registry whose imports plain Node cannot load still stops the build, naming the file. Tests build families through the CLI in its own process: .ts, .tsx and .jsx registries that import a helper without its extension build, and the family module loads in plain Node (all three fail on main); a .tsx entry of a linked workspace package stops the build, naming the package file and writing nothing, whether the member imports the package or a local registry re-exports it; --check on a read-only folder and a build refused outside cwd make no write. Author a theme's family section says a member's TypeScript or JSX registry or slot module is compiled as for a single build; the icon and icon set search counts each rise by one.
Astracat's first review found that --check, by only reading a compiled registry, no longer caught a registry whose installed dependency drops an export. --check now checks each registry from its source, exactly as on main, and writes nothing; checking the committed compiled copies under --check follows as its own change. [skip ci]
…s on main The family section's sentence named an icon registry, which added one match to the icon and icon set searches; main has since moved those snapshots, so the counts no longer lined up. It now says a member's registry or slot module, and no search golden changes.
93a4f13 to
d901f60
Compare
There was a problem hiding this comment.
Changes requested: family builds now accept local TypeScript and JSX registries the way a single build does, and the new CLI tests prove it, but --check still fails on exactly those families.
--checkstill imports each registry's source (packages/cli/api/theme/build/build.mjs:2717), so right after a successfultheme build --familywith a local.tsx,.jsxor extensionless-import registry it exits 1 withCannot import family registry …instead of comparing the outputs, whichspec:AST-034FR8 and FR2 require.
Next: bring the --check change described in #13388 (which targets this branch) into this pull request, with a CLI-process test that runs --check after a .tsx family build. Everything else checked out, including byte-identical output for the published themes.
Claims and files checked
Review mode: full; reason: rebase
- Claim: main's family check imported each registry's source, while a single build compiles local registries into a modules folder: verified (main's check imports the source file; a single build here writes and checks
ocean-calm.modules/icons.tsx.js). - Claim: main's family build stopped on a
.tsxor.jsxregistry, a.tsone before Node 22.18, or an extensionless local import, while a single build worked: verified for.tsx,.jsxand the extensionless import (the three new CLI tests fail on main's code); the Node 22.18 boundary was not run. - Claim: before writing, the compiled modules go to a sibling folder at the same depth, each compiled registry is imported from there, outputs are written only when all pass, and the folder is always removed: verified (
build.mjs:2719-2739,:7201before:7271; test:377-419finds no folder left). - Claim: the check runs after the output checks, so a build refused outside the working directory writes nothing: verified (
build.mjs:7187-7201; test:459-485). - Claim:
--checkwrites nothing and checks registries from their source, as on main: verified (build.mjs:2717,:7137; test:443-457); its consequence is the blocking finding. - Claim: a registry that is not compiled (a package, or
--icons-specifier) is checked from its source, and the static walk is unchanged: verified (build.mjs:2683-2688,:6750,:7081). - Claim: the compiled check gives plain Node's verdict, so local
.tsx/.jsxand extensionless imports pass and a registry Node cannot load still stops the build, naming the file: verified for the build (tests:290-419); false for--check(the finding). - Claim: the family spec asks for one complete resolved export per member that parses and imports: verified (the FR6 text).
- Claim: "Author a theme" gains a sentence on the family's modules folder: verified (
author-a-theme.doc.mjs:158). - Claim: the new tests run the CLI in its own process: verified (test
:100-107). - Claim: the three registry tests fail on main: verified (3 fail on main's code with this test file).
- Claim: the two package tests pass on main, and the second fails on a loader-by-path approach: passing on main verified; the other approach was not checked, since it describes different code.
- Claim: the read-only
--checktest and the outside-working-directory test pass, and fail on a version that writes the check folder first: passing verified (also on main); the other version was not checked. - Claim: no search golden changes: verified (no golden in the patch; the golden tests pass).
- Claim: the named suites give 813 passing and 2 skipped: 812 pass and 2 skip here; the one other test fails only because it lists files with git in a tree with no git history.
- Claim: the strict CLI typecheck shows only the two errors main shows when the neutral theme is unbuilt: consistent; it passes with 0 errors once the themes are built.
- Claim: the release note's account of the build, the compiled-copy check, main's failures and the unchanged
--check: verified; the unchanged--checkis the finding. - File:
.changeset/family-build-compiled-registry-check.md: clear. - File:
packages/cli/api/theme/build/build.mjs: blocking finding at:2717. - File:
packages/cli/api/theme/build/build.self-contained.test.mjs: clear; no test runs--checkon a TypeScript or JSX registry family (part of the finding). - File:
packages/cli/assets/docs/author-a-theme.doc.mjs: clear.
- #13358 fix(cli): a theme family checks its compiled registries as plain Node loads them Author: @josephfarina - #13388 fix(cli): --check reads a theme family's committed compiled registries Author: @josephfarina - #13464 experimental theme: a resting background color, outline or shadow keeps a part's hover and keyboard focus visible Author: @josephfarina - #13433 cli(icons): icon response types say "icon meaning" and "variant" Author: @josephfarina - #13456 feat(templates): dashboard-scorecard shows two headline numbers per row on a phone when they fit Author: @josephfarina - #13473 docs(icons): icon-set guide's relatives line; template icons say icon component Author: @josephfarina
|
Landed in #13542. |
fix(cli): a theme family checks its compiled registries as plain Node loads them
What changes
theme build --familychecked each member's icon registry by importing its source file with Node's ownimport(). A singletheme buildnever does that: it compiles a local registry into<name>.modules/, and the built module imports the compiled copy. So a family stopped withCannot import family registry …and wrote nothing when a member's local registry was.tsxor.jsx, was.tson Node before 22.18 (the CLI supports 22.13+), or imported a local file without its extension — while a single build of the same member worked.The family build now checks what plain Node will actually load. Before it writes anything, it writes the modules it compiles to a folder beside
<family-key>.modules/, at the same depth (so every relative import in them resolves exactly as it will from the modules folder), and imports each compiled registry from there with Node's ownimport(), as<key>.jswill import it. Only when every registry passes does it write its outputs. The folder is removed whether the check passes or fails, so a failed check leaves the output untouched. The check runs after the output checks (confineOutputs,assertOutputsReplaceable), so a build refused for writing outside cwd writes nothing at all, asarchitecture:cli-surfaceINV10/DEC-3 require.--checkwrites nothing (spec:AST-034FR8) and checks registries from their source, exactly as on main. A registry that is not compiled (from a package, or named by--icons-specifier) is checked from its source, as before; the static walk of the source graph (CSS imports, missing named exports) is unchanged.Because the check runs on the compiled copy, it gives plain Node's verdict for every case at once, with no rule keyed on paths or specifiers: a local
.tsx/.jsxregistry and an extensionless import pass, and a registry whose imports Node cannot load — such as a workspace package whose entry is.tsx, imported directly or through a local registry — still stops the build, naming that file. This is whatspec:AST-034FR6 asks of<key>.js: one complete resolved export for every selected member, which parses and imports."Author a theme"'s family section gains the sentence this makes true: a member's TypeScript or JSX registry or slot module is compiled into
<family-key>.modules/, as for a single build.Testing
Size: one fix that can't be split: the code change is about 75 lines in
build.mjs; the rest is the plain-Node CLI tests that prove each case (and each fails on main or on the earlier approaches).New tests in
build.self-contained.test.mjsrun the CLI in its own process (plain Node, outside Vitest's loader, which would load.tsxitself):.ts,.tsxand.jsxregistries, each importing a helper without its extension: the family builds and its module imports in plain Node. All three fail on main.a
.tsxentry of a workspace package linked intonode_modules, imported by the member directly, and through a local.tsregistry that re-exports it: the build stops withCannot import family registry, names the package file, writes neither<key>.jsnor the modules folder, and leaves no check folder behind. Both pass on main (main stops too); the second fails on a loader-by-path approach.--checkon a family with a compiled.tsregistry, with its folder read-only, passes and leaves the folder as it was; a build refused outside cwd (also on a read-only folder) fails withERR_PATH_TRAVERSAL. Both fail on a version that writes the check folder first (EACCESfrommkdtemp).The family sentence says "registry" (not "icon registry"), so no search golden changes.
vitest run packages/cli/api/theme/build packages/cli/foundation/doc-compiler/doc-loads.test.mjs packages/cli/test/experimental-isolation.test.mjs: 813 pass, 2 skipped.pnpm -F @astryxdesign/cli typecheck:strict: only the two@astryxdesign/theme-neutral/builterrors main shows on a box without that package built.Stack: #13358 → #13388
preflight: pass d901f60