@astryxdesign/cli 0.7.15 → 0.7.16-canary.g07c77c0

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 (159) hide show
  1. package/README.md +5 -3
  2. package/api/build/_adapter.d.mts +1 -0
  3. package/api/build/blocks/blocks.d.mts +1 -0
  4. package/api/build/blocks/blocks.mjs +18 -1
  5. package/api/component/_adapter.d.mts +1 -1
  6. package/api/component/_adapter.mjs +28 -1
  7. package/api/doctor/_adapter.d.mts +17 -0
  8. package/api/doctor/_adapter.mjs +43 -0
  9. package/api/doctor/built-checks.mjs +1 -1
  10. package/api/doctor/doctor.mjs +18 -4
  11. package/api/doctor/theme-checks.mjs +1 -1
  12. package/api/integration/add-contribution.mjs +3 -3
  13. package/api/integration/pack-check.mjs +14 -8
  14. package/api/integration/validate-integration.mjs +1 -1
  15. package/api/search/_adapter.mjs +15 -16
  16. package/api/search/_entries.d.mts +2 -1
  17. package/api/search/_entries.mjs +28 -1
  18. package/api/swizzle/_moduleGraph.mjs +1 -1
  19. package/api/theme/_adapter.d.mts +5 -2
  20. package/api/theme/_adapter.mjs +43 -12
  21. package/api/theme/_fork.mjs +1 -1
  22. package/api/theme/build/build.d.mts +116 -32
  23. package/api/theme/build/build.mjs +449 -102
  24. package/api/theme/eject/eject.mjs +22 -1
  25. package/api/theme/template/template.d.mts +19 -0
  26. package/api/theme/template/template.mjs +102 -25
  27. package/api/theme/theme.type.d.mts +5 -1
  28. package/api/theme/theme.type.mjs +2 -1
  29. package/api/theme/themeBuild.doc.mjs +3 -3
  30. package/api/theme/themeEject.doc.mjs +1 -1
  31. package/api/theme/themeTemplate.doc.mjs +9 -3
  32. package/api/theme-edit/_adapter.d.mts +32 -2
  33. package/api/theme-edit/_adapter.mjs +213 -36
  34. package/api/theme-edit/_check.d.mts +69 -3
  35. package/api/theme-edit/_check.mjs +1517 -218
  36. package/api/theme-edit/_color.d.mts +2 -8
  37. package/api/theme-edit/_color.mjs +292 -219
  38. package/api/theme-edit/_compiler.d.mts +1 -0
  39. package/api/theme-edit/_compiler.mjs +20 -1
  40. package/api/theme-edit/_context.d.mts +29 -0
  41. package/api/theme-edit/_context.mjs +426 -40
  42. package/api/theme-edit/_css.d.mts +60 -1
  43. package/api/theme-edit/_css.mjs +404 -28
  44. package/api/theme-edit/_edit.d.mts +9 -0
  45. package/api/theme-edit/_edit.mjs +1300 -135
  46. package/api/theme-edit/_how-commands.d.mts +11 -26
  47. package/api/theme-edit/_how-commands.mjs +30 -2
  48. package/api/theme-edit/_how-question.d.mts +7 -0
  49. package/api/theme-edit/_how-question.mjs +1304 -176
  50. package/api/theme-edit/_how.mjs +144 -30
  51. package/api/theme-edit/_overview.mjs +2 -0
  52. package/api/theme-edit/_palette.d.mts +11 -0
  53. package/api/theme-edit/_palette.mjs +194 -65
  54. package/api/theme-edit/_parts.d.mts +33 -0
  55. package/api/theme-edit/_parts.mjs +138 -9
  56. package/api/theme-edit/_png.d.mts +18 -0
  57. package/api/theme-edit/_png.mjs +95 -14
  58. package/api/theme-edit/_preview-app.d.mts +9 -0
  59. package/api/theme-edit/_preview-app.mjs +1191 -71
  60. package/api/theme-edit/_preview.d.mts +16 -3
  61. package/api/theme-edit/_preview.mjs +335 -30
  62. package/api/theme-edit/_project.d.mts +11 -0
  63. package/api/theme-edit/_project.mjs +46 -12
  64. package/api/theme-edit/_settings.d.mts +240 -5
  65. package/api/theme-edit/_settings.mjs +2561 -115
  66. package/api/theme-edit/_tables.d.mts +24 -0
  67. package/api/theme-edit/_tables.mjs +211 -149
  68. package/api/theme-edit/_vet.d.mts +42 -0
  69. package/api/theme-edit/_vet.mjs +144 -0
  70. package/api/theme-edit/theme-edit.type.d.mts +2 -1
  71. package/api/theme-edit/theme-edit.type.mjs +1 -1
  72. package/api/theme-edit/themeEditNew.doc.mjs +1 -1
  73. package/api/theme-edit/themeEditShow.doc.mjs +11 -3
  74. package/api/upgrade/registry/registry.mjs +6 -1
  75. package/assets/codemods/parse.mjs +2 -2
  76. package/assets/docs/tree/single-component.doc.mjs +11 -2
  77. package/assets/docs/tree/tokens-and-setup.doc.mjs +39 -3
  78. package/assets/docs.generated.json +2 -2
  79. package/assets/preview-app/next.config.mjs +7 -1
  80. package/assets/preview-app/package.json +1 -0
  81. package/assets/preview-app/src/app/globals.css +1 -0
  82. package/assets/self-audit.generated.json +1 -1
  83. package/assets/templates/blocks/components/Table/ColumnsVirtualizationHookUsage.doc.mjs +14 -0
  84. package/assets/templates/blocks/components/Table/ColumnsVirtualizationHookUsage.tsx +53 -0
  85. package/assets/templates/blocks/components/Table/InfiniteScrollHookUsage.doc.mjs +14 -0
  86. package/assets/templates/blocks/components/Table/InfiniteScrollHookUsage.tsx +33 -0
  87. package/assets/templates/components.generated.json +1 -1
  88. package/assets/templates/pages/dashboard/page.tsx +1 -1
  89. package/authoring/doctypes/_schema.d.mts +52 -5
  90. package/authoring/doctypes/_schema.mjs +62 -7
  91. package/authoring/doctypes/base/type.ts +10 -0
  92. package/authoring/doctypes/component/component.doc.mjs +1 -1
  93. package/authoring/doctypes/function/function.doc.mjs +6 -0
  94. package/authoring/doctypes/function/type.ts +3 -0
  95. package/authoring/doctypes/legacy.mjs +5 -1
  96. package/authoring/index.d.ts +1 -0
  97. package/authoring/shadcn/source-variants.d.mts +1 -1
  98. package/authoring/shadcn/source-variants.mjs +32 -10
  99. package/clients/cli/build-id.generated.json +1 -1
  100. package/clients/cli/commands/doctor.doc.mjs +2 -2
  101. package/clients/cli/commands/experimental/theme.mjs +237 -45
  102. package/clients/cli/commands/experimental-theme-compile.doc.mjs +2 -2
  103. package/clients/cli/commands/experimental-theme-editor-new.doc.mjs +2 -2
  104. package/clients/cli/commands/experimental-theme-editor-set.doc.mjs +2 -2
  105. package/clients/cli/commands/experimental-theme-editor-show.doc.mjs +3 -3
  106. package/clients/cli/commands/experimental-theme-editor-undo.doc.mjs +2 -2
  107. package/clients/cli/commands/experimental-theme-editor.doc.mjs +1 -1
  108. package/clients/cli/commands/experimental-theme-eject.doc.mjs +1 -1
  109. package/clients/cli/commands/experimental-theme-preview-add.doc.mjs +1 -1
  110. package/clients/cli/commands/experimental-theme-template.doc.mjs +2 -2
  111. package/clients/cli/commands/theme-build.doc.mjs +2 -2
  112. package/clients/cli/commands/theme-eject.doc.mjs +1 -1
  113. package/clients/cli/commands/theme-template.doc.mjs +3 -1
  114. package/clients/cli/commands/theme.mjs +190 -46
  115. package/clients/cli/formatters/index.mjs +7 -4
  116. package/clients/cli/lib/cli-error.mjs +9 -3
  117. package/clients/cli/lib/component-format.mjs +27 -9
  118. package/clients/cli/lib/json-shim.mjs +72 -2
  119. package/clients/cli/manifest.generated.json +1 -1
  120. package/clients/cli/run.mjs +49 -0
  121. package/foundation/agent-docs/agent-docs-target.d.mts +2 -6
  122. package/foundation/agent-docs/agent-docs-target.mjs +9 -17
  123. package/foundation/agent-docs/agent-docs.mjs +3 -2
  124. package/foundation/config/config-writer.mjs +2 -2
  125. package/foundation/config/project.mjs +60 -14
  126. package/foundation/discovery/component-discovery.mjs +5 -17
  127. package/foundation/discovery/icon-set-writer.mjs +1 -1
  128. package/foundation/discovery/module-exports.mjs +1 -15
  129. package/foundation/discovery/template-adapter.mjs +44 -19
  130. package/foundation/discovery/template-source-tree.mjs +3 -16
  131. package/foundation/discovery/theme-discovery.d.mts +5 -1
  132. package/foundation/discovery/theme-discovery.mjs +30 -35
  133. package/foundation/fs/exact-codec.d.mts +35 -0
  134. package/foundation/fs/exact-codec.mjs +148 -0
  135. package/foundation/fs/gather-cache.d.mts +15 -5
  136. package/foundation/fs/gather-cache.mjs +123 -30
  137. package/foundation/fs/paths.d.mts +39 -0
  138. package/foundation/fs/paths.mjs +44 -11
  139. package/foundation/fs/read-record.mjs +11 -1
  140. package/foundation/integrations/contribution-fixes.mjs +1 -16
  141. package/foundation/integrations/may-have-integrations.mjs +3 -2
  142. package/foundation/integrations/public-imports.mjs +1 -1
  143. package/foundation/render/embedded-imports.mjs +1 -1
  144. package/foundation/render/host-exit.d.mts +8 -0
  145. package/foundation/render/host-exit.mjs +11 -0
  146. package/foundation/render/page-host.mjs +56 -10
  147. package/foundation/render/page-worker.mjs +14 -0
  148. package/foundation/render/render-page.mjs +37 -2
  149. package/foundation/response/error-codes.d.mts +2 -1
  150. package/foundation/response/error-codes.d.ts +1 -0
  151. package/foundation/response/error-codes.doc.mjs +5 -0
  152. package/foundation/response/error-codes.mjs +3 -0
  153. package/foundation/response/json.d.mts +15 -0
  154. package/foundation/response/json.mjs +52 -1
  155. package/foundation/response/response-types.doc.mjs +1 -1
  156. package/foundation/runtime/lazy-dependencies.d.mts +14 -0
  157. package/foundation/runtime/lazy-dependencies.mjs +82 -0
  158. package/foundation/xle/browser.d.mts +2 -2
  159. package/package.json +7 -6
