@astryxdesign/cli 0.7.15-canary.gea16e8d → 0.7.15

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 (134) hide show
  1. package/CHANGELOG.md +353 -3
  2. package/README.md +63 -63
  3. package/api/build/_adapter.d.mts +4 -0
  4. package/api/build/_adapter.mjs +28 -2
  5. package/api/build/blocks/blocks.d.mts +10 -1
  6. package/api/build/blocks/blocks.mjs +84 -7
  7. package/api/build/build.mjs +6 -1
  8. package/api/build/tree.d.mts +4 -0
  9. package/api/build/tree.mjs +9 -2
  10. package/api/doctor/_adapter.d.mts +2 -1
  11. package/api/doctor/_adapter.mjs +6 -1
  12. package/api/doctor/doctor.mjs +2 -2
  13. package/api/doctor/theme-checks.mjs +56 -21
  14. package/api/integration/add-helpers.mjs +5 -0
  15. package/api/integration/add-theme.mjs +15 -110
  16. package/api/integration/validate-integration.mjs +17 -3
  17. package/api/integration/validateIntegration.doc.mjs +1 -1
  18. package/api/theme/_adapter.d.mts +37 -5
  19. package/api/theme/_adapter.mjs +363 -50
  20. package/api/theme/_fork.d.mts +90 -0
  21. package/api/theme/_fork.mjs +246 -0
  22. package/api/theme/build/build.d.mts +25 -1
  23. package/api/theme/build/build.mjs +352 -41
  24. package/api/theme/eject/eject.mjs +36 -15
  25. package/api/theme/list/list.mjs +3 -6
  26. package/api/theme/palette/generate/generator.d.mts +13 -0
  27. package/api/theme/palette/generate/generator.mjs +32 -2
  28. package/api/theme/targets/targets.mjs +10 -3
  29. package/api/theme/template/template.mjs +48 -2
  30. package/api/theme/theme.type.d.mts +8 -0
  31. package/api/theme/theme.type.mjs +5 -1
  32. package/api/theme/themeBuild.doc.mjs +2 -2
  33. package/api/theme/themeRemove.doc.mjs +5 -2
  34. package/api/theme/themeTemplate.doc.mjs +2 -2
  35. package/api/theme/themeUse.doc.mjs +8 -2
  36. package/api/theme-edit/_adapter.mjs +157 -36
  37. package/api/theme-edit/_catalog.d.mts +1 -6
  38. package/api/theme-edit/_catalog.mjs +5 -268
  39. package/api/theme-edit/_check.d.mts +3 -1
  40. package/api/theme-edit/_check.mjs +733 -308
  41. package/api/theme-edit/_color.d.mts +19 -0
  42. package/api/theme-edit/_color.mjs +277 -33
  43. package/api/theme-edit/_compiler.d.mts +1 -0
  44. package/api/theme-edit/_compiler.mjs +25 -0
  45. package/api/theme-edit/_context.d.mts +2 -0
  46. package/api/theme-edit/_context.mjs +83 -9
  47. package/api/theme-edit/_css.d.mts +84 -0
  48. package/api/theme-edit/_css.mjs +700 -0
  49. package/api/theme-edit/_edit.mjs +370 -85
  50. package/api/theme-edit/_how-commands.d.mts +5 -0
  51. package/api/theme-edit/_how-commands.mjs +20 -13
  52. package/api/theme-edit/_how-question.d.mts +29 -0
  53. package/api/theme-edit/_how-question.mjs +1573 -182
  54. package/api/theme-edit/_how.mjs +306 -22
  55. package/api/theme-edit/_overview.mjs +2 -7
  56. package/api/theme-edit/_palette.d.mts +27 -5
  57. package/api/theme-edit/_palette.mjs +231 -97
  58. package/api/theme-edit/_parts.d.mts +42 -10
  59. package/api/theme-edit/_parts.mjs +224 -69
  60. package/api/theme-edit/_preview-app.d.mts +8 -0
  61. package/api/theme-edit/_preview-app.mjs +549 -96
  62. package/api/theme-edit/_preview.d.mts +7 -16
  63. package/api/theme-edit/_preview.mjs +77 -84
  64. package/api/theme-edit/_project.d.mts +20 -1
  65. package/api/theme-edit/_project.mjs +43 -13
  66. package/api/theme-edit/_settings.d.mts +96 -20
  67. package/api/theme-edit/_settings.mjs +646 -141
  68. package/api/theme-edit/_tables.d.mts +18 -12
  69. package/api/theme-edit/_tables.mjs +144 -147
  70. package/api/theme-edit/theme-edit.type.d.mts +10 -1
  71. package/api/theme-edit/theme-edit.type.mjs +3 -1
  72. package/api/theme-edit/themeEditNew.doc.mjs +1 -1
  73. package/api/theme-edit/themeEditPreviewAdd.doc.mjs +1 -1
  74. package/api/theme-edit/themeEditPreviewApp.doc.mjs +1 -1
  75. package/api/theme-edit/themeEditPreviewList.doc.mjs +2 -2
  76. package/api/theme-edit/themeEditSet.doc.mjs +1 -1
  77. package/api/theme-edit/themeEditUndo.doc.mjs +1 -1
  78. package/assets/docs/tree/checks.doc.mjs +22 -1
  79. package/assets/docs/tree/publishing.doc.mjs +1 -0
  80. package/assets/docs.generated.json +2 -2
  81. package/assets/self-audit.generated.json +1 -1
  82. package/authoring/integration/integration.doc.mjs +8 -0
  83. package/authoring/integration/schema.d.mts +8 -0
  84. package/authoring/integration/schema.mjs +1 -0
  85. package/authoring/integration/type.ts +9 -0
  86. package/clients/cli/build-id.generated.json +1 -1
  87. package/clients/cli/commands/experimental/index.mjs +10 -10
  88. package/clients/cli/commands/experimental/theme.mjs +22 -3
  89. package/clients/cli/commands/experimental-theme-compile.doc.mjs +2 -2
  90. package/clients/cli/commands/experimental-theme-editor-new.doc.mjs +3 -3
  91. package/clients/cli/commands/experimental-theme-preview-add.doc.mjs +1 -1
  92. package/clients/cli/commands/experimental-theme-preview-app.doc.mjs +1 -1
  93. package/clients/cli/commands/integration.mjs +8 -0
  94. package/clients/cli/commands/theme-build.doc.mjs +2 -2
  95. package/clients/cli/commands/theme-list.doc.mjs +1 -1
  96. package/clients/cli/commands/theme-template.doc.mjs +1 -1
  97. package/clients/cli/commands/theme.mjs +325 -48
  98. package/clients/cli/index.mjs +18 -3
  99. package/clients/cli/lib/cli-error.mjs +118 -3
  100. package/clients/cli/manifest.generated.json +1 -1
  101. package/foundation/config/project.mjs +34 -8
  102. package/foundation/config/theme-state.d.mts +16 -0
  103. package/foundation/config/theme-state.mjs +84 -13
  104. package/foundation/discovery/template-needs.d.mts +13 -0
  105. package/foundation/discovery/template-needs.mjs +30 -15
  106. package/foundation/discovery/theme-discovery.mjs +14 -2
  107. package/foundation/discovery/theme-imports.d.mts +16 -0
  108. package/foundation/discovery/theme-imports.mjs +30 -2
  109. package/foundation/doc-compiler/import.mjs +10 -4
  110. package/foundation/fs/gather-cache.mjs +82 -23
  111. package/foundation/fs/jiti-cache.d.mts +21 -0
  112. package/foundation/fs/jiti-cache.mjs +66 -0
  113. package/foundation/fs/module-loader.mjs +7 -2
  114. package/foundation/integrations/autolink.d.mts +1 -24
  115. package/foundation/integrations/autolink.mjs +7 -60
  116. package/foundation/integrations/declared-dependencies.d.mts +27 -0
  117. package/foundation/integrations/declared-dependencies.mjs +73 -0
  118. package/foundation/integrations/integrations.d.mts +8 -0
  119. package/foundation/integrations/integrations.mjs +4 -0
  120. package/foundation/integrations/may-have-integrations.d.mts +8 -0
  121. package/foundation/integrations/may-have-integrations.mjs +47 -0
  122. package/foundation/integrations/validate-contributions.d.mts +62 -1
  123. package/foundation/integrations/validate-contributions.mjs +452 -29
  124. package/foundation/release/cache.d.mts +21 -2
  125. package/foundation/release/cache.mjs +48 -8
  126. package/foundation/release/folder-lock.d.mts +7 -0
  127. package/foundation/release/folder-lock.mjs +60 -26
  128. package/foundation/release/lock-lease.d.mts +2 -1
  129. package/foundation/release/lock-lease.mjs +7 -2
  130. package/foundation/response/error-codes.doc.mjs +1 -1
  131. package/foundation/response/response-types.doc.mjs +5 -5
  132. package/package.json +6 -6
  133. package/api/theme-edit/_css-properties.d.mts +0 -10
  134. package/api/theme-edit/_css-properties.mjs +0 -556
