@astryxdesign/cli 0.6.4-canary.06c8fa3 → 0.6.4-canary.10dd683

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.
Files changed (91) hide show
  1. package/README.md +66 -63
  2. package/api/component/_adapter.d.mts +0 -25
  3. package/api/component/_adapter.mjs +5 -59
  4. package/api/component/component.d.mts +3 -6
  5. package/api/component/component.doc.mjs +10 -23
  6. package/api/component/component.mjs +9 -249
  7. package/api/component/component.type.d.mts +0 -25
  8. package/api/component/component.type.mjs +0 -44
  9. package/api/docs/docs.test.mjs +0 -2
  10. package/api/doctor/doctor.d.mts +3 -8
  11. package/api/doctor/doctor.mjs +9 -90
  12. package/api/doctor/doctor.test.mjs +10 -122
  13. package/api/index.d.mts +2 -1
  14. package/api/index.mjs +4 -4
  15. package/api/integration/pack-check.mjs +3 -28
  16. package/api/json/index.ts +1 -0
  17. package/api/layout/_adapter.d.mts +34 -0
  18. package/api/layout/_adapter.mjs +148 -0
  19. package/api/layout/check/check.d.mts +16 -0
  20. package/api/layout/check/check.mjs +40 -0
  21. package/api/layout/expand/expand.d.mts +22 -0
  22. package/api/layout/expand/expand.mjs +155 -0
  23. package/api/layout/expand/expand.path-safety.test.mjs +53 -0
  24. package/api/layout/grammar/grammar.d.mts +13 -0
  25. package/api/layout/grammar/grammar.mjs +87 -0
  26. package/api/layout/layout.d.mts +6 -0
  27. package/api/layout/layout.mjs +17 -0
  28. package/api/layout/layout.test.mjs +297 -0
  29. package/api/layout/layout.type.d.mts +89 -0
  30. package/api/layout/layout.type.mjs +103 -0
  31. package/api/layout/layoutCheck.doc.d.mts +11 -0
  32. package/api/layout/layoutCheck.doc.mjs +85 -0
  33. package/api/layout/layoutExpand.doc.d.mts +11 -0
  34. package/api/layout/layoutExpand.doc.mjs +107 -0
  35. package/api/layout/layoutGrammar.doc.d.mts +11 -0
  36. package/api/layout/layoutGrammar.doc.mjs +57 -0
  37. package/api/search/search.test.mjs +0 -18
  38. package/api/template/template-integration.test.mjs +65 -1
  39. package/api/template/template.mjs +1 -1
  40. package/api/upgrade/run/run.mjs +4 -6
  41. package/api/upgrade/upgrade.type.mjs +2 -2
  42. package/assets/codemods/__tests__/runner.test.mjs +1 -3
  43. package/assets/codemods/integration-runner.mjs +3 -3
  44. package/assets/codemods/runner.mjs +4 -5
  45. package/authoring/config/config.doc.mjs +1 -1
  46. package/authoring/config/type.ts +2 -2
  47. package/authoring/doctypes/command/command.doc.mjs +1 -1
  48. package/authoring/doctypes/command/type.ts +1 -1
  49. package/clients/cli/command-result-coverage.test.mjs +7 -7
  50. package/clients/cli/commands/component/index.mjs +55 -152
  51. package/clients/cli/commands/component-ownership.test.mjs +0 -89
  52. package/clients/cli/commands/component.doc.mjs +6 -23
  53. package/clients/cli/commands/debug-result-summary.test.mjs +2 -2
  54. package/clients/cli/commands/docs.test.mjs +0 -29
  55. package/clients/cli/commands/layout-check.doc.mjs +65 -0
  56. package/clients/cli/commands/layout-expand.doc.mjs +83 -0
  57. package/clients/cli/commands/layout-grammar.doc.mjs +30 -0
  58. package/clients/cli/commands/layout.doc.mjs +34 -0
  59. package/clients/cli/commands/layout.error-codes.test.mjs +66 -0
  60. package/clients/cli/commands/layout.exit-parity.test.mjs +41 -0
  61. package/clients/cli/commands/layout.mjs +275 -0
  62. package/clients/cli/commands/layout.path-help.test.mjs +33 -0
  63. package/clients/cli/commands/layout.stdin-cap.test.mjs +47 -0
  64. package/clients/cli/commands/layout.text-fields.test.mjs +39 -0
  65. package/clients/cli/commands/text-json-parity.test.mjs +17 -0
  66. package/clients/cli/index.mjs +4 -0
  67. package/clients/cli/lib/exit-codes.test.mjs +8 -1
  68. package/clients/cli/lib/json-shim.mjs +14 -24
  69. package/clients/cli/lib/json-shim.test.mjs +20 -6
  70. package/clients/cli/lib/manifest.mjs +8 -2
  71. package/clients/cli/lib/manifest.test.mjs +2 -5
  72. package/foundation/discovery/template-adapter.mjs +1 -1
  73. package/foundation/doc-compiler/doc-loads.test.mjs +12 -0
  74. package/foundation/doc-compiler/tree.test.mjs +1 -9
  75. package/foundation/response/response-types.doc.mjs +17 -5
  76. package/foundation/response/response-types.doc.test.mjs +0 -23
  77. package/foundation/xle/browser.d.mts +3 -3
  78. package/foundation/xle/browser.mjs +3 -3
  79. package/foundation/xle/expand.mjs +2 -2
  80. package/foundation/xle/parse.mjs +1 -1
  81. package/foundation/xle/print.mjs +2 -2
  82. package/foundation/xle/splice.mjs +1 -1
  83. package/package.json +9 -9
  84. package/api/integration/pack-check.lifecycle-output.test.mjs +0 -105
  85. package/api/upgrade/run/files-changed.test.mjs +0 -111
  86. package/assets/codemods/file-count.test.mjs +0 -163
  87. package/assets/docs/tree/component-lookups.doc.mjs +0 -149
  88. package/clients/cli/commands/component-batch.test.mjs +0 -341
  89. package/clients/cli/lib/parse-error-format.test.mjs +0 -81
  90. package/foundation/response/batch.type.d.mts +0 -33
  91. package/foundation/response/batch.type.mjs +0 -34
