@astryxdesign/cli 0.7.4 → 0.7.5-canary.031a639

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 (315) hide show
  1. package/README.md +20 -20
  2. package/api/component/_adapter.mjs +16 -1
  3. package/api/component/component.test.mjs +31 -0
  4. package/api/discover/_adapter.d.mts +1 -1
  5. package/api/docs/_adapter.d.mts +5 -2
  6. package/api/docs/_adapter.mjs +24 -16
  7. package/api/docs/docs.test.mjs +18 -0
  8. package/api/docs/integrationDocs.test.mjs +2 -2
  9. package/api/experimental.d.mts +5 -0
  10. package/api/experimental.mjs +15 -0
  11. package/api/hook/list/list.d.mts +1 -1
  12. package/api/icon/_adapter.d.mts +3 -2
  13. package/api/icon/_adapter.mjs +16 -3
  14. package/api/icon/_authoring.d.mts +5 -1
  15. package/api/icon/_authoring.mjs +478 -63
  16. package/api/icon/_options.d.mts +11 -0
  17. package/api/icon/_options.mjs +39 -4
  18. package/api/icon/_records.d.mts +19 -0
  19. package/api/icon/_records.mjs +25 -0
  20. package/api/icon/add/add.d.mts +3 -3
  21. package/api/icon/add/add.mjs +227 -14
  22. package/api/icon/all-or-nothing.test.mjs +283 -0
  23. package/api/icon/detail/detail.mjs +2 -13
  24. package/api/icon/error-codes.test.mjs +14 -7
  25. package/api/icon/icon.d.mts +2 -2
  26. package/api/icon/icon.doc.mjs +30 -2
  27. package/api/icon/icon.mjs +57 -8
  28. package/api/icon/icon.test.mjs +133 -1
  29. package/api/icon/icon.type.d.mts +126 -1
  30. package/api/icon/icon.type.mjs +67 -3
  31. package/api/icon/iconAdd.doc.mjs +22 -6
  32. package/api/icon/iconMap.doc.mjs +24 -8
  33. package/api/icon/iconNewDefinition.doc.mjs +2 -2
  34. package/api/icon/iconNewSet.doc.mjs +30 -2
  35. package/api/icon/iconUse.doc.mjs +4 -1
  36. package/api/icon/map/map.d.mts +4 -4
  37. package/api/icon/map/map.mjs +134 -9
  38. package/api/icon/new-definition/new-definition.mjs +6 -2
  39. package/api/icon/new-set/new-set.mjs +2 -2
  40. package/api/icon/new-set/new-set.test.mjs +60 -10
  41. package/api/icon/option-pairs.test.mjs +368 -0
  42. package/api/icon/search/search.d.mts +10 -0
  43. package/api/icon/search/search.mjs +55 -14
  44. package/api/icon/use/use.mjs +2 -13
  45. package/api/integration/add-helpers.d.mts +15 -1
  46. package/api/integration/add-helpers.mjs +1 -1
  47. package/api/integration/pack-check.lifecycle-output.test.mjs +24 -1
  48. package/api/integration/pack-check.mjs +10 -4
  49. package/api/integration/pack-check.test.mjs +5 -1
  50. package/api/integration/validate-integration.type.d.mts +3 -2
  51. package/api/integration/validate-integration.type.mjs +3 -2
  52. package/api/render/_adapter.d.mts +28 -0
  53. package/api/render/_adapter.mjs +540 -0
  54. package/api/render/render.d.mts +15 -0
  55. package/api/render/render.doc.d.mts +9 -0
  56. package/api/render/render.doc.mjs +112 -0
  57. package/api/render/render.mjs +113 -0
  58. package/api/render/render.test.mjs +1155 -0
  59. package/api/render/render.type.d.mts +74 -0
  60. package/api/render/render.type.mjs +64 -0
  61. package/api/search/_adapter.test.mjs +21 -2
  62. package/api/search/_result.d.mts +5 -5
  63. package/api/search/search.d.mts +1 -1
  64. package/api/template/template.mjs +3 -1
  65. package/api/template/template.type.d.mts +2 -1
  66. package/api/template/template.type.mjs +1 -1
  67. package/api/template/tokenizer-showcase.test.mjs +47 -0
  68. package/api/template/unknown-name.test.mjs +63 -0
  69. package/api/theme/build/build.adaptation-enrollment.test.mjs +4 -0
  70. package/api/theme/build/build.icon-entry-variants.test.mjs +134 -0
  71. package/api/theme/build/build.icon-variants.test.mjs +105 -0
  72. package/api/theme/build/build.mjs +134 -75
  73. package/api/theme/build/build.test.mjs +77 -0
  74. package/api/upgrade/_adapter.d.mts +47 -2
  75. package/api/upgrade/_adapter.mjs +58 -2
  76. package/api/upgrade/run/failure-receipt.test.mjs +212 -0
  77. package/api/upgrade/run/outcomes.test.mjs +646 -0
  78. package/api/upgrade/run/run.d.mts +36 -0
  79. package/api/upgrade/run/run.mjs +670 -44
  80. package/api/upgrade/upgrade.doc.mjs +4 -4
  81. package/api/upgrade/upgrade.mjs +19 -4
  82. package/api/upgrade/upgrade.type.d.mts +36 -1
  83. package/api/upgrade/upgrade.type.mjs +29 -4
  84. package/assets/codemods/__tests__/runner.symlinks.test.mjs +205 -0
  85. package/assets/codemods/__tests__/runner.unparseable.test.mjs +457 -0
  86. package/assets/codemods/integration-runner.mjs +8 -2
  87. package/assets/codemods/integration-runner.protection.test.mjs +53 -0
  88. package/assets/codemods/outcome.mjs +79 -0
  89. package/assets/codemods/outcome.test.mjs +40 -0
  90. package/assets/codemods/parse.mjs +94 -0
  91. package/assets/codemods/run-codemod.mjs +109 -5
  92. package/assets/codemods/runner.mjs +119 -13
  93. package/assets/codemods/transform-prop.mjs +99 -49
  94. package/assets/codemods/transform-prop.test.mjs +36 -1
  95. package/assets/codemods/transforms/next/__tests__/migrate-codeblock-tokenizer-to-language.test.mjs +130 -0
  96. package/assets/codemods/transforms/next/index.mjs +11 -1
  97. package/assets/codemods/transforms/next/migrate-codeblock-tokenizer-to-language.mjs +315 -0
  98. package/assets/codemods/transforms/v0.1.3/__tests__/migrate-layout-components-to-experimental.test.mjs +216 -2
  99. package/assets/codemods/transforms/v0.1.3/migrate-layout-components-to-experimental.mjs +88 -6
  100. package/assets/codemods/transforms/v0.6.0/migrate-astryx-theme-selectors-to-data-attrs.mjs +4 -3
  101. package/assets/codemods/transforms/v0.7.0/__tests__/migrate-deprecated-theme-surface.test.mjs +207 -6
  102. package/assets/codemods/transforms/v0.7.0/__tests__/validate-data-token-ownership.test.mjs +143 -70
  103. package/assets/codemods/transforms/v0.7.0/migrate-deprecated-theme-surface-v0.6-data.mjs +6 -1
  104. package/assets/codemods/transforms/v0.7.0/migrate-deprecated-theme-surface.mjs +244 -42
  105. package/assets/codemods/transforms/v0.7.0/validate-data-token-ownership.mjs +23 -78
  106. package/assets/discover/official-packages.json +4 -0
  107. package/assets/docs/author-a-theme.doc.mjs +3 -1
  108. package/assets/docs/icons.doc.mjs +82 -1
  109. package/assets/docs/theme.doc.dense.mjs +8 -0
  110. package/assets/docs/theme.doc.mjs +16 -0
  111. package/assets/docs/theme.doc.zh.mjs +11 -0
  112. package/assets/docs/tree/icon-definitions.doc.mjs +2 -2
  113. package/assets/docs/tree/icon-set-files.doc.mjs +1 -1
  114. package/assets/docs/tree/icon-sets.doc.mjs +50 -20
  115. package/assets/docs/tree/render-pages.doc.mjs +94 -0
  116. package/assets/docs/tree/styling-advanced.doc.mjs +1 -1
  117. package/assets/docs/tree/template-styles.doc.mjs +1 -1
  118. package/assets/docs/tree/tokens-color.doc.mjs +145 -1
  119. package/assets/docs/tree/tokens.doc.mjs +1 -1
  120. package/assets/icons/definitions/activity.doc.mjs +1 -1
  121. package/assets/icons/definitions/alignCenter.doc.mjs +9 -0
  122. package/assets/icons/definitions/alignEnd.doc.mjs +10 -0
  123. package/assets/icons/definitions/alignStart.doc.mjs +10 -0
  124. package/assets/icons/definitions/archive.doc.mjs +1 -1
  125. package/assets/icons/definitions/arrowsUpDown.doc.mjs +1 -1
  126. package/assets/icons/definitions/attach.doc.mjs +1 -1
  127. package/assets/icons/definitions/audio.doc.mjs +1 -1
  128. package/assets/icons/definitions/cart.doc.mjs +1 -1
  129. package/assets/icons/definitions/checkDouble.doc.mjs +1 -1
  130. package/assets/icons/definitions/chevronsLeft.doc.mjs +1 -1
  131. package/assets/icons/definitions/chevronsRight.doc.mjs +1 -1
  132. package/assets/icons/definitions/close.doc.mjs +1 -1
  133. package/assets/icons/definitions/collapse.doc.mjs +1 -1
  134. package/assets/icons/definitions/compose.doc.mjs +1 -1
  135. package/assets/icons/definitions/conversation.doc.mjs +1 -1
  136. package/assets/icons/definitions/copy.doc.mjs +1 -1
  137. package/assets/icons/definitions/cpu.doc.mjs +9 -0
  138. package/assets/icons/definitions/database.doc.mjs +1 -1
  139. package/assets/icons/definitions/desktop.doc.mjs +1 -1
  140. package/assets/icons/definitions/discount.doc.mjs +1 -1
  141. package/assets/icons/definitions/download.doc.mjs +1 -1
  142. package/assets/icons/definitions/emoji.doc.mjs +1 -1
  143. package/assets/icons/definitions/error.doc.mjs +1 -1
  144. package/assets/icons/definitions/expand.doc.mjs +1 -1
  145. package/assets/icons/definitions/experiment.doc.mjs +1 -1
  146. package/assets/icons/definitions/externalLink.doc.mjs +7 -1
  147. package/assets/icons/definitions/eyeSlash.doc.mjs +1 -1
  148. package/assets/icons/definitions/flipHorizontal.doc.mjs +9 -0
  149. package/assets/icons/definitions/flipVertical.doc.mjs +9 -0
  150. package/assets/icons/definitions/folderAdd.doc.mjs +1 -1
  151. package/assets/icons/definitions/gitBranch.doc.mjs +9 -0
  152. package/assets/icons/definitions/gitFork.doc.mjs +9 -0
  153. package/assets/icons/definitions/info.doc.mjs +1 -1
  154. package/assets/icons/definitions/location.doc.mjs +1 -1
  155. package/assets/icons/definitions/mention.doc.mjs +1 -1
  156. package/assets/icons/definitions/menu.doc.mjs +1 -1
  157. package/assets/icons/definitions/microphone.doc.mjs +1 -1
  158. package/assets/icons/definitions/mobile.doc.mjs +1 -1
  159. package/assets/icons/definitions/money.doc.mjs +1 -1
  160. package/assets/icons/definitions/moreHorizontal.doc.mjs +1 -1
  161. package/assets/icons/definitions/notificationActive.doc.mjs +1 -1
  162. package/assets/icons/definitions/notificationOff.doc.mjs +1 -1
  163. package/assets/icons/definitions/panelLeft.doc.mjs +10 -0
  164. package/assets/icons/definitions/panelRight.doc.mjs +10 -0
  165. package/assets/icons/definitions/raiseHand.doc.mjs +1 -1
  166. package/assets/icons/definitions/redo.doc.mjs +1 -1
  167. package/assets/icons/definitions/refresh.doc.mjs +1 -1
  168. package/assets/icons/definitions/rotate.doc.mjs +9 -0
  169. package/assets/icons/definitions/scale.doc.mjs +10 -0
  170. package/assets/icons/definitions/search.doc.mjs +1 -1
  171. package/assets/icons/definitions/send.doc.mjs +1 -1
  172. package/assets/icons/definitions/settings.doc.mjs +1 -1
  173. package/assets/icons/definitions/star.doc.mjs +1 -1
  174. package/assets/icons/definitions/stop.doc.mjs +1 -1
  175. package/assets/icons/definitions/success.doc.mjs +1 -1
  176. package/assets/icons/definitions/textCase.doc.mjs +9 -0
  177. package/assets/icons/definitions/thumbsDown.doc.mjs +1 -1
  178. package/assets/icons/definitions/thumbsUp.doc.mjs +1 -1
  179. package/assets/icons/definitions/trendDown.doc.mjs +7 -1
  180. package/assets/icons/definitions/trendUp.doc.mjs +1 -1
  181. package/assets/icons/definitions/undo.doc.mjs +1 -1
  182. package/assets/icons/definitions/upload.doc.mjs +1 -1
  183. package/assets/icons/definitions/userAdd.doc.mjs +1 -1
  184. package/assets/icons/definitions/warning.doc.mjs +1 -1
  185. package/assets/templates/blocks/components/BottomSheet/BottomSheetSwitcherReviewFlow.doc.mjs +6 -4
  186. package/assets/templates/blocks/components/BottomSheet/BottomSheetSwitcherReviewFlow.tsx +61 -55
  187. package/assets/templates/blocks/components/BottomSheet/BottomSheetSwitcherShowcase.doc.mjs +6 -4
  188. package/assets/templates/blocks/components/BottomSheet/BottomSheetSwitcherShowcase.tsx +68 -37
  189. package/assets/templates/blocks/components/CodeBlock/CodeBlockBashCommand.doc.mjs +1 -1
  190. package/assets/templates/blocks/components/CodeBlock/CodeBlockBashCommand.tsx +10 -2
  191. package/assets/templates/blocks/components/Thumbnail/ThumbnailDisabled.doc.mjs +1 -1
  192. package/assets/templates/blocks/components/Tokenizer/TokenizerClear.tsx +15 -14
  193. package/assets/templates/blocks/components/Tokenizer/TokenizerCreatable.tsx +30 -30
  194. package/assets/templates/blocks/components/Tokenizer/TokenizerEndContent.tsx +15 -14
  195. package/assets/templates/blocks/components/Tokenizer/TokenizerIcon.tsx +15 -14
  196. package/assets/templates/blocks/components/Tokenizer/TokenizerMaxEntries.tsx +17 -16
  197. package/assets/templates/blocks/components/Tokenizer/TokenizerOverflow.tsx +29 -29
  198. package/assets/templates/blocks/components/Tokenizer/TokenizerShowcase.tsx +22 -14
  199. package/assets/templates/blocks/components/Tokenizer/TokenizerStates.tsx +39 -41
  200. package/assets/templates/pages/canvas-editor/template.doc.mjs +9 -0
  201. package/assets/templates/pages/dashboard-alert-rail/page.tsx +3 -3
  202. package/assets/templates/pages/form-wizard-inline/template.doc.mjs +6 -1
  203. package/assets/templates/pages/library/page.tsx +1 -2
  204. package/assets/templates/pages/table-comparison/page.tsx +12 -3
  205. package/assets/templates/pages/table-comparison/template.doc.mjs +1 -0
  206. package/assets/templates/pages/table-tree/template.doc.mjs +3 -0
  207. package/assets/templates/themes/butter/butterPaletteRefs.generated.ts +3 -2
  208. package/assets/templates/themes/butter/butterTheme.ts +47 -44
  209. package/assets/templates/themes/chocolate/chocolateTheme.ts +15 -2
  210. package/assets/templates/themes/gothic/gothicTheme.ts +21 -16
  211. package/assets/templates/themes/matcha/matchaPaletteRefs.generated.ts +1 -1
  212. package/assets/templates/themes/matcha/matchaTheme.ts +15 -2
  213. package/assets/templates/themes/neutral/neutralPaletteRefs.generated.ts +4 -4
  214. package/assets/templates/themes/neutral/neutralTheme.ts +24 -119
  215. package/assets/templates/themes/stone/stoneTheme.ts +46 -21
  216. package/assets/templates/themes/y2k/y2kTheme.ts +20 -16
  217. package/assets/theme.template.ts +18 -5
  218. package/authoring/codemod/type.ts +10 -0
  219. package/authoring/debug/parse.d.mts +2 -2
  220. package/authoring/doctypes/icon-definition/icon-definition.doc.mjs +4 -4
  221. package/authoring/doctypes/icon-set/icon-set-data.doc.mjs +6 -0
  222. package/authoring/doctypes/icon-set/parse.d.mts +1 -0
  223. package/authoring/doctypes/icon-set/parse.mjs +1 -0
  224. package/authoring/doctypes/icon-set/type.ts +5 -0
  225. package/authoring/doctypes/template/template.doc.mjs +1 -1
  226. package/authoring/doctypes/template/type.ts +2 -1
  227. package/clients/cli/commands/build-theme.adaptations.test.mjs +110 -0
  228. package/clients/cli/commands/build-theme.outside-project.test.mjs +140 -0
  229. package/clients/cli/commands/doctor.mjs +16 -17
  230. package/clients/cli/commands/experimental/icon.mjs +167 -35
  231. package/clients/cli/commands/experimental/index.mjs +2 -0
  232. package/clients/cli/commands/experimental/render.mjs +113 -0
  233. package/clients/cli/commands/experimental-icon-add.doc.mjs +14 -4
  234. package/clients/cli/commands/experimental-icon-map.doc.mjs +12 -2
  235. package/clients/cli/commands/experimental-icon-new-definition.doc.mjs +1 -1
  236. package/clients/cli/commands/experimental-icon-new-set.doc.mjs +28 -1
  237. package/clients/cli/commands/experimental-icon.doc.mjs +18 -2
  238. package/clients/cli/commands/experimental-render.doc.mjs +60 -0
  239. package/clients/cli/commands/experimental.doc.mjs +4 -2
  240. package/clients/cli/commands/icon-authoring.test.mjs +1823 -13
  241. package/clients/cli/commands/icon-options-wiring.test.mjs +158 -0
  242. package/clients/cli/commands/icon.test.mjs +1 -1
  243. package/clients/cli/commands/template.mjs +4 -1
  244. package/clients/cli/commands/text-json-parity.test.mjs +46 -0
  245. package/clients/cli/commands/upgrade.doc.mjs +47 -2
  246. package/clients/cli/commands/upgrade.file-protection.test.mjs +175 -0
  247. package/clients/cli/commands/upgrade.flag-help.test.mjs +37 -0
  248. package/clients/cli/commands/upgrade.integration-policy.test.mjs +103 -0
  249. package/clients/cli/commands/upgrade.mjs +9 -2
  250. package/clients/cli/commands/upgrade.outcomes.test.mjs +350 -0
  251. package/clients/cli/index.mjs +1 -0
  252. package/foundation/agent-docs/agent-docs.mjs +1 -0
  253. package/foundation/agent-docs/agent-docs.test.mjs +5 -0
  254. package/foundation/discovery/component-discovery.d.mts +2 -1
  255. package/foundation/discovery/component-discovery.export-names.test.mjs +41 -0
  256. package/foundation/discovery/component-discovery.mjs +13 -7
  257. package/foundation/discovery/icon-set-checks.d.mts +43 -9
  258. package/foundation/discovery/icon-set-checks.mjs +296 -21
  259. package/foundation/discovery/icon-set-checks.test.mjs +125 -12
  260. package/foundation/discovery/icon-set-writer.d.mts +192 -3
  261. package/foundation/discovery/icon-set-writer.mjs +608 -34
  262. package/foundation/discovery/icon-set-writer.test.mjs +26 -0
  263. package/foundation/discovery/module-exports.mjs +82 -25
  264. package/foundation/discovery/module-exports.test.mjs +38 -1
  265. package/foundation/discovery/package-exports.d.mts +13 -0
  266. package/foundation/discovery/package-exports.mjs +40 -1
  267. package/foundation/discovery/template-icons.d.mts +6 -0
  268. package/foundation/discovery/template-icons.mjs +98 -10
  269. package/foundation/discovery/template-icons.test.mjs +103 -0
  270. package/foundation/doc-compiler/doc-loads.test.mjs +22 -11
  271. package/foundation/doc-compiler/import.mjs +81 -8
  272. package/foundation/doc-compiler/read.d.mts +4 -3
  273. package/foundation/doc-compiler/read.mjs +15 -10
  274. package/foundation/doc-compiler/read.test.mjs +59 -1
  275. package/foundation/doc-compiler/tree.mjs +3 -1
  276. package/foundation/fs/module-loader.d.mts +3 -2
  277. package/foundation/fs/module-loader.mjs +3 -2
  278. package/foundation/fs/publish-file-eperm-mutation.test.mjs +2 -0
  279. package/foundation/fs/read-record.d.mts +27 -0
  280. package/foundation/fs/read-record.mjs +83 -15
  281. package/foundation/fs/read-record.test.mjs +88 -1
  282. package/foundation/render/assets.d.mts +31 -0
  283. package/foundation/render/assets.mjs +102 -0
  284. package/foundation/render/component-map.d.mts +52 -0
  285. package/foundation/render/component-map.mjs +141 -0
  286. package/foundation/render/css-cut.d.mts +29 -0
  287. package/foundation/render/css-cut.mjs +144 -0
  288. package/foundation/render/embedded-files.d.mts +28 -0
  289. package/foundation/render/embedded-files.mjs +108 -0
  290. package/foundation/render/embedded-imports.d.mts +61 -0
  291. package/foundation/render/embedded-imports.mjs +315 -0
  292. package/foundation/render/html-reader.d.mts +37 -0
  293. package/foundation/render/html-reader.mjs +121 -0
  294. package/foundation/render/page-worker.d.mts +7 -0
  295. package/foundation/render/page-worker.mjs +519 -0
  296. package/foundation/render/rebuild.d.mts +19 -0
  297. package/foundation/render/rebuild.mjs +269 -0
  298. package/foundation/render/render-page.d.mts +85 -0
  299. package/foundation/render/render-page.mjs +612 -0
  300. package/foundation/render/render.test.mjs +117 -0
  301. package/foundation/render/source-block.d.mts +52 -0
  302. package/foundation/render/source-block.mjs +106 -0
  303. package/foundation/response/base.d.ts +7 -0
  304. package/foundation/response/error-codes.d.mts +10 -1
  305. package/foundation/response/error-codes.doc.mjs +59 -2
  306. package/foundation/response/error-codes.mjs +62 -1
  307. package/foundation/response/json.d.mts +10 -3
  308. package/foundation/response/json.mjs +16 -4
  309. package/foundation/response/response-types.doc.mjs +39 -2
  310. package/foundation/text/string-utils.mjs +33 -0
  311. package/foundation/text/string-utils.test.mjs +17 -0
  312. package/foundation/text/suggest-order.d.mts +17 -3
  313. package/foundation/text/suggest-order.mjs +58 -13
  314. package/foundation/text/suggest-order.test.mjs +53 -0
  315. package/package.json +15 -9
