@astryxdesign/cli 0.7.14-canary.gfb823d9 → 0.7.14
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +197 -0
- package/api/component/_adapter.d.mts +15 -0
- package/api/component/_adapter.mjs +76 -0
- package/api/component/component.mjs +8 -1
- package/api/search/_named-keywords.d.mts +31 -0
- package/api/search/_named-keywords.mjs +177 -0
- package/api/search/search-index.mjs +8 -1
- package/api/search/search.d.mts +6 -1
- package/api/search/search.mjs +49 -8
- package/api/theme/_adapter.d.mts +33 -0
- package/api/theme/_adapter.mjs +352 -16
- package/api/theme/build/build.mjs +261 -10
- package/api/theme/eject/eject.mjs +13 -1
- package/api/theme/list/list.mjs +11 -2
- package/api/theme/palette/generate/color.d.mts +2 -0
- package/api/theme/palette/generate/color.mjs +1 -1
- package/api/theme/template/template.mjs +139 -6
- package/api/theme/theme.type.d.mts +15 -1
- package/api/theme/theme.type.mjs +9 -3
- package/api/theme/themeAdd.doc.mjs +1 -1
- package/api/theme/themeBuild.doc.mjs +10 -2
- package/api/theme/themeEject.doc.mjs +2 -2
- package/api/theme/themeListAvailable.doc.mjs +1 -1
- package/api/theme/themeRemove.doc.mjs +1 -1
- package/api/theme/themeTemplate.doc.mjs +8 -0
- package/api/theme/themeUse.doc.mjs +1 -1
- package/api/theme-edit/_adapter.d.mts +36 -2
- package/api/theme-edit/_adapter.mjs +340 -12
- package/api/theme-edit/_check.d.mts +28 -25
- package/api/theme-edit/_check.mjs +876 -308
- package/api/theme-edit/_color.d.mts +53 -4
- package/api/theme-edit/_color.mjs +406 -79
- package/api/theme-edit/_compiler.d.mts +14 -6
- package/api/theme-edit/_compiler.mjs +89 -59
- package/api/theme-edit/_context.d.mts +28 -8
- package/api/theme-edit/_context.mjs +142 -19
- package/api/theme-edit/_edit.d.mts +3 -1
- package/api/theme-edit/_edit.mjs +746 -76
- package/api/theme-edit/_how-commands.d.mts +91 -0
- package/api/theme-edit/_how-commands.mjs +269 -0
- package/api/theme-edit/_how-question.d.mts +57 -0
- package/api/theme-edit/_how-question.mjs +2574 -0
- package/api/theme-edit/_how.d.mts +27 -8
- package/api/theme-edit/_how.mjs +776 -175
- package/api/theme-edit/_overview.d.mts +9 -0
- package/api/theme-edit/_overview.mjs +296 -0
- package/api/theme-edit/_palette.d.mts +155 -15
- package/api/theme-edit/_palette.mjs +1446 -262
- package/api/theme-edit/_parts.mjs +61 -5
- package/api/theme-edit/_png.d.mts +18 -6
- package/api/theme-edit/_png.mjs +135 -25
- package/api/theme-edit/_preview-app.d.mts +32 -11
- package/api/theme-edit/_preview-app.mjs +1976 -285
- package/api/theme-edit/_preview.d.mts +39 -8
- package/api/theme-edit/_preview.mjs +367 -41
- package/api/theme-edit/_settings.d.mts +147 -11
- package/api/theme-edit/_settings.mjs +908 -99
- package/api/theme-edit/_tables.d.mts +4 -16
- package/api/theme-edit/_tables.mjs +51 -117
- package/api/theme-edit/theme-edit.type.d.mts +102 -66
- package/api/theme-edit/theme-edit.type.mjs +58 -40
- package/api/theme-edit/themeEditHow.doc.mjs +17 -6
- package/api/theme-edit/themeEditNew.doc.mjs +21 -5
- package/api/theme-edit/themeEditPreviewAdd.doc.mjs +18 -5
- package/api/theme-edit/themeEditPreviewApp.doc.mjs +12 -9
- package/api/theme-edit/themeEditPreviewList.doc.mjs +11 -2
- package/api/theme-edit/themeEditPreviewRemove.doc.mjs +29 -3
- package/api/theme-edit/themeEditSet.doc.mjs +14 -8
- package/api/theme-edit/themeEditShow.doc.mjs +10 -5
- package/api/theme-edit/themeEditUndo.doc.mjs +9 -4
- package/assets/discover/official-packages.json +4 -0
- package/assets/docs/tree/icon-sets.doc.mjs +3 -3
- package/assets/docs.generated.json +1 -0
- package/assets/icons/definitions/bookmarkAdd.doc.mjs +9 -0
- package/assets/icons/definitions/documentSearch.doc.mjs +9 -0
- package/assets/icons/definitions/keyboard.doc.mjs +9 -0
- package/assets/icons/definitions/paintBrush.doc.mjs +9 -0
- package/assets/icons/definitions/wallet.doc.mjs +9 -0
- package/assets/preview-app/gitignore +3 -0
- package/assets/templates/blocks/components/ButtonGroup/ButtonGroupShowcase.doc.mjs +1 -1
- package/assets/templates/blocks/components/Lightbox/LightboxGallery.tsx +1 -1
- package/assets/templates/components.generated.json +1 -0
- package/assets/templates/pages/gallery-hero/page.tsx +8 -2
- package/assets/templates/pages/settings-dialog/template.doc.mjs +3 -3
- package/assets/templates/pages/side-gallery/page.tsx +1 -1
- package/assets/templates/pages/table-filter/template.doc.mjs +2 -2
- package/assets/templates/pages/theme-showcase/template.doc.mjs +1 -1
- package/clients/cli/bin/astryx.mjs +37 -5
- package/clients/cli/commands/experimental/theme.mjs +422 -57
- package/clients/cli/commands/experimental-theme-editor-how.doc.mjs +22 -9
- package/clients/cli/commands/experimental-theme-editor-new.doc.mjs +103 -4
- package/clients/cli/commands/experimental-theme-editor-set.doc.mjs +13 -8
- package/clients/cli/commands/experimental-theme-editor-show.doc.mjs +5 -5
- package/clients/cli/commands/experimental-theme-editor-undo.doc.mjs +5 -5
- package/clients/cli/commands/experimental-theme-editor.doc.mjs +1 -1
- package/clients/cli/commands/experimental-theme-preview-add.doc.mjs +3 -2
- package/clients/cli/commands/experimental-theme-preview-app.doc.mjs +2 -8
- package/clients/cli/commands/experimental-theme-preview-list.doc.mjs +2 -2
- package/clients/cli/commands/experimental-theme-preview-remove.doc.mjs +2 -2
- package/clients/cli/commands/experimental-theme-targets.doc.mjs +1 -1
- package/clients/cli/commands/experimental-theme.doc.mjs +3 -4
- package/clients/cli/commands/theme-build.doc.mjs +1 -1
- package/clients/cli/commands/theme-eject.doc.mjs +3 -3
- package/clients/cli/commands/theme-remove.doc.mjs +2 -2
- package/clients/cli/commands/theme-template.doc.mjs +11 -4
- package/clients/cli/commands/theme.mjs +145 -46
- package/clients/cli/commands.generated.json +1 -0
- package/clients/cli/index.mjs +96 -5
- package/clients/cli/lib/json-shim.mjs +29 -1
- package/foundation/config/project.d.mts +16 -2
- package/foundation/config/project.mjs +40 -6
- package/foundation/config/theme-state.d.mts +9 -0
- package/foundation/config/theme-state.mjs +20 -1
- package/foundation/discovery/template-adapter.d.mts +12 -1
- package/foundation/discovery/template-adapter.mjs +29 -4
- package/foundation/discovery/template-icons.d.mts +13 -0
- package/foundation/discovery/template-icons.mjs +76 -0
- package/foundation/discovery/template-needs.d.mts +7 -0
- package/foundation/discovery/template-needs.mjs +117 -8
- package/foundation/discovery/template-source-tree.d.mts +5 -1
- package/foundation/discovery/template-source-tree.mjs +6 -4
- package/foundation/discovery/theme-discovery.d.mts +14 -3
- package/foundation/discovery/theme-discovery.mjs +45 -12
- package/foundation/doc-compiler/import.mjs +68 -3
- package/foundation/doc-compiler/stored-docs.d.mts +27 -0
- package/foundation/doc-compiler/stored-docs.mjs +65 -0
- package/foundation/fs/fs-error.d.mts +17 -0
- package/foundation/fs/fs-error.mjs +34 -0
- package/foundation/response/error-codes.d.mts +3 -1
- package/foundation/response/error-codes.doc.mjs +13 -1
- package/foundation/response/error-codes.mjs +11 -1
- package/foundation/response/response-types.doc.mjs +6 -6
- package/package.json +6 -7
- package/clients/cli/commands/experimental-theme-palette-generate.doc.mjs +0 -73
- package/clients/cli/commands/experimental-theme-palette.doc.mjs +0 -37
|
@@ -1345,15 +1345,17 @@ function copiedThemeFiles(files, entry, descriptor, exportName, bundled) {
|
|
|
1345
1345
|
* Discover and validate one theme root.
|
|
1346
1346
|
* @param {string} themeRoot absolute root containing one directory per slug
|
|
1347
1347
|
* @param {string} owner package that owns the root
|
|
1348
|
-
* @param {{bundled?: boolean, allowUnmigrated?: boolean}} [options] a bundled root is the CLI's own; its
|
|
1348
|
+
* @param {{bundled?: boolean, allowUnmigrated?: boolean, skip?: Set<string>, progress?: {slug?: string}}} [options] a bundled root is the CLI's own; its
|
|
1349
1349
|
* sources are checked by the CLI's tests rather than on every read. A local
|
|
1350
1350
|
* root may skip released source copies until `astryx upgrade` adds descriptors.
|
|
1351
|
+
* `skip` names theme folders to leave out; `progress.slug` is set to the
|
|
1352
|
+
* folder being read, so a caller can tell which folder an error is about.
|
|
1351
1353
|
* @returns {DiscoveredTheme[]}
|
|
1352
1354
|
*/
|
|
1353
1355
|
export function discoverThemeDirectory(
|
|
1354
1356
|
themeRoot,
|
|
1355
1357
|
owner,
|
|
1356
|
-
{bundled = false, allowUnmigrated = false} = {},
|
|
1358
|
+
{bundled = false, allowUnmigrated = false, skip, progress} = {},
|
|
1357
1359
|
) {
|
|
1358
1360
|
if (!fs.existsSync(themeRoot) || !fs.statSync(themeRoot).isDirectory()) {
|
|
1359
1361
|
throw new Error(
|
|
@@ -1392,6 +1394,8 @@ export function discoverThemeDirectory(
|
|
|
1392
1394
|
|
|
1393
1395
|
for (const directory of directories) {
|
|
1394
1396
|
const slug = directory.name;
|
|
1397
|
+
if (skip?.has(slug)) continue;
|
|
1398
|
+
if (progress) progress.slug = slug;
|
|
1395
1399
|
const listing = listThemeFolder(path.join(themeRoot, slug));
|
|
1396
1400
|
const evidence = themeEvidence(listing);
|
|
1397
1401
|
if (evidence === undefined) continue;
|
|
@@ -1574,6 +1578,7 @@ export function discoverThemeDirectory(
|
|
|
1574
1578
|
});
|
|
1575
1579
|
}
|
|
1576
1580
|
|
|
1581
|
+
if (progress) progress.slug = undefined;
|
|
1577
1582
|
return themes;
|
|
1578
1583
|
}
|
|
1579
1584
|
|
|
@@ -1690,20 +1695,48 @@ export function discoverBundledThemes() {
|
|
|
1690
1695
|
* Discover authored themes in the app's conventional local themes root.
|
|
1691
1696
|
* @param {string} projectDir
|
|
1692
1697
|
* @param {string} [owner]
|
|
1698
|
+
* @param {{onFolderError?: (slug: string, error: Error) => void}} [options]
|
|
1699
|
+
* with `onFolderError`, a theme folder that fails validation is reported
|
|
1700
|
+
* through it and left out, so one broken folder does not hide the others
|
|
1693
1701
|
* @returns {DiscoveredTheme[]}
|
|
1694
1702
|
*/
|
|
1695
|
-
export function discoverLocalThemes(
|
|
1703
|
+
export function discoverLocalThemes(
|
|
1704
|
+
projectDir,
|
|
1705
|
+
owner = LOCAL_THEME_ROOT,
|
|
1706
|
+
{onFolderError} = {},
|
|
1707
|
+
) {
|
|
1696
1708
|
const root = path.resolve(projectDir, owner);
|
|
1697
1709
|
if (!fs.existsSync(root) || !fs.statSync(root).isDirectory()) return [];
|
|
1698
|
-
|
|
1699
|
-
|
|
1700
|
-
|
|
1701
|
-
|
|
1702
|
-
|
|
1703
|
-
|
|
1704
|
-
|
|
1705
|
-
|
|
1706
|
-
|
|
1710
|
+
/** @type {Set<string>} */
|
|
1711
|
+
const skip = new Set();
|
|
1712
|
+
/** @type {{slug?: string}} */
|
|
1713
|
+
const progress = {};
|
|
1714
|
+
let discovered;
|
|
1715
|
+
for (;;) {
|
|
1716
|
+
try {
|
|
1717
|
+
discovered = discoverThemeDirectory(root, owner, {
|
|
1718
|
+
allowUnmigrated: true,
|
|
1719
|
+
skip,
|
|
1720
|
+
progress,
|
|
1721
|
+
});
|
|
1722
|
+
break;
|
|
1723
|
+
} catch (error) {
|
|
1724
|
+
const slug = progress.slug;
|
|
1725
|
+
if (!onFolderError || slug === undefined) throw error;
|
|
1726
|
+
skip.add(slug);
|
|
1727
|
+
onFolderError(
|
|
1728
|
+
slug,
|
|
1729
|
+
error instanceof Error ? error : new Error(String(error)),
|
|
1730
|
+
);
|
|
1731
|
+
}
|
|
1732
|
+
}
|
|
1733
|
+
return discovered.map(theme => ({
|
|
1734
|
+
...theme,
|
|
1735
|
+
package: owner,
|
|
1736
|
+
packageDir: projectDir,
|
|
1737
|
+
packageExports: null,
|
|
1738
|
+
source: /** @type {const} */ ('local'),
|
|
1739
|
+
}));
|
|
1707
1740
|
}
|
|
1708
1741
|
|
|
1709
1742
|
/**
|
|
@@ -5,7 +5,9 @@
|
|
|
5
5
|
* authored doc file.
|
|
6
6
|
*
|
|
7
7
|
* @input An absolute path to a `.doc.{ts,mjs,js}` (or legacy template) file.
|
|
8
|
-
* @output The module's
|
|
8
|
+
* @output The module's exports: for a doc Astryx ships whose text matches its
|
|
9
|
+
* stored exports, a non-extensible, namespace-like object built from them (see
|
|
10
|
+
* `storedModule`); otherwise the namespace object a plain import of the file
|
|
9
11
|
* gives, until the file changes; then the edited file's, read once by each
|
|
10
12
|
* importer, its own way, and shared until the next change. A long-running
|
|
11
13
|
* process (a docs site's search, an agent harness) thereby sees an edit to
|
|
@@ -22,6 +24,7 @@
|
|
|
22
24
|
* whatever the local names; deliberate obfuscation is out of scope.
|
|
23
25
|
*/
|
|
24
26
|
|
|
27
|
+
import * as fs from 'node:fs';
|
|
25
28
|
import {pathToFileURL} from 'node:url';
|
|
26
29
|
import {createJiti} from 'jiti';
|
|
27
30
|
import {importUrl} from '../fs/import-url.mjs';
|
|
@@ -31,6 +34,12 @@ import {
|
|
|
31
34
|
readInTurn,
|
|
32
35
|
} from '../fs/module-loader.mjs';
|
|
33
36
|
import {fileStamp, recordContentRead} from '../fs/read-record.mjs';
|
|
37
|
+
import {
|
|
38
|
+
readStore,
|
|
39
|
+
storedKey,
|
|
40
|
+
SHIPPED_ASSETS,
|
|
41
|
+
STORED_DOCS_FILE,
|
|
42
|
+
} from './stored-docs.mjs';
|
|
34
43
|
|
|
35
44
|
/** @type {ReturnType<typeof createJiti> | undefined} */
|
|
36
45
|
let jsxJiti;
|
|
@@ -62,16 +71,72 @@ function importCurrent(file, kind, load, loadFresh) {
|
|
|
62
71
|
let seen = imported.get(file);
|
|
63
72
|
if (!seen) {
|
|
64
73
|
imported.set(file, {stamp, changed: null});
|
|
65
|
-
return
|
|
74
|
+
return loadFirst(file, load);
|
|
66
75
|
}
|
|
67
76
|
if (seen.stamp !== stamp) {
|
|
68
77
|
seen = {stamp, changed: {}};
|
|
69
78
|
imported.set(file, seen);
|
|
70
79
|
}
|
|
71
|
-
if (!seen.changed) return
|
|
80
|
+
if (!seen.changed) return loadFirst(file, load);
|
|
72
81
|
return (seen.changed[kind] ??= loadFresh(file));
|
|
73
82
|
}
|
|
74
83
|
|
|
84
|
+
/**
|
|
85
|
+
* A doc file as first imported: a doc Astryx ships answers from its stored
|
|
86
|
+
* exports (STORED_DOCS_FILE), anything else is imported with `load`.
|
|
87
|
+
* @param {string} file
|
|
88
|
+
* @param {(file: string) => Promise<any>} load
|
|
89
|
+
* @returns {Promise<any>}
|
|
90
|
+
*/
|
|
91
|
+
function loadFirst(file, load) {
|
|
92
|
+
const stored = storedModule(file);
|
|
93
|
+
return stored ? Promise.resolve(stored) : load(file);
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* Each stored doc's module, by file, so every read of an unchanged file gets
|
|
98
|
+
* the same object, as an import of it does.
|
|
99
|
+
* @type {Map<string, {key: string, module: Record<string, unknown>}>}
|
|
100
|
+
*/
|
|
101
|
+
const storedModules = new Map();
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* The module of a shipped doc file whose text has stored exports: an object
|
|
105
|
+
* shaped as its namespace (no prototype, the export names in order, tagged
|
|
106
|
+
* `Module`, closed to new names). Null for any other file.
|
|
107
|
+
* @param {string} file
|
|
108
|
+
* @returns {Record<string, unknown> | null}
|
|
109
|
+
*/
|
|
110
|
+
function storedModule(file) {
|
|
111
|
+
if (!file.startsWith(SHIPPED_ASSETS) || !file.endsWith('.doc.mjs')) {
|
|
112
|
+
return null;
|
|
113
|
+
}
|
|
114
|
+
let text;
|
|
115
|
+
try {
|
|
116
|
+
text = fs.readFileSync(file, 'utf-8');
|
|
117
|
+
} catch {
|
|
118
|
+
return null;
|
|
119
|
+
}
|
|
120
|
+
const key = storedKey(text);
|
|
121
|
+
const known = storedModules.get(file);
|
|
122
|
+
if (known?.key === key) return known.module;
|
|
123
|
+
const exports = readStore(STORED_DOCS_FILE).get(key);
|
|
124
|
+
if (!exports) return null;
|
|
125
|
+
/** @type {Record<string, unknown>} */
|
|
126
|
+
const module = Object.create(null);
|
|
127
|
+
for (const name of Object.keys(exports).sort()) {
|
|
128
|
+
Object.defineProperty(module, name, {
|
|
129
|
+
value: exports[name],
|
|
130
|
+
enumerable: true,
|
|
131
|
+
writable: true,
|
|
132
|
+
});
|
|
133
|
+
}
|
|
134
|
+
Object.defineProperty(module, Symbol.toStringTag, {value: 'Module'});
|
|
135
|
+
Object.preventExtensions(module);
|
|
136
|
+
storedModules.set(file, {key, module});
|
|
137
|
+
return module;
|
|
138
|
+
}
|
|
139
|
+
|
|
75
140
|
/**
|
|
76
141
|
* The file's URL, naming a new module for each change.
|
|
77
142
|
* @param {string} file
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
// @generated by scripts/sync-api-types.mjs from the JSDoc in foundation/**/*.mjs.
|
|
2
|
+
// DO NOT EDIT — run `pnpm sync:api-types` to regenerate.
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* The key of a source file's text in a store written at publish (the stored
|
|
6
|
+
* docs, the stored template component lists): a hash of the text, so an
|
|
7
|
+
* edited or unknown file is never answered from a store.
|
|
8
|
+
* @param {string} text
|
|
9
|
+
* @returns {string}
|
|
10
|
+
*/
|
|
11
|
+
export function storedKey(text: string): string;
|
|
12
|
+
/**
|
|
13
|
+
* A store written at publish, by key, read once per process. A missing or
|
|
14
|
+
* unreadable file reads as empty, so every source is worked out as before.
|
|
15
|
+
* @param {string} file
|
|
16
|
+
* @returns {Map<string, any>}
|
|
17
|
+
*/
|
|
18
|
+
export function readStore(file: string): Map<string, any>;
|
|
19
|
+
/**
|
|
20
|
+
* Where the exports of the doc files Astryx ships are stored: each doc that
|
|
21
|
+
* imports nothing, runs nothing as it loads and exports only plain data, by a
|
|
22
|
+
* hash of its text. A stored doc then needs no import; an edited or unknown
|
|
23
|
+
* file is imported as before.
|
|
24
|
+
*/
|
|
25
|
+
export const STORED_DOCS_FILE: string;
|
|
26
|
+
/** The folder of the files Astryx ships; only its doc files are stored. */
|
|
27
|
+
export const SHIPPED_ASSETS: string;
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
// Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @file Where the exports of the doc files Astryx ships are stored, how a
|
|
5
|
+
* source file's text is keyed in a store written at publish, and how such a
|
|
6
|
+
* store is read. ./import.mjs reads the stored exports and
|
|
7
|
+
* foundation/discovery/template-adapter.mjs the stored template component
|
|
8
|
+
* lists; scripts/generate-stored-docs.mjs and
|
|
9
|
+
* scripts/generate-template-components.mjs write them.
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
import {createHash} from 'node:crypto';
|
|
13
|
+
import * as fs from 'node:fs';
|
|
14
|
+
import * as path from 'node:path';
|
|
15
|
+
import {CLI_ROOT} from '../fs/paths.mjs';
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Where the exports of the doc files Astryx ships are stored: each doc that
|
|
19
|
+
* imports nothing, runs nothing as it loads and exports only plain data, by a
|
|
20
|
+
* hash of its text. A stored doc then needs no import; an edited or unknown
|
|
21
|
+
* file is imported as before.
|
|
22
|
+
*/
|
|
23
|
+
export const STORED_DOCS_FILE = path.join(
|
|
24
|
+
CLI_ROOT,
|
|
25
|
+
'assets',
|
|
26
|
+
'docs.generated.json',
|
|
27
|
+
);
|
|
28
|
+
|
|
29
|
+
/** The folder of the files Astryx ships; only its doc files are stored. */
|
|
30
|
+
export const SHIPPED_ASSETS = path.join(CLI_ROOT, 'assets') + path.sep;
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* The key of a source file's text in a store written at publish (the stored
|
|
34
|
+
* docs, the stored template component lists): a hash of the text, so an
|
|
35
|
+
* edited or unknown file is never answered from a store.
|
|
36
|
+
* @param {string} text
|
|
37
|
+
* @returns {string}
|
|
38
|
+
*/
|
|
39
|
+
export function storedKey(text) {
|
|
40
|
+
return createHash('sha256').update(text).digest('hex').slice(0, 32);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/** @type {Map<string, Map<string, any>>} */
|
|
44
|
+
const stores = new Map();
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* A store written at publish, by key, read once per process. A missing or
|
|
48
|
+
* unreadable file reads as empty, so every source is worked out as before.
|
|
49
|
+
* @param {string} file
|
|
50
|
+
* @returns {Map<string, any>}
|
|
51
|
+
*/
|
|
52
|
+
export function readStore(file) {
|
|
53
|
+
let store = stores.get(file);
|
|
54
|
+
if (!store) {
|
|
55
|
+
try {
|
|
56
|
+
store = new Map(
|
|
57
|
+
Object.entries(JSON.parse(fs.readFileSync(file, 'utf-8'))),
|
|
58
|
+
);
|
|
59
|
+
} catch {
|
|
60
|
+
store = new Map();
|
|
61
|
+
}
|
|
62
|
+
stores.set(file, store);
|
|
63
|
+
}
|
|
64
|
+
return store;
|
|
65
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
// @generated by scripts/sync-api-types.mjs from the JSDoc in foundation/**/*.mjs.
|
|
2
|
+
// DO NOT EDIT — run `pnpm sync:api-types` to regenerate.
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* @file Plain words for file-system failures.
|
|
6
|
+
*
|
|
7
|
+
* @input an error thrown by `node:fs`, and the project-relative path it hit
|
|
8
|
+
* @output one sentence that names the path and the fix, with no errno text
|
|
9
|
+
* @position shared by commands that write into the user's project, so a raw
|
|
10
|
+
* `EISDIR` or `ENAMETOOLONG` never reaches the caller
|
|
11
|
+
*/
|
|
12
|
+
/**
|
|
13
|
+
* @param {unknown} err
|
|
14
|
+
* @param {string} relative the path as the user wrote it, relative to the project
|
|
15
|
+
* @returns {string | null} null when the error is not a known file-system failure
|
|
16
|
+
*/
|
|
17
|
+
export function fsErrorMessage(err: unknown, relative: string): string | null;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
// Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @file Plain words for file-system failures.
|
|
5
|
+
*
|
|
6
|
+
* @input an error thrown by `node:fs`, and the project-relative path it hit
|
|
7
|
+
* @output one sentence that names the path and the fix, with no errno text
|
|
8
|
+
* @position shared by commands that write into the user's project, so a raw
|
|
9
|
+
* `EISDIR` or `ENAMETOOLONG` never reaches the caller
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* @param {unknown} err
|
|
14
|
+
* @param {string} relative the path as the user wrote it, relative to the project
|
|
15
|
+
* @returns {string | null} null when the error is not a known file-system failure
|
|
16
|
+
*/
|
|
17
|
+
export function fsErrorMessage(err, relative) {
|
|
18
|
+
switch (/** @type {NodeJS.ErrnoException | null} */ (err)?.code) {
|
|
19
|
+
case 'EISDIR':
|
|
20
|
+
return `${relative} is a folder; give a file path.`;
|
|
21
|
+
case 'ENOTDIR':
|
|
22
|
+
return `A part of ${relative} is a file, not a folder; give another path.`;
|
|
23
|
+
case 'EEXIST':
|
|
24
|
+
return `A file is in the way at ${relative}, where a folder is needed; give another path.`;
|
|
25
|
+
case 'ENAMETOOLONG':
|
|
26
|
+
return 'The path is too long for this file system; give a shorter name.';
|
|
27
|
+
case 'EACCES':
|
|
28
|
+
case 'EPERM':
|
|
29
|
+
case 'EROFS':
|
|
30
|
+
return `No permission to write ${relative}.`;
|
|
31
|
+
default:
|
|
32
|
+
return null;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
@@ -118,6 +118,8 @@ export function allErrorCodes(): string[];
|
|
|
118
118
|
* | 'ERR_THEME_PRIVATE_TOKEN'
|
|
119
119
|
* | 'ERR_THEME_UNKNOWN_TOKEN'
|
|
120
120
|
* | 'ERR_THEME_NO_EFFECT'
|
|
121
|
+
* | 'ERR_THEME_NOT_CHECKED'
|
|
122
|
+
* | 'ERR_THEME_BUSY'
|
|
121
123
|
* | 'ERR_THEME_UNKNOWN_THING'
|
|
122
124
|
* | 'ERR_THEME_NOT_SET'
|
|
123
125
|
* | 'ERR_THEME_NOTHING_TO_UNDO'
|
|
@@ -131,4 +133,4 @@ export const ERROR_CODES: Readonly<Record<ErrorCode, ErrorCode>>;
|
|
|
131
133
|
/**
|
|
132
134
|
* Stable error-code string union. Append-only.
|
|
133
135
|
*/
|
|
134
|
-
export type ErrorCode = ("ERR_UNKNOWN" | "ERR_UNKNOWN_COMMAND" | "ERR_UNKNOWN_SUBCOMMAND" | "ERR_INVALID_OPTION" | "ERR_INVALID_ARGUMENT" | "ERR_MISSING_ARGUMENT" | "ERR_INVALID_LANG" | "ERR_INVALID_DETAIL" | "ERR_NODE_VERSION" | "ERR_CORE_NOT_FOUND" | "ERR_CORE_INCOMPATIBLE" | "ERR_UNKNOWN_COMPONENT" | "ERR_UNKNOWN_HOOK" | "ERR_UNKNOWN_TOPIC" | "ERR_UNKNOWN_SECTION" | "ERR_UNKNOWN_CATEGORY" | "ERR_UNKNOWN_TEMPLATE" | "ERR_AMBIGUOUS_TEMPLATE" | "ERR_AMBIGUOUS_COMPONENT" | "ERR_AMBIGUOUS_THEME" | "ERR_UNKNOWN_THEME" | "ERR_INTEGRATION_ROOT_CONFLICT" | "ERR_INTEGRATION_EXPORT_CONFLICT" | "ERR_UNKNOWN_PACKAGE" | "ERR_UNKNOWN_AGENT" | "ERR_UNKNOWN_FEATURE" | "ERR_UNKNOWN_CODEMOD" | "ERR_CODEMOD_FAILED" | "ERR_CODEMOD_PROTECTED" | "ERR_CODEMOD_PROTECTION_SOURCE" | "ERR_NOT_FOUND" | "ERR_NO_DOC" | "ERR_NO_SHOWCASE" | "ERR_NO_SOURCE" | "ERR_INVALID_DOC" | "ERR_FILE_NOT_FOUND" | "ERR_FILE_EXISTS" | "ERR_PATH_TRAVERSAL" | "ERR_WRITE_FAILED" | "ERR_THEME_INVALID" | "ERR_THEME_LOAD" | "ERR_PALETTE_GENERATION" | "ERR_VERSION_DETECT" | "ERR_INVALID_VERSION" | "ERR_DEP_MISSING" | "ERR_GH_CLI" | "ERR_UNKNOWN_POST" | "ERR_FETCH_FAILED" | "ERR_LAYOUT_PARSE" | "ERR_LAYOUT_INVALID" | "ERR_UNCLASSIFIED_EXIT" | "ERR_SIGNAL_TERMINATED" | "ERR_VERSIONS_UNAVAILABLE" | "ERR_PROJECT_REQUIRED" | "ERR_RENDER_COMPILE" | "ERR_RENDER_NO_DEFAULT_EXPORT" | "ERR_RENDER_MISSING_DEPENDENCY" | "ERR_RENDER_BROWSER_API" | "ERR_RENDER_ASSET_TOO_LARGE" | "ERR_RENDER_TIMEOUT" | "ERR_RENDER_FAILED" | "ERR_RENDER_NOT_ASTRYX" | "ERR_RENDER_SOURCE_DAMAGED" | "ERR_THEME_BAD_VALUE" | "ERR_THEME_NO_MODE" | "ERR_THEME_UNKNOWN_PART" | "ERR_THEME_UNKNOWN_VARIANT" | "ERR_THEME_UNKNOWN_STATE" | "ERR_THEME_PRIVATE_TOKEN" | "ERR_THEME_UNKNOWN_TOKEN" | "ERR_THEME_NO_EFFECT" | "ERR_THEME_UNKNOWN_THING" | "ERR_THEME_NOT_SET" | "ERR_THEME_NOTHING_TO_UNDO");
|
|
136
|
+
export type ErrorCode = ("ERR_UNKNOWN" | "ERR_UNKNOWN_COMMAND" | "ERR_UNKNOWN_SUBCOMMAND" | "ERR_INVALID_OPTION" | "ERR_INVALID_ARGUMENT" | "ERR_MISSING_ARGUMENT" | "ERR_INVALID_LANG" | "ERR_INVALID_DETAIL" | "ERR_NODE_VERSION" | "ERR_CORE_NOT_FOUND" | "ERR_CORE_INCOMPATIBLE" | "ERR_UNKNOWN_COMPONENT" | "ERR_UNKNOWN_HOOK" | "ERR_UNKNOWN_TOPIC" | "ERR_UNKNOWN_SECTION" | "ERR_UNKNOWN_CATEGORY" | "ERR_UNKNOWN_TEMPLATE" | "ERR_AMBIGUOUS_TEMPLATE" | "ERR_AMBIGUOUS_COMPONENT" | "ERR_AMBIGUOUS_THEME" | "ERR_UNKNOWN_THEME" | "ERR_INTEGRATION_ROOT_CONFLICT" | "ERR_INTEGRATION_EXPORT_CONFLICT" | "ERR_UNKNOWN_PACKAGE" | "ERR_UNKNOWN_AGENT" | "ERR_UNKNOWN_FEATURE" | "ERR_UNKNOWN_CODEMOD" | "ERR_CODEMOD_FAILED" | "ERR_CODEMOD_PROTECTED" | "ERR_CODEMOD_PROTECTION_SOURCE" | "ERR_NOT_FOUND" | "ERR_NO_DOC" | "ERR_NO_SHOWCASE" | "ERR_NO_SOURCE" | "ERR_INVALID_DOC" | "ERR_FILE_NOT_FOUND" | "ERR_FILE_EXISTS" | "ERR_PATH_TRAVERSAL" | "ERR_WRITE_FAILED" | "ERR_THEME_INVALID" | "ERR_THEME_LOAD" | "ERR_PALETTE_GENERATION" | "ERR_VERSION_DETECT" | "ERR_INVALID_VERSION" | "ERR_DEP_MISSING" | "ERR_GH_CLI" | "ERR_UNKNOWN_POST" | "ERR_FETCH_FAILED" | "ERR_LAYOUT_PARSE" | "ERR_LAYOUT_INVALID" | "ERR_UNCLASSIFIED_EXIT" | "ERR_SIGNAL_TERMINATED" | "ERR_VERSIONS_UNAVAILABLE" | "ERR_PROJECT_REQUIRED" | "ERR_RENDER_COMPILE" | "ERR_RENDER_NO_DEFAULT_EXPORT" | "ERR_RENDER_MISSING_DEPENDENCY" | "ERR_RENDER_BROWSER_API" | "ERR_RENDER_ASSET_TOO_LARGE" | "ERR_RENDER_TIMEOUT" | "ERR_RENDER_FAILED" | "ERR_RENDER_NOT_ASTRYX" | "ERR_RENDER_SOURCE_DAMAGED" | "ERR_THEME_BAD_VALUE" | "ERR_THEME_NO_MODE" | "ERR_THEME_UNKNOWN_PART" | "ERR_THEME_UNKNOWN_VARIANT" | "ERR_THEME_UNKNOWN_STATE" | "ERR_THEME_PRIVATE_TOKEN" | "ERR_THEME_UNKNOWN_TOKEN" | "ERR_THEME_NO_EFFECT" | "ERR_THEME_NOT_CHECKED" | "ERR_THEME_BUSY" | "ERR_THEME_UNKNOWN_THING" | "ERR_THEME_NOT_SET" | "ERR_THEME_NOTHING_TO_UNDO");
|
|
@@ -394,6 +394,18 @@ export const doc = {
|
|
|
394
394
|
description:
|
|
395
395
|
'The change could not take effect: neither the part nor any part inside it reads the token (or, for the whole theme, no part reads it). The suggestions name the token the part really reads and the property that sets it directly. Nothing was changed. Raised only by the experimental theme command.',
|
|
396
396
|
},
|
|
397
|
+
{
|
|
398
|
+
value: 'ERR_THEME_NOT_CHECKED',
|
|
399
|
+
stability: 'experimental',
|
|
400
|
+
description:
|
|
401
|
+
"Not an error and never an exit code: the change is saved, but the components could not be rendered, so it was not checked against what they read and has no preview. The result carries it in `notChecked` with the cause, such as two copies of React (the app's and the one Core resolves). Reported only by the experimental theme command.",
|
|
402
|
+
},
|
|
403
|
+
{
|
|
404
|
+
value: 'ERR_THEME_BUSY',
|
|
405
|
+
stability: 'experimental',
|
|
406
|
+
description:
|
|
407
|
+
'Another command is changing the same theme (or the same preview) and did not finish within 30 seconds. Commands on one theme run one after the other; nothing was changed. Run the command again. Raised only by the experimental theme command.',
|
|
408
|
+
},
|
|
397
409
|
{
|
|
398
410
|
value: 'ERR_THEME_UNKNOWN_THING',
|
|
399
411
|
stability: 'experimental',
|
|
@@ -404,7 +416,7 @@ export const doc = {
|
|
|
404
416
|
value: 'ERR_THEME_NOT_SET',
|
|
405
417
|
stability: 'experimental',
|
|
406
418
|
description:
|
|
407
|
-
'`
|
|
419
|
+
'`editor undo <theme> <thing>` names a setting the theme does not have (with those `--on`, `--when`, `--state` and `--mode`). Nothing was changed. Raised only by the experimental theme command.',
|
|
408
420
|
},
|
|
409
421
|
{
|
|
410
422
|
value: 'ERR_THEME_NOTHING_TO_UNDO',
|
|
@@ -107,6 +107,8 @@
|
|
|
107
107
|
* | 'ERR_THEME_PRIVATE_TOKEN'
|
|
108
108
|
* | 'ERR_THEME_UNKNOWN_TOKEN'
|
|
109
109
|
* | 'ERR_THEME_NO_EFFECT'
|
|
110
|
+
* | 'ERR_THEME_NOT_CHECKED'
|
|
111
|
+
* | 'ERR_THEME_BUSY'
|
|
110
112
|
* | 'ERR_THEME_UNKNOWN_THING'
|
|
111
113
|
* | 'ERR_THEME_NOT_SET'
|
|
112
114
|
* | 'ERR_THEME_NOTHING_TO_UNDO'
|
|
@@ -358,12 +360,20 @@ export const ERROR_CODES = Object.freeze({
|
|
|
358
360
|
* The change could not take effect: neither the part nor any part inside it reads the token (or, for the whole theme, no part reads it). The suggestions name the token the part really reads and the property that sets it directly. Nothing was changed. Raised only by `experimental theme`.
|
|
359
361
|
*/
|
|
360
362
|
ERR_THEME_NO_EFFECT: 'ERR_THEME_NO_EFFECT',
|
|
363
|
+
/**
|
|
364
|
+
* Not an error: the change is saved, but the components could not be rendered, so it was not checked and has no preview. The result's `notChecked` carries this code and the cause, such as two copies of React. Reported only by `experimental theme`.
|
|
365
|
+
*/
|
|
366
|
+
ERR_THEME_NOT_CHECKED: 'ERR_THEME_NOT_CHECKED',
|
|
367
|
+
/**
|
|
368
|
+
* Another command is changing the same theme (or preview) and did not finish in time. Nothing was changed; run the command again. Raised only by `experimental theme`.
|
|
369
|
+
*/
|
|
370
|
+
ERR_THEME_BUSY: 'ERR_THEME_BUSY',
|
|
361
371
|
/**
|
|
362
372
|
* The thing to change is not a dial, a design token, or a CSS property. Nothing was changed. Raised only by `experimental theme`.
|
|
363
373
|
*/
|
|
364
374
|
ERR_THEME_UNKNOWN_THING: 'ERR_THEME_UNKNOWN_THING',
|
|
365
375
|
/**
|
|
366
|
-
* `
|
|
376
|
+
* `editor undo <theme> <thing>` names a setting the theme does not have (with those `--on`, `--when`, `--state` and `--mode`). Nothing was changed. Raised only by `experimental theme`.
|
|
367
377
|
*/
|
|
368
378
|
ERR_THEME_NOT_SET: 'ERR_THEME_NOT_SET',
|
|
369
379
|
/**
|
|
@@ -117,31 +117,31 @@ export const doc = {
|
|
|
117
117
|
value: 'themeEdit.new',
|
|
118
118
|
stability: 'experimental',
|
|
119
119
|
description:
|
|
120
|
-
'A theme made by `experimental theme editor new`: `theme`, `like` (the built-in theme it builds on, or null), the `files` written (settings, source, css, module), contrast `problems`, the `preview` page, and any `pictures` (with `pictureProblem` when none could be taken). Experimental: may change or be removed in a patch release.',
|
|
120
|
+
'A theme made by `experimental theme editor new`: `theme`, `like` (the built-in theme it builds on, or null), the `files` written (settings, source, css, module), the dial `settings` it started with, font `notes`, contrast `problems`, the `preview` page, and any `pictures` (with `pictureProblem` when none could be taken). Experimental: may change or be removed in a patch release.',
|
|
121
121
|
},
|
|
122
122
|
{
|
|
123
123
|
value: 'themeEdit.set',
|
|
124
124
|
stability: 'experimental',
|
|
125
125
|
description:
|
|
126
|
-
'One checked change written: the `setting`, the one it `replaced`, `was` (for base and mode), the `parts` and `
|
|
126
|
+
'One checked change written: the `setting`, the one it `replaced`, `was` (for base and mode), the `parts` and `group` it styles, resolved `changedTokens`, part styles written (`styled`), part settings a dial `kept`, newly `lifted` variant keys, `notes`, contrast `problems`, build `warnings`, the `preview` page and any `pictures`. Experimental: may change or be removed in a patch release.',
|
|
127
127
|
},
|
|
128
128
|
{
|
|
129
129
|
value: 'themeEdit.show',
|
|
130
130
|
stability: 'experimental',
|
|
131
131
|
description:
|
|
132
|
-
'Every `settings` entry with the `parts` it styles, key `resolved` token values per mode,
|
|
132
|
+
'Every `settings` entry with the `parts` it styles, key `resolved` token values (colors and shadows per mode, other values once), `partValues` (corners or spacing set on a part or group, with what its parts get beside the whole-theme value), the generated colors (`vibrancy`; `colors`, each with its `seed` and the shade each token uses in light and dark; `colorNotes` on shades moved for contrast), contrast `problems`, font `notes`, the `preview` and `sheet` pages, the `sheetComponents` count, template pages `skipped`, any `pictures`, and last the generated color files (`colorFiles`; null with no color). Experimental: may change or be removed in a patch release.',
|
|
133
133
|
},
|
|
134
134
|
{
|
|
135
135
|
value: 'themeEdit.undo',
|
|
136
136
|
stability: 'experimental',
|
|
137
137
|
description:
|
|
138
|
-
"An undo. One step back (`action` `step`): what was `undone`, the `settings` count now, the `stepsLeft`, the `preview` page and any `pictures`. One setting removed (`action` `undo`): the same fields as `themeEdit.set`, with `setting` naming the
|
|
138
|
+
"An undo. One step back (`action` `step`): what was `undone`, the `settings` count now, the `stepsLeft`, the `preview` page and any `pictures`. One setting removed (`action` `undo`): the same fields as `themeEdit.set`, with `setting` and `removed` both naming the setting removed, and `now` saying what applies instead (a whole-theme setting of the same thing, or the base theme's value; `changedTokens` lists the values). Experimental: may change or be removed in a patch release.",
|
|
139
139
|
},
|
|
140
140
|
{
|
|
141
141
|
value: 'themeEdit.previewAdd',
|
|
142
142
|
stability: 'experimental',
|
|
143
143
|
description:
|
|
144
|
-
"Pages added to the theme preview in the app: the route `folder`, the `theme` the pages wear (null for the app's own), the pages `added
|
|
144
|
+
"Pages added to the theme preview in the app: the route `folder`, the `theme` the pages wear (null for the app's own), the pages `added`, the pages that were there already and are written again (`refreshed`), every page (`pages`), each template page picked and why (`matched`), the template pages `skipped` (each with its `reason` and `installCommand`), the `files` the preview wrote, `notes`, and how to `open` it. Experimental: may change or be removed in a patch release.",
|
|
145
145
|
},
|
|
146
146
|
{
|
|
147
147
|
value: 'themeEdit.previewApp',
|
|
@@ -165,7 +165,7 @@ export const doc = {
|
|
|
165
165
|
value: 'themeEdit.how',
|
|
166
166
|
stability: 'experimental',
|
|
167
167
|
description:
|
|
168
|
-
'A how answer; `kind` says which: `part` (`component`, `recorded`, `
|
|
168
|
+
'A how answer; `kind` says which: `part` (`component`, `recorded`, `group`, `groupMembers`, `spreads`, `variants`, `states`, `reads` per aspect, `contains`), `group` (`members`, `spreads`), `setting` (a dial: `values`, `help`, `examples`, and for a color the `shades` each token starts from; a token: `tokenType`, `default`, `perMode`, `readBy`, `examples`; a property: `setBy`, `examples`), `aspect` or `question` (`results`, each a `text` and its `commands`), `picture` (main colors or the color at points) or `list` (the `items`). Experimental: may change or be removed in a patch release.',
|
|
169
169
|
},
|
|
170
170
|
// render (experimental: may change or be removed in a patch release)
|
|
171
171
|
{
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@astryxdesign/cli",
|
|
3
|
-
"version": "0.7.14
|
|
3
|
+
"version": "0.7.14",
|
|
4
4
|
"displayName": "CLI",
|
|
5
5
|
"description": "Scaffold projects, browse templates, generate themes, and get agent-ready docs from the command line.",
|
|
6
6
|
"author": "Meta Open Source",
|
|
@@ -125,7 +125,7 @@
|
|
|
125
125
|
"zod": "^4.6.7"
|
|
126
126
|
},
|
|
127
127
|
"peerDependencies": {
|
|
128
|
-
"@astryxdesign/core": "
|
|
128
|
+
"@astryxdesign/core": "*"
|
|
129
129
|
},
|
|
130
130
|
"peerDependenciesMeta": {
|
|
131
131
|
"@astryxdesign/core": {
|
|
@@ -133,10 +133,10 @@
|
|
|
133
133
|
}
|
|
134
134
|
},
|
|
135
135
|
"devDependencies": {
|
|
136
|
-
"@astryxdesign/charts": "
|
|
137
|
-
"@astryxdesign/core": "
|
|
138
|
-
"@astryxdesign/lab": "
|
|
139
|
-
"@astryxdesign/theme-neutral": "
|
|
136
|
+
"@astryxdesign/charts": "*",
|
|
137
|
+
"@astryxdesign/core": "*",
|
|
138
|
+
"@astryxdesign/lab": "*",
|
|
139
|
+
"@astryxdesign/theme-neutral": "*",
|
|
140
140
|
"@heroicons/react": "^2.2.0",
|
|
141
141
|
"@stylexjs/stylex": "^0.19.1",
|
|
142
142
|
"@types/babel__core": "^7.20.5",
|
|
@@ -144,7 +144,6 @@
|
|
|
144
144
|
"recharts": "^3.10.1"
|
|
145
145
|
},
|
|
146
146
|
"scripts": {
|
|
147
|
-
"api:report": "node ../../scripts/api-report/cli.mjs --package .",
|
|
148
147
|
"astryx": "node clients/cli/bin/astryx.mjs",
|
|
149
148
|
"postinstall": "node scripts/postinstall.mjs",
|
|
150
149
|
"test": "cd ../.. && vitest run packages/cli",
|
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
// Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* @file CommandDoc for `astryx experimental theme palette generate`: the experimental
|
|
5
|
-
* copy of `astryx theme palette generate`, with the same function, flags and output.
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
/** @type {import('@astryxdesign/cli/authoring').CommandDoc} */
|
|
9
|
-
export const doc = {
|
|
10
|
-
type: 'command',
|
|
11
|
-
name: 'experimental theme palette generate',
|
|
12
|
-
displayName: 'astryx experimental theme palette generate',
|
|
13
|
-
namespace: 'cli/commands',
|
|
14
|
-
stability: 'experimental',
|
|
15
|
-
summary: 'Generate an OKLCH palette candidate for human review',
|
|
16
|
-
description:
|
|
17
|
-
'Reads an explicit JSON request and runs the versioned astryx-oklch-v1 recipe. The command defaults to 21 stops (0 through 100) but accepts any non-empty ordered numeric stop list, including decimals. Stops apply to every family in the request. Authors may omit the repeated endpoints with a custom list; standalone exact black and white values remain available in every candidate. For anchors, exact preserves the chosen color at its mode and stop; bounded allows movement within maxDeltaE; flexible uses the color as guidance. Without --out it prints a preview. With --out it writes a candidate file and detached receipt. --preview writes a standardized, self-contained HTML review artifact. TypeScript output is directly importable and contains no generator dependency. JSON is also supported. Existing author-owned files are left untouched unless --overwrite is explicit. When used in a theme integration, keep the palette request under the theme slug, write the candidate and receipt under that same slug, import the candidate from the theme source, and keep all three inside the theme directory. The package ships that directory as one source unit for discovery and explicit eject, while apps use its built exports.',
|
|
18
|
-
fn: 'themePaletteGenerate',
|
|
19
|
-
args: [
|
|
20
|
-
{
|
|
21
|
-
name: 'config',
|
|
22
|
-
param: 'configPath',
|
|
23
|
-
required: true,
|
|
24
|
-
},
|
|
25
|
-
],
|
|
26
|
-
options: [
|
|
27
|
-
{
|
|
28
|
-
flag: '-o, --out <path>',
|
|
29
|
-
param: 'options.out',
|
|
30
|
-
description:
|
|
31
|
-
'Write a candidate TypeScript or JSON file and a sibling receipt',
|
|
32
|
-
},
|
|
33
|
-
{
|
|
34
|
-
flag: '--preview <path>',
|
|
35
|
-
param: 'options.preview',
|
|
36
|
-
description:
|
|
37
|
-
'Write a self-contained HTML preview page; the path must end in .html',
|
|
38
|
-
},
|
|
39
|
-
{
|
|
40
|
-
flag: '-f, --overwrite',
|
|
41
|
-
param: 'options.overwrite',
|
|
42
|
-
description:
|
|
43
|
-
'Replace existing candidate, receipt, and preview files. Without it, if any of them exists, nothing is written',
|
|
44
|
-
},
|
|
45
|
-
],
|
|
46
|
-
examples: [
|
|
47
|
-
{
|
|
48
|
-
label: 'Preview candidate JSON',
|
|
49
|
-
cli: 'astryx experimental theme palette generate themes/ocean/palette.config.json',
|
|
50
|
-
},
|
|
51
|
-
{
|
|
52
|
-
label: 'Write candidate and receipt',
|
|
53
|
-
cli: 'astryx experimental theme palette generate themes/ocean/palette.config.json --out themes/ocean/tokens/ocean.palette.ts',
|
|
54
|
-
},
|
|
55
|
-
{
|
|
56
|
-
label: 'Write candidate, receipt, and review preview',
|
|
57
|
-
cli: 'astryx experimental theme palette generate themes/ocean/palette.config.json --out themes/ocean/tokens/ocean.palette.ts --preview themes/ocean/tokens/ocean.palette.html',
|
|
58
|
-
},
|
|
59
|
-
],
|
|
60
|
-
outsideProject: 'same',
|
|
61
|
-
exitCodes: [
|
|
62
|
-
{
|
|
63
|
-
code: 0,
|
|
64
|
-
when: 'a candidate is produced or existing output is left untouched',
|
|
65
|
-
},
|
|
66
|
-
{
|
|
67
|
-
code: 1,
|
|
68
|
-
when: 'the request is invalid or output cannot be written safely',
|
|
69
|
-
},
|
|
70
|
-
],
|
|
71
|
-
related: ['experimental theme compile', 'experimental theme template'],
|
|
72
|
-
replaces: ['theme palette generate'],
|
|
73
|
-
};
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
// Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* @file CommandDoc for `astryx experimental theme palette`: the experimental
|
|
5
|
-
* copy of `astryx theme palette`, with the same function, flags and output.
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
/** @type {import('@astryxdesign/cli/authoring').CommandDoc} */
|
|
9
|
-
export const doc = {
|
|
10
|
-
type: 'command',
|
|
11
|
-
name: 'experimental theme palette',
|
|
12
|
-
displayName: 'astryx experimental theme palette',
|
|
13
|
-
namespace: 'cli/commands',
|
|
14
|
-
stability: 'experimental',
|
|
15
|
-
summary: 'Create and work with theme-owned color palettes',
|
|
16
|
-
description:
|
|
17
|
-
'Palette authoring tools. generate writes a palette candidate for you to review before a theme uses it.',
|
|
18
|
-
subcommands: ['generate'],
|
|
19
|
-
examples: [
|
|
20
|
-
{
|
|
21
|
-
label: 'Generate a candidate',
|
|
22
|
-
cli: 'astryx experimental theme palette generate palette.config.json',
|
|
23
|
-
},
|
|
24
|
-
],
|
|
25
|
-
exitCodes: [
|
|
26
|
-
{
|
|
27
|
-
code: 0,
|
|
28
|
-
when: 'help is shown or a subcommand succeeds',
|
|
29
|
-
},
|
|
30
|
-
{
|
|
31
|
-
code: 1,
|
|
32
|
-
when: 'an unknown subcommand is provided',
|
|
33
|
-
},
|
|
34
|
-
],
|
|
35
|
-
related: ['experimental theme compile', 'experimental theme template'],
|
|
36
|
-
replaces: ['theme palette'],
|
|
37
|
-
};
|