@astryxdesign/cli 0.7.15 → 0.7.16-canary.g22213fd
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/README.md +6 -4
- package/api/build/_adapter.d.mts +10 -0
- package/api/build/_adapter.mjs +24 -0
- package/api/build/blocks/blocks.d.mts +1 -0
- package/api/build/blocks/blocks.mjs +18 -1
- package/api/build/kit/shell.weights.json +1 -0
- package/api/build/kit/shellcall.d.mts +26 -0
- package/api/build/kit/shellcall.mjs +87 -0
- package/api/build/kit/start.mjs +67 -4
- package/api/build/kit/weights.d.mts +15 -0
- package/api/build/kit/weights.mjs +27 -0
- package/api/component/__fixtures__/resolutions/modules.txt +1 -1
- package/api/component/_adapter.d.mts +1 -1
- package/api/component/_adapter.mjs +28 -1
- package/api/doctor/_adapter.d.mts +38 -2
- package/api/doctor/_adapter.mjs +76 -1
- package/api/doctor/built-checks.mjs +1 -1
- package/api/doctor/doctor.d.mts +26 -0
- package/api/doctor/doctor.doc.mjs +1 -1
- package/api/doctor/doctor.mjs +156 -11
- package/api/doctor/theme-checks.mjs +163 -18
- package/api/icon/_adapter.d.mts +7 -3
- package/api/icon/_adapter.mjs +12 -3
- package/api/icon/icon.type.d.mts +15 -0
- package/api/icon/icon.type.mjs +10 -3
- package/api/icon/iconUse.doc.mjs +19 -5
- package/api/icon/list/list.mjs +7 -1
- package/api/icon/use/use.d.mts +8 -5
- package/api/icon/use/use.mjs +95 -13
- package/api/init/run/run.mjs +1 -0
- package/api/integration/add-contribution.mjs +3 -3
- package/api/integration/pack-check.mjs +14 -8
- package/api/integration/validate-integration.mjs +1 -1
- package/api/search/_adapter.mjs +15 -16
- package/api/search/_entries.d.mts +2 -1
- package/api/search/_entries.mjs +28 -1
- package/api/swizzle/_moduleGraph.mjs +1 -1
- package/api/template/template.type.d.mts +6 -2
- package/api/template/template.type.mjs +2 -1
- package/api/theme/_adapter.d.mts +5 -2
- package/api/theme/_adapter.mjs +59 -14
- package/api/theme/_fork.mjs +1 -1
- package/api/theme/build/build.d.mts +120 -32
- package/api/theme/build/build.mjs +471 -111
- package/api/theme/eject/eject.mjs +22 -1
- package/api/theme/generateTonalPalette.doc.mjs +2 -2
- package/api/theme/palette/generate/generator.mjs +141 -2
- package/api/theme/template/template.d.mts +19 -0
- package/api/theme/template/template.mjs +102 -25
- package/api/theme/theme.type.d.mts +44 -1
- package/api/theme/theme.type.mjs +23 -1
- package/api/theme/themeBuild.doc.mjs +4 -4
- package/api/theme/themeEject.doc.mjs +1 -1
- package/api/theme/themePaletteGenerate.doc.mjs +1 -1
- package/api/theme/themeTemplate.doc.mjs +9 -3
- package/api/theme-edit/_adapter.d.mts +33 -2
- package/api/theme-edit/_adapter.mjs +276 -41
- package/api/theme-edit/_check.d.mts +93 -4
- package/api/theme-edit/_check.mjs +1712 -223
- package/api/theme-edit/_color.d.mts +2 -8
- package/api/theme-edit/_color.mjs +292 -219
- package/api/theme-edit/_compiler.d.mts +1 -0
- package/api/theme-edit/_compiler.mjs +20 -1
- package/api/theme-edit/_context.d.mts +31 -1
- package/api/theme-edit/_context.mjs +445 -41
- package/api/theme-edit/_css.d.mts +60 -1
- package/api/theme-edit/_css.mjs +404 -28
- package/api/theme-edit/_edit.d.mts +25 -0
- package/api/theme-edit/_edit.mjs +1620 -154
- package/api/theme-edit/_how-commands.d.mts +11 -26
- package/api/theme-edit/_how-commands.mjs +30 -2
- package/api/theme-edit/_how-question.d.mts +15 -0
- package/api/theme-edit/_how-question.mjs +1469 -194
- package/api/theme-edit/_how.mjs +144 -30
- package/api/theme-edit/_marks.d.mts +13 -0
- package/api/theme-edit/_marks.mjs +15 -0
- package/api/theme-edit/_overview.mjs +2 -0
- package/api/theme-edit/_palette.d.mts +38 -0
- package/api/theme-edit/_palette.mjs +306 -73
- package/api/theme-edit/_parts.d.mts +33 -0
- package/api/theme-edit/_parts.mjs +138 -9
- package/api/theme-edit/_png.d.mts +18 -0
- package/api/theme-edit/_png.mjs +95 -14
- package/api/theme-edit/_preview-app.d.mts +55 -1
- package/api/theme-edit/_preview-app.mjs +1552 -101
- package/api/theme-edit/_preview.d.mts +71 -3
- package/api/theme-edit/_preview.mjs +565 -35
- package/api/theme-edit/_project.d.mts +15 -0
- package/api/theme-edit/_project.mjs +68 -13
- package/api/theme-edit/_settings.d.mts +299 -5
- package/api/theme-edit/_settings.mjs +2806 -158
- package/api/theme-edit/_tables.d.mts +24 -0
- package/api/theme-edit/_tables.mjs +212 -150
- package/api/theme-edit/_vet.d.mts +42 -0
- package/api/theme-edit/_vet.mjs +144 -0
- package/api/theme-edit/theme-edit.type.d.mts +31 -2
- package/api/theme-edit/theme-edit.type.mjs +10 -2
- package/api/theme-edit/themeEditNew.doc.mjs +1 -1
- package/api/theme-edit/themeEditPreviewApp.doc.mjs +1 -1
- package/api/theme-edit/themeEditShow.doc.mjs +11 -3
- package/api/upgrade/registry/registry.mjs +6 -1
- package/assets/codemods/parse.mjs +2 -2
- package/assets/docs/author-a-theme.doc.mjs +1 -1
- package/assets/docs/theme.doc.dense.mjs +1 -1
- package/assets/docs/theme.doc.mjs +1 -1
- package/assets/docs/theme.doc.zh.mjs +4 -3
- package/assets/docs/tree/define-the-theme.doc.mjs +1 -1
- package/assets/docs/tree/icon-sets.doc.mjs +63 -8
- package/assets/docs/tree/single-component.doc.mjs +11 -2
- package/assets/docs/tree/tokens-and-setup.doc.mjs +39 -3
- package/assets/docs.generated.json +2 -2
- package/assets/preview-app/next.config.mjs +7 -1
- package/assets/preview-app/package.json +1 -0
- package/assets/preview-app/src/app/globals.css +1 -0
- package/assets/self-audit.generated.json +1 -1
- package/assets/templates/blocks/components/Outline/useOutlineFromDOMHookUsage.doc.mjs +21 -0
- package/assets/templates/blocks/components/Outline/useOutlineFromDOMHookUsage.tsx +62 -0
- package/assets/templates/blocks/components/Table/ColumnsVirtualizationHookUsage.doc.mjs +14 -0
- package/assets/templates/blocks/components/Table/ColumnsVirtualizationHookUsage.tsx +53 -0
- package/assets/templates/blocks/components/Table/InfiniteScrollHookUsage.doc.mjs +14 -0
- package/assets/templates/blocks/components/Table/InfiniteScrollHookUsage.tsx +33 -0
- package/assets/templates/components.generated.json +1 -1
- package/assets/templates/pages/ai-chat/page.tsx +20 -2
- package/assets/templates/pages/dashboard/page.tsx +1 -1
- package/assets/templates/themes/neutral/neutralPalettes.generated.receipt.json +2 -0
- package/authoring/config/config.doc.mjs +8 -0
- package/authoring/config/parse.d.mts +1 -0
- package/authoring/config/parse.mjs +12 -0
- package/authoring/config/type.ts +8 -0
- package/authoring/doctypes/_schema.d.mts +52 -5
- package/authoring/doctypes/_schema.mjs +62 -7
- package/authoring/doctypes/base/type.ts +10 -0
- package/authoring/doctypes/component/component.doc.mjs +1 -1
- package/authoring/doctypes/function/function.doc.mjs +6 -0
- package/authoring/doctypes/function/type.ts +3 -0
- package/authoring/doctypes/icon-set/icon-set-data.doc.mjs +3 -3
- package/authoring/doctypes/legacy.mjs +5 -1
- package/authoring/index.d.ts +1 -0
- package/authoring/shadcn/source-variants.d.mts +1 -1
- package/authoring/shadcn/source-variants.mjs +32 -10
- package/clients/cli/build-id.generated.json +1 -1
- package/clients/cli/commands/doctor.doc.mjs +2 -2
- package/clients/cli/commands/experimental/icon.mjs +61 -6
- package/clients/cli/commands/experimental/theme.mjs +244 -45
- package/clients/cli/commands/experimental-icon-use.doc.mjs +12 -5
- package/clients/cli/commands/experimental-theme-compile.doc.mjs +2 -2
- package/clients/cli/commands/experimental-theme-editor-new.doc.mjs +2 -2
- package/clients/cli/commands/experimental-theme-editor-set.doc.mjs +2 -2
- package/clients/cli/commands/experimental-theme-editor-show.doc.mjs +3 -3
- package/clients/cli/commands/experimental-theme-editor-undo.doc.mjs +2 -2
- package/clients/cli/commands/experimental-theme-editor.doc.mjs +1 -1
- package/clients/cli/commands/experimental-theme-eject.doc.mjs +1 -1
- 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/experimental-theme-template.doc.mjs +2 -2
- package/clients/cli/commands/theme-build.doc.mjs +2 -2
- package/clients/cli/commands/theme-eject.doc.mjs +1 -1
- package/clients/cli/commands/theme-template.doc.mjs +3 -1
- package/clients/cli/commands/theme.doc.mjs +7 -2
- package/clients/cli/commands/theme.mjs +222 -55
- package/clients/cli/commands.generated.json +1 -1
- package/clients/cli/formatters/index.mjs +7 -4
- package/clients/cli/index.mjs +25 -5
- package/clients/cli/lib/cli-error.mjs +9 -3
- package/clients/cli/lib/component-format.mjs +27 -9
- package/clients/cli/lib/json-shim.mjs +72 -2
- package/clients/cli/manifest.generated.json +1 -1
- package/clients/cli/run.mjs +49 -0
- package/foundation/agent-docs/agent-docs-target.d.mts +2 -6
- package/foundation/agent-docs/agent-docs-target.mjs +9 -17
- package/foundation/agent-docs/agent-docs.mjs +4 -3
- package/foundation/config/config-writer.d.mts +23 -0
- package/foundation/config/config-writer.mjs +152 -58
- package/foundation/config/project.mjs +103 -16
- package/foundation/discovery/component-discovery.mjs +11 -22
- package/foundation/discovery/icon-set-checks.mjs +164 -48
- package/foundation/discovery/icon-set-discovery.d.mts +38 -5
- package/foundation/discovery/icon-set-discovery.mjs +50 -6
- package/foundation/discovery/icon-set-theme-maps.d.mts +59 -0
- package/foundation/discovery/icon-set-theme-maps.mjs +95 -0
- package/foundation/discovery/icon-set-writer.d.mts +2 -3
- package/foundation/discovery/icon-set-writer.mjs +58 -17
- package/foundation/discovery/module-exports.mjs +1 -15
- package/foundation/discovery/template-adapter.mjs +44 -19
- package/foundation/discovery/template-icons.d.mts +27 -10
- package/foundation/discovery/template-icons.mjs +142 -26
- package/foundation/discovery/template-source-tree.mjs +3 -16
- package/foundation/discovery/theme-discovery.d.mts +30 -1
- package/foundation/discovery/theme-discovery.mjs +109 -50
- package/foundation/fs/exact-codec.d.mts +35 -0
- package/foundation/fs/exact-codec.mjs +148 -0
- package/foundation/fs/gather-cache.d.mts +15 -5
- package/foundation/fs/gather-cache.mjs +129 -31
- package/foundation/fs/paths.d.mts +39 -0
- package/foundation/fs/paths.mjs +44 -11
- package/foundation/fs/read-record.mjs +11 -1
- package/foundation/integrations/autolink.d.mts +4 -2
- package/foundation/integrations/autolink.mjs +4 -2
- package/foundation/integrations/cli-requirement.d.mts +16 -5
- package/foundation/integrations/cli-requirement.mjs +27 -6
- package/foundation/integrations/contribution-fixes.mjs +1 -16
- package/foundation/integrations/may-have-integrations.mjs +7 -3
- package/foundation/integrations/missing-dependency.d.mts +9 -0
- package/foundation/integrations/missing-dependency.mjs +100 -0
- package/foundation/integrations/public-imports.mjs +1 -1
- package/foundation/render/embedded-imports.mjs +1 -1
- package/foundation/render/host-exit.d.mts +8 -0
- package/foundation/render/host-exit.mjs +11 -0
- package/foundation/render/page-host.mjs +56 -10
- package/foundation/render/page-worker.mjs +14 -0
- package/foundation/render/render-page.mjs +37 -2
- package/foundation/response/error-codes.d.mts +2 -1
- package/foundation/response/error-codes.d.ts +1 -0
- package/foundation/response/error-codes.doc.mjs +5 -0
- package/foundation/response/error-codes.mjs +3 -0
- package/foundation/response/json.d.mts +15 -0
- package/foundation/response/json.mjs +52 -1
- package/foundation/response/response-types.doc.mjs +1 -1
- package/foundation/runtime/lazy-dependencies.d.mts +14 -0
- package/foundation/runtime/lazy-dependencies.mjs +82 -0
- package/foundation/xle/browser.d.mts +2 -2
- package/package.json +7 -6
|
@@ -35,6 +35,7 @@ import {fileURLToPath} from 'node:url';
|
|
|
35
35
|
import {spawn} from 'node:child_process';
|
|
36
36
|
import {
|
|
37
37
|
getCliInvocation,
|
|
38
|
+
commandInFolder,
|
|
38
39
|
quoteCommandArgument,
|
|
39
40
|
} from '../../../foundation/env/package-manager.mjs';
|
|
40
41
|
import {isOutsideProject} from '../../../foundation/env/project-scope.mjs';
|
|
@@ -57,7 +58,11 @@ import {themeAdd} from '../../../api/theme/add/add.mjs';
|
|
|
57
58
|
import {themeRemove} from '../../../api/theme/remove/remove.mjs';
|
|
58
59
|
import {themeUse} from '../../../api/theme/use/use.mjs';
|
|
59
60
|
import {themeEject} from '../../../api/theme/eject/eject.mjs';
|
|
60
|
-
import {
|
|
61
|
+
import {
|
|
62
|
+
OUTSIDE_PROJECT_WARNING,
|
|
63
|
+
themeTemplate,
|
|
64
|
+
} from '../../../api/theme/template/template.mjs';
|
|
65
|
+
import {findPackageRoot} from '../../../foundation/fs/paths.mjs';
|
|
61
66
|
import {
|
|
62
67
|
themeListAvailable,
|
|
63
68
|
themeListCopySources,
|
|
@@ -73,11 +78,13 @@ import {
|
|
|
73
78
|
import {
|
|
74
79
|
printBatchTrailer,
|
|
75
80
|
printCompactTrailer,
|
|
76
|
-
|
|
81
|
+
setEditorFolderListener,
|
|
77
82
|
themeBuildFamily,
|
|
78
83
|
themeBuildForReport,
|
|
84
|
+
themeBuildWithHandOff,
|
|
79
85
|
themeSourceFiles,
|
|
80
86
|
themeSourceGuesses,
|
|
87
|
+
buildSuggestion,
|
|
81
88
|
writeDeferredBuildOutputs,
|
|
82
89
|
} from '../../../api/theme/build/build.mjs';
|
|
83
90
|
import {defineCommand} from '../lib/define-command.mjs';
|
|
@@ -111,8 +118,10 @@ import {doc as themePaletteGenerateFn} from '../../../api/theme/themePaletteGene
|
|
|
111
118
|
* @property {string} group - The group's command path: `theme` or `experimental theme`.
|
|
112
119
|
* @property {string} build - The build subcommand's name: `build` or `compile`.
|
|
113
120
|
* @property {(err: import('../../../api/error.mjs').AstryxError, cwd: string) => import('../../../api/error.mjs').AstryxError | null} [explain] - A clearer refusal for this group, or null.
|
|
114
|
-
* @property {(files: string[], options: {cwd: string, check?: boolean, family?: boolean}) => Promise<import('../../../api/error.mjs').AstryxError | null>} [preflight] - A refusal before a build starts, or null.
|
|
121
|
+
* @property {(files: string[], options: {cwd: string, check?: boolean, family?: boolean, iconsSpecifier?: string, out?: string}) => Promise<import('../../../api/error.mjs').AstryxError | null>} [preflight] - A refusal before a build starts, or null.
|
|
115
122
|
* @property {(files: string[], options: {cwd: string}) => Promise<() => Promise<void>>} [hold] - Locks held while a build or check runs; resolves to their release.
|
|
123
|
+
* @property {(file: string, cwd: string) => {name: string, reason: string} | null} [missingSource] - For a source file that is not there, this group's way to write it again, or null.
|
|
124
|
+
* @property {(options: {targetPath?: string, overwrite?: boolean, cwd?: string}) => import('../../../api/theme/theme.type.mjs').ThemeTemplateResponse} [template] - This group's template write, in place of `themeTemplate`.
|
|
116
125
|
*/
|
|
117
126
|
|
|
118
127
|
/** @type {ThemeCommandWords} */
|
|
@@ -222,6 +231,20 @@ function themeCommand(words, sub, args = [], reason = '') {
|
|
|
222
231
|
};
|
|
223
232
|
}
|
|
224
233
|
|
|
234
|
+
/**
|
|
235
|
+
* The message type a `theme build` child sends its watcher in place of a
|
|
236
|
+
* warning a build prints once per invocation (the --out editor-folder
|
|
237
|
+
* warning), so a watch session prints it once, not on every rebuild.
|
|
238
|
+
*/
|
|
239
|
+
const WATCH_WARNING = 'astryx.theme.build.warning';
|
|
240
|
+
|
|
241
|
+
/**
|
|
242
|
+
* The `argv0` a watcher starts each `theme build` child with. With the IPC
|
|
243
|
+
* channel it marks the child as the watcher's own, so a CLI run another way
|
|
244
|
+
* with an IPC channel (forked by a tool or test runner) still prints.
|
|
245
|
+
*/
|
|
246
|
+
const WATCH_CHILD_ARGV0 = 'astryx-theme-watch';
|
|
247
|
+
|
|
225
248
|
/**
|
|
226
249
|
* Path to this CLI's real entry (clients/cli/bin/astryx.mjs), resolved from
|
|
227
250
|
* this module's location (clients/cli/commands/theme.mjs → ../bin/
|
|
@@ -244,9 +267,17 @@ function resolveCliBin() {
|
|
|
244
267
|
* @param {(child: import('node:child_process').ChildProcess) => void} [onSpawn] -
|
|
245
268
|
* Receives the child, so a watcher that stops can stop it too.
|
|
246
269
|
* @param {ThemeCommandWords} [words]
|
|
270
|
+
* @param {(message: unknown) => void} [onMessage] - Receives what the child
|
|
271
|
+
* hands over the channel (WATCH_WARNING messages).
|
|
247
272
|
* @returns {Promise<number>}
|
|
248
273
|
*/
|
|
249
|
-
function runThemeBuildOnceChild(
|
|
274
|
+
function runThemeBuildOnceChild(
|
|
275
|
+
file,
|
|
276
|
+
options,
|
|
277
|
+
onSpawn,
|
|
278
|
+
words = THEME_WORDS,
|
|
279
|
+
onMessage,
|
|
280
|
+
) {
|
|
250
281
|
const cliBin = resolveCliBin();
|
|
251
282
|
const command = [...words.group.split(' '), words.build];
|
|
252
283
|
// A detail level the user chose applies to every rebuild.
|
|
@@ -257,10 +288,15 @@ function runThemeBuildOnceChild(file, options, onSpawn, words = THEME_WORDS) {
|
|
|
257
288
|
if (options.iconsSpecifier)
|
|
258
289
|
args.push('--icons-specifier', options.iconsSpecifier);
|
|
259
290
|
return new Promise((/** @type {(code: number) => void} */ resolve) => {
|
|
291
|
+
// The IPC channel and argv0 tell the child it builds for this watcher: it
|
|
292
|
+
// hands its once-per-invocation warnings over the channel instead of
|
|
293
|
+
// printing them.
|
|
260
294
|
const child = spawn(process.execPath, args, {
|
|
261
|
-
|
|
295
|
+
argv0: WATCH_CHILD_ARGV0,
|
|
296
|
+
stdio: ['inherit', 'inherit', 'inherit', 'ipc'],
|
|
262
297
|
env: process.env,
|
|
263
298
|
});
|
|
299
|
+
child.on('message', message => onMessage?.(message));
|
|
264
300
|
onSpawn?.(child);
|
|
265
301
|
child.on('close', code => resolve(code ?? 0));
|
|
266
302
|
child.on('error', () => resolve(1));
|
|
@@ -290,9 +326,29 @@ async function runThemeBuildWatch(entries, options, words = THEME_WORDS) {
|
|
|
290
326
|
.map(e => rel(e.filePath))
|
|
291
327
|
.join(', ')} for changes — press Ctrl-C to stop.`;
|
|
292
328
|
|
|
329
|
+
// A warning a build prints once per invocation is printed at most once
|
|
330
|
+
// per watch session (spec:AST-017 FR29a), not on every rebuild.
|
|
331
|
+
/** @type {Set<string>} each warning once, whichever build printed it */
|
|
332
|
+
const warned = new Set();
|
|
333
|
+
// Watch never runs under --json, so the logger prints (cli-surface INV12).
|
|
334
|
+
logger.setSilent(false);
|
|
335
|
+
const onMessage = (/** @type {unknown} */ message) => {
|
|
336
|
+
const m = /** @type {{type?: unknown, text?: unknown}} */ (message);
|
|
337
|
+
if (m?.type !== WATCH_WARNING || typeof m.text !== 'string') return;
|
|
338
|
+
if (warned.has(m.text)) return;
|
|
339
|
+
warned.add(m.text);
|
|
340
|
+
logger.warn(m.text);
|
|
341
|
+
};
|
|
342
|
+
|
|
293
343
|
// Initial build.
|
|
294
344
|
for (const entry of entries) {
|
|
295
|
-
await runThemeBuildOnceChild(
|
|
345
|
+
await runThemeBuildOnceChild(
|
|
346
|
+
entry.file,
|
|
347
|
+
options,
|
|
348
|
+
undefined,
|
|
349
|
+
words,
|
|
350
|
+
onMessage,
|
|
351
|
+
);
|
|
296
352
|
}
|
|
297
353
|
|
|
298
354
|
let building = false;
|
|
@@ -323,6 +379,7 @@ async function runThemeBuildWatch(entries, options, words = THEME_WORDS) {
|
|
|
323
379
|
rebuildChild = child;
|
|
324
380
|
},
|
|
325
381
|
words,
|
|
382
|
+
onMessage,
|
|
326
383
|
);
|
|
327
384
|
rebuildDone = done.then(() => {});
|
|
328
385
|
await done;
|
|
@@ -612,12 +669,28 @@ function printThemeApp(result) {
|
|
|
612
669
|
);
|
|
613
670
|
}
|
|
614
671
|
|
|
672
|
+
/**
|
|
673
|
+
* The base the experimental theme editor can start an ejected theme from,
|
|
674
|
+
* by the editor's own check: the theme's slug when it is a built-in base the
|
|
675
|
+
* editor knows (LIKE) and its package is installed where the command runs
|
|
676
|
+
* (baseInstalled), else neutral. Loaded only for an eject.
|
|
677
|
+
* @param {{slug?: string | null}} data
|
|
678
|
+
* @param {string} cwd
|
|
679
|
+
* @returns {Promise<string>}
|
|
680
|
+
*/
|
|
681
|
+
export async function editorBaseFor(data, cwd) {
|
|
682
|
+
if (!data.slug) return 'neutral';
|
|
683
|
+
const {editorBaseIn} = await import('../../../api/theme-edit/_adapter.mjs');
|
|
684
|
+
return editorBaseIn(data.slug, cwd);
|
|
685
|
+
}
|
|
686
|
+
|
|
615
687
|
/**
|
|
616
688
|
* Print every field in a source-fork receipt.
|
|
617
689
|
* @param {import('../../../api/theme/theme.type.mjs').ThemeEjectResponse} result
|
|
618
690
|
* @param {ThemeCommandWords} [words]
|
|
691
|
+
* @param {string} [like] the base the theme editor line starts from
|
|
619
692
|
*/
|
|
620
|
-
function printThemeEject(result, words = THEME_WORDS) {
|
|
693
|
+
function printThemeEject(result, words = THEME_WORDS, like = 'neutral') {
|
|
621
694
|
const {data} = result;
|
|
622
695
|
emit(
|
|
623
696
|
section('Ejected theme'),
|
|
@@ -645,11 +718,41 @@ function printThemeEject(result, words = THEME_WORDS) {
|
|
|
645
718
|
]
|
|
646
719
|
: []),
|
|
647
720
|
text(
|
|
648
|
-
`This is a local fork. Build it with ${getCliInvocation()
|
|
721
|
+
`This is a local fork. Build it with ${buildStep(getCliInvocation(), words, path.join(data.outputDir, data.entry))}.`,
|
|
722
|
+
),
|
|
723
|
+
// One theme-only line (AST-017 FR27): the editor builds only on an
|
|
724
|
+
// Astryx theme package, so a theme from another package starts from
|
|
725
|
+
// neutral.
|
|
726
|
+
text(
|
|
727
|
+
`To make or change a theme: the experimental theme editor, ${getCliInvocation()} experimental theme editor new <name> --like ${like}.`,
|
|
649
728
|
),
|
|
650
729
|
);
|
|
651
730
|
}
|
|
652
731
|
|
|
732
|
+
/**
|
|
733
|
+
* The build command for a theme file a command just wrote, as it works from
|
|
734
|
+
* the current folder: a build writes its outputs beside the source and only
|
|
735
|
+
* inside the folder it runs from, so a file above that folder is built from
|
|
736
|
+
* the project root (`cd ../.. && … theme build theme.template.ts`).
|
|
737
|
+
* @param {string} invocation
|
|
738
|
+
* @param {{group: string, build: string}} words
|
|
739
|
+
* @param {string} file relative to the current folder
|
|
740
|
+
*/
|
|
741
|
+
function buildStep(invocation, words, file) {
|
|
742
|
+
const cwd = process.cwd();
|
|
743
|
+
const abs = path.resolve(cwd, file);
|
|
744
|
+
const rel = path.relative(cwd, abs);
|
|
745
|
+
const posix = (/** @type {string} */ p) => p.split(path.sep).join('/');
|
|
746
|
+
if (!rel.startsWith('..'))
|
|
747
|
+
return `${invocation} ${words.group} ${words.build} ${quoteCommandArgument(posix(rel))}`;
|
|
748
|
+
const root = findPackageRoot(path.dirname(abs)) ?? path.dirname(abs);
|
|
749
|
+
// The shell's own form of "in that folder" (PowerShell has no &&).
|
|
750
|
+
return commandInFolder(
|
|
751
|
+
posix(path.relative(cwd, root)),
|
|
752
|
+
`${invocation} ${words.group} ${words.build} ${quoteCommandArgument(posix(path.relative(root, abs)))}`,
|
|
753
|
+
);
|
|
754
|
+
}
|
|
755
|
+
|
|
653
756
|
/**
|
|
654
757
|
* The CommandDocs one copy of the theme subcommands is built from.
|
|
655
758
|
* @typedef {object} ThemeCommandDocs
|
|
@@ -843,6 +946,10 @@ function registerPaletteCommands(
|
|
|
843
946
|
text(
|
|
844
947
|
'Review and edit the candidate before adopting it as theme-owned palette data.',
|
|
845
948
|
),
|
|
949
|
+
// One theme-only line (AST-017 FR27).
|
|
950
|
+
text(
|
|
951
|
+
`To make or change a theme: the experimental theme editor makes the palettes from one color, ${getCliInvocation(process.cwd())} experimental theme editor set <name> accent <color>.`,
|
|
952
|
+
),
|
|
846
953
|
);
|
|
847
954
|
return NO_RESULT_SET;
|
|
848
955
|
},
|
|
@@ -884,30 +991,52 @@ function registerThemeCommands(theme, program, docs, words) {
|
|
|
884
991
|
const guesses = looksGlobby
|
|
885
992
|
? []
|
|
886
993
|
: themeSourceGuesses(entry.file, process.cwd());
|
|
994
|
+
// An editor theme's own source, deleted by hand: the editor writes
|
|
995
|
+
// it again.
|
|
996
|
+
const rewrite = looksGlobby
|
|
997
|
+
? null
|
|
998
|
+
: (words.missingSource?.(entry.file, process.cwd()) ?? null);
|
|
887
999
|
return cliError(`File not found: ${entry.filePath}`, {
|
|
888
1000
|
code: ERROR_CODES.ERR_FILE_NOT_FOUND,
|
|
889
|
-
suggestions:
|
|
890
|
-
? [
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
1001
|
+
suggestions: rewrite
|
|
1002
|
+
? [rewrite]
|
|
1003
|
+
: looksGlobby
|
|
1004
|
+
? [
|
|
1005
|
+
{
|
|
1006
|
+
// The pattern stays unquoted: the shell expands it.
|
|
1007
|
+
// The caller's mode follows it, quoted, and a family
|
|
1008
|
+
// run stays one.
|
|
1009
|
+
name: buildSuggestion(
|
|
1010
|
+
entry.file,
|
|
1011
|
+
options,
|
|
1012
|
+
process.cwd(),
|
|
1013
|
+
words,
|
|
1014
|
+
{
|
|
1015
|
+
glob: true,
|
|
1016
|
+
family: Boolean(options.family),
|
|
1017
|
+
...(options.family && options.familyKey
|
|
1018
|
+
? {familyKey: String(options.familyKey)}
|
|
1019
|
+
: {}),
|
|
1020
|
+
},
|
|
1021
|
+
),
|
|
1022
|
+
reason:
|
|
1023
|
+
'globs are expanded by your shell; pass the pattern unquoted, or list the files',
|
|
1024
|
+
},
|
|
1025
|
+
]
|
|
1026
|
+
: guesses.length > 0
|
|
1027
|
+
? guesses.map(guess => ({
|
|
1028
|
+
// The same build of that source: a --check stays a check.
|
|
1029
|
+
name: buildSuggestion(guess, options, process.cwd(), words),
|
|
1030
|
+
reason: 'a theme source that exists',
|
|
1031
|
+
}))
|
|
1032
|
+
: [
|
|
1033
|
+
themeCommand(
|
|
1034
|
+
words,
|
|
1035
|
+
'template',
|
|
1036
|
+
['theme.template.ts'],
|
|
1037
|
+
'start a theme source from the annotated template',
|
|
1038
|
+
),
|
|
1039
|
+
],
|
|
911
1040
|
});
|
|
912
1041
|
}
|
|
913
1042
|
|
|
@@ -999,6 +1128,9 @@ function registerThemeCommands(theme, program, docs, words) {
|
|
|
999
1128
|
...(options.out && files.length === 1
|
|
1000
1129
|
? ['--out', options.out]
|
|
1001
1130
|
: []),
|
|
1131
|
+
...(options.iconsSpecifier
|
|
1132
|
+
? ['--icons-specifier', options.iconsSpecifier]
|
|
1133
|
+
: []),
|
|
1002
1134
|
...(options.check ? ['--check'] : []),
|
|
1003
1135
|
],
|
|
1004
1136
|
'build each theme on its own',
|
|
@@ -1074,15 +1206,28 @@ function registerThemeCommands(theme, program, docs, words) {
|
|
|
1074
1206
|
// [ok]/[warn] lines, and the install instructions are all emitted from
|
|
1075
1207
|
// inside themeBuild via the shared logger.
|
|
1076
1208
|
logger.setSilent(json);
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
|
|
1209
|
+
// Started by a watcher (runThemeBuildWatch): hand the editor-folder
|
|
1210
|
+
// warning to it, and let the channel not keep this build alive.
|
|
1211
|
+
const watchChild =
|
|
1212
|
+
typeof process.send === 'function' &&
|
|
1213
|
+
process.argv0 === WATCH_CHILD_ARGV0;
|
|
1214
|
+
if (watchChild) {
|
|
1215
|
+
process.channel?.unref();
|
|
1216
|
+
setEditorFolderListener(warning => {
|
|
1217
|
+
// Held open until the message is out, then let go again.
|
|
1218
|
+
process.channel?.ref();
|
|
1219
|
+
process.send?.({type: WATCH_WARNING, text: warning}, () =>
|
|
1220
|
+
process.channel?.unref(),
|
|
1221
|
+
);
|
|
1222
|
+
});
|
|
1223
|
+
}
|
|
1081
1224
|
|
|
1082
1225
|
const refused = await words.preflight?.(files, {
|
|
1083
1226
|
cwd: process.cwd(),
|
|
1084
1227
|
check: options.check,
|
|
1085
1228
|
family: Boolean(options.family),
|
|
1229
|
+
iconsSpecifier: options.iconsSpecifier,
|
|
1230
|
+
out: options.out,
|
|
1086
1231
|
});
|
|
1087
1232
|
if (refused) return themeError(refused, words, buildFallback);
|
|
1088
1233
|
|
|
@@ -1094,15 +1239,18 @@ function registerThemeCommands(theme, program, docs, words) {
|
|
|
1094
1239
|
familyKey: /** @type {string} */ (options.familyKey),
|
|
1095
1240
|
check: options.check,
|
|
1096
1241
|
iconsSpecifier: options.iconsSpecifier,
|
|
1097
|
-
__onPrivateVarError: onPrivateVarError,
|
|
1098
|
-
__commandWords: words,
|
|
1099
1242
|
},
|
|
1100
1243
|
{cwd: process.cwd()},
|
|
1244
|
+
{commandWords: words},
|
|
1101
1245
|
);
|
|
1102
1246
|
if (json) jsonOut(result);
|
|
1103
1247
|
if (
|
|
1104
|
-
|
|
1105
|
-
(
|
|
1248
|
+
result.type === 'theme.build.check' &&
|
|
1249
|
+
!(
|
|
1250
|
+
/** @type {import('../../../api/theme/theme.type.mjs').ThemeBuildCheckResponse} */ (
|
|
1251
|
+
result
|
|
1252
|
+
).data.upToDate
|
|
1253
|
+
)
|
|
1106
1254
|
) {
|
|
1107
1255
|
process.exitCode = 1;
|
|
1108
1256
|
}
|
|
@@ -1173,10 +1321,12 @@ function registerThemeCommands(theme, program, docs, words) {
|
|
|
1173
1321
|
out: options.out,
|
|
1174
1322
|
check: options.check,
|
|
1175
1323
|
iconsSpecifier: options.iconsSpecifier,
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
|
|
1324
|
+
};
|
|
1325
|
+
/** @type {import('../../../api/theme/build/build.mjs').ThemeBuildHandOff} */
|
|
1326
|
+
const handOff = {
|
|
1327
|
+
claimedOutputs,
|
|
1328
|
+
deferredWrites: deferred ? writes : undefined,
|
|
1329
|
+
commandWords: words,
|
|
1180
1330
|
};
|
|
1181
1331
|
let result;
|
|
1182
1332
|
if (report) {
|
|
@@ -1185,6 +1335,7 @@ function registerThemeCommands(theme, program, docs, words) {
|
|
|
1185
1335
|
buildOptions,
|
|
1186
1336
|
{cwd: process.cwd()},
|
|
1187
1337
|
{compact},
|
|
1338
|
+
handOff,
|
|
1188
1339
|
);
|
|
1189
1340
|
result = built.receipt;
|
|
1190
1341
|
if (built.trailer) trailers.push(built.trailer);
|
|
@@ -1200,9 +1351,12 @@ function registerThemeCommands(theme, program, docs, words) {
|
|
|
1200
1351
|
else show();
|
|
1201
1352
|
}
|
|
1202
1353
|
} else {
|
|
1203
|
-
result = await
|
|
1204
|
-
|
|
1205
|
-
|
|
1354
|
+
result = await themeBuildWithHandOff(
|
|
1355
|
+
entry.file,
|
|
1356
|
+
buildOptions,
|
|
1357
|
+
{cwd: process.cwd()},
|
|
1358
|
+
handOff,
|
|
1359
|
+
);
|
|
1206
1360
|
}
|
|
1207
1361
|
logger.log = log;
|
|
1208
1362
|
logger.warn = warn;
|
|
@@ -1288,10 +1442,8 @@ function registerThemeCommands(theme, program, docs, words) {
|
|
|
1288
1442
|
);
|
|
1289
1443
|
}
|
|
1290
1444
|
|
|
1291
|
-
//
|
|
1292
|
-
|
|
1293
|
-
// a failure after its receipt has been emitted.
|
|
1294
|
-
if (privateVarError || (options.check && stale)) {
|
|
1445
|
+
// Stale --check output is a failure after its receipt has been emitted.
|
|
1446
|
+
if (options.check && stale) {
|
|
1295
1447
|
process.exitCode = 1;
|
|
1296
1448
|
}
|
|
1297
1449
|
|
|
@@ -1471,6 +1623,9 @@ function registerThemeCommands(theme, program, docs, words) {
|
|
|
1471
1623
|
const json = program.opts().json || false;
|
|
1472
1624
|
/** @type {import('../../../api/theme/theme.type.mjs').ThemeEjectResponse} */
|
|
1473
1625
|
let result;
|
|
1626
|
+
// Eject's warnings go to stderr in text mode; the logger is silent
|
|
1627
|
+
// under --json (cli-surface INV12).
|
|
1628
|
+
logger.setSilent(json);
|
|
1474
1629
|
try {
|
|
1475
1630
|
result = await themeEject(slug, {
|
|
1476
1631
|
targetPath,
|
|
@@ -1487,7 +1642,12 @@ function registerThemeCommands(theme, program, docs, words) {
|
|
|
1487
1642
|
}
|
|
1488
1643
|
await warnOnThemeIntegrationIssues(json);
|
|
1489
1644
|
if (json) jsonOut(result);
|
|
1490
|
-
else
|
|
1645
|
+
else
|
|
1646
|
+
printThemeEject(
|
|
1647
|
+
result,
|
|
1648
|
+
words,
|
|
1649
|
+
await editorBaseFor(result.data, process.cwd()),
|
|
1650
|
+
);
|
|
1491
1651
|
return NO_RESULT_SET;
|
|
1492
1652
|
},
|
|
1493
1653
|
});
|
|
@@ -1503,7 +1663,9 @@ function registerThemeCommands(theme, program, docs, words) {
|
|
|
1503
1663
|
/** @type {import('../../../api/theme/theme.type.mjs').ThemeTemplateResponse} */
|
|
1504
1664
|
let result;
|
|
1505
1665
|
try {
|
|
1506
|
-
|
|
1666
|
+
// The experimental command passes its own write, which protects
|
|
1667
|
+
// only the editor's own files.
|
|
1668
|
+
result = (words.template ?? themeTemplate)({
|
|
1507
1669
|
targetPath,
|
|
1508
1670
|
overwrite: options.overwrite,
|
|
1509
1671
|
cwd: process.cwd(),
|
|
@@ -1512,15 +1674,22 @@ function registerThemeCommands(theme, program, docs, words) {
|
|
|
1512
1674
|
const err =
|
|
1513
1675
|
/** @type {import('../../../api/error.mjs').AstryxError} */ (e);
|
|
1514
1676
|
return themeError(err, words, [
|
|
1677
|
+
// No path: the template at the project root, from any folder.
|
|
1515
1678
|
themeCommand(
|
|
1516
1679
|
words,
|
|
1517
1680
|
'template',
|
|
1518
|
-
[
|
|
1681
|
+
[],
|
|
1519
1682
|
'write the template at the project root',
|
|
1520
1683
|
),
|
|
1521
1684
|
]);
|
|
1522
1685
|
}
|
|
1523
1686
|
|
|
1687
|
+
// Outside a project the template is written here, with one warning
|
|
1688
|
+
// on stderr when a file was written; the logger is silent under --json
|
|
1689
|
+
// (cli-surface INV12).
|
|
1690
|
+
logger.setSilent(json);
|
|
1691
|
+
if (result.data.written && !findPackageRoot(process.cwd()))
|
|
1692
|
+
logger.warn(OUTSIDE_PROJECT_WARNING);
|
|
1524
1693
|
// Writes a starter theme file, or declines to overwrite one.
|
|
1525
1694
|
if (json) {
|
|
1526
1695
|
jsonOut(result);
|
|
@@ -1551,9 +1720,7 @@ function registerThemeCommands(theme, program, docs, words) {
|
|
|
1551
1720
|
'It documents every defineTheme field, the token families, and the component override syntax. ' +
|
|
1552
1721
|
'Copy what you need into your own theme file, then delete it.',
|
|
1553
1722
|
),
|
|
1554
|
-
code(
|
|
1555
|
-
`${invocation} ${words.group} ${words.build} ${quoteCommandArgument(result.data.path)}`,
|
|
1556
|
-
),
|
|
1723
|
+
code(buildStep(invocation, words, result.data.path)),
|
|
1557
1724
|
);
|
|
1558
1725
|
return NO_RESULT_SET;
|
|
1559
1726
|
},
|
|
@@ -1 +1 @@
|
|
|
1
|
-
[{"name":"init","term":"init [options]","description":"Initialize the design system in your project"},{"name":"component","term":"component [options] [names...]","description":"List components or print component docs"},{"name":"docs","term":"docs [options] [topic] [section]","description":"Print reference docs"},{"name":"blog","term":"blog [slug]","description":"Read the Astryx blog from the published feed"},{"name":"swizzle","term":"swizzle [options] [component]","description":"Copy component source for customization"},{"name":"gap-report","term":"gap-report [options] [component]","description":"Report a missing component or feature to the package that owns it"},{"name":"template","term":"template [options] [name] [path]","description":"List, show, or scaffold page and block templates"},{"name":"upgrade","term":"upgrade [options]","description":"Update your code after upgrading Astryx, and refresh ShadCN-copied components"},{"name":"theme","term":"theme","description":"Add, switch, build, and author themes"},{"name":"integration","term":"integration","description":"Author and verify an Astryx integration package"},{"name":"hook","term":"hook [options] [name]","description":"List hooks or print hook docs"},{"name":"discover","term":"discover [options] [query]","description":"Browse and search integrations: the ones you have and the ones you could add"},{"name":"search","term":"search [options] <query...>","description":"Search components, hooks, docs, templates, and themes in one ranked list"},{"name":"build","term":"build [options] [query]","description":"Build a page: the template to start from, or the workflow playbook (no query)"},{"name":"doctor","term":"doctor [options]","description":"Diagnose Astryx projects and integration packages"},{"name":"experimental","term":"experimental","description":"[experimental] Try features that may change in a patch release: icon sets, page rendering, checked theme editing"},{"name":"manifest","term":"manifest","description":"Print the full CLI capability manifest (use with --json)"},{"name":"help","term":"help","description":"Show all commands"}]
|
|
1
|
+
[{"name":"init","term":"init [options]","description":"Initialize the design system in your project"},{"name":"component","term":"component [options] [names...]","description":"List components or print component docs"},{"name":"docs","term":"docs [options] [topic] [section]","description":"Print reference docs"},{"name":"blog","term":"blog [slug]","description":"Read the Astryx blog from the published feed"},{"name":"swizzle","term":"swizzle [options] [component]","description":"Copy component source for customization"},{"name":"gap-report","term":"gap-report [options] [component]","description":"Report a missing component or feature to the package that owns it"},{"name":"template","term":"template [options] [name] [path]","description":"List, show, or scaffold page and block templates"},{"name":"upgrade","term":"upgrade [options]","description":"Update your code after upgrading Astryx, and refresh ShadCN-copied components"},{"name":"theme","term":"theme","description":"Add, switch, build, and author themes (to make or change one, use experimental theme editor)"},{"name":"integration","term":"integration","description":"Author and verify an Astryx integration package"},{"name":"hook","term":"hook [options] [name]","description":"List hooks or print hook docs"},{"name":"discover","term":"discover [options] [query]","description":"Browse and search integrations: the ones you have and the ones you could add"},{"name":"search","term":"search [options] <query...>","description":"Search components, hooks, docs, templates, and themes in one ranked list"},{"name":"build","term":"build [options] [query]","description":"Build a page: the template to start from, or the workflow playbook (no query)"},{"name":"doctor","term":"doctor [options]","description":"Diagnose Astryx projects and integration packages"},{"name":"experimental","term":"experimental","description":"[experimental] Try features that may change in a patch release: icon sets, page rendering, checked theme editing"},{"name":"manifest","term":"manifest","description":"Print the full CLI capability manifest (use with --json)"},{"name":"help","term":"help","description":"Show all commands"}]
|
|
@@ -236,7 +236,9 @@ function wrapLine(line, width, indent) {
|
|
|
236
236
|
* @returns {Block}
|
|
237
237
|
*/
|
|
238
238
|
export function section(heading, subtitle) {
|
|
239
|
-
return new Block(
|
|
239
|
+
return new Block(
|
|
240
|
+
toAscii(subtitle ? `${heading}\n${subtitle}` : String(heading)),
|
|
241
|
+
);
|
|
240
242
|
}
|
|
241
243
|
|
|
242
244
|
/**
|
|
@@ -311,9 +313,10 @@ export function records(items, options = {}) {
|
|
|
311
313
|
* @returns {Block}
|
|
312
314
|
*/
|
|
313
315
|
function inlineRecords(items, options) {
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
316
|
+
// Columns from every row: an optional field is on some rows only.
|
|
317
|
+
const [lead, ...rest] = (
|
|
318
|
+
options.fields ?? [...new Set(items.flatMap(o => Object.keys(o ?? {})))]
|
|
319
|
+
).filter(k => !options.omit?.includes(k));
|
|
317
320
|
if (lead == null) return new Block('');
|
|
318
321
|
/** @param {any} o @param {string} k */
|
|
319
322
|
const value = (o, k) => {
|
package/clients/cli/index.mjs
CHANGED
|
@@ -17,8 +17,9 @@ import {fileURLToPath} from 'node:url';
|
|
|
17
17
|
import * as fs from 'node:fs';
|
|
18
18
|
import * as path from 'node:path';
|
|
19
19
|
import {formatCliCommand, getCliInvocation, quoteCommandArgument} from '../../foundation/env/package-manager.mjs';
|
|
20
|
-
import {hasRecordedProject} from '../../foundation/env/cli-command.mjs';
|
|
20
|
+
import {hasRecordedProject, recordDeclaredCliCommands} from '../../foundation/env/cli-command.mjs';
|
|
21
21
|
import {isOutsideProject} from '../../foundation/env/project-scope.mjs';
|
|
22
|
+
import {mayHaveIntegrations} from '../../foundation/integrations/may-have-integrations.mjs';
|
|
22
23
|
import {findConfigPath} from '../../foundation/config/config-path.mjs';
|
|
23
24
|
import {API_VERSION, setJsonMode} from '../../foundation/response/json.mjs';
|
|
24
25
|
import {answeredBy, runChoice} from '../../foundation/release/run-context.mjs';
|
|
@@ -235,7 +236,10 @@ export async function loadProjectDebugHandler() {
|
|
|
235
236
|
* Commander parses, before any hook, so the preAction load cannot reach it.
|
|
236
237
|
* `Project.load` reads astryx.config and each integration's manifest; it does
|
|
237
238
|
* no discovery. Skipped when the debug preload already loaded the project, and
|
|
238
|
-
*
|
|
239
|
+
* where no integration can load (no config, no manifest of its own, no
|
|
240
|
+
* installed dependency that ships one): nothing there declares a command, so
|
|
241
|
+
* help prints the same without loading the project module. Called from the
|
|
242
|
+
* bin before Commander parses.
|
|
239
243
|
*
|
|
240
244
|
* @param {string[]} [argv] arguments after the binary.
|
|
241
245
|
* @returns {Promise<void>}
|
|
@@ -247,6 +251,11 @@ export async function loadProjectForHelp(argv = process.argv.slice(2)) {
|
|
|
247
251
|
try {
|
|
248
252
|
const cwd = process.cwd();
|
|
249
253
|
if (hasRecordedProject(cwd)) return;
|
|
254
|
+
if (!mayHaveIntegrations(cwd)) {
|
|
255
|
+
// What loading this project would record: no declared command.
|
|
256
|
+
recordDeclaredCliCommands(cwd, []);
|
|
257
|
+
return;
|
|
258
|
+
}
|
|
250
259
|
const {Project} = await import('../../foundation/config/project.mjs');
|
|
251
260
|
await Project.load(cwd);
|
|
252
261
|
} catch {
|
|
@@ -586,7 +595,7 @@ export async function createProgram({argv} = {}) {
|
|
|
586
595
|
|
|
587
596
|
program
|
|
588
597
|
.name('astryx')
|
|
589
|
-
.description('Design system CLI — components, themes, and tooling')
|
|
598
|
+
.description('Design system CLI — components, themes, and tooling\n\nMaking or changing a theme? Use the experimental theme editor: astryx experimental theme editor new <name> --like neutral, then editor set / editor how "<what you want>"; after each change look at it with astryx experimental theme editor show <name> --png (writes PNGs, changes nothing in the app): a theme change is not done until you have looked. No app yet: astryx experimental theme preview app <dir>.')
|
|
590
599
|
.version(pkg.version)
|
|
591
600
|
// These four change only the reads named in their text; every other
|
|
592
601
|
// command ignores them.
|
|
@@ -792,13 +801,20 @@ export async function createProgram({argv} = {}) {
|
|
|
792
801
|
* Load the project's integrations before any command runs, so every command
|
|
793
802
|
* it prints starts with the `cliCommand` they declare (the picker reads them
|
|
794
803
|
* synchronously; see foundation/env/cli-command.mjs). Skipped when this
|
|
795
|
-
* process already loaded the project, such as the bin's debug preload
|
|
796
|
-
*
|
|
804
|
+
* process already loaded the project, such as the bin's debug preload, and
|
|
805
|
+
* where no integration can load, so nothing declares a command (a command
|
|
806
|
+
* that needs the project still loads it). A project that cannot load is the
|
|
807
|
+
* command's to report, never this hook's.
|
|
797
808
|
*/
|
|
798
809
|
program.hook('preAction', async () => {
|
|
799
810
|
try {
|
|
800
811
|
const cwd = process.cwd();
|
|
801
812
|
if (hasRecordedProject(cwd)) return;
|
|
813
|
+
if (!mayHaveIntegrations(cwd)) {
|
|
814
|
+
// What loading this project would record: no declared command.
|
|
815
|
+
recordDeclaredCliCommands(cwd, []);
|
|
816
|
+
return;
|
|
817
|
+
}
|
|
802
818
|
const {Project} = await import('../../foundation/config/project.mjs');
|
|
803
819
|
await Project.load(cwd);
|
|
804
820
|
} catch {
|
|
@@ -933,6 +949,10 @@ export async function createProgram({argv} = {}) {
|
|
|
933
949
|
const stub = program
|
|
934
950
|
.command(cmd.name)
|
|
935
951
|
.description(`(failed to load: ${reason})`)
|
|
952
|
+
// Whatever options and words the run passed, it gets the load
|
|
953
|
+
// error, not a complaint about an option this stand-in never knew.
|
|
954
|
+
.allowUnknownOption()
|
|
955
|
+
.allowExcessArguments()
|
|
936
956
|
.action(() => {
|
|
937
957
|
// Nothing loaded, so nothing was answered — say that rather than
|
|
938
958
|
// leaving the run's result unreported.
|
|
@@ -54,6 +54,8 @@ import {
|
|
|
54
54
|
isJsonMode,
|
|
55
55
|
jsonError as _jsonError,
|
|
56
56
|
humanWarn,
|
|
57
|
+
outputCaptured,
|
|
58
|
+
writeAllSync,
|
|
57
59
|
} from '../../../foundation/response/json.mjs';
|
|
58
60
|
import {ERROR_CODES} from '../../../foundation/response/error-codes.mjs';
|
|
59
61
|
import {setOutcome} from '../../../foundation/debug/index.mjs';
|
|
@@ -129,18 +131,22 @@ export function cliError(message, options = {}) {
|
|
|
129
131
|
// Human mode: prefix "Error:" and print suggestions on subsequent lines.
|
|
130
132
|
// Use console.error directly — we always want stderr for errors regardless
|
|
131
133
|
// of the JSON-mode flag (we already handled JSON above).
|
|
132
|
-
|
|
134
|
+
const lines = [`Error: ${message}`];
|
|
133
135
|
if (suggestions?.length) {
|
|
134
|
-
|
|
136
|
+
lines.push('');
|
|
135
137
|
for (const s of suggestions) {
|
|
136
138
|
// A suggested command stays bare in JSON and is prefixed here.
|
|
137
139
|
const name = /^astryx(\s|$)/.test(s.name)
|
|
138
140
|
? formatCliCommand(s.name)
|
|
139
141
|
: s.name;
|
|
140
142
|
const tag = s.reason ? ` ${name} (${s.reason})` : ` ${name}`;
|
|
141
|
-
|
|
143
|
+
lines.push(tag);
|
|
142
144
|
}
|
|
143
145
|
}
|
|
146
|
+
// Written whole before a hard exit: output still queued for a slow pipe
|
|
147
|
+
// would be cut at 64 KiB. A soft exit lets the stream drain on its own.
|
|
148
|
+
if (hard && !outputCaptured(2)) writeAllSync(2, `${lines.join('\n')}\n`);
|
|
149
|
+
else for (const line of lines) console.error(line);
|
|
144
150
|
|
|
145
151
|
if (hard) {
|
|
146
152
|
process.exit(exitCode);
|