@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,6 +1,6 @@
1
1
  // Copyright (c) Meta Platforms, Inc. and affiliates.
2
2
 
3
- /** @file Compatibility and deprecation coverage for the two-step theme-add lifecycle. */
3
+ /** @file Compatibility coverage for the cleanup stage of the theme-add lifecycle. */
4
4
 
5
5
  import {afterEach, beforeEach, describe, expect, it} from 'vitest';
6
6
  import * as fs from 'node:fs';
@@ -14,9 +14,50 @@ let tmpDir;
14
14
  beforeEach(() => {
15
15
  tmpDir = fs.mkdtempSync(path.join(os.tmpdir(), 'astryx-theme-add-cli-'));
16
16
  fs.mkdirSync(path.join(tmpDir, 'src'));
17
+ fs.writeFileSync(path.join(tmpDir, 'tsconfig.json'), '{}\n');
17
18
  fs.writeFileSync(
18
19
  path.join(tmpDir, 'package.json'),
19
- JSON.stringify({name: 'app', private: true}),
20
+ JSON.stringify({
21
+ name: 'app',
22
+ private: true,
23
+ dependencies: {'@acme/themes': '^1.0.0'},
24
+ }),
25
+ );
26
+ const packageDir = path.join(tmpDir, 'node_modules', '@acme', 'themes');
27
+ const themeDir = path.join(packageDir, 'themes', 'ocean');
28
+ fs.mkdirSync(themeDir, {recursive: true});
29
+ fs.mkdirSync(path.join(packageDir, 'dist'), {recursive: true});
30
+ fs.writeFileSync(
31
+ path.join(packageDir, 'package.json'),
32
+ JSON.stringify({
33
+ name: '@acme/themes',
34
+ version: '1.0.0',
35
+ type: 'module',
36
+ exports: {
37
+ './themes/ocean': './dist/ocean.js',
38
+ './themes/ocean.css': './dist/ocean.css',
39
+ },
40
+ }),
41
+ );
42
+ fs.writeFileSync(
43
+ path.join(packageDir, 'astryx.integration.mjs'),
44
+ "export default {themes: './themes'};\n",
45
+ );
46
+ fs.writeFileSync(
47
+ path.join(themeDir, 'oceanTheme.doc.mjs'),
48
+ "/** @type {import('@astryxdesign/cli/authoring').ThemeDoc} */\nexport default {type: 'theme', name: 'ocean', displayName: 'Ocean', description: 'Ocean theme.', maintained: true};\n",
49
+ );
50
+ fs.writeFileSync(
51
+ path.join(themeDir, 'oceanTheme.ts'),
52
+ 'export const oceanTheme = {};\n',
53
+ );
54
+ fs.writeFileSync(
55
+ path.join(packageDir, 'dist/ocean.js'),
56
+ "export const oceanTheme = {name: 'ocean', __built: true};\n",
57
+ );
58
+ fs.writeFileSync(
59
+ path.join(packageDir, 'dist/ocean.css'),
60
+ '[data-astryx-theme="ocean"] {}\n',
20
61
  );
21
62
  });
22
63
 
@@ -24,53 +65,66 @@ afterEach(() => {
24
65
  fs.rmSync(tmpDir, {recursive: true, force: true});
25
66
  });
26
67
 