@@ -58,7 +58,7 @@
58
58
 
59
59
  import * as fs from 'node:fs';
60
60
  import * as path from 'node:path';
61
- import {isBuiltin} from 'node:module';
61
+ import {createRequire, isBuiltin} from 'node:module';
62
62
  import {fileURLToPath, pathToFileURL} from 'node:url';
63
63
  import {parse} from '@babel/parser';
64
64
  import {createJiti} from 'jiti';
@@ -1103,6 +1103,28 @@ function componentHasAugmentableInterface(pascalName, interfaceName) {
1103
1103
  return re.test(decl);
1104
1104
  }
1105
1105
 
1106
+ /**
1107
+ * Public augmentable maps whose axis requests artwork instead of styling.
1108
+ * `Icon.variant` selects a theme's icon artwork, so it has no component styling
1109
+ * map (architecture:component-theming-surface INV14): a `components` key on it
1110
+ * never enrolls a value or generates an augmentation of its map.
1111
+ */
1112
+ const ARTWORK_REQUEST_MAPS = new Set(['IconVariantMap']);
1113
+
1114
+ /**
1115
+ * Whether a theme's component styling keys may enroll values in `interfaceName`
1116
+ * on `@astryxdesign/core/<Component>`.
1117
+ * @param {string} pascalName
1118
+ * @param {string} interfaceName
1119
+ * @returns {boolean}
1120
+ */
1121
+ function isComponentValueAugmentationPoint(pascalName, interfaceName) {
1122
+ return (
1123
+ !ARTWORK_REQUEST_MAPS.has(interfaceName) &&
1124
+ componentHasAugmentableInterface(pascalName, interfaceName)
1125
+ );
1126
+ }
1127
+
1106
1128
  /**
1107
1129
  * Adaptation values from resolved runtime rules, raw input, or normalized built
1108
1130
  * metadata. Built modules intentionally omit `__adaptationRules`, so every CLI
@@ -1410,7 +1432,7 @@ async function classifyComponentValue(component, prop, value) {
1410
1432
  const propPascal = prop.charAt(0).toUpperCase() + prop.slice(1);
1411
1433
  const target = (await resolveAugmentationTargetCandidates(component)).find(
1412
1434
  candidate =>
1413
- componentHasAugmentableInterface(
1435
+ isComponentValueAugmentationPoint(
1414
1436
  candidate.moduleName,
1415
1437
  `${candidate.interfacePrefix}${propPascal}Map`,
1416
1438
  ),
@@ -1567,7 +1589,7 @@ async function generateVariantDeclarationsAsync(themeDef) {
1567
1589
  const target = (
1568
1590
  await resolveAugmentationTargetCandidates(component)
1569
1591
  ).find(candidate =>
1570
- componentHasAugmentableInterface(
1592
+ isComponentValueAugmentationPoint(
1571
1593
  candidate.moduleName,
1572
1594
  `${candidate.interfacePrefix}${propPascal}Map`,
1573
1595
  ),
@@ -1833,19 +1855,43 @@ async function importThemeModule(filePath, interception, /** @type {any} */ load
1833
1855
  commonJsPatch.undo();
