@astryxdesign/cli 0.6.5-canary.5d9940d → 0.6.5-canary.5e7c207
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/api/integration/add-contribution.d.mts +1 -2
- package/api/integration/add-contribution.mjs +3 -7
- package/api/integration/add-theme.mjs +22 -243
- package/api/integration/add-theme.test.mjs +0 -213
- package/api/integration/integration-authoring.type.d.mts +1 -4
- package/api/integration/integration-authoring.type.mjs +1 -6
- package/api/integration/integrationAdd.doc.mjs +0 -6
- package/api/integration/integrationAddTheme.doc.mjs +0 -10
- package/api/theme/build/build.d.mts +0 -24
- package/api/theme/build/build.mjs +8 -235
- package/clients/cli/commands/integration-add.doc.mjs +0 -10
- package/clients/cli/commands/integration-authoring.test.mjs +2 -12
- package/clients/cli/commands/integration.mjs +1 -3
- package/foundation/doc-compiler/doc-loads.test.mjs +2 -2
- package/package.json +9 -9
- package/api/theme/build/build.project-core.test.mjs +0 -165
|
@@ -31,7 +31,7 @@ export function integrationAddAgentDoc(line: string, options?: import("./integra
|
|
|
31
31
|
*
|
|
32
32
|
* @param {'component'|'doc'|'template'|'codemod'|'agent-doc'|'theme'} kind
|
|
33
33
|
* @param {string} name
|
|
34
|
-
* @param {{cwd?: string, dryRun?: boolean, templateType?: 'page'|'block', to?: string, replaces?: string, extends?: string, parent?: string
|
|
34
|
+
* @param {{cwd?: string, dryRun?: boolean, templateType?: 'page'|'block', to?: string, replaces?: string, extends?: string, parent?: string}} [options]
|
|
35
35
|
* @returns {Promise<import('./integration-authoring.type.mjs').IntegrationAddResponse>}
|
|
36
36
|
*/
|
|
37
37
|
export function integrationAdd(kind: "component" | "doc" | "template" | "codemod" | "agent-doc" | "theme", name: string, options?: {
|
|
@@ -42,5 +42,4 @@ export function integrationAdd(kind: "component" | "doc" | "template" | "codemod
|
|
|
42
42
|
replaces?: string;
|
|
43
43
|
extends?: string;
|
|
44
44
|
parent?: string;
|
|
45
|
-
from?: string;
|
|
46
45
|
}): Promise<import("./integration-authoring.type.mjs").IntegrationAddResponse>;
|
|
@@ -1211,7 +1211,7 @@ const KIND_OPTIONS = {
|
|
|
1211
1211
|
template: new Set(['cwd', 'dryRun', 'templateType']),
|
|
1212
1212
|
codemod: new Set(['cwd', 'dryRun', 'to']),
|
|
1213
1213
|
'agent-doc': new Set(['cwd', 'dryRun']),
|
|
1214
|
-
theme: new Set(['cwd', 'dryRun'
|
|
1214
|
+
theme: new Set(['cwd', 'dryRun']),
|
|
1215
1215
|
};
|
|
1216
1216
|
|
|
1217
1217
|
/**
|
|
@@ -1238,7 +1238,7 @@ function validateKindOptions(kind, options) {
|
|
|
1238
1238
|
*
|
|
1239
1239
|
* @param {'component'|'doc'|'template'|'codemod'|'agent-doc'|'theme'} kind
|
|
1240
1240
|
* @param {string} name
|
|
1241
|
-
* @param {{cwd?: string, dryRun?: boolean, templateType?: 'page'|'block', to?: string, replaces?: string, extends?: string, parent?: string
|
|
1241
|
+
* @param {{cwd?: string, dryRun?: boolean, templateType?: 'page'|'block', to?: string, replaces?: string, extends?: string, parent?: string}} [options]
|
|
1242
1242
|
* @returns {Promise<import('./integration-authoring.type.mjs').IntegrationAddResponse>}
|
|
1243
1243
|
*/
|
|
1244
1244
|
export async function integrationAdd(kind, name, options = {}) {
|
|
@@ -1270,10 +1270,6 @@ export async function integrationAdd(kind, name, options = {}) {
|
|
|
1270
1270
|
case 'agent-doc':
|
|
1271
1271
|
return integrationAddAgentDoc(name, options);
|
|
1272
1272
|
case 'theme':
|
|
1273
|
-
return integrationAddTheme(name,
|
|
1274
|
-
cwd: options.cwd,
|
|
1275
|
-
dryRun: options.dryRun,
|
|
1276
|
-
from: options.from,
|
|
1277
|
-
});
|
|
1273
|
+
return integrationAddTheme(name, options);
|
|
1278
1274
|
}
|
|
1279
1275
|
}
|
|
@@ -4,9 +4,6 @@
|
|
|
4
4
|
* @file `astryx integration add theme` — scaffold one strongly typed,
|
|
5
5
|
* same-stem source/descriptor pair into an integration package and declare the
|
|
6
6
|
* themes root on first use.
|
|
7
|
-
*
|
|
8
|
-
* `--from <base>` forks an existing theme's source files as the starting point
|
|
9
|
-
* instead of writing a blank `defineTheme` skeleton.
|
|
10
7
|
*/
|
|
11
8
|
|
|
12
9
|
import * as fs from 'node:fs';
|
|
@@ -18,10 +15,7 @@ import {
|
|
|
18
15
|
PathSafetyError,
|
|
19
16
|
sanitizeName,
|
|
20
17
|
} from '../../foundation/fs/path-safety.mjs';
|
|
21
|
-
import {
|
|
22
|
-
discoverBundledThemes,
|
|
23
|
-
discoverThemeDirectory,
|
|
24
|
-
} from '../../foundation/discovery/theme-discovery.mjs';
|
|
18
|
+
import {discoverThemeDirectory} from '../../foundation/discovery/theme-discovery.mjs';
|
|
25
19
|
import {
|
|
26
20
|
findLocalIntegrationManifestOrNull,
|
|
27
21
|
IntegrationRootConflictError,
|
|
@@ -35,7 +29,6 @@ import {
|
|
|
35
29
|
themesCliProblem,
|
|
36
30
|
withCliPeer,
|
|
37
31
|
} from '../../foundation/integrations/cli-requirement.mjs';
|
|
38
|
-
import {stripCopyrightHeader} from '../../foundation/text/copyright-header.mjs';
|
|
39
32
|
import {
|
|
40
33
|
applyWrites,
|
|
41
34
|
findPackageDir,
|
|
@@ -77,7 +70,6 @@ function themeIdentity(slug) {
|
|
|
77
70
|
.join(' ');
|
|
78
71
|
return {
|
|
79
72
|
slug,
|
|
80
|
-
identifier,
|
|
81
73
|
displayName,
|
|
82
74
|
exportName: `${identifier}Theme`,
|
|
83
75
|
entry: `${identifier}Theme.ts`,
|
|
@@ -101,182 +93,6 @@ function themeDescriptor(identity) {
|
|
|
101
93
|
});
|
|
102
94
|
}
|
|
103
95
|
|
|
104
|
-
// ── --from: resolve and fork a base theme ───────────────────────────
|
|
105
|
-
|
|
106
|
-
/**
|
|
107
|
-
* Resolve a theme slug to its discovered record, searching the bundled themes
|
|
108
|
-
* and the package's own themes root (when it has one).
|
|
109
|
-
* @param {string} slug
|
|
110
|
-
* @param {string} packageDir
|
|
111
|
-
* @param {string} owner
|
|
112
|
-
* @param {string | undefined} themesRoot resolved absolute themes root, if any
|
|
113
|
-
* @returns {import('../../foundation/discovery/theme-discovery.mjs').DiscoveredTheme}
|
|
114
|
-
*/
|
|
115
|
-
function resolveBaseTheme(slug, packageDir, owner, themesRoot) {
|
|
116
|
-
const normalized = slug.toLowerCase();
|
|
117
|
-
|
|
118
|
-
/** @type {import('../../foundation/discovery/theme-discovery.mjs').DiscoveredTheme[]} */
|
|
119
|
-
let candidates = [];
|
|
120
|
-
try {
|
|
121
|
-
candidates = discoverBundledThemes();
|
|
122
|
-
} catch {
|
|
123
|
-
// Bundled themes unavailable — not fatal, package themes may suffice.
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
// Also check the package's own themes root.
|
|
127
|
-
if (themesRoot && fs.existsSync(themesRoot)) {
|
|
128
|
-
try {
|
|
129
|
-
candidates = [...candidates, ...discoverThemeDirectory(themesRoot, owner)];
|
|
130
|
-
} catch {
|
|
131
|
-
// A broken local root is not the caller's problem here.
|
|
132
|
-
}
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
const match = candidates.find(t => t.slug.toLowerCase() === normalized);
|
|
136
|
-
if (!match) {
|
|
137
|
-
throw new AstryxError(
|
|
138
|
-
`Unknown base theme "${slug}". Available themes: ${candidates.map(t => t.slug).join(', ') || '(none)'}.`,
|
|
139
|
-
candidates.map(t => ({
|
|
140
|
-
name: t.slug,
|
|
141
|
-
reason: t.bundled ? 'bundled theme' : `provided by ${t.package}`,
|
|
142
|
-
})),
|
|
143
|
-
ERROR_CODES.ERR_UNKNOWN_THEME,
|
|
144
|
-
);
|
|
145
|
-
}
|
|
146
|
-
return match;
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
/**
|
|
150
|
-
* Rename a file from the base theme's namespace to the new theme's namespace.
|
|
151
|
-
* Files whose name starts with the base identifier get the new identifier;
|
|
152
|
-
* others keep their name as-is.
|
|
153
|
-
* @param {string} file POSIX relative path inside the theme directory
|
|
154
|
-
* @param {string} baseIdentifier
|
|
155
|
-
* @param {string} newIdentifier
|
|
156
|
-
* @returns {string}
|
|
157
|
-
*/
|
|
158
|
-
function renameThemeFile(file, baseIdentifier, newIdentifier) {
|
|
159
|
-
const basename = path.posix.basename(file);
|
|
160
|
-
const dir = path.posix.dirname(file);
|
|
161
|
-
if (!basename.startsWith(baseIdentifier)) return file;
|
|
162
|
-
const renamed = newIdentifier + basename.slice(baseIdentifier.length);
|
|
163
|
-
return dir === '.' ? renamed : `${dir}/${renamed}`;
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
/**
|
|
167
|
-
* Rewrite a source file's contents from the base theme's names to the new
|
|
168
|
-
* theme's names. This replaces:
|
|
169
|
-
* 1. Identifier prefixes (camelCase variables, import paths): baseIdentifier
|
|
170
|
-
* followed by an uppercase letter.
|
|
171
|
-
* 2. The theme slug in string literals: 'baseSlug' → 'newSlug' and
|
|
172
|
-
* 'astryx-baseSlug' → 'astryx-newSlug'.
|
|
173
|
-
* 3. CSS custom properties scoped to the theme: --astryx-theme-baseSlug-.
|
|
174
|
-
* @param {string} source
|
|
175
|
-
* @param {string} baseSlug
|
|
176
|
-
* @param {string} baseIdentifier
|
|
177
|
-
* @param {string} newSlug
|
|
178
|
-
* @param {string} newIdentifier
|
|
179
|
-
* @returns {string}
|
|
180
|
-
*/
|
|
181
|
-
function rewriteThemeSource(
|
|
182
|
-
source,
|
|
183
|
-
baseSlug,
|
|
184
|
-
baseIdentifier,
|
|
185
|
-
newSlug,
|
|
186
|
-
newIdentifier,
|
|
187
|
-
) {
|
|
188
|
-
let result = source;
|
|
189
|
-
// 1. Identifier prefixes: neutralPalettes → oceanPalettes, neutralTheme → oceanTheme
|
|
190
|
-
const identRe = new RegExp(`${escapeRegExp(baseIdentifier)}(?=[A-Z])`, 'gu');
|
|
191
|
-
result = result.replace(identRe, newIdentifier);
|
|
192
|
-
// 2. String-literal theme names
|
|
193
|
-
result = result.replace(
|
|
194
|
-
new RegExp(`'astryx-${escapeRegExp(baseSlug)}'`, 'gu'),
|
|
195
|
-
`'astryx-${newSlug}'`,
|
|
196
|
-
);
|
|
197
|
-
result = result.replace(
|
|
198
|
-
new RegExp(`'${escapeRegExp(baseSlug)}'`, 'gu'),
|
|
199
|
-
`'${newSlug}'`,
|
|
200
|
-
);
|
|
201
|
-
// 3. CSS custom properties scoped to the base theme
|
|
202
|
-
result = result.replace(
|
|
203
|
-
new RegExp(
|
|
204
|
-
`--astryx-theme-${escapeRegExp(baseSlug)}-`,
|
|
205
|
-
'gu',
|
|
206
|
-
),
|
|
207
|
-
`--astryx-theme-${newSlug}-`,
|
|
208
|
-
);
|
|
209
|
-
return result;
|
|
210
|
-
}
|
|
211
|
-
|
|
212
|
-
/** @param {string} s */
|
|
213
|
-
function escapeRegExp(s) {
|
|
214
|
-
return s.replace(/[.*+?^${}()|[\]\\]/gu, '\\$&');
|
|
215
|
-
}
|
|
216
|
-
|
|
217
|
-
/**
|
|
218
|
-
* Build the write plans for a forked theme.
|
|
219
|
-
* @param {import('../../foundation/discovery/theme-discovery.mjs').DiscoveredTheme} base
|
|
220
|
-
* @param {ReturnType<typeof themeIdentity>} identity new theme identity
|
|
221
|
-
* @param {string} themeDir absolute target directory
|
|
222
|
-
* @returns {import('./add-helpers.mjs').WritePlan[]}
|
|
223
|
-
*/
|
|
224
|
-
function forkThemePlans(base, identity, themeDir) {
|
|
225
|
-
const baseIdentity = themeIdentity(base.slug);
|
|
226
|
-
/** @type {import('./add-helpers.mjs').WritePlan[]} */
|
|
227
|
-
const plans = [];
|
|
228
|
-
|
|
229
|
-
// Copy every file the base theme ships (entry first, then the rest), except
|
|
230
|
-
// the descriptor — we write a fresh one.
|
|
231
|
-
const filesToCopy = base.files.filter(
|
|
232
|
-
file => path.posix.basename(file) !== `${baseIdentity.exportName}.doc.mjs`,
|
|
233
|
-
);
|
|
234
|
-
|
|
235
|
-
for (const file of filesToCopy) {
|
|
236
|
-
const srcPath = path.join(base.sourceDir, file);
|
|
237
|
-
const newFileName = renameThemeFile(
|
|
238
|
-
file,
|
|
239
|
-
baseIdentity.identifier,
|
|
240
|
-
identity.identifier,
|
|
241
|
-
);
|
|
242
|
-
const destPath = assertWithin(newFileName, themeDir, {
|
|
243
|
-
label: `forked theme file "${newFileName}"`,
|
|
244
|
-
});
|
|
245
|
-
|
|
246
|
-
// Read source bytes; for text, strip copyright and rewrite identifiers.
|
|
247
|
-
const bytes = fs.readFileSync(srcPath);
|
|
248
|
-
const text = bytes.toString('utf-8');
|
|
249
|
-
const isText = Buffer.from(text, 'utf-8').equals(bytes);
|
|
250
|
-
|
|
251
|
-
/** @type {string | Buffer} */
|
|
252
|
-
let contents;
|
|
253
|
-
if (isText) {
|
|
254
|
-
contents = rewriteThemeSource(
|
|
255
|
-
stripCopyrightHeader(text),
|
|
256
|
-
base.slug,
|
|
257
|
-
baseIdentity.identifier,
|
|
258
|
-
identity.slug,
|
|
259
|
-
identity.identifier,
|
|
260
|
-
);
|
|
261
|
-
} else {
|
|
262
|
-
contents = bytes;
|
|
263
|
-
}
|
|
264
|
-
plans.push({path: destPath, contents, createOnly: true});
|
|
265
|
-
}
|
|
266
|
-
|
|
267
|
-
// Write a fresh descriptor — the fork is a new theme, not a derivative.
|
|
268
|
-
const descriptorPath = assertWithin(identity.descriptor, themeDir, {
|
|
269
|
-
label: 'theme descriptor file',
|
|
270
|
-
});
|
|
271
|
-
plans.push({
|
|
272
|
-
path: descriptorPath,
|
|
273
|
-
contents: themeDescriptor(identity),
|
|
274
|
-
createOnly: true,
|
|
275
|
-
});
|
|
276
|
-
|
|
277
|
-
return plans;
|
|
278
|
-
}
|
|
279
|
-
|
|
280
96
|
/**
|
|
281
97
|
* Read bytes back through the same discovery seam Project uses. A write is not
|
|
282
98
|
* successful until the requested slug resolves.
|
|
@@ -314,7 +130,7 @@ async function verifyThemeContribution(packageDir, manifestFile, owner, slug) {
|
|
|
314
130
|
* @returns {Promise<import('./integration-authoring.type.mjs').IntegrationAddResponse>}
|
|
315
131
|
*/
|
|
316
132
|
export async function integrationAddTheme(name, options = {}) {
|
|
317
|
-
const {cwd = process.cwd(), dryRun = false
|
|
133
|
+
const {cwd = process.cwd(), dryRun = false} = options;
|
|
318
134
|
const packageDir = findPackageDir(cwd);
|
|
319
135
|
const packageFile = path.join(packageDir, 'package.json');
|
|
320
136
|
let pkg;
|
|
@@ -396,64 +212,32 @@ export async function integrationAddTheme(name, options = {}) {
|
|
|
396
212
|
const themeDir = assertWithin(identity.slug, root, {
|
|
397
213
|
label: 'theme directory',
|
|
398
214
|
});
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
215
|
+
const sourceFile = assertWithin(identity.entry, themeDir, {
|
|
216
|
+
label: 'theme source file',
|
|
217
|
+
});
|
|
218
|
+
const descriptorFile = assertWithin(identity.descriptor, themeDir, {
|
|
219
|
+
label: 'theme descriptor file',
|
|
220
|
+
});
|
|
221
|
+
// An existing folder is filled; only a file this would write is refused.
|
|
222
|
+
for (const file of [sourceFile, descriptorFile]) {
|
|
223
|
+
if (fs.existsSync(file)) {
|
|
405
224
|
throw new AstryxError(
|
|
406
|
-
`
|
|
225
|
+
`Refusing to overwrite existing file ${projectPath(path.relative(packageDir, file))}.`,
|
|
407
226
|
undefined,
|
|
408
|
-
ERROR_CODES.
|
|
227
|
+
ERROR_CODES.ERR_FILE_EXISTS,
|
|
409
228
|
);
|
|
410
229
|
}
|
|
411
|
-
baseTheme = resolveBaseTheme(from, packageDir, owner, root);
|
|
412
230
|
}
|
|
413
231
|
|
|
414
232
|
/** @type {import('./add-helpers.mjs').WritePlan[]} */
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
throw new AstryxError(
|
|
424
|
-
`Refusing to overwrite existing file ${projectPath(path.relative(packageDir, plan.path))}.`,
|
|
425
|
-
undefined,
|
|
426
|
-
ERROR_CODES.ERR_FILE_EXISTS,
|
|
427
|
-
);
|
|
428
|
-
}
|
|
429
|
-
}
|
|
430
|
-
} else {
|
|
431
|
-
// Blank scaffold.
|
|
432
|
-
const sourceFile = assertWithin(identity.entry, themeDir, {
|
|
433
|
-
label: 'theme source file',
|
|
434
|
-
});
|
|
435
|
-
const descriptorFile = assertWithin(identity.descriptor, themeDir, {
|
|
436
|
-
label: 'theme descriptor file',
|
|
437
|
-
});
|
|
438
|
-
for (const file of [sourceFile, descriptorFile]) {
|
|
439
|
-
if (fs.existsSync(file)) {
|
|
440
|
-
throw new AstryxError(
|
|
441
|
-
`Refusing to overwrite existing file ${projectPath(path.relative(packageDir, file))}.`,
|
|
442
|
-
undefined,
|
|
443
|
-
ERROR_CODES.ERR_FILE_EXISTS,
|
|
444
|
-
);
|
|
445
|
-
}
|
|
446
|
-
}
|
|
447
|
-
plans = [
|
|
448
|
-
{path: sourceFile, contents: themeSource(identity), createOnly: true},
|
|
449
|
-
{
|
|
450
|
-
path: descriptorFile,
|
|
451
|
-
contents: themeDescriptor(identity),
|
|
452
|
-
createOnly: true,
|
|
453
|
-
},
|
|
454
|
-
];
|
|
455
|
-
}
|
|
456
|
-
|
|
233
|
+
const plans = [
|
|
234
|
+
{path: sourceFile, contents: themeSource(identity), createOnly: true},
|
|
235
|
+
{
|
|
236
|
+
path: descriptorFile,
|
|
237
|
+
contents: themeDescriptor(identity),
|
|
238
|
+
createOnly: true,
|
|
239
|
+
},
|
|
240
|
+
];
|
|
457
241
|
let packageUpdate = packageJsonUpdate(
|
|
458
242
|
packageFile,
|
|
459
243
|
rootPath,
|
|
@@ -525,8 +309,7 @@ export async function integrationAddTheme(name, options = {}) {
|
|
|
525
309
|
writtenFiles.push(manifestPath);
|
|
526
310
|
}
|
|
527
311
|
|
|
528
|
-
|
|
529
|
-
const response = {
|
|
312
|
+
return {
|
|
530
313
|
type: 'integration.add',
|
|
531
314
|
data: {
|
|
532
315
|
kind: 'theme',
|
|
@@ -538,8 +321,4 @@ export async function integrationAddTheme(name, options = {}) {
|
|
|
538
321
|
dryRun,
|
|
539
322
|
},
|
|
540
323
|
};
|
|
541
|
-
if (from != null) {
|
|
542
|
-
response.data.from = from;
|
|
543
|
-
}
|
|
544
|
-
return response;
|
|
545
324
|
}
|
|
@@ -310,216 +310,3 @@ describe('integrationAddTheme', () => {
|
|
|
310
310
|
);
|
|
311
311
|
});
|
|
312
312
|
});
|
|
313
|
-
|
|
314
|
-
describe('integrationAddTheme --from', () => {
|
|
315
|
-
it('forks a bundled theme into the integration package', async () => {
|
|
316
|
-
setup();
|
|
317
|
-
const result = await integrationAddTheme('ocean', {
|
|
318
|
-
cwd: tmpDir,
|
|
319
|
-
from: 'neutral',
|
|
320
|
-
});
|
|
321
|
-
|
|
322
|
-
expect(result.type).toBe('integration.add');
|
|
323
|
-
expect(result.data.kind).toBe('theme');
|
|
324
|
-
expect(result.data.name).toBe('ocean');
|
|
325
|
-
expect(result.data.from).toBe('neutral');
|
|
326
|
-
expect(result.data.written).toBe(true);
|
|
327
|
-
expect(result.data.dryRun).toBe(false);
|
|
328
|
-
expect(result.data.root).toEqual({path: './themes', created: true});
|
|
329
|
-
|
|
330
|
-
// The entry file must exist with the new export name.
|
|
331
|
-
const entry = fs.readFileSync(
|
|
332
|
-
path.join(tmpDir, 'themes/ocean/oceanTheme.ts'),
|
|
333
|
-
'utf-8',
|
|
334
|
-
);
|
|
335
|
-
expect(entry).toContain('oceanTheme');
|
|
336
|
-
expect(entry).toContain("name: 'ocean'");
|
|
337
|
-
// It must NOT contain the original theme identifier as a prefix.
|
|
338
|
-
expect(entry).not.toMatch(/\bneutralTheme\b/);
|
|
339
|
-
expect(entry).not.toMatch(/\bneutralPalettes\b/);
|
|
340
|
-
expect(entry).not.toMatch(/\bneutralSyntax\b/);
|
|
341
|
-
expect(entry).toContain('defineTheme');
|
|
342
|
-
|
|
343
|
-
// A fresh descriptor, not copied from the base.
|
|
344
|
-
const descriptor = fs.readFileSync(
|
|
345
|
-
path.join(tmpDir, 'themes/ocean/oceanTheme.doc.mjs'),
|
|
346
|
-
'utf-8',
|
|
347
|
-
);
|
|
348
|
-
expect(descriptor).toContain("name: 'ocean'");
|
|
349
|
-
expect(descriptor).toContain("@astryxdesign/cli/authoring').ThemeDoc");
|
|
350
|
-
expect(descriptor).toContain('maintained: true');
|
|
351
|
-
|
|
352
|
-
// The theme must validate.
|
|
353
|
-
expect((await validateLocalIntegration(tmpDir)).issues).toEqual([]);
|
|
354
|
-
});
|
|
355
|
-
|
|
356
|
-
it('renames palette and support files from the base theme', async () => {
|
|
357
|
-
setup();
|
|
358
|
-
await integrationAddTheme('ocean', {cwd: tmpDir, from: 'neutral'});
|
|
359
|
-
|
|
360
|
-
const themeDir = path.join(tmpDir, 'themes/ocean');
|
|
361
|
-
const files = fs.readdirSync(themeDir).sort();
|
|
362
|
-
// neutralPalettes.ts → oceanPalettes.ts, etc.
|
|
363
|
-
expect(files).toContain('oceanTheme.ts');
|
|
364
|
-
expect(files).toContain('oceanTheme.doc.mjs');
|
|
365
|
-
expect(files).toContain('oceanPalettes.ts');
|
|
366
|
-
expect(files).toContain('oceanPaletteRefs.generated.ts');
|
|
367
|
-
expect(files).toContain('icons.tsx');
|
|
368
|
-
// Must not contain any file starting with 'neutral'.
|
|
369
|
-
expect(files.filter(f => f.startsWith('neutral'))).toEqual([]);
|
|
370
|
-
});
|
|
371
|
-
|
|
372
|
-
it('rewrites import paths inside forked files', async () => {
|
|
373
|
-
setup();
|
|
374
|
-
await integrationAddTheme('ocean', {cwd: tmpDir, from: 'neutral'});
|
|
375
|
-
|
|
376
|
-
const entry = fs.readFileSync(
|
|
377
|
-
path.join(tmpDir, 'themes/ocean/oceanTheme.ts'),
|
|
378
|
-
'utf-8',
|
|
379
|
-
);
|
|
380
|
-
// Import references must use the new identifier.
|
|
381
|
-
expect(entry).toContain('./oceanPaletteRefs.generated');
|
|
382
|
-
expect(entry).not.toContain('./neutralPaletteRefs.generated');
|
|
383
|
-
// The icon registry import must also be renamed.
|
|
384
|
-
expect(entry).toContain('oceanIconRegistry');
|
|
385
|
-
expect(entry).not.toContain('neutralIconRegistry');
|
|
386
|
-
});
|
|
387
|
-
|
|
388
|
-
it('rewrites CSS custom properties scoped to the base theme', async () => {
|
|
389
|
-
setup();
|
|
390
|
-
await integrationAddTheme('ocean', {cwd: tmpDir, from: 'neutral'});
|
|
391
|
-
|
|
392
|
-
const entry = fs.readFileSync(
|
|
393
|
-
path.join(tmpDir, 'themes/ocean/oceanTheme.ts'),
|
|
394
|
-
'utf-8',
|
|
395
|
-
);
|
|
396
|
-
expect(entry).toContain('--astryx-theme-ocean-');
|
|
397
|
-
expect(entry).not.toContain('--astryx-theme-neutral-');
|
|
398
|
-
});
|
|
399
|
-
|
|
400
|
-
it('rewrites the syntax theme name', async () => {
|
|
401
|
-
setup();
|
|
402
|
-
await integrationAddTheme('ocean', {cwd: tmpDir, from: 'neutral'});
|
|
403
|
-
|
|
404
|
-
const entry = fs.readFileSync(
|
|
405
|
-
path.join(tmpDir, 'themes/ocean/oceanTheme.ts'),
|
|
406
|
-
'utf-8',
|
|
407
|
-
);
|
|
408
|
-
expect(entry).toContain("'astryx-ocean'");
|
|
409
|
-
expect(entry).not.toContain("'astryx-neutral'");
|
|
410
|
-
});
|
|
411
|
-
|
|
412
|
-
it('strips the copyright header from forked files', async () => {
|
|
413
|
-
setup();
|
|
414
|
-
await integrationAddTheme('ocean', {cwd: tmpDir, from: 'neutral'});
|
|
415
|
-
|
|
416
|
-
const entry = fs.readFileSync(
|
|
417
|
-
path.join(tmpDir, 'themes/ocean/oceanTheme.ts'),
|
|
418
|
-
'utf-8',
|
|
419
|
-
);
|
|
420
|
-
expect(entry).not.toContain('Copyright (c) Meta Platforms');
|
|
421
|
-
});
|
|
422
|
-
|
|
423
|
-
it('includes data.from in the receipt only when --from is used', async () => {
|
|
424
|
-
setup();
|
|
425
|
-
const blank = await integrationAddTheme('plain', {cwd: tmpDir});
|
|
426
|
-
expect(blank.data).not.toHaveProperty('from');
|
|
427
|
-
|
|
428
|
-
const forked = await integrationAddTheme('ocean', {
|
|
429
|
-
cwd: tmpDir,
|
|
430
|
-
from: 'neutral',
|
|
431
|
-
});
|
|
432
|
-
expect(forked.data.from).toBe('neutral');
|
|
433
|
-
});
|
|
434
|
-
|
|
435
|
-
it('refuses to fork a theme into itself', async () => {
|
|
436
|
-
setup();
|
|
437
|
-
await expect(
|
|
438
|
-
integrationAddTheme('neutral', {cwd: tmpDir, from: 'neutral'}),
|
|
439
|
-
).rejects.toMatchObject({code: 'ERR_INVALID_ARGUMENT'});
|
|
440
|
-
});
|
|
441
|
-
|
|
442
|
-
it('refuses an unknown base theme with a helpful suggestion list', async () => {
|
|
443
|
-
setup();
|
|
444
|
-
await expect(
|
|
445
|
-
integrationAddTheme('ocean', {cwd: tmpDir, from: 'nonexistent'}),
|
|
446
|
-
).rejects.toMatchObject({
|
|
447
|
-
code: 'ERR_UNKNOWN_THEME',
|
|
448
|
-
message: expect.stringContaining('nonexistent'),
|
|
449
|
-
});
|
|
450
|
-
});
|
|
451
|
-
|
|
452
|
-
it('dry-runs with --from without writing anything', async () => {
|
|
453
|
-
setup();
|
|
454
|
-
const result = await integrationAddTheme('ocean', {
|
|
455
|
-
cwd: tmpDir,
|
|
456
|
-
from: 'neutral',
|
|
457
|
-
dryRun: true,
|
|
458
|
-
});
|
|
459
|
-
|
|
460
|
-
expect(result.data.written).toBe(false);
|
|
461
|
-
expect(result.data.dryRun).toBe(true);
|
|
462
|
-
expect(result.data.from).toBe('neutral');
|
|
463
|
-
expect(result.data.files).toContain('themes/ocean/oceanTheme.ts');
|
|
464
|
-
expect(result.data.files).toContain('themes/ocean/oceanTheme.doc.mjs');
|
|
465
|
-
expect(fs.existsSync(path.join(tmpDir, 'themes'))).toBe(false);
|
|
466
|
-
});
|
|
467
|
-
|
|
468
|
-
it('refuses to overwrite when the target already exists', async () => {
|
|
469
|
-
setup();
|
|
470
|
-
await integrationAddTheme('ocean', {cwd: tmpDir, from: 'neutral'});
|
|
471
|
-
await expect(
|
|
472
|
-
integrationAddTheme('ocean', {cwd: tmpDir, from: 'neutral'}),
|
|
473
|
-
).rejects.toMatchObject({code: 'ERR_FILE_EXISTS'});
|
|
474
|
-
});
|
|
475
|
-
|
|
476
|
-
it('works with different bundled themes', async () => {
|
|
477
|
-
setup();
|
|
478
|
-
const result = await integrationAddTheme('dusk', {
|
|
479
|
-
cwd: tmpDir,
|
|
480
|
-
from: 'gothic',
|
|
481
|
-
});
|
|
482
|
-
|
|
483
|
-
expect(result.data.from).toBe('gothic');
|
|
484
|
-
const entry = fs.readFileSync(
|
|
485
|
-
path.join(tmpDir, 'themes/dusk/duskTheme.ts'),
|
|
486
|
-
'utf-8',
|
|
487
|
-
);
|
|
488
|
-
expect(entry).toContain('duskTheme');
|
|
489
|
-
expect(entry).toContain("name: 'dusk'");
|
|
490
|
-
expect(entry).not.toMatch(/\bgothicTheme\b/);
|
|
491
|
-
expect((await validateLocalIntegration(tmpDir)).issues).toEqual([]);
|
|
492
|
-
});
|
|
493
|
-
|
|
494
|
-
it('forks from a theme the package already owns', async () => {
|
|
495
|
-
setup();
|
|
496
|
-
// First, add a blank theme.
|
|
497
|
-
await integrationAddTheme('base', {cwd: tmpDir});
|
|
498
|
-
// Then fork it.
|
|
499
|
-
const result = await integrationAddTheme('variant', {
|
|
500
|
-
cwd: tmpDir,
|
|
501
|
-
from: 'base',
|
|
502
|
-
});
|
|
503
|
-
|
|
504
|
-
expect(result.data.from).toBe('base');
|
|
505
|
-
const entry = fs.readFileSync(
|
|
506
|
-
path.join(tmpDir, 'themes/variant/variantTheme.ts'),
|
|
507
|
-
'utf-8',
|
|
508
|
-
);
|
|
509
|
-
expect(entry).toContain('variantTheme');
|
|
510
|
-
expect(entry).toContain("name: 'variant'");
|
|
511
|
-
expect((await validateLocalIntegration(tmpDir)).issues).toEqual([]);
|
|
512
|
-
});
|
|
513
|
-
|
|
514
|
-
it('declares the optional CLI peer that reads typed theme descriptors', async () => {
|
|
515
|
-
setup({includeFiles: false});
|
|
516
|
-
await integrationAddTheme('ocean', {cwd: tmpDir, from: 'neutral'});
|
|
517
|
-
const pkg = JSON.parse(
|
|
518
|
-
fs.readFileSync(path.join(tmpDir, 'package.json'), 'utf-8'),
|
|
519
|
-
);
|
|
520
|
-
expect(pkg.peerDependencies).toEqual({'@astryxdesign/cli': '>=0.6.4'});
|
|
521
|
-
expect(pkg.peerDependenciesMeta).toEqual({
|
|
522
|
-
'@astryxdesign/cli': {optional: true},
|
|
523
|
-
});
|
|
524
|
-
});
|
|
525
|
-
});
|
|
@@ -19,9 +19,7 @@ export type IntegrationAddCodemodOptions = IntegrationAddBaseOptions & {
|
|
|
19
19
|
to: string;
|
|
20
20
|
};
|
|
21
21
|
export type IntegrationAddAgentDocOptions = IntegrationAddBaseOptions;
|
|
22
|
-
export type IntegrationAddThemeOptions = IntegrationAddBaseOptions
|
|
23
|
-
from?: string;
|
|
24
|
-
};
|
|
22
|
+
export type IntegrationAddThemeOptions = IntegrationAddBaseOptions;
|
|
25
23
|
/**
|
|
26
24
|
* Options for the generic `integrationAdd` dispatcher. Prefer a per-kind API
|
|
27
25
|
* when the contribution kind is known so the accepted options stay narrow.
|
|
@@ -56,5 +54,4 @@ export type IntegrationAddData = {
|
|
|
56
54
|
files: string[];
|
|
57
55
|
written: boolean;
|
|
58
56
|
dryRun: boolean;
|
|
59
|
-
from?: string | undefined;
|
|
60
57
|
};
|
|
@@ -37,11 +37,7 @@
|
|
|
37
37
|
*/
|
|
38
38
|
|
|
39
39
|
/** @typedef {IntegrationAddBaseOptions} IntegrationAddAgentDocOptions */
|
|
40
|
-
/**
|
|
41
|
-
* @typedef {IntegrationAddBaseOptions & {
|
|
42
|
-
* from?: string,
|
|
43
|
-
* }} IntegrationAddThemeOptions
|
|
44
|
-
*/
|
|
40
|
+
/** @typedef {IntegrationAddBaseOptions} IntegrationAddThemeOptions */
|
|
45
41
|
|
|
46
42
|
/**
|
|
47
43
|
* Options for the generic `integrationAdd` dispatcher. Prefer a per-kind API
|
|
@@ -77,7 +73,6 @@
|
|
|
77
73
|
* @property {string[]} files
|
|
78
74
|
* @property {boolean} written
|
|
79
75
|
* @property {boolean} dryRun
|
|
80
|
-
* @property {string} [from]
|
|
81
76
|
*/
|
|
82
77
|
|
|
83
78
|
export {};
|
|
@@ -78,12 +78,6 @@ export const doc = {
|
|
|
78
78
|
type: 'string',
|
|
79
79
|
description: 'Exact target semver (e.g. 1.2.0). Required for codemod and only valid there.',
|
|
80
80
|
},
|
|
81
|
-
{
|
|
82
|
-
name: 'options.from',
|
|
83
|
-
type: 'string',
|
|
84
|
-
description:
|
|
85
|
-
'Slug of an existing theme to fork as the starting point. Only valid for theme.',
|
|
86
|
-
},
|
|
87
81
|
],
|
|
88
82
|
returns: [
|
|
89
83
|
{
|
|
@@ -33,12 +33,6 @@ export const doc = {
|
|
|
33
33
|
'Validate and return the same receipt without writing; data.written is false and data.dryRun is true.',
|
|
34
34
|
default: 'false',
|
|
35
35
|
},
|
|
36
|
-
{
|
|
37
|
-
name: 'options.from',
|
|
38
|
-
type: 'string',
|
|
39
|
-
description:
|
|
40
|
-
'Slug of an existing theme to fork as the starting point. The new theme copies the base and has no link back.',
|
|
41
|
-
},
|
|
42
36
|
],
|
|
43
37
|
returns: [
|
|
44
38
|
{
|
|
@@ -82,10 +76,6 @@ export const doc = {
|
|
|
82
76
|
label: 'Add a theme',
|
|
83
77
|
code: "await integrationAddTheme('ocean');",
|
|
84
78
|
},
|
|
85
|
-
{
|
|
86
|
-
label: 'Fork an existing theme',
|
|
87
|
-
code: "await integrationAddTheme('ocean', {from: 'neutral'});",
|
|
88
|
-
},
|
|
89
79
|
{
|
|
90
80
|
label: 'Preview writes',
|
|
91
81
|
code: "await integrationAddTheme('ocean', {dryRun: true});",
|
|
@@ -1,16 +1,6 @@
|
|
|
1
1
|
// @generated by scripts/sync-api-types.mjs from the JSDoc in api/**/*.mjs.
|
|
2
2
|
// DO NOT EDIT — run `pnpm sync:api-types` to regenerate.
|
|
3
3
|
|
|
4
|
-
/**
|
|
5
|
-
* Why `theme build` has no Core to generate with, and the fix for where it
|
|
6
|
-
* ran: the Astryx repository builds Core, an app installs it, and an installed
|
|
7
|
-
* Core that will not load is named.
|
|
8
|
-
*
|
|
9
|
-
* @param {string} cwd
|
|
10
|
-
* @param {any} importError - Why the import failed, when it threw.
|
|
11
|
-
* @returns {string}
|
|
12
|
-
*/
|
|
13
|
-
export function coreUnavailableMessage(cwd: string, importError: any): string;
|
|
14
4
|
/**
|
|
15
5
|
* Import specifier for install/scaffold instructions. Drops a leading `src/`
|
|
16
6
|
* from the cwd-relative dir (most consumers import from a file under src/) but
|
|
@@ -116,17 +106,3 @@ export function themeBuildFamily(files: string[], options: {
|
|
|
116
106
|
* validateAdaptationEnrollment)
|
|
117
107
|
*/
|
|
118
108
|
export type ComponentValueClass = "builtin" | "enrollment" | "unresolved";
|
|
119
|
-
/**
|
|
120
|
-
* The bindings one Core provides: the namespaces interception spreads, the
|
|
121
|
-
* functions the build calls, and why the import failed, if it did.
|
|
122
|
-
*/
|
|
123
|
-
export type CoreBindings = {
|
|
124
|
-
themeModule: any;
|
|
125
|
-
rootModule: any;
|
|
126
|
-
importError: any;
|
|
127
|
-
defineTheme: any;
|
|
128
|
-
generateThemeRulesSplit: any;
|
|
129
|
-
generateOnMediaCSS: any;
|
|
130
|
-
generateAdaptationCSS: any;
|
|
131
|
-
dataTokenDefaults: any;
|
|
132
|
-
};
|
|
@@ -45,11 +45,7 @@ import {fileURLToPath, pathToFileURL} from 'node:url';
|
|
|
45
45
|
import {parse} from '@babel/parser';
|
|
46
46
|
import {createJiti} from 'jiti';
|
|
47
47
|
import {getCliInvocation} from '../../../foundation/env/package-manager.mjs';
|
|
48
|
-
import {
|
|
49
|
-
CLI_ROOT,
|
|
50
|
-
findCoreDir,
|
|
51
|
-
findInstalledPackage,
|
|
52
|
-
} from '../../../foundation/fs/paths.mjs';
|
|
48
|
+
import {CLI_ROOT, findCoreDir} from '../../../foundation/fs/paths.mjs';
|
|
53
49
|
import {
|
|
54
50
|
assertWithin,
|
|
55
51
|
sanitizeName,
|
|
@@ -129,232 +125,6 @@ try {
|
|
|
129
125
|
_coreImportError = e;
|
|
130
126
|
}
|
|
131
127
|
|
|
132
|
-
/**
|
|
133
|
-
* The bindings one Core provides: the namespaces interception spreads, the
|
|
134
|
-
* functions the build calls, and why the import failed, if it did.
|
|
135
|
-
* @typedef {{
|
|
136
|
-
* themeModule: any,
|
|
137
|
-
* rootModule: any,
|
|
138
|
-
* importError: any,
|
|
139
|
-
* defineTheme: any,
|
|
140
|
-
* generateThemeRulesSplit: any,
|
|
141
|
-
* generateOnMediaCSS: any,
|
|
142
|
-
* generateAdaptationCSS: any,
|
|
143
|
-
* dataTokenDefaults: any,
|
|
144
|
-
* }} CoreBindings
|
|
145
|
-
*/
|
|
146
|
-
|
|
147
|
-
/**
|
|
148
|
-
* The bindings exactly as the CLI's own import left them, kept so each build
|
|
149
|
-
* can choose between them and the project's installed Core.
|
|
150
|
-
* @type {CoreBindings}
|
|
151
|
-
*/
|
|
152
|
-
const _cliCore = {
|
|
153
|
-
themeModule: _coreThemeModule,
|
|
154
|
-
rootModule: _coreRootModule,
|
|
155
|
-
importError: _coreImportError,
|
|
156
|
-
defineTheme: _defineTheme,
|
|
157
|
-
generateThemeRulesSplit: _generateThemeRulesSplit,
|
|
158
|
-
generateOnMediaCSS: _generateOnMediaCSS,
|
|
159
|
-
generateAdaptationCSS: _generateAdaptationCSS,
|
|
160
|
-
dataTokenDefaults: _dataTokenDefaults,
|
|
161
|
-
};
|
|
162
|
-
|
|
163
|
-
/**
|
|
164
|
-
* Point the build at one Core: the module-level bindings every step reads.
|
|
165
|
-
* @param {CoreBindings} core
|
|
166
|
-
*/
|
|
167
|
-
function setCore(core) {
|
|
168
|
-
_coreThemeModule = core.themeModule;
|
|
169
|
-
_coreRootModule = core.rootModule;
|
|
170
|
-
_coreImportError = core.importError;
|
|
171
|
-
_defineTheme = core.defineTheme;
|
|
172
|
-
_generateThemeRulesSplit = core.generateThemeRulesSplit;
|
|
173
|
-
_generateOnMediaCSS = core.generateOnMediaCSS;
|
|
174
|
-
_generateAdaptationCSS = core.generateAdaptationCSS;
|
|
175
|
-
_dataTokenDefaults = core.dataTokenDefaults;
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
/**
|
|
179
|
-
* The file an `import` of `subpath` reaches through a package's `exports` map,
|
|
180
|
-
* or null when the map has no entry for it. Conditions are taken in the map's
|
|
181
|
-
* own order, as Node does, accepting the ones an import matches here: `node`,
|
|
182
|
-
* `import`, and `default` (so `source` and `types` are skipped).
|
|
183
|
-
*
|
|
184
|
-
* @param {string} dir - The package directory.
|
|
185
|
-
* @param {string} subpath - `'.'` or a subpath such as `'./theme'`.
|
|
186
|
-
* @returns {string|null}
|
|
187
|
-
*/
|
|
188
|
-
function importTarget(dir, subpath) {
|
|
189
|
-
let pkg;
|
|
190
|
-
try {
|
|
191
|
-
pkg = JSON.parse(fs.readFileSync(path.join(dir, 'package.json'), 'utf-8'));
|
|
192
|
-
} catch {
|
|
193
|
-
return null;
|
|
194
|
-
}
|
|
195
|
-
const map = pkg?.exports;
|
|
196
|
-
const bySubpath =
|
|
197
|
-
map &&
|
|
198
|
-
typeof map === 'object' &&
|
|
199
|
-
!Array.isArray(map) &&
|
|
200
|
-
Object.keys(map).some(key => key.startsWith('.'));
|
|
201
|
-
const entry = bySubpath ? map[subpath] : subpath === '.' ? map : undefined;
|
|
202
|
-
/** @param {any} value @returns {string|null} */
|
|
203
|
-
const pick = value => {
|
|
204
|
-
if (typeof value === 'string') return value;
|
|
205
|
-
if (!value || typeof value !== 'object' || Array.isArray(value))
|
|
206
|
-
return null;
|
|
207
|
-
for (const [condition, target] of Object.entries(value)) {
|
|
208
|
-
if (
|
|
209
|
-
condition !== 'node' &&
|
|
210
|
-
condition !== 'import' &&
|
|
211
|
-
condition !== 'default'
|
|
212
|
-
)
|
|
213
|
-
continue;
|
|
214
|
-
const picked = pick(target);
|
|
215
|
-
if (picked) return picked;
|
|
216
|
-
}
|
|
217
|
-
return null;
|
|
218
|
-
};
|
|
219
|
-
const target = pick(entry);
|
|
220
|
-
return target ? path.resolve(dir, target) : null;
|
|
221
|
-
}
|
|
222
|
-
|
|
223
|
-
/** @param {string} file @returns {string} its real path, or itself */
|
|
224
|
-
function realOrSelf(file) {
|
|
225
|
-
try {
|
|
226
|
-
return fs.realpathSync(file);
|
|
227
|
-
} catch {
|
|
228
|
-
return file;
|
|
229
|
-
}
|
|
230
|
-
}
|
|
231
|
-
|
|
232
|
-
/**
|
|
233
|
-
* The Core the project at `cwd` installed, when it differs from the one the
|
|
234
|
-
* CLI's own import found and loads. The app's `<Theme>` runs on the app's
|
|
235
|
-
* Core, so building with it keeps the CSS identical; and a CLI run one-off
|
|
236
|
-
* (`npx @astryxdesign/cli`) has no Core beside it at all. Null when there is
|
|
237
|
-
* nothing better than the CLI's own import: no installed Core (the Astryx
|
|
238
|
-
* repository, a bare directory), the same Core, or one that does not load.
|
|
239
|
-
*
|
|
240
|
-
* @param {string} cwd
|
|
241
|
-
* @returns {Promise<CoreBindings | null>}
|
|
242
|
-
*/
|
|
243
|
-
async function loadProjectCore(cwd) {
|
|
244
|
-
const dir = findInstalledPackage(cwd, '@astryxdesign/core');
|
|
245
|
-
const themeFile = dir ? importTarget(dir, './theme') : null;
|
|
246
|
-
if (!dir || !themeFile) return null;
|
|
247
|
-
if (_cliCore.themeModule) {
|
|
248
|
-
try {
|
|
249
|
-
const own = fileURLToPath(
|
|
250
|
-
import.meta.resolve('@astryxdesign/core/theme'),
|
|
251
|
-
);
|
|
252
|
-
if (realOrSelf(own) === realOrSelf(themeFile)) return null;
|
|
253
|
-
} catch {
|
|
254
|
-
// The CLI's own Core cannot be located; load the project's.
|
|
255
|
-
}
|
|
256
|
-
}
|
|
257
|
-
let themeModule;
|
|
258
|
-
try {
|
|
259
|
-
themeModule = await import(pathToFileURL(themeFile).href);
|
|
260
|
-
} catch {
|
|
261
|
-
return null;
|
|
262
|
-
}
|
|
263
|
-
if (!themeModule.defineTheme || !themeModule.generateThemeRulesSplit)
|
|
264
|
-
return null;
|
|
265
|
-
let rootModule = null;
|
|
266
|
-
const rootFile = importTarget(dir, '.');
|
|
267
|
-
if (rootFile) {
|
|
268
|
-
try {
|
|
269
|
-
rootModule = await import(pathToFileURL(rootFile).href);
|
|
270
|
-
} catch {
|
|
271
|
-
// As with the CLI's own import, the theme namespace stands in for it.
|
|
272
|
-
}
|
|
273
|
-
}
|
|
274
|
-
return {
|
|
275
|
-
themeModule,
|
|
276
|
-
rootModule,
|
|
277
|
-
importError: null,
|
|
278
|
-
defineTheme: themeModule.defineTheme,
|
|
279
|
-
generateThemeRulesSplit: themeModule.generateThemeRulesSplit,
|
|
280
|
-
generateOnMediaCSS: themeModule.generateOnMediaCSS,
|
|
281
|
-
generateAdaptationCSS: themeModule.generateAdaptationCSS,
|
|
282
|
-
dataTokenDefaults: themeModule.dataTokenDefaults,
|
|
283
|
-
};
|
|
284
|
-
}
|
|
285
|
-
|
|
286
|
-
/** @type {Map<string, Awaited<ReturnType<typeof loadProjectCore>>>} */
|
|
287
|
-
const _projectCores = new Map();
|
|
288
|
-
|
|
289
|
-
/**
|
|
290
|
-
* Choose the Core this build generates with: the project's installed one when
|
|
291
|
-
* {@link loadProjectCore} finds it, else the CLI's own.
|
|
292
|
-
* @param {string} cwd
|
|
293
|
-
*/
|
|
294
|
-
async function selectCore(cwd) {
|
|
295
|
-
if (!_projectCores.has(cwd))
|
|
296
|
-
_projectCores.set(cwd, await loadProjectCore(cwd));
|
|
297
|
-
setCore(_projectCores.get(cwd) ?? _cliCore);
|
|
298
|
-
}
|
|
299
|
-
|
|
300
|
-
/**
|
|
301
|
-
* Whether `cwd` sits in the Astryx repository, where Core is built from
|
|
302
|
-
* source rather than installed.
|
|
303
|
-
* @param {string} cwd
|
|
304
|
-
*/
|
|
305
|
-
function inAstryxRepository(cwd) {
|
|
306
|
-
let dir = cwd;
|
|
307
|
-
for (let i = 0; i < 6; i++) {
|
|
308
|
-
try {
|
|
309
|
-
const pkg = JSON.parse(
|
|
310
|
-
fs.readFileSync(
|
|
311
|
-
path.join(dir, 'packages', 'core', 'package.json'),
|
|
312
|
-
'utf-8',
|
|
313
|
-
),
|
|
314
|
-
);
|
|
315
|
-
if (pkg?.name === '@astryxdesign/core') return true;
|
|
316
|
-
} catch {
|
|
317
|
-
// Not here; keep walking up.
|
|
318
|
-
}
|
|
319
|
-
const parent = path.dirname(dir);
|
|
320
|
-
if (parent === dir) break;
|
|
321
|
-
dir = parent;
|
|
322
|
-
}
|
|
323
|
-
return false;
|
|
324
|
-
}
|
|
325
|
-
|
|
326
|
-
/**
|
|
327
|
-
* Why `theme build` has no Core to generate with, and the fix for where it
|
|
328
|
-
* ran: the Astryx repository builds Core, an app installs it, and an installed
|
|
329
|
-
* Core that will not load is named.
|
|
330
|
-
*
|
|
331
|
-
* @param {string} cwd
|
|
332
|
-
* @param {any} importError - Why the import failed, when it threw.
|
|
333
|
-
* @returns {string}
|
|
334
|
-
*/
|
|
335
|
-
export function coreUnavailableMessage(cwd, importError) {
|
|
336
|
-
const why =
|
|
337
|
-
'`astryx theme build` generates CSS with @astryxdesign/core, the same code the runtime <Theme> uses';
|
|
338
|
-
const detail = importError ? `\n Import error: ${importError.message}` : '';
|
|
339
|
-
if (inAstryxRepository(cwd)) {
|
|
340
|
-
return (
|
|
341
|
-
`Could not load @astryxdesign/core/theme: ${why}. Build @astryxdesign/core ` +
|
|
342
|
-
`first (e.g. \`pnpm -F @astryxdesign/core build\`).${detail}`
|
|
343
|
-
);
|
|
344
|
-
}
|
|
345
|
-
const installed = findInstalledPackage(cwd, '@astryxdesign/core');
|
|
346
|
-
if (installed) {
|
|
347
|
-
return (
|
|
348
|
-
`Could not load the @astryxdesign/core installed at ` +
|
|
349
|
-
`${path.relative(cwd, installed) || '.'}: ${why}. Reinstall it.${detail}`
|
|
350
|
-
);
|
|
351
|
-
}
|
|
352
|
-
return (
|
|
353
|
-
`This project does not have @astryxdesign/core installed: ${why}. Install ` +
|
|
354
|
-
`it: \`npm install @astryxdesign/core\` (or yarn/pnpm/bun).${detail}`
|
|
355
|
-
);
|
|
356
|
-
}
|
|
357
|
-
|
|
358
128
|
/**
|
|
359
129
|
* Read a package's `version` from a resolved directory. Returns `'unknown'`
|
|
360
130
|
* when it can't be read so the header always has a value.
|
|
@@ -2337,8 +2107,6 @@ async function themeBuildInternal(
|
|
|
2337
2107
|
|
|
2338
2108
|
logger.log(`\nBuilding theme from ${path.relative(cwd, filePath)}...`);
|
|
2339
2109
|
|
|
2340
|
-
await selectCore(cwd);
|
|
2341
|
-
|
|
2342
2110
|
// Standalone builds only need interception when an older Core could erase
|
|
2343
2111
|
// adaptations. Family preparation always supplies the same recorder as its
|
|
2344
2112
|
// shared loader so exact authored parent identity stays CLI-private instead
|
|
@@ -2465,7 +2233,13 @@ async function themeBuildInternal(
|
|
|
2465
2233
|
// capability exports are checked against what the theme actually asks for.
|
|
2466
2234
|
if (!_defineTheme || !_generateThemeRulesSplit) {
|
|
2467
2235
|
throw new AstryxError(
|
|
2468
|
-
|
|
2236
|
+
'Could not load @astryxdesign/core/theme: `astryx theme build` requires a ' +
|
|
2237
|
+
'built, resolvable @astryxdesign/core so it emits the same CSS as the ' +
|
|
2238
|
+
'runtime <Theme>. Build @astryxdesign/core first (e.g. `pnpm -F @astryxdesign/core ' +
|
|
2239
|
+
'build`)' +
|
|
2240
|
+
(_coreImportError
|
|
2241
|
+
? `.\n Import error: ${_coreImportError.message}`
|
|
2242
|
+
: '.'),
|
|
2469
2243
|
undefined,
|
|
2470
2244
|
ERROR_CODES.ERR_CORE_NOT_FOUND,
|
|
2471
2245
|
);
|
|
@@ -3033,7 +2807,6 @@ export async function themeBuildFamily(
|
|
|
3033
2807
|
error instanceof Error ? error.message : 'Invalid family key.';
|
|
3034
2808
|
throw new AstryxError(message, undefined, ERROR_CODES.ERR_THEME_INVALID);
|
|
3035
2809
|
}
|
|
3036
|
-
await selectCore(cwd);
|
|
3037
2810
|
const familyInterception = interceptCore(_coreThemeModule, _coreRootModule);
|
|
3038
2811
|
// prettier-ignore
|
|
3039
2812
|
const familyLoader = createJiti(import.meta.url, {moduleCache: true, interopDefault: false, jsx: true, extensions: THEME_MODULE_EXTENSIONS, virtualModules: familyInterception.modules});
|
|
@@ -56,12 +56,6 @@ export const doc = {
|
|
|
56
56
|
description:
|
|
57
57
|
"Namespace of this package to place the doc in, as a guide in its `guides` slot; writes the namespace doc when it is missing, and declares the CLI that reads it as an optional `@astryxdesign/cli` peer. Only valid for doc, and not with --replaces or --extends",
|
|
58
58
|
},
|
|
59
|
-
{
|
|
60
|
-
flag: '--from <theme>',
|
|
61
|
-
param: 'options.from',
|
|
62
|
-
description:
|
|
63
|
-
'Existing theme slug to fork as a starting point instead of a blank scaffold; the new theme copies the base and has no link back. Only valid for theme',
|
|
64
|
-
},
|
|
65
59
|
{
|
|
66
60
|
flag: '--to <version>',
|
|
67
61
|
param: 'options.to',
|
|
@@ -108,10 +102,6 @@ export const doc = {
|
|
|
108
102
|
cli: "astryx integration add agent-doc 'Run acme verify before finishing.'",
|
|
109
103
|
},
|
|
110
104
|
{label: 'Add a source theme', cli: 'astryx integration add theme ocean'},
|
|
111
|
-
{
|
|
112
|
-
label: 'Fork an existing theme',
|
|
113
|
-
cli: 'astryx integration add theme ocean --from neutral',
|
|
114
|
-
},
|
|
115
105
|
],
|
|
116
106
|
exitCodes: [
|
|
117
107
|
{code: 0, when: 'the contribution is written or the dry run succeeds'},
|
|
@@ -174,21 +174,11 @@ describe('integration authoring CLI', () => {
|
|
|
174
174
|
expect(text.stdout).toBe(verifyText.stdout);
|
|
175
175
|
expect(text.stderr).toContain('`integration pack --check` is deprecated');
|
|
176
176
|
expect(text.stderr).toContain('astryx integration verify');
|
|
177
|
-
// Without --check it fails, as it did, and
|
|
178
|
-
// suggesting `--check` would send people to the deprecated spelling.
|
|
177
|
+
// Without --check it fails, as it did, and names both spellings.
|
|
179
178
|
const bare = await runCli(['integration', 'pack'], tmpDir);
|
|
180
179
|
expect(bare.status).not.toBe(0);
|
|
181
|
-
expect(bare.stderr).toContain(
|
|
182
|
-
'`integration pack` is now `integration verify`',
|
|
183
|
-
);
|
|
180
|
+
expect(bare.stderr).toContain('--check');
|
|
184
181
|
expect(bare.stderr).toContain('astryx integration verify');
|
|
185
|
-
expect(bare.stderr).toContain('npm pack');
|
|
186
|
-
expect(bare.stderr).not.toContain('--check');
|
|
187
|
-
const bareJson = await runCli(['--json', 'integration', 'pack'], tmpDir);
|
|
188
|
-
expect(parseEnvelope(bareJson.stdout)).toMatchObject({
|
|
189
|
-
code: 'ERR_INVALID_ARGUMENT',
|
|
190
|
-
error: expect.stringContaining('astryx integration verify'),
|
|
191
|
-
});
|
|
192
182
|
// Help lists it, marked deprecated: nothing is hidden.
|
|
193
183
|
const help = await runCli(['integration', '--help'], tmpDir);
|
|
194
184
|
expect(help.stdout).toMatch(
|
|
@@ -115,7 +115,6 @@ export function registerIntegration(program) {
|
|
|
115
115
|
extends: options.extends,
|
|
116
116
|
parent: options.parent,
|
|
117
117
|
to: options.to,
|
|
118
|
-
from: options.from,
|
|
119
118
|
});
|
|
120
119
|
} catch (error) {
|
|
121
120
|
const err =
|
|
@@ -169,9 +168,8 @@ export function registerIntegration(program) {
|
|
|
169
168
|
fn: integrationPackCheckFn,
|
|
170
169
|
action: async options => {
|
|
171
170
|
if (!options.check) {
|
|
172
|
-
// One way forward: the new name. `npm pack` is what builds a tarball.
|
|
173
171
|
return cliError(
|
|
174
|
-
'
|
|
172
|
+
'Pass --check to verify the integration tarball, or run `astryx integration verify`.',
|
|
175
173
|
{code: ERROR_CODES.ERR_INVALID_ARGUMENT},
|
|
176
174
|
);
|
|
177
175
|
}
|
|
@@ -61,13 +61,13 @@ const RUNNERS = {
|
|
|
61
61
|
sites: ['child_process.execFileSync'],
|
|
62
62
|
},
|
|
63
63
|
'api/theme/build/build.mjs': {
|
|
64
|
-
runs:
|
|
64
|
+
runs: 'theme source modules, through jiti; eval for legacy theme object literals',
|
|
65
65
|
sites: [
|
|
66
66
|
'.evalModule() ×2',
|
|
67
67
|
'.import()',
|
|
68
68
|
'createJiti ×4',
|
|
69
69
|
'eval ×2',
|
|
70
|
-
'import(<computed>)
|
|
70
|
+
'import(<computed>)',
|
|
71
71
|
],
|
|
72
72
|
},
|
|
73
73
|
'api/theme/build/core-interception.mjs': {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@astryxdesign/cli",
|
|
3
|
-
"version": "0.6.5-canary.
|
|
3
|
+
"version": "0.6.5-canary.5e7c207",
|
|
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",
|
|
@@ -101,10 +101,10 @@
|
|
|
101
101
|
"zod": "^4.4.3"
|
|
102
102
|
},
|
|
103
103
|
"peerDependencies": {
|
|
104
|
-
"@astryxdesign/charts": "0.6.5-canary.
|
|
105
|
-
"@astryxdesign/core": "0.6.5-canary.
|
|
106
|
-
"@astryxdesign/lab": "0.6.5-canary.
|
|
107
|
-
"@astryxdesign/theme-neutral": "0.6.5-canary.
|
|
104
|
+
"@astryxdesign/charts": "0.6.5-canary.5e7c207",
|
|
105
|
+
"@astryxdesign/core": "0.6.5-canary.5e7c207",
|
|
106
|
+
"@astryxdesign/lab": "0.6.5-canary.5e7c207",
|
|
107
|
+
"@astryxdesign/theme-neutral": "0.6.5-canary.5e7c207"
|
|
108
108
|
},
|
|
109
109
|
"peerDependenciesMeta": {
|
|
110
110
|
"@astryxdesign/charts": {
|
|
@@ -121,10 +121,10 @@
|
|
|
121
121
|
}
|
|
122
122
|
},
|
|
123
123
|
"devDependencies": {
|
|
124
|
-
"@astryxdesign/charts": "0.6.5-canary.
|
|
125
|
-
"@astryxdesign/core": "0.6.5-canary.
|
|
126
|
-
"@astryxdesign/lab": "0.6.5-canary.
|
|
127
|
-
"@astryxdesign/theme-neutral": "0.6.5-canary.
|
|
124
|
+
"@astryxdesign/charts": "0.6.5-canary.5e7c207",
|
|
125
|
+
"@astryxdesign/core": "0.6.5-canary.5e7c207",
|
|
126
|
+
"@astryxdesign/lab": "0.6.5-canary.5e7c207",
|
|
127
|
+
"@astryxdesign/theme-neutral": "0.6.5-canary.5e7c207",
|
|
128
128
|
"@heroicons/react": "^2.2.0",
|
|
129
129
|
"@stylexjs/stylex": "^0.19.0",
|
|
130
130
|
"@types/babel__core": "^7.20.5",
|
|
@@ -1,165 +0,0 @@
|
|
|
1
|
-
// Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* @file `theme build` in an app generates with the Core the app installed.
|
|
5
|
-
*
|
|
6
|
-
* A CLI run one-off (`npx @astryxdesign/cli`) has no Core beside it, and the
|
|
7
|
-
* app's `<Theme>` runs on the app's Core either way, so the build loads the
|
|
8
|
-
* project's installed `@astryxdesign/core` when it differs from the CLI's own.
|
|
9
|
-
* When there is no Core to use, the error names the fix for where it ran:
|
|
10
|
-
* install it in an app, build it in the Astryx repository.
|
|
11
|
-
*/
|
|
12
|
-
|
|
13
|
-
import {afterEach, beforeEach, describe, expect, it} from 'vitest';
|
|
14
|
-
import * as fs from 'node:fs';
|
|
15
|
-
import * as os from 'node:os';
|
|
16
|
-
import * as path from 'node:path';
|
|
17
|
-
import {fileURLToPath, pathToFileURL} from 'node:url';
|
|
18
|
-
import {coreUnavailableMessage, themeBuild} from './build.mjs';
|
|
19
|
-
|
|
20
|
-
const HERE = path.dirname(fileURLToPath(import.meta.url));
|
|
21
|
-
const REPO_ROOT = path.resolve(HERE, '../../../../..');
|
|
22
|
-
const CORE_DIST = path.join(REPO_ROOT, 'packages/core/dist');
|
|
23
|
-
|
|
24
|
-
/** @type {string[]} */
|
|
25
|
-
const tmpDirs = [];
|
|
26
|
-
const makeDir = () => {
|
|
27
|
-
const dir = fs.mkdtempSync(path.join(os.tmpdir(), 'astryx-project-core-'));
|
|
28
|
-
tmpDirs.push(dir);
|
|
29
|
-
fs.writeFileSync(
|
|
30
|
-
path.join(dir, 'package.json'),
|
|
31
|
-
'{"name":"app","type":"module"}',
|
|
32
|
-
);
|
|
33
|
-
// A plain theme object: the file itself never imports Core, so only the
|
|
34
|
-
// build's own Core loading can set the marker below.
|
|
35
|
-
fs.writeFileSync(
|
|
36
|
-
path.join(dir, 'ocean.mjs'),
|
|
37
|
-
"export default {name: 'ocean', tokens: {'--color-bg': '#0a0a0a'}};\n",
|
|
38
|
-
);
|
|
39
|
-
return dir;
|
|
40
|
-
};
|
|
41
|
-
|
|
42
|
-
beforeEach(() => {
|
|
43
|
-
delete globalThis.__astryxProjectCoreLoads;
|
|
44
|
-
});
|
|
45
|
-
afterEach(() => {
|
|
46
|
-
delete globalThis.__astryxProjectCoreLoads;
|
|
47
|
-
for (const dir of tmpDirs.splice(0))
|
|
48
|
-
fs.rmSync(dir, {recursive: true, force: true});
|
|
49
|
-
});
|
|
50
|
-
|
|
51
|
-
/**
|
|
52
|
-
* Install a Core in `dir` that is the built one, re-exported, and records each
|
|
53
|
-
* entry as it is imported. Its `exports` map lists `source` first, as Core's
|
|
54
|
-
* own does, so the build must skip that condition to find the runtime file.
|
|
55
|
-
* @param {string} dir
|
|
56
|
-
* @param {{broken?: boolean}} [options]
|
|
57
|
-
*/
|
|
58
|
-
function installCore(dir, {broken = false} = {}) {
|
|
59
|
-
const core = path.join(dir, 'node_modules', '@astryxdesign', 'core');
|
|
60
|
-
fs.mkdirSync(core, {recursive: true});
|
|
61
|
-
fs.writeFileSync(
|
|
62
|
-
path.join(core, 'package.json'),
|
|
63
|
-
JSON.stringify({
|
|
64
|
-
name: '@astryxdesign/core',
|
|
65
|
-
version: '0.6.5',
|
|
66
|
-
type: 'module',
|
|
67
|
-
exports: {
|
|
68
|
-
'.': {types: './root.d.ts', default: './root.mjs'},
|
|
69
|
-
'./theme': {
|
|
70
|
-
source: './src/theme/index.ts',
|
|
71
|
-
types: './theme.d.ts',
|
|
72
|
-
default: './theme.mjs',
|
|
73
|
-
},
|
|
74
|
-
},
|
|
75
|
-
}),
|
|
76
|
-
);
|
|
77
|
-
/** @param {string} entry @param {string} target */
|
|
78
|
-
const module = (entry, target) =>
|
|
79
|
-
broken
|
|
80
|
-
? "throw new Error('this Core is broken');\n"
|
|
81
|
-
: `export * from ${JSON.stringify(pathToFileURL(path.join(CORE_DIST, target)).href)};\n` +
|
|
82
|
-
`globalThis.__astryxProjectCoreLoads = [...(globalThis.__astryxProjectCoreLoads ?? []), '${entry}'];\n`;
|
|
83
|
-
fs.writeFileSync(
|
|
84
|
-
path.join(core, 'theme.mjs'),
|
|
85
|
-
module('theme', 'theme/index.js'),
|
|
86
|
-
);
|
|
87
|
-
fs.writeFileSync(path.join(core, 'root.mjs'), module('root', 'index.js'));
|
|
88
|
-
return core;
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
describe('theme build generates with the Core the project installed', () => {
|
|
92
|
-
it('loads the app’s installed Core when it differs from the CLI’s own', async () => {
|
|
93
|
-
const app = makeDir();
|
|
94
|
-
installCore(app);
|
|
95
|
-
await themeBuild('ocean.mjs', {}, {cwd: app});
|
|
96
|
-
expect(globalThis.__astryxProjectCoreLoads).toEqual(['theme', 'root']);
|
|
97
|
-
// The same Core, re-exported, emits the same CSS as the CLI's own. The
|
|
98
|
-
// generated header differs only in the Core version it records.
|
|
99
|
-
const bare = makeDir();
|
|
100
|
-
await themeBuild('ocean.mjs', {}, {cwd: bare});
|
|
101
|
-
/** @param {string} dir */
|
|
102
|
-
const rules = dir =>
|
|
103
|
-
fs
|
|
104
|
-
.readFileSync(path.join(dir, 'ocean.css'), 'utf-8')
|
|
105
|
-
.replace(/^\/\*[\s\S]*?\*\/\n/, '');
|
|
106
|
-
expect(rules(app)).toBe(rules(bare));
|
|
107
|
-
expect(rules(app)).toContain('#0a0a0a');
|
|
108
|
-
});
|
|
109
|
-
|
|
110
|
-
it('keeps the CLI’s own Core when the project has none', async () => {
|
|
111
|
-
const bare = makeDir();
|
|
112
|
-
await themeBuild('ocean.mjs', {}, {cwd: bare});
|
|
113
|
-
expect(globalThis.__astryxProjectCoreLoads).toBeUndefined();
|
|
114
|
-
expect(fs.existsSync(path.join(bare, 'ocean.css'))).toBe(true);
|
|
115
|
-
});
|
|
116
|
-
|
|
117
|
-
it('keeps the CLI’s own Core when the installed one does not load', async () => {
|
|
118
|
-
const app = makeDir();
|
|
119
|
-
installCore(app, {broken: true});
|
|
120
|
-
await themeBuild('ocean.mjs', {}, {cwd: app});
|
|
121
|
-
expect(fs.existsSync(path.join(app, 'ocean.css'))).toBe(true);
|
|
122
|
-
});
|
|
123
|
-
});
|
|
124
|
-
|
|
125
|
-
describe('the error when there is no Core to generate with', () => {
|
|
126
|
-
it('tells an app to install Core, not to build it', () => {
|
|
127
|
-
const app = makeDir();
|
|
128
|
-
const message = coreUnavailableMessage(
|
|
129
|
-
app,
|
|
130
|
-
new Error("Cannot find package '@astryxdesign/core'"),
|
|
131
|
-
);
|
|
132
|
-
expect(message).toContain(
|
|
133
|
-
'This project does not have @astryxdesign/core installed',
|
|
134
|
-
);
|
|
135
|
-
expect(message).toContain('`npm install @astryxdesign/core`');
|
|
136
|
-
expect(message).not.toContain('pnpm -F');
|
|
137
|
-
expect(message).toContain(
|
|
138
|
-
"Import error: Cannot find package '@astryxdesign/core'",
|
|
139
|
-
);
|
|
140
|
-
});
|
|
141
|
-
|
|
142
|
-
it('names an installed Core that does not load', () => {
|
|
143
|
-
const app = makeDir();
|
|
144
|
-
installCore(app, {broken: true});
|
|
145
|
-
const message = coreUnavailableMessage(
|
|
146
|
-
app,
|
|
147
|
-
new Error('this Core is broken'),
|
|
148
|
-
);
|
|
149
|
-
expect(message).toContain(
|
|
150
|
-
`Could not load the @astryxdesign/core installed at ${path.join('node_modules', '@astryxdesign', 'core')}`,
|
|
151
|
-
);
|
|
152
|
-
expect(message).toContain('Reinstall it.');
|
|
153
|
-
expect(message).not.toContain('pnpm -F');
|
|
154
|
-
});
|
|
155
|
-
|
|
156
|
-
it('keeps the build instruction in the Astryx repository', () => {
|
|
157
|
-
const message = coreUnavailableMessage(
|
|
158
|
-
path.join(REPO_ROOT, 'packages', 'cli'),
|
|
159
|
-
undefined,
|
|
160
|
-
);
|
|
161
|
-
expect(message).toContain('Build @astryxdesign/core first');
|
|
162
|
-
expect(message).toContain('`pnpm -F @astryxdesign/core build`');
|
|
163
|
-
expect(message).not.toContain('Import error');
|
|
164
|
-
});
|
|
165
|
-
});
|