Repository navigation
feat(cli): discover lists the official Astryx packages first, from a list built into each release - #7495
Conversation
…list built into each release Each CLI release carries a generated list of the official packages: every package the release workflow publishes that adds at least one item discover lists, read with the CLI's own integration and theme readers. A drift test fails when the committed list no longer matches the repository. Discover reads the list after every other source, so a project's or an integration's source keeps its entry for an official package; the list adds the rest. Official packages come first in what discover shows, read like any other package, and name their source Astryx. Entries take the CLI's own version; a canary CLI also lists the canary-only packages, as prereleases. A declared official theme package counts as installed. On a package page, an official entry's add command pins the project's Core version when the package releases with Core, otherwise the CLI's version, and a theme's add text ends with `theme add <slug>`. A project that loads no integration and has no source of its own still gets the list for every query.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
AI review status for this pull request.
|
PR Analysis Report📚 Storybook Preview🧪 Sandbox PreviewNo new or modified components detected. Bundle Size SummaryNo component packages changed. Accessibility AuditStatus: No accessibility violations detected. Visual Regression40 of 486 shot(s) changed. A change here is a question, not a failure: check whether the after is the
and 20 more. Generated by PR Enrichment workflow | Storybook | Sandbox | View full report |
…eep released answers An official entry now shows, lists and pins one version, so the package page, a lookup by version and the add command agree: the project's Core version, installed or declared exactly, for a package released with Core and for a canary-only package; with no Core, a release CLI's own version, or a canary CLI's own version for a canary-only package. Otherwise it lists none and the add command pins nothing, because a canary CLI may have been published without some packages and a declared range names no single version. Canary-only packages are no longer listed beside a released Core, which they cannot be installed with. A source keeps its entry for any official package whose integration it publishes under another name, so a fork or mirror stays in the list and in search; the official list is merged in source order and put first only where discover shows it. Declared official packages are read from the project's own package.json, the nearest one above the current folder, including npm aliases; a peer dependency alone no longer counts as installed. For a package only the official list supplies, a version or item it does not show answers ERR_UNKNOWN_PACKAGE, as before. Each package the project could add carries its add command, and in a project that loads no integration and has no source of its own the list points at those commands instead of at queries that only return the list. A published theme package whose folder does not match its theme file now fails the generator, and the drift test checks that every listed stable package releases with Core.
…ns the project's Core, range included An official entry's latest release is again the newest release the CLI knows: its own version on a release CLI, or the project's Core version when that is a newer release, so an update check is not told the project's older Core is the latest. An entry for a package released with Core lists that latest release and the project's Core version, so a lookup of either works, and its add command pins the project's Core version. In a fresh clone that declares Core as a semver range and has not installed it, the add command pins that range, quoted for the shell, so the package manager resolves the release that matches the project's Core. A declaration that names no version, such as a path, a workspace protocol or a dist-tag, pins nothing. When the page shows the latest release and the command installs another version, the text says which version it installs and why.
Conflict: packages/cli/authoring/discover/discover.doc.mjs, the DiscoverSource description. Keeps #7495's sentence on the official list the CLI carries (another source's entry for an official package is kept) and main's newer wording for a failing source (the last good answer that source gave for the same request, or reported as failed when it saved none). Also regenerated packages/cli/assets/discover/official-packages.json (pnpm bundle:cli-official-packages): main's lab added and renamed components and templates since #7495's base, and the check test compares the file with what the generator builds.
#7494 renumbers the official-list requirement to AST-051 FR11 (FR10 is now "A package can link its docs site"); the six comments that cite it follow. Comments only; no behavior change.
There was a problem hiding this comment.
Changes requested: the official package list, its drift check and the discover wiring follow spec:AST-051 FR11, but one FR11 rule is not met and the change needs splitting or a reason it cannot be split.
- When a project declares
@astryxdesign/coreasworkspace:*, afile:path or a dist-tag and has not installed it, an official entry's add command is unpinned, while FR11 says it pins the latest release;pin = core?.version ?? core?.range ?? entryLatest ?? undefined;inpackages/cli/api/discover/_adapter.mjs, with the three matching rows in_adapter.test.mjsupdated, fixes it. - At 2,548 authored lines, please split the change (for example the generator, committed list and drift test first, then the discover wiring) or explain why it has to land as one.
[Automated review]
| pin = | ||
| core == null | ||
| ? canaryCli | ||
| ? undefined | ||
| : cli | ||
| : (core.version ?? core.range); |
There was a problem hiding this comment.
spec:AST-051 FR11 pins “the project's Core version, else the Core range the project declares, else the latest release”. When Core is declared as workspace:*, a file: path or a dist-tag and is not installed, projectCore returns {} and this pins nothing, so a release CLI prints an unpinned install beside version: <CLI version>. Falling back to the entry's latest release keeps every other case:
pin = core?.version ?? core?.range ?? entryLatest ?? undefined;The rows for workspace:*, file:../core and latest in _adapter.test.mjs would then expect '0.7.1'.
| * @file Writes the official package list that `astryx discover` reads before | ||
| * every other source (spec:AST-051 FR11) to |
There was a problem hiding this comment.
Discover reads this list after every other source (spec:AST-051 FR11 and DEC-5), not before. Lines 15-16 also still say every entry takes the CLI's own version, while entries now list the project's Core version too.
…no plain range - The official list's pin for a package released with Core is the project's Core version, else the Core range it declares, else the latest release (spec:AST-051 FR11). A Core declared as `workspace:*`, a `file:` path or a dist-tag, and not installed, gave no range and no pin; it now pins the latest release. The `workspace:*`, `file:../core` and `latest` rows expect it. - generate-cli-official-packages.mjs: discover reads the list after every other source (FR11 and DEC-5), and each entry lists the CLI's own version and the project's Core version, with the pin rule above.
There was a problem hiding this comment.
Changes requested: the official package list, its drift check and the discover wiring now follow spec:AST-051 FR11, including the pin for a Core declared as workspace:*, a file: path or a dist-tag, so what remains is the size of the change. At 2,554 authored lines it is over the 2,000-line bar, and the “Why one pull request” note does not show the parts are inseparable: the generator, committed list and drift test (494 lines) can land first with no behaviour change. Please split them out and, because the discover wiring alone is still 2,060 lines, move one layer (for example counting declared official packages as installed, or the text changes) to a follow-up, or show concretely why the wiring cannot be split.
[Automated review]
There was a problem hiding this comment.
Changes requested: the official package list, its drift check and the discover wiring follow spec:AST-051 FR11, and the change's size is accepted as one piece of work, so one FR11 pin rule is all that remains. When a project declares @astryxdesign/core as a range with a space after an operator, such as ~ 0.6.8 or >= 0.6.8 < 0.7.0, and has not installed it yet, isSemverRange in packages/cli/api/discover/_adapter.mjs rejects the range and the add command pins the latest release (@0.7.2), which falls outside that range. Dropping whitespace after an operator before the check (for example spec.trim().replace(/([<>]=?|=|\^|~)\s+/gu, '$1')), pinning that normalized range, and adding those two rows to the fresh-clone pin test in _adapter.test.mjs fixes it.
[Automated review]
| if (typeof spec !== 'string') continue; | ||
| const exact = spec.trim().replace(/^=\s*/u, ''); | ||
| if (isValidSemver(exact)) return {version: exact}; | ||
| return isSemverRange(spec) ? {range: spec.trim()} : {}; |
There was a problem hiding this comment.
~ 0.6.8 and >= 0.6.8 < 0.7.0 are valid ranges (node-semver reads both as >=0.6.8 <0.7.0), but the whitespace split in isSemverRange (line 359) leaves a bare ~ or >= that fails RANGE_PART, so this returns {} and the add command pins the latest release (@0.7.2), outside the declared range. spec:AST-051 FR11 pins “the Core range the project declares”. Normalizing first keeps every other case:
const range = spec.trim().replace(/([<>]=?|=|\^|~)\s+/gu, '$1');
return isSemverRange(range) ? {range} : {};Rows for ~ 0.6.8 and >= 0.6.8 < 0.7.0 in the fresh-clone pin test (_adapter.test.mjs:469) would cover it.
…operator node-semver accepts a space between an operator and its version (`~ 0.6.8`, `>= 0.6.8 < 0.7.0`), but the range check split on whitespace, so such a declaration counted as no range and add pinned the latest release, outside it. Each operator is now joined to its version first, and the joined range is pinned. Two rows in the fresh-clone pin test.
There was a problem hiding this comment.
No further changes requested: the official package list, its drift check and the discover wiring follow spec:AST-051 FR11, and a Core range declared with a space after an operator (~ 0.6.8, >= 0.6.8 < 0.7.0) is now pinned as that range in every official add command. One optional tidy-up for the description, not the code: it counts 7 themes and 4 canary-only packages where the list has 8 packages released with Core and 3 canary-only, and it cites FR10 where the list is FR11.
[Automated review]
User need
A person or agent in a new app, or in an empty folder, asks
astryx discoverwhat they could add. Today the answer is "No discover source is configured", even though the CLI already ships the seven official themes fortheme list. An app that installed an official theme never sees it as installed. The add text for a theme says the package loads on the next command, which is wrong: a theme still needstheme add. And the add command pins no version, so it can install a theme newer than the app's Core.Problem and solution fit
packages/cli/assets/discover/official-packages.json. It keeps each package the release workflow publishes (the workflow's own@astryxdesign/,privateandcanaryOnlyrule) that adds at least one item discover lists, read with the CLI's own integration loader, contribution inventory and theme descriptor reader.pnpm buildregenerates it, and a drift test fails when the committed file is stale.Astryx,meta.sourcesreports the list last, and a list that cannot be read is reported like a failed source.meta.configuredstays whenever no integration is listed.astryx theme add <slug>.Current specification
spec:AST-051as amended by the paired spec pull request "discover lists the official packages first, from a list built into each release (AST-051)": FR1, FR2, FR6, FR11 and DEC-5. This lands after it.Public delta and caller burden
Before, published 0.7.0 in an empty folder:
After:
JSON:
discover.listalways carriesmeta.availableandmeta.sources;dataincludes declared official packages;installfor an official package is pinned. No new command, option or setting.Compatibility (
spec:AST-017, against published 0.7.0)Patch tier. Every 0.7.0 result keeps its type, exit code and values; the change adds entries, fields and matches. Checked side by side with published 0.7.0:
discover,discover gothic,discover @astryxdesign/theme-gothicand a blank query all returndiscover.list, exit 0,data: [],meta.configured: false, as before;meta.availableandmeta.sourcesare added.discover @astryxdesign/[email protected]anddiscover @astryxdesign/theme-gothicgive the same detail as 0.7.0 (source, versions,install), and a declared official package that source lists still shows as it did. The list adds the other official packages and puts official packages first;meta.sourcesgains the official list as its last entry, so existing indexes keep their meaning.Next minor: answer queries in a project with no integration and no source of its own (package pages, search, and errors such as
ERR_NOT_FOUNDthere), which changes released results and needs its own[breaking]changeset.Known limit until then: an app with no integration and no source of its own, which is most plain apps, sees the official packages in the list, but the package page with the pinned add command and the
theme addtext appears only in projects that load an integration or have their own source.Design and alternatives
The list is built into the release because official packages change only when Astryx releases, so it is exactly as current as the CLI that carries it, works offline and in an empty folder, and needs nothing beyond the CLI's own tarball. Searching the package registry at run time was rejected (network on every run, unrelated scope matches, and no way to know what a package adds without running it), as was a hosted catalog. The list is read after the other sources so a project's or an integration's source keeps the entry it gives an official package; reading it first would replace those entries.
Evidence
pnpm vitest run --project node packages/cli scripts/check-cli-official-packages.test.mjs scripts/check-cli-theme-bundle.test.mjs: 394 test files, 6,317 tests pass (2 more are marked expected failures).pnpm check:repo, run script by script: every check passes,check:changesetsincluded.typecheck:json-api,typecheck:authoringandcli-api-types-verify: pass.typecheck:strict: the same two errors as bare main (@astryxdesign/theme-neutral/builtin two page templates, which needspnpm build).npm pack --dry-runincludesassets/discover/official-packages.json.Scope
#7147 (source package names and typo tolerance in discover results) edits the same discover code; whichever lands second needs a rebase. It does not change source order or where official packages come from.
Why one pull request
The official list is one behavior with three parts that only work together: the generator that writes the list at release time, the file it writes, and discover reading that file after every other source and pinning from it (
spec:AST-051FR11, DEC-5). Landing the generator or the file without the reader ships a list nothing reads; landing the reader without the file makes discover fail its check. The tests cover them as one: the check test compares the committed file with the generator's output, and the discover tests read that file. Splitting would leave main with half the feature between merges, and the project keeps one change in one pull request.Testing
Second commit: version consistency and released answers
Testing against published 0.7.0 found that the official entries could contradict their own add command and change answers that 0.7.0 gave. This commit fixes each case and keeps the change patch-tier.
discover <package>@<that version>and the add command now agree.src/. npm aliases are recognized, and a peer dependency alone no longer counts as installed. Packages that a project's or an integration's source lists keep 0.7.0's reading.ERR_UNKNOWN_PACKAGE, as 0.7.0 did; the message says which version discover shows.meta.availablecarries itsinstallcommand (an additive field), and the text points at those commands instead of at queries that would only return the list again.--checkand the build, and the drift test checks that every listed stable package releases with Core./<item>, not/<ComponentName>; the prerelease count no longer counts the version it shows; a page with no version skips the Versions section; "N published" reads "N known".Compatibility (
spec:AST-017, against published 0.7.0)Patch tier,
[feat]changeset. 12 projects × 33 query forms in--json(396 runs) against published 0.7.0: 267 supersets, 41 errors that now answer, 86 identical error codes, and 0 changed exit codes or error codes. The other 2 runs are--limit 2cuts where new official matches rank above an older match. Before this commit, 14 runs changed error codes.Evidence for this commit
check:reposcript by script,typecheck:json-api,typecheck:authoring,cli-api-types-verify,check:cli-structure, ESLint on changed files, copyright, exports sync, README check and the official list--checkall pass.typecheck:strictshows the same 2 errors as bare main (@astryxdesign/theme-neutral/built, which needspnpm build).Third commit:
latestkeeps its meaning, and a declared Core range is pinnedlatestis the newest release the CLI knows: its own version on a release CLI, or the project's Core version when that is a newer release. A project on an older Core is no longer told its Core is the latest.discover <package>@<either>works. Its add command still pins the project's Core version. When the page shows the latest release and the command installs another version, the text says so: "This installs 0.6.8, the version that matches this project's Core."^0.6.8) and has not installed it, the add command pins that range so the package manager resolves the matching release:npm install "@astryxdesign/theme-gothic@^0.6.8". The spec is quoted because^,<,>,|and spaces mean something to a shell. A declaration that names no version, such as a path, a workspace protocol or a dist-tag, pins nothing.Known limit: canary pins
On a canary CLI, a canary-only package is pinned to the CLI's own canary version when the project has no Core, and a package released with Core is pinned to an installed canary Core's version. A canary publish that skipped a package makes that one command fail with
ETARGET. This is accepted for canary users: a release CLI never pins a canary, and on a canary CLI with no Core, packages released with Core are left unpinned.Evidence for this commit
"@astryxdesign/core": "^0.6.8",npm install "@astryxdesign/theme-gothic@^0.6.8"installs Core 0.6.8 and gothic 0.6.8.--json): 267 supersets, 45 errors that now answer, 82 identical error codes, 0 changed exit codes or error codes. The other 2 runs are the known--limit 2cuts.check:reposcript by script,typecheck:json-api,typecheck:authoring,cli-api-types-verify, ESLint, copyright, exports sync, the README check and the official list--checkall pass.typecheck:strictshows the same 2 errors as bare main (@astryxdesign/theme-neutral/built, which needspnpm build).