@astryxdesign/cli 0.7.15-canary.gf890983 → 0.7.15
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 +353 -3
- package/api/doctor/_adapter.d.mts +2 -1
- package/api/doctor/_adapter.mjs +6 -1
- package/api/doctor/doctor.mjs +2 -2
- 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/theme/_adapter.d.mts +37 -5
- package/api/theme/_adapter.mjs +363 -50
- package/api/theme/_fork.d.mts +90 -0
- package/api/theme/_fork.mjs +246 -0
- package/api/theme/build/build.d.mts +25 -1
- package/api/theme/build/build.mjs +352 -41
- 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.mjs +10 -3
- 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 +2 -2
- package/api/theme/themeRemove.doc.mjs +5 -2
- package/api/theme/themeTemplate.doc.mjs +2 -2
- package/api/theme/themeUse.doc.mjs +8 -2
- package/api/theme-edit/_adapter.mjs +157 -36
- package/api/theme-edit/_catalog.d.mts +1 -6
- package/api/theme-edit/_catalog.mjs +5 -268
- package/api/theme-edit/_check.d.mts +3 -1
- package/api/theme-edit/_check.mjs +733 -308
- package/api/theme-edit/_color.d.mts +19 -0
- package/api/theme-edit/_color.mjs +277 -33
- package/api/theme-edit/_compiler.d.mts +1 -0
- package/api/theme-edit/_compiler.mjs +25 -0
- package/api/theme-edit/_context.d.mts +2 -0
- package/api/theme-edit/_context.mjs +83 -9
- package/api/theme-edit/_css.d.mts +84 -0
- package/api/theme-edit/_css.mjs +700 -0
- package/api/theme-edit/_edit.mjs +370 -85
- package/api/theme-edit/_how-commands.d.mts +5 -0
- package/api/theme-edit/_how-commands.mjs +20 -13
- package/api/theme-edit/_how-question.d.mts +29 -0
- package/api/theme-edit/_how-question.mjs +1573 -182
- package/api/theme-edit/_how.mjs +306 -22
- package/api/theme-edit/_overview.mjs +2 -7
- package/api/theme-edit/_palette.d.mts +27 -5
- package/api/theme-edit/_palette.mjs +231 -97
- package/api/theme-edit/_parts.d.mts +42 -10
- package/api/theme-edit/_parts.mjs +224 -69
- package/api/theme-edit/_preview-app.d.mts +8 -0
- package/api/theme-edit/_preview-app.mjs +549 -96
- package/api/theme-edit/_preview.d.mts +7 -16
- package/api/theme-edit/_preview.mjs +77 -84
- package/api/theme-edit/_project.d.mts +20 -1
- package/api/theme-edit/_project.mjs +43 -13
- package/api/theme-edit/_settings.d.mts +96 -20
- package/api/theme-edit/_settings.mjs +646 -141
- package/api/theme-edit/_tables.d.mts +18 -12
- package/api/theme-edit/_tables.mjs +144 -147
- package/api/theme-edit/theme-edit.type.d.mts +10 -1
- package/api/theme-edit/theme-edit.type.mjs +3 -1
- 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/themeEditSet.doc.mjs +1 -1
- package/api/theme-edit/themeEditUndo.doc.mjs +1 -1
- package/assets/docs/tree/publishing.doc.mjs +1 -0
- package/assets/docs.generated.json +2 -2
- package/assets/self-audit.generated.json +1 -1
- package/clients/cli/build-id.generated.json +1 -1
- package/clients/cli/commands/experimental/index.mjs +10 -10
- package/clients/cli/commands/experimental/theme.mjs +22 -3
- package/clients/cli/commands/experimental-theme-compile.doc.mjs +2 -2
- package/clients/cli/commands/experimental-theme-editor-new.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/integration.mjs +8 -0
- 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 +325 -48
- package/clients/cli/index.mjs +18 -3
- package/clients/cli/lib/cli-error.mjs +118 -3
- package/clients/cli/manifest.generated.json +1 -1
- 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/template-needs.d.mts +13 -0
- package/foundation/discovery/template-needs.mjs +30 -15
- package/foundation/discovery/theme-discovery.mjs +14 -2
- package/foundation/discovery/theme-imports.d.mts +16 -0
- package/foundation/discovery/theme-imports.mjs +30 -2
- package/foundation/doc-compiler/import.mjs +10 -4
- package/foundation/fs/gather-cache.mjs +82 -23
- package/foundation/fs/jiti-cache.d.mts +21 -0
- package/foundation/fs/jiti-cache.mjs +66 -0
- package/foundation/fs/module-loader.mjs +7 -2
- 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/may-have-integrations.d.mts +8 -0
- package/foundation/integrations/may-have-integrations.mjs +47 -0
- package/foundation/release/cache.d.mts +21 -2
- package/foundation/release/cache.mjs +48 -8
- package/foundation/release/folder-lock.d.mts +7 -0
- package/foundation/release/folder-lock.mjs +60 -26
- 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 +4 -4
- package/package.json +6 -6
- package/api/theme-edit/_css-properties.d.mts +0 -10
- package/api/theme-edit/_css-properties.mjs +0 -556
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
// @generated by scripts/sync-api-types.mjs from the JSDoc in api/**/*.mjs.
|
|
2
|
+
// DO NOT EDIT — run `pnpm sync:api-types` to regenerate.
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* A theme name as the identifier `theme build` gives its export: each run
|
|
6
|
+
* of dashes goes, and the letter after it is capitalized.
|
|
7
|
+
* @param {string} name
|
|
8
|
+
*/
|
|
9
|
+
export function themeIdentifier(name: string): string;
|
|
10
|
+
/**
|
|
11
|
+
* The binding a theme named `name` exports, as `theme build` names it.
|
|
12
|
+
* @param {string} name
|
|
13
|
+
*/
|
|
14
|
+
export function themeBinding(name: string): string;
|
|
15
|
+
/**
|
|
16
|
+
* A new theme's names, from a checked kebab-case slug.
|
|
17
|
+
* @param {string} slug
|
|
18
|
+
*/
|
|
19
|
+
export function themeIdentity(slug: string): {
|
|
20
|
+
slug: string;
|
|
21
|
+
identifier: string;
|
|
22
|
+
displayName: string;
|
|
23
|
+
exportName: string;
|
|
24
|
+
entry: string;
|
|
25
|
+
descriptor: string;
|
|
26
|
+
};
|
|
27
|
+
/**
|
|
28
|
+
* Rename a file from the base theme's namespace to the new theme's namespace.
|
|
29
|
+
* Files whose name starts with the base identifier get the new identifier;
|
|
30
|
+
* others keep their name as-is.
|
|
31
|
+
* @param {string} file POSIX relative path inside the theme directory
|
|
32
|
+
* @param {string} baseIdentifier
|
|
33
|
+
* @param {string} newIdentifier
|
|
34
|
+
* @returns {string}
|
|
35
|
+
*/
|
|
36
|
+
export function renameThemeFile(file: string, baseIdentifier: string, newIdentifier: string): string;
|
|
37
|
+
/**
|
|
38
|
+
* Rewrite a source file's contents from the base theme's names to the new
|
|
39
|
+
* theme's names. This replaces:
|
|
40
|
+
* 1. Identifier prefixes (camelCase variables, import paths): baseIdentifier
|
|
41
|
+
* followed by an uppercase letter.
|
|
42
|
+
* 2. The theme slug in string literals: 'baseSlug' → 'newSlug' and
|
|
43
|
+
* 'astryx-baseSlug' → 'astryx-newSlug'.
|
|
44
|
+
* 3. CSS custom properties scoped to the theme: --astryx-theme-baseSlug-.
|
|
45
|
+
* @param {string} source
|
|
46
|
+
* @param {string} baseSlug
|
|
47
|
+
* @param {string} baseIdentifier
|
|
48
|
+
* @param {string} newSlug
|
|
49
|
+
* @param {string} newIdentifier
|
|
50
|
+
* @returns {string}
|
|
51
|
+
*/
|
|
52
|
+
export function rewriteThemeSource(source: string, baseSlug: string, baseIdentifier: string, newSlug: string, newIdentifier: string): string;
|
|
53
|
+
/**
|
|
54
|
+
* The theme source with its `defineTheme({...})` name set to `to`, wherever
|
|
55
|
+
* the `name` property sits in the object (after `extends`, under a
|
|
56
|
+
* comment), or null when no `defineTheme` call names a theme. Only that
|
|
57
|
+
* one string changes.
|
|
58
|
+
* @param {string} source
|
|
59
|
+
* @param {string} to
|
|
60
|
+
* @returns {string | null}
|
|
61
|
+
*/
|
|
62
|
+
export function renameDefinedTheme(source: string, to: string): string | null;
|
|
63
|
+
/**
|
|
64
|
+
* The file names of a fork: the theme's own, except that a fork named other
|
|
65
|
+
* than the theme names its entry and descriptor after its binding
|
|
66
|
+
* (`acmeOceanTheme.ts`, `acmeOceanTheme.doc.mjs`), as discovery reads them.
|
|
67
|
+
* @param {{slug: string, docPath: string, files: string[]}} theme
|
|
68
|
+
* @param {string} forkName
|
|
69
|
+
* @returns {string[]} in the order of theme.files
|
|
70
|
+
*/
|
|
71
|
+
export function forkFileNames(theme: {
|
|
72
|
+
slug: string;
|
|
73
|
+
docPath: string;
|
|
74
|
+
files: string[];
|
|
75
|
+
}, forkName: string): string[];
|
|
76
|
+
/**
|
|
77
|
+
* The theme entry renamed for a fork: its `defineTheme` name is the fork's,
|
|
78
|
+
* so the build writes `<fork>.css` and `<fork>.js`, and its export binding is
|
|
79
|
+
* the build's (`acmeOceanTheme`), the name discovery and `theme add` read.
|
|
80
|
+
* Refused when the entry names no theme to rename, since the fork would
|
|
81
|
+
* then build under the base theme's name.
|
|
82
|
+
* @param {string} contents
|
|
83
|
+
* @param {{slug: string, docPath: string}} theme
|
|
84
|
+
* @param {string} to
|
|
85
|
+
* @returns {string}
|
|
86
|
+
*/
|
|
87
|
+
export function renamedEntry(contents: string, theme: {
|
|
88
|
+
slug: string;
|
|
89
|
+
docPath: string;
|
|
90
|
+
}, to: string): string;
|
|
@@ -0,0 +1,246 @@
|
|
|
1
|
+
// Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @file The names a theme fork takes: its identity (slug, identifier,
|
|
5
|
+
* export binding, entry and descriptor file names), its renamed files, and
|
|
6
|
+
* its source rewritten from the base theme's names to the fork's.
|
|
7
|
+
*
|
|
8
|
+
* Shared by `theme eject` (api/theme/_adapter.mjs) and `integration add
|
|
9
|
+
* theme` (api/integration/add-theme.mjs), so the two forks name a theme the
|
|
10
|
+
* same way, and both the way `theme build` names its outputs.
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
import * as path from 'node:path';
|
|
14
|
+
import {parse} from '@babel/parser';
|
|
15
|
+
import {AstryxError} from '../error.mjs';
|
|
16
|
+
import {ERROR_CODES} from '../../foundation/response/error-codes.mjs';
|
|
17
|
+
import {
|
|
18
|
+
PathSafetyError,
|
|
19
|
+
sanitizeName,
|
|
20
|
+
} from '../../foundation/fs/path-safety.mjs';
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* A theme name as the identifier `theme build` gives its export: each run
|
|
24
|
+
* of dashes goes, and the letter after it is capitalized.
|
|
25
|
+
* @param {string} name
|
|
26
|
+
*/
|
|
27
|
+
export function themeIdentifier(name) {
|
|
28
|
+
return name.replace(/-+([a-z0-9])/gu, (_, c) => c.toUpperCase());
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* The binding a theme named `name` exports, as `theme build` names it.
|
|
33
|
+
* @param {string} name
|
|
34
|
+
*/
|
|
35
|
+
export function themeBinding(name) {
|
|
36
|
+
return `${themeIdentifier(name)}Theme`;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* A new theme's names, from a checked kebab-case slug.
|
|
41
|
+
* @param {string} slug
|
|
42
|
+
*/
|
|
43
|
+
export function themeIdentity(slug) {
|
|
44
|
+
try {
|
|
45
|
+
sanitizeName(slug, {label: 'theme name'});
|
|
46
|
+
} catch (error) {
|
|
47
|
+
if (error instanceof PathSafetyError) {
|
|
48
|
+
throw new AstryxError(
|
|
49
|
+
error.message,
|
|
50
|
+
undefined,
|
|
51
|
+
ERROR_CODES.ERR_INVALID_ARGUMENT,
|
|
52
|
+
);
|
|
53
|
+
}
|
|
54
|
+
throw error;
|
|
55
|
+
}
|
|
56
|
+
if (!/^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/u.test(slug)) {
|
|
57
|
+
throw new AstryxError(
|
|
58
|
+
`Invalid theme name "${slug}": use lowercase kebab-case starting with a letter.`,
|
|
59
|
+
undefined,
|
|
60
|
+
ERROR_CODES.ERR_INVALID_ARGUMENT,
|
|
61
|
+
);
|
|
62
|
+
}
|
|
63
|
+
const identifier = themeIdentifier(slug);
|
|
64
|
+
const displayName = slug
|
|
65
|
+
.split('-')
|
|
66
|
+
.map(part =>
|
|
67
|
+
part === 'y2k' ? 'Y2K' : part[0].toUpperCase() + part.slice(1),
|
|
68
|
+
)
|
|
69
|
+
.join(' ');
|
|
70
|
+
return {
|
|
71
|
+
slug,
|
|
72
|
+
identifier,
|
|
73
|
+
displayName,
|
|
74
|
+
exportName: `${identifier}Theme`,
|
|
75
|
+
entry: `${identifier}Theme.ts`,
|
|
76
|
+
descriptor: `${identifier}Theme.doc.mjs`,
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* Rename a file from the base theme's namespace to the new theme's namespace.
|
|
82
|
+
* Files whose name starts with the base identifier get the new identifier;
|
|
83
|
+
* others keep their name as-is.
|
|
84
|
+
* @param {string} file POSIX relative path inside the theme directory
|
|
85
|
+
* @param {string} baseIdentifier
|
|
86
|
+
* @param {string} newIdentifier
|
|
87
|
+
* @returns {string}
|
|
88
|
+
*/
|
|
89
|
+
export function renameThemeFile(file, baseIdentifier, newIdentifier) {
|
|
90
|
+
const basename = path.posix.basename(file);
|
|
91
|
+
const dir = path.posix.dirname(file);
|
|
92
|
+
if (!basename.startsWith(baseIdentifier)) return file;
|
|
93
|
+
const renamed = newIdentifier + basename.slice(baseIdentifier.length);
|
|
94
|
+
return dir === '.' ? renamed : `${dir}/${renamed}`;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
/** @param {string} s */
|
|
98
|
+
function escapeRegExp(s) {
|
|
99
|
+
return s.replace(/[.*+?^${}()|[\]\\]/gu, '\\$&');
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* Rewrite a source file's contents from the base theme's names to the new
|
|
104
|
+
* theme's names. This replaces:
|
|
105
|
+
* 1. Identifier prefixes (camelCase variables, import paths): baseIdentifier
|
|
106
|
+
* followed by an uppercase letter.
|
|
107
|
+
* 2. The theme slug in string literals: 'baseSlug' → 'newSlug' and
|
|
108
|
+
* 'astryx-baseSlug' → 'astryx-newSlug'.
|
|
109
|
+
* 3. CSS custom properties scoped to the theme: --astryx-theme-baseSlug-.
|
|
110
|
+
* @param {string} source
|
|
111
|
+
* @param {string} baseSlug
|
|
112
|
+
* @param {string} baseIdentifier
|
|
113
|
+
* @param {string} newSlug
|
|
114
|
+
* @param {string} newIdentifier
|
|
115
|
+
* @returns {string}
|
|
116
|
+
*/
|
|
117
|
+
export function rewriteThemeSource(
|
|
118
|
+
source,
|
|
119
|
+
baseSlug,
|
|
120
|
+
baseIdentifier,
|
|
121
|
+
newSlug,
|
|
122
|
+
newIdentifier,
|
|
123
|
+
) {
|
|
124
|
+
let result = source;
|
|
125
|
+
const identRe = new RegExp(`${escapeRegExp(baseIdentifier)}(?=[A-Z])`, 'gu');
|
|
126
|
+
result = result.replace(identRe, newIdentifier);
|
|
127
|
+
result = result.replace(
|
|
128
|
+
new RegExp(`'astryx-${escapeRegExp(baseSlug)}'`, 'gu'),
|
|
129
|
+
`'astryx-${newSlug}'`,
|
|
130
|
+
);
|
|
131
|
+
result = result.replace(
|
|
132
|
+
new RegExp(`'${escapeRegExp(baseSlug)}'`, 'gu'),
|
|
133
|
+
`'${newSlug}'`,
|
|
134
|
+
);
|
|
135
|
+
result = result.replace(
|
|
136
|
+
new RegExp(`--astryx-theme-${escapeRegExp(baseSlug)}-`, 'gu'),
|
|
137
|
+
`--astryx-theme-${newSlug}-`,
|
|
138
|
+
);
|
|
139
|
+
return result;
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
/**
|
|
143
|
+
* The theme source with its `defineTheme({...})` name set to `to`, wherever
|
|
144
|
+
* the `name` property sits in the object (after `extends`, under a
|
|
145
|
+
* comment), or null when no `defineTheme` call names a theme. Only that
|
|
146
|
+
* one string changes.
|
|
147
|
+
* @param {string} source
|
|
148
|
+
* @param {string} to
|
|
149
|
+
* @returns {string | null}
|
|
150
|
+
*/
|
|
151
|
+
export function renameDefinedTheme(source, to) {
|
|
152
|
+
/** @type {any} */
|
|
153
|
+
let ast;
|
|
154
|
+
try {
|
|
155
|
+
ast = parse(source, {
|
|
156
|
+
sourceType: 'module',
|
|
157
|
+
plugins: ['typescript', 'jsx'],
|
|
158
|
+
});
|
|
159
|
+
} catch {
|
|
160
|
+
return null;
|
|
161
|
+
}
|
|
162
|
+
/** @type {{start: number, end: number, quote: string} | null} */
|
|
163
|
+
let hit = null;
|
|
164
|
+
/** @param {any} node */
|
|
165
|
+
const visit = node => {
|
|
166
|
+
if (hit || !node || typeof node !== 'object') return;
|
|
167
|
+
if (
|
|
168
|
+
node.type === 'CallExpression' &&
|
|
169
|
+
node.callee?.type === 'Identifier' &&
|
|
170
|
+
node.callee.name === 'defineTheme' &&
|
|
171
|
+
node.arguments?.[0]?.type === 'ObjectExpression'
|
|
172
|
+
) {
|
|
173
|
+
const prop = node.arguments[0].properties.find(
|
|
174
|
+
(/** @type {any} */ p) =>
|
|
175
|
+
p.type === 'ObjectProperty' &&
|
|
176
|
+
!p.computed &&
|
|
177
|
+
((p.key.type === 'Identifier' && p.key.name === 'name') ||
|
|
178
|
+
(p.key.type === 'StringLiteral' && p.key.value === 'name')) &&
|
|
179
|
+
p.value.type === 'StringLiteral',
|
|
180
|
+
);
|
|
181
|
+
if (prop)
|
|
182
|
+
hit = {
|
|
183
|
+
start: prop.value.start,
|
|
184
|
+
end: prop.value.end,
|
|
185
|
+
quote: source[prop.value.start],
|
|
186
|
+
};
|
|
187
|
+
return;
|
|
188
|
+
}
|
|
189
|
+
for (const value of Object.values(node)) {
|
|
190
|
+
if (Array.isArray(value)) value.forEach(visit);
|
|
191
|
+
else if (value && typeof value === 'object' && value.type) visit(value);
|
|
192
|
+
}
|
|
193
|
+
};
|
|
194
|
+
visit(ast.program);
|
|
195
|
+
if (!hit) return null;
|
|
196
|
+
const {start, end, quote} = hit;
|
|
197
|
+
return `${source.slice(0, start)}${quote}${to}${quote}${source.slice(end)}`;
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
/**
|
|
201
|
+
* The file names of a fork: the theme's own, except that a fork named other
|
|
202
|
+
* than the theme names its entry and descriptor after its binding
|
|
203
|
+
* (`acmeOceanTheme.ts`, `acmeOceanTheme.doc.mjs`), as discovery reads them.
|
|
204
|
+
* @param {{slug: string, docPath: string, files: string[]}} theme
|
|
205
|
+
* @param {string} forkName
|
|
206
|
+
* @returns {string[]} in the order of theme.files
|
|
207
|
+
*/
|
|
208
|
+
export function forkFileNames(theme, forkName) {
|
|
209
|
+
if (forkName === theme.slug) return [...theme.files];
|
|
210
|
+
const docName = path.basename(theme.docPath);
|
|
211
|
+
const stem = docName.slice(0, -'.doc.mjs'.length);
|
|
212
|
+
const binding = themeBinding(forkName);
|
|
213
|
+
return theme.files.map(name =>
|
|
214
|
+
name === docName
|
|
215
|
+
? `${binding}.doc.mjs`
|
|
216
|
+
: name === theme.files[0] && path.basename(name).startsWith(`${stem}.`)
|
|
217
|
+
? path.join(path.dirname(name), binding + path.extname(name))
|
|
218
|
+
: name,
|
|
219
|
+
);
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
/**
|
|
223
|
+
* The theme entry renamed for a fork: its `defineTheme` name is the fork's,
|
|
224
|
+
* so the build writes `<fork>.css` and `<fork>.js`, and its export binding is
|
|
225
|
+
* the build's (`acmeOceanTheme`), the name discovery and `theme add` read.
|
|
226
|
+
* Refused when the entry names no theme to rename, since the fork would
|
|
227
|
+
* then build under the base theme's name.
|
|
228
|
+
* @param {string} contents
|
|
229
|
+
* @param {{slug: string, docPath: string}} theme
|
|
230
|
+
* @param {string} to
|
|
231
|
+
* @returns {string}
|
|
232
|
+
*/
|
|
233
|
+
export function renamedEntry(contents, theme, to) {
|
|
234
|
+
const stem = path.basename(theme.docPath).slice(0, -'.doc.mjs'.length);
|
|
235
|
+
const named = renameDefinedTheme(contents, to);
|
|
236
|
+
if (named == null)
|
|
237
|
+
throw new AstryxError(
|
|
238
|
+
`The entry of theme "${theme.slug}" names no theme in a defineTheme({name: ...}) call, so a fork named "${to}" would still build as "${theme.slug}". Fork it under its own name.`,
|
|
239
|
+
undefined,
|
|
240
|
+
ERROR_CODES.ERR_INVALID_ARGUMENT,
|
|
241
|
+
);
|
|
242
|
+
return named.replace(
|
|
243
|
+
new RegExp(`\\b${escapeRegExp(stem)}\\b`, 'gu'),
|
|
244
|
+
themeBinding(to),
|
|
245
|
+
);
|
|
246
|
+
}
|
|
@@ -43,11 +43,21 @@ export function coreUnavailableMessage(cwd: string, importError: any): string;
|
|
|
43
43
|
* the header and all real content — is compared verbatim. Used only by
|
|
44
44
|
* `--check`: a differing command must NOT report a file as stale, but any real
|
|
45
45
|
* content drift must. The `CLI:`/`Core:` provenance lines are deterministic
|
|
46
|
-
* for a given toolchain, so they compare verbatim like real content.
|
|
46
|
+
* for a given toolchain, so they compare verbatim like real content. CRLF
|
|
47
|
+
* line endings read as LF.
|
|
47
48
|
* @param {string} content
|
|
48
49
|
* @returns {string}
|
|
49
50
|
*/
|
|
50
51
|
export function normalizeThemeBuildForCompare(content: string): string;
|
|
52
|
+
/**
|
|
53
|
+
* The files a theme source is made of: the source and every local file it
|
|
54
|
+
* imports, directly or through other local files, read from their import
|
|
55
|
+
* statements. A watch rebuilds when any of them changes. Package imports and
|
|
56
|
+
* files that cannot be read are left out.
|
|
57
|
+
* @param {string} filePath absolute theme source
|
|
58
|
+
* @returns {string[]} absolute paths, the source first
|
|
59
|
+
*/
|
|
60
|
+
export function themeSourceFiles(filePath: string): string[];
|
|
51
61
|
/**
|
|
52
62
|
* Theme sources a missing build input probably meant, relative to `cwd`: the
|
|
53
63
|
* same path with `/` for `\`; or, for a bare theme name, the theme sources in
|
|
@@ -58,6 +68,14 @@ export function normalizeThemeBuildForCompare(content: string): string;
|
|
|
58
68
|
* @returns {string[]} at most three paths
|
|
59
69
|
*/
|
|
60
70
|
export function themeSourceGuesses(file: string, cwd: string): string[];
|
|
71
|
+
/**
|
|
72
|
+
* Publish the outputs a batch deferred, one theme at a time, in build order.
|
|
73
|
+
* @param {Array<Array<{dest: string, content: string}>>} deferred
|
|
74
|
+
*/
|
|
75
|
+
export function writeDeferredBuildOutputs(deferred: Array<Array<{
|
|
76
|
+
dest: string;
|
|
77
|
+
content: string;
|
|
78
|
+
}>>): void;
|
|
61
79
|
/**
|
|
62
80
|
* Import specifier for install/scaffold instructions. Drops a leading `src/`
|
|
63
81
|
* from the cwd-relative dir (most consumers import from a file under src/) but
|
|
@@ -68,6 +86,12 @@ export function themeSourceGuesses(file: string, cwd: string): string[];
|
|
|
68
86
|
* @returns {string}
|
|
69
87
|
*/
|
|
70
88
|
export function importSpecifier(relDir: string, base: string): string;
|
|
89
|
+
/**
|
|
90
|
+
* The package a theme load failed on because it is not installed.
|
|
91
|
+
* @param {unknown} error
|
|
92
|
+
* @returns {string | null}
|
|
93
|
+
*/
|
|
94
|
+
export function missingThemePackage(error: unknown): string | null;
|
|
71
95
|
/**
|
|
72
96
|
* Load one theme through the build's real module loader and validate the raw
|
|
73
97
|
* input captured from its defineTheme lineage. Used by doctor so it applies the
|