@astryxdesign/cli 0.7.15 → 0.7.16-canary.g3aa244b

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 (163) 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 +35 -0
  8. package/api/doctor/_adapter.mjs +69 -0
  9. package/api/doctor/built-checks.mjs +1 -1
  10. package/api/doctor/doctor.d.mts +18 -0
  11. package/api/doctor/doctor.doc.mjs +1 -1
  12. package/api/doctor/doctor.mjs +104 -4
  13. package/api/doctor/theme-checks.mjs +6 -10
  14. package/api/integration/add-contribution.mjs +3 -3
  15. package/api/integration/pack-check.mjs +14 -8
  16. package/api/integration/validate-integration.mjs +1 -1
  17. package/api/search/_adapter.mjs +15 -16
  18. package/api/search/_entries.d.mts +2 -1
  19. package/api/search/_entries.mjs +28 -1
  20. package/api/swizzle/_moduleGraph.mjs +1 -1
  21. package/api/theme/_adapter.d.mts +5 -2
  22. package/api/theme/_adapter.mjs +43 -12
  23. package/api/theme/_fork.mjs +1 -1
  24. package/api/theme/build/build.d.mts +116 -32
  25. package/api/theme/build/build.mjs +449 -102
  26. package/api/theme/eject/eject.mjs +22 -1
  27. package/api/theme/template/template.d.mts +19 -0
  28. package/api/theme/template/template.mjs +102 -25
  29. package/api/theme/theme.type.d.mts +5 -1
  30. package/api/theme/theme.type.mjs +2 -1
  31. package/api/theme/themeBuild.doc.mjs +3 -3
  32. package/api/theme/themeEject.doc.mjs +1 -1
  33. package/api/theme/themeTemplate.doc.mjs +9 -3
  34. package/api/theme-edit/_adapter.d.mts +32 -2
  35. package/api/theme-edit/_adapter.mjs +264 -40
  36. package/api/theme-edit/_check.d.mts +93 -4
  37. package/api/theme-edit/_check.mjs +1727 -223
  38. package/api/theme-edit/_color.d.mts +2 -8
  39. package/api/theme-edit/_color.mjs +292 -219
  40. package/api/theme-edit/_compiler.d.mts +1 -0
  41. package/api/theme-edit/_compiler.mjs +20 -1
  42. package/api/theme-edit/_context.d.mts +31 -1
  43. package/api/theme-edit/_context.mjs +445 -41
  44. package/api/theme-edit/_css.d.mts +60 -1
  45. package/api/theme-edit/_css.mjs +404 -28
  46. package/api/theme-edit/_edit.d.mts +25 -0
  47. package/api/theme-edit/_edit.mjs +1532 -149
  48. package/api/theme-edit/_how-commands.d.mts +11 -26
  49. package/api/theme-edit/_how-commands.mjs +30 -2
  50. package/api/theme-edit/_how-question.d.mts +7 -0
  51. package/api/theme-edit/_how-question.mjs +1304 -176
  52. package/api/theme-edit/_how.mjs +144 -30
  53. package/api/theme-edit/_overview.mjs +2 -0
  54. package/api/theme-edit/_palette.d.mts +38 -0
  55. package/api/theme-edit/_palette.mjs +305 -71
  56. package/api/theme-edit/_parts.d.mts +33 -0
  57. package/api/theme-edit/_parts.mjs +138 -9
  58. package/api/theme-edit/_png.d.mts +18 -0
  59. package/api/theme-edit/_png.mjs +95 -14
  60. package/api/theme-edit/_preview-app.d.mts +36 -1
  61. package/api/theme-edit/_preview-app.mjs +1415 -96
  62. package/api/theme-edit/_preview.d.mts +64 -3
  63. package/api/theme-edit/_preview.mjs +514 -31
  64. package/api/theme-edit/_project.d.mts +11 -0
  65. package/api/theme-edit/_project.mjs +46 -12
  66. package/api/theme-edit/_settings.d.mts +278 -5
  67. package/api/theme-edit/_settings.mjs +2741 -195
  68. package/api/theme-edit/_tables.d.mts +24 -0
  69. package/api/theme-edit/_tables.mjs +211 -149
  70. package/api/theme-edit/_vet.d.mts +42 -0
  71. package/api/theme-edit/_vet.mjs +144 -0
  72. package/api/theme-edit/theme-edit.type.d.mts +20 -2
  73. package/api/theme-edit/theme-edit.type.mjs +6 -2
  74. package/api/theme-edit/themeEditNew.doc.mjs +1 -1
  75. package/api/theme-edit/themeEditPreviewApp.doc.mjs +1 -1
  76. package/api/theme-edit/themeEditShow.doc.mjs +11 -3
  77. package/api/upgrade/registry/registry.mjs +6 -1
  78. package/assets/codemods/parse.mjs +2 -2
  79. package/assets/docs/tree/single-component.doc.mjs +11 -2
  80. package/assets/docs/tree/tokens-and-setup.doc.mjs +39 -3
  81. package/assets/docs.generated.json +2 -2
  82. package/assets/preview-app/next.config.mjs +7 -1
  83. package/assets/preview-app/package.json +1 -0
  84. package/assets/preview-app/src/app/globals.css +1 -0
  85. package/assets/self-audit.generated.json +1 -1
  86. package/assets/templates/blocks/components/Table/ColumnsVirtualizationHookUsage.doc.mjs +14 -0
  87. package/assets/templates/blocks/components/Table/ColumnsVirtualizationHookUsage.tsx +53 -0
  88. package/assets/templates/blocks/components/Table/InfiniteScrollHookUsage.doc.mjs +14 -0
  89. package/assets/templates/blocks/components/Table/InfiniteScrollHookUsage.tsx +33 -0
  90. package/assets/templates/components.generated.json +1 -1
  91. package/assets/templates/pages/dashboard/page.tsx +1 -1
  92. package/authoring/doctypes/_schema.d.mts +52 -5
  93. package/authoring/doctypes/_schema.mjs +62 -7
  94. package/authoring/doctypes/base/type.ts +10 -0
  95. package/authoring/doctypes/component/component.doc.mjs +1 -1
  96. package/authoring/doctypes/function/function.doc.mjs +6 -0
  97. package/authoring/doctypes/function/type.ts +3 -0
  98. package/authoring/doctypes/legacy.mjs +5 -1
  99. package/authoring/index.d.ts +1 -0
  100. package/authoring/shadcn/source-variants.d.mts +1 -1
  101. package/authoring/shadcn/source-variants.mjs +32 -10
  102. package/clients/cli/build-id.generated.json +1 -1
  103. package/clients/cli/commands/doctor.doc.mjs +2 -2
  104. package/clients/cli/commands/experimental/theme.mjs +239 -45
  105. package/clients/cli/commands/experimental-theme-compile.doc.mjs +2 -2
  106. package/clients/cli/commands/experimental-theme-editor-new.doc.mjs +2 -2
  107. package/clients/cli/commands/experimental-theme-editor-set.doc.mjs +2 -2
  108. package/clients/cli/commands/experimental-theme-editor-show.doc.mjs +3 -3
  109. package/clients/cli/commands/experimental-theme-editor-undo.doc.mjs +2 -2
  110. package/clients/cli/commands/experimental-theme-editor.doc.mjs +1 -1
  111. package/clients/cli/commands/experimental-theme-eject.doc.mjs +1 -1
  112. package/clients/cli/commands/experimental-theme-preview-add.doc.mjs +1 -1
  113. package/clients/cli/commands/experimental-theme-preview-app.doc.mjs +1 -1
  114. package/clients/cli/commands/experimental-theme-template.doc.mjs +2 -2
  115. package/clients/cli/commands/theme-build.doc.mjs +2 -2
  116. package/clients/cli/commands/theme-eject.doc.mjs +1 -1
  117. package/clients/cli/commands/theme-template.doc.mjs +3 -1
  118. package/clients/cli/commands/theme.mjs +190 -46
  119. package/clients/cli/formatters/index.mjs +7 -4
  120. package/clients/cli/lib/cli-error.mjs +9 -3
  121. package/clients/cli/lib/component-format.mjs +27 -9
  122. package/clients/cli/lib/json-shim.mjs +72 -2
  123. package/clients/cli/manifest.generated.json +1 -1
  124. package/clients/cli/run.mjs +49 -0
  125. package/foundation/agent-docs/agent-docs-target.d.mts +2 -6
  126. package/foundation/agent-docs/agent-docs-target.mjs +9 -17
  127. package/foundation/agent-docs/agent-docs.mjs +3 -2
  128. package/foundation/config/config-writer.mjs +2 -2
  129. package/foundation/config/project.mjs +60 -14
  130. package/foundation/discovery/component-discovery.mjs +5 -17
  131. package/foundation/discovery/icon-set-writer.mjs +1 -1
  132. package/foundation/discovery/module-exports.mjs +1 -15
  133. package/foundation/discovery/template-adapter.mjs +44 -19
  134. package/foundation/discovery/template-source-tree.mjs +3 -16
  135. package/foundation/discovery/theme-discovery.d.mts +5 -1
  136. package/foundation/discovery/theme-discovery.mjs +61 -43
  137. package/foundation/fs/exact-codec.d.mts +35 -0
  138. package/foundation/fs/exact-codec.mjs +148 -0
  139. package/foundation/fs/gather-cache.d.mts +15 -5
  140. package/foundation/fs/gather-cache.mjs +129 -31
  141. package/foundation/fs/paths.d.mts +39 -0
  142. package/foundation/fs/paths.mjs +44 -11
  143. package/foundation/fs/read-record.mjs +11 -1
  144. package/foundation/integrations/contribution-fixes.mjs +1 -16
  145. package/foundation/integrations/may-have-integrations.mjs +3 -2
  146. package/foundation/integrations/public-imports.mjs +1 -1
  147. package/foundation/render/embedded-imports.mjs +1 -1
  148. package/foundation/render/host-exit.d.mts +8 -0
  149. package/foundation/render/host-exit.mjs +11 -0
  150. package/foundation/render/page-host.mjs +56 -10
  151. package/foundation/render/page-worker.mjs +14 -0
  152. package/foundation/render/render-page.mjs +37 -2
  153. package/foundation/response/error-codes.d.mts +2 -1
  154. package/foundation/response/error-codes.d.ts +1 -0
  155. package/foundation/response/error-codes.doc.mjs +5 -0
  156. package/foundation/response/error-codes.mjs +3 -0
  157. package/foundation/response/json.d.mts +15 -0
  158. package/foundation/response/json.mjs +52 -1
  159. package/foundation/response/response-types.doc.mjs +1 -1
  160. package/foundation/runtime/lazy-dependencies.d.mts +14 -0
  161. package/foundation/runtime/lazy-dependencies.mjs +82 -0
  162. package/foundation/xle/browser.d.mts +2 -2
  163. package/package.json +7 -6
