@astryxdesign/cli 0.7.0-canary.693da50 → 0.7.0-canary.6ecd417

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 (241) 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__/preserve-bottom-sheet-content-padding.test.mjs +178 -0
  65. package/assets/codemods/transforms/next/__tests__/validate-data-token-ownership.test.mjs +84 -0
  66. package/assets/codemods/transforms/next/index.mjs +35 -1
  67. package/assets/codemods/transforms/next/migrate-deprecated-theme-surface-v0.6-data.mjs +229 -0
  68. package/assets/codemods/transforms/next/migrate-deprecated-theme-surface.mjs +624 -0
  69. package/assets/codemods/transforms/next/migrate-field-input-styling.mjs +198 -0
  70. package/assets/codemods/transforms/next/preserve-bottom-sheet-content-padding.mjs +242 -0
  71. package/assets/codemods/transforms/next/validate-data-token-ownership.mjs +102 -0
  72. package/assets/codemods/transforms/v0.6.0/migrate-astryx-theme-selectors-to-data-attrs.mjs +38 -18
  73. package/assets/docs/author-a-theme.doc.mjs +5 -5
  74. package/assets/docs/getting-started.doc.mjs +2 -2
  75. package/assets/docs/spacing.doc.mjs +2 -2
  76. package/assets/docs/theme.doc.dense.mjs +1 -1
  77. package/assets/docs/theme.doc.mjs +2 -2
  78. package/assets/docs/tree/add-a-theme.doc.mjs +1 -1
  79. package/assets/docs/tree/document-the-theme.doc.mjs +2 -2
  80. package/assets/docs/tree/fonts-and-assets.doc.mjs +3 -3
  81. package/assets/docs/tree/styling-advanced.doc.mjs +21 -14
  82. package/assets/docs/tree/themes.doc.mjs +1 -1
  83. package/assets/docs/tree/tokens-data.doc.mjs +2 -2
  84. package/assets/docs/tree/tokens-spacing.doc.mjs +15 -15
  85. package/assets/docs/tree/tokens-usage.doc.mjs +1 -1
  86. package/assets/docs/tree/use-a-theme-in-an-app.doc.mjs +2 -2
  87. package/assets/docs/tree/versioning.doc.mjs +1 -4
  88. package/assets/docs/use-a-theme.doc.mjs +16 -16
  89. package/assets/templates/blocks/components/BottomSheet/BottomSheetHeights.tsx +1 -1
  90. package/assets/templates/blocks/components/BottomSheet/BottomSheetMobileKeyboard.tsx +1 -1
  91. package/assets/templates/blocks/components/BottomSheet/BottomSheetNoScrim.tsx +1 -1
  92. package/assets/templates/blocks/components/BottomSheet/BottomSheetSnapPoints.tsx +1 -1
  93. package/assets/templates/blocks/components/ComplexSelector/ComplexSelectorDeadlinePicker.tsx +1 -1
  94. package/assets/templates/blocks/components/ComplexSelector/ComplexSelectorShowcase.tsx +1 -1
  95. package/assets/templates/blocks/components/ComplexSelector/ComplexSelectorTreeSearch.tsx +1 -1
  96. package/assets/templates/blocks/components/Dialog/DialogAdaptivePresentation.tsx +1 -1
  97. package/assets/templates/blocks/components/InternationalizationProvider/InternationalizationProvider01ShippedLocale.tsx +1 -1
  98. package/assets/templates/blocks/components/InternationalizationProvider/InternationalizationProvider02Overrides.tsx +1 -1
  99. package/assets/templates/blocks/components/Selector/SelectorClearable.tsx +1 -1
  100. package/assets/templates/blocks/components/Selector/SelectorOptionDescriptions.tsx +2 -2
  101. package/assets/templates/blocks/components/Selector/SelectorShowcase.tsx +1 -1
  102. package/assets/templates/blocks/components/Selector/SelectorWithSections.tsx +1 -1
  103. package/assets/templates/blocks/components/SelectorOption/SelectorOptionBasic.tsx +1 -1
  104. package/assets/templates/blocks/components/SelectorOption/SelectorOptionShowcase.tsx +1 -1
  105. package/assets/templates/blocks/components/Slider/SliderFormattedValue.tsx +1 -1
  106. package/assets/templates/blocks/components/Slider/SliderRangeSlider.tsx +1 -1
  107. package/assets/templates/blocks/components/Slider/SliderShowcase.tsx +1 -1
  108. package/assets/templates/blocks/components/Slider/SliderWithMarks.tsx +1 -1
  109. package/assets/templates/blocks/components/Tokenizer/TokenizerClear.tsx +1 -1
  110. package/assets/templates/blocks/components/Tokenizer/TokenizerCreatable.tsx +2 -2
  111. package/assets/templates/blocks/components/Tokenizer/TokenizerEndContent.tsx +1 -1
  112. package/assets/templates/blocks/components/Tokenizer/TokenizerIcon.tsx +1 -1
  113. package/assets/templates/blocks/components/Tokenizer/TokenizerMaxEntries.tsx +1 -1
  114. package/assets/templates/blocks/components/Tokenizer/TokenizerOverflow.tsx +2 -2
  115. package/assets/templates/blocks/components/Tokenizer/TokenizerShowcase.tsx +1 -1
  116. package/assets/templates/blocks/components/Tokenizer/TokenizerStates.tsx +4 -4
  117. package/assets/templates/blocks/components/Toolbar/ToolbarTableFilter.tsx +1 -1
  118. package/assets/templates/pages/canvas-editor/page.tsx +2 -2
  119. package/assets/templates/pages/form-wizard-vertical/page.tsx +1 -1
  120. package/assets/templates/pages/payment-form/page.tsx +1 -1
  121. package/assets/templates/pages/table-filter/page.tsx +11 -6
  122. package/assets/templates/pages/table-inbox/page.tsx +3 -1
  123. package/assets/templates/pages/theme-showcase/page.tsx +2 -2
  124. package/assets/templates/themes/butter/butterTheme.ts +12 -0
  125. package/assets/templates/themes/chocolate/chocolateTheme.ts +12 -0
  126. package/assets/templates/themes/matcha/matchaTheme.ts +14 -14
  127. package/assets/templates/themes/neutral/neutralPaletteRefs.generated.ts +10 -9
  128. package/assets/templates/themes/neutral/neutralTheme.ts +12 -0
  129. package/assets/templates/themes/stone/stoneTheme.ts +12 -0
  130. package/assets/templates/themes/y2k/y2kTheme.ts +10 -10
  131. package/assets/theme.template.ts +1 -1
  132. package/authoring/debug/type.ts +2 -2
  133. package/authoring/doctypes/base/type.ts +0 -9
  134. package/authoring/integration/integration.doc.mjs +1 -1
  135. package/clients/cli/command-result-coverage.test.mjs +1 -1
  136. package/clients/cli/commands/build-theme.adaptations.test.mjs +4 -0
  137. package/clients/cli/commands/build-theme.ascii-output.test.mjs +35 -8
  138. package/clients/cli/commands/build-theme.color-scheme.test.mjs +10 -6
  139. package/clients/cli/commands/build-theme.data-tokens.test.mjs +23 -75
  140. package/clients/cli/commands/build-theme.mjs +31 -67
  141. package/clients/cli/commands/build-theme.registry.test.mjs +0 -10
  142. package/clients/cli/commands/build.doc.mjs +1 -1
  143. package/clients/cli/commands/build.mjs +1 -1
  144. package/clients/cli/commands/component-ownership.test.mjs +2 -2
  145. package/clients/cli/commands/debug-result-summary.test.mjs +0 -16
  146. package/clients/cli/commands/discover.mjs +2 -1
  147. package/clients/cli/commands/doctor.mjs +5 -2
  148. package/clients/cli/commands/empty-argument.test.mjs +16 -0
  149. package/clients/cli/commands/gap-report.doc.mjs +1 -1
  150. package/clients/cli/commands/gap-report.test.mjs +2 -2
  151. package/clients/cli/commands/init.doc.mjs +4 -4
  152. package/clients/cli/commands/init.flag-help.test.mjs +7 -10
  153. package/clients/cli/commands/init.next-steps.test.mjs +1 -1
  154. package/clients/cli/commands/integration.mjs +2 -1
  155. package/clients/cli/commands/option-pair-refusals.test.mjs +37 -0
  156. package/clients/cli/commands/search.test.mjs +1 -1
  157. package/clients/cli/commands/silent-success-refusals.test.mjs +15 -0
  158. package/clients/cli/commands/swizzle.mjs +4 -1
  159. package/clients/cli/commands/template.doc.mjs +4 -4
  160. package/clients/cli/commands/template.flag-help.test.mjs +18 -11
  161. package/clients/cli/commands/template.mjs +7 -1
  162. package/clients/cli/commands/text-json-parity.test.mjs +0 -17
  163. package/clients/cli/commands/theme-add-lifecycle.test.mjs +142 -49
  164. package/clients/cli/commands/theme-add.doc.mjs +10 -17
  165. package/clients/cli/commands/theme-list.behavior.test.mjs +2 -1
  166. package/clients/cli/commands/theme-targets.behavior.test.mjs +8 -6
  167. package/clients/cli/commands/theme-template.doc.mjs +1 -1
  168. package/clients/cli/commands/theme.doc.mjs +2 -2
  169. package/clients/cli/commands/upgrade.doc.mjs +1 -1
  170. package/clients/cli/commands/upgrade.flag-help.test.mjs +7 -11
  171. package/clients/cli/commands/validate-nothing-exits-nonzero.test.mjs +67 -0
  172. package/clients/cli/index.mjs +0 -4
  173. package/clients/cli/lib/cli-error.mjs +19 -0
  174. package/clients/cli/lib/component-format.mjs +111 -57
  175. package/clients/cli/lib/component-format.test.mjs +28 -39
  176. package/clients/cli/lib/doc-text-ascii.test.mjs +5 -2
  177. package/clients/cli/lib/exit-codes.test.mjs +0 -7
  178. package/clients/cli/lib/json-shim.test.mjs +0 -24
  179. package/foundation/agent-docs/agent-docs.d.mts +2 -1
  180. package/foundation/agent-docs/agent-docs.mjs +6 -1
  181. package/foundation/agent-docs/app-theme-workflow.test.mjs +3 -0
  182. package/foundation/config/theme-state.mjs +3 -3
  183. package/foundation/debug/debug-fields.test.mjs +13 -35
  184. package/foundation/debug/event.mjs +13 -78
  185. package/foundation/debug/privacy-contract.test.mjs +20 -12
  186. package/foundation/debug/redact.d.mts +2 -2
  187. package/foundation/debug/redact.mjs +2 -2
  188. package/foundation/discovery/template-needs.mjs +93 -11
  189. package/foundation/discovery/template-needs.test.mjs +106 -3
  190. package/foundation/discovery/theme-imports.mjs +1 -1
  191. package/foundation/discovery/theming-targets.d.mts +1 -20
  192. package/foundation/discovery/theming-targets.mjs +1 -38
  193. package/foundation/discovery/theming-targets.test.mjs +9 -175
  194. package/foundation/doc-compiler/doc-loads.test.mjs +0 -12
  195. package/foundation/env/package-manager.d.mts +13 -0
  196. package/foundation/env/package-manager.mjs +106 -63
  197. package/foundation/response/error-codes.doc.mjs +1 -1
  198. package/foundation/response/response-types.doc.mjs +11 -31
  199. package/foundation/response/response-types.doc.test.mjs +36 -14
  200. package/foundation/response/response.doc.mjs +1 -1
  201. package/foundation/xle/browser.d.mts +2 -2
  202. package/foundation/xle/browser.mjs +2 -2
  203. package/foundation/xle/expand.mjs +1 -1
  204. package/foundation/xle/print.mjs +1 -1
  205. package/package.json +9 -9
  206. package/api/layout/_adapter.d.mts +0 -34
  207. package/api/layout/_adapter.mjs +0 -148
  208. package/api/layout/check/check.d.mts +0 -17
  209. package/api/layout/check/check.mjs +0 -41
  210. package/api/layout/expand/expand.d.mts +0 -23
  211. package/api/layout/expand/expand.mjs +0 -161
  212. package/api/layout/expand/expand.path-safety.test.mjs +0 -53
  213. package/api/layout/expand/expand.receipt.test.mjs +0 -74
  214. package/api/layout/grammar/grammar.d.mts +0 -14
  215. package/api/layout/grammar/grammar.mjs +0 -88
  216. package/api/layout/layout.d.mts +0 -6
  217. package/api/layout/layout.mjs +0 -17
  218. package/api/layout/layout.test.mjs +0 -297
  219. package/api/layout/layout.type.d.mts +0 -90
  220. package/api/layout/layout.type.mjs +0 -104
  221. package/api/layout/layoutCheck.doc.d.mts +0 -11
  222. package/api/layout/layoutCheck.doc.mjs +0 -85
  223. package/api/layout/layoutExpand.doc.d.mts +0 -11
  224. package/api/layout/layoutExpand.doc.mjs +0 -107
  225. package/api/layout/layoutGrammar.doc.d.mts +0 -11
  226. package/api/layout/layoutGrammar.doc.mjs +0 -57
  227. package/api/theme/add/add.binary.test.mjs +0 -157
  228. package/api/theme/add/add.rollback.test.mjs +0 -158
  229. package/api/theme/add/add.staging.test.mjs +0 -83
  230. package/clients/cli/commands/layout-check.doc.mjs +0 -67
  231. package/clients/cli/commands/layout-expand.doc.mjs +0 -87
  232. package/clients/cli/commands/layout-grammar.doc.mjs +0 -32
  233. package/clients/cli/commands/layout.deprecation-lifecycle.test.mjs +0 -140
  234. package/clients/cli/commands/layout.doc.mjs +0 -36
  235. package/clients/cli/commands/layout.error-codes.test.mjs +0 -66
  236. package/clients/cli/commands/layout.exit-parity.test.mjs +0 -41
  237. package/clients/cli/commands/layout.expand-receipt.test.mjs +0 -94
  238. package/clients/cli/commands/layout.mjs +0 -327
  239. package/clients/cli/commands/layout.path-help.test.mjs +0 -33
  240. package/clients/cli/commands/layout.stdin-cap.test.mjs +0 -47
  241. package/clients/cli/commands/layout.text-fields.test.mjs +0 -39
@@ -48,7 +48,8 @@ export const doc = {
48
48
  {
49
49
  name: 'options.list',
50
50
  type: 'boolean',
51
- description: 'Force the list response even when a name is given.',
51
+ description:
52
+ 'List templates instead of scaffolding; refused with ERR_INVALID_ARGUMENT when a name or path is also given.',
52
53
  default: 'false',
53
54
  },
54
55
  {
@@ -89,7 +90,7 @@ export const doc = {
89
90
  type: 'string',
90
91
  description:
91
92
  'Destination (relative to cwd) to scaffold the template into. Its presence switches a named lookup into a copy. ' +
92
- 'A path that ends in .tsx, .ts, .jsx, .js, .mjs, .cjs, .css, .scss, .json, .md or .html is the file to write; any other path is a directory, which receives page.tsx for a page template or the block\'s own file name for a block.',
93
+ "A path that ends in .tsx, .ts, .jsx, .js, .mjs, .cjs, .css, .scss, .json, .md or .html is the file to write; any other path is a directory, which receives page.tsx for a page template or the block's own file name for a block.",
93
94
  },
94
95
  {
95
96
  name: 'options.overwrite',
@@ -124,7 +125,7 @@ export const doc = {
124
125
  {
125
126
  type: 'template.copy',
126
127
  description:
127
- 'A receipt after scaffolding the template into the project: the template id, output directory, written file name, file count, `demoMediaReplaced` — how many Astryx demo media references were replaced with placeholders, `notes` — setup notes naming what the template needs that the project lacks (missing packages, missing StyleX compiler; empty when satisfied), `missingPackages` — external package names the template imports that are not in the project, and `installCommand` — a ready-to-run install command with the detected package manager and workspace version ranges (null when nothing is missing).',
128
+ 'A receipt after scaffolding the template into the project: the template id, output directory, written file name, file count, `demoMediaReplaced` — how many Astryx demo media references were replaced with placeholders, `notes` — setup notes naming what the template needs that the project lacks (missing packages, missing StyleX compiler; empty when satisfied), `missingPackages` — external package names the template imports that are not in the project, and `installCommand` — a ready-to-run install command with the detected package manager and workspace version ranges (null when nothing is missing, or when several lockfiles leave the package manager undetermined; `missingPackages` still names the packages).',
128
129
  },
129
130
  {
130
131
  type: 'template.cdn',
@@ -133,6 +134,10 @@ export const doc = {
133
134
  },
134
135
  ],
135
136
  throws: [
137
+ {
138
+ code: 'ERR_INVALID_ARGUMENT',
139
+ when: '--cdn is combined with <name>, --list, --skeleton, --type, or --package; --list is combined with <name>, <path>, --skeleton, or --overwrite; --skeleton is combined with <path> or --overwrite; or options.list is set with a type outside page or block, or with a package that provides no templates (a valid filter that matches nothing returns an empty list instead)',
140
+ },
136
141
  {
137
142
  code: 'ERR_UNKNOWN_TEMPLATE',
138
143
  when: 'the named template does not exist, or options.skeleton is set without a name',
@@ -86,6 +86,51 @@ export async function template(name, options = {}) {
86
86
  cwd = process.cwd(),
87
87
  } = options;
88
88
 
89
+ if (cdn) {
90
+ const ignored = [
91
+ name ? '<name>' : null,
92
+ list ? '--list' : null,
93
+ skeleton ? '--skeleton' : null,
94
+ type ? '--type' : null,
95
+ packageFilter ? '--package' : null,
96
+ ].filter(Boolean);
97
+ if (ignored.length > 0) {
98
+ throw new AstryxError(
99
+ `\`--cdn\` cannot be combined with ${ignored.join(', ')}: the CDN starter does not use templates.`,
100
+ undefined,
101
+ ERROR_CODES.ERR_INVALID_ARGUMENT,
102
+ );
103
+ }
104
+ }
105
+ if (list) {
106
+ const ignored = [
107
+ name ? '<name>' : null,
108
+ targetPath ? '<path>' : null,
109
+ skeleton ? '--skeleton' : null,
110
+ overwrite ? '--overwrite' : null,
111
+ ].filter(Boolean);
112
+ if (ignored.length > 0) {
113
+ throw new AstryxError(
114
+ `\`--list\` cannot be combined with ${ignored.join(', ')}: it lists templates and does not scaffold.`,
115
+ undefined,
116
+ ERROR_CODES.ERR_INVALID_ARGUMENT,
117
+ );
118
+ }
119
+ }
120
+ if (skeleton) {
121
+ const ignored = [
122
+ targetPath ? '<path>' : null,
123
+ overwrite ? '--overwrite' : null,
124
+ ].filter(Boolean);
125
+ if (ignored.length > 0) {
126
+ throw new AstryxError(
127
+ `\`--skeleton\` cannot be combined with ${ignored.join(', ')}: it prints the skeleton and does not write files.`,
128
+ undefined,
129
+ ERROR_CODES.ERR_INVALID_ARGUMENT,
130
+ );
131
+ }
132
+ }
133
+
89
134
  // The CDN starter ships as an asset rather than as a discovered template, so
90
135
  // it answers before discovery — nothing here needs a name resolved.
91
136
  if (cdn) {
@@ -82,7 +82,7 @@
82
82
  * @property {number} data.demoMediaReplaced Astryx demo media references (images, posters, videos) replaced in the written file: images with a neutral placeholder, videos with an empty source. Swap in your own media at those points; no media is installed. 0 when the template carried none.
83
83
  * @property {string[]} data.notes Setup notes: what the template needs that the project lacks (missing packages, missing StyleX compiler). Each note is one actionable line. Empty when the template needs nothing the project lacks.
84
84
  * @property {string[]} data.missingPackages External package names the template imports that are not in the project's dependencies. Empty when none are missing.
85
- * @property {string | null} data.installCommand A ready-to-run install command for the missing packages, using the project's package manager and the CLI workspace's version ranges. Null when no packages are missing.
85
+ * @property {string | null} data.installCommand A ready-to-run install command for the missing packages, using the project's package manager and the CLI workspace's version ranges. Null when no packages are missing, or when several lockfiles leave the package manager undetermined; missingPackages still names the packages.
86
86
  */
87
87
 
88
88
  /**
@@ -565,7 +565,7 @@ export function resolveRecordedThemes(state, available) {
565
565
  );
566
566
  if (!theme) {
567
567
  throw new AstryxError(
568
- `Added theme "${slug}" from ${owner} is unavailable. Reinstall the package or restore the local theme, then run \`astryx theme add ${slug} --import --package ${owner}\`.`,
568
+ `Added theme "${slug}" from ${owner} is unavailable. Reinstall the package or restore the local theme, then run \`astryx theme add ${slug} --package ${owner}\`.`,
569
569
  undefined,
570
570
  ERROR_CODES.ERR_UNKNOWN_THEME,
571
571
  );
@@ -732,7 +732,7 @@ export async function removeThemeFromApp(slug, options = {}) {
732
732
  const recordedSlug = recordedThemeSlug(state, slug);
733
733
  if (!state.configured || recordedSlug == null) {
734
734
  throw new AstryxError(
735
- `Theme "${slug}" is not added. Run \`astryx theme add ${slug} --import\` first.`,
735
+ `Theme "${slug}" is not added. Run \`astryx theme add ${slug}\` first.`,
736
736
  undefined,
737
737
  ERROR_CODES.ERR_UNKNOWN_THEME,
738
738
  );
@@ -776,7 +776,7 @@ export async function useThemeInApp(slug, options = {}) {
776
776
  const recordedSlug = recordedThemeSlug(state, slug);
777
777
  if (!state.configured || recordedSlug == null) {
778
778
  throw new AstryxError(
779
- `Theme "${slug}" is not added. Run \`astryx theme add ${slug} --import\` first.`,
779
+ `Theme "${slug}" is not added. Run \`astryx theme add ${slug}\` first.`,
780
780
  undefined,
781
781
  ERROR_CODES.ERR_UNKNOWN_THEME,
782
782
  );
@@ -2,15 +2,21 @@
2
2
  // DO NOT EDIT — run `pnpm sync:api-types` to regenerate.
3
3
 
4
4
  /**
5
- * Copy one available source theme, or import its built output with `import`.
5
+ * Add one available built theme to the generated app module. `import` remains
6
+ * accepted as a no-op so callers that opted in before the cleanup keep working.
7
+ *
8
+ * Removed source-copy options are rejected before discovery or any write, and
9
+ * name the function that now owns them. `overwrite: false` remains an accepted
10
+ * compatibility no-op.
11
+ *
6
12
  * @param {string} slug
7
- * @param {{targetPath?: string, overwrite?: boolean, cwd?: string, package?: string, import?: boolean}} [options]
8
- * @returns {Promise<import('../theme.type.mjs').ThemeAddResponse | import('../theme.type.mjs').ThemeAppResponse>}
13
+ * @param {{targetPath?: string, overwrite?: boolean, import?: boolean, cwd?: string, package?: string}} [options]
14
+ * @returns {Promise<import('../theme.type.mjs').ThemeAppResponse>}
9
15
  */
10
16
  export function themeAdd(slug: string, options?: {
11
17
  targetPath?: string;
12
18
  overwrite?: boolean;
19
+ import?: boolean;
13
20
  cwd?: string;
14
21
  package?: string;
15
- import?: boolean;
16
- }): Promise<import("../theme.type.mjs").ThemeAddResponse | import("../theme.type.mjs").ThemeAppResponse>;
22
+ }): Promise<import("../theme.type.mjs").ThemeAppResponse>;
@@ -1,210 +1,37 @@
1
1
  // Copyright (c) Meta Platforms, Inc. and affiliates.
2
2
 
3
3
  /**
4
- * @file `astryx theme add` — copy by default; import built output by opt-in.
4
+ * @file `astryx theme add` — add built theme output to the app.
5
5
  *
6
- * The released command copies source and returns `theme.add`. `--import` adds
7
- * the built theme to the generated app module and returns `theme.app`.
6
+ * Plain `theme add` and the compatibility `--import` spelling both record the
7
+ * built theme in the generated app module. Source copying belongs only to
8
+ * `theme eject`.
8
9
  */
9
10
 
10
- import * as fs from 'node:fs';
11
- import * as path from 'node:path';
12
- import {addThemeToApp, findTheme, listAvailableThemes} from '../_adapter.mjs';
13
- import {
14
- assertWithin,
15
- PathSafetyError,
16
- } from '../../../foundation/fs/path-safety.mjs';
11
+ import {addThemeToApp} from '../_adapter.mjs';
17
12
  import {AstryxError} from '../../error.mjs';
18
13
  import {ERROR_CODES} from '../../../foundation/response/error-codes.mjs';
19
- import {applyWrites} from '../../integration/add-helpers.mjs';
20
- import {stripCopyrightHeader} from '../../../foundation/text/copyright-header.mjs';
21
-
22
- const COPY_DEPRECATION = Object.freeze({
23
- id: 'DEP-0005',
24
- replacements: ['theme eject', 'theme add --import'],
25
- });
26
-
27
- /** @param {string} slug */
28
- function defaultTargetDir(slug) {
29
- return path.join('src', 'themes', slug);
30
- }
31
-
32
- /**
33
- * Strip repository boilerplate from UTF-8 text while preserving binary bytes.
34
- * @param {Buffer} bytes
35
- * @returns {Buffer|string}
36
- */
37
- function scaffoldContents(bytes) {
38
- const text = bytes.toString('utf-8');
39
- return Buffer.from(text, 'utf-8').equals(bytes)
40
- ? stripCopyrightHeader(text)
41
- : bytes;
42
- }
43
14
 
44
15
  /**
45
- * Bundled and package themes preserve their released copy inventories. Bundled
46
- * themes keep their authoring descriptor behind; integration themes copy the
47
- * complete directory, including the descriptor. Local themes are deliberately
48
- * excluded: copying `theme add` resolves only bundled and package themes, while
49
- * `--import` can select a built local theme.
16
+ * Add one available built theme to the generated app module. `import` remains
17
+ * accepted as a no-op so callers that opted in before the cleanup keep working.
18
+ *
19
+ * Removed source-copy options are rejected before discovery or any write, and
20
+ * name the function that now owns them. `overwrite: false` remains an accepted
21
+ * compatibility no-op.
50
22
  *
51
23
  * @param {string} slug
52
- * @param {{targetPath?: string, overwrite?: boolean, cwd?: string, package?: string}} options
53
- * @returns {Promise<import('../theme.type.mjs').ThemeAddResponse>}
54
- */
55
- async function copyThemeSource(slug, options) {
56
- const {
57
- targetPath,
58
- overwrite = false,
59
- cwd = process.cwd(),
60
- package: packageName,
61
- } = options;
62
-
63
- const match = await findTheme(slug, {
64
- cwd,
65
- package: packageName,
66
- includeLocal: false,
67
- });
68
- if (!match) {
69
- const available = await listAvailableThemes(cwd, {includeLocal: false});
70
- throw new AstryxError(
71
- `Unknown theme "${slug}"${packageName ? ` in package "${packageName}"` : ''}`,
72
- available.map(theme => ({
73
- name: `${theme.slug} --package ${theme.package}`,
74
- reason:
75
- theme.source === 'bundled'
76
- ? 'bundled theme'
77
- : `provided by ${theme.package}`,
78
- })),
79
- ERROR_CODES.ERR_UNKNOWN_THEME,
80
- );
81
- }
82
-
83
- const rawTarget = targetPath || defaultTargetDir(match.slug);
84
- let resolvedDir;
85
- try {
86
- resolvedDir = assertWithin(rawTarget, cwd, {label: 'theme target path'});
87
- } catch (error) {
88
- if (error instanceof PathSafetyError) {
89
- throw new AstryxError(
90
- error.message,
91
- undefined,
92
- ERROR_CODES.ERR_PATH_TRAVERSAL,
93
- );
94
- }
95
- throw error;
96
- }
97
-
98
- const descriptor = path
99
- .relative(match.sourceDir, match.docPath)
100
- .split(path.sep)
101
- .join('/');
102
- const copyFiles = match.bundled
103
- ? match.files.filter(name => name !== descriptor)
104
- : [match.entry, ...match.files.filter(name => name !== match.entry).sort()];
105
- let writes;
106
- try {
107
- writes = copyFiles.map(name => ({
108
- name,
109
- src: path.join(match.sourceDir, name),
110
- dest: assertWithin(name, resolvedDir, {
111
- label: `theme destination for ${name}`,
112
- }),
113
- }));
114
- } catch (error) {
115
- if (error instanceof PathSafetyError) {
116
- throw new AstryxError(
117
- error.message,
118
- undefined,
119
- ERROR_CODES.ERR_PATH_TRAVERSAL,
120
- );
121
- }
122
- throw error;
123
- }
124
-
125
- for (const write of writes) {
126
- if (!fs.existsSync(write.src)) {
127
- throw new AstryxError(
128
- `Theme "${match.slug}" is missing bundled file "${write.name}". ` +
129
- 'Re-run `node scripts/generate-cli-themes.mjs` to rebuild the bundle.',
130
- undefined,
131
- ERROR_CODES.ERR_NO_SOURCE,
132
- );
133
- }
134
- }
135
-
136
- if (!overwrite) {
137
- const existing = writes.find(write => fs.existsSync(write.dest));
138
- if (existing) {
139
- const rel = path.relative(cwd, existing.dest) || existing.dest;
140
- throw new AstryxError(
141
- `Refusing to overwrite existing file ${rel}. ` +
142
- 'Re-run with --overwrite (or -f) to replace it.',
143
- undefined,
144
- ERROR_CODES.ERR_FILE_EXISTS,
145
- );
146
- }
147
- }
148
-
149
- try {
150
- fs.mkdirSync(resolvedDir, {recursive: true});
151
- const plans = writes.map(write => {
152
- fs.mkdirSync(path.dirname(write.dest), {recursive: true});
153
- const dest = assertWithin(write.name, resolvedDir, {
154
- label: `theme destination for ${write.name}`,
155
- });
156
- return {
157
- path: dest,
158
- contents: scaffoldContents(fs.readFileSync(write.src)),
159
- createOnly: !overwrite,
160
- };
161
- });
162
- applyWrites(plans);
163
- } catch (error) {
164
- if (error instanceof AstryxError) throw error;
165
- if (error instanceof PathSafetyError) {
166
- throw new AstryxError(
167
- error.message,
168
- undefined,
169
- ERROR_CODES.ERR_PATH_TRAVERSAL,
170
- );
171
- }
172
- const message = error instanceof Error ? error.message : String(error);
173
- throw new AstryxError(
174
- `Failed to write theme files: ${message}`,
175
- undefined,
176
- ERROR_CODES.ERR_WRITE_FAILED,
177
- );
178
- }
179
-
180
- return {
181
- type: 'theme.add',
182
- data: {
183
- slug: match.slug,
184
- displayName: match.displayName,
185
- maintained: match.maintained,
186
- package: match.package,
187
- outputDir: path.relative(cwd, resolvedDir) || '.',
188
- entry: match.entry,
189
- exportName: match.exportName,
190
- files: copyFiles,
191
- },
192
- meta: {deprecations: [COPY_DEPRECATION]},
193
- };
194
- }
195
-
196
- /**
197
- * Copy one available source theme, or import its built output with `import`.
198
- * @param {string} slug
199
- * @param {{targetPath?: string, overwrite?: boolean, cwd?: string, package?: string, import?: boolean}} [options]
200
- * @returns {Promise<import('../theme.type.mjs').ThemeAddResponse | import('../theme.type.mjs').ThemeAppResponse>}
24
+ * @param {{targetPath?: string, overwrite?: boolean, import?: boolean, cwd?: string, package?: string}} [options]
25
+ * @returns {Promise<import('../theme.type.mjs').ThemeAppResponse>}
201
26
  */
202
27
  export async function themeAdd(slug, options = {}) {
203
- if (!options.import) return copyThemeSource(slug, options);
204
-
205
- if (options.targetPath != null || options.overwrite === true) {
28
+ const legacy = /** @type {{targetPath?: unknown, overwrite?: unknown}} */ (
29
+ options
30
+ );
31
+ if (legacy.targetPath != null || legacy.overwrite === true) {
206
32
  throw new AstryxError(
207
- '`theme add --import` cannot be combined with a target path or --overwrite.',
33
+ '`themeAdd` no longer copies source or accepts targetPath or overwrite: true. ' +
34
+ 'Call `themeEject` with the same slug and copy options to fork source.',
208
35
  undefined,
209
36
  ERROR_CODES.ERR_THEME_INVALID,
210
37
  );