@astryxdesign/cli 0.7.0-canary.693da50 → 0.7.0-canary.7ec7d16

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 (224) hide show
  1. package/README.md +79 -84
  2. package/api/build/build.mjs +9 -0
  3. package/api/component/_adapter.d.mts +2 -0
  4. package/api/component/_adapter.mjs +3 -1
  5. package/api/component/component.doc.mjs +5 -1
  6. package/api/docs/compiled-topics.test.mjs +16 -0
  7. package/api/doctor/doctor.doc.mjs +1 -1
  8. package/api/doctor/doctor.test.mjs +28 -0
  9. package/api/doctor/theme-checks.mjs +10 -10
  10. package/api/doctor/theme-checks.test.mjs +5 -4
  11. package/api/gap-report/gap-report.doc.mjs +1 -1
  12. package/api/gap-report/gap-report.mjs +15 -0
  13. package/api/gap-report/gap-report.test.mjs +1 -1
  14. package/api/index.d.mts +0 -2
  15. package/api/index.mjs +0 -2
  16. package/api/init/init.doc.mjs +5 -1
  17. package/api/init/init.mjs +22 -0
  18. package/api/init/init.type.d.mts +4 -1
  19. package/api/init/init.type.mjs +1 -1
  20. package/api/init/remove/remove.mjs +8 -3
  21. package/api/init/remove/remove.test.mjs +12 -0
  22. package/api/init/run/run.d.mts +1 -1
  23. package/api/init/run/run.mjs +3 -3
  24. package/api/integration/pack-check.test.mjs +8 -0
  25. package/api/integration/validate-integration.d.mts +4 -0
  26. package/api/integration/validate-integration.mjs +5 -2
  27. package/api/integration/validateIntegration.doc.mjs +1 -1
  28. package/api/json/index.ts +0 -1
  29. package/api/search/search.doc.mjs +1 -1
  30. package/api/search/search.mjs +1 -1
  31. package/api/search/search.test.mjs +1 -1
  32. package/api/search/search.type.d.mts +1 -1
  33. package/api/search/search.type.mjs +1 -1
  34. package/api/template/list/list.mjs +23 -2
  35. package/api/template/list/list.test.mjs +52 -0
  36. package/api/template/template-integration.test.mjs +37 -100
  37. package/api/template/template.doc.mjs +8 -3
  38. package/api/template/template.mjs +45 -0
  39. package/api/template/template.type.mjs +1 -1
  40. package/api/theme/_adapter.mjs +3 -3
  41. package/api/theme/add/add.d.mts +11 -5
  42. package/api/theme/add/add.mjs +19 -192
  43. package/api/theme/add/add.test.mjs +68 -258
  44. package/api/theme/add/add.types.test.mjs +0 -1
  45. package/api/theme/build/build.d.mts +3 -4
  46. package/api/theme/build/build.mjs +26 -65
  47. package/api/theme/build/build.test.mjs +11 -24
  48. package/api/theme/build/family.mjs +1 -1
  49. package/api/theme/eject/eject.copy-compat.test.mjs +168 -0
  50. package/api/theme/integration-themes.test.mjs +3 -3
  51. package/api/theme/remove/remove.test.mjs +1 -1
  52. package/api/theme/targets/targets.test.mjs +0 -4
  53. package/api/theme/template/template.mjs +1 -1
  54. package/api/theme/theme.type.d.mts +1 -30
  55. package/api/theme/theme.type.mjs +3 -13
  56. package/api/theme/themeAdd.doc.mjs +19 -27
  57. package/api/theme/themeTargets.doc.mjs +3 -4
  58. package/api/theme/themeTemplate.doc.mjs +1 -1
  59. package/api/theme/use/use.test.mjs +1 -1
  60. package/api/upgrade/upgrade.doc.mjs +1 -1
  61. package/api/upgrade/upgrade.mjs +19 -0
  62. package/assets/codemods/transforms/next/__tests__/migrate-deprecated-theme-surface.test.mjs +322 -0
  63. package/assets/codemods/transforms/next/__tests__/migrate-field-input-styling.test.mjs +108 -0
  64. package/assets/codemods/transforms/next/__tests__/validate-data-token-ownership.test.mjs +84 -0
  65. package/assets/codemods/transforms/next/index.mjs +27 -1
  66. package/assets/codemods/transforms/next/migrate-deprecated-theme-surface-v0.6-data.mjs +229 -0
  67. package/assets/codemods/transforms/next/migrate-deprecated-theme-surface.mjs +624 -0
  68. package/assets/codemods/transforms/next/migrate-field-input-styling.mjs +198 -0
  69. package/assets/codemods/transforms/next/validate-data-token-ownership.mjs +102 -0
  70. package/assets/codemods/transforms/v0.6.0/migrate-astryx-theme-selectors-to-data-attrs.mjs +38 -18
  71. package/assets/docs/author-a-theme.doc.mjs +5 -5
  72. package/assets/docs/getting-started.doc.mjs +2 -2
  73. package/assets/docs/theme.doc.dense.mjs +1 -1
  74. package/assets/docs/theme.doc.mjs +2 -2
  75. package/assets/docs/tree/add-a-theme.doc.mjs +1 -1
  76. package/assets/docs/tree/document-the-theme.doc.mjs +2 -2
  77. package/assets/docs/tree/fonts-and-assets.doc.mjs +3 -3
  78. package/assets/docs/tree/styling-advanced.doc.mjs +21 -14
  79. package/assets/docs/tree/themes.doc.mjs +1 -1
  80. package/assets/docs/tree/tokens-data.doc.mjs +2 -2
  81. package/assets/docs/tree/tokens-usage.doc.mjs +1 -1
  82. package/assets/docs/tree/use-a-theme-in-an-app.doc.mjs +2 -2
  83. package/assets/docs/tree/versioning.doc.mjs +1 -4
  84. package/assets/docs/use-a-theme.doc.mjs +16 -16
  85. package/assets/templates/blocks/components/ComplexSelector/ComplexSelectorDeadlinePicker.tsx +1 -1
  86. package/assets/templates/blocks/components/ComplexSelector/ComplexSelectorShowcase.tsx +1 -1
  87. package/assets/templates/blocks/components/ComplexSelector/ComplexSelectorTreeSearch.tsx +1 -1
  88. package/assets/templates/blocks/components/InternationalizationProvider/InternationalizationProvider01ShippedLocale.tsx +1 -1
  89. package/assets/templates/blocks/components/InternationalizationProvider/InternationalizationProvider02Overrides.tsx +1 -1
  90. package/assets/templates/blocks/components/Selector/SelectorClearable.tsx +1 -1
  91. package/assets/templates/blocks/components/Selector/SelectorOptionDescriptions.tsx +2 -2
  92. package/assets/templates/blocks/components/Selector/SelectorShowcase.tsx +1 -1
  93. package/assets/templates/blocks/components/Selector/SelectorWithSections.tsx +1 -1
  94. package/assets/templates/blocks/components/SelectorOption/SelectorOptionBasic.tsx +1 -1
  95. package/assets/templates/blocks/components/SelectorOption/SelectorOptionShowcase.tsx +1 -1
  96. package/assets/templates/blocks/components/Slider/SliderFormattedValue.tsx +1 -1
  97. package/assets/templates/blocks/components/Slider/SliderRangeSlider.tsx +1 -1
  98. package/assets/templates/blocks/components/Slider/SliderShowcase.tsx +1 -1
  99. package/assets/templates/blocks/components/Slider/SliderWithMarks.tsx +1 -1
  100. package/assets/templates/blocks/components/Tokenizer/TokenizerClear.tsx +1 -1
  101. package/assets/templates/blocks/components/Tokenizer/TokenizerCreatable.tsx +2 -2
  102. package/assets/templates/blocks/components/Tokenizer/TokenizerEndContent.tsx +1 -1
  103. package/assets/templates/blocks/components/Tokenizer/TokenizerIcon.tsx +1 -1
  104. package/assets/templates/blocks/components/Tokenizer/TokenizerMaxEntries.tsx +1 -1
  105. package/assets/templates/blocks/components/Tokenizer/TokenizerOverflow.tsx +2 -2
  106. package/assets/templates/blocks/components/Tokenizer/TokenizerShowcase.tsx +1 -1
  107. package/assets/templates/blocks/components/Tokenizer/TokenizerStates.tsx +4 -4
  108. package/assets/templates/blocks/components/Toolbar/ToolbarTableFilter.tsx +1 -1
  109. package/assets/templates/pages/canvas-editor/page.tsx +2 -2
  110. package/assets/templates/pages/form-wizard-vertical/page.tsx +1 -1
  111. package/assets/templates/pages/payment-form/page.tsx +1 -1
  112. package/assets/templates/pages/table-filter/page.tsx +3 -3
  113. package/assets/templates/pages/theme-showcase/page.tsx +2 -2
  114. package/assets/templates/themes/neutral/neutralPaletteRefs.generated.ts +10 -9
  115. package/authoring/debug/type.ts +2 -2
  116. package/authoring/doctypes/base/type.ts +0 -9
  117. package/authoring/integration/integration.doc.mjs +1 -1
  118. package/clients/cli/command-result-coverage.test.mjs +1 -1
  119. package/clients/cli/commands/build-theme.adaptations.test.mjs +4 -0
  120. package/clients/cli/commands/build-theme.ascii-output.test.mjs +35 -8
  121. package/clients/cli/commands/build-theme.color-scheme.test.mjs +10 -6
  122. package/clients/cli/commands/build-theme.data-tokens.test.mjs +23 -75
  123. package/clients/cli/commands/build-theme.mjs +31 -67
  124. package/clients/cli/commands/build-theme.registry.test.mjs +0 -10
  125. package/clients/cli/commands/build.doc.mjs +1 -1
  126. package/clients/cli/commands/build.mjs +1 -1
  127. package/clients/cli/commands/component-ownership.test.mjs +2 -2
  128. package/clients/cli/commands/debug-result-summary.test.mjs +0 -16
  129. package/clients/cli/commands/discover.mjs +2 -1
  130. package/clients/cli/commands/doctor.mjs +5 -2
  131. package/clients/cli/commands/empty-argument.test.mjs +16 -0
  132. package/clients/cli/commands/gap-report.doc.mjs +1 -1
  133. package/clients/cli/commands/gap-report.test.mjs +2 -2
  134. package/clients/cli/commands/init.doc.mjs +4 -4
  135. package/clients/cli/commands/init.flag-help.test.mjs +7 -10
  136. package/clients/cli/commands/init.next-steps.test.mjs +1 -1
  137. package/clients/cli/commands/integration.mjs +2 -1
  138. package/clients/cli/commands/option-pair-refusals.test.mjs +37 -0
  139. package/clients/cli/commands/search.test.mjs +1 -1
  140. package/clients/cli/commands/silent-success-refusals.test.mjs +15 -0
  141. package/clients/cli/commands/swizzle.mjs +4 -1
  142. package/clients/cli/commands/template.doc.mjs +4 -4
  143. package/clients/cli/commands/template.flag-help.test.mjs +18 -11
  144. package/clients/cli/commands/template.mjs +7 -1
  145. package/clients/cli/commands/text-json-parity.test.mjs +0 -17
  146. package/clients/cli/commands/theme-add-lifecycle.test.mjs +142 -49
  147. package/clients/cli/commands/theme-add.doc.mjs +10 -17
  148. package/clients/cli/commands/theme-list.behavior.test.mjs +2 -1
  149. package/clients/cli/commands/theme-targets.behavior.test.mjs +8 -6
  150. package/clients/cli/commands/theme-template.doc.mjs +1 -1
  151. package/clients/cli/commands/theme.doc.mjs +2 -2
  152. package/clients/cli/commands/upgrade.doc.mjs +1 -1
  153. package/clients/cli/commands/upgrade.flag-help.test.mjs +7 -11
  154. package/clients/cli/commands/validate-nothing-exits-nonzero.test.mjs +67 -0
  155. package/clients/cli/index.mjs +0 -4
  156. package/clients/cli/lib/cli-error.mjs +19 -0
  157. package/clients/cli/lib/component-format.mjs +111 -57
  158. package/clients/cli/lib/component-format.test.mjs +28 -39
  159. package/clients/cli/lib/doc-text-ascii.test.mjs +5 -2
  160. package/clients/cli/lib/exit-codes.test.mjs +0 -7
  161. package/clients/cli/lib/json-shim.test.mjs +0 -24
  162. package/foundation/agent-docs/agent-docs.d.mts +2 -1
  163. package/foundation/agent-docs/agent-docs.mjs +6 -1
  164. package/foundation/agent-docs/app-theme-workflow.test.mjs +3 -0
  165. package/foundation/config/theme-state.mjs +3 -3
  166. package/foundation/debug/debug-fields.test.mjs +13 -35
  167. package/foundation/debug/event.mjs +13 -78
  168. package/foundation/debug/privacy-contract.test.mjs +20 -12
  169. package/foundation/debug/redact.d.mts +2 -2
  170. package/foundation/debug/redact.mjs +2 -2
  171. package/foundation/discovery/template-needs.mjs +93 -11
  172. package/foundation/discovery/template-needs.test.mjs +106 -3
  173. package/foundation/discovery/theme-imports.mjs +1 -1
  174. package/foundation/discovery/theming-targets.d.mts +1 -20
  175. package/foundation/discovery/theming-targets.mjs +1 -38
  176. package/foundation/discovery/theming-targets.test.mjs +9 -175
  177. package/foundation/doc-compiler/doc-loads.test.mjs +0 -12
  178. package/foundation/env/package-manager.d.mts +13 -0
  179. package/foundation/env/package-manager.mjs +106 -63
  180. package/foundation/response/error-codes.doc.mjs +1 -1
  181. package/foundation/response/response-types.doc.mjs +11 -31
  182. package/foundation/response/response-types.doc.test.mjs +36 -14
  183. package/foundation/response/response.doc.mjs +1 -1
  184. package/foundation/xle/browser.d.mts +2 -2
  185. package/foundation/xle/browser.mjs +2 -2
  186. package/foundation/xle/expand.mjs +1 -1
  187. package/foundation/xle/print.mjs +1 -1
  188. package/package.json +9 -9
  189. package/api/layout/_adapter.d.mts +0 -34
  190. package/api/layout/_adapter.mjs +0 -148
  191. package/api/layout/check/check.d.mts +0 -17
  192. package/api/layout/check/check.mjs +0 -41
  193. package/api/layout/expand/expand.d.mts +0 -23
  194. package/api/layout/expand/expand.mjs +0 -161
  195. package/api/layout/expand/expand.path-safety.test.mjs +0 -53
  196. package/api/layout/expand/expand.receipt.test.mjs +0 -74
  197. package/api/layout/grammar/grammar.d.mts +0 -14
  198. package/api/layout/grammar/grammar.mjs +0 -88
  199. package/api/layout/layout.d.mts +0 -6
  200. package/api/layout/layout.mjs +0 -17
  201. package/api/layout/layout.test.mjs +0 -297
  202. package/api/layout/layout.type.d.mts +0 -90
  203. package/api/layout/layout.type.mjs +0 -104
  204. package/api/layout/layoutCheck.doc.d.mts +0 -11
  205. package/api/layout/layoutCheck.doc.mjs +0 -85
  206. package/api/layout/layoutExpand.doc.d.mts +0 -11
  207. package/api/layout/layoutExpand.doc.mjs +0 -107
  208. package/api/layout/layoutGrammar.doc.d.mts +0 -11
  209. package/api/layout/layoutGrammar.doc.mjs +0 -57
  210. package/api/theme/add/add.binary.test.mjs +0 -157
  211. package/api/theme/add/add.rollback.test.mjs +0 -158
  212. package/api/theme/add/add.staging.test.mjs +0 -83
  213. package/clients/cli/commands/layout-check.doc.mjs +0 -67
  214. package/clients/cli/commands/layout-expand.doc.mjs +0 -87
  215. package/clients/cli/commands/layout-grammar.doc.mjs +0 -32
  216. package/clients/cli/commands/layout.deprecation-lifecycle.test.mjs +0 -140
  217. package/clients/cli/commands/layout.doc.mjs +0 -36
  218. package/clients/cli/commands/layout.error-codes.test.mjs +0 -66
  219. package/clients/cli/commands/layout.exit-parity.test.mjs +0 -41
  220. package/clients/cli/commands/layout.expand-receipt.test.mjs +0 -94
  221. package/clients/cli/commands/layout.mjs +0 -327
  222. package/clients/cli/commands/layout.path-help.test.mjs +0 -33
  223. package/clients/cli/commands/layout.stdin-cap.test.mjs +0 -47
  224. package/clients/cli/commands/layout.text-fields.test.mjs +0 -39