@@ -0,0 +1,39 @@
1
+ // Copyright (c) Meta Platforms, Inc. and affiliates.
2
+
3
+ /**
4
+ * @file `layout expand` text output names its fields after the JSON keys, so
5
+ * the two views stay greppable against each other.
6
+ */
7
+
8
+ import {describe, it, expect, beforeEach, afterEach} from 'vitest';
9
+ import * as fs from 'node:fs';
10
+ import * as path from 'node:path';
11
+ import {runCli} from '../../../test-utils/run-cli.mjs';
12
+
13
+ const SLOW = 60_000;
14
+
15
+ describe('layout expand text fields mirror the JSON keys', () => {
16
+ let cwd;
17
+ beforeEach(() => {
18
+ // Inside the workspace so @astryxdesign/core resolves.
19
+ cwd = fs.mkdtempSync(path.join(process.cwd(), '.xle-text-fields-'));
20
+ });
21
+ afterEach(() => fs.rmSync(cwd, {recursive: true, force: true}));
22
+
23
+ it('labels every record field with a key of the layout.expand data', async () => {
24
+ const expr = 'V > B + {not-a-real-block}';
25
+ const json = await runCli(['layout', 'expand', expr, './a', '--loose', '--json'], cwd);
26
+ expect(json.status).toBe(0);
27
+ const {data} = JSON.parse(json.stdout);
28
+ expect(data.todos.length).toBeGreaterThan(0);
29
+
30
+ const human = await runCli(['layout', 'expand', expr, './b', '--loose'], cwd);
31
+ expect(human.status).toBe(0);
32
+ const fields = human.stdout
33
+ .split('\n')
34
+ .map(line => /^([A-Za-z]+):\s/.exec(line)?.[1])
35
+ .filter(Boolean);
36
+ expect(fields).toEqual(['componentsUsed', 'todos']);
37
+ for (const field of fields) expect(Object.keys(data)).toContain(field);
38
+ }, SLOW);
39
+ });
@@ -377,6 +377,23 @@ const CASES = [
377
377
  // Needs a packable project; pack itself may exit differently.
378
378
  skipFieldChecks: true,
379
379
  },
