@astryxdesign/cli 0.7.14 → 0.7.15-canary.g061b2fa

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 (164) hide show
  1. package/README.md +63 -63
  2. package/api/build/_adapter.d.mts +4 -0
  3. package/api/build/_adapter.mjs +28 -2
  4. package/api/build/blocks/blocks.d.mts +10 -1
  5. package/api/build/blocks/blocks.mjs +84 -7
  6. package/api/build/build.mjs +6 -1
  7. package/api/build/tree.d.mts +4 -0
  8. package/api/build/tree.mjs +9 -2
  9. package/api/doctor/_adapter.d.mts +3 -1
  10. package/api/doctor/_adapter.mjs +14 -1
  11. package/api/doctor/_authoring-audit.d.mts +42 -0
  12. package/api/doctor/_authoring-audit.mjs +106 -0
  13. package/api/doctor/doctor.d.mts +7 -0
  14. package/api/doctor/doctor.mjs +24 -39
  15. package/api/doctor/theme-checks.mjs +56 -21
  16. package/api/integration/validate-integration.mjs +17 -3
  17. package/api/integration/validateIntegration.doc.mjs +1 -1
  18. package/api/search/_adapter.mjs +124 -3
  19. package/api/search/_candidate-score.mjs +63 -9
  20. package/api/search/_entries.d.mts +10 -0
  21. package/api/search/_entries.mjs +68 -1
  22. package/api/search/_gather-templates.d.mts +11 -0
  23. package/api/search/_gather-templates.mjs +22 -2
  24. package/api/search/_words.mjs +26 -6
  25. package/api/swizzle/copy/copy.mjs +1 -1
  26. package/api/theme/_adapter.d.mts +17 -1
  27. package/api/theme/_adapter.mjs +185 -40
  28. package/api/theme/build/build.d.mts +29 -1
  29. package/api/theme/build/build.mjs +426 -65
  30. package/api/theme/eject/eject.mjs +10 -6
  31. package/api/theme/targets/targets.d.mts +8 -0
  32. package/api/theme/targets/targets.mjs +24 -4
  33. package/api/theme/template/template.mjs +48 -2
  34. package/api/theme/theme.type.d.mts +8 -0
  35. package/api/theme/theme.type.mjs +5 -1
  36. package/api/theme/themeBuild.doc.mjs +7 -4
  37. package/api/theme/themeEject.doc.mjs +3 -3
  38. package/api/theme/themeRemove.doc.mjs +5 -2
  39. package/api/theme/themeTargets.doc.mjs +1 -1
  40. package/api/theme/themeTemplate.doc.mjs +2 -2
  41. package/api/theme/themeUse.doc.mjs +8 -2
  42. package/api/theme-edit/_adapter.d.mts +46 -3
  43. package/api/theme-edit/_adapter.mjs +372 -109
  44. package/api/theme-edit/_check.d.mts +6 -3
  45. package/api/theme-edit/_check.mjs +665 -87
  46. package/api/theme-edit/_color.mjs +4 -2
  47. package/api/theme-edit/_compiler.d.mts +2 -1
  48. package/api/theme-edit/_compiler.mjs +27 -13
  49. package/api/theme-edit/_context.d.mts +2 -1
  50. package/api/theme-edit/_context.mjs +47 -8
  51. package/api/theme-edit/_edit.d.mts +9 -3
  52. package/api/theme-edit/_edit.mjs +484 -66
  53. package/api/theme-edit/_how-commands.d.mts +33 -7
  54. package/api/theme-edit/_how-commands.mjs +57 -45
  55. package/api/theme-edit/_how-question.d.mts +4 -0
  56. package/api/theme-edit/_how-question.mjs +1004 -223
  57. package/api/theme-edit/_how.mjs +96 -9
  58. package/api/theme-edit/_palette.d.mts +38 -13
  59. package/api/theme-edit/_palette.mjs +620 -223
  60. package/api/theme-edit/_parts.mjs +63 -7
  61. package/api/theme-edit/_png.d.mts +4 -4
  62. package/api/theme-edit/_png.mjs +4 -2
  63. package/api/theme-edit/_preview-app.d.mts +6 -0
  64. package/api/theme-edit/_preview-app.mjs +1194 -207
  65. package/api/theme-edit/_preview.mjs +2 -2
  66. package/api/theme-edit/_project.d.mts +12 -1
  67. package/api/theme-edit/_project.mjs +37 -6
  68. package/api/theme-edit/_settings.d.mts +104 -33
  69. package/api/theme-edit/_settings.mjs +818 -118
  70. package/api/theme-edit/_tables.d.mts +7 -0
  71. package/api/theme-edit/_tables.mjs +61 -0
  72. package/api/theme-edit/theme-edit.type.d.mts +11 -1
  73. package/api/theme-edit/theme-edit.type.mjs +4 -3
  74. package/api/theme-edit/themeEditHow.doc.mjs +6 -0
  75. package/api/theme-edit/themeEditPreviewAdd.doc.mjs +1 -1
  76. package/api/theme-edit/themeEditPreviewApp.doc.mjs +1 -1
  77. package/api/theme-edit/themeEditPreviewList.doc.mjs +1 -1
  78. package/api/theme-edit/themeEditPreviewRemove.doc.mjs +5 -1
  79. package/api/theme-edit/themeEditUndo.doc.mjs +1 -1
  80. package/api/upgrade/_adapter.d.mts +1 -0
  81. package/assets/codemods/run-codemod.mjs +61 -0
  82. package/assets/codemods/runner.mjs +5 -4
  83. package/assets/codemods/transforms/v0.0.14/rename-status-variants.mjs +3 -0
  84. package/assets/codemods/transforms/v0.1.8/rename-avatar-size-scale.mjs +5 -1
  85. package/assets/codemods/transforms/v0.6.4/migrate-native-picker-to-presentation.mjs +3 -0
  86. package/assets/codemods/transforms/v0.7.0/migrate-deprecated-theme-surface.mjs +4 -0
  87. package/assets/codemods/transforms/v0.7.0/rename-empty-search-results-text.mjs +17 -12
  88. package/assets/codemods/transforms/v0.7.2/migrate-list-edge-compensation-to-edge.mjs +3 -0
  89. package/assets/codemods/transforms/v0.7.5/migrate-codeblock-tokenizer-to-language.mjs +3 -0
  90. package/assets/codemods/transforms/v0.7.8/promote-tokenizer-presentation.mjs +3 -0
  91. package/assets/docs/tree/calendars.doc.mjs +1 -3
  92. package/assets/docs/tree/checks.doc.mjs +22 -1
  93. package/assets/docs.generated.json +2 -1
  94. package/assets/self-audit.generated.json +1 -0
  95. package/assets/templates/blocks/components/Theme/useThemeNameHookUsage.doc.mjs +14 -0
  96. package/assets/templates/blocks/components/Theme/useThemeNameHookUsage.tsx +31 -0
  97. package/assets/templates/components.generated.json +1 -1
  98. package/authoring/integration/integration.doc.mjs +8 -0
  99. package/authoring/integration/schema.d.mts +8 -0
  100. package/authoring/integration/schema.mjs +1 -0
  101. package/authoring/integration/type.ts +9 -0
  102. package/clients/cli/bin/astryx.mjs +19 -15
  103. package/clients/cli/build-id.generated.json +1 -0
  104. package/clients/cli/commands/ensure-core-built.mjs +12 -5
  105. package/clients/cli/commands/experimental/theme.mjs +178 -78
  106. package/clients/cli/commands/experimental-theme-compile.doc.mjs +2 -2
  107. package/clients/cli/commands/experimental-theme-editor-how.doc.mjs +1 -1
  108. package/clients/cli/commands/experimental-theme-editor-set.doc.mjs +1 -2
  109. package/clients/cli/commands/experimental-theme-editor-show.doc.mjs +1 -1
  110. package/clients/cli/commands/experimental-theme-editor-undo.doc.mjs +2 -2
  111. package/clients/cli/commands/experimental-theme-editor.doc.mjs +1 -1
  112. package/clients/cli/commands/experimental-theme-eject.doc.mjs +3 -3
  113. package/clients/cli/commands/experimental-theme-preview-add.doc.mjs +1 -1
  114. package/clients/cli/commands/experimental-theme-preview-app.doc.mjs +1 -1
  115. package/clients/cli/commands/experimental-theme-preview-list.doc.mjs +1 -1
  116. package/clients/cli/commands/experimental-theme-preview-remove.doc.mjs +1 -1
  117. package/clients/cli/commands/experimental-theme-remove.doc.mjs +1 -1
  118. package/clients/cli/commands/experimental-theme-template.doc.mjs +4 -3
  119. package/clients/cli/commands/manifest.mjs +5 -2
  120. package/clients/cli/commands/theme-build.doc.mjs +1 -1
  121. package/clients/cli/commands/theme-list.doc.mjs +1 -1
  122. package/clients/cli/commands/theme-template.doc.mjs +1 -1
  123. package/clients/cli/commands/theme.mjs +374 -42
  124. package/clients/cli/index.mjs +9 -3
  125. package/clients/cli/lib/manifest.mjs +37 -0
  126. package/clients/cli/lib/resolve-theme.mjs +2 -1
  127. package/clients/cli/manifest.generated.json +1 -0
  128. package/foundation/config/theme-state.d.mts +16 -0
  129. package/foundation/config/theme-state.mjs +84 -13
  130. package/foundation/discovery/module-exports.mjs +16 -2
  131. package/foundation/discovery/stored-self-audit.d.mts +31 -0
  132. package/foundation/discovery/stored-self-audit.mjs +119 -0
  133. package/foundation/discovery/template-adapter.d.mts +48 -2
  134. package/foundation/discovery/template-adapter.mjs +51 -19
  135. package/foundation/discovery/template-needs.d.mts +19 -0
  136. package/foundation/discovery/template-needs.mjs +50 -16
  137. package/foundation/discovery/template-source-tree.d.mts +7 -0
  138. package/foundation/discovery/template-source-tree.mjs +15 -0
  139. package/foundation/discovery/theme-discovery.d.mts +2 -1
  140. package/foundation/discovery/theme-discovery.mjs +2 -8
  141. package/foundation/discovery/theme-module-extensions.d.mts +18 -0
  142. package/foundation/discovery/theme-module-extensions.mjs +30 -0
  143. package/foundation/doc-compiler/import.mjs +22 -15
  144. package/foundation/doc-compiler/stored-docs.d.mts +18 -12
  145. package/foundation/doc-compiler/stored-docs.mjs +52 -19
  146. package/foundation/env/private-dir.d.mts +17 -0
  147. package/foundation/env/private-dir.mjs +42 -0
  148. package/foundation/fs/gather-cache.d.mts +108 -0
  149. package/foundation/fs/gather-cache.mjs +741 -0
  150. package/foundation/fs/jiti-cache.d.mts +21 -0
  151. package/foundation/fs/jiti-cache.mjs +66 -0
  152. package/foundation/fs/module-loader.mjs +14 -3
  153. package/foundation/fs/read-record.d.mts +31 -1
  154. package/foundation/fs/read-record.mjs +100 -7
  155. package/foundation/integrations/integrations.d.mts +8 -0
  156. package/foundation/integrations/integrations.mjs +4 -0
  157. package/foundation/integrations/validate-contributions.d.mts +62 -1
  158. package/foundation/integrations/validate-contributions.mjs +476 -40
  159. package/foundation/release/cache.d.mts +11 -2
  160. package/foundation/release/cache.mjs +59 -10
  161. package/foundation/release/folder-lock.d.mts +21 -0
  162. package/foundation/release/folder-lock.mjs +171 -0
  163. package/foundation/response/response-types.doc.mjs +1 -1
  164. package/package.json +8 -6