@@ -547,26 +547,17 @@ describe('themeBuild() — component override validation', () => {
547
547
  ]);
548
548
  });
549
549
 
550
- it('warns with the exact replacement for deprecated root and media targets', () => {
550
+ it('deduplicates removed aliases as unknown across root and conditional layers', () => {
551
551
  const registry = {
552
- propsByKey: {
553
- 'old-target': ['variant'],
554
- 'new-target': ['variant'],
555
- },
556
- deprecatedByKey: {'old-target': 'new-target'},
552
+ propsByKey: {'new-target': ['variant']},
557
553
  };
558
554
 
559
555
  expect(
560
556
  validateComponentOverridesAgainstRegistry(
561
557
  {
562
- components: {
563
- 'old-target': {base: {color: 'red'}},
564
- 'new-target': {base: {color: 'blue'}},
565
- },
558
+ components: {'old-target': {base: {color: 'red'}}},
566
559
  onDark: {
567
- components: {
568
- 'old-target': {'variant:quiet': {color: 'pink'}},
569
- },
560
+ components: {'old-target': {'variant:quiet': {color: 'pink'}}},
570
561
  },
571
562
  adaptations: {
572
563
  rules: [
@@ -583,31 +574,27 @@ describe('themeBuild() — component override validation', () => {
583
574
  },
584
575
  registry,
585
576
  ),
586
- ).toEqual([
587
- 'Deprecated component target "old-target". Use "new-target" instead.',
588
- 'Deprecated component target "old-target" in onDark. Use "new-target" instead.',
589
- 'Deprecated component target "old-target" in adaptation rule 1. Use "new-target" instead.',
590
- ]);
577
+ ).toEqual(['Unknown component "old-target".']);
591
578
  });
592
579
 
593
- it('warns with the exact replacement for a supported deprecated target', async () => {
594
- const themeFile = path.join(tmpDir, 'deprecated-target.mjs');
580
+ it('reports a removed target alias as an unknown component key', async () => {
581
+ const themeFile = path.join(tmpDir, 'removed-target.mjs');
595
582
  fs.writeFileSync(
596
583
  themeFile,
597
584
  `export default {
598
- name: 'deprecated-target',
585
+ name: 'removed-target',
599
586
  tokens: {},
600
587
  components: {progressbar: {base: {color: 'red'}}},
601
588
  };\n`,
602
589
  );
603
590
 
604
- const result = await themeBuild('deprecated-target.mjs', {}, {cwd: tmpDir});
591
+ const result = await themeBuild('removed-target.mjs', {}, {cwd: tmpDir});
605
592
 
606
593
  expect(result?.data.warnings).toContain(
607
- 'Deprecated component target "progressbar". Use "progress-bar" instead.',
594
+ 'Unknown component "progressbar". Did you mean: progress-bar?',
608
595
  );
609
596
  expect(
610
- fs.readFileSync(path.join(tmpDir, 'deprecated-target.css'), 'utf8'),
597
+ fs.readFileSync(path.join(tmpDir, 'removed-target.css'), 'utf8'),
611
598
  ).toContain('.astryx-progressbar');
612
599
  });
613
600
  });
@@ -438,5 +438,5 @@ export function generateFamilyCSS(members) {
438
438
  parts.push(`@layer astryx-base {\n${base.join('\n\n')}\n}`);
439
439
  if (themed.length > 0)
440
440
  parts.push(`@layer astryx-theme {\n${themed.join('\n\n')}\n}`);
441
- return `${parts.join('\n\n')}\n`;
441
+ return `@layer reset, astryx-base, astryx-theme;\n\n${parts.join('\n\n')}\n`;
442
442
  }
@@ -0,0 +1,168 @@
1
+ // Copyright (c) Meta Platforms, Inc. and affiliates.
2
+
3
+ /**
4
+ * @file Cleanup-stage compatibility: `theme eject` keeps the released copying
5
+ * `theme add` receipt fields, file set, and copied bytes. Its one intentional
6
+ * file-list change moves the unmaintained local descriptor directly behind the
7
+ * entry.
8
+ */
9
+
10
+ import {afterEach, beforeEach, describe, expect, it} from 'vitest';
11
+ import * as fs from 'node:fs';
12
+ import * as os from 'node:os';
13
+ import * as path from 'node:path';
14
+ import {themeEject} from './eject.mjs';
15
+ import {runCli} from '../../../test-utils/run-cli.mjs';
16
+
17
+ const HEADER = '// Copyright (c) Meta Platforms, Inc. and affiliates.\n\n';
18
+ const RELEASED_COPY_FILES = [
19
+ 'oceanTheme.ts',
20
+ 'fonts/ocean.woff2',
21
+ 'icons.tsx',
22
+ 'oceanTheme.doc.mjs',
23
+ 'tokens/colors.ts',
24
+ ];
25
+ const EJECT_FILES = [
26
+ RELEASED_COPY_FILES[0],
27
+ 'oceanTheme.doc.mjs',
28
+ ...RELEASED_COPY_FILES.slice(1).filter(file => file !== 'oceanTheme.doc.mjs'),
29
+ ];
30
+ const FONT_BYTES = Buffer.concat([
31
+ Buffer.from('wOF2'),
32
+ Buffer.from(Array.from({length: 256}, (_, byte) => byte)),
33
+ ]);
34
+
35
+ let tmpDir;
36
+
37
+ beforeEach(() => {
38
+ tmpDir = fs.mkdtempSync(path.join(os.tmpdir(), 'astryx-themeeject-compat-'));
39
+ fs.writeFileSync(
40
+ path.join(tmpDir, 'package.json'),
41
+ JSON.stringify({
42
+ name: 'consumer',
43
+ dependencies: {'@acme/themes': '^1.0.0'},
44
+ }),
45
+ );
46
+ const packageDir = path.join(tmpDir, 'node_modules', '@acme', 'themes');
47
+ const themeDir = path.join(packageDir, 'themes', 'ocean');
48
+ fs.mkdirSync(path.join(themeDir, 'fonts'), {recursive: true});
49
+ fs.mkdirSync(path.join(themeDir, 'tokens'), {recursive: true});
50
+ fs.writeFileSync(
51
+ path.join(packageDir, 'package.json'),
52
+ JSON.stringify({name: '@acme/themes', version: '1.0.0'}),
53
+ );
54
+ fs.writeFileSync(
55
+ path.join(packageDir, 'astryx.integration.mjs'),
56
+ "export default {themes: './themes'};\n",
57
+ );
58
+ fs.writeFileSync(
59
+ path.join(themeDir, 'oceanTheme.doc.mjs'),
60
+ `/** @type {import('@astryxdesign/cli/authoring').ThemeDoc} */
61
+ export default {type: 'theme', name: 'ocean', displayName: 'Ocean', description: 'Integration theme that ships a font.', maintained: true};
62
+ `,
63
+ );
64
+ fs.writeFileSync(
65
+ path.join(themeDir, 'oceanTheme.ts'),
66
+ `${HEADER}export const oceanTheme = {};\n`,
67
+ );
68
+ fs.writeFileSync(
69
+ path.join(themeDir, 'icons.tsx'),
70
+ 'export const oceanIcons = {};\n',
71
+ );
72
+ fs.writeFileSync(path.join(themeDir, 'fonts', 'ocean.woff2'), FONT_BYTES);
73
+ fs.writeFileSync(
74
+ path.join(themeDir, 'tokens', 'colors.ts'),
75
+ "export const oceanBlue = '#0064e0';\n",
76
+ );
77
+ });
78
+
79
+ afterEach(() => {
80
+ fs.rmSync(tmpDir, {recursive: true, force: true});
81
+ });
82
+
83
+ describe('themeEject released-copy compatibility', () => {
84
+ it('keeps the old copy receipt fields and moves the descriptor to second', async () => {
85
+ const result = await themeEject('ocean', {
86
+ cwd: tmpDir,
87
+ package: '@acme/themes',
88
+ });
89
+
90
+ expect(result).toEqual({
91
+ type: 'theme.eject',
92
+ data: {
93
+ slug: 'ocean',
94
+ displayName: 'Ocean',
95
+ maintained: true,
96
+ package: '@acme/themes',
97
+ outputDir: 'src/themes/ocean',
98
+ entry: 'oceanTheme.ts',
99
+ exportName: 'oceanTheme',
100
+ files: EJECT_FILES,
101
+ },
102
+ });
103
+ expect(new Set(result.data.files)).toEqual(new Set(RELEASED_COPY_FILES));
104
+ expect(result.data.files).toEqual(EJECT_FILES);
105
+ expect(Object.keys(result.data)).toEqual([
106
+ 'slug',
107
+ 'displayName',
108
+ 'maintained',
109
+ 'package',
110
+ 'outputDir',
111
+ 'entry',
112
+ 'exportName',
113
+ 'files',
114
+ ]);
115
+ });
116
+
117
+ it('keeps copied source and binary bytes, with only the local descriptor change', async () => {
118
+ await themeEject('ocean', {cwd: tmpDir, package: '@acme/themes'});
119
+ const output = path.join(tmpDir, 'src', 'themes', 'ocean');
120
+
121
+ expect(fs.readFileSync(path.join(output, 'oceanTheme.ts'), 'utf-8')).toBe(
122
+ 'export const oceanTheme = {};\n',
123
+ );
124
+ expect(
125
+ fs
126
+ .readFileSync(path.join(output, 'fonts/ocean.woff2'))
127
+ .equals(FONT_BYTES),
128
+ ).toBe(true);
129
+ expect(fs.readFileSync(path.join(output, 'icons.tsx'), 'utf-8')).toBe(
130
+ 'export const oceanIcons = {};\n',
131
+ );
132
+ expect(
133
+ fs.readFileSync(path.join(output, 'tokens/colors.ts'), 'utf-8'),
134
+ ).toBe("export const oceanBlue = '#0064e0';\n");
135
+ expect(
136
+ fs.readFileSync(path.join(output, 'oceanTheme.doc.mjs'), 'utf-8'),
137
+ ).toContain('maintained: false');
138
+ });
139
+
140
+ it('keeps the same fields and file order in CLI JSON and text', async () => {
141
+ const json = await runCli(
142
+ [
143
+ 'theme',
144
+ 'eject',
145
+ 'ocean',
146
+ 'json-fork',
147
+ '--package',
148
+ '@acme/themes',
149
+ '--json',
150
+ ],
151
+ tmpDir,
152
+ );
153
+ expect(json.status, json.stderr).toBe(0);
154
+ expect(JSON.parse(json.stdout)).toMatchObject({
155
+ type: 'theme.eject',
156
+ data: {outputDir: 'json-fork', files: EJECT_FILES},
157
+ });
158
+
159
+ const text = await runCli(
160
+ ['theme', 'eject', 'ocean', 'text-fork', '--package', '@acme/themes'],
161
+ tmpDir,
162
+ );
163
+ expect(text.status, text.stderr).toBe(0);
164
+ const positions = EJECT_FILES.map(file => text.stdout.indexOf(file));
165
+ expect(positions.every(position => position >= 0)).toBe(true);
166
+ expect(positions).toEqual([...positions].sort((a, b) => a - b));
167
+ });
168
+ });
@@ -93,7 +93,7 @@ describe('package and integration themes', () => {
93
93
  ).toContain('oceanTheme');
94
94
  });
95
95
 
96
- it('copies the complete nested integration theme directory', async () => {
96
+ it('ejects the complete nested integration theme directory', async () => {
97
97
  installThemeIntegration(
98
98
  '@acme/themes',
99
99
  'ocean',
@@ -104,7 +104,7 @@ describe('package and integration themes', () => {
104
104
  },
105
105
  );
106
106
 
107
- const result = await themeAdd('ocean', {cwd: tmpDir});
107
+ const result = await themeEject('ocean', {cwd: tmpDir});
108
108
 
109
109
  expect(result.data.files).toEqual([
110
110
  'oceanTheme.ts',
@@ -123,7 +123,7 @@ describe('package and integration themes', () => {
123
123
  path.join(tmpDir, 'src', 'themes', 'ocean', 'oceanTheme.doc.mjs'),
124
124
  'utf-8',
125
125
  ),
126
- ).toContain('maintained: true');
126
+ ).toContain('maintained: false');
127
127
  expect(
128
128
  fs.readFileSync(
129
129
  path.join(tmpDir, 'src', 'themes', 'ocean', 'tokens', 'colors.ts'),
@@ -88,7 +88,7 @@ describe('themeRemove', () => {
88
88
  it('names theme add when the slug is not added', async () => {
89
89
  await expect(themeRemove('missing', {cwd: tmpDir})).rejects.toMatchObject({
90
90
  code: 'ERR_UNKNOWN_THEME',
91
- message: expect.stringContaining('astryx theme add missing --import'),
91
+ message: expect.stringContaining('astryx theme add missing'),
92
92
  });
93
93
  });
94
94
  });
@@ -19,7 +19,6 @@ describe('themeTargets (api/theme/targets)', () => {
19
19
  const allowedKeys = new Set([
20
20
  'className',
21
21
  'component',
22
- 'deprecatedFor',
23
22
  'key',
24
23
  'props',
25
24
  'states',
@@ -35,9 +34,6 @@ describe('themeTargets (api/theme/targets)', () => {
35
34
  expect(Object.keys(target).filter(key => !allowedKeys.has(key))).toEqual(
36
35
  [],
37
36
  );
38
- if (target.deprecatedFor !== undefined) {
39
- expect(target.deprecatedFor).toEqual(expect.any(String));
40
- }
41
37
  }
42
38
  }, 60_000);
43
39
 
@@ -4,7 +4,7 @@
4
4
  * @file `astryx theme template` leaf — writes the annotated theme template into the
5
5
  * consumer's project.
6
6
  *
7
- * `theme add --import` uses an installed built theme without copying source. This command
7
+ * `theme add` uses an installed built theme without copying source. This command
8
8
  * writes the blank annotated reference for a new theme. `theme eject` is the
9
9
  * separate path for starting from a complete source fork of an existing theme.
10
10
  *
@@ -106,31 +106,6 @@ export type ThemeListResponse = {
106
106
  unmigratedCopies: ThemeUnmigratedCopy[];
107
107
  } | undefined;
108
108
  };
109
- /**
110
- * astryx --json theme add <slug> [path]
111
- */
112
- export type ThemeAddResponse = {
113
- type: "theme.add";
114
- data: {
115
- slug: string;
116
- displayName: string;
117
- maintained: boolean;
118
- package: string;
119
- outputDir: string;
120
- entry: string;
121
- exportName: string;
122
- files: string[];
123
- };
124
- /**
125
- * additive lifecycle guidance; every released data field is unchanged
126
- */
127
- meta: {
128
- deprecations: Array<{
129
- id: "DEP-0005";
130
- replacements: string[];
131
- }>;
132
- };
133
- };
134
109
  /**
135
110
  * One built theme imported by the generated app module.
136
111
  */
@@ -155,7 +130,7 @@ export type ThemeAppEntry = {
155
130
  source: "bundled" | "package" | "local";
156
131
  };
157
132
  /**
158
- * astryx --json theme add <slug> --import / remove / use
133
+ * astryx --json theme add <slug> [--import] / remove / use
159
134
  */
160
135
  export type ThemeAppResponse = {
161
136
  type: "theme.app";
@@ -221,10 +196,6 @@ export type ThemeTargetEntry = {
221
196
  component: string;
222
197
  props: string[];
223
198
  states: string[];
224
- /**
225
- * - exact canonical replacement for a deprecated target
226
- */
227
- deprecatedFor?: string | undefined;
228
199
  };
229
200
  /**
230
201
  * astryx --json theme targets [filter]
@@ -13,9 +13,8 @@
13
13
  * astryx --json theme build <a> <b> … -> theme.build.batch
14
14
  * astryx --json theme list -> theme.list
15
15
  * astryx --json theme add --list -> theme.list
16
- * astryx --json theme add <slug> -> theme.add
17
- * astryx --json theme add <slug> --import -> theme.app
18
- * astryx --json theme remove/use <slug> -> theme.app
16
+ * astryx --json theme add <slug> [--import] -> theme.app
17
+ * astryx --json theme remove/use <slug> -> theme.app
19
18
  * astryx --json theme eject <slug> -> theme.eject
20
19
  * astryx --json theme template -> theme.template
21
20
  * astryx --json theme targets [filter] -> theme.targets
@@ -83,14 +82,6 @@
83
82
  * @property {{unmigratedCopies: ThemeUnmigratedCopy[]}} [meta] descriptor-less released copies that are not listed as themes
84
83
  */
85
84
 
86
- /**
87
- * astryx --json theme add <slug> [path]
88
- * @typedef {object} ThemeAddResponse
89
- * @property {'theme.add'} type
90
- * @property {{slug: string, displayName: string, maintained: boolean, package: string, outputDir: string, entry: string, exportName: string, files: string[]}} data
91
- * @property {{deprecations: Array<{id: 'DEP-0005', replacements: string[]}>}} meta additive lifecycle guidance; every released data field is unchanged
92
- */
93
-
94
85
  /**
95
86
  * One built theme imported by the generated app module.
96
87
  * @typedef {object} ThemeAppEntry
@@ -103,7 +94,7 @@
103
94
  */
104
95
 
105
96
  /**
106
- * astryx --json theme add <slug> --import / remove / use
97
+ * astryx --json theme add <slug> [--import] / remove / use
107
98
  * @typedef {object} ThemeAppResponse
108
99
  * @property {'theme.app'} type
109
100
  * @property {string} [package] npm package that owns the theme `theme add`
@@ -140,7 +131,6 @@
140
131
  * @property {string} component
141
132
  * @property {string[]} props
142
133
  * @property {string[]} states
143
- * @property {string} [deprecatedFor] - exact canonical replacement for a deprecated target
144
134
  */
145
135
 
146
136
  /**
@@ -9,13 +9,13 @@ export const doc = {
9
9
  name: 'themeAdd',
10
10
  namespace: 'cli/api',
11
11
  displayName: 'themeAdd()',
12
- summary: 'Copy theme source, or import its built output into the app.',
12
+ summary: 'Add a built theme to the app.',
13
13
  description:
14
- 'Copies a bundled or package theme into the project by default, preserving the released theme.add response while that path is deprecated. With options.import, records a package or built local theme and regenerates the app theme module with its built module and stylesheets. Import refuses targetPath and overwrite before writing.',
14
+ 'Records a package or built local theme and regenerates the app theme module with its built module and stylesheets. options.import is an accepted compatibility no-op, as is options.overwrite set to false. Passing targetPath or options.overwrite set to true fails before writing and names themeEject, which owns source copying.',
15
15
  importPath: '@astryxdesign/cli/api',
16
16
  signature:
17
- 'themeAdd(slug: string, options?: {targetPath?: string, overwrite?: boolean, import?: boolean, cwd?: string, package?: string}): Promise<ThemeAddResponse | ThemeAppResponse>',
18
- keywords: ['theme', 'add', 'import', 'copy', 'app', 'default', 'local'],
17
+ 'themeAdd(slug: string, options?: {targetPath?: string, overwrite?: boolean, import?: boolean, cwd?: string, package?: string}): Promise<ThemeAppResponse>',
18
+ keywords: ['theme', 'add', 'import', 'app', 'default', 'local'],
19
19
  params: [
20
20
  {
21
21
  name: 'slug',
@@ -27,28 +27,26 @@ export const doc = {
27
27
  name: 'options.targetPath',
28
28
  type: 'string',
29
29
  description:
30
- 'Destination for the deprecated source-copy path. Cannot be combined with import.',
31
- default: "'src/themes/<slug>'",
30
+ 'Removed copy destination. Passing it throws ERR_THEME_INVALID. Call themeEject instead.',
32
31
  },
33
32
  {
34
33
  name: 'options.overwrite',
35
34
  type: 'boolean',
36
35
  description:
37
- 'Replace copied files instead of refusing. Cannot be combined with import.',
36
+ 'False is a compatibility no-op. True throws ERR_THEME_INVALID. Call themeEject instead.',
38
37
  default: 'false',
39
38
  },
40
39
  {
41
40
  name: 'options.import',
42
41
  type: 'boolean',
43
42
  description:
44
- 'Import the built theme through the generated app module instead of copying source.',
43
+ 'Compatibility no-op; the built theme is added with or without this option.',
45
44
  default: 'false',
46
45
  },
47
46
  {
48
47
  name: 'options.cwd',
49
48
  type: 'string',
50
- description:
51
- 'Project directory used for discovery, state, and target paths.',
49
+ description: 'Project directory used for discovery and app-theme state.',
52
50
  default: 'process.cwd()',
53
51
  },
54
52
  {
@@ -58,15 +56,10 @@ export const doc = {
58
56
  },
59
57
  ],
60
58
  returns: [
61
- {
62
- type: 'theme.add',
63
- description:
64
- 'The released copy receipt plus additive meta.deprecations with DEP-0005 and its replacement commands when import is false.',
65
- },
66
59
  {
67
60
  type: 'theme.app',
68
61
  description:
69
- 'The complete generated-module state and add change when import is true. Its envelope package names the npm package that owns the added theme, except for a local theme.',
62
+ 'The complete generated-module state and add change. Its envelope package names the npm package that owns the added theme, except for a local theme.',
70
63
  },
71
64
  ],
72
65
  throws: [
@@ -77,27 +70,26 @@ export const doc = {
77
70
  {code: 'ERR_AMBIGUOUS_THEME', when: 'more than one package owns the slug'},
78
71
  {
79
72
  code: 'ERR_THEME_INVALID',
80
- when: 'the selected theme is invalid, or import is combined with a copy option',
81
- },
82
- {code: 'ERR_PATH_TRAVERSAL', when: 'a copy target escapes cwd'},
83
- {
84
- code: 'ERR_NO_SOURCE',
85
- when: 'a copied source file is missing',
73
+ when: 'the selected theme is invalid, targetPath is passed, or overwrite is true',
86
74
  },
87
75
  {
88
76
  code: 'ERR_FILE_EXISTS',
89
- when: 'a destination or generated module path conflicts',
77
+ when: 'the generated module path conflicts with an authored file',
90
78
  },
91
- {code: 'ERR_WRITE_FAILED', when: 'copying or module generation fails'},
79
+ {code: 'ERR_WRITE_FAILED', when: 'module generation fails'},
92
80
  ],
93
81
  examples: [
94
82
  {
95
- label: 'Import a built theme',
96
- code: "await themeAdd('butter', {import: true});",
83
+ label: 'Add a built theme',
84
+ code: "await themeAdd('butter');",
97
85
  },
98
86
  {
99
87
  label: 'Select a package theme over a local theme',
100
- code: "await themeAdd('ocean', {import: true, package: '@acme/themes'});",
88
+ code: "await themeAdd('ocean', {package: '@acme/themes'});",
89
+ },
90
+ {
91
+ label: 'Keep the earlier opt-in spelling',
92
+ code: "await themeAdd('butter', {import: true});",
101
93
  },
102
94
  ],
103
95
  command: 'theme add',
@@ -17,9 +17,8 @@ export const doc = {
17
17
  summary: 'List every component theming target a theme can override.',
18
18
  description:
19
19
  'Enumerates the whole themeable surface: each `defineTheme` components key, the stable ' +
20
- 'class it paints, the component that declares it, the props and states that are legal ' +
21
- 'override keys under it, and the canonical replacement when a listed target is deprecated. ' +
22
- 'Same source as the Theming table `astryx component <Name>` prints ' +
20
+ 'class it paints, the component that declares it, and the props and states that are legal ' +
21
+ 'override keys under it. Same source as the Theming table `astryx component <Name>` prints ' +
23
22
  '(the component docs), so the list cannot drift from the components, and `theme build` ' +
24
23
  'validates overrides against this exact set. A filter naming a component gives that ' +
25
24
  "component's set; anything else is a case-insensitive substring search over each target's key, class and component.",
@@ -55,7 +54,7 @@ export const doc = {
55
54
  {
56
55
  type: 'theme.targets',
57
56
  description:
58
- 'The echoed filter, how many components are represented, and the targets: each {key, className, component, props, states, deprecatedFor?}.',
57
+ 'The echoed filter, how many components are represented, and the targets: each {key, className, component, props, states}.',
59
58
  },
60
59
  ],
61
60
  throws: [
@@ -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, with the CLI command that prints the authoritative reference for each section. ' +
22
- 'Read it, copy what you need into your own theme file, delete it. Use `theme add --import` to ' +
22
+ 'Read it, copy what you need into your own theme file, delete it. Use `theme add` to ' +
23
23
  'use an installed built theme, extend that theme for ordinary customization, or use ' +
24
24
  '`theme eject` for a complete source fork. This command starts a new blank theme. Refuses to overwrite without ' +
25
25
  '`overwrite`, so it is safe to re-run.',
@@ -92,7 +92,7 @@ describe('themeUse', () => {
92
92
  it('names theme add when the slug is not added', async () => {
93
93
  await expect(themeUse('missing', {cwd: tmpDir})).rejects.toMatchObject({
94
94
  code: 'ERR_UNKNOWN_THEME',
95
- message: expect.stringContaining('astryx theme add missing --import'),
95
+ message: expect.stringContaining('astryx theme add missing'),
96
96
  });
97
97
  });
98
98
  });
@@ -129,7 +129,7 @@ export const doc = {
129
129
  throws: [
130
130
  {
131
131
  code: 'ERR_INVALID_ARGUMENT',
132
- when: '`from` is missing (and neither `list` nor `registry` is set); `list` and `registry` are both set; `registry` is combined with `from`, `force`, `codemod`, `skipCodemod`, `integration` or `installDeps`; an `integration` specifier is invalid or not installed; or astryx.config fails to load or validate and no pending config codemod repairs it',
132
+ when: '`from` is missing (and neither `list` nor `registry` is set); `list` and `registry` are both set; `list` is combined with `from`, `force`, `apply`, `path` (non-default), `codemod`, `skipCodemod`, `integration` or `installDeps`; `registry` is combined with `from`, `force`, `codemod`, `skipCodemod`, `integration` or `installDeps`; an `integration` specifier is invalid or not installed; or astryx.config fails to load or validate and no pending config codemod repairs it',
133
133
  },
134
134
  {code: 'ERR_INVALID_VERSION', when: '`from` is not a valid semver string'},
135
135
  {code: 'ERR_PATH_TRAVERSAL', when: '`path` resolves outside cwd'},
@@ -53,6 +53,25 @@ export async function upgrade(options = {}, {cwd = process.cwd()} = {}) {
53
53
  throw new AstryxError(msg, undefined, ERROR_CODES.ERR_INVALID_ARGUMENT);
54
54
  }
55
55
 
56
+ if (options.list) {
57
+ const ignored = [
58
+ options.from ? '--from' : null,
59
+ options.force ? '--force' : null,
60
+ options.apply ? '--apply' : null,
61
+ options.path && options.path !== './src' ? '--path' : null,
62
+ options.codemod ? '--codemod' : null,
63
+ options.skipCodemod?.length ? '--skip-codemod' : null,
64
+ options.integration?.length ? '--integration' : null,
65
+ options.installDeps ? '--install-deps' : null,
66
+ ].filter(Boolean);
67
+ if (ignored.length > 0) {
68
+ const msg = `\`--list\` cannot be combined with ${ignored.join(', ')}: it lists available codemods and does not run a migration.`;
69
+ logger.error(msg);
70
+ logger.log('Aborted\n');
71
+ throw new AstryxError(msg, undefined, ERROR_CODES.ERR_INVALID_ARGUMENT);
72
+ }
73
+ }
74
+
56
75
  if (options.registry) {
57
76
  const incompatible = [
58
77
  options.from ? '--from' : null,