@astryxdesign/cli 0.7.3-canary.b74cf21 → 0.7.3-canary.cbe384c

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.
@@ -173,8 +173,23 @@ export async function readDocView(file, options) {
173
173
  );
174
174
  if (result.loadFailed) throw result.loadFailure;
175
175
  if (result.missing) {
176
- if (strict)
176
+ if (strict) {
177
+ // A doc that exports nothing its reader takes (an empty file, or one
178
+ // with other exports) is said plainly, with what it does export and
179
+ // the fix; the schema would only say "(root): Invalid input".
180
+ const exported =
181
+ options.exports ??
182
+ /** @type {Record<string, readonly string[]>} */ (DOC_EXPORTS)[
183
+ options.root
184
+ ] ??
185
+ [];
186
+ const problem =
187
+ result.missingValue === undefined
188
+ ? await missingDocProblem(file, options, exported)
189
+ : null;
190
+ if (problem) throw new Error(`${options.label ?? file} ${problem}`);
177
191
  parserFor(options.root)(result.missingValue, options.label ?? file);
192
+ }
178
193
  return result.missingValue;
179
194
  }
180
195
  if (strict && result.failed) throw result.failure;
@@ -182,6 +197,49 @@ export async function readDocView(file, options) {
182
197
  return result.view;
183
198
  }
184
199
 
200
+ /**
201
+ * Why a doc file exports no doc, with the fix: it is empty, or it exports
202
+ * other names than the ones its reader takes. Null when neither explains it.
203
+ * @param {string} file
204
+ * @param {ReadOptions} options
205
+ * @param {readonly string[]} exported the export names the reader takes
206
+ * @returns {Promise<string | null>}
207
+ */
208
+ async function missingDocProblem(file, options, exported) {
209
+ // A theme descriptor is read statically, never imported.
210
+ if (options.root === 'themes') return null;
211
+ const fix =
212
+ 'Fix: export the doc object as the default export: `export default {type: ..., name: ..., ...}`.';
213
+ let text;
214
+ try {
215
+ text = fs.readFileSync(file, 'utf8');
216
+ } catch {
217
+ return null;
218
+ }
219
+ const code = text
220
+ .replace(/^\uFEFF/u, '')
221
+ .replace(/\/\*[\s\S]*?\*\//gu, '')
222
+ .replace(/(^|[^:])\/\/.*$/gmu, '$1')
223
+ .trim();
224
+ if (code === '') return `is empty, so it documents nothing. ${fix}`;
225
+ /** @type {string[]} */
226
+ let names;
227
+ try {
228
+ const mod = await LOADERS[options.loader ?? 'user'](file);
229
+ names = Object.keys(mod ?? {}).filter(name => name !== 'default');
230
+ } catch {
231
+ return null;
232
+ }
233
+ const takes = exported.map(name =>
234
+ name === 'default' ? 'default export' : `\`${name}\` export`,
235
+ );
236
+ const found =
237
+ names.length > 0
238
+ ? ` (it exports ${names.map(name => `\`${name}\``).join(', ')})`
239
+ : ' (it exports nothing)';
240
+ return `has no ${takes.join(' or ')}${found}, so it documents nothing. ${fix}`;
241
+ }
242
+
185
243
  /**
186
244
  * Load one file as its root reads it: the doc its module exports and, for a
187
245
  * component or hook, the translation it exports for `lang`.
@@ -109,10 +109,19 @@ describe('readDocView', () => {
109
109
  }
110
110
  });
111
111
 
112
- it("reads a file with no doc as undefined, or as its parser's error when checked", async () => {
112
+ it('reads a file with no doc as undefined, or, checked, says what it exports instead', async () => {
113
113
  const file = write('Empty.doc.mjs', 'export const unrelated = 1;\n');
114
114
  await expect(loadDocs(file)).resolves.toBeUndefined();
115
- await expect(loadComponentDoc(file)).rejects.toThrow(`${file} is invalid`);
115
+ await expect(loadComponentDoc(file)).rejects.toThrow(
116
+ `${file} has no default export or \`docs\` export (it exports \`unrelated\`), so it documents nothing. Fix: export the doc object as the default export`,
117
+ );
118
+ });
119
+
120
+ it('says a checked doc file is empty', async () => {
121
+ const file = write('Blank.doc.mjs', '// nothing yet\n');
122
+ await expect(loadComponentDoc(file)).rejects.toThrow(
123
+ `${file} is empty, so it documents nothing.`,
124
+ );
116
125
  });
117
126
 
118
127
  it('applies the translation a module exports for the reading language', async () => {
@@ -45,13 +45,14 @@ export function findManifestPaths(dir: string): string[];
45
45
  * @param {string} file absolute manifest path
46
46
  * @param {string} [label] used in error messages
47
47
  * @param {{fresh?: boolean}} [options]
48
- * @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}>}
48
+ * @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}>}
49
49
  */