1834
1856
  }
1835
1857
  } else {
1836
- mod = await jiti.import(filePath, {default: true});
1858
+ mod = await jiti.import(filePath);
1837
1859
  }
1838
1860
 
1839
- if (isThemeObject(mod)) return {theme: mod, exportName: 'default', degraded};
1840
-
1841
- if (mod && typeof mod === 'object') {
1842
- if (isThemeObject(mod.default)) {
1843
- return {theme: mod.default, exportName: 'default', degraded};
1844
- }
1861
+ // Both loads hand back the module. The theme is read from the module's own
1862
+ // exports, never from the module object itself: jiti's interop answers a
1863
+ // property the module lacks from its default export (and a missing
1864
+ // `default` with the module), so the module can pass for the theme while
1865
+ // its own keys hide the theme's fields.
1866
+ const isModule = mod != null && typeof mod === 'object';
1867
+ const hasDefault = isModule && Object.hasOwn(mod, 'default');
1868
+ const defaultExport = hasDefault ? mod.default : undefined;
1869
+ if (isThemeObject(defaultExport)) {
1870
+ return {theme: defaultExport, exportName: 'default', degraded};
1871
+ }
1872
+ if (isModule) {
1845
1873
  for (const [exportName, value] of Object.entries(mod)) {
1874
+ if (exportName === 'default' || exportName === 'module.exports') continue;
1846
1875
  if (isThemeObject(value)) return {theme: value, exportName, degraded};
1847
1876
  }
1848
1877
  }
1878
+ // A plain-object default export is the module's theme even when it has
1879
+ // no tokens of its own (local tokens, typography or component styles may
1880
+ // be all it defines), or no name: the build's validation says what it
1881
+ // lacks.
1882
+ if (isPlainObject(defaultExport)) {
1883
+ return {theme: defaultExport, exportName: 'default', degraded};
1884
+ }
1885
+ // A CommonJS module whose exports are the theme (`module.exports =
1886
+ // theme`) has no default of its own: interop answers `default` with
1887
+ // those exports, and without interop (a family build's loader) the module
1888
+ // is them.
1889
+ if (isModule && !hasDefault) {
1890
+ const exportsObject = mod.default ?? mod;
1891
+ if (isThemeObject(exportsObject)) {
1892
+ return {theme: exportsObject, exportName: 'default', degraded};
1893
+ }
1894
+ }
1849
1895
 
1850
1896
  throw new Error(
1851
1897
  `Could not find a defineTheme() result in ${filePath}.\n` +
@@ -1853,6 +1899,45 @@ async function importThemeModule(filePath, interception, /** @type {any} */ load
1853
1899
  );
1854
1900
  }
1855
1901
 
1902
+ /**
1903
+ * Whether the theme file's own folder resolves Core's theme entry, as the
1904
+ * theme's own `import ... from '@astryxdesign/core/theme'` would. A theme
1905
+ * outside any project (an empty folder, a fresh clone) does not, and is
1906
+ * handed the Core the CLI answers with instead, as a new project with that
1907
+ * Core would build it (`theme build` runs the same outside a project, spec
1908
+ * AST-081 FR3). Only a Core not installed there (MODULE_NOT_FOUND) reads as
1909
+ * no: an installed Core whose entry does not resolve is the theme's own, and
1910
+ * its load reports that.
1911
+ * @param {string} filePath
1912
+ * @returns {boolean}
1913
+ */
1914
+ function themeFolderResolvesCore(filePath) {
1915
+ try {
1916
+ createRequire(filePath).resolve('@astryxdesign/core/theme');
1917
+ return true;
1918
+ } catch (error) {
1919
+ const {code} = /** @type {NodeJS.ErrnoException} */ (error);
1920
+ if (code === 'MODULE_NOT_FOUND') return false;
1921
+ if (code === 'ERR_PACKAGE_PATH_NOT_EXPORTED') return true;
1922
+ throw error;
1923
+ }
1924
+ }
1925
+
1926
+ /**
1927
+ * A plain object, not an array or a module namespace: a theme module's
1928
+ * default export, read as its theme.
1929
+ * @param {any} value
1930
+ * @returns {boolean}
1931
+ */
1932
+ function isPlainObject(value) {
1933
+ return (
1934
+ value != null &&
1935
+ typeof value === 'object' &&
1936
+ !Array.isArray(value) &&
1937
+ value[Symbol.toStringTag] !== 'Module'
1938
+ );
1939
+ }
1940
+
1856
1941
  /**
1857
1942
  * @param {any} value
1858
1943
  * @returns {boolean}
@@ -1868,12 +1953,9 @@ function isThemeObject(value) {
1868
1953
  }
1869
1954
 
1870
1955
  /**
1871
- * Extract the theme definition from a JS/TS file.
1872
- * Tries jiti first (full TS support), falls back to regex+eval.
1873
- *
1874
- * The legacy fallback needs no interception: it evaluates the `defineTheme()`
1875
- * ARGUMENT, so what it returns is raw authored input with `adaptations` still
1876
- * on it — nothing has erased anything yet. It is therefore never degraded.
1956
+ * Extract the theme definition from a JS/TS file, through jiti (full TS
1957
+ * support). A module that does not load fails with its own error: the theme
1958
+ * is never read from the file's text instead.
1877
1959
  *
1878
1960
  * @param {string} filePath
1879
1961
  * @param {import('./core-interception.mjs').CoreInterception} [interception]
@@ -1884,18 +1966,12 @@ async function extractThemeDefinition(filePath, interception, /** @type {any} */
1884
1966
  try {
1885
1967
  return await importThemeModule(filePath, interception, loader);
1886
1968
  } catch (jitiError) {
1887
- try {
1888
- return {
1889
- theme: extractThemeDefinitionLegacy(filePath),
1890
- degraded: {topLevelAwait: false, commonJs: false},
1891
- };
1892
- } catch {
1893
- const je = /** @type {Error} */ (jitiError);
1894
- throw new Error(
1895
- `Failed to load theme from ${filePath}: ${je.message}\n` +
1896
- `Make sure all imports in the theme file are resolvable.`,
1897
- );
1898
- }
1969
+ const je = /** @type {Error} */ (jitiError);
1970
+ throw new Error(
1971
+ `Failed to load theme from ${filePath}: ${je.message}\n` +
1972
+ `Make sure all imports in the theme file are resolvable.`,
1973
+ {cause: jitiError},
1974
+ );
1899
1975
  }
1900
1976
  }
