@astryxdesign/cli 0.7.5 → 0.7.6-canary.0bd3b37

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 (505) hide show
  1. package/assets/docs/author-a-theme.doc.mjs +3 -3
  2. package/assets/docs/motion.doc.mjs +39 -3
  3. package/assets/docs/tree/tokens-duration.doc.mjs +2 -2
  4. package/assets/docs/tree/tokens-ease.doc.mjs +10 -2
  5. package/assets/docs/tree/tokens.doc.mjs +1 -1
  6. package/assets/theme.template.ts +20 -5
  7. package/foundation/config/theme-private-vars.mjs +26 -6
  8. package/package.json +23 -10
  9. package/api/api-docs-parse.test.mjs +0 -47
  10. package/api/blog/_adapter.test.mjs +0 -183
  11. package/api/blog/blog.test.mjs +0 -144
  12. package/api/blog/detail/detail.test.mjs +0 -118
  13. package/api/blog/list/list.test.mjs +0 -81
  14. package/api/build/blocks/blocks.test.mjs +0 -238
  15. package/api/build/build.test.mjs +0 -569
  16. package/api/build/kit/answer.test.mjs +0 -108
  17. package/api/build/kit/rank.test.mjs +0 -380
  18. package/api/build/kit/weights.test.mjs +0 -286
  19. package/api/build/tree.test.mjs +0 -185
  20. package/api/component/component-replacement.test.mjs +0 -616
  21. package/api/component/component.test.mjs +0 -532
  22. package/api/component/doc-links.test.mjs +0 -419
  23. package/api/component/integration-export-name.test.mjs +0 -644
  24. package/api/component/integration-import-agreement.test.mjs +0 -474
  25. package/api/discover/_adapter.test.mjs +0 -839
  26. package/api/discover/_catalog-view.test.mjs +0 -129
  27. package/api/discover/_package-scanner.test.mjs +0 -117
  28. package/api/discover/detail/detail.test.mjs +0 -145
  29. package/api/discover/detail/doc/doc.test.mjs +0 -93
  30. package/api/discover/detail/item/item.test.mjs +0 -75
  31. package/api/discover/discover.test.mjs +0 -100
  32. package/api/discover/list/list.test.mjs +0 -107
  33. package/api/discover/search/search.test.mjs +0 -319
  34. package/api/docs/compiled-topics.test.mjs +0 -94
  35. package/api/docs/detail/section/section.test.mjs +0 -92
  36. package/api/docs/docOverlays.test.mjs +0 -189
  37. package/api/docs/docs-homes.test.mjs +0 -127
  38. package/api/docs/docs.depth.test.mjs +0 -134
  39. package/api/docs/docs.test.mjs +0 -315
  40. package/api/docs/guide-route-targets.test.mjs +0 -1002
  41. package/api/docs/index/index.test.mjs +0 -67
  42. package/api/docs/integration-tree.test.mjs +0 -616
  43. package/api/docs/integrationDocs.test.mjs +0 -546
  44. package/api/docs/namespace-section.test.mjs +0 -260
  45. package/api/docs/react-version-sync.test.mjs +0 -79
  46. package/api/docs/reference-blocks.test.mjs +0 -404
  47. package/api/docs/token-tables.test.mjs +0 -93
  48. package/api/doctor/built-checks.test.mjs +0 -531
  49. package/api/doctor/doctor.test.mjs +0 -1651
  50. package/api/doctor/icon-sets.test.mjs +0 -111
  51. package/api/doctor/release-checks.test.mjs +0 -156
  52. package/api/doctor/theme-checks.test.mjs +0 -884
  53. package/api/gap-report/gap-report.test.mjs +0 -1549
  54. package/api/hook/detail/detail.test.mjs +0 -53
  55. package/api/hook/detail/params/params.test.mjs +0 -39
  56. package/api/hook/hook.test.mjs +0 -75
  57. package/api/icon/all-or-nothing.test.mjs +0 -283
  58. package/api/icon/error-codes.test.mjs +0 -341
  59. package/api/icon/experimental-markers.test.mjs +0 -93
  60. package/api/icon/icon.test.mjs +0 -506
  61. package/api/icon/new-definition/new-definition.undo.test.mjs +0 -97
  62. package/api/icon/new-set/new-set.test.mjs +0 -398
  63. package/api/icon/option-pairs.test.mjs +0 -368
  64. package/api/init/init.test.mjs +0 -319
  65. package/api/init/remove/remove.test.mjs +0 -124
  66. package/api/init/user/user.test.mjs +0 -232
  67. package/api/integration/add-contribution.component-names.test.mjs +0 -186
  68. package/api/integration/add-contribution.test.mjs +0 -990
  69. package/api/integration/add-helpers.test.mjs +0 -161
  70. package/api/integration/add-theme.test.mjs +0 -676
  71. package/api/integration/authoring-checks.test.mjs +0 -1683
  72. package/api/integration/check/check.test.mjs +0 -538
  73. package/api/integration/doc-stability.test.mjs +0 -216
  74. package/api/integration/example-checks.no-npm.test.mjs +0 -140
  75. package/api/integration/example-checks.test.mjs +0 -776
  76. package/api/integration/integration-block-exports.test.mjs +0 -248
  77. package/api/integration/pack-check.component-replaces.test.mjs +0 -126
  78. package/api/integration/pack-check.lifecycle-output.test.mjs +0 -149
  79. package/api/integration/pack-check.test.mjs +0 -2512
  80. package/api/integration/public-api.test.mjs +0 -21
  81. package/api/integration/template-conflict-compatibility.test.mjs +0 -73
  82. package/api/integration/validate-installed-icon-sets.test.mjs +0 -67
  83. package/api/integration/validate-integration-case-disk.test.mjs +0 -123
  84. package/api/integration/validate-integration-fixes.test.mjs +0 -1457
  85. package/api/integration/validate-integration-gaps.test.mjs +0 -1999
  86. package/api/integration/validate-integration.test.mjs +0 -835
  87. package/api/integration/validate-unread-theme-folders.test.mjs +0 -111
  88. package/api/json/envelope-types.test.mjs +0 -76
  89. package/api/json/parse.test.mjs +0 -76
  90. package/api/render/render.test.mjs +0 -1155
  91. package/api/search/_adapter.test.mjs +0 -192
  92. package/api/search/_doc-searcher.test.mjs +0 -36
  93. package/api/search/_entries.test.mjs +0 -48
  94. package/api/search/_main-searcher.test.mjs +0 -106
  95. package/api/search/_order.test.mjs +0 -72
  96. package/api/search/_template-searcher.test.mjs +0 -40
  97. package/api/search/search-return-type.test.mjs +0 -54
  98. package/api/search/search.domain-priority.test.mjs +0 -351
  99. package/api/search/search.family-members.test.mjs +0 -124
  100. package/api/search/search.family-word.test.mjs +0 -146
  101. package/api/search/search.integration-block.test.mjs +0 -100
  102. package/api/search/search.integration-check.test.mjs +0 -24
  103. package/api/search/search.test.mjs +0 -1007
  104. package/api/search/search.tie-order.test.mjs +0 -39
  105. package/api/search/tree.test.mjs +0 -66
  106. package/api/swizzle/_github.test.mjs +0 -53
  107. package/api/swizzle/copy/copy.test.mjs +0 -60
  108. package/api/swizzle/swizzle.test.mjs +0 -157
  109. package/api/template/cdn/cdn.test.mjs +0 -108
  110. package/api/template/checkout-wizard.test.mjs +0 -87
  111. package/api/template/copy/copy.receipt.test.mjs +0 -77
  112. package/api/template/copy/copy.test.mjs +0 -77
  113. package/api/template/data-token-fallbacks.test.mjs +0 -85
  114. package/api/template/discover-integration-templates.test.mjs +0 -56
  115. package/api/template/form-wizard-dialog.test.mjs +0 -47
  116. package/api/template/inline-wizard-template.test.mjs +0 -24
  117. package/api/template/list/list.test.mjs +0 -52
  118. package/api/template/show/show.test.mjs +0 -76
  119. package/api/template/table-filter-view-tabs.test.mjs +0 -45
  120. package/api/template/table-floating-bulk-actions.test.mjs +0 -66
  121. package/api/template/template-integration.test.mjs +0 -1274
  122. package/api/template/template-suffix.test.mjs +0 -286
  123. package/api/template/template.test.mjs +0 -222
  124. package/api/template/tokenizer-showcase.test.mjs +0 -47
  125. package/api/template/unknown-name.test.mjs +0 -63
  126. package/api/theme/add/add.test.mjs +0 -363
  127. package/api/theme/add/add.types.test.mjs +0 -150
  128. package/api/theme/build/build.adaptation-core-compat.test.mjs +0 -394
  129. package/api/theme/build/build.adaptation-enrollment.test.mjs +0 -219
  130. package/api/theme/build/build.core-on-demand.test.mjs +0 -113
  131. package/api/theme/build/build.family.test.mjs +0 -503
  132. package/api/theme/build/build.font-warning.test.mjs +0 -170
  133. package/api/theme/build/build.heading-core-compat.test.mjs +0 -68
  134. package/api/theme/build/build.icon-entry-variants.test.mjs +0 -134
  135. package/api/theme/build/build.icon-function-entries.test.mjs +0 -499
  136. package/api/theme/build/build.icon-lineage.test.mjs +0 -117
  137. package/api/theme/build/build.icon-preservation.test.mjs +0 -639
  138. package/api/theme/build/build.icon-variants.test.mjs +0 -105
  139. package/api/theme/build/build.icons-specifier.test.mjs +0 -149
  140. package/api/theme/build/build.packed-old-core.test.mjs +0 -1512
  141. package/api/theme/build/build.project-core.test.mjs +0 -220
  142. package/api/theme/build/build.public-component-vars.test.mjs +0 -151
  143. package/api/theme/build/build.receipt-doc.test.mjs +0 -111
  144. package/api/theme/build/build.rollback.test.mjs +0 -148
  145. package/api/theme/build/build.test.mjs +0 -1258
  146. package/api/theme/build/font-warning.test.mjs +0 -268
  147. package/api/theme/eject/eject.binary.test.mjs +0 -90
  148. package/api/theme/eject/eject.copy-compat.test.mjs +0 -168
  149. package/api/theme/eject/eject.rollback.test.mjs +0 -158
  150. package/api/theme/eject/eject.staging.test.mjs +0 -83
  151. package/api/theme/eject/eject.test.mjs +0 -160
  152. package/api/theme/integration-themes.test.mjs +0 -218
  153. package/api/theme/list/list.test.mjs +0 -271
  154. package/api/theme/palette/generate/generate.test.mjs +0 -445
  155. package/api/theme/palette/generate/generator.test.mjs +0 -385
  156. package/api/theme/palette/generate/preview.test.mjs +0 -55
  157. package/api/theme/remove/remove.test.mjs +0 -94
  158. package/api/theme/targets/targets.test.mjs +0 -91
  159. package/api/theme/template/template.test.mjs +0 -102
  160. package/api/theme/use/use.test.mjs +0 -98
  161. package/api/upgrade/list/list.test.mjs +0 -73
  162. package/api/upgrade/project-context.test.mjs +0 -272
  163. package/api/upgrade/provider-agreement.test.mjs +0 -152
  164. package/api/upgrade/registry/registry.test.mjs +0 -911
  165. package/api/upgrade/run/authoring-codemod-reachable.test.mjs +0 -99
  166. package/api/upgrade/run/cli-behind-core.test.mjs +0 -438
  167. package/api/upgrade/run/failure-receipt.test.mjs +0 -212
  168. package/api/upgrade/run/files-changed.test.mjs +0 -111
  169. package/api/upgrade/run/outcomes.test.mjs +0 -646
  170. package/api/upgrade/run/run.test.mjs +0 -511
  171. package/api/upgrade/upgrade.test.mjs +0 -594
  172. package/assets/codemods/__tests__/registry.test.mjs +0 -77
  173. package/assets/codemods/__tests__/rename-imperative-ref-to-handleRef.test.mjs +0 -65
  174. package/assets/codemods/__tests__/rename-isStreaming-to-isStopShown.test.mjs +0 -58
  175. package/assets/codemods/__tests__/rename-section-wash-to-muted.test.mjs +0 -103
  176. package/assets/codemods/__tests__/runner.symlinks.test.mjs +0 -205
  177. package/assets/codemods/__tests__/runner.test.mjs +0 -559
  178. package/assets/codemods/__tests__/runner.unparseable.test.mjs +0 -457
  179. package/assets/codemods/__tests__/toolbar-density-to-size.test.mjs +0 -69
  180. package/assets/codemods/__tests__/validation.test.mjs +0 -108
  181. package/assets/codemods/file-count.test.mjs +0 -163
  182. package/assets/codemods/integration-discovery.test.mjs +0 -360
  183. package/assets/codemods/integration-runner.protection.test.mjs +0 -206
  184. package/assets/codemods/outcome.test.mjs +0 -40
  185. package/assets/codemods/term-log.test.mjs +0 -80
  186. package/assets/codemods/transform-prop.test.mjs +0 -130
  187. package/assets/codemods/transforms/v0.0.10/__tests__/remove-size-props.test.mjs +0 -144
  188. package/assets/codemods/transforms/v0.0.12/__tests__/add-is-icon-only.test.mjs +0 -193
  189. package/assets/codemods/transforms/v0.0.13/__tests__/icon-name-deprecations.test.mjs +0 -81
  190. package/assets/codemods/transforms/v0.0.13/__tests__/rename-attachments-to-drawer.test.mjs +0 -126
  191. package/assets/codemods/transforms/v0.0.14/__tests__/rename-action-props.test.mjs +0 -129
  192. package/assets/codemods/transforms/v0.0.14/__tests__/rename-status-variants.test.mjs +0 -126
  193. package/assets/codemods/transforms/v0.0.15/__tests__/migrate-item-children-to-endcontent.test.mjs +0 -95
  194. package/assets/codemods/transforms/v0.0.15/__tests__/migrate-selector-children-to-render-option.test.mjs +0 -109
  195. package/assets/codemods/transforms/v0.0.15/__tests__/migrate-theme-selectors-to-data-attrs.test.mjs +0 -44
  196. package/assets/codemods/transforms/v0.0.15/__tests__/rename-date-picker-to-input.test.mjs +0 -110
  197. package/assets/codemods/transforms/v0.0.15/__tests__/rename-stack-element-to-as.test.mjs +0 -71
  198. package/assets/codemods/transforms/v0.0.2/__tests__/migrate-badge-dot-to-statusdot.test.mjs +0 -137
  199. package/assets/codemods/transforms/v0.0.2/__tests__/migrate-gap-to-numeric.test.mjs +0 -161
  200. package/assets/codemods/transforms/v0.0.2/__tests__/migrate-isFullBleed-to-padding.test.mjs +0 -137
  201. package/assets/codemods/transforms/v0.0.2/__tests__/migrate-useXDSIcon-to-getIcon.test.mjs +0 -110
  202. package/assets/codemods/transforms/v0.0.2/__tests__/rename-banner-endButton-to-endContent.test.mjs +0 -61
  203. package/assets/codemods/transforms/v0.0.2/__tests__/rename-form-tooltip-startIcon.test.mjs +0 -130
  204. package/assets/codemods/transforms/v0.0.2/__tests__/rename-isShown-to-isOpen.test.mjs +0 -89
  205. package/assets/codemods/transforms/v0.0.2/__tests__/rename-selector-items-to-options.test.mjs +0 -74
  206. package/assets/codemods/transforms/v0.0.2/__tests__/rename-sidenav-header-to-heading.test.mjs +0 -140
  207. package/assets/codemods/transforms/v0.0.2/__tests__/rename-topnav-title-to-heading.test.mjs +0 -116
  208. package/assets/codemods/transforms/v0.0.2/__tests__/unify-uncontrolled-to-defaultX.test.mjs +0 -79
  209. package/assets/codemods/transforms/v0.0.2/__tests__/unify-visibility-to-onOpenChange.test.mjs +0 -130
  210. package/assets/codemods/transforms/v0.0.6/__tests__/migrate-badge-children-to-label.test.mjs +0 -46
  211. package/assets/codemods/transforms/v0.0.6/__tests__/migrate-collapse-to-collapsible.test.mjs +0 -72
  212. package/assets/codemods/transforms/v0.0.6/__tests__/migrate-radius-tokens.test.mjs +0 -98
  213. package/assets/codemods/transforms/v0.0.6/__tests__/migrate-shadow-tokens.test.mjs +0 -117
  214. package/assets/codemods/transforms/v0.0.6/__tests__/migrate-skeleton-radius.test.mjs +0 -75
  215. package/assets/codemods/transforms/v0.0.6/__tests__/migrate-token-names.test.mjs +0 -275
  216. package/assets/codemods/transforms/v0.0.7/__tests__/rename-banner-variant-to-container.test.mjs +0 -85
  217. package/assets/codemods/transforms/v0.0.8/__tests__/migrate-token-renames.test.mjs +0 -327
  218. package/assets/codemods/transforms/v0.0.8/__tests__/rename-endslot-to-endcontent.test.mjs +0 -98
  219. package/assets/codemods/transforms/v0.1.0/__tests__/drop-xds-prefix-imports.test.mjs +0 -460
  220. package/assets/codemods/transforms/v0.1.0/__tests__/migrate-xds-css-surfaces.test.mjs +0 -103
  221. package/assets/codemods/transforms/v0.1.0/__tests__/migrate-xds-declare-module.test.mjs +0 -61
  222. package/assets/codemods/transforms/v0.1.0/__tests__/migrate-xds-module-specifiers.test.mjs +0 -123
  223. package/assets/codemods/transforms/v0.1.0/__tests__/v0.1.0-ordering.test.mjs +0 -104
  224. package/assets/codemods/transforms/v0.1.2/__tests__/rename-text-color-active-to-accent.test.mjs +0 -120
  225. package/assets/codemods/transforms/v0.1.3/__tests__/migrate-layout-components-to-experimental.test.mjs +0 -574
  226. package/assets/codemods/transforms/v0.1.5/__tests__/rename-switch-label-spacing-default-to-hug.test.mjs +0 -93
  227. package/assets/codemods/transforms/v0.1.7/__tests__/migrate-table-tableprops-to-direct-props.test.mjs +0 -120
  228. package/assets/codemods/transforms/v0.1.7/__tests__/rename-table-renderprops-styles-to-xstyle.test.mjs +0 -112
  229. package/assets/codemods/transforms/v0.1.8/__tests__/rename-avatar-size-scale.test.mjs +0 -129
  230. package/assets/codemods/transforms/v0.2.0/__tests__/remove-tablist-orientation.test.mjs +0 -81
  231. package/assets/codemods/transforms/v0.2.1/__tests__/migrate-dialog-position-to-logical.test.mjs +0 -119
  232. package/assets/codemods/transforms/v0.3.0/__tests__/authoring-migration.e2e.test.mjs +0 -296
  233. package/assets/codemods/transforms/v0.3.0/__tests__/authoring-migration.tsc.test.mjs +0 -139
  234. package/assets/codemods/transforms/v0.3.0/__tests__/migrate-authoring-imports.test.mjs +0 -80
  235. package/assets/codemods/transforms/v0.3.0/__tests__/migrate-grid-minchildwidth-to-columns.test.mjs +0 -82
  236. package/assets/codemods/transforms/v0.3.0/__tests__/next-codemods.test.mjs +0 -64
  237. package/assets/codemods/transforms/v0.3.0/__tests__/rename-authoring-doctypes.test.mjs +0 -94
  238. package/assets/codemods/transforms/v0.3.0/__tests__/rename-radiogroup-arialabel-to-label.test.mjs +0 -86
  239. package/assets/codemods/transforms/v0.3.0/__tests__/unwrap-authoring-factories.test.mjs +0 -170
  240. package/assets/codemods/transforms/v0.4.0/__tests__/migrate-table-rowexpansion-to-tree.test.mjs +0 -201
  241. package/assets/codemods/transforms/v0.4.0/__tests__/next-codemods.test.mjs +0 -154
  242. package/assets/codemods/transforms/v0.5.0/__tests__/next-codemods.test.mjs +0 -127
  243. package/assets/codemods/transforms/v0.6.0/__tests__/migrate-astryx-theme-selectors-to-data-attrs.test.mjs +0 -398
  244. package/assets/codemods/transforms/v0.6.0/__tests__/next-codemods.test.mjs +0 -270
  245. package/assets/codemods/transforms/v0.6.4/__tests__/migrate-native-picker-to-presentation.test.mjs +0 -63
  246. package/assets/codemods/transforms/v0.6.4/__tests__/migrate-theme-catalog-to-descriptors.test.mjs +0 -220
  247. package/assets/codemods/transforms/v0.6.7/__tests__/migrate-copied-themes-to-descriptors.test.mjs +0 -129
  248. package/assets/codemods/transforms/v0.7.0/__tests__/migrate-deprecated-theme-surface.test.mjs +0 -523
  249. package/assets/codemods/transforms/v0.7.0/__tests__/migrate-field-input-styling.test.mjs +0 -108
  250. package/assets/codemods/transforms/v0.7.0/__tests__/preserve-bottom-sheet-content-padding.test.mjs +0 -178
  251. package/assets/codemods/transforms/v0.7.0/__tests__/rename-empty-search-results-text.test.mjs +0 -202
  252. package/assets/codemods/transforms/v0.7.0/__tests__/validate-data-token-ownership.test.mjs +0 -168
  253. package/assets/codemods/transforms/v0.7.2/__tests__/migrate-list-edge-compensation-to-edge.test.mjs +0 -120
  254. package/assets/codemods/transforms/v0.7.5/__tests__/migrate-codeblock-tokenizer-to-language.test.mjs +0 -130
  255. package/authoring/_shared/errors.test.mjs +0 -49
  256. package/authoring/codemod/parse.test.mjs +0 -99
  257. package/authoring/config/debug-composition.test.mjs +0 -92
  258. package/authoring/config/parse.test.mjs +0 -121
  259. package/authoring/debug/parse.test.mjs +0 -187
  260. package/authoring/discover/parse.test.mjs +0 -158
  261. package/authoring/doctypes/doc-stability-types.test.mjs +0 -91
  262. package/authoring/doctypes/doctypes-new.test.mjs +0 -162
  263. package/authoring/doctypes/icon-definition/parse.test.mjs +0 -78
  264. package/authoring/doctypes/icon-set/icon-names.test.mjs +0 -26
  265. package/authoring/doctypes/icon-set/parse.test.mjs +0 -179
  266. package/authoring/doctypes/load-contract.test.mjs +0 -246
  267. package/authoring/doctypes/namespace/parse.test.mjs +0 -163
  268. package/authoring/doctypes/parse.test.mjs +0 -422
  269. package/authoring/doctypes/template/parse.test.mjs +0 -198
  270. package/authoring/gap-report/parse.test.mjs +0 -172
  271. package/authoring/integration/parse.test.mjs +0 -184
  272. package/authoring/shadcn/receipt.test.mjs +0 -187
  273. package/authoring/shadcn/source-variants.test.mjs +0 -120
  274. package/clients/cli/__tests__/cliManifest.test.ts +0 -37
  275. package/clients/cli/cli-command.test.mjs +0 -166
  276. package/clients/cli/cli-exit-codes.test.mjs +0 -163
  277. package/clients/cli/command-load-failure.test.mjs +0 -83
  278. package/clients/cli/command-result-coverage.test.mjs +0 -136
  279. package/clients/cli/commands/blog.test.mjs +0 -138
  280. package/clients/cli/commands/build-theme.adaptations.test.mjs +0 -773
  281. package/clients/cli/commands/build-theme.ascii-output.test.mjs +0 -198
  282. package/clients/cli/commands/build-theme.batch-report.test.mjs +0 -349
  283. package/clients/cli/commands/build-theme.color-scheme.test.mjs +0 -136
  284. package/clients/cli/commands/build-theme.data-tokens.test.mjs +0 -92
  285. package/clients/cli/commands/build-theme.flag-docs.test.mjs +0 -110
  286. package/clients/cli/commands/build-theme.font-warning.test.mjs +0 -170
  287. package/clients/cli/commands/build-theme.icons-specifier.test.mjs +0 -350
  288. package/clients/cli/commands/build-theme.import-path.test.mjs +0 -103
  289. package/clients/cli/commands/build-theme.multi.test.mjs +0 -148
  290. package/clients/cli/commands/build-theme.outside-project.test.mjs +0 -140
  291. package/clients/cli/commands/build-theme.path-safety.test.mjs +0 -398
  292. package/clients/cli/commands/build-theme.prose.test.mjs +0 -103
  293. package/clients/cli/commands/build-theme.registry.test.mjs +0 -160
  294. package/clients/cli/commands/build-theme.variants.test.mjs +0 -560
  295. package/clients/cli/commands/build-theme.watch.test.mjs +0 -320
  296. package/clients/cli/commands/build.error-codes.test.mjs +0 -50
  297. package/clients/cli/commands/build.exit-codes-doc.test.mjs +0 -54
  298. package/clients/cli/commands/build.playbook.test.mjs +0 -75
  299. package/clients/cli/commands/build.text-fields.test.mjs +0 -81
  300. package/clients/cli/commands/cli-postinstall.test.mjs +0 -90
  301. package/clients/cli/commands/component-batch.test.mjs +0 -341
  302. package/clients/cli/commands/component-ownership.test.mjs +0 -384
  303. package/clients/cli/commands/component-package.test.mjs +0 -169
  304. package/clients/cli/commands/component-replacement.text.test.mjs +0 -316
  305. package/clients/cli/commands/component-resolution.test.mjs +0 -204
  306. package/clients/cli/commands/component.test.mjs +0 -612
  307. package/clients/cli/commands/debug-result-summary.test.mjs +0 -214
  308. package/clients/cli/commands/detail-levels.test.mjs +0 -145
  309. package/clients/cli/commands/dialog-adaptive-template.test.mjs +0 -24
  310. package/clients/cli/commands/discover.broken-integration.test.mjs +0 -163
  311. package/clients/cli/commands/discover.components-flag.test.mjs +0 -97
  312. package/clients/cli/commands/discover.icon-sets.test.mjs +0 -133
  313. package/clients/cli/commands/discover.no-source.test.mjs +0 -490
  314. package/clients/cli/commands/discover.sources.test.mjs +0 -292
  315. package/clients/cli/commands/discover.text-projection.test.mjs +0 -103
  316. package/clients/cli/commands/docs.depth.test.mjs +0 -219
  317. package/clients/cli/commands/docs.test.mjs +0 -385
  318. package/clients/cli/commands/doctor-integration.package-json.test.mjs +0 -53
  319. package/clients/cli/commands/doctor-integration.test.mjs +0 -1483
  320. package/clients/cli/commands/doctor.test.mjs +0 -509
  321. package/clients/cli/commands/empty-argument.test.mjs +0 -16
  322. package/clients/cli/commands/external-showcase.test.mjs +0 -121
  323. package/clients/cli/commands/gap-report.test.mjs +0 -412
  324. package/clients/cli/commands/hook.text-projection.test.mjs +0 -45
  325. package/clients/cli/commands/icon-authoring.test.mjs +0 -2845
  326. package/clients/cli/commands/icon-options-wiring.test.mjs +0 -158
  327. package/clients/cli/commands/icon-sets-guide.test.mjs +0 -186
  328. package/clients/cli/commands/icon.test.mjs +0 -96
  329. package/clients/cli/commands/import-hint-correctness.test.mjs +0 -274
  330. package/clients/cli/commands/init.behavior.test.mjs +0 -434
  331. package/clients/cli/commands/init.flag-help.test.mjs +0 -151
  332. package/clients/cli/commands/init.next-steps.test.mjs +0 -41
  333. package/clients/cli/commands/integration-add.controls.test.mjs +0 -132
  334. package/clients/cli/commands/integration-authoring.test.mjs +0 -288
  335. package/clients/cli/commands/integration-check.test.mjs +0 -522
  336. package/clients/cli/commands/integration-real-world.test.mjs +0 -661
  337. package/clients/cli/commands/interactive-guard.test.mjs +0 -143
  338. package/clients/cli/commands/json-contract.test.mjs +0 -216
  339. package/clients/cli/commands/no-prompt-wording.test.mjs +0 -94
  340. package/clients/cli/commands/option-pair-refusals.test.mjs +0 -37
  341. package/clients/cli/commands/outside-project.test.mjs +0 -874
  342. package/clients/cli/commands/search.test.mjs +0 -514
  343. package/clients/cli/commands/setup-nudge.test.mjs +0 -280
  344. package/clients/cli/commands/silent-success-refusals.test.mjs +0 -15
  345. package/clients/cli/commands/swizzle.path-safety.test.mjs +0 -137
  346. package/clients/cli/commands/swizzle.routing.test.mjs +0 -342
  347. package/clients/cli/commands/template-cdn.behavior.test.mjs +0 -113
  348. package/clients/cli/commands/template.copy-receipt.test.mjs +0 -60
  349. package/clients/cli/commands/template.flag-help.test.mjs +0 -124
  350. package/clients/cli/commands/template.icons.test.mjs +0 -132
  351. package/clients/cli/commands/template.path-help.test.mjs +0 -40
  352. package/clients/cli/commands/template.path-safety.test.mjs +0 -82
  353. package/clients/cli/commands/template.show-media.test.mjs +0 -62
  354. package/clients/cli/commands/template.test.mjs +0 -62
  355. package/clients/cli/commands/text-json-parity.test.mjs +0 -850
  356. package/clients/cli/commands/theme-add-lifecycle.test.mjs +0 -228
  357. package/clients/cli/commands/theme-list.behavior.test.mjs +0 -51
  358. package/clients/cli/commands/theme-palette-generate.test.mjs +0 -154
  359. package/clients/cli/commands/theme-targets.behavior.test.mjs +0 -84
  360. package/clients/cli/commands/theme-template.behavior.test.mjs +0 -97
  361. package/clients/cli/commands/upgrade.ascii-output.test.mjs +0 -101
  362. package/clients/cli/commands/upgrade.config-ordering.test.mjs +0 -342
  363. package/clients/cli/commands/upgrade.file-protection.test.mjs +0 -404
  364. package/clients/cli/commands/upgrade.flag-help.test.mjs +0 -221
  365. package/clients/cli/commands/upgrade.hook-output.test.mjs +0 -89
  366. package/clients/cli/commands/upgrade.integration-policy.test.mjs +0 -581
  367. package/clients/cli/commands/upgrade.older-cli.test.mjs +0 -160
  368. package/clients/cli/commands/upgrade.outcomes.test.mjs +0 -350
  369. package/clients/cli/commands/upgrade.subfolder-path.test.mjs +0 -97
  370. package/clients/cli/commands/upgrade.test.mjs +0 -361
  371. package/clients/cli/commands/validate-nothing-exits-nonzero.test.mjs +0 -67
  372. package/clients/cli/commands/write-failure.test.mjs +0 -175
  373. package/clients/cli/e2e-smoke.test.mjs +0 -162
  374. package/clients/cli/error-envelope-code.test.mjs +0 -38
  375. package/clients/cli/formatters/index.test.mjs +0 -262
  376. package/clients/cli/latest-version-env.test.mjs +0 -50
  377. package/clients/cli/lib/cli-error.test.mjs +0 -206
  378. package/clients/cli/lib/component-format.test.mjs +0 -246
  379. package/clients/cli/lib/define-command.test.mjs +0 -103
  380. package/clients/cli/lib/doc-text-ascii.test.mjs +0 -85
  381. package/clients/cli/lib/exit-codes.test.mjs +0 -111
  382. package/clients/cli/lib/hook-format.test.mjs +0 -35
  383. package/clients/cli/lib/json-shim.test.mjs +0 -268
  384. package/clients/cli/lib/manifest.test.mjs +0 -346
  385. package/clients/cli/lib/parse-error-format.test.mjs +0 -81
  386. package/clients/cli/lib/resolve-theme.test.mjs +0 -543
  387. package/foundation/agent-docs/agent-docs.path-safety.test.mjs +0 -1550
  388. package/foundation/agent-docs/agent-docs.test.mjs +0 -1937
  389. package/foundation/agent-docs/app-theme-workflow.test.mjs +0 -16
  390. package/foundation/agent-docs/computer-agent-text.test.mjs +0 -699
  391. package/foundation/config/config-cache.test.mjs +0 -83
  392. package/foundation/config/config-writer.test.mjs +0 -84
  393. package/foundation/config/integration-debug.test.mjs +0 -218
  394. package/foundation/config/project-themes.test.mjs +0 -119
  395. package/foundation/config/project.test.mjs +0 -931
  396. package/foundation/config/theme-private-vars.test.mjs +0 -55
  397. package/foundation/config/theme-state.test.mjs +0 -182
  398. package/foundation/debug/debug-fields.test.mjs +0 -327
  399. package/foundation/debug/integration-handlers.test.mjs +0 -267
  400. package/foundation/debug/on-event.test.mjs +0 -643
  401. package/foundation/debug/privacy-contract.test.mjs +0 -195
  402. package/foundation/debug/redact.test.mjs +0 -534
  403. package/foundation/discovery/authoring-self-docs.test.mjs +0 -202
  404. package/foundation/discovery/authoring-surface.test.mjs +0 -392
  405. package/foundation/discovery/cli-self-docs.test.mjs +0 -396
  406. package/foundation/discovery/component-discovery.export-names.test.mjs +0 -832
  407. package/foundation/discovery/component-discovery.importpath.test.mjs +0 -59
  408. package/foundation/discovery/component-discovery.test.mjs +0 -336
  409. package/foundation/discovery/component-loader.test.mjs +0 -190
  410. package/foundation/discovery/component-replacement.test.mjs +0 -520
  411. package/foundation/discovery/componentDocOverlay.test.mjs +0 -159
  412. package/foundation/discovery/copied-passages.test.mjs +0 -124
  413. package/foundation/discovery/doc-consistency.test.mjs +0 -347
  414. package/foundation/discovery/doc-fluff.test.mjs +0 -142
  415. package/foundation/discovery/doc-types.test.mjs +0 -774
  416. package/foundation/discovery/docs-discovery.test.mjs +0 -707
  417. package/foundation/discovery/docs-section-key.test.mjs +0 -246
  418. package/foundation/discovery/hook-discovery.test.mjs +0 -216
  419. package/foundation/discovery/icon-set-checks.test.mjs +0 -1018
  420. package/foundation/discovery/icon-set-discovery.test.mjs +0 -320
  421. package/foundation/discovery/icon-set-writer.test.mjs +0 -26
  422. package/foundation/discovery/integration-doc-files.test.mjs +0 -275
  423. package/foundation/discovery/module-exports.test.mjs +0 -209
  424. package/foundation/discovery/package-tsconfig.test.mjs +0 -210
  425. package/foundation/discovery/prop-drift.test.mjs +0 -2337
  426. package/foundation/discovery/runner-commands.test.mjs +0 -131
  427. package/foundation/discovery/stray-pointers.test.mjs +0 -92
  428. package/foundation/discovery/template-adapter.fixture-refs.test.mjs +0 -284
  429. package/foundation/discovery/template-adapter.integration-isolation.test.mjs +0 -94
  430. package/foundation/discovery/template-adapter.test.mjs +0 -223
  431. package/foundation/discovery/template-conflict-release.test.mjs +0 -40
  432. package/foundation/discovery/template-icons.test.mjs +0 -560
  433. package/foundation/discovery/template-needs.test.mjs +0 -306
  434. package/foundation/discovery/theme-discovery.test.mjs +0 -775
  435. package/foundation/discovery/theme-imports.test.mjs +0 -173
  436. package/foundation/discovery/theming-targets.test.mjs +0 -328
  437. package/foundation/discovery/type-match.test.mjs +0 -169
  438. package/foundation/discovery/type-text.test.mjs +0 -196
  439. package/foundation/discovery/unresolved-references.test.mjs +0 -567
  440. package/foundation/doc-compiler/bundle.test.mjs +0 -266
  441. package/foundation/doc-compiler/doc-compiler.test.mjs +0 -714
  442. package/foundation/doc-compiler/doc-loads.test.mjs +0 -1762
  443. package/foundation/doc-compiler/doc-syntax.test.mjs +0 -383
  444. package/foundation/doc-compiler/inputs.test.mjs +0 -298
  445. package/foundation/doc-compiler/links.test.mjs +0 -285
  446. package/foundation/doc-compiler/lower-doc.test.mjs +0 -495
  447. package/foundation/doc-compiler/read.test.mjs +0 -380
  448. package/foundation/doc-compiler/split-topic-keywords.test.mjs +0 -74
  449. package/foundation/doc-compiler/tree.test.mjs +0 -691
  450. package/foundation/env/cli-command.test.mjs +0 -129
  451. package/foundation/env/node-version.test.mjs +0 -103
  452. package/foundation/env/package-manager.global.test.mjs +0 -66
  453. package/foundation/env/package-manager.test.mjs +0 -897
  454. package/foundation/env/search-path.test.mjs +0 -122
  455. package/foundation/env/semver.test.mjs +0 -111
  456. package/foundation/env/user-dirs.test.mjs +0 -72
  457. package/foundation/env/user-settings.test.mjs +0 -64
  458. package/foundation/fs/file-protection.test.mjs +0 -250
  459. package/foundation/fs/listing-cache.test.mjs +0 -88
  460. package/foundation/fs/module-loader.stdout.test.mjs +0 -333
  461. package/foundation/fs/module-loader.test.mjs +0 -410
  462. package/foundation/fs/path-safety.test.mjs +0 -222
  463. package/foundation/fs/paths.test.mjs +0 -725
  464. package/foundation/fs/publish-file-eperm-mutation.test.mjs +0 -64
  465. package/foundation/fs/publish-file-hardlink-unavailable.test.mjs +0 -142
  466. package/foundation/fs/publish-file.test.mjs +0 -136
  467. package/foundation/fs/read-record.test.mjs +0 -164
  468. package/foundation/identity/provider-identity.test.mjs +0 -254
  469. package/foundation/integrations/autolink.test.mjs +0 -430
  470. package/foundation/integrations/cli-peer-version.test.mjs +0 -354
  471. package/foundation/integrations/cli-requirement.test.mjs +0 -383
  472. package/foundation/integrations/computer-integrations.test.mjs +0 -292
  473. package/foundation/integrations/contribution-inventory.test.mjs +0 -420
  474. package/foundation/integrations/integration-warnings.test.mjs +0 -191
  475. package/foundation/integrations/integrations.test.mjs +0 -818
  476. package/foundation/integrations/manifest-writer.test.mjs +0 -271
  477. package/foundation/integrations/provider-conflicts.test.mjs +0 -125
  478. package/foundation/integrations/provider-ledger.test.mjs +0 -275
  479. package/foundation/integrations/provider-resolution.test.mjs +0 -369
  480. package/foundation/integrations/public-imports.test.mjs +0 -1793
  481. package/foundation/release/cache.test.mjs +0 -923
  482. package/foundation/release/choose.test.mjs +0 -427
  483. package/foundation/release/global-state.test.mjs +0 -381
  484. package/foundation/release/handoff.e2e.test.mjs +0 -278
  485. package/foundation/release/notices.test.mjs +0 -586
  486. package/foundation/release/project.test.mjs +0 -288
  487. package/foundation/render/render.test.mjs +0 -117
  488. package/foundation/response/error-codes.test.mjs +0 -297
  489. package/foundation/response/json-contract.test.mjs +0 -235
  490. package/foundation/response/json-serialize.test.mjs +0 -66
  491. package/foundation/response/response-types.doc.test.mjs +0 -278
  492. package/foundation/route/route.test.mjs +0 -153
  493. package/foundation/runtime/hosted-runtime.test.mjs +0 -403
  494. package/foundation/runtime/package-set.test.mjs +0 -432
  495. package/foundation/text/copyright-header.test.mjs +0 -58
  496. package/foundation/text/levenshtein.test.mjs +0 -53
  497. package/foundation/text/string-utils.test.mjs +0 -175
  498. package/foundation/text/suggest-order.test.mjs +0 -312
  499. package/foundation/xle/browser-imports.test.mjs +0 -74
  500. package/foundation/xle/expand.test.mjs +0 -54
  501. package/foundation/xle/print.test.mjs +0 -50
  502. package/foundation/xle/registry.test.mjs +0 -28
  503. package/foundation/xle/xle.test.mjs +0 -382
  504. package/host/door-conformance.test.mjs +0 -274
  505. package/host/index.test.mjs +0 -302
