@astryxdesign/cli 0.6.3-canary.dea6813 → 0.6.3-canary.df1837b

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 (284) hide show
  1. package/README.md +79 -58
  2. package/api/blog/blog.doc.mjs +1 -0
  3. package/api/build/build.doc.mjs +1 -0
  4. package/api/component/component.doc.mjs +2 -1
  5. package/api/component/component.mjs +3 -3
  6. package/api/component/component.type.d.mts +5 -4
  7. package/api/component/component.type.mjs +5 -4
  8. package/api/component/detail/blocks/blocks.d.mts +2 -1
  9. package/api/component/detail/blocks/blocks.mjs +4 -3
  10. package/api/component/list/list.d.mts +0 -5
  11. package/api/component/list/list.mjs +37 -9
  12. package/api/discover/discover.doc.mjs +1 -0
  13. package/api/docs/_adapter.d.mts +3 -8
  14. package/api/docs/_adapter.mjs +13 -105
  15. package/api/docs/docs.doc.mjs +1 -0
  16. package/api/docs/list/list.mjs +3 -7
  17. package/api/doctor/doctor.d.mts +25 -3
  18. package/api/doctor/doctor.doc.mjs +1 -0
  19. package/api/doctor/doctor.mjs +185 -13
  20. package/api/doctor/doctor.test.mjs +326 -1
  21. package/api/gap-report/gap-report.doc.mjs +1 -0
  22. package/api/hook/_adapter.mjs +19 -5
  23. package/api/hook/hook.doc.mjs +1 -0
  24. package/api/hook/list/list.d.mts +1 -1
  25. package/api/hook/list/list.mjs +69 -17
  26. package/api/init/init.doc.mjs +1 -0
  27. package/api/integration/add-contribution.mjs +7 -7
  28. package/api/integration/add-contribution.test.mjs +37 -3
  29. package/api/integration/add-theme.mjs +34 -64
  30. package/api/integration/add-theme.test.mjs +105 -21
  31. package/api/integration/authoring-checks.test.mjs +8 -4
  32. package/api/integration/integration-block-exports.test.mjs +10 -6
  33. package/api/integration/integrationAdd.doc.mjs +1 -0
  34. package/api/integration/integrationAddAgentDoc.doc.mjs +1 -0
  35. package/api/integration/integrationAddCodemod.doc.mjs +1 -0
  36. package/api/integration/integrationAddComponent.doc.mjs +1 -0
  37. package/api/integration/integrationAddDoc.doc.mjs +1 -0
  38. package/api/integration/integrationAddTemplate.doc.mjs +1 -0
  39. package/api/integration/integrationAddTheme.doc.mjs +6 -5
  40. package/api/integration/integrationComponentConflicts.doc.mjs +1 -0
  41. package/api/integration/integrationDocConflicts.doc.mjs +1 -0
  42. package/api/integration/integrationPackCheck.doc.mjs +1 -0
  43. package/api/integration/integrationTemplateConflicts.doc.mjs +1 -0
  44. package/api/integration/pack-check.test.mjs +17 -47
  45. package/api/integration/summarizeIssues.doc.mjs +1 -0
  46. package/api/integration/validate-integration-fixes.test.mjs +1389 -0
  47. package/api/integration/validate-integration.mjs +50 -102
  48. package/api/integration/validate-integration.test.mjs +85 -23
  49. package/api/integration/validate-unread-theme-folders.test.mjs +110 -0
  50. package/api/integration/validateIntegration.doc.mjs +1 -0
  51. package/api/json/assertResponse.doc.mjs +1 -0
  52. package/api/json/isError.doc.mjs +1 -0
  53. package/api/json/parseResponse.doc.mjs +1 -0
  54. package/api/layout/layoutCheck.doc.mjs +1 -0
  55. package/api/layout/layoutExpand.doc.mjs +1 -0
  56. package/api/layout/layoutGrammar.doc.mjs +1 -0
  57. package/api/search/search.doc.mjs +1 -0
  58. package/api/search/search.mjs +16 -6
  59. package/api/swizzle/swizzle.doc.mjs +1 -0
  60. package/api/template/template-suffix.test.mjs +41 -21
  61. package/api/template/template.doc.mjs +1 -0
  62. package/api/theme/_adapter.d.mts +2 -3
  63. package/api/theme/_adapter.mjs +4 -5
  64. package/api/theme/add/add.binary.test.mjs +10 -17
  65. package/api/theme/add/add.test.mjs +14 -1
  66. package/api/theme/generateTonalPalette.doc.mjs +1 -0
  67. package/api/theme/integration-themes.test.mjs +39 -28
  68. package/api/theme/list/list.test.mjs +19 -20
  69. package/api/theme/listThemes.doc.mjs +6 -5
  70. package/api/theme/themeAdd.doc.mjs +4 -3
  71. package/api/theme/themeBuild.doc.mjs +1 -0
  72. package/api/theme/themeList.doc.mjs +6 -3
  73. package/api/theme/themeListAvailable.doc.mjs +5 -3
  74. package/api/theme/themePaletteGenerate.doc.mjs +1 -0
  75. package/api/theme/themeTargets.doc.mjs +1 -0
  76. package/api/theme/themeTemplate.doc.mjs +1 -0
  77. package/api/upgrade/_adapter.d.mts +32 -5
  78. package/api/upgrade/_adapter.mjs +97 -69
  79. package/api/upgrade/provider-agreement.test.mjs +152 -0
  80. package/api/upgrade/run/run.mjs +356 -59
  81. package/api/upgrade/upgrade.doc.mjs +6 -1
  82. package/api/upgrade/upgrade.type.d.mts +34 -0
  83. package/api/upgrade/upgrade.type.mjs +15 -0
  84. package/assets/codemods/__tests__/runner.test.mjs +330 -8
  85. package/assets/codemods/integration-discovery.mjs +8 -2
  86. package/assets/codemods/integration-discovery.test.mjs +15 -0
  87. package/assets/codemods/integration-runner.mjs +56 -4
  88. package/assets/codemods/integration-runner.protection.test.mjs +153 -0
  89. package/assets/codemods/run-codemod.mjs +177 -34
  90. package/assets/codemods/runner.mjs +350 -102
  91. package/assets/codemods/transform-prop.mjs +109 -0
  92. package/assets/codemods/transform-prop.test.mjs +95 -0
  93. package/assets/codemods/transforms/next/__tests__/migrate-native-picker-to-presentation.test.mjs +63 -0
  94. package/assets/codemods/transforms/next/__tests__/migrate-theme-catalog-to-descriptors.test.mjs +220 -0
  95. package/assets/codemods/transforms/next/index.mjs +19 -1
  96. package/assets/codemods/transforms/next/migrate-native-picker-to-presentation.mjs +148 -0
  97. package/assets/codemods/transforms/next/migrate-theme-catalog-to-descriptors.mjs +141 -0
  98. package/assets/codemods/transforms/v0.0.14/__tests__/rename-status-variants.test.mjs +86 -165
  99. package/assets/codemods/transforms/v0.0.14/rename-status-variants.mjs +72 -210
  100. package/assets/codemods/transforms/v0.1.8/__tests__/rename-avatar-size-scale.test.mjs +83 -115
  101. package/assets/codemods/transforms/v0.1.8/rename-avatar-size-scale.mjs +57 -186
  102. package/assets/docs/cli-integrations.doc.mjs +30 -30
  103. package/assets/docs/cli.doc.mjs +15 -0
  104. package/assets/docs/theme.doc.mjs +1 -1
  105. package/assets/templates/blocks/components/DateInput/DateInputDateRange.tsx +1 -1
  106. package/assets/templates/blocks/components/Item/ItemDocumentTabs.doc.mjs +14 -0
  107. package/assets/templates/blocks/components/Item/ItemDocumentTabs.tsx +100 -0
  108. package/assets/templates/blocks/components/ScrollableArea/ScrollableAreaInlineRail.doc.mjs +14 -0
  109. package/assets/templates/blocks/components/ScrollableArea/ScrollableAreaInlineRail.tsx +61 -0
  110. package/assets/templates/blocks/components/ScrollableArea/ScrollableAreaOverscrollChaining.doc.mjs +14 -0
  111. package/assets/templates/blocks/components/ScrollableArea/ScrollableAreaOverscrollChaining.tsx +126 -0
  112. package/assets/templates/blocks/components/ScrollableArea/ScrollableAreaShowcase.doc.mjs +15 -0
  113. package/assets/templates/blocks/components/ScrollableArea/ScrollableAreaShowcase.tsx +86 -0
  114. package/assets/templates/blocks/components/ScrollableArea/ScrollableAreaStickyGroupHeaders.doc.mjs +14 -0
  115. package/assets/templates/blocks/components/ScrollableArea/ScrollableAreaStickyGroupHeaders.tsx +99 -0
  116. package/assets/templates/blocks/components/ScrollableArea/ScrollableAreaStickyPassthrough.doc.mjs +14 -0
  117. package/assets/templates/blocks/components/ScrollableArea/ScrollableAreaStickyPassthrough.tsx +122 -0
  118. package/assets/templates/blocks/components/ScrollableArea/ScrollableAreaTwoAxisBoard.doc.mjs +14 -0
  119. package/assets/templates/blocks/components/ScrollableArea/ScrollableAreaTwoAxisBoard.tsx +95 -0
  120. package/assets/templates/blocks/components/TimeInput/TimeInputConstrained.tsx +1 -0
  121. package/assets/templates/themes/butter/butterTheme.doc.mjs +11 -0
  122. package/assets/templates/themes/chocolate/chocolateTheme.doc.mjs +11 -0
  123. package/assets/templates/themes/gothic/gothicTheme.doc.mjs +11 -0
  124. package/assets/templates/themes/matcha/matchaTheme.doc.mjs +11 -0
  125. package/assets/templates/themes/neutral/neutralTheme.doc.mjs +11 -0
  126. package/assets/templates/themes/stone/stoneTheme.doc.mjs +11 -0
  127. package/assets/templates/themes/y2k/y2kTheme.doc.mjs +11 -0
  128. package/authoring/codemod/codemod.doc.mjs +1 -1
  129. package/authoring/codemod/type.ts +12 -0
  130. package/authoring/config/config.doc.mjs +1 -1
  131. package/authoring/debug/debug.doc.d.mts +11 -0
  132. package/authoring/debug/debug.doc.mjs +182 -0
  133. package/authoring/doctypes/base/graph-fields.doc.mjs +1 -1
  134. package/authoring/doctypes/command/command.doc.mjs +1 -1
  135. package/authoring/doctypes/command/type.ts +1 -1
  136. package/authoring/doctypes/component/type.ts +2 -2
  137. package/authoring/doctypes/doctypes-new.test.mjs +48 -6
  138. package/authoring/doctypes/enum/enum.doc.mjs +1 -1
  139. package/authoring/doctypes/enum/type.ts +1 -1
  140. package/authoring/doctypes/function/function.doc.mjs +1 -1
  141. package/authoring/doctypes/function/type.ts +1 -1
  142. package/authoring/doctypes/hook/type.ts +2 -2
  143. package/authoring/doctypes/load-contract.test.mjs +2 -1
  144. package/authoring/doctypes/parse.d.mts +4 -2
  145. package/authoring/doctypes/parse.mjs +7 -3
  146. package/authoring/doctypes/reference/reference.doc.mjs +1 -1
  147. package/authoring/doctypes/reference/type.ts +2 -2
  148. package/authoring/doctypes/schema/schema.doc.mjs +1 -1
  149. package/authoring/doctypes/schema/type.ts +1 -2
  150. package/authoring/doctypes/template/template.doc.mjs +3 -3
  151. package/authoring/doctypes/theme/parse.d.mts +35 -0
  152. package/authoring/doctypes/theme/parse.mjs +76 -0
  153. package/authoring/doctypes/theme/theme.doc.d.mts +9 -0
  154. package/authoring/doctypes/theme/theme.doc.mjs +79 -0
  155. package/authoring/doctypes/theme/type.ts +42 -0
  156. package/authoring/doctypes/types.ts +2 -1
  157. package/authoring/gap-report/gap-report.doc.d.mts +12 -0
  158. package/authoring/gap-report/gap-report.doc.mjs +183 -0
  159. package/authoring/index.d.mts +1 -0
  160. package/authoring/index.d.ts +6 -4
  161. package/authoring/index.mjs +2 -1
  162. package/authoring/integration/integration.doc.mjs +2 -2
  163. package/authoring/integration/type.ts +3 -9
  164. package/clients/cli/__tests__/cliManifest.test.ts +27 -29
  165. package/clients/cli/commands/blog.doc.mjs +1 -1
  166. package/clients/cli/commands/build.doc.mjs +1 -1
  167. package/clients/cli/commands/component-package.test.mjs +28 -0
  168. package/clients/cli/commands/component.doc.mjs +1 -1
  169. package/clients/cli/commands/discover.doc.mjs +1 -1
  170. package/clients/cli/commands/docs.doc.mjs +1 -1
  171. package/clients/cli/commands/doctor-integration-components.doc.mjs +1 -1
  172. package/clients/cli/commands/doctor-integration-docs.doc.mjs +1 -1
  173. package/clients/cli/commands/doctor-integration-templates.doc.mjs +1 -1
  174. package/clients/cli/commands/doctor-integration-validate.doc.mjs +1 -1
  175. package/clients/cli/commands/doctor-integration.doc.mjs +1 -1
  176. package/clients/cli/commands/doctor-integration.test.mjs +15 -7
  177. package/clients/cli/commands/doctor.doc.mjs +1 -1
  178. package/clients/cli/commands/gap-report.doc.mjs +1 -1
  179. package/clients/cli/commands/hook.doc.mjs +1 -1
  180. package/clients/cli/commands/init.doc.mjs +1 -1
  181. package/clients/cli/commands/integration-add.controls.test.mjs +1 -1
  182. package/clients/cli/commands/integration-add.doc.mjs +1 -1
  183. package/clients/cli/commands/integration-pack.doc.mjs +1 -1
  184. package/clients/cli/commands/integration-real-world.test.mjs +3 -9
  185. package/clients/cli/commands/integration.doc.mjs +1 -1
  186. package/clients/cli/commands/layout-check.doc.mjs +1 -1
  187. package/clients/cli/commands/layout-expand.doc.mjs +1 -1
  188. package/clients/cli/commands/layout-grammar.doc.mjs +1 -1
  189. package/clients/cli/commands/layout.doc.mjs +1 -1
  190. package/clients/cli/commands/manifest.doc.mjs +1 -1
  191. package/clients/cli/commands/search.doc.mjs +1 -1
  192. package/clients/cli/commands/swizzle.doc.mjs +1 -1
  193. package/clients/cli/commands/template.doc.mjs +1 -1
  194. package/clients/cli/commands/theme-add.doc.mjs +2 -2
  195. package/clients/cli/commands/theme-build.doc.mjs +1 -1
  196. package/clients/cli/commands/theme-list.doc.mjs +2 -2
  197. package/clients/cli/commands/theme-palette-generate.doc.mjs +3 -3
  198. package/clients/cli/commands/theme-palette.doc.mjs +1 -1
  199. package/clients/cli/commands/theme-targets.doc.mjs +1 -1
  200. package/clients/cli/commands/theme-template.doc.mjs +1 -1
  201. package/clients/cli/commands/theme.doc.mjs +1 -1
  202. package/clients/cli/commands/upgrade.doc.mjs +3 -2
  203. package/clients/cli/commands/upgrade.file-protection.test.mjs +228 -0
  204. package/clients/cli/commands/upgrade.mjs +3 -0
  205. package/clients/cli/lib/hook-format.mjs +14 -5
  206. package/foundation/config/project-themes.test.mjs +11 -19
  207. package/foundation/config/project.d.mts +8 -0
  208. package/foundation/config/project.mjs +50 -21
  209. package/foundation/config/project.test.mjs +3 -16
  210. package/foundation/discovery/authoring-self-docs.d.mts +6 -0
  211. package/foundation/discovery/authoring-self-docs.mjs +17 -7
  212. package/foundation/discovery/authoring-surface.d.mts +74 -0
  213. package/foundation/discovery/authoring-surface.mjs +525 -0
  214. package/foundation/discovery/authoring-surface.test.mjs +392 -0
  215. package/foundation/discovery/cli-self-docs.d.mts +113 -0
  216. package/foundation/discovery/cli-self-docs.mjs +514 -0
  217. package/foundation/discovery/cli-self-docs.test.mjs +437 -0
  218. package/foundation/discovery/component-loader.d.mts +35 -38
  219. package/foundation/discovery/component-loader.mjs +53 -222
  220. package/foundation/discovery/docs-discovery.d.mts +3 -2
  221. package/foundation/discovery/docs-discovery.mjs +8 -12
  222. package/foundation/discovery/docs-discovery.test.mjs +8 -5
  223. package/foundation/discovery/template-adapter.d.mts +7 -0
  224. package/foundation/discovery/template-adapter.mjs +27 -40
  225. package/foundation/discovery/template-adapter.test.mjs +15 -0
  226. package/foundation/discovery/theme-discovery.d.mts +67 -7
  227. package/foundation/discovery/theme-discovery.mjs +916 -186
  228. package/foundation/discovery/theme-discovery.test.mjs +613 -219
  229. package/foundation/doc-compiler/bundle.d.mts +47 -0
  230. package/foundation/doc-compiler/bundle.mjs +218 -0
  231. package/foundation/doc-compiler/bundle.test.mjs +255 -0
  232. package/foundation/doc-compiler/compile.d.mts +200 -0
  233. package/foundation/doc-compiler/compile.mjs +254 -5
  234. package/foundation/doc-compiler/diagnostics.d.mts +126 -0
  235. package/foundation/doc-compiler/diagnostics.mjs +277 -0
  236. package/foundation/doc-compiler/doc-compiler.test.mjs +28 -1
  237. package/foundation/doc-compiler/doc-loads.test.mjs +1642 -0
  238. package/foundation/doc-compiler/import.d.mts +24 -0
  239. package/foundation/doc-compiler/import.mjs +59 -0
  240. package/foundation/doc-compiler/inputs.d.mts +102 -0
  241. package/foundation/doc-compiler/inputs.mjs +286 -0
  242. package/foundation/doc-compiler/inputs.test.mjs +299 -0
  243. package/foundation/doc-compiler/ir.d.mts +13 -0
  244. package/foundation/doc-compiler/ir.mjs +189 -12
  245. package/foundation/doc-compiler/lower-doc.test.mjs +492 -0
  246. package/foundation/doc-compiler/overlays.d.mts +37 -0
  247. package/foundation/doc-compiler/overlays.mjs +206 -0
  248. package/foundation/doc-compiler/parse-readable.d.mts +9 -0
  249. package/foundation/doc-compiler/parse-readable.mjs +29 -0
  250. package/foundation/doc-compiler/read.d.mts +126 -0
  251. package/foundation/doc-compiler/read.mjs +320 -0
  252. package/foundation/doc-compiler/read.test.mjs +313 -0
  253. package/foundation/doc-compiler/source.d.mts +33 -0
  254. package/foundation/doc-compiler/source.mjs +128 -0
  255. package/foundation/fs/file-protection.d.mts +33 -0
  256. package/foundation/fs/file-protection.mjs +825 -0
  257. package/foundation/fs/file-protection.test.mjs +250 -0
  258. package/foundation/integrations/autolink.d.mts +58 -1
  259. package/foundation/integrations/autolink.mjs +143 -57
  260. package/foundation/integrations/contribution-fixes.d.mts +145 -0
  261. package/foundation/integrations/contribution-fixes.mjs +1284 -0
  262. package/foundation/integrations/contribution-inventory.d.mts +1 -1
  263. package/foundation/integrations/contribution-inventory.mjs +17 -20
  264. package/foundation/integrations/contribution-inventory.test.mjs +67 -27
  265. package/foundation/integrations/integrations.d.mts +3 -0
  266. package/foundation/integrations/integrations.mjs +11 -97
  267. package/foundation/integrations/provider-ledger.test.mjs +275 -0
  268. package/foundation/integrations/provider-resolution.d.mts +152 -0
  269. package/foundation/integrations/provider-resolution.mjs +576 -0
  270. package/foundation/integrations/provider-resolution.test.mjs +369 -0
  271. package/foundation/integrations/theme-descriptor.d.mts +8 -0
  272. package/foundation/integrations/theme-descriptor.mjs +44 -0
  273. package/foundation/integrations/validate-contributions.mjs +104 -10
  274. package/foundation/response/error-codes.d.mts +3 -1
  275. package/foundation/response/error-codes.d.ts +2 -0
  276. package/foundation/response/error-codes.doc.mjs +12 -2
  277. package/foundation/response/error-codes.mjs +7 -1
  278. package/foundation/response/error-codes.test.mjs +55 -11
  279. package/foundation/response/response-types.doc.mjs +8 -8
  280. package/foundation/response/response-types.doc.test.mjs +158 -0
  281. package/foundation/response/response.doc.mjs +1 -1
  282. package/foundation/text/string-utils.mjs +22 -10
  283. package/package.json +10 -9
  284. package/assets/templates/themes/manifest.json +0 -95