@@ -30,6 +30,7 @@ import {
30
30
  text,
31
31
  } from '../../formatters/index.mjs';
32
32
  import {cliError} from '../../lib/cli-error.mjs';
33
+ import {editorMissingArgument} from '../../lib/json-shim.mjs';
33
34
  import {AstryxError} from '../../../../api/error.mjs';
34
35
  import {defineCommand} from '../../lib/define-command.mjs';
35
36
  import {
@@ -45,9 +46,14 @@ import {
45
46
  } from '../../../../api/theme-edit/theme-edit.mjs';
46
47
  import {
47
48
  builtInThemes,
49
+ dialValueFits,
50
+ newFlagList,
48
51
  editorCompileProblem,
49
52
  editorThemeHold,
50
53
  editorThemeRefusal,
54
+ editorMissingSource,
55
+ editorThemeTemplate,
56
+ showSections,
51
57
  } from '../../../../api/theme-edit/_adapter.mjs';
52
58
  import {registerThemeSubcommands} from '../theme.mjs';
53
59
  import {doc as groupDoc} from '../experimental-theme.doc.mjs';
@@ -99,6 +105,8 @@ const cmd = line => {
99
105
  .map(part => part.split(PREFIX).join(stem))
100
106
  .join(stem);
101
107
  };
108
+ /** The project's invocation of a command line (cmd, under a name an action's own `cmd` parameter does not hide). */
109
+ const cliLine = (/** @type {string} */ line) => cmd(line);
102
110
 
103
111
  /**
104
112
  * Print blocks, a blank line between them, with this project's run prefix
@@ -348,29 +356,110 @@ const changeOptions = o => ({
348
356
  * @param {any} o
349
357
  * @returns {Record<string, string | string[]>}
350
358
  */
351
- function newSettings(o) {
359
+ function newSettings(o, themeName = '<theme>') {
352
360
  /** @type {Record<string, string | string[]>} */
353
361
  const out = {};
362
+ // --like given two values is refused like a dial given two.
363
+ const likes = flagValues('like');
364
+ if (new Set(likes).size > 1) {
365
+ // The suggestion keeps the first built-in theme given, or drops --like.
366
+ const like = likes
367
+ .map(l => l.toLowerCase())
368
+ .find(l => builtInThemes().includes(l));
369
+ throw new AstryxError(
370
+ `--like was given twice (${likes.join(', ')}); give it once. Nothing was changed.`,
371
+ [
372
+ {
373
+ name: cmd(`${EDITOR} new ${themeName}${newFlagLine({...o, like})}`),
374
+ reason: like
375
+ ? 'do this instead: the first built-in theme given'
376
+ : 'do this instead: none of them is a built-in theme',
377
+ },
378
+ ],
379
+ ERROR_CODES.ERR_INVALID_ARGUMENT,
380
+ );
381
+ }
354
382
  for (const opt of newDoc.options ?? []) {
355
383
  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())];
384
+ const flag = opt.flag.split(' ')[0].slice(2);
385
+ const key = flag.replace(/-([a-z])/g, (_, c) => c.toUpperCase());
386
+ const value = o[key];
358
387
  if (value == null) continue;
359
388
  // A flag given twice: headings takes one value per axis (a weight and a
360
389
  // 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)
390
+ const all = flagValues(flag);
391
+ if (flag === 'headings' && all.length > 1) out[flag] = all;
392
+ else if (new Set(all).size > 1) {
393
+ // The suggestion keeps the first value the dial takes, or drops it.
394
+ const fits = all.find(v => dialValueFits(flag, v));
364
395
  throw new AstryxError(
365
- `--${name} was given twice (${all.join(', ')}); give it once. Nothing was changed.`,
366
- [],
396
+ `--${flag} was given twice (${all.join(', ')}); give it once. Nothing was changed.`,
397
+ [
398
+ {
399
+ name: cmd(
400
+ `${EDITOR} new ${themeName}${newFlagLine({...o, [key]: fits})}`,
401
+ ),
402
+ reason: fits
403
+ ? 'do this instead: the first value it takes'
404
+ : `do this instead: none of them is a value --${flag} takes`,
405
+ },
406
+ ],
367
407
  ERROR_CODES.ERR_INVALID_ARGUMENT,
368
408
  );
369
- else out[name] = String(value);
409
+ } else out[flag] = String(value);
370
410
  }
371
411
  return out;
372
412
  }
