@astryxdesign/cli 0.7.0-canary.450c68d → 0.7.0-canary.4ec1f4e

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 (168) hide show
  1. package/README.md +30 -33
  2. package/api/doctor/doctor.doc.mjs +1 -1
  3. package/api/doctor/doctor.test.mjs +28 -0
  4. package/api/doctor/theme-checks.mjs +10 -10
  5. package/api/doctor/theme-checks.test.mjs +5 -4
  6. package/api/gap-report/gap-report.doc.mjs +1 -1
  7. package/api/gap-report/gap-report.mjs +15 -0
  8. package/api/gap-report/gap-report.test.mjs +1 -1
  9. package/api/index.d.mts +0 -2
  10. package/api/index.mjs +0 -2
  11. package/api/init/init.doc.mjs +5 -1
  12. package/api/init/init.mjs +22 -0
  13. package/api/init/init.type.d.mts +4 -1
  14. package/api/init/init.type.mjs +1 -1
  15. package/api/init/remove/remove.mjs +8 -3
  16. package/api/init/remove/remove.test.mjs +12 -0
  17. package/api/init/run/run.d.mts +1 -1
  18. package/api/init/run/run.mjs +3 -3
  19. package/api/integration/validate-integration.d.mts +4 -0
  20. package/api/integration/validate-integration.mjs +5 -2
  21. package/api/integration/validateIntegration.doc.mjs +1 -1
  22. package/api/json/index.ts +0 -1
  23. package/api/search/search.doc.mjs +1 -1
  24. package/api/search/search.mjs +1 -1
  25. package/api/search/search.test.mjs +1 -1
  26. package/api/search/search.type.d.mts +1 -1
  27. package/api/search/search.type.mjs +1 -1
  28. package/api/template/template-integration.test.mjs +37 -100
  29. package/api/template/template.doc.mjs +5 -1
  30. package/api/template/template.mjs +45 -0
  31. package/api/theme/_adapter.mjs +3 -3
  32. package/api/theme/add/add.d.mts +11 -5
  33. package/api/theme/add/add.mjs +19 -192
  34. package/api/theme/add/add.test.mjs +68 -258
  35. package/api/theme/add/add.types.test.mjs +0 -1
  36. package/api/theme/build/build.d.mts +3 -3
  37. package/api/theme/build/build.mjs +22 -36
  38. package/api/theme/build/build.test.mjs +11 -24
  39. package/api/theme/eject/eject.copy-compat.test.mjs +168 -0
  40. package/api/theme/integration-themes.test.mjs +3 -3
  41. package/api/theme/remove/remove.test.mjs +1 -1
  42. package/api/theme/targets/targets.test.mjs +0 -4
  43. package/api/theme/template/template.mjs +1 -1
  44. package/api/theme/theme.type.d.mts +1 -30
  45. package/api/theme/theme.type.mjs +3 -13
  46. package/api/theme/themeAdd.doc.mjs +19 -27
  47. package/api/theme/themeTargets.doc.mjs +3 -4
  48. package/api/theme/themeTemplate.doc.mjs +1 -1
  49. package/api/theme/use/use.test.mjs +1 -1
  50. package/api/upgrade/upgrade.doc.mjs +1 -1
  51. package/api/upgrade/upgrade.mjs +19 -0
  52. package/assets/codemods/transforms/next/README.md +15 -17
  53. package/assets/codemods/transforms/next/__tests__/migrate-deprecated-theme-surface.test.mjs +322 -0
  54. package/assets/codemods/transforms/next/index.mjs +11 -1
  55. package/assets/codemods/transforms/next/migrate-deprecated-theme-surface-v0.6-data.mjs +229 -0
  56. package/assets/codemods/transforms/next/migrate-deprecated-theme-surface.mjs +624 -0
  57. package/assets/codemods/transforms/v0.6.0/migrate-astryx-theme-selectors-to-data-attrs.mjs +38 -18
  58. package/assets/docs/author-a-theme.doc.mjs +1 -1
  59. package/assets/docs/getting-started.doc.mjs +2 -2
  60. package/assets/docs/theme.doc.dense.mjs +1 -1
  61. package/assets/docs/theme.doc.mjs +2 -2
  62. package/assets/docs/tree/add-a-theme.doc.mjs +1 -1
  63. package/assets/docs/tree/document-the-theme.doc.mjs +2 -2
  64. package/assets/docs/tree/fonts-and-assets.doc.mjs +3 -3
  65. package/assets/docs/tree/styling-advanced.doc.mjs +21 -14
  66. package/assets/docs/tree/themes.doc.mjs +1 -1
  67. package/assets/docs/tree/use-a-theme-in-an-app.doc.mjs +2 -2
  68. package/assets/docs/tree/versioning.doc.mjs +1 -4
  69. package/assets/docs/use-a-theme.doc.mjs +16 -16
  70. package/authoring/debug/type.ts +2 -2
  71. package/authoring/doctypes/base/type.ts +0 -9
  72. package/authoring/integration/integration.doc.mjs +1 -1
  73. package/clients/cli/command-result-coverage.test.mjs +1 -1
  74. package/clients/cli/commands/build-theme.adaptations.test.mjs +4 -0
  75. package/clients/cli/commands/build-theme.ascii-output.test.mjs +35 -8
  76. package/clients/cli/commands/build-theme.mjs +31 -67
  77. package/clients/cli/commands/build-theme.registry.test.mjs +0 -10
  78. package/clients/cli/commands/debug-result-summary.test.mjs +0 -16
  79. package/clients/cli/commands/discover.mjs +2 -1
  80. package/clients/cli/commands/doctor.mjs +5 -2
  81. package/clients/cli/commands/empty-argument.test.mjs +16 -0
  82. package/clients/cli/commands/gap-report.doc.mjs +1 -1
  83. package/clients/cli/commands/gap-report.test.mjs +2 -2
  84. package/clients/cli/commands/init.doc.mjs +4 -4
  85. package/clients/cli/commands/init.flag-help.test.mjs +7 -10
  86. package/clients/cli/commands/init.next-steps.test.mjs +1 -1
  87. package/clients/cli/commands/option-pair-refusals.test.mjs +37 -0
  88. package/clients/cli/commands/search.test.mjs +1 -1
  89. package/clients/cli/commands/swizzle.mjs +4 -1
  90. package/clients/cli/commands/template.doc.mjs +3 -3
  91. package/clients/cli/commands/template.flag-help.test.mjs +18 -11
  92. package/clients/cli/commands/template.mjs +7 -1
  93. package/clients/cli/commands/text-json-parity.test.mjs +0 -17
  94. package/clients/cli/commands/theme-add-lifecycle.test.mjs +142 -49
  95. package/clients/cli/commands/theme-add.doc.mjs +10 -17
  96. package/clients/cli/commands/theme-list.behavior.test.mjs +2 -1
  97. package/clients/cli/commands/theme-targets.behavior.test.mjs +8 -6
  98. package/clients/cli/commands/theme-template.doc.mjs +1 -1
  99. package/clients/cli/commands/theme.doc.mjs +2 -2
  100. package/clients/cli/commands/upgrade.doc.mjs +1 -1
  101. package/clients/cli/commands/upgrade.flag-help.test.mjs +7 -11
  102. package/clients/cli/commands/validate-nothing-exits-nonzero.test.mjs +67 -0
  103. package/clients/cli/index.mjs +0 -4
  104. package/clients/cli/lib/cli-error.mjs +19 -0
  105. package/clients/cli/lib/component-format.mjs +111 -57
  106. package/clients/cli/lib/component-format.test.mjs +28 -39
  107. package/clients/cli/lib/doc-text-ascii.test.mjs +5 -2
  108. package/clients/cli/lib/exit-codes.test.mjs +0 -7
  109. package/clients/cli/lib/json-shim.test.mjs +0 -24
  110. package/foundation/agent-docs/agent-docs.d.mts +2 -1
  111. package/foundation/agent-docs/agent-docs.mjs +6 -1
  112. package/foundation/agent-docs/app-theme-workflow.test.mjs +3 -0
  113. package/foundation/config/theme-state.mjs +3 -3
  114. package/foundation/debug/debug-fields.test.mjs +13 -35
  115. package/foundation/debug/event.mjs +13 -78
  116. package/foundation/debug/privacy-contract.test.mjs +20 -12
  117. package/foundation/debug/redact.d.mts +2 -2
  118. package/foundation/debug/redact.mjs +2 -2
  119. package/foundation/discovery/theme-imports.mjs +1 -1
  120. package/foundation/discovery/theming-targets.d.mts +1 -20
  121. package/foundation/discovery/theming-targets.mjs +1 -38
  122. package/foundation/discovery/theming-targets.test.mjs +9 -175
  123. package/foundation/doc-compiler/doc-loads.test.mjs +0 -12
  124. package/foundation/response/error-codes.doc.mjs +1 -1
  125. package/foundation/response/response-types.doc.mjs +11 -30
  126. package/foundation/response/response-types.doc.test.mjs +36 -14
  127. package/foundation/response/response.doc.mjs +1 -1
  128. package/foundation/xle/browser.d.mts +2 -2
  129. package/foundation/xle/browser.mjs +2 -2
  130. package/foundation/xle/expand.mjs +1 -1
  131. package/foundation/xle/print.mjs +1 -1
  132. package/package.json +9 -9
  133. package/api/layout/_adapter.d.mts +0 -34
  134. package/api/layout/_adapter.mjs +0 -148
  135. package/api/layout/check/check.d.mts +0 -17
  136. package/api/layout/check/check.mjs +0 -41
  137. package/api/layout/expand/expand.d.mts +0 -23
  138. package/api/layout/expand/expand.mjs +0 -161
  139. package/api/layout/expand/expand.path-safety.test.mjs +0 -53
  140. package/api/layout/expand/expand.receipt.test.mjs +0 -74
  141. package/api/layout/grammar/grammar.d.mts +0 -14
  142. package/api/layout/grammar/grammar.mjs +0 -88
  143. package/api/layout/layout.d.mts +0 -6
  144. package/api/layout/layout.mjs +0 -17
  145. package/api/layout/layout.test.mjs +0 -297
  146. package/api/layout/layout.type.d.mts +0 -90
  147. package/api/layout/layout.type.mjs +0 -104
  148. package/api/layout/layoutCheck.doc.d.mts +0 -11
  149. package/api/layout/layoutCheck.doc.mjs +0 -85
  150. package/api/layout/layoutExpand.doc.d.mts +0 -11
  151. package/api/layout/layoutExpand.doc.mjs +0 -107
  152. package/api/layout/layoutGrammar.doc.d.mts +0 -11
  153. package/api/layout/layoutGrammar.doc.mjs +0 -57
  154. package/api/theme/add/add.binary.test.mjs +0 -157
  155. package/api/theme/add/add.rollback.test.mjs +0 -158
  156. package/api/theme/add/add.staging.test.mjs +0 -83
  157. package/clients/cli/commands/layout-check.doc.mjs +0 -67
  158. package/clients/cli/commands/layout-expand.doc.mjs +0 -87
  159. package/clients/cli/commands/layout-grammar.doc.mjs +0 -32
  160. package/clients/cli/commands/layout.deprecation-lifecycle.test.mjs +0 -140
  161. package/clients/cli/commands/layout.doc.mjs +0 -36
  162. package/clients/cli/commands/layout.error-codes.test.mjs +0 -66
  163. package/clients/cli/commands/layout.exit-parity.test.mjs +0 -41
  164. package/clients/cli/commands/layout.expand-receipt.test.mjs +0 -94
  165. package/clients/cli/commands/layout.mjs +0 -327
  166. package/clients/cli/commands/layout.path-help.test.mjs +0 -33
  167. package/clients/cli/commands/layout.stdin-cap.test.mjs +0 -47
  168. package/clients/cli/commands/layout.text-fields.test.mjs +0 -39
