@astryxdesign/cli 0.7.15 → 0.7.16-canary.g54dd64e

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.
Files changed (123) hide show
  1. package/README.md +5 -3
  2. package/api/component/_adapter.d.mts +1 -1
  3. package/api/component/_adapter.mjs +28 -1
  4. package/api/doctor/_adapter.d.mts +17 -0
  5. package/api/doctor/_adapter.mjs +35 -0
  6. package/api/doctor/doctor.mjs +18 -4
  7. package/api/integration/pack-check.mjs +13 -7
  8. package/api/integration/validate-integration.mjs +1 -1
  9. package/api/theme/_adapter.d.mts +5 -2
  10. package/api/theme/_adapter.mjs +43 -12
  11. package/api/theme/build/build.d.mts +64 -27
  12. package/api/theme/build/build.mjs +341 -69
  13. package/api/theme/eject/eject.mjs +22 -1
  14. package/api/theme/template/template.d.mts +19 -0
  15. package/api/theme/template/template.mjs +102 -25
  16. package/api/theme/theme.type.d.mts +5 -1
  17. package/api/theme/theme.type.mjs +2 -1
  18. package/api/theme/themeBuild.doc.mjs +3 -3
  19. package/api/theme/themeEject.doc.mjs +1 -1
  20. package/api/theme/themeTemplate.doc.mjs +9 -3
  21. package/api/theme-edit/_adapter.d.mts +33 -0
  22. package/api/theme-edit/_adapter.mjs +208 -31
  23. package/api/theme-edit/_check.d.mts +38 -0
  24. package/api/theme-edit/_check.mjs +1326 -211
  25. package/api/theme-edit/_color.d.mts +2 -8
  26. package/api/theme-edit/_color.mjs +292 -219
  27. package/api/theme-edit/_compiler.d.mts +1 -0
  28. package/api/theme-edit/_compiler.mjs +20 -1
  29. package/api/theme-edit/_context.d.mts +29 -0
  30. package/api/theme-edit/_context.mjs +329 -30
  31. package/api/theme-edit/_css.d.mts +60 -1
  32. package/api/theme-edit/_css.mjs +404 -28
  33. package/api/theme-edit/_edit.d.mts +9 -0
  34. package/api/theme-edit/_edit.mjs +1025 -126
  35. package/api/theme-edit/_how-commands.d.mts +11 -26
  36. package/api/theme-edit/_how-commands.mjs +30 -2
  37. package/api/theme-edit/_how-question.d.mts +7 -0
  38. package/api/theme-edit/_how-question.mjs +1304 -176
  39. package/api/theme-edit/_how.mjs +144 -30
  40. package/api/theme-edit/_overview.mjs +2 -0
  41. package/api/theme-edit/_palette.d.mts +11 -0
  42. package/api/theme-edit/_palette.mjs +194 -65
  43. package/api/theme-edit/_parts.d.mts +16 -0
  44. package/api/theme-edit/_parts.mjs +59 -7
  45. package/api/theme-edit/_png.mjs +19 -14
  46. package/api/theme-edit/_preview-app.d.mts +3 -0
  47. package/api/theme-edit/_preview-app.mjs +843 -45
  48. package/api/theme-edit/_preview.d.mts +16 -3
  49. package/api/theme-edit/_preview.mjs +310 -29
  50. package/api/theme-edit/_project.d.mts +11 -0
  51. package/api/theme-edit/_project.mjs +46 -12
  52. package/api/theme-edit/_settings.d.mts +178 -5
  53. package/api/theme-edit/_settings.mjs +2035 -86
  54. package/api/theme-edit/_tables.d.mts +24 -0
  55. package/api/theme-edit/_tables.mjs +211 -149
  56. package/api/theme-edit/_vet.d.mts +42 -0
  57. package/api/theme-edit/_vet.mjs +144 -0
  58. package/api/theme-edit/theme-edit.type.d.mts +2 -1
  59. package/api/theme-edit/theme-edit.type.mjs +1 -1
  60. package/api/theme-edit/themeEditNew.doc.mjs +1 -1
  61. package/api/theme-edit/themeEditShow.doc.mjs +11 -3
  62. package/api/upgrade/registry/registry.mjs +6 -1
  63. package/assets/docs/tree/single-component.doc.mjs +11 -2
  64. package/assets/docs/tree/tokens-and-setup.doc.mjs +39 -3
  65. package/assets/docs.generated.json +2 -2
  66. package/assets/preview-app/next.config.mjs +7 -1
  67. package/assets/preview-app/package.json +1 -0
  68. package/assets/preview-app/src/app/globals.css +1 -0
  69. package/assets/self-audit.generated.json +1 -1
  70. package/assets/templates/blocks/components/Table/ColumnsVirtualizationHookUsage.doc.mjs +14 -0
  71. package/assets/templates/blocks/components/Table/ColumnsVirtualizationHookUsage.tsx +53 -0
  72. package/assets/templates/blocks/components/Table/InfiniteScrollHookUsage.doc.mjs +14 -0
  73. package/assets/templates/blocks/components/Table/InfiniteScrollHookUsage.tsx +33 -0
  74. package/assets/templates/components.generated.json +1 -1
  75. package/assets/templates/pages/dashboard/page.tsx +1 -1
  76. package/authoring/doctypes/_schema.d.mts +52 -5
  77. package/authoring/doctypes/_schema.mjs +62 -7
  78. package/authoring/doctypes/base/type.ts +10 -0
  79. package/authoring/doctypes/component/component.doc.mjs +1 -1
  80. package/authoring/doctypes/function/function.doc.mjs +6 -0
  81. package/authoring/doctypes/function/type.ts +3 -0
  82. package/authoring/doctypes/legacy.mjs +5 -1
  83. package/authoring/index.d.ts +1 -0
  84. package/clients/cli/build-id.generated.json +1 -1
  85. package/clients/cli/commands/doctor.doc.mjs +2 -2
  86. package/clients/cli/commands/experimental/theme.mjs +190 -37
  87. package/clients/cli/commands/experimental-theme-compile.doc.mjs +2 -2
  88. package/clients/cli/commands/experimental-theme-editor-new.doc.mjs +1 -1
  89. package/clients/cli/commands/experimental-theme-editor-show.doc.mjs +2 -2
  90. package/clients/cli/commands/experimental-theme-editor-undo.doc.mjs +1 -1
  91. package/clients/cli/commands/experimental-theme-editor.doc.mjs +1 -1
  92. package/clients/cli/commands/experimental-theme-eject.doc.mjs +1 -1
  93. package/clients/cli/commands/experimental-theme-template.doc.mjs +2 -2
  94. package/clients/cli/commands/theme-build.doc.mjs +2 -2
  95. package/clients/cli/commands/theme-eject.doc.mjs +1 -1
  96. package/clients/cli/commands/theme-template.doc.mjs +3 -1
  97. package/clients/cli/commands/theme.mjs +168 -45
  98. package/clients/cli/formatters/index.mjs +7 -4
  99. package/clients/cli/lib/cli-error.mjs +9 -3
  100. package/clients/cli/lib/component-format.mjs +27 -9
  101. package/clients/cli/lib/json-shim.mjs +40 -2
  102. package/clients/cli/manifest.generated.json +1 -1
  103. package/clients/cli/run.mjs +49 -0
  104. package/foundation/config/project.mjs +50 -14
  105. package/foundation/discovery/theme-discovery.d.mts +5 -1
  106. package/foundation/discovery/theme-discovery.mjs +24 -3
  107. package/foundation/fs/gather-cache.d.mts +9 -2
  108. package/foundation/fs/gather-cache.mjs +79 -15
  109. package/foundation/fs/paths.d.mts +31 -0
  110. package/foundation/fs/paths.mjs +43 -10
  111. package/foundation/render/host-exit.d.mts +8 -0
  112. package/foundation/render/host-exit.mjs +11 -0
  113. package/foundation/render/page-host.mjs +56 -10
  114. package/foundation/render/page-worker.mjs +14 -0
  115. package/foundation/render/render-page.mjs +37 -2
  116. package/foundation/response/error-codes.d.mts +2 -1
  117. package/foundation/response/error-codes.d.ts +1 -0
  118. package/foundation/response/error-codes.doc.mjs +5 -0
  119. package/foundation/response/error-codes.mjs +3 -0
  120. package/foundation/response/json.d.mts +15 -0
  121. package/foundation/response/json.mjs +52 -1
  122. package/foundation/response/response-types.doc.mjs +1 -1
  123. package/package.json +7 -6