380
+ // ── Layout command: remove these cases when the layout command is deleted ──
381
+ {
382
+ name: 'layout check',
383
+ args: ['layout', 'check', 'Button'],
384
+ skipFieldChecks: true,
385
+ },
386
+ {
387
+ name: 'layout expand',
388
+ args: ['layout', 'expand', 'Button'],
389
+ skipFieldChecks: true,
390
+ },
391
+ {
392
+ name: 'layout grammar',
393
+ args: ['layout', 'grammar'],
394
+ skipFieldChecks: true,
395
+ },
396
+ // ── End layout cases ──
380
397
  {
381
398
  name: 'manifest',
382
399
  args: ['manifest'],
@@ -103,6 +103,9 @@ export const JSON_SUPPORTED = new Set([
103
103
  'doctor integration templates',
104
104
  'doctor integration components',
105
105
  'doctor integration docs',
106
+ 'layout expand',
107
+ 'layout check',
108
+ 'layout grammar',
106
109
  ]);
107
110
 
108
111
  /**
@@ -261,6 +264,7 @@ const commands = [
261
264
  {name: 'gap-report', path: './commands/gap-report.mjs', register: 'registerGapReport'},
262
265
  // agent-docs folded into init — functions still importable from agent-docs.mjs
263
266
  {name: 'template', path: './commands/template.mjs', register: 'registerTemplate'},
267
+ {name: 'layout', path: './commands/layout.mjs', register: 'registerLayout'},
264
268
  {name: 'upgrade', path: './commands/upgrade.mjs', register: 'registerUpgrade'},
265
269
  {name: 'theme', path: './commands/build-theme.mjs', register: 'registerTheme'},
266
270
  {name: 'integration', path: './commands/integration.mjs', register: 'registerIntegration'},
@@ -34,7 +34,7 @@ manifest.commands.forEach(walk);
34
34
 
35
35
  describe('command exit codes', () => {
36
36
  it('every CommandDoc documents its exit codes', () => {
37
- expect(commandDocs.length).toBeGreaterThan(25);
37
+ expect(commandDocs.length).toBeGreaterThan(30);
38
38
  for (const doc of commandDocs) {
39
39
  expect(doc.exitCodes?.length, doc.name).toBeGreaterThan(0);
40
40
  }
@@ -54,6 +54,13 @@ describe('command exit codes', () => {
54
54
  },
55
55
  );
56
56
 
57
+ it('bare `astryx layout` exits 1 in both modes, as documented', async () => {
58
+ const doc = commandDocs.find((d) => d.name === 'layout');
59
+ expect(doc.exitCodes.find((e) => e.code === 1)?.when).toMatch(/^no subcommand/);
60
+ expect((await runCli(['layout'])).status).toBe(1);
61
+ expect((await runCli(['layout', '--json'])).status).toBe(1);
62
+ });
63
+
57
64
  it('`astryx discover` with a blank query exits 1 only when packages are discovered', async () => {
58
65
  const doc = commandDocs.find((d) => d.name === 'discover');
59
66
  expect(doc.exitCodes.find((e) => e.code === 1)?.when).toMatch(/blank query when packages are discovered/);
@@ -33,12 +33,10 @@
33
33
  * shows help because the invocation failed (`help <unknown>`, or a
34
34
  * command group with no subcommand), which exits 1.
35
35
  *
36
- * Commander writes its own "error: ..." line via configureOutput.writeErr.
37
- * The shim drops that line in both modes. Under --json the error envelope
38
- * replaces it; in text mode `handleCommanderError` writes the Astryx line
39
- * instead (`Error: <message>`, the same message the envelope carries), so
40
- * a parse failure reads like every other CLI error. Other stderr output,
41
- * such as help printed as the failure report, still passes through.
36
+ * Non-JSON behavior is preserved exactly: every code path that printed
37
+ * to stderr before still prints to stderr. Commander writes its
38
+ * "error: ..." line via configureOutput.writeErr, which we pass
39
+ * through verbatim outside of --json mode.
42
40
  */
43
41
 
44
42
  import {API_VERSION, isJsonMode, toErrorEnvelope} from '../../../foundation/response/json.mjs';
@@ -251,20 +249,11 @@ function applyShimRecursively(cmd) {
251
249
  });
252
250
  cmd.configureOutput({
253
251
  writeOut: (str) => process.stdout.write(str),
254
- // Commander's own "error: ..." line never reaches the user. Under --json a
255
- // consumer parsing both streams must not see it alongside the envelope;
256
- // in text mode it is Commander's format, not Astryx's, so an invalid
257
- // global option (`--lang zh-Hans`) printed `error: option '--lang
258
- // <locale>' argument 'zh-Hans' is invalid…` where every other CLI error
259
- // prints `Error: …`. handleCommanderError writes the Astryx line below,
260
- // for both modes, from the same message.
261
- //
262
- // ONLY that line. Commander also writes HELP through this channel when it
263
- // shows help because the invocation failed (a command group with no
264
- // subcommand), and that output is still wanted in text mode.
265
252
  writeErr: (str) => {
253
+ // Suppress Commander's "error: ..." stderr line when --json is
254
+ // active, so a JSON consumer parsing both streams doesn't see
255
+ // it alongside the envelope. Non-JSON callers are unaffected.
266
256
  if (jsonActive()) return;
267
- if (/^error:\s/i.test(str)) return;
268
257
  process.stderr.write(str);
269
258
  },
270
259
  });
@@ -443,15 +432,16 @@ export function handleCommanderError(err) {
443
432
  code: commanderCodeToErrorCode(code, message),
444
433
  });
445
434
 
