@astryxdesign/cli 0.7.14 → 0.7.15-canary.g2025dc7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +63 -63
- package/api/build/_adapter.d.mts +4 -0
- package/api/build/_adapter.mjs +28 -2
- package/api/build/blocks/blocks.d.mts +10 -1
- package/api/build/blocks/blocks.mjs +84 -7
- package/api/build/build.mjs +6 -1
- package/api/build/tree.d.mts +4 -0
- package/api/build/tree.mjs +9 -2
- package/api/doctor/_adapter.d.mts +1 -0
- package/api/doctor/_adapter.mjs +8 -0
- package/api/doctor/_authoring-audit.d.mts +42 -0
- package/api/doctor/_authoring-audit.mjs +106 -0
- package/api/doctor/doctor.d.mts +7 -0
- package/api/doctor/doctor.mjs +24 -39
- package/api/integration/validate-integration.mjs +17 -3
- package/api/integration/validateIntegration.doc.mjs +1 -1
- package/api/search/_adapter.mjs +124 -3
- package/api/search/_candidate-score.mjs +63 -9
- package/api/search/_entries.d.mts +10 -0
- package/api/search/_entries.mjs +68 -1
- package/api/search/_gather-templates.d.mts +11 -0
- package/api/search/_gather-templates.mjs +22 -2
- package/api/search/_words.mjs +26 -6
- package/api/swizzle/copy/copy.mjs +1 -1
- package/api/theme/_adapter.mjs +20 -9
- package/api/theme/build/build.d.mts +15 -1
- package/api/theme/build/build.mjs +132 -32
- package/api/theme/targets/targets.d.mts +8 -0
- package/api/theme/targets/targets.mjs +14 -1
- package/api/theme/themeBuild.doc.mjs +6 -3
- package/api/theme/themeEject.doc.mjs +3 -3
- package/api/theme/themeTargets.doc.mjs +1 -1
- package/api/theme-edit/_adapter.d.mts +46 -3
- package/api/theme-edit/_adapter.mjs +372 -109
- package/api/theme-edit/_check.d.mts +6 -3
- package/api/theme-edit/_check.mjs +665 -87
- package/api/theme-edit/_color.mjs +4 -2
- package/api/theme-edit/_compiler.d.mts +2 -1
- package/api/theme-edit/_compiler.mjs +27 -13
- package/api/theme-edit/_context.d.mts +2 -1
- package/api/theme-edit/_context.mjs +47 -8
- package/api/theme-edit/_edit.d.mts +9 -3
- package/api/theme-edit/_edit.mjs +484 -66
- package/api/theme-edit/_how-commands.d.mts +33 -7
- package/api/theme-edit/_how-commands.mjs +57 -45
- package/api/theme-edit/_how-question.d.mts +4 -0
- package/api/theme-edit/_how-question.mjs +1004 -223
- package/api/theme-edit/_how.mjs +96 -9
- package/api/theme-edit/_palette.d.mts +38 -13
- package/api/theme-edit/_palette.mjs +620 -223
- package/api/theme-edit/_parts.mjs +63 -7
- package/api/theme-edit/_png.d.mts +4 -4
- package/api/theme-edit/_png.mjs +4 -2
- package/api/theme-edit/_preview-app.d.mts +6 -0
- package/api/theme-edit/_preview-app.mjs +1194 -207
- package/api/theme-edit/_preview.mjs +2 -2
- package/api/theme-edit/_project.d.mts +12 -1
- package/api/theme-edit/_project.mjs +37 -6
- package/api/theme-edit/_settings.d.mts +104 -33
- package/api/theme-edit/_settings.mjs +818 -118
- package/api/theme-edit/_tables.d.mts +7 -0
- package/api/theme-edit/_tables.mjs +61 -0
- package/api/theme-edit/theme-edit.type.d.mts +11 -1
- package/api/theme-edit/theme-edit.type.mjs +4 -3
- package/api/theme-edit/themeEditHow.doc.mjs +6 -0
- package/api/theme-edit/themeEditPreviewAdd.doc.mjs +1 -1
- package/api/theme-edit/themeEditPreviewApp.doc.mjs +1 -1
- package/api/theme-edit/themeEditPreviewList.doc.mjs +1 -1
- package/api/theme-edit/themeEditPreviewRemove.doc.mjs +5 -1
- package/api/theme-edit/themeEditUndo.doc.mjs +1 -1
- package/api/upgrade/_adapter.d.mts +1 -0
- package/assets/codemods/run-codemod.mjs +61 -0
- package/assets/codemods/runner.mjs +5 -4
- package/assets/codemods/transforms/v0.0.14/rename-status-variants.mjs +3 -0
- package/assets/codemods/transforms/v0.1.8/rename-avatar-size-scale.mjs +5 -1
- package/assets/codemods/transforms/v0.6.4/migrate-native-picker-to-presentation.mjs +3 -0
- package/assets/codemods/transforms/v0.7.0/migrate-deprecated-theme-surface.mjs +4 -0
- package/assets/codemods/transforms/v0.7.0/rename-empty-search-results-text.mjs +17 -12
- package/assets/codemods/transforms/v0.7.2/migrate-list-edge-compensation-to-edge.mjs +3 -0
- package/assets/codemods/transforms/v0.7.5/migrate-codeblock-tokenizer-to-language.mjs +3 -0
- package/assets/codemods/transforms/v0.7.8/promote-tokenizer-presentation.mjs +3 -0
- package/assets/docs/tree/calendars.doc.mjs +1 -3
- package/assets/docs/tree/checks.doc.mjs +22 -1
- package/assets/docs.generated.json +2 -1
- package/assets/self-audit.generated.json +1 -0
- package/assets/templates/blocks/components/Theme/useThemeNameHookUsage.doc.mjs +14 -0
- package/assets/templates/blocks/components/Theme/useThemeNameHookUsage.tsx +31 -0
- package/assets/templates/components.generated.json +1 -1
- package/authoring/integration/integration.doc.mjs +8 -0
- package/authoring/integration/schema.d.mts +8 -0
- package/authoring/integration/schema.mjs +1 -0
- package/authoring/integration/type.ts +9 -0
- package/clients/cli/bin/astryx.mjs +19 -15
- package/clients/cli/build-id.generated.json +1 -0
- package/clients/cli/commands/ensure-core-built.mjs +12 -5
- package/clients/cli/commands/experimental/theme.mjs +178 -78
- package/clients/cli/commands/experimental-theme-compile.doc.mjs +2 -2
- package/clients/cli/commands/experimental-theme-editor-how.doc.mjs +1 -1
- package/clients/cli/commands/experimental-theme-editor-set.doc.mjs +1 -2
- package/clients/cli/commands/experimental-theme-editor-show.doc.mjs +1 -1
- package/clients/cli/commands/experimental-theme-editor-undo.doc.mjs +2 -2
- package/clients/cli/commands/experimental-theme-editor.doc.mjs +1 -1
- package/clients/cli/commands/experimental-theme-eject.doc.mjs +3 -3
- package/clients/cli/commands/experimental-theme-preview-add.doc.mjs +1 -1
- package/clients/cli/commands/experimental-theme-preview-app.doc.mjs +1 -1
- package/clients/cli/commands/experimental-theme-preview-list.doc.mjs +1 -1
- package/clients/cli/commands/experimental-theme-preview-remove.doc.mjs +1 -1
- package/clients/cli/commands/experimental-theme-remove.doc.mjs +1 -1
- package/clients/cli/commands/experimental-theme-template.doc.mjs +4 -3
- package/clients/cli/commands/manifest.mjs +5 -2
- package/clients/cli/commands/theme.mjs +118 -22
- package/clients/cli/index.mjs +9 -3
- package/clients/cli/lib/manifest.mjs +37 -0
- package/clients/cli/lib/resolve-theme.mjs +2 -1
- package/clients/cli/manifest.generated.json +1 -0
- package/foundation/discovery/module-exports.mjs +16 -2
- package/foundation/discovery/stored-self-audit.d.mts +31 -0
- package/foundation/discovery/stored-self-audit.mjs +119 -0
- package/foundation/discovery/template-adapter.d.mts +48 -2
- package/foundation/discovery/template-adapter.mjs +51 -19
- package/foundation/discovery/template-needs.d.mts +6 -0
- package/foundation/discovery/template-needs.mjs +20 -1
- package/foundation/discovery/template-source-tree.d.mts +7 -0
- package/foundation/discovery/template-source-tree.mjs +15 -0
- package/foundation/discovery/theme-discovery.d.mts +2 -1
- package/foundation/discovery/theme-discovery.mjs +2 -8
- package/foundation/discovery/theme-module-extensions.d.mts +18 -0
- package/foundation/discovery/theme-module-extensions.mjs +30 -0
- package/foundation/doc-compiler/import.mjs +12 -11
- package/foundation/doc-compiler/stored-docs.d.mts +18 -12
- package/foundation/doc-compiler/stored-docs.mjs +52 -19
- package/foundation/env/private-dir.d.mts +17 -0
- package/foundation/env/private-dir.mjs +42 -0
- package/foundation/fs/gather-cache.d.mts +108 -0
- package/foundation/fs/gather-cache.mjs +724 -0
- package/foundation/fs/module-loader.mjs +7 -1
- package/foundation/fs/read-record.d.mts +31 -1
- package/foundation/fs/read-record.mjs +100 -7
- package/foundation/integrations/integrations.d.mts +8 -0
- package/foundation/integrations/integrations.mjs +4 -0
- package/foundation/integrations/validate-contributions.d.mts +62 -1
- package/foundation/integrations/validate-contributions.mjs +476 -40
- package/foundation/release/cache.d.mts +11 -2
- package/foundation/release/cache.mjs +59 -10
- package/foundation/release/folder-lock.d.mts +21 -0
- package/foundation/release/folder-lock.mjs +171 -0
- package/foundation/response/response-types.doc.mjs +1 -1
- package/package.json +8 -6
|
@@ -14,7 +14,7 @@ export const doc = {
|
|
|
14
14
|
stability: 'experimental',
|
|
15
15
|
summary: 'Fork a theme as editable local source',
|
|
16
16
|
description:
|
|
17
|
-
"Copies a bundled or installed package theme's complete source into the local themes root, including a local descriptor. Writes are atomic. Existing files require --overwrite. Use --package when package themes share a slug.",
|
|
17
|
+
"Copies a bundled or installed package theme's complete source into the local themes root, including a local descriptor. Writes are atomic. Existing files require --overwrite. Eject never writes into a folder that holds another theme or a theme the theme editor made, even with --overwrite. When the fork imports packages the app lacks, the result names them with an install command. Use --package when package themes share a slug.",
|
|
18
18
|
fn: 'themeEject',
|
|
19
19
|
args: [
|
|
20
20
|
{
|
|
@@ -33,7 +33,7 @@ export const doc = {
|
|
|
33
33
|
flag: '-f, --overwrite',
|
|
34
34
|
param: 'options.overwrite',
|
|
35
35
|
description:
|
|
36
|
-
'Replace existing files. Without it, an existing file fails with ERR_FILE_EXISTS and nothing is written',
|
|
36
|
+
'Replace the existing files of an earlier fork of the same theme. Without it, an existing file fails with ERR_FILE_EXISTS and nothing is written',
|
|
37
37
|
},
|
|
38
38
|
{
|
|
39
39
|
flag: '--package <package>',
|
|
@@ -59,7 +59,7 @@ export const doc = {
|
|
|
59
59
|
},
|
|
60
60
|
{
|
|
61
61
|
code: 1,
|
|
62
|
-
when: 'the theme is unknown or ambiguous, a path escapes, a source file is missing,
|
|
62
|
+
when: 'the theme is unknown or ambiguous, a path escapes, a source file is missing, a destination exists, or the folder holds another theme',
|
|
63
63
|
},
|
|
64
64
|
],
|
|
65
65
|
related: [
|
|
@@ -12,7 +12,7 @@ export const doc = {
|
|
|
12
12
|
summary:
|
|
13
13
|
'Add pages to the theme preview in the app: the default pages, the best template pages for a description, or one template',
|
|
14
14
|
description:
|
|
15
|
-
"Writes the theme preview into the app: one route, a normal page of the app that keeps its layout, global CSS and providers, in an app shell with a side nav item per preview page and a top bar with the theme name and, when it wears a theme made by `editor`, a light, dark and system switch. A description (\"a sales dashboard\") asks the same page ranking `build` uses for the template pages that fit it best (--top of them, default 1), and adds each as a page, saying in `matched` what it picked and why (the words of the description it covers). App frames (the Shell templates) are left out, since the preview is an app shell already. When no page is exactly the one described, the closest is added and `matched` says the rest of the description is not on it; only a description no page relates to is refused, writing nothing and naming the closest pages to add with --template, with the other options repeated. A page the app cannot show (a missing package, or StyleX without a compiler) is skipped and the next match is taken (from the ranking, then the template search), and the result says so. A page's nav label is its template's display name, however it was added; --template names one page template instead; with neither, it adds the default pages: Overview (the theme at a glance, built to show what themes most often break: long and short text, every text level on every surface, every button variant and size with disabled and loading, inputs in their states, selected navigation, status colors, a table, open layers), Components (every component grouped, each with the command that changes it most) and, when the theme sets a color, Colors (each color's shades in light and dark, with the shade number, the hex and the tokens that use each; it reads the theme's generated colors, so it changes with every `editor set`). The route goes in theme-preview/ in the app's routes folder (app/ or src/app/), or in --path; the first add records the pages and the files it wrote in theme-preview.json beside the route, so later calls find it. With no routes folder and no --path, it refuses and names both ways on: --path, or `experimental theme preview app <dir>`, which makes a new starter app with the preview in it. The route fills the whole window with the theme, shell and edges included. Every check (the theme, the template, the ranking and every file it writes) runs before the first write, so a refusal changes nothing. A template page that imports a package the app lacks, or that uses StyleX in an app with no StyleX compiler, is not added: the result names it and the command that installs what it needs. A file the preview did not write is never replaced. The pages wear --theme (default: the only theme under themes/; with none or several, the app's own theme). The pages go in _pages/ beside the route, a folder Next never serves as a route; a preview an older release wrote into pages/ is moved there. theme-preview.json records a hash of each file the preview writes: a file changed by hand since is never replaced (the refusal names it), and a page file that already holds exactly the planned text is taken over. The files are staged and renamed into place together; when a write fails, every file is put back as it was. A damaged theme-preview.json is refused with `ERR_THEME_INVALID`, naming the file. The folder is refused when it is a file, in themes/ or node_modules/, in a Pages Router folder (pages/ or src/pages/), in a folder Next does not route (_private, @slot, [param]), or written with Windows separators, a leading ~ or white space at either end. With no --path and no preview in the default place, a preview recorded for a theme is used; with several, the refusal names each. A theme the preview wore that is gone is replaced by the app's own theme, with a note; a changed theme writes the default pages again. A template page whose package the app's package.json names but nobody installed is skipped like a missing one. Only the first 40 different words of a long description go to the ranking, with a note. The description may be several words without quotes. The project root, src/ and the routes folder itself are refused too: they hold the app. An older preview found there is named, with the remove that clears it. A recorded page whose file is gone is written again (a default page, or the template its id names), or else left out of the nav, with a note. A formatter run (white space, quotes, semicolons, commas) does not count as a change by hand. Refusals never suggest deleting files: they say what to move or rename. Preview commands in one project run one after another. Experimental: it may change or be removed in a patch release.",
|
|
15
|
+
"Writes the theme preview into the app: one route, a normal page of the app that keeps its layout, global CSS and providers, in an app shell with a side nav item per preview page and a top bar with the theme name and, when it wears a theme made by `editor`, a light, dark and system switch. A description (\"a sales dashboard\") asks the same page ranking `build` uses for the template pages that fit it best (--top of them, default 1), and adds each as a page, saying in `matched` what it picked and why (the words of the description it covers). App frames (the Shell templates) are left out, since the preview is an app shell already. When no page is exactly the one described, the closest is added and `matched` says the rest of the description is not on it; only a description no page relates to is refused, writing nothing and naming the closest pages to add with --template, with the other options repeated. A page the app cannot show (a missing package, or StyleX without a compiler) is skipped and the next match is taken (from the ranking, then the template search), and the result says so. A page's nav label is its template's display name, however it was added; --template names one page template instead; with neither, it adds the default pages: Overview (the theme at a glance, built to show what themes most often break: long and short text, every text level on every surface, every button variant and size with disabled and loading, inputs in their states, selected navigation, status colors, a table, open layers), Components (every component grouped, each with the command that changes it most) and, when the theme sets a color, Colors (each color's shades in light and dark, with the shade number, the hex and the tokens that use each; it reads the theme's generated colors, so it changes with every `editor set`). The route goes in theme-preview/ in the app's routes folder (app/ or src/app/), or in --path; the first add records the pages and the files it wrote in theme-preview.json beside the route, so later calls find it. With no routes folder and no --path, it refuses and names both ways on: --path, or `experimental theme preview app <dir>`, which makes a new starter app with the preview in it. The route fills the whole window with the theme, shell and edges included. Every check (the theme, the template, the ranking and every file it writes) runs before the first write, so a refusal changes nothing. A template page that imports a package the app lacks, or that uses StyleX in an app with no StyleX compiler, is not added: the result names it and the command that installs what it needs. A file the preview did not write is never replaced. The pages wear --theme (default: the only theme under themes/; with none or several, the app's own theme). The pages go in _pages/ beside the route, a folder Next never serves as a route; a preview an older release wrote into pages/ is moved there. theme-preview.json records a hash of each file the preview writes: a file changed by hand since is never replaced (the refusal names it), and a page file that already holds exactly the planned text is taken over. The files are staged and renamed into place together; when a write fails, every file is put back as it was. A damaged theme-preview.json is refused with `ERR_THEME_INVALID`, naming the file. The folder is refused when it is a file, in themes/ or node_modules/, in a Pages Router folder (pages/ or src/pages/), in a folder Next does not route (_private, @slot, [param]), or written with Windows separators, a leading ~ or white space at either end. With no --path and no preview in the default place, a preview recorded for a theme is used; with several, the refusal names each. A theme the preview wore that is gone is replaced by the app's own theme, with a note; a changed theme writes the default pages again. A template page whose package the app's package.json names but nobody installed is skipped like a missing one. Only the first 40 different words of a long description go to the ranking, with a note. The description may be several words without quotes. The project root, src/ and the routes folder itself are refused too: they hold the app. An older preview found there is named, with the remove that clears it. A recorded page whose file is gone is written again (a default page, or the template its id names), or else left out of the nav, with a note. A formatter run (white space, quotes, semicolons, commas) does not count as a change by hand. Refusals never suggest deleting files: they say what to move or rename. Preview commands in one project run one after another. The folder is also refused when it holds a package.json, when another page of the app already serves its URL (a route group or the Pages Router), when next.config sets pageExtensions without tsx, when it is in src/app/ while app/ is what Next serves, and when no root layout is above it (an app with its root layout in [locale]/ gets its preview there, opened at /<locale>/theme-preview; an app with a root layout in each route group takes the preview under any of them). A template's needs come from its real import statements, never words in comments or strings; a package the app does not name gets the command that adds it. A theme with no build is built only after every check passed, holding that theme's lock, with a note. An edit inside a string counts as a change by hand; a formatter run does not. Experimental: it may change or be removed in a patch release.",
|
|
16
16
|
fn: 'themeEditPreviewAdd',
|
|
17
17
|
args: [
|
|
18
18
|
{
|
|
@@ -12,7 +12,7 @@ export const doc = {
|
|
|
12
12
|
summary:
|
|
13
13
|
'Make a new starter app with the theme preview inside, ready to install and run',
|
|
14
14
|
description:
|
|
15
|
-
"Writes a new starter app into <dir> (Next.js app router, Core and the neutral theme, with the Astryx packages pinned to this CLI's release), with the theme preview route and its default pages (the sample app page and every component grouped) in src/app/theme-preview/. With --theme, the theme folder is copied into the app's themes/ and the pages wear it; a base theme or font package it needs is added to package.json. No install runs: it prints the install and dev commands and the page to open. <dir> must be new or empty, inside the current folder; a folder that is not empty is refused, with a free folder name to use instead. Every check runs before the first write, so a refusal changes nothing. Later pages go in with `experimental theme preview add`, run in the new app. Every open font the theme names is added to package.json, at the version this project has or a pinned range, and the route imports it; a theme with generated colors gets the Colors page too, and a one-mode theme starts the route in its mode. The app is written into a temp folder beside the folder and moved into place, so a failure leaves nothing behind. A folder holding only .git, .DS_Store or Thumbs.db counts as empty. The folder is refused when it is a file, a dangling link, inside this app's routes folder, themes/ or node_modules/, or written with Windows separators, white space at either end or a name too long. A theme whose build is missing or older than its settings is built first, with a note. The app's home page links to the preview, and its .gitignore leaves out node_modules, next-env.d.ts and *.tsbuildinfo. Inside a project with a tsconfig.json, a note says to exclude the new folder. It takes one folder; more arguments are refused. With a theme, it holds that theme's lock while it builds and copies it, so an `editor set` on the same theme waits for it. A folder given from a subfolder of the project is taken from where it was given. Experimental: it may change or be removed in a patch release.",
|
|
15
|
+
"Writes a new starter app into <dir> (Next.js app router, Core and the neutral theme, with the Astryx packages pinned to this CLI's release), with the theme preview route and its default pages (the sample app page and every component grouped) in src/app/theme-preview/. With --theme, the theme folder is copied into the app's themes/ and the pages wear it; a base theme or font package it needs is added to package.json. No install runs: it prints the install and dev commands and the page to open. <dir> must be new or empty, inside the current folder; a folder that is not empty is refused, with a free folder name to use instead. Every check runs before the first write, so a refusal changes nothing. Later pages go in with `experimental theme preview add`, run in the new app. Every open font the theme names is added to package.json, at the version this project has or a pinned range, and the route imports it; a theme with generated colors gets the Colors page too, and a one-mode theme starts the route in its mode. The app is written into a temp folder beside the folder and moved into place, so a failure leaves nothing behind. A folder holding only .git, .DS_Store or Thumbs.db counts as empty. The folder is refused when it is a file, a dangling link, inside this app's routes folder, themes/ or node_modules/, or written with Windows separators, white space at either end or a name too long. A theme whose build is missing or older than its settings is built first, with a note. The app's home page links to the preview, and its .gitignore leaves out node_modules, next-env.d.ts and *.tsbuildinfo. Inside a project with a tsconfig.json, a note says to exclude the new folder. It takes one folder; more arguments are refused. With a theme, it holds that theme's lock while it builds and copies it, so an `editor set` on the same theme waits for it. A folder given from a subfolder of the project is taken from where it was given. An app is refused in public/ (served as files at the site root) and under a name Windows does not allow; a base theme passed to --theme is named as a package theme, installed or not, with the command that adds it. Experimental: it may change or be removed in a patch release.",
|
|
16
16
|
fn: 'themeEditPreviewApp',
|
|
17
17
|
args: [
|
|
18
18
|
{
|
|
@@ -11,7 +11,7 @@ export const doc = {
|
|
|
11
11
|
stability: 'experimental',
|
|
12
12
|
summary: 'The pages of the theme preview in the app',
|
|
13
13
|
description:
|
|
14
|
-
'Lists the pages of the theme preview, in nav order, with the theme they wear and the route folder. With no preview, and with no routes folder for one, it says so and how to add one (the JSON list is empty). A damaged theme-preview.json is refused with `ERR_THEME_INVALID`, naming the file. With no folder given and no preview in the default place, a preview recorded for a theme is listed; with several, the refusal names each. The tip repeats --path. Experimental: it may change or be removed in a patch release.',
|
|
14
|
+
'Lists the pages of the theme preview, in nav order, with the theme they wear and the route folder. With no preview, and with no routes folder for one, it says so and how to add one (the JSON list is empty). A damaged theme-preview.json is refused with `ERR_THEME_INVALID`, naming the file. With no folder given and no preview in the default place, a preview recorded for a theme is listed; with several, the refusal names each. The tip repeats --path. `notes` says when the theme the preview wears is gone. Experimental: it may change or be removed in a patch release.',
|
|
15
15
|
fn: 'themeEditPreviewList',
|
|
16
16
|
options: [
|
|
17
17
|
{
|
|
@@ -11,7 +11,7 @@ export const doc = {
|
|
|
11
11
|
stability: 'experimental',
|
|
12
12
|
summary: 'Remove one page from the theme preview, or the whole preview',
|
|
13
13
|
description:
|
|
14
|
-
'Removes one page and its nav item, and rewrites the route. With no page, or for the last page, it removes the whole preview: only the files the preview wrote (theme-preview.json lists them) are deleted, and the folder only when nothing else is in it. A path in theme-preview.json that leads outside the route folder is refused before anything is deleted. Only files the preview wrote are deleted: a page file it did not write, or one changed by hand since it wrote it (by the hash theme-preview.json records), is kept and named in `kept`, with a note; files already gone are named in `missing`, and the route and Colors page written again in `rewritten`. Every check runs before the first delete: the theme the route wears is loaded first, so a theme that does not load is refused with nothing deleted, and the refusal names the whole-preview remove, which needs no theme. A theme that is gone is replaced by the theme of the app itself, with a note. A page id matches in any case. A damaged theme-preview.json (not JSON, the wrong shape, a duplicate page, a folder or an absolute path in its files) is refused with `ERR_THEME_INVALID`, naming the file. With no folder given and no preview in the default place, a preview recorded for a theme is used. It takes one page; more arguments are refused. A whole remove stops, deleting nothing, when page.tsx was changed by hand: it imports the pages. A page whose file is gone leaves the nav, with a note. Refusals never suggest deleting files. Preview commands in one project run one after another. Experimental: it may change or be removed in a patch release.',
|
|
14
|
+
'Removes one page and its nav item, and rewrites the route. With no page, or for the last page, it removes the whole preview: only the files the preview wrote (theme-preview.json lists them) are deleted, and the folder only when nothing else is in it. A path in theme-preview.json that leads outside the route folder is refused before anything is deleted. Only files the preview wrote are deleted: a page file it did not write, or one changed by hand since it wrote it (by the hash theme-preview.json records), is kept and named in `kept`, with a note; files already gone are named in `missing`, and the route and Colors page written again in `rewritten`. Every check runs before the first delete: the theme the route wears is loaded first, so a theme that does not load is refused with nothing deleted, and the refusal names the whole-preview remove, which needs no theme. A theme that is gone is replaced by the theme of the app itself, with a note. A page id matches in any case. A damaged theme-preview.json (not JSON, the wrong shape, a duplicate page, a folder or an absolute path in its files) is refused with `ERR_THEME_INVALID`, naming the file. With no folder given and no preview in the default place, a preview recorded for a theme is used. It takes one page; more arguments are refused. A whole remove stops, deleting nothing, when page.tsx was changed by hand: it imports the pages. A page whose file is gone leaves the nav, with a note. Refusals never suggest deleting files. Preview commands in one project run one after another. A remove deletes only the route file, the record and the page files of recorded pages (in _pages/, or pages/ for an older release), and only when a recorded hash shows they are as the preview wrote them: any other file the record names, and any file with no recorded hash, is kept and named, so a copied or edited record never deletes a project file. A route that stays keeps the pages it imports. Experimental: it may change or be removed in a patch release.',
|
|
15
15
|
fn: 'themeEditPreviewRemove',
|
|
16
16
|
args: [
|
|
17
17
|
{
|
|
@@ -14,7 +14,7 @@ export const doc = {
|
|
|
14
14
|
stability: 'experimental',
|
|
15
15
|
summary: 'Remove a non-default theme from the app',
|
|
16
16
|
description:
|
|
17
|
-
'Removes one added theme from the generated module and regenerates the whole module. Choose another default with theme use before removing the current default.',
|
|
17
|
+
'Removes one added theme from the generated module and regenerates the whole module. Choose another default with `astryx experimental theme use` before removing the current default.',
|
|
18
18
|
fn: 'themeRemove',
|
|
19
19
|
args: [
|
|
20
20
|
{
|
|
@@ -14,7 +14,7 @@ export const doc = {
|
|
|
14
14
|
stability: 'experimental',
|
|
15
15
|
summary: 'Write the annotated theme template into your project',
|
|
16
16
|
description:
|
|
17
|
-
'Writes theme.template.ts: the annotated reference for the whole theme surface, covering every defineTheme field, the token families, the component override syntax, and how a theme is consumed, naming the CLI command that prints the authoritative reference for each. Read it, copy what you need into your own theme file, delete it. Use `experimental theme add <slug>` to use an installed built theme, extend that theme for ordinary customization, or use `experimental theme eject <slug>` for a complete source fork. Leaves an existing file untouched unless --overwrite.',
|
|
17
|
+
'Writes theme.template.ts: the annotated reference for the whole theme surface, covering every defineTheme field, the token families, the component override syntax, and how a theme is consumed, naming the CLI command that prints the authoritative reference for each. Read it, copy what you need into your own theme file, delete it. Use `experimental theme add <slug>` to use an installed built theme, extend that theme for ordinary customization, or use `experimental theme eject <slug>` for a complete source fork. The path is a .ts file, never a folder. Leaves an existing file untouched unless --overwrite, which replaces only an earlier copy of the template or a file named like a theme source (`*.theme.ts`, `*Theme.ts`, `*.template.ts`).',
|
|
18
18
|
fn: 'themeTemplate',
|
|
19
19
|
args: [
|
|
20
20
|
{
|
|
@@ -27,7 +27,8 @@ export const doc = {
|
|
|
27
27
|
{
|
|
28
28
|
flag: '-f, --overwrite',
|
|
29
29
|
param: 'options.overwrite',
|
|
30
|
-
description:
|
|
30
|
+
description:
|
|
31
|
+
'Replace an existing copy of the template or theme source file. Any other file, such as package.json, or a file in a folder the theme editor made, fails with ERR_FILE_EXISTS and is left as it was',
|
|
31
32
|
},
|
|
32
33
|
],
|
|
33
34
|
examples: [
|
|
@@ -48,7 +49,7 @@ export const doc = {
|
|
|
48
49
|
},
|
|
49
50
|
{
|
|
50
51
|
code: 1,
|
|
51
|
-
when: 'the target path escapes the project, or the file cannot be written',
|
|
52
|
+
when: 'the target path escapes the project, is blank, a folder or not a .ts file, --overwrite names a file that is not a theme template or source, or the file cannot be written',
|
|
52
53
|
},
|
|
53
54
|
],
|
|
54
55
|
related: [
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
import {getCliInvocation} from '../../../foundation/env/package-manager.mjs';
|
|
20
20
|
import {jsonOut} from '../../../foundation/response/json.mjs';
|
|
21
21
|
import {emit, section, text, records} from '../formatters/index.mjs';
|
|
22
|
-
import {buildManifest} from '../lib/manifest.mjs';
|
|
22
|
+
import {buildManifest, storedManifest} from '../lib/manifest.mjs';
|
|
23
23
|
import {defineCommand} from '../lib/define-command.mjs';
|
|
24
24
|
import {resultSet} from '../../../foundation/debug/index.mjs';
|
|
25
25
|
import {doc as manifestCommand} from './manifest.doc.mjs';
|
|
@@ -32,7 +32,10 @@ import {doc as manifestCommand} from './manifest.doc.mjs';
|
|
|
32
32
|
export function registerManifest(program, {jsonSupported, version}) {
|
|
33
33
|
defineCommand(program, manifestCommand, {
|
|
34
34
|
action: () => {
|
|
35
|
-
|
|
35
|
+
// The published package reads the manifest it stored: only this
|
|
36
|
+
// command is loaded then (see commandsForArgs).
|
|
37
|
+
const manifest =
|
|
38
|
+
storedManifest() ?? buildManifest(program, {jsonSupported, version});
|
|
36
39
|
// The manifest IS a result set: one entry per command the CLI ships.
|
|
37
40
|
const answered = resultSet({
|
|
38
41
|
count: manifest.commands.length,
|
|
@@ -33,7 +33,10 @@ import * as fs from 'node:fs';
|
|
|
33
33
|
import * as path from 'node:path';
|
|
34
34
|
import {fileURLToPath} from 'node:url';
|
|
35
35
|
import {spawn} from 'node:child_process';
|
|
36
|
-
import {
|
|
36
|
+
import {
|
|
37
|
+
getCliInvocation,
|
|
38
|
+
quoteCommandArgument,
|
|
39
|
+
} from '../../../foundation/env/package-manager.mjs';
|
|
37
40
|
import {isOutsideProject} from '../../../foundation/env/project-scope.mjs';
|
|
38
41
|
import {jsonOut} from '../../../foundation/response/json.mjs';
|
|
39
42
|
import {
|
|
@@ -59,7 +62,10 @@ import {
|
|
|
59
62
|
themeListAvailable,
|
|
60
63
|
themeListCopySources,
|
|
61
64
|
} from '../../../api/theme/list/list.mjs';
|
|
62
|
-
import {
|
|
65
|
+
import {
|
|
66
|
+
normalizeTargetFilter,
|
|
67
|
+
themeTargets,
|
|
68
|
+
} from '../../../api/theme/targets/targets.mjs';
|
|
63
69
|
import {
|
|
64
70
|
serializePaletteCandidate,
|
|
65
71
|
themePaletteGenerate,
|
|
@@ -70,6 +76,7 @@ import {
|
|
|
70
76
|
themeBuild,
|
|
71
77
|
themeBuildFamily,
|
|
72
78
|
themeBuildForReport,
|
|
79
|
+
themeSourceGuesses,
|
|
73
80
|
} from '../../../api/theme/build/build.mjs';
|
|
74
81
|
import {defineCommand} from '../lib/define-command.mjs';
|
|
75
82
|
import {NO_RESULT_SET, resultSet} from '../../../foundation/debug/index.mjs';
|
|
@@ -101,11 +108,72 @@ import {doc as themePaletteGenerateFn} from '../../../api/theme/themePaletteGene
|
|
|
101
108
|
* @typedef {object} ThemeCommandWords
|
|
102
109
|
* @property {string} group - The group's command path: `theme` or `experimental theme`.
|
|
103
110
|
* @property {string} build - The build subcommand's name: `build` or `compile`.
|
|
111
|
+
* @property {(err: import('../../../api/error.mjs').AstryxError, cwd: string) => import('../../../api/error.mjs').AstryxError | null} [explain] - A clearer refusal for this group, or null.
|
|
112
|
+
* @property {(files: string[], options: {cwd: string, check?: boolean, family?: boolean}) => Promise<import('../../../api/error.mjs').AstryxError | null>} [preflight] - A refusal before a build starts, or null.
|
|
113
|
+
* @property {(files: string[], options: {cwd: string}) => Promise<() => Promise<void>>} [hold] - Locks held while a build or check runs; resolves to their release.
|
|
104
114
|
*/
|
|
105
115
|
|
|
106
116
|
/** @type {ThemeCommandWords} */
|
|
107
117
|
const THEME_WORDS = {group: 'theme', build: 'build'};
|
|
108
118
|
|
|
119
|
+
/**
|
|
120
|
+
* Text as the group that ran the command words it: under `experimental
|
|
121
|
+
* theme`, the commands it names are that group's own (`build` is `compile`
|
|
122
|
+
* there). Only a command the CLI wrote is reworded: one after the CLI's
|
|
123
|
+
* name, or in backticks; text a person typed (a path, a name) stays as
|
|
124
|
+
* typed. Under `theme`, the text is unchanged.
|
|
125
|
+
* @param {string} text
|
|
126
|
+
* @param {ThemeCommandWords} words
|
|
127
|
+
*/
|
|
128
|
+
function inGroupWords(text, words) {
|
|
129
|
+
if (words.group === THEME_WORDS.group) return text;
|
|
130
|
+
// An argument the person typed can hold the same words (a filter of
|
|
131
|
+
// `astryx theme list`); it is echoed as typed. Only an argument with a
|
|
132
|
+
// space or a backtick can match, and it is set aside only where the CLI
|
|
133
|
+
// echoes it: in double quotes, or as the argument after a subcommand.
|
|
134
|
+
const typed = [...new Set(process.argv.slice(2))]
|
|
135
|
+
.filter(arg => /[\s`]/.test(arg))
|
|
136
|
+
.sort((a, b) => b.length - a.length);
|
|
137
|
+
/** @type {string[]} */
|
|
138
|
+
const kept = [];
|
|
139
|
+
let masked = String(text);
|
|
140
|
+
for (const arg of typed) {
|
|
141
|
+
const escaped = arg.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
|
142
|
+
masked = masked.replace(
|
|
143
|
+
new RegExp(
|
|
144
|
+
`(?<="|\\b(?:add|use|remove|eject|targets|template|build|compile) )${escaped}(?="|\`|\\s|$)`,
|
|
145
|
+
'g',
|
|
146
|
+
),
|
|
147
|
+
() => `\uE000${kept.push(arg) - 1}\uE001`,
|
|
148
|
+
);
|
|
149
|
+
}
|
|
150
|
+
return masked
|
|
151
|
+
.replace(
|
|
152
|
+
/((?:\bastryx|@astryxdesign\/cli@[\w.-]+) |`)theme (add|use|remove|list|build|eject|template|targets)\b/g,
|
|
153
|
+
(_, lead, sub) =>
|
|
154
|
+
`${lead}${words.group} ${sub === 'build' ? words.build : sub}`,
|
|
155
|
+
)
|
|
156
|
+
.replace(/\uE000(\d+)\uE001/g, (_, i) => kept[Number(i)]);
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
/**
|
|
160
|
+
* A theme app result with its notes in the words of the group that ran it.
|
|
161
|
+
* @template {{data: {notes?: string[]}}} R
|
|
162
|
+
* @param {R} result
|
|
163
|
+
* @param {ThemeCommandWords} words
|
|
164
|
+
* @returns {R}
|
|
165
|
+
*/
|
|
166
|
+
function inGroupNotes(result, words) {
|
|
167
|
+
if (!result?.data?.notes || words.group === THEME_WORDS.group) return result;
|
|
168
|
+
return {
|
|
169
|
+
...result,
|
|
170
|
+
data: {
|
|
171
|
+
...result.data,
|
|
172
|
+
notes: result.data.notes.map(n => inGroupWords(n, words)),
|
|
173
|
+
},
|
|
174
|
+
};
|
|
175
|
+
}
|
|
176
|
+
|
|
109
177
|
/**
|
|
110
178
|
* A theme API refusal as the group that ran it words it: under
|
|
111
179
|
* `experimental theme`, the commands it names are that group's own (`build`
|
|
@@ -114,14 +182,9 @@ const THEME_WORDS = {group: 'theme', build: 'build'};
|
|
|
114
182
|
* @param {ThemeCommandWords} [words]
|
|
115
183
|
*/
|
|
116
184
|
function themeError(err, words = THEME_WORDS) {
|
|
185
|
+
err = words.explain?.(err, process.cwd()) ?? err;
|
|
117
186
|
/** @param {string} text */
|
|
118
|
-
const local = text =>
|
|
119
|
-
words.group === THEME_WORDS.group
|
|
120
|
-
? text
|
|
121
|
-
: text.replace(
|
|
122
|
-
/(?<!experimental )\btheme (add|use|remove|list|build|eject|template|targets)\b/g,
|
|
123
|
-
(_, sub) => `${words.group} ${sub === 'build' ? words.build : sub}`,
|
|
124
|
-
);
|
|
187
|
+
const local = text => inGroupWords(text, words);
|
|
125
188
|
return cliError(local(err.message), {
|
|
126
189
|
suggestions: (err.suggestions || []).map(x => ({
|
|
127
190
|
...x,
|
|
@@ -730,7 +793,7 @@ function registerPaletteCommands(
|
|
|
730
793
|
* @param {ThemeCommandWords} words
|
|
731
794
|
*/
|
|
732
795
|
function registerThemeCommands(theme, program, docs, words) {
|
|
733
|
-
defineCommand(theme, docs.build, {
|
|
796
|
+
const buildCli = defineCommand(theme, docs.build, {
|
|
734
797
|
fn: themeBuildFn,
|
|
735
798
|
action: async (
|
|
736
799
|
/** @type {string[]} */ files,
|
|
@@ -754,17 +817,26 @@ function registerThemeCommands(theme, program, docs, words) {
|
|
|
754
817
|
// A quoted glob reaches us unexpanded: say so rather than reporting a
|
|
755
818
|
// literal `themes/*.ts` as a missing file.
|
|
756
819
|
const looksGlobby = /[*?[\]{}]/.test(entry.file);
|
|
820
|
+
const guesses = looksGlobby
|
|
821
|
+
? []
|
|
822
|
+
: themeSourceGuesses(entry.file, process.cwd());
|
|
757
823
|
return cliError(`File not found: ${entry.filePath}`, {
|
|
758
824
|
code: ERROR_CODES.ERR_FILE_NOT_FOUND,
|
|
759
825
|
suggestions: looksGlobby
|
|
760
826
|
? [
|
|
761
827
|
{
|
|
762
|
-
|
|
828
|
+
// The pattern stays unquoted: the shell expands it.
|
|
829
|
+
name: `${getCliInvocation(process.cwd())} ${words.group} ${words.build} ${entry.file.replace(/['"]/g, '')}`,
|
|
763
830
|
reason:
|
|
764
831
|
'globs are expanded by your shell; pass the pattern unquoted, or list the files',
|
|
765
832
|
},
|
|
766
833
|
]
|
|
767
|
-
:
|
|
834
|
+
: guesses.length > 0
|
|
835
|
+
? guesses.map(guess => ({
|
|
836
|
+
name: `${getCliInvocation(process.cwd())} ${words.group} ${words.build} ${quoteCommandArgument(guess)}`,
|
|
837
|
+
reason: 'a theme source that exists',
|
|
838
|
+
}))
|
|
839
|
+
: undefined,
|
|
768
840
|
});
|
|
769
841
|
}
|
|
770
842
|
|
|
@@ -847,6 +919,13 @@ function registerThemeCommands(theme, program, docs, words) {
|
|
|
847
919
|
privateVarError = true;
|
|
848
920
|
};
|
|
849
921
|
|
|
922
|
+
const refused = await words.preflight?.(files, {
|
|
923
|
+
cwd: process.cwd(),
|
|
924
|
+
check: options.check,
|
|
925
|
+
family: Boolean(options.family),
|
|
926
|
+
});
|
|
927
|
+
if (refused) return themeError(refused, words);
|
|
928
|
+
|
|
850
929
|
if (options.family) {
|
|
851
930
|
try {
|
|
852
931
|
const result = await themeBuildFamily(
|
|
@@ -856,6 +935,7 @@ function registerThemeCommands(theme, program, docs, words) {
|
|
|
856
935
|
check: options.check,
|
|
857
936
|
iconsSpecifier: options.iconsSpecifier,
|
|
858
937
|
__onPrivateVarError: onPrivateVarError,
|
|
938
|
+
__commandWords: words,
|
|
859
939
|
},
|
|
860
940
|
{cwd: process.cwd()},
|
|
861
941
|
);
|
|
@@ -870,10 +950,7 @@ function registerThemeCommands(theme, program, docs, words) {
|
|
|
870
950
|
} catch (e) {
|
|
871
951
|
const err =
|
|
872
952
|
/** @type {import('../../../api/error.mjs').AstryxError} */ (e);
|
|
873
|
-
return
|
|
874
|
-
suggestions: err.suggestions,
|
|
875
|
-
code: err.code,
|
|
876
|
-
});
|
|
953
|
+
return themeError(err, words);
|
|
877
954
|
}
|
|
878
955
|
}
|
|
879
956
|
|
|
@@ -895,6 +972,7 @@ function registerThemeCommands(theme, program, docs, words) {
|
|
|
895
972
|
iconsSpecifier: options.iconsSpecifier,
|
|
896
973
|
__onPrivateVarError: onPrivateVarError,
|
|
897
974
|
__claimedOutputs: claimedOutputs,
|
|
975
|
+
__commandWords: words,
|
|
898
976
|
};
|
|
899
977
|
let result;
|
|
900
978
|
if (report) {
|
|
@@ -937,10 +1015,8 @@ function registerThemeCommands(theme, program, docs, words) {
|
|
|
937
1015
|
// and font guidance.
|
|
938
1016
|
if (report && compact) printCompactTrailer(trailers);
|
|
939
1017
|
else if (report) printBatchTrailer(trailers);
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
{suggestions: err.suggestions, code: err.code},
|
|
943
|
-
);
|
|
1018
|
+
if (entries.length > 1) err.message = `${entry.file}: ${err.message}`;
|
|
1019
|
+
return themeError(err, words);
|
|
944
1020
|
}
|
|
945
1021
|
}
|
|
946
1022
|
|
|
@@ -986,6 +1062,19 @@ function registerThemeCommands(theme, program, docs, words) {
|
|
|
986
1062
|
return NO_RESULT_SET;
|
|
987
1063
|
},
|
|
988
1064
|
});
|
|
1065
|
+
// A group may hold locks while a build or check runs (the editor's theme
|
|
1066
|
+
// lock), so it never reads a change half written.
|
|
1067
|
+
if (words.hold) {
|
|
1068
|
+
/** @type {(() => Promise<void>) | undefined} */
|
|
1069
|
+
let release;
|
|
1070
|
+
buildCli.hook('preAction', async (_, cmd) => {
|
|
1071
|
+
release = await words.hold?.(cmd.args, {cwd: process.cwd()});
|
|
1072
|
+
});
|
|
1073
|
+
buildCli.hook('postAction', async () => {
|
|
1074
|
+
await release?.();
|
|
1075
|
+
release = undefined;
|
|
1076
|
+
});
|
|
1077
|
+
}
|
|
989
1078
|
|
|
990
1079
|
const listCli = defineCommand(theme, docs.list, {
|
|
991
1080
|
fn: themeListFn,
|
|
@@ -1057,6 +1146,10 @@ function registerThemeCommands(theme, program, docs, words) {
|
|
|
1057
1146
|
? resultSet({count: result.data.length, resultKind: 'theme'})
|
|
1058
1147
|
: NO_RESULT_SET;
|
|
1059
1148
|
|
|
1149
|
+
if (result.type !== 'theme.list')
|
|
1150
|
+
result = /** @type {any} */ (
|
|
1151
|
+
inGroupNotes(/** @type {any} */ (result), words)
|
|
1152
|
+
);
|
|
1060
1153
|
if (json) {
|
|
1061
1154
|
jsonOut(result);
|
|
1062
1155
|
return answered;
|
|
@@ -1086,6 +1179,7 @@ function registerThemeCommands(theme, program, docs, words) {
|
|
|
1086
1179
|
return themeError(err, words);
|
|
1087
1180
|
}
|
|
1088
1181
|
await warnOnThemeIntegrationIssues(json);
|
|
1182
|
+
result = inGroupNotes(result, words);
|
|
1089
1183
|
if (json) jsonOut(result);
|
|
1090
1184
|
else printThemeApp(result);
|
|
1091
1185
|
return NO_RESULT_SET;
|
|
@@ -1106,6 +1200,7 @@ function registerThemeCommands(theme, program, docs, words) {
|
|
|
1106
1200
|
return themeError(err, words);
|
|
1107
1201
|
}
|
|
1108
1202
|
await warnOnThemeIntegrationIssues(json);
|
|
1203
|
+
result = inGroupNotes(result, words);
|
|
1109
1204
|
if (json) jsonOut(result);
|
|
1110
1205
|
else printThemeApp(result);
|
|
1111
1206
|
return NO_RESULT_SET;
|
|
@@ -1212,15 +1307,16 @@ function registerThemeCommands(theme, program, docs, words) {
|
|
|
1212
1307
|
const matched = new Set(
|
|
1213
1308
|
result.data.targets.map(target => target.component.toLowerCase()),
|
|
1214
1309
|
);
|
|
1310
|
+
const needle = normalizeTargetFilter(filter);
|
|
1215
1311
|
const answered = resultSet({
|
|
1216
1312
|
count: result.data.targets.length,
|
|
1217
1313
|
resultKind: 'theme',
|
|
1218
1314
|
// Falsy, not just null: the api treats an empty filter as no filter
|
|
1219
1315
|
// at all, so recording one as a match that missed would invent a
|
|
1220
1316
|
// failed lookup out of a run that never looked anything up.
|
|
1221
|
-
directMatch: !
|
|
1317
|
+
directMatch: !needle
|
|
1222
1318
|
? undefined
|
|
1223
|
-
: matched.size === 1 && matched.has(
|
|
1319
|
+
: matched.size === 1 && matched.has(needle),
|
|
1224
1320
|
});
|
|
1225
1321
|
if (json) {
|
|
1226
1322
|
jsonOut(result);
|
package/clients/cli/index.mjs
CHANGED
|
@@ -24,7 +24,7 @@ import {API_VERSION, setJsonMode} from '../../foundation/response/json.mjs';
|
|
|
24
24
|
import {answeredBy, runChoice} from '../../foundation/release/run-context.mjs';
|
|
25
25
|
import {cliInstallAdvice, installFolder, projectRelease, SETUP_REMINDER_KEY, takeNotice} from '../../foundation/release/notices.mjs';
|
|
26
26
|
import {isCi} from '../../foundation/release/update-notice-env.mjs';
|
|
27
|
-
import {buildManifest} from './lib/manifest.mjs';
|
|
27
|
+
import {buildManifest, storedManifest} from './lib/manifest.mjs';
|
|
28
28
|
import {cliError} from './lib/cli-error.mjs';
|
|
29
29
|
import {section, text, records} from './formatters/index.mjs';
|
|
30
30
|
import {ERROR_CODES} from '../../foundation/response/error-codes.mjs';
|
|
@@ -106,6 +106,10 @@ export const JSON_SUPPORTED = new Set([
|
|
|
106
106
|
'experimental icon new-set',
|
|
107
107
|
'experimental icon new-definition',
|
|
108
108
|
'experimental render',
|
|
109
|
+
// The groups answer --json with their own help, as the root does.
|
|
110
|
+
'experimental theme',
|
|
111
|
+
'experimental theme editor',
|
|
112
|
+
'experimental theme preview',
|
|
109
113
|
'experimental theme editor new',
|
|
110
114
|
'experimental theme editor set',
|
|
111
115
|
'experimental theme editor undo',
|
|
@@ -364,7 +368,8 @@ const READS_EVERY_COMMAND = new Set(['manifest']);
|
|
|
364
368
|
* same way. It returns that one command, no command for a run that only
|
|
365
369
|
* prints the version, or null for every command. These runs load every
|
|
366
370
|
* command: the root help when no stored list ships (a checkout; the published
|
|
367
|
-
* package prints it from the list, see `printsRootHelp`), the manifest
|
|
371
|
+
* package prints it from the list, see `printsRootHelp`), the manifest
|
|
372
|
+
* when no stored manifest ships (the published package reads its own),
|
|
368
373
|
* `help <command>`, an unknown word, and a flag the root does not declare.
|
|
369
374
|
* They print or read the whole list.
|
|
370
375
|
*
|
|
@@ -378,7 +383,8 @@ export function commandsForArgs(program, argv) {
|
|
|
378
383
|
const arg = argv[i];
|
|
379
384
|
// Commander reads a lone `-` as an operand, as it reads any word.
|
|
380
385
|
if (arg.length < 2 || arg[0] !== '-') {
|
|
381
|
-
return commands.some(cmd => cmd.name === arg) &&
|
|
386
|
+
return commands.some(cmd => cmd.name === arg) &&
|
|
387
|
+
(!READS_EVERY_COMMAND.has(arg) || (arg === 'manifest' && storedManifest() != null))
|
|
382
388
|
? new Set([arg])
|
|
383
389
|
: null;
|
|
384
390
|
}
|
|
@@ -36,6 +36,9 @@
|
|
|
36
36
|
* @position consumed by the bare `astryx --json` action and the `manifest` command
|
|
37
37
|
*/
|
|
38
38
|
|
|
39
|
+
import * as fs from 'node:fs';
|
|
40
|
+
import * as path from 'node:path';
|
|
41
|
+
import {fileURLToPath} from 'node:url';
|
|
39
42
|
import {API_VERSION} from '../../../foundation/response/json.mjs';
|
|
40
43
|
import {commandDocsOf} from './define-command.mjs';
|
|
41
44
|
import {doc as manifestDoc} from '../commands/manifest.doc.mjs';
|
|
@@ -63,6 +66,10 @@ const CLI_LAYER_RESPONSE_TYPES = {
|
|
|
63
66
|
manifest: ['manifest'],
|
|
64
67
|
'theme build': ['theme.build.batch'],
|
|
65
68
|
'theme add': ['theme.list'],
|
|
69
|
+
// The experimental theme groups answer a bare --json with their help.
|
|
70
|
+
'experimental theme': ['help'],
|
|
71
|
+
'experimental theme editor': ['help'],
|
|
72
|
+
'experimental theme preview': ['help'],
|
|
66
73
|
};
|
|
67
74
|
|
|
68
75
|
/**
|
|
@@ -253,6 +260,36 @@ function flattenCommands(commands) {
|
|
|
253
260
|
return commands.flatMap(c => [c, ...flattenCommands(c.subcommands || [])]);
|
|
254
261
|
}
|
|
255
262
|
|
|
263
|
+
/**
|
|
264
|
+
* Where the published package keeps its manifest: the `data` of `astryx
|
|
265
|
+
* manifest --json` as the fully loaded CLI builds it. `prepack` writes it
|
|
266
|
+
* (scripts/generate-manifest.mjs), so the published `manifest` needs no other
|
|
267
|
+
* command loaded. A checkout has none and builds it.
|
|
268
|
+
*/
|
|
269
|
+
export const MANIFEST_FILE = path.join(
|
|
270
|
+
path.dirname(fileURLToPath(import.meta.url)),
|
|
271
|
+
'..',
|
|
272
|
+
'manifest.generated.json',
|
|
273
|
+
);
|
|
274
|
+
|
|
275
|
+
/** @type {import('./manifest').CLIManifest | null | undefined} */
|
|
276
|
+
let storedManifestData;
|
|
277
|
+
|
|
278
|
+
/**
|
|
279
|
+
* The stored manifest, or null when there is none or it cannot be read.
|
|
280
|
+
* @returns {import('./manifest').CLIManifest | null}
|
|
281
|
+
*/
|
|
282
|
+
export function storedManifest() {
|
|
283
|
+
if (storedManifestData === undefined) {
|
|
284
|
+
try {
|
|
285
|
+
storedManifestData = JSON.parse(fs.readFileSync(MANIFEST_FILE, 'utf-8'));
|
|
286
|
+
} catch {
|
|
287
|
+
storedManifestData = null;
|
|
288
|
+
}
|
|
289
|
+
}
|
|
290
|
+
return storedManifestData ?? null;
|
|
291
|
+
}
|
|
292
|
+
|
|
256
293
|
/**
|
|
257
294
|
* Build the full capability manifest from a configured Commander program.
|
|
258
295
|
*
|
|
@@ -20,7 +20,6 @@
|
|
|
20
20
|
import * as fs from 'node:fs';
|
|
21
21
|
import * as path from 'node:path';
|
|
22
22
|
import {createRequire} from 'node:module';
|
|
23
|
-
import {resolveRecordedTheme} from '../../../api/theme/theme.mjs';
|
|
24
23
|
|
|
25
24
|
const legacyRequire = createRequire(import.meta.url);
|
|
26
25
|
|
|
@@ -108,6 +107,8 @@ function resolvedThemeData(mod, specifier) {
|
|
|
108
107
|
* @returns {Promise<{variants?: Record<string, string[]>|null, fonts?: Record<string, string>|null, name?: string|null}|null>}
|
|
109
108
|
*/
|
|
110
109
|
export async function resolveTheme(cwd = process.cwd()) {
|
|
110
|
+
// The theme API loads on first use: a command's JSON output never needs it.
|
|
111
|
+
const {resolveRecordedTheme} = await import('../../../api/theme/theme.mjs');
|
|
111
112
|
const loaded = await resolveRecordedTheme(cwd);
|
|
112
113
|
if (loaded.configured) {
|
|
113
114
|
if (!loaded.module) {
|