@@ -73,6 +73,7 @@ import {
73
73
  findCoreDir,
74
74
  findInstalledPackage,
75
75
  findProjectCoreDir,
76
+ findPackageRoot,
76
77
  } from '../../../foundation/fs/paths.mjs';
77
78
  import {isGlobalCopy} from '../../../foundation/release/choose.mjs';
78
79
  import {isInReleaseCache} from '../../../foundation/release/cache.mjs';
@@ -88,6 +89,7 @@ import {AstryxError} from '../../error.mjs';
88
89
  import {applyWrites} from '../../integration/add-helpers.mjs';
89
90
  import {logger} from '../../logger.mjs';
90
91
  import {loadComponentDoc} from '../../../foundation/discovery/component-loader.mjs';
92
+ import {THEME_SOURCE_EXTENSIONS} from '../../../foundation/discovery/theme-module-extensions.mjs';
91
93
  import {
92
94
  collectThemingTargets,
93
95
  targetsByKey,
@@ -98,6 +100,7 @@ import {
98
100
  formatFontLoadingHelp,
99
101
  } from './font-warning.mjs';
100
102
  import {interceptCore} from './core-interception.mjs';
103
+ import {installCommandFor} from '../../../foundation/discovery/template-needs.mjs';
101
104
  import {generateFamilyCSS, resolveThemeFamily} from './family.mjs';
102
105
  import {resolveIconImports} from './icon-imports.mjs';
103
106
 
@@ -578,6 +581,83 @@ function resolveToolVersions(cwd) {
578
581
  };
579
582
  }
580
583
 