446
- // Real error paths. Strip Commander's "error: " prefix once: in the envelope
447
- // the key is already `error`, and in text mode the Astryx prefix replaces it.
448
- const cleaned = message.replace(/^error:\s*/i, '');
435
+ // Real error paths.
449
436
  if (jsonActive()) {
437
+ // Strip Commander's "error: " prefix — the envelope key is `error`
438
+ // already, doubled "error" is noise.
439
+ const cleaned = message.replace(/^error:\s*/i, '');
450
440
  emitJsonError(cleaned, undefined, commanderCodeToErrorCode(code, cleaned));
451
441
  } else {
452
- // Commander's own line was suppressed above, so a parse failure reads the
453
- // same as every other CLI error — the `Error: …` line cliError prints.
454
- process.stderr.write(`Error: ${cleaned}\n`);
442
+ // Non-JSON mode: Commander already wrote the "error: ..." line
443
+ // to stderr via configureOutput.writeErr before throwing the
444
+ // CommanderError. Nothing to do — exit with the original code.
455
445
  }
456
446
  process.exit(exitCode || 1);
457
447
  }
@@ -225,6 +225,23 @@ describe('--json shim: help shown for a failed invocation is an error envelope',
225
225
  expect(parsed.error).toMatch(/bogus/);
226
226
  });
227
227
 