373
413
 
414
+ /**
415
+ * The options a `new` was given, as flags for a suggested command, so a
416
+ * corrected command makes the theme that was asked for.
417
+ * @param {any} o
418
+ * @returns {string}
419
+ */
420
+ function newFlagLine(o) {
421
+ /** @type {Record<string, string | string[]>} */
422
+ const settings = {};
423
+ for (const opt of newDoc.options ?? []) {
424
+ if (opt.param !== 'options.settings') continue;
425
+ const flag = opt.flag.split(' ')[0].slice(2);
426
+ const value = o[flag.replace(/-([a-z])/g, (_, c) => c.toUpperCase())];
427
+ if (value != null) settings[flag] = value;
428
+ }
429
+ const parts = newFlagList(
430
+ o.like == null ? undefined : String(o.like),
431
+ settings,
432
+ Boolean(o.png),
433
+ );
434
+ return parts.length ? ` ${parts.join(' ')}` : '';
435
+ }
436
+
437
+ /**
438
+ * Refuse a preview flag given twice with different values: the command
439
+ * would keep only the last one without a word. Undefined when each is
440
+ * given once.
441
+ * @param {string} command the preview subcommand, for the suggestion
442
+ * @param {string[]} flags
443
+ * @returns {undefined}
444
+ */
445
+ function previewFlagsOnce(command, flags) {
446
+ for (const flag of flags) {
447
+ const all = flagValues(flag);
448
+ if (new Set(all).size > 1)
449
+ throw new AstryxError(
450
+ `--${flag} was given twice (${all.join(', ')}); give it once. Nothing was changed.`,
451
+ [
452
+ {
453
+ name: cmd(`${PREFIX} preview ${command} --help`),
454
+ reason: 'every option it takes',
455
+ },
456
+ ],
457
+ ERROR_CODES.ERR_INVALID_ARGUMENT,
458
+ );
459
+ }
460
+ return undefined;
461
+ }
462
+
374
463
  /**
375
464
  * Every value one flag was given on the command line, in order.
376
465
  * @param {string} name
@@ -707,7 +796,7 @@ export function registerExperimentalTheme(group, program) {
707
796
  const editor = defineGroup(theme, editorDoc);
708
797
  explained(editor, editorDoc);
709
798
 
710
- explained(
799
+ const newCli = explained(
711
800
  defineCommand(editor, newDoc, {
712
801
  fn: newFn,
713
802
  action: (
@@ -718,38 +807,80 @@ export function registerExperimentalTheme(group, program) {
718
807
  run(
719
808
  program,
720
809
  () => {
810
+ // An option new does not take (--force, --dry-run, -t) is refused
811
+ // with new's help, as every editor command's unknown option is.
812
+ const takes = new Set(
813
+ (newDoc.options ?? []).flatMap(opt =>
814
+ String(opt.flag)
815
+ .split(/[\s,]+/)
816
+ .filter(w => w.startsWith('-'))
817
+ .map(w => w.replace(/[<[].*$/, '')),
818
+ ),
819
+ );
820
+ const stray = (cmd?.args ?? [])
821
+ .slice(1)
822
+ .map(String)
823
+ .find(
824
+ (/** @type {string} */ w) =>
825
+ /^-/.test(w) && !takes.has(w.split('=')[0]),
826
+ );
827
+ if (stray)
828
+ return cliError(`unknown option '${stray}'.`, {
829
+ suggestions: [
830
+ {
831
+ name: cliLine(`${EDITOR} new --help`),
832
+ reason: 'every option it takes',
833
+ },
834
+ ],
835
+ code: ERROR_CODES.ERR_INVALID_OPTION,
836
+ });
721
837
  // A word after the name is never dropped without a word.
