@astryxdesign/cli 0.7.14-canary.gfdb9213 → 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/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/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 +10 -2
- package/api/theme-edit/_adapter.mjs +52 -31
- package/api/theme-edit/_check.d.mts +28 -25
- package/api/theme-edit/_check.mjs +586 -548
- package/api/theme-edit/_color.d.mts +28 -2
- package/api/theme-edit/_color.mjs +306 -68
- package/api/theme-edit/_compiler.d.mts +8 -4
- package/api/theme-edit/_compiler.mjs +30 -27
- package/api/theme-edit/_context.d.mts +10 -4
- package/api/theme-edit/_context.mjs +21 -4
- package/api/theme-edit/_edit.mjs +300 -43
- 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 +25 -17
- package/api/theme-edit/_how.mjs +727 -305
- package/api/theme-edit/_palette.d.mts +127 -19
- package/api/theme-edit/_palette.mjs +1313 -399
- package/api/theme-edit/_parts.mjs +36 -3
- 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 +26 -7
- package/api/theme-edit/_preview-app.mjs +1611 -280
- package/api/theme-edit/_preview.d.mts +4 -2
- package/api/theme-edit/_preview.mjs +18 -7
- package/api/theme-edit/_settings.d.mts +56 -5
- package/api/theme-edit/_settings.mjs +197 -49
- package/api/theme-edit/_tables.d.mts +0 -12
- package/api/theme-edit/_tables.mjs +24 -97
- package/api/theme-edit/theme-edit.type.d.mts +22 -5
- package/api/theme-edit/theme-edit.type.mjs +17 -6
- package/api/theme-edit/themeEditHow.doc.mjs +13 -3
- package/api/theme-edit/themeEditNew.doc.mjs +2 -1
- package/api/theme-edit/themeEditPreviewAdd.doc.mjs +16 -4
- package/api/theme-edit/themeEditPreviewApp.doc.mjs +12 -4
- package/api/theme-edit/themeEditPreviewList.doc.mjs +9 -1
- package/api/theme-edit/themeEditPreviewRemove.doc.mjs +27 -2
- package/api/theme-edit/themeEditUndo.doc.mjs +1 -1
- package/assets/docs.generated.json +1 -0
- package/assets/preview-app/gitignore +3 -0
- package/assets/templates/components.generated.json +1 -0
- package/clients/cli/bin/astryx.mjs +37 -5
- package/clients/cli/commands/experimental/theme.mjs +231 -31
- package/clients/cli/commands/experimental-theme-editor-how.doc.mjs +14 -5
- package/clients/cli/commands/experimental-theme-editor-new.doc.mjs +0 -1
- package/clients/cli/commands/experimental-theme-editor-undo.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 -2
- 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 +2 -2
- 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 +104 -40
- package/clients/cli/commands.generated.json +1 -0
- package/clients/cli/index.mjs +96 -4
- 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 +24 -1
- 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/package.json +6 -6
|
@@ -96,14 +96,20 @@ export function discoverUnmigratedThemeCopies(projectDir: string, owner?: string
|
|
|
96
96
|
* Discover and validate one theme root.
|
|
97
97
|
* @param {string} themeRoot absolute root containing one directory per slug
|
|
98
98
|
* @param {string} owner package that owns the root
|
|
99
|
-
* @param {{bundled?: boolean, allowUnmigrated?: boolean}} [options] a bundled root is the CLI's own; its
|
|
99
|
+
* @param {{bundled?: boolean, allowUnmigrated?: boolean, skip?: Set<string>, progress?: {slug?: string}}} [options] a bundled root is the CLI's own; its
|
|
100
100
|
* sources are checked by the CLI's tests rather than on every read. A local
|
|
101
101
|
* root may skip released source copies until `astryx upgrade` adds descriptors.
|
|
102
|
+
* `skip` names theme folders to leave out; `progress.slug` is set to the
|
|
103
|
+
* folder being read, so a caller can tell which folder an error is about.
|
|
102
104
|
* @returns {DiscoveredTheme[]}
|
|
103
105
|
*/
|
|
104
|
-
export function discoverThemeDirectory(themeRoot: string, owner: string, { bundled, allowUnmigrated }?: {
|
|
106
|
+
export function discoverThemeDirectory(themeRoot: string, owner: string, { bundled, allowUnmigrated, skip, progress }?: {
|
|
105
107
|
bundled?: boolean;
|
|
106
108
|
allowUnmigrated?: boolean;
|
|
109
|
+
skip?: Set<string>;
|
|
110
|
+
progress?: {
|
|
111
|
+
slug?: string;
|
|
112
|
+
};
|
|
107
113
|
}): DiscoveredTheme[];
|
|
108
114
|
/**
|
|
109
115
|
* Folders under a themes root that look like themes (see looksLikeTheme)
|
|
@@ -125,9 +131,14 @@ export function discoverBundledThemes(): DiscoveredTheme[];
|
|
|
125
131
|
* Discover authored themes in the app's conventional local themes root.
|
|
126
132
|
* @param {string} projectDir
|
|
127
133
|
* @param {string} [owner]
|
|
134
|
+
* @param {{onFolderError?: (slug: string, error: Error) => void}} [options]
|
|
135
|
+
* with `onFolderError`, a theme folder that fails validation is reported
|
|
136
|
+
* through it and left out, so one broken folder does not hide the others
|
|
128
137
|
* @returns {DiscoveredTheme[]}
|
|
129
138
|
*/
|
|
130
|
-
export function discoverLocalThemes(projectDir: string, owner?: string
|
|
139
|
+
export function discoverLocalThemes(projectDir: string, owner?: string, { onFolderError }?: {
|
|
140
|
+
onFolderError?: (slug: string, error: Error) => void;
|
|
141
|
+
}): DiscoveredTheme[];
|
|
131
142
|
/**
|
|
132
143
|
* @param {import('../integrations/integrations.mjs').LoadedIntegration} integration
|
|
133
144
|
* @returns {Promise<DiscoveredTheme[]>}
|
|
@@ -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
|
+
}
|
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",
|