1901
1977
 
@@ -1941,45 +2017,6 @@ export async function validateThemePrivateInputs(
1941
2017
  }
1942
2018
  }
1943
2019
 
1944
- /**
1945
- * Fallback extraction via regex + eval.
1946
- * Only works for plain object literals — can't follow imports or variables.
1947
- * Never erase icon references: an unresolved registry must preserve the loader
1948
- * error instead of turning an incomplete theme into a successful build.
1949
- * @param {string} filePath
1950
- * @returns {any}
1951
- */
1952
- function extractThemeDefinitionLegacy(filePath) {
1953
- const content = fs.readFileSync(filePath, 'utf8');
1954
-
1955
- const defineMatch = content.match(/defineTheme\s*\(\s*({[\s\S]*?})\s*\)/);
1956
- if (!defineMatch) {
1957
- const defaultMatch = content.match(/export\s+default\s+({[\s\S]*?});/);
1958
- if (!defaultMatch) {
1959
- throw new Error(
1960
- `Could not find defineTheme() call or default export in ${filePath}.\n` +
1961
- `Expected: defineTheme({ name: '...', tokens: {...} })`,
1962
- );
1963
- }
1964
-
1965
- return eval(`(${defaultMatch[1]})`);
1966
- }
1967
-
1968
- let objStr = defineMatch[1];
1969
- objStr = objStr.replace(/\s+as\s+const/g, '');
1970
-
1971
- try {
1972
- return eval(`(${objStr})`);
1973
- } catch (e) {
1974
- const err = /** @type {Error} */ (e);
1975
- throw new Error(
1976
- `Failed to parse theme definition in ${filePath}: ${err.message}\n` +
1977
- `Make sure the defineTheme() argument is a plain object literal.`,
1978
- {cause: e},
1979
- );
1980
- }
1981
- }
1982
-
1983
2020
  /**
1984
2021
  * Extract a family member's named registry import from its source file.
1985
2022
  * Returns { importPath, exportName } or null when the theme names none.
@@ -2151,7 +2188,22 @@ function generateBuiltModule(
2151
2188
  serializeField('__onDark', themeDef.__onDark) +
2152
2189
  serializeField('__onLight', themeDef.__onLight) +
2153
2190
  serializeField('__adaptations', themeDef.__adaptations) +
2154
- serializeField('__axes', themeDef.__axes ?? {}, true);
2191
+ serializeField('__axes', themeDef.__axes ?? {}, true) +
2192
+ // An explicit empty list replaces an inherited one, so keep `[]`.
2193
+ serializeField('iconVariants', themeDef.iconVariants, true) +
2194
+ // Each inherited function entry keeps its defining theme's list. JSON
2195
+ // drops `undefined`, so a defining theme with no list is written as `[]`,
2196
+ // which no variant matches either.
2197
+ serializeField(
2198
+ '__iconEntryVariants',
2199
+ themeDef.__iconEntryVariants &&
2200
+ Object.fromEntries(
2201
+ Object.entries(themeDef.__iconEntryVariants).map(([name, list]) => [
2202
+ name,
2203
+ list ?? [],
2204
+ ]),
2205
+ ),
2206
+ );
2155
2207
 
2156
2208
  return `${iconImport}${iconDeclaration}/**
2157
2209
  * ${themeDef.name} theme — built by \`${getCliInvocation()} theme build\`
@@ -2580,13 +2632,15 @@ async function themeBuildInternal(
2580
2632
  }
2581
2633
  await selectCore(cwd, {projectOnly: projectCore});
2582
2634
 
2583
- // Standalone builds only need interception when an older Core could erase
2584
- // adaptations. Family preparation always supplies the same recorder as its
2635
+ // Standalone builds need interception when an older Core could erase
2636
+ // adaptations, and when the theme's folder has no Core of its own: its
2637
+ // imports of Core are then handed the Core this build selected, as family
2638
+ // builds' are. Family preparation always supplies the same recorder as its
2585
2639
  // shared loader so exact authored parent identity stays CLI-private instead
2586
2640
  // of becoming a public DefinedTheme field.
2587
2641
  const interception =
2588
2642
  options.__familyInterception ??
2589
- (_generateAdaptationCSS
2643
+ (_generateAdaptationCSS && themeFolderResolvesCore(filePath)
2590
2644
  ? undefined
2591
2645
  : interceptCore(_coreThemeModule, _coreRootModule));
2592
2646
 
@@ -2870,10 +2924,15 @@ async function themeBuildInternal(
2870
2924
  /** @type {string[]} */