722
838
  const extra = (cmd?.args ?? []).slice(1);
723
- if (extra.length)
839
+ if (extra.length) {
840
+ // Words after `--` that are `--<option> <value>` pairs new
841
+ // takes become options; the other words were most likely
842
+ // part of the name. The options given stay in the suggestion.
843
+ /** @type {Record<string, unknown>} */
844
+ const given = {...o};
845
+ /** @type {string[]} */
846
+ const words = [];
847
+ for (let i = 0; i < extra.length; i++) {
848
+ const w = String(extra[i]);
849
+ if (w.startsWith('--')) {
850
+ const key = w
851
+ .slice(2)
852
+ .replace(/-([a-z])/g, (_, c) => c.toUpperCase());
853
+ if (extra[i + 1] != null && given[key] == null)
854
+ given[key] = extra[++i];
855
+ continue;
856
+ }
857
+ words.push(w);
858
+ }
859
+ const builtIn =
860
+ words.length && builtInThemes().includes(words[0]);
861
+ if (builtIn && given.like == null) given.like = words[0];
862
+ const fixed = builtIn
863
+ ? name
864
+ : [name, ...words]
865
+ .join('-')
866
+ .toLowerCase()
867
+ .replace(/[^a-z0-9-]+/g, '-');
724
868
  throw new AstryxError(
725
869
  `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
- ],
870
+ [
871
+ {
872
+ name: `${EDITOR} new ${quoteCommandArgument(fixed)}${newFlagLine(given)}`,
873
+ reason: 'do this instead',
874
+ },
875
+ ],
746
876
  ERROR_CODES.ERR_INVALID_ARGUMENT,
747
877
  );
878
+ }
748
879
  return themeEditNew(name, {
749
880
  cwd: process.cwd(),
750
881
  like: o.like,
751
882
  png: o.png ?? false,
752
- settings: newSettings(o),
883
+ settings: newSettings(o, name),
753
884
  });
754
885
  },
755
886
  r => [
@@ -761,6 +892,8 @@ export function registerExperimentalTheme(group, program) {
761
892
  }),
762
893
  newDoc,
763
894
  );
895
+ // new refuses an option it does not take itself, naming its help.
896
+ newCli.allowUnknownOption();
764
897
 
765
898
  explained(
766
899
  defineCommand(editor, setDoc, {
@@ -770,13 +903,28 @@ export function registerExperimentalTheme(group, program) {
770
903
  /** @type {string} */ thing,
771
904
  /** @type {string[]} */ value,
772
905
  /** @type {any} */ o,
773
- ) =>
774
- strayOption('set', value) ??
775
- run(
776
- program,
777
- () => themeEditSet(name, thing, value.join(' '), changeOptions(o)),
778
- changeBlocks,
779
- ),
906
+ ) => {
907
+ // A declaration pasted as one argument (`--color-accent: #e11d48`,
908
+ // or `--color-accent:#e11d48`) is the token and its value; with no
909
+ // value otherwise, the missing-argument error the parser gives.
910
+ if (!value.length) {
911
+ const pasted = /^(--[a-z0-9-]+)\s*:\s*(.+?);?\s*$/i.exec(thing);
912
+ if (!pasted)
913
+ return missingSetValue(
914
+ editor.commands.find(c => c.name() === 'set'),
915
+ );
916
+ thing = pasted[1];
917
+ value = [pasted[2]];
918
+ }
919
+ return (
920
+ strayOption('set', value) ??
921
+ run(
922
+ program,
923
+ () => themeEditSet(name, thing, value.join(' '), changeOptions(o)),
924
+ changeBlocks,
925
+ )
926
+ );
927
+ },
780
928
  }),
