@astryxdesign/cli 0.7.14 → 0.7.15-canary.g06b7e61
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +3 -3
- package/README.md +63 -63
- package/api/build/_adapter.d.mts +4 -0
- package/api/build/_adapter.mjs +28 -2
- package/api/build/blocks/blocks.d.mts +10 -1
- package/api/build/blocks/blocks.mjs +84 -7
- package/api/build/build.mjs +6 -1
- package/api/build/tree.d.mts +4 -0
- package/api/build/tree.mjs +9 -2
- package/api/doctor/_adapter.d.mts +3 -1
- package/api/doctor/_adapter.mjs +14 -1
- 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/doctor/theme-checks.mjs +56 -21
- package/api/integration/add-helpers.mjs +5 -0
- package/api/integration/add-theme.mjs +15 -110
- package/api/integration/validate-integration.mjs +17 -3
- package/api/integration/validateIntegration.doc.mjs +1 -1
- package/api/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.d.mts +37 -5
- package/api/theme/_adapter.mjs +381 -57
- package/api/theme/_fork.d.mts +90 -0
- package/api/theme/_fork.mjs +246 -0
- package/api/theme/build/build.d.mts +40 -2
- package/api/theme/build/build.mjs +477 -66
- package/api/theme/eject/eject.mjs +36 -15
- package/api/theme/list/list.mjs +3 -6
- package/api/theme/palette/generate/generator.d.mts +13 -0
- package/api/theme/palette/generate/generator.mjs +32 -2
- package/api/theme/targets/targets.d.mts +8 -0
- package/api/theme/targets/targets.mjs +24 -4
- package/api/theme/template/template.mjs +48 -2
- package/api/theme/theme.type.d.mts +8 -0
- package/api/theme/theme.type.mjs +5 -1
- package/api/theme/themeBuild.doc.mjs +7 -4
- package/api/theme/themeEject.doc.mjs +3 -3
- package/api/theme/themeRemove.doc.mjs +5 -2
- package/api/theme/themeTargets.doc.mjs +1 -1
- package/api/theme/themeTemplate.doc.mjs +2 -2
- package/api/theme/themeUse.doc.mjs +8 -2
- package/api/theme-edit/_adapter.d.mts +46 -3
- package/api/theme-edit/_adapter.mjs +496 -112
- package/api/theme-edit/_catalog.d.mts +1 -6
- package/api/theme-edit/_catalog.mjs +5 -268
- package/api/theme-edit/_check.d.mts +9 -4
- package/api/theme-edit/_check.mjs +1232 -229
- package/api/theme-edit/_color.d.mts +19 -0
- package/api/theme-edit/_color.mjs +280 -34
- package/api/theme-edit/_compiler.d.mts +3 -1
- package/api/theme-edit/_compiler.mjs +52 -13
- package/api/theme-edit/_context.d.mts +4 -1
- package/api/theme-edit/_context.mjs +126 -13
- package/api/theme-edit/_css.d.mts +84 -0
- package/api/theme-edit/_css.mjs +700 -0
- package/api/theme-edit/_edit.d.mts +9 -3
- package/api/theme-edit/_edit.mjs +806 -103
- package/api/theme-edit/_how-commands.d.mts +38 -7
- package/api/theme-edit/_how-commands.mjs +64 -45
- package/api/theme-edit/_how-question.d.mts +33 -0
- package/api/theme-edit/_how-question.mjs +2553 -381
- package/api/theme-edit/_how.mjs +402 -31
- package/api/theme-edit/_overview.mjs +2 -7
- package/api/theme-edit/_palette.d.mts +60 -13
- package/api/theme-edit/_palette.mjs +826 -295
- package/api/theme-edit/_parts.d.mts +42 -10
- package/api/theme-edit/_parts.mjs +280 -69
- 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 +14 -0
- package/api/theme-edit/_preview-app.mjs +1675 -235
- package/api/theme-edit/_preview.d.mts +7 -16
- package/api/theme-edit/_preview.mjs +79 -86
- package/api/theme-edit/_project.d.mts +32 -2
- package/api/theme-edit/_project.mjs +80 -19
- package/api/theme-edit/_settings.d.mts +199 -52
- package/api/theme-edit/_settings.mjs +1422 -217
- package/api/theme-edit/_tables.d.mts +19 -6
- package/api/theme-edit/_tables.mjs +150 -92
- package/api/theme-edit/theme-edit.type.d.mts +20 -1
- package/api/theme-edit/theme-edit.type.mjs +6 -3
- package/api/theme-edit/themeEditHow.doc.mjs +6 -0
- package/api/theme-edit/themeEditNew.doc.mjs +1 -1
- package/api/theme-edit/themeEditPreviewAdd.doc.mjs +1 -1
- package/api/theme-edit/themeEditPreviewApp.doc.mjs +1 -1
- package/api/theme-edit/themeEditPreviewList.doc.mjs +2 -2
- package/api/theme-edit/themeEditPreviewRemove.doc.mjs +5 -1
- package/api/theme-edit/themeEditSet.doc.mjs +1 -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/tree/checks.doc.mjs +22 -1
- package/assets/docs/tree/publishing.doc.mjs +1 -0
- package/assets/docs/tree/tokens-and-setup.doc.mjs +39 -3
- package/assets/docs.generated.json +2 -1
- package/assets/preview-app/next.config.mjs +7 -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/authoring/integration/integration.doc.mjs +8 -0
- package/authoring/integration/schema.d.mts +8 -0
- package/authoring/integration/schema.mjs +1 -0
- package/authoring/integration/type.ts +9 -0
- package/clients/cli/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/index.mjs +10 -10
- package/clients/cli/commands/experimental/theme.mjs +200 -81
- package/clients/cli/commands/experimental-theme-compile.doc.mjs +3 -3
- package/clients/cli/commands/experimental-theme-editor-how.doc.mjs +1 -1
- package/clients/cli/commands/experimental-theme-editor-new.doc.mjs +3 -3
- 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/integration.mjs +8 -0
- package/clients/cli/commands/manifest.mjs +5 -2
- package/clients/cli/commands/theme-build.doc.mjs +2 -2
- package/clients/cli/commands/theme-list.doc.mjs +1 -1
- package/clients/cli/commands/theme-template.doc.mjs +1 -1
- package/clients/cli/commands/theme.mjs +439 -66
- package/clients/cli/index.mjs +27 -6
- package/clients/cli/lib/cli-error.mjs +118 -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/config/project.mjs +34 -8
- package/foundation/config/theme-state.d.mts +16 -0
- package/foundation/config/theme-state.mjs +84 -13
- package/foundation/discovery/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 +19 -0
- package/foundation/discovery/template-needs.mjs +50 -16
- 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 +16 -10
- package/foundation/discovery/theme-imports.d.mts +16 -0
- package/foundation/discovery/theme-imports.mjs +30 -2
- 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 +22 -15
- 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 +783 -0
- package/foundation/fs/jiti-cache.d.mts +21 -0
- package/foundation/fs/jiti-cache.mjs +66 -0
- package/foundation/fs/module-loader.mjs +14 -3
- package/foundation/fs/read-record.d.mts +31 -1
- package/foundation/fs/read-record.mjs +100 -7
- package/foundation/integrations/autolink.d.mts +1 -24
- package/foundation/integrations/autolink.mjs +7 -60
- package/foundation/integrations/declared-dependencies.d.mts +27 -0
- package/foundation/integrations/declared-dependencies.mjs +73 -0
- package/foundation/integrations/integrations.d.mts +8 -0
- package/foundation/integrations/integrations.mjs +4 -0
- package/foundation/integrations/may-have-integrations.d.mts +8 -0
- package/foundation/integrations/may-have-integrations.mjs +47 -0
- package/foundation/integrations/validate-contributions.d.mts +62 -1
- package/foundation/integrations/validate-contributions.mjs +476 -40
- package/foundation/release/cache.d.mts +32 -4
- package/foundation/release/cache.mjs +105 -16
- package/foundation/release/folder-lock.d.mts +28 -0
- package/foundation/release/folder-lock.mjs +205 -0
- package/foundation/release/lock-lease.d.mts +2 -1
- package/foundation/release/lock-lease.mjs +7 -2
- package/foundation/response/error-codes.doc.mjs +1 -1
- package/foundation/response/response-types.doc.mjs +5 -5
- package/package.json +8 -6
- package/api/theme-edit/_css-properties.d.mts +0 -10
- package/api/theme-edit/_css-properties.mjs +0 -556
package/api/search/_entries.mjs
CHANGED
|
@@ -8,6 +8,16 @@
|
|
|
8
8
|
|
|
9
9
|
import {createHash} from 'node:crypto';
|
|
10
10
|
import {DOMAINS, words, fold, nameWords} from './_query-words.mjs';
|
|
11
|
+
import {fileURLToPath} from 'node:url';
|
|
12
|
+
import {persistedDerived} from '../../foundation/fs/gather-cache.mjs';
|
|
13
|
+
|
|
14
|
+
/** This module and the word rules it builds entries with, by path. */
|
|
15
|
+
const ENTRIES_FILE = fileURLToPath(import.meta.url);
|
|
16
|
+
const QUERY_WORDS_FILE = fileURLToPath(
|
|
17
|
+
new URL('./_query-words.mjs', import.meta.url),
|
|
18
|
+
);
|
|
19
|
+
/** The cards search reads (./_adapter.mjs), by path. */
|
|
20
|
+
const CARDS_FILE = fileURLToPath(new URL('./_cards.json', import.meta.url));
|
|
11
21
|
|
|
12
22
|
/** @param {string[]} list @returns {Map<string, number>} */
|
|
13
23
|
const counts = list => {
|
|
@@ -65,7 +75,16 @@ export function entryTable(all, cards) {
|
|
|
65
75
|
tables.set(all, last.table);
|
|
66
76
|
return last.table;
|
|
67
77
|
}
|
|
68
|
-
|
|
78
|
+
// The table is a function of the text it is built from: kept beside the
|
|
79
|
+
// catalog, a later run with the same catalog reads it back.
|
|
80
|
+
const built = persistedDerived(
|
|
81
|
+
['entry-table', key],
|
|
82
|
+
() => buildTable(all, cards),
|
|
83
|
+
tableCodec(all),
|
|
84
|
+
// The code that builds it, loaded or not when the table is kept, and the
|
|
85
|
+
// cards it reads, which search reads after the catalog is kept.
|
|
86
|
+
[ENTRIES_FILE, QUERY_WORDS_FILE, CARDS_FILE],
|
|
87
|
+
);
|
|
69
88
|
last = {key, table: built};
|
|
70
89
|
tables.set(all, built);
|
|
71
90
|
return built;
|
|
@@ -73,6 +92,54 @@ export function entryTable(all, cards) {
|
|
|
73
92
|
|
|
74
93
|
/** @type {{key: string, table: EntryTable} | null} */
|
|
75
94
|
let last = null;
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* A table's plain-JSON form and back. Candidates are kept as their place in
|
|
98
|
+
* `all`, maps as their entries in order, so the table reads back the same.
|
|
99
|
+
* @param {any[]} all
|
|
100
|
+
* @returns {{encode: (table: EntryTable) => any, decode: (stored: any) => EntryTable}}
|
|
101
|
+
*/
|
|
102
|
+
export function tableCodec(all) {
|
|
103
|
+
return {
|
|
104
|
+
encode(table) {
|
|
105
|
+
const place = new Map(all.map((c, k) => [c, k]));
|
|
106
|
+
const t = /** @type {any} */ (table);
|
|
107
|
+
return {
|
|
108
|
+
ids: t.ids,
|
|
109
|
+
candidate: t.candidate.map((/** @type {any} */ c) => place.get(c)),
|
|
110
|
+
domain: t.domain,
|
|
111
|
+
name: t.name,
|
|
112
|
+
fields: Object.fromEntries(
|
|
113
|
+
Object.entries(t.fields).map(([f, {post, idf, len, avg}]) => [
|
|
114
|
+
f,
|
|
115
|
+
{post: [...post], idf: [...idf], len, avg},
|
|
116
|
+
]),
|
|
117
|
+
),
|
|
118
|
+
};
|
|
119
|
+
},
|
|
120
|
+
decode(stored) {
|
|
121
|
+
return /** @type {EntryTable} */ (
|
|
122
|
+
/** @type {unknown} */ ({
|
|
123
|
+
ids: stored.ids,
|
|
124
|
+
index: new Map(
|
|
125
|
+
stored.ids.map(
|
|
126
|
+
(/** @type {string} */ id, /** @type {number} */ k) => [id, k],
|
|
127
|
+
),
|
|
128
|
+
),
|
|
129
|
+
candidate: stored.candidate.map((/** @type {number} */ k) => all[k]),
|
|
130
|
+
domain: stored.domain,
|
|
131
|
+
name: stored.name,
|
|
132
|
+
fields: Object.fromEntries(
|
|
133
|
+
Object.entries(stored.fields).map(([f, {post, idf, len, avg}]) => [
|
|
134
|
+
f,
|
|
135
|
+
{post: new Map(post), idf: new Map(idf), len, avg},
|
|
136
|
+
]),
|
|
137
|
+
),
|
|
138
|
+
})
|
|
139
|
+
);
|
|
140
|
+
},
|
|
141
|
+
};
|
|
142
|
+
}
|
|
76
143
|
/** @type {WeakMap<object, number>} */
|
|
77
144
|
const cardIds = new WeakMap();
|
|
78
145
|
let nextCardId = 0;
|
|
@@ -21,4 +21,15 @@ export function gatherTemplates(cwd: string): Promise<Candidate[]>;
|
|
|
21
21
|
* @returns {Promise<Candidate[]>}
|
|
22
22
|
*/
|
|
23
23
|
export function gatherThemes(cwd: string): Promise<Candidate[]>;
|
|
24
|
+
/**
|
|
25
|
+
* The source file each template candidate's `weakKeywords` are read from,
|
|
26
|
+
* when it could be read, and the names if this run already read them: a
|
|
27
|
+
* gather kept between runs stores the names it has and the file for the rest
|
|
28
|
+
* (api/search/_adapter.mjs), so storing costs no parse.
|
|
29
|
+
* @type {WeakMap<object, {file: string, derivedSoFar: () => string[] | undefined}>}
|
|
30
|
+
*/
|
|
31
|
+
export const derivedFromSource: WeakMap<object, {
|
|
32
|
+
file: string;
|
|
33
|
+
derivedSoFar: () => string[] | undefined;
|
|
34
|
+
}>;
|
|
24
35
|
export type Candidate = import("./_lexical.mjs").Candidate;
|
|
@@ -15,6 +15,14 @@ import {
|
|
|
15
15
|
} from '../../foundation/discovery/template-adapter.mjs';
|
|
16
16
|
import {sameWord, wordsOf} from './_words.mjs';
|
|
17
17
|
|
|
18
|
+
/**
|
|
19
|
+
* The source file each template candidate's `weakKeywords` are read from,
|
|
20
|
+
* when it could be read, and the names if this run already read them: a
|
|
21
|
+
* gather kept between runs stores the names it has and the file for the rest
|
|
22
|
+
* (api/search/_adapter.mjs), so storing costs no parse.
|
|
23
|
+
* @type {WeakMap<object, {file: string, derivedSoFar: () => string[] | undefined}>}
|
|
24
|
+
*/
|
|
25
|
+
export const derivedFromSource = new WeakMap();
|
|
18
26
|
/** @typedef {import('./_lexical.mjs').Candidate} Candidate */
|
|
19
27
|
|
|
20
28
|
/**
|
|
@@ -75,14 +83,20 @@ export async function gatherTemplates(cwd) {
|
|
|
75
83
|
let derive = () => [];
|
|
76
84
|
/** @type {string[] | null} */
|
|
77
85
|
let weakKeywordBound = null;
|
|
86
|
+
/** @type {string | null} */
|
|
87
|
+
let readSource = null;
|
|
88
|
+
/** @type {(() => string[] | undefined) | undefined} */
|
|
89
|
+
let derivedNow;
|
|
78
90
|
if (t.type === 'page') {
|
|
79
91
|
if (t.filePath) {
|
|
80
92
|
try {
|
|
81
93
|
const source = fs.readFileSync(t.filePath, 'utf-8');
|
|
94
|
+
readSource = t.filePath;
|
|
82
95
|
// Parsing the source costs more than the rest of the page's gather.
|
|
83
96
|
// It waits until a term could match a name the source can yield.
|
|
84
97
|
/** @type {string[] | undefined} */
|
|
85
98
|
let derived;
|
|
99
|
+
derivedNow = () => derived;
|
|
86
100
|
derive = () => {
|
|
87
101
|
if (derived === undefined) {
|
|
88
102
|
try {
|
|
@@ -101,8 +115,8 @@ export async function gatherTemplates(cwd) {
|
|
|
101
115
|
if (t.category)
|
|
102
116
|
keywords.push(...t.category.split(/[^A-Za-z0-9]+/).filter(Boolean));
|
|
103
117
|
}
|
|
104
|
-
|
|
105
|
-
domain: 'template',
|
|
118
|
+
const candidate = {
|
|
119
|
+
domain: /** @type {const} */ ('template'),
|
|
106
120
|
name: commandName,
|
|
107
121
|
keywords,
|
|
108
122
|
get weakKeywords() {
|
|
@@ -123,6 +137,12 @@ export async function gatherTemplates(cwd) {
|
|
|
123
137
|
_resultName: t.dirName,
|
|
124
138
|
_commandName: commandName,
|
|
125
139
|
};
|
|
140
|
+
if (readSource)
|
|
141
|
+
derivedFromSource.set(candidate, {
|
|
142
|
+
file: readSource,
|
|
143
|
+
derivedSoFar: () => derivedNow?.(),
|
|
144
|
+
});
|
|
145
|
+
return candidate;
|
|
126
146
|
});
|
|
127
147
|
}
|
|
128
148
|
|
package/api/search/_words.mjs
CHANGED
|
@@ -136,14 +136,34 @@ export function sameTermWord(t, w) {
|
|
|
136
136
|
* @returns {string[]}
|
|
137
137
|
*/
|
|
138
138
|
export function wordsOf(text) {
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
.
|
|
143
|
-
.
|
|
144
|
-
.
|
|
139
|
+
const key = String(text);
|
|
140
|
+
let words = splitWords.get(key);
|
|
141
|
+
if (words === undefined) {
|
|
142
|
+
// A long-running caller ranks many queries; start over rather than grow.
|
|
143
|
+
if (splitWords.size >= SPLIT_WORDS_LIMIT) splitWords.clear();
|
|
144
|
+
words = Object.freeze(
|
|
145
|
+
key
|
|
146
|
+
.replace(/([a-z0-9])([A-Z])/g, '$1 $2')
|
|
147
|
+
.replace(/([A-Z])([A-Z][a-z])/g, '$1 $2')
|
|
148
|
+
.toLowerCase()
|
|
149
|
+
.split(/[^a-z0-9]+/)
|
|
150
|
+
.filter(Boolean),
|
|
151
|
+
);
|
|
152
|
+
splitWords.set(key, words);
|
|
153
|
+
}
|
|
154
|
+
return /** @type {string[]} */ (words);
|
|
145
155
|
}
|
|
146
156
|
|
|
157
|
+
/**
|
|
158
|
+
* Each text's words, split once per process: a search splits the same names
|
|
159
|
+
* and keywords for every term of every query.
|
|
160
|
+
* @type {Map<string, readonly string[]>}
|
|
161
|
+
*/
|
|
162
|
+
const splitWords = new Map();
|
|
163
|
+
|
|
164
|
+
/** How many texts' words are kept before the cache starts over. */
|
|
165
|
+
const SPLIT_WORDS_LIMIT = 100_000;
|
|
166
|
+
|
|
147
167
|
/**
|
|
148
168
|
* Whether a term is found inside a name or keyword: it is one of its words, or
|
|
149
169
|
* the start of one (a truncation), and covers at least half of the whole
|
|
@@ -554,7 +554,7 @@ export async function swizzleCopy(component, options = {}) {
|
|
|
554
554
|
for (const dir of [...createdDirs].reverse()) {
|
|
555
555
|
fs.rmSync(dir, {recursive: true, force: true});
|
|
556
556
|
}
|
|
557
|
-
if (!outputDirExisted) {
|
|
557
|
+
if (!outputDirExisted && fs.existsSync(outputDir)) {
|
|
558
558
|
fs.rmSync(outputDir, {recursive: true, force: true});
|
|
559
559
|
}
|
|
560
560
|
throw writeFailed(output.dest, cwd, err, unrestored);
|
package/api/theme/_adapter.d.mts
CHANGED
|
@@ -6,6 +6,15 @@
|
|
|
6
6
|
* @param {import('../../foundation/discovery/theme-discovery.mjs').DiscoveredTheme} theme
|
|
7
7
|
*/
|
|
8
8
|
export function themeRecordOwner(theme: import("../../foundation/discovery/theme-discovery.mjs").DiscoveredTheme): string;
|
|
9
|
+
/**
|
|
10
|
+
* Whether `--package <name>` selects a theme. It takes either name the CLI
|
|
11
|
+
* shows for it: the package that provides it (`@astryxdesign/cli` for a
|
|
12
|
+
* bundled theme) or the package the app imports it from, which the record
|
|
13
|
+
* holds (`@astryxdesign/theme-butter`).
|
|
14
|
+
* @param {import('../../foundation/discovery/theme-discovery.mjs').DiscoveredTheme} theme
|
|
15
|
+
* @param {string | undefined} name
|
|
16
|
+
*/
|
|
17
|
+
export function themeInPackage(theme: import("../../foundation/discovery/theme-discovery.mjs").DiscoveredTheme, name: string | undefined): boolean;
|
|
9
18
|
/**
|
|
10
19
|
* A bundled theme entry kept for the historical public `listThemes()` helper.
|
|
11
20
|
* @typedef {Pick<import('../../foundation/discovery/theme-discovery.mjs').DiscoveredTheme, 'slug' | 'displayName' | 'description' | 'maintained' | 'entry' | 'exportName' | 'files'>} BundledTheme
|
|
@@ -66,14 +75,21 @@ export function listUnmigratedThemeCopies(cwd: string): import("../../foundation
|
|
|
66
75
|
/**
|
|
67
76
|
* Publish one theme's complete source inventory as an atomic local fork.
|
|
68
77
|
* @param {import('../../foundation/discovery/theme-discovery.mjs').DiscoveredTheme} theme
|
|
69
|
-
* @param {{cwd: string, targetPath?: string, overwrite?: boolean}} options
|
|
70
|
-
*
|
|
78
|
+
* @param {{cwd: string, targetPath?: string, overwrite?: boolean, takenSlugs?: Set<string>}} options
|
|
79
|
+
* `takenSlugs`: the slugs of the themes the project can use, which a fork's
|
|
80
|
+
* new folder name may not take
|
|
81
|
+
* @returns {{outputDir: string, files: string[]}} the project-relative output
|
|
82
|
+
* directory and the files written, named as the fork names them
|
|
71
83
|
*/
|
|
72
|
-
export function ejectThemeFiles(theme: import("../../foundation/discovery/theme-discovery.mjs").DiscoveredTheme, { cwd, targetPath, overwrite }: {
|
|
84
|
+
export function ejectThemeFiles(theme: import("../../foundation/discovery/theme-discovery.mjs").DiscoveredTheme, { cwd, targetPath: typedPath, overwrite, takenSlugs }: {
|
|
73
85
|
cwd: string;
|
|
74
86
|
targetPath?: string;
|
|
75
87
|
overwrite?: boolean;
|
|
76
|
-
|
|
88
|
+
takenSlugs?: Set<string>;
|
|
89
|
+
}): {
|
|
90
|
+
outputDir: string;
|
|
91
|
+
files: string[];
|
|
92
|
+
};
|
|
77
93
|
/**
|
|
78
94
|
* The packages the fork imports that the app does not declare. A fork that
|
|
79
95
|
* imports a missing package (bundled icon sets use `lucide-react`) fails to
|
|
@@ -91,14 +107,30 @@ export function forkNeeds(outputDir: string, files: string[], cwd: string): {
|
|
|
91
107
|
* Without an explicit package, a local theme shadows package themes that share
|
|
92
108
|
* its slug. Other duplicate slugs fail closed until the caller selects an owner.
|
|
93
109
|
* @param {string} [slug]
|
|
94
|
-
* @param {{cwd?: string, package?: string, includeLocal?: boolean}} [options]
|
|
110
|
+
* @param {{cwd?: string, package?: string, includeLocal?: boolean, command?: string}} [options]
|
|
111
|
+
* `command`: the command a refusal suggests running with `--package`,
|
|
112
|
+
* `theme add` by default
|
|
95
113
|
* @returns {Promise<import('../../foundation/discovery/theme-discovery.mjs').DiscoveredTheme | undefined>}
|
|
96
114
|
*/
|
|
97
115
|
export function findTheme(slug?: string, options?: {
|
|
98
116
|
cwd?: string;
|
|
99
117
|
package?: string;
|
|
100
118
|
includeLocal?: boolean;
|
|
119
|
+
command?: string;
|
|
101
120
|
}): Promise<import("../../foundation/discovery/theme-discovery.mjs").DiscoveredTheme | undefined>;
|
|
121
|
+
/**
|
|
122
|
+
* Runnable `<command> <slug>` suggestions for an unknown slug, closest names
|
|
123
|
+
* first; `--package` is named only where packages share a slug.
|
|
124
|
+
* @param {string} command such as `theme add`
|
|
125
|
+
* @param {string} slug what the person typed
|
|
126
|
+
* @param {import('../../foundation/discovery/theme-discovery.mjs').DiscoveredTheme[]} available
|
|
127
|
+
* @param {string} cwd
|
|
128
|
+
* @returns {Array<{theme: import('../../foundation/discovery/theme-discovery.mjs').DiscoveredTheme, name: string}>}
|
|
129
|
+
*/
|
|
130
|
+
export function themeCommandsFor(command: string, slug: string, available: import("../../foundation/discovery/theme-discovery.mjs").DiscoveredTheme[], cwd: string): Array<{
|
|
131
|
+
theme: import("../../foundation/discovery/theme-discovery.mjs").DiscoveredTheme;
|
|
132
|
+
name: string;
|
|
133
|
+
}>;
|
|
102
134
|
/**
|
|
103
135
|
* Read the generated module's app-theme record with stable CLI errors.
|
|
104
136
|
* @param {string} [cwd]
|