@@ -25,7 +25,7 @@ import {answeredBy, runChoice} from '../../foundation/release/run-context.mjs';
25
25
  import {cliInstallAdvice, installFolder, projectRelease, SETUP_REMINDER_KEY, takeNotice} from '../../foundation/release/notices.mjs';
26
26
  import {isCi} from '../../foundation/release/update-notice-env.mjs';
27
27
  import {buildManifest, storedManifest} from './lib/manifest.mjs';
28
- import {cliError} from './lib/cli-error.mjs';
28
+ import {cliError, themeGroupUnknownSubcommand} from './lib/cli-error.mjs';
29
29
  import {section, text, records} from './formatters/index.mjs';
30
30
  import {ERROR_CODES} from '../../foundation/response/error-codes.mjs';
31
31
  import {levenshteinDistance} from '../../foundation/text/string-utils.mjs';
@@ -732,10 +732,25 @@ export async function createProgram({argv} = {}) {
732
732
  const extras = actionCommand.commands.length > 0 ? actionCommand.args : [];
733
733
  const unknown = extras.find(arg => !String(arg).startsWith('-'));
734
734
  if (unknown != null) {
735
+ const names = actionCommand.commands.map(child => child.name());
736
+ if (fullName === 'theme' || fullName === 'experimental') {
737
+ // The theme groups name whole commands, closest first, and point at
738
+ // `experimental theme <word>` when the word is one of its commands.
739
+ const {message, suggestions} = themeGroupUnknownSubcommand(
740
+ fullName,
741
+ String(unknown),
742
+ names,
743
+ actionCommand,
744
+ );
745
+ cliError(message, {
746
+ code: ERROR_CODES.ERR_UNKNOWN_SUBCOMMAND,
747
+ suggestions,
748
+ });
749
+ }
735
750
  cliError(`unknown subcommand '${fullName} ${unknown}'`, {
736
751
  code: ERROR_CODES.ERR_UNKNOWN_SUBCOMMAND,
737
- suggestions: actionCommand.commands.map(child => ({
738
- name: child.name(),
752
+ suggestions: names.map(name => ({
753
+ name,
739
754
  reason: 'available subcommand',
740
755
  })),
741
756
  });
@@ -50,10 +50,20 @@
50
50
  * NEVER add ad-hoc fields. NEVER vary the shape. Consumers depend on it.
51
51
  */
52
52
 
53
- import {isJsonMode, jsonError as _jsonError, humanWarn} from '../../../foundation/response/json.mjs';
53
+ import {
54
+ isJsonMode,
55
+ jsonError as _jsonError,
56
+ humanWarn,
57
+ } from '../../../foundation/response/json.mjs';
54
58
  import {ERROR_CODES} from '../../../foundation/response/error-codes.mjs';
55
59
  import {setOutcome} from '../../../foundation/debug/index.mjs';
56
- import {formatCliCommand} from '../../../foundation/env/package-manager.mjs';
60
+ import {
61
+ formatCliCommand,
62
+ getCliInvocation,
63
+ } from '../../../foundation/env/package-manager.mjs';
64
+ import {levenshteinDistance} from '../../../foundation/text/levenshtein.mjs';
65
+ import {doc as experimentalEditorDoc} from '../commands/experimental-theme-editor.doc.mjs';
66
+ import {doc as experimentalPreviewDoc} from '../commands/experimental-theme-preview.doc.mjs';
57
67
 
58
68
  /**
59
69
  * Suggestion object — matches the shape used by API errors and the JSON
@@ -124,7 +134,9 @@ export function cliError(message, options = {}) {
124
134
  console.error('');
125
135
  for (const s of suggestions) {
126
136
  // A suggested command stays bare in JSON and is prefixed here.
127
- const name = /^astryx(\s|$)/.test(s.name) ? formatCliCommand(s.name) : s.name;
137
+ const name = /^astryx(\s|$)/.test(s.name)
138
+ ? formatCliCommand(s.name)
139
+ : s.name;
128
140
  const tag = s.reason ? ` ${name} (${s.reason})` : ` ${name}`;
129
141
  console.error(tag);
130
142
  }
@@ -189,3 +201,106 @@ export function assertOrExit(condition, message, options) {
189
201
  // Re-export humanWarn for callers that want a non-fatal warning channel.
190
202
  // Warnings should NOT change the exit code.
191
203
  export {humanWarn};
204
+
205
+ /**
206
+ * Runnable suggestions for an unknown subcommand of a group: each of the
207
+ * group's subcommands as a whole command, closest to the typed word first.
208
+ * `elsewhere` lists other groups' subcommands with the same name (`theme
209
+ * editor` is `experimental theme editor`); they come first, as the likely
210
+ * meaning.
211
+ * @param {string} here the group's command, such as `npx @astryxdesign/cli experimental`
212
+ * @param {string} word the unknown word
213
+ * @param {string[]} names the group's subcommand names
214
+ * @param {Array<{name: string, reason: string}>} [elsewhere]
215
+ * @returns {Array<{name: string, reason: string}>}
216
+ */
217
+ export function unknownSubcommandSuggestions(
218
+ here,
219
+ word,
220
+ names,
221
+ elsewhere = [],
222
+ ) {
223
+ const typed = word.toLowerCase();
224
+ const ranked = [...names].sort(
225
+ (a, b) =>
226
+ levenshteinDistance(typed, a) - levenshteinDistance(typed, b) ||
227
+ a.localeCompare(b),
228
+ );
229
+ return [
230
+ ...elsewhere,
231
+ ...ranked.map(name => ({
232
+ name: `${here} ${name}`,
233
+ reason: 'available subcommand',
234
+ })),
235
+ ];
236
+ }
237
+
238
+ /**
239
+ * The pointer for a word that is a command only under `experimental theme`
240
+ * (`theme editor` is `experimental theme editor`), read from those commands'
241
+ * docs so it needs no other command loaded. Empty for any other word.
242
+ * @param {string} invocation how to run the CLI
243
+ * @param {string} word
244
+ * @returns {Array<{name: string, reason: string}>}
245
+ */
246
+ export function experimentalThemePointer(invocation, word) {
247
+ const only = [experimentalEditorDoc.name, experimentalPreviewDoc.name];
248
+ const command = only.find(name => name.split(' ').at(-1) === word);
249
+ return command
250
+ ? [
251
+ {
252
+ name: `${invocation} ${command}`,
253
+ reason: `${word} is in the experimental theme commands`,
254
+ },
255
+ ]
256
+ : [];
257
+ }
258
+
259
+ /**
260
+ * The pointer for a word under `experimental` that is a command of
261
+ * `experimental theme` (`experimental editor` is `experimental theme
262
+ * editor`). Empty for any other word.
263
+ * @param {string} invocation how to run the CLI
264
+ * @param {string} word
265
+ * @param {import('commander').Command | undefined} experimental the loaded
266
+ * `experimental` group
267
+ * @returns {Array<{name: string, reason: string}>}
268
+ */
269
+ export function experimentalSubcommandPointer(invocation, word, experimental) {
270
+ const theme = experimental?.commands.find(c => c.name() === 'theme');
271
+ return theme?.commands.some(c => c.name() === word)
272
+ ? [
273
+ {
274
+ name: `${invocation} experimental theme ${word}`,
275
+ reason: `${word} is a theme subcommand`,
276
+ },
277
+ ]
278
+ : [];
279
+ }
280
+
281
+ /**
282
+ * The refusal of an unknown subcommand of `theme` or `experimental`: its
283
+ * message, and whole commands to run, closest first, led by the
284
+ * `experimental theme` command the word names when it names one.
285
+ * @param {'theme' | 'experimental'} group
286
+ * @param {string} word the unknown word
287
+ * @param {string[]} names the group's subcommand names
288
+ * @param {import('commander').Command | undefined} loaded the loaded group
289
+ * @returns {{message: string, suggestions: Array<{name: string, reason: string}>}}
290
+ */
291
+ export function themeGroupUnknownSubcommand(group, word, names, loaded) {
292
+ const invocation = getCliInvocation(process.cwd());
293
+ const moved =
294
+ group === 'theme'
295
+ ? experimentalThemePointer(invocation, word)
296
+ : experimentalSubcommandPointer(invocation, word, loaded);
297
+ return {
298
+ message: `unknown subcommand '${group} ${word}'${moved.length > 0 ? `; it is ${moved[0].name}` : ''}`,
299
+ suggestions: unknownSubcommandSuggestions(
300
+ `${invocation} ${group}`,
301
+ word,
302
+ names,
303
+ moved,
304
+ ),
305
+ };
306
+ }