@@ -45,9 +45,14 @@ 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
+ editorMissingSource,
54
+ editorThemeTemplate,
55
+ showSections,
51
56
  } from '../../../../api/theme-edit/_adapter.mjs';
52
57
  import {registerThemeSubcommands} from '../theme.mjs';
53
58
  import {doc as groupDoc} from '../experimental-theme.doc.mjs';
@@ -99,6 +104,8 @@ const cmd = line => {
99
104
  .map(part => part.split(PREFIX).join(stem))
100
105
  .join(stem);
101
106
  };
107
+ /** The project's invocation of a command line (cmd, under a name an action's own `cmd` parameter does not hide). */
108
+ const cliLine = (/** @type {string} */ line) => cmd(line);
102
109
 
103
110
  /**
104
111
  * Print blocks, a blank line between them, with this project's run prefix
@@ -348,29 +355,110 @@ const changeOptions = o => ({
348
355
  * @param {any} o
349
356
  * @returns {Record<string, string | string[]>}
350
357
  */
351
- function newSettings(o) {
358
+ function newSettings(o, themeName = '<theme>') {
352
359
  /** @type {Record<string, string | string[]>} */
353
360
  const out = {};
361
+ // --like given two values is refused like a dial given two.
362
+ const likes = flagValues('like');
363
+ if (new Set(likes).size > 1) {
364
+ // The suggestion keeps the first built-in theme given, or drops --like.
365
+ const like = likes
366
+ .map(l => l.toLowerCase())
367
+ .find(l => builtInThemes().includes(l));
368
+ throw new AstryxError(
369
+ `--like was given twice (${likes.join(', ')}); give it once. Nothing was changed.`,
370
+ [
371
+ {
372
+ name: cmd(`${EDITOR} new ${themeName}${newFlagLine({...o, like})}`),
373
+ reason: like
374
+ ? 'do this instead: the first built-in theme given'
375
+ : 'do this instead: none of them is a built-in theme',
376
+ },
377
+ ],
378
+ ERROR_CODES.ERR_INVALID_ARGUMENT,
379
+ );
380
+ }
354
381
  for (const opt of newDoc.options ?? []) {
355
382
  if (opt.param !== 'options.settings') continue;
356
- const name = opt.flag.split(' ')[0].slice(2);
357
- const value = o[name.replace(/-([a-z])/g, (_, c) => c.toUpperCase())];
383
+ const flag = opt.flag.split(' ')[0].slice(2);
384
+ const key = flag.replace(/-([a-z])/g, (_, c) => c.toUpperCase());
385
+ const value = o[key];
358
386
  if (value == null) continue;
359
387
  // A flag given twice: headings takes one value per axis (a weight and a
360
388
  // tracking); any other flag given two different values is refused.
361
- const all = flagValues(name);
362
- if (name === 'headings' && all.length > 1) out[name] = all;
363
- else if (new Set(all).size > 1)
389
+ const all = flagValues(flag);
390
+ if (flag === 'headings' && all.length > 1) out[flag] = all;
391
+ else if (new Set(all).size > 1) {
392
+ // The suggestion keeps the first value the dial takes, or drops it.
393
+ const fits = all.find(v => dialValueFits(flag, v));
364
394
  throw new AstryxError(
365
- `--${name} was given twice (${all.join(', ')}); give it once. Nothing was changed.`,
366
- [],
395
+ `--${flag} was given twice (${all.join(', ')}); give it once. Nothing was changed.`,
396
+ [
397
+ {
398
+ name: cmd(
399
+ `${EDITOR} new ${themeName}${newFlagLine({...o, [key]: fits})}`,
400
+ ),
401
+ reason: fits
402
+ ? 'do this instead: the first value it takes'
403
+ : `do this instead: none of them is a value --${flag} takes`,
404
+ },
405
+ ],
367
406
  ERROR_CODES.ERR_INVALID_ARGUMENT,
368
407
  );
369
- else out[name] = String(value);
408
+ } else out[flag] = String(value);
370
409
  }
371
410
  return out;
372
411
  }
373
412
 
413
+ /**
414
+ * The options a `new` was given, as flags for a suggested command, so a
415
+ * corrected command makes the theme that was asked for.
416
+ * @param {any} o
417
+ * @returns {string}
418
+ */
419
+ function newFlagLine(o) {
420
+ /** @type {Record<string, string | string[]>} */
421
+ const settings = {};
422
+ for (const opt of newDoc.options ?? []) {
423
+ if (opt.param !== 'options.settings') continue;
424
+ const flag = opt.flag.split(' ')[0].slice(2);
425
+ const value = o[flag.replace(/-([a-z])/g, (_, c) => c.toUpperCase())];
426
+ if (value != null) settings[flag] = value;
427
+ }
428
+ const parts = newFlagList(
429
+ o.like == null ? undefined : String(o.like),
430
+ settings,
431
+ Boolean(o.png),
432
+ );
433
+ return parts.length ? ` ${parts.join(' ')}` : '';
434
+ }
435
+
436
+ /**
437
+ * Refuse a preview flag given twice with different values: the command
438
+ * would keep only the last one without a word. Undefined when each is
439
+ * given once.
440
+ * @param {string} command the preview subcommand, for the suggestion
441
+ * @param {string[]} flags
442
+ * @returns {undefined}
443
+ */
444
+ function previewFlagsOnce(command, flags) {
445
+ for (const flag of flags) {
446
+ const all = flagValues(flag);
447
+ if (new Set(all).size > 1)
448
+ throw new AstryxError(
449
+ `--${flag} was given twice (${all.join(', ')}); give it once. Nothing was changed.`,
450
+ [
451
+ {
452
+ name: cmd(`${PREFIX} preview ${command} --help`),
453
+ reason: 'every option it takes',
454
+ },
455
+ ],
456
+ ERROR_CODES.ERR_INVALID_ARGUMENT,
457
+ );
458
+ }
459
+ return undefined;
460
+ }
461
+
374
462
  /**
375
463
  * Every value one flag was given on the command line, in order.
376
464
  * @param {string} name
@@ -707,7 +795,7 @@ export function registerExperimentalTheme(group, program) {
707
795
  const editor = defineGroup(theme, editorDoc);
708
796
  explained(editor, editorDoc);
709
797
 
710
- explained(
798
+ const newCli = explained(
711
799
  defineCommand(editor, newDoc, {
712
800
  fn: newFn,
713
801
  action: (
@@ -718,38 +806,80 @@ export function registerExperimentalTheme(group, program) {
718
806
  run(
719
807
  program,
720
808
  () => {
809
+ // An option new does not take (--force, --dry-run, -t) is refused
810
+ // with new's help, as every editor command's unknown option is.
811
+ const takes = new Set(
812
+ (newDoc.options ?? []).flatMap(opt =>
813
+ String(opt.flag)
814
+ .split(/[\s,]+/)
815
+ .filter(w => w.startsWith('-'))
816
+ .map(w => w.replace(/[<[].*$/, '')),
817
+ ),
818
+ );
819
+ const stray = (cmd?.args ?? [])
820
+ .slice(1)
821
+ .map(String)
822
+ .find(
823
+ (/** @type {string} */ w) =>
824
+ /^-/.test(w) && !takes.has(w.split('=')[0]),
825
+ );
826
+ if (stray)
827
+ return cliError(`unknown option '${stray}'.`, {
828
+ suggestions: [
829
+ {
830
+ name: cliLine(`${EDITOR} new --help`),
831
+ reason: 'every option it takes',
832
+ },
833
+ ],
834
+ code: ERROR_CODES.ERR_INVALID_OPTION,
835
+ });
721
836
  // A word after the name is never dropped without a word.
