@astryxdesign/cli 0.6.5 → 0.6.6-canary.11a80dd

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 (464) hide show
  1. package/CHANGELOG.md +87 -0
  2. package/README.md +91 -88
  3. package/api/build/_adapter.d.mts +70 -2
  4. package/api/build/_adapter.mjs +122 -10
  5. package/api/build/build.doc.mjs +3 -3
  6. package/api/build/build.test.mjs +111 -2
  7. package/api/build/build.type.d.mts +12 -0
  8. package/api/build/build.type.mjs +3 -0
  9. package/api/build/help/help.mjs +1 -1
  10. package/api/build/kit/kit.mjs +110 -22
  11. package/api/build/kit/rank.d.mts +32 -8
  12. package/api/build/kit/rank.mjs +291 -97
  13. package/api/build/kit/rank.test.mjs +231 -48
  14. package/api/build/kit/weights.d.mts +82 -0
  15. package/api/build/kit/weights.json +1 -0
  16. package/api/build/kit/weights.mjs +305 -0
  17. package/api/build/kit/weights.test.mjs +190 -0
  18. package/api/component/_adapter.d.mts +19 -0
  19. package/api/component/_adapter.mjs +33 -0
  20. package/api/component/component-replacement.test.mjs +603 -0
  21. package/api/component/component.mjs +49 -15
  22. package/api/component/component.test.mjs +32 -0
  23. package/api/component/component.type.d.mts +33 -3
  24. package/api/component/component.type.mjs +10 -3
  25. package/api/component/detail/blocks/blocks.d.mts +2 -1
  26. package/api/component/detail/blocks/blocks.mjs +5 -2
  27. package/api/component/detail/detail.mjs +5 -1
  28. package/api/component/detail/props/props.d.mts +2 -1
  29. package/api/component/detail/props/props.mjs +3 -2
  30. package/api/component/detail/showcase/showcase.d.mts +3 -1
  31. package/api/component/detail/showcase/showcase.mjs +3 -1
  32. package/api/component/detail/source/source.d.mts +3 -2
  33. package/api/component/detail/source/source.mjs +7 -3
  34. package/api/component/list/list.mjs +128 -10
  35. package/api/docs/_adapter.d.mts +11 -0
  36. package/api/docs/_adapter.mjs +25 -0
  37. package/api/docs/detail/detail.mjs +19 -3
  38. package/api/docs/detail/section/section.mjs +7 -1
  39. package/api/docs/docOverlays.test.mjs +10 -6
  40. package/api/docs/docs.d.mts +6 -0
  41. package/api/docs/docs.depth.test.mjs +134 -0
  42. package/api/docs/docs.doc.mjs +31 -2
  43. package/api/docs/docs.mjs +46 -1
  44. package/api/docs/docs.test.mjs +279 -0
  45. package/api/docs/docs.type.d.mts +81 -4
  46. package/api/docs/docs.type.mjs +41 -4
  47. package/api/docs/index/index.mjs +11 -2
  48. package/api/docs/index/index.test.mjs +7 -2
  49. package/api/docs/integration-tree.test.mjs +572 -0
  50. package/api/docs/integrationDocs.test.mjs +337 -0
  51. package/api/docs/node/node.d.mts +28 -3
  52. package/api/docs/node/node.mjs +149 -23
  53. package/api/doctor/_adapter.d.mts +50 -0
  54. package/api/doctor/_adapter.mjs +190 -0
  55. package/api/doctor/doctor.d.mts +0 -10
  56. package/api/doctor/doctor.doc.mjs +1 -3
  57. package/api/doctor/doctor.mjs +8 -123
  58. package/api/doctor/theme-checks.d.mts +24 -0
  59. package/api/doctor/theme-checks.mjs +1231 -0
  60. package/api/doctor/theme-checks.test.mjs +667 -0
  61. package/api/error.d.mts +22 -0
  62. package/api/error.mjs +42 -0
  63. package/api/gap-report/gap-report.d.mts +3 -1
  64. package/api/gap-report/gap-report.mjs +27 -3
  65. package/api/gap-report/gap-report.test.mjs +106 -0
  66. package/api/hook/_adapter.d.mts +1 -0
  67. package/api/hook/_adapter.mjs +3 -0
  68. package/api/hook/detail/detail.mjs +2 -2
  69. package/api/hook/detail/params/params.mjs +2 -2
  70. package/api/hook/hook.type.d.mts +12 -0
  71. package/api/hook/hook.type.mjs +3 -0
  72. package/api/hook/list/list.d.mts +1 -1
  73. package/api/hook/list/list.mjs +8 -8
  74. package/api/index.d.mts +1 -1
  75. package/api/index.mjs +4 -0
  76. package/api/init/run/run.d.mts +3 -5
  77. package/api/init/run/run.mjs +11 -11
  78. package/api/integration/__fixtures__/released-0.6.5-ocean.d.mts +14 -0
  79. package/api/integration/__fixtures__/released-0.6.5-ocean.mjs +15 -0
  80. package/api/integration/add-contribution.d.mts +2 -1
  81. package/api/integration/add-contribution.mjs +7 -3
  82. package/api/integration/add-contribution.test.mjs +3 -3
  83. package/api/integration/add-helpers.d.mts +26 -5
  84. package/api/integration/add-helpers.mjs +50 -5
  85. package/api/integration/add-theme.mjs +354 -28
  86. package/api/integration/add-theme.test.mjs +380 -16
  87. package/api/integration/authoring-checks.mjs +31 -8
  88. package/api/integration/authoring-checks.type.d.mts +8 -0
  89. package/api/integration/authoring-checks.type.mjs +7 -3
  90. package/api/integration/integration-authoring.type.d.mts +4 -1
  91. package/api/integration/integration-authoring.type.mjs +6 -1
  92. package/api/integration/integrationAdd.doc.mjs +6 -0
  93. package/api/integration/integrationAddTheme.doc.mjs +10 -0
  94. package/api/integration/integrationComponentConflicts.doc.mjs +6 -3
  95. package/api/integration/integrationDocConflicts.doc.mjs +1 -1
  96. package/api/integration/integrationTemplateConflicts.doc.mjs +1 -1
  97. package/api/integration/pack-check.component-replaces.test.mjs +126 -0
  98. package/api/integration/pack-check.d.mts +10 -0
  99. package/api/integration/pack-check.lifecycle-output.test.mjs +21 -2
  100. package/api/integration/pack-check.mjs +495 -4
  101. package/api/integration/pack-check.test.mjs +619 -10
  102. package/api/integration/validate-integration.d.mts +4 -2
  103. package/api/integration/validate-integration.mjs +7 -2
  104. package/api/integration/validate-integration.test.mjs +55 -0
  105. package/api/integration/validate-integration.type.d.mts +5 -0
  106. package/api/integration/validate-integration.type.mjs +5 -1
  107. package/api/integration/validateIntegration.doc.mjs +1 -1
  108. package/api/layout/check/check.d.mts +1 -0
  109. package/api/layout/check/check.mjs +1 -0
  110. package/api/layout/expand/expand.d.mts +1 -0
  111. package/api/layout/expand/expand.mjs +13 -7
  112. package/api/layout/expand/expand.receipt.test.mjs +74 -0
  113. package/api/layout/grammar/grammar.d.mts +1 -0
  114. package/api/layout/grammar/grammar.mjs +1 -0
  115. package/api/layout/layout.type.d.mts +1 -0
  116. package/api/layout/layout.type.mjs +1 -0
  117. package/api/layout/layoutCheck.doc.mjs +1 -1
  118. package/api/layout/layoutExpand.doc.mjs +2 -2
  119. package/api/layout/layoutGrammar.doc.mjs +1 -1
  120. package/api/search/search.d.mts +39 -8
  121. package/api/search/search.doc.mjs +4 -4
  122. package/api/search/search.mjs +248 -66
  123. package/api/search/search.test.mjs +829 -0
  124. package/api/search/search.type.d.mts +6 -6
  125. package/api/search/search.type.mjs +5 -5
  126. package/api/swizzle/_adapter.d.mts +10 -0
  127. package/api/swizzle/_adapter.mjs +23 -0
  128. package/api/swizzle/copy/copy.d.mts +5 -6
  129. package/api/swizzle/copy/copy.mjs +95 -13
  130. package/api/swizzle/list/list.mjs +2 -2
  131. package/api/swizzle/swizzle.doc.mjs +4 -0
  132. package/api/swizzle/swizzle.test.mjs +55 -5
  133. package/api/swizzle/swizzle.type.d.mts +8 -0
  134. package/api/swizzle/swizzle.type.mjs +2 -0
  135. package/api/template/copy/copy.mjs +27 -8
  136. package/api/template/copy/copy.receipt.test.mjs +77 -0
  137. package/api/template/show/show.mjs +17 -4
  138. package/api/template/show/show.test.mjs +76 -0
  139. package/api/template/skeleton/skeleton.mjs +2 -1
  140. package/api/template/template-integration.test.mjs +14 -0
  141. package/api/template/template.d.mts +1 -1
  142. package/api/template/template.doc.mjs +6 -2
  143. package/api/template/template.mjs +2 -0
  144. package/api/template/template.type.d.mts +17 -0
  145. package/api/template/template.type.mjs +8 -0
  146. package/api/theme/_adapter.d.mts +106 -6
  147. package/api/theme/_adapter.mjs +687 -18
  148. package/api/theme/add/add.binary.test.mjs +76 -3
  149. package/api/theme/add/add.d.mts +5 -9
  150. package/api/theme/add/add.mjs +87 -64
  151. package/api/theme/add/add.rollback.test.mjs +9 -9
  152. package/api/theme/add/add.staging.test.mjs +9 -9
  153. package/api/theme/add/add.test.mjs +461 -55
  154. package/api/theme/add/add.types.test.mjs +151 -0
  155. package/api/theme/build/build.d.mts +120 -2
  156. package/api/theme/build/build.family.test.mjs +13 -4
  157. package/api/theme/build/build.icon-lineage.test.mjs +117 -0
  158. package/api/theme/build/build.icon-preservation.test.mjs +639 -0
  159. package/api/theme/build/build.mjs +667 -195
  160. package/api/theme/build/build.project-core.test.mjs +165 -0
  161. package/api/theme/build/build.test.mjs +220 -1
  162. package/api/theme/build/font-warning.d.mts +11 -0
  163. package/api/theme/build/font-warning.mjs +28 -3
  164. package/api/theme/build/icon-imports.d.mts +47 -0
  165. package/api/theme/build/icon-imports.mjs +691 -0
  166. package/api/theme/eject/eject.binary.test.mjs +90 -0
  167. package/api/theme/eject/eject.d.mts +17 -0
  168. package/api/theme/eject/eject.mjs +65 -0
  169. package/api/theme/eject/eject.rollback.test.mjs +158 -0
  170. package/api/theme/eject/eject.staging.test.mjs +83 -0
  171. package/api/theme/eject/eject.test.mjs +160 -0
  172. package/api/theme/integration-themes.test.mjs +30 -6
  173. package/api/theme/list/list.d.mts +10 -0
  174. package/api/theme/list/list.mjs +75 -7
  175. package/api/theme/list/list.test.mjs +155 -4
  176. package/api/theme/remove/remove.d.mts +12 -0
  177. package/api/theme/remove/remove.mjs +15 -0
  178. package/api/theme/remove/remove.test.mjs +94 -0
  179. package/api/theme/template/template.mjs +3 -4
  180. package/api/theme/theme.d.mts +5 -2
  181. package/api/theme/theme.mjs +13 -8
  182. package/api/theme/theme.type.d.mts +106 -2
  183. package/api/theme/theme.type.mjs +54 -5
  184. package/api/theme/themeAdd.doc.d.mts +1 -3
  185. package/api/theme/themeAdd.doc.mjs +35 -22
  186. package/api/theme/themeBuild.doc.d.mts +4 -1
  187. package/api/theme/themeBuild.doc.mjs +15 -4
  188. package/api/theme/themeEject.doc.d.mts +8 -0
  189. package/api/theme/themeEject.doc.mjs +89 -0
  190. package/api/theme/themeListAvailable.doc.mjs +4 -4
  191. package/api/theme/themeListCopySources.doc.d.mts +8 -0
  192. package/api/theme/themeListCopySources.doc.mjs +60 -0
  193. package/api/theme/themeRemove.doc.d.mts +6 -0
  194. package/api/theme/themeRemove.doc.mjs +50 -0
  195. package/api/theme/themeTemplate.doc.mjs +4 -3
  196. package/api/theme/themeUse.doc.d.mts +6 -0
  197. package/api/theme/themeUse.doc.mjs +47 -0
  198. package/api/theme/use/use.d.mts +12 -0
  199. package/api/theme/use/use.mjs +15 -0
  200. package/api/theme/use/use.test.mjs +98 -0
  201. package/api/upgrade/_adapter.d.mts +1 -0
  202. package/api/upgrade/_adapter.mjs +3 -0
  203. package/api/upgrade/list/list.mjs +9 -3
  204. package/api/upgrade/run/run.mjs +20 -3
  205. package/api/upgrade/run/run.test.mjs +45 -1
  206. package/api/upgrade/upgrade.doc.mjs +1 -1
  207. package/api/upgrade/upgrade.type.d.mts +5 -0
  208. package/api/upgrade/upgrade.type.mjs +2 -0
  209. package/assets/codemods/integration-discovery.mjs +1 -1
  210. package/assets/codemods/integration-discovery.test.mjs +64 -0
  211. package/assets/codemods/transforms/next/__tests__/migrate-copied-themes-to-descriptors.test.mjs +129 -0
  212. package/assets/codemods/transforms/next/index.mjs +14 -1
  213. package/assets/codemods/transforms/next/migrate-copied-themes-to-descriptors.mjs +54 -0
  214. package/assets/docs/author-a-theme.doc.mjs +166 -0
  215. package/assets/docs/getting-started.doc.mjs +59 -15
  216. package/assets/docs/icons.doc.mjs +1 -0
  217. package/assets/docs/principles.doc.dense.mjs +2 -2
  218. package/assets/docs/principles.doc.mjs +2 -2
  219. package/assets/docs/principles.doc.zh.mjs +2 -2
  220. package/assets/docs/styling-libraries.doc.mjs +1 -1
  221. package/assets/docs/styling-overview.doc.mjs +211 -0
  222. package/assets/docs/styling.doc.mjs +2 -2
  223. package/assets/docs/theme.doc.dense.mjs +10 -198
  224. package/assets/docs/theme.doc.mjs +13 -770
  225. package/assets/docs/theme.doc.zh.mjs +31 -12
  226. package/assets/docs/tokens.doc.mjs +4 -4
  227. package/assets/docs/tree/add-a-theme.doc.mjs +6 -2
  228. package/assets/docs/tree/add-a-topic.doc.mjs +1 -1
  229. package/assets/docs/tree/check-your-docs.doc.mjs +2 -2
  230. package/assets/docs/tree/checks.doc.mjs +6 -5
  231. package/assets/docs/tree/debug-and-gap-reports.doc.mjs +1 -1
  232. package/assets/docs/tree/define-the-theme.doc.mjs +2 -2
  233. package/assets/docs/tree/document-the-theme.doc.mjs +4 -4
  234. package/assets/docs/tree/fonts-and-assets.doc.mjs +25 -20
  235. package/assets/docs/tree/headers-and-footers.doc.mjs +68 -0
  236. package/assets/docs/tree/layout-spacing.doc.mjs +168 -0
  237. package/assets/docs/tree/layout.doc.mjs +52 -0
  238. package/assets/docs/tree/replace-a-core-component.doc.mjs +21 -4
  239. package/assets/docs/tree/responsive.doc.mjs +102 -0
  240. package/assets/docs/tree/scaffold.doc.mjs +145 -0
  241. package/assets/docs/tree/sections-and-placement.doc.mjs +1 -1
  242. package/assets/docs/tree/side-panels.doc.mjs +82 -0
  243. package/assets/docs/tree/structure.doc.mjs +144 -0
  244. package/assets/docs/tree/template-doc-overview.doc.mjs +13 -1
  245. package/assets/docs/tree/themes.doc.mjs +2 -2
  246. package/assets/docs/tree/troubleshooting.doc.mjs +13 -5
  247. package/assets/docs/tree/use-a-theme-in-an-app.doc.mjs +22 -5
  248. package/assets/docs/tree/versioning.doc.mjs +11 -7
  249. package/assets/docs/use-a-theme.doc.mjs +212 -0
  250. package/assets/templates/blocks/components/DropdownMenuGroup/DropdownMenuGroupShowcase.doc.mjs +15 -0
  251. package/assets/templates/blocks/components/DropdownMenuGroup/DropdownMenuGroupShowcase.tsx +38 -0
  252. package/assets/templates/blocks/components/DropdownMenuGroup/DropdownMenuGroupWithSelectable.doc.mjs +20 -0
  253. package/assets/templates/blocks/components/DropdownMenuGroup/DropdownMenuGroupWithSelectable.tsx +48 -0
  254. package/assets/templates/pages/ai-chat/template.doc.mjs +16 -1
  255. package/assets/templates/pages/ai-chat-landing/template.doc.mjs +9 -1
  256. package/assets/templates/pages/blank/template.doc.mjs +3 -1
  257. package/assets/templates/pages/canvas-editor/template.doc.mjs +9 -1
  258. package/assets/templates/pages/centered-hero/template.doc.mjs +3 -1
  259. package/assets/templates/pages/checkout-wizard/template.doc.mjs +1 -0
  260. package/assets/templates/pages/classic-gallery/template.doc.mjs +3 -1
  261. package/assets/templates/pages/contact-form/template.doc.mjs +16 -1
  262. package/assets/templates/pages/dashboard/template.doc.mjs +15 -1
  263. package/assets/templates/pages/dashboard-alert-rail/template.doc.mjs +23 -1
  264. package/assets/templates/pages/dashboard-cohort-funnel/template.doc.mjs +10 -1
  265. package/assets/templates/pages/dashboard-comparison/template.doc.mjs +9 -1
  266. package/assets/templates/pages/dashboard-composition/template.doc.mjs +10 -1
  267. package/assets/templates/pages/dashboard-progress/template.doc.mjs +17 -1
  268. package/assets/templates/pages/dashboard-scorecard/template.doc.mjs +2 -1
  269. package/assets/templates/pages/detail-page/template.doc.mjs +8 -0
  270. package/assets/templates/pages/documentation/template.doc.mjs +10 -1
  271. package/assets/templates/pages/documentation-design/template.doc.mjs +10 -1
  272. package/assets/templates/pages/documentation-technical/template.doc.mjs +10 -1
  273. package/assets/templates/pages/editor/template.doc.mjs +9 -1
  274. package/assets/templates/pages/file-explorer/template.doc.mjs +3 -1
  275. package/assets/templates/pages/form-two-column/template.doc.mjs +17 -1
  276. package/assets/templates/pages/form-wizard/template.doc.mjs +14 -1
  277. package/assets/templates/pages/form-wizard-dialog/template.doc.mjs +1 -0
  278. package/assets/templates/pages/gallery-hero/template.doc.mjs +10 -1
  279. package/assets/templates/pages/ide/template.doc.mjs +9 -1
  280. package/assets/templates/pages/incident-console/page.tsx +1 -1
  281. package/assets/templates/pages/incident-console/template.doc.mjs +10 -1
  282. package/assets/templates/pages/kanban-board/template.doc.mjs +11 -1
  283. package/assets/templates/pages/library/template.doc.mjs +15 -1
  284. package/assets/templates/pages/login/template.doc.mjs +10 -1
  285. package/assets/templates/pages/login-card/template.doc.mjs +11 -1
  286. package/assets/templates/pages/login-split/template.doc.mjs +10 -1
  287. package/assets/templates/pages/login-sso/template.doc.mjs +10 -1
  288. package/assets/templates/pages/messaging-shell/template.doc.mjs +11 -1
  289. package/assets/templates/pages/mixed-gallery/template.doc.mjs +10 -1
  290. package/assets/templates/pages/payment-form/template.doc.mjs +3 -1
  291. package/assets/templates/pages/product-detail/template.doc.mjs +9 -1
  292. package/assets/templates/pages/product-gallery/template.doc.mjs +10 -1
  293. package/assets/templates/pages/settings/template.doc.mjs +3 -1
  294. package/assets/templates/pages/settings-dialog/template.doc.mjs +9 -1
  295. package/assets/templates/pages/settings-sidebar/template.doc.mjs +9 -1
  296. package/assets/templates/pages/shell-nav/template.doc.mjs +10 -1
  297. package/assets/templates/pages/shell-side-nav/template.doc.mjs +14 -1
  298. package/assets/templates/pages/shell-top-nav/template.doc.mjs +11 -1
  299. package/assets/templates/pages/side-gallery/template.doc.mjs +3 -1
  300. package/assets/templates/pages/table/template.doc.mjs +11 -1
  301. package/assets/templates/pages/table-collapsible/page.tsx +1474 -0
  302. package/assets/templates/pages/table-collapsible/template.doc.mjs +12 -0
  303. package/assets/templates/pages/table-comparison/page.tsx +1449 -0
  304. package/assets/templates/pages/table-comparison/template.doc.mjs +12 -0
  305. package/assets/templates/pages/table-filter/template.doc.mjs +21 -1
  306. package/assets/templates/pages/table-grouped/template.doc.mjs +15 -1
  307. package/assets/templates/pages/table-inbox/template.doc.mjs +18 -6
  308. package/assets/templates/pages/table-page/template.doc.mjs +20 -1
  309. package/assets/templates/pages/table-tree/template.doc.mjs +14 -1
  310. package/assets/templates/pages/theme-showcase/template.doc.mjs +10 -1
  311. package/assets/templates/pages/work-item-detail/template.doc.mjs +10 -0
  312. package/assets/templates/themes/butter/icons.tsx +2 -0
  313. package/assets/templates/themes/chocolate/icons.tsx +2 -0
  314. package/assets/templates/themes/gothic/icons.tsx +2 -0
  315. package/assets/templates/themes/matcha/icons.tsx +2 -0
  316. package/assets/templates/themes/neutral/icons.tsx +2 -0
  317. package/assets/templates/themes/stone/icons.tsx +2 -0
  318. package/assets/templates/themes/y2k/icons.tsx +2 -0
  319. package/authoring/doctypes/command/command.doc.mjs +5 -0
  320. package/authoring/doctypes/command/type.ts +2 -0
  321. package/authoring/doctypes/component/component.doc.mjs +1 -1
  322. package/authoring/doctypes/component/type.ts +8 -4
  323. package/authoring/doctypes/template/parse.d.mts +2 -0
  324. package/authoring/doctypes/template/parse.mjs +1 -0
  325. package/authoring/doctypes/template/parse.test.mjs +21 -0
  326. package/authoring/doctypes/template/template.doc.mjs +6 -0
  327. package/authoring/doctypes/template/type.ts +11 -0
  328. package/authoring/integration/integration.doc.mjs +1 -1
  329. package/clients/cli/commands/blog.mjs +3 -3
  330. package/clients/cli/commands/build-theme.adaptations.test.mjs +1 -1
  331. package/clients/cli/commands/build-theme.ascii-output.test.mjs +11 -1
  332. package/clients/cli/commands/build-theme.batch-report.test.mjs +335 -0
  333. package/clients/cli/commands/build-theme.font-warning.test.mjs +36 -7
  334. package/clients/cli/commands/build-theme.import-path.test.mjs +3 -3
  335. package/clients/cli/commands/build-theme.mjs +346 -47
  336. package/clients/cli/commands/build-theme.watch.test.mjs +33 -0
  337. package/clients/cli/commands/build.mjs +8 -6
  338. package/clients/cli/commands/build.text-fields.test.mjs +1 -1
  339. package/clients/cli/commands/component/index.mjs +88 -12
  340. package/clients/cli/commands/component-replacement.text.test.mjs +271 -0
  341. package/clients/cli/commands/component.doc.mjs +9 -2
  342. package/clients/cli/commands/discover.mjs +29 -1
  343. package/clients/cli/commands/discover.no-source.test.mjs +75 -0
  344. package/clients/cli/commands/docs.depth.test.mjs +219 -0
  345. package/clients/cli/commands/docs.doc.mjs +15 -2
  346. package/clients/cli/commands/docs.mjs +273 -16
  347. package/clients/cli/commands/docs.test.mjs +383 -0
  348. package/clients/cli/commands/doctor-integration-components.doc.mjs +15 -4
  349. package/clients/cli/commands/doctor.doc.mjs +1 -1
  350. package/clients/cli/commands/doctor.mjs +4 -4
  351. package/clients/cli/commands/doctor.test.mjs +26 -52
  352. package/clients/cli/commands/gap-report.doc.mjs +2 -2
  353. package/clients/cli/commands/gap-report.mjs +12 -0
  354. package/clients/cli/commands/gap-report.test.mjs +63 -0
  355. package/clients/cli/commands/hook/index.mjs +7 -2
  356. package/clients/cli/commands/import-hint-correctness.test.mjs +28 -5
  357. package/clients/cli/commands/init.next-steps.test.mjs +18 -23
  358. package/clients/cli/commands/integration-add.doc.mjs +10 -0
  359. package/clients/cli/commands/integration-authoring.test.mjs +12 -2
  360. package/clients/cli/commands/integration-real-world.test.mjs +61 -12
  361. package/clients/cli/commands/integration.mjs +3 -1
  362. package/clients/cli/commands/layout-check.doc.mjs +2 -0
  363. package/clients/cli/commands/layout-expand.doc.mjs +5 -1
  364. package/clients/cli/commands/layout-grammar.doc.mjs +2 -0
  365. package/clients/cli/commands/layout.deprecation-lifecycle.test.mjs +140 -0
  366. package/clients/cli/commands/layout.doc.mjs +2 -0
  367. package/clients/cli/commands/layout.expand-receipt.test.mjs +94 -0
  368. package/clients/cli/commands/layout.mjs +56 -4
  369. package/clients/cli/commands/no-prompt-wording.test.mjs +4 -4
  370. package/clients/cli/commands/search.doc.mjs +5 -4
  371. package/clients/cli/commands/search.mjs +30 -6
  372. package/clients/cli/commands/search.test.mjs +69 -19
  373. package/clients/cli/commands/swizzle.doc.mjs +12 -3
  374. package/clients/cli/commands/swizzle.mjs +2 -1
  375. package/clients/cli/commands/swizzle.routing.test.mjs +2 -1
  376. package/clients/cli/commands/template.copy-receipt.test.mjs +60 -0
  377. package/clients/cli/commands/template.mjs +71 -6
  378. package/clients/cli/commands/template.show-media.test.mjs +62 -0
  379. package/clients/cli/commands/text-json-parity.test.mjs +40 -0
  380. package/clients/cli/commands/theme-add-lifecycle.test.mjs +135 -0
  381. package/clients/cli/commands/theme-add.doc.mjs +19 -19
  382. package/clients/cli/commands/theme-build.doc.mjs +3 -1
  383. package/clients/cli/commands/theme-eject.doc.mjs +47 -0
  384. package/clients/cli/commands/theme-list.behavior.test.mjs +44 -0
  385. package/clients/cli/commands/theme-list.doc.mjs +2 -2
  386. package/clients/cli/commands/theme-palette-generate.doc.mjs +1 -2
  387. package/clients/cli/commands/theme-remove.doc.mjs +22 -0
  388. package/clients/cli/commands/theme-template.doc.mjs +4 -3
  389. package/clients/cli/commands/theme-use.doc.mjs +22 -0
  390. package/clients/cli/commands/theme.doc.mjs +21 -16
  391. package/clients/cli/commands/upgrade.ascii-output.test.mjs +14 -0
  392. package/clients/cli/commands/upgrade.config-ordering.test.mjs +2 -1
  393. package/clients/cli/commands/upgrade.mjs +1 -1
  394. package/clients/cli/commands/write-failure.test.mjs +175 -0
  395. package/clients/cli/index.mjs +5 -2
  396. package/clients/cli/lib/component-format.mjs +19 -2
  397. package/clients/cli/lib/component-format.test.mjs +1 -1
  398. package/clients/cli/lib/define-command.mjs +4 -0
  399. package/clients/cli/lib/manifest.mjs +44 -165
  400. package/clients/cli/lib/manifest.test.mjs +98 -7
  401. package/clients/cli/lib/resolve-theme.mjs +80 -78
  402. package/clients/cli/lib/resolve-theme.test.mjs +523 -27
  403. package/foundation/agent-docs/agent-docs.mjs +34 -28
  404. package/foundation/agent-docs/agent-docs.test.mjs +1181 -0
  405. package/foundation/agent-docs/app-theme-workflow.test.mjs +13 -0
  406. package/foundation/config/project.d.mts +20 -5
  407. package/foundation/config/project.mjs +43 -6
  408. package/foundation/config/theme-private-vars.d.mts +12 -0
  409. package/foundation/config/theme-private-vars.mjs +107 -0
  410. package/foundation/config/theme-private-vars.test.mjs +55 -0
  411. package/foundation/config/theme-state.d.mts +145 -0
  412. package/foundation/config/theme-state.mjs +417 -0
  413. package/foundation/config/theme-state.test.mjs +182 -0
  414. package/foundation/discovery/component-discovery.d.mts +5 -2
  415. package/foundation/discovery/component-discovery.mjs +12 -6
  416. package/foundation/discovery/component-replacement.d.mts +91 -0
  417. package/foundation/discovery/component-replacement.mjs +417 -0
  418. package/foundation/discovery/component-replacement.test.mjs +480 -0
  419. package/foundation/discovery/docs-output-budget.d.mts +6 -2
  420. package/foundation/discovery/docs-output-budget.mjs +2 -1
  421. package/foundation/discovery/docs-section-key.d.mts +4 -2
  422. package/foundation/discovery/docs-section-key.mjs +1 -1
  423. package/foundation/discovery/module-exports.d.mts +10 -0
  424. package/foundation/discovery/module-exports.mjs +146 -0
  425. package/foundation/discovery/package-exports.d.mts +29 -0
  426. package/foundation/discovery/package-exports.mjs +200 -0
  427. package/foundation/discovery/template-adapter.d.mts +14 -0
  428. package/foundation/discovery/template-adapter.fixture-refs.test.mjs +37 -1
  429. package/foundation/discovery/template-adapter.mjs +21 -1
  430. package/foundation/discovery/template-needs.d.mts +31 -0
  431. package/foundation/discovery/template-needs.mjs +156 -0
  432. package/foundation/discovery/template-needs.test.mjs +203 -0
  433. package/foundation/discovery/theme-discovery.d.mts +78 -5
  434. package/foundation/discovery/theme-discovery.mjs +143 -18
  435. package/foundation/discovery/theme-discovery.test.mjs +9 -3
  436. package/foundation/discovery/theme-imports.d.mts +15 -0
  437. package/foundation/discovery/theme-imports.mjs +217 -0
  438. package/foundation/discovery/theme-imports.test.mjs +173 -0
  439. package/foundation/doc-compiler/doc-loads.test.mjs +18 -8
  440. package/foundation/doc-compiler/inputs.mjs +2 -1
  441. package/foundation/doc-compiler/inputs.test.mjs +0 -1
  442. package/foundation/doc-compiler/lenses.d.mts +4 -2
  443. package/foundation/doc-compiler/lenses.mjs +1 -1
  444. package/foundation/doc-compiler/tree.test.mjs +649 -0
  445. package/foundation/env/package-manager.d.mts +28 -8
  446. package/foundation/env/package-manager.mjs +49 -10
  447. package/foundation/env/package-manager.test.mjs +93 -1
  448. package/foundation/fs/module-loader.d.mts +9 -0
  449. package/foundation/fs/module-loader.mjs +71 -2
  450. package/foundation/integrations/cli-requirement.d.mts +79 -13
  451. package/foundation/integrations/cli-requirement.mjs +115 -22
  452. package/foundation/integrations/cli-requirement.test.mjs +205 -8
  453. package/foundation/integrations/contribution-inventory.mjs +3 -3
  454. package/foundation/response/base.d.ts +9 -3
  455. package/foundation/response/json.d.mts +7 -4
  456. package/foundation/response/json.mjs +10 -6
  457. package/foundation/response/response-types.doc.d.mts +5 -5
  458. package/foundation/response/response-types.doc.mjs +52 -37
  459. package/foundation/response/response.doc.mjs +18 -4
  460. package/foundation/text/copyright-header.mjs +1 -1
  461. package/foundation/text/copyright-header.test.mjs +1 -1
  462. package/package.json +9 -9
  463. package/assets/docs/layout.doc.dense.mjs +0 -388
  464. package/assets/docs/layout.doc.mjs +0 -550