2871
2925
  const droppedDeclarations = [];
2872
2926
 
2873
- const {component, prose} = _generateThemeRulesSplit(
2874
- resolvedTheme,
2875
- droppedDeclarations,
2876
- );
2927
+ let themeRules;
2928
+ try {
2929
+ themeRules = _generateThemeRulesSplit(resolvedTheme, droppedDeclarations);
2930
+ } catch (error) {
2931
+ const message =
2932
+ error instanceof Error ? error.message : 'Theme normalization failed.';
2933
+ throw new AstryxError(message, undefined, ERROR_CODES.ERR_THEME_INVALID);
2934
+ }
2935
+ const {component, prose} = themeRules;
2877
2936
  const cssParts = [];
2878
2937
  // Prose element defaults always ship — the `<Theme>` runtime
2879
2938
  // (generateThemeCSS) always emits them, so the build must too, or the
@@ -27,6 +27,7 @@ import {
27
27
  import {
28
28
  themeBuild,
29
29
  validateComponentOverridesAgainstRegistry,
30
+ validateThemePrivateInputs,
30
31
  } from './build.mjs';
31
32
 
32
33
  // `themeBuild` captures core's generator once at module load. Wrap the two
@@ -212,6 +213,55 @@ describe('themeBuild() — receipt', () => {
212
213
  });
213
214
  });