50
50
  export function loadManifest(file: string, label?: string, { fresh }?: {
51
51
  fresh?: boolean;
52
52
  }): Promise<{
53
53
  manifest: import("../../authoring/integration/type").AstryxIntegration;
54
54
  unknownKeys: string[];
55
+ declaredKeys: string[];
55
56
  debug?: import("../../authoring/debug/type").DebugEventHandler;
56
57
  gapReport?: import("../../authoring/gap-report/type").GapReportHandler;
57
58
  gapReportError?: string;
@@ -147,6 +148,8 @@ export function loadIntegrations(specs?: string[], { cwd, fresh, resolveProvider
147
148
  * set on a package whose provider ID an earlier-loaded package already
148
149
  * claims; it contributes nothing and is reported as a `duplicate_provider`
149
150
  * warning
151
+ * @property {string[]} [__declaredKeys] the keys the manifest object itself
152
+ * declares, before any is filled in (providerId from the package name)
150
153
  * @property {string[]} [__unknownKeys] manifest keys this CLI does not know —
151
154
  * surfaced as a warning; the rest of the manifest still contributes
152
155
  * @property {boolean} [__autolinked] loaded because the project declares the
@@ -240,6 +243,11 @@ export type LoadedIntegration = {
240
243
  claimedBy: string;
241
244
  message: string;
242
245
  } | undefined;
246
+ /**
247
+ * the keys the manifest object itself
248
+ * declares, before any is filled in (providerId from the package name)
249
+ */
250
+ __declaredKeys?: string[] | undefined;
243
251
  /**
244
252
  * manifest keys this CLI does not know —
245
253
  * surfaced as a warning; the rest of the manifest still contributes
@@ -73,6 +73,8 @@ import {resolveProviders} from './provider-resolution.mjs';
73
73
  * set on a package whose provider ID an earlier-loaded package already
74
74
  * claims; it contributes nothing and is reported as a `duplicate_provider`
75
75
  * warning
76
+ * @property {string[]} [__declaredKeys] the keys the manifest object itself
77
+ * declares, before any is filled in (providerId from the package name)
76
78
  * @property {string[]} [__unknownKeys] manifest keys this CLI does not know —
77
79
  * surfaced as a warning; the rest of the manifest still contributes
78
80
  * @property {boolean} [__autolinked] loaded because the project declares the
@@ -215,7 +217,7 @@ function parseDiscoverSourceExport(value, label) {
215
217
  * @param {string} file absolute manifest path
216
218
  * @param {string} [label] used in error messages
217
219
  * @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}>}
220
+ * @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
221
  */
220
222
  export async function loadManifest(
221
223
  file,
@@ -224,6 +226,7 @@ export async function loadManifest(
224
226
  ) {
225
227
  const mod = await importUserModule(file, {fresh});
226
228
  const raw = mod?.default;
229
+ if (raw === undefined) throw new Error(noDefaultExportMessage(file, label, mod));
227
230
  const baseManifest = parseIntegrationBase(raw, label);
228
231
  const gapReport = parseGapReportHandlerExport(mod?.gapReport, label);
229
232
  const discover = parseDiscoverSourceExport(mod?.discover, label);
@@ -276,6 +279,8 @@ export async function loadManifest(
276
279
  ...(cliCommand == null ? {} : {cliCommand}),
277
280
  },
278
281
  unknownKeys: unknownIntegrationKeys(raw),
282
+ declaredKeys:
283
+ raw != null && typeof raw === 'object' ? Object.keys(raw) : [],
279
284
  debug:
280
285
  typeof mod?.debug === 'function'
281
286
  ? /** @type {import('../../authoring/debug/type').DebugEventHandler} */ (
@@ -291,6 +296,30 @@ export async function loadManifest(
291
296
  };
292
297
  }
293
298
 
299
+ /**
300
+ * Why a manifest has no default export, said plainly instead of as a schema
301
+ * failure on `undefined`: the file is empty, or it exports other names.
302
+ * @param {string} file
303
+ * @param {string} label
304
+ * @param {Record<string, unknown> | undefined} mod
305
+ */
306
+ function noDefaultExportMessage(file, label, mod) {
307
+ const fix = `Fix: export the manifest object as the default export: \`export default {components: './components'}\`, naming the roots the package has.`;
308
+ let text = '';
309
+ try {
310
+ text = fs.readFileSync(file, 'utf8');
311
+ } catch {
312
+ // Unreadable now: say only what is missing.
313
+ }
314
+ const names = Object.keys(mod ?? {}).filter(name => name !== 'default');
315
+ if (text.trim() === '') return `${label} is empty. ${fix}`;
316
+ const found =
317
+ names.length > 0
318
+ ? ` (it exports ${names.map(name => `\`${name}\``).join(', ')})`
319
+ : '';
320
+ return `${label} has no default export${found}. ${fix}`;
321
+ }
322
+
294
323
  /**
295
324
  * Load and validate a manifest module's default export against the integration
296
325
  * schema. Throws if the default export is missing or invalid. Exposed for
@@ -398,6 +427,8 @@ export async function loadLocalIntegration(packageDir, {fresh = false} = {}) {
398
427
  let manifest;
399
428
  /** @type {string[]} */
400
429
  let unknownKeys;
430
+ /** @type {string[]} */
431
+ let declaredKeys;
401
432
  /** @type {import('../../authoring/debug/type').DebugEventHandler | undefined} */
402
433
  let debugHandler;
403
434
  /** @type {import('../../authoring/gap-report/type').GapReportHandler | undefined} */
@@ -416,6 +447,7 @@ export async function loadLocalIntegration(packageDir, {fresh = false} = {}) {
416
447
  ({
417
448
  manifest,
418
449
  unknownKeys,
450
+ declaredKeys,
419
451
  debug: debugHandler,
420
452
  gapReport: gapReportHandler,
421
453
  gapReportError,
@@ -464,6 +496,7 @@ export async function loadLocalIntegration(packageDir, {fresh = false} = {}) {
464
496
  __cliCommandError: cliCommandError,
465
497
  __agentDocsError: agentDocsError,
466
498
  __unknownKeys: unknownKeys,
499
+ __declaredKeys: declaredKeys,
467
500
  __debug: debugHandler,
468
501
  __gapReport: gapReportHandler,
469
502
  __gapReportError: gapReportError,
@@ -514,6 +547,8 @@ export async function loadIntegrations(
514
547
  let manifest;
515
548
  /** @type {string[]} */
516
549
  let unknownKeys;
550
+ /** @type {string[]} */
551
+ let declaredKeys;
517
552
  /** @type {import('../../authoring/debug/type').DebugEventHandler | undefined} */
518
553
  let debugHandler;
519
554
  /** @type {import('../../authoring/gap-report/type').GapReportHandler | undefined} */
@@ -532,6 +567,7 @@ export async function loadIntegrations(
532
567
  ({
533
568
  manifest,
534
569
  unknownKeys,
570
+ declaredKeys,
535
571
  debug: debugHandler,
536
572
  gapReport: gapReportHandler,
537
573
  gapReportError,
@@ -587,6 +623,7 @@ export async function loadIntegrations(
587
623
  __cliCommandError: cliCommandError,
588
624
  __agentDocsError: agentDocsError,
589
625
  __unknownKeys: unknownKeys,
626
+ __declaredKeys: declaredKeys,
590
627
  __debug: debugHandler,
591
628
  __gapReport: gapReportHandler,
592
629
  __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 ${keys.length === 1 ? 'key' : 'keys'} ` +
134
- `${keys.map(key => `"${key}"`).join(', ')}, so ${keys.length === 1 ? 'it is' : 'they are'} ` +
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', `${error.message} ${fix}`));
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.b74cf21",
3
+ "version": "0.7.3-canary.cbe384c",
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.b74cf21",
110
- "@astryxdesign/core": "0.7.3-canary.b74cf21",
111
- "@astryxdesign/lab": "0.7.3-canary.b74cf21",
112
- "@astryxdesign/theme-neutral": "0.7.3-canary.b74cf21"
109
+ "@astryxdesign/charts": "0.7.3-canary.cbe384c",
110
+ "@astryxdesign/core": "0.7.3-canary.cbe384c",
111
+ "@astryxdesign/lab": "0.7.3-canary.cbe384c",
112
+ "@astryxdesign/theme-neutral": "0.7.3-canary.cbe384c"
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.b74cf21",
130
- "@astryxdesign/core": "0.7.3-canary.b74cf21",
131
- "@astryxdesign/lab": "0.7.3-canary.b74cf21",
132
- "@astryxdesign/theme-neutral": "0.7.3-canary.b74cf21",
129
+ "@astryxdesign/charts": "0.7.3-canary.cbe384c",
130
+ "@astryxdesign/core": "0.7.3-canary.cbe384c",
131
+ "@astryxdesign/lab": "0.7.3-canary.cbe384c",
132
+ "@astryxdesign/theme-neutral": "0.7.3-canary.cbe384c",
133
133
  "@heroicons/react": "^2.2.0",
134
134
  "@stylexjs/stylex": "^0.19.0",
135
135
  "@types/babel__core": "^7.20.5",