@@ -0,0 +1,667 @@
1
+ // Copyright (c) Meta Platforms, Inc. and affiliates.
2
+
3
+ /** @file Fault-injection coverage for all ten app-theme doctor checks. */
4
+
5
+ import {afterEach, describe, expect, it} from 'vitest';
6
+ import * as fs from 'node:fs';
7
+ import * as path from 'node:path';
8
+ import {spawnSync} from 'node:child_process';
9
+ import {checkAppThemes, checkThemes} from './theme-checks.mjs';
10
+ import {runChecks} from './doctor.mjs';
11
+ import {themeAdd} from '../theme/add/add.mjs';
12
+ import {themeEject} from '../theme/eject/eject.mjs';
13
+ import {themeBuild} from '../theme/build/build.mjs';
14
+ import {parseThemeModuleRecord} from '../../foundation/config/theme-state.mjs';
15
+
16
+ /** @type {string[]} */
17
+ const dirs = [];
18
+ const REPO_ROOT = path.resolve(import.meta.dirname, '../../../..');
19
+
20
+ /** @param {string} file @param {string} content */
21
+ function write(file, content) {
22
+ fs.mkdirSync(path.dirname(file), {recursive: true});
23
+ fs.writeFileSync(file, content);
24
+ }
25
+
26
+ /**
27
+ * @param {Array<{slug: string, css?: string, fontFamily?: string, fontCss?: string}>} themeSpecs
28
+ * @param {{peerRange?: string, importModule?: boolean}} [options]
29
+ */
30
+ async function fixture(themeSpecs = [{slug: 'ocean'}], options = {}) {
31
+ const dir = fs.mkdtempSync(
32
+ path.join(process.cwd(), '.astryx-doctor-themes-'),
33
+ );
34
+ dirs.push(dir);
35
+ fs.mkdirSync(path.join(dir, 'src'), {recursive: true});
36
+ write(path.join(dir, 'tsconfig.json'), '{}\n');
37
+ write(
38
+ path.join(dir, 'package.json'),
39
+ JSON.stringify({
40
+ name: 'doctor-app',
41
+ private: true,
42
+ dependencies: {
43
+ '@acme/themes': '1.0.0',
44
+ '@astryxdesign/core': '1.0.0',
45
+ },
46
+ }),
47
+ );
48
+ write(
49
+ path.join(dir, 'node_modules/@astryxdesign/core/package.json'),
50
+ JSON.stringify({name: '@astryxdesign/core', version: '1.0.0'}),
51
+ );
52
+
53
+ const packageDir = path.join(dir, 'node_modules/@acme/themes');
54
+ const exportsMap = {};
55
+ for (const spec of themeSpecs) {
56
+ exportsMap[`./themes/${spec.slug}`] = `./dist/${spec.slug}.js`;
57
+ exportsMap[`./themes/${spec.slug}.css`] = `./dist/${spec.slug}.css`;
58
+ if (spec.fontCss != null) {
59
+ exportsMap[`./themes/${spec.slug}.fonts.css`] =
60
+ `./dist/${spec.slug}.fonts.css`;
61
+ }
62
+ }
63
+ write(
64
+ path.join(packageDir, 'package.json'),
65
+ JSON.stringify({
66
+ name: '@acme/themes',
67
+ version: '1.0.0',
68
+ type: 'module',
69
+ peerDependencies: {
70
+ '@astryxdesign/core': options.peerRange ?? '^1.0.0',
71
+ },
72
+ exports: exportsMap,
73
+ }),
74
+ );
75
+ write(
76
+ path.join(packageDir, 'astryx.integration.mjs'),
77
+ "export default {themes: './themes'};\n",
78
+ );
79
+
80
+ for (const spec of themeSpecs) {
81
+ const exportName = `${spec.slug}Theme`;
82
+ const sourceDir = path.join(packageDir, 'themes', spec.slug);
83
+ const fontProperty = spec.fontFamily
84
+ ? `, fontFamily: ${JSON.stringify(spec.fontFamily)}`
85
+ : '';
86
+ write(
87
+ path.join(sourceDir, `${exportName}.doc.mjs`),
88
+ `/** @type {import('@astryxdesign/cli/authoring').ThemeDoc} */\nexport default {type: 'theme', name: '${spec.slug}', displayName: '${spec.slug}', description: '${spec.slug} theme.', maintained: true};\n`,
89
+ );
90
+ write(
91
+ path.join(sourceDir, `${exportName}.ts`),
92
+ `export const ${exportName} = {name: '${spec.slug}', tokens: {}${fontProperty}};\n`,
93
+ );
94
+ write(
95
+ path.join(packageDir, `dist/${spec.slug}.js`),
96
+ `export const ${exportName} = {name: '${spec.slug}', tokens: {}${fontProperty}};\n`,
97
+ );
98
+ write(
99
+ path.join(packageDir, `dist/${spec.slug}.css`),
100
+ spec.css ??
101
+ `[data-astryx-theme="${spec.slug}"] { --color-text: black; }\n`,
102
+ );
103
+ if (spec.fontCss != null) {
104
+ write(path.join(packageDir, `dist/${spec.slug}.fonts.css`), spec.fontCss);
105
+ }
106
+ await themeAdd(spec.slug, {
107
+ cwd: dir,
108
+ import: true,
109
+ package: '@acme/themes',
110
+ });
111
+ }
112
+
113
+ if (options.importModule !== false) {
114
+ write(
115
+ path.join(dir, 'src/index.tsx'),
116
+ "import {themes, defaultThemeSlug} from './astryx-themes';\nvoid themes[defaultThemeSlug];\n",
117
+ );
118
+ }
119
+ return {dir, packageDir, moduleFile: path.join(dir, 'src/astryx-themes.ts')};
120
+ }
121
+
122
+ /** @param {Awaited<ReturnType<typeof checkAppThemes>>} checks @param {string} id */
123
+ function check(checks, id) {
124
+ const result = checks.find(item => item.id === id);
125
+ if (!result) throw new Error(`Missing doctor check ${id}`);
126
+ return result;
127
+ }
128
+
129
+ /** @param {string} dir */
130
+ function runDoctor(dir) {
131
+ return spawnSync(
132
+ process.execPath,
133
+ [path.join(REPO_ROOT, 'packages/cli/clients/cli/bin/astryx.mjs'), 'doctor'],
134
+ {cwd: dir, encoding: 'utf-8', timeout: 30_000},
135
+ );
136
+ }
137
+
138
+ afterEach(() => {
139
+ while (dirs.length > 0) {
140
+ fs.rmSync(dirs.pop(), {recursive: true, force: true});
141
+ }
142
+ });
143
+
144
+ describe('the released themes check', () => {
145
+ /** @param {string} name */
146
+ function emptyApp(name) {
147
+ const dir = fs.mkdtempSync(
148
+ path.join(process.cwd(), `.astryx-doctor-${name}-`),
149
+ );
150
+ dirs.push(dir);
151
+ write(path.join(dir, 'package.json'), '{"name":"app","private":true}\n');
152
+ return dir;
153
+ }
154
+
155
+ /** @param {string} dir @param {string} slug */
156
+ function installThemePackage(dir, slug) {
157
+ write(
158
+ path.join(
159
+ dir,
160
+ 'node_modules/@astryxdesign',
161
+ `theme-${slug}`,
162
+ 'package.json',
163
+ ),
164
+ JSON.stringify({name: `@astryxdesign/theme-${slug}`, version: '1.0.0'}),
165
+ );
166
+ }
167
+
168
+ it('keeps its released id, label, fields, and statuses without a generated theme module', async () => {
169
+ const dir = emptyApp('themes-none');
170
+ expect(checkThemes(dir, await checkAppThemes(dir))).toEqual({
171
+ id: 'themes',
172
+ label: 'Theme packages',
173
+ status: 'warn',
174
+ message: 'No @astryxdesign/theme-* packages are installed.',
175
+ fix: expect.stringContaining('theme add neutral --import'),
176
+ });
177
+
178
+ installThemePackage(dir, 'neutral');
179
+ const unwired = checkThemes(dir, await checkAppThemes(dir));
180
+ expect(unwired).toEqual({
181
+ id: 'themes',
182
+ label: 'Theme packages',
183
+ status: 'warn',
184
+ message:
185
+ 'Theme package(s) installed (@astryxdesign/theme-neutral) but no theme appears wired.',
186
+ fix: expect.stringContaining('theme add <slug> --import'),
187
+ });
188
+ expect(unwired.fix).not.toContain('ASTRYX_THEME');
189
+
190
+ write(
191
+ path.join(dir, 'package.json'),
192
+ JSON.stringify({
193
+ name: 'app',
194
+ private: true,
195
+ astryx: {theme: '@astryxdesign/theme-neutral'},
196
+ }),
197
+ );
198
+ expect(checkThemes(dir, await checkAppThemes(dir))).toEqual({
199
+ id: 'themes',
200
+ label: 'Theme packages',
201
+ status: 'pass',
202
+ message:
203
+ 'Theme package(s) installed (@astryxdesign/theme-neutral); wired via package.json astryx.theme.',
204
+ });
205
+ });
206
+
207
+ it('reports the overall result of the app-theme checks with a generated module', async () => {
208
+ const healthy = await fixture();
209
+ expect(checkThemes(healthy.dir, await checkAppThemes(healthy.dir))).toEqual(
210
+ {
211
+ id: 'themes',
212
+ label: 'Theme packages',
213
+ status: 'pass',
214
+ message:
215
+ 'App themes come from the generated theme module, and every theme check passes.',
216
+ },
217
+ );
218
+
219
+ // A module is loaded once per process, so the broken one is a new fixture.
220
+ const {dir, packageDir} = await fixture();
221
+ write(
222
+ path.join(packageDir, 'dist/ocean.js'),
223
+ `import '@acme/definitely-missing-dep';\nexport const oceanTheme = {name: 'ocean', tokens: {}};\n`,
224
+ );
225
+ expect(checkThemes(dir, await checkAppThemes(dir))).toEqual({
226
+ id: 'themes',
227
+ label: 'Theme packages',
228
+ status: 'fail',
229
+ message: 'One theme check needs attention: theme-owners.',
230
+ fix: 'Follow the fix on the theme-owners check.',
231
+ });
232
+ }, 30_000);
233
+
234
+ it('passes the module rollup only when every summarized check passed', () => {
235
+ /** @param {string} id @param {'pass'|'warn'|'fail'|'info'} status */
236
+ const result = (id, status) => ({id, label: id, status, message: id});
237
+ const passing = [
238
+ result('theme-owners', 'pass'),
239
+ result('theme-module', 'pass'),
240
+ ];
241
+
242
+ expect(
243
+ checkThemes(process.cwd(), [
244
+ ...passing,
245
+ result('theme-stylesheet-imports', 'info'),
246
+ ]),
247
+ ).toEqual({
248
+ id: 'themes',
249
+ label: 'Theme packages',
250
+ status: 'info',
251
+ message:
252
+ 'One theme check could not prove its result: theme-stylesheet-imports.',
253
+ fix: 'See the theme-stylesheet-imports check.',
254
+ });
255
+ expect(
256
+ checkThemes(process.cwd(), [
257
+ result('theme-owners', 'fail'),
258
+ result('theme-module', 'pass'),
259
+ result('theme-fonts', 'warn'),
260
+ result('theme-global-rules', 'info'),
261
+ ]),
262
+ ).toMatchObject({
263
+ status: 'fail',
264
+ message: '2 theme checks need attention: theme-owners, theme-fonts.',
265
+ });
266
+ expect(checkThemes(process.cwd(), passing)).toMatchObject({
267
+ status: 'pass',
268
+ });
269
+ });
270
+
271
+ it('appears once in the doctor report, right after version alignment, with and without a module', async () => {
272
+ const {dir} = await fixture();
273
+ for (const cwd of [emptyApp('themes-report'), dir]) {
274
+ const ids = (await runChecks({cwd})).checks.map(item => item.id);
275
+ expect(ids.filter(id => id === 'themes')).toHaveLength(1);
276
+ expect(ids.indexOf('themes')).toBe(ids.indexOf('version-alignment') + 1);
277
+ expect(ids.indexOf('themes')).toBeLessThan(
278
+ ids.findIndex(id => id === 'theme-management' || id === 'theme-owners'),
279
+ );
280
+ }
281
+ }, 30_000);
282
+ });
283
+
284
+ describe('app-theme doctor checks', () => {
285
+ it('returns ten positive passes for a healthy package theme', async () => {
286
+ const {dir} = await fixture();
287
+ const checks = await checkAppThemes(dir);
288
+
289
+ expect(checks.map(item => item.id)).toEqual([
290
+ 'theme-owners',
291
+ 'theme-module',
292
+ 'theme-module-import',
293
+ 'theme-stylesheet-imports',
294
+ 'theme-local-builds',
295
+ 'theme-private-variables',
296
+ 'theme-core-peers',
297
+ 'theme-default',
298
+ 'theme-fonts',
299
+ 'theme-global-rules',
300
+ ]);
301
+ expect(checks.map(item => item.status)).toEqual(Array(10).fill('pass'));
302
+ expect(check(checks, 'theme-owners').message).toContain(
303
+ 'every built module loads',
304
+ );
305
+ });
306
+
307
+ it('fails theme-owners when a recorded module has a missing dependency', async () => {
308
+ const {dir, packageDir} = await fixture();
309
+ write(
310
+ path.join(packageDir, 'dist/ocean.js'),
311
+ `import '@acme/definitely-missing-dep';\nexport const oceanTheme = {name: 'ocean', tokens: {}};\n`,
312
+ );
313
+
314
+ const result = check(await checkAppThemes(dir), 'theme-owners');
315
+
316
+ expect(result).toMatchObject({id: 'theme-owners', status: 'fail'});
317
+ expect(result.message).toContain('Theme "ocean"');
318
+ expect(result.message).toContain('@acme/definitely-missing-dep');
319
+ expect(result.message).not.toMatch(/\n\s+at /u);
320
+ const cli = runDoctor(dir);
321
+ expect(cli.status).toBe(1);
322
+ expect(cli.stdout).not.toContain('No failures');
323
+ expect(cli.stdout).toContain('Theme owners and built imports');
324
+ expect(cli.stdout).toContain('@acme/definitely-missing-dep');
325
+ expect(cli.stderr).not.toMatch(/\n\s+at /u);
326
+ }, 30_000);
327
+
328
+ it('fails theme-owners when a recorded module is malformed', async () => {
329
+ const {dir, packageDir} = await fixture();
330
+ write(
331
+ path.join(packageDir, 'dist/ocean.js'),
332
+ 'export const oceanTheme = ;\n',
333
+ );
334
+
335
+ const result = check(await checkAppThemes(dir), 'theme-owners');
336
+
337
+ expect(result).toMatchObject({id: 'theme-owners', status: 'fail'});
338
+ expect(result.message).toContain('Theme "ocean"');
339
+ expect(result.message).toContain('does not export "oceanTheme"');
340
+ expect(result.message).not.toMatch(/\n\s+at /u);
341
+ });
342
+
343
+ it('fails theme-owners for an ambiguous multi-theme record', async () => {
344
+ const {dir, packageDir} = await fixture([{slug: 'ocean'}, {slug: 'reef'}]);
345
+ const packageFile = path.join(packageDir, 'package.json');
346
+ const pkg = JSON.parse(fs.readFileSync(packageFile, 'utf-8'));
347
+ delete pkg.exports['./themes/ocean'];
348
+ write(packageFile, JSON.stringify(pkg));
349
+
350
+ const result = check(await checkAppThemes(dir), 'theme-owners');
351
+
352
+ expect(result).toMatchObject({id: 'theme-owners', status: 'fail'});
353
+ expect(result.message).toContain('ocean');
354
+ expect(result.message).not.toMatch(/\n\s+at /u);
355
+ });
356
+
357
+ it.each([
358
+ 'theme-local-builds',
359
+ 'theme-private-variables',
360
+ 'theme-core-peers',
361
+ 'theme-fonts',
362
+ 'theme-global-rules',
363
+ ])('%s cannot pass when theme discovery throws', async id => {
364
+ const {dir} = await fixture();
365
+ write(
366
+ path.join(dir, 'astryx.config.mjs'),
367
+ "throw new Error('fixture discovery failure');\n",
368
+ );
369
+
370
+ expect(check(await checkAppThemes(dir), id)).toMatchObject({
371
+ status: 'info',
372
+ });
373
+ });
374
+
375
+ it('lets the static default check pass when discovery throws', async () => {
376
+ const {dir} = await fixture();
377
+ write(
378
+ path.join(dir, 'astryx.config.mjs'),
379
+ "throw new Error('fixture discovery failure');\n",
380
+ );
381
+
382
+ expect(check(await checkAppThemes(dir), 'theme-default')).toMatchObject({
383
+ status: 'pass',
384
+ });
385
+ });
386
+
387
+ it('check 1 fails when a recorded built stylesheet no longer resolves', async () => {
388
+ const {dir, packageDir} = await fixture();
389
+ fs.rmSync(path.join(packageDir, 'dist/ocean.css'));
390
+
391
+ expect(check(await checkAppThemes(dir), 'theme-owners')).toMatchObject({
392
+ status: 'fail',
393
+ fix: expect.stringContaining('theme add ocean --import'),
394
+ });
395
+ });
396
+
397
+ it('check 2 fails when the generated module is hand-edited', async () => {
398
+ const {dir, moduleFile} = await fixture();
399
+ fs.appendFileSync(moduleFile, '// hand edit\n');
400
+
401
+ expect(check(await checkAppThemes(dir), 'theme-module')).toMatchObject({
402
+ status: 'fail',
403
+ fix: expect.stringContaining('theme use ocean'),
404
+ });
405
+ });
406
+
407
+ it('check 3 warns when no project source imports the generated module', async () => {
408
+ const {dir} = await fixture([{slug: 'ocean'}], {importModule: false});
409
+
410
+ expect(
411
+ check(await checkAppThemes(dir), 'theme-module-import'),
412
+ ).toMatchObject({
413
+ status: 'warn',
414
+ fix: expect.stringContaining('themes[defaultThemeSlug]'),
415
+ });
416
+ });
417
+
418
+ it('check 4 fails when a built module import loses its stylesheet pair', async () => {
419
+ const {dir, moduleFile} = await fixture();
420
+ const source = fs
421
+ .readFileSync(moduleFile, 'utf-8')
422
+ .replace('import "@acme/themes/themes/ocean.css";\n', '');
423
+ fs.writeFileSync(moduleFile, source);
424
+
425
+ expect(
426
+ check(await checkAppThemes(dir), 'theme-stylesheet-imports'),
427
+ ).toMatchObject({
428
+ status: 'fail',
429
+ fix: expect.stringContaining('theme use ocean'),
430
+ });
431
+ });
432
+
433
+ it('check 5 fails when an added local theme cannot reproduce its outputs', async () => {
434
+ const {dir} = await fixture();
435
+ await themeEject('ocean', {cwd: dir, package: '@acme/themes'});
436
+ const localDir = path.join(dir, 'src/themes/ocean');
437
+ const sourceFile = path.join(localDir, 'oceanTheme.ts');
438
+ fs.writeFileSync(
439
+ sourceFile,
440
+ "const oceanTheme = {name: 'ocean', tokens: {'--color-bg': '#000'}};\nexport {oceanTheme};\nexport default oceanTheme;\n",
441
+ );
442
+ await themeBuild(sourceFile, {}, {cwd: dir});
443
+ await themeAdd('ocean', {cwd: dir, import: true});
444
+ expect(
445
+ parseThemeModuleRecord(
446
+ fs.readFileSync(path.join(dir, 'src/astryx-themes.ts'), 'utf-8'),
447
+ ),
448
+ ).toMatchObject({themes: {ocean: './src/themes'}});
449
+ fs.appendFileSync(path.join(localDir, 'ocean.css'), '\n.injected {}\n');
450
+
451
+ expect(
452
+ check(await checkAppThemes(dir), 'theme-local-builds'),
453
+ ).toMatchObject({
454
+ status: 'fail',
455
+ fix: expect.stringContaining('theme build'),
456
+ });
457
+ });
458
+
459
+ it('check 6 ignores private variables generated from guaranteed component properties', async () => {
460
+ const {dir, packageDir} = await fixture([
461
+ {
462
+ slug: 'ocean',
463
+ css: '[data-astryx-theme="ocean"] { --_button-radius: var(--radius-full); }\n',
464
+ },
465
+ ]);
466
+ write(
467
+ path.join(packageDir, 'themes/ocean/oceanTheme.ts'),
468
+ "export const oceanTheme = {name: 'ocean', tokens: {}, components: {button: {base: {borderRadius: 'var(--radius-full)'}}}};\n",
469
+ );
470
+
471
+ expect(
472
+ check(await checkAppThemes(dir), 'theme-private-variables'),
473
+ ).toMatchObject({status: 'pass'});
474
+ });
475
+
476
+ it('check 6 fails on a private --_* key in theme input', async () => {
477
+ const {dir, packageDir} = await fixture();
478
+ write(
479
+ path.join(packageDir, 'themes/ocean/oceanTheme.ts'),
480
+ "export const oceanTheme = {name: 'ocean', tokens: {}, components: {button: {base: {'--_button-radius': '2px'}}}};\n",
481
+ );
482
+
483
+ const result = check(await checkAppThemes(dir), 'theme-private-variables');
484
+ expect(result).toMatchObject({status: 'fail'});
485
+ expect(result.message).toContain('--_button-radius');
486
+ });
487
+
488
+ it('check 7 fails when a theme peer range rejects installed Core', async () => {
489
+ const {dir} = await fixture([{slug: 'ocean'}], {peerRange: '^9.0.0'});
490
+
491
+ const result = check(await checkAppThemes(dir), 'theme-core-peers');
492
+ expect(result).toMatchObject({
493
+ status: 'fail',
494
+ fix: expect.stringContaining('npm install'),
495
+ });
496
+ expect(result.message).toContain('^9.0.0');
497
+ });
498
+
499
+ it('check 8 fails when the static default is not an added slug', async () => {
500
+ const {dir, moduleFile} = await fixture();
501
+ const source = fs
502
+ .readFileSync(moduleFile, 'utf-8')
503
+ .replace('"defaultThemeSlug":"ocean"', '"defaultThemeSlug":"ghost"');
504
+ fs.writeFileSync(moduleFile, source);
505
+
506
+ expect(check(await checkAppThemes(dir), 'theme-default')).toMatchObject({
507
+ status: 'fail',
508
+ fix: expect.stringContaining('theme use ocean'),
509
+ });
510
+ });
511
+
512
+ it('check 9 warns when a named font has no stylesheet loader', async () => {
513
+ const {dir} = await fixture([{slug: 'ocean', fontFamily: 'Ocean Sans'}]);
514
+
515
+ const checks = await checkAppThemes(dir);
516
+ const result = check(checks, 'theme-fonts');
517
+ expect(result).toMatchObject({
518
+ status: 'warn',
519
+ fix: expect.stringContaining('fonts.css'),
520
+ });
521
+ expect(result.message).toContain('Ocean Sans');
522
+ expect(checks.some(item => item.status === 'fail')).toBe(false);
523
+ });
524
+
525
+ it('check 9 warns when a local theme has no font stylesheet', async () => {
526
+ const {dir} = await fixture([{slug: 'ocean', fontFamily: 'Ocean Sans'}]);
527
+ await themeEject('ocean', {cwd: dir, package: '@acme/themes'});
528
+ const sourceFile = path.join(dir, 'src/themes/ocean/oceanTheme.ts');
529
+ await themeBuild(sourceFile, {}, {cwd: dir});
530
+ await themeAdd('ocean', {cwd: dir, import: true});
531
+
532
+ const checks = await checkAppThemes(dir);
533
+ expect(check(checks, 'theme-fonts')).toMatchObject({
534
+ status: 'warn',
535
+ message: expect.stringContaining('Ocean Sans'),
536
+ fix: expect.stringContaining('<slug>.fonts.css'),
537
+ });
538
+ expect(checks.some(item => item.status === 'fail')).toBe(false);
539
+ });
540
+
541
+ it('check 9 passes when a local @font-face proves the named family', async () => {
542
+ const {dir} = await fixture([
543
+ {
544
+ slug: 'ocean',
545
+ fontFamily: 'Ocean Sans',
546
+ fontCss:
547
+ '@font-face { font-family: "Ocean Sans"; src: url("./ocean.woff2"); }\n',
548
+ },
549
+ ]);
550
+
551
+ expect(check(await checkAppThemes(dir), 'theme-fonts')).toMatchObject({
552
+ status: 'pass',
553
+ });
554
+ });
555
+
556
+ it('check 9 warns when an external import cannot prove the named family', async () => {
557
+ const {dir} = await fixture([
558
+ {
559
+ slug: 'ocean',
560
+ fontFamily: 'Ocean Sans',
561
+ fontCss: '@import url("https://fonts.example/ocean.css");\n',
562
+ },
563
+ ]);
564
+
565
+ expect(check(await checkAppThemes(dir), 'theme-fonts')).toMatchObject({
566
+ status: 'warn',
567
+ message: expect.stringContaining('Ocean Sans'),
568
+ });
569
+ });
570
+
571
+ it('check 10 fails on conflicting unscoped rules across added themes', async () => {
572
+ const {dir} = await fixture([
573
+ {slug: 'ocean', css: 'body { color: blue; }\n'},
574
+ {slug: 'sunset', css: 'body { color: red; }\n'},
575
+ ]);
576
+
577
+ const result = check(await checkAppThemes(dir), 'theme-global-rules');
578
+ expect(result).toMatchObject({status: 'fail'});
579
+ expect(result.message).toContain('body');
580
+ });
581
+
582
+ it('reports one information check when the CLI manages no themes', async () => {
583
+ const dir = fs.mkdtempSync(
584
+ path.join(process.cwd(), '.astryx-doctor-empty-'),
585
+ );
586
+ dirs.push(dir);
587
+ write(path.join(dir, 'package.json'), '{"name":"empty"}\n');
588
+
589
+ const checks = await checkAppThemes(dir);
590
+ expect(checks).toEqual([
591
+ expect.objectContaining({
592
+ id: 'theme-management',
593
+ status: 'info',
594
+ message: expect.stringContaining('manages no themes'),
595
+ fix: expect.stringContaining('theme add <slug> --import'),
596
+ }),
597
+ ]);
598
+ });
599
+
600
+ it('reads astryx.theme from the app package when node_modules is hoisted to a workspace root', async () => {
601
+ const root = fs.mkdtempSync(
602
+ path.join(process.cwd(), '.astryx-doctor-monorepo-'),
603
+ );
604
+ dirs.push(root);
605
+ write(
606
+ path.join(root, 'package.json'),
607
+ JSON.stringify({name: 'mono', private: true, workspaces: ['packages/*']}),
608
+ );
609
+ for (const name of ['@astryxdesign/core', '@astryxdesign/theme-neutral']) {
610
+ write(
611
+ path.join(root, 'node_modules', name, 'package.json'),
612
+ JSON.stringify({name, version: '1.0.0'}),
613
+ );
614
+ }
615
+ const app = path.join(root, 'packages/app');
616
+ write(
617
+ path.join(app, 'package.json'),
618
+ JSON.stringify({
619
+ name: 'app',
620
+ private: true,
621
+ dependencies: {
622
+ '@astryxdesign/core': '1.0.0',
623
+ '@astryxdesign/theme-neutral': '1.0.0',
624
+ },
625
+ astryx: {theme: '@astryxdesign/theme-neutral'},
626
+ }),
627
+ );
628
+
629
+ expect(await checkAppThemes(app)).toEqual([
630
+ expect.objectContaining({
631
+ id: 'theme-management',
632
+ status: 'info',
633
+ message: expect.stringContaining(
634
+ 'astryx.theme value "@astryxdesign/theme-neutral" remains active',
635
+ ),
636
+ }),
637
+ ]);
638
+ const doctor = runDoctor(app);
639
+ expect(doctor.stdout).toContain('remains active');
640
+ expect(doctor.stdout).not.toContain('no theme appears wired');
641
+ });
642
+
643
+ it('names an unmigrated copy without failing a project that has no module', async () => {
644
+ const dir = fs.mkdtempSync(
645
+ path.join(process.cwd(), '.astryx-doctor-unmigrated-'),
646
+ );
647
+ dirs.push(dir);
648
+ write(path.join(dir, 'package.json'), '{"name":"empty"}\n');
649
+ write(
650
+ path.join(dir, 'src/themes/ocean/oceanTheme.ts'),
651
+ 'export const oceanTheme = {};\n',
652
+ );
653
+
654
+ const checks = await checkAppThemes(dir);
655
+
656
+ expect(checks).toHaveLength(2);
657
+ expect(checks.some(item => item.status === 'fail')).toBe(false);
658
+ expect(checks).toContainEqual(
659
+ expect.objectContaining({
660
+ id: 'theme-unmigrated-copies',
661
+ status: 'warn',
662
+ message: expect.stringContaining('src/themes/ocean'),
663
+ fix: expect.stringContaining('upgrade --from 0.6.4 --path . --apply'),
664
+ }),
665
+ );
666
+ });
667
+ });
package/api/error.d.mts CHANGED
@@ -1,6 +1,28 @@
1
1
  // @generated by scripts/sync-api-types.mjs from the JSDoc in api/**/*.mjs.