214
215
 
216
+ describe.each(['mjs', 'ts'])('a .%s theme module with no theme export', ext => {
217
+ beforeEach(() => {
218
+ fs.writeFileSync(
219
+ path.join(tmpDir, `none.${ext}`),
220
+ 'export const notATheme = 42;\n',
221
+ );
222
+ });
223
+
224
+ it('fails the build as a module that does not load a theme', async () => {
225
+ const build = themeBuild(`none.${ext}`, {}, {cwd: tmpDir});
226
+ await expect(build).rejects.toThrow(
227
+ /Could not find a defineTheme\(\) result/,
228
+ );
229
+ await expect(build).rejects.toMatchObject({code: 'ERR_THEME_LOAD'});
230
+ });
231
+
232
+ it("fails doctor's private-input check the same way, rather than read its exports as a theme", async () => {
233
+ await expect(
234
+ validateThemePrivateInputs(`none.${ext}`, {cwd: tmpDir}),
235
+ ).rejects.toThrow(/Could not find a defineTheme\(\) result/);
236
+ });
237
+ });
238
+
239
+ describe('themeBuild() — a theme module that does not load', () => {
240
+ it('fails with the import error, rather than build the theme from the file text', async () => {
241
+ fs.writeFileSync(
242
+ path.join(tmpDir, 'unresolved.mjs'),
243
+ "import './missing-helper.mjs';\nexport default {name: 'unresolved', tokens: {'--color-bg': '#000'}};\n",
244
+ );
245
+ await expect(
246
+ themeBuild('unresolved.mjs', {}, {cwd: tmpDir}),
247
+ ).rejects.toThrow(
248
+ /Failed to load theme from .*unresolved\.mjs: .*missing-helper\.mjs/s,
249
+ );
250
+ expect(fs.existsSync(path.join(tmpDir, 'unresolved.css'))).toBe(false);
251
+ });
252
+
253
+ it('fails with the error the module throws, rather than build the theme from the file text', async () => {
254
+ fs.writeFileSync(
255
+ path.join(tmpDir, 'throws.mjs'),
256
+ "throw new Error('the theme module failed');\nexport default {name: 'throws', tokens: {'--color-bg': '#000'}};\n",
257
+ );
258
+ await expect(themeBuild('throws.mjs', {}, {cwd: tmpDir})).rejects.toThrow(
259
+ /the theme module failed/,
260
+ );
261
+ expect(fs.existsSync(path.join(tmpDir, 'throws.css'))).toBe(false);
262
+ });
263
+ });
264
+
215
265
  describe('themeBuild() — dropped declarations reach the receipt', () => {
216
266
  // Core's generator refuses a declaration whose value would end it early
217
267
  // (an unquoted `;` or brace, an unclosed string/comment/url). The runtime
@@ -599,6 +649,33 @@ describe('themeBuild() — component override validation', () => {
599
649
  });
600
650
  });