584
+ /**
585
+ * The command a stale check names, in the words of the group that ran it
586
+ * (`experimental theme compile`); the generated headers keep `theme build`.
587
+ * @param {string} command
588
+ * @param {{group: string, build: string}} [words]
589
+ */
590
+ function rebuildLine(command, words) {
591
+ if (!words || words.group === 'theme') return command;
592
+ return command.replace(/\btheme build\b/, `${words.group} ${words.build}`);
593
+ }
594
+
595
+ /**
596
+ * The folder a build header names paths from: the project root (nearest
597
+ * package.json) of the outputs' folder, or `cwd` outside any project.
598
+ * @param {string} outDir
599
+ * @param {string} cwd
600
+ */
601
+ function headerRoot(outDir, cwd) {
602
+ return findPackageRoot(outDir) ?? path.resolve(cwd);
603
+ }
604
+
605
+ /**
606
+ * Whether a build refuses to replace, at a path `--out` names, the output of
607
+ * another theme source that still exists. False makes it warn and replace.
608
+ */
609
+ const OUT_REFUSES_OTHER_SOURCE = false;
610
+
611
+ /**
612
+ * Where a source name in a build header may point. A header names its source
613
+ * from the outputs' project root; older CLIs named it from the folder the
614
+ * build ran in, which is the output's folder or one above it, up to a
615
+ * monorepo root above the project. The project root comes first, then the
616
+ * output's folder and each folder above it.
617
+ * @param {string} outputFile absolute file the header is in
618
+ * @param {string} name the name the header gives
619
+ * @param {string} cwd
620
+ * @returns {string[]} absolute candidates, without repeats
621
+ */
622
+ function headerSourceCandidates(outputFile, name, cwd) {
623
+ const outDir = path.dirname(path.resolve(outputFile));
624
+ const candidates = [path.resolve(headerRoot(outDir, cwd), name)];
625
+ for (let dir = outDir; ; dir = path.dirname(dir)) {
626
+ candidates.push(path.resolve(dir, name));
627
+ if (path.dirname(dir) === dir) break;
628
+ }
629
+ return [...new Set(candidates)];
630
+ }
631
+
632
+ /**
633
+ * The file a build header's source name points at: the first candidate that
634
+ * exists, or the one from the project root when none does.
635
+ * @param {string} outputFile
636
+ * @param {string} name
637
+ * @param {string} cwd
638
+ */
639
+ function headerSourceFile(outputFile, name, cwd) {
640
+ const candidates = headerSourceCandidates(outputFile, name, cwd);
641
+ return (
642
+ candidates.find(file => {
643
+ try {
644
+ return fs.statSync(file).isFile();
645
+ } catch {
646
+ return false;
647
+ }
648
+ }) ?? candidates[0]
649
+ );
650
+ }
651
+
652
+ /**
653
+ * A path as a build header names it: relative to `base`, with `/`.
654
+ * @param {string} base
655
+ * @param {string} file absolute
656
+ */
657
+ function headerPath(base, file) {
658
+ return path.relative(base, file).split(path.sep).join('/');
659
+ }
660
+
581
661
  /**
582
662
  * Build a @generated attribution header for generated files.
583
663
  * @param {string} sourceFile - Relative path to the source theme file
@@ -820,7 +900,12 @@ function themeFilesIn(dir) {
820
900
  try {
821
901
  return fs
822
902
  .readdirSync(dir)
823
- .filter(name => /(?:\.theme|Theme)\.(?:[cm]?[jt]sx?)$/.test(name))
903
+ .filter(
904
+ name =>
905
+ /(?:\.theme|Theme)\.[^.]+$/.test(name) &&
906
+ THEME_SOURCE_EXTENSIONS.includes(path.extname(name)) &&
907
+ !fileHead(path.join(dir, name)).includes(GENERATED_MARKER),
908
+ )
824
909
  .sort()
825
910
  .slice(0, 3);
826
911
  } catch {
@@ -828,12 +913,109 @@ function themeFilesIn(dir) {
828
913
  }
829
914
  }
830
915
 
916
+ /**
917
+ * Theme sources a missing build input probably meant, relative to `cwd`: the
918
+ * same path with `/` for `\`; or, for a bare theme name, the theme sources in
919
+ * `themes/<name>/` and `src/themes/<name>/` of the project, and `<name>` with a
920
+ * theme source extension. A build output is never offered.
921
+ * @param {string} file the input as given
922
+ * @param {string} cwd
923
+ * @returns {string[]} at most three paths
924
+ */
925
+ export function themeSourceGuesses(file, cwd) {
926
+ const shown = (/** @type {string} */ absolute) =>
927
+ path.relative(cwd, absolute).split(path.sep).join('/');
928
+ const isSource = (/** @type {string} */ absolute) =>
929
+ fs.existsSync(absolute) &&
930
+ !fs.statSync(absolute).isDirectory() &&
931
+ !fileHead(absolute).includes(GENERATED_MARKER);
932
+ if (file.includes('\\')) {
933
+ const forward = path.resolve(cwd, file.replace(/\\/g, '/'));
934
+ return isSource(forward) ? [shown(forward)] : [];
935
+ }
936
+ if (/[/.]/.test(file)) return [];
937
+ const root = findPackageRoot(cwd) ?? cwd;
938
+ const guesses = [
939
+ path.join(root, 'themes', file),
940
+ path.join(root, 'src', 'themes', file),
941
+ ].flatMap(folder =>
942
+ themeFilesIn(folder).map(name => shown(path.join(folder, name))),
943
+ );
944
+ for (const extension of THEME_SOURCE_EXTENSIONS) {
945
+ const candidate = path.resolve(cwd, file + extension);
946
+ if (isSource(candidate)) guesses.push(shown(candidate));
947
+ }
948
+ return guesses.slice(0, 3);
949
+ }
950
+
951
+ /**
952
+ * Refuse a file that is not a theme source before loading it: an output of a
953
+ * build (it carries the `@generated` header, whatever its extension, and
954
+ * names the source it was built from), or a file whose extension no theme
955
+ * source has, such as `.css` or `.json` (THEME_SOURCE_EXTENSIONS).
956
+ * @param {string} filePath
957
+ * @param {string} cwd
958
+ */
959
+ function assertThemeSourceFile(filePath, cwd) {
960
+ const rel = (/** @type {string} */ file) => path.relative(cwd, file);
961
+ const sourceHead = fileHead(filePath);
962
+ if (sourceHead.includes(GENERATED_MARKER)) {
963
+ const line = /Source: (.+)/.exec(sourceHead)?.[1]?.trim();
964
+ // The header names its sources from the outputs' project root; the
965
+ // command to build them names them from the working folder.
966
+ const sources = line
967
+ ? line.split(', ').map(name =>
968
+ rel(headerSourceFile(filePath, name.trim(), cwd))
969
+ .split(path.sep)
970
+ .join('/'),
971
+ )
972
+ : [];
973
+ const familyKey = /Command: .*--family-key (\S+)/.exec(sourceHead)?.[1];
974
+ const build =
975
+ sources.length > 1 && familyKey
976
+ ? `theme build --family ${sources.map(shellWord).join(' ')} --family-key ${shellWord(familyKey)}`
977
+ : sources.length > 0
978
+ ? `theme build ${shellWord(sources[0])}`
979
+ : null;
980
+ throw new AstryxError(
981
+ `${rel(filePath)} is an output of \`theme build\`, not a theme source.${sources.length > 0 ? ` It was built from ${sources.join(', ')}.` : ''}`,
982
+ build
983
+ ? [
984
+ {
985
+ name: formatCliCommand(build, cwd),
986
+ reason: 'build the theme source',
987
+ },
988
+ ]
989
+ : undefined,
990
+ ERROR_CODES.ERR_THEME_INVALID,
991
+ );
992
+ }
993
+ if (!THEME_SOURCE_EXTENSIONS.includes(path.extname(filePath).toLowerCase())) {
994
+ throw new AstryxError(
995
+ `${rel(filePath)} is not a theme module. A theme source is a ${THEME_SOURCE_EXTENSIONS.join(', ')} file that exports defineTheme(...).`,
996
+ themeFilesIn(path.dirname(filePath)).map(name => ({
997
+ name: formatCliCommand(
998
+ `theme build ${shellWord(
999
+ rel(path.join(path.dirname(filePath), name))
1000
+ .split(path.sep)
1001
+ .join('/'),
1002
+ )}`,
1003
+ cwd,
1004
+ ),
1005
+ reason: 'a theme source in that folder',
1006
+ })),
1007
+ ERROR_CODES.ERR_THEME_LOAD,
1008
+ );
1009
+ }
1010
+ }
1011
+
831
1012
  /**
832
1013
  * Refuse a build that would replace a file it does not own. A build never
833
1014
  * writes over its input, two of its own outputs at one path, or an output
834
- * another theme in the same run already wrote. With `refuseUnmarked`, it also
835
- * replaces only its own earlier outputs (they carry the `@generated` header)
836
- * and empty files, never another file such as `package.json` or app source.
1015
+ * another theme in the same run already wrote. With `refuseUnmarked` (a path
1016
+ * --out names), it also replaces only its own earlier outputs (their header
1017
+ * names this source, or a source that is gone) and empty files, never another
1018
+ * source's output or another file such as `package.json` or app source.
837
1019
  * @param {Array<{dest: string}>} writes
838
1020
  * @param {string} filePath the theme source
839
1021
  * @param {string} cwd
@@ -850,23 +1032,8 @@ function assertOutputsReplaceable(
850
1032
  ) {
851
1033
  const rel = (/** @type {string} */ file) => path.relative(cwd, file);