2
2
  // DO NOT EDIT — run `pnpm sync:api-types` to regenerate.
3
3
 
4
+ /**
5
+ * The error for a write that failed on the filesystem: no permission, a
6
+ * read-only mount, a full disk, a path component that is not a directory.
7
+ *
8
+ * A raw Node errno error reached the envelope as
9
+ * `{"error": "EACCES: permission denied, open '/home/you/p/readonly/x.tsx'",
10
+ * "code": "ERR_UNKNOWN"}` — the wrong code (ERR_WRITE_FAILED is in the frozen
11
+ * registry for exactly this) and an absolute host path in the message. This
12
+ * keeps the errno, which is the part that tells you what to fix, and reports
13
+ * the target the way every other Astryx message does: relative to the project.
14
+ *
15
+ * A caller that wrote files before the failure must undo them first and pass
16
+ * the ones it could not restore as `unrestored`, so the message never says
17
+ * nothing was written when something was.
18
+ *
19
+ * @param {string} target absolute path the write was aimed at
20
+ * @param {string} cwd project root, for the relative form
21
+ * @param {unknown} cause the error the filesystem call threw
22
+ * @param {string[]} [unrestored] absolute paths an undo could not put back
23
+ * @returns {AstryxError}
24
+ */
25
+ export function writeFailed(target: string, cwd: string, cause: unknown, unrestored?: string[]): AstryxError;
4
26
  export class AstryxError extends Error {
5
27
  /**
6
28
  * @param {string} message