@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
|
@@ -18,7 +18,6 @@ import {ERROR_CODES} from '../../foundation/response/error-codes.mjs';
|
|
|
18
18
|
import {
|
|
19
19
|
assertWithin,
|
|
20
20
|
PathSafetyError,
|
|
21
|
-
sanitizeName,
|
|
22
21
|
} from '../../foundation/fs/path-safety.mjs';
|
|
23
22
|
import {
|
|
24
23
|
discoverBundledThemes,
|
|
@@ -46,47 +45,14 @@ import {
|
|
|
46
45
|
projectPath,
|
|
47
46
|
} from './add-helpers.mjs';
|
|
48
47
|
|
|
49
|
-
|
|
48
|
+
import {
|
|
49
|
+
renameDefinedTheme,
|
|
50
|
+
renameThemeFile,
|
|
51
|
+
rewriteThemeSource,
|
|
52
|
+
themeIdentity,
|
|
53
|
+
} from '../theme/_fork.mjs';
|
|
50
54
|
|
|
51
|
-
|
|
52
|
-
function themeIdentity(slug) {
|
|
53
|
-
try {
|
|
54
|
-
sanitizeName(slug, {label: 'theme name'});
|
|
55
|
-
} catch (error) {
|
|
56
|
-
if (error instanceof PathSafetyError) {
|
|
57
|
-
throw new AstryxError(
|
|
58
|
-
error.message,
|
|
59
|
-
undefined,
|
|
60
|
-
ERROR_CODES.ERR_INVALID_ARGUMENT,
|
|
61
|
-
);
|
|
62
|
-
}
|
|
63
|
-
throw error;
|
|
64
|
-
}
|
|
65
|
-
if (!/^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/u.test(slug)) {
|
|
66
|
-
throw new AstryxError(
|
|
67
|
-
`Invalid theme name "${slug}": use lowercase kebab-case starting with a letter.`,
|
|
68
|
-
undefined,
|
|
69
|
-
ERROR_CODES.ERR_INVALID_ARGUMENT,
|
|
70
|
-
);
|
|
71
|
-
}
|
|
72
|
-
const identifier = slug.replace(/-([a-z0-9])/gu, (_, character) =>
|
|
73
|
-
character.toUpperCase(),
|
|
74
|
-
);
|
|
75
|
-
const displayName = slug
|
|
76
|
-
.split('-')
|
|
77
|
-
.map(part =>
|
|
78
|
-
part === 'y2k' ? 'Y2K' : part[0].toUpperCase() + part.slice(1),
|
|
79
|
-
)
|
|
80
|
-
.join(' ');
|
|
81
|
-
return {
|
|
82
|
-
slug,
|
|
83
|
-
identifier,
|
|
84
|
-
displayName,
|
|
85
|
-
exportName: `${identifier}Theme`,
|
|
86
|
-
entry: `${identifier}Theme.ts`,
|
|
87
|
-
descriptor: `${identifier}Theme.doc.mjs`,
|
|
88
|
-
};
|
|
89
|
-
}
|
|
55
|
+
const DEFAULT_THEMES_ROOT = './themes';
|
|
90
56
|
|
|
91
57
|
/** @param {{slug: string, exportName: string}} identity */
|
|
92
58
|
function themeSource(identity) {
|
|
@@ -129,7 +95,10 @@ function resolveBaseTheme(slug, packageDir, owner, themesRoot) {
|
|
|
129
95
|
// Also check the package's own themes root.
|
|
130
96
|
if (themesRoot && fs.existsSync(themesRoot)) {
|
|
131
97
|
try {
|
|
132
|
-
candidates = [
|
|
98
|
+
candidates = [
|
|
99
|
+
...candidates,
|
|
100
|
+
...discoverThemeDirectory(themesRoot, owner),
|
|
101
|
+
];
|
|
133
102
|
} catch {
|
|
134
103
|
// A broken local root is not the caller's problem here.
|
|
135
104
|
}
|
|
@@ -149,74 +118,6 @@ function resolveBaseTheme(slug, packageDir, owner, themesRoot) {
|
|
|
149
118
|
return match;
|
|
150
119
|
}
|
|
151
120
|
|
|
152
|
-
/**
|
|
153
|
-
* Rename a file from the base theme's namespace to the new theme's namespace.
|
|
154
|
-
* Files whose name starts with the base identifier get the new identifier;
|
|
155
|
-
* others keep their name as-is.
|
|
156
|
-
* @param {string} file POSIX relative path inside the theme directory
|
|
157
|
-
* @param {string} baseIdentifier
|
|
158
|
-
* @param {string} newIdentifier
|
|
159
|
-
* @returns {string}
|
|
160
|
-
*/
|
|
161
|
-
function renameThemeFile(file, baseIdentifier, newIdentifier) {
|
|
162
|
-
const basename = path.posix.basename(file);
|
|
163
|
-
const dir = path.posix.dirname(file);
|
|
164
|
-
if (!basename.startsWith(baseIdentifier)) return file;
|
|
165
|
-
const renamed = newIdentifier + basename.slice(baseIdentifier.length);
|
|
166
|
-
return dir === '.' ? renamed : `${dir}/${renamed}`;
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
/**
|
|
170
|
-
* Rewrite a source file's contents from the base theme's names to the new
|
|
171
|
-
* theme's names. This replaces:
|
|
172
|
-
* 1. Identifier prefixes (camelCase variables, import paths): baseIdentifier
|
|
173
|
-
* followed by an uppercase letter.
|
|
174
|
-
* 2. The theme slug in string literals: 'baseSlug' → 'newSlug' and
|
|
175
|
-
* 'astryx-baseSlug' → 'astryx-newSlug'.
|
|
176
|
-
* 3. CSS custom properties scoped to the theme: --astryx-theme-baseSlug-.
|
|
177
|
-
* @param {string} source
|
|
178
|
-
* @param {string} baseSlug
|
|
179
|
-
* @param {string} baseIdentifier
|
|
180
|
-
* @param {string} newSlug
|
|
181
|
-
* @param {string} newIdentifier
|
|
182
|
-
* @returns {string}
|
|
183
|
-
*/
|
|
184
|
-
function rewriteThemeSource(
|
|
185
|
-
source,
|
|
186
|
-
baseSlug,
|
|
187
|
-
baseIdentifier,
|
|
188
|
-
newSlug,
|
|
189
|
-
newIdentifier,
|
|
190
|
-
) {
|
|
191
|
-
let result = source;
|
|
192
|
-
// 1. Identifier prefixes: neutralPalettes → oceanPalettes, neutralTheme → oceanTheme
|
|
193
|
-
const identRe = new RegExp(`${escapeRegExp(baseIdentifier)}(?=[A-Z])`, 'gu');
|
|
194
|
-
result = result.replace(identRe, newIdentifier);
|
|
195
|
-
// 2. String-literal theme names
|
|
196
|
-
result = result.replace(
|
|
197
|
-
new RegExp(`'astryx-${escapeRegExp(baseSlug)}'`, 'gu'),
|
|
198
|
-
`'astryx-${newSlug}'`,
|
|
199
|
-
);
|
|
200
|
-
result = result.replace(
|
|
201
|
-
new RegExp(`'${escapeRegExp(baseSlug)}'`, 'gu'),
|
|
202
|
-
`'${newSlug}'`,
|
|
203
|
-
);
|
|
204
|
-
// 3. CSS custom properties scoped to the base theme
|
|
205
|
-
result = result.replace(
|
|
206
|
-
new RegExp(
|
|
207
|
-
`--astryx-theme-${escapeRegExp(baseSlug)}-`,
|
|
208
|
-
'gu',
|
|
209
|
-
),
|
|
210
|
-
`--astryx-theme-${newSlug}-`,
|
|
211
|
-
);
|
|
212
|
-
return result;
|
|
213
|
-
}
|
|
214
|
-
|
|
215
|
-
/** @param {string} s */
|
|
216
|
-
function escapeRegExp(s) {
|
|
217
|
-
return s.replace(/[.*+?^${}()|[\]\\]/gu, '\\$&');
|
|
218
|
-
}
|
|
219
|
-
|
|
220
121
|
/** What every app that uses Astryx already has: Core, and React through Core's peers. */
|
|
221
122
|
const APP_PROVIDED = new Set(['@astryxdesign/core', 'react', 'react-dom']);
|
|
222
123
|
|
|
@@ -332,6 +233,10 @@ function forkThemePlans(base, identity, themeDir) {
|
|
|
332
233
|
identity.slug,
|
|
333
234
|
identity.identifier,
|
|
334
235
|
);
|
|
236
|
+
// The entry's defineTheme name, wherever it sits (a double-quoted name,
|
|
237
|
+
// one after `extends`), is the fork's, as the build names its files.
|
|
238
|
+
if (file === base.files[0])
|
|
239
|
+
contents = renameDefinedTheme(contents, identity.slug) ?? contents;
|
|
335
240
|
} else {
|
|
336
241
|
contents = bytes;
|
|
337
242
|
}
|
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]
|