601
651
 
652
+ describe('themeBuild() — Icon size dimensions', () => {
653
+ it('writes width and height on an icon size into the vars the glyph reads, with no warnings', async () => {
654
+ // spec:AST-087 FR10: a built theme sets an Icon size's glyph dimension the
655
+ // way the runtime provider does, through the shared compiler's derived
656
+ // vars. Raw width/height would lose to a consumer's unlayered StyleX.
657
+ const themeFile = path.join(tmpDir, 'iconsizes.mjs');
658
+ fs.writeFileSync(
659
+ themeFile,
660
+ `export default {
661
+ name: 'iconsizes',
662
+ tokens: {'--color-bg': '#0a0a0a'},
663
+ components: {icon: {'size:sm': {width: '18px', height: '22px'}}},
664
+ };\n`,
665
+ );
666
+
667
+ const result = await themeBuild('iconsizes.mjs', {}, {cwd: tmpDir});
668
+
669
+ expect(result?.data.warnings).toEqual([]);
670
+ const css = fs.readFileSync(path.join(tmpDir, 'iconsizes.css'), 'utf8');
671
+ const rule =
672
+ css.match(/\.astryx-icon\[data-size="sm"\]\s*\{([^}]*)\}/)?.[1] ?? '';
673
+ expect(rule).toMatch(/--_icon-width:\s*18px/);
674
+ expect(rule).toMatch(/--_icon-height:\s*22px/);
675
+ expect(rule).not.toMatch(/(^|[\s;])(width|height)\s*:/);
676
+ });
677
+ });
678
+
602
679
  describe('themeBuild() — the shipped theme template', () => {
603
680
  // `assets/theme.template.ts` is what `astryx theme template` puts in a
604
681
  // consumer's project. It is the one theme file we hand out, so it has to
@@ -180,13 +180,42 @@ export function getCoreVersionManifests(from: string, to: string): Promise<CoreV
180
180
  export function ensureCodemodDeps({ installDeps }?: {
181
181
  installDeps?: boolean;
182
182
  }): Promise<boolean>;
183
+ /**
184
+ * @typedef {{kind: 'manual', file: string, codemod: string, message: string, line?: number} | {kind: 'regenerate', file: string, codemod: string, message: string, commands: string[]}} CodemodOutcomeRecord
185
+ */
186
+ /**
187
+ * Wrap each core code and config transform so the non-failure outcomes it
188
+ * throws (`assets/codemods/outcome.mjs`) are recorded instead of reaching the
189
+ * runner as errors. The wrapped transform leaves that file unchanged, exactly
190
+ * as the throw did. Project codemods keep their own contract. One wrapper per
191
+ * pass: the regeneration re-check takes a fresh one, so an outcome a hook
192
+ * resolved does not linger.
193
+ *
194
+ * @template {{version: string, transforms: Array<{name: string, transform: any, meta?: {codemodType?: string}}>}} M
195
+ * @param {M[]} versionManifests
196
+ * @param {string} root project root; recorded files are relative to it
197
+ * @returns {{versionManifests: M[], outcomes: CodemodOutcomeRecord[]}}
198
+ */
199
+ export function withCodemodOutcomes<M extends {
200
+ version: string;
201
+ transforms: Array<{
202
+ name: string;
203
+ transform: any;
204
+ meta?: {
205
+ codemodType?: string;
206
+ };
207
+ }>;
208
+ }>(versionManifests: M[], root: string): {
209
+ versionManifests: M[];
210
+ outcomes: CodemodOutcomeRecord[];
211
+ };
183
212
  /**
184
213
  * Run the CORE registry codemods. Runs BEFORE the config is loaded so a core
185
214
  * CONFIG codemod can repair a config the strict loader would otherwise reject.
186
215
  * @param {CoreVersionManifest[]} versionManifests
187
- * @param {{apply: boolean, path: string, codemod?: string, skipCodemods: Set<string>, root?: string, protection?: {root: string, classify: (file: string) => import('../../foundation/fs/file-protection.mjs').FileProtection[]}, silent?: boolean, coversTarget?: boolean}} options
216
+ * @param {{apply: boolean, path: string, codemod?: string, skipCodemods: Set<string>, root?: string, protection?: {root: string, classify: (file: string) => import('../../foundation/fs/file-protection.mjs').FileProtection[]}, silent?: boolean, coversTarget?: boolean, outcomes?: CodemodOutcomeRecord[]}} options
188
217
  */
189
- export function runCoreCodemods(versionManifests: CoreVersionManifest[], { apply, path: srcPath, codemod, skipCodemods, root, protection, silent, coversTarget, }: {
218
+ export function runCoreCodemods(versionManifests: CoreVersionManifest[], { apply, path: srcPath, codemod, skipCodemods, root, protection, silent, coversTarget, outcomes, }: {
190
219
  apply: boolean;
191
220
  path: string;
192
221
  codemod?: string;
@@ -198,6 +227,7 @@ export function runCoreCodemods(versionManifests: CoreVersionManifest[], { apply
198
227
  };
199
228
  silent?: boolean;
200
229
  coversTarget?: boolean;
230
+ outcomes?: CodemodOutcomeRecord[];
201
231
  }): Promise<{
202
232
  totalFilesChanged: number;
203
233
  totalTransformsApplied: number;
@@ -206,6 +236,7 @@ export function runCoreCodemods(versionManifests: CoreVersionManifest[], { apply
206
236
  writtenFiles: string[];
207
237
  stagedContents: Map<string, string>;
208
238
  protectedFiles: import("../../authoring/codemod/type").CodemodRunResult["protectedFiles"];
239
+ declinedCandidates: NonNullable<import("../../authoring/codemod/type").CodemodRunResult["declinedCandidates"]>;
209
240
  errors: Array<{
210
241
  file: string;
211
242
  codemod: string;
@@ -301,6 +332,7 @@ export function runIntegrationCodemodsStep(versionGroups: Array<{
301
332
  writtenFiles: string[];
302
333
  stagedContents: Map<string, string>;
303
334
  protectedFiles: import("../../authoring/codemod/type").CodemodRunResult["protectedFiles"];
335
+ declinedCandidates: NonNullable<import("../../authoring/codemod/type").CodemodRunResult["declinedCandidates"]>;
304
336
  errors: Array<{
305
337
  file: string;
306
338
  codemod: string;
@@ -347,4 +379,17 @@ export type AgentDocsRefreshPlan = {
347
379
  renderedBlock: string | null;
348
380
  summary: import("./upgrade.type.mjs").AgentDocsSummary;
349
381
  };
382
+ export type CodemodOutcomeRecord = {
383
+ kind: "manual";
384
+ file: string;
385
+ codemod: string;
386
+ message: string;
387
+ line?: number;
388
+ } | {
389
+ kind: "regenerate";
390
+ file: string;
391
+ codemod: string;
392
+ message: string;
393
+ commands: string[];
394
+ };
350
395
  import { inspectAgentDocs } from '../../foundation/agent-docs/agent-docs.mjs';
@@ -24,6 +24,7 @@ import {
24
24
  latestVersion,
25
25
  } from '../../assets/codemods/registry.mjs';
26
26
  import {runCodemods} from '../../assets/codemods/runner.mjs';
27
+ import {codemodOutcome} from '../../assets/codemods/outcome.mjs';
27
28
  import {
28
29
  discoverIntegrationCodemods,
29
30
  selectIntegrationCodemods,
@@ -141,7 +142,12 @@ export function relativeToOrigin(result, {cwd: root, origin}) {
141
142
  };
142
143
  }
143
144
  if (data.modifiedFiles) data.modifiedFiles = data.modifiedFiles.map(rebase);
144
- for (const key of ['protectedFiles', 'declinedCandidates', 'errors']) {
145
+ for (const key of [
146
+ 'protectedFiles',
147
+ 'declinedCandidates',
148
+ 'errors',
149
+ 'regenerate',
150
+ ]) {
145
151
  if (data[key]) {
146
152
  data[key] = data[key].map(
147
153
  (/** @type {{file: string, declarations?: string[]}} */ entry) => ({
@@ -599,11 +605,59 @@ export async function ensureCodemodDeps({installDeps} = {}) {
599
605
  return ensureJscodeshift({installDeps, silent: logger.silent});
600
606
  }
601
607
 
608
+ /**
609
+ * @typedef {{kind: 'manual', file: string, codemod: string, message: string, line?: number} | {kind: 'regenerate', file: string, codemod: string, message: string, commands: string[]}} CodemodOutcomeRecord
610
+ */
611
+
612
+ /**
613
+ * Wrap each core code and config transform so the non-failure outcomes it
614
+ * throws (`assets/codemods/outcome.mjs`) are recorded instead of reaching the
615
+ * runner as errors. The wrapped transform leaves that file unchanged, exactly
616
+ * as the throw did. Project codemods keep their own contract. One wrapper per
617
+ * pass: the regeneration re-check takes a fresh one, so an outcome a hook
618
+ * resolved does not linger.
619
+ *
620
+ * @template {{version: string, transforms: Array<{name: string, transform: any, meta?: {codemodType?: string}}>}} M
621
+ * @param {M[]} versionManifests
622
+ * @param {string} root project root; recorded files are relative to it
623
+ * @returns {{versionManifests: M[], outcomes: CodemodOutcomeRecord[]}}
624
+ */
625
+ export function withCodemodOutcomes(versionManifests, root) {
626
+ /** @type {CodemodOutcomeRecord[]} */
627
+ const outcomes = [];
628
+ const wrapped = versionManifests.map(manifest => ({
629
+ ...manifest,
630
+ transforms: manifest.transforms.map(entry => {
631
+ if (entry.meta?.codemodType === 'project') return entry;
632
+ const {transform, name} = entry;
633
+ return {
634
+ ...entry,
635
+ /** @param {{path: string, source: string}} file @param {unknown} api */
636
+ transform(file, api) {
637
+ try {
638
+ return transform(file, api);
639
+ } catch (err) {
640
+ const outcome = codemodOutcome(err);
641
+ if (!outcome) throw err;
642
+ outcomes.push({
643
+ ...outcome,
644
+ file: path.relative(root, file.path).split(path.sep).join('/'),
645
+ codemod: `core:${name}`,
646
+ });
647
+ return undefined;
648
+ }
649
+ },
650
+ };
651
+ }),
652
+ }));
653
+ return {versionManifests: /** @type {M[]} */ (wrapped), outcomes};
654
+ }
655
+
602
656
  /**
603
657
  * Run the CORE registry codemods. Runs BEFORE the config is loaded so a core
604
658
  * CONFIG codemod can repair a config the strict loader would otherwise reject.
605
659
  * @param {CoreVersionManifest[]} versionManifests
606
- * @param {{apply: boolean, path: string, codemod?: string, skipCodemods: Set<string>, root?: string, protection?: {root: string, classify: (file: string) => import('../../foundation/fs/file-protection.mjs').FileProtection[]}, silent?: boolean, coversTarget?: boolean}} options
660
+ * @param {{apply: boolean, path: string, codemod?: string, skipCodemods: Set<string>, root?: string, protection?: {root: string, classify: (file: string) => import('../../foundation/fs/file-protection.mjs').FileProtection[]}, silent?: boolean, coversTarget?: boolean, outcomes?: CodemodOutcomeRecord[]}} options
607
661
  */
608
662
  export async function runCoreCodemods(
609
663
  versionManifests,
@@ -616,6 +670,7 @@ export async function runCoreCodemods(
616
670
  protection,
617
671
  silent,
618
672
  coversTarget,
673
+ outcomes,
619
674
  },
620
675
  ) {
621
676
  return runCodemods(versionManifests, {
@@ -627,6 +682,7 @@ export async function runCoreCodemods(
627
682
  root,
628
683
  protection,
629
684
  coversTarget,
685
+ outcomes,
630
686
  });
631
687
  }
632
688