27
- describe('theme add compatibility lifecycle', () => {
28
- it('keeps copy stdout and emits one text-only deprecation warning', async () => {
29
- const result = await runCli(['theme', 'add', 'neutral'], tmpDir);
68
+ describe('theme add cleanup lifecycle', () => {
69
+ it('plain theme add imports built output and prints no deprecation warning', async () => {
70
+ const result = await runCli(
71
+ ['theme', 'add', 'ocean', '--package', '@acme/themes'],
72
+ tmpDir,
73
+ );
30
74
 
31
75
  expect(result.status, result.stderr).toBe(0);
32
- expect(result.stdout).toContain(
33
- '[ok] Added Neutral theme from @astryxdesign/cli to src/themes/neutral/',
34
- );
35
- expect(result.stdout).toContain('This is your copy of the Neutral theme');
36
- expect(result.stderr.match(/source copying is deprecated/g)).toHaveLength(
37
- 1,
38
- );
39
- // The app has no CLI installed, so the commands name the scoped package.
40
- const run = getCliInvocation(tmpDir);
41
- expect(run).toMatch(/ @astryxdesign\/cli$/);
42
- expect(result.stderr).toContain(`${run} theme eject neutral`);
43
- expect(result.stderr).toContain(`${run} theme add neutral --import`);
44
- expect(fs.existsSync(path.join(tmpDir, 'src/themes/neutral'))).toBe(true);
45
- expect(fs.existsSync(path.join(tmpDir, 'src/astryx-themes.ts'))).toBe(
46
- false,
47
- );
76
+ expect(result.stdout).toMatch(/^owner:\s+@acme\/themes$/m);
77
+ expect(result.stdout).toMatch(/^module:\s+@acme\/themes\/themes\/ocean$/m);
78
+ expect(result.stdout).toMatch(/^action:\s+add$/m);
79
+ expect(result.stderr).not.toContain('DEP-0005');
80
+ expect(result.stderr).not.toContain('deprecated');
81
+ expect(fs.existsSync(path.join(tmpDir, 'src/astryx-themes.ts'))).toBe(true);
82
+ expect(fs.existsSync(path.join(tmpDir, 'src/themes/ocean'))).toBe(false);
48
83
  });
49
84
 
50
- it('keeps theme.add data and adds machine-readable deprecation metadata', async () => {
51
- const result = await runCli(['theme', 'add', 'neutral', '--json'], tmpDir);
85
+ it('plain theme add returns theme.app with no deprecation metadata', async () => {
86
+ const result = await runCli(
87
+ ['theme', 'add', 'ocean', '--package', '@acme/themes', '--json'],
88
+ tmpDir,
89
+ );
52
90
 
53
91
  expect(result.status, result.stderr).toBe(0);
54
- expect(result.stderr).not.toContain('source copying is deprecated');
55
- expect(JSON.parse(result.stdout)).toMatchObject({
56
- type: 'theme.add',
92
+ expect(result.stderr).toBe('');
93
+ const payload = JSON.parse(result.stdout);
94
+ expect(payload).toMatchObject({
95
+ type: 'theme.app',
57
96
  data: {
58
- slug: 'neutral',
59
- package: '@astryxdesign/cli',
60
- outputDir: 'src/themes/neutral',
61
- },
62
- meta: {
63
- deprecations: [
64
- {
65
- id: 'DEP-0005',
66
- replacements: ['theme eject', 'theme add --import'],
67
- },
68
- ],
97
+ default: 'ocean',
98
+ modulePath: 'src/astryx-themes.ts',
99
+ change: {action: 'add', slug: 'ocean', changed: true},
69
100
  },
70
101
  });
102
+ expect(payload.meta).toBeUndefined();
103
+ });
104
+
105
+ it('keeps --import as an accepted no-op with the same response', async () => {
106
+ const result = await runCli(
107
+ [
108
+ 'theme',
109
+ 'add',
110
+ 'ocean',
111
+ '--import',
112
+ '--package',
113
+ '@acme/themes',
114
+ '--json',
115
+ ],
116
+ tmpDir,
117
+ );
118
+
119
+ expect(result.status, result.stderr).toBe(0);
120
+ expect(JSON.parse(result.stdout)).toMatchObject({
121
+ type: 'theme.app',
122
+ data: {default: 'ocean', change: {action: 'add', slug: 'ocean'}},
123
+ });
124
+ expect(fs.existsSync(path.join(tmpDir, 'src/themes/ocean'))).toBe(false);
71
125
  });
72
126
 
73
- it('keeps the list JSON unchanged and names the stage commands in text', async () => {
127
+ it('keeps list JSON byte-compatible and names cleanup commands in text', async () => {
74
128
  fs.mkdirSync(path.join(tmpDir, 'src/themes/broken'), {recursive: true});
75
129
  fs.writeFileSync(
76
130
  path.join(tmpDir, 'src/themes/broken/brokenTheme.ts'),
@@ -81,16 +135,19 @@ describe('theme add compatibility lifecycle', () => {
81
135
  expect(textResult.status, textResult.stderr).toBe(0);
82
136
  const run = getCliInvocation(tmpDir);
83
137
  expect(textResult.stdout).toContain(
84
- `Import one: ${run} theme add <slug> --import [--package <package>]`,
138
+ `Import one: ${run} theme add <slug> [--package <package>]`,
85
139
  );
86
140
  expect(textResult.stdout).toContain(
87
141
  `Fork source: ${run} theme eject <slug> [target-path]`,
88
142
  );
143
+ expect(textResult.stdout).toMatch(
144
+ /More themes in packages you could add: .*discover theme$/m,
145
+ );
89
146
  expect(textResult.stdout).not.toContain('theme add <slug> [target-path]');
147
+ expect(textResult.stdout).not.toContain('theme add <slug> --import');
90
148
  expect(textResult.stderr).not.toContain('deprecated');
91
149
 
92
150
  const result = await runCli(['theme', 'add', '--list', '--json'], tmpDir);
93
-
94
151
  expect(result.status, result.stderr).toBe(0);
95
152
  const payload = JSON.parse(result.stdout);
96
153
  expect(payload).toMatchObject({type: 'theme.list'});
@@ -107,29 +164,65 @@ describe('theme add compatibility lifecycle', () => {
107
164
  });
108
165
 
109
166
  it.each([
110
- ['target path', ['src/brand']],
111
- ['overwrite', ['--overwrite']],
112
- ])('rejects --import with a %s before writing', async (_label, extra) => {
167
+ ['target path', ['src/brand'], 'ERR_INVALID_ARGUMENT'],
168
+ ['overwrite', ['--overwrite'], 'ERR_INVALID_OPTION'],
169
+ [
170
+ 'target path with --import',
171
+ ['--import', 'src/brand'],
172
+ 'ERR_INVALID_ARGUMENT',
173
+ ],
174
+ [
175
+ 'overwrite with --import',
176
+ ['--import', '--overwrite'],
177
+ 'ERR_INVALID_OPTION',
178
+ ],
179
+ ])(
180
+ 'rejects removed %s before writing with the standard parser code',
181
+ async (_label, extra, code) => {
182
+ const result = await runCli(
183
+ [
184
+ 'theme',
185
+ 'add',
186
+ 'ocean',
187
+ ...extra,
188
+ '--package',
189
+ '@acme/themes',
190
+ '--json',
191
+ ],
192
+ tmpDir,
193
+ );
194
+
195
+ expect(result.status).toBe(1);
196
+ expect(JSON.parse(result.stdout)).toMatchObject({code});
197
+ expect(fs.existsSync(path.join(tmpDir, 'src/astryx-themes.ts'))).toBe(
198
+ false,
199
+ );
200
+ expect(fs.existsSync(path.join(tmpDir, 'src/brand'))).toBe(false);
201
+ },
202
+ );
203
+
204
+ it('rejects --overwrite without a slug as an invalid option', async () => {
113
205
  const result = await runCli(
114
- ['theme', 'add', 'neutral', '--import', ...extra, '--json'],
206
+ ['theme', 'add', '--overwrite', '--json'],
115
207
  tmpDir,
116
208
  );
117
209
 
118
- expect(result.status).not.toBe(0);
210
+ expect(result.status).toBe(1);
119
211
  expect(JSON.parse(result.stdout)).toMatchObject({
120
- code: 'ERR_THEME_INVALID',
121
- error: expect.stringContaining('cannot be combined'),
212
+ code: 'ERR_INVALID_OPTION',
122
213
  });
123
214
  expect(fs.existsSync(path.join(tmpDir, 'src/astryx-themes.ts'))).toBe(
124
215
  false,
125
216
  );
126
- expect(fs.existsSync(path.join(tmpDir, 'src/brand'))).toBe(false);
127
217
  });
128
218
 
129
- it('lists --import in help', async () => {
219
+ it('shows --import and the visible eject replacement without a hidden option', async () => {
130
220
  const result = await runCli(['theme', 'add', '--help'], tmpDir);
131
221
 
132
222
  expect(result.status, result.stderr).toBe(0);
133
223
  expect(result.stdout).toContain('--import');
224
+ expect(result.stdout).toMatch(/compatibility no-op/i);
225
+ expect(result.stdout).toContain('theme eject <slug> [path] [--overwrite]');
226
+ expect(result.stdout).not.toMatch(/^\s+-f, --overwrite/m);
134
227
  });
135
228
  });
@@ -8,26 +8,19 @@ export const doc = {
8
8
  name: 'theme add',
9
9
  displayName: 'astryx theme add',
10
10
  namespace: 'cli/commands',
11
- summary: 'Copy a theme, or import its built output into the app',
11
+ summary:
12
+ "Add a built theme to the app. To copy a theme's source as an editable fork, run `theme eject <slug> [path] [--overwrite]`.",
12
13
  description:
13
- 'With --import, records the theme in the generated app module and imports its built module and stylesheets. Without --import, keeps the released source-copy behavior, emits one text warning, and adds meta.deprecations with DEP-0005 and the theme eject/theme add --import replacements to JSON. A bare command or --list delegates to themeListCopySources() so the released list fields stay unchanged; use --package when owners share a slug.',
14
+ "Records the theme in the generated app module and imports its built module and stylesheets. --import remains accepted as a compatibility no-op. To copy a theme's source as an editable fork, run `theme eject <slug> [path] [--overwrite]`. A bare command or --list delegates to themeListCopySources(), whose released JSON bytes stay unchanged while its text names the current add and eject commands; use --package when owners share a slug.",
14
15
  fn: 'themeAdd',
15
- args: [
16
- {name: 'slug', param: 'slug', required: false},
17
- {name: 'path', param: 'options.targetPath', required: false},
18
- ],
16
+ args: [{name: 'slug', param: 'slug', required: false}],
19
17
  options: [
20
- {
21
- flag: '-f, --overwrite',
22
- param: 'options.overwrite',
23
- description: 'Replace copied files. Cannot be combined with --import',
24
- },
25
18
  {flag: '--list', description: 'List available themes'},
26
19
  {
27
20
  flag: '--import',
28
21
  param: 'options.import',
29
22
  description:
30
- 'Use the built theme through the generated app module instead of copying source',
23
+ 'Compatibility no-op; the built theme is added with or without this flag',
31
24
  },
32
25
  {
33
26
  flag: '--package <package>',
@@ -37,19 +30,19 @@ export const doc = {
37
30
  ],
38
31
  examples: [
39
32
  {
40
- label: 'Import a built theme into the app',
41
- cli: 'astryx theme add ocean --import',
33
+ label: 'Add a built theme to the app',
34
+ cli: 'astryx theme add ocean',
42
35
  },
43
36
  {
44
37
  label: 'Select a package theme over a local theme',
45
- cli: 'astryx theme add ocean --import --package @acme/themes',
38
+ cli: 'astryx theme add ocean --package @acme/themes',
46
39
  },
47
40
  ],
48
41
  exitCodes: [
49
- {code: 0, when: 'the theme is listed, copied, or imported'},
42
+ {code: 0, when: 'the theme is listed or added'},
50
43
  {
51
44
  code: 1,
52
- when: 'the theme, its source or built imports, its record, the target path, or the option combination is invalid',
45
+ when: 'the theme, its built imports, its record, or the option combination is invalid',
53
46
  },
54
47
  ],
55
48
  related: ['theme list', 'theme remove', 'theme use', 'theme eject'],
@@ -29,7 +29,8 @@ describe('astryx theme list', () => {
29
29
  expect(status).toBe(0);
30
30
  expect(stdout).toMatch(/^slug:\s+neutral$/m);
31
31
  expect(stdout).toMatch(/^package:\s+@astryxdesign\/cli$/m);
32
- expect(stdout).toMatch(/Import one: .*theme add <slug> --import/m);
32
+ expect(stdout).toMatch(/Import one: .*theme add <slug>/m);
33
+ expect(stdout).not.toContain('theme add <slug> --import');
33
34
  expect(stdout).toMatch(/Fork source: .*theme eject <slug>/m);
34
35
  expect(stdout).toMatch(/More themes in packages you could add: .*discover theme$/m);
35
36
  });
@@ -18,19 +18,21 @@ describe('astryx theme targets', () => {
18
18
 
19
19
  expect(status).toBe(0);
20
20
  // Inline layout: key component - props - states - className
21
- expect(stdout).toMatch(/^switch\s+Switch - size - checked, disabled - astryx-switch$/m);
22
- expect(stdout).toMatch(/^switch-thumb\s+Switch - size - checked - astryx-switch-thumb$/m);
21
+ expect(stdout).toMatch(
22
+ /^switch\s+Switch - size - checked, disabled - astryx-switch$/m,
23
+ );
24
+ expect(stdout).toMatch(
25
+ /^switch-thumb\s+Switch - size - checked - astryx-switch-thumb$/m,
26
+ );
23
27
  expect(stdout).toMatch(/4 across 1 component/);
24
28
  });
25
29
 
26
- it('labels deprecated targets with their exact canonical replacement', async () => {
30
+ it('omits removed aliases from the target list', async () => {
27
31
  const {status, stdout} = await runCli(['theme', 'targets', 'Popover']);
28
32
 
29
33
  expect(status).toBe(0);
30
34
  expect(stdout).toMatch(/^popover\s{2,}Popover/m);
31
- expect(stdout).toMatch(
32
- /^popover-surface\s{2,}Popover - astryx-popover-surface - deprecated; use popover$/m,
33
- );
35
+ expect(stdout).not.toContain('popover-surface');
34
36
  });
35
37
 
36
38
  it('lists the whole surface when unfiltered', async () => {
@@ -19,7 +19,7 @@ export const doc = {
19
19
  'Writes theme.template.ts: the annotated reference for the whole theme surface, covering every ' +
20
20
  'defineTheme field, the token families, the component override syntax, and how a theme is ' +
21
21
  'consumed, naming the CLI command that prints the authoritative reference for each. Read ' +
22
- 'it, copy what you need into your own theme file, delete it. Use `theme add <slug> --import` to ' +
22
+ 'it, copy what you need into your own theme file, delete it. Use `theme add <slug>` to ' +
23
23
  'use an installed built theme, extend that theme for ordinary customization, or use ' +
24
24
  '`theme eject <slug>` for a complete source fork. Leaves an existing file untouched unless --overwrite.',
25
25
  fn: 'themeTemplate',
@@ -13,7 +13,7 @@ export const doc = {
13
13
  namespace: 'cli/commands',
14
14
  summary: 'Add, switch, build, and author themes',
15
15
  description:
16
- 'The theme command group. Import built themes into an app, choose its default, remove them, list available and added themes, or eject source to make a local fork. Plain theme add still copies source while that default is deprecated. The authoring commands build themes, generate palettes, write the annotated template, and list component theme targets.',
16
+ 'The theme command group. Add built themes to an app, choose its default, remove them, list available and added themes, or eject source to make a local fork. The authoring commands build themes, generate palettes, write the annotated template, and list component theme targets.',
17
17
  subcommands: [
18
18
  'build',
19
19
  'list',
@@ -27,7 +27,7 @@ export const doc = {
27
27
  ],
28
28
  examples: [
29
29
  {label: 'List available and added themes', cli: 'astryx theme list'},
30
- {label: 'Import a theme into the app', cli: 'astryx theme add ocean --import'},
30
+ {label: 'Import a theme into the app', cli: 'astryx theme add ocean'},
31
31
  {label: 'Choose the default', cli: 'astryx theme use ocean'},
32
32
  {label: 'Fork source to customize', cli: 'astryx theme eject ocean'},
33
33
  {
@@ -90,7 +90,7 @@ export const doc = {
90
90
  flag: '--list',
91
91
  param: 'options.list',
92
92
  description:
93
- 'List available codemods and do nothing else. Every other flag is ignored, except --registry, which is refused (exit 1)',
93
+ 'List available codemods and do nothing else. Every other flag is refused, as is --registry (exit 1)',
94
94
  default: false,
95
95
  },
96
96
  ],
@@ -79,22 +79,18 @@ const MIGRATION_FLAGS = [
79
79
  describe('astryx upgrade flag interactions', () => {
80
80
  it('--list: help says it ignores every other flag but --registry, and it does', async () => {
81
81
  const options = await upgradeOptions();
82
- expect(options['--list']).toMatch(/Every other flag is ignored, except --registry/);
82
+ expect(options['--list']).toMatch(/Every other flag is refused, as is --registry/);
83
83
 
84
84
  installPackage('@astryxdesign/core', '0.6.0');
85
- const listed = await upgradeJson([
86
- '--list',
87
- '--from',
88
- 'bogus',
89
- '--codemod',
90
- 'bogus',
91
- '--apply',
92
- '--path',
93
- '../outside',
94
- ]);
85
+
86
+ const listed = await upgradeJson(['--list']);
95
87
  expect(listed.status).toBe(0);
96
88
  expect(listed.envelope.type).toBe('upgrade.list');
97
89
 
90
+ const withFlags = await upgradeJson(['--list', '--from', 'bogus']);
91
+ expect(withFlags.status).toBe(1);
92
+ expect(withFlags.envelope.code).toBe('ERR_INVALID_ARGUMENT');
93
+
98
94
  const refused = await upgradeJson(['--list', '--registry']);
99
95
  expect(refused.status).toBe(1);
100
96
  expect(refused.envelope.code).toBe('ERR_INVALID_ARGUMENT');
@@ -0,0 +1,67 @@
1
+ // Copyright (c) Meta Platforms, Inc. and affiliates.
2
+ import {describe, it, expect, beforeEach, afterEach} from 'vitest';
3
+ import * as fs from 'node:fs'; import * as os from 'node:os'; import * as path from 'node:path';
4
+ import {runCli} from '../../../test-utils/run-cli.mjs';
5
+ import {validateIntegration} from '../../../api/integration/validate-integration.mjs';
6
+ import {integrationTemplateConflicts, integrationComponentConflicts, integrationDocConflicts} from '../../../api/integration/authoring-checks.mjs';
7
+ let dir;
8
+ beforeEach(() => { dir = fs.mkdtempSync(path.join(os.tmpdir(),'astryx-val-')); });
9
+ afterEach(() => fs.rmSync(dir, {recursive:true,force:true}));
10
+ const json = async a => { const {status,stdout}=await runCli(['--json',...a],{cwd:dir}); return {status,body:JSON.parse(stdout)}; };
11
+ const text = async a => runCli(a, {cwd: dir});
12
+
13
+ describe('doctor integration validate exit codes (IFIX-0008)', () => {
14
+ it('exits 1 with no package.json (JSON has no_package issue)', async () => {
15
+ const {status, body} = await json(['doctor','integration','validate']);
16
+ expect(status).toBe(1);
17
+ expect(body.data.validated).toBe(false);
18
+ expect(body.data.issues).toEqual([
19
+ expect.objectContaining({code: 'no_package', severity: 'error'}),
20
+ ]);
21
+ });
22
+
23
+ it('text mode says no package.json when there is none', async () => {
24
+ const {status, stdout} = await text(['doctor','integration','validate']);
25
+ expect(status).toBe(1);
26
+ expect(stdout).toContain('no package.json found');
27
+ });
28
+
29
+ it('exits 0 with package.json but no manifest (byte-identical to published)', async () => {
30
+ fs.writeFileSync(path.join(dir,'package.json'), JSON.stringify({name:'myapp',version:'1.0.0'}));
31
+ const {status, body} = await json(['doctor','integration','validate']);
32
+ expect(status).toBe(0);
33
+ expect(body.data).toEqual({validated: false, name: null, version: null, issues: []});
34
+ });
35
+
36
+ it('text mode says no manifest when package.json exists', async () => {
37
+ fs.writeFileSync(path.join(dir,'package.json'), JSON.stringify({name:'myapp',version:'1.0.0'}));
38
+ const {status, stdout} = await text(['doctor','integration','validate']);
39
+ expect(status).toBe(0);
40
+ expect(stdout).toContain('no astryx.integration');
41
+ });
42
+
43
+ it('exported API returns the no_package issue', async () => {
44
+ const result = await validateIntegration(undefined, {cwd: dir});
45
+ expect(result.type).toBe('integration.validate');
46
+ expect(result.data.validated).toBe(false);
47
+ expect(result.data.issues).toEqual([
48
+ expect.objectContaining({code: 'no_package', severity: 'error'}),
49
+ ]);
50
+ });
51
+
52
+ it('integration verify exits 1 with a data envelope', async () => {
53
+ const {status, body} = await json(['integration','verify']);
54
+ expect(status).toBe(1);
55
+ expect(body.type).toBe('integration.pack-check');
56
+ expect(body.data.issues.some(i => i.code === 'no_package')).toBe(true);
57
+ });
58
+
59
+ it('sibling commands stay unchanged with no package.json', async () => {
60
+ for (const sub of ['templates', 'components', 'docs']) {
61
+ const {status, body} = await json(['doctor','integration', sub]);
62
+ expect(status, `doctor integration ${sub}`).toBe(0);
63
+ expect(body.data.validated).toBe(false);
64
+ expect(body.data.issues).toEqual([]);
65
+ }
66
+ });
67
+ });
@@ -107,9 +107,6 @@ export const JSON_SUPPORTED = new Set([
107
107
  'doctor integration templates',
108
108
  'doctor integration components',
109
109
  'doctor integration docs',
110
- 'layout expand',
111
- 'layout check',
112
- 'layout grammar',
113
110
  ]);
114
111
 
115
112
  /**
@@ -268,7 +265,6 @@ const commands = [
268
265
  {name: 'gap-report', path: './commands/gap-report.mjs', register: 'registerGapReport'},
269
266
  // agent-docs folded into init — functions still importable from agent-docs.mjs
270
267
  {name: 'template', path: './commands/template.mjs', register: 'registerTemplate'},
271
- {name: 'layout', path: './commands/layout.mjs', register: 'registerLayout'},
272
268
  {name: 'upgrade', path: './commands/upgrade.mjs', register: 'registerUpgrade'},
273
269
  {name: 'theme', path: './commands/build-theme.mjs', register: 'registerTheme'},
274
270
  {name: 'integration', path: './commands/integration.mjs', register: 'registerIntegration'},
@@ -135,6 +135,25 @@ export function cliError(message, options = {}) {
135
135
  return /** @type {never} */ (undefined);
136
136
  }
137
137
 
138
+ /**
139
+ * Reject a positional argument the user typed as `""`.
140
+ *
141
+ * @param {string} name the argument as the help spells it, without brackets
142
+ * @param {unknown} value what Commander passed
143
+ * @param {string} command the command as a user types it, e.g. `astryx template`
144
+ * @returns {void} returns only when the argument is not an empty string
145
+ */
146
+ export function rejectEmptyArgument(name, value, command) {
147
+ if (typeof value !== 'string' || value.length > 0) return;
148
+ cliError(
149
+ `Argument <${name}> is an empty string. ` +
150
+ 'An empty argument is not the same as an omitted one, and ignoring it ' +
151
+ 'would silently discard the rest of the command: pass a value, or leave ' +
152
+ `<${name}> out of \`${command}\` entirely.`,
153
+ {code: ERROR_CODES.ERR_INVALID_ARGUMENT},
154
+ );
155
+ }
156
+
138
157
  /**
139
158
  * Clean exit. Mostly a marker for intent — `process.exit(0)` works fine,
140
159
  * but using cliExit at success boundaries makes greps for "exit policy"