@astryxdesign/cli 0.7.15 → 0.7.16-canary.g9b5ad42
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 +5 -3
- package/api/doctor/_adapter.d.mts +17 -0
- package/api/doctor/_adapter.mjs +35 -0
- package/api/doctor/doctor.mjs +18 -4
- package/api/integration/validate-integration.mjs +1 -1
- package/api/theme/_adapter.d.mts +5 -2
- package/api/theme/_adapter.mjs +43 -12
- package/api/theme/build/build.d.mts +1 -21
- package/api/theme/build/build.mjs +149 -37
- package/api/theme/eject/eject.mjs +22 -1
- package/api/theme/template/template.d.mts +2 -0
- package/api/theme/template/template.mjs +41 -12
- package/api/theme/theme.type.d.mts +4 -0
- package/api/theme/theme.type.mjs +2 -1
- package/api/theme/themeBuild.doc.mjs +3 -3
- package/api/theme/themeEject.doc.mjs +1 -1
- package/api/theme/themeTemplate.doc.mjs +9 -3
- package/api/theme-edit/_adapter.d.mts +10 -0
- package/api/theme-edit/_adapter.mjs +76 -5
- package/api/theme-edit/_check.mjs +181 -50
- package/api/theme-edit/_color.d.mts +2 -8
- package/api/theme-edit/_color.mjs +126 -55
- package/api/theme-edit/_compiler.d.mts +1 -0
- package/api/theme-edit/_compiler.mjs +3 -0
- package/api/theme-edit/_context.d.mts +7 -0
- package/api/theme-edit/_context.mjs +34 -1
- package/api/theme-edit/_css.d.mts +21 -1
- package/api/theme-edit/_css.mjs +172 -13
- package/api/theme-edit/_edit.d.mts +9 -0
- package/api/theme-edit/_edit.mjs +377 -48
- package/api/theme-edit/_how-commands.d.mts +7 -26
- package/api/theme-edit/_how-commands.mjs +27 -1
- package/api/theme-edit/_how-question.mjs +330 -12
- package/api/theme-edit/_how.mjs +68 -26
- package/api/theme-edit/_palette.mjs +10 -0
- package/api/theme-edit/_parts.d.mts +16 -0
- package/api/theme-edit/_parts.mjs +49 -1
- package/api/theme-edit/_preview-app.mjs +176 -9
- package/api/theme-edit/_preview.mjs +7 -3
- package/api/theme-edit/_project.d.mts +11 -0
- package/api/theme-edit/_project.mjs +35 -9
- package/api/theme-edit/_settings.d.mts +46 -5
- package/api/theme-edit/_settings.mjs +217 -25
- package/api/theme-edit/theme-edit.type.d.mts +2 -1
- package/api/theme-edit/theme-edit.type.mjs +1 -1
- package/api/theme-edit/themeEditNew.doc.mjs +1 -1
- package/api/theme-edit/themeEditShow.doc.mjs +1 -1
- package/assets/docs/tree/tokens-and-setup.doc.mjs +39 -3
- package/assets/docs.generated.json +2 -2
- package/assets/preview-app/next.config.mjs +7 -1
- package/assets/self-audit.generated.json +1 -1
- package/assets/templates/blocks/components/Table/ColumnsVirtualizationHookUsage.doc.mjs +14 -0
- package/assets/templates/blocks/components/Table/ColumnsVirtualizationHookUsage.tsx +53 -0
- package/assets/templates/blocks/components/Table/InfiniteScrollHookUsage.doc.mjs +14 -0
- package/assets/templates/blocks/components/Table/InfiniteScrollHookUsage.tsx +33 -0
- package/assets/templates/components.generated.json +1 -1
- package/clients/cli/build-id.generated.json +1 -1
- package/clients/cli/commands/doctor.doc.mjs +2 -2
- package/clients/cli/commands/experimental/theme.mjs +113 -34
- package/clients/cli/commands/experimental-theme-compile.doc.mjs +1 -1
- package/clients/cli/commands/experimental-theme-editor-new.doc.mjs +1 -1
- package/clients/cli/commands/experimental-theme-editor-show.doc.mjs +1 -1
- package/clients/cli/commands/experimental-theme-editor.doc.mjs +1 -1
- package/clients/cli/commands/experimental-theme-eject.doc.mjs +1 -1
- package/clients/cli/commands/experimental-theme-template.doc.mjs +1 -1
- package/clients/cli/commands/theme-build.doc.mjs +2 -2
- package/clients/cli/commands/theme-eject.doc.mjs +1 -1
- package/clients/cli/commands/theme-template.doc.mjs +3 -1
- package/clients/cli/commands/theme.mjs +85 -5
- package/clients/cli/manifest.generated.json +1 -1
- package/foundation/config/project.mjs +50 -14
- package/foundation/fs/gather-cache.d.mts +9 -2
- package/foundation/fs/gather-cache.mjs +36 -10
- package/foundation/fs/paths.d.mts +16 -0
- package/foundation/fs/paths.mjs +25 -0
- package/foundation/response/error-codes.d.mts +2 -1
- package/foundation/response/error-codes.d.ts +1 -0
- package/foundation/response/error-codes.doc.mjs +5 -0
- package/foundation/response/error-codes.mjs +3 -0
- package/foundation/response/response-types.doc.mjs +1 -1
- package/package.json +7 -6
|
@@ -1 +1 @@
|
|
|
1
|
-
{"id":"
|
|
1
|
+
{"id":"84dd25bb7eabfd4de876c35eee92d89cd8fb9f80082a29f37a7915cb9faa66b9"}
|
|
@@ -15,10 +15,10 @@ export const doc = {
|
|
|
15
15
|
namespace: 'cli/commands',
|
|
16
16
|
summary: 'Diagnose Astryx projects and integration packages',
|
|
17
17
|
description:
|
|
18
|
-
'Runs
|
|
18
|
+
'Runs project health diagnostics by default: Node version, @astryxdesign/core ' +
|
|
19
19
|
'install and version alignment, theme packages, generated app themes when present, earlier copied-theme migration, config, integrations (every one astryx.config names must load, linked without a config entry, ' +
|
|
20
20
|
'provider identity, contribution issues), agent docs, core peer dependencies, package manager, ' +
|
|
21
|
-
"the docs the CLI reads, the newest release the computer knows of, with the install and upgrade commands when the project's release is older, and every `astryx` command on the search path, warning when the first one is not the Astryx CLI or predates the hand-off.
|
|
21
|
+
"the docs the CLI reads, the newest release the computer knows of, with the install and upgrade commands when the project's release is older, and every `astryx` command on the search path, warning when the first one is not the Astryx CLI or predates the hand-off. Loading astryx.config runs that file's code. " +
|
|
22
22
|
'The `integration` subcommands provide authoring checks for one integration package. ' +
|
|
23
23
|
'Outside a project it checks the computer instead: the Node version, the release that answered, ' +
|
|
24
24
|
"the newest release this computer knows of, with the command that upgrades the CLI installed for the computer when it is older, the astryx commands on the search path, the integrations installed for the computer (warning about one it skips), and whether the computer-level agent text (`{@command init --user}`) is present, matches this release, was edited, or is turned off (info only); when that text names `astryx` and no `astryx` command is on the search path, apart from a package runner's own copy, it says so and names the install step the text records, or npm's when it records none. " +
|
|
@@ -45,9 +45,12 @@ import {
|
|
|
45
45
|
} from '../../../../api/theme-edit/theme-edit.mjs';
|
|
46
46
|
import {
|
|
47
47
|
builtInThemes,
|
|
48
|
+
dialValueFits,
|
|
49
|
+
newFlagList,
|
|
48
50
|
editorCompileProblem,
|
|
49
51
|
editorThemeHold,
|
|
50
52
|
editorThemeRefusal,
|
|
53
|
+
showSections,
|
|
51
54
|
} from '../../../../api/theme-edit/_adapter.mjs';
|
|
52
55
|
import {registerThemeSubcommands} from '../theme.mjs';
|
|
53
56
|
import {doc as groupDoc} from '../experimental-theme.doc.mjs';
|
|
@@ -348,29 +351,84 @@ const changeOptions = o => ({
|
|
|
348
351
|
* @param {any} o
|
|
349
352
|
* @returns {Record<string, string | string[]>}
|
|
350
353
|
*/
|
|
351
|
-
function newSettings(o) {
|
|
354
|
+
function newSettings(o, themeName = '<theme>') {
|
|
352
355
|
/** @type {Record<string, string | string[]>} */
|
|
353
356
|
const out = {};
|
|
357
|
+
// --like given two values is refused like a dial given two.
|
|
358
|
+
const likes = flagValues('like');
|
|
359
|
+
if (new Set(likes).size > 1) {
|
|
360
|
+
// The suggestion keeps the first built-in theme given, or drops --like.
|
|
361
|
+
const like = likes
|
|
362
|
+
.map(l => l.toLowerCase())
|
|
363
|
+
.find(l => builtInThemes().includes(l));
|
|
364
|
+
throw new AstryxError(
|
|
365
|
+
`--like was given twice (${likes.join(', ')}); give it once. Nothing was changed.`,
|
|
366
|
+
[
|
|
367
|
+
{
|
|
368
|
+
name: cmd(`${EDITOR} new ${themeName}${newFlagLine({...o, like})}`),
|
|
369
|
+
reason: like
|
|
370
|
+
? 'do this instead: the first built-in theme given'
|
|
371
|
+
: 'do this instead: none of them is a built-in theme',
|
|
372
|
+
},
|
|
373
|
+
],
|
|
374
|
+
ERROR_CODES.ERR_INVALID_ARGUMENT,
|
|
375
|
+
);
|
|
376
|
+
}
|
|
354
377
|
for (const opt of newDoc.options ?? []) {
|
|
355
378
|
if (opt.param !== 'options.settings') continue;
|
|
356
|
-
const
|
|
357
|
-
const
|
|
379
|
+
const flag = opt.flag.split(' ')[0].slice(2);
|
|
380
|
+
const key = flag.replace(/-([a-z])/g, (_, c) => c.toUpperCase());
|
|
381
|
+
const value = o[key];
|
|
358
382
|
if (value == null) continue;
|
|
359
383
|
// A flag given twice: headings takes one value per axis (a weight and a
|
|
360
384
|
// tracking); any other flag given two different values is refused.
|
|
361
|
-
const all = flagValues(
|
|
362
|
-
if (
|
|
363
|
-
else if (new Set(all).size > 1)
|
|
385
|
+
const all = flagValues(flag);
|
|
386
|
+
if (flag === 'headings' && all.length > 1) out[flag] = all;
|
|
387
|
+
else if (new Set(all).size > 1) {
|
|
388
|
+
// The suggestion keeps the first value the dial takes, or drops it.
|
|
389
|
+
const fits = all.find(v => dialValueFits(flag, v));
|
|
364
390
|
throw new AstryxError(
|
|
365
|
-
`--${
|
|
366
|
-
[
|
|
391
|
+
`--${flag} was given twice (${all.join(', ')}); give it once. Nothing was changed.`,
|
|
392
|
+
[
|
|
393
|
+
{
|
|
394
|
+
name: cmd(
|
|
395
|
+
`${EDITOR} new ${themeName}${newFlagLine({...o, [key]: fits})}`,
|
|
396
|
+
),
|
|
397
|
+
reason: fits
|
|
398
|
+
? 'do this instead: the first value it takes'
|
|
399
|
+
: `do this instead: none of them is a value --${flag} takes`,
|
|
400
|
+
},
|
|
401
|
+
],
|
|
367
402
|
ERROR_CODES.ERR_INVALID_ARGUMENT,
|
|
368
403
|
);
|
|
369
|
-
else out[
|
|
404
|
+
} else out[flag] = String(value);
|
|
370
405
|
}
|
|
371
406
|
return out;
|
|
372
407
|
}
|
|
373
408
|
|
|
409
|
+
/**
|
|
410
|
+
* The options a `new` was given, as flags for a suggested command, so a
|
|
411
|
+
* corrected command makes the theme that was asked for.
|
|
412
|
+
* @param {any} o
|
|
413
|
+
* @returns {string}
|
|
414
|
+
*/
|
|
415
|
+
function newFlagLine(o) {
|
|
416
|
+
/** @type {Record<string, string | string[]>} */
|
|
417
|
+
const settings = {};
|
|
418
|
+
for (const opt of newDoc.options ?? []) {
|
|
419
|
+
if (opt.param !== 'options.settings') continue;
|
|
420
|
+
const flag = opt.flag.split(' ')[0].slice(2);
|
|
421
|
+
const value = o[flag.replace(/-([a-z])/g, (_, c) => c.toUpperCase())];
|
|
422
|
+
if (value != null) settings[flag] = value;
|
|
423
|
+
}
|
|
424
|
+
const parts = newFlagList(
|
|
425
|
+
o.like == null ? undefined : String(o.like),
|
|
426
|
+
settings,
|
|
427
|
+
Boolean(o.png),
|
|
428
|
+
);
|
|
429
|
+
return parts.length ? ` ${parts.join(' ')}` : '';
|
|
430
|
+
}
|
|
431
|
+
|
|
374
432
|
/**
|
|
375
433
|
* Every value one flag was given on the command line, in order.
|
|
376
434
|
* @param {string} name
|
|
@@ -720,36 +778,51 @@ export function registerExperimentalTheme(group, program) {
|
|
|
720
778
|
() => {
|
|
721
779
|
// A word after the name is never dropped without a word.
|
|
722
780
|
const extra = (cmd?.args ?? []).slice(1);
|
|
723
|
-
if (extra.length)
|
|
781
|
+
if (extra.length) {
|
|
782
|
+
// Words after `--` that are `--<option> <value>` pairs new
|
|
783
|
+
// takes become options; the other words were most likely
|
|
784
|
+
// part of the name. The options given stay in the suggestion.
|
|
785
|
+
/** @type {Record<string, unknown>} */
|
|
786
|
+
const given = {...o};
|
|
787
|
+
/** @type {string[]} */
|
|
788
|
+
const words = [];
|
|
789
|
+
for (let i = 0; i < extra.length; i++) {
|
|
790
|
+
const w = String(extra[i]);
|
|
791
|
+
if (w.startsWith('--')) {
|
|
792
|
+
const key = w
|
|
793
|
+
.slice(2)
|
|
794
|
+
.replace(/-([a-z])/g, (_, c) => c.toUpperCase());
|
|
795
|
+
if (extra[i + 1] != null && given[key] == null)
|
|
796
|
+
given[key] = extra[++i];
|
|
797
|
+
continue;
|
|
798
|
+
}
|
|
799
|
+
words.push(w);
|
|
800
|
+
}
|
|
801
|
+
const builtIn =
|
|
802
|
+
words.length && builtInThemes().includes(words[0]);
|
|
803
|
+
if (builtIn && given.like == null) given.like = words[0];
|
|
804
|
+
const fixed = builtIn
|
|
805
|
+
? name
|
|
806
|
+
: [name, ...words]
|
|
807
|
+
.join('-')
|
|
808
|
+
.toLowerCase()
|
|
809
|
+
.replace(/[^a-z0-9-]+/g, '-');
|
|
724
810
|
throw new AstryxError(
|
|
725
811
|
`new takes one theme name; "${extra.join(' ')}" is extra. For a base theme, use --like. Nothing was changed.`,
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
reason: 'do this instead',
|
|
733
|
-
},
|
|
734
|
-
]
|
|
735
|
-
: [
|
|
736
|
-
{
|
|
737
|
-
name: `${EDITOR} new ${quoteCommandArgument(
|
|
738
|
-
[name, ...extra]
|
|
739
|
-
.join('-')
|
|
740
|
-
.toLowerCase()
|
|
741
|
-
.replace(/[^a-z0-9-]+/g, '-'),
|
|
742
|
-
)}`,
|
|
743
|
-
reason: 'do this instead',
|
|
744
|
-
},
|
|
745
|
-
],
|
|
812
|
+
[
|
|
813
|
+
{
|
|
814
|
+
name: `${EDITOR} new ${quoteCommandArgument(fixed)}${newFlagLine(given)}`,
|
|
815
|
+
reason: 'do this instead',
|
|
816
|
+
},
|
|
817
|
+
],
|
|
746
818
|
ERROR_CODES.ERR_INVALID_ARGUMENT,
|
|
747
819
|
);
|
|
820
|
+
}
|
|
748
821
|
return themeEditNew(name, {
|
|
749
822
|
cwd: process.cwd(),
|
|
750
823
|
like: o.like,
|
|
751
824
|
png: o.png ?? false,
|
|
752
|
-
settings: newSettings(o),
|
|
825
|
+
settings: newSettings(o, name),
|
|
753
826
|
});
|
|
754
827
|
},
|
|
755
828
|
r => [
|
|
@@ -799,7 +872,11 @@ export function registerExperimentalTheme(group, program) {
|
|
|
799
872
|
{
|
|
800
873
|
suggestions: [
|
|
801
874
|
{
|
|
802
|
-
|
|
875
|
+
// The first section given that `show` takes, else the
|
|
876
|
+
// whole sheet.
|
|
877
|
+
name: cmd(
|
|
878
|
+
`${EDITOR} show ${name}${(sec => (sec ? ` --section ${sec}` : ''))(flagValues('section').find(v => showSections().includes(v)))}`,
|
|
879
|
+
),
|
|
803
880
|
reason: 'do this instead',
|
|
804
881
|
},
|
|
805
882
|
],
|
|
@@ -1025,14 +1102,16 @@ export function registerExperimentalTheme(group, program) {
|
|
|
1025
1102
|
);
|
|
1026
1103
|
if (themeFlags.length > 1)
|
|
1027
1104
|
return cliError('--theme is given twice; give it once.', {
|
|
1028
|
-
suggestions: [
|
|
1105
|
+
suggestions: [
|
|
1106
|
+
{name: cmd(`${HOW} --help`), reason: 'give --theme once'},
|
|
1107
|
+
],
|
|
1029
1108
|
code: ERROR_CODES.ERR_INVALID_ARGUMENT,
|
|
1030
1109
|
});
|
|
1031
1110
|
if (listFlags.length > 1)
|
|
1032
1111
|
return cliError('--list is given twice; give it once.', {
|
|
1033
1112
|
suggestions: [
|
|
1034
1113
|
{
|
|
1035
|
-
name: `${HOW} --list tokens accent
|
|
1114
|
+
name: cmd(`${HOW} --list tokens accent`),
|
|
1036
1115
|
reason: 'one list, then the filter',
|
|
1037
1116
|
},
|
|
1038
1117
|
],
|
|
@@ -89,7 +89,7 @@ export const doc = {
|
|
|
89
89
|
},
|
|
90
90
|
{
|
|
91
91
|
code: 1,
|
|
92
|
-
when: 'a build or validation error (an error envelope), or --check finds stale or missing outputs (the check result, with upToDate false
|
|
92
|
+
when: 'a build or validation error (an error envelope), or --check finds stale or missing outputs (the check result, with upToDate false, the stale files and code ERR_THEME_STALE, is still printed: it is a result, not an error). One exception: an editor theme whose settings changed after its build is refused (ERR_THEME_INVALID, an error envelope) before any file is checked, with `editor show <theme>` to build it again',
|
|
93
93
|
},
|
|
94
94
|
],
|
|
95
95
|
related: ['experimental theme add', 'experimental theme list'],
|
|
@@ -11,7 +11,7 @@ export const doc = {
|
|
|
11
11
|
stability: 'experimental',
|
|
12
12
|
summary: 'Start a theme in themes/<theme>/, optionally on a built-in theme',
|
|
13
13
|
description:
|
|
14
|
-
'Makes themes/<theme>/ with <theme>.settings.json (the settings this command owns), the generated <theme>.settings.ts, <theme>.theme.ts (which extends it and is yours), and the built <theme>.css and <theme>.js (
|
|
14
|
+
'Makes themes/<theme>/ with <theme>.settings.json (the settings this command owns), the generated <theme>.settings.ts, <theme>.theme.ts (which extends it and is yours), and the built <theme>.css and <theme>.js (build them again with `astryx experimental theme compile themes/<theme>/<theme>.theme.ts`, which checks the editor settings first), then writes preview.html, the sample app page with the theme. --like builds on a built-in theme (neutral, stone, matcha, y2k, gothic, chocolate, butter; its package must be installed); without it, or with --like none, the theme starts from Astryx defaults. Any `set` dial can be a flag too (--accent "#7c3aed" --font inter --corners round --vibrancy 60 ...): the same names, values and checks as `set`, all applied in the one build, with one result that lists them. Change the base later with `astryx experimental theme editor set <theme> base <theme|none>`. Afterwards, <theme>.theme.ts is yours: it extends the generated <theme>.settings.ts, and every later change rewrites only the settings files, so your own edits in <theme>.theme.ts survive. A theme name is lowercase letters, digits and dashes, starts with a letter, has 64 characters at most, and is not the name of a built-in theme or a name Windows reserves for a device (con, prn, aux, nul, com1-com9, lpt1-lpt9). Experimental: it may change or be removed in a patch release.',
|
|
15
15
|
fn: 'themeEditNew',
|
|
16
16
|
args: [
|
|
17
17
|
{
|
|
@@ -12,7 +12,7 @@ export const doc = {
|
|
|
12
12
|
summary:
|
|
13
13
|
'Every setting, key values, problems the theme caused, and the theme-building page with every component',
|
|
14
14
|
description:
|
|
15
|
-
'Lists every setting with where it applies and its source (dial, token or property), the resolved value of key tokens in each mode, the colors (the vibrancy; each color with its seed and the shade each token uses in light and dark, marked when an exact token setting wins; any shade moved so text reads), contrast problems this theme caused versus its base, font notes, and last the generated color files. Writes two self-contained HTML files: preview.html (the sample app page) and sheet.html (the theme-building page: every component grouped, each variant side by side, overlays open, and real template pages, with an auto/light/dark switch). A theme with no build is built first, and an in-app preview (`preview add`) of the theme has its route and Colors page rewritten. --section limits the sheet to one section. Experimental: it may change or be removed in a patch release.',
|
|
15
|
+
'Lists every setting with where it applies and its source (dial, token or property), the resolved value of key tokens in each mode, the colors (the vibrancy; each color with its seed and the shade each token uses in light and dark, marked when an exact token setting wins; any shade moved so text reads), contrast problems this theme caused versus its base, font notes, and last the generated color files. Writes two self-contained HTML files: preview.html (the sample app page) and sheet.html (the theme-building page: every component grouped, each variant side by side, overlays open, and real template pages, with an auto/light/dark switch). A theme with no build is built first, and an in-app preview (`preview add`) of the theme has its route and Colors page rewritten. --section limits the sheet to one section. An own change to <theme>.theme.ts since the last build is built first, and the colors mark where it wins over a generated shade; a theme source that no longer builds, or a token in it that is not text, is refused (ERR_THEME_INVALID, exit 1) and the folder stays as it was. Experimental: it may change or be removed in a patch release.',
|
|
16
16
|
fn: 'themeEditShow',
|
|
17
17
|
args: [
|
|
18
18
|
{
|
|
@@ -15,7 +15,7 @@ export const doc = {
|
|
|
15
15
|
summary:
|
|
16
16
|
'Make and change a theme one checked change at a time (dials, tokens, part styles), with previews',
|
|
17
17
|
description:
|
|
18
|
-
"A type-safe compiler for themes. A theme lives in themes/<theme>/: <theme>.settings.json holds the checked settings and is owned by this command; <theme>.settings.ts is generated from it on every change; <theme>.theme.ts extends it, is written once and is yours to edit; <theme>.css and <theme>.js are built from it
|
|
18
|
+
"A type-safe compiler for themes. A theme lives in themes/<theme>/: <theme>.settings.json holds the checked settings and is owned by this command; <theme>.settings.ts is generated from it on every change; <theme>.theme.ts extends it, is written once and is yours to edit; <theme>.css and <theme>.js are built from it; build them again with `astryx experimental theme compile themes/<theme>/<theme>.theme.ts`, which checks the editor's settings first. Every change is CHECKED against what the installed Core's components really read (derived from Core itself, version for version, and cached under node_modules/.cache/) and against the token's type; a change that cannot take effect is refused, nothing is written, and the error leads with the command that works. The thing you set is a dial (a big move with named rungs: corners, spacing, font, headings, text-size, base, mode; or a color: accent, neutral, success, warning, danger, info, each generating its light and dark shades from one color for the color tokens, and vibrancy, how saturated they are), a design token by name, or a CSS property on a part. Where it applies: --on <part|group>, --when <prop>:<value>, --state <state>, --mode light|dark, --only. Every accepted change rebuilds and writes preview.html (the sample app page); `show` adds the theme-building page with every component. PNG pictures only with --png. Commands on one theme run one after the other, through a lock in node_modules/.cache/astryx-theme/ of the project; when node_modules cannot be written (a read-only install), changes are refused and `show` still reads the last build. `how` answers everything else: what a part, group, setting or aspect does, how the colors are made, plain-words questions (with exact commands), a picture's colors, and lists of what you can set. Experimental: it may change or be removed in a patch release.",
|
|
19
19
|
subcommands: ['new', 'set', 'undo', 'show', 'how'],
|
|
20
20
|
examples: [
|
|
21
21
|
{
|
|
@@ -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. 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.",
|
|
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. A subfolder of a folder the theme editor made is written, and the CLI warns; to keep the editor folder to its own theme, fork into the default folder or a path outside it. 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
|
{
|
|
@@ -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. 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`).',
|
|
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`). A path is read from the current folder and must stay inside the project root (the nearest folder with a package.json); with no path it writes at the project root. Outside a project (no package.json in the folder or above it) it writes in the current folder and warns; run it inside a project, or run `npm init -y` in the folder first, to write it at a project root.',
|
|
18
18
|
fn: 'themeTemplate',
|
|
19
19
|
args: [
|
|
20
20
|
{
|
|
@@ -41,7 +41,7 @@ export const doc = {
|
|
|
41
41
|
flag: '-o, --out <path>',
|
|
42
42
|
param: 'options.out',
|
|
43
43
|
description:
|
|
44
|
-
'Output CSS file path, relative or absolute; the .js and .d.ts are written beside it (default: <theme name>.css next to the source). A folder, or a path ending in /, writes <theme name>.css into it. The path should end in .css; another name still builds, with a warning. A build never replaces the theme source (ERR_THEME_INVALID). At a path --out names, it replaces its own earlier outputs, and the output of another theme source with a warning that names both sources; any other existing file fails with ERR_FILE_EXISTS and nothing is written. A build writes only inside the working directory, the defaults beside the source too (ERR_PATH_TRAVERSAL); --check writes nothing, so it compares outputs anywhere and refuses only a relative path that escapes the working directory. Single theme only: refused with more than one file or with --family (ERR_THEME_INVALID)',
|
|
44
|
+
'Output CSS file path, relative or absolute; the .js and .d.ts are written beside it (default: <theme name>.css next to the source). A folder, or a path ending in /, writes <theme name>.css into it. The path should end in .css; another name still builds, with a warning. A build never replaces the theme source (ERR_THEME_INVALID). At a path --out names, it replaces its own earlier outputs, and the output of another theme source with a warning that names both sources; any other existing file fails with ERR_FILE_EXISTS and nothing is written. Into a folder the theme editor made (folder <slug>/ holds <slug>.settings.json), a source outside that folder builds there too, with a warning; to keep the editor folder to its own theme, build beside the source, or pass an --out outside it. A build writes only inside the working directory, the defaults beside the source too (ERR_PATH_TRAVERSAL); --check writes nothing, so it compares outputs anywhere and refuses only a relative path that escapes the working directory. Single theme only: refused with more than one file or with --family (ERR_THEME_INVALID)',
|
|
45
45
|
},
|
|
46
46
|
{
|
|
47
47
|
flag: '--icons-specifier <specifier>',
|
|
@@ -91,7 +91,7 @@ export const doc = {
|
|
|
91
91
|
},
|
|
92
92
|
{
|
|
93
93
|
code: 1,
|
|
94
|
-
when: 'a build or validation error, or --check finds stale or missing outputs',
|
|
94
|
+
when: 'a build or validation error (an error envelope), or --check finds stale or missing outputs (the check result, with upToDate false, the stale files and code ERR_THEME_STALE)',
|
|
95
95
|
},
|
|
96
96
|
],
|
|
97
97
|
related: ['theme add', 'theme list'],
|
|
@@ -10,7 +10,7 @@ export const doc = {
|
|
|
10
10
|
namespace: 'cli/commands',
|
|
11
11
|
summary: 'Fork a theme as editable local source',
|
|
12
12
|
description:
|
|
13
|
-
"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.",
|
|
13
|
+
"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. A subfolder of a folder the theme editor made is written, and the CLI warns; to keep the editor folder to its own theme, fork into the default folder or a path outside it. When the fork imports packages the app lacks, the result names them with an install command. Use --package when package themes share a slug.",
|
|
14
14
|
fn: 'themeEject',
|
|
15
15
|
args: [
|
|
16
16
|
{name: 'slug', param: 'slug', required: true},
|
|
@@ -21,7 +21,9 @@ export const doc = {
|
|
|
21
21
|
'consumed, naming the CLI command that prints the authoritative reference for each. Read ' +
|
|
22
22
|
'it, copy what you need into your own theme file, delete it. Use `theme add <slug>` to ' +
|
|
23
23
|
'use an installed built theme, extend that theme for ordinary customization, or use ' +
|
|
24
|
-
'`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`).'
|
|
24
|
+
'`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`).' +
|
|
25
|
+
' A path is read from the current folder and must stay inside the project root (the nearest folder with a package.json); with no path it writes at the project root.' +
|
|
26
|
+
' Outside a project (no package.json in the folder or above it) it writes in the current folder and warns; run it inside a project, or run `npm init -y` in the folder first, to write it at a project root.',
|
|
25
27
|
fn: 'themeTemplate',
|
|
26
28
|
args: [{name: 'path', param: 'options.targetPath', required: false}],
|
|
27
29
|
options: [
|
|
@@ -57,7 +57,11 @@ import {themeAdd} from '../../../api/theme/add/add.mjs';
|
|
|
57
57
|
import {themeRemove} from '../../../api/theme/remove/remove.mjs';
|
|
58
58
|
import {themeUse} from '../../../api/theme/use/use.mjs';
|
|
59
59
|
import {themeEject} from '../../../api/theme/eject/eject.mjs';
|
|
60
|
-
import {
|
|
60
|
+
import {
|
|
61
|
+
OUTSIDE_PROJECT_WARNING,
|
|
62
|
+
themeTemplate,
|
|
63
|
+
} from '../../../api/theme/template/template.mjs';
|
|
64
|
+
import {findPackageRoot} from '../../../foundation/fs/paths.mjs';
|
|
61
65
|
import {
|
|
62
66
|
themeListAvailable,
|
|
63
67
|
themeListCopySources,
|
|
@@ -222,6 +226,20 @@ function themeCommand(words, sub, args = [], reason = '') {
|
|
|
222
226
|
};
|
|
223
227
|
}
|
|
224
228
|
|
|
229
|
+
/**
|
|
230
|
+
* The message type a `theme build` child sends its watcher in place of a
|
|
231
|
+
* warning a build prints once per invocation (the --out editor-folder
|
|
232
|
+
* warning), so a watch session prints it once, not on every rebuild.
|
|
233
|
+
*/
|
|
234
|
+
const WATCH_WARNING = 'astryx.theme.build.warning';
|
|
235
|
+
|
|
236
|
+
/**
|
|
237
|
+
* The `argv0` a watcher starts each `theme build` child with. With the IPC
|
|
238
|
+
* channel it marks the child as the watcher's own, so a CLI run another way
|
|
239
|
+
* with an IPC channel (forked by a tool or test runner) still prints.
|
|
240
|
+
*/
|
|
241
|
+
const WATCH_CHILD_ARGV0 = 'astryx-theme-watch';
|
|
242
|
+
|
|
225
243
|
/**
|
|
226
244
|
* Path to this CLI's real entry (clients/cli/bin/astryx.mjs), resolved from
|
|
227
245
|
* this module's location (clients/cli/commands/theme.mjs → ../bin/
|
|
@@ -244,9 +262,17 @@ function resolveCliBin() {
|
|
|
244
262
|
* @param {(child: import('node:child_process').ChildProcess) => void} [onSpawn] -
|
|
245
263
|
* Receives the child, so a watcher that stops can stop it too.
|
|
246
264
|
* @param {ThemeCommandWords} [words]
|
|
265
|
+
* @param {(message: unknown) => void} [onMessage] - Receives what the child
|
|
266
|
+
* hands over the channel (WATCH_WARNING messages).
|
|
247
267
|
* @returns {Promise<number>}
|
|
248
268
|
*/
|
|
249
|
-
function runThemeBuildOnceChild(
|
|
269
|
+
function runThemeBuildOnceChild(
|
|
270
|
+
file,
|
|
271
|
+
options,
|
|
272
|
+
onSpawn,
|
|
273
|
+
words = THEME_WORDS,
|
|
274
|
+
onMessage,
|
|
275
|
+
) {
|
|
250
276
|
const cliBin = resolveCliBin();
|
|
251
277
|
const command = [...words.group.split(' '), words.build];
|
|
252
278
|
// A detail level the user chose applies to every rebuild.
|
|
@@ -257,10 +283,15 @@ function runThemeBuildOnceChild(file, options, onSpawn, words = THEME_WORDS) {
|
|
|
257
283
|
if (options.iconsSpecifier)
|
|
258
284
|
args.push('--icons-specifier', options.iconsSpecifier);
|
|
259
285
|
return new Promise((/** @type {(code: number) => void} */ resolve) => {
|
|
286
|
+
// The IPC channel and argv0 tell the child it builds for this watcher: it
|
|
287
|
+
// hands its once-per-invocation warnings over the channel instead of
|
|
288
|
+
// printing them.
|
|
260
289
|
const child = spawn(process.execPath, args, {
|
|
261
|
-
|
|
290
|
+
argv0: WATCH_CHILD_ARGV0,
|
|
291
|
+
stdio: ['inherit', 'inherit', 'inherit', 'ipc'],
|
|
262
292
|
env: process.env,
|
|
263
293
|
});
|
|
294
|
+
child.on('message', message => onMessage?.(message));
|
|
264
295
|
onSpawn?.(child);
|
|
265
296
|
child.on('close', code => resolve(code ?? 0));
|
|
266
297
|
child.on('error', () => resolve(1));
|
|
@@ -290,9 +321,28 @@ async function runThemeBuildWatch(entries, options, words = THEME_WORDS) {
|
|
|
290
321
|
.map(e => rel(e.filePath))
|
|
291
322
|
.join(', ')} for changes — press Ctrl-C to stop.`;
|
|
292
323
|
|
|
324
|
+
// A warning a build prints once per invocation is printed at most once
|
|
325
|
+
// per watch session (spec:AST-017 FR29a), not on every rebuild.
|
|
326
|
+
let warned = false;
|
|
327
|
+
// Watch never runs under --json, so the logger prints (cli-surface INV12).
|
|
328
|
+
logger.setSilent(false);
|
|
329
|
+
const onMessage = (/** @type {unknown} */ message) => {
|
|
330
|
+
const m = /** @type {{type?: unknown, text?: unknown}} */ (message);
|
|
331
|
+
if (warned || m?.type !== WATCH_WARNING || typeof m.text !== 'string')
|
|
332
|
+
return;
|
|
333
|
+
warned = true;
|
|
334
|
+
logger.warn(m.text);
|
|
335
|
+
};
|
|
336
|
+
|
|
293
337
|
// Initial build.
|
|
294
338
|
for (const entry of entries) {
|
|
295
|
-
await runThemeBuildOnceChild(
|
|
339
|
+
await runThemeBuildOnceChild(
|
|
340
|
+
entry.file,
|
|
341
|
+
options,
|
|
342
|
+
undefined,
|
|
343
|
+
words,
|
|
344
|
+
onMessage,
|
|
345
|
+
);
|
|
296
346
|
}
|
|
297
347
|
|
|
298
348
|
let building = false;
|
|
@@ -323,6 +373,7 @@ async function runThemeBuildWatch(entries, options, words = THEME_WORDS) {
|
|
|
323
373
|
rebuildChild = child;
|
|
324
374
|
},
|
|
325
375
|
words,
|
|
376
|
+
onMessage,
|
|
326
377
|
);
|
|
327
378
|
rebuildDone = done.then(() => {});
|
|
328
379
|
await done;
|
|
@@ -1074,6 +1125,12 @@ function registerThemeCommands(theme, program, docs, words) {
|
|
|
1074
1125
|
// [ok]/[warn] lines, and the install instructions are all emitted from
|
|
1075
1126
|
// inside themeBuild via the shared logger.
|
|
1076
1127
|
logger.setSilent(json);
|
|
1128
|
+
// Started by a watcher (runThemeBuildWatch): hand the editor-folder
|
|
1129
|
+
// warning to it, and let the channel not keep this build alive.
|
|
1130
|
+
const watchChild =
|
|
1131
|
+
typeof process.send === 'function' &&
|
|
1132
|
+
process.argv0 === WATCH_CHILD_ARGV0;
|
|
1133
|
+
if (watchChild) process.channel?.unref();
|
|
1077
1134
|
let privateVarError = false;
|
|
1078
1135
|
const onPrivateVarError = () => {
|
|
1079
1136
|
privateVarError = true;
|
|
@@ -1102,7 +1159,12 @@ function registerThemeCommands(theme, program, docs, words) {
|
|
|
1102
1159
|
if (json) jsonOut(result);
|
|
1103
1160
|
if (
|
|
1104
1161
|
privateVarError ||
|
|
1105
|
-
(result.type === 'theme.build.check' &&
|
|
1162
|
+
(result.type === 'theme.build.check' &&
|
|
1163
|
+
!(
|
|
1164
|
+
/** @type {import('../../../api/theme/theme.type.mjs').ThemeBuildCheckResponse} */ (
|
|
1165
|
+
result
|
|
1166
|
+
).data.upToDate
|
|
1167
|
+
))
|
|
1106
1168
|
) {
|
|
1107
1169
|
process.exitCode = 1;
|
|
1108
1170
|
}
|
|
@@ -1177,6 +1239,15 @@ function registerThemeCommands(theme, program, docs, words) {
|
|
|
1177
1239
|
__claimedOutputs: claimedOutputs,
|
|
1178
1240
|
__deferredWrites: deferred ? writes : undefined,
|
|
1179
1241
|
__commandWords: words,
|
|
1242
|
+
__onEditorFolder: watchChild
|
|
1243
|
+
? (/** @type {string} */ warning) => {
|
|
1244
|
+
// Held open until the message is out, then let go again.
|
|
1245
|
+
process.channel?.ref();
|
|
1246
|
+
process.send?.({type: WATCH_WARNING, text: warning}, () =>
|
|
1247
|
+
process.channel?.unref(),
|
|
1248
|
+
);
|
|
1249
|
+
}
|
|
1250
|
+
: undefined,
|
|
1180
1251
|
};
|
|
1181
1252
|
let result;
|
|
1182
1253
|
if (report) {
|
|
@@ -1471,6 +1542,9 @@ function registerThemeCommands(theme, program, docs, words) {
|
|
|
1471
1542
|
const json = program.opts().json || false;
|
|
1472
1543
|
/** @type {import('../../../api/theme/theme.type.mjs').ThemeEjectResponse} */
|
|
1473
1544
|
let result;
|
|
1545
|
+
// Eject's warnings go to stderr in text mode; the logger is silent
|
|
1546
|
+
// under --json (cli-surface INV12).
|
|
1547
|
+
logger.setSilent(json);
|
|
1474
1548
|
try {
|
|
1475
1549
|
result = await themeEject(slug, {
|
|
1476
1550
|
targetPath,
|
|
@@ -1521,6 +1595,12 @@ function registerThemeCommands(theme, program, docs, words) {
|
|
|
1521
1595
|
]);
|
|
1522
1596
|
}
|
|
1523
1597
|
|
|
1598
|
+
// Outside a project the template is written here, with one warning
|
|
1599
|
+
// on stderr when a file was written; the logger is silent under --json
|
|
1600
|
+
// (cli-surface INV12).
|
|
1601
|
+
logger.setSilent(json);
|
|
1602
|
+
if (result.data.written && !findPackageRoot(process.cwd()))
|
|
1603
|
+
logger.warn(OUTSIDE_PROJECT_WARNING);
|
|
1524
1604
|
// Writes a starter theme file, or declines to overwrite one.
|
|
1525
1605
|
if (json) {
|
|
1526
1606
|
jsonOut(result);
|