@@ -1,87 +0,0 @@
1
- // Copyright (c) Meta Platforms, Inc. and affiliates.
2
-
3
- /**
4
- * @file CommandDoc for `astryx layout expand`. The terminal binding of the
5
- * `layoutExpand()` function (referenced via `fn`); its args/flags map to that
6
- * function's params so a converter can build Commander config + --help from one
7
- * source of truth.
8
- * @position packages/cli/clients/cli/commands — command documentation
9
- */
10
-
11
- /** @type {import('@astryxdesign/cli/authoring').CommandDoc} */
12
- export const doc = {
13
- type: 'command',
14
- name: 'layout expand',
15
- displayName: 'astryx layout expand',
16
- namespace: 'cli/commands',
17
- summary: 'Expand a layout expression into validated XDS TSX',
18
- description:
19
- 'Parses and validates a compressed XLE/XLO expression, then expands it into ' +
20
- 'ready-to-use XDS TSX, routing children into slots, scaffolding typed useState for ' +
21
- 'interactive controls, and splicing referenced blocks. Writes to a path, or returns the code. ' +
22
- 'Astryx demo media in a spliced block becomes a placeholder, and the output says how many ' +
23
- 'references were replaced (as a closing line comment when it prints the code).',
24
- fn: 'layoutExpand',
25
- args: [
26
- {
27
- name: 'expression',
28
- param: 'expression',
29
- required: false,
30
- description:
31
- 'The XLE/XLO expression. Pass - to read it from stdin; --file reads it from a file instead.',
32
- },
33
- {
34
- name: 'path',
35
- param: 'options.targetPath',
36
- required: false,
37
- description:
38
- 'Where to write the TSX, relative to the project root. A path that ends in .tsx, .ts, .jsx, .js, .mjs, .cjs, .css, .scss, .json, .md or .html is the file to write; ' +
39
- 'any other path is a directory, which receives <Name>.tsx (see --name). An existing file there is replaced. ' +
40
- 'Omit it to print the code.',
41
- },
42
- ],
43
- options: [
44
- {
45
- flag: '--file <file>',
46
- description: 'Read the expression from a file (used instead of the argument when both are given)',
47
- },
48
- {
49
- flag: '--form <form>',
50
- param: 'options.form',
51
- choices: ['compact', 'outline', 'auto'],
52
- default: 'auto',
53
- description: 'Input surface: compact, outline, or auto',
54
- },
55
- {
56
- flag: '--name <name>',
57
- param: 'options.name',
58
- default: 'GeneratedLayout',
59
- description: 'Generated component name (PascalCase)',
60
- },
61
- {
62
- flag: '--loose',
63
- param: 'options.loose',
64
- description: 'Downgrade unknown {block} hints to TODO placeholders',
65
- },
66
- ],
67
- examples: [
68
- {
69
- label: 'Expand to a file',
70
- cli: "astryx layout expand 'V[g6] > C{card-callout}*4' ./src/Page.tsx",
71
- },
72
- {
73
- label: 'From a file, named',
74
- cli: 'astryx layout expand --file layout.xlo --name Dashboard',
75
- },
76
- ],
77
- exitCodes: [
78
- {code: 0, when: 'success'},
79
- {
80
- code: 1,
81
- when: 'a missing, empty or over-5 MB expression (from stdin or --file), a bad --name or --form, a parse/validation error, or a path escape',
82
- },
83
- ],
84
- deprecated: 'DEP-0006: Use `astryx build` to start from a template, `astryx template` to scaffold, and `astryx docs layout` for guidance.',
85
- notes: [{"type": "prose", "text": "**Deprecated (DEP-0006).** Use `astryx build` to choose the template to start from, `astryx template` to scaffold it, and `astryx docs layout` for layout guidance. This command will be removed in a future minor release."}],
86
- related: ['layout check', 'layout grammar'],
87
- };
@@ -1,32 +0,0 @@
1
- // Copyright (c) Meta Platforms, Inc. and affiliates.
2
-
3
- /**
4
- * @file CommandDoc for `astryx layout grammar`. The terminal binding of the
5
- * `layoutGrammar()` function (referenced via `fn`); it carries only CLI-surface
6
- * facts so a converter can build Commander config + --help from one source of
7
- * truth.
8
- * @position packages/cli/clients/cli/commands — command documentation
9
- */
10
-
11
- /** @type {import('@astryxdesign/cli/authoring').CommandDoc} */
12
- export const doc = {
13
- type: 'command',
14
- name: 'layout grammar',
15
- displayName: 'astryx layout grammar',
16
- namespace: 'cli/commands',
17
- summary:
18
- 'Print the XLE/XLO cheatsheet (alias table generated from this branch)',
19
- description:
20
- 'Prints the XLE/XLO grammar cheatsheet for writing layout expressions, with the alias ' +
21
- "table generated from this install's registry so short names always reflect the " +
22
- 'components actually available.',
23
- fn: 'layoutGrammar',
24
- examples: [{label: 'Get the cheatsheet', cli: 'astryx layout grammar'}],
25
- exitCodes: [
26
- {code: 0, when: 'success'},
27
- {code: 1, when: 'the component registry cannot be read'},
28
- ],
29
- deprecated: 'DEP-0006: Use `astryx build` to start from a template, `astryx template` to scaffold, and `astryx docs layout` for guidance.',
30
- notes: [{"type": "prose", "text": "**Deprecated (DEP-0006).** Use `astryx build` to choose the template to start from, `astryx template` to scaffold it, and `astryx docs layout` for layout guidance. This command will be removed in a future minor release."}],
31
- related: ['layout expand', 'layout check'],
32
- };
@@ -1,140 +0,0 @@
1
- // Copyright (c) Meta Platforms, Inc. and affiliates.
2
-
3
- /**
4
- * @file Deprecation lifecycle coverage for the layout command group (DEP-0006).
5
- *
6
- * Mirrors the DEP-0005 theme-add-lifecycle tests: pins the JSON
7
- * `meta.deprecations` entry, the human-mode stderr warning, the help label,
8
- * and the docs reference pages.
9
- */
10
-
11
- import {describe, it, expect} from 'vitest';
12
- import {runCli} from '../../../test-utils/run-cli.mjs';
13
-
14
- const SLOW = 30_000;
15
-
16
- describe('layout DEP-0006 lifecycle', () => {
17
- it('JSON mode carries meta.deprecations with DEP-0006 and its replacements', async () => {
18
- const result = await runCli(['layout', 'grammar', '--json']);
19
- expect(result.status).toBe(0);
20
- const envelope = JSON.parse(result.stdout);
21
- expect(envelope.meta).toBeDefined();
22
- expect(envelope.meta.deprecations).toEqual([
23
- {
24
- id: 'DEP-0006',
25
- replacements: ['build', 'template', 'docs layout'],
26
- },
27
- ]);
28
- // Canonical data is unchanged
29
- expect(envelope.type).toBe('layout.grammar');
30
- expect(envelope.data.text).toBeDefined();
31
- expect(envelope.data.aliases).toBeDefined();
32
- }, SLOW);
33
-
34
- it('human mode emits one stderr deprecation warning', async () => {
35
- const result = await runCli(['layout', 'grammar']);
36
- expect(result.status).toBe(0);
37
- expect(result.stderr).toContain('[DEP-0006]');
38
- expect(result.stderr).toContain('astryx layout is deprecated');
39
- expect(result.stderr).toContain('astryx build');
40
- expect(result.stderr).toContain('astryx template');
41
- expect(result.stderr).toContain('astryx docs layout');
42
- }, SLOW);
43
-
44
- it('JSON mode does NOT emit the stderr warning', async () => {
45
- const result = await runCli(['layout', 'grammar', '--json']);
46
- expect(result.stderr).not.toContain('[DEP-0006]');
47
- }, SLOW);
48
-
49
- it('layout --help labels the command as deprecated', async () => {
50
- const result = await runCli(['layout', '--help']);
51
- expect(result.stdout).toContain('DEPRECATED');
52
- expect(result.stdout).toContain('DEP-0006');
53
- });
54
-
55
- it('layout expand --json carries the same meta.deprecations', async () => {
56
- const result = await runCli([
57
- 'layout', 'expand', 'V[g6] > C*2', '--json',
58
- ]);
59
- expect(result.status).toBe(0);
60
- const envelope = JSON.parse(result.stdout);
61
- expect(envelope.meta.deprecations).toEqual([
62
- {
63
- id: 'DEP-0006',
64
- replacements: ['build', 'template', 'docs layout'],
65
- },
66
- ]);
67
- expect(envelope.type).toBe('layout.expand');
68
- }, SLOW);
69
-
70
- it('layout check --json carries the same meta.deprecations', async () => {
71
- const result = await runCli([
72
- 'layout', 'check', 'V[g6] > C*2', '--json',
73
- ]);
74
- expect(result.status).toBe(0);
75
- const envelope = JSON.parse(result.stdout);
76
- expect(envelope.meta.deprecations).toEqual([
77
- {
78
- id: 'DEP-0006',
79
- replacements: ['build', 'template', 'docs layout'],
80
- },
81
- ]);
82
- expect(envelope.type).toBe('layout.check');
83
- }, SLOW);
84
-
85
- // FR29d: every reference page names DEP-0006 and the replacements.
86
- // Removing the label from any single page must fail this test.
87
- describe('docs reference pages name DEP-0006', () => {
88
- const COMMAND_PAGES = [
89
- 'cli/commands/layout',
90
- 'cli/commands/layout-expand',
91
- 'cli/commands/layout-check',
92
- 'cli/commands/layout-grammar',
93
- ];
94
-
95
- const FUNCTION_PAGES = [
96
- 'cli/api/functions/layout-expand',
97
- 'cli/api/functions/layout-check',
98
- 'cli/api/functions/layout-grammar',
99
- ];
100
-
101
- for (const page of COMMAND_PAGES) {
102
- it(`${page} names DEP-0006 and replacements`, async () => {
103
- const result = await runCli(['docs', page, '--json']);
104
- expect(result.status, result.stderr).toBe(0);
105
- const body = result.stdout;
106
- expect(body).toContain('DEP-0006');
107
- expect(body).toContain('build');
108
- expect(body).toContain('template');
109
- expect(body).toContain('docs layout');
110
- }, SLOW);
111
- }
112
-
113
- for (const page of FUNCTION_PAGES) {
114
- it(`${page} names DEP-0006 and replacements`, async () => {
115
- const result = await runCli(['docs', page, '--json']);
116
- expect(result.status, result.stderr).toBe(0);
117
- const body = result.stdout;
118
- expect(body).toContain('DEP-0006');
119
- expect(body).toContain('build');
120
- expect(body).toContain('template');
121
- expect(body).toContain('docs layout');
122
- }, SLOW);
123
- }
124
- });
125
-
126
- it('response-types reference names DEP-0006 in each layout entry description', async () => {
127
- const result = await runCli(['docs', 'cli/api/enums/response-types', '--json']);
128
- expect(result.status, result.stderr).toBe(0);
129
- const envelope = JSON.parse(result.stdout);
130
- // The enum page has a table in its content; each row is [value, description].
131
- const tables = envelope.data.content.filter(b => b.type === 'table');
132
- const rows = tables.flatMap(t => t.rows || []);
133
- for (const type of ['layout.expand', 'layout.check', 'layout.grammar']) {
134
- const row = rows.find(r => r[0] && r[0].includes(type));
135
- expect(row, `${type} not found in response-types table`).toBeDefined();
136
- expect(row[1], `${type} description missing DEP-0006`).toContain('DEP-0006');
137
- expect(row[1], `${type} description missing replacements`).toContain('replacement');
138
- }
139
- }, SLOW);
140
- });
@@ -1,36 +0,0 @@
1
- // Copyright (c) Meta Platforms, Inc. and affiliates.
2
-
3
- /**
4
- * @file CommandDoc for the `astryx layout` command group. A parent group with no
5
- * behavior of its own; it dispatches to the expand/check/grammar subcommands,
6
- * which carry the actual args, flags, and wrapped functions.
7
- * @position packages/cli/clients/cli/commands — command documentation
8
- */
9
-
10
- /** @type {import('@astryxdesign/cli/authoring').CommandDoc} */
11
- export const doc = {
12
- type: 'command',
13
- name: 'layout',
14
- displayName: 'astryx layout',
15
- namespace: 'cli/commands',
16
- summary: 'Generate XDS layouts from compressed expressions (XLE/XLO)',
17
- description:
18
- 'The layout command group. Running astryx layout with no subcommand prints the ' +
19
- 'subcommand list; the work happens in the subcommands: expand an expression into ' +
20
- 'TSX (expand), validate one (check), or print the grammar cheatsheet (grammar).',
21
- subcommands: ['expand', 'check', 'grammar'],
22
- examples: [
23
- {label: 'Print the grammar', cli: 'astryx layout grammar'},
24
- {
25
- label: 'Expand to TSX',
26
- cli: "astryx layout expand 'V[g6] > C{card-callout}*4' ./src/Page.tsx",
27
- },
28
- ],
29
- exitCodes: [
30
- {code: 0, when: 'a subcommand succeeded, or --help'},
31
- {code: 1, when: 'no subcommand (help is printed) or an unknown subcommand'},
32
- ],
33
- deprecated: 'DEP-0006: Use `astryx build` to start from a template, `astryx template` to scaffold, and `astryx docs layout` for guidance.',
34
- notes: [{"type": "prose", "text": "**Deprecated (DEP-0006).** Use `astryx build` to choose the template to start from, `astryx template` to scaffold it, and `astryx docs layout` for layout guidance. This command will be removed in a future minor release."}],
35
- related: ['template', 'build'],
36
- };
@@ -1,66 +0,0 @@
1
- // Copyright (c) Meta Platforms, Inc. and affiliates.
2
-
3
- /**
4
- * @file Error-code contract tests for the layout command wrapper. Locks the
5
- * two foreseeable input errors to STABLE ERR_* codes (never ERR_UNKNOWN or a
6
- * raw fs errno) and asserts --json/human exit parity:
7
- * - empty expression → ERR_MISSING_ARGUMENT
8
- * - --file <missing> → ERR_FILE_NOT_FOUND (not raw ENOENT), no stack leak
9
- * Spawns the real binary so the bin error boundary is exercised faithfully.
10
- */
11
-
12
- import {describe, it, expect} from 'vitest';
13
- import {spawnSync} from 'node:child_process';
14
- import * as path from 'node:path';
15
- import {fileURLToPath} from 'node:url';
16
-
17
- const __dirname = path.dirname(fileURLToPath(import.meta.url));
18
- const CLI_BIN = path.resolve(__dirname, '../bin/astryx.mjs');
19
-
20
- function run(args) {
21
- const res = spawnSync('node', [CLI_BIN, ...args], {
22
- encoding: 'utf-8',
23
- timeout: 20_000,
24
- });
25
- return {status: res.status, stdout: res.stdout || '', stderr: res.stderr || ''};
26
- }
27
-
28
- describe('layout --json error codes', () => {
29
- for (const sub of ['expand', 'check']) {
30
- it(`layout ${sub} "" → ERR_MISSING_ARGUMENT (not ERR_UNKNOWN)`, () => {
31
- const r = run(['--json', 'layout', sub, '']);
32
- expect(r.status).toBe(1);
33
- const env = JSON.parse(r.stdout);
34
- expect(env.code).toBe('ERR_MISSING_ARGUMENT');
35
- expect(r.stderr).toBe('');
36
- expect(r.stdout).not.toMatch(/\n\s+at /); // no stack frames
37
- });
38
-
39
- it(`layout ${sub} --file <missing> → ERR_FILE_NOT_FOUND (not ENOENT)`, () => {
40
- const r = run([
41
- '--json',
42
- 'layout',
43
- sub,
44
- '--file',
45
- '/tmp/definitely-missing-astryx-xyz.mjs',
46
- ]);
47
- expect(r.status).toBe(1);
48
- const env = JSON.parse(r.stdout);
49
- expect(env.code).toBe('ERR_FILE_NOT_FOUND');
50
- expect(r.stderr).toBe('');
51
- });
52
-
53
- it(`layout ${sub}: --json and human agree on exit code (empty input)`, () => {
54
- const human = run(['layout', sub, '']);
55
- const json = run(['--json', 'layout', sub, '']);
56
- expect(json.status).toBe(human.status);
57
- expect(json.status).toBe(1);
58
- });
59
-
60
- it(`layout ${sub} --file <missing> in human mode leaks no stack trace`, () => {
61
- const r = run(['layout', sub, '--file', '/tmp/definitely-missing-astryx-xyz.mjs']);
62
- expect(r.status).toBe(1);
63
- expect(r.stderr).not.toMatch(/\n\s+at /);
64
- });
65
- }
66
- });
@@ -1,41 +0,0 @@
1
- // Copyright (c) Meta Platforms, Inc. and affiliates.
2
-
3
- /**
4
- * @file CLI-level tests for `astryx layout check` exit-code parity.
5
- *
6
- * The exit code is the contract and must NOT depend on --json vs human mode:
7
- * an invalid (but parseable) layout exits 1 in BOTH modes so `layout check`
8
- * works as a CI gate / agent check without parsing stdout. Runs the real
9
- * program in-process via the shared runCli harness.
10
- */
11
-
12
- import {describe, it, expect} from 'vitest';
13
- import {runCli} from '../../../test-utils/run-cli.mjs';
14
-
15
- const SLOW = 30_000;
16
- // Parses fine, but references an unknown component -> data.valid: false
17
- // (a semantic error, surfaced as data, not a thrown ERR_LAYOUT_PARSE).
18
- const INVALID = 'ZzzUnknownComponent[foo=bar]';
19
- const VALID = 'K';
20
-
21
- describe('layout check — exit-code parity (--json vs human)', () => {
22
- it('human mode exits 1 for an invalid (parseable) expression', async () => {
23
- const {status} = await runCli(['layout', 'check', INVALID]);
24
- expect(status).toBe(1);
25
- }, SLOW);
26
-
27
- it('--json exits 1 for the SAME invalid expression (modes agree)', async () => {
28
- const {status, stdout} = await runCli(['layout', 'check', INVALID, '--json']);
29
- const env = JSON.parse(stdout);
30
- expect(env.type).toBe('layout.check');
31
- expect(env.data.valid).toBe(false);
32
- expect(status).toBe(1);
33
- }, SLOW);
34
-
35
- it('a valid expression exits 0 in both modes', async () => {
36
- expect((await runCli(['layout', 'check', VALID])).status).toBe(0);
37
- const {status, stdout} = await runCli(['layout', 'check', VALID, '--json']);
38
- expect(JSON.parse(stdout).data.valid).toBe(true);
39
- expect(status).toBe(0);
40
- }, SLOW);
41
- });
@@ -1,94 +0,0 @@
1
- // Copyright (c) Meta Platforms, Inc. and affiliates.
2
-
3
- /**
4
- * @file `astryx layout expand` tells the caller, in JSON and in text, when demo
5
- * media in a spliced template block was replaced with placeholders. Printed
6
- * code stays verbatim and valid TSX: the disclosure follows it as a comment.
7
- */
8
-
9
- import {describe, it, expect, beforeEach, afterEach} from 'vitest';
10
- import * as fs from 'node:fs';
11
- import * as path from 'node:path';
12
- import ts from 'typescript';
13
- import {runCli} from '../../../test-utils/run-cli.mjs';
14
- import {discoverTemplates} from '../../../api/template/template.mjs';
15
-
16
- const SLOW = 60_000;
17
- const DISCLOSURE = /demo media/i;
18
-
19
- /** @param {string} name */
20
- const hintKey = name => name.toLowerCase().replace(/[^a-z0-9]/g, '');
21
-
22
- /** @param {string} source */
23
- const tsxErrors = source =>
24
- /** @type {any} */ (
25
- ts.createSourceFile('out.tsx', source, ts.ScriptTarget.Latest, true, ts.ScriptKind.TSX)
26
- ).parseDiagnostics.map((/** @type {ts.Diagnostic} */ d) =>
27
- ts.flattenDiagnosticMessageText(d.messageText, ' '),
28
- );
29
-
30
- /** A `{hint}` for a template block whose source carries demo media. */
31
- async function mediaBlockHint() {
32
- const blocks = /** @type {Array<{dirName: string, type: string, filePath: string}>} */ (
33
- await discoverTemplates()
34
- ).filter(t => t.type === 'block' && t.filePath && fs.existsSync(t.filePath));
35
- const seen = new Map();
36
- for (const t of blocks) seen.set(hintKey(t.dirName), (seen.get(hintKey(t.dirName)) ?? 0) + 1);
37
- const found = blocks.find(
38
- t =>
39
- seen.get(hintKey(t.dirName)) === 1 &&
40
- /\/template-assets\/[\w.-]+\.\w+/.test(fs.readFileSync(t.filePath, 'utf-8')),
41
- );
42
- if (!found) throw new Error('no template block carries demo media');
43
- return hintKey(found.dirName);
44
- }
45
-
46
- describe('layout expand discloses replaced demo media', () => {
47
- let cwd;
48
- beforeEach(() => {
49
- // Inside the workspace so @astryxdesign/core resolves.
50
- cwd = fs.mkdtempSync(path.join(process.cwd(), '.xle-media-receipt-'));
51
- });
52
- afterEach(() => fs.rmSync(cwd, {recursive: true, force: true}));
53
-
54
- it('--json carries demoMediaReplaced; the text receipt states it for the written file', async () => {
55
- const expr = `V > {${await mediaBlockHint()}}`;
56
- const json = await runCli(['layout', 'expand', expr, './a', '--json'], cwd);
57
- expect(json.status).toBe(0);
58
- const {data} = JSON.parse(json.stdout);
59
- expect(data.demoMediaReplaced).toBeGreaterThan(0);
60
-
61
- const human = await runCli(['layout', 'expand', expr, './b'], cwd);
62
- expect(human.status).toBe(0);
63
- expect(human.stdout).toContain(
64
- `Replaced ${data.demoMediaReplaced} Astryx demo media reference`,
65
- );
66
- expect(human.stdout).toContain(path.join('b', 'GeneratedLayout.tsx'));
67
- }, SLOW);
68
-
69
- it('prints the code verbatim, then states the count in a comment that keeps it valid TSX', async () => {
70
- const expr = `V > {${await mediaBlockHint()}}`;
71
- const {data} = JSON.parse((await runCli(['layout', 'expand', expr, '--json'], cwd)).stdout);
72
-
73
- const human = await runCli(['layout', 'expand', expr], cwd);
74
- expect(human.status).toBe(0);
75
- expect(human.stdout.startsWith(data.code)).toBe(true);
76
- expect(human.stdout.slice(data.code.length).trim()).toMatch(
77
- new RegExp(`^// Replaced ${data.demoMediaReplaced} Astryx demo media references? in the code above: [^\\n]+$`),
78
- );
79
- expect(tsxErrors(human.stdout)).toEqual([]);
80
- }, SLOW);
81
-
82
- it('says nothing about demo media when none was replaced', async () => {
83
- const json = await runCli(['layout', 'expand', 'V > B"Save"', '--json'], cwd);
84
- const {data} = JSON.parse(json.stdout);
85
- expect(data.demoMediaReplaced).toBe(0);
86
-
87
- const written = await runCli(['layout', 'expand', 'V > B"Save"', './a'], cwd);
88
- expect(written.status).toBe(0);
89
- expect(written.stdout).not.toMatch(DISCLOSURE);
90
- const printed = await runCli(['layout', 'expand', 'V > B"Save"'], cwd);
91
- expect(printed.status).toBe(0);
92
- expect(printed.stdout).toBe(`${data.code}\n`);
93
- }, SLOW);
94
- });