722
837
  const extra = (cmd?.args ?? []).slice(1);
723
- if (extra.length)
838
+ if (extra.length) {
839
+ // Words after `--` that are `--<option> <value>` pairs new
840
+ // takes become options; the other words were most likely
841
+ // part of the name. The options given stay in the suggestion.
842
+ /** @type {Record<string, unknown>} */
843
+ const given = {...o};
844
+ /** @type {string[]} */
845
+ const words = [];
846
+ for (let i = 0; i < extra.length; i++) {
847
+ const w = String(extra[i]);
848
+ if (w.startsWith('--')) {
849
+ const key = w
850
+ .slice(2)
851
+ .replace(/-([a-z])/g, (_, c) => c.toUpperCase());
852
+ if (extra[i + 1] != null && given[key] == null)
853
+ given[key] = extra[++i];
854
+ continue;
855
+ }
856
+ words.push(w);
857
+ }
858
+ const builtIn =
859
+ words.length && builtInThemes().includes(words[0]);
860
+ if (builtIn && given.like == null) given.like = words[0];
861
+ const fixed = builtIn
862
+ ? name
863
+ : [name, ...words]
864
+ .join('-')
865
+ .toLowerCase()
866
+ .replace(/[^a-z0-9-]+/g, '-');
724
867
  throw new AstryxError(
725
868
  `new takes one theme name; "${extra.join(' ')}" is extra. For a base theme, use --like. Nothing was changed.`,
726
- // A built-in theme after the name is the base; other words
727
- // were most likely part of the name.
728
- builtInThemes().includes(extra[0])
729
- ? [
730
- {
731
- name: `${EDITOR} new ${name} --like ${extra[0]}`,
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
- ],
869
+ [
870
+ {
871
+ name: `${EDITOR} new ${quoteCommandArgument(fixed)}${newFlagLine(given)}`,
872
+ reason: 'do this instead',
873
+ },
874
+ ],
746
875
  ERROR_CODES.ERR_INVALID_ARGUMENT,
747
876
  );
877
+ }
748
878
  return themeEditNew(name, {
749
879
  cwd: process.cwd(),
750
880
  like: o.like,
751
881
  png: o.png ?? false,
752
- settings: newSettings(o),
882
+ settings: newSettings(o, name),
753
883
  });
754
884
  },