781
929
  setDoc,
782
930
  {tokens: true},
@@ -799,7 +947,11 @@ export function registerExperimentalTheme(group, program) {
799
947
  {
800
948
  suggestions: [
801
949
  {
802
- name: `${EDITOR} show ${name} --section ${flagValues('section')[0]}`,
950
+ // The first section given that `show` takes, else the
951
+ // whole sheet.
952
+ name: cmd(
953
+ `${EDITOR} show ${name}${(sec => (sec ? ` --section ${sec}` : ''))(flagValues('section').find(v => showSections().includes(v)))}`,
954
+ ),
803
955
  reason: 'do this instead',
804
956
  },
805
957
  ],
@@ -870,6 +1022,7 @@ export function registerExperimentalTheme(group, program) {
870
1022
  run(
871
1023
  program,
872
1024
  () =>
1025
+ previewFlagsOnce('add', ['theme', 'template', 'top', 'path']) ??
873
1026
  themeEditPreviewAdd([words ?? []].flat().join(' ') || undefined, {
874
1027
  cwd: process.cwd(),
875
1028
  theme: o.theme,
@@ -916,6 +1069,7 @@ export function registerExperimentalTheme(group, program) {
916
1069
  run(
917
1070
  program,
918
1071
  () =>
1072
+ previewFlagsOnce('app', ['theme']) ??
919
1073
  themeEditPreviewApp(dir, {
920
1074
  cwd: process.cwd(),
921
1075
  theme: o.theme,
@@ -954,13 +1108,28 @@ export function registerExperimentalTheme(group, program) {
954
1108
  action: (/** @type {any} */ o) =>
955
1109
  run(
956
1110
  program,
957
- () => themeEditPreviewList({cwd: process.cwd(), path: o.path}),
1111
+ () =>
1112
+ previewFlagsOnce('list', ['path']) ??
1113
+ themeEditPreviewList({cwd: process.cwd(), path: o.path}),
958
1114
  r =>
959
1115
  r.data.folder
960
- ? project(/** @type {any} */ (r.data))
1116
+ ? project(
1117
+ /** @type {any} */ ({
1118
+ ...r.data,
1119
+ // A page whose file is gone says so in words.
1120
+ pages: r.data.pages.map(({missing, ...p}) =>
1121
+ missing ? {...p, file: 'missing'} : p,
1122
+ ),
1123
+ }),
1124
+ )
961
1125
  : [
962
1126
  ...project(/** @type {any} */ (r.data)),
963
- `Tip: ${PREFIX} preview add${o.path == null ? '' : ` --path ${quoteCommandArgument(String(o.path))}`}`,
1127
+ // A folder add refuses has a note that says why instead.
1128
+ ...(r.data.notes.some(n => n.includes(' refuses this folder'))
1129
+ ? []
1130
+ : [
1131
+ `Tip: ${PREFIX} preview add${o.path == null ? '' : ` --path ${quoteCommandArgument(String(o.path))}`}`,
1132
+ ]),
964
1133
  ],
965
1134
  r =>
966
1135
  resultSet({
@@ -980,6 +1149,7 @@ export function registerExperimentalTheme(group, program) {
980
1149
  run(
981
1150
  program,
982
1151
  () =>
1152
+ previewFlagsOnce('remove', ['path']) ??
983
1153
  themeEditPreviewRemove(page, {cwd: process.cwd(), path: o.path}),
984
1154
  r => [
985
1155
  r.data.pages.length
@@ -1025,14 +1195,16 @@ export function registerExperimentalTheme(group, program) {
1025
1195
  );
1026
1196
  if (themeFlags.length > 1)
1027
1197
  return cliError('--theme is given twice; give it once.', {
1028
- suggestions: [{name: `${HOW} --help`, reason: 'give --theme once'}],
1198
+ suggestions: [
1199
+ {name: cmd(`${HOW} --help`), reason: 'give --theme once'},
1200
+ ],
1029
1201
  code: ERROR_CODES.ERR_INVALID_ARGUMENT,
1030
1202
  });
1031
1203
  if (listFlags.length > 1)
1032
1204
  return cliError('--list is given twice; give it once.', {
1033
1205
  suggestions: [
1034
1206
  {
1035
- name: `${HOW} --list tokens accent`,
1207
+ name: cmd(`${HOW} --list tokens accent`),
1036
1208
  reason: 'one list, then the filter',
1037
1209
  },
1038
1210
  ],
@@ -1124,7 +1296,27 @@ export function registerExperimentalTheme(group, program) {
1124
1296
  build: 'compile',
1125
1297
  explain: editorThemeRefusal,
1126
1298
  preflight: editorCompileProblem,
1299
+ missingSource: editorMissingSource,
1300
+ template: editorThemeTemplate,
1127
1301
  hold: editorThemeHold,
1128
1302
  },
1129
1303
  );
1130
1304
  }
1305
+
1306
+ /**
1307
+ * The error for `set` given a theme and a thing but no value: the parser's
1308
+ * missing-argument report, from the one builder it uses.
1309
+ * @param {any} cmd the set command
1310
+ * @returns {never}
1311
+ */
1312
+ function missingSetValue(cmd) {
1313
+ const {message, suggestions} = editorMissingArgument(
1314
+ cmd,
1315
+ ['theme', 'thing', 'value'],
1316
+ 'value',
1317
+ );
1318
+ return cliError(message, {
1319
+ code: ERROR_CODES.ERR_MISSING_ARGUMENT,
1320
+ suggestions,
1321
+ });
1322
+ }
@@ -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
  {
@@ -31,7 +31,7 @@ export const doc = {
31
31
  flag: '--png',
32
32
  param: 'options.png',
33
33
  description:
34
- 'Also take PNG pictures of the previews (light and dark), with a Playwright installed in the project or a Chrome or Chromium found on the machine; without one, the result says how to get it. Nothing else changes',
34
+ 'Also take PNG pictures of the previews (light and dark), with a Playwright installed in the project or a Chrome or Chromium found on the machine; without one, the result says how to get it. Each picture carries the editor stamp and is recorded, by name and content, in themes/<theme>/<theme>.pictures.json; a file of yours named like a picture (preview.png, sheet.png) is never written over: no picture is taken, and the result names the file',
35
35
  },
36
36
  {
37
37
  flag: '--corners <rung>',
@@ -28,7 +28,7 @@ export const doc = {
28
28
  {
29
29
  name: 'value',
30
30
  param: 'value',
31
- required: true,
31
+ required: false,
32
32
  variadic: true,
33
33
  },
34
34
  ],
@@ -67,7 +67,7 @@ export const doc = {
67
67
  flag: '--png',
68
68
  param: 'options.png',
69
69
  description:
70
- 'Also take PNG pictures of the previews (light and dark), with a Playwright installed in the project or a Chrome or Chromium found on the machine; without one, the result says how to get it. Nothing else changes',
70
+ 'Also take PNG pictures of the previews (light and dark), with a Playwright installed in the project or a Chrome or Chromium found on the machine; without one, the result says how to get it. Each picture carries the editor stamp and is recorded, by name and content, in themes/<theme>/<theme>.pictures.json; a file of yours named like a picture (preview.png, sheet.png) is never written over: no picture is taken, and the result names the file',
71
71
  },
72
72
  ],
73
73
  examples: [
@@ -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
  {
@@ -32,7 +32,7 @@ export const doc = {
32
32
  flag: '--png',
33
33
  param: 'options.png',
34
34
  description:
35
- 'Also take PNG pictures of the previews (light and dark), with a Playwright installed in the project or a Chrome or Chromium found on the machine; without one, the result says how to get it. Nothing else changes',
35
+ 'Also take PNG pictures of the previews (light and dark), with a Playwright installed in the project or a Chrome or Chromium found on the machine; without one, the result says how to get it. Each picture carries the editor stamp and is recorded, by name and content, in themes/<theme>/<theme>.pictures.json; a file of yours named like a picture (preview.png, sheet.png) is never written over: no picture is taken, and the result names the file',
36
36
  },
37
37
  ],
38
38
  examples: [
@@ -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
  {
@@ -66,7 +66,7 @@ export const doc = {
66
66
  flag: '--png',
67
67
  param: 'options.png',
68
68
  description:
69
- 'Also take PNG pictures of the previews (light and dark), with a Playwright installed in the project or a Chrome or Chromium found on the machine; without one, the result says how to get it. Nothing else changes',
69
+ 'Also take PNG pictures of the previews (light and dark), with a Playwright installed in the project or a Chrome or Chromium found on the machine; without one, the result says how to get it. Each picture carries the editor stamp and is recorded, by name and content, in themes/<theme>/<theme>.pictures.json; a file of yours named like a picture (preview.png, sheet.png) is never written over: no picture is taken, and the result names the file',
70
70
  },
71
71
  ],
72
72
  examples: [
@@ -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
  {
@@ -33,7 +33,7 @@ export const doc = {
33
33
  flag: '--template <id>',
34
34
  param: 'options.template',
35
35
  description:
36
- 'Add this page template (astryx template --list --type page) instead of ranking one from a description',
36
+ 'Add this page template (astryx template --list --type page) instead of ranking one from a description. A default page (overview, components, colors) adds just that page back when it is missing',
37
37
  },
38
38
  {
39
39
  flag: '--top <n>',
@@ -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: [