852
1034
  const sourceKey = outputKey(filePath);
853
- const sourceHead = fileHead(filePath);
854
- if (sourceHead.includes(GENERATED_MARKER)) {
855
- const from = /Source: (.+)/.exec(sourceHead)?.[1]?.trim();
856
- throw new AstryxError(
857
- `${rel(filePath)} is an output of \`theme build\`, not a theme source.${from ? ` It was built from ${from}.` : ''}`,
858
- from
859
- ? [
860
- {
861
- name: formatCliCommand(`theme build ${shellWord(from)}`, cwd),
862
- reason: 'build the theme source',
863
- },
864
- ]
865
- : undefined,
866
- ERROR_CODES.ERR_THEME_INVALID,
867
- );
868
- }
869
1035
  const seen = new Set();
1036
+ let warnedOtherSource = false;
870
1037
  for (const write of writes) {
871
1038
  const key = outputKey(write.dest);
872
1039
  if (key === sourceKey) {
@@ -894,11 +1061,13 @@ function assertOutputsReplaceable(
894
1061
  seen.add(key);
895
1062
  const earlier = claimed?.get(key);
896
1063
  if (earlier !== undefined) {
897
- throw new AstryxError(
898
- `${earlier} already wrote ${rel(write.dest)} in this run. Two themes build the same outputs; give each theme its own name.`,
1064
+ const collision = new AstryxError(
1065
+ `${earlier} and ${rel(filePath)} both build ${rel(write.dest)}. Give each theme its own name; nothing was written.`,
899
1066
  undefined,
900
1067
  ERROR_CODES.ERR_THEME_INVALID,
901
1068
  );
1069
+ /** @type {any} */ (collision).outputCollision = true;
1070
+ throw collision;
902
1071
  }
903
1072
  let stat;
904
1073
  try {
@@ -913,6 +1082,33 @@ function assertOutputsReplaceable(
913
1082
  ERROR_CODES.ERR_INVALID_ARGUMENT,
914
1083
  );
915
1084
  }
1085
+ // Only a path --out names is checked: at the default paths beside the
1086
+ // source, a build replaces what is there, as it always has.
1087
+ const otherSource = refuseUnmarked
1088
+ ? builtFromOtherSource(write.dest, filePath, cwd)
1089
+ : null;
1090
+ if (otherSource && !OUT_REFUSES_OTHER_SOURCE) {
1091
+ // One warning per build: every output of that source goes together.
1092
+ if (warnedOtherSource) continue;
1093
+ warnedOtherSource = true;
1094
+ logger.warn(
1095
+ `Warning: ${rel(write.dest)} was built from ${otherSource}; this build of ${rel(filePath)} replaces it.`,
1096
+ );
1097
+ } else if (otherSource) {
1098
+ throw new AstryxError(
1099
+ `${rel(write.dest)} is the build output of another theme source, ${otherSource}, so this build does not replace it. Pick another ${elsewhere}.`,
1100
+ [
1101
+ {
1102
+ name: formatCliCommand(
1103
+ `theme build ${shellWord(rel(filePath))}`,
1104
+ cwd,
1105
+ ),
1106
+ reason: 'write the outputs beside this source',
1107
+ },
1108
+ ],
1109
+ ERROR_CODES.ERR_FILE_EXISTS,
1110
+ );
1111
+ }
916
1112
  // Outputs from CLIs before 0.6.7 have no header, so they read as files
917
1113
  // the build did not write; only the user can say they may go.
918
1114
  if (
@@ -936,6 +1132,46 @@ function assertOutputsReplaceable(
936
1132
  }
937
1133
  }
938
1134
 
1135
+ /**
1136
+ * The other theme source a build output names in its `Source:` header, when
1137
+ * that source still exists and is not `source`. The name is resolved as
1138
+ * headerSourceCandidates says; a match is exact. A family output names
1139
+ * every member, and is this source's when any of them is. Null when the output is this source's,
1140
+ * names no source, or names one that is gone (an orphan a build may replace).
1141
+ * @param {string} dest
1142
+ * @param {string} source absolute theme source
1143
+ * @param {string} cwd
1144
+ * @returns {string | null}
1145
+ */
1146
+ function builtFromOtherSource(dest, source, cwd) {
1147
+ const head = fileHead(dest);
1148
+ if (!head.includes(GENERATED_MARKER)) return null;
1149
+ const line = /Source: (.+)/.exec(head)?.[1]?.trim();
1150
+ if (!line) return null;
1151
+ const names = line.split(', ').map(name => name.trim());
1152
+ const own = path.resolve(source);
1153
+ const candidates = names.flatMap(name =>
1154
+ headerSourceCandidates(dest, name, cwd),
1155
+ );
1156
+ if (candidates.includes(own)) return null;
1157
+ const existing = candidates.find(file => {
1158
+ try {
1159
+ return fs.statSync(file).isFile();
1160
+ } catch {
1161
+ return false;
1162
+ }
1163
+ });
1164
+ return existing ? path.relative(cwd, existing) || existing : null;
1165
+ }
1166
+
1167
+ /**
1168
+ * Publish the outputs a batch deferred, one theme at a time, in build order.
1169
+ * @param {Array<Array<{dest: string, content: string}>>} deferred
1170
+ */
1171
+ export function writeDeferredBuildOutputs(deferred) {
1172
+ for (const writes of deferred.splice(0)) writeBuildOutputs(writes);
1173
+ }
1174
+
939
1175
  /** @param {Array<{dest: string, content: string}>} writes */
940
1176
  function writeBuildOutputs(writes) {
941
1177
  if (writes.length === 0) return;
@@ -1972,17 +2208,24 @@ const THEME_SCOPE_TO = `[data-astryx-theme]`;
1972
2208
  * the author's TypeScript sees, which is the point: the CSS the build emits
1973
2209
  * matches the theme they type-checked.
1974
2210
  */
2211
+ // Every theme source extension is in this list: jiti hands a file whose
2212
+ // extension it does not list to Node's own loader, which cannot load `.jsx`
2213
+ // or, on some Node versions, TypeScript.
1975
2214
  const THEME_MODULE_EXTENSIONS = [
1976
- '.ts',
1977
- '.tsx',
1978
- '.mts',
1979
- '.cts',
1980
- '.mtsx',
1981
- '.ctsx',
1982
- '.mjs',
1983
- '.cjs',
1984
- '.js',
1985
- '.json',
2215
+ ...new Set([
2216
+ '.ts',
2217
+ '.tsx',
2218
+ '.mts',
2219
+ '.cts',
2220
+ '.mtsx',
2221
+ '.ctsx',
2222
+ '.mjs',
2223
+ '.cjs',
2224
+ '.js',
2225
+ '.jsx',
2226
+ '.json',
2227
+ ...THEME_SOURCE_EXTENSIONS,
2228
+ ]),
1986
2229
  ];
1987
2230
  // prettier-ignore
1988
2231
  const registryGraphError = (/** @type {string} */ message) => new AstryxError(message, undefined, ERROR_CODES.ERR_THEME_INVALID);
@@ -2328,12 +2571,10 @@ function themeLoadReason(error) {
2328
2571
  ) {
2329
2572
  return `its default export is null or not an object.\n${THEME_EXPORT_FIX}`;
2330
2573
  }
2331
- const missing =
2332
- /Cannot find (?:module|package) '((?:@[^/']+\/)?[^/'.][^/']*)/.exec(
2333
- message,
2334
- )?.[1];
2574
+ const missing = missingThemePackage(error);
2335
2575
  if (missing) {
2336
- return `${message}\nThe theme imports ${missing}, which is not installed. Install it (for example \`npm install ${missing}\`), then build again.`;
2576
+ // Node's "Require stack" names absolute paths; the package is the fact.
2577
+ return `Cannot find module '${missing}'.\nThe theme imports ${missing}, which is not installed. Install it, then build again.`;
2337
2578
  }
2338
2579
  return `${message}\nMake sure all imports in the theme file are resolvable.`;
2339
2580
  }
@@ -2341,6 +2582,62 @@ function themeLoadReason(error) {
2341
2582
  /** A theme module that loaded but exports no theme object. */
2342
2583
  class ThemeShapeError extends Error {}
2343
2584
 
2585
+ /**
2586
+ * The command that moves a failed theme load forward: the install for a
2587
+ * package the theme imports and the app lacks, the same build for a file that
2588
+ * changed while it loaded, else the annotated template, which shows a theme
2589
+ * source that loads.
2590
+ * @param {Error} error
2591
+ * @param {string} shown the theme file as the message names it
2592
+ * @param {string} cwd
2593
+ * @returns {import('../../../foundation/response/base').Suggestion[]}
2594
+ */
2595
+ function themeLoadSuggestions(error, shown, cwd) {
2596
+ const missing = missingThemePackage(error.cause ?? error);
2597
+ if (missing) {
2598
+ const {installCommand} = installCommandFor(
2599
+ [missing],
2600
+ findPackageRoot(cwd) ?? cwd,
2601
+ );
2602
+ if (installCommand) {
2603
+ return [
2604
+ {
2605
+ name: installCommand,
2606
+ reason: `install ${missing}, which the theme imports`,
2607
+ },
2608
+ ];
2609
+ }
2610
+ }
2611
+ if (/changed while it was loading/.test(error.message)) {
2612
+ return [
2613
+ {
2614
+ name: formatCliCommand(`theme build ${shellWord(shown)}`, cwd),
2615
+ reason: 'build again once the file is saved',
2616
+ },
2617
+ ];
2618
+ }
2619
+ return [
2620
+ {
2621
+ name: formatCliCommand('theme template theme.template.ts', cwd),
2622
+ reason: 'an annotated theme source that loads, to compare with',
2623
+ },
2624
+ ];
2625
+ }
2626
+
2627
+ /**
2628
+ * The package a theme load failed on because it is not installed.
2629
+ * @param {unknown} error
2630
+ * @returns {string | null}
2631
+ */
2632
+ export function missingThemePackage(error) {
2633
+ const message = error instanceof Error ? error.message : String(error);
2634
+ return (
2635
+ /Cannot find (?:module|package) '((?:@[^/']+\/)?[^/'.][^/']*)/.exec(
2636
+ message,
2637
+ )?.[1] ?? null
2638
+ );
2639
+ }
2640
+
2344
2641
  /**
2345
2642
  * Load one theme through the build's real module loader and validate the raw
2346
2643
  * input captured from its defineTheme lineage. Used by doctor so it applies the
@@ -2581,7 +2878,7 @@ function importStatement({importPath, importedName, localName}, specifier) {
2581
2878
  * @param {any} themeDef
2582
2879
  * @param {import('./icon-imports.mjs').IconImports | null} iconInfo
2583
2880
  * @param {string} [iconsSpecifier] - Overrides the selected registry specifier.
2584
- * @param {{themeBinding?: string, iconsExpression?: string, indicatorsExpression?: string, artifactBaseName?: string, exportIcons?: boolean, componentIconInfo?: {imports: import('./icon-imports.mjs').IconImports['imports'], expression: string, mergeName?: string} | null}} [moduleOptions]
2881
+ * @param {{themeBinding?: string, iconsExpression?: string, indicatorsExpression?: string, artifactBaseName?: string, cssFileName?: string, exportIcons?: boolean, componentIconInfo?: {imports: import('./icon-imports.mjs').IconImports['imports'], expression: string, mergeName?: string} | null}} [moduleOptions]
2585
2882
  * @returns {string}
2586
2883
  */