228
+ it('astryx layout --json (group, no subcommand) emits ERR_MISSING_ARGUMENT, exit 1', async () => {
229
+ const {status, stdout, stderr} = await runCli(['layout', '--json']);
230
+ expect(status).toBe(1);
231
+ expect(stderr).toBe('');
232
+ const parsed = parseJson(stdout);
233
+ expect(parsed).not.toHaveProperty('type');
234
+ expect(parsed.code).toBe('ERR_MISSING_ARGUMENT');
235
+ expect(parsed.suggestions.map((s) => s.name)).toContain('layout expand');
236
+ });
237
+
238
+ it('astryx layout (no --json) still prints help to stderr, exit 1', async () => {
239
+ const {status, stdout, stderr} = await runCli(['layout']);
240
+ expect(status).toBe(1);
241
+ expect(stdout).toBe('');
242
+ expect(stderr).toMatch(/Usage: astryx layout/);
243
+ });
244
+
228
245
  it('the real binary emits the same envelope for help bogus --json', () => {
229
246
  // One program per process, so the root's own outputHelp patch is used here.
230
247
  const bin = fileURLToPath(new URL('../bin/astryx.mjs', import.meta.url));
@@ -240,9 +257,6 @@ describe('--json shim: help shown for a failed invocation is an error envelope',
240
257
  });
241
258
 
242
259
  it('a group added after install gets the same error envelope', () => {
243
- // This is the only coverage of the no-subcommand path: every group the CLI
244
- // ships has an action of its own (see command-result-coverage.test.mjs), so
245
- // a group without one has to be built here.
246
260
  const program = new Command('astryx');
247
261
  installJsonShim(program);
248
262
  // Added later, so only the prototype-level patch covers its outputHelp.
@@ -268,11 +282,11 @@ describe('--json shim: help shown for a failed invocation is an error envelope',
268
282
  expect(parsed.suggestions).toEqual([{name: 'late child', reason: 'available subcommand'}]);
269
283
  });
270
284
 
271
- it('astryx help theme --json still emits the help envelope, exit 0', async () => {
272
- const {status, stdout} = await runCli(['help', 'theme', '--json']);
285
+ it('astryx help layout --json still emits the help envelope, exit 0', async () => {
286
+ const {status, stdout} = await runCli(['help', 'layout', '--json']);
273
287
  expect(status).toBe(0);
274
288
  const parsed = parseJson(stdout);
275
289
  expect(parsed.type).toBe('help');
276
- expect(parsed.data.command).toBe('astryx theme');
290
+ expect(parsed.data.command).toBe('astryx layout');
277
291
  });
278
292
  });
@@ -51,7 +51,6 @@ export const RESPONSE_TYPES = {
51
51
  init: ['init.run', 'init.remove'],
52
52
  component: [
53
53
  'component.list',
54
- 'component.batch',
55
54
  'component.detail',
56
55
  'component.detail.props',
57
56
  'component.detail.source',
@@ -100,6 +99,9 @@ export const RESPONSE_TYPES = {
100
99
  'doctor integration templates': ['integration.template-conflicts'],
101
100
  'doctor integration components': ['integration.component-conflicts'],
102
101
  'doctor integration docs': ['integration.doc-conflicts'],
102
+ 'layout expand': ['layout.expand'],
103
+ 'layout check': ['layout.check'],
104
+ 'layout grammar': ['layout.grammar'],
103
105
  };
104
106
 
105
107
  /**
@@ -110,7 +112,6 @@ const EXAMPLES = {
110
112
  component: [
111
113
  'astryx component',
112
114
  'astryx component XDSButton',
113
- 'astryx component Button Badge Text',
114
115
  'astryx component XDSButton --props --json',
115
116
  ],
116
117
  docs: [
@@ -180,6 +181,11 @@ const EXAMPLES = {
180
181
  'astryx doctor integration docs @acme/widgets --json',
181
182
  ],
182
183
  init: ['astryx init', 'astryx init --all --json'],
184
+ 'layout expand': [
185
+ `astryx layout expand 'V[g6] > C{card-callout}*4' ./src/Page.tsx`,
186
+ ],
187
+ 'layout check': [`astryx layout check 'A[cp6] > L > LC > S[p6]' --json`],
188
+ 'layout grammar': ['astryx layout grammar'],
183
189
  };
184
190
 
185
191
  /**
@@ -156,10 +156,7 @@ describe('manifest: shape', () => {
156
156
 
157
157
  it('derives arguments from Commander metadata', () => {
158
158
  const component = allEntries.find((c) => c.name === 'component');
159
- const names = component.arguments.find((a) => a.name === 'names');
160
- expect(names.required).toBe(false);
161
- expect(names.variadic).toBe(true);
162
- expect(names.description).toContain('Two or more return one ordered batch');
159
+ expect(component.arguments.map((a) => a.name)).toContain('name');
163
160
  const themeBuild = allEntries.find((c) => c.name === 'theme build');
164
161
  expect(themeBuild.arguments.map((a) => a.name)).toContain('files');
165
162
  const files = themeBuild.arguments.find((a) => a.name === 'files');
@@ -196,7 +193,7 @@ describe('manifest: e2e', () => {
196
193
  // Enriched: the full structured manifest is embedded.
197
194
  expect(parsed.data.manifest).toBeDefined();
198
195
  expect(parsed.data.manifest.commands.find((c) => c.name === 'component').responseTypes)
199
- .toEqual(expect.arrayContaining(['component.list', 'component.batch']));
196
+ .toContain('component.list');
200
197
  });
201
198
  });
202
199
 
@@ -4,7 +4,7 @@
4
4
  * @file Shared template discovery + IO.
5
5
  *
6
6
  * Owns everything the template leaves (list/show/skeleton/copy) AND other
7
- * commands (component, search, init, discover, Doctor integration)
7
+ * commands (component, layout, search, init, discover, Doctor integration)
8
8
  * share: template discovery across core/external/integration sources, the
9
9
  * template-spec loaders, and the cross-command helpers (stripTemplateAssetRefs,
10
10
  * findShowcase, findRelatedBlocks, extractComponents, listTemplates). The
@@ -191,6 +191,18 @@ const RUNNERS = {
191
191
  'import ./integration.doc.mjs',
192
192
  ],
193
193
  },
194
+ 'clients/cli/commands/layout.mjs': {
195
+ runs: SELF_DOCS,
196
+ sites: [
197
+ 'import ../../../api/layout/layoutCheck.doc.mjs',
198
+ 'import ../../../api/layout/layoutExpand.doc.mjs',
199
+ 'import ../../../api/layout/layoutGrammar.doc.mjs',
200
+ 'import ./layout-check.doc.mjs',
201
+ 'import ./layout-expand.doc.mjs',
202
+ 'import ./layout-grammar.doc.mjs',
203
+ 'import ./layout.doc.mjs',
204
+ ],
205
+ },
194
206
  'clients/cli/commands/search.mjs': {
195
207
  runs: SELF_DOCS,
196
208
  sites: [
@@ -497,14 +497,7 @@ describe("the CLI's own docs tree", () => {
497
497
  expect(
498
498
  tree.get('cli')?.slots.map(slot => [slot.name, slot.children]),
499
499
  ).toEqual([
500
- [
501
- 'guides',
502
- [
503
- 'cli/component-lookups',
504
- 'cli/integrations',
505
- 'cli/writing-docs',
506
- ],
507
- ],
500
+ ['guides', ['cli/integrations', 'cli/writing-docs']],
508
501
  ['reference', ['cli/commands', 'cli/api']],
509
502
  ]);
510
503
  expect(tree.get('cli/api')?.slots[0].children).toEqual([
@@ -573,7 +566,6 @@ describe("the CLI's own docs tree", () => {
573
566
  'commands',
574
567
  ]);
575
568
  expect(inputs.docs.map(d => [d.name, d.placement?.parent])).toEqual([
576
- ['component-lookups', 'namespace:cli'],
577
569
  ['integrations', 'namespace:cli'],
578
570
  ['writing-docs', 'namespace:cli'],
579
571
  ]);
@@ -37,11 +37,6 @@ export const doc = {
37
37
  description:
38
38
  'The component catalog grouped by category: `detail` (the level: names | compact | full) and `components`, the grouped map of names entries ({name, package, and optional canonical import for integrations}), brief entries, or a full ComponentDoc per entry.',
39
39
  },
40
- {
41
- value: 'component.batch',
42
- description:
43
- 'The component specialization of the shared `BatchResponse` and `BatchRow` types. An explicit programmatic selector array, or two or more CLI selectors, returns one ordered receipt: `count` plus `results`, one row per selector including duplicates. Every row carries `selector` and `status` (found | not_found | ambiguous | error). A found row carries `result`, the same {type, data} response as one selector. An ambiguous row carries `code`, `error`, and `candidates` ({package, component, kind, installed}). Other failed rows carry `code`, `error`, and optional `suggestions` ({name, reason}).',
44
- },
45
40
  {
46
41
  value: 'component.detail',
47
42
  description:
@@ -318,5 +313,22 @@ export const doc = {
318
313
  description:
319
314
  'The integration identity, structural issues, and Core doc overlaps. Each finding includes `severity` (`info` | `error`) and `relationship` (`replaces` | `extends` | `accidental`).',
320
315
  },
316
+
317
+ // layout (XLE/XLO)
318
+ {
319
+ value: 'layout.expand',
320
+ description:
321
+ 'The expansion: parsed form, generated TSX code, componentsUsed, states (count of useState hooks scaffolded), todos, blocksReferenced (each {name, mode}), warnings, and written (the output path, or null when nothing was written).',
322
+ },
323
+ {
324
+ value: 'layout.check',
325
+ description:
326
+ 'The validation result: a valid flag, the detected form, errors (each with line/col, message, formatted text, and suggestions), warnings, and the expression re-printed in both canonical surfaces (compact and outline).',
327
+ },
328
+ {
329
+ value: 'layout.grammar',
330
+ description:
331
+ "The XLE/XLO grammar cheatsheet: a text field with the full reference plus an aliases map (short name → canonical component) generated from this install's registry.",
332
+ },
321
333
  ],
322
334
  };
@@ -53,29 +53,6 @@ function expectNamed(type, fields) {
53
53
  }
54
54
 
55
55
  describe('response-types EnumDoc names every field', () => {
56
- it('component.batch names every row field and state', async () => {
57
- const res = await data(['component', 'Button', 'Badge']);
58
- expect(res.type).toBe('component.batch');
59
- expect(describedAs('component.batch')).toMatch(/BatchResponse.*BatchRow/);
60
- expectNamed('component.batch', [
61
- 'count',
62
- 'results',
63
- 'selector',
64
- 'status',
65
- 'result',
66
- 'code',
67
- 'error',
68
- 'candidates',
69
- 'package',
70
- 'component',
71
- 'kind',
72
- 'installed',
73
- 'suggestions',
74
- 'name',
75
- 'reason',
76
- ]);
77
- });
78
-
79
56
  it('component.detail: the ownership fields and parentDoc', async () => {
80
57
  const res = await data(['component', 'HStack']);
81
58
  expect(res.type).toBe('component.detail');
@@ -2,8 +2,8 @@
2
2
  // DO NOT EDIT — run `pnpm sync:api-types` to regenerate.
3
3
 
4
4
  /**
5
- * Validate an expression and return both canonical surfaces. Never throws on
6
- * invalid input; returns the errors.
5
+ * Validate an expression and return both canonical surfaces — the browser
6
+ * twin of `layout check`. Never throws on invalid input; returns the errors.
7
7
  *
8
8
  * @param {string} expression
9
9
  * @param {import('./xle-ast').Registry | import('./browser').SerializedRegistry | object} registry - serialized or hydrated
@@ -19,7 +19,7 @@ export function checkExpression(expression: string, registry: import("./xle-ast"
19
19
  loose?: boolean | undefined;
20
20
  }): import("./browser").CheckResult;
21
21
  /**
22
- * Validate + expand to TSX.
22
+ * Validate + expand to TSX — the browser twin of `layout expand`.
23
23
  * Returns either {code, ...} or {errors} (never writes files).
24
24
  *
25
25
  * @param {string} expression
@@ -44,8 +44,8 @@ function formatIssue(issue) {
44
44
  }
45
45
 
46
46
  /**
47
- * Validate an expression and return both canonical surfaces. Never throws on
48
- * invalid input; returns the errors.
47
+ * Validate an expression and return both canonical surfaces — the browser
48
+ * twin of `layout check`. Never throws on invalid input; returns the errors.
49
49
  *
50
50
  * @param {string} expression
51
51
  * @param {import('./xle-ast').Registry | import('./browser').SerializedRegistry | object} registry - serialized or hydrated
@@ -85,7 +85,7 @@ export function checkExpression(expression, registry, opts = {}) {
85
85
  }
86
86
 
87
87
  /**
88
- * Validate + expand to TSX.
88
+ * Validate + expand to TSX — the browser twin of `layout expand`.
89
89
  * Returns either {code, ...} or {errors} (never writes files).
90
90
  *
91
91
  * @param {string} expression
@@ -13,7 +13,7 @@
13
13
  *
14
14
  * @input validated doc (nodes carry .bound) + registry
15
15
  * @output expand() → {code, componentsUsed, states, todos}
16
- * @position lib/xle — last stage; the browser barrel orchestrates
16
+ * @position lib/xle — last stage; api/layout.mjs orchestrates
17
17
  */
18
18
 
19
19
  import {PAYLOAD_PROPS} from './validate.mjs';
@@ -751,7 +751,7 @@ export function expand(doc, registry, options = {}) {
751
751
  : [];
752
752
 
753
753
  const code = [
754
- `// Generated by the Astryx XLE expander — this file is the artifact; edit freely.`,
754
+ `// Generated by \`astryx layout expand\` — this file is the artifact; edit freely.`,
755
755
  ...importLines,
756
756
  ...blockSection,
757
757
  '',
@@ -302,7 +302,7 @@ function parseAttrToken(token, line) {
302
302
  * Guard against unbounded recursion in the compact parser. A layout tree this
303
303
  * deep is never hand-authored; without the cap the recursive descent blows the
304
304
  * JS call stack and surfaces a raw RangeError (→ ERR_UNKNOWN, no line/col)
305
- * instead of a located parse error. The counter is module-level so it
305
+ * instead of a located ERR_LAYOUT_PARSE. The counter is module-level so it
306
306
  * spans group / attribute sub-streams; each parse entry point resets it.
307
307
  */
308
308
  const MAX_COMPACT_DEPTH = 512;
@@ -3,8 +3,8 @@
3
3
  /**
4
4
  * @file XLE canonical printers — AST → compact (XLE) or outline (XLO) text.
5
5
  *
6
- * Used by `checkExpression` so either party (agent or human) can request the
7
- * other surface, and by round-trip conformance tests.
6
+ * Used by `astryx layout check --form …` so either party (agent or human)
7
+ * can request the other surface, and by round-trip conformance tests.
8
8
  * Printing is best-effort canonical: spelling variants the lexer
9
9
  * normalized are emitted in canonical form.
10
10
  *
@@ -18,7 +18,7 @@
18
18
  *
19
19
  * @input block TSX source (splice) or a name+importPath (import)
20
20
  * @output prepareSpliceModule / parseImportStatements + import-merge helpers
21
- * @position lib/xle — used by expand.mjs; sources gathered by the caller
21
+ * @position lib/xle — used by expand.mjs; sources gathered in api/layout.mjs
22
22
  */
23
23
 
24
24
  const IMPORT_RE =
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@astryxdesign/cli",
3
- "version": "0.6.4-canary.06c8fa3",
3
+ "version": "0.6.4-canary.10dd683",
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.4-canary.06c8fa3",
105
- "@astryxdesign/core": "0.6.4-canary.06c8fa3",
106
- "@astryxdesign/lab": "0.6.4-canary.06c8fa3",
107
- "@astryxdesign/theme-neutral": "0.6.4-canary.06c8fa3"
104
+ "@astryxdesign/charts": "0.6.4-canary.10dd683",
105
+ "@astryxdesign/core": "0.6.4-canary.10dd683",
106
+ "@astryxdesign/lab": "0.6.4-canary.10dd683",
107
+ "@astryxdesign/theme-neutral": "0.6.4-canary.10dd683"
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.4-canary.06c8fa3",
125
- "@astryxdesign/core": "0.6.4-canary.06c8fa3",
126
- "@astryxdesign/lab": "0.6.4-canary.06c8fa3",
127
- "@astryxdesign/theme-neutral": "0.6.4-canary.06c8fa3",
124
+ "@astryxdesign/charts": "0.6.4-canary.10dd683",
125
+ "@astryxdesign/core": "0.6.4-canary.10dd683",
126
+ "@astryxdesign/lab": "0.6.4-canary.10dd683",
127
+ "@astryxdesign/theme-neutral": "0.6.4-canary.10dd683",
128
128
  "@heroicons/react": "^2.2.0",
129
129
  "@stylexjs/stylex": "^0.19.0",
130
130
  "@types/babel__core": "^7.20.5",
@@ -1,105 +0,0 @@
1
- // Copyright (c) Meta Platforms, Inc. and affiliates.
2
-
3
- import {afterEach, beforeEach, describe, expect, it} from 'vitest';
4
- import * as fs from 'node:fs';
5
- import * as path from 'node:path';
6
- import {integrationPackCheck} from './pack-check.mjs';
7
-
8
- let tmpDir;
9
-
10
- beforeEach(() => {
11
- tmpDir = fs.mkdtempSync(path.join(process.cwd(), '.astryx-pack-check-'));
12
- });
13
-
14
- afterEach(() => {
15
- fs.rmSync(tmpDir, {recursive: true, force: true});
16
- });
17
-
18
- /** @param {Record<string, string>} scripts */
19
- function writeThemePackage(scripts) {
20
- fs.writeFileSync(
21
- path.join(tmpDir, 'package.json'),
22
- `${JSON.stringify(
23
- {
24
- name: '@acme/widgets',
25
- version: '1.0.0',
26
- files: ['astryx.integration.mjs', 'themes'],
27
- scripts,
28
- },
29
- null,
30
- 2,
31
- )}\n`,
32
- );
33
- fs.writeFileSync(
34
- path.join(tmpDir, 'astryx.integration.mjs'),
35
- "export default {themes: './themes'};\n",
36
- );
37
- const root = path.join(tmpDir, 'themes');
38
- fs.mkdirSync(path.join(root, 'ocean'), {recursive: true});
39
- fs.writeFileSync(
40
- path.join(root, 'ocean', 'oceanTheme.ts'),
41
- "import {defineTheme} from '@astryxdesign/core/theme';\n\nexport const oceanTheme = defineTheme({name: 'ocean'});\n",
42
- );
43
- fs.writeFileSync(
44
- path.join(root, 'ocean', 'oceanTheme.doc.mjs'),
45
- `/** @type {import('@astryxdesign/cli/authoring').ThemeDoc} */
46
- export default {type: 'theme', name: 'ocean', displayName: 'Ocean', description: 'Ocean theme.', maintained: true};
47
- `,
48
- );
49
- }
50
-
51
- describe('integrationPackCheck with lifecycle script output', () => {
52
- it('checks the tarball when lifecycle scripts print to stdout', async () => {
53
- writeThemePackage({
54
- prepack: 'node -e "console.log(\'building the package\')"',
55
- prepare: 'node -e "console.log(\'preparing\')"',
56
- postpack: 'node -e "console.log(\'packed\')"',
57
- });
58
-
59
- const result = await integrationPackCheck({cwd: tmpDir});
60
-
61
- expect(result.data.issues).toEqual([]);
62
- expect(result.data.packable).toBe(true);
63
- expect(result.data.tarball?.filename).toBe('acme-widgets-1.0.0.tgz');
64
- expect(result.data.contributions.packed).toEqual(
65
- result.data.contributions.local,
66
- );
67
- });
68
-
69
- it('still runs a chatty lifecycle script and compares what it packed', async () => {
70
- const renameTheme = [
71
- "console.log('renaming ocean to storm')",
72
- "const fs=require('fs')",
73
- "fs.renameSync('themes/ocean','themes/storm')",
74
- "const p='themes/storm/oceanTheme.doc.mjs'",
75
- "let x=fs.readFileSync(p,'utf8')",
76
- "x=x.replace(/name: 'ocean'/, 'name: '+String.fromCharCode(39)+'storm'+String.fromCharCode(39))",
77
- 'fs.writeFileSync(p,x)',
78
- ].join(';');
79
- writeThemePackage({prepack: `node -e "${renameTheme}"`});
80
-
81
- const result = await integrationPackCheck({cwd: tmpDir});
82
- const codes = result.data.issues.map(issue => issue.code);
83
-
84
- expect(codes).not.toContain('pack_failed');
85
- expect(codes).toContain('identity_not_packed');
86
- expect(codes).toContain('packed_identity_unexpected');
87
- expect(result.data.packable).toBe(false);
88
- });
89
-
90
- it('keeps a failing lifecycle script output in the pack_failed issue', async () => {
91
- writeThemePackage({
92
- prepack:
93
- 'node -e "console.error(\'prepack exploded\'); process.exit(3)"',
94
- });
95
-
96
- const result = await integrationPackCheck({cwd: tmpDir});
97
- const failure = result.data.issues.find(
98
- issue => issue.code === 'pack_failed',
99
- );
100
-
101
- expect(result.data.packable).toBe(false);
102
- expect(failure?.message).toContain('npm pack failed (exit 3)');
103
- expect(failure?.message).toContain('prepack exploded');
104
- });
105
- });