@@ -1,2512 +0,0 @@
1
- // Copyright (c) Meta Platforms, Inc. and affiliates.
2
-
3
- import {afterEach, beforeEach, describe, expect, it, vi} from 'vitest';
4
- import * as fs from 'node:fs';
5
- import * as os from 'node:os';
6
- import * as path from 'node:path';
7
- import {spawnSync} from 'node:child_process';
8
- import {createHash} from 'node:crypto';
9
- import {
10
- integrationPackCheck,
11
- normalizeThemeVerifyForCompare,
12
- parseNpmPackOutput,
13
- } from './pack-check.mjs';
14
- import {normalizeThemeBuildForCompare} from '../theme/build/build.mjs';
15
- import {released065Ocean} from './__fixtures__/released-0.6.5-ocean.mjs';
16
- import {
17
- integrationAddComponent,
18
- integrationAddTemplate,
19
- } from './add-contribution.mjs';
20
- import {formatCliCommand} from '../../foundation/env/package-manager.mjs';
21
-
22
- let tmpDir;
23
-
24
- beforeEach(() => {
25
- tmpDir = fs.mkdtempSync(path.join(process.cwd(), '.astryx-pack-check-'));
26
- });
27
-
28
- afterEach(() => {
29
- fs.rmSync(tmpDir, {recursive: true, force: true});
30
- });
31
-
32
- function generatedCssArtifact({
33
- source = 'themes/ocean/oceanTheme.ts',
34
- cli = '0.6.6',
35
- core = '0.6.6',
36
- body = ':root { color: red; }',
37
- } = {}) {
38
- return `/*
39
- * @generated by \`astryx theme build\` — do not edit manually.
40
- * Source: ${source}
41
- * Command: astryx theme build ${source}
42
- * CLI: @astryxdesign/cli@${cli}
43
- * Core: @astryxdesign/core@${core}
44
- */
45
-
46
- ${body}
47
- `;
48
- }
49
-
50
- function generatedJsArtifact({
51
- source = 'themes/ocean/oceanTheme.ts',
52
- cli = '0.6.6',
53
- core = '0.6.6',
54
- body = "export const oceanTheme = {name: 'ocean'};",
55
- } = {}) {
56
- return `/**
57
- * @generated by \`astryx theme build\` — do not edit manually.
58
- * Source: ${source}
59
- * CLI: @astryxdesign/cli@${cli}
60
- * Core: @astryxdesign/core@${core}
61
- */
62
-
63
- ${body}
64
- `;
65
- }
66
-
67
- describe('verify-only generated CSS header normalization', () => {
68
- it('ignores one source path and exact version pair but leaves build --check strict', () => {
69
- const current = generatedCssArtifact();
70
- const released = generatedCssArtifact({
71
- source: 'oceanTheme.ts',
72
- cli: '0.6.5',
73
- core: '0.6.5',
74
- });
75
-
76
- expect(normalizeThemeVerifyForCompare(released)).toBe(
77
- normalizeThemeVerifyForCompare(current),
78
- );
79
- expect(normalizeThemeBuildForCompare(released)).not.toBe(
80
- normalizeThemeBuildForCompare(current),
81
- );
82
- expect(released).not.toBe(current);
83
- });
84
-
85
- it.each([
86
- ['body change', source => source.replace('color: red', 'color: blue')],
87
- [
88
- 'Source text in the CSS body',
89
- source =>
90
- source.replace(
91
- ':root { color: red; }',
92
- ':root { color: red; }\n * Source: body.css',
93
- ),
94
- ],
95
- [
96
- 'header reordering',
97
- source =>
98
- source.replace(
99
- ' * CLI: @astryxdesign/cli@0.6.6\n * Core: @astryxdesign/core@0.6.6',
100
- ' * Core: @astryxdesign/core@0.6.6\n * CLI: @astryxdesign/cli@0.6.6',
101
- ),
102
- ],
103
- [
104
- 'other header change',
105
- source => source.replace('@generated by', '@generated with'),
106
- ],
107
- [
108
- 'missing version line',
109
- source => source.replace(' * CLI: @astryxdesign/cli@0.6.6\n', ''),
110
- ],
111
- [
112
- 'duplicate version line',
113
- source =>
114
- source.replace(
115
- ' * CLI: @astryxdesign/cli@0.6.6\n',
116
- ' * CLI: @astryxdesign/cli@0.6.6\n * CLI: @astryxdesign/cli@0.6.5\n',
117
- ),
118
- ],
119
- [
120
- 'malformed version line',
121
- source =>
122
- source.replace(
123
- 'CLI: @astryxdesign/cli@0.6.6',
124
- 'CLI: malformed-version-header',
125
- ),
126
- ],
127
- [
128
- 'missing Source line',
129
- source => source.replace(' * Source: themes/ocean/oceanTheme.ts\n', ''),
130
- ],
131
- [
132
- 'duplicate Source line',
133
- source =>
134
- source.replace(
135
- ' * Source: themes/ocean/oceanTheme.ts\n',
136
- ' * Source: themes/ocean/oceanTheme.ts\n * Source: oceanTheme.ts\n',
137
- ),
138
- ],
139
- [
140
- 'malformed Source line',
141
- source =>
142
- source.replace(' * Source: themes/ocean/oceanTheme.ts', ' * Source: '),
143
- ],
144
- ])('keeps a %s significant', (_label, mutate) => {
145
- const current = generatedCssArtifact();
146
- expect(normalizeThemeVerifyForCompare(mutate(current))).not.toBe(
147
- normalizeThemeVerifyForCompare(current),
148
- );
149
- });
150
-
151
- it('normalizes one generated JavaScript header source and version pair', () => {
152
- const current = generatedJsArtifact();
153
- const fromThemeDir = generatedJsArtifact({
154
- source: 'oceanTheme.ts',
155
- cli: '0.6.5',
156
- core: '0.6.5',
157
- });
158
- expect(normalizeThemeVerifyForCompare(fromThemeDir)).toBe(
159
- normalizeThemeVerifyForCompare(current),
160
- );
161
- expect(normalizeThemeBuildForCompare(fromThemeDir)).not.toBe(
162
- normalizeThemeBuildForCompare(current),
163
- );
164
- });
165
-
166
- it.each([
167
- [
168
- 'JavaScript body change',
169
- source => source.replace("name: 'ocean'", "name: 'reef'"),
170
- ],
171
- [
172
- 'Source text in the JavaScript body',
173
- source =>
174
- source.replace(
175
- "export const oceanTheme = {name: 'ocean'};",
176
- "export const oceanTheme = {name: 'ocean'};\n * Source: body.js",
177
- ),
178
- ],
179
- [
180
- 'missing JavaScript Source line',
181
- source => source.replace(' * Source: themes/ocean/oceanTheme.ts\n', ''),
182
- ],
183
- [
184
- 'duplicate JavaScript Source line',
185
- source =>
186
- source.replace(
187
- ' * Source: themes/ocean/oceanTheme.ts\n',
188
- ' * Source: themes/ocean/oceanTheme.ts\n * Source: oceanTheme.ts\n',
189
- ),
190
- ],
191
- [
192
- 'malformed JavaScript Source line',
193
- source =>
194
- source.replace(' * Source: themes/ocean/oceanTheme.ts', ' * Source: '),
195
- ],
196
- ])('keeps a %s significant', (_label, mutate) => {
197
- const current = generatedJsArtifact();
198
- expect(normalizeThemeVerifyForCompare(mutate(current))).not.toBe(
199
- normalizeThemeVerifyForCompare(current),
200
- );
201
- });
202
- });
203
-
204
- /**
205
- * Write a minimal integration package into tmpDir.
206
- * Returns the package directory.
207
- */
208
- function writePackage({
209
- name = '@acme/widgets',
210
- version = '1.0.0',
211
- files,
212
- manifest = "export default {themes: './themes'};\n",
213
- themes = true,
214
- themeExports = false,
215
- npmignore,
216
- components = false,
217
- templates = false,
218
- scripts,
219
- } = {}) {
220
- const pkg = {name, version};
221
- // A theme needs a CLI that reads typed theme descriptors.
222
- if (themes) pkg.peerDependencies = {'@astryxdesign/cli': '>=0.6.4'};
223
- if (files !== undefined) pkg.files = files;
224
- if (scripts !== undefined) pkg.scripts = scripts;
225
- if (themes && themeExports) {
226
- pkg.exports = {
227
- './themes/ocean': './themes/ocean/ocean.js',
228
- './themes/ocean.css': './themes/ocean/ocean.css',
229
- };
230
- }
231
- fs.writeFileSync(
232
- path.join(tmpDir, 'package.json'),
233
- JSON.stringify(pkg, null, 2) + '\n',
234
- );
235
- if (manifest != null) {
236
- fs.writeFileSync(path.join(tmpDir, 'astryx.integration.mjs'), manifest);
237
- }
238
- if (themes) {
239
- const root = path.join(tmpDir, 'themes');
240
- fs.mkdirSync(path.join(root, 'ocean'), {recursive: true});
241
- fs.writeFileSync(
242
- path.join(root, 'ocean', 'oceanTheme.ts'),
243
- "import {defineTheme} from '@astryxdesign/core/theme';\n\nexport const oceanTheme = defineTheme({name: 'ocean'});\n",
244
- );
245
- fs.writeFileSync(
246
- path.join(root, 'ocean', 'oceanTheme.doc.mjs'),
247
- `/** @type {import('@astryxdesign/cli/authoring').ThemeDoc} */
248
- export default {type: 'theme', name: 'ocean', displayName: 'Ocean', description: 'Ocean theme.', maintained: true};
249
- `,
250
- );
251
- if (themeExports) {
252
- const built = spawnSync(
253
- process.execPath,
254
- [
255
- path.join(process.cwd(), 'packages/cli/clients/cli/bin/astryx.mjs'),
256
- 'theme',
257
- 'build',
258
- 'themes/ocean/oceanTheme.ts',
259
- ],
260
- {cwd: tmpDir, encoding: 'utf-8', timeout: 30_000},
261
- );
262
- if (built.status !== 0) {
263
- throw new Error(
264
- `Could not build the theme fixture: ${built.stderr || built.stdout}`,
265
- );
266
- }
267
- }
268
- }
269
- if (components) {
270
- const root = path.join(tmpDir, 'components');
271
- fs.mkdirSync(root, {recursive: true});
272
- fs.writeFileSync(
273
- path.join(root, 'Card.tsx'),
274
- 'export default function Card() { return null; }\n',
275
- );
276
- }
277
- if (templates) {
278
- const root = path.join(tmpDir, 'templates');
279
- fs.mkdirSync(root, {recursive: true});
280
- fs.writeFileSync(
281
- path.join(root, 'stray.tsx'),
282
- 'export default function Stray() { return null; }\n',
283
- );
284
- }
285
- if (npmignore) {
286
- fs.writeFileSync(path.join(tmpDir, '.npmignore'), npmignore);
287
- }
288
- return tmpDir;
289
- }
290
-
291
- function setThemeExports(exportsMap) {
292
- const packageFile = path.join(tmpDir, 'package.json');
293
- const pkg = JSON.parse(fs.readFileSync(packageFile, 'utf-8'));
294
- pkg.exports = exportsMap;
295
- fs.writeFileSync(packageFile, `${JSON.stringify(pkg, null, 2)}\n`);
296
- }
297
-
298
- function runCliVerify() {
299
- const run = spawnSync(
300
- process.execPath,
301
- [
302
- path.join(process.cwd(), 'packages/cli/clients/cli/bin/astryx.mjs'),
303
- 'integration',
304
- 'verify',
305
- '--json',
306
- ],
307
- {cwd: tmpDir, encoding: 'utf-8', timeout: 30_000},
308
- );
309
- return {
310
- status: run.status,
311
- stderr: run.stderr,
312
- receipt: run.stdout ? JSON.parse(run.stdout) : null,
313
- };
314
- }
315
-
316
- /**
317
- * Give the built ocean theme a font stylesheet and an entry module that loads
318
- * the theme's own styles, and export them the way such a package does.
319
- * @param {string} entry
320
- * @param {string} [file] the entry's file name in `entries/`
321
- */
322
- function writeOwnStylesEntry(entry, file = 'ocean.mjs') {
323
- fs.writeFileSync(
324
- path.join(tmpDir, 'themes', 'ocean', 'ocean.fonts.css'),
325
- "@font-face { font-family: 'Ocean Sans'; src: local('Ocean Sans'); }\n",
326
- );
327
- fs.mkdirSync(path.join(tmpDir, 'entries'), {recursive: true});
328
- fs.writeFileSync(path.join(tmpDir, 'entries', file), entry);
329
- const packageFile = path.join(tmpDir, 'package.json');
330
- const pkg = JSON.parse(fs.readFileSync(packageFile, 'utf-8'));
331
- pkg.files = ['astryx.integration.mjs', 'themes', 'entries'];
332
- pkg.exports = {
333
- './themes/ocean': `./entries/${file}`,
334
- './themes/ocean.css': './themes/ocean/ocean.css',
335
- './themes/ocean.fonts.css': './themes/ocean/ocean.fonts.css',
336
- };
337
- fs.writeFileSync(packageFile, `${JSON.stringify(pkg, null, 2)}\n`);
338
- }
339
-
340
- /**
341
- * Rename the ocean theme to deep-sea, keeping its `ocean` slug, and build it,
342
- * so its outputs are named after the theme: `deep-sea.css` and `deep-sea.js`,
343
- * which exports `deepSeaTheme`.
344
- */
345
- function writeRenamedOcean() {
346
- writePackage({files: ['astryx.integration.mjs', 'themes', 'entries']});
347
- fs.writeFileSync(
348
- path.join(tmpDir, 'themes', 'ocean', 'oceanTheme.ts'),
349
- "import {defineTheme} from '@astryxdesign/core/theme';\n\nexport const oceanTheme = defineTheme({name: 'deep-sea'});\n",
350
- );
351
- const built = spawnSync(
352
- process.execPath,
353
- [
354
- path.join(process.cwd(), 'packages/cli/clients/cli/bin/astryx.mjs'),
355
- 'theme',
356
- 'build',
357
- 'themes/ocean/oceanTheme.ts',
358
- ],
359
- {cwd: tmpDir, encoding: 'utf-8', timeout: 30_000},
360
- );
361
- if (built.status !== 0) {
362
- throw new Error(`Could not build the theme fixture: ${built.stderr}`);
363
- }
364
- }
365
-
366
- /**
367
- * Give the ocean theme an icon registry and build it, so its built module
368
- * also exports `oceanIcons`.
369
- */
370
- function writeOceanWithIcons() {
371
- writePackage({files: ['astryx.integration.mjs', 'themes', 'entries']});
372
- const themeDir = path.join(tmpDir, 'themes', 'ocean');
373
- fs.writeFileSync(
374
- path.join(themeDir, 'icons.js'),
375
- 'export const oceanIcons = {};\n',
376
- );
377
- fs.writeFileSync(
378
- path.join(themeDir, 'oceanTheme.ts'),
379
- "import {defineTheme} from '@astryxdesign/core/theme';\nimport {oceanIcons} from './icons';\n\nexport const oceanTheme = defineTheme({name: 'ocean', icons: oceanIcons});\n",
380
- );
381
- const built = spawnSync(
382
- process.execPath,
383
- [
384
- path.join(process.cwd(), 'packages/cli/clients/cli/bin/astryx.mjs'),
385
- 'theme',
386
- 'build',
387
- 'themes/ocean/oceanTheme.ts',
388
- ],
389
- {cwd: tmpDir, encoding: 'utf-8', timeout: 30_000},
390
- );
391
- if (built.status !== 0) {
392
- throw new Error(`Could not build the theme fixture: ${built.stderr}`);
393
- }
394
- }
395
-
396
- // An entry like one whose import is the whole integration: it loads the
397
- // theme's fonts and stylesheet, by relative path and through the package's
398
- // own exports, and re-exports the built theme.
399
- const OWN_STYLES_ENTRY = `// Copyright (c) Acme.
400
-
401
- import '../themes/ocean/ocean.fonts.css';
402
- import '@acme/widgets/themes/ocean.css';
403
-
404
- export {oceanTheme} from '../themes/ocean/ocean.js';
405
- `;
406
-
407
- describe('a theme module that loads its own styles', () => {
408
- it('passes an entry that imports the theme stylesheet and fonts and re-exports the built module', async () => {
409
- writePackage({themeExports: true});
410
- writeOwnStylesEntry(OWN_STYLES_ENTRY);
411
-
412
- const result = await integrationPackCheck({cwd: tmpDir});
413
-
414
- expect(result.data.issues).toEqual([]);
415
- expect(result.data.packable).toBe(true);
416
- const cli = runCliVerify();
417
- expect(cli.status, cli.stderr).toBe(0);
418
- expect(cli.receipt?.data.issues).toEqual([]);
419
- });
420
-
421
- it('passes an entry that imports its fonts through the package exports and re-exports everything', async () => {
422
- writePackage({themeExports: true});
423
- writeOwnStylesEntry(
424
- "import '@acme/widgets/themes/ocean.fonts.css';\nimport '../themes/ocean/ocean.css';\nexport * from '../themes/ocean/ocean.js';\n",
425
- );
426
-
427
- const result = await integrationPackCheck({cwd: tmpDir});
428
-
429
- expect(result.data.issues).toEqual([]);
430
- expect(result.data.packable).toBe(true);
431
- });
432
-
433
- it.each([
434
- [
435
- 'also imports another stylesheet',
436
- `${OWN_STYLES_ENTRY}import './other.css';\n`,
437
- "./other.css is not the theme's own stylesheet or font stylesheet",
438
- ],
439
- [
440
- 'also imports a script',
441
- `import './setup.mjs';\n${OWN_STYLES_ENTRY}`,
442
- "./setup.mjs is not the theme's own stylesheet or font stylesheet",
443
- ],
444
- [
445
- 'runs code',
446
- `${OWN_STYLES_ENTRY}console.log('ocean');\n`,
447
- 'line 7 is neither a stylesheet import nor the re-export',
448
- ],
449
- [
450
- 'exports another value',
451
- `${OWN_STYLES_ENTRY}export const extra = 1;\n`,
452
- 'line 7 is neither a stylesheet import nor the re-export',
453
- ],
454
- [
455
- 'renames the theme it re-exports',
456
- "import '../themes/ocean/ocean.css';\nexport {oceanTheme, oceanTheme as theme} from '../themes/ocean/ocean.js';\n",
457
- 'it re-exports names other than oceanTheme',
458
- ],
459
- [
460
- 'binds the stylesheet it imports',
461
- "import styles from '../themes/ocean/ocean.css';\nexport {oceanTheme} from '../themes/ocean/ocean.js';\n",
462
- 'its import of ../themes/ocean/ocean.css is not a side-effect import',
463
- ],
464
- [
465
- 'imports the stylesheet as a CSS module script',
466
- "import '../themes/ocean/ocean.css' with {type: 'css'};\nexport {oceanTheme} from '../themes/ocean/ocean.js';\n",
467
- 'its import of ../themes/ocean/ocean.css is not a side-effect import',
468
- ],
469
- [
470
- 're-exports another name',
471
- "import '../themes/ocean/ocean.css';\nexport {oceanTheme, missing} from '../themes/ocean/ocean.js';\n",
472
- 'it re-exports names other than oceanTheme',
473
- ],
474
- [
475
- 're-exports a copy that is not a .js module',
476
- "import '../themes/ocean/ocean.css';\nexport {oceanTheme} from './copy.cjs';\n",
477
- 'its re-export from ./copy.cjs does not name a .js module',
478
- ],
479
- [
480
- 'has a directive',
481
- `'use client';\n${OWN_STYLES_ENTRY}`,
482
- 'it has a directive',
483
- ],
484
- [
485
- 're-exports twice',
486
- `${OWN_STYLES_ENTRY}export * from '../themes/ocean/ocean.js';\n`,
487
- 'it has more than one re-export',
488
- ],
489
- ])('fails an entry that %s', async (_label, entry, reason) => {
490
- writePackage({themeExports: true});
491
- writeOwnStylesEntry(entry);
492
- fs.writeFileSync(path.join(tmpDir, 'entries', 'other.css'), '.x {}\n');
493
- fs.writeFileSync(path.join(tmpDir, 'entries', 'setup.mjs'), 'export {};\n');
494
- fs.copyFileSync(
495
- path.join(tmpDir, 'themes', 'ocean', 'ocean.js'),
496
- path.join(tmpDir, 'entries', 'copy.cjs'),
497
- );
498
-
499
- const result = await integrationPackCheck({cwd: tmpDir});
500
-
501
- expect(result.data.packable).toBe(false);
502
- expect(result.data.issues).toEqual([
503
- {
504
- code: 'theme_module_stale',
505
- severity: 'error',
506
- message: `Theme "ocean" module is not the module \`${formatCliCommand('theme build themes/ocean/oceanTheme.ts', tmpDir)}\` writes and does not only wrap it: ${reason}. A module that wraps the built module may only import the theme's own stylesheet and font stylesheet for their side effects and re-export from the built module either everything or only its theme, as oceanTheme.`,
507
- },
508
- ]);
509
- });
510
-
511
- it('fails an entry whose re-exported module drifts from source', async () => {
512
- writePackage({themeExports: true});
513
- writeOwnStylesEntry(OWN_STYLES_ENTRY);
514
- fs.appendFileSync(
515
- path.join(tmpDir, 'themes', 'ocean', 'ocean.js'),
516
- '// stale module\n',
517
- );
518
-
519
- const result = await integrationPackCheck({cwd: tmpDir});
520
-
521
- expect(result.data.packable).toBe(false);
522
- expect(result.data.issues).toEqual([
523
- {
524
- code: 'theme_module_stale',
525
- severity: 'error',
526
- message: `Theme "ocean" module re-exports ../themes/ocean/ocean.js, which does not match themes/ocean/oceanTheme.ts. Run \`${formatCliCommand('theme build themes/ocean/oceanTheme.ts', tmpDir)}\` before packing.`,
527
- },
528
- ]);
529
- });
530
-
531
- it('does not accept a TypeScript entry', async () => {
532
- writePackage({themeExports: true});
533
- writeOwnStylesEntry(OWN_STYLES_ENTRY, 'ocean.ts');
534
-
535
- const result = await integrationPackCheck({cwd: tmpDir});
536
-
537
- expect(result.data.packable).toBe(false);
538
- expect(result.data.issues).toEqual([
539
- {
540
- code: 'theme_module_stale',
541
- severity: 'error',
542
- message: `Theme "ocean" module does not match themes/ocean/oceanTheme.ts. Run \`${formatCliCommand('theme build themes/ocean/oceanTheme.ts', tmpDir)}\` before packing.`,
543
- },
544
- ]);
545
- });
546
-
547
- it('does not accept an entry that re-exports itself', async () => {
548
- writePackage({themeExports: true});
549
- writeOwnStylesEntry(
550
- "import '../themes/ocean/ocean.css';\nexport * from './ocean.js';\n",
551
- 'ocean.js',
552
- );
553
-
554
- const result = await integrationPackCheck({cwd: tmpDir});
555
-
556
- expect(result.data.packable).toBe(false);
557
- expect(result.data.issues).toContainEqual(
558
- expect.objectContaining({
559
- code: 'theme_import_unresolvable',
560
- message: expect.stringContaining('does not export "oceanTheme"'),
561
- }),
562
- );
563
- });
564
-
565
- it('passes an entry for a theme whose own name differs from its slug', async () => {
566
- writeRenamedOcean();
567
- writeOwnStylesEntry(
568
- "import '../themes/ocean/deep-sea.css';\nexport {deepSeaTheme as oceanTheme} from '../themes/ocean/deep-sea.js';\n",
569
- );
570
- setThemeExports({
571
- './themes/ocean': './entries/ocean.mjs',
572
- './themes/ocean.css': './themes/ocean/deep-sea.css',
573
- });
574
-
575
- const result = await integrationPackCheck({cwd: tmpDir});
576
-
577
- expect(result.data.issues).toEqual([]);
578
- expect(result.data.packable).toBe(true);
579
- const cli = runCliVerify();
580
- expect(cli.status, cli.stderr).toBe(0);
581
- });
582
-
583
- it('says a rebuild cannot fix exports that name the theme after its folder once its source renames it', async () => {
584
- writePackage({
585
- files: ['astryx.integration.mjs', 'themes'],
586
- themeExports: true,
587
- });
588
- fs.writeFileSync(
589
- path.join(tmpDir, 'themes', 'ocean', 'oceanTheme.ts'),
590
- "import {defineTheme} from '@astryxdesign/core/theme';\n\nexport const oceanTheme = defineTheme({name: 'sea'});\n",
591
- );
592
-
593
- const result = await integrationPackCheck({cwd: tmpDir});
594
-
595
- expect(result.data.issues.map(issue => issue.message)).toEqual([
596
- `Theme "ocean" module is themes/ocean/ocean.js, but oceanTheme.ts calls defineTheme with name: 'sea', so \`${formatCliCommand('theme build themes/ocean/oceanTheme.ts', tmpDir)}\` writes themes/ocean/sea.js instead and rebuilding never updates ocean.js. Fix: point the package export that serves it at themes/ocean/sea.js after building, or set name: 'ocean' in oceanTheme.ts and rebuild.`,
597
- `Theme "ocean" stylesheet is themes/ocean/ocean.css, but oceanTheme.ts calls defineTheme with name: 'sea', so \`${formatCliCommand('theme build themes/ocean/oceanTheme.ts', tmpDir)}\` writes themes/ocean/sea.css instead and rebuilding never updates ocean.css. Fix: point the package export that serves it at themes/ocean/sea.css after building, or set name: 'ocean' in oceanTheme.ts and rebuild.`,
598
- ]);
599
- });
600
-
601
- it('compares a partial export set with the module named after the theme', async () => {
602
- writeRenamedOcean();
603
- setThemeExports({'./themes/ocean': './themes/ocean/deep-sea.js'});
604
-
605
- const result = await integrationPackCheck({cwd: tmpDir});
606
-
607
- expect(result.data.packable).toBe(true);
608
- expect(result.data.issues.map(issue => issue.code)).toEqual([
609
- 'theme_exports_incomplete',
610
- ]);
611
- });
612
-
613
- it('passes an entry that re-exports only the theme from a built module that also exports its icons', async () => {
614
- writeOceanWithIcons();
615
- writeOwnStylesEntry(OWN_STYLES_ENTRY);
616
-
617
- const result = await integrationPackCheck({cwd: tmpDir});
618
-
619
- expect(result.data.issues).toEqual([]);
620
- expect(result.data.packable).toBe(true);
621
- });
622
-
623
- it('fails an entry that gives the built icons the theme export name', async () => {
624
- writeOceanWithIcons();
625
- writeOwnStylesEntry(
626
- "import '../themes/ocean/ocean.css';\nexport {oceanIcons as oceanTheme} from '../themes/ocean/ocean.js';\n",
627
- );
628
-
629
- const result = await integrationPackCheck({cwd: tmpDir});
630
-
631
- expect(result.data.packable).toBe(false);
632
- expect(result.data.issues).toEqual([
633
- expect.objectContaining({
634
- code: 'theme_module_stale',
635
- message: expect.stringContaining(
636
- 'it re-exports oceanIcons, which is not the built theme',
637
- ),
638
- }),
639
- ]);
640
- });
641
-
642
- it('fails when packing changes the module an entry re-exports', async () => {
643
- const prepack = [
644
- "const fs=require('fs')",
645
- "fs.copyFileSync('themes/ocean/ocean.js','.ocean.js.orig')",
646
- "fs.appendFileSync('themes/ocean/ocean.js','// packed\\n')",
647
- ].join(';');
648
- const postpack =
649
- "require('fs').renameSync('.ocean.js.orig','themes/ocean/ocean.js')";
650
- writePackage({
651
- themeExports: true,
652
- scripts: {
653
- prepack: `node -e "${prepack}"`,
654
- postpack: `node -e "${postpack}"`,
655
- },
656
- });
657
- writeOwnStylesEntry(OWN_STYLES_ENTRY);
658
-
659
- const result = await integrationPackCheck({cwd: tmpDir});
660
-
661
- expect(result.data.packable).toBe(false);
662
- expect(result.data.issues).toEqual([
663
- {
664
- code: 'packed_theme_module_changed',
665
- severity: 'error',
666
- message:
667
- 'Theme "ocean" module changed during packing. Keep the built output unchanged in the tarball.',
668
- },
669
- ]);
670
- });
671
- });
672
-
673
- describe('integrationPackCheck', () => {
674
- it('returns packable:true for a valid integration with themes', async () => {
675
- writePackage({files: ['astryx.integration.mjs', 'themes']});
676
- const result = await integrationPackCheck({cwd: tmpDir});
677
-
678
- expect(result.type).toBe('integration.pack-check');
679
- expect(
680
- result.data.packable,
681
- JSON.stringify(result.data.issues, null, 2),
682
- ).toBe(true);
683
- expect(result.data.name).toBe('@acme/widgets');
684
- expect(result.data.tarball).not.toBeNull();
685
- expect(result.data.inventory.manifest).toBe('astryx.integration.mjs');
686
- expect(result.data.contributions.local?.themes).toEqual([
687
- {slug: 'ocean', exportName: 'oceanTheme'},
688
- ]);
689
- expect(result.data.contributions.packed).toEqual(
690
- result.data.contributions.local,
691
- );
692
- expect(result.data.issues.filter(i => i.severity === 'error')).toHaveLength(
693
- 0,
694
- );
695
- });
696
-
697
- it('warns but remains packable when a theme declares no built exports', async () => {
698
- writePackage({files: ['astryx.integration.mjs', 'themes']});
699
-
700
- const result = await integrationPackCheck({cwd: tmpDir});
701
-
702
- expect(result.data.packable).toBe(true);
703
- expect(result.data.issues).toEqual([
704
- {
705
- code: 'theme_exports_missing',
706
- severity: 'warning',
707
- message: `Theme "ocean" has no declared built exports. The package remains source-compatible. To make it importable, run \`${formatCliCommand('theme build themes/ocean/oceanTheme.ts', tmpDir)}\` and export "./themes/ocean" plus "./themes/ocean.css" from package.json; \`${formatCliCommand('integration add theme ocean', tmpDir)}\` creates those exports for a new theme.`,
708
- },
709
- ]);
710
- const cli = runCliVerify();
711
- expect(cli.status, cli.stderr).toBe(0);
712
- expect(cli.receipt?.data.packable).toBe(true);
713
- expect(cli.receipt?.data.issues).toEqual(result.data.issues);
714
- });
715
-
716
- it('fails a package that ships a theme on a CLI range that cannot read it', async () => {
717
- writePackage({files: ['astryx.integration.mjs', 'themes']});
718
- const pkgFile = path.join(tmpDir, 'package.json');
719
- const pkg = JSON.parse(fs.readFileSync(pkgFile, 'utf-8'));
720
- delete pkg.peerDependencies;
721
- fs.writeFileSync(pkgFile, `${JSON.stringify(pkg, null, 2)}\n`);
722
-
723
- const missing = await integrationPackCheck({cwd: tmpDir});
724
- expect(missing.data.packable).toBe(false);
725
- expect(missing.data.issues).toContainEqual(
726
- expect.objectContaining({
727
- code: 'themes_need_cli',
728
- message: expect.stringContaining('ships a theme'),
729
- }),
730
- );
731
-
732
- pkg.peerDependencies = {'@astryxdesign/cli': '^0.6.3'};
733
- fs.writeFileSync(pkgFile, `${JSON.stringify(pkg, null, 2)}\n`);
734
- const old = await integrationPackCheck({cwd: tmpDir});
735
- expect(old.data.issues).toContainEqual(
736
- expect.objectContaining({code: 'themes_need_cli'}),
737
- );
738
-
739
- // Published 0.6.4 reads typed theme descriptors.
740
- pkg.peerDependencies = {'@astryxdesign/cli': '>=0.6.4'};
741
- fs.writeFileSync(pkgFile, `${JSON.stringify(pkg, null, 2)}\n`);
742
- const current = await integrationPackCheck({cwd: tmpDir});
743
- expect(current.data.issues).not.toContainEqual(
744
- expect.objectContaining({code: 'themes_need_cli'}),
745
- );
746
- });
747
-
748
- it('fails when a declared theme export does not resolve', async () => {
749
- writePackage({
750
- files: ['astryx.integration.mjs', 'themes'],
751
- themeExports: true,
752
- });
753
- fs.rmSync(path.join(tmpDir, 'themes', 'ocean', 'ocean.css'));
754
-
755
- const result = await integrationPackCheck({cwd: tmpDir});
756
-
757
- expect(result.data.packable).toBe(false);
758
- expect(result.data.issues).toContainEqual(
759
- expect.objectContaining({
760
- code: 'theme_import_unresolvable',
761
- message: expect.stringContaining('stylesheet export'),
762
- }),
763
- );
764
- });
765
-
766
- it.each([
767
- {
768
- label: 'module only',
769
- exportsMap: {'./built': './themes/ocean/ocean.js'},
770
- specifiers: ['@acme/widgets/built'],
771
- },
772
- {
773
- label: 'stylesheet only',
774
- exportsMap: {'./theme.css': './themes/ocean/ocean.css'},
775
- specifiers: ['@acme/widgets/theme.css'],
776
- },
777
- {
778
- label: 'font stylesheet only',
779
- exportsMap: {'./fonts.css': './themes/ocean/ocean.fonts.css'},
780
- specifiers: ['@acme/widgets/fonts.css'],
781
- fonts: true,
782
- },
783
- {
784
- label: 'module and font stylesheet',
785
- exportsMap: {
786
- './built': './themes/ocean/ocean.js',
787
- './fonts.css': './themes/ocean/ocean.fonts.css',
788
- },
789
- specifiers: ['@acme/widgets/built', '@acme/widgets/fonts.css'],
790
- fonts: true,
791
- },
792
- {
793
- label: 'stylesheet and font stylesheet',
794
- exportsMap: {
795
- './theme.css': './themes/ocean/ocean.css',
796
- './fonts.css': './themes/ocean/ocean.fonts.css',
797
- },
798
- specifiers: ['@acme/widgets/theme.css', '@acme/widgets/fonts.css'],
799
- fonts: true,
800
- },
801
- ])(
802
- 'warns and exits zero for an incomplete $label export set',
803
- async ({exportsMap, specifiers, fonts}) => {
804
- writePackage({
805
- files: ['astryx.integration.mjs', 'themes'],
806
- themeExports: true,
807
- });
808
- if (fonts) {
809
- fs.writeFileSync(
810
- path.join(tmpDir, 'themes', 'ocean', 'ocean.fonts.css'),
811
- '@font-face { font-family: Ocean; src: url(./ocean.woff2); }\n',
812
- );
813
- }
814
- setThemeExports(exportsMap);
815
- const message = `Theme "ocean" exports ${specifiers.join(', ')} without a complete built module and stylesheet pair. Missing partner exports alone do not block packing; add the matching export when the theme should be importable. Every declared export must resolve. Staleness is a warning until the complete importable pair is declared.`;
816
-
817
- const result = await integrationPackCheck({cwd: tmpDir});
818
-
819
- expect(result.data.packable).toBe(true);
820
- expect(result.data.issues).toEqual([
821
- {code: 'theme_exports_incomplete', severity: 'warning', message},
822
- ]);
823
- const cli = runCliVerify();
824
- expect(cli.status, cli.stderr).toBe(0);
825
- expect(cli.receipt?.data.packable).toBe(true);
826
- expect(cli.receipt?.data.issues).toEqual(result.data.issues);
827
- },
828
- );
829
-
830
- it('keeps a published 0.6.5 stylesheet-only package packable', async () => {
831
- writePackage({
832
- files: ['astryx.integration.mjs', 'themes'],
833
- themeExports: true,
834
- });
835
- setThemeExports({'./theme.css': './themes/ocean/ocean.css'});
836
- const provenance = released065Ocean;
837
- const released = Buffer.from(provenance.base64, 'base64');
838
- expect(createHash('sha256').update(released).digest('hex')).toBe(
839
- provenance.sha256,
840
- );
841
- expect(provenance).toMatchObject({
842
- artifact: 'released-0.6.5-ocean.css',
843
- package: '@astryxdesign/cli@0.6.5',
844
- source: 'npm',
845
- command: 'astryx theme build oceanTheme.ts',
846
- workingDirectory: 'themes/ocean',
847
- inputSha256:
848
- '05ac5f9fc3eb71a0096e4fd6dcecfb0d508e403a564be49bf5c535b3c5080245',
849
- sha256:
850
- 'd48aa16f5a87dcaa0d851928a4be735f80c29e462d3dd223cfc38570495f6fbd',
851
- });
852
- const source = fs.readFileSync(
853
- path.join(tmpDir, 'themes', 'ocean', 'oceanTheme.ts'),
854
- );
855
- expect(createHash('sha256').update(source).digest('hex')).toBe(
856
- provenance.inputSha256,
857
- );
858
- fs.writeFileSync(
859
- path.join(tmpDir, 'themes', 'ocean', 'ocean.css'),
860
- released,
861
- );
862
-
863
- const result = await integrationPackCheck({cwd: tmpDir});
864
-
865
- expect(result.data.packable).toBe(true);
866
- expect(result.data.issues).toEqual([
867
- {
868
- code: 'theme_exports_incomplete',
869
- severity: 'warning',
870
- message:
871
- 'Theme "ocean" exports @acme/widgets/theme.css without a complete built module and stylesheet pair. Missing partner exports alone do not block packing; add the matching export when the theme should be importable. Every declared export must resolve. Staleness is a warning until the complete importable pair is declared.',
872
- },
873
- // A 0.6.5-built stylesheet still carries the root data-color defaults
874
- // that theme output no longer emits, so it no longer matches its source.
875
- {
876
- code: 'theme_stylesheet_stale',
877
- severity: 'warning',
878
- message: `Theme "ocean" stylesheet does not match themes/ocean/oceanTheme.ts. This incomplete export remains packable, but run \`${formatCliCommand('theme build themes/ocean/oceanTheme.ts', tmpDir)}\` before adding its matching export.`,
879
- },
880
- ]);
881
- const cli = runCliVerify();
882
- expect(cli.status, cli.stderr).toBe(0);
883
- expect(cli.receipt?.data.packable).toBe(true);
884
- expect(cli.receipt?.data.issues).toEqual(result.data.issues);
885
- });
886
-
887
- it('warns and exits zero for stale content in an incomplete export set', async () => {
888
- writePackage({
889
- files: ['astryx.integration.mjs', 'themes'],
890
- themeExports: true,
891
- });
892
- setThemeExports({'./theme.css': './themes/ocean/ocean.css'});
893
- fs.appendFileSync(
894
- path.join(tmpDir, 'themes', 'ocean', 'ocean.css'),
895
- '/* stale stylesheet body */\n',
896
- );
897
-
898
- const result = await integrationPackCheck({cwd: tmpDir});
899
-
900
- expect(result.data.packable).toBe(true);
901
- expect(result.data.issues).toEqual([
902
- {
903
- code: 'theme_exports_incomplete',
904
- severity: 'warning',
905
- message:
906
- 'Theme "ocean" exports @acme/widgets/theme.css without a complete built module and stylesheet pair. Missing partner exports alone do not block packing; add the matching export when the theme should be importable. Every declared export must resolve. Staleness is a warning until the complete importable pair is declared.',
907
- },
908
- {
909
- code: 'theme_stylesheet_stale',
910
- severity: 'warning',
911
- message: `Theme "ocean" stylesheet does not match themes/ocean/oceanTheme.ts. This incomplete export remains packable, but run \`${formatCliCommand('theme build themes/ocean/oceanTheme.ts', tmpDir)}\` before adding its matching export.`,
912
- },
913
- ]);
914
- const cli = runCliVerify();
915
- expect(cli.status, cli.stderr).toBe(0);
916
- expect(cli.receipt?.data.packable).toBe(true);
917
- expect(cli.receipt?.data.issues).toEqual(result.data.issues);
918
- });
919
-
920
- it('passes a complete pair generated by the current CLI', async () => {
921
- writePackage({
922
- files: ['astryx.integration.mjs', 'themes'],
923
- themeExports: true,
924
- });
925
-
926
- const result = await integrationPackCheck({cwd: tmpDir});
927
-
928
- expect(result.data.packable).toBe(true);
929
- expect(result.data.issues).toEqual([]);
930
- const cli = runCliVerify();
931
- expect(cli.status, cli.stderr).toBe(0);
932
- expect(cli.receipt?.data.packable).toBe(true);
933
- expect(cli.receipt?.data.issues).toEqual([]);
934
- });
935
-
936
- it('passes a complete pair built from inside the theme directory', async () => {
937
- writePackage({
938
- files: ['astryx.integration.mjs', 'themes'],
939
- themeExports: true,
940
- });
941
- const themeDir = path.join(tmpDir, 'themes', 'ocean');
942
- const built = spawnSync(
943
- process.execPath,
944
- [
945
- path.join(process.cwd(), 'packages/cli/clients/cli/bin/astryx.mjs'),
946
- 'theme',
947
- 'build',
948
- 'oceanTheme.ts',
949
- ],
950
- {cwd: themeDir, encoding: 'utf-8', timeout: 30_000},
951
- );
952
- expect(built.status, built.stderr).toBe(0);
953
-
954
- const result = await integrationPackCheck({cwd: tmpDir});
955
-
956
- expect(result.data.packable).toBe(true);
957
- expect(result.data.issues).toEqual([]);
958
- const cli = runCliVerify();
959
- expect(cli.status, cli.stderr).toBe(0);
960
- expect(cli.receipt?.data.issues).toEqual([]);
961
- });
962
-
963
- it('fails when a complete pair drifts from source', async () => {
964
- writePackage({
965
- files: ['astryx.integration.mjs', 'themes'],
966
- themeExports: true,
967
- });
968
- fs.appendFileSync(
969
- path.join(tmpDir, 'themes', 'ocean', 'ocean.js'),
970
- '// stale module\n',
971
- );
972
- fs.appendFileSync(
973
- path.join(tmpDir, 'themes', 'ocean', 'ocean.css'),
974
- '/* stale stylesheet */\n',
975
- );
976
-
977
- const result = await integrationPackCheck({cwd: tmpDir});
978
-
979
- expect(result.data.packable).toBe(false);
980
- expect(result.data.issues).toEqual([
981
- {
982
- code: 'theme_module_stale',
983
- severity: 'error',
984
- message: `Theme "ocean" module does not match themes/ocean/oceanTheme.ts. Run \`${formatCliCommand('theme build themes/ocean/oceanTheme.ts', tmpDir)}\` before packing.`,
985
- },
986
- {
987
- code: 'theme_stylesheet_stale',
988
- severity: 'error',
989
- message: `Theme "ocean" stylesheet does not match themes/ocean/oceanTheme.ts. Run \`${formatCliCommand('theme build themes/ocean/oceanTheme.ts', tmpDir)}\` before packing.`,
990
- },
991
- ]);
992
- const cli = runCliVerify();
993
- expect(cli.status).toBe(1);
994
- expect(cli.receipt?.data.packable).toBe(false);
995
- expect(cli.receipt?.data.issues).toEqual(result.data.issues);
996
- });
997
-
998
- it('fails when a built module omits the descriptor export', async () => {
999
- writePackage({
1000
- files: ['astryx.integration.mjs', 'themes'],
1001
- themeExports: true,
1002
- });
1003
- const built = path.join(tmpDir, 'themes', 'ocean', 'ocean.js');
1004
- fs.writeFileSync(
1005
- built,
1006
- fs
1007
- .readFileSync(built, 'utf-8')
1008
- .replace('export const oceanTheme', 'export const otherTheme'),
1009
- );
1010
-
1011
- const result = await integrationPackCheck({cwd: tmpDir});
1012
-
1013
- expect(result.data.packable).toBe(false);
1014
- expect(result.data.issues).toContainEqual(
1015
- expect.objectContaining({
1016
- code: 'theme_import_unresolvable',
1017
- message: expect.stringContaining('does not export "oceanTheme"'),
1018
- }),
1019
- );
1020
- });
1021
-
1022
- it('fails when an exported font stylesheet is absent from the tarball', async () => {
1023
- writePackage({npmignore: '**/*.fonts.css\n', themeExports: true});
1024
- const packageFile = path.join(tmpDir, 'package.json');
1025
- const pkg = JSON.parse(fs.readFileSync(packageFile, 'utf-8'));
1026
- pkg.exports['./themes/ocean.fonts.css'] = './themes/ocean/ocean.fonts.css';
1027
- fs.writeFileSync(packageFile, `${JSON.stringify(pkg, null, 2)}\n`);
1028
- fs.writeFileSync(
1029
- path.join(tmpDir, 'themes', 'ocean', 'ocean.fonts.css'),
1030
- '@import url("https://example.com/fonts.css");\n',
1031
- );
1032
-
1033
- const result = await integrationPackCheck({cwd: tmpDir});
1034
-
1035
- expect(result.data.packable).toBe(false);
1036
- expect(result.data.issues).toContainEqual(
1037
- expect.objectContaining({
1038
- code: 'theme_import_unresolvable',
1039
- message: expect.stringContaining('font stylesheet does not resolve'),
1040
- }),
1041
- );
1042
- });
1043
-
1044
- it('fails when a theme entry omits its inferred runtime export', async () => {
1045
- writePackage({files: ['astryx.integration.mjs', 'themes']});
1046
- fs.writeFileSync(
1047
- path.join(tmpDir, 'themes', 'ocean', 'oceanTheme.ts'),
1048
- 'export const anotherTheme = {};\n',
1049
- );
1050
-
1051
- const result = await integrationPackCheck({cwd: tmpDir});
1052
-
1053
- expect(result.data.packable).toBe(false);
1054
- expect(result.data.issues).toContainEqual(
1055
- expect.objectContaining({
1056
- code: 'invalid_theme',
1057
- message: expect.stringContaining(
1058
- 'entry "oceanTheme.ts" does not export "oceanTheme"',
1059
- ),
1060
- }),
1061
- );
1062
- });
1063
-
1064
- it('fails when a theme imports a missing local file', async () => {
1065
- writePackage({files: ['astryx.integration.mjs', 'themes']});
1066
- fs.writeFileSync(
1067
- path.join(tmpDir, 'themes', 'ocean', 'oceanTheme.ts'),
1068
- "import {oceanPalette} from './tokens/ocean.palette';\nexport const oceanTheme = {oceanPalette};\n",
1069
- );
1070
-
1071
- const result = await integrationPackCheck({cwd: tmpDir});
1072
-
1073
- expect(result.data.packable).toBe(false);
1074
- expect(result.data.issues).toContainEqual(
1075
- expect.objectContaining({
1076
- code: 'invalid_theme',
1077
- message: expect.stringContaining(
1078
- 'must resolve to a file inside the theme directory',
1079
- ),
1080
- }),
1081
- );
1082
- });
1083
-
1084
- it('fails when a discovered component is not exported to consumers', async () => {
1085
- writePackage({
1086
- manifest: "export default {components: './components'};\n",
1087
- files: ['astryx.integration.mjs', 'components', 'index.mjs'],
1088
- themes: false,
1089
- });
1090
- const pkgFile = path.join(tmpDir, 'package.json');
1091
- const pkg = JSON.parse(fs.readFileSync(pkgFile, 'utf-8'));
1092
- pkg.exports = {'.': './index.mjs'};
1093
- fs.writeFileSync(pkgFile, `${JSON.stringify(pkg, null, 2)}\n`);
1094
- fs.writeFileSync(
1095
- path.join(tmpDir, 'index.mjs'),
1096
- 'export const existing = 1;\n',
1097
- );
1098
- fs.mkdirSync(path.join(tmpDir, 'components'));
1099
- fs.writeFileSync(
1100
- path.join(tmpDir, 'components', 'AcmeWidget.doc.mjs'),
1101
- "export default {type: 'component', name: 'AcmeWidget', description: 'Widget.', props: []};\n",
1102
- );
1103
- fs.writeFileSync(
1104
- path.join(tmpDir, 'components', 'AcmeWidget.tsx'),
1105
- 'export function AcmeWidget() { return null; }\n',
1106
- );
1107
-
1108
- const result = await integrationPackCheck({cwd: tmpDir});
1109
-
1110
- expect(result.data.packable).toBe(false);
1111
- expect(result.data.issues).toContainEqual(
1112
- expect.objectContaining({
1113
- code: 'component_export_missing',
1114
- message: expect.stringContaining('AcmeWidget'),
1115
- }),
1116
- );
1117
- });
1118
-
1119
- it('checks the export a component doc names when its file is named otherwise', async () => {
1120
- fs.writeFileSync(
1121
- path.join(tmpDir, 'package.json'),
1122
- `${JSON.stringify({
1123
- name: '@acme/widgets',
1124
- version: '1.0.0',
1125
- files: ['astryx.integration.mjs', 'components'],
1126
- exports: {'./components/Slides': './components/Slides.tsx'},
1127
- })}\n`,
1128
- );
1129
- fs.writeFileSync(
1130
- path.join(tmpDir, 'astryx.integration.mjs'),
1131
- "export default {components: './components'};\n",
1132
- );
1133
- fs.mkdirSync(path.join(tmpDir, 'components'));
1134
- // Slides.tsx exports AcmeCarousel and nothing named Slides.
1135
- fs.writeFileSync(
1136
- path.join(tmpDir, 'components', 'Slides.tsx'),
1137
- 'export function AcmeCarousel() { return null; }\n',
1138
- );
1139
- fs.writeFileSync(
1140
- path.join(tmpDir, 'components', 'Slides.doc.mjs'),
1141
- "export default {type: 'component', name: 'AcmeCarousel', import: '@acme/widgets/components/Slides', description: 'x', props: []};\n",
1142
- );
1143
-
1144
- const result = await integrationPackCheck({cwd: tmpDir});
1145
- expect(result.data.packable).toBe(true);
1146
- expect(result.data.contributions.packed.components).toEqual([
1147
- 'AcmeCarousel',
1148
- ]);
1149
- });
1150
-
1151
- it('checks each family member against the module its family doc imports', async () => {
1152
- fs.writeFileSync(
1153
- path.join(tmpDir, 'package.json'),
1154
- `${JSON.stringify({
1155
- name: '@acme/widgets',
1156
- version: '1.0.0',
1157
- files: ['astryx.integration.mjs', 'components'],
1158
- exports: {'./tabs': './components/tabs/index.ts'},
1159
- })}\n`,
1160
- );
1161
- fs.writeFileSync(
1162
- path.join(tmpDir, 'astryx.integration.mjs'),
1163
- "export default {components: './components'};\n",
1164
- );
1165
- const dir = path.join(tmpDir, 'components', 'tabs');
1166
- fs.mkdirSync(dir, {recursive: true});
1167
- fs.writeFileSync(
1168
- path.join(dir, 'AcmeTabs.tsx'),
1169
- 'export function AcmeTabs() { return null; }\nexport function AcmeTabsLegacy() { return null; }\n',
1170
- );
1171
- fs.writeFileSync(
1172
- path.join(dir, 'tab.tsx'),
1173
- 'export function AcmeTab() { return null; }\n',
1174
- );
1175
- // The module apps import exports AcmeTabs and AcmeTab, not AcmeTabsLegacy.
1176
- fs.writeFileSync(
1177
- path.join(dir, 'index.ts'),
1178
- "export {AcmeTabs} from './AcmeTabs';\nexport {AcmeTab} from './tab';\n",
1179
- );
1180
- fs.writeFileSync(
1181
- path.join(dir, 'AcmeTabs.doc.mjs'),
1182
- "export default {type: 'component', name: 'AcmeTabs', import: '@acme/widgets/tabs', description: 'x', components: [{name: 'AcmeTabs', description: 'x', props: []}, {name: 'AcmeTab', description: 'x', props: []}, {name: 'AcmeTabsLegacy', description: 'x', props: []}]};\n",
1183
- );
1184
-
1185
- const result = await integrationPackCheck({cwd: tmpDir});
1186
-
1187
- expect(result.data.issues).toEqual([]);
1188
- expect(result.data.packable).toBe(true);
1189
- expect(result.data.contributions.packed.components).toEqual([
1190
- 'AcmeTab',
1191
- 'AcmeTabs',
1192
- ]);
1193
- });
1194
-
1195
- it.each([
1196
- 'a clean checkout',
1197
- 'a stale build',
1198
- 'a stale build that exports more',
1199
- ])(
1200
- 'reads members a family imports from output its pack lifecycle builds, from %s',
1201
- async start => {
1202
- fs.writeFileSync(
1203
- path.join(tmpDir, 'package.json'),
1204
- `${JSON.stringify({
1205
- name: '@acme/widgets',
1206
- version: '1.0.0',
1207
- files: ['astryx.integration.mjs', 'components', 'dist'],
1208
- exports: {'./tabs': './dist/tabs/index.mjs'},
1209
- scripts: {prepack: 'node build.mjs'},
1210
- })}\n`,
1211
- );
1212
- fs.writeFileSync(
1213
- path.join(tmpDir, 'astryx.integration.mjs'),
1214
- "export default {components: './components'};\n",
1215
- );
1216
- // The build writes the module the family imports; a clean checkout has none.
1217
- fs.writeFileSync(
1218
- path.join(tmpDir, 'build.mjs'),
1219
- "import fs from 'node:fs';\nfs.mkdirSync('dist/tabs', {recursive: true});\nfs.writeFileSync('dist/tabs/index.mjs', \"export {AcmeTabs, AcmeTab} from '../../components/tabs/AcmeTabs.tsx';\\n\");\n",
1220
- );
1221
- const dir = path.join(tmpDir, 'components', 'tabs');
1222
- fs.mkdirSync(dir, {recursive: true});
1223
- fs.writeFileSync(
1224
- path.join(dir, 'AcmeTabs.tsx'),
1225
- 'export function AcmeTabs() { return null; }\nexport function AcmeTab() { return null; }\nexport function AcmeTabLegacy() { return null; }\n',
1226
- );
1227
- fs.writeFileSync(
1228
- path.join(dir, 'AcmeTabs.doc.mjs'),
1229
- "export default {type: 'component', name: 'AcmeTabs', import: '@acme/widgets/tabs', description: 'x', components: [{name: 'AcmeTabs', description: 'x', props: []}, {name: 'AcmeTab', description: 'x', props: []}, {name: 'AcmeTabLegacy', description: 'x', props: []}]};\n",
1230
- );
1231
-
1232
- if (start !== 'a clean checkout') {
1233
- // An earlier build: before AcmeTab was exported, or while AcmeTabLegacy
1234
- // still was.
1235
- const names =
1236
- start === 'a stale build'
1237
- ? 'AcmeTabs'
1238
- : 'AcmeTabs, AcmeTab, AcmeTabLegacy';
1239
- fs.mkdirSync(path.join(tmpDir, 'dist', 'tabs'), {recursive: true});
1240
- fs.writeFileSync(
1241
- path.join(tmpDir, 'dist', 'tabs', 'index.mjs'),
1242
- `export {${names}} from '../../components/tabs/AcmeTabs.tsx';\n`,
1243
- );
1244
- }
1245
-
1246
- const result = await integrationPackCheck({cwd: tmpDir});
1247
-
1248
- expect(result.data.issues).toEqual([]);
1249
- expect(result.data.packable).toBe(true);
1250
- expect(result.data.contributions.local.components).toEqual(
1251
- result.data.contributions.packed.components,
1252
- );
1253
- },
1254
- );
1255
-
1256
- it.each(['a clean checkout', 'an incremental build'])(
1257
- 'reads members built output re-exports from compiled files, from %s',
1258
- async start => {
1259
- fs.writeFileSync(
1260
- path.join(tmpDir, 'package.json'),
1261
- `${JSON.stringify({
1262
- name: '@acme/widgets',
1263
- version: '1.0.0',
1264
- files: ['astryx.integration.mjs', 'components', 'dist'],
1265
- exports: {'./tabs': './dist/tabs/index.mjs'},
1266
- scripts: {prepack: 'node build.mjs'},
1267
- })}\n`,
1268
- );
1269
- fs.writeFileSync(
1270
- path.join(tmpDir, 'astryx.integration.mjs'),
1271
- "export default {components: './components'};\n",
1272
- );
1273
- // The build compiles each source to its own file and, like an
1274
- // incremental build, rewrites only the files whose output changed.
1275
- const output = {
1276
- 'index.mjs':
1277
- "export {AcmeTabs} from './tabs.mjs';\nexport * from './tab.mjs';\n",
1278
- 'tabs.mjs': 'export function AcmeTabs() { return null; }\n',
1279
- 'tab.mjs': 'export function AcmeTab() { return null; }\n',
1280
- };
1281
- fs.writeFileSync(
1282
- path.join(tmpDir, 'build.mjs'),
1283
- `import fs from 'node:fs';\nconst output = ${JSON.stringify(output)};\nfs.mkdirSync('dist/tabs', {recursive: true});\nfor (const [file, text] of Object.entries(output)) {\n const target = 'dist/tabs/' + file;\n if (!fs.existsSync(target) || fs.readFileSync(target, 'utf-8') !== text) fs.writeFileSync(target, text);\n}\n`,
1284
- );
1285
- const dir = path.join(tmpDir, 'components', 'tabs');
1286
- fs.mkdirSync(dir, {recursive: true});
1287
- fs.writeFileSync(
1288
- path.join(dir, 'AcmeTabs.tsx'),
1289
- 'export function AcmeTabs() { return null; }\n',
1290
- );
1291
- fs.writeFileSync(
1292
- path.join(dir, 'AcmeTab.tsx'),
1293
- 'export function AcmeTab() { return null; }\n',
1294
- );
1295
- fs.writeFileSync(
1296
- path.join(dir, 'AcmeTabs.doc.mjs'),
1297
- "export default {type: 'component', name: 'AcmeTabs', import: '@acme/widgets/tabs', description: 'x', components: [{name: 'AcmeTabs', description: 'x', props: []}, {name: 'AcmeTab', description: 'x', props: []}]};\n",
1298
- );
1299
- if (start === 'an incremental build') {
1300
- // An earlier build from before AcmeTab existed: the file the import
1301
- // names is already current, so the build leaves it untouched.
1302
- fs.mkdirSync(path.join(tmpDir, 'dist', 'tabs'), {recursive: true});
1303
- for (const [file, text] of Object.entries({...output, 'tab.mjs': ''})) {
1304
- fs.writeFileSync(path.join(tmpDir, 'dist', 'tabs', file), text);
1305
- }
1306
- }
1307
-
1308
- const result = await integrationPackCheck({cwd: tmpDir});
1309
-
1310
- expect(result.data.issues).toEqual([]);
1311
- expect(result.data.packable).toBe(true);
1312
- expect(result.data.contributions.packed.components).toEqual([
1313
- 'AcmeTab',
1314
- 'AcmeTabs',
1315
- ]);
1316
- expect(result.data.contributions.local.components).toEqual(
1317
- result.data.contributions.packed.components,
1318
- );
1319
- },
1320
- );
1321
-
1322
- it('passes a member another folder declares, which has no source', async () => {
1323
- fs.writeFileSync(
1324
- path.join(tmpDir, 'package.json'),
1325
- `${JSON.stringify({
1326
- name: '@acme/widgets',
1327
- version: '1.0.0',
1328
- files: ['astryx.integration.mjs', 'components'],
1329
- exports: {'./menu': './components/menu/index.ts'},
1330
- })}\n`,
1331
- );
1332
- fs.writeFileSync(
1333
- path.join(tmpDir, 'astryx.integration.mjs'),
1334
- "export default {components: './components'};\n",
1335
- );
1336
- const menu = path.join(tmpDir, 'components', 'menu');
1337
- const shared = path.join(tmpDir, 'components', 'shared');
1338
- fs.mkdirSync(menu, {recursive: true});
1339
- fs.mkdirSync(shared, {recursive: true});
1340
- fs.writeFileSync(
1341
- path.join(menu, 'AcmeMenu.doc.mjs'),
1342
- "export default {type: 'component', name: 'AcmeMenu', import: '@acme/widgets/menu', description: 'x', components: [{name: 'AcmeMenuItem', description: 'x', props: []}]};\n",
1343
- );
1344
- fs.writeFileSync(
1345
- path.join(menu, 'AcmeMenu.tsx'),
1346
- 'export function AcmeMenu() { return null; }\n',
1347
- );
1348
- fs.writeFileSync(
1349
- path.join(menu, 'index.ts'),
1350
- "export {AcmeMenu} from './AcmeMenu';\nexport {AcmeMenuItem} from '../shared/AcmeMenuItem';\n",
1351
- );
1352
- fs.writeFileSync(
1353
- path.join(shared, 'AcmeMenuItem.tsx'),
1354
- 'export function AcmeMenuItem() { return null; }\n',
1355
- );
1356
-
1357
- const result = await integrationPackCheck({cwd: tmpDir});
1358
-
1359
- expect(result.data.issues).toEqual([]);
1360
- expect(result.data.packable).toBe(true);
1361
- expect(result.data.contributions.packed.components).toEqual([
1362
- 'AcmeMenu',
1363
- 'AcmeMenuItem',
1364
- ]);
1365
- });
1366
-
1367
- it('reports a family doc the loader rejects once, not once per member', async () => {
1368
- fs.writeFileSync(
1369
- path.join(tmpDir, 'package.json'),
1370
- `${JSON.stringify({
1371
- name: '@acme/widgets',
1372
- version: '1.0.0',
1373
- files: ['astryx.integration.mjs', 'components'],
1374
- })}\n`,
1375
- );
1376
- fs.writeFileSync(
1377
- path.join(tmpDir, 'astryx.integration.mjs'),
1378
- "export default {components: './components'};\n",
1379
- );
1380
- fs.mkdirSync(path.join(tmpDir, 'components'));
1381
- fs.writeFileSync(
1382
- path.join(tmpDir, 'components', 'AcmeTabs.tsx'),
1383
- 'export function AcmeTabs() { return null; }\nexport function AcmeTab() { return null; }\nexport function AcmeTabPanel() { return null; }\n',
1384
- );
1385
- // A displayName that is not a string makes the loader reject the doc.
1386
- fs.writeFileSync(
1387
- path.join(tmpDir, 'components', 'AcmeTabs.doc.mjs'),
1388
- "export default {type: 'component', name: 'AcmeTabs', displayName: 1, description: 'x', components: [{name: 'AcmeTab', description: 'x', props: []}, {name: 'AcmeTabPanel', description: 'x', props: []}]};\n",
1389
- );
1390
-
1391
- const result = await integrationPackCheck({cwd: tmpDir});
1392
- const codes = result.data.issues.map(issue => issue.code);
1393
-
1394
- expect(codes).toContain('component_doc_unloadable');
1395
- expect(codes.length).toBe(new Set(codes).size);
1396
- });
1397
-
1398
- it('passes a generated component through its exact packed export', async () => {
1399
- fs.writeFileSync(
1400
- path.join(tmpDir, 'package.json'),
1401
- `${JSON.stringify({
1402
- name: '@acme/widgets',
1403
- version: '1.0.0',
1404
- files: ['index.mjs'],
1405
- exports: {'.': './index.mjs'},
1406
- })}\n`,
1407
- );
1408
- fs.writeFileSync(
1409
- path.join(tmpDir, 'index.mjs'),
1410
- 'export const existing = 1;\n',
1411
- );
1412
- await integrationAddComponent('AcmeWidget', {cwd: tmpDir});
1413
-
1414
- const result = await integrationPackCheck({cwd: tmpDir});
1415
-
1416
- expect(result.data.packable).toBe(true);
1417
- expect(result.data.issues).not.toContainEqual(
1418
- expect.objectContaining({code: 'component_export_missing'}),
1419
- );
1420
- });
1421
-
1422
- it('resolves public imports in the packed package, not the source', async () => {
1423
- // The root export's target is left out of `files`: the source package
1424
- // resolves it, but an app that installs the tarball cannot.
1425
- fs.writeFileSync(
1426
- path.join(tmpDir, 'package.json'),
1427
- `${JSON.stringify({
1428
- name: '@acme/widgets',
1429
- version: '1.0.0',
1430
- files: ['astryx.integration.mjs'],
1431
- exports: {'.': './index.mjs'},
1432
- })}\n`,
1433
- );
1434
- fs.writeFileSync(
1435
- path.join(tmpDir, 'index.mjs'),
1436
- "export {AcmeWidget} from './components/AcmeWidget.tsx';\n",
1437
- );
1438
- await integrationAddComponent('AcmeWidget', {cwd: tmpDir});
1439
- const docFile = path.join(tmpDir, 'components', 'AcmeWidget.doc.mjs');
1440
- const doc = fs.readFileSync(docFile, 'utf-8');
1441
- expect(doc).toContain('@acme/widgets/components/AcmeWidget');
1442
- fs.writeFileSync(
1443
- docFile,
1444
- doc.replace('@acme/widgets/components/AcmeWidget', '@acme/widgets'),
1445
- );
1446
-
1447
- const result = await integrationPackCheck({cwd: tmpDir});
1448
-
1449
- expect(result.data.packable).toBe(false);
1450
- expect(result.data.issues).toContainEqual(
1451
- expect.objectContaining({code: 'component_export_missing'}),
1452
- );
1453
- });
1454
-
1455
- it('does not count a type-only re-export as the component', async () => {
1456
- fs.writeFileSync(
1457
- path.join(tmpDir, 'package.json'),
1458
- `${JSON.stringify({
1459
- name: '@acme/widgets',
1460
- version: '1.0.0',
1461
- files: ['astryx.integration.mjs', 'src'],
1462
- exports: {'.': './src/index.ts'},
1463
- })}\n`,
1464
- );
1465
- fs.writeFileSync(
1466
- path.join(tmpDir, 'astryx.integration.mjs'),
1467
- "export default {components: './src'};\n",
1468
- );
1469
- fs.mkdirSync(path.join(tmpDir, 'src'));
1470
- fs.writeFileSync(
1471
- path.join(tmpDir, 'src', 'index.ts'),
1472
- "export type {AcmeWidget} from './AcmeWidget';\n",
1473
- );
1474
- fs.writeFileSync(
1475
- path.join(tmpDir, 'src', 'AcmeWidget.tsx'),
1476
- 'export function AcmeWidget() { return null; }\n',
1477
- );
1478
- fs.writeFileSync(
1479
- path.join(tmpDir, 'src', 'AcmeWidget.doc.mjs'),
1480
- "export default {type: 'component', name: 'AcmeWidget', import: '@acme/widgets', description: 'Widget.', props: []};\n",
1481
- );
1482
-
1483
- const result = await integrationPackCheck({cwd: tmpDir});
1484
-
1485
- expect(result.data.issues).toContainEqual(
1486
- expect.objectContaining({code: 'component_export_missing'}),
1487
- );
1488
- });
1489
-
1490
- it('follows a re-export of a folder to its index file', async () => {
1491
- // `./primitives` names a folder: TypeScript and bundlers load its index file.
1492
- fs.writeFileSync(
1493
- path.join(tmpDir, 'package.json'),
1494
- `${JSON.stringify({
1495
- name: '@acme/widgets',
1496
- version: '1.0.0',
1497
- files: ['astryx.integration.mjs', 'src'],
1498
- exports: {'.': './src/index.ts'},
1499
- })}\n`,
1500
- );
1501
- fs.writeFileSync(
1502
- path.join(tmpDir, 'astryx.integration.mjs'),
1503
- "export default {components: './src'};\n",
1504
- );
1505
- const primitives = path.join(tmpDir, 'src', 'primitives');
1506
- fs.mkdirSync(primitives, {recursive: true});
1507
- fs.writeFileSync(
1508
- path.join(tmpDir, 'src', 'index.ts'),
1509
- "export * from './primitives';\n",
1510
- );
1511
- fs.writeFileSync(
1512
- path.join(primitives, 'index.ts'),
1513
- "export * from './AcmeWidget';\n",
1514
- );
1515
- fs.writeFileSync(
1516
- path.join(primitives, 'AcmeWidget.tsx'),
1517
- 'export function AcmeWidget() { return null; }\n',
1518
- );
1519
- fs.writeFileSync(
1520
- path.join(primitives, 'AcmeWidget.doc.mjs'),
1521
- "export default {type: 'component', name: 'AcmeWidget', import: '@acme/widgets', description: 'Widget.', props: []};\n",
1522
- );
1523
-
1524
- const result = await integrationPackCheck({cwd: tmpDir});
1525
-
1526
- expect(result.data.issues).not.toContainEqual(
1527
- expect.objectContaining({code: 'component_export_missing'}),
1528
- );
1529
- expect(
1530
- result.data.packable,
1531
- JSON.stringify(result.data.issues, null, 2),
1532
- ).toBe(true);
1533
- });
1534
-
1535
- it('fails when packed template source is hidden by package exports', async () => {
1536
- writePackage({
1537
- manifest: "export default {templates: './templates'};\n",
1538
- files: ['astryx.integration.mjs', 'templates', 'index.mjs'],
1539
- themes: false,
1540
- });
1541
- const pkgFile = path.join(tmpDir, 'package.json');
1542
- const pkg = JSON.parse(fs.readFileSync(pkgFile, 'utf-8'));
1543
- pkg.exports = {'.': './index.mjs'};
1544
- fs.writeFileSync(pkgFile, `${JSON.stringify(pkg, null, 2)}\n`);
1545
- fs.writeFileSync(
1546
- path.join(tmpDir, 'index.mjs'),
1547
- 'export const existing = 1;\n',
1548
- );
1549
- fs.mkdirSync(path.join(tmpDir, 'templates'));
1550
- fs.writeFileSync(
1551
- path.join(tmpDir, 'templates', 'account-page.doc.mjs'),
1552
- "export default {type: 'page', name: 'Account page', description: 'Account page.'};\n",
1553
- );
1554
- fs.writeFileSync(
1555
- path.join(tmpDir, 'templates', 'account-page.tsx'),
1556
- 'export default function AccountPage() { return null; }\n',
1557
- );
1558
-
1559
- const result = await integrationPackCheck({cwd: tmpDir});
1560
-
1561
- expect(result.data.packable).toBe(false);
1562
- expect(result.data.issues).toContainEqual(
1563
- expect.objectContaining({
1564
- code: 'template_import_unresolvable',
1565
- message: expect.stringContaining('account-page'),
1566
- }),
1567
- );
1568
- });
1569
-
1570
- it('passes generated component and template source through exact packed exports', async () => {
1571
- fs.writeFileSync(
1572
- path.join(tmpDir, 'package.json'),
1573
- `${JSON.stringify({
1574
- name: '@acme/widgets',
1575
- version: '1.0.0',
1576
- files: ['index.mjs'],
1577
- exports: {'.': './index.mjs'},
1578
- })}\n`,
1579
- );
1580
- fs.writeFileSync(
1581
- path.join(tmpDir, 'index.mjs'),
1582
- 'export const existing = 1;\n',
1583
- );
1584
- await integrationAddComponent('AcmeWidget', {cwd: tmpDir});
1585
- await integrationAddTemplate('account-page', {cwd: tmpDir, type: 'page'});
1586
-
1587
- const result = await integrationPackCheck({cwd: tmpDir});
1588
-
1589
- expect(result.data.packable).toBe(true);
1590
- expect(result.data.issues).not.toContainEqual(
1591
- expect.objectContaining({code: 'component_export_missing'}),
1592
- );
1593
- expect(result.data.issues).not.toContainEqual(
1594
- expect.objectContaining({code: 'template_import_unresolvable'}),
1595
- );
1596
- });
1597
-
1598
- it('errors when a root directory is excluded from files[]', async () => {
1599
- // Include manifest but NOT themes
1600
- writePackage({files: ['astryx.integration.mjs']});
1601
- const result = await integrationPackCheck({cwd: tmpDir});
1602
-
1603
- expect(result.data.packable).toBe(false);
1604
- const rootError = result.data.issues.find(
1605
- i => i.code === 'root_not_packed',
1606
- );
1607
- expect(rootError).toBeDefined();
1608
- expect(rootError.message).toContain('themes');
1609
- });
1610
-
1611
- it('errors when .npmignore excludes a contribution', async () => {
1612
- writePackage({npmignore: 'themes/\n'});
1613
- const result = await integrationPackCheck({cwd: tmpDir});
1614
-
1615
- expect(result.data.packable).toBe(false);
1616
- const fileErrors = result.data.issues.filter(
1617
- i => i.code === 'root_not_packed' || i.code === 'file_not_packed',
1618
- );
1619
- expect(fileErrors.length).toBeGreaterThan(0);
1620
- });
1621
-
1622
- it('fails a package that ships a namespace doc on a CLI range that cannot read it', async () => {
1623
- writePackage({
1624
- manifest: "export default {docs: './docs'};\n",
1625
- themes: false,
1626
- });
1627
- fs.mkdirSync(path.join(tmpDir, 'docs'), {recursive: true});
1628
- fs.writeFileSync(
1629
- path.join(tmpDir, 'docs', 'acme.doc.mjs'),
1630
- "export default {type: 'namespace', name: 'acme', title: 'Acme', summary: 'Acme guides.', slots: {guides: {title: 'Guides', accepts: {kinds: ['generic']}}}};\n",
1631
- );
1632
- fs.writeFileSync(
1633
- path.join(tmpDir, 'docs', 'deploying.doc.mjs'),
1634
- "export default {type: 'generic', name: 'deploying', title: 'Deploying', description: 'Ship it.', placement: {parent: 'namespace:acme', slot: 'guides'}, sections: [{title: 'Overview', content: [{type: 'prose', text: 'Ship it.'}]}]};\n",
1635
- );
1636
- const file = path.join(tmpDir, 'package.json');
1637
- const peer = (/** @type {string | undefined} */ range) => {
1638
- const pkg = JSON.parse(fs.readFileSync(file, 'utf-8'));
1639
- if (range == null) delete pkg.peerDependencies;
1640
- else pkg.peerDependencies = {'@astryxdesign/cli': range};
1641
- fs.writeFileSync(file, `${JSON.stringify(pkg, null, 2)}\n`);
1642
- };
1643
- const codes = async () =>
1644
- (await integrationPackCheck({cwd: tmpDir})).data.issues.map(
1645
- (/** @type {{code: string}} */ issue) => issue.code,
1646
- );
1647
-
1648
- peer(undefined);
1649
- expect(await codes()).toContain('docs_tree_needs_cli');
1650
- peer('^0.6.0 || >=0.7.0');
1651
- expect(await codes()).toContain('docs_tree_needs_cli');
1652
- peer('>=0.6.3');
1653
- expect(await codes()).toContain('docs_tree_needs_cli');
1654
- // Published 0.6.4 reads the docs tree.
1655
- peer('>=0.6.4');
1656
- expect(await codes()).not.toContain('docs_tree_needs_cli');
1657
- }, 120_000);
1658
-
1659
- it('fails a package with only a placed guide on a CLI range that cannot read the docs tree, and passes flat topics', async () => {
1660
- writePackage({
1661
- manifest: "export default {docs: './docs'};\n",
1662
- themes: false,
1663
- });
1664
- fs.mkdirSync(path.join(tmpDir, 'docs'), {recursive: true});
1665
- fs.writeFileSync(
1666
- path.join(tmpDir, 'docs', 'notes.doc.mjs'),
1667
- "export default {type: 'generic', name: 'notes', title: 'Notes', description: 'Notes.', sections: [{title: 'Overview', content: [{type: 'prose', text: 'Notes.'}]}]};\n",
1668
- );
1669
- const codes = async () =>
1670
- (await integrationPackCheck({cwd: tmpDir})).data.issues.map(
1671
- (/** @type {{code: string}} */ issue) => issue.code,
1672
- );
1673
- // Flat topics alone need no CLI peer.
1674
- expect(await codes()).not.toContain('docs_tree_needs_cli');
1675
- fs.writeFileSync(
1676
- path.join(tmpDir, 'docs', 'setup.doc.mjs'),
1677
- "export default {type: 'generic', name: 'setup', title: 'Setup', description: 'Set up.', placement: {parent: 'namespace:acme', slot: 'guides'}, sections: [{title: 'Overview', content: [{type: 'prose', text: 'Set up.'}]}]};\n",
1678
- );
1679
- expect(await codes()).toContain('docs_tree_needs_cli');
1680
- const file = path.join(tmpDir, 'package.json');
1681
- const pkg = JSON.parse(fs.readFileSync(file, 'utf-8'));
1682
- pkg.peerDependencies = {'@astryxdesign/cli': '>=0.7.0'};
1683
- fs.writeFileSync(file, `${JSON.stringify(pkg, null, 2)}\n`);
1684
- expect(await codes()).not.toContain('docs_tree_needs_cli');
1685
- }, 120_000);
1686
-
1687
- it('fails a package whose doc section sets id on a CLI range that rejects the field', async () => {
1688
- writePackage({
1689
- manifest: "export default {docs: './docs'};\n",
1690
- themes: false,
1691
- });
1692
- fs.mkdirSync(path.join(tmpDir, 'docs'), {recursive: true});
1693
- const topic = (/** @type {string} */ section) =>
1694
- `export default {type: 'generic', name: 'notes', title: 'Notes', description: 'Notes.', sections: [${section}]};\n`;
1695
- const file = path.join(tmpDir, 'docs', 'notes.doc.mjs');
1696
- const codes = async () =>
1697
- (await integrationPackCheck({cwd: tmpDir})).data.issues.map(
1698
- (/** @type {{code: string}} */ issue) => issue.code,
1699
- );
1700
- fs.writeFileSync(
1701
- file,
1702
- topic(
1703
- "{title: 'Take notes', content: [{type: 'prose', text: 'Notes.'}]}",
1704
- ),
1705
- );
1706
- expect(await codes()).not.toContain('section_ids_need_cli');
1707
- // A fresh file name: the module loader caches a path once it is imported.
1708
- fs.rmSync(file);
1709
- fs.writeFileSync(
1710
- path.join(tmpDir, 'docs', 'notes-with-ids.doc.mjs'),
1711
- topic(
1712
- "{id: 'take-notes', title: 'Take notes', content: [{type: 'prose', text: 'Notes.'}]}",
1713
- ),
1714
- );
1715
- expect(await codes()).toContain('section_ids_need_cli');
1716
- const pkgFile = path.join(tmpDir, 'package.json');
1717
- const pkg = JSON.parse(fs.readFileSync(pkgFile, 'utf-8'));
1718
- pkg.peerDependencies = {'@astryxdesign/cli': '^0.6.3'};
1719
- fs.writeFileSync(pkgFile, `${JSON.stringify(pkg, null, 2)}\n`);
1720
- expect(await codes()).toContain('section_ids_need_cli');
1721
- // Published 0.6.4 reads a section id.
1722
- pkg.peerDependencies = {'@astryxdesign/cli': '>=0.6.4'};
1723
- fs.writeFileSync(pkgFile, `${JSON.stringify(pkg, null, 2)}\n`);
1724
- expect(await codes()).not.toContain('section_ids_need_cli');
1725
- }, 120_000);
1726
-
1727
- it('warns, without failing, when a doc section sets before or after on a CLI range that rejects them', async () => {
1728
- writePackage({
1729
- manifest: "export default {docs: './docs'};\n",
1730
- themes: false,
1731
- });
1732
- fs.mkdirSync(path.join(tmpDir, 'docs'), {recursive: true});
1733
- const pkgFile = path.join(tmpDir, 'package.json');
1734
- const pkg = JSON.parse(fs.readFileSync(pkgFile, 'utf-8'));
1735
- pkg.peerDependencies = {'@astryxdesign/cli': '>=0.7.0'};
1736
- fs.writeFileSync(pkgFile, `${JSON.stringify(pkg, null, 2)}\n`);
1737
- const issues = async () =>
1738
- (await integrationPackCheck({cwd: tmpDir})).data.issues.filter(
1739
- (/** @type {{code: string}} */ issue) =>
1740
- issue.code === 'section_position_needs_cli',
1741
- );
1742
- // A placed guide's section counts too: an older CLI rejects the field in
1743
- // any doc and hides the package's topics.
1744
- fs.writeFileSync(
1745
- path.join(tmpDir, 'docs', 'acme.doc.mjs'),
1746
- "export default {type: 'namespace', name: 'acme', title: 'Acme', summary: 'Acme.', slots: {guides: {title: 'Guides', accepts: {kinds: ['generic']}}}};\n",
1747
- );
1748
- fs.writeFileSync(
1749
- path.join(tmpDir, 'docs', 'setup.doc.mjs'),
1750
- "export default {type: 'generic', name: 'setup', title: 'Setup', description: 'Set up.', placement: {parent: 'namespace:acme', slot: 'guides'}, sections: [{id: 'overview', title: 'Overview', after: 'nothing', content: [{type: 'prose', text: 'Set up.'}]}]};\n",
1751
- );
1752
- expect(await issues()).toEqual([
1753
- expect.objectContaining({severity: 'warning'}),
1754
- ]);
1755
- pkg.peerDependencies = {'@astryxdesign/cli': '>=0.7.4'};
1756
- fs.writeFileSync(pkgFile, `${JSON.stringify(pkg, null, 2)}\n`);
1757
- expect(await issues()).toEqual([]);
1758
- }, 120_000);
1759
-
1760
- it('warns when a package whose docs write doc tokens has a CLI range that prints them raw', async () => {
1761
- writePackage({
1762
- manifest: "export default {docs: './docs'};\n",
1763
- themes: false,
1764
- });
1765
- fs.mkdirSync(path.join(tmpDir, 'docs'), {recursive: true});
1766
- const write = (/** @type {string} */ name, /** @type {string} */ text) =>
1767
- fs.writeFileSync(
1768
- path.join(tmpDir, 'docs', `${name}.doc.mjs`),
1769
- `export default {type: 'generic', name: '${name}', title: 'Notes', description: 'Notes.', sections: [{title: 'Run', content: [{type: 'prose', text: ${JSON.stringify(text)}}]}]};\n`,
1770
- );
1771
- const found = async () =>
1772
- (await integrationPackCheck({cwd: tmpDir})).data.issues.filter(
1773
- (/** @type {{code: string}} */ issue) => issue.code === 'doc_tokens_need_cli',
1774
- );
1775
- // An escaped token is shown as written by every release.
1776
- write('escaped', 'Write {@@pm install x} for an install.');
1777
- expect(await found()).toEqual([]);
1778
- write('tokens', 'Run {@command doctor} first.');
1779
- expect((await found()).map((/** @type {any} */ issue) => issue.severity)).toEqual(['warning']);
1780
- const pkgFile = path.join(tmpDir, 'package.json');
1781
- const pkg = JSON.parse(fs.readFileSync(pkgFile, 'utf-8'));
1782
- pkg.peerDependencies = {'@astryxdesign/cli': '>=0.7.3'};
1783
- fs.writeFileSync(pkgFile, `${JSON.stringify(pkg, null, 2)}\n`);
1784
- expect(await found()).toHaveLength(1);
1785
- pkg.peerDependencies = {'@astryxdesign/cli': '>=0.7.4'};
1786
- fs.writeFileSync(pkgFile, `${JSON.stringify(pkg, null, 2)}\n`);
1787
- expect(await found()).toEqual([]);
1788
- }, 120_000);
1789
-
1790
- it('fails a package with a template that sets replaces on a CLI range that rejects the field', async () => {
1791
- writePackage({
1792
- manifest: "export default {templates: './templates'};\n",
1793
- themes: false,
1794
- });
1795
- fs.mkdirSync(path.join(tmpDir, 'templates'), {recursive: true});
1796
- fs.writeFileSync(
1797
- path.join(tmpDir, 'templates', 'acme-shell.doc.mjs'),
1798
- "export default {type: 'page', name: 'acme-shell', description: 'Acme shell.', replaces: 'shell-side-nav'};\n",
1799
- );
1800
- fs.writeFileSync(
1801
- path.join(tmpDir, 'templates', 'acme-shell.tsx'),
1802
- 'export default function AcmeShell() { return null; }\n',
1803
- );
1804
- const file = path.join(tmpDir, 'package.json');
1805
- const peer = (/** @type {string | undefined} */ range) => {
1806
- const pkg = JSON.parse(fs.readFileSync(file, 'utf-8'));
1807
- if (range == null) delete pkg.peerDependencies;
1808
- else pkg.peerDependencies = {'@astryxdesign/cli': range};
1809
- fs.writeFileSync(file, `${JSON.stringify(pkg, null, 2)}\n`);
1810
- };
1811
- const codes = async () =>
1812
- (await integrationPackCheck({cwd: tmpDir})).data.issues.map(
1813
- (/** @type {{code: string}} */ issue) => issue.code,
1814
- );
1815
-
1816
- peer(undefined);
1817
- expect(await codes()).toContain('replaces_needs_cli');
1818
- peer('^0.6.0');
1819
- expect(await codes()).toContain('replaces_needs_cli');
1820
- // Published 0.6.3 rejects `replaces`; published 0.6.4 applies it.
1821
- peer('>=0.6.3');
1822
- expect(await codes()).toContain('replaces_needs_cli');
1823
- peer('>=0.6.4');
1824
- expect(await codes()).not.toContain('replaces_needs_cli');
1825
- peer('>=0.7.0');
1826
- expect(await codes()).not.toContain('replaces_needs_cli');
1827
- }, 120_000);
1828
-
1829
- it('fails a package with a template that sets keywords on a CLI range that rejects the field', async () => {
1830
- writePackage({
1831
- manifest: "export default {templates: './templates'};\n",
1832
- themes: false,
1833
- });
1834
- fs.mkdirSync(path.join(tmpDir, 'templates'), {recursive: true});
1835
- fs.writeFileSync(
1836
- path.join(tmpDir, 'templates', 'acme-health.doc.mjs'),
1837
- "export default {type: 'page', name: 'acme-health', description: 'Status tiles.', keywords: ['uptime']};\n",
1838
- );
1839
- fs.writeFileSync(
1840
- path.join(tmpDir, 'templates', 'acme-health.tsx'),
1841
- 'export default function AcmeHealth() { return null; }\n',
1842
- );
1843
- const file = path.join(tmpDir, 'package.json');
1844
- const peer = (/** @type {string | undefined} */ range) => {
1845
- const pkg = JSON.parse(fs.readFileSync(file, 'utf-8'));
1846
- if (range == null) delete pkg.peerDependencies;
1847
- else pkg.peerDependencies = {'@astryxdesign/cli': range};
1848
- fs.writeFileSync(file, `${JSON.stringify(pkg, null, 2)}\n`);
1849
- };
1850
- const codes = async () =>
1851
- (await integrationPackCheck({cwd: tmpDir})).data.issues.map(
1852
- (/** @type {{code: string}} */ issue) => issue.code,
1853
- );
1854
-
1855
- peer(undefined);
1856
- expect(await codes()).toContain('keywords_needs_cli');
1857
- peer('^0.6.0');
1858
- expect(await codes()).toContain('keywords_needs_cli');
1859
- // Published 0.6.4 and 0.6.5 drop a template that sets `keywords`;
1860
- // published 0.6.6 reads it.
1861
- peer('>=0.6.5');
1862
- expect(await codes()).toContain('keywords_needs_cli');
1863
- peer('>=0.6.6');
1864
- expect(await codes()).not.toContain('keywords_needs_cli');
1865
- peer('>=0.7.0');
1866
- expect(await codes()).not.toContain('keywords_needs_cli');
1867
- }, 120_000);
1868
-
1869
- it('passes when package.json has no files field', async () => {
1870
- writePackage({files: undefined});
1871
- const result = await integrationPackCheck({cwd: tmpDir});
1872
-
1873
- // No files field → npm includes everything
1874
- expect(result.data.packable).toBe(true);
1875
- });
1876
-
1877
- it('detects a lifecycle script that changes packed template replacements', async () => {
1878
- const script = [
1879
- "const fs=require('fs')",
1880
- "const p='templates/acme-shell.template.mjs'",
1881
- "const s=fs.readFileSync(p,'utf8')",
1882
- "fs.writeFileSync(p,s.replace('shell-side-nav','shell-top-nav'))",
1883
- ].join(';');
1884
- writePackage({
1885
- manifest: "export default {templates: './templates'};\n",
1886
- files: ['astryx.integration.mjs', 'templates'],
1887
- themes: false,
1888
- scripts: {prepack: `node -e "${script}"`},
1889
- });
1890
- fs.mkdirSync(path.join(tmpDir, 'templates'));
1891
- fs.writeFileSync(
1892
- path.join(tmpDir, 'templates', 'acme-shell.template.mjs'),
1893
- "export default {type: 'page', name: 'Acme shell', description: 'Fixture.', replaces: 'shell-side-nav'};\n",
1894
- );
1895
- fs.writeFileSync(
1896
- path.join(tmpDir, 'templates', 'acme-shell.tsx'),
1897
- 'export default function AcmeShell() { return null; }\n',
1898
- );
1899
-
1900
- const result = await integrationPackCheck({cwd: tmpDir});
1901
-
1902
- expect(result.data.packable).toBe(false);
1903
- expect(result.data.issues).toContainEqual(
1904
- expect.objectContaining({
1905
- code: 'identity_mismatch',
1906
- message: expect.stringContaining('acme-shell'),
1907
- }),
1908
- );
1909
- });
1910
-
1911
- it('detects a lifecycle script that changes the packed identity', async () => {
1912
- const script = [
1913
- "const fs=require('fs')",
1914
- "fs.renameSync('themes/ocean','themes/storm')",
1915
- "const p='themes/storm/oceanTheme.doc.mjs'",
1916
- "let x=fs.readFileSync(p,'utf8')",
1917
- "x=x.replace(/name: 'ocean'/, 'name: '+String.fromCharCode(39)+'storm'+String.fromCharCode(39))",
1918
- 'fs.writeFileSync(p,x)',
1919
- ].join(';');
1920
- writePackage({
1921
- files: ['astryx.integration.mjs', 'themes'],
1922
- scripts: {prepack: `node -e "${script}"`},
1923
- });
1924
-
1925
- const result = await integrationPackCheck({cwd: tmpDir});
1926
-
1927
- expect(result.data.packable).toBe(false);
1928
- expect(
1929
- result.data.issues.find(issue => issue.code === 'identity_not_packed')
1930
- ?.message,
1931
- ).toContain('ocean');
1932
- expect(
1933
- result.data.issues.find(
1934
- issue => issue.code === 'packed_identity_unexpected',
1935
- )?.message,
1936
- ).toContain('storm');
1937
- });
1938
-
1939
- it('rejects a declared root with no contribution files', async () => {
1940
- writePackage({
1941
- manifest: "export default {docs: './docs'};\n",
1942
- files: ['astryx.integration.mjs', 'docs'],
1943
- themes: false,
1944
- });
1945
- fs.mkdirSync(path.join(tmpDir, 'docs'));
1946
-
1947
- const result = await integrationPackCheck({cwd: tmpDir});
1948
-
1949
- expect(result.data.packable).toBe(false);
1950
- expect(
1951
- result.data.issues.some(
1952
- issue => issue.code === 'empty_contribution_root',
1953
- ),
1954
- ).toBe(true);
1955
- });
1956
-
1957
- it('handles scoped package extraction correctly', async () => {
1958
- writePackage({
1959
- name: '@my-org/deep-integration',
1960
- files: ['astryx.integration.mjs', 'themes'],
1961
- });
1962
- const result = await integrationPackCheck({cwd: tmpDir});
1963
-
1964
- expect(result.data.name).toBe('@my-org/deep-integration');
1965
- expect(result.data.packable).toBe(true);
1966
- });
1967
-
1968
- it('reports source-only component candidates as warnings', async () => {
1969
- writePackage({
1970
- manifest:
1971
- "export default {themes: './themes', components: './components'};\n",
1972
- files: ['astryx.integration.mjs', 'themes', 'components'],
1973
- components: true,
1974
- });
1975
- const result = await integrationPackCheck({cwd: tmpDir});
1976
-
1977
- const sourceWarnings = result.data.issues.filter(
1978
- issue => issue.code === 'source_without_component_doc',
1979
- );
1980
- // Card.tsx is PascalCase but has no doc metadata → warning
1981
- expect(sourceWarnings.length).toBeGreaterThanOrEqual(1);
1982
- expect(sourceWarnings[0].severity).toBe('warning');
1983
- expect(sourceWarnings[0].message).toContain('Card.tsx');
1984
- });
1985
-
1986
- it('reports template sources without metadata as warnings', async () => {
1987
- writePackage({
1988
- manifest:
1989
- "export default {themes: './themes', templates: './templates'};\n",
1990
- files: ['astryx.integration.mjs', 'themes', 'templates'],
1991
- templates: true,
1992
- });
1993
- const result = await integrationPackCheck({cwd: tmpDir});
1994
-
1995
- const sourceWarnings = result.data.issues.filter(
1996
- issue => issue.code === 'source_without_template_doc',
1997
- );
1998
- expect(sourceWarnings).toHaveLength(1);
1999
- expect(sourceWarnings[0].severity).toBe('warning');
2000
- expect(sourceWarnings[0].message).toContain('stray.tsx');
2001
- });
2002
-
2003
- it('says npm pack skips a symlinked root instead of asking for a "files" entry', async () => {
2004
- writePackage({
2005
- manifest:
2006
- "export default {themes: './themes', components: './components'};\n",
2007
- });
2008
- const real = path.join(tmpDir, 'real-components');
2009
- fs.mkdirSync(real, {recursive: true});
2010
- fs.writeFileSync(
2011
- path.join(real, 'Card.doc.mjs'),
2012
- "export default {type: 'component', name: 'Card', displayName: 'Card', usage: {description: 'Card.'}, props: []};\n",
2013
- );
2014
- fs.writeFileSync(
2015
- path.join(real, 'Card.tsx'),
2016
- 'export function Card() { return null; }\n',
2017
- );
2018
- fs.symlinkSync('real-components', path.join(tmpDir, 'components'));
2019
-
2020
- const result = await integrationPackCheck({cwd: tmpDir});
2021
- const codes = result.data.issues.map(issue => issue.code);
2022
- expect(codes).toContain('symlinked_root');
2023
- const notPacked = result.data.issues.find(
2024
- issue => issue.code === 'root_not_packed',
2025
- );
2026
- expect(notPacked?.message).toBe(
2027
- 'Declared components root "components" has 0 of 2 expected files in the pack list. It is reached through the symlink "components", and npm pack does not follow a symlinked folder. Fix: replace the link with the folder itself, or point "components" at the folder it links to.',
2028
- );
2029
- });
2030
-
2031
- it('names packed files by their path in the package, never the scratch copy', async () => {
2032
- writePackage({
2033
- manifest:
2034
- "export default {themes: './themes', docs: './docs/a.doc.mjs'};\n",
2035
- });
2036
- fs.mkdirSync(path.join(tmpDir, 'docs'), {recursive: true});
2037
- fs.writeFileSync(path.join(tmpDir, 'docs', 'a.doc.mjs'), '');
2038
-
2039
- const result = await integrationPackCheck({cwd: tmpDir});
2040
- const messages = result.data.issues.map(issue => issue.message);
2041
- expect(messages.join('\n')).not.toContain(
2042
- path.join(tmpDir, '.astryx-pack-check-'),
2043
- );
2044
- expect(messages).toContain(
2045
- 'Packed: Declared docs root is a file, not a folder: docs/a.doc.mjs. Fix: point "docs" in the manifest at the folder that holds them.',
2046
- );
2047
- // The root's own issue covers it: no empty-root error, no raw errno.
2048
- const codes = result.data.issues.map(issue => issue.code);
2049
- expect(codes).not.toContain('empty_contribution_root');
2050
- expect(codes).not.toContain('local_discovery_failed');
2051
- expect(codes).not.toContain('packed_discovery_failed');
2052
- });
2053
-
2054
- it('fails on a package.json npm cannot pack, which validate only warns about', async () => {
2055
- writePackage({files: ['astryx.integration.mjs', 'themes']});
2056
- const packageFile = path.join(tmpDir, 'package.json');
2057
- const pkg = JSON.parse(fs.readFileSync(packageFile, 'utf-8'));
2058
- delete pkg.name;
2059
- fs.writeFileSync(packageFile, `${JSON.stringify(pkg, null, 2)}\n`);
2060
-
2061
- const result = await integrationPackCheck({cwd: tmpDir});
2062
-
2063
- expect(result.data.packable).toBe(false);
2064
- expect(
2065
- result.data.issues.map(issue => [issue.code, issue.severity]),
2066
- ).toEqual([
2067
- ['invalid_package_json', 'error'],
2068
- ['pack_failed', 'error'],
2069
- ]);
2070
- });
2071
-
2072
- it('cleans up its scratch consumer when npm pack fails', async () => {
2073
- writePackage({
2074
- files: ['astryx.integration.mjs', 'themes'],
2075
- scripts: {prepack: 'node -e "process.exit(17)"'},
2076
- });
2077
-
2078
- const result = await integrationPackCheck({cwd: tmpDir});
2079
-
2080
- expect(result.data.packable).toBe(false);
2081
- expect(result.data.issues.some(issue => issue.code === 'pack_failed')).toBe(
2082
- true,
2083
- );
2084
- expect(
2085
- fs
2086
- .readdirSync(tmpDir)
2087
- .filter(name => name.startsWith('.astryx-pack-check-')),
2088
- ).toEqual([]);
2089
- });
2090
-
2091
- it('cleans up its scratch consumer after a successful check', async () => {
2092
- writePackage({files: ['astryx.integration.mjs', 'themes']});
2093
-
2094
- const result = await integrationPackCheck({cwd: tmpDir});
2095
-
2096
- expect(result.data.packable).toBe(true);
2097
- expect(
2098
- fs
2099
- .readdirSync(tmpDir)
2100
- .filter(name => name.startsWith('.astryx-pack-check-')),
2101
- ).toEqual([]);
2102
- });
2103
-
2104
- it("reads npm 8's scoped tarball name as the file npm writes", () => {
2105
- const entry = {entryCount: 1, size: 1, unpackedSize: 1, files: []};
2106
- expect(
2107
- parseNpmPackOutput(
2108
- JSON.stringify([{...entry, filename: '@acme/kit-1.0.0.tgz'}]),
2109
- ).filename,
2110
- ).toBe('acme-kit-1.0.0.tgz');
2111
- expect(
2112
- parseNpmPackOutput(
2113
- JSON.stringify([{...entry, filename: 'acme-kit-1.0.0.tgz'}]),
2114
- ).filename,
2115
- ).toBe('acme-kit-1.0.0.tgz');
2116
- });
2117
-
2118
- it('rejects malformed npm pack output without a raw TypeError', () => {
2119
- expect(() =>
2120
- parseNpmPackOutput(
2121
- JSON.stringify([
2122
- {filename: 'pkg.tgz', entryCount: 1, size: 1, unpackedSize: 1},
2123
- ]),
2124
- ),
2125
- ).toThrow(/without a files array/);
2126
- });
2127
-
2128
- it('reports pack_failed when no npm can be found', async () => {
2129
- writePackage({files: ['astryx.integration.mjs', 'themes']});
2130
- const originalPath = process.env.PATH;
2131
- const originalExecPath = process.execPath;
2132
- process.env.PATH = '';
2133
- // A Node with no npm beside it, and no npm on the PATH.
2134
- process.execPath = path.join(tmpDir, 'no-npm', 'bin', 'node');
2135
- try {
2136
- const result = await integrationPackCheck({cwd: tmpDir});
2137
- expect(result.data.packable).toBe(false);
2138
- expect(result.data.issues).toContainEqual(
2139
- expect.objectContaining({
2140
- code: 'pack_failed',
2141
- message: expect.stringContaining('Could not start npm pack'),
2142
- }),
2143
- );
2144
- } finally {
2145
- process.env.PATH = originalPath;
2146
- process.execPath = originalExecPath;
2147
- }
2148
- });
2149
-
2150
- it('does not execute shell metacharacters embedded in the cwd', async () => {
2151
- const marker = path.join(process.cwd(), 'astryx-pack-check-injected');
2152
- fs.rmSync(marker, {force: true});
2153
- const weirdDir = fs.mkdtempSync(
2154
- path.join(process.cwd(), '.astryx-;touch astryx-pack-check-injected;#-'),
2155
- );
2156
- try {
2157
- const pkg = {name: 'safe-pkg', version: '1.0.0'};
2158
- fs.writeFileSync(
2159
- path.join(weirdDir, 'package.json'),
2160
- JSON.stringify(pkg),
2161
- );
2162
- fs.writeFileSync(
2163
- path.join(weirdDir, 'astryx.integration.mjs'),
2164
- 'export default {};\n',
2165
- );
2166
- const result = await integrationPackCheck({cwd: weirdDir});
2167
- expect(result.type).toBe('integration.pack-check');
2168
- expect(fs.existsSync(marker)).toBe(false);
2169
- } finally {
2170
- fs.rmSync(weirdDir, {recursive: true, force: true});
2171
- fs.rmSync(marker, {force: true});
2172
- }
2173
- });
2174
-
2175
- it('returns early with issues for a directory without package.json', async () => {
2176
- const emptyDir = fs.mkdtempSync(
2177
- path.join(os.tmpdir(), 'astryx-pack-check-empty-'),
2178
- );
2179
- try {
2180
- const result = await integrationPackCheck({cwd: emptyDir});
2181
- expect(result.data.packable).toBe(false);
2182
- expect(result.data.issues.some(i => i.code === 'no_package')).toBe(true);
2183
- } finally {
2184
- fs.rmSync(emptyDir, {recursive: true, force: true});
2185
- }
2186
- });
2187
-
2188
- it('reports malformed package.json instead of treating it as missing', async () => {
2189
- fs.writeFileSync(path.join(tmpDir, 'package.json'), '{bad-json');
2190
- fs.writeFileSync(
2191
- path.join(tmpDir, 'astryx.integration.mjs'),
2192
- 'export default {};\n',
2193
- );
2194
-
2195
- const result = await integrationPackCheck({cwd: tmpDir});
2196
-
2197
- expect(result.data.packable).toBe(false);
2198
- expect(result.data.issues).toContainEqual(
2199
- expect.objectContaining({code: 'invalid_package_json'}),
2200
- );
2201
- });
2202
-
2203
- it('returns early with issues for a package without a manifest', async () => {
2204
- fs.writeFileSync(
2205
- path.join(tmpDir, 'package.json'),
2206
- '{"name":"bare-pkg","version":"1.0.0"}\n',
2207
- );
2208
- const result = await integrationPackCheck({cwd: tmpDir});
2209
-
2210
- expect(result.data.packable).toBe(false);
2211
- expect(result.data.issues.some(i => i.code === 'missing_manifest')).toBe(
2212
- true,
2213
- );
2214
- });
2215
- });
2216
-
2217
- describe('pack-check mutation tests', () => {
2218
- it('detects when a theme source is deleted after initial authoring', async () => {
2219
- writePackage({files: ['astryx.integration.mjs', 'themes']});
2220
- fs.rmSync(path.join(tmpDir, 'themes', 'ocean', 'oceanTheme.ts'));
2221
-
2222
- const result = await integrationPackCheck({cwd: tmpDir});
2223
- expect(result.data.packable).toBe(false);
2224
- expect(result.data.issues).toContainEqual(
2225
- expect.objectContaining({code: 'invalid_theme'}),
2226
- );
2227
- });
2228
-
2229
- it('detects when files[] is narrowed after add removes themes', async () => {
2230
- // First: valid package
2231
- writePackage({files: ['astryx.integration.mjs', 'themes']});
2232
-
2233
- // Narrow files to exclude themes
2234
- const pkg = JSON.parse(
2235
- fs.readFileSync(path.join(tmpDir, 'package.json'), 'utf-8'),
2236
- );
2237
- pkg.files = ['astryx.integration.mjs'];
2238
- fs.writeFileSync(
2239
- path.join(tmpDir, 'package.json'),
2240
- JSON.stringify(pkg, null, 2) + '\n',
2241
- );
2242
-
2243
- const result = await integrationPackCheck({cwd: tmpDir});
2244
- expect(result.data.packable).toBe(false);
2245
- expect(result.data.issues.some(i => i.code === 'root_not_packed')).toBe(
2246
- true,
2247
- );
2248
- });
2249
-
2250
- it('correctly counts packed vs expected files in inventory', async () => {
2251
- writePackage({files: ['astryx.integration.mjs', 'themes']});
2252
- const result = await integrationPackCheck({cwd: tmpDir});
2253
-
2254
- expect(result.data.inventory.expectedFiles).toBeGreaterThan(0);
2255
- expect(result.data.inventory.packedFiles).toBe(
2256
- result.data.inventory.expectedFiles,
2257
- );
2258
- for (const root of result.data.inventory.roots) {
2259
- expect(root.complete).toBe(true);
2260
- expect(root.missingFiles).toEqual([]);
2261
- }
2262
- });
2263
- });
2264
-
2265
- describe('extensionless subpath resolution', () => {
2266
- it('rejects .tsx public specifiers before publishing', async () => {
2267
- // Manually construct a package with OLD-style .tsx exports keys
2268
- writePackage({
2269
- manifest: "export default {components: './components'};\n",
2270
- files: ['astryx.integration.mjs', 'components', 'index.mjs'],
2271
- themes: false,
2272
- });
2273
- const pkgFile = path.join(tmpDir, 'package.json');
2274
- const pkg = JSON.parse(fs.readFileSync(pkgFile, 'utf-8'));
2275
- pkg.exports = {
2276
- '.': './index.mjs',
2277
- './components/AcmeWidget.tsx': './components/AcmeWidget.tsx',
2278
- };
2279
- fs.writeFileSync(pkgFile, `${JSON.stringify(pkg, null, 2)}\n`);
2280
- fs.writeFileSync(
2281
- path.join(tmpDir, 'index.mjs'),
2282
- 'export const existing = 1;\n',
2283
- );
2284
- fs.mkdirSync(path.join(tmpDir, 'components'));
2285
- fs.writeFileSync(
2286
- path.join(tmpDir, 'components', 'AcmeWidget.doc.mjs'),
2287
- `export default {type: 'component', name: 'AcmeWidget', import: '@acme/widgets/components/AcmeWidget.tsx', description: 'Widget.', props: []};\n`,
2288
- );
2289
- fs.writeFileSync(
2290
- path.join(tmpDir, 'components', 'AcmeWidget.tsx'),
2291
- 'export function AcmeWidget() { return null; }\n',
2292
- );
2293
-
2294
- const result = await integrationPackCheck({cwd: tmpDir});
2295
-
2296
- // The .tsx extension in the specifier must be caught
2297
- expect(result.data.packable).toBe(false);
2298
- expect(result.data.issues).toContainEqual(
2299
- expect.objectContaining({
2300
- code: 'typescript_extension_in_specifier',
2301
- message: expect.stringContaining('.tsx'),
2302
- }),
2303
- );
2304
- });
2305
-
2306
- it('generated extensionless component specifier resolves through exports map', async () => {
2307
- fs.writeFileSync(
2308
- path.join(tmpDir, 'package.json'),
2309
- `${JSON.stringify({
2310
- name: '@acme/widgets',
2311
- version: '1.0.0',
2312
- files: ['index.mjs'],
2313
- exports: {'.': './index.mjs'},
2314
- })}\n`,
2315
- );
2316
- fs.writeFileSync(
2317
- path.join(tmpDir, 'index.mjs'),
2318
- 'export const existing = 1;\n',
2319
- );
2320
- await integrationAddComponent('AcmeWidget', {cwd: tmpDir});
2321
-
2322
- // Verify the exports map has extensionless key → .tsx target
2323
- const pkg = JSON.parse(
2324
- fs.readFileSync(path.join(tmpDir, 'package.json'), 'utf-8'),
2325
- );
2326
- expect(pkg.exports['./components/AcmeWidget']).toBe(
2327
- './components/AcmeWidget.tsx',
2328
- );
2329
- expect(pkg.exports['./components/AcmeWidget.tsx']).toBeUndefined();
2330
-
2331
- const result = await integrationPackCheck({cwd: tmpDir});
2332
-
2333
- expect(result.data.packable).toBe(true);
2334
- expect(result.data.issues).not.toContainEqual(
2335
- expect.objectContaining({code: 'typescript_extension_in_specifier'}),
2336
- );
2337
- expect(result.data.issues).not.toContainEqual(
2338
- expect.objectContaining({code: 'component_import_unresolvable'}),
2339
- );
2340
- });
2341
-
2342
- it('validates generated imports without project-local TypeScript', async () => {
2343
- fs.rmSync(tmpDir, {recursive: true, force: true});
2344
- tmpDir = fs.mkdtempSync(
2345
- path.join(os.tmpdir(), 'astryx-pack-check-no-typescript-'),
2346
- );
2347
- fs.writeFileSync(
2348
- path.join(tmpDir, 'package.json'),
2349
- `${JSON.stringify({
2350
- name: '@acme/widgets',
2351
- version: '1.0.0',
2352
- files: ['index.mjs'],
2353
- exports: {'.': './index.mjs'},
2354
- })}\n`,
2355
- );
2356
- fs.writeFileSync(
2357
- path.join(tmpDir, 'index.mjs'),
2358
- 'export const existing = 1;\n',
2359
- );
2360
- await integrationAddComponent('AcmeWidget', {cwd: tmpDir});
2361
-
2362
- const result = await integrationPackCheck({cwd: tmpDir});
2363
-
2364
- expect(result.data.packable).toBe(true);
2365
- expect(result.data.issues).not.toContainEqual(
2366
- expect.objectContaining({code: 'component_import_unresolvable'}),
2367
- );
2368
- });
2369
-
2370
- it('generated extensionless template specifiers resolve for page and block types', async () => {
2371
- fs.writeFileSync(
2372
- path.join(tmpDir, 'package.json'),
2373
- `${JSON.stringify({
2374
- name: '@acme/widgets',
2375
- version: '1.0.0',
2376
- files: ['index.mjs'],
2377
- exports: {'.': './index.mjs'},
2378
- })}\n`,
2379
- );
2380
- fs.writeFileSync(
2381
- path.join(tmpDir, 'index.mjs'),
2382
- 'export const existing = 1;\n',
2383
- );
2384
- await integrationAddTemplate('account-page', {cwd: tmpDir, type: 'page'});
2385
- await integrationAddTemplate('info-card', {cwd: tmpDir, type: 'block'});
2386
-
2387
- const pkg = JSON.parse(
2388
- fs.readFileSync(path.join(tmpDir, 'package.json'), 'utf-8'),
2389
- );
2390
- expect(pkg.exports['./templates/account-page']).toBe(
2391
- './templates/account-page.tsx',
2392
- );
2393
- expect(pkg.exports['./templates/info-card']).toBe(
2394
- './templates/info-card.tsx',
2395
- );
2396
-
2397
- const result = await integrationPackCheck({cwd: tmpDir});
2398
-
2399
- expect(result.data.packable).toBe(true);
2400
- expect(result.data.issues).not.toContainEqual(
2401
- expect.objectContaining({code: 'template_import_unresolvable'}),
2402
- );
2403
- expect(result.data.issues).not.toContainEqual(
2404
- expect.objectContaining({code: 'typescript_extension_in_specifier'}),
2405
- );
2406
- });
2407
-
2408
- it('preserves condition-style exports sugar without creating a map', async () => {
2409
- // Package with condition-only exports (sugar, no subpaths)
2410
- fs.writeFileSync(
2411
- path.join(tmpDir, 'package.json'),
2412
- `${JSON.stringify({
2413
- name: '@acme/widgets',
2414
- version: '1.0.0',
2415
- files: ['index.mjs'],
2416
- exports: {import: './index.mjs', require: './index.cjs'},
2417
- })}\n`,
2418
- );
2419
- fs.writeFileSync(
2420
- path.join(tmpDir, 'index.mjs'),
2421
- 'export const existing = 1;\n',
2422
- );
2423
- fs.writeFileSync(path.join(tmpDir, 'index.cjs'), 'exports.existing = 1;\n');
2424
- fs.writeFileSync(
2425
- path.join(tmpDir, 'astryx.integration.mjs'),
2426
- 'export default {};\n',
2427
- );
2428
-
2429
- await integrationAddComponent('AcmeWidget', {cwd: tmpDir});
2430
-
2431
- const pkg = JSON.parse(
2432
- fs.readFileSync(path.join(tmpDir, 'package.json'), 'utf-8'),
2433
- );
2434
- // Condition sugar wrapped into subpath map with the component added
2435
- expect(pkg.exports['.']).toEqual({
2436
- import: './index.mjs',
2437
- require: './index.cjs',
2438
- });
2439
- expect(pkg.exports['./components/AcmeWidget']).toBe(
2440
- './components/AcmeWidget.tsx',
2441
- );
2442
- });
2443
-
2444
- it('no-map: pack-check fails when generated component has no exports map', async () => {
2445
- fs.writeFileSync(
2446
- path.join(tmpDir, 'package.json'),
2447
- `${JSON.stringify({
2448
- name: '@acme/widgets',
2449
- version: '1.0.0',
2450
- files: ['dist'],
2451
- })}\n`,
2452
- );
2453
- fs.writeFileSync(
2454
- path.join(tmpDir, 'astryx.integration.mjs'),
2455
- 'export default {};\n',
2456
- );
2457
-
2458
- await integrationAddComponent('AcmeWidget', {cwd: tmpDir});
2459
- await integrationAddTemplate('hero-page', {cwd: tmpDir, type: 'page'});
2460
-
2461
- const pkg = JSON.parse(
2462
- fs.readFileSync(path.join(tmpDir, 'package.json'), 'utf-8'),
2463
- );
2464
- // No exports map created
2465
- expect(pkg.exports).toBeUndefined();
2466
-
2467
- const result = await integrationPackCheck({cwd: tmpDir});
2468
-
2469
- // The extensionless import cannot resolve without an exports map —
2470
- // pack-check must fail closed, not false-green.
2471
- expect(result.data.packable).toBe(false);
2472
- expect(result.data.issues).toContainEqual(
2473
- expect.objectContaining({
2474
- severity: 'error',
2475
- message: expect.stringContaining('AcmeWidget'),
2476
- }),
2477
- );
2478
- });
2479
-
2480
- it('idempotent when extensionless export already exists', async () => {
2481
- fs.writeFileSync(
2482
- path.join(tmpDir, 'package.json'),
2483
- `${JSON.stringify({
2484
- name: '@acme/widgets',
2485
- version: '1.0.0',
2486
- files: ['index.mjs'],
2487
- exports: {
2488
- '.': './index.mjs',
2489
- './components/AcmeWidget': './components/AcmeWidget.tsx',
2490
- },
2491
- })}\n`,
2492
- );
2493
- fs.writeFileSync(
2494
- path.join(tmpDir, 'index.mjs'),
2495
- 'export const existing = 1;\n',
2496
- );
2497
- fs.writeFileSync(
2498
- path.join(tmpDir, 'astryx.integration.mjs'),
2499
- 'export default {};\n',
2500
- );
2501
-
2502
- await integrationAddComponent('AcmeWidget', {cwd: tmpDir});
2503
-
2504
- const pkg = JSON.parse(
2505
- fs.readFileSync(path.join(tmpDir, 'package.json'), 'utf-8'),
2506
- );
2507
- // Export preserved, no duplicate
2508
- expect(
2509
- Object.keys(pkg.exports).filter(k => k.includes('AcmeWidget')),
2510
- ).toEqual(['./components/AcmeWidget']);
2511
- });
2512
- });