@astryxdesign/cli 0.7.3-canary.b74cf21 → 0.7.3-canary.cb489ff
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/doctor/doctor.test.mjs +28 -3
- package/api/integration/pack-check.mjs +110 -4
- package/api/integration/pack-check.test.mjs +69 -0
- package/api/integration/validate-integration-gaps.test.mjs +292 -0
- package/api/integration/validate-integration.d.mts +2 -1
- package/api/integration/validate-integration.mjs +10 -6
- package/api/integration/validate-integration.type.d.mts +1 -0
- package/api/integration/validate-integration.type.mjs +1 -0
- package/api/upgrade/_adapter.d.mts +57 -3
- package/api/upgrade/_adapter.mjs +149 -27
- package/api/upgrade/registry/registry.d.mts +10 -4
- package/api/upgrade/registry/registry.mjs +33 -16
- package/api/upgrade/registry/registry.test.mjs +85 -0
- package/api/upgrade/run/run.d.mts +4 -2
- package/api/upgrade/run/run.mjs +13 -2
- package/api/upgrade/run/run.test.mjs +417 -3
- package/api/upgrade/upgrade.doc.mjs +10 -5
- package/api/upgrade/upgrade.mjs +13 -2
- package/api/upgrade/upgrade.type.d.mts +5 -3
- package/api/upgrade/upgrade.type.mjs +8 -6
- package/assets/docs/is-my-code-good.doc.mjs +287 -0
- package/assets/docs/tree/template-grading-rubric.doc.mjs +16 -37
- package/clients/cli/commands/upgrade.doc.mjs +4 -2
- package/clients/cli/commands/upgrade.mjs +9 -2
- package/clients/cli/commands/upgrade.subfolder-path.test.mjs +97 -0
- package/foundation/config/project.mjs +5 -20
- package/foundation/config/project.test.mjs +56 -0
- package/foundation/discovery/template-adapter.mjs +18 -1
- package/foundation/discovery/template-needs.mjs +1 -44
- package/foundation/discovery/theme-discovery.mjs +147 -3
- package/foundation/doc-compiler/read.mjs +59 -1
- package/foundation/doc-compiler/read.test.mjs +11 -2
- package/foundation/fs/paths.d.mts +70 -8
- package/foundation/fs/paths.mjs +526 -35
- package/foundation/fs/paths.test.mjs +430 -54
- package/foundation/integrations/autolink.d.mts +2 -1
- package/foundation/integrations/autolink.mjs +4 -13
- package/foundation/integrations/integrations.d.mts +20 -1
- package/foundation/integrations/integrations.mjs +59 -2
- package/foundation/integrations/validate-contributions.d.mts +19 -0
- package/foundation/integrations/validate-contributions.mjs +172 -3
- package/package.json +9 -9
|
@@ -19,6 +19,7 @@
|
|
|
19
19
|
import * as fs from 'node:fs';
|
|
20
20
|
import * as path from 'node:path';
|
|
21
21
|
import {assertWithin} from '../fs/path-safety.mjs';
|
|
22
|
+
import {findNodeModulesPackage} from '../fs/paths.mjs';
|
|
22
23
|
import {normalizeProviderId} from '../identity/provider-identity.mjs';
|
|
23
24
|
// The key census and contribution parsers are internal to the schema module on
|
|
24
25
|
// purpose: the public parser still validates the complete authored type, while
|
|
@@ -73,6 +74,8 @@ import {resolveProviders} from './provider-resolution.mjs';
|
|
|
73
74
|
* set on a package whose provider ID an earlier-loaded package already
|
|
74
75
|
* claims; it contributes nothing and is reported as a `duplicate_provider`
|
|
75
76
|
* warning
|
|
77
|
+
* @property {string[]} [__declaredKeys] the keys the manifest object itself
|
|
78
|
+
* declares, before any is filled in (providerId from the package name)
|
|
76
79
|
* @property {string[]} [__unknownKeys] manifest keys this CLI does not know —
|
|
77
80
|
* surfaced as a warning; the rest of the manifest still contributes
|
|
78
81
|
* @property {boolean} [__autolinked] loaded because the project declares the
|
|
@@ -215,7 +218,7 @@ function parseDiscoverSourceExport(value, label) {
|
|
|
215
218
|
* @param {string} file absolute manifest path
|
|
216
219
|
* @param {string} [label] used in error messages
|
|
217
220
|
* @param {{fresh?: boolean}} [options]
|
|
218
|
-
* @returns {Promise<{manifest: import('../../authoring/integration/type').AstryxIntegration, unknownKeys: string[], debug?: import('../../authoring/debug/type').DebugEventHandler, gapReport?: import('../../authoring/gap-report/type').GapReportHandler, gapReportError?: string, discover?: import('../../authoring/discover/type').DiscoverSource, discoverError?: string, agentDocsError?: string, cliCommandError?: string}>}
|
|
221
|
+
* @returns {Promise<{manifest: import('../../authoring/integration/type').AstryxIntegration, unknownKeys: string[], declaredKeys: string[], debug?: import('../../authoring/debug/type').DebugEventHandler, gapReport?: import('../../authoring/gap-report/type').GapReportHandler, gapReportError?: string, discover?: import('../../authoring/discover/type').DiscoverSource, discoverError?: string, agentDocsError?: string, cliCommandError?: string}>}
|
|
219
222
|
*/
|
|
220
223
|
export async function loadManifest(
|
|
221
224
|
file,
|
|
@@ -224,6 +227,7 @@ export async function loadManifest(
|
|
|
224
227
|
) {
|
|
225
228
|
const mod = await importUserModule(file, {fresh});
|
|
226
229
|
const raw = mod?.default;
|
|
230
|
+
if (raw === undefined) throw new Error(noDefaultExportMessage(file, label, mod));
|
|
227
231
|
const baseManifest = parseIntegrationBase(raw, label);
|
|
228
232
|
const gapReport = parseGapReportHandlerExport(mod?.gapReport, label);
|
|
229
233
|
const discover = parseDiscoverSourceExport(mod?.discover, label);
|
|
@@ -276,6 +280,8 @@ export async function loadManifest(
|
|
|
276
280
|
...(cliCommand == null ? {} : {cliCommand}),
|
|
277
281
|
},
|
|
278
282
|
unknownKeys: unknownIntegrationKeys(raw),
|
|
283
|
+
declaredKeys:
|
|
284
|
+
raw != null && typeof raw === 'object' ? Object.keys(raw) : [],
|
|
279
285
|
debug:
|
|
280
286
|
typeof mod?.debug === 'function'
|
|
281
287
|
? /** @type {import('../../authoring/debug/type').DebugEventHandler} */ (
|
|
@@ -291,6 +297,30 @@ export async function loadManifest(
|
|
|
291
297
|
};
|
|
292
298
|
}
|
|
293
299
|
|
|
300
|
+
/**
|
|
301
|
+
* Why a manifest has no default export, said plainly instead of as a schema
|
|
302
|
+
* failure on `undefined`: the file is empty, or it exports other names.
|
|
303
|
+
* @param {string} file
|
|
304
|
+
* @param {string} label
|
|
305
|
+
* @param {Record<string, unknown> | undefined} mod
|
|
306
|
+
*/
|
|
307
|
+
function noDefaultExportMessage(file, label, mod) {
|
|
308
|
+
const fix = `Fix: export the manifest object as the default export: \`export default {components: './components'}\`, naming the roots the package has.`;
|
|
309
|
+
let text = '';
|
|
310
|
+
try {
|
|
311
|
+
text = fs.readFileSync(file, 'utf8');
|
|
312
|
+
} catch {
|
|
313
|
+
// Unreadable now: say only what is missing.
|
|
314
|
+
}
|
|
315
|
+
const names = Object.keys(mod ?? {}).filter(name => name !== 'default');
|
|
316
|
+
if (text.trim() === '') return `${label} is empty. ${fix}`;
|
|
317
|
+
const found =
|
|
318
|
+
names.length > 0
|
|
319
|
+
? ` (it exports ${names.map(name => `\`${name}\``).join(', ')})`
|
|
320
|
+
: '';
|
|
321
|
+
return `${label} has no default export${found}. ${fix}`;
|
|
322
|
+
}
|
|
323
|
+
|
|
294
324
|
/**
|
|
295
325
|
* Load and validate a manifest module's default export against the integration
|
|
296
326
|
* schema. Throws if the default export is missing or invalid. Exposed for
|
|
@@ -339,6 +369,25 @@ export function resolvePackageDir(packageName, cwd = process.cwd()) {
|
|
|
339
369
|
return dir;
|
|
340
370
|
}
|
|
341
371
|
|
|
372
|
+
/**
|
|
373
|
+
* Where an integration named in astryx.config is installed: the nearest
|
|
374
|
+
* `node_modules/<name>` at or above `cwd`, found the way an autolinked
|
|
375
|
+
* dependency is, so a package a workspace hoists to its root loads in every
|
|
376
|
+
* member. When it is installed nowhere, `cwd`'s own `node_modules/<name>`,
|
|
377
|
+
* which the caller reports as not installed.
|
|
378
|
+
* @param {string} packageName
|
|
379
|
+
* @param {string} [cwd]
|
|
380
|
+
* @returns {string}
|
|
381
|
+
*/
|
|
382
|
+
export function resolveInstalledIntegrationDir(
|
|
383
|
+
packageName,
|
|
384
|
+
cwd = process.cwd(),
|
|
385
|
+
) {
|
|
386
|
+
// Validates the name first: it throws on a spec with path segments.
|
|
387
|
+
const ownDir = resolvePackageDir(packageName, cwd);
|
|
388
|
+
return findNodeModulesPackage(cwd, packageName)?.packageDir ?? ownDir;
|
|
389
|
+
}
|
|
390
|
+
|
|
342
391
|
/**
|
|
343
392
|
* Find the single conventional root manifest sibling of the package's
|
|
344
393
|
* package.json. Multiple present is a hard error; missing is a hard error.
|
|
@@ -398,6 +447,8 @@ export async function loadLocalIntegration(packageDir, {fresh = false} = {}) {
|
|
|
398
447
|
let manifest;
|
|
399
448
|
/** @type {string[]} */
|
|
400
449
|
let unknownKeys;
|
|
450
|
+
/** @type {string[]} */
|
|
451
|
+
let declaredKeys;
|
|
401
452
|
/** @type {import('../../authoring/debug/type').DebugEventHandler | undefined} */
|
|
402
453
|
let debugHandler;
|
|
403
454
|
/** @type {import('../../authoring/gap-report/type').GapReportHandler | undefined} */
|
|
@@ -416,6 +467,7 @@ export async function loadLocalIntegration(packageDir, {fresh = false} = {}) {
|
|
|
416
467
|
({
|
|
417
468
|
manifest,
|
|
418
469
|
unknownKeys,
|
|
470
|
+
declaredKeys,
|
|
419
471
|
debug: debugHandler,
|
|
420
472
|
gapReport: gapReportHandler,
|
|
421
473
|
gapReportError,
|
|
@@ -464,6 +516,7 @@ export async function loadLocalIntegration(packageDir, {fresh = false} = {}) {
|
|
|
464
516
|
__cliCommandError: cliCommandError,
|
|
465
517
|
__agentDocsError: agentDocsError,
|
|
466
518
|
__unknownKeys: unknownKeys,
|
|
519
|
+
__declaredKeys: declaredKeys,
|
|
467
520
|
__debug: debugHandler,
|
|
468
521
|
__gapReport: gapReportHandler,
|
|
469
522
|
__gapReportError: gapReportError,
|
|
@@ -498,7 +551,7 @@ export async function loadIntegrations(
|
|
|
498
551
|
if (!spec || seenSpecs.has(spec)) continue;
|
|
499
552
|
seenSpecs.add(spec);
|
|
500
553
|
|
|
501
|
-
const packageDir =
|
|
554
|
+
const packageDir = resolveInstalledIntegrationDir(spec, cwd);
|
|
502
555
|
const pkgPath = path.join(packageDir, 'package.json');
|
|
503
556
|
let pkg;
|
|
504
557
|
try {
|
|
@@ -514,6 +567,8 @@ export async function loadIntegrations(
|
|
|
514
567
|
let manifest;
|
|
515
568
|
/** @type {string[]} */
|
|
516
569
|
let unknownKeys;
|
|
570
|
+
/** @type {string[]} */
|
|
571
|
+
let declaredKeys;
|
|
517
572
|
/** @type {import('../../authoring/debug/type').DebugEventHandler | undefined} */
|
|
518
573
|
let debugHandler;
|
|
519
574
|
/** @type {import('../../authoring/gap-report/type').GapReportHandler | undefined} */
|
|
@@ -532,6 +587,7 @@ export async function loadIntegrations(
|
|
|
532
587
|
({
|
|
533
588
|
manifest,
|
|
534
589
|
unknownKeys,
|
|
590
|
+
declaredKeys,
|
|
535
591
|
debug: debugHandler,
|
|
536
592
|
gapReport: gapReportHandler,
|
|
537
593
|
gapReportError,
|
|
@@ -587,6 +643,7 @@ export async function loadIntegrations(
|
|
|
587
643
|
__cliCommandError: cliCommandError,
|
|
588
644
|
__agentDocsError: agentDocsError,
|
|
589
645
|
__unknownKeys: unknownKeys,
|
|
646
|
+
__declaredKeys: declaredKeys,
|
|
590
647
|
__debug: debugHandler,
|
|
591
648
|
__gapReport: gapReportHandler,
|
|
592
649
|
__gapReportError: gapReportError,
|
|
@@ -20,6 +20,14 @@ export function issueListed(code: string, message: string): Issue;
|
|
|
20
20
|
* @param {Issue} issue
|
|
21
21
|
*/
|
|
22
22
|
export function isListedIssue(issue: Issue): boolean;
|
|
23
|
+
/**
|
|
24
|
+
* The known manifest key `key` is a near miss of: a different letter case, or
|
|
25
|
+
* at most two letters added, dropped or changed (`component`, `doc`,
|
|
26
|
+
* `tempaltes`). Null when no known key is that close, or two are.
|
|
27
|
+
* @param {string} key
|
|
28
|
+
* @returns {string | null}
|
|
29
|
+
*/
|
|
30
|
+
export function nearestKnownKey(key: string): string | null;
|
|
23
31
|
/**
|
|
24
32
|
* Why a declared root cannot be read as a folder, or null when it can.
|
|
25
33
|
* A missing root keeps its own issue; a root that is a file or that the
|
|
@@ -98,6 +106,17 @@ export function componentDocNamesCheck(integration: LoadedIntegration): Promise<
|
|
|
98
106
|
};
|
|
99
107
|
notes: Note[];
|
|
100
108
|
}>;
|
|
109
|
+
/**
|
|
110
|
+
* The `name` a theme source passes to defineTheme for its exported theme,
|
|
111
|
+
* when the file says it as a string literal: `export const oceanTheme =
|
|
112
|
+
* defineTheme({name: 'ocean', ...})`. Null whenever only running the module
|
|
113
|
+
* could tell (a variable, a factory, a spread after the name, `extends`
|
|
114
|
+
* alone), so nothing is judged that a build would decide.
|
|
115
|
+
* @param {string} file
|
|
116
|
+
* @param {string} exportName
|
|
117
|
+
* @returns {string | null}
|
|
118
|
+
*/
|
|
119
|
+
export function literalThemeName(file: string, exportName: string): string | null;
|
|
101
120
|
/**
|
|
102
121
|
* Validate an already-LOADED integration (as produced by `loadIntegrations` —
|
|
103
122
|
* absolute contribution roots plus identity) and return its issues. This is the
|
|
@@ -26,6 +26,7 @@ import * as path from 'node:path';
|
|
|
26
26
|
import {parse as parseModule} from '@babel/parser';
|
|
27
27
|
import {isValidSemver} from '../env/semver.mjs';
|
|
28
28
|
import {findProjectCoreDir} from '../fs/paths.mjs';
|
|
29
|
+
import {KNOWN_INTEGRATION_KEYS} from '../../authoring/integration/schema.mjs';
|
|
29
30
|
import {
|
|
30
31
|
contributionFiles,
|
|
31
32
|
findSourceOnlyCandidates,
|
|
@@ -127,11 +128,36 @@ export function isListedIssue(issue) {
|
|
|
127
128
|
function checkUnknownKeys(integration, issues) {
|
|
128
129
|
const keys = integration.__unknownKeys ?? [];
|
|
129
130
|
if (keys.length === 0) return;
|
|
131
|
+
// A key one edit away from a known one is almost always a typo: say so
|
|
132
|
+
// first, since "a newer CLI" sends the author to upgrade for nothing.
|
|
133
|
+
const typos = keys
|
|
134
|
+
.map(key => ({key, known: nearestKnownKey(key)}))
|
|
135
|
+
.filter(each => each.known != null);
|
|
136
|
+
for (const {key, known} of typos) {
|
|
137
|
+
// The manifest object already declares the key it is a near miss of:
|
|
138
|
+
// renaming would give it twice, so the stray key goes. Read from what
|
|
139
|
+
// the manifest says, not the loaded integration, which fills some keys
|
|
140
|
+
// in (providerId from the package name).
|
|
141
|
+
const alreadySet = (integration.__declaredKeys ?? []).includes(
|
|
142
|
+
/** @type {string} */ (known),
|
|
143
|
+
);
|
|
144
|
+
const fix = alreadySet
|
|
145
|
+
? `Fix: remove "${key}" from ${manifestName(integration)}; it already sets "${known}".`
|
|
146
|
+
: `Fix: rename "${key}" to "${known}" in ${manifestName(integration)}.`;
|
|
147
|
+
issues.push(
|
|
148
|
+
issueWarning(
|
|
149
|
+
'unknown_manifest_key',
|
|
150
|
+
`This CLI does not know the manifest key "${key}", so it is ignored. Did you mean \`${known}\`? ${fix} If it is a key from a newer Astryx CLI instead, upgrading @astryxdesign/cli picks it up.`,
|
|
151
|
+
),
|
|
152
|
+
);
|
|
153
|
+
}
|
|
154
|
+
const rest = keys.filter(key => !typos.some(each => each.key === key));
|
|
155
|
+
if (rest.length === 0) return;
|
|
130
156
|
issues.push(
|
|
131
157
|
issueWarning(
|
|
132
158
|
'unknown_manifest_key',
|
|
133
|
-
`This CLI does not know the manifest ${
|
|
134
|
-
`${
|
|
159
|
+
`This CLI does not know the manifest ${rest.length === 1 ? 'key' : 'keys'} ` +
|
|
160
|
+
`${rest.map(key => `"${key}"`).join(', ')}, so ${rest.length === 1 ? 'it is' : 'they are'} ` +
|
|
135
161
|
`ignored — everything else in the manifest still applies. This usually ` +
|
|
136
162
|
`means the integration was published against a newer Astryx CLI than ` +
|
|
137
163
|
`this project resolves; upgrading @astryxdesign/cli picks it up.`,
|
|
@@ -146,6 +172,53 @@ function manifestName(integration) {
|
|
|
146
172
|
: 'the integration manifest';
|
|
147
173
|
}
|
|
148
174
|
|
|
175
|
+
/**
|
|
176
|
+
* The known manifest key `key` is a near miss of: a different letter case, or
|
|
177
|
+
* at most two letters added, dropped or changed (`component`, `doc`,
|
|
178
|
+
* `tempaltes`). Null when no known key is that close, or two are.
|
|
179
|
+
* @param {string} key
|
|
180
|
+
* @returns {string | null}
|
|
181
|
+
*/
|
|
182
|
+
export function nearestKnownKey(key) {
|
|
183
|
+
const lower = key.toLowerCase();
|
|
184
|
+
const limit = lower.length <= 4 ? 1 : 2;
|
|
185
|
+
/** @type {string[]} */
|
|
186
|
+
const close = [];
|
|
187
|
+
for (const known of KNOWN_INTEGRATION_KEYS) {
|
|
188
|
+
const distance = editDistance(lower, known.toLowerCase());
|
|
189
|
+
if (distance <= limit) close.push(known);
|
|
190
|
+
}
|
|
191
|
+
return close.length === 1 ? close[0] : null;
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
/**
|
|
195
|
+
* Levenshtein distance, with a swap of two neighbours counted as one edit.
|
|
196
|
+
* @param {string} a
|
|
197
|
+
* @param {string} b
|
|
198
|
+
*/
|
|
199
|
+
function editDistance(a, b) {
|
|
200
|
+
/** @type {number[][]} */
|
|
201
|
+
const d = Array.from({length: a.length + 1}, (_, i) =>
|
|
202
|
+
Array.from({length: b.length + 1}, (_, j) =>
|
|
203
|
+
i === 0 ? j : j === 0 ? i : 0,
|
|
204
|
+
),
|
|
205
|
+
);
|
|
206
|
+
for (let i = 1; i <= a.length; i++) {
|
|
207
|
+
for (let j = 1; j <= b.length; j++) {
|
|
208
|
+
const cost = a[i - 1] === b[j - 1] ? 0 : 1;
|
|
209
|
+
d[i][j] = Math.min(
|
|
210
|
+
d[i - 1][j] + 1,
|
|
211
|
+
d[i][j - 1] + 1,
|
|
212
|
+
d[i - 1][j - 1] + cost,
|
|
213
|
+
);
|
|
214
|
+
if (i > 1 && j > 1 && a[i - 1] === b[j - 2] && a[i - 2] === b[j - 1]) {
|
|
215
|
+
d[i][j] = Math.min(d[i][j], d[i - 2][j - 2] + 1);
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
return d[a.length][b.length];
|
|
220
|
+
}
|
|
221
|
+
|
|
149
222
|
/**
|
|
150
223
|
* Why a declared root cannot be read as a folder, or null when it can.
|
|
151
224
|
* A missing root keeps its own issue; a root that is a file or that the
|
|
@@ -1005,13 +1078,20 @@ async function checkComponents(integration, issues) {
|
|
|
1005
1078
|
const docName = docPath
|
|
1006
1079
|
? path.basename(docPath)
|
|
1007
1080
|
: `${record.name}.doc.mjs`;
|
|
1081
|
+
let message = error.message;
|
|
1008
1082
|
let fix = `Fix: add ${record.name}.tsx beside ${docName}.`;
|
|
1009
1083
|
const stamp = docPath ? readContributionStamp(docPath, false) : null;
|
|
1010
1084
|
if (stamp && stamp.type !== 'component' && integration.__packageDir) {
|
|
1011
1085
|
context ??= createFixContext(integration.__packageDir, integration);
|
|
1012
1086
|
fix = notAComponentFix(context, docPath, stamp);
|
|
1087
|
+
} else {
|
|
1088
|
+
const other = docPath ? otherSourceFor(docPath) : null;
|
|
1089
|
+
if (other) {
|
|
1090
|
+
message = `${message.replace(/\.$/u, '')}: found ${other}, but a component source must be a .tsx file.`;
|
|
1091
|
+
fix = `Fix: rename ${other} to ${record.name}.tsx (and point its package export at the new file).`;
|
|
1092
|
+
}
|
|
1013
1093
|
}
|
|
1014
|
-
issues.push(issueError('invalid_component', `${
|
|
1094
|
+
issues.push(issueError('invalid_component', `${message} ${fix}`));
|
|
1015
1095
|
}
|
|
1016
1096
|
/** @type {Set<string>} sources a case-only rename is reported for */
|
|
1017
1097
|
const reportedSources = new Set();
|
|
@@ -1104,6 +1184,21 @@ function docStemOf(file) {
|
|
|
1104
1184
|
return suffix ? file.slice(0, -suffix.length) : file;
|
|
1105
1185
|
}
|
|
1106
1186
|
|
|
1187
|
+
/**
|
|
1188
|
+
* A same-stem source discovery does not read: `.jsx`, `.js`, `.ts` or `.mjs`.
|
|
1189
|
+
* @param {string} docPath
|
|
1190
|
+
* @returns {string | null} its file name
|
|
1191
|
+
*/
|
|
1192
|
+
function otherSourceFor(docPath) {
|
|
1193
|
+
const stem = docStemOf(path.basename(docPath));
|
|
1194
|
+
const dir = path.dirname(docPath);
|
|
1195
|
+
return (
|
|
1196
|
+
['.jsx', '.js', '.ts', '.mjs']
|
|
1197
|
+
.map(extension => `${stem}${extension}`)
|
|
1198
|
+
.find(file => fs.existsSync(path.join(dir, file))) ?? null
|
|
1199
|
+
);
|
|
1200
|
+
}
|
|
1201
|
+
|
|
1107
1202
|
/**
|
|
1108
1203
|
* The component docs under a root, read from the real directory listings:
|
|
1109
1204
|
* those beside a source whose name differs only in letter case (which an
|
|
@@ -1370,6 +1465,80 @@ async function checkThemes(integration, issues) {
|
|
|
1370
1465
|
}
|
|
1371
1466
|
}
|
|
1372
1467
|
|
|
1468
|
+
/**
|
|
1469
|
+
* The `name` a theme source passes to defineTheme for its exported theme,
|
|
1470
|
+
* when the file says it as a string literal: `export const oceanTheme =
|
|
1471
|
+
* defineTheme({name: 'ocean', ...})`. Null whenever only running the module
|
|
1472
|
+
* could tell (a variable, a factory, a spread after the name, `extends`
|
|
1473
|
+
* alone), so nothing is judged that a build would decide.
|
|
1474
|
+
* @param {string} file
|
|
1475
|
+
* @param {string} exportName
|
|
1476
|
+
* @returns {string | null}
|
|
1477
|
+
*/
|
|
1478
|
+
export function literalThemeName(file, exportName) {
|
|
1479
|
+
let ast;
|
|
1480
|
+
try {
|
|
1481
|
+
ast = parseModule(fs.readFileSync(file, 'utf8'), {
|
|
1482
|
+
sourceType: 'module',
|
|
1483
|
+
plugins: ['typescript', 'jsx'],
|
|
1484
|
+
errorRecovery: true,
|
|
1485
|
+
});
|
|
1486
|
+
} catch {
|
|
1487
|
+
return null;
|
|
1488
|
+
}
|
|
1489
|
+
/** @type {any} */
|
|
1490
|
+
let init = null;
|
|
1491
|
+
for (const node of ast.program.body) {
|
|
1492
|
+
const declaration =
|
|
1493
|
+
node.type === 'ExportNamedDeclaration' ? node.declaration : node;
|
|
1494
|
+
if (declaration?.type !== 'VariableDeclaration') continue;
|
|
1495
|
+
for (const declarator of declaration.declarations) {
|
|
1496
|
+
if (
|
|
1497
|
+
declarator.id.type === 'Identifier' &&
|
|
1498
|
+
declarator.id.name === exportName
|
|
1499
|
+
) {
|
|
1500
|
+
init = declarator.init;
|
|
1501
|
+
}
|
|
1502
|
+
}
|
|
1503
|
+
}
|
|
1504
|
+
while (
|
|
1505
|
+
init?.type === 'TSAsExpression' ||
|
|
1506
|
+
init?.type === 'TSSatisfiesExpression'
|
|
1507
|
+
) {
|
|
1508
|
+
init = init.expression;
|
|
1509
|
+
}
|
|
1510
|
+
if (init?.type !== 'CallExpression') return null;
|
|
1511
|
+
const callee =
|
|
1512
|
+
init.callee.type === 'Identifier'
|
|
1513
|
+
? init.callee.name
|
|
1514
|
+
: init.callee.type === 'MemberExpression' &&
|
|
1515
|
+
init.callee.property.type === 'Identifier'
|
|
1516
|
+
? init.callee.property.name
|
|
1517
|
+
: null;
|
|
1518
|
+
if (callee !== 'defineTheme') return null;
|
|
1519
|
+
const [config] = init.arguments;
|
|
1520
|
+
if (config?.type !== 'ObjectExpression') return null;
|
|
1521
|
+
/** @type {string | null} */
|
|
1522
|
+
let name = null;
|
|
1523
|
+
for (const property of config.properties) {
|
|
1524
|
+
if (property.type === 'SpreadElement') {
|
|
1525
|
+
name = null;
|
|
1526
|
+
continue;
|
|
1527
|
+
}
|
|
1528
|
+
if (property.type !== 'ObjectProperty' || property.computed) continue;
|
|
1529
|
+
const key =
|
|
1530
|
+
property.key.type === 'Identifier'
|
|
1531
|
+
? property.key.name
|
|
1532
|
+
: property.key.type === 'StringLiteral'
|
|
1533
|
+
? property.key.value
|
|
1534
|
+
: null;
|
|
1535
|
+
if (key !== 'name') continue;
|
|
1536
|
+
name =
|
|
1537
|
+
property.value.type === 'StringLiteral' ? property.value.value : null;
|
|
1538
|
+
}
|
|
1539
|
+
return name;
|
|
1540
|
+
}
|
|
1541
|
+
|
|
1373
1542
|
/**
|
|
1374
1543
|
* A warning for each contribution file a reader reads (the docs and sources
|
|
1375
1544
|
* `integration verify` expects in the tarball) that the user running astryx
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@astryxdesign/cli",
|
|
3
|
-
"version": "0.7.3-canary.
|
|
3
|
+
"version": "0.7.3-canary.cb489ff",
|
|
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",
|
|
@@ -106,10 +106,10 @@
|
|
|
106
106
|
"zod": "^4.4.3"
|
|
107
107
|
},
|
|
108
108
|
"peerDependencies": {
|
|
109
|
-
"@astryxdesign/charts": "0.7.3-canary.
|
|
110
|
-
"@astryxdesign/core": "0.7.3-canary.
|
|
111
|
-
"@astryxdesign/lab": "0.7.3-canary.
|
|
112
|
-
"@astryxdesign/theme-neutral": "0.7.3-canary.
|
|
109
|
+
"@astryxdesign/charts": "0.7.3-canary.cb489ff",
|
|
110
|
+
"@astryxdesign/core": "0.7.3-canary.cb489ff",
|
|
111
|
+
"@astryxdesign/lab": "0.7.3-canary.cb489ff",
|
|
112
|
+
"@astryxdesign/theme-neutral": "0.7.3-canary.cb489ff"
|
|
113
113
|
},
|
|
114
114
|
"peerDependenciesMeta": {
|
|
115
115
|
"@astryxdesign/charts": {
|
|
@@ -126,10 +126,10 @@
|
|
|
126
126
|
}
|
|
127
127
|
},
|
|
128
128
|
"devDependencies": {
|
|
129
|
-
"@astryxdesign/charts": "0.7.3-canary.
|
|
130
|
-
"@astryxdesign/core": "0.7.3-canary.
|
|
131
|
-
"@astryxdesign/lab": "0.7.3-canary.
|
|
132
|
-
"@astryxdesign/theme-neutral": "0.7.3-canary.
|
|
129
|
+
"@astryxdesign/charts": "0.7.3-canary.cb489ff",
|
|
130
|
+
"@astryxdesign/core": "0.7.3-canary.cb489ff",
|
|
131
|
+
"@astryxdesign/lab": "0.7.3-canary.cb489ff",
|
|
132
|
+
"@astryxdesign/theme-neutral": "0.7.3-canary.cb489ff",
|
|
133
133
|
"@heroicons/react": "^2.2.0",
|
|
134
134
|
"@stylexjs/stylex": "^0.19.0",
|
|
135
135
|
"@types/babel__core": "^7.20.5",
|