@astryxdesign/cli 0.7.14 → 0.7.15-canary.g79b95eb
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/api/doctor/_adapter.d.mts +1 -0
- package/api/doctor/_adapter.mjs +8 -0
- package/api/doctor/_authoring-audit.d.mts +42 -0
- package/api/doctor/_authoring-audit.mjs +106 -0
- package/api/doctor/doctor.d.mts +7 -0
- package/api/doctor/doctor.mjs +24 -39
- package/api/search/_adapter.mjs +124 -3
- package/api/search/_candidate-score.mjs +63 -9
- package/api/search/_entries.d.mts +10 -0
- package/api/search/_entries.mjs +68 -1
- package/api/search/_gather-templates.d.mts +11 -0
- package/api/search/_gather-templates.mjs +22 -2
- package/api/search/_words.mjs +26 -6
- package/api/swizzle/copy/copy.mjs +1 -1
- package/api/theme/_adapter.mjs +20 -9
- package/api/theme/build/build.d.mts +15 -1
- package/api/theme/build/build.mjs +132 -32
- package/api/theme/targets/targets.d.mts +8 -0
- package/api/theme/targets/targets.mjs +14 -1
- package/api/theme/themeBuild.doc.mjs +6 -3
- package/api/theme/themeEject.doc.mjs +3 -3
- package/api/theme/themeTargets.doc.mjs +1 -1
- package/api/theme-edit/_adapter.d.mts +46 -3
- package/api/theme-edit/_adapter.mjs +372 -109
- package/api/theme-edit/_check.d.mts +6 -3
- package/api/theme-edit/_check.mjs +665 -87
- package/api/theme-edit/_color.mjs +4 -2
- package/api/theme-edit/_compiler.d.mts +2 -1
- package/api/theme-edit/_compiler.mjs +27 -13
- package/api/theme-edit/_context.d.mts +2 -1
- package/api/theme-edit/_context.mjs +47 -8
- package/api/theme-edit/_edit.d.mts +9 -3
- package/api/theme-edit/_edit.mjs +484 -66
- package/api/theme-edit/_how-commands.d.mts +33 -7
- package/api/theme-edit/_how-commands.mjs +57 -45
- package/api/theme-edit/_how-question.d.mts +4 -0
- package/api/theme-edit/_how-question.mjs +1004 -223
- package/api/theme-edit/_how.mjs +96 -9
- package/api/theme-edit/_palette.d.mts +38 -13
- package/api/theme-edit/_palette.mjs +620 -223
- package/api/theme-edit/_parts.mjs +63 -7
- package/api/theme-edit/_png.d.mts +4 -4
- package/api/theme-edit/_png.mjs +4 -2
- package/api/theme-edit/_preview-app.d.mts +6 -0
- package/api/theme-edit/_preview-app.mjs +1194 -207
- package/api/theme-edit/_preview.mjs +2 -2
- package/api/theme-edit/_project.d.mts +12 -1
- package/api/theme-edit/_project.mjs +37 -6
- package/api/theme-edit/_settings.d.mts +104 -33
- package/api/theme-edit/_settings.mjs +818 -118
- package/api/theme-edit/_tables.d.mts +7 -0
- package/api/theme-edit/_tables.mjs +61 -0
- package/api/theme-edit/theme-edit.type.d.mts +11 -1
- package/api/theme-edit/theme-edit.type.mjs +4 -3
- package/api/theme-edit/themeEditHow.doc.mjs +6 -0
- 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 +1 -1
- package/api/theme-edit/themeEditPreviewRemove.doc.mjs +5 -1
- package/api/theme-edit/themeEditUndo.doc.mjs +1 -1
- package/api/upgrade/_adapter.d.mts +1 -0
- package/assets/codemods/run-codemod.mjs +61 -0
- package/assets/codemods/runner.mjs +5 -4
- package/assets/codemods/transforms/v0.0.14/rename-status-variants.mjs +3 -0
- package/assets/codemods/transforms/v0.1.8/rename-avatar-size-scale.mjs +5 -1
- package/assets/codemods/transforms/v0.6.4/migrate-native-picker-to-presentation.mjs +3 -0
- package/assets/codemods/transforms/v0.7.0/migrate-deprecated-theme-surface.mjs +4 -0
- package/assets/codemods/transforms/v0.7.0/rename-empty-search-results-text.mjs +17 -12
- package/assets/codemods/transforms/v0.7.2/migrate-list-edge-compensation-to-edge.mjs +3 -0
- package/assets/codemods/transforms/v0.7.5/migrate-codeblock-tokenizer-to-language.mjs +3 -0
- package/assets/codemods/transforms/v0.7.8/promote-tokenizer-presentation.mjs +3 -0
- package/assets/docs/tree/calendars.doc.mjs +1 -3
- package/assets/docs.generated.json +2 -1
- package/assets/self-audit.generated.json +1 -0
- package/assets/templates/blocks/components/Theme/useThemeNameHookUsage.doc.mjs +14 -0
- package/assets/templates/blocks/components/Theme/useThemeNameHookUsage.tsx +31 -0
- package/assets/templates/components.generated.json +1 -1
- package/clients/cli/bin/astryx.mjs +19 -15
- package/clients/cli/build-id.generated.json +1 -0
- package/clients/cli/commands/ensure-core-built.mjs +12 -5
- package/clients/cli/commands/experimental/theme.mjs +178 -78
- package/clients/cli/commands/experimental-theme-compile.doc.mjs +2 -2
- package/clients/cli/commands/experimental-theme-editor-how.doc.mjs +1 -1
- package/clients/cli/commands/experimental-theme-editor-set.doc.mjs +1 -2
- package/clients/cli/commands/experimental-theme-editor-show.doc.mjs +1 -1
- 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 +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/experimental-theme-preview-list.doc.mjs +1 -1
- package/clients/cli/commands/experimental-theme-preview-remove.doc.mjs +1 -1
- package/clients/cli/commands/experimental-theme-remove.doc.mjs +1 -1
- package/clients/cli/commands/experimental-theme-template.doc.mjs +4 -3
- package/clients/cli/commands/manifest.mjs +5 -2
- package/clients/cli/commands/theme.mjs +118 -22
- package/clients/cli/index.mjs +9 -3
- package/clients/cli/lib/manifest.mjs +37 -0
- package/clients/cli/lib/resolve-theme.mjs +2 -1
- package/clients/cli/manifest.generated.json +1 -0
- package/foundation/discovery/module-exports.mjs +16 -2
- package/foundation/discovery/stored-self-audit.d.mts +31 -0
- package/foundation/discovery/stored-self-audit.mjs +119 -0
- package/foundation/discovery/template-adapter.d.mts +48 -2
- package/foundation/discovery/template-adapter.mjs +51 -19
- package/foundation/discovery/template-needs.d.mts +6 -0
- package/foundation/discovery/template-needs.mjs +20 -1
- package/foundation/discovery/template-source-tree.d.mts +7 -0
- package/foundation/discovery/template-source-tree.mjs +15 -0
- package/foundation/discovery/theme-discovery.d.mts +2 -1
- package/foundation/discovery/theme-discovery.mjs +2 -8
- package/foundation/discovery/theme-module-extensions.d.mts +18 -0
- package/foundation/discovery/theme-module-extensions.mjs +30 -0
- package/foundation/doc-compiler/import.mjs +12 -11
- package/foundation/doc-compiler/stored-docs.d.mts +18 -12
- package/foundation/doc-compiler/stored-docs.mjs +52 -19
- package/foundation/env/private-dir.d.mts +17 -0
- package/foundation/env/private-dir.mjs +42 -0
- package/foundation/fs/gather-cache.d.mts +108 -0
- package/foundation/fs/gather-cache.mjs +716 -0
- package/foundation/fs/module-loader.mjs +7 -1
- package/foundation/fs/read-record.d.mts +31 -1
- package/foundation/fs/read-record.mjs +93 -6
- package/foundation/integrations/validate-contributions.mjs +24 -11
- package/foundation/release/cache.d.mts +11 -2
- package/foundation/release/cache.mjs +59 -10
- package/foundation/release/folder-lock.d.mts +21 -0
- package/foundation/release/folder-lock.mjs +171 -0
- package/package.json +8 -6
|
@@ -24,8 +24,12 @@
|
|
|
24
24
|
import {fileURLToPath, pathToFileURL} from 'node:url';
|
|
25
25
|
import {dirname, join} from 'node:path';
|
|
26
26
|
import * as nodeModule from 'node:module';
|
|
27
|
-
import {existsSync,
|
|
27
|
+
import {existsSync, mkdirSync, realpathSync} from 'node:fs';
|
|
28
28
|
import {tmpdir} from 'node:os';
|
|
29
|
+
import {
|
|
30
|
+
currentUid,
|
|
31
|
+
isPrivateDir,
|
|
32
|
+
} from '../../../foundation/env/private-dir.mjs';
|
|
29
33
|
|
|
30
34
|
// Node's compile cache keeps the compiled form of the CLI's modules between
|
|
31
35
|
// runs, so a run skips most of their compiling. It lives in a folder of the
|
|
@@ -33,24 +37,19 @@ import {tmpdir} from 'node:os';
|
|
|
33
37
|
// only once that folder exists, so a machine's first run just makes it and a
|
|
34
38
|
// one-off run never pays to write the cache; and only while it is a real
|
|
35
39
|
// folder the user owns that no one else can reach, since a shared folder
|
|
36
|
-
// could hold planted cache files.
|
|
40
|
+
// could hold planted cache files (foundation/env/private-dir.mjs, the check
|
|
41
|
+
// the kept search catalogs use too). Where the system has no user ids
|
|
37
42
|
// (Windows), ownership cannot be checked, so the cache stays off.
|
|
38
43
|
// NODE_DISABLE_COMPILE_CACHE turns it off. It is best effort: a cache Node
|
|
39
44
|
// cannot read or write is skipped, and nothing about it is printed.
|
|
40
45
|
try {
|
|
41
|
-
const uid =
|
|
46
|
+
const uid = currentUid();
|
|
42
47
|
if (!process.env.NODE_DISABLE_COMPILE_CACHE && uid != null) {
|
|
43
48
|
const cacheDir = join(tmpdir(), `node-compile-cache-${uid}`);
|
|
44
49
|
if (!existsSync(cacheDir)) {
|
|
45
50
|
mkdirSync(cacheDir, {mode: 0o700});
|
|
46
|
-
} else {
|
|
47
|
-
|
|
48
|
-
const own =
|
|
49
|
-
stat.isDirectory() &&
|
|
50
|
-
!stat.isSymbolicLink() &&
|
|
51
|
-
stat.uid === uid &&
|
|
52
|
-
(stat.mode & 0o077) === 0;
|
|
53
|
-
if (own) nodeModule.enableCompileCache?.(cacheDir);
|
|
51
|
+
} else if (isPrivateDir(cacheDir)) {
|
|
52
|
+
nodeModule.enableCompileCache?.(cacheDir);
|
|
54
53
|
}
|
|
55
54
|
}
|
|
56
55
|
} catch {
|
|
@@ -91,7 +90,12 @@ if (!isNodeVersionSupported(process.versions.node)) {
|
|
|
91
90
|
// does it load and dispatch the command. See clients/cli/run.mjs,
|
|
92
91
|
// foundation/release/handoff.mjs, and spec AST-081 FR2 and FR9.
|
|
93
92
|
const {runCli} = await importSrc('run.mjs');
|
|
94
|
-
await
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
93
|
+
const {recordRunFor} = await importSrc('../../foundation/fs/gather-cache.mjs');
|
|
94
|
+
// A search or build records what it reads, so a later run with the same
|
|
95
|
+
// inputs can reuse its gathered catalog (foundation/fs/gather-cache.mjs).
|
|
96
|
+
await recordRunFor(process.argv.slice(2), () =>
|
|
97
|
+
runCli({
|
|
98
|
+
cliRoot: join(binDir, '..', '..', '..'),
|
|
99
|
+
argv: process.argv.slice(2),
|
|
100
|
+
}),
|
|
101
|
+
);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"id":"6815bcd55c654ff0536b6aee644a609ba6f23661740618a60b0565559e437c95"}
|
|
@@ -231,11 +231,18 @@ export function coreBuildIsStale(entry, roots, generated = []) {
|
|
|
231
231
|
}
|
|
232
232
|
|
|
233
233
|
function buildCore() {
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
234
|
+
const args = ['-F', '@astryxdesign/core', 'build'];
|
|
235
|
+
/** @type {import('node:child_process').ExecFileSyncOptions} */
|
|
236
|
+
const options = {cwd: REPO_ROOT, stdio: 'pipe', timeout: BUILD_TIMEOUT_MS};
|
|
237
|
+
// On Windows, pnpm is a `pnpm.cmd` batch file. execFileSync cannot start a
|
|
238
|
+
// batch file without a shell: `pnpm` gives ENOENT and `pnpm.cmd` gives
|
|
239
|
+
// EINVAL. The arguments are literals, so cmd.exe gets them directly.
|
|
240
|
+
/** @type {[string, string[]]} */
|
|
241
|
+
const [file, fileArgs] =
|
|
242
|
+
process.platform === 'win32'
|
|
243
|
+
? ['cmd.exe', ['/d', '/s', '/c', 'pnpm', ...args]]
|
|
244
|
+
: ['pnpm', args];
|
|
245
|
+
execFileSync(file, fileArgs, options);
|
|
239
246
|
}
|
|
240
247
|
|
|
241
248
|
/**
|
|
@@ -18,6 +18,7 @@
|
|
|
18
18
|
|
|
19
19
|
import {getCliInvocation} from '../../../../foundation/env/package-manager.mjs';
|
|
20
20
|
import {jsonOut} from '../../../../foundation/response/json.mjs';
|
|
21
|
+
import {levenshteinDistance} from '../../../../foundation/text/levenshtein.mjs';
|
|
21
22
|
import {NO_RESULT_SET, resultSet} from '../../../../foundation/debug/index.mjs';
|
|
22
23
|
import {ERROR_CODES} from '../../../../foundation/response/error-codes.mjs';
|
|
23
24
|
import {
|
|
@@ -43,8 +44,10 @@ import {
|
|
|
43
44
|
themeEditUndo,
|
|
44
45
|
} from '../../../../api/theme-edit/theme-edit.mjs';
|
|
45
46
|
import {
|
|
46
|
-
|
|
47
|
-
|
|
47
|
+
builtInThemes,
|
|
48
|
+
editorCompileProblem,
|
|
49
|
+
editorThemeHold,
|
|
50
|
+
editorThemeRefusal,
|
|
48
51
|
} from '../../../../api/theme-edit/_adapter.mjs';
|
|
49
52
|
import {registerThemeSubcommands} from '../theme.mjs';
|
|
50
53
|
import {doc as groupDoc} from '../experimental-theme.doc.mjs';
|
|
@@ -76,6 +79,7 @@ import {doc as previewAppFn} from '../../../../api/theme-edit/themeEditPreviewAp
|
|
|
76
79
|
import {doc as previewListFn} from '../../../../api/theme-edit/themeEditPreviewList.doc.mjs';
|
|
77
80
|
import {doc as previewRemoveFn} from '../../../../api/theme-edit/themeEditPreviewRemove.doc.mjs';
|
|
78
81
|
import {doc as howFn} from '../../../../api/theme-edit/themeEditHow.doc.mjs';
|
|
82
|
+
import {quoteCommandArgument} from '../../../../foundation/env/package-manager.mjs';
|
|
79
83
|
|
|
80
84
|
const PREFIX = 'astryx experimental theme';
|
|
81
85
|
const EDITOR = `${PREFIX} editor`;
|
|
@@ -250,6 +254,18 @@ function notCheckedLine(result) {
|
|
|
250
254
|
return n ? [`[warn] saved, not checked (${n.code}): ${n.cause}`] : [];
|
|
251
255
|
}
|
|
252
256
|
|
|
257
|
+
/**
|
|
258
|
+
* Text with C0 control characters and DEL shown as escapes (\u001b), so
|
|
259
|
+
* text a person typed cannot move the cursor or recolor the terminal.
|
|
260
|
+
* @param {string} text
|
|
261
|
+
*/
|
|
262
|
+
const escapeControls = text =>
|
|
263
|
+
String(text).replace(
|
|
264
|
+
// eslint-disable-next-line no-control-regex
|
|
265
|
+
/[\u0000-\u0008\u000b-\u001f\u007f]/g,
|
|
266
|
+
c => `\\u${`000${c.charCodeAt(0).toString(16)}`.slice(-4)}`,
|
|
267
|
+
);
|
|
268
|
+
|
|
253
269
|
/**
|
|
254
270
|
* Run one API call: errors become the CLI error envelope, results go to
|
|
255
271
|
* JSON or to `render`.
|
|
@@ -269,8 +285,14 @@ async function run(program, call, render, answer) {
|
|
|
269
285
|
const err = /** @type {import('../../../../api/error.mjs').AstryxError} */ (
|
|
270
286
|
e
|
|
271
287
|
);
|
|
272
|
-
|
|
273
|
-
|
|
288
|
+
// Suggested commands start the way this project runs the CLI, in JSON
|
|
289
|
+
// as in text. Echoed user text never drives the terminal: control
|
|
290
|
+
// characters print as escapes.
|
|
291
|
+
return cliError(escapeControls(err.message), {
|
|
292
|
+
suggestions: err.suggestions?.map(x => ({
|
|
293
|
+
...x,
|
|
294
|
+
name: escapeControls(cmd(x.name)),
|
|
295
|
+
})),
|
|
274
296
|
code: err.code ?? ERROR_CODES.ERR_UNKNOWN,
|
|
275
297
|
});
|
|
276
298
|
}
|
|
@@ -281,7 +303,20 @@ async function run(program, call, render, answer) {
|
|
|
281
303
|
jsonOut(/** @type {any} */ (result));
|
|
282
304
|
return answered;
|
|
283
305
|
}
|
|
284
|
-
|
|
306
|
+
// --detail compact|brief (and --dense) print a change's status line
|
|
307
|
+
// alone; an answer (how, show, list) is the answer, and prints whole.
|
|
308
|
+
const o = program.opts();
|
|
309
|
+
const change = ['themeEdit.set', 'themeEdit.undo', 'themeEdit.new'].includes(
|
|
310
|
+
/** @type {any} */ (result)?.type,
|
|
311
|
+
);
|
|
312
|
+
const short =
|
|
313
|
+
change &&
|
|
314
|
+
(o.detail === 'compact' ||
|
|
315
|
+
o.detail === 'brief' ||
|
|
316
|
+
o.dense ||
|
|
317
|
+
o.lang === 'dense');
|
|
318
|
+
const lines = [...notCheckedLine(result), ...render(result)];
|
|
319
|
+
print(short ? lines.slice(0, notCheckedLine(result).length + 1) : lines);
|
|
285
320
|
return answered;
|
|
286
321
|
}
|
|
287
322
|
|
|
@@ -434,53 +469,52 @@ function lookupBlocks(d) {
|
|
|
434
469
|
/** @param {string[]} cmds @param {boolean} [sequence] */
|
|
435
470
|
const commandLines = (cmds, sequence) =>
|
|
436
471
|
sequence && cmds.length > 1
|
|
437
|
-
? [
|
|
438
|
-
: cmds
|
|
439
|
-
/** @param {Array<{command: string, why: string}>}
|
|
440
|
-
const refusedLines =
|
|
441
|
-
|
|
472
|
+
? [cmds.join(' && '), 'sequence: run as one line, in this order']
|
|
473
|
+
: cmds;
|
|
474
|
+
/** @param {Array<{command: string, why: string}>} refusedList */
|
|
475
|
+
const refusedLines = refusedList =>
|
|
476
|
+
refusedList.flatMap(r => [`x ${r.command}`, ` not run: ${r.why}`]);
|
|
442
477
|
/** @type {Array<string | import('../../formatters/index.mjs').Block>} */
|
|
443
478
|
const blocks = [...(hint ? [String(hint)] : []), ...project(rest)];
|
|
444
479
|
if (Array.isArray(results) && results.length)
|
|
445
480
|
blocks.push(
|
|
446
481
|
section('results:'),
|
|
447
|
-
|
|
448
|
-
results
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
])
|
|
454
|
-
.join('\n'),
|
|
482
|
+
list(
|
|
483
|
+
results.map((/** @type {any} */ r) => [
|
|
484
|
+
String(r.text),
|
|
485
|
+
...commandLines(r.commands ?? [], r.sequence),
|
|
486
|
+
...refusedLines(r.refused ?? []),
|
|
487
|
+
]),
|
|
455
488
|
),
|
|
456
489
|
);
|
|
457
490
|
if (Array.isArray(examples) && examples.length)
|
|
458
|
-
blocks.push(section('examples:'),
|
|
491
|
+
blocks.push(section('examples:'), list(commandLines(examples)));
|
|
459
492
|
if (Array.isArray(refused) && refused.length)
|
|
460
|
-
blocks.push(
|
|
493
|
+
blocks.push(
|
|
494
|
+
section('refused:'),
|
|
495
|
+
list(refused.map((/** @type {any} */ r) => refusedLines([r]))),
|
|
496
|
+
);
|
|
461
497
|
if (Array.isArray(points) && points.length)
|
|
462
498
|
blocks.push(
|
|
463
499
|
section('points:'),
|
|
464
|
-
|
|
465
|
-
points
|
|
466
|
-
.
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
500
|
+
records(
|
|
501
|
+
points.map((/** @type {any} */ x) => ({
|
|
502
|
+
at: x.at,
|
|
503
|
+
color: x.color,
|
|
504
|
+
alpha: x.alpha,
|
|
505
|
+
})),
|
|
470
506
|
),
|
|
471
507
|
);
|
|
472
508
|
if (Array.isArray(items) && items.length) {
|
|
473
509
|
if (items.some((/** @type {any} */ x) => Array.isArray(x.examples)))
|
|
474
510
|
blocks.push(
|
|
475
511
|
section('items:'),
|
|
476
|
-
|
|
477
|
-
items
|
|
478
|
-
.
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
])
|
|
483
|
-
.join('\n'),
|
|
512
|
+
list(
|
|
513
|
+
items.map((/** @type {any} */ x) => [
|
|
514
|
+
`${x.name} ${x.values}`,
|
|
515
|
+
`help: ${x.help}`,
|
|
516
|
+
...commandLines(x.examples),
|
|
517
|
+
]),
|
|
484
518
|
),
|
|
485
519
|
);
|
|
486
520
|
else blocks.push(...project({items}).slice(1));
|
|
@@ -561,9 +595,28 @@ function explained(c, doc, {tokens = false} = {}) {
|
|
|
561
595
|
return c;
|
|
562
596
|
}
|
|
563
597
|
|
|
598
|
+
/** Old and sibling names, and where each now is. */
|
|
599
|
+
const MOVED = /** @type {Record<string, Record<string, string>>} */ ({
|
|
600
|
+
theme: {
|
|
601
|
+
build: 'compile',
|
|
602
|
+
set: 'editor set',
|
|
603
|
+
undo: 'editor undo',
|
|
604
|
+
show: 'editor show',
|
|
605
|
+
new: 'editor new',
|
|
606
|
+
how: 'editor how',
|
|
607
|
+
explain: 'editor how',
|
|
608
|
+
reset: 'editor undo',
|
|
609
|
+
palette: 'editor set',
|
|
610
|
+
help: '--help',
|
|
611
|
+
},
|
|
612
|
+
editor: {explain: 'how', reset: 'undo', help: '--help', palette: 'set'},
|
|
613
|
+
preview: {help: '--help'},
|
|
614
|
+
});
|
|
615
|
+
|
|
564
616
|
/**
|
|
565
|
-
* A command group: bare, it prints its help
|
|
566
|
-
* unknown
|
|
617
|
+
* A command group: bare, it prints its help (in JSON too, as the root
|
|
618
|
+
* does); with an unknown word, the unknown-subcommand error, leading with
|
|
619
|
+
* where a moved name now is, then the nearest subcommands.
|
|
567
620
|
* @param {import('commander').Command} parent
|
|
568
621
|
* @param {import('@astryxdesign/cli/authoring').CommandDoc} doc
|
|
569
622
|
* @returns {import('commander').Command}
|
|
@@ -576,18 +629,55 @@ function defineGroup(parent, doc) {
|
|
|
576
629
|
/** @type {import('commander').Command} */ c,
|
|
577
630
|
) => {
|
|
578
631
|
const extras = c?.args ?? [];
|
|
632
|
+
const words = [];
|
|
633
|
+
for (let x = cmd; x && x.parent; x = x.parent) words.unshift(x.name());
|
|
634
|
+
const here = `${getCliInvocation()} ${words.join(' ')}`;
|
|
579
635
|
if (extras.length > 0) {
|
|
636
|
+
const word = String(extras[0]).toLowerCase();
|
|
637
|
+
const group = doc.name.split(' ').at(-1) ?? '';
|
|
638
|
+
const moved =
|
|
639
|
+
MOVED[group]?.[word] ??
|
|
640
|
+
// `preview <theme>`: the pages for a theme.
|
|
641
|
+
(group === 'preview' && /^[a-z][a-z0-9-]*$/.test(word)
|
|
642
|
+
? `add --theme ${word}`
|
|
643
|
+
: null);
|
|
644
|
+
const ranked = (cmd.commands ?? [])
|
|
645
|
+
.map(command => command.name())
|
|
646
|
+
.sort(
|
|
647
|
+
(a, b) =>
|
|
648
|
+
levenshteinDistance(word, a) - levenshteinDistance(word, b),
|
|
649
|
+
);
|
|
580
650
|
return cliError(
|
|
581
|
-
`unknown subcommand '${doc.name} ${String(extras[0])}'`,
|
|
651
|
+
`unknown subcommand '${doc.name} ${String(extras[0])}'${moved ? `; it is ${here} ${moved}` : ''}`,
|
|
582
652
|
{
|
|
583
|
-
suggestions:
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
653
|
+
suggestions: [
|
|
654
|
+
...(moved
|
|
655
|
+
? [{name: `${here} ${moved}`, reason: 'do this instead'}]
|
|
656
|
+
: []),
|
|
657
|
+
...ranked.map(name => ({
|
|
658
|
+
name: `${here} ${name}`,
|
|
659
|
+
reason: 'available subcommand',
|
|
660
|
+
})),
|
|
661
|
+
],
|
|
587
662
|
code: ERROR_CODES.ERR_UNKNOWN_SUBCOMMAND,
|
|
588
663
|
},
|
|
589
664
|
);
|
|
590
665
|
}
|
|
666
|
+
if (c?.optsWithGlobals?.().json) {
|
|
667
|
+
jsonOut(
|
|
668
|
+
/** @type {any} */ ({
|
|
669
|
+
type: 'help',
|
|
670
|
+
data: {
|
|
671
|
+
command: words.join(' '),
|
|
672
|
+
commands: (cmd.commands ?? []).map(command => ({
|
|
673
|
+
name: command.name(),
|
|
674
|
+
summary: command.summary() || command.description(),
|
|
675
|
+
})),
|
|
676
|
+
},
|
|
677
|
+
}),
|
|
678
|
+
);
|
|
679
|
+
return NO_RESULT_SET;
|
|
680
|
+
}
|
|
591
681
|
cmd.help();
|
|
592
682
|
return NO_RESULT_SET;
|
|
593
683
|
},
|
|
@@ -630,14 +720,26 @@ export function registerExperimentalTheme(group, program) {
|
|
|
630
720
|
if (extra.length)
|
|
631
721
|
throw new AstryxError(
|
|
632
722
|
`new takes one theme name; "${extra.join(' ')}" is extra. For a base theme, use --like. Nothing was changed.`,
|
|
633
|
-
|
|
723
|
+
// A built-in theme after the name is the base; other words
|
|
724
|
+
// were most likely part of the name.
|
|
725
|
+
builtInThemes().includes(extra[0])
|
|
634
726
|
? [
|
|
635
727
|
{
|
|
636
728
|
name: `${EDITOR} new ${name} --like ${extra[0]}`,
|
|
637
729
|
reason: 'do this instead',
|
|
638
730
|
},
|
|
639
731
|
]
|
|
640
|
-
: [
|
|
732
|
+
: [
|
|
733
|
+
{
|
|
734
|
+
name: `${EDITOR} new ${quoteCommandArgument(
|
|
735
|
+
[name, ...extra]
|
|
736
|
+
.join('-')
|
|
737
|
+
.toLowerCase()
|
|
738
|
+
.replace(/[^a-z0-9-]+/g, '-'),
|
|
739
|
+
)}`,
|
|
740
|
+
reason: 'do this instead',
|
|
741
|
+
},
|
|
742
|
+
],
|
|
641
743
|
ERROR_CODES.ERR_INVALID_ARGUMENT,
|
|
642
744
|
);
|
|
643
745
|
return themeEditNew(name, {
|
|
@@ -807,6 +909,25 @@ export function registerExperimentalTheme(group, program) {
|
|
|
807
909
|
}).allowExcessArguments(false),
|
|
808
910
|
previewAppDoc,
|
|
809
911
|
);
|
|
912
|
+
{
|
|
913
|
+
// A folder name that starts with "-" reads as an option: say how to
|
|
914
|
+
// pass it.
|
|
915
|
+
const app = /** @type {any} */ (
|
|
916
|
+
preview.commands.find(
|
|
917
|
+
(/** @type {any} */ x) =>
|
|
918
|
+
x.name() === previewAppDoc.name.split(' ').pop(),
|
|
919
|
+
)
|
|
920
|
+
);
|
|
921
|
+
const unknown = app?.unknownOption?.bind(app);
|
|
922
|
+
if (app && unknown)
|
|
923
|
+
app.unknownOption = (/** @type {string} */ flag) =>
|
|
924
|
+
/^-[^-]/.test(flag) && flag.length > 2
|
|
925
|
+
? app.error(
|
|
926
|
+
`error: unknown option '${flag}'. A folder name that starts with "-" goes after --: ${PREFIX} preview app -- ${flag}`,
|
|
927
|
+
{code: 'commander.unknownOption'},
|
|
928
|
+
)
|
|
929
|
+
: unknown(flag);
|
|
930
|
+
}
|
|
810
931
|
|
|
811
932
|
explained(
|
|
812
933
|
defineCommand(preview, previewListDoc, {
|
|
@@ -820,7 +941,7 @@ export function registerExperimentalTheme(group, program) {
|
|
|
820
941
|
? project(/** @type {any} */ (r.data))
|
|
821
942
|
: [
|
|
822
943
|
...project(/** @type {any} */ (r.data)),
|
|
823
|
-
`Tip: ${PREFIX} preview add${o.path == null ? '' : ` --path
|
|
944
|
+
`Tip: ${PREFIX} preview add${o.path == null ? '' : ` --path ${quoteCommandArgument(String(o.path))}`}`,
|
|
824
945
|
],
|
|
825
946
|
r =>
|
|
826
947
|
resultSet({
|
|
@@ -933,46 +1054,19 @@ export function registerExperimentalTheme(group, program) {
|
|
|
933
1054
|
},
|
|
934
1055
|
);
|
|
935
1056
|
}
|
|
936
|
-
//
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
`After a picture, give only how many colors to list, not "${rest.slice(1).join(' ')}".`,
|
|
941
|
-
{
|
|
942
|
-
suggestions: [
|
|
943
|
-
{name: `${HOW} ${rest[0]} 5`, reason: 'do this instead'},
|
|
944
|
-
],
|
|
945
|
-
code: ERROR_CODES.ERR_INVALID_ARGUMENT,
|
|
946
|
-
},
|
|
947
|
-
);
|
|
948
|
-
// A missing picture is the first thing to say, before a bad count.
|
|
949
|
-
if (
|
|
950
|
-
picture &&
|
|
951
|
-
rest.length === 2 &&
|
|
952
|
-
!/^[1-9]\d*$/.test(rest[1]) &&
|
|
953
|
-
fileExists(rest[0])
|
|
954
|
-
)
|
|
955
|
-
return cliError(
|
|
956
|
-
`The count after a picture must be a positive whole number, not "${rest[1]}".`,
|
|
957
|
-
{
|
|
958
|
-
suggestions: [
|
|
959
|
-
{name: `${HOW} ${rest[0]} 5`, reason: 'do this instead'},
|
|
960
|
-
],
|
|
961
|
-
code: ERROR_CODES.ERR_INVALID_ARGUMENT,
|
|
962
|
-
},
|
|
963
|
-
);
|
|
1057
|
+
// The API decides what the words are (a picture and a count, or a
|
|
1058
|
+
// question); a picture is told by its extension here only to keep
|
|
1059
|
+
// option words after it for the count.
|
|
1060
|
+
const picture = /\.png$/i.test(rest[0] ?? '');
|
|
964
1061
|
const stray = picture ? null : strayOption('how', rest.slice(1));
|
|
965
1062
|
if (stray) return stray;
|
|
966
|
-
const count =
|
|
967
|
-
picture && rest.length === 2 ? Number(rest[1]) : undefined;
|
|
968
|
-
const subject = picture ? rest[0] : rest.join(' ');
|
|
969
1063
|
return run(
|
|
970
1064
|
program,
|
|
971
1065
|
() =>
|
|
972
|
-
themeEditHow(
|
|
1066
|
+
themeEditHow(rest.join(' '), {
|
|
973
1067
|
cwd: process.cwd(),
|
|
974
1068
|
at: o.at ?? [],
|
|
975
|
-
|
|
1069
|
+
words: rest,
|
|
976
1070
|
theme: o.theme,
|
|
977
1071
|
}),
|
|
978
1072
|
r => lookupBlocks(/** @type {any} */ (r.data)),
|
|
@@ -1006,6 +1100,12 @@ export function registerExperimentalTheme(group, program) {
|
|
|
1006
1100
|
template: templateDoc,
|
|
1007
1101
|
targets: targetsDoc,
|
|
1008
1102
|
},
|
|
1009
|
-
{
|
|
1103
|
+
{
|
|
1104
|
+
group: 'experimental theme',
|
|
1105
|
+
build: 'compile',
|
|
1106
|
+
explain: editorThemeRefusal,
|
|
1107
|
+
preflight: editorCompileProblem,
|
|
1108
|
+
hold: editorThemeHold,
|
|
1109
|
+
},
|
|
1010
1110
|
);
|
|
1011
1111
|
}
|
|
@@ -39,7 +39,7 @@ export const doc = {
|
|
|
39
39
|
flag: '-o, --out <path>',
|
|
40
40
|
param: 'options.out',
|
|
41
41
|
description:
|
|
42
|
-
'Output CSS file path, relative or absolute; the .js and .d.ts are written beside it (default: <theme name>.css next to the source). A build writes only inside the working directory, the defaults beside the source too (ERR_PATH_TRAVERSAL); --check writes nothing, so it compares outputs anywhere and refuses only a relative path that escapes the working directory. Single theme only: refused with more than one file or with --family (ERR_THEME_INVALID)',
|
|
42
|
+
'Output CSS file path, relative or absolute; the .js and .d.ts are written beside it (default: <theme name>.css next to the source). A folder, or a path ending in /, writes <theme name>.css into it. A build never replaces the theme source (ERR_THEME_INVALID). At a path --out names, it replaces only its own earlier outputs: any other existing file fails with ERR_FILE_EXISTS and nothing is written. A build writes only inside the working directory, the defaults beside the source too (ERR_PATH_TRAVERSAL); --check writes nothing, so it compares outputs anywhere and refuses only a relative path that escapes the working directory. Single theme only: refused with more than one file or with --family (ERR_THEME_INVALID)',
|
|
43
43
|
},
|
|
44
44
|
{
|
|
45
45
|
flag: '--icons-specifier <specifier>',
|
|
@@ -89,7 +89,7 @@ export const doc = {
|
|
|
89
89
|
},
|
|
90
90
|
{
|
|
91
91
|
code: 1,
|
|
92
|
-
when: 'a build or validation error, or --check finds stale or missing outputs',
|
|
92
|
+
when: 'a build or validation error (an error envelope), or --check finds stale or missing outputs (the check result, with upToDate false and the stale files, is still printed: it is a result, not an error)',
|
|
93
93
|
},
|
|
94
94
|
],
|
|
95
95
|
related: ['experimental theme add', 'experimental theme list'],
|
|
@@ -94,7 +94,7 @@ export const doc = {
|
|
|
94
94
|
},
|
|
95
95
|
{
|
|
96
96
|
code: 1,
|
|
97
|
-
when: 'an unknown option, an unknown or empty theme, --theme given twice, an unknown --list kind, --list given twice, --at without a picture, a picture that is not a PNG or is damaged or too big, an --at point that is not whole pixel numbers or falls outside the picture, a count beside --at, or a count that is not a positive whole number, or a missing picture',
|
|
97
|
+
when: 'an unknown option, an unknown or empty theme, --theme given twice, an unknown --list kind, --list given twice, --at without a picture, a picture that is not a PNG or is damaged or too big, an --at point that is not whole pixel numbers or falls outside the picture, a count beside --at, or a count that is not a positive whole number, or a missing picture; or a folder outside a project with Core installed (ERR_PROJECT_REQUIRED)',
|
|
98
98
|
},
|
|
99
99
|
],
|
|
100
100
|
related: ['experimental theme editor', 'experimental theme targets'],
|
|
@@ -126,9 +126,8 @@ export const doc = {
|
|
|
126
126
|
},
|
|
127
127
|
{
|
|
128
128
|
code: 1,
|
|
129
|
-
when: 'an unknown option, a refused change (an unknown part, variant, state, token or thing; a value of the wrong type; --mode on something that has no mode; a token the part never reads for that; corners on a part that shows no edge), a theme that does not exist, or a build failure; nothing is written',
|
|
129
|
+
when: 'an unknown option, a refused change (an unknown part, variant, state, token or thing; a value of the wrong type; --mode on something that has no mode; a token the part never reads for that; corners on a part that shows no edge), a theme that does not exist, or a build failure, or a folder outside a project with Core installed (ERR_PROJECT_REQUIRED); nothing is written',
|
|
130
130
|
},
|
|
131
131
|
],
|
|
132
132
|
related: ['experimental theme editor', 'experimental theme compile'],
|
|
133
|
-
replaces: ['theme palette generate'],
|
|
134
133
|
};
|
|
@@ -59,7 +59,7 @@ export const doc = {
|
|
|
59
59
|
},
|
|
60
60
|
{
|
|
61
61
|
code: 1,
|
|
62
|
-
when: 'the theme does not exist, an unknown --section, or a page that does not render',
|
|
62
|
+
when: 'the theme does not exist, an unknown --section, or a page that does not render; or a folder outside a project with Core installed (ERR_PROJECT_REQUIRED)',
|
|
63
63
|
},
|
|
64
64
|
],
|
|
65
65
|
related: ['experimental theme editor', 'experimental theme compile'],
|
|
@@ -12,7 +12,7 @@ export const doc = {
|
|
|
12
12
|
summary:
|
|
13
13
|
'Step back one change, or remove one setting; the result says what applies instead',
|
|
14
14
|
description:
|
|
15
|
-
"With only the theme, it steps back one change: the settings
|
|
15
|
+
"With only the theme, it steps back one change: the settings, the generated settings module and the build go back to how they were before the last change (your <theme>.theme.ts is not touched), and the preview is rewritten; the result names what was undone and how many earlier steps are left. When the settings file is damaged (not valid JSON), the step back restores the settings from before the last change without reading it. With a thing, it removes that one setting wherever it is in the settings, and the result says what applies now (`now`): the whole-theme setting for a part setting removed, or the base theme's value; the theme is rebuilt and previewed. Name the setting the way it was set: the same thing and the same --on, --when, --state, --mode and --only (`show` lists every setting that way). For the headings dial, name which half: weight or tracking (default weight). Removing a color (accent, neutral, success, warning, danger, info) stops generating it, and the tokens it fed go back to the base theme; with no color left, the generated color files the editor wrote are deleted; a palette.config.json you made, or one that holds a color of your own, stays. Removing vibrancy makes the colors again at the default, 50; removing the last color removes vibrancy too, as it needs a color. A setting the theme does not have is refused and the error lists the settings it has for that thing. `undo <theme> base` and `undo <theme> mode` go back to the base and mode the theme was made with; when they never changed, that is refused. The history keeps the last 80 steps (in <theme>.history.json); older steps are dropped. Experimental: it may change or be removed in a patch release.",
|
|
16
16
|
fn: 'themeEditUndo',
|
|
17
17
|
args: [
|
|
18
18
|
{
|
|
@@ -97,7 +97,7 @@ export const doc = {
|
|
|
97
97
|
},
|
|
98
98
|
{
|
|
99
99
|
code: 1,
|
|
100
|
-
when: 'an unknown option, there is no earlier change, the theme does not set the thing, or the theme does not exist',
|
|
100
|
+
when: 'an unknown option, there is no earlier change, the theme does not set the thing, or the theme does not exist; or a folder outside a project with Core installed (ERR_PROJECT_REQUIRED)',
|
|
101
101
|
},
|
|
102
102
|
],
|
|
103
103
|
related: ['experimental theme editor', 'experimental theme editor show'],
|
|
@@ -15,7 +15,7 @@ export const doc = {
|
|
|
15
15
|
summary:
|
|
16
16
|
'Make and change a theme one checked change at a time (dials, tokens, part styles), with previews',
|
|
17
17
|
description:
|
|
18
|
-
"A type-safe compiler for themes. A theme lives in themes/<theme>/: <theme>.settings.json holds the checked settings and is owned by this command; <theme>.settings.ts is generated from it on every change; <theme>.theme.ts extends it, is written once and is yours to edit; <theme>.css and <theme>.js are built from it by the same build as `astryx theme build` (`experimental theme compile`). Every change is CHECKED against what the installed Core's components really read (derived from Core itself, version for version, and cached under node_modules/.cache/) and against the token's type; a change that cannot take effect is refused, nothing is written, and the error leads with the command that works. The thing you set is a dial (a big move with named rungs: corners, spacing, font, headings, text-size, base, mode; or a color: accent, neutral, success, warning, danger, info, each generating its light and dark shades from one color for the color tokens, and vibrancy, how saturated they are), a design token by name, or a CSS property on a part. Where it applies: --on <part|group>, --when <prop>:<value>, --state <state>, --mode light|dark, --only. Every accepted change rebuilds and writes preview.html (the sample app page); `show` adds the theme-building page with every component. PNG pictures only with --png. `how` answers everything else: what a part, group, setting or aspect does, how the colors are made, plain-words questions (with exact commands), a picture's colors, and lists of what you can set. Experimental: it may change or be removed in a patch release.",
|
|
18
|
+
"A type-safe compiler for themes. A theme lives in themes/<theme>/: <theme>.settings.json holds the checked settings and is owned by this command; <theme>.settings.ts is generated from it on every change; <theme>.theme.ts extends it, is written once and is yours to edit; <theme>.css and <theme>.js are built from it by the same build as `astryx theme build` (`experimental theme compile`). Every change is CHECKED against what the installed Core's components really read (derived from Core itself, version for version, and cached under node_modules/.cache/) and against the token's type; a change that cannot take effect is refused, nothing is written, and the error leads with the command that works. The thing you set is a dial (a big move with named rungs: corners, spacing, font, headings, text-size, base, mode; or a color: accent, neutral, success, warning, danger, info, each generating its light and dark shades from one color for the color tokens, and vibrancy, how saturated they are), a design token by name, or a CSS property on a part. Where it applies: --on <part|group>, --when <prop>:<value>, --state <state>, --mode light|dark, --only. Every accepted change rebuilds and writes preview.html (the sample app page); `show` adds the theme-building page with every component. PNG pictures only with --png. Commands on one theme run one after the other, through a lock in node_modules/.cache/astryx-theme/ of the project; when node_modules cannot be written (a read-only install), changes are refused and `show` still reads the last build. `how` answers everything else: what a part, group, setting or aspect does, how the colors are made, plain-words questions (with exact commands), a picture's colors, and lists of what you can set. Experimental: it may change or be removed in a patch release.",
|
|
19
19
|
subcommands: ['new', 'set', 'undo', 'show', 'how'],
|
|
20
20
|
examples: [
|
|
21
21
|
{
|
|
@@ -14,7 +14,7 @@ export const doc = {
|
|
|
14
14
|
stability: 'experimental',
|
|
15
15
|
summary: 'Fork a theme as editable local source',
|
|
16
16
|
description:
|
|
17
|
-
"Copies a bundled or installed package theme's complete source into the local themes root, including a local descriptor. Writes are atomic. Existing files require --overwrite. Use --package when package themes share a slug.",
|
|
17
|
+
"Copies a bundled or installed package theme's complete source into the local themes root, including a local descriptor. Writes are atomic. Existing files require --overwrite. Eject never writes into a folder that holds another theme or a theme the theme editor made, even with --overwrite. When the fork imports packages the app lacks, the result names them with an install command. Use --package when package themes share a slug.",
|
|
18
18
|
fn: 'themeEject',
|
|
19
19
|
args: [
|
|
20
20
|
{
|
|
@@ -33,7 +33,7 @@ export const doc = {
|
|
|
33
33
|
flag: '-f, --overwrite',
|
|
34
34
|
param: 'options.overwrite',
|
|
35
35
|
description:
|
|
36
|
-
'Replace existing files. Without it, an existing file fails with ERR_FILE_EXISTS and nothing is written',
|
|
36
|
+
'Replace the existing files of an earlier fork of the same theme. Without it, an existing file fails with ERR_FILE_EXISTS and nothing is written',
|
|
37
37
|
},
|
|
38
38
|
{
|
|
39
39
|
flag: '--package <package>',
|
|
@@ -59,7 +59,7 @@ export const doc = {
|
|
|
59
59
|
},
|
|
60
60
|
{
|
|
61
61
|
code: 1,
|
|
62
|
-
when: 'the theme is unknown or ambiguous, a path escapes, a source file is missing,
|
|
62
|
+
when: 'the theme is unknown or ambiguous, a path escapes, a source file is missing, a destination exists, or the folder holds another theme',
|
|
63
63
|
},
|
|
64
64
|
],
|
|
65
65
|
related: [
|
|
@@ -12,7 +12,7 @@ export const doc = {
|
|
|
12
12
|
summary:
|
|
13
13
|
'Add pages to the theme preview in the app: the default pages, the best template pages for a description, or one template',
|
|
14
14
|
description:
|
|
15
|
-
"Writes the theme preview into the app: one route, a normal page of the app that keeps its layout, global CSS and providers, in an app shell with a side nav item per preview page and a top bar with the theme name and, when it wears a theme made by `editor`, a light, dark and system switch. A description (\"a sales dashboard\") asks the same page ranking `build` uses for the template pages that fit it best (--top of them, default 1), and adds each as a page, saying in `matched` what it picked and why (the words of the description it covers). App frames (the Shell templates) are left out, since the preview is an app shell already. When no page is exactly the one described, the closest is added and `matched` says the rest of the description is not on it; only a description no page relates to is refused, writing nothing and naming the closest pages to add with --template, with the other options repeated. A page the app cannot show (a missing package, or StyleX without a compiler) is skipped and the next match is taken (from the ranking, then the template search), and the result says so. A page's nav label is its template's display name, however it was added; --template names one page template instead; with neither, it adds the default pages: Overview (the theme at a glance, built to show what themes most often break: long and short text, every text level on every surface, every button variant and size with disabled and loading, inputs in their states, selected navigation, status colors, a table, open layers), Components (every component grouped, each with the command that changes it most) and, when the theme sets a color, Colors (each color's shades in light and dark, with the shade number, the hex and the tokens that use each; it reads the theme's generated colors, so it changes with every `editor set`). The route goes in theme-preview/ in the app's routes folder (app/ or src/app/), or in --path; the first add records the pages and the files it wrote in theme-preview.json beside the route, so later calls find it. With no routes folder and no --path, it refuses and names both ways on: --path, or `experimental theme preview app <dir>`, which makes a new starter app with the preview in it. The route fills the whole window with the theme, shell and edges included. Every check (the theme, the template, the ranking and every file it writes) runs before the first write, so a refusal changes nothing. A template page that imports a package the app lacks, or that uses StyleX in an app with no StyleX compiler, is not added: the result names it and the command that installs what it needs. A file the preview did not write is never replaced. The pages wear --theme (default: the only theme under themes/; with none or several, the app's own theme). The pages go in _pages/ beside the route, a folder Next never serves as a route; a preview an older release wrote into pages/ is moved there. theme-preview.json records a hash of each file the preview writes: a file changed by hand since is never replaced (the refusal names it), and a page file that already holds exactly the planned text is taken over. The files are staged and renamed into place together; when a write fails, every file is put back as it was. A damaged theme-preview.json is refused with `ERR_THEME_INVALID`, naming the file. The folder is refused when it is a file, in themes/ or node_modules/, in a Pages Router folder (pages/ or src/pages/), in a folder Next does not route (_private, @slot, [param]), or written with Windows separators, a leading ~ or white space at either end. With no --path and no preview in the default place, a preview recorded for a theme is used; with several, the refusal names each. A theme the preview wore that is gone is replaced by the app's own theme, with a note; a changed theme writes the default pages again. A template page whose package the app's package.json names but nobody installed is skipped like a missing one. Only the first 40 different words of a long description go to the ranking, with a note. The description may be several words without quotes. The project root, src/ and the routes folder itself are refused too: they hold the app. An older preview found there is named, with the remove that clears it. A recorded page whose file is gone is written again (a default page, or the template its id names), or else left out of the nav, with a note. A formatter run (white space, quotes, semicolons, commas) does not count as a change by hand. Refusals never suggest deleting files: they say what to move or rename. Preview commands in one project run one after another. Experimental: it may change or be removed in a patch release.",
|
|
15
|
+
"Writes the theme preview into the app: one route, a normal page of the app that keeps its layout, global CSS and providers, in an app shell with a side nav item per preview page and a top bar with the theme name and, when it wears a theme made by `editor`, a light, dark and system switch. A description (\"a sales dashboard\") asks the same page ranking `build` uses for the template pages that fit it best (--top of them, default 1), and adds each as a page, saying in `matched` what it picked and why (the words of the description it covers). App frames (the Shell templates) are left out, since the preview is an app shell already. When no page is exactly the one described, the closest is added and `matched` says the rest of the description is not on it; only a description no page relates to is refused, writing nothing and naming the closest pages to add with --template, with the other options repeated. A page the app cannot show (a missing package, or StyleX without a compiler) is skipped and the next match is taken (from the ranking, then the template search), and the result says so. A page's nav label is its template's display name, however it was added; --template names one page template instead; with neither, it adds the default pages: Overview (the theme at a glance, built to show what themes most often break: long and short text, every text level on every surface, every button variant and size with disabled and loading, inputs in their states, selected navigation, status colors, a table, open layers), Components (every component grouped, each with the command that changes it most) and, when the theme sets a color, Colors (each color's shades in light and dark, with the shade number, the hex and the tokens that use each; it reads the theme's generated colors, so it changes with every `editor set`). The route goes in theme-preview/ in the app's routes folder (app/ or src/app/), or in --path; the first add records the pages and the files it wrote in theme-preview.json beside the route, so later calls find it. With no routes folder and no --path, it refuses and names both ways on: --path, or `experimental theme preview app <dir>`, which makes a new starter app with the preview in it. The route fills the whole window with the theme, shell and edges included. Every check (the theme, the template, the ranking and every file it writes) runs before the first write, so a refusal changes nothing. A template page that imports a package the app lacks, or that uses StyleX in an app with no StyleX compiler, is not added: the result names it and the command that installs what it needs. A file the preview did not write is never replaced. The pages wear --theme (default: the only theme under themes/; with none or several, the app's own theme). The pages go in _pages/ beside the route, a folder Next never serves as a route; a preview an older release wrote into pages/ is moved there. theme-preview.json records a hash of each file the preview writes: a file changed by hand since is never replaced (the refusal names it), and a page file that already holds exactly the planned text is taken over. The files are staged and renamed into place together; when a write fails, every file is put back as it was. A damaged theme-preview.json is refused with `ERR_THEME_INVALID`, naming the file. The folder is refused when it is a file, in themes/ or node_modules/, in a Pages Router folder (pages/ or src/pages/), in a folder Next does not route (_private, @slot, [param]), or written with Windows separators, a leading ~ or white space at either end. With no --path and no preview in the default place, a preview recorded for a theme is used; with several, the refusal names each. A theme the preview wore that is gone is replaced by the app's own theme, with a note; a changed theme writes the default pages again. A template page whose package the app's package.json names but nobody installed is skipped like a missing one. Only the first 40 different words of a long description go to the ranking, with a note. The description may be several words without quotes. The project root, src/ and the routes folder itself are refused too: they hold the app. An older preview found there is named, with the remove that clears it. A recorded page whose file is gone is written again (a default page, or the template its id names), or else left out of the nav, with a note. A formatter run (white space, quotes, semicolons, commas) does not count as a change by hand. Refusals never suggest deleting files: they say what to move or rename. Preview commands in one project run one after another. The folder is also refused when it holds a package.json, when another page of the app already serves its URL (a route group or the Pages Router), when next.config sets pageExtensions without tsx, when it is in src/app/ while app/ is what Next serves, and when no root layout is above it (an app with its root layout in [locale]/ gets its preview there, opened at /<locale>/theme-preview; an app with a root layout in each route group takes the preview under any of them). A template's needs come from its real import statements, never words in comments or strings; a package the app does not name gets the command that adds it. A theme with no build is built only after every check passed, holding that theme's lock, with a note. An edit inside a string counts as a change by hand; a formatter run does not. Experimental: it may change or be removed in a patch release.",
|
|
16
16
|
fn: 'themeEditPreviewAdd',
|
|
17
17
|
args: [
|
|
18
18
|
{
|