2587
2884
  function generateBuiltModule(
@@ -2593,6 +2890,7 @@ function generateBuiltModule(
2593
2890
  const themeBinding =
2594
2891
  moduleOptions.themeBinding ?? `${toIdentifier(themeDef.name)}Theme`;
2595
2892
  const artifactBaseName = moduleOptions.artifactBaseName ?? themeDef.name;
2893
+ const cssFileName = moduleOptions.cssFileName ?? `${artifactBaseName}.css`;
2596
2894
  const exportIcons = moduleOptions.exportIcons ?? true;
2597
2895
  const iconImport = (iconInfo?.imports ?? [])
2598
2896
  .map(binding =>
@@ -2743,7 +3041,7 @@ function generateBuiltModule(
2743
3041
  * Import the CSS file alongside this module:
2744
3042
  *
2745
3043
  * import { ${themeBinding} } from './${artifactBaseName}';
2746
- * import './${artifactBaseName}.css';
3044
+ * import './${cssFileName}';
2747
3045
  */
2748
3046
  export const ${themeBinding} = {
2749
3047
  name: '${themeDef.name}',
@@ -3156,10 +3454,12 @@ function validateHeadingTypeAugmentationSupport(themeDef) {
3156
3454
  * `logger` (silent by default).
3157
3455
  *
3158
3456
  * @param {string} file - Theme file path, resolved against `cwd`.
3159
- * @param {{out?: string, check?: boolean, iconsSpecifier?: string, __prepareFamily?: boolean, __familyLoader?: any, __familyInterception?: any, __onPrivateVarError?: () => void, __writeRoot?: string, __claimedOutputs?: Map<string, string>}} [options] -
3457
+ * @param {{out?: string, check?: boolean, iconsSpecifier?: string, __prepareFamily?: boolean, __familyLoader?: any, __familyInterception?: any, __onPrivateVarError?: () => void, __writeRoot?: string, __claimedOutputs?: Map<string, string>, __deferredWrites?: Array<Array<{dest: string, content: string}>>, __commandWords?: {group: string, build: string}}} [options] -
3160
3458
  * `out` overrides the output CSS path, or names the folder for it; `check` compares against on-disk outputs
3161
3459
  * instead of writing. `__claimedOutputs` records the outputs earlier builds
3162
- * in one run wrote, so a later theme cannot replace them. `__writeRoot` replaces `cwd` as the directory every
3460
+ * in one run wrote, so a later theme cannot replace them; with
3461
+ * `__deferredWrites` the build adds its outputs to that list instead of
3462
+ * writing them, for writeDeferredBuildOutputs. `__writeRoot` replaces `cwd` as the directory every
3163
3463
  * output must stay inside, for a CLI-internal scratch build. `iconsSpecifier` overrides the icon registry import
3164
3464
  * specifier in the generated module (e.g. `./icons.mjs`); when omitted, the
3165
3465
  * direct registry specifiers from the theme source are emitted unchanged.
@@ -3178,7 +3478,10 @@ async function themeBuildInternal(
3178
3478
  if (!fs.existsSync(filePath)) {
3179
3479
  throw new AstryxError(
3180
3480
  `File not found: ${filePath}`,
3181
- undefined,
3481
+ themeSourceGuesses(file, cwd).map(guess => ({
3482
+ name: formatCliCommand(`theme build ${shellWord(guess)}`, cwd),
3483
+ reason: 'a theme source that exists',
3484
+ })),
3182
3485
  ERROR_CODES.ERR_FILE_NOT_FOUND,
3183
3486
  );
3184
3487
  }
@@ -3197,6 +3500,8 @@ async function themeBuildInternal(
3197
3500
  );
3198
3501
  }
3199
3502
 
3503
+ assertThemeSourceFile(filePath, cwd);
3504
+
3200
3505
  if (!report.compact) {
3201
3506
  logger.log(`\nBuilding theme from ${path.relative(cwd, filePath)}...`);
3202
3507
  }
@@ -3258,7 +3563,12 @@ async function themeBuildInternal(
3258
3563
  loadDegradation = loaded.degraded;
3259
3564
  } catch (e) {
3260
3565
  const err = /** @type {Error} */ (e);
3261
- throw new AstryxError(err.message, undefined, ERROR_CODES.ERR_THEME_LOAD);
3566
+ const shown = path.relative(cwd, filePath) || filePath;
3567
+ throw new AstryxError(
3568
+ err.message.split(filePath).join(shown),
3569
+ themeLoadSuggestions(err, shown, cwd),
3570
+ ERROR_CODES.ERR_THEME_LOAD,
3571
+ );
3262
3572
  }
3263
3573
 
3264
3574
  // The marker is scoped to that isolated load: drop it before the theme
@@ -3288,9 +3598,15 @@ async function themeBuildInternal(
3288
3598
  interception && hasCoverageGap ? interception.unobservedIn(themeDef) : [];
3289
3599
  if (interception) interception.strip(themeDef);
3290
3600
  if (!ancestryObserved) {
3601
+ const shown = path.relative(cwd, filePath);
3291
3602
  throw new AstryxError(
3292
- `Theme "${themeDef.name ?? path.basename(filePath)}" exact family ancestry could not be observed during CLI loading.`,
3293
- undefined,
3603
+ `Theme "${themeDef.name ?? path.basename(filePath)}" in ${shown} is a plain object, so a family build cannot see which theme it extends. A family member is made with defineTheme(...) from @astryxdesign/core/theme; build a plain-object theme on its own.`,
3604
+ [
3605
+ {
3606
+ name: formatCliCommand(`theme build ${shellWord(shown)}`, cwd),
3607
+ reason: 'build this theme on its own',
3608
+ },
3609
+ ],
3294
3610
  ERROR_CODES.ERR_THEME_INVALID,
3295
3611
  );
3296
3612
  }
@@ -3700,7 +4016,8 @@ async function themeBuildInternal(
3700
4016
 
3701
4017
  // Source path relative to cwd — used in @generated headers
3702
4018
  const sourceRelative = path.relative(cwd, filePath);
3703
- const buildCommand = `astryx theme build ${sourceRelative}${options.out ? ' --out ' + path.relative(cwd, path.resolve(cwd, options.out)) : ''}`;
4019
+ // What `--check` prints to rebuild, from the working folder.
4020
+ const rebuildCommand = `astryx theme build ${sourceRelative}${options.out ? ' --out ' + path.relative(cwd, path.resolve(cwd, options.out)) : ''}`;
3704
4021
  // Stable provenance recorded in @generated headers — versions, not a
3705
4022
  // timestamp, so identical inputs produce byte-identical output.
3706
4023
  const versions = resolveToolVersions(cwd);
@@ -3719,6 +4036,18 @@ async function themeBuildInternal(
3719
4036
  if (/[\\/]$/.test(options.out) || isDirectorySync(outPath)) {
3720
4037
  outPath = path.join(outPath, `${baseName}.css`);
3721
4038
  }
4039
+ // The stylesheet is CSS whatever its name; a name that does not end in
4040
+ // .css still builds, and the module's import names the file as written.
4041
+ if (path.extname(outPath).toLowerCase() !== '.css') {
4042
+ const stem = path.basename(outPath).replace(/(?:\.d)?\.[^.]+$/, '');
4043
+ const fixed = path
4044
+ .join(path.dirname(options.out), `${stem}.css`)
4045
+ .split(path.sep)
4046
+ .join('/');
4047
+ logger.warn(
4048
+ `Warning: --out names the stylesheet, which is CSS; give it a .css name such as ${fixed}.`,
4049
+ );
4050
+ }
3722
4051
  // A build keeps the explicit output inside the write root, relative or
3723
4052
  // absolute. Check mode writes nothing, so it refuses only a relative path
3724
4053
  // that escapes cwd.
@@ -3728,6 +4057,12 @@ async function themeBuildInternal(
3728
4057
  } else {
3729
4058
  outPath = path.join(path.dirname(filePath), `${baseName}.css`);
3730
4059
  }
4060
+ // The header names the source and command from the project root of the
4061
+ // outputs, so a build from any folder writes the same bytes, `--check`
4062
+ // agrees with it, and a later build reads the source back exactly.
4063
+ const headerBase = headerRoot(path.dirname(outPath), cwd);
4064
+ const headerSource = headerPath(headerBase, filePath);
4065
+ const buildCommand = `astryx theme build ${headerSource}${options.out ? ' --out ' + headerPath(headerBase, outPath) : ''}`;
3731
4066
 
3732
4067
  const displayTheme = resolvedTheme || themeDef;
3733
4068
  const tokenCount =
@@ -3759,31 +4094,38 @@ async function themeBuildInternal(
3759
4094
  ? path.join(outDir, variantsFileName)
3760
4095
  : null;
3761
4096
  const variantContent = variantDecl
3762
- ? generatedHeader(sourceRelative, 'ts', buildCommand, versions) +
3763
- variantDecl
4097
+ ? generatedHeader(headerSource, 'ts', buildCommand, versions) + variantDecl
3764
4098
  : null;
3765
4099
 
3766
4100
  // Generate all file contents in memory first. The main .d.ts references
3767
4101
  // the variants file (when present) via a triple-slash directive so
3768
4102
  // importing the theme also loads the custom-variant augmentations.
3769
4103
  const cssContent =
3770
- generatedHeader(sourceRelative, 'css', buildCommand, versions) + css;
4104
+ generatedHeader(headerSource, 'css', buildCommand, versions) + css;
3771
4105
  const cssDtsContent =
3772
- generatedHeader(sourceRelative, 'ts', buildCommand, versions) +
4106
+ generatedHeader(headerSource, 'ts', buildCommand, versions) +
3773
4107
  'export {};\n';
3774
4108
  // A family member's module is generated by themeBuildFamily, which carries
3775
4109
  // its registries and slot functions through the family's own imports.
3776
4110
  const jsContent = options.__prepareFamily
3777
4111
  ? ''
3778
- : generatedHeader(sourceRelative, 'js', buildCommand, versions) +
4112
+ : generatedHeader(headerSource, 'js', buildCommand, versions) +
3779
4113
  generateBuiltModule(
3780
4114
  resolvedTheme || themeDef,
3781
4115
  iconInfo,
3782
4116
  options.iconsSpecifier,
3783
- {componentIconInfo},
4117
+ {
4118
+ componentIconInfo,
4119
+ // A stylesheet named other than `.css` is named as written. A
4120
+ // `.css` name keeps the theme's own name in the module, so the
4121
+ // module is the same whatever `--out` names the stylesheet.
4122
+ ...(path.extname(outPath).toLowerCase() === '.css'
4123
+ ? {}
4124
+ : {cssFileName: path.basename(outPath)}),
4125
+ },
3784
4126
  );
3785
4127
  const dtsContent =
3786
- generatedHeader(sourceRelative, 'ts', buildCommand, versions) +
4128
+ generatedHeader(headerSource, 'ts', buildCommand, versions) +
3787
4129
  generateBuiltTypes(resolvedTheme || themeDef, iconInfo, variantsFileName);
3788
4130
 
3789
4131
  const unloadedFonts = [
@@ -3849,12 +4191,15 @@ async function themeBuildInternal(
3849
4191
  if (options.check) {
3850
4192
  const stale = staleBuildOutputs(writes, cwd);
3851
4193
  const upToDate = stale.length === 0;
4194
+ const checkedLine = ` checked: ${checkedBuildOutputs(writes, cwd).join(', ')}`;
3852
4195
  if (upToDate) {
3853
4196
  logger.log(`\n[ok] Theme outputs are up to date with ${sourceRelative}.`);
4197
+ logger.log(checkedLine);
3854
4198
  } else {
3855
4199
  logger.error(
3856
4200
  `\n[fail] ${stale.length} theme output(s) are out of date with ${sourceRelative}:`,
3857
4201
  );
4202
+ logger.error(checkedLine);
3858
4203
  for (const s of stale) {
3859
4204
  logger.error(
3860
4205
  ` ${s.reason === 'missing' ? 'missing' : 'stale'}: ${s.path}`,
@@ -3863,7 +4208,10 @@ async function themeBuildInternal(
3863
4208
  // prettier-ignore
3864
4209
  const remedy = outsideCheckRemedy(writes, [filePath], writeRoot, relative => [relative(filePath), ...(options.out ? ['--out', relative(outPath)] : []), ...(options.iconsSpecifier ? ['--icons-specifier', options.iconsSpecifier] : [])]);
3865
4210
  if (remedy) logger.error(`\n ${remedy.join('\n ')}`);
3866
- else logger.error(`\n Rebuild with: ${buildCommand}`);
4211
+ else
4212
+ logger.error(
4213
+ `\n Rebuild with: ${rebuildLine(rebuildCommand, options.__commandWords)}`,
4214
+ );
3867
4215
  }
3868
4216
  return {
3869
4217
  type: 'theme.build.check',
@@ -3876,7 +4224,10 @@ async function themeBuildInternal(
3876
4224
  };
3877
4225
  }
3878
4226
 
3879
- writeBuildOutputs(writes);
4227
+ // A batch publishes every theme's outputs after all of them are built, so
4228
+ // two themes that build the same files are refused before either writes.
4229
+ if (options.__deferredWrites) options.__deferredWrites.push(writes);
4230
+ else writeBuildOutputs(writes);
3880
4231
  for (const write of writes) {
3881
4232
  options.__claimedOutputs?.set(outputKey(write.dest), sourceRelative);
3882
4233
  }
@@ -3899,9 +4250,8 @@ async function themeBuildInternal(
3899
4250
  }
3900
4251
 
3901
4252
  const relOutDir = path.relative(cwd, outDir) || '.';
3902
- const cssBase = path.basename(outPath, '.css');
3903
4253
  const jsImport = importSpecifier(relOutDir, baseName);
3904
- const cssImport = importSpecifier(relOutDir, cssBase) + '.css';
4254
+ const cssImport = importSpecifier(relOutDir, path.basename(outPath));
3905
4255
  const exportName = `${toIdentifier(baseName)}Theme`;
3906
4256
 
3907
4257
  // Fonts the theme names but nothing loads (#5015). Resolved tokens and
@@ -4260,7 +4610,7 @@ async function preloadFamilySource(filePath, loader, interception) {
4260
4610
  finally { patch.undo(); }
4261
4611
  }
4262
4612
 
4263
- /** @param {string[]} files @param {{familyKey: string, check?: boolean, iconsSpecifier?: string, __onPrivateVarError?: () => void}} options @param {{cwd?: string}} [ctx] */
4613
+ /** @param {string[]} files @param {{familyKey: string, check?: boolean, iconsSpecifier?: string, __onPrivateVarError?: () => void, __commandWords?: {group: string, build: string}}} options @param {{cwd?: string}} [ctx] */
4264
4614
  export async function themeBuildFamily(
4265
4615
  files,
4266
4616
  options,
@@ -4380,9 +4730,15 @@ export async function themeBuildFamily(
4380
4730
  const sourceRelative = members
4381
4731
  .map(member => member.sourceRelative)
4382
4732
  .join(', ');
4383
- const buildCommand = `${getCliInvocation()} theme build --family ${members
4733
+ const rebuildCommand = `${getCliInvocation()} theme build --family ${members
4384
4734
  .map(member => member.sourceRelative)
4385
4735
  .join(' ')} --family-key ${baseName}`;
4736
+ const headerBase = headerRoot(outDir, cwd);
4737
+ const headerSources = members.map(member =>
4738
+ headerPath(headerBase, member.filePath),
4739
+ );
4740
+ const headerSource = headerSources.join(', ');
4741
+ const buildCommand = `astryx theme build --family ${headerSources.join(' ')} --family-key ${baseName}`;
4386
4742
  const bindings = allocateFamilyBindings(members);
4387
4743
  const css = generateFamilyCSS(members);
4388
4744
  /** @type {Array<{specifier: string, exportName: string}>} */
@@ -4461,25 +4817,24 @@ export async function themeBuildFamily(
4461
4817
  {
4462
4818
  dest: outPath,
4463
4819
  content:
4464
- generatedHeader(sourceRelative, 'css', buildCommand, root.versions) +
4465
- css,
4820
+ generatedHeader(headerSource, 'css', buildCommand, root.versions) + css,
4466
4821
  },
4467
4822
  {
4468
4823
  dest: cssDtsPath,
4469
4824
  allowMissingInCheck: true,
4470
4825
  content:
4471
- generatedHeader(sourceRelative, 'ts', buildCommand, root.versions) +
4826
+ generatedHeader(headerSource, 'ts', buildCommand, root.versions) +
4472
4827
  'export {};\n',
4473
4828
  },
4474
4829
  {
4475
4830
  dest: jsPath,
4476
4831
  content:
4477
- generatedHeader(sourceRelative, 'js', buildCommand, root.versions) + js,
4832
+ generatedHeader(headerSource, 'js', buildCommand, root.versions) + js,
4478
4833
  },
4479
4834
  {
4480
4835
  dest: dtsPath,
4481
4836
  content:
4482
- generatedHeader(sourceRelative, 'ts', buildCommand, root.versions) +
4837
+ generatedHeader(headerSource, 'ts', buildCommand, root.versions) +
4483
4838
  declarations +
4484
4839
  (augmentations ? `\n${augmentations}` : ''),
4485
4840
  },
@@ -4502,14 +4857,17 @@ export async function themeBuildFamily(
4502
4857
  if (options.check) {
4503
4858
  const stale = staleBuildOutputs(writes, cwd);
4504
4859
  const upToDate = stale.length === 0;
4860
+ const checkedLine = ` checked: ${checkedBuildOutputs(writes, cwd).join(', ')}`;
4505
4861
  if (upToDate) {
4506
4862
  logger.log(
4507
4863
  `\n[ok] Theme family outputs are up to date with ${sourceRelative}.`,
4508
4864
  );
4865
+ logger.log(checkedLine);
4509
4866
  } else {
4510
4867
  logger.error(
4511
4868
  `\n[fail] ${stale.length} theme family output(s) are out of date:`,
4512
4869
  );
4870
+ logger.error(checkedLine);
4513
4871
  for (const entry of stale) {
4514
4872
  logger.error(
4515
4873
  ` ${entry.reason === 'missing' ? 'missing' : 'stale'}: ${entry.path}`,
@@ -4518,7 +4876,10 @@ export async function themeBuildFamily(
4518
4876
  // prettier-ignore
4519
4877
  const remedy = outsideCheckRemedy(writes, members.map(member => member.filePath), cwd, relative => ['--family', ...members.map(member => relative(member.filePath)), '--family-key', baseName, ...(options.iconsSpecifier ? ['--icons-specifier', options.iconsSpecifier] : [])]);
4520
4878
  if (remedy) logger.error(`\n ${remedy.join('\n ')}`);
4521
- else logger.error(`\n Rebuild with: ${buildCommand}`);
4879
+ else
4880
+ logger.error(
4881
+ `\n Rebuild with: ${rebuildLine(rebuildCommand, options.__commandWords)}`,
4882
+ );
4522
4883
  }
4523
4884
  return {
4524
4885
  type: 'theme.build.check',