@astryxdesign/cli 0.7.15-canary.g79b95eb → 0.7.15-canary.gbe99721
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.
- package/CHANGELOG.md +3 -3
- package/README.md +63 -63
- package/api/build/_adapter.d.mts +4 -0
- package/api/build/_adapter.mjs +28 -2
- package/api/build/blocks/blocks.d.mts +10 -1
- package/api/build/blocks/blocks.mjs +84 -7
- package/api/build/build.mjs +6 -1
- package/api/build/tree.d.mts +4 -0
- package/api/build/tree.mjs +9 -2
- package/api/doctor/_adapter.d.mts +2 -1
- package/api/doctor/_adapter.mjs +6 -1
- package/api/doctor/doctor.mjs +2 -2
- package/api/doctor/theme-checks.mjs +56 -21
- package/api/integration/add-helpers.mjs +5 -0
- package/api/integration/add-theme.mjs +15 -110
- package/api/integration/validate-integration.mjs +17 -3
- package/api/integration/validateIntegration.doc.mjs +1 -1
- package/api/theme/_adapter.d.mts +37 -5
- package/api/theme/_adapter.mjs +363 -50
- package/api/theme/_fork.d.mts +90 -0
- package/api/theme/_fork.mjs +246 -0
- package/api/theme/build/build.d.mts +25 -1
- package/api/theme/build/build.mjs +352 -41
- package/api/theme/eject/eject.mjs +36 -15
- package/api/theme/list/list.mjs +3 -6
- package/api/theme/palette/generate/generator.d.mts +13 -0
- package/api/theme/palette/generate/generator.mjs +32 -2
- package/api/theme/targets/targets.mjs +10 -3
- package/api/theme/template/template.mjs +48 -2
- package/api/theme/theme.type.d.mts +8 -0
- package/api/theme/theme.type.mjs +5 -1
- package/api/theme/themeBuild.doc.mjs +2 -2
- package/api/theme/themeRemove.doc.mjs +5 -2
- package/api/theme/themeTemplate.doc.mjs +2 -2
- package/api/theme/themeUse.doc.mjs +8 -2
- package/api/theme-edit/_adapter.mjs +157 -36
- package/api/theme-edit/_catalog.d.mts +1 -6
- package/api/theme-edit/_catalog.mjs +5 -268
- package/api/theme-edit/_check.d.mts +3 -1
- package/api/theme-edit/_check.mjs +733 -308
- package/api/theme-edit/_color.d.mts +19 -0
- package/api/theme-edit/_color.mjs +277 -33
- package/api/theme-edit/_compiler.d.mts +1 -0
- package/api/theme-edit/_compiler.mjs +25 -0
- package/api/theme-edit/_context.d.mts +2 -0
- package/api/theme-edit/_context.mjs +83 -9
- package/api/theme-edit/_css.d.mts +84 -0
- package/api/theme-edit/_css.mjs +700 -0
- package/api/theme-edit/_edit.mjs +370 -85
- package/api/theme-edit/_how-commands.d.mts +5 -0
- package/api/theme-edit/_how-commands.mjs +20 -13
- package/api/theme-edit/_how-question.d.mts +29 -0
- package/api/theme-edit/_how-question.mjs +1573 -182
- package/api/theme-edit/_how.mjs +306 -22
- package/api/theme-edit/_overview.mjs +2 -7
- package/api/theme-edit/_palette.d.mts +27 -5
- package/api/theme-edit/_palette.mjs +231 -97
- package/api/theme-edit/_parts.d.mts +42 -10
- package/api/theme-edit/_parts.mjs +224 -69
- package/api/theme-edit/_preview-app.d.mts +8 -0
- package/api/theme-edit/_preview-app.mjs +549 -96
- package/api/theme-edit/_preview.d.mts +7 -16
- package/api/theme-edit/_preview.mjs +77 -84
- package/api/theme-edit/_project.d.mts +20 -1
- package/api/theme-edit/_project.mjs +43 -13
- package/api/theme-edit/_settings.d.mts +96 -20
- package/api/theme-edit/_settings.mjs +646 -141
- package/api/theme-edit/_tables.d.mts +18 -12
- package/api/theme-edit/_tables.mjs +144 -147
- package/api/theme-edit/theme-edit.type.d.mts +10 -1
- package/api/theme-edit/theme-edit.type.mjs +3 -1
- package/api/theme-edit/themeEditNew.doc.mjs +1 -1
- package/api/theme-edit/themeEditPreviewAdd.doc.mjs +1 -1
- package/api/theme-edit/themeEditPreviewApp.doc.mjs +1 -1
- package/api/theme-edit/themeEditPreviewList.doc.mjs +2 -2
- package/api/theme-edit/themeEditSet.doc.mjs +1 -1
- package/api/theme-edit/themeEditUndo.doc.mjs +1 -1
- package/assets/docs/tree/checks.doc.mjs +22 -1
- package/assets/docs/tree/publishing.doc.mjs +1 -0
- package/assets/docs.generated.json +2 -2
- package/assets/self-audit.generated.json +1 -1
- package/authoring/integration/integration.doc.mjs +8 -0
- package/authoring/integration/schema.d.mts +8 -0
- package/authoring/integration/schema.mjs +1 -0
- package/authoring/integration/type.ts +9 -0
- package/clients/cli/build-id.generated.json +1 -1
- package/clients/cli/commands/experimental/index.mjs +10 -10
- package/clients/cli/commands/experimental/theme.mjs +22 -3
- package/clients/cli/commands/experimental-theme-compile.doc.mjs +2 -2
- package/clients/cli/commands/experimental-theme-editor-new.doc.mjs +3 -3
- package/clients/cli/commands/experimental-theme-preview-add.doc.mjs +1 -1
- package/clients/cli/commands/experimental-theme-preview-app.doc.mjs +1 -1
- package/clients/cli/commands/integration.mjs +8 -0
- package/clients/cli/commands/theme-build.doc.mjs +2 -2
- package/clients/cli/commands/theme-list.doc.mjs +1 -1
- package/clients/cli/commands/theme-template.doc.mjs +1 -1
- package/clients/cli/commands/theme.mjs +325 -48
- package/clients/cli/index.mjs +18 -3
- package/clients/cli/lib/cli-error.mjs +118 -3
- package/clients/cli/manifest.generated.json +1 -1
- package/foundation/config/project.mjs +34 -8
- package/foundation/config/theme-state.d.mts +16 -0
- package/foundation/config/theme-state.mjs +84 -13
- package/foundation/discovery/template-needs.d.mts +13 -0
- package/foundation/discovery/template-needs.mjs +30 -15
- package/foundation/discovery/theme-discovery.mjs +14 -2
- package/foundation/discovery/theme-imports.d.mts +16 -0
- package/foundation/discovery/theme-imports.mjs +30 -2
- package/foundation/doc-compiler/import.mjs +10 -4
- package/foundation/fs/gather-cache.mjs +93 -26
- package/foundation/fs/jiti-cache.d.mts +21 -0
- package/foundation/fs/jiti-cache.mjs +66 -0
- package/foundation/fs/module-loader.mjs +7 -2
- package/foundation/fs/read-record.mjs +8 -2
- package/foundation/integrations/autolink.d.mts +1 -24
- package/foundation/integrations/autolink.mjs +7 -60
- package/foundation/integrations/declared-dependencies.d.mts +27 -0
- package/foundation/integrations/declared-dependencies.mjs +73 -0
- package/foundation/integrations/integrations.d.mts +8 -0
- package/foundation/integrations/integrations.mjs +4 -0
- package/foundation/integrations/may-have-integrations.d.mts +8 -0
- package/foundation/integrations/may-have-integrations.mjs +47 -0
- package/foundation/integrations/validate-contributions.d.mts +62 -1
- package/foundation/integrations/validate-contributions.mjs +452 -29
- package/foundation/release/cache.d.mts +21 -2
- package/foundation/release/cache.mjs +48 -8
- package/foundation/release/folder-lock.d.mts +7 -0
- package/foundation/release/folder-lock.mjs +60 -26
- package/foundation/release/lock-lease.d.mts +2 -1
- package/foundation/release/lock-lease.mjs +7 -2
- package/foundation/response/error-codes.doc.mjs +1 -1
- package/foundation/response/response-types.doc.mjs +5 -5
- package/package.json +6 -6
- package/api/theme-edit/_css-properties.d.mts +0 -10
- package/api/theme-edit/_css-properties.mjs +0 -556
package/clients/cli/index.mjs
CHANGED
|
@@ -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:
|
|
738
|
-
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 {
|
|
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 {
|
|
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)
|
|
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
|
+
}
|