@@ -7,7 +7,12 @@
7
7
 
8
8
  import * as path from 'node:path';
9
9
  import {AstryxError} from '../../error.mjs';
10
+ import {logger} from '../../logger.mjs';
10
11
  import {ERROR_CODES} from '../../../foundation/response/error-codes.mjs';
12
+ import {
13
+ formatCliCommand,
14
+ quoteCommandArgument,
15
+ } from '../../../foundation/env/package-manager.mjs';
11
16
  import {
12
17
  ejectThemeFiles,
13
18
  findTheme,
@@ -54,12 +59,28 @@ export async function themeEject(slug, options = {}) {
54
59
  );
55
60
  }
56
61
 
57
- const {outputDir, files} = ejectThemeFiles(match, {
62
+ const {outputDir, files, editorFolder} = ejectThemeFiles(match, {
58
63
  cwd,
59
64
  targetPath,
60
65
  overwrite,
61
66
  takenSlugs: await availableSlugs(cwd),
62
67
  });
68
+ // A folder the theme editor made holds that theme only, but a subfolder of
69
+ // it was always writable, so the fork is written there with one warning.
70
+ if (editorFolder != null) {
71
+ const fork = formatCliCommand(
72
+ [
73
+ 'theme eject',
74
+ match.slug,
75
+ ...(packageName
76
+ ? ['--package', quoteCommandArgument(packageName)]
77
+ : []),
78
+ ].join(' '),
79
+ cwd,
80
+ );
81
+ const warning = `Warning: ${editorFolder} is a folder the theme editor made, and the fork in ${outputDir} is inside it; eject writes there anyway. Fork into the project's local themes folder (${fork}), or pick a path outside ${editorFolder}, to keep the editor's folder to its own theme.`;
82
+ logger.warn(warning);
83
+ }
63
84
  const {missingPackages, installCommand} = forkNeeds(outputDir, files, cwd);
64
85
  return {
65
86
  type: 'theme.eject',
@@ -15,7 +15,26 @@ export function themeTemplate(options?: {
15
15
  overwrite?: boolean;
16
16
  cwd?: string;
17
17
  }): import("../theme.type.mjs").ThemeTemplateResponse;
18
+ /**
19
+ * The template write behind `themeTemplate`, with the experimental editor's
20
+ * one difference: with `editorFilesOnly`, in a folder the theme editor made
21
+ * only the editor's own files (`<folder>.*`) are protected, so an earlier
22
+ * template there is the person's. Internal: the experimental `template`
23
+ * command reaches it through `editorThemeTemplate` (api/theme-edit), and it
24
+ * is not part of the public API.
25
+ * @internal
26
+ * @param {{targetPath?: string, overwrite?: boolean, cwd?: string}} options
27
+ * @param {boolean} editorFilesOnly
28
+ * @returns {import('../theme.type.mjs').ThemeTemplateResponse}
29
+ */
30
+ export function writeThemeTemplate(options: {
31
+ targetPath?: string;
32
+ overwrite?: boolean;
33
+ cwd?: string;
34
+ }, editorFilesOnly: boolean): import("../theme.type.mjs").ThemeTemplateResponse;
18
35
  /** The annotated `defineTheme` reference that ships with the CLI. */
19
36
  export const THEME_TEMPLATE_SRC: string;
37
+ /** The warning the CLI prints when it writes the template outside a project. */
38
+ export const OUTSIDE_PROJECT_WARNING: "Warning: no package.json is in this folder or above it, so the template is written here. Run it inside a project, or run `npm init -y` here first, to write it at a project root.";
20
39
  /** Where it lands when the caller does not say. */
21
40
  export const THEME_TEMPLATE_DEFAULT_PATH: "theme.template.ts";
@@ -15,8 +15,11 @@
15
15
 
16
16
  import * as fs from 'node:fs';
17
17
  import * as path from 'node:path';
18
- import {CLI_ROOT} from '../../../foundation/fs/paths.mjs';
19
- import {assertWithin, PathSafetyError} from '../../../foundation/fs/path-safety.mjs';
18
+ import {CLI_ROOT, projectWritePath} from '../../../foundation/fs/paths.mjs';
19
+ import {
20
+ assertWithin,
21
+ PathSafetyError,
22
+ } from '../../../foundation/fs/path-safety.mjs';
20
23
  import {stripCopyrightHeader} from '../../../foundation/text/copyright-header.mjs';
21
24
  import {formatCliCommand} from '../../../foundation/env/package-manager.mjs';
22
25
  import {fsErrorMessage} from '../../../foundation/fs/fs-error.mjs';
@@ -25,7 +28,15 @@ import {AstryxError} from '../../error.mjs';
25
28
  import {ERROR_CODES} from '../../../foundation/response/error-codes.mjs';
26
29
 
27
30
  /** The annotated `defineTheme` reference that ships with the CLI. */
28
- export const THEME_TEMPLATE_SRC = path.join(CLI_ROOT, 'assets', 'theme.template.ts');
31
+ export const THEME_TEMPLATE_SRC = path.join(
32
+ CLI_ROOT,
33
+ 'assets',
34
+ 'theme.template.ts',
35
+ );
36
+
37
+ /** The warning the CLI prints when it writes the template outside a project. */
38
+ export const OUTSIDE_PROJECT_WARNING =
39
+ 'Warning: no package.json is in this folder or above it, so the template is written here. Run it inside a project, or run `npm init -y` here first, to write it at a project root.';
29
40
 
30
41
  /** Where it lands when the caller does not say. */
31
42
  export const THEME_TEMPLATE_DEFAULT_PATH = 'theme.template.ts';
@@ -72,6 +83,22 @@ function isReplaceableThemeFile(file) {
72
83
  * @returns {import('../theme.type.mjs').ThemeTemplateResponse}
73
84
  */
74
85
  export function themeTemplate(options = {}) {
86
+ return writeThemeTemplate(options, false);
87
+ }
88
+
89
+ /**
90
+ * The template write behind `themeTemplate`, with the experimental editor's
91
+ * one difference: with `editorFilesOnly`, in a folder the theme editor made
92
+ * only the editor's own files (`<folder>.*`) are protected, so an earlier
93
+ * template there is the person's. Internal: the experimental `template`
94
+ * command reaches it through `editorThemeTemplate` (api/theme-edit), and it
95
+ * is not part of the public API.
96
+ * @internal
97
+ * @param {{targetPath?: string, overwrite?: boolean, cwd?: string}} options
98
+ * @param {boolean} editorFilesOnly
99
+ * @returns {import('../theme.type.mjs').ThemeTemplateResponse}
100
+ */
101
+ export function writeThemeTemplate(options, editorFilesOnly) {
75
102
  const {
76
103
  targetPath = THEME_TEMPLATE_DEFAULT_PATH,
77
104
  overwrite = false,
@@ -86,34 +113,52 @@ export function themeTemplate(options = {}) {
86
113
  );
87
114
  if (String(targetPath).trim() === '') {
88
115
  throw new AstryxError(
89
- 'The theme template path is blank. Give a file path, or leave it out for theme.template.ts.',
116
+ 'The theme template path is blank. Give a file path, or leave it out for theme.template.ts at the project root.',
90
117
  [
91
118
  {
92
- name: formatCliCommand(
93
- `theme template ${THEME_TEMPLATE_DEFAULT_PATH}`,
94
- cwd,
95
- ),
96
- reason: 'the default path',
119
+ // No path: the template at the project root, from any folder.
120
+ name: formatCliCommand('theme template', cwd),
121
+ reason: 'write the template at the project root',
97
122
  },
98
123
  ],
99
124
  ERROR_CODES.ERR_INVALID_ARGUMENT,
100
125
  );
101
126
  }
102
127
 
128
+ // The project the folder belongs to bounds the path, as for other theme
129
+ // commands: a path given is read from the current folder, and no path
130
+ // means the project root.
131
+ // With no package.json at or above the folder it writes here, and the CLI
132
+ // prints OUTSIDE_PROJECT_WARNING.
133
+ // Read as every theme command reads a path it writes; a backslash
134
+ // separates folders on every platform.
135
+ const {projectDir, relative: fromRoot} = projectWritePath(
136
+ cwd,
137
+ options.targetPath == null ? undefined : String(targetPath),
138
+ THEME_TEMPLATE_DEFAULT_PATH,
139
+ );
103
140
  let resolved;
104
141
  try {
105
- resolved = assertWithin(targetPath, cwd, {label: 'theme template path'});
142
+ resolved = assertWithin(fromRoot, projectDir, {
143
+ label: 'theme template path',
144
+ });
106
145
  } catch (err) {
107
146
  if (err instanceof PathSafetyError) {
108
147
  throw new AstryxError(
109
- err.message,
148
+ // The path as typed, not as read from the project root.
149
+ // A typed path is read from the current folder, so the advice says
150
+ // so (the safety check reads it from the project root).
151
+ err.message
152
+ .replace(`"${fromRoot}"`, `"${targetPath}"`)
153
+ .replace(
154
+ /relative to the project root/g,
155
+ 'relative to the current folder, inside the project',
156
+ ),
110
157
  [
111
158
  {
112
- name: formatCliCommand(
113
- `theme template ${THEME_TEMPLATE_DEFAULT_PATH}`,
114
- cwd,
115
- ),
116
- reason: 'write the template in this project',
159
+ // No path: the template at the project root.
160
+ name: formatCliCommand('theme template', cwd),
161
+ reason: 'write the template at the project root',
117
162
  },
118
163
  ],
119
164
  ERROR_CODES.ERR_PATH_TRAVERSAL,
@@ -153,10 +198,39 @@ export function themeTemplate(options = {}) {
153
198
  );
154
199
  }
155
200
 
156
- const editorRecord =
157
- fs.existsSync(resolved) && overwrite
158
- ? editorThemeRecord(path.dirname(resolved))
159
- : null;
201
+ // The folder as it is on disk (`themes/T` is `themes/t` on a
202
+ // case-insensitive disk, or through a link).
203
+ const realDir = fs.existsSync(resolved)
204
+ ? fs.realpathSync(path.dirname(resolved))
205
+ : path.dirname(resolved);
206
+ const record = fs.existsSync(resolved) ? editorThemeRecord(realDir) : null;
207
+ // The editor's own files are `<folder>.*` beside its settings; with
208
+ // editorFilesOnly any other file there (an earlier template) is the
209
+ // person's.
210
+ // On a case-insensitive disk `T.theme.ts` is `t.theme.ts`: names are
211
+ // compared in any case, and an existing file by what it is on disk.
212
+ const folder = path.basename(realDir).toLowerCase();
213
+ const sameFile = (/** @type {string} */ other) => {
214
+ try {
215
+ const a = fs.statSync(resolved);
216
+ const b = fs.statSync(other);
217
+ return a.ino === b.ino && a.dev === b.dev;
218
+ } catch {
219
+ return false;
220
+ }
221
+ };
222
+ const editorFile =
223
+ record != null &&
224
+ (!editorFilesOnly ||
225
+ path.basename(resolved).toLowerCase().startsWith(`${folder}.`) ||
226
+ fs
227
+ .readdirSync(realDir)
228
+ .some(
229
+ f =>
230
+ f.toLowerCase().startsWith(`${folder}.`) &&
231
+ sameFile(path.join(realDir, f)),
232
+ ));
233
+ const editorRecord = overwrite && editorFile ? record : null;
160
234
  if (editorRecord) {
161
235
  throw new AstryxError(
162
236
  `${relative} belongs to a theme the theme editor made (${editorRecord} is beside it). Replacing it would cut the theme off from its settings, so --overwrite does not replace it.`,
@@ -196,9 +270,7 @@ export function themeTemplate(options = {}) {
196
270
  if (fs.existsSync(resolved) && !overwrite) {
197
271
  // Whether --overwrite would replace this file, and if not, a path that
198
272
  // takes the template, so the hint never names a command that refuses.
199
- const overwritable =
200
- !editorThemeRecord(path.dirname(resolved)) &&
201
- isReplaceableThemeFile(resolved);
273
+ const overwritable = !editorFile && isReplaceableThemeFile(resolved);
202
274
  return {
203
275
  type: 'theme.template',
204
276
  data: {
@@ -212,7 +284,9 @@ export function themeTemplate(options = {}) {
212
284
  }
213
285
 
214
286
  // Our repo header has no business in someone else's source tree.
215
- const contents = stripCopyrightHeader(fs.readFileSync(THEME_TEMPLATE_SRC, 'utf-8'));
287
+ const contents = stripCopyrightHeader(
288
+ fs.readFileSync(THEME_TEMPLATE_SRC, 'utf-8'),
289
+ );
216
290
  try {
217
291
  fs.mkdirSync(path.dirname(resolved), {recursive: true});
218
292
  fs.writeFileSync(resolved, contents);
@@ -223,7 +297,10 @@ export function themeTemplate(options = {}) {
223
297
  throw new AstryxError(message, undefined, ERROR_CODES.ERR_WRITE_FAILED);
224
298
  }
225
299
 
226
- return {type: 'theme.template', data: {path: relative, written: true, reason: null}};
300
+ return {
301
+ type: 'theme.template',
302
+ data: {path: relative, written: true, reason: null},
303
+ };
227
304
  }
228
305
 
229
306
  /** @param {string} file */
@@ -32,6 +32,9 @@ export type ThemeBuildResponse = {
32
32
  */
33
33
  export type ThemeBuildCheckResponse = {
34
34
  type: "theme.build.check";
35
+ /**
36
+ * `code` is set when the outputs are stale or missing (exit 1).
37
+ */
35
38
  data: {
36
39
  name: string;
37
40
  upToDate: boolean;
@@ -40,6 +43,7 @@ export type ThemeBuildCheckResponse = {
40
43
  reason: "missing" | "outdated";
41
44
  }>;
42
45
  checked: string[];
46
+ code?: "ERR_THEME_STALE";
43
47
  };
44
48
  };
45
49
  /**
@@ -281,7 +285,7 @@ export type TonalPaletteFamilyInput = {
281
285
  * `neutral` derives the ramp from
282
286
  * `neutralProfile` instead of the seed hue; defaults to `chromatic`.
283
287
  */
284
- kind?: "neutral" | "chromatic" | undefined;
288
+ kind?: "chromatic" | "neutral" | undefined;
285
289
  /**
286
290
  * Colors pinned at specific stops.
287
291
  */
@@ -38,7 +38,8 @@
38
38
  * astryx --json theme build <file> --check
39
39
  * @typedef {object} ThemeBuildCheckResponse
40
40
  * @property {'theme.build.check'} type
41
- * @property {{name: string, upToDate: boolean, stale: Array<{path: string, reason: 'missing' | 'outdated'}>, checked: string[]}} data
41
+ * @property {{name: string, upToDate: boolean, stale: Array<{path: string, reason: 'missing' | 'outdated'}>, checked: string[], code?: 'ERR_THEME_STALE'}} data
42
+ * `code` is set when the outputs are stale or missing (exit 1).
42
43
  */
43
44
 
44
45
  /**
@@ -58,7 +58,7 @@ export const doc = {
58
58
  name: 'options.out',
59
59
  type: 'string',
60
60
  description:
61
- 'Override the output CSS path, relative or absolute; a build refuses a path outside cwd, and check mode refuses only a relative path that escapes cwd. The .js, .d.ts and any .variants.d.ts are written in the same directory, named after the theme (<name>.js), not after the CSS file. An existing folder, or a path that ends in a separator, names the folder: the CSS is written there as <name>.css. A file path should end in .css; another name still builds, with a warning, and the import line it prints names the file as written.',
61
+ 'Override the output CSS path, relative or absolute; a build refuses a path outside cwd, and check mode refuses only a relative path that escapes cwd. The .js, .d.ts and any .variants.d.ts are written in the same directory, named after the theme (<name>.js), not after the CSS file. An existing folder, or a path that ends in a separator, names the folder: the CSS is written there as <name>.css. A file path should end in .css; another name still builds, with a warning, and the import line it prints names the file as written. A path in a folder the theme editor made (folder <slug>/ holds <slug>.settings.json) takes the outputs of a source outside that folder too, and the CLI warns; to keep the editor folder to its own theme, build beside the source, or pick an out path outside it.',
62
62
  },
63
63
  {
64
64
  name: 'options.check',
@@ -90,7 +90,7 @@ export const doc = {
90
90
  {
91
91
  type: 'theme.build.check',
92
92
  description:
93
- 'The {check: true} receipt: theme name, an upToDate flag, the stale outputs (each {path, reason: "missing" | "outdated"}), and the full list of checked paths. Writes nothing. Resolves to null, like a normal build, when the theme produces no CSS.',
93
+ 'The {check: true} receipt: theme name, an upToDate flag, the stale outputs (each {path, reason: "missing" | "outdated"}), the full list of checked paths, and, when stale, code ERR_THEME_STALE. Writes nothing. Resolves to null, like a normal build, when the theme produces no CSS.',
94
94
  },
95
95
  ],
96
96
  throws: [
@@ -108,7 +108,7 @@ export const doc = {
108
108
  },
109
109
  {
110
110
  code: 'ERR_FILE_EXISTS',
111
- when: 'a path that out names holds a non-empty file without the generated header, such as package.json, app source, or an output from a CLI before 0.6.7; nothing is written. Delete the file and run the same build again (the suggestion), or pick another out path. At the default paths beside the source, and at family output paths, a header-less file is an output of a CLI before 0.6.7 and is replaced',
111
+ when: 'a path that out names holds a non-empty file without the generated header, such as package.json, app source, or an output from a CLI before 0.6.7; nothing is written. The suggestions name a free out path beside it and the build beside the source; the file is left as it is. At the default paths beside the source, and at family output paths, a header-less file is an output of a CLI before 0.6.7 and is replaced',
112
112
  },
113
113
  {
114
114
  code: 'ERR_INVALID_ARGUMENT',
@@ -13,7 +13,7 @@ export const doc = {
13
13
  displayName: 'themeEject()',
14
14
  summary: 'Eject an available theme into a project as editable source.',
15
15
  description:
16
- "Resolves a theme from the CLI bundle or an installed integration and ejects it into the consumer project: a bundled theme's source files, or an integration theme's complete directory with its descriptor. Writes are staged and existing files require explicit overwrite. Duplicate slugs fail closed until the caller selects an owner package.",
16
+ "Resolves a theme from the CLI bundle or an installed integration and ejects it into the consumer project: a bundled theme's source files, or an integration theme's complete directory with its descriptor. Writes are staged and existing files require explicit overwrite. A target inside a folder the theme editor made (a subfolder of <slug>/ that holds <slug>.settings.json) is written, and the CLI warns. Duplicate slugs fail closed until the caller selects an owner package.",
17
17
  importPath: '@astryxdesign/cli/api',
18
18
  signature:
19
19
  'themeEject(slug: string, options?: {targetPath?: string, overwrite?: boolean, cwd?: string, package?: string}): Promise<ThemeEjectResponse>',
@@ -22,7 +22,9 @@ export const doc = {
22
22
  'Read it, copy what you need into your own theme file, delete it. Use `theme add` to ' +
23
23
  'use an installed built theme, extend that theme for ordinary customization, or use ' +
24
24
  '`theme eject` for a complete source fork. This command starts a new blank theme. Refuses to overwrite without ' +
25
- '`overwrite`, so it is safe to re-run.',
25
+ '`overwrite`, so it is safe to re-run. With no package.json at or above cwd, it writes in cwd ' +
26
+ 'and the CLI warns; pass a cwd inside a project, or run `npm init -y` in that folder first, to ' +
27
+ 'write it at a project root.',
26
28
  importPath: '@astryxdesign/cli/api',
27
29
  signature:
28
30
  'themeTemplate(options?: {targetPath?: string, overwrite?: boolean, cwd?: string}): ThemeTemplateResponse',
@@ -31,7 +33,8 @@ export const doc = {
31
33
  {
32
34
  name: 'options.targetPath',
33
35
  type: 'string',
34
- description: 'Destination file. Must resolve within cwd.',
36
+ description:
37
+ 'Destination file, read from cwd. Must resolve within the project root: the nearest folder at or above cwd with a package.json. Left out, the template is written at the project root.',
35
38
  default: "'theme.template.ts'",
36
39
  },
37
40
  {
@@ -55,7 +58,10 @@ export const doc = {
55
58
  },
56
59
  ],
57
60
  throws: [
58
- {code: 'ERR_PATH_TRAVERSAL', when: 'the target path escapes cwd'},
61
+ {
62
+ code: 'ERR_PATH_TRAVERSAL',
63
+ when: 'the target path escapes the project root (the nearest folder at or above cwd with a package.json)',
64
+ },
59
65
  {
60
66
  code: 'ERR_INVALID_ARGUMENT',
61
67
  when: 'the target path is blank, names a folder, or is not a .ts file (with or without overwrite)',
@@ -36,13 +36,17 @@ export function editorThemeRefusal(err: AstryxError, cwd: string): AstryxError |
36
36
  * take an editor theme, and `--check` checks an editor theme by the editor's
37
37
  * own rules (waiting for a change in progress).
38
38
  * @param {string[]} files
39
- * @param {{cwd: string, check?: boolean, family?: boolean}} options
39
+ * @param {{cwd: string, check?: boolean, family?: boolean, iconsSpecifier?: string, out?: string}} options
40
+ * `check`, `out` and `iconsSpecifier` are kept in every compile a refusal
41
+ * suggests
40
42
  * @returns {Promise<AstryxError | null>}
41
43
  */
42
- export function editorCompileProblem(files: string[], { cwd, check, family }: {
44
+ export function editorCompileProblem(files: string[], { cwd, check, family, iconsSpecifier, out }: {
43
45
  cwd: string;
44
46
  check?: boolean;
45
47
  family?: boolean;
48
+ iconsSpecifier?: string;
49
+ out?: string;
46
50
  }): Promise<AstryxError | null>;
47
51
  /**
48
52
  * Hold the theme lock of every editor theme among the files while
@@ -55,8 +59,34 @@ export function editorCompileProblem(files: string[], { cwd, check, family }: {
55
59
  export function editorThemeHold(files: string[], { cwd }: {
56
60
  cwd: string;
57
61
  }): Promise<() => Promise<void>>;
62
+ /**
63
+ * For `compile` of a file that is not there: when it is an editor theme's
64
+ * own source (`themes/<t>/<t>.theme.ts` beside its settings), the command
65
+ * that writes it again; null otherwise.
66
+ * @param {string} file the path as given
67
+ * @param {string} cwd
68
+ * @returns {{name: string, reason: string} | null}
69
+ */
70
+ export function editorMissingSource(file: string, cwd: string): {
71
+ name: string;
72
+ reason: string;
73
+ } | null;
74
+ /**
75
+ * `theme template` for the experimental command: in a folder the theme
76
+ * editor made, only the editor's own files are protected.
77
+ * @param {{targetPath?: string, overwrite?: boolean, cwd?: string}} options
78
+ * @returns {import('../theme/theme.type.mjs').ThemeTemplateResponse}
79
+ */
80
+ export function editorThemeTemplate(options: {
81
+ targetPath?: string;
82
+ overwrite?: boolean;
83
+ cwd?: string;
84
+ }): import("../theme/theme.type.mjs").ThemeTemplateResponse;
58
85
  export { parsePoints } from "./_how.mjs";
86
+ export { newFlagList } from "./_edit.mjs";
59
87
  export function builtInThemes(): string[];
88
+ export function showSections(): string[];
89
+ export { dialValueFits } from "./_settings.mjs";
60
90
  /** @type {typeof edit.themeEditNew} */
61
91
  export const themeEditNew: typeof edit.themeEditNew;
62
92
  /** @type {typeof edit.themeEditSet} */