@astryxdesign/cli 0.7.15-canary.gf890983 → 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 (115) hide show
  1. package/CHANGELOG.md +353 -3
  2. package/api/doctor/_adapter.d.mts +2 -1
  3. package/api/doctor/_adapter.mjs +6 -1
  4. package/api/doctor/doctor.mjs +2 -2
  5. package/api/doctor/theme-checks.mjs +56 -21
  6. package/api/integration/add-helpers.mjs +5 -0
  7. package/api/integration/add-theme.mjs +15 -110
  8. package/api/theme/_adapter.d.mts +37 -5
  9. package/api/theme/_adapter.mjs +363 -50
  10. package/api/theme/_fork.d.mts +90 -0
  11. package/api/theme/_fork.mjs +246 -0
  12. package/api/theme/build/build.d.mts +25 -1
  13. package/api/theme/build/build.mjs +352 -41
  14. package/api/theme/eject/eject.mjs +36 -15
  15. package/api/theme/list/list.mjs +3 -6
  16. package/api/theme/palette/generate/generator.d.mts +13 -0
  17. package/api/theme/palette/generate/generator.mjs +32 -2
  18. package/api/theme/targets/targets.mjs +10 -3
  19. package/api/theme/template/template.mjs +48 -2
  20. package/api/theme/theme.type.d.mts +8 -0
  21. package/api/theme/theme.type.mjs +5 -1
  22. package/api/theme/themeBuild.doc.mjs +2 -2
  23. package/api/theme/themeRemove.doc.mjs +5 -2
  24. package/api/theme/themeTemplate.doc.mjs +2 -2
  25. package/api/theme/themeUse.doc.mjs +8 -2
  26. package/api/theme-edit/_adapter.mjs +157 -36
  27. package/api/theme-edit/_catalog.d.mts +1 -6
  28. package/api/theme-edit/_catalog.mjs +5 -268
  29. package/api/theme-edit/_check.d.mts +3 -1
  30. package/api/theme-edit/_check.mjs +733 -308
  31. package/api/theme-edit/_color.d.mts +19 -0
  32. package/api/theme-edit/_color.mjs +277 -33
  33. package/api/theme-edit/_compiler.d.mts +1 -0
  34. package/api/theme-edit/_compiler.mjs +25 -0
  35. package/api/theme-edit/_context.d.mts +2 -0
  36. package/api/theme-edit/_context.mjs +83 -9
  37. package/api/theme-edit/_css.d.mts +84 -0
  38. package/api/theme-edit/_css.mjs +700 -0
  39. package/api/theme-edit/_edit.mjs +370 -85
  40. package/api/theme-edit/_how-commands.d.mts +5 -0
  41. package/api/theme-edit/_how-commands.mjs +20 -13
  42. package/api/theme-edit/_how-question.d.mts +29 -0
  43. package/api/theme-edit/_how-question.mjs +1573 -182
  44. package/api/theme-edit/_how.mjs +306 -22
  45. package/api/theme-edit/_overview.mjs +2 -7
  46. package/api/theme-edit/_palette.d.mts +27 -5
  47. package/api/theme-edit/_palette.mjs +231 -97
  48. package/api/theme-edit/_parts.d.mts +42 -10
  49. package/api/theme-edit/_parts.mjs +224 -69
  50. package/api/theme-edit/_preview-app.d.mts +8 -0
  51. package/api/theme-edit/_preview-app.mjs +549 -96
  52. package/api/theme-edit/_preview.d.mts +7 -16
  53. package/api/theme-edit/_preview.mjs +77 -84
  54. package/api/theme-edit/_project.d.mts +20 -1
  55. package/api/theme-edit/_project.mjs +43 -13
  56. package/api/theme-edit/_settings.d.mts +96 -20
  57. package/api/theme-edit/_settings.mjs +646 -141
  58. package/api/theme-edit/_tables.d.mts +18 -12
  59. package/api/theme-edit/_tables.mjs +144 -147
  60. package/api/theme-edit/theme-edit.type.d.mts +10 -1
  61. package/api/theme-edit/theme-edit.type.mjs +3 -1
  62. package/api/theme-edit/themeEditNew.doc.mjs +1 -1
  63. package/api/theme-edit/themeEditPreviewAdd.doc.mjs +1 -1
  64. package/api/theme-edit/themeEditPreviewApp.doc.mjs +1 -1
  65. package/api/theme-edit/themeEditPreviewList.doc.mjs +2 -2
  66. package/api/theme-edit/themeEditSet.doc.mjs +1 -1
  67. package/api/theme-edit/themeEditUndo.doc.mjs +1 -1
  68. package/assets/docs/tree/publishing.doc.mjs +1 -0
  69. package/assets/docs.generated.json +2 -2
  70. package/assets/self-audit.generated.json +1 -1
  71. package/clients/cli/build-id.generated.json +1 -1
  72. package/clients/cli/commands/experimental/index.mjs +10 -10
  73. package/clients/cli/commands/experimental/theme.mjs +22 -3
  74. package/clients/cli/commands/experimental-theme-compile.doc.mjs +2 -2
  75. package/clients/cli/commands/experimental-theme-editor-new.doc.mjs +3 -3
  76. package/clients/cli/commands/experimental-theme-preview-add.doc.mjs +1 -1
  77. package/clients/cli/commands/experimental-theme-preview-app.doc.mjs +1 -1
  78. package/clients/cli/commands/integration.mjs +8 -0
  79. package/clients/cli/commands/theme-build.doc.mjs +2 -2
  80. package/clients/cli/commands/theme-list.doc.mjs +1 -1
  81. package/clients/cli/commands/theme-template.doc.mjs +1 -1
  82. package/clients/cli/commands/theme.mjs +325 -48
  83. package/clients/cli/index.mjs +18 -3
  84. package/clients/cli/lib/cli-error.mjs +118 -3
  85. package/clients/cli/manifest.generated.json +1 -1
  86. package/foundation/config/project.mjs +34 -8
  87. package/foundation/config/theme-state.d.mts +16 -0
  88. package/foundation/config/theme-state.mjs +84 -13
  89. package/foundation/discovery/template-needs.d.mts +13 -0
  90. package/foundation/discovery/template-needs.mjs +30 -15
  91. package/foundation/discovery/theme-discovery.mjs +14 -2
  92. package/foundation/discovery/theme-imports.d.mts +16 -0
  93. package/foundation/discovery/theme-imports.mjs +30 -2
  94. package/foundation/doc-compiler/import.mjs +10 -4
  95. package/foundation/fs/gather-cache.mjs +82 -23
  96. package/foundation/fs/jiti-cache.d.mts +21 -0
  97. package/foundation/fs/jiti-cache.mjs +66 -0
  98. package/foundation/fs/module-loader.mjs +7 -2
  99. package/foundation/integrations/autolink.d.mts +1 -24
  100. package/foundation/integrations/autolink.mjs +7 -60
  101. package/foundation/integrations/declared-dependencies.d.mts +27 -0
  102. package/foundation/integrations/declared-dependencies.mjs +73 -0
  103. package/foundation/integrations/may-have-integrations.d.mts +8 -0
  104. package/foundation/integrations/may-have-integrations.mjs +47 -0
  105. package/foundation/release/cache.d.mts +21 -2
  106. package/foundation/release/cache.mjs +48 -8
  107. package/foundation/release/folder-lock.d.mts +7 -0
  108. package/foundation/release/folder-lock.mjs +60 -26
  109. package/foundation/release/lock-lease.d.mts +2 -1
  110. package/foundation/release/lock-lease.mjs +7 -2
  111. package/foundation/response/error-codes.doc.mjs +1 -1
  112. package/foundation/response/response-types.doc.mjs +4 -4
  113. package/package.json +6 -6
  114. package/api/theme-edit/_css-properties.d.mts +0 -10
  115. package/api/theme-edit/_css-properties.mjs +0 -556
@@ -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
+ }