755
885
  r => [
@@ -761,6 +891,8 @@ export function registerExperimentalTheme(group, program) {
761
891
  }),
762
892
  newDoc,
763
893
  );
894
+ // new refuses an option it does not take itself, naming its help.
895
+ newCli.allowUnknownOption();
764
896
 
765
897
  explained(
766
898
  defineCommand(editor, setDoc, {
@@ -799,7 +931,11 @@ export function registerExperimentalTheme(group, program) {
799
931
  {
800
932
  suggestions: [
801
933
  {
802
- name: `${EDITOR} show ${name} --section ${flagValues('section')[0]}`,
934
+ // The first section given that `show` takes, else the
935
+ // whole sheet.
936
+ name: cmd(
937
+ `${EDITOR} show ${name}${(sec => (sec ? ` --section ${sec}` : ''))(flagValues('section').find(v => showSections().includes(v)))}`,
938
+ ),
803
939
  reason: 'do this instead',
804
940
  },
805
941
  ],
@@ -870,6 +1006,7 @@ export function registerExperimentalTheme(group, program) {
870
1006
  run(
871
1007
  program,
872
1008
  () =>
1009
+ previewFlagsOnce('add', ['theme', 'template', 'top', 'path']) ??
873
1010
  themeEditPreviewAdd([words ?? []].flat().join(' ') || undefined, {
874
1011
  cwd: process.cwd(),
875
1012
  theme: o.theme,
@@ -916,6 +1053,7 @@ export function registerExperimentalTheme(group, program) {
916
1053
  run(
917
1054
  program,
918
1055
  () =>
1056
+ previewFlagsOnce('app', ['theme']) ??
919
1057
  themeEditPreviewApp(dir, {
920
1058
  cwd: process.cwd(),
921
1059
  theme: o.theme,
@@ -954,10 +1092,20 @@ export function registerExperimentalTheme(group, program) {
954
1092
  action: (/** @type {any} */ o) =>
955
1093
  run(
956
1094
  program,
957
- () => themeEditPreviewList({cwd: process.cwd(), path: o.path}),
1095
+ () =>
1096
+ previewFlagsOnce('list', ['path']) ??
1097
+ themeEditPreviewList({cwd: process.cwd(), path: o.path}),
958
1098
  r =>
959
1099
  r.data.folder
960
- ? project(/** @type {any} */ (r.data))
1100
+ ? project(
1101
+ /** @type {any} */ ({
1102
+ ...r.data,
1103
+ // A page whose file is gone says so in words.
1104
+ pages: r.data.pages.map(({missing, ...p}) =>
1105
+ missing ? {...p, file: 'missing'} : p,
1106
+ ),
1107
+ }),
1108
+ )
961
1109
  : [
962
1110
  ...project(/** @type {any} */ (r.data)),
963
1111
  `Tip: ${PREFIX} preview add${o.path == null ? '' : ` --path ${quoteCommandArgument(String(o.path))}`}`,
@@ -980,6 +1128,7 @@ export function registerExperimentalTheme(group, program) {
980
1128
  run(
981
1129
  program,
982
1130
  () =>
1131
+ previewFlagsOnce('remove', ['path']) ??
983
1132
  themeEditPreviewRemove(page, {cwd: process.cwd(), path: o.path}),
984
1133
  r => [
985
1134
  r.data.pages.length
@@ -1025,14 +1174,16 @@ export function registerExperimentalTheme(group, program) {
1025
1174
  );
1026
1175
  if (themeFlags.length > 1)
1027
1176
  return cliError('--theme is given twice; give it once.', {
1028
- suggestions: [{name: `${HOW} --help`, reason: 'give --theme once'}],
1177
+ suggestions: [
1178
+ {name: cmd(`${HOW} --help`), reason: 'give --theme once'},
1179
+ ],
1029
1180
  code: ERROR_CODES.ERR_INVALID_ARGUMENT,
1030
1181
  });
1031
1182
  if (listFlags.length > 1)
1032
1183
  return cliError('--list is given twice; give it once.', {
1033
1184
  suggestions: [
1034
1185
  {
1035
- name: `${HOW} --list tokens accent`,
1186
+ name: cmd(`${HOW} --list tokens accent`),
1036
1187
  reason: 'one list, then the filter',
1037
1188
  },
1038
1189
  ],
@@ -1124,6 +1275,8 @@ export function registerExperimentalTheme(group, program) {
1124
1275
  build: 'compile',
1125
1276
  explain: editorThemeRefusal,
1126
1277
  preflight: editorCompileProblem,
1278
+ missingSource: editorMissingSource,
1279
+ template: editorThemeTemplate,
1127
1280
  hold: editorThemeHold,
1128
1281
  },
1129
1282
  );
@@ -39,7 +39,7 @@ export const doc = {
39
39
  flag: '-o, --out <path>',
40
40
  param: 'options.out',
41
41
  description:
42
- '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. A build never replaces the theme source (ERR_THEME_INVALID). At a path --out names, it replaces only its own earlier outputs: 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)',
42
+ '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)',
43
43
  },
44
44
  {
45
45
  flag: '--icons-specifier <specifier>',
@@ -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 and the stale files, 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',
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. An editor theme run from a folder other than its app root is refused (ERR_INVALID_ARGUMENT) with the `cd` to the root and the same command; `--family` does not take an editor theme (ERR_INVALID_ARGUMENT); its damaged or unbuildable settings are refused (ERR_THEME_INVALID)',
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 (the same build as `astryx theme build`), 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.',
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
  {
@@ -59,7 +59,7 @@ export const doc = {
59
59
  },
60
60
  {
61
61
  code: 1,
62
- when: 'the theme does not exist, an unknown --section, or a page that does not render; or a folder outside a project with Core installed (ERR_PROJECT_REQUIRED)',
62
+ when: 'the theme does not exist or its base theme package is not installed (ERR_UNKNOWN_THEME), an unknown --section (ERR_INVALID_ARGUMENT), a theme source that does not build or parse or a token in it that is not text (ERR_THEME_INVALID), a folder where a built file goes (ERR_FILE_EXISTS), a built file that cannot be read or written (ERR_WRITE_FAILED), another command changing the theme (ERR_THEME_BUSY), a page that does not render (ERR_RENDER_FAILED), or a folder outside a project with Core installed (ERR_PROJECT_REQUIRED)',
63
63
  },
64
64
  ],
65
65
  related: ['experimental theme editor', 'experimental theme compile'],
@@ -12,7 +12,7 @@ export const doc = {
12
12
  summary:
13
13
  'Step back one change, or remove one setting; the result says what applies instead',
14
14
  description:
15
- "With only the theme, it steps back one change: the settings, the generated settings module and the build go back to how they were before the last change (your <theme>.theme.ts is not touched), and the preview is rewritten; the result names what was undone and how many earlier steps are left. When the settings file is damaged (not valid JSON), the step back restores the settings from before the last change without reading it. With a thing, it removes that one setting wherever it is in the settings, and the result says what applies now (`now`): the whole-theme setting for a part setting removed, or the base theme's value; the theme is rebuilt and previewed. Name the setting the way it was set: the same thing and the same --on, --when, --state, --mode and --only (`show` lists every setting that way). For the headings dial, name which half: weight or tracking (default weight). Removing a color (accent, neutral, success, warning, danger, info) stops generating it, and the tokens it fed go back to the base theme; with no color left, the generated color files the editor wrote are deleted; a palette.config.json you made, or one that holds a color of your own, stays. Removing vibrancy makes the colors again at the default, 50; removing the last color removes vibrancy too, as it needs a color. A setting the theme does not have is refused and the error lists the settings it has for that thing. `undo <theme> base` and `undo <theme> mode` go back to the base and mode the theme was made with; when they never changed, that is refused. The history keeps the last 80 steps (in <theme>.history.json); older steps are dropped. Experimental: it may change or be removed in a patch release.",
15
+ "With only the theme, it steps back one change: the settings, the generated settings module and the build go back to how they were before the last change (your <theme>.theme.ts is not touched), and the preview is rewritten; the result names what was undone and how many earlier steps are left. When the settings file is damaged (not valid JSON), the step back restores the settings from before the last change without reading it. With a thing, it removes that one setting wherever it is in the settings, and the result says what applies now (`now`): the whole-theme setting for a part setting removed, or the base theme's value; the theme is rebuilt and previewed. Name the setting the way it was set: the same thing and the same --on, --when, --state, --mode and --only (`show` lists every setting that way). For the headings dial, name which half: weight or tracking; with no half named it removes the weight half, or the tracking half when that is the only one set. Removing a color (accent, neutral, success, warning, danger, info) stops generating it, and the tokens it fed go back to the base theme; with no color left, the generated color files the editor wrote are deleted; a palette.config.json you made, or one that holds a color of your own, stays. Removing vibrancy makes the colors again at the default, 50; removing the last color removes vibrancy too, as it needs a color. A setting the theme does not have is refused and the error lists the settings it has for that thing. `undo <theme> base` and `undo <theme> mode` go back to the base and mode the theme was made with; when they never changed, that is refused. The history keeps the last 80 steps (in <theme>.history.json); older steps are dropped. Experimental: it may change or be removed in a patch release.",
16
16
  fn: 'themeEditUndo',
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 by the same build as `astryx theme build` (`experimental theme compile`). 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.",
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
  {
@@ -28,7 +28,7 @@ export const doc = {
28
28
  flag: '-f, --overwrite',
29
29
  param: 'options.overwrite',
30
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
+ 'Replace an existing copy of the template or theme source file. Any other .ts file, such as util.ts, or a file the theme editor owns (named after its folder, beside its settings, such as themes/t/t.theme.ts), fails with ERR_FILE_EXISTS and is left as it was; an earlier template in that folder is replaced. A path that is not .ts, such as package.json, fails with ERR_INVALID_ARGUMENT, with or without --overwrite',
32
32
  },
33
33
  ],
34
34
  examples: [
@@ -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: [