@@ -44,7 +44,7 @@ function writeIntegration({
44
44
  const stem = path.join(tmpDir, 'templates', id);
45
45
  fs.mkdirSync(path.dirname(stem), {recursive: true});
46
46
  fs.writeFileSync(
47
- `${stem}.template.mjs`,
47
+ `${stem}.doc.mjs`,
48
48
  `export default {type: 'page', name: ${JSON.stringify(name)}, description: 'fixture'};\n`,
49
49
  );
50
50
  fs.writeFileSync(
@@ -124,7 +124,12 @@ describe('doctor integration — command', () => {
124
124
  return true;
125
125
  });
126
126
 
127
- await createProgram().parseAsync(['node', 'astryx', 'doctor', 'integration']);
127
+ await createProgram().parseAsync([
128
+ 'node',
129
+ 'astryx',
130
+ 'doctor',
131
+ 'integration',
132
+ ]);
128
133
 
129
134
  const output = writes.join('');
130
135
  expect(output).toContain('validate [package]');
@@ -136,7 +141,9 @@ describe('doctor integration — command', () => {
136
141
 
137
142
  it('explains the optional package argument in every leaf help', () => {
138
143
  const program = createProgram();
139
- const doctor = program.commands.find(command => command.name() === 'doctor');
144
+ const doctor = program.commands.find(
145
+ command => command.name() === 'doctor',
146
+ );
140
147
  const integration = doctor?.commands.find(
141
148
  command => command.name() === 'integration',
142
149
  );
@@ -152,7 +159,10 @@ describe('doctor integration — command', () => {
152
159
  });
153
160
 
154
161
  it('templates explains how to check an installed package when no local manifest exists', async () => {
155
- fs.writeFileSync(path.join(tmpDir, 'package.json'), JSON.stringify({name: 'plain'}));
162
+ fs.writeFileSync(
163
+ path.join(tmpDir, 'package.json'),
164
+ JSON.stringify({name: 'plain'}),
165
+ );
156
166
  process.chdir(tmpDir);
157
167
 
158
168
  await createProgram().parseAsync([
@@ -278,9 +288,7 @@ describe('doctor integration — command', () => {
278
288
  const output = logCalls.join('\n');
279
289
  expect(output).toContain('[warn]');
280
290
  expect(output).toContain(core.name);
281
- expect(output).toContain(
282
- `component ${core.name} --package @acme/widgets`,
283
- );
291
+ expect(output).toContain(`component ${core.name} --package @acme/widgets`);
284
292
  expect(process.exitCode).toBeUndefined();
285
293
  });
286
294
 
@@ -12,7 +12,7 @@ export const doc = {
12
12
  type: 'command',
13
13
  name: 'doctor',
14
14
  displayName: 'astryx doctor',
15
- namespace: 'cli',
15
+ namespace: 'cli/commands',
16
16
  summary: 'Diagnose Astryx projects and integration packages',
17
17
  description:
18
18
  'Runs read-only project health diagnostics by default: Node version, @astryxdesign/core ' +
@@ -10,7 +10,7 @@ export const doc = {
10
10
  type: 'command',
11
11
  name: 'gap-report',
12
12
  displayName: 'astryx gap-report',
13
- namespace: 'cli',
13
+ namespace: 'cli/commands',
14
14
  summary: 'Route a design-system gap to its owning package',
15
15
  description:
16
16
  'Reports a missing component, variant, layout, styling, accessibility, API, or documentation capability. The command selects an explicit package first, then a unique component owner, then Core. The report fans out to every effective handler: project config first, then each loaded integration in config order. Public handlers require --confirm-public per handler; internal handlers always run. A handler failure is isolated and does not prevent later handlers.',
@@ -12,7 +12,7 @@ export const doc = {
12
12
  type: 'command',
13
13
  name: 'hook',
14
14
  displayName: 'astryx hook',
15
- namespace: 'cli',
15
+ namespace: 'cli/commands',
16
16
  summary: 'List hooks or print hook docs',
17
17
  description:
18
18
  'Resolves a hook by name and prints its authored doc, or lists the catalog grouped ' +
@@ -12,7 +12,7 @@ export const doc = {
12
12
  type: 'command',
13
13
  name: 'init',
14
14
  displayName: 'astryx init',
15
- namespace: 'cli',
15
+ namespace: 'cli/commands',
16
16
  summary: 'Initialize the design system in your project',
17
17
  description:
18
18
  'Non-interactive project setup (no prompts, so it behaves the same for humans, ' +
@@ -126,7 +126,7 @@ describe('integration add control definitions', () => {
126
126
  );
127
127
  expect(page.status).toBe(0);
128
128
  expect(
129
- fs.readFileSync(path.join(tmpDir, 'templates', 'acme-page.template.mjs'), 'utf-8'),
129
+ fs.readFileSync(path.join(tmpDir, 'templates', 'acme-page.doc.mjs'), 'utf-8'),
130
130
  ).toContain("type: 'page'");
131
131
  });
132
132
  });
@@ -5,7 +5,7 @@ export const doc = {
5
5
  type: 'command',
6
6
  name: 'integration add',
7
7
  displayName: 'astryx integration add',
8
- namespace: 'cli',
8
+ namespace: 'cli/commands',
9
9
  summary: 'Add one working contribution to an integration package',
10
10
  description:
11
11
  'Writes the complete minimum shape the selected contribution needs, creates the integration manifest on first use, declares the root only after a valid contribution exists, and verifies the result through the same discovery contract the packed-package check uses.',
@@ -5,7 +5,7 @@ export const doc = {
5
5
  type: 'command',
6
6
  name: 'integration pack',
7
7
  displayName: 'astryx integration pack',
8
- namespace: 'cli',
8
+ namespace: 'cli/commands',
9
9
  summary: 'Prove the packed integration is what consumers receive',
10
10
  description:
11
11
  'Runs the package lifecycle, packs with npm, checks every required contribution file against the real tarball, extracts it into a scratch consumer, and compares the local and packed contribution inventories through one shared contract.',
@@ -201,13 +201,6 @@ export const oceanTheme = defineTheme({
201
201
  });
202
202
  `,
203
203
  );
204
- const catalogFile = path.join(providerDir, 'themes', 'manifest.json');
205
- const catalog = JSON.parse(fs.readFileSync(catalogFile, 'utf-8'));
206
- catalog.themes[0].files.push(
207
- 'tokens/ocean.palette.ts',
208
- 'tokens/ocean.palette.receipt.json',
209
- );
210
- writeJson(catalogFile, catalog);
211
204
 
212
205
  const providerPackage = JSON.parse(
213
206
  fs.readFileSync(path.join(providerDir, 'package.json'), 'utf-8'),
@@ -464,8 +457,9 @@ export const oceanTheme = defineTheme({
464
457
  outputDir: target,
465
458
  files: [
466
459
  'oceanTheme.ts',
467
- 'tokens/ocean.palette.ts',
460
+ 'oceanTheme.doc.mjs',
468
461
  'tokens/ocean.palette.receipt.json',
462
+ 'tokens/ocean.palette.ts',
469
463
  ],
470
464
  },
471
465
  });
@@ -612,7 +606,7 @@ export const oceanTheme = defineTheme({
612
606
  expect(corruptedInstall.status).not.toBe(0);
613
607
  expect(parseEnvelope(corruptedInstall.stdout)).toMatchObject({
614
608
  code: 'ERR_THEME_INVALID',
615
- error: expect.stringContaining('ocean.palette.ts'),
609
+ error: expect.stringContaining('./tokens/ocean.palette'),
616
610
  });
617
611
  }, 120_000);
618
612
  });
@@ -5,7 +5,7 @@ export const doc = {
5
5
  type: 'command',
6
6
  name: 'integration',
7
7
  displayName: 'astryx integration',
8
- namespace: 'cli',
8
+ namespace: 'cli/commands',
9
9
  summary: 'Author and verify an Astryx integration package',
10
10
  description:
11
11
  'Add contributions that are valid on arrival, then prove the packed package exposes the same contributions a consumer will receive.',
@@ -13,7 +13,7 @@ export const doc = {
13
13
  type: 'command',
14
14
  name: 'layout check',
15
15
  displayName: 'astryx layout check',
16
- namespace: 'cli',
16
+ namespace: 'cli/commands',
17
17
  summary:
18
18
  'Validate a layout expression and echo canonical compact/outline forms',
19
19
  description:
@@ -13,7 +13,7 @@ export const doc = {
13
13
  type: 'command',
14
14
  name: 'layout expand',
15
15
  displayName: 'astryx layout expand',
16
- namespace: 'cli',
16
+ namespace: 'cli/commands',
17
17
  summary: 'Expand a layout expression into validated XDS TSX',
18
18
  description:
19
19
  'Parses and validates a compressed XLE/XLO expression, then expands it into ' +
@@ -13,7 +13,7 @@ export const doc = {
13
13
  type: 'command',
14
14
  name: 'layout grammar',
15
15
  displayName: 'astryx layout grammar',
16
- namespace: 'cli',
16
+ namespace: 'cli/commands',
17
17
  summary:
18
18
  'Print the XLE/XLO cheatsheet (alias table generated from this branch)',
19
19
  description:
@@ -12,7 +12,7 @@ export const doc = {
12
12
  type: 'command',
13
13
  name: 'layout',
14
14
  displayName: 'astryx layout',
15
- namespace: 'cli',
15
+ namespace: 'cli/commands',
16
16
  summary: 'Generate XDS layouts from compressed expressions (XLE/XLO)',
17
17
  description:
18
18
  'The layout command group. Running astryx layout with no subcommand prints the ' +
@@ -12,7 +12,7 @@ export const doc = {
12
12
  type: 'command',
13
13
  name: 'manifest',
14
14
  displayName: 'astryx manifest',
15
- namespace: 'cli',
15
+ namespace: 'cli/commands',
16
16
  summary: 'Print the full CLI capability manifest (use with --json).',
17
17
  description:
18
18
  'Emits the complete CLI surface: every command with its arguments, options, ' +
@@ -12,7 +12,7 @@ export const doc = {
12
12
  type: 'command',
13
13
  name: 'search',
14
14
  displayName: 'astryx search',
15
- namespace: 'cli',
15
+ namespace: 'cli/commands',
16
16
  summary: 'Search components, hooks, docs, and templates in one ranked list',
17
17
  description:
18
18
  'Terminal front-end to search(): prints one ranked, greppable list across ' +
@@ -12,7 +12,7 @@ export const doc = {
12
12
  type: 'command',
13
13
  name: 'swizzle',
14
14
  displayName: 'astryx swizzle',
15
- namespace: 'cli',
15
+ namespace: 'cli/commands',
16
16
  summary: 'Copy component source for customization',
17
17
  description:
18
18
  "Ejects a component's source from the resolved @astryxdesign/core (or its owning " +
@@ -13,7 +13,7 @@ export const doc = {
13
13
  type: 'command',
14
14
  name: 'template',
15
15
  displayName: 'astryx template',
16
- namespace: 'cli',
16
+ namespace: 'cli/commands',
17
17
  summary: 'Inject a page or block template',
18
18
  description:
19
19
  'One entry point for the template family: with no name it lists the discovered ' +
@@ -13,7 +13,7 @@ export const doc = {
13
13
  type: 'command',
14
14
  name: 'theme add',
15
15
  displayName: 'astryx theme add',
16
- namespace: 'cli',
16
+ namespace: 'cli/commands',
17
17
  summary: 'Scaffold a theme into your project as editable source',
18
18
  description:
19
19
  "Copies a bundled or installed integration theme's source into your project so you own it. " +
@@ -49,7 +49,7 @@ export const doc = {
49
49
  {code: 0, when: 'success'},
50
50
  {
51
51
  code: 1,
52
- when: 'unknown or ambiguous theme, a path escape, a missing catalog file, or an existing file without --overwrite',
52
+ when: 'unknown or ambiguous theme, a path escape, a missing descriptor or source, or an existing file without --overwrite',
53
53
  },
54
54
  ],
55
55
  related: ['theme list', 'theme build'],
@@ -13,7 +13,7 @@ export const doc = {
13
13
  type: 'command',
14
14
  name: 'theme build',
15
15
  displayName: 'astryx theme build',
16
- namespace: 'cli',
16
+ namespace: 'cli/commands',
17
17
  summary: 'Compile standalone themes or one keyed theme family',
18
18
  description:
19
19
  'Compiles defineTheme() sources through the same theme pipeline into scoped CSS, ' +
@@ -13,7 +13,7 @@ export const doc = {
13
13
  type: 'command',
14
14
  name: 'theme list',
15
15
  displayName: 'astryx theme list',
16
- namespace: 'cli',
16
+ namespace: 'cli/commands',
17
17
  summary: 'List themes available to add',
18
18
  description:
19
19
  'Lists themes bundled with this CLI and source themes contributed by installed integrations, ' +
@@ -37,7 +37,7 @@ export const doc = {
37
37
  {code: 0, when: 'success'},
38
38
  {
39
39
  code: 1,
40
- when: 'the bundled-theme manifest or an installed theme catalog cannot be read',
40
+ when: 'a bundled or installed theme descriptor cannot be read',
41
41
  },
42
42
  ],
43
43
  related: ['theme add', 'theme build'],
@@ -5,7 +5,7 @@ export const doc = {
5
5
  type: 'command',
6
6
  name: 'theme palette generate',
7
7
  displayName: 'astryx theme palette generate',
8
- namespace: 'cli',
8
+ namespace: 'cli/commands',
9
9
  summary: 'Generate an OKLCH palette candidate for human review',
10
10
  description:
11
11
  'Reads an explicit JSON request and runs the versioned astryx-oklch-v1 recipe. ' +
@@ -21,8 +21,8 @@ export const doc = {
21
21
  'JSON is also supported. Existing author-owned files are left untouched unless --overwrite is explicit. ' +
22
22
  'When used in a theme integration, keep the palette request under the theme slug, ' +
23
23
  'write the candidate and receipt under that same slug, import the candidate from the theme source, ' +
24
- "and list all three paths in the theme catalog entry's `files` array " +
25
- 'so `astryx theme add` copies them into the consumer project.',
24
+ 'and keep all three inside the theme directory: `astryx theme add` copies that whole ' +
25
+ 'directory into the consumer project, so nothing else has to list them.',
26
26
  fn: 'themePaletteGenerate',
27
27
  args: [{name: 'config', param: 'configPath', required: true}],
28
28
  options: [
@@ -5,7 +5,7 @@ export const doc = {
5
5
  type: 'command',
6
6
  name: 'theme palette',
7
7
  displayName: 'astryx theme palette',
8
- namespace: 'cli',
8
+ namespace: 'cli/commands',
9
9
  summary: 'Create and work with theme-owned color palettes',
10
10
  description:
11
11
  'Palette authoring tools. The initial generate command creates reviewable candidates. ' +
@@ -13,7 +13,7 @@ export const doc = {
13
13
  type: 'command',
14
14
  name: 'theme targets',
15
15
  displayName: 'astryx theme targets',
16
- namespace: 'cli',
16
+ namespace: 'cli/commands',
17
17
  summary: 'List the component theming targets a theme can override',
18
18
  description:
19
19
  'Prints every `defineTheme` components key across the system: the stable class it paints, ' +
@@ -13,7 +13,7 @@ export const doc = {
13
13
  type: 'command',
14
14
  name: 'theme template',
15
15
  displayName: 'astryx theme template',
16
- namespace: 'cli',
16
+ namespace: 'cli/commands',
17
17
  summary: 'Write the annotated theme template into your project',
18
18
  description:
19
19
  'Writes theme.template.ts: the annotated reference for the whole theme surface, covering every ' +
@@ -12,7 +12,7 @@ export const doc = {
12
12
  type: 'command',
13
13
  name: 'theme',
14
14
  displayName: 'astryx theme',
15
- namespace: 'cli',
15
+ namespace: 'cli/commands',
16
16
  summary: 'Theme tools: build, export, and manage themes',
17
17
  description:
18
18
  'The theme command group. Running astryx theme with no subcommand prints the ' +
@@ -12,7 +12,7 @@ export const doc = {
12
12
  type: 'command',
13
13
  name: 'upgrade',
14
14
  displayName: 'astryx upgrade',
15
- namespace: 'cli',
15
+ namespace: 'cli/commands',
16
16
  summary: 'Migrate versions and update ShadCN-copied compositions',
17
17
  description:
18
18
  'Migrates project source from a previous Astryx version to the installed one by ' +
@@ -101,13 +101,14 @@ export const doc = {
101
101
  {label: 'Apply a migration', cli: 'astryx upgrade --from 0.1.0 --apply'},
102
102
  ],
103
103
  exitCodes: [
104
- {code: 0, when: 'success (including dry-run previews)'},
104
+ {code: 0, when: 'success, including complete dry-run previews'},
105
105
  {
106
106
  code: 1,
107
107
  when:
108
108
  'missing or invalid --from, --registry with --list or a migration flag, a --path escape, ' +
109
109
  'no installed @astryxdesign/core (or legacy @xds/core), jscodeshift missing and not installed by --install-deps, ' +
110
110
  'an astryx.config that fails validation and that no pending config codemod repairs, ' +
111
+ 'an unreadable or invalid protection declaration, a protected file that still requires a codemod change, ' +
111
112
  'an unknown codemod, a codemod or post-codemod hook failure, or unresolved registry items',
112
113
  },
113
114
  ],
@@ -0,0 +1,228 @@
1
+ // Copyright (c) Meta Platforms, Inc. and affiliates.
2
+
3
+ /**
4
+ * @file End-to-end protection and regeneration behavior for `astryx upgrade`.
5
+ */
6
+
7
+ import {afterEach, beforeEach, describe, expect, it} from 'vitest';
8
+ import {spawnSync} from 'node:child_process';
9
+ import * as fs from 'node:fs';
10
+ import * as os from 'node:os';
11
+ import * as path from 'node:path';
12
+ import {fileURLToPath} from 'node:url';
13
+
14
+ const CLI = path.resolve(
15
+ path.dirname(fileURLToPath(import.meta.url)),
16
+ '..',
17
+ 'bin',
18
+ 'astryx.mjs',
19
+ );
20
+ let root;
21
+
22
+ function write(relative, contents) {
23
+ const file = path.join(root, relative);
24
+ fs.mkdirSync(path.dirname(file), {recursive: true});
25
+ fs.writeFileSync(file, contents);
26
+ return file;
27
+ }
28
+
29
+ function run(args) {
30
+ const result = spawnSync(
31
+ process.execPath,
32
+ [CLI, '--json', 'upgrade', ...args],
33
+ {
34
+ cwd: root,
35
+ encoding: 'utf8',
36
+ timeout: 60_000,
37
+ env: {...process.env, FORCE_COLOR: '0', CI: ''},
38
+ },
39
+ );
40
+ return {...result, envelope: JSON.parse(result.stdout)};
41
+ }
42
+
43
+ function seed({hook = false} = {}) {
44
+ write('package.json', JSON.stringify({name: 'consumer', private: true}));
45
+ write(
46
+ 'node_modules/@astryxdesign/core/package.json',
47
+ JSON.stringify({name: '@astryxdesign/core', version: '0.6.0'}),
48
+ );
49
+ write('.gitattributes', 'generated/** linguist-generated=true\n');
50
+ const source =
51
+ "import {useResizable} from '@astryxdesign/core';\n" +
52
+ 'export const usePanel = () => useResizable({minSizePx: 200});\n';
53
+ write('src/owned.tsx', source);
54
+ write('generated/panel.tsx', `// @generated\n${source}`);
55
+ write(
56
+ 'astryx.config.mjs',
57
+ hook
58
+ ? `export default {hooks: {postCodemod: [{name: 'regenerate', buildCommand: () => ({command: process.execPath, args: ['-e', ${JSON.stringify("const fs=require('node:fs');const p='generated/panel.tsx';const s=fs.readFileSync(p,'utf8');fs.writeFileSync(p,s.replaceAll('minSizePx','minSize')); ")} ]})}]}};\n`
59
+ : 'export default {};\n',
60
+ );
61
+ }
62
+
63
+ beforeEach(() => {
64
+ root = fs.mkdtempSync(path.join(os.tmpdir(), 'astryx-protected-upgrade-'));
65
+ });
66
+
67
+ afterEach(() => {
68
+ fs.rmSync(root, {recursive: true, force: true});
69
+ });
70
+
71
+ const ARGS = [
72
+ '--from',
73
+ '0.5.0',
74
+ '--codemod',
75
+ 'rename-resizable-pixel-bounds',
76
+ '--path',
77
+ '.',
78
+ ];
79
+
80
+ describe('upgrade protected-file contract', () => {
81
+ it('reports the same protected candidate in dry-run and apply while retaining owned edits', () => {
82
+ seed();
83
+
84
+ const dry = run(ARGS);
85
+ expect(dry.status).toBe(1);
86
+ expect(dry.envelope).toMatchObject({
87
+ type: 'upgrade.run',
88
+ data: {
89
+ complete: false,
90
+ errorCode: 'ERR_CODEMOD_PROTECTED',
91
+ modifiedFiles: ['src/owned.tsx'],
92
+ protectedFiles: [
93
+ {
94
+ file: 'generated/panel.tsx',
95
+ reasons: ['generated'],
96
+ declarations: expect.arrayContaining([
97
+ 'linguist-generated in .gitattributes:1',
98
+ '@generated in the leading comment block',
99
+ ]),
100
+ },
101
+ ],
102
+ },
103
+ });
104
+ expect(fs.readFileSync(path.join(root, 'src/owned.tsx'), 'utf8')).toContain(
105
+ 'minSizePx',
106
+ );
107
+
108
+ const applied = run([...ARGS, '--apply']);
109
+ expect(applied.status).toBe(1);
110
+ expect(applied.envelope.data.protectedFiles).toEqual(
111
+ dry.envelope.data.protectedFiles,
112
+ );
113
+ expect(fs.readFileSync(path.join(root, 'src/owned.tsx'), 'utf8')).toContain(
114
+ 'minSize: 200',
115
+ );
116
+ expect(
117
+ fs.readFileSync(path.join(root, 'generated/panel.tsx'), 'utf8'),
118
+ ).toContain('minSizePx');
119
+ });
120
+
121
+ it('preserves a protected config migration when strict config loading fails', () => {
122
+ write('package.json', JSON.stringify({name: 'consumer', private: true}));
123
+ write(
124
+ 'node_modules/@astryxdesign/core/package.json',
125
+ JSON.stringify({name: '@astryxdesign/core', version: '0.1.3'}),
126
+ );
127
+ write(
128
+ 'astryx.config.mjs',
129
+ `// @generated\nexport default {layout: {components: {KpiCard: '@/KpiCard'}}};\n`,
130
+ );
131
+ write('src/index.ts', 'export {};\n');
132
+
133
+ const result = run([
134
+ '--from',
135
+ '0.1.2',
136
+ '--codemod',
137
+ 'migrate-layout-components-to-experimental',
138
+ '--path',
139
+ 'src',
140
+ '--apply',
141
+ ]);
142
+
143
+ expect(result.status).toBe(1);
144
+ expect(result.envelope).toMatchObject({
145
+ type: 'upgrade.run',
146
+ data: {
147
+ complete: false,
148
+ errorCode: 'ERR_CODEMOD_PROTECTED',
149
+ protectedFiles: [expect.objectContaining({file: 'astryx.config.mjs'})],
150
+ },
151
+ });
152
+ expect(
153
+ fs.readFileSync(path.join(root, 'astryx.config.mjs'), 'utf8'),
154
+ ).toContain('layout');
155
+ });
156
+
157
+ it('fails before writes when a protection declaration cannot be parsed', () => {
158
+ seed();
159
+ write('.hgignore', 'syntax: regexp\n[bad\n');
160
+
161
+ const result = run([...ARGS, '--apply']);
162
+
163
+ expect(result.status).toBe(1);
164
+ expect(result.envelope).toMatchObject({
165
+ code: 'ERR_CODEMOD_PROTECTION_SOURCE',
166
+ });
167
+ expect(result.envelope.error).toContain('.hgignore');
168
+ expect(fs.readFileSync(path.join(root, 'src/owned.tsx'), 'utf8')).toContain(
169
+ 'minSizePx',
170
+ );
171
+ });
172
+
173
+ it('preserves protected-file facts when regeneration fails', () => {
174
+ seed();
175
+ write(
176
+ 'astryx.config.mjs',
177
+ `export default {hooks: {postCodemod: [{name: 'regenerate', buildCommand: () => ({command: process.execPath, args: ['-e', 'process.exit(7)']})}]}};\n`,
178
+ );
179
+
180
+ const applied = run([...ARGS, '--apply']);
181
+
182
+ expect(applied.status).toBe(1);
183
+ expect(applied.envelope).toMatchObject({
184
+ type: 'upgrade.run',
185
+ data: {
186
+ complete: false,
187
+ errorCode: 'ERR_CODEMOD_PROTECTED',
188
+ protectedFiles: [
189
+ expect.objectContaining({file: 'generated/panel.tsx'}),
190
+ ],
191
+ errors: [
192
+ expect.objectContaining({
193
+ codemod: 'post-codemod-hook',
194
+ error: expect.stringContaining('Post-codemod hook failed'),
195
+ }),
196
+ ],
197
+ },
198
+ });
199
+ });
200
+
201
+ it('runs declared regeneration and clears a generated-file block after reevaluation', () => {
202
+ seed({hook: true});
203
+
204
+ const applied = run([...ARGS, '--apply']);
205
+
206
+ expect(applied.status, applied.stderr).toBe(0);
207
+ expect(applied.envelope).toMatchObject({
208
+ type: 'upgrade.run',
209
+ data: {
210
+ complete: true,
211
+ modifiedFiles: ['src/owned.tsx', 'generated/panel.tsx'],
212
+ protectedFiles: [],
213
+ declinedCandidates: [],
214
+ },
215
+ });
216
+ expect(fs.readFileSync(path.join(root, 'src/owned.tsx'), 'utf8')).toContain(
217
+ 'minSize: 200',
218
+ );
219
+ expect(
220
+ fs.readFileSync(path.join(root, 'generated/panel.tsx'), 'utf8'),
221
+ ).toContain('minSize: 200');
222
+
223
+ const second = run([...ARGS, '--apply']);
224
+ expect(second.status, second.stderr).toBe(0);
225
+ expect(second.envelope.data.complete).toBe(true);
226
+ expect(second.envelope.data.filesChanged).toBe(0);
227
+ });
228
+ });
@@ -65,6 +65,9 @@ export function registerUpgrade(program) {
65
65
  ? result.data.registryCompositions
66
66
  : undefined;
67
67
  if (registrySummary && !registrySummary.ok) process.exitCode = 1;
68
+ if (result.type === 'upgrade.run' && result.data.complete === false) {
69
+ process.exitCode = 1;
70
+ }
68
71
 
69
72
  // `--list` is the one lookup here: which migrations exist for the
70
73
  // range. Everything else migrates the project — an effect, reported by