@astryxdesign/cli 0.7.6-canary.f73623d → 0.7.6-canary.f899313

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 (498) hide show
  1. package/package.json +23 -10
  2. package/api/api-docs-parse.test.mjs +0 -47
  3. package/api/blog/_adapter.test.mjs +0 -183
  4. package/api/blog/blog.test.mjs +0 -144
  5. package/api/blog/detail/detail.test.mjs +0 -118
  6. package/api/blog/list/list.test.mjs +0 -81
  7. package/api/build/blocks/blocks.test.mjs +0 -238
  8. package/api/build/build.test.mjs +0 -569
  9. package/api/build/kit/answer.test.mjs +0 -108
  10. package/api/build/kit/rank.test.mjs +0 -380
  11. package/api/build/kit/weights.test.mjs +0 -286
  12. package/api/build/tree.test.mjs +0 -185
  13. package/api/component/component-replacement.test.mjs +0 -616
  14. package/api/component/component.test.mjs +0 -532
  15. package/api/component/doc-links.test.mjs +0 -419
  16. package/api/component/integration-export-name.test.mjs +0 -644
  17. package/api/component/integration-import-agreement.test.mjs +0 -474
  18. package/api/discover/_adapter.test.mjs +0 -839
  19. package/api/discover/_catalog-view.test.mjs +0 -129
  20. package/api/discover/_package-scanner.test.mjs +0 -117
  21. package/api/discover/detail/detail.test.mjs +0 -145
  22. package/api/discover/detail/doc/doc.test.mjs +0 -93
  23. package/api/discover/detail/item/item.test.mjs +0 -75
  24. package/api/discover/discover.test.mjs +0 -100
  25. package/api/discover/list/list.test.mjs +0 -107
  26. package/api/discover/search/search.test.mjs +0 -319
  27. package/api/docs/compiled-topics.test.mjs +0 -94
  28. package/api/docs/detail/section/section.test.mjs +0 -92
  29. package/api/docs/docOverlays.test.mjs +0 -189
  30. package/api/docs/docs-homes.test.mjs +0 -127
  31. package/api/docs/docs.depth.test.mjs +0 -134
  32. package/api/docs/docs.test.mjs +0 -315
  33. package/api/docs/guide-route-targets.test.mjs +0 -1002
  34. package/api/docs/index/index.test.mjs +0 -67
  35. package/api/docs/integration-tree.test.mjs +0 -616
  36. package/api/docs/integrationDocs.test.mjs +0 -546
  37. package/api/docs/namespace-section.test.mjs +0 -260
  38. package/api/docs/react-version-sync.test.mjs +0 -79
  39. package/api/docs/reference-blocks.test.mjs +0 -404
  40. package/api/docs/token-tables.test.mjs +0 -93
  41. package/api/doctor/built-checks.test.mjs +0 -537
  42. package/api/doctor/doctor.test.mjs +0 -1651
  43. package/api/doctor/icon-sets.test.mjs +0 -111
  44. package/api/doctor/release-checks.test.mjs +0 -156
  45. package/api/doctor/theme-checks.test.mjs +0 -884
  46. package/api/gap-report/gap-report.test.mjs +0 -1549
  47. package/api/hook/detail/detail.test.mjs +0 -53
  48. package/api/hook/detail/params/params.test.mjs +0 -39
  49. package/api/hook/hook.test.mjs +0 -75
  50. package/api/icon/all-or-nothing.test.mjs +0 -283
  51. package/api/icon/error-codes.test.mjs +0 -341
  52. package/api/icon/experimental-markers.test.mjs +0 -93
  53. package/api/icon/icon.test.mjs +0 -506
  54. package/api/icon/new-definition/new-definition.undo.test.mjs +0 -97
  55. package/api/icon/new-set/new-set.test.mjs +0 -398
  56. package/api/icon/option-pairs.test.mjs +0 -368
  57. package/api/init/init.test.mjs +0 -319
  58. package/api/init/remove/remove.test.mjs +0 -124
  59. package/api/init/user/user.test.mjs +0 -232
  60. package/api/integration/add-contribution.component-names.test.mjs +0 -186
  61. package/api/integration/add-contribution.test.mjs +0 -990
  62. package/api/integration/add-helpers.test.mjs +0 -161
  63. package/api/integration/add-theme.test.mjs +0 -676
  64. package/api/integration/authoring-checks.test.mjs +0 -1691
  65. package/api/integration/check/check.test.mjs +0 -538
  66. package/api/integration/doc-stability.test.mjs +0 -216
  67. package/api/integration/example-checks.no-npm.test.mjs +0 -140
  68. package/api/integration/example-checks.test.mjs +0 -776
  69. package/api/integration/integration-block-exports.test.mjs +0 -248
  70. package/api/integration/pack-check.component-replaces.test.mjs +0 -126
  71. package/api/integration/pack-check.lifecycle-output.test.mjs +0 -149
  72. package/api/integration/pack-check.test.mjs +0 -2512
  73. package/api/integration/public-api.test.mjs +0 -21
  74. package/api/integration/template-conflict-compatibility.test.mjs +0 -73
  75. package/api/integration/validate-installed-icon-sets.test.mjs +0 -67
  76. package/api/integration/validate-integration-case-disk.test.mjs +0 -123
  77. package/api/integration/validate-integration-fixes.test.mjs +0 -1457
  78. package/api/integration/validate-integration-gaps.test.mjs +0 -2007
  79. package/api/integration/validate-integration.test.mjs +0 -835
  80. package/api/integration/validate-unread-theme-folders.test.mjs +0 -111
  81. package/api/json/envelope-types.test.mjs +0 -76
  82. package/api/json/parse.test.mjs +0 -76
  83. package/api/render/render.test.mjs +0 -1155
  84. package/api/search/_adapter.test.mjs +0 -192
  85. package/api/search/_doc-searcher.test.mjs +0 -36
  86. package/api/search/_entries.test.mjs +0 -48
  87. package/api/search/_main-searcher.test.mjs +0 -106
  88. package/api/search/_order.test.mjs +0 -72
  89. package/api/search/_template-searcher.test.mjs +0 -40
  90. package/api/search/search-return-type.test.mjs +0 -54
  91. package/api/search/search.domain-priority.test.mjs +0 -351
  92. package/api/search/search.family-members.test.mjs +0 -124
  93. package/api/search/search.family-word.test.mjs +0 -146
  94. package/api/search/search.integration-block.test.mjs +0 -100
  95. package/api/search/search.integration-check.test.mjs +0 -24
  96. package/api/search/search.test.mjs +0 -1007
  97. package/api/search/search.tie-order.test.mjs +0 -39
  98. package/api/search/tree.test.mjs +0 -66
  99. package/api/swizzle/_github.test.mjs +0 -53
  100. package/api/swizzle/copy/copy.test.mjs +0 -60
  101. package/api/swizzle/swizzle.test.mjs +0 -157
  102. package/api/template/cdn/cdn.test.mjs +0 -108
  103. package/api/template/checkout-wizard.test.mjs +0 -87
  104. package/api/template/copy/copy.receipt.test.mjs +0 -77
  105. package/api/template/copy/copy.test.mjs +0 -77
  106. package/api/template/data-token-fallbacks.test.mjs +0 -85
  107. package/api/template/discover-integration-templates.test.mjs +0 -56
  108. package/api/template/form-wizard-dialog.test.mjs +0 -47
  109. package/api/template/inline-wizard-template.test.mjs +0 -24
  110. package/api/template/list/list.test.mjs +0 -52
  111. package/api/template/show/show.test.mjs +0 -76
  112. package/api/template/table-filter-view-tabs.test.mjs +0 -45
  113. package/api/template/table-floating-bulk-actions.test.mjs +0 -66
  114. package/api/template/template-integration.test.mjs +0 -1274
  115. package/api/template/template-suffix.test.mjs +0 -286
  116. package/api/template/template.test.mjs +0 -222
  117. package/api/template/tokenizer-showcase.test.mjs +0 -47
  118. package/api/template/unknown-name.test.mjs +0 -63
  119. package/api/theme/add/add.test.mjs +0 -363
  120. package/api/theme/add/add.types.test.mjs +0 -150
  121. package/api/theme/build/build.adaptation-core-compat.test.mjs +0 -394
  122. package/api/theme/build/build.adaptation-enrollment.test.mjs +0 -219
  123. package/api/theme/build/build.core-on-demand.test.mjs +0 -113
  124. package/api/theme/build/build.family.test.mjs +0 -503
  125. package/api/theme/build/build.font-warning.test.mjs +0 -170
  126. package/api/theme/build/build.heading-core-compat.test.mjs +0 -68
  127. package/api/theme/build/build.icon-entry-variants.test.mjs +0 -134
  128. package/api/theme/build/build.icon-function-entries.test.mjs +0 -499
  129. package/api/theme/build/build.icon-lineage.test.mjs +0 -117
  130. package/api/theme/build/build.icon-preservation.test.mjs +0 -639
  131. package/api/theme/build/build.icon-variants.test.mjs +0 -105
  132. package/api/theme/build/build.icons-specifier.test.mjs +0 -149
  133. package/api/theme/build/build.packed-old-core.test.mjs +0 -1512
  134. package/api/theme/build/build.project-core.test.mjs +0 -220
  135. package/api/theme/build/build.public-component-vars.test.mjs +0 -151
  136. package/api/theme/build/build.receipt-doc.test.mjs +0 -111
  137. package/api/theme/build/build.rollback.test.mjs +0 -148
  138. package/api/theme/build/build.test.mjs +0 -1258
  139. package/api/theme/build/font-warning.test.mjs +0 -268
  140. package/api/theme/eject/eject.binary.test.mjs +0 -90
  141. package/api/theme/eject/eject.copy-compat.test.mjs +0 -168
  142. package/api/theme/eject/eject.rollback.test.mjs +0 -158
  143. package/api/theme/eject/eject.staging.test.mjs +0 -83
  144. package/api/theme/eject/eject.test.mjs +0 -160
  145. package/api/theme/integration-themes.test.mjs +0 -218
  146. package/api/theme/list/list.test.mjs +0 -271
  147. package/api/theme/palette/generate/generate.test.mjs +0 -445
  148. package/api/theme/palette/generate/generator.test.mjs +0 -385
  149. package/api/theme/palette/generate/preview.test.mjs +0 -55
  150. package/api/theme/remove/remove.test.mjs +0 -94
  151. package/api/theme/targets/targets.test.mjs +0 -91
  152. package/api/theme/template/template.test.mjs +0 -102
  153. package/api/theme/use/use.test.mjs +0 -98
  154. package/api/upgrade/list/list.test.mjs +0 -73
  155. package/api/upgrade/project-context.test.mjs +0 -272
  156. package/api/upgrade/provider-agreement.test.mjs +0 -152
  157. package/api/upgrade/registry/registry.test.mjs +0 -911
  158. package/api/upgrade/run/authoring-codemod-reachable.test.mjs +0 -99
  159. package/api/upgrade/run/cli-behind-core.test.mjs +0 -438
  160. package/api/upgrade/run/failure-receipt.test.mjs +0 -212
  161. package/api/upgrade/run/files-changed.test.mjs +0 -111
  162. package/api/upgrade/run/outcomes.test.mjs +0 -646
  163. package/api/upgrade/run/run.test.mjs +0 -511
  164. package/api/upgrade/upgrade.test.mjs +0 -594
  165. package/assets/codemods/__tests__/registry.test.mjs +0 -77
  166. package/assets/codemods/__tests__/rename-imperative-ref-to-handleRef.test.mjs +0 -65
  167. package/assets/codemods/__tests__/rename-isStreaming-to-isStopShown.test.mjs +0 -58
  168. package/assets/codemods/__tests__/rename-section-wash-to-muted.test.mjs +0 -103
  169. package/assets/codemods/__tests__/runner.symlinks.test.mjs +0 -205
  170. package/assets/codemods/__tests__/runner.test.mjs +0 -559
  171. package/assets/codemods/__tests__/runner.unparseable.test.mjs +0 -457
  172. package/assets/codemods/__tests__/toolbar-density-to-size.test.mjs +0 -69
  173. package/assets/codemods/__tests__/validation.test.mjs +0 -108
  174. package/assets/codemods/file-count.test.mjs +0 -163
  175. package/assets/codemods/integration-discovery.test.mjs +0 -360
  176. package/assets/codemods/integration-runner.protection.test.mjs +0 -206
  177. package/assets/codemods/outcome.test.mjs +0 -40
  178. package/assets/codemods/term-log.test.mjs +0 -80
  179. package/assets/codemods/transform-prop.test.mjs +0 -130
  180. package/assets/codemods/transforms/v0.0.10/__tests__/remove-size-props.test.mjs +0 -144
  181. package/assets/codemods/transforms/v0.0.12/__tests__/add-is-icon-only.test.mjs +0 -193
  182. package/assets/codemods/transforms/v0.0.13/__tests__/icon-name-deprecations.test.mjs +0 -81
  183. package/assets/codemods/transforms/v0.0.13/__tests__/rename-attachments-to-drawer.test.mjs +0 -126
  184. package/assets/codemods/transforms/v0.0.14/__tests__/rename-action-props.test.mjs +0 -129
  185. package/assets/codemods/transforms/v0.0.14/__tests__/rename-status-variants.test.mjs +0 -126
  186. package/assets/codemods/transforms/v0.0.15/__tests__/migrate-item-children-to-endcontent.test.mjs +0 -95
  187. package/assets/codemods/transforms/v0.0.15/__tests__/migrate-selector-children-to-render-option.test.mjs +0 -109
  188. package/assets/codemods/transforms/v0.0.15/__tests__/migrate-theme-selectors-to-data-attrs.test.mjs +0 -44
  189. package/assets/codemods/transforms/v0.0.15/__tests__/rename-date-picker-to-input.test.mjs +0 -110
  190. package/assets/codemods/transforms/v0.0.15/__tests__/rename-stack-element-to-as.test.mjs +0 -71
  191. package/assets/codemods/transforms/v0.0.2/__tests__/migrate-badge-dot-to-statusdot.test.mjs +0 -137
  192. package/assets/codemods/transforms/v0.0.2/__tests__/migrate-gap-to-numeric.test.mjs +0 -161
  193. package/assets/codemods/transforms/v0.0.2/__tests__/migrate-isFullBleed-to-padding.test.mjs +0 -137
  194. package/assets/codemods/transforms/v0.0.2/__tests__/migrate-useXDSIcon-to-getIcon.test.mjs +0 -110
  195. package/assets/codemods/transforms/v0.0.2/__tests__/rename-banner-endButton-to-endContent.test.mjs +0 -61
  196. package/assets/codemods/transforms/v0.0.2/__tests__/rename-form-tooltip-startIcon.test.mjs +0 -130
  197. package/assets/codemods/transforms/v0.0.2/__tests__/rename-isShown-to-isOpen.test.mjs +0 -89
  198. package/assets/codemods/transforms/v0.0.2/__tests__/rename-selector-items-to-options.test.mjs +0 -74
  199. package/assets/codemods/transforms/v0.0.2/__tests__/rename-sidenav-header-to-heading.test.mjs +0 -140
  200. package/assets/codemods/transforms/v0.0.2/__tests__/rename-topnav-title-to-heading.test.mjs +0 -116
  201. package/assets/codemods/transforms/v0.0.2/__tests__/unify-uncontrolled-to-defaultX.test.mjs +0 -79
  202. package/assets/codemods/transforms/v0.0.2/__tests__/unify-visibility-to-onOpenChange.test.mjs +0 -130
  203. package/assets/codemods/transforms/v0.0.6/__tests__/migrate-badge-children-to-label.test.mjs +0 -46
  204. package/assets/codemods/transforms/v0.0.6/__tests__/migrate-collapse-to-collapsible.test.mjs +0 -72
  205. package/assets/codemods/transforms/v0.0.6/__tests__/migrate-radius-tokens.test.mjs +0 -98
  206. package/assets/codemods/transforms/v0.0.6/__tests__/migrate-shadow-tokens.test.mjs +0 -117
  207. package/assets/codemods/transforms/v0.0.6/__tests__/migrate-skeleton-radius.test.mjs +0 -75
  208. package/assets/codemods/transforms/v0.0.6/__tests__/migrate-token-names.test.mjs +0 -275
  209. package/assets/codemods/transforms/v0.0.7/__tests__/rename-banner-variant-to-container.test.mjs +0 -85
  210. package/assets/codemods/transforms/v0.0.8/__tests__/migrate-token-renames.test.mjs +0 -327
  211. package/assets/codemods/transforms/v0.0.8/__tests__/rename-endslot-to-endcontent.test.mjs +0 -98
  212. package/assets/codemods/transforms/v0.1.0/__tests__/drop-xds-prefix-imports.test.mjs +0 -460
  213. package/assets/codemods/transforms/v0.1.0/__tests__/migrate-xds-css-surfaces.test.mjs +0 -103
  214. package/assets/codemods/transforms/v0.1.0/__tests__/migrate-xds-declare-module.test.mjs +0 -61
  215. package/assets/codemods/transforms/v0.1.0/__tests__/migrate-xds-module-specifiers.test.mjs +0 -123
  216. package/assets/codemods/transforms/v0.1.0/__tests__/v0.1.0-ordering.test.mjs +0 -104
  217. package/assets/codemods/transforms/v0.1.2/__tests__/rename-text-color-active-to-accent.test.mjs +0 -120
  218. package/assets/codemods/transforms/v0.1.3/__tests__/migrate-layout-components-to-experimental.test.mjs +0 -574
  219. package/assets/codemods/transforms/v0.1.5/__tests__/rename-switch-label-spacing-default-to-hug.test.mjs +0 -93
  220. package/assets/codemods/transforms/v0.1.7/__tests__/migrate-table-tableprops-to-direct-props.test.mjs +0 -120
  221. package/assets/codemods/transforms/v0.1.7/__tests__/rename-table-renderprops-styles-to-xstyle.test.mjs +0 -112
  222. package/assets/codemods/transforms/v0.1.8/__tests__/rename-avatar-size-scale.test.mjs +0 -129
  223. package/assets/codemods/transforms/v0.2.0/__tests__/remove-tablist-orientation.test.mjs +0 -81
  224. package/assets/codemods/transforms/v0.2.1/__tests__/migrate-dialog-position-to-logical.test.mjs +0 -119
  225. package/assets/codemods/transforms/v0.3.0/__tests__/authoring-migration.e2e.test.mjs +0 -296
  226. package/assets/codemods/transforms/v0.3.0/__tests__/authoring-migration.tsc.test.mjs +0 -139
  227. package/assets/codemods/transforms/v0.3.0/__tests__/migrate-authoring-imports.test.mjs +0 -80
  228. package/assets/codemods/transforms/v0.3.0/__tests__/migrate-grid-minchildwidth-to-columns.test.mjs +0 -82
  229. package/assets/codemods/transforms/v0.3.0/__tests__/next-codemods.test.mjs +0 -64
  230. package/assets/codemods/transforms/v0.3.0/__tests__/rename-authoring-doctypes.test.mjs +0 -94
  231. package/assets/codemods/transforms/v0.3.0/__tests__/rename-radiogroup-arialabel-to-label.test.mjs +0 -86
  232. package/assets/codemods/transforms/v0.3.0/__tests__/unwrap-authoring-factories.test.mjs +0 -170
  233. package/assets/codemods/transforms/v0.4.0/__tests__/migrate-table-rowexpansion-to-tree.test.mjs +0 -201
  234. package/assets/codemods/transforms/v0.4.0/__tests__/next-codemods.test.mjs +0 -154
  235. package/assets/codemods/transforms/v0.5.0/__tests__/next-codemods.test.mjs +0 -127
  236. package/assets/codemods/transforms/v0.6.0/__tests__/migrate-astryx-theme-selectors-to-data-attrs.test.mjs +0 -398
  237. package/assets/codemods/transforms/v0.6.0/__tests__/next-codemods.test.mjs +0 -270
  238. package/assets/codemods/transforms/v0.6.4/__tests__/migrate-native-picker-to-presentation.test.mjs +0 -63
  239. package/assets/codemods/transforms/v0.6.4/__tests__/migrate-theme-catalog-to-descriptors.test.mjs +0 -220
  240. package/assets/codemods/transforms/v0.6.7/__tests__/migrate-copied-themes-to-descriptors.test.mjs +0 -129
  241. package/assets/codemods/transforms/v0.7.0/__tests__/migrate-deprecated-theme-surface.test.mjs +0 -523
  242. package/assets/codemods/transforms/v0.7.0/__tests__/migrate-field-input-styling.test.mjs +0 -108
  243. package/assets/codemods/transforms/v0.7.0/__tests__/preserve-bottom-sheet-content-padding.test.mjs +0 -178
  244. package/assets/codemods/transforms/v0.7.0/__tests__/rename-empty-search-results-text.test.mjs +0 -202
  245. package/assets/codemods/transforms/v0.7.0/__tests__/validate-data-token-ownership.test.mjs +0 -168
  246. package/assets/codemods/transforms/v0.7.2/__tests__/migrate-list-edge-compensation-to-edge.test.mjs +0 -120
  247. package/assets/codemods/transforms/v0.7.5/__tests__/migrate-codeblock-tokenizer-to-language.test.mjs +0 -130
  248. package/authoring/_shared/errors.test.mjs +0 -49
  249. package/authoring/codemod/parse.test.mjs +0 -99
  250. package/authoring/config/debug-composition.test.mjs +0 -92
  251. package/authoring/config/parse.test.mjs +0 -121
  252. package/authoring/debug/parse.test.mjs +0 -187
  253. package/authoring/discover/parse.test.mjs +0 -158
  254. package/authoring/doctypes/doc-stability-types.test.mjs +0 -91
  255. package/authoring/doctypes/doctypes-new.test.mjs +0 -162
  256. package/authoring/doctypes/icon-definition/parse.test.mjs +0 -78
  257. package/authoring/doctypes/icon-set/icon-names.test.mjs +0 -26
  258. package/authoring/doctypes/icon-set/parse.test.mjs +0 -179
  259. package/authoring/doctypes/load-contract.test.mjs +0 -246
  260. package/authoring/doctypes/namespace/parse.test.mjs +0 -163
  261. package/authoring/doctypes/parse.test.mjs +0 -422
  262. package/authoring/doctypes/template/parse.test.mjs +0 -198
  263. package/authoring/gap-report/parse.test.mjs +0 -172
  264. package/authoring/integration/parse.test.mjs +0 -184
  265. package/authoring/shadcn/receipt.test.mjs +0 -187
  266. package/authoring/shadcn/source-variants.test.mjs +0 -120
  267. package/clients/cli/__tests__/cliManifest.test.ts +0 -37
  268. package/clients/cli/cli-command.test.mjs +0 -166
  269. package/clients/cli/cli-exit-codes.test.mjs +0 -163
  270. package/clients/cli/command-load-failure.test.mjs +0 -83
  271. package/clients/cli/command-result-coverage.test.mjs +0 -136
  272. package/clients/cli/commands/blog.test.mjs +0 -138
  273. package/clients/cli/commands/build-theme.adaptations.test.mjs +0 -773
  274. package/clients/cli/commands/build-theme.ascii-output.test.mjs +0 -198
  275. package/clients/cli/commands/build-theme.batch-report.test.mjs +0 -349
  276. package/clients/cli/commands/build-theme.color-scheme.test.mjs +0 -136
  277. package/clients/cli/commands/build-theme.data-tokens.test.mjs +0 -92
  278. package/clients/cli/commands/build-theme.flag-docs.test.mjs +0 -110
  279. package/clients/cli/commands/build-theme.font-warning.test.mjs +0 -170
  280. package/clients/cli/commands/build-theme.icons-specifier.test.mjs +0 -350
  281. package/clients/cli/commands/build-theme.import-path.test.mjs +0 -103
  282. package/clients/cli/commands/build-theme.multi.test.mjs +0 -148
  283. package/clients/cli/commands/build-theme.outside-project.test.mjs +0 -140
  284. package/clients/cli/commands/build-theme.path-safety.test.mjs +0 -398
  285. package/clients/cli/commands/build-theme.prose.test.mjs +0 -103
  286. package/clients/cli/commands/build-theme.registry.test.mjs +0 -160
  287. package/clients/cli/commands/build-theme.variants.test.mjs +0 -560
  288. package/clients/cli/commands/build-theme.watch.test.mjs +0 -320
  289. package/clients/cli/commands/build.error-codes.test.mjs +0 -50
  290. package/clients/cli/commands/build.exit-codes-doc.test.mjs +0 -54
  291. package/clients/cli/commands/build.playbook.test.mjs +0 -75
  292. package/clients/cli/commands/build.text-fields.test.mjs +0 -81
  293. package/clients/cli/commands/cli-postinstall.test.mjs +0 -90
  294. package/clients/cli/commands/component-batch.test.mjs +0 -341
  295. package/clients/cli/commands/component-ownership.test.mjs +0 -384
  296. package/clients/cli/commands/component-package.test.mjs +0 -169
  297. package/clients/cli/commands/component-replacement.text.test.mjs +0 -316
  298. package/clients/cli/commands/component-resolution.test.mjs +0 -204
  299. package/clients/cli/commands/component.test.mjs +0 -612
  300. package/clients/cli/commands/debug-result-summary.test.mjs +0 -214
  301. package/clients/cli/commands/detail-levels.test.mjs +0 -145
  302. package/clients/cli/commands/dialog-adaptive-template.test.mjs +0 -24
  303. package/clients/cli/commands/discover.broken-integration.test.mjs +0 -163
  304. package/clients/cli/commands/discover.components-flag.test.mjs +0 -97
  305. package/clients/cli/commands/discover.icon-sets.test.mjs +0 -133
  306. package/clients/cli/commands/discover.no-source.test.mjs +0 -490
  307. package/clients/cli/commands/discover.sources.test.mjs +0 -292
  308. package/clients/cli/commands/discover.text-projection.test.mjs +0 -103
  309. package/clients/cli/commands/docs.depth.test.mjs +0 -219
  310. package/clients/cli/commands/docs.test.mjs +0 -385
  311. package/clients/cli/commands/doctor-integration.package-json.test.mjs +0 -53
  312. package/clients/cli/commands/doctor-integration.test.mjs +0 -1483
  313. package/clients/cli/commands/doctor.test.mjs +0 -509
  314. package/clients/cli/commands/empty-argument.test.mjs +0 -16
  315. package/clients/cli/commands/external-showcase.test.mjs +0 -121
  316. package/clients/cli/commands/gap-report.test.mjs +0 -412
  317. package/clients/cli/commands/hook.text-projection.test.mjs +0 -45
  318. package/clients/cli/commands/icon-authoring.test.mjs +0 -2845
  319. package/clients/cli/commands/icon-options-wiring.test.mjs +0 -158
  320. package/clients/cli/commands/icon-sets-guide.test.mjs +0 -186
  321. package/clients/cli/commands/icon.test.mjs +0 -96
  322. package/clients/cli/commands/import-hint-correctness.test.mjs +0 -293
  323. package/clients/cli/commands/init.behavior.test.mjs +0 -434
  324. package/clients/cli/commands/init.flag-help.test.mjs +0 -151
  325. package/clients/cli/commands/init.next-steps.test.mjs +0 -41
  326. package/clients/cli/commands/integration-add.controls.test.mjs +0 -132
  327. package/clients/cli/commands/integration-authoring.test.mjs +0 -288
  328. package/clients/cli/commands/integration-check.test.mjs +0 -522
  329. package/clients/cli/commands/integration-real-world.test.mjs +0 -661
  330. package/clients/cli/commands/interactive-guard.test.mjs +0 -143
  331. package/clients/cli/commands/json-contract.test.mjs +0 -216
  332. package/clients/cli/commands/no-prompt-wording.test.mjs +0 -94
  333. package/clients/cli/commands/option-pair-refusals.test.mjs +0 -37
  334. package/clients/cli/commands/outside-project.test.mjs +0 -874
  335. package/clients/cli/commands/search.test.mjs +0 -514
  336. package/clients/cli/commands/setup-nudge.test.mjs +0 -280
  337. package/clients/cli/commands/silent-success-refusals.test.mjs +0 -15
  338. package/clients/cli/commands/swizzle.path-safety.test.mjs +0 -137
  339. package/clients/cli/commands/swizzle.routing.test.mjs +0 -342
  340. package/clients/cli/commands/template-cdn.behavior.test.mjs +0 -113
  341. package/clients/cli/commands/template.copy-receipt.test.mjs +0 -60
  342. package/clients/cli/commands/template.flag-help.test.mjs +0 -124
  343. package/clients/cli/commands/template.icons.test.mjs +0 -132
  344. package/clients/cli/commands/template.path-help.test.mjs +0 -40
  345. package/clients/cli/commands/template.path-safety.test.mjs +0 -82
  346. package/clients/cli/commands/template.show-media.test.mjs +0 -62
  347. package/clients/cli/commands/template.test.mjs +0 -62
  348. package/clients/cli/commands/text-json-parity.test.mjs +0 -850
  349. package/clients/cli/commands/theme-add-lifecycle.test.mjs +0 -228
  350. package/clients/cli/commands/theme-list.behavior.test.mjs +0 -51
  351. package/clients/cli/commands/theme-palette-generate.test.mjs +0 -154
  352. package/clients/cli/commands/theme-targets.behavior.test.mjs +0 -84
  353. package/clients/cli/commands/theme-template.behavior.test.mjs +0 -97
  354. package/clients/cli/commands/upgrade.ascii-output.test.mjs +0 -101
  355. package/clients/cli/commands/upgrade.config-ordering.test.mjs +0 -342
  356. package/clients/cli/commands/upgrade.file-protection.test.mjs +0 -404
  357. package/clients/cli/commands/upgrade.flag-help.test.mjs +0 -221
  358. package/clients/cli/commands/upgrade.hook-output.test.mjs +0 -89
  359. package/clients/cli/commands/upgrade.integration-policy.test.mjs +0 -581
  360. package/clients/cli/commands/upgrade.older-cli.test.mjs +0 -160
  361. package/clients/cli/commands/upgrade.outcomes.test.mjs +0 -350
  362. package/clients/cli/commands/upgrade.subfolder-path.test.mjs +0 -97
  363. package/clients/cli/commands/upgrade.test.mjs +0 -361
  364. package/clients/cli/commands/validate-nothing-exits-nonzero.test.mjs +0 -67
  365. package/clients/cli/commands/write-failure.test.mjs +0 -175
  366. package/clients/cli/e2e-smoke.test.mjs +0 -162
  367. package/clients/cli/error-envelope-code.test.mjs +0 -38
  368. package/clients/cli/formatters/index.test.mjs +0 -262
  369. package/clients/cli/latest-version-env.test.mjs +0 -50
  370. package/clients/cli/lib/cli-error.test.mjs +0 -206
  371. package/clients/cli/lib/component-format.test.mjs +0 -246
  372. package/clients/cli/lib/define-command.test.mjs +0 -103
  373. package/clients/cli/lib/doc-text-ascii.test.mjs +0 -85
  374. package/clients/cli/lib/exit-codes.test.mjs +0 -111
  375. package/clients/cli/lib/hook-format.test.mjs +0 -35
  376. package/clients/cli/lib/json-shim.test.mjs +0 -268
  377. package/clients/cli/lib/manifest.test.mjs +0 -346
  378. package/clients/cli/lib/parse-error-format.test.mjs +0 -81
  379. package/clients/cli/lib/resolve-theme.test.mjs +0 -543
  380. package/foundation/agent-docs/agent-docs.path-safety.test.mjs +0 -1550
  381. package/foundation/agent-docs/agent-docs.test.mjs +0 -1937
  382. package/foundation/agent-docs/app-theme-workflow.test.mjs +0 -16
  383. package/foundation/agent-docs/computer-agent-text.test.mjs +0 -699
  384. package/foundation/config/config-cache.test.mjs +0 -83
  385. package/foundation/config/config-writer.test.mjs +0 -84
  386. package/foundation/config/integration-debug.test.mjs +0 -218
  387. package/foundation/config/project-themes.test.mjs +0 -119
  388. package/foundation/config/project.test.mjs +0 -931
  389. package/foundation/config/theme-private-vars.test.mjs +0 -76
  390. package/foundation/config/theme-state.test.mjs +0 -182
  391. package/foundation/debug/debug-fields.test.mjs +0 -327
  392. package/foundation/debug/integration-handlers.test.mjs +0 -267
  393. package/foundation/debug/on-event.test.mjs +0 -643
  394. package/foundation/debug/privacy-contract.test.mjs +0 -195
  395. package/foundation/debug/redact.test.mjs +0 -534
  396. package/foundation/discovery/authoring-self-docs.test.mjs +0 -202
  397. package/foundation/discovery/authoring-surface.test.mjs +0 -392
  398. package/foundation/discovery/cli-self-docs.test.mjs +0 -396
  399. package/foundation/discovery/component-discovery.export-names.test.mjs +0 -832
  400. package/foundation/discovery/component-discovery.importpath.test.mjs +0 -59
  401. package/foundation/discovery/component-discovery.test.mjs +0 -336
  402. package/foundation/discovery/component-loader.test.mjs +0 -190
  403. package/foundation/discovery/component-replacement.test.mjs +0 -520
  404. package/foundation/discovery/componentDocOverlay.test.mjs +0 -159
  405. package/foundation/discovery/copied-passages.test.mjs +0 -124
  406. package/foundation/discovery/doc-consistency.test.mjs +0 -347
  407. package/foundation/discovery/doc-fluff.test.mjs +0 -142
  408. package/foundation/discovery/doc-types.test.mjs +0 -774
  409. package/foundation/discovery/docs-discovery.test.mjs +0 -707
  410. package/foundation/discovery/docs-section-key.test.mjs +0 -246
  411. package/foundation/discovery/hook-discovery.test.mjs +0 -216
  412. package/foundation/discovery/icon-set-checks.test.mjs +0 -1018
  413. package/foundation/discovery/icon-set-discovery.test.mjs +0 -320
  414. package/foundation/discovery/icon-set-writer.test.mjs +0 -26
  415. package/foundation/discovery/integration-doc-files.test.mjs +0 -275
  416. package/foundation/discovery/module-exports.test.mjs +0 -209
  417. package/foundation/discovery/package-tsconfig.test.mjs +0 -210
  418. package/foundation/discovery/prop-drift.test.mjs +0 -2337
  419. package/foundation/discovery/runner-commands.test.mjs +0 -131
  420. package/foundation/discovery/stray-pointers.test.mjs +0 -92
  421. package/foundation/discovery/template-adapter.fixture-refs.test.mjs +0 -284
  422. package/foundation/discovery/template-adapter.integration-isolation.test.mjs +0 -94
  423. package/foundation/discovery/template-adapter.test.mjs +0 -223
  424. package/foundation/discovery/template-conflict-release.test.mjs +0 -40
  425. package/foundation/discovery/template-icons.test.mjs +0 -560
  426. package/foundation/discovery/template-needs.test.mjs +0 -306
  427. package/foundation/discovery/theme-discovery.test.mjs +0 -775
  428. package/foundation/discovery/theme-imports.test.mjs +0 -173
  429. package/foundation/discovery/theming-targets.test.mjs +0 -328
  430. package/foundation/discovery/type-match.test.mjs +0 -169
  431. package/foundation/discovery/type-text.test.mjs +0 -196
  432. package/foundation/discovery/unresolved-references.test.mjs +0 -567
  433. package/foundation/doc-compiler/bundle.test.mjs +0 -266
  434. package/foundation/doc-compiler/doc-compiler.test.mjs +0 -714
  435. package/foundation/doc-compiler/doc-loads.test.mjs +0 -1762
  436. package/foundation/doc-compiler/doc-syntax.test.mjs +0 -383
  437. package/foundation/doc-compiler/inputs.test.mjs +0 -298
  438. package/foundation/doc-compiler/links.test.mjs +0 -285
  439. package/foundation/doc-compiler/lower-doc.test.mjs +0 -495
  440. package/foundation/doc-compiler/read.test.mjs +0 -380
  441. package/foundation/doc-compiler/split-topic-keywords.test.mjs +0 -74
  442. package/foundation/doc-compiler/tree.test.mjs +0 -691
  443. package/foundation/env/cli-command.test.mjs +0 -129
  444. package/foundation/env/node-version.test.mjs +0 -103
  445. package/foundation/env/package-manager.global.test.mjs +0 -66
  446. package/foundation/env/package-manager.test.mjs +0 -910
  447. package/foundation/env/search-path.test.mjs +0 -122
  448. package/foundation/env/semver.test.mjs +0 -111
  449. package/foundation/env/user-dirs.test.mjs +0 -72
  450. package/foundation/env/user-settings.test.mjs +0 -64
  451. package/foundation/fs/file-protection.test.mjs +0 -250
  452. package/foundation/fs/listing-cache.test.mjs +0 -88
  453. package/foundation/fs/module-loader.stdout.test.mjs +0 -333
  454. package/foundation/fs/module-loader.test.mjs +0 -410
  455. package/foundation/fs/path-safety.test.mjs +0 -222
  456. package/foundation/fs/paths.test.mjs +0 -725
  457. package/foundation/fs/publish-file-eperm-mutation.test.mjs +0 -64
  458. package/foundation/fs/publish-file-hardlink-unavailable.test.mjs +0 -142
  459. package/foundation/fs/publish-file.test.mjs +0 -136
  460. package/foundation/fs/read-record.test.mjs +0 -164
  461. package/foundation/identity/provider-identity.test.mjs +0 -254
  462. package/foundation/integrations/autolink.test.mjs +0 -430
  463. package/foundation/integrations/cli-peer-version.test.mjs +0 -354
  464. package/foundation/integrations/cli-requirement.test.mjs +0 -383
  465. package/foundation/integrations/computer-integrations.test.mjs +0 -292
  466. package/foundation/integrations/contribution-inventory.test.mjs +0 -420
  467. package/foundation/integrations/integration-warnings.test.mjs +0 -191
  468. package/foundation/integrations/integrations.test.mjs +0 -818
  469. package/foundation/integrations/manifest-writer.test.mjs +0 -271
  470. package/foundation/integrations/provider-conflicts.test.mjs +0 -125
  471. package/foundation/integrations/provider-ledger.test.mjs +0 -275
  472. package/foundation/integrations/provider-resolution.test.mjs +0 -369
  473. package/foundation/integrations/public-imports.test.mjs +0 -1818
  474. package/foundation/release/cache.test.mjs +0 -923
  475. package/foundation/release/choose.test.mjs +0 -427
  476. package/foundation/release/global-state.test.mjs +0 -381
  477. package/foundation/release/handoff.e2e.test.mjs +0 -278
  478. package/foundation/release/notices.test.mjs +0 -586
  479. package/foundation/release/project.test.mjs +0 -288
  480. package/foundation/render/render.test.mjs +0 -117
  481. package/foundation/response/error-codes.test.mjs +0 -297
  482. package/foundation/response/json-contract.test.mjs +0 -235
  483. package/foundation/response/json-serialize.test.mjs +0 -66
  484. package/foundation/response/response-types.doc.test.mjs +0 -278
  485. package/foundation/route/route.test.mjs +0 -153
  486. package/foundation/runtime/hosted-runtime.test.mjs +0 -403
  487. package/foundation/runtime/package-set.test.mjs +0 -432
  488. package/foundation/text/copyright-header.test.mjs +0 -58
  489. package/foundation/text/levenshtein.test.mjs +0 -53
  490. package/foundation/text/string-utils.test.mjs +0 -175
  491. package/foundation/text/suggest-order.test.mjs +0 -312
  492. package/foundation/xle/browser-imports.test.mjs +0 -74
  493. package/foundation/xle/expand.test.mjs +0 -54
  494. package/foundation/xle/print.test.mjs +0 -50
  495. package/foundation/xle/registry.test.mjs +0 -28
  496. package/foundation/xle/xle.test.mjs +0 -382
  497. package/host/door-conformance.test.mjs +0 -274
  498. package/host/index.test.mjs +0 -302
@@ -1,2007 +0,0 @@
1
- // Copyright (c) Meta Platforms, Inc. and affiliates.
2
-
3
- /**
4
- * @file Package mistakes `astryx doctor integration validate` and
5
- * `astryx integration check` used to pass, crash on, or describe badly: names
6
- * that differ from file names, ids readers cannot take, duplicate and
7
- * case-mismatched docs, symlinked or absolute roots, a root that is a file, a
8
- * package.json missing what npm needs, manifest key typos, docs and manifests
9
- * with no default export, and theme descriptors named for built output. Each
10
- * finding carries a `Fix:` that holds when followed.
11
- *
12
- * Temp dirs live under the repo root, as in validate-integration.test.mjs.
13
- */
14
-
15
- import {afterEach, beforeEach, describe, expect, it} from 'vitest';
16
- import * as fs from 'node:fs';
17
- import * as os from 'node:os';
18
- import * as path from 'node:path';
19
- import {parse} from '@babel/parser';
20
- import {spawnSync} from 'node:child_process';
21
- import {
22
- validateIntegration,
23
- validateLocalIntegration,
24
- } from './validate-integration.mjs';
25
- import {
26
- integrationCheck,
27
- strictIssues,
28
- summarizeCheck,
29
- } from './check/check.mjs';
30
- import {componentDocNamesCheck} from '../../foundation/integrations/validate-contributions.mjs';
31
- import {formatCliCommand} from '../../foundation/env/package-manager.mjs';
32
-
33
- let tmpDir;
34
- let copies = 0;
35
-
36
- const CLI = path.join(
37
- process.cwd(),
38
- 'packages',
39
- 'cli',
40
- 'clients',
41
- 'cli',
42
- 'bin',
43
- 'astryx.mjs',
44
- );
45
-
46
- beforeEach(() => {
47
- tmpDir = fs.mkdtempSync(path.join(process.cwd(), '.astryx-validate-gaps-'));
48
- // The fixture is a package with its own TypeScript config, scoped to its
49
- // own files. Without one, the prop check reads the repository's root
50
- // config, as `tsc` would for a folder inside it, and compiles every
51
- // declaration in the repository for each check.
52
- fs.writeFileSync(
53
- path.join(tmpDir, 'tsconfig.json'),
54
- `${JSON.stringify({extends: '../tsconfig.json', include: ['**/*']})}\n`,
55
- );
56
- });
57
-
58
- afterEach(() => {
59
- fs.rmSync(tmpDir, {recursive: true, force: true});
60
- });
61
-
62
- const MANIFEST = 'astryx.integration.mjs';
63
- const THEME_TYPE =
64
- "/** @type {import('@astryxdesign/cli/authoring').ThemeDoc} */\n";
65
-
66
- /** @param {Record<string, unknown>} roots */
67
- const manifest = roots => `export default ${JSON.stringify(roots)};\n`;
68
- /** @param {string} name */
69
- const componentDoc = name =>
70
- `export default {type: 'component', name: '${name}', displayName: '${name}', usage: {description: '${name}.'}, props: []};\n`;
71
- /** @param {string} name */
72
- const componentSource = name => `export function ${name}() { return null; }\n`;
73
- /** @param {string} name */
74
- const topic = name =>
75
- `export default ${JSON.stringify({
76
- type: 'generic',
77
- name,
78
- title: name,
79
- description: `The ${name} topic.`,
80
- sections: [{title: 'Overview', content: [{type: 'prose', text: name}]}],
81
- })};\n`;
82
- /** @param {string} name */
83
- const templateDoc = name =>
84
- `export default {type: 'block', name: '${name}', displayName: '${name}', aspectRatio: 1};\n`;
85
- const templateSource = 'export default function Block() { return null; }\n';
86
-
87
- /**
88
- * @param {Record<string, string>} files package-relative path -> contents
89
- * @param {Record<string, unknown>} [pkg] package.json
90
- * @returns {string} the package directory
91
- */
92
- function writePackage(files, pkg = {name: '@acme/kit', version: '1.0.0'}) {
93
- const dir = path.join(tmpDir, 'pkg');
94
- fs.mkdirSync(dir, {recursive: true});
95
- fs.writeFileSync(path.join(dir, 'package.json'), JSON.stringify(pkg));
96
- for (const [file, contents] of Object.entries(files)) {
97
- fs.mkdirSync(path.dirname(path.join(dir, file)), {recursive: true});
98
- fs.writeFileSync(path.join(dir, file), contents);
99
- }
100
- return dir;
101
- }
102
-
103
- /**
104
- * Carry out a fix on a fresh copy of the package.
105
- * @param {string} dir
106
- * @param {{move?: Array<[string, string]>, write?: Record<string, string>, remove?: string[]}} steps
107
- */
108
- function follow(dir, {move = [], write = {}, remove = []}) {
109
- copies += 1;
110
- const copy = path.join(tmpDir, `followed-${copies}`);
111
- fs.cpSync(dir, copy, {recursive: true, verbatimSymlinks: true});
112
- for (const file of remove) {
113
- fs.rmSync(path.join(copy, file), {recursive: true, force: true});
114
- }
115
- for (const [from, to] of move) {
116
- fs.mkdirSync(path.dirname(path.join(copy, to)), {recursive: true});
117
- fs.renameSync(path.join(copy, from), path.join(copy, to));
118
- }
119
- for (const [file, contents] of Object.entries(write)) {
120
- fs.mkdirSync(path.dirname(path.join(copy, file)), {recursive: true});
121
- fs.writeFileSync(path.join(copy, file), contents);
122
- }
123
- return copy;
124
- }
125
-
126
- /** @param {string} dir */
127
- async function issuesOf(dir) {
128
- return (await validateLocalIntegration(dir)).issues;
129
- }
130
-
131
- /**
132
- * The notes validate lists beside its issues, which count nowhere: the layout
133
- * findings added after the last minor release, each with its fix.
134
- * @param {string} dir
135
- * @returns {Promise<Array<{code: string, message: string}>>}
136
- */
137
- async function listedOf(dir) {
138
- return (
139
- (await validateIntegration(undefined, {cwd: dir})).data.notes ?? []
140
- ).filter(note => !EXAMPLE_CODES.has(note.code));
141
- }
142
-
143
- /**
144
- * The example notes, which nearly every fixture here draws (a component with
145
- * no example template); authoring-checks.test.mjs covers them.
146
- */
147
- const EXAMPLE_CODES = new Set([
148
- 'component_without_example',
149
- 'template_category',
150
- 'showcase_not_standalone',
151
- 'template_asset_not_packed',
152
- ]);
153
-
154
- /**
155
- * Notes without the example notes.
156
- * @param {Array<{code: string, message: string, next?: boolean}> | undefined} notes
157
- */
158
- function others(notes) {
159
- return (notes ?? []).filter(note => !EXAMPLE_CODES.has(note.code));
160
- }
161
-
162
- /**
163
- * Issues and notes together: what a followed fix must clear.
164
- * @param {string} dir
165
- */
166
- async function allOf(dir) {
167
- return [...(await issuesOf(dir)), ...(await listedOf(dir))];
168
- }
169
-
170
- /**
171
- * The one issue with this code, which the test is about.
172
- * @param {Array<{code: string, message: string}>} issues
173
- * @param {string} code
174
- */
175
- function only(issues, code) {
176
- const found = issues.filter(issue => issue.code === code);
177
- expect(found).toHaveLength(1);
178
- return found[0].message;
179
- }
180
-
181
- /**
182
- * A component doc whose import names its published subpath.
183
- * @param {string} stem the doc's file name
184
- * @param {string} name
185
- */
186
- const namedDoc = (stem, name) =>
187
- componentDoc(name).replace(
188
- "type: 'component',",
189
- `type: 'component', import: '@acme/kit/components/${stem}',`,
190
- );
191
- /**
192
- * A package that publishes each file under its components folder.
193
- * @param {Record<string, string>} files
194
- */
195
- const writeNamed = files =>
196
- writePackage(files, {
197
- name: '@acme/kit',
198
- version: '1.0.0',
199
- exports: {
200
- './components/*': './components/*.tsx',
201
- './templates/*': './templates/*.tsx',
202
- '.': './index.ts',
203
- },
204
- });
205
-
206
- describe('a name that differs from its file name', () => {
207
- it('lists a component doc whose name is not the name it is listed under, without an issue', async () => {
208
- const dir = writeNamed({
209
- [MANIFEST]: manifest({components: './components'}),
210
- 'components/AcmeWidget.doc.mjs': namedDoc('AcmeWidget', 'AcmeWidgets'),
211
- 'components/AcmeWidget.tsx': componentSource('AcmeWidget'),
212
- });
213
-
214
- expect(await issuesOf(dir)).toEqual([]);
215
- const issues = await allOf(dir);
216
- expect(issues.map(issue => issue.code)).toEqual(['doc_name_mismatch']);
217
- expect(Object.keys(issues[0]).sort()).toEqual(['code', 'message', 'next']);
218
- expect(issues[0].message).toBe(
219
- 'Component doc "AcmeWidget.doc.mjs" sets name: \'AcmeWidgets\', but components/AcmeWidget.tsx, the module its import names, does not export AcmeWidgets, so Astryx lists the component as "AcmeWidget" (its file name), and `astryx component AcmeWidget` prints `import {AcmeWidgets}`. Fix: set name: \'AcmeWidget\' in AcmeWidget.doc.mjs.',
220
- );
221
-
222
- const fixed = follow(dir, {
223
- write: {
224
- 'components/AcmeWidget.doc.mjs': namedDoc('AcmeWidget', 'AcmeWidget'),
225
- },
226
- });
227
- expect(await allOf(fixed)).toEqual([]);
228
- });
229
-
230
- it.each([
231
- [
232
- 'a re-export from another package',
233
- "export {AcmeWidgets} from '@acme/ui';\n",
234
- 'AcmeWidget.tsx re-exports AcmeWidgets from "@acme/ui", another package this check does not read.',
235
- ],
236
- [
237
- 'a .js specifier this read cannot follow',
238
- "export {AcmeWidgets} from './impl/widgets.js';\n",
239
- 'AcmeWidget.tsx re-exports AcmeWidgets from "./impl/widgets.js", which resolves to no file this check can read.',
240
- ],
241
- [
242
- 'an export * from another package',
243
- "export * from '@acme/ui';\n",
244
- 'AcmeWidget.tsx re-exports everything from "@acme/ui", another package this check does not read.',
245
- ],
246
- [
247
- 'a destructured export',
248
- 'const parts = {AcmeWidgets: () => null};\nexport const {AcmeWidgets} = parts;\n',
249
- 'AcmeWidget.tsx exports a destructured binding, whose names this check does not read.',
250
- ],
251
- [
252
- 'a TypeScript namespace export',
253
- 'export namespace AcmeWidgets {\n export const Root = () => null;\n}\n',
254
- 'AcmeWidget.tsx exports AcmeWidgets as a TypeScript namespace, which has a runtime value only when it holds one.',
255
- ],
256
- [
257
- 'an export assignment',
258
- 'const AcmeWidgets = () => null;\nexport = {AcmeWidgets};\n',
259
- 'AcmeWidget.tsx uses `export =`, whose names this check does not read.',
260
- ],
261
- ])(
262
- 'lists a doc name the code cannot judge as not checked, with no finding: %s',
263
- async (_label, source, reason) => {
264
- const dir = writeNamed({
265
- [MANIFEST]: manifest({components: './components'}),
266
- 'components/AcmeWidget.doc.mjs': namedDoc('AcmeWidget', 'AcmeWidgets'),
267
- 'components/AcmeWidget.tsx': source,
268
- });
269
-
270
- const {data} = await validateIntegration(undefined, {cwd: dir});
271
- expect(others(data.notes)).toEqual([]);
272
- expect(data.docNames).toEqual({
273
- status: 'checked',
274
- findings: [],
275
- unchecked: [
276
- {file: 'components/AcmeWidget.doc.mjs', name: 'AcmeWidgets', reason},
277
- ],
278
- });
279
- // Counted as not compared, never as a failure, even under --strict.
280
- const checked = await integrationCheck({cwd: dir, strict: true});
281
- const propsNotCompared = checked.data.checks
282
- .map(check => check.response.data.propDrift?.unchecked?.length ?? 0)
283
- .reduce((a, b) => a + b, 0);
284
- expect(checked.data.unchecked).toBe(1 + propsNotCompared);
285
- expect(
286
- checked.data.failures.filter(
287
- failure => failure.code === 'doc_names_skipped',
288
- ),
289
- ).toEqual([]);
290
- },
291
- );
292
-
293
- it.each([
294
- [
295
- 'a source that exports both names',
296
- 'export function AcmeWidget() { return null; }\nexport const AcmeWidgets = AcmeWidget;\n',
297
- ],
298
- [
299
- 'an export import alias, a runtime value',
300
- 'namespace Impl {\n export const Widgets = () => null;\n}\nexport function AcmeWidget() { return null; }\nexport import AcmeWidgets = Impl.Widgets;\n',
301
- ],
302
- [
303
- 'an enum, a runtime value',
304
- 'export function AcmeWidget() { return null; }\nexport enum AcmeWidgets {\n Small,\n}\n',
305
- ],
306
- ])(
307
- 'checks a doc name the source exports, with nothing listed: %s',
308
- async (_label, source) => {
309
- const dir = writeNamed({
310
- [MANIFEST]: manifest({components: './components'}),
311
- 'components/AcmeWidget.doc.mjs': namedDoc('AcmeWidget', 'AcmeWidgets'),
312
- 'components/AcmeWidget.tsx': source,
313
- });
314
-
315
- const {data} = await validateIntegration(undefined, {cwd: dir});
316
- expect(data.issues).toEqual([]);
317
- expect(data.docNames).toEqual({
318
- status: 'checked',
319
- findings: [],
320
- unchecked: [],
321
- });
322
- },
323
- );
324
-
325
- it('prints the doc names it could not check', () => {
326
- const dir = writeNamed({
327
- [MANIFEST]: manifest({components: './components'}),
328
- 'components/AcmeWidget.doc.mjs': namedDoc('AcmeWidget', 'AcmeWidgets'),
329
- 'components/AcmeWidget.tsx': "export {AcmeWidgets} from '@acme/ui';\n",
330
- });
331
-
332
- const run = spawnSync(
333
- process.execPath,
334
- [CLI, 'doctor', 'integration', 'validate'],
335
- {cwd: dir, encoding: 'utf-8', timeout: 60_000},
336
- );
337
- expect(run.status, run.stderr).toBe(0);
338
- expect(run.stdout).toContain(
339
- '[info] Component names not checked: 1 doc(s) whose source exports this check cannot read:',
340
- );
341
- expect(run.stdout).toContain('components/AcmeWidget.doc.mjs');
342
- expect(run.stdout).toContain(
343
- 'AcmeWidget.tsx re-exports AcmeWidgets from "@acme/ui", another package this check does not read.',
344
- );
345
- });
346
-
347
- it('does not count a member a namespace exports as an export of the module', async () => {
348
- const dir = writeNamed({
349
- [MANIFEST]: manifest({components: './components'}),
350
- 'components/AcmeWidget.doc.mjs': namedDoc('AcmeWidget', 'AcmeWidgets'),
351
- 'components/AcmeWidget.tsx':
352
- 'namespace Impl {\n export const AcmeWidgets = () => null;\n}\nexport function AcmeWidget() { return null; }\n',
353
- });
354
-
355
- expect(only(await allOf(dir), 'doc_name_mismatch')).toContain(
356
- 'components/AcmeWidget.tsx, the module its import names, does not export AcmeWidgets',
357
- );
358
- });
359
-
360
- it('follows a local re-export that does not export the documented name', async () => {
361
- const dir = writeNamed({
362
- [MANIFEST]: manifest({components: './components'}),
363
- 'components/AcmeWidget.doc.mjs': namedDoc('AcmeWidget', 'AcmeWidgets'),
364
- 'components/AcmeWidget.tsx': "export * from './impl';\n",
365
- 'components/impl.tsx': componentSource('AcmeWidget'),
366
- });
367
-
368
- expect(only(await allOf(dir), 'doc_name_mismatch')).toContain(
369
- "sets name: 'AcmeWidgets'",
370
- );
371
- });
372
-
373
- it('proposes the export a kebab-case source holds, never its file name', async () => {
374
- const dir = writeNamed({
375
- [MANIFEST]: manifest({components: './components'}),
376
- 'components/acme-widget.doc.mjs': namedDoc('acme-widget', 'AcmeWidgets'),
377
- 'components/acme-widget.tsx': componentSource('AcmeWidget'),
378
- });
379
-
380
- const message = only(await allOf(dir), 'doc_name_mismatch');
381
- expect(message).toBe(
382
- 'Component doc "acme-widget.doc.mjs" sets name: \'AcmeWidgets\', but components/acme-widget.tsx, the module its import names, does not export AcmeWidgets, so Astryx lists the component as "acme-widget" (its file name), and `astryx component acme-widget` prints `import {AcmeWidgets}`. Fix: set name: \'AcmeWidget\' in acme-widget.doc.mjs, the component components/acme-widget.tsx exports.',
383
- );
384
- const fixed = follow(dir, {
385
- write: {
386
- 'components/acme-widget.doc.mjs': namedDoc('acme-widget', 'AcmeWidget'),
387
- },
388
- });
389
- expect(await allOf(fixed)).toEqual([]);
390
- });
391
-
392
- it('names no single export when a source exports several components', async () => {
393
- const dir = writeNamed({
394
- [MANIFEST]: manifest({components: './components'}),
395
- 'components/acme-widget.doc.mjs': namedDoc('acme-widget', 'AcmeWidgets'),
396
- 'components/acme-widget.tsx':
397
- 'export function AcmeWidget() { return null; }\nexport function AcmeGizmo() { return null; }\n',
398
- });
399
-
400
- expect(only(await allOf(dir), 'doc_name_mismatch')).toContain(
401
- 'Fix: set name in acme-widget.doc.mjs to the component components/acme-widget.tsx exports (AcmeGizmo, AcmeWidget).',
402
- );
403
- });
404
-
405
- it('judges the module the printed import names: an entry that publishes a default under the doc name passes', async () => {
406
- const dir = writePackage(
407
- {
408
- [MANIFEST]: manifest({components: './components'}),
409
- 'components/acme-widget.doc.mjs': componentDoc('AcmeWidget'),
410
- 'components/acme-widget.tsx':
411
- 'export default function AcmeWidget() { return null; }\n',
412
- 'index.ts':
413
- "export {default as AcmeWidget} from './components/acme-widget';\n",
414
- },
415
- {name: '@acme/kit', version: '1.0.0', exports: {'.': './index.ts'}},
416
- );
417
-
418
- const {data} = await validateIntegration(undefined, {cwd: dir});
419
- expect(data.issues).toEqual([]);
420
- expect(data.docNames?.unchecked).toEqual([]);
421
- });
422
-
423
- it('flags a name the printed entry provably does not publish', async () => {
424
- const dir = writePackage(
425
- {
426
- [MANIFEST]: manifest({components: './components'}),
427
- 'components/acme-widget.doc.mjs': componentDoc('AcmeWidget'),
428
- 'components/acme-widget.tsx':
429
- 'export default function AcmeWidget() { return null; }\n',
430
- 'index.ts':
431
- "export {default as AcmeGadget} from './components/acme-widget';\n",
432
- },
433
- {name: '@acme/kit', version: '1.0.0', exports: {'.': './index.ts'}},
434
- );
435
-
436
- expect(only(await allOf(dir), 'doc_name_mismatch')).toContain(
437
- 'but index.ts, the module its import names, does not export AcmeWidget',
438
- );
439
- });
440
-
441
- it('flags a name a default-only printed module cannot give, with a fix that parses and clears it', async () => {
442
- const dir = writeNamed({
443
- [MANIFEST]: manifest({components: './components'}),
444
- 'components/acme-widget.doc.mjs': namedDoc('acme-widget', 'AcmeWidget'),
445
- 'components/acme-widget.tsx':
446
- 'export default function AcmeWidget() { return null; }\n',
447
- });
448
-
449
- const message = only(await allOf(dir), 'doc_name_mismatch');
450
- expect(message).toContain(
451
- 'but components/acme-widget.tsx, the module its import names, does not export AcmeWidget',
452
- );
453
- expect(message).toContain(
454
- "Fix: add `export {AcmeWidget};` to components/acme-widget.tsx, so it exports AcmeWidget by name as well, or set the doc's import to the module that publishes it as AcmeWidget.",
455
- );
456
-
457
- const source =
458
- 'export default function AcmeWidget() { return null; }\nexport {AcmeWidget};\n';
459
- expect(() =>
460
- parse(source, {sourceType: 'module', plugins: ['typescript', 'jsx']}),
461
- ).not.toThrow();
462
- const fixed = follow(dir, {write: {'components/acme-widget.tsx': source}});
463
- expect(await allOf(fixed)).toEqual([]);
464
- });
465
-
466
- it('proposes a named binding for an anonymous default, which parses and clears it', async () => {
467
- const dir = writeNamed({
468
- [MANIFEST]: manifest({components: './components'}),
469
- 'components/acme-widget.doc.mjs': namedDoc('acme-widget', 'AcmeWidget'),
470
- 'components/acme-widget.tsx': 'export default () => null;\n',
471
- });
472
-
473
- expect(only(await allOf(dir), 'doc_name_mismatch')).toContain(
474
- 'Fix: bind the default to AcmeWidget in components/acme-widget.tsx and export it by name too (`const AcmeWidget = …; export default AcmeWidget; export {AcmeWidget};`)',
475
- );
476
- const source =
477
- 'const AcmeWidget = () => null;\nexport default AcmeWidget;\nexport {AcmeWidget};\n';
478
- expect(() =>
479
- parse(source, {sourceType: 'module', plugins: ['typescript', 'jsx']}),
480
- ).not.toThrow();
481
- const fixed = follow(dir, {write: {'components/acme-widget.tsx': source}});
482
- expect(await allOf(fixed)).toEqual([]);
483
- });
484
-
485
- it('lists a default-only source as not checked when no printed import can be resolved', async () => {
486
- const dir = writePackage({
487
- [MANIFEST]: manifest({components: './components'}),
488
- 'components/acme-widget.doc.mjs': componentDoc('AcmeWidget'),
489
- 'components/acme-widget.tsx':
490
- 'export default function AcmeWidget() { return null; }\n',
491
- });
492
- // No package to resolve an import in: the same-stem source is read.
493
- const {report} = await componentDocNamesCheck({
494
- name: '@acme/kit',
495
- components: path.join(dir, 'components'),
496
- __spec: '@acme/kit',
497
- __manifestFile: path.join(dir, MANIFEST),
498
- });
499
-
500
- expect(report.unchecked).toEqual([
501
- {
502
- file: 'acme-widget.doc.mjs',
503
- name: 'AcmeWidget',
504
- reason:
505
- 'acme-widget.tsx exports a default, which the package entry may publish under any name.',
506
- },
507
- ]);
508
- });
509
-
510
- it('lists a name whose printed import resolves to no file as not checked', async () => {
511
- const dir = writePackage({
512
- [MANIFEST]: manifest({components: './components'}),
513
- 'components/acme-widget.doc.mjs': componentDoc('AcmeGadget'),
514
- 'components/acme-widget.tsx': componentSource('AcmeWidget'),
515
- });
516
-
517
- const {data} = await validateIntegration(undefined, {cwd: dir});
518
- expect(data.issues).toEqual([]);
519
- expect(data.docNames?.unchecked.map(entry => entry.file)).toEqual([
520
- 'components/acme-widget.doc.mjs',
521
- ]);
522
- });
523
-
524
- it('accepts a kebab-case file whose doc names the export it holds', async () => {
525
- const dir = writeNamed({
526
- [MANIFEST]: manifest({components: './components'}),
527
- 'components/acme-widget.doc.mjs': namedDoc('acme-widget', 'AcmeWidget'),
528
- 'components/acme-widget.tsx': componentSource('AcmeWidget'),
529
- });
530
-
531
- expect(await allOf(dir)).toEqual([]);
532
- });
533
-
534
- it('leaves a doc topic named differently from its file alone: the code does not contradict it', async () => {
535
- const dir = writeNamed({
536
- [MANIFEST]: manifest({docs: './docs'}),
537
- 'docs/deploying.doc.mjs': topic('deploy'),
538
- });
539
-
540
- expect(await allOf(dir)).toEqual([]);
541
- });
542
-
543
- it('leaves a template name alone: it is the display title', async () => {
544
- const dir = writeNamed({
545
- [MANIFEST]: manifest({templates: './templates'}),
546
- 'templates/account-card.doc.mjs': templateDoc('Account card'),
547
- 'templates/account-card.tsx': templateSource,
548
- });
549
-
550
- expect(await allOf(dir)).toEqual([]);
551
- });
552
- });
553
-
554
- describe('block component names', () => {
555
- /**
556
- * A package whose own name resolves, through its exports, to an entry that
557
- * publishes the names the templates import from it.
558
- * @param {Record<string, string>} files
559
- */
560
- const writeKit = files =>
561
- writePackage(
562
- {
563
- 'index.tsx':
564
- 'export function Panel() { return null; }\nexport const UI = {};\nexport const Lib = {};\nexport function pick() { return null; }\n',
565
- ...files,
566
- },
567
- {
568
- name: '@acme/kit',
569
- version: '1.0.0',
570
- exports: {
571
- '.': './index.tsx',
572
- './templates/*': './templates/*.tsx',
573
- },
574
- },
575
- );
576
- /** @param {string} extra */
577
- const block = extra =>
578
- `export default {type: 'block', name: 'Account card', displayName: 'Account card', aspectRatio: 1,${extra}};\n`;
579
-
580
- it('flags exampleFor and componentsUsed naming no component', async () => {
581
- const dir = writeKit({
582
- [MANIFEST]: manifest({templates: './templates'}),
583
- 'templates/account-card.doc.mjs': block(
584
- " exampleFor: 'AcmeGizmo', componentsUsed: ['AcmeGizmo']",
585
- ),
586
- 'templates/account-card.tsx': templateSource,
587
- });
588
-
589
- const issues = await allOf(dir);
590
- expect(issues.map(issue => issue.code)).toEqual([
591
- 'unknown_block_component',
592
- 'unknown_block_component',
593
- ]);
594
- expect(issues[0].message).toBe(
595
- 'Template "account-card" names "AcmeGizmo" in exampleFor, but neither this package nor Core has a component by that name and the template does not import it, so `astryx template --list` and the block\'s search keywords give a component name no one can look up. Fix: use the component\'s exact name, or remove "AcmeGizmo" from exampleFor.',
596
- );
597
- });
598
-
599
- it("accepts every doc astryx component resolves in Core, such as Chat and Layout, and the package's and imported names", async () => {
600
- const dir = writeKit({
601
- [MANIFEST]: manifest({
602
- components: './components',
603
- templates: './templates',
604
- }),
605
- 'components/AcmeWidget.doc.mjs': componentDoc('AcmeWidget'),
606
- 'components/AcmeWidget.tsx': componentSource('AcmeWidget'),
607
- 'templates/account-card.doc.mjs': block(
608
- " exampleFor: 'AcmeWidget', componentsUsed: ['Chat', 'Layout', 'Button', 'AcmeWidget', 'Helper']",
609
- ),
610
- 'templates/account-card.tsx':
611
- "import {Helper} from 'some-lib';\nexport default function A() {\n return <Helper />;\n}\n",
612
- // The package root the doc's derived import names exports the component.
613
- 'index.tsx':
614
- "export function Panel() { return null; }\nexport {AcmeWidget} from './components/AcmeWidget';\n",
615
- });
616
-
617
- expect(await allOf(dir)).toEqual([]);
618
- });
619
-
620
- it('looks a name up in Core before giving up on a namespace import', async () => {
621
- const dir = writeKit({
622
- [MANIFEST]: manifest({templates: './templates'}),
623
- 'templates/account-card.doc.mjs': block(
624
- " componentsUsed: ['Layout', 'Panel']",
625
- ),
626
- 'templates/account-card.tsx':
627
- "import * as stylex from '@stylexjs/stylex';\nimport * as UI from '@acme/kit';\nexport default function A() {\n return <UI.Panel />;\n}\n",
628
- });
629
-
630
- const {data} = await validateIntegration(undefined, {cwd: dir});
631
- expect(data.issues).toEqual([]);
632
- expect(data.blockComponents?.unchecked.map(entry => entry.name)).toEqual([
633
- 'Panel',
634
- ]);
635
- });
636
-
637
- it('lists a name the template may render through a namespace import as not checked', async () => {
638
- const dir = writeKit({
639
- [MANIFEST]: manifest({templates: './templates'}),
640
- 'templates/account-card.doc.mjs': block(" componentsUsed: ['Panel']"),
641
- 'templates/account-card.tsx':
642
- "import * as UI from '@acme/kit';\nexport default function A() {\n return <UI.Panel />;\n}\n",
643
- });
644
-
645
- const {data} = await validateIntegration(undefined, {cwd: dir});
646
- expect(data.issues).toEqual([]);
647
- expect(data.blockComponents?.unchecked).toEqual([
648
- {
649
- file: 'templates/account-card.doc.mjs',
650
- name: 'Panel',
651
- reason:
652
- 'account-card.tsx imports "@acme/kit" as a namespace (UI), whose component names this check does not read.',
653
- },
654
- ]);
655
- });
656
-
657
- it('prints the block names it could not judge', () => {
658
- const dir = writeKit({
659
- [MANIFEST]: manifest({templates: './templates'}),
660
- 'templates/account-card.doc.mjs': block(" componentsUsed: ['Panel']"),
661
- 'templates/account-card.tsx':
662
- "import * as UI from '@acme/kit';\nexport default function A() {\n return <UI.Panel />;\n}\n",
663
- });
664
-
665
- const run = spawnSync(
666
- process.execPath,
667
- [CLI, 'doctor', 'integration', 'validate'],
668
- {cwd: dir, encoding: 'utf-8', timeout: 60_000},
669
- );
670
- expect(run.status, run.stderr).toBe(0);
671
- expect(run.stdout).toContain(
672
- '[info] Block component names not checked: 1 name(s) this check could not judge:',
673
- );
674
- });
675
-
676
- it('follows a local helper the template renders through', async () => {
677
- const dir = writeKit({
678
- [MANIFEST]: manifest({templates: './templates'}),
679
- 'templates/account-card/account-card.doc.mjs': block(
680
- " componentsUsed: ['Panel', 'AcmeGizmo']",
681
- ),
682
- 'templates/account-card/account-card.tsx':
683
- "import {Body} from './parts/Body';\nexport default function A() {\n return <Body />;\n}\n",
684
- 'templates/account-card/parts/Body.tsx':
685
- "import {Panel} from '@acme/kit';\nexport function Body() {\n return <Panel />;\n}\n",
686
- });
687
-
688
- const {data} = await validateIntegration(undefined, {cwd: dir});
689
- expect(others(data.notes).map(note => note.message)).toEqual([
690
- expect.stringContaining('names "AcmeGizmo" in componentsUsed'),
691
- ]);
692
- expect(data.blockComponents?.unchecked).toEqual([]);
693
- });
694
-
695
- it.each([
696
- ['a named re-export', "export {Body} from './Body';\n"],
697
- ['an export *', "export * from './Body';\n"],
698
- ])(
699
- 'follows a helper barrel with %s like an import',
700
- async (_label, barrel) => {
701
- const dir = writeKit({
702
- [MANIFEST]: manifest({templates: './templates'}),
703
- 'templates/account-card/account-card.doc.mjs': block(
704
- " componentsUsed: ['Panel', 'AcmeGizmo']",
705
- ),
706
- 'templates/account-card/account-card.tsx':
707
- "import {Body} from './parts';\nexport default function A() {\n return <Body />;\n}\n",
708
- 'templates/account-card/parts/index.ts': barrel,
709
- 'templates/account-card/parts/Body.tsx':
710
- "import {Panel} from '@acme/kit';\nexport function Body() {\n return <Panel />;\n}\n",
711
- });
712
-
713
- const {data} = await validateIntegration(undefined, {cwd: dir});
714
- expect(others(data.notes).map(note => note.message)).toEqual([
715
- expect.stringContaining('names "AcmeGizmo" in componentsUsed'),
716
- ]);
717
- expect(data.blockComponents?.unchecked).toEqual([]);
718
- },
719
- );
720
-
721
- it.each([
722
- [
723
- 'a default import used as a namespace',
724
- "import UI from '@acme/kit';\nexport default function A() {\n return <UI.Panel />;\n}\n",
725
- 'account-card.tsx imports the default of "@acme/kit" as UI, which may be any component.',
726
- ],
727
- [
728
- 'members destructured off a named import',
729
- "import {UI} from '@acme/kit';\nconst {Panel} = UI;\nexport default function A() {\n return <Panel />;\n}\n",
730
- 'account-card.tsx reads UI (imported from "@acme/kit") into another name, which this check does not follow.',
731
- ],
732
- [
733
- 'a member read off a named import',
734
- "import {UI} from '@acme/kit';\nconst Panel = UI.Panel;\nexport default function A() {\n return <Panel />;\n}\n",
735
- 'account-card.tsx reads members of UI (imported from "@acme/kit"), whose names this check does not read.',
736
- ],
737
- [
738
- 'createElement with a member',
739
- "import {createElement} from 'react';\nimport {UI} from '@acme/kit';\nexport default function A() {\n return createElement(UI.Panel);\n}\n",
740
- 'account-card.tsx reads members of UI (imported from "@acme/kit"), whose names this check does not read.',
741
- ],
742
- [
743
- 'a default import under another name',
744
- "import Panel from '@acme/kit/AcmePanel';\nexport default function A() {\n return <Panel />;\n}\n",
745
- 'account-card.tsx imports the default of "@acme/kit/AcmePanel" as Panel, which may be any component.',
746
- ],
747
- [
748
- 'an alias of an imported binding',
749
- "import {Lib} from '@acme/kit';\nconst UI = Lib;\nexport default function A() {\n return <UI.AcmePanel />;\n}\n",
750
- 'account-card.tsx reads Lib (imported from "@acme/kit") into another name, which this check does not follow.',
751
- ],
752
- [
753
- 'an optional member read',
754
- "import {UI} from '@acme/kit';\nconst Panel = UI?.AcmePanel;\nexport default function A() {\n return <Panel />;\n}\n",
755
- 'account-card.tsx reads members of UI (imported from "@acme/kit"), whose names this check does not read.',
756
- ],
757
- [
758
- 'a component held in a variable',
759
- "import {pick} from '@acme/kit';\nconst Panel = pick('panel');\nexport default function A() {\n return <Panel />;\n}\n",
760
- 'account-card.tsx renders Panel, a value this check does not trace to an import.',
761
- ],
762
- [
763
- 'require()',
764
- "const {Panel} = require('@acme/kit');\nexport default function A() {\n return <Panel />;\n}\n",
765
- 'account-card.tsx loads "@acme/kit" with require(), whose component names this check does not read.',
766
- ],
767
- [
768
- 'a lazy dynamic import',
769
- "import {lazy} from 'react';\nconst Panel = lazy(() => import('@acme/kit/Panel'));\nexport default function A() {\n return <Panel />;\n}\n",
770
- 'account-card.tsx loads "@acme/kit/Panel" with a dynamic import(), whose component names this check does not read.',
771
- ],
772
- ])(
773
- 'lists a name the template may render through %s as not checked',
774
- async (_label, source, reason) => {
775
- const dir = writeKit({
776
- [MANIFEST]: manifest({templates: './templates'}),
777
- 'templates/account-card.doc.mjs': block(
778
- " componentsUsed: ['AcmePanel']",
779
- ),
780
- 'templates/account-card.tsx': source,
781
- });
782
-
783
- const {data} = await validateIntegration(undefined, {cwd: dir});
784
- expect(data.issues).toEqual([]);
785
- expect(data.blockComponents?.unchecked).toEqual([
786
- {file: 'templates/account-card.doc.mjs', name: 'AcmePanel', reason},
787
- ]);
788
- },
789
- );
790
-
791
- it('leaves names to unchecked when the template imports another package, which may render them', async () => {
792
- const dir = writeKit({
793
- [MANIFEST]: manifest({templates: './templates'}),
794
- 'templates/account-card.doc.mjs': block(
795
- " componentsUsed: ['AcmeCardGrid', 'AcmeCard']",
796
- ),
797
- 'templates/account-card.tsx':
798
- "import {AcmeCardGrid} from '@acme/cards';\nexport default function A() {\n return <AcmeCardGrid />;\n}\n",
799
- });
800
-
801
- const {data} = await validateIntegration(undefined, {cwd: dir});
802
- expect(data.issues).toEqual([]);
803
- expect(data.blockComponents?.unchecked).toEqual([
804
- {
805
- file: 'templates/account-card.doc.mjs',
806
- name: 'AcmeCard',
807
- reason:
808
- 'account-card.tsx imports from "@acme/cards", another package whose components may render ones this check does not see.',
809
- },
810
- ]);
811
- });
812
-
813
- it('leaves names to unchecked when the template imports a default by name', async () => {
814
- const dir = writeKit({
815
- [MANIFEST]: manifest({templates: './templates'}),
816
- 'templates/account-card.doc.mjs': block(" componentsUsed: ['AcmePanel']"),
817
- 'templates/account-card.tsx':
818
- "import {default as Panel} from '@acme/kit/AcmePanel';\nexport default function A() {\n return <Panel />;\n}\n",
819
- });
820
-
821
- const {data} = await validateIntegration(undefined, {cwd: dir});
822
- expect(data.issues).toEqual([]);
823
- expect(data.blockComponents?.unchecked).toEqual([
824
- {
825
- file: 'templates/account-card.doc.mjs',
826
- name: 'AcmePanel',
827
- reason:
828
- 'account-card.tsx imports the default of "@acme/kit/AcmePanel" as Panel, which may be any component.',
829
- },
830
- ]);
831
- });
832
-
833
- it('leaves names to unchecked when a helper re-exports a default by name', async () => {
834
- const dir = writeKit({
835
- [MANIFEST]: manifest({templates: './templates'}),
836
- 'templates/account-card/account-card.doc.mjs': block(
837
- " componentsUsed: ['AcmePanel']",
838
- ),
839
- 'templates/account-card/account-card.tsx':
840
- "import {Body} from './parts';\nexport default function A() {\n return <Body />;\n}\n",
841
- 'templates/account-card/parts/index.ts':
842
- "export {default as Body} from './Body';\n",
843
- 'templates/account-card/parts/Body.tsx':
844
- 'export default function Body() {\n return null;\n}\n',
845
- });
846
-
847
- const {data} = await validateIntegration(undefined, {cwd: dir});
848
- expect(data.issues).toEqual([]);
849
- expect(data.blockComponents?.unchecked).toEqual([
850
- {
851
- file: 'templates/account-card/account-card.doc.mjs',
852
- name: 'AcmePanel',
853
- reason:
854
- 'parts/index.ts re-exports the default of "./Body" as Body, which may be any component.',
855
- },
856
- ]);
857
- });
858
-
859
- it('still flags a name when the template imports only from Core, React, StyleX and itself', async () => {
860
- const dir = writeKit({
861
- [MANIFEST]: manifest({templates: './templates'}),
862
- 'templates/account-card.doc.mjs': block(
863
- " componentsUsed: ['Layout', 'AcmeGizmo']",
864
- ),
865
- 'templates/account-card.tsx':
866
- "import {useState} from 'react';\nimport * as stylex from '@stylexjs/stylex';\nimport {Layout} from '@astryxdesign/core';\nimport type {ReactNode} from 'react';\nimport type {Gizmo} from '@acme/types';\nexport default function A() {\n useState();\n return <Layout />;\n}\n",
867
- });
868
-
869
- const {data} = await validateIntegration(undefined, {cwd: dir});
870
- expect(others(data.notes).map(note => note.message)).toEqual([
871
- expect.stringContaining('names "AcmeGizmo" in componentsUsed'),
872
- ]);
873
- });
874
-
875
- it("follows an import of the package's own name to its source, and lists what that source may render", async () => {
876
- const dir = writeKit({
877
- [MANIFEST]: manifest({templates: './templates'}),
878
- 'index.tsx': "export {AcmeCardGrid} from './src/AcmeCardGrid';\n",
879
- 'src/AcmeCardGrid.tsx':
880
- "import {AcmeCard} from '@acme/cards';\nexport function AcmeCardGrid() {\n return <AcmeCard />;\n}\n",
881
- 'templates/account-card.doc.mjs': block(
882
- " componentsUsed: ['AcmeCardGrid', 'AcmeCardRow']",
883
- ),
884
- 'templates/account-card.tsx':
885
- "import {AcmeCardGrid} from '@acme/kit';\nexport default function A() {\n return <AcmeCardGrid />;\n}\n",
886
- });
887
-
888
- const {data} = await validateIntegration(undefined, {cwd: dir});
889
- expect(others(data.notes)).toEqual([]);
890
- expect(data.blockComponents?.unchecked).toEqual([
891
- {
892
- file: 'templates/account-card.doc.mjs',
893
- name: 'AcmeCardRow',
894
- reason:
895
- '../src/AcmeCardGrid.tsx imports from "@acme/cards", another package whose components may render ones this check does not see.',
896
- },
897
- ]);
898
- });
899
-
900
- it("still flags a name when the package's own source it follows imports only what this check sees", async () => {
901
- const dir = writeKit({
902
- [MANIFEST]: manifest({templates: './templates'}),
903
- 'index.tsx': "export {AcmeCardGrid} from './src/AcmeCardGrid';\n",
904
- 'src/AcmeCardGrid.tsx':
905
- "import {Layout} from '@astryxdesign/core';\nexport function AcmeCardGrid() {\n return <Layout />;\n}\n",
906
- 'templates/account-card.doc.mjs': block(
907
- " componentsUsed: ['AcmeCardGrid', 'AcmeGizmo']",
908
- ),
909
- 'templates/account-card.tsx':
910
- "import {AcmeCardGrid} from '@acme/kit';\nexport default function A() {\n return <AcmeCardGrid />;\n}\n",
911
- });
912
-
913
- const {data} = await validateIntegration(undefined, {cwd: dir});
914
- expect(others(data.notes).map(note => note.message)).toEqual([
915
- expect.stringContaining('names "AcmeGizmo" in componentsUsed'),
916
- ]);
917
- expect(data.blockComponents?.unchecked).toEqual([]);
918
- });
919
-
920
- it("lists names behind an import of the package's own name that resolves to no source", async () => {
921
- const dir = writePackage({
922
- [MANIFEST]: manifest({templates: './templates'}),
923
- 'templates/account-card.doc.mjs': block(" componentsUsed: ['AcmeGizmo']"),
924
- 'templates/account-card.tsx':
925
- "import {AcmeCardGrid} from '@acme/kit/grid';\nexport default function A() {\n return <AcmeCardGrid />;\n}\n",
926
- });
927
-
928
- const {data} = await validateIntegration(undefined, {cwd: dir});
929
- expect(others(data.notes)).toEqual([]);
930
- expect(data.blockComponents?.unchecked).toEqual([
931
- {
932
- file: 'templates/account-card.doc.mjs',
933
- name: 'AcmeGizmo',
934
- reason:
935
- 'account-card.tsx imports "@acme/kit/grid", this package\'s own name, which resolves to no source this check can read.',
936
- },
937
- ]);
938
- });
939
-
940
- it("skips a renderless library's default import, as its namespace import", async () => {
941
- const dir = writeKit({
942
- [MANIFEST]: manifest({templates: './templates'}),
943
- 'templates/account-card.doc.mjs': block(" componentsUsed: ['AcmeGizmo']"),
944
- 'templates/account-card.tsx':
945
- "import React from 'react';\nexport default function A() {\n return <div />;\n}\n",
946
- });
947
-
948
- const {data} = await validateIntegration(undefined, {cwd: dir});
949
- expect(others(data.notes).map(note => note.message)).toEqual([
950
- expect.stringContaining('names "AcmeGizmo" in componentsUsed'),
951
- ]);
952
- expect(data.blockComponents?.unchecked).toEqual([]);
953
- });
954
-
955
- it('lists a name behind a local helper it cannot read as not checked', async () => {
956
- const dir = writeKit({
957
- [MANIFEST]: manifest({templates: './templates'}),
958
- 'templates/account-card.doc.mjs': block(" componentsUsed: ['Panel']"),
959
- 'templates/account-card.tsx':
960
- "import {Body} from './parts/missing';\nexport default function A() {\n return <Body />;\n}\n",
961
- });
962
-
963
- const {data} = await validateIntegration(undefined, {cwd: dir});
964
- expect(data.issues).toEqual([]);
965
- expect(data.blockComponents?.unchecked.map(entry => entry.name)).toEqual([
966
- 'Panel',
967
- ]);
968
- });
969
-
970
- it('lists names only Core could resolve as not checked when Core is not installed', async () => {
971
- const outside = fs.mkdtempSync(path.join(os.tmpdir(), 'astryx-no-core-'));
972
- try {
973
- fs.writeFileSync(
974
- path.join(outside, 'package.json'),
975
- JSON.stringify({name: '@acme/kit', version: '1.0.0'}),
976
- );
977
- fs.writeFileSync(
978
- path.join(outside, MANIFEST),
979
- manifest({templates: './templates'}),
980
- );
981
- fs.mkdirSync(path.join(outside, 'templates'));
982
- fs.writeFileSync(
983
- path.join(outside, 'templates', 'account-card.doc.mjs'),
984
- block(" componentsUsed: ['Chat', 'Layout']"),
985
- );
986
- fs.writeFileSync(
987
- path.join(outside, 'templates', 'account-card.tsx'),
988
- templateSource,
989
- );
990
-
991
- const {data} = await validateIntegration(undefined, {cwd: outside});
992
- expect(others(data.notes)).toEqual([]);
993
- const reason =
994
- 'Core is not installed, so its component names cannot be checked.';
995
- expect(data.blockComponents).toEqual({
996
- status: 'checked',
997
- findings: [],
998
- unchecked: [
999
- {file: 'templates/account-card.doc.mjs', name: 'Chat', reason},
1000
- {file: 'templates/account-card.doc.mjs', name: 'Layout', reason},
1001
- ],
1002
- });
1003
- } finally {
1004
- fs.rmSync(outside, {recursive: true, force: true});
1005
- }
1006
- });
1007
- });
1008
-
1009
- describe('template ids', () => {
1010
- it('leaves an id with spaces alone: it is naming policy, not a contradiction', async () => {
1011
- const dir = writePackage({
1012
- [MANIFEST]: manifest({templates: './templates'}),
1013
- 'templates/AI Chat Conversation.doc.mjs': templateDoc(
1014
- 'AI Chat Conversation',
1015
- ),
1016
- 'templates/AI Chat Conversation.tsx': templateSource,
1017
- });
1018
-
1019
- expect(await issuesOf(dir)).toEqual([]);
1020
- });
1021
- });
1022
-
1023
- describe('component doc files', () => {
1024
- it('lists two docs for one component, naming the one read, without an issue', async () => {
1025
- const dir = writePackage({
1026
- [MANIFEST]: manifest({components: './components'}),
1027
- 'components/AcmeWidget.doc.mjs': componentDoc('AcmeWidget'),
1028
- 'components/AcmeWidget.doc.js': componentDoc('AcmeWidget'),
1029
- 'components/AcmeWidget.tsx': componentSource('AcmeWidget'),
1030
- });
1031
-
1032
- expect(await issuesOf(dir)).toEqual([]);
1033
- const message = only(await listedOf(dir), 'duplicate_component_doc');
1034
- expect(message).toBe(
1035
- 'Component "AcmeWidget" has 2 docs: AcmeWidget.doc.mjs, AcmeWidget.doc.js. Astryx reads AcmeWidget.doc.mjs and ignores AcmeWidget.doc.js. Fix: delete AcmeWidget.doc.js, moving anything only it says into AcmeWidget.doc.mjs.',
1036
- );
1037
-
1038
- const fixed = follow(dir, {remove: ['components/AcmeWidget.doc.js']});
1039
- expect(await allOf(fixed)).toEqual([]);
1040
- });
1041
-
1042
- it('gives one finding for a doc whose name differs from its source only in case', async () => {
1043
- const dir = writePackage({
1044
- [MANIFEST]: manifest({components: './components'}),
1045
- 'components/Acmewidget.doc.mjs': componentDoc('AcmeWidget'),
1046
- 'components/AcmeWidget.tsx': componentSource('AcmeWidget'),
1047
- });
1048
-
1049
- const issues = await issuesOf(dir);
1050
- expect(issues).toHaveLength(1);
1051
- expect(issues[0]).toEqual({
1052
- code: 'invalid_component',
1053
- severity: 'error',
1054
- message:
1055
- 'Component doc "Acmewidget.doc.mjs" and its source "AcmeWidget.tsx" differ only in letter case. They pair on a case-insensitive disk (macOS, Windows) but not on Linux, where CI and most installs run, so here the component is missing. Fix: rename Acmewidget.doc.mjs to AcmeWidget.doc.mjs.',
1056
- });
1057
-
1058
- // Through a temporary name, so a case-insensitive disk renames it too.
1059
- const fixed = follow(dir, {
1060
- move: [
1061
- ['components/Acmewidget.doc.mjs', 'components/tmp.doc.mjs'],
1062
- ['components/tmp.doc.mjs', 'components/AcmeWidget.doc.mjs'],
1063
- ],
1064
- });
1065
- expect(await issuesOf(fixed)).toEqual([]);
1066
- });
1067
-
1068
- it('names a .jsx source beside a component doc and says to rename it', async () => {
1069
- const dir = writePackage({
1070
- [MANIFEST]: manifest({components: './components'}),
1071
- 'components/AcmeWidget.doc.mjs': componentDoc('AcmeWidget'),
1072
- 'components/AcmeWidget.jsx': componentSource('AcmeWidget'),
1073
- });
1074
-
1075
- const message = only(await issuesOf(dir), 'invalid_component');
1076
- expect(message).toBe(
1077
- 'Component "AcmeWidget" is missing its same-stem source file AcmeWidget.tsx: found AcmeWidget.jsx, but a component source must be a .tsx file. Fix: rename AcmeWidget.jsx to AcmeWidget.tsx (and point its package export at the new file).',
1078
- );
1079
-
1080
- const fixed = follow(dir, {
1081
- move: [['components/AcmeWidget.jsx', 'components/AcmeWidget.tsx']],
1082
- });
1083
- expect(await issuesOf(fixed)).toEqual([]);
1084
- });
1085
-
1086
- it('says what an empty doc and a doc with no default export are missing', async () => {
1087
- const dir = writePackage({
1088
- [MANIFEST]: manifest({components: './components'}),
1089
- 'components/Empty.doc.mjs': '',
1090
- 'components/Empty.tsx': componentSource('Empty'),
1091
- 'components/Named.doc.mjs': componentDoc('Named').replace(
1092
- 'export default',
1093
- 'export const doc =',
1094
- ),
1095
- 'components/Named.tsx': componentSource('Named'),
1096
- });
1097
-
1098
- const messages = (await issuesOf(dir)).map(issue => issue.message);
1099
- const fix =
1100
- 'Fix: export the doc object as the default export: `export default {type: ..., name: ..., ...}`.';
1101
- expect(messages).toEqual([
1102
- `Component "Empty" has invalid metadata: ${path.join(dir, 'components', 'Empty.doc.mjs')} is empty, so it documents nothing. ${fix}`,
1103
- `Component "Named" has invalid metadata: ${path.join(dir, 'components', 'Named.doc.mjs')} has no default export or \`docs\` export (it exports \`doc\`), so it documents nothing. ${fix}`,
1104
- ]);
1105
- expect(messages.join('\n')).not.toContain('Invalid input');
1106
- });
1107
- });
1108
-
1109
- describe('template and theme pairing', () => {
1110
- it('gives a template doc with no source a fix', async () => {
1111
- const dir = writePackage({
1112
- [MANIFEST]: manifest({templates: './templates'}),
1113
- 'templates/account-card.doc.mjs': templateDoc('Account card'),
1114
- });
1115
-
1116
- const message = only(await issuesOf(dir), 'invalid_template');
1117
- expect(message).toBe(
1118
- 'Template "account-card" is missing its same-stem source file account-card.tsx. Fix: add account-card.tsx beside account-card.doc.mjs, with the template as its default export.',
1119
- );
1120
- const fixed = follow(dir, {
1121
- write: {'templates/account-card.tsx': templateSource},
1122
- });
1123
- expect(await issuesOf(fixed)).toEqual([]);
1124
- });
1125
-
1126
- const themeDoc = `${THEME_TYPE}export default {type: 'theme', name: 'ocean', displayName: 'Ocean', description: 'A theme.', maintained: true};\n`;
1127
- const themeSource =
1128
- "import {defineTheme} from '@astryxdesign/core/theme';\nexport const oceanTheme = defineTheme({name: 'ocean'});\n";
1129
-
1130
- it('gives a theme descriptor with no source a fix', async () => {
1131
- const dir = writePackage({
1132
- [MANIFEST]: manifest({themes: './themes'}),
1133
- 'themes/ocean/oceanTheme.doc.mjs': themeDoc,
1134
- });
1135
-
1136
- expect(only(await issuesOf(dir), 'invalid_theme')).toBe(
1137
- 'Theme "ocean" for @acme/kit must contain exactly one same-stem source for oceanTheme.doc.mjs; found 0. Fix: add oceanTheme.ts beside oceanTheme.doc.mjs, exporting `oceanTheme` from defineTheme.',
1138
- );
1139
- });
1140
-
1141
- it('gives a theme source with no descriptor a fix', async () => {
1142
- const dir = writePackage({
1143
- [MANIFEST]: manifest({themes: './themes'}),
1144
- 'themes/ocean/oceanTheme.ts': themeSource,
1145
- });
1146
-
1147
- const message = only(await issuesOf(dir), 'invalid_theme');
1148
- expect(message).toBe(
1149
- `Theme "ocean" for @acme/kit must contain exactly one same-stem .doc.mjs descriptor; found 0 beside "oceanTheme.ts". Fix: add oceanTheme.doc.mjs beside it with type: 'theme' and name: 'ocean'; \`${formatCliCommand('docs authoring theme-doc', path.join(dir, 'themes', 'ocean'))}\` lists its fields.`,
1150
- );
1151
- const fixed = follow(dir, {
1152
- write: {'themes/ocean/oceanTheme.doc.mjs': themeDoc},
1153
- });
1154
- expect(
1155
- (await issuesOf(fixed)).filter(issue => issue.code === 'invalid_theme'),
1156
- ).toEqual([]);
1157
- });
1158
-
1159
- it('says to rename a source named for its theme when the build writes beside it, and the rename clears it', async () => {
1160
- const brandDoc = `${THEME_TYPE}export default {type: 'theme', name: 'brand', displayName: 'Brand', description: 'A theme.', maintained: true};\n`;
1161
- const dir = writePackage({
1162
- [MANIFEST]: manifest({themes: './themes'}),
1163
- 'themes/brand/brand.doc.mjs': brandDoc,
1164
- 'themes/brand/brand.ts':
1165
- "import {defineTheme} from '@astryxdesign/core/theme';\nexport const brand = defineTheme({name: 'brand'});\n",
1166
- 'themes/brand/brand.js':
1167
- "/**\n * @generated by `astryx theme build` — do not edit manually.\n */\nimport './brand.css';\nexport const brandTheme = {};\n",
1168
- 'themes/brand/brand.css': '.astryx-theme-brand {}\n',
1169
- });
1170
-
1171
- expect(only(await issuesOf(dir), 'invalid_theme')).toBe(
1172
- `Theme "brand" for @acme/kit must contain exactly one same-stem source for brand.doc.mjs; found 2: "brand.js", "brand.ts". Fix: "brand.js" is the module \`${formatCliCommand('theme build', path.join(dir, 'themes', 'brand'))}\` writes, which takes the theme's name; rename brand.ts to brandTheme.ts and brand.doc.mjs to brandTheme.doc.mjs, export \`brandTheme\` from it, and build again.`,
1173
- );
1174
-
1175
- const fixed = follow(dir, {
1176
- remove: ['themes/brand/brand.ts', 'themes/brand/brand.doc.mjs'],
1177
- write: {
1178
- 'themes/brand/brandTheme.ts':
1179
- "import {defineTheme} from '@astryxdesign/core/theme';\nexport const brandTheme = defineTheme({name: 'brand'});\n",
1180
- 'themes/brand/brandTheme.doc.mjs': brandDoc,
1181
- },
1182
- });
1183
- expect(
1184
- (await issuesOf(fixed)).filter(issue => issue.code === 'invalid_theme'),
1185
- ).toEqual([]);
1186
- });
1187
-
1188
- const builtOcean = (/** @type {string} */ extra) =>
1189
- `/**\n * @generated by \`astryx theme build\` — do not edit manually.\n${extra} */\nimport './ocean.css';\nexport const oceanTheme = {};\n`;
1190
-
1191
- it("names the theme's source when its defineTheme gives the theme's name, for a descriptor named for the built module", async () => {
1192
- const dir = writePackage({
1193
- [MANIFEST]: manifest({themes: './themes'}),
1194
- 'themes/ocean/ocean.doc.mjs': themeDoc,
1195
- 'themes/ocean/oceanTheme.ts': themeSource,
1196
- 'themes/ocean/ocean.js': builtOcean(''),
1197
- 'themes/ocean/ocean.css': '.astryx-theme-ocean {}\n',
1198
- });
1199
-
1200
- const message = only(await issuesOf(dir), 'invalid_theme');
1201
- expect(message).toContain(
1202
- 'shares its stem with the built module "ocean.js", which does not export "ocean": a descriptor must share its stem with the source that calls defineTheme. The theme\'s source is "oceanTheme.ts". Fix: rename ocean.doc.mjs to oceanTheme.doc.mjs.',
1203
- );
1204
- const fixed = follow(dir, {
1205
- move: [['themes/ocean/ocean.doc.mjs', 'themes/ocean/oceanTheme.doc.mjs']],
1206
- });
1207
- expect(
1208
- (await issuesOf(fixed)).filter(issue => issue.code === 'invalid_theme'),
1209
- ).toEqual([]);
1210
- });
1211
-
1212
- it("names the source the built module's Source: line gives, over a <name>Theme helper", async () => {
1213
- const dir = writePackage({
1214
- [MANIFEST]: manifest({themes: './themes'}),
1215
- 'themes/ocean/ocean.doc.mjs': themeDoc,
1216
- 'themes/ocean/seaTheme.ts': themeSource.replace('oceanTheme', 'seaTheme'),
1217
- 'themes/ocean/baseTheme.ts':
1218
- "import {defineTheme} from '@astryxdesign/core/theme';\nexport const baseTheme = defineTheme({name: 'base'});\n",
1219
- 'themes/ocean/ocean.js': builtOcean(
1220
- ' * Source: themes/ocean/seaTheme.ts\n',
1221
- ),
1222
- 'themes/ocean/ocean.css': '.astryx-theme-ocean {}\n',
1223
- });
1224
-
1225
- expect(only(await issuesOf(dir), 'invalid_theme')).toContain(
1226
- 'The theme\'s source is "seaTheme.ts". Fix: rename ocean.doc.mjs to seaTheme.doc.mjs.',
1227
- );
1228
- });
1229
-
1230
- it('never names a lone <name>Theme helper as the source: the message stays generic', async () => {
1231
- const dir = writePackage({
1232
- [MANIFEST]: manifest({themes: './themes'}),
1233
- 'themes/ocean/ocean.doc.mjs': themeDoc,
1234
- 'themes/ocean/oceanTheme.ts':
1235
- "import {defineTheme} from '@astryxdesign/core/theme';\nexport const oceanTheme = defineTheme({name: 'base'});\n",
1236
- 'themes/ocean/ocean.js': builtOcean(''),
1237
- 'themes/ocean/ocean.css': '.astryx-theme-ocean {}\n',
1238
- });
1239
-
1240
- const message = only(await issuesOf(dir), 'invalid_theme');
1241
- expect(message).toContain(
1242
- 'shares its stem with the built module "ocean.js", which does not export "ocean": a descriptor must share its stem with the source that calls defineTheme. Fix: rename ocean.doc.mjs to share its stem with the theme\'s source (the module that calls defineTheme, such as oceanTheme.ts).',
1243
- );
1244
- expect(message).not.toContain("The theme's source is");
1245
- });
1246
-
1247
- it('accepts a descriptor named for a built module that exports its stem, as 0.7.2 does', async () => {
1248
- const dir = writePackage({
1249
- [MANIFEST]: manifest({themes: './themes'}),
1250
- 'themes/ocean/ocean.doc.mjs': themeDoc,
1251
- 'themes/ocean/oceanTheme.ts': themeSource,
1252
- 'themes/ocean/ocean.js': builtOcean('').replace(
1253
- 'export const oceanTheme = {};',
1254
- 'export const oceanTheme = {};\nexport const ocean = oceanTheme;',
1255
- ),
1256
- 'themes/ocean/ocean.css': '.astryx-theme-ocean {}\n',
1257
- });
1258
-
1259
- expect(
1260
- (await issuesOf(dir)).filter(issue => issue.code === 'invalid_theme'),
1261
- ).toEqual([]);
1262
- });
1263
- });
1264
-
1265
- describe('a theme folder with a helper', () => {
1266
- it('reads a descriptor beside its own defineTheme source, with a <name>Theme helper beside them', async () => {
1267
- const dir = writePackage({
1268
- [MANIFEST]: manifest({themes: './themes'}),
1269
- 'themes/brand/brand.doc.mjs': `${THEME_TYPE}export default {type: 'theme', name: 'brand', displayName: 'Brand', description: 'A theme.', maintained: true};\n`,
1270
- 'themes/brand/brand.ts':
1271
- "import {defineTheme} from '@astryxdesign/core/theme';\nimport {baseTheme} from './baseTheme';\nexport const brand = defineTheme({name: 'brand', extends: baseTheme});\n",
1272
- 'themes/brand/baseTheme.ts':
1273
- "import {defineTheme} from '@astryxdesign/core/theme';\nexport const baseTheme = defineTheme({name: 'base'});\n",
1274
- });
1275
-
1276
- expect(
1277
- (await issuesOf(dir)).filter(issue => issue.code === 'invalid_theme'),
1278
- ).toEqual([]);
1279
- });
1280
- });
1281
-
1282
- describe('a hidden doc beside a source whose name differs only in case', () => {
1283
- it('keeps the source warning 0.7.2 gives where the hidden doc does not pair, as on Linux', async () => {
1284
- const dir = writePackage({
1285
- [MANIFEST]: manifest({components: './components'}),
1286
- 'components/Acmewidget.doc.mjs': componentDoc('AcmeWidget').replace(
1287
- "type: 'component',",
1288
- "type: 'component',\n hidden: true,",
1289
- ),
1290
- 'components/AcmeWidget.tsx': componentSource('AcmeWidget'),
1291
- });
1292
-
1293
- const issues = await issuesOf(dir);
1294
- expect(issues.map(issue => [issue.code, issue.severity])).toEqual([
1295
- ['source_without_component_doc', 'warning'],
1296
- ]);
1297
- expect(issues[0].message).toMatch(
1298
- /^Component source "AcmeWidget\.tsx" has no same-stem metadata file AcmeWidget\.doc\.mjs, so Astryx ignores it\. Fix: /u,
1299
- );
1300
- expect(await listedOf(dir)).toEqual([]);
1301
- });
1302
- });
1303
-
1304
- describe('roots', () => {
1305
- it('lists that npm pack does not follow a symlinked root, and reads its folder through it', async () => {
1306
- const dir = writePackage({
1307
- [MANIFEST]: manifest({components: './components'}),
1308
- 'real-components/AcmeWidget.doc.mjs': componentDoc('AcmeWidget'),
1309
- 'real-components/AcmeWidget.tsx': componentSource('AcmeWidget'),
1310
- });
1311
- fs.symlinkSync('real-components', path.join(dir, 'components'));
1312
-
1313
- expect(await issuesOf(dir)).toEqual([]);
1314
- const issues = await listedOf(dir);
1315
- expect(issues.map(issue => issue.code)).toEqual(['symlinked_root']);
1316
- expect(issues[0].message).toBe(
1317
- 'Declared components root "components" is reached through the symlink "components" (to "real-components"). Astryx follows it locally, but npm pack does not follow a symlinked folder, so the published package ships none of these files. Fix: replace the link with the folder itself (move real-components/ to components/), or set `components: \'./real-components\'` in astryx.integration.mjs.',
1318
- );
1319
-
1320
- const fixed = follow(dir, {
1321
- remove: ['components'],
1322
- move: [['real-components', 'components']],
1323
- });
1324
- expect(await allOf(fixed)).toEqual([]);
1325
- });
1326
-
1327
- it('says an absolute root inside the package must be relative', async () => {
1328
- const dir = writePackage({
1329
- 'docs/deploying.doc.mjs': topic('deploying'),
1330
- });
1331
- fs.writeFileSync(
1332
- path.join(dir, MANIFEST),
1333
- manifest({docs: path.join(dir, 'docs')}),
1334
- );
1335
-
1336
- const issues = await issuesOf(dir);
1337
- expect(issues).toEqual([
1338
- {
1339
- code: 'root_outside_package',
1340
- severity: 'error',
1341
- message: `The docs root "${path.join(dir, 'docs')}" is an absolute path, so Astryx reads nothing from it: a root is relative to the package, so it resolves the same wherever the package is installed. Fix: set \`docs: './docs'\` in astryx.integration.mjs.`,
1342
- },
1343
- ]);
1344
- expect(issues[0].message).not.toContain('outside');
1345
-
1346
- const fixed = follow(dir, {
1347
- write: {[MANIFEST]: manifest({docs: './docs'})},
1348
- });
1349
- expect(await issuesOf(fixed)).toEqual([]);
1350
- });
1351
-
1352
- it('reports a root that is a file from every check, without crashing', async () => {
1353
- const dir = writePackage({
1354
- [MANIFEST]: manifest({
1355
- components: './components/AcmeWidget.tsx',
1356
- templates: './templates/account-card.tsx',
1357
- docs: './docs/deploying.doc.mjs',
1358
- }),
1359
- 'components/AcmeWidget.tsx': componentSource('AcmeWidget'),
1360
- 'templates/account-card.tsx': templateSource,
1361
- 'docs/deploying.doc.mjs': topic('deploying'),
1362
- });
1363
-
1364
- const result = await integrationCheck({cwd: dir});
1365
- expect(result.data.checks.map(check => check.check)).toEqual([
1366
- 'validate',
1367
- 'components',
1368
- 'templates',
1369
- 'docs',
1370
- ]);
1371
- for (const check of result.data.checks) {
1372
- const codes = check.response.data.issues
1373
- .filter(issue => issue.severity === 'error')
1374
- .map(issue => issue.code);
1375
- expect(codes).toEqual(['invalid_root', 'invalid_root', 'invalid_root']);
1376
- }
1377
- });
1378
- });
1379
-
1380
- describe('package.json', () => {
1381
- it('lists a missing name and keeps checking, without crashing any check', async () => {
1382
- const dir = writePackage(
1383
- {
1384
- [MANIFEST]: manifest({components: './components', docs: './docs'}),
1385
- 'components/AcmeWidget.doc.mjs': componentDoc('AcmeWidget'),
1386
- 'docs/deploying.doc.mjs': topic('deploying'),
1387
- },
1388
- {version: '1.0.0'},
1389
- );
1390
-
1391
- const result = await integrationCheck({cwd: dir});
1392
- for (const check of result.data.checks) {
1393
- expect(
1394
- check.response.data.issues.map(issue => [issue.code, issue.severity]),
1395
- ).toEqual([['invalid_component', 'error']]);
1396
- }
1397
- const validate = result.data.checks[0].response.data;
1398
- expect('notes' in validate ? others(validate.notes) : undefined).toEqual([
1399
- {
1400
- code: 'invalid_package_json',
1401
- next: true,
1402
- message:
1403
- 'package.json has no "name", so npm cannot pack or publish the package, and a project that installs it has no name to select it by. Fix: add "name": "@your-scope/your-package" to package.json.',
1404
- },
1405
- ]);
1406
- expect(result.data.failed).toBe(true);
1407
- });
1408
-
1409
- it('still compares documented props for a package without a name', async () => {
1410
- const dir = writePackage(
1411
- {
1412
- [MANIFEST]: manifest({components: './components'}),
1413
- 'components/AcmeWidget.doc.mjs':
1414
- "export default {type: 'component', name: 'AcmeWidget', displayName: 'AcmeWidget', usage: {description: 'A widget.'}, props: [{name: 'label', type: 'string', description: 'Text.'}]};\n",
1415
- 'components/AcmeWidget.tsx':
1416
- 'export function AcmeWidget(props: {title: string}) { return null; }\n',
1417
- },
1418
- {version: '1.0.0'},
1419
- );
1420
-
1421
- const result = await integrationCheck({cwd: dir, strict: true});
1422
- const components = result.data.checks.find(
1423
- check => check.check === 'components',
1424
- );
1425
- const propDrift = /** @type {any} */ (components?.response.data)?.propDrift;
1426
- expect(propDrift).toBeDefined();
1427
- const failures = result.data.failures.map(failure => failure.code);
1428
- expect(failures).not.toContain('invalid_package_json');
1429
- if (propDrift.status === 'skipped') {
1430
- // No TypeScript here: --strict names the skipped comparison.
1431
- expect(failures).toContain('prop_drift_skipped');
1432
- } else {
1433
- expect(propDrift.findings.map((/** @type {any} */ f) => f.kind)).toEqual(
1434
- expect.arrayContaining(['not_in_code', 'not_in_doc']),
1435
- );
1436
- }
1437
- });
1438
-
1439
- it('completes --strict for a package without a name whose component docs hold links, reporting none', async () => {
1440
- const dir = writePackage(
1441
- {
1442
- [MANIFEST]: manifest({components: './components'}),
1443
- 'components/AcmeWidget.doc.mjs':
1444
- "export default {type: 'component', name: 'AcmeWidget', displayName: 'AcmeWidget', usage: {description: 'Read {@link generic:x} first.'}, props: []};\n",
1445
- 'components/AcmeWidget.tsx': componentSource('AcmeWidget'),
1446
- },
1447
- {version: '1.0.0'},
1448
- );
1449
-
1450
- const result = await integrationCheck({cwd: dir, strict: true});
1451
- const components = result.data.checks.find(
1452
- check => check.check === 'components',
1453
- );
1454
- expect(components?.response.data.issues.map(issue => issue.code)).toEqual(
1455
- [],
1456
- );
1457
- expect(
1458
- result.data.failures.filter(
1459
- failure => failure.code === 'invalid_doc_graph',
1460
- ),
1461
- ).toEqual([]);
1462
- });
1463
-
1464
- it('checks the docs of a package without a name, naming them by path', async () => {
1465
- const dir = writePackage(
1466
- {
1467
- [MANIFEST]: manifest({docs: './docs'}),
1468
- 'docs/deploying.doc.mjs': topic('deploying').replace(
1469
- '"text":"deploying"',
1470
- '"text":"See {@link generic:no-such-topic}."',
1471
- ),
1472
- },
1473
- {version: '1.0.0'},
1474
- );
1475
-
1476
- const result = await integrationCheck({cwd: dir});
1477
- const docs = result.data.checks.find(check => check.check === 'docs');
1478
- const messages =
1479
- docs?.response.data.issues.map(issue => issue.message) ?? [];
1480
- expect(messages.join('\n')).not.toContain('astryx-unnamed-local-package');
1481
- expect(docs?.response.data.issues.map(issue => issue.code)).toEqual([
1482
- 'invalid_doc_graph',
1483
- ]);
1484
- expect(messages[0]).toMatch(
1485
- /^deploying § overview: "generic:no-such-topic" names no doc\./u,
1486
- );
1487
- });
1488
-
1489
- it.each([
1490
- ['acme kit'],
1491
- ['_acme'],
1492
- ['acme/kit'],
1493
- ['-acme'],
1494
- ['@acme/-kit'],
1495
- ['~acme'],
1496
- ])(
1497
- 'lists that no provider ID can be derived from the name %s, and keeps checking',
1498
- async name => {
1499
- const dir = writePackage(
1500
- {
1501
- [MANIFEST]: manifest({components: './components'}),
1502
- 'components/AcmeWidget.doc.mjs': componentDoc('AcmeWidget'),
1503
- },
1504
- {name, version: '1.0.0'},
1505
- );
1506
-
1507
- expect(
1508
- (await issuesOf(dir)).map(issue => [issue.code, issue.severity]),
1509
- ).toEqual([['invalid_component', 'error']]);
1510
- const issues = await listedOf(dir);
1511
- expect(issues.map(issue => issue.code)).toEqual(['no_provider_id']);
1512
- expect(issues[0].message).toBe(
1513
- `No provider ID can be derived for this package: package.json "name" ${JSON.stringify(name)} is not a bare package name (an optional @scope/ and a name, each starting with a lowercase letter or digit and holding only lowercase letters, digits, "-", ".", "_" and "~"), and astryx.integration.mjs declares no providerId that is one. Astryx files the package's components, templates and docs under that ID, so links to them and selecting the package cannot work. Fix: rename the package, such as "@your-scope/your-package", or set \`providerId: '@your-scope/your-package'\` in astryx.integration.mjs.`,
1514
- );
1515
- expect(issues[0].message).not.toContain('npm cannot pack');
1516
- const result = await integrationCheck({cwd: dir});
1517
- expect(result.data.checks.every(check => check.response.type)).toBe(true);
1518
- },
1519
- );
1520
-
1521
- it('leaves the provider ID to invalid_manifest when the manifest does not load', async () => {
1522
- const dir = writePackage(
1523
- {
1524
- [MANIFEST]: manifest({providerId: '@acme/kit', issuesUrl: 42}),
1525
- },
1526
- {name: '-acme', version: '1.0.0'},
1527
- );
1528
-
1529
- const issues = await issuesOf(dir);
1530
- expect(issues.map(issue => issue.code)).toEqual(['invalid_manifest']);
1531
- expect(await listedOf(dir)).toEqual([]);
1532
- });
1533
-
1534
- it('derives the provider ID from the manifest when the name cannot give one', async () => {
1535
- const dir = writePackage(
1536
- {
1537
- [MANIFEST]: manifest({
1538
- providerId: '@acme/kit',
1539
- components: './components',
1540
- }),
1541
- 'components/AcmeWidget.doc.mjs': componentDoc('AcmeWidget'),
1542
- 'components/AcmeWidget.tsx': componentSource('AcmeWidget'),
1543
- },
1544
- {name: '@acme/_kit', version: '1.0.0'},
1545
- );
1546
-
1547
- expect(await issuesOf(dir)).toEqual([]);
1548
- expect((await integrationCheck({cwd: dir, strict: true})).data.failed).toBe(
1549
- false,
1550
- );
1551
- });
1552
-
1553
- it('checks a package without a name whose root is a file, without crashing', async () => {
1554
- const dir = writePackage(
1555
- {
1556
- [MANIFEST]: manifest({
1557
- templates: './templates/account-card.tsx',
1558
- docs: './docs/deploying.doc.mjs',
1559
- }),
1560
- 'templates/account-card.tsx': templateSource,
1561
- 'docs/deploying.doc.mjs': topic('deploying'),
1562
- },
1563
- {version: '1.0.0'},
1564
- );
1565
-
1566
- const result = await integrationCheck({cwd: dir});
1567
- for (const check of result.data.checks) {
1568
- expect(
1569
- check.response.data.issues
1570
- .filter(issue => issue.severity === 'error')
1571
- .map(issue => issue.code),
1572
- ).toEqual(['invalid_root', 'invalid_root']);
1573
- }
1574
- });
1575
-
1576
- it('checks links under the manifest providerId when the name gives none', async () => {
1577
- const linked = (/** @type {string} */ name, /** @type {string} */ text) =>
1578
- `export default ${JSON.stringify({
1579
- type: 'generic',
1580
- name,
1581
- title: name,
1582
- description: `The ${name} topic.`,
1583
- sections: [{title: 'Overview', content: [{type: 'prose', text}]}],
1584
- })};\n`;
1585
- const dir = writePackage(
1586
- {
1587
- [MANIFEST]: manifest({
1588
- providerId: '@acme/kit',
1589
- components: './components',
1590
- docs: './docs',
1591
- }),
1592
- 'components/AcmeWidget.doc.mjs':
1593
- "export default {type: 'component', name: 'AcmeWidget', displayName: 'AcmeWidget', usage: {description: 'Read {@link generic:no-such-topic}.'}, props: []};\n",
1594
- 'components/AcmeWidget.tsx': componentSource('AcmeWidget'),
1595
- 'docs/deploying.doc.mjs': linked(
1596
- 'deploying',
1597
- 'See {@link @acme/kit:generic:other}.',
1598
- ),
1599
- 'docs/other.doc.mjs': linked('other', 'The other topic.'),
1600
- },
1601
- {name: '@acme/_kit', version: '1.0.0'},
1602
- );
1603
-
1604
- const result = await integrationCheck({cwd: dir});
1605
- const issuesOf = (/** @type {string} */ name) =>
1606
- result.data.checks.find(check => check.check === name)?.response.data
1607
- .issues ?? [];
1608
- const componentLinks = issuesOf('components').filter(
1609
- issue => issue.code === 'invalid_doc_graph',
1610
- );
1611
- expect(componentLinks).toHaveLength(1);
1612
- expect(componentLinks[0].message).toContain('no-such-topic');
1613
- expect(
1614
- issuesOf('docs').filter(issue => issue.code === 'invalid_doc_graph'),
1615
- ).toEqual([]);
1616
- });
1617
-
1618
- it('fails neither run on a missing name when nothing else is wrong: it is listed until the next minor', async () => {
1619
- const dir = writePackage(
1620
- {
1621
- [MANIFEST]: manifest({docs: './docs'}),
1622
- 'docs/deploying.doc.mjs': topic('deploying'),
1623
- },
1624
- {version: '1.0.0'},
1625
- );
1626
-
1627
- expect((await integrationCheck({cwd: dir})).data.failed).toBe(false);
1628
- expect((await integrationCheck({cwd: dir, strict: true})).data.failed).toBe(
1629
- false,
1630
- );
1631
- });
1632
-
1633
- it('lists a missing version and still checks the rest', async () => {
1634
- const dir = writePackage(
1635
- {
1636
- [MANIFEST]: manifest({components: './components'}),
1637
- 'components/AcmeWidget.doc.mjs': componentDoc('AcmeWidget'),
1638
- },
1639
- {name: '@acme/kit'},
1640
- );
1641
-
1642
- expect(
1643
- (await issuesOf(dir)).map(issue => [issue.code, issue.severity]),
1644
- ).toEqual([['invalid_component', 'error']]);
1645
- const issues = await listedOf(dir);
1646
- expect(issues.map(issue => issue.code)).toEqual(['invalid_package_json']);
1647
- expect(issues[0].message).toBe(
1648
- 'package.json has no "version", so npm cannot pack or publish the package. Fix: add "version": "0.1.0" to package.json.',
1649
- );
1650
- });
1651
-
1652
- it('asks no version of a private package', async () => {
1653
- const dir = writePackage(
1654
- {[MANIFEST]: manifest({docs: './docs'}), 'docs/a.doc.mjs': topic('a')},
1655
- {name: '@acme/kit', private: true},
1656
- );
1657
-
1658
- expect(await allOf(dir)).toEqual([]);
1659
- });
1660
- });
1661
-
1662
- describe('the manifest', () => {
1663
- it('asks about a key one letter from a known one before blaming the CLI version', async () => {
1664
- const dir = writePackage({
1665
- [MANIFEST]: manifest({component: './components'}),
1666
- });
1667
-
1668
- const message = only(await issuesOf(dir), 'unknown_manifest_key');
1669
- expect(message).toBe(
1670
- 'This CLI does not know the manifest key "component", so it is ignored. Did you mean `components`? Fix: rename "component" to "components" in astryx.integration.mjs. If it is a key from a newer Astryx CLI instead, upgrading @astryxdesign/cli picks it up.',
1671
- );
1672
- });
1673
-
1674
- it('says to remove a near-miss key when the manifest already sets the key it suggests', async () => {
1675
- const dir = writePackage({
1676
- [MANIFEST]: manifest({components: './components', component: './x'}),
1677
- 'components/AcmeWidget.doc.mjs': componentDoc('AcmeWidget'),
1678
- 'components/AcmeWidget.tsx': componentSource('AcmeWidget'),
1679
- });
1680
-
1681
- expect(only(await issuesOf(dir), 'unknown_manifest_key')).toBe(
1682
- 'This CLI does not know the manifest key "component", so it is ignored. Did you mean `components`? Fix: remove "component" from astryx.integration.mjs; it already sets "components". If it is a key from a newer Astryx CLI instead, upgrading @astryxdesign/cli picks it up.',
1683
- );
1684
- const fixed = follow(dir, {
1685
- write: {[MANIFEST]: manifest({components: './components'})},
1686
- });
1687
- expect(await issuesOf(fixed)).toEqual([]);
1688
- });
1689
-
1690
- it.each([
1691
- [
1692
- 'alone, though the package name gives a provider ID',
1693
- {providerID: '@acme/kit', docs: './docs'},
1694
- 'Fix: rename "providerID" to "providerId" in astryx.integration.mjs.',
1695
- ],
1696
- [
1697
- 'beside the key it suggests',
1698
- {providerID: '@acme/kit', providerId: '@acme/kit', docs: './docs'},
1699
- 'Fix: remove "providerID" from astryx.integration.mjs; it already sets "providerId".',
1700
- ],
1701
- ])(
1702
- 'reads the keys the manifest declares: providerID %s',
1703
- async (_label, keys, fix) => {
1704
- const dir = writePackage({
1705
- [MANIFEST]: manifest(keys),
1706
- 'docs/a.doc.mjs': topic('a'),
1707
- });
1708
-
1709
- expect(only(await issuesOf(dir), 'unknown_manifest_key')).toContain(fix);
1710
- },
1711
- );
1712
-
1713
- it('keeps the newer-CLI explanation for a key that is no near miss', async () => {
1714
- const dir = writePackage({[MANIFEST]: manifest({playgrounds: './x'})});
1715
-
1716
- expect(only(await issuesOf(dir), 'unknown_manifest_key')).toContain(
1717
- 'published against a newer Astryx CLI',
1718
- );
1719
- });
1720
-
1721
- it('says a manifest has no default export, and what it exports', async () => {
1722
- const dir = writePackage({
1723
- [MANIFEST]: "export const integration = {docs: './docs'};\n",
1724
- });
1725
-
1726
- expect(only(await issuesOf(dir), 'invalid_manifest')).toBe(
1727
- "Integration manifest (astryx.integration.mjs) has no default export (it exports `integration`). Fix: export the manifest object as the default export: `export default {components: './components'}`, naming the roots the package has.",
1728
- );
1729
- });
1730
-
1731
- it('says a manifest is empty', async () => {
1732
- const dir = writePackage({[MANIFEST]: ''});
1733
-
1734
- expect(only(await issuesOf(dir), 'invalid_manifest')).toMatch(
1735
- /^Integration manifest \(astryx\.integration\.mjs\) is empty\. Fix: /u,
1736
- );
1737
- });
1738
- });
1739
-
1740
- describe('unreadable files and theme names', () => {
1741
- const asRoot = process.getuid?.() === 0;
1742
-
1743
- it.skipIf(asRoot)(
1744
- 'reports a contribution file it cannot read, which npm pack would fail on',
1745
- async () => {
1746
- const dir = writePackage({
1747
- [MANIFEST]: manifest({components: './components'}),
1748
- 'components/AcmeWidget.doc.mjs': componentDoc('AcmeWidget'),
1749
- 'components/AcmeWidget.tsx': componentSource('AcmeWidget'),
1750
- });
1751
- const file = path.join(dir, 'components', 'AcmeWidget.tsx');
1752
- fs.chmodSync(file, 0);
1753
- try {
1754
- expect(await issuesOf(dir)).toEqual([]);
1755
- const message = only(await listedOf(dir), 'unreadable_file');
1756
- expect(message).toBe(
1757
- 'Could not read "components/AcmeWidget.tsx" (EACCES), so Astryx cannot check it and npm pack fails on it. Fix: make it readable (chmod a+r components/AcmeWidget.tsx), or delete it if it does not belong in the package.',
1758
- );
1759
- } finally {
1760
- fs.chmodSync(file, 0o644);
1761
- }
1762
- expect(await allOf(dir)).toEqual([]);
1763
- },
1764
- );
1765
-
1766
- it.skipIf(asRoot)(
1767
- 'ignores an unreadable file no reader and no pack reads, such as .DS_Store',
1768
- async () => {
1769
- const dir = writePackage({
1770
- [MANIFEST]: manifest({components: './components'}),
1771
- 'components/AcmeWidget.doc.mjs': componentDoc('AcmeWidget'),
1772
- 'components/AcmeWidget.tsx': componentSource('AcmeWidget'),
1773
- 'components/.DS_Store': 'x',
1774
- 'components/notes.txt': 'x',
1775
- });
1776
- const files = ['.DS_Store', 'notes.txt'].map(name =>
1777
- path.join(dir, 'components', name),
1778
- );
1779
- for (const file of files) fs.chmodSync(file, 0);
1780
- try {
1781
- expect(await allOf(dir)).toEqual([]);
1782
- } finally {
1783
- for (const file of files) fs.chmodSync(file, 0o644);
1784
- }
1785
- },
1786
- );
1787
-
1788
- const themeDoc = `${THEME_TYPE}export default {type: 'theme', name: 'ocean', displayName: 'Ocean', description: 'A theme.', maintained: true};\n`;
1789
- /** @param {string} name */
1790
- const themeSource = name =>
1791
- `import {defineTheme} from '@astryxdesign/core/theme';\nexport const oceanTheme = defineTheme({\n name: '${name}',\n});\n`;
1792
-
1793
- it('accepts a theme that names itself differently from its folder', async () => {
1794
- const dir = writePackage({
1795
- [MANIFEST]: manifest({themes: './themes'}),
1796
- 'themes/ocean/oceanTheme.doc.mjs': themeDoc,
1797
- 'themes/ocean/oceanTheme.ts': themeSource('deep-sea'),
1798
- });
1799
-
1800
- expect(
1801
- (await issuesOf(dir)).filter(issue => issue.code === 'invalid_theme'),
1802
- ).toEqual([]);
1803
- });
1804
-
1805
- it('leaves a theme name it can only know by building alone', async () => {
1806
- const dir = writePackage({
1807
- [MANIFEST]: manifest({themes: './themes'}),
1808
- 'themes/ocean/oceanTheme.doc.mjs': themeDoc,
1809
- 'themes/ocean/oceanTheme.ts':
1810
- "import {defineTheme} from '@astryxdesign/core/theme';\nconst name = 'sea';\nexport const oceanTheme = defineTheme({name});\n",
1811
- });
1812
-
1813
- expect(
1814
- (await issuesOf(dir)).filter(issue => issue.code === 'invalid_theme'),
1815
- ).toEqual([]);
1816
- });
1817
- });
1818
-
1819
- describe('layout findings 0.7.2 did not fail on', () => {
1820
- it('never fails --strict on a note: notes count nowhere', () => {
1821
- /** @type {any} */
1822
- const response = {
1823
- type: 'integration.validate',
1824
- data: {
1825
- validated: true,
1826
- name: '@acme/kit',
1827
- version: '1.0.0',
1828
- issues: [],
1829
- notes: [
1830
- {code: 'duplicate_component_doc', message: 'Two docs. Fix: one.'},
1831
- ],
1832
- },
1833
- };
1834
- expect(strictIssues('validate', response)).toEqual({
1835
- warnings: [],
1836
- skipped: [],
1837
- });
1838
- expect(summarizeCheck(response)).toEqual({
1839
- errors: 0,
1840
- warnings: 0,
1841
- skipped: [],
1842
- failed: false,
1843
- });
1844
- });
1845
-
1846
- const asRoot = process.getuid?.() === 0;
1847
-
1848
- /** @type {Array<[string, () => string]>} */
1849
- const layouts = [
1850
- [
1851
- 'two docs for one component',
1852
- () =>
1853
- writePackage({
1854
- [MANIFEST]: manifest({components: './components'}),
1855
- 'components/AcmeWidget.doc.mjs': componentDoc('AcmeWidget'),
1856
- 'components/AcmeWidget.doc.js': componentDoc('AcmeWidget'),
1857
- 'components/AcmeWidget.tsx': componentSource('AcmeWidget'),
1858
- }),
1859
- ],
1860
- [
1861
- 'a root reached through a symlink',
1862
- () => {
1863
- const dir = writePackage({
1864
- [MANIFEST]: manifest({components: './components'}),
1865
- 'real-components/AcmeWidget.doc.mjs': componentDoc('AcmeWidget'),
1866
- 'real-components/AcmeWidget.tsx': componentSource('AcmeWidget'),
1867
- });
1868
- fs.symlinkSync('real-components', path.join(dir, 'components'));
1869
- return dir;
1870
- },
1871
- ],
1872
- [
1873
- 'a package.json without a version',
1874
- () =>
1875
- writePackage(
1876
- {
1877
- [MANIFEST]: manifest({docs: './docs'}),
1878
- 'docs/a.doc.mjs': topic('a'),
1879
- },
1880
- {name: '@acme/kit'},
1881
- ),
1882
- ],
1883
- [
1884
- 'a package.json without a name',
1885
- () =>
1886
- writePackage(
1887
- {
1888
- [MANIFEST]: manifest({docs: './docs'}),
1889
- 'docs/a.doc.mjs': topic('a'),
1890
- },
1891
- {version: '1.0.0'},
1892
- ),
1893
- ],
1894
- ...(asRoot
1895
- ? []
1896
- : /** @type {Array<[string, () => string]>} */ ([
1897
- [
1898
- 'a contribution file it cannot read',
1899
- () => {
1900
- const dir = writePackage({
1901
- [MANIFEST]: manifest({components: './components'}),
1902
- 'components/AcmeWidget.doc.mjs': componentDoc('AcmeWidget'),
1903
- 'components/AcmeWidget.tsx': componentSource('AcmeWidget'),
1904
- });
1905
- fs.chmodSync(path.join(dir, 'components', 'AcmeWidget.tsx'), 0);
1906
- return dir;
1907
- },
1908
- ],
1909
- ])),
1910
- ];
1911
-
1912
- it.each(layouts)(
1913
- 'lists %s as a note and passes integration check --strict',
1914
- async (_label, make) => {
1915
- const dir = make();
1916
- try {
1917
- const result = await integrationCheck({cwd: dir, strict: true});
1918
- expect(result.data.failures).toEqual([]);
1919
- expect(result.data.failed).toBe(false);
1920
- const validate = /** @type {any} */ (
1921
- result.data.checks[0].response.data
1922
- );
1923
- expect(others(validate.notes).length).toBeGreaterThan(0);
1924
- for (const note of others(validate.notes)) {
1925
- // Listed now, a warning from the next minor release: `next`.
1926
- expect(Object.keys(note).sort()).toEqual(['code', 'message', 'next']);
1927
- expect(note.next).toBe(true);
1928
- expect(note.message).toContain('Fix: ');
1929
- }
1930
- } finally {
1931
- const file = path.join(dir, 'components', 'AcmeWidget.tsx');
1932
- if (fs.existsSync(file)) fs.chmodSync(file, 0o644);
1933
- }
1934
- },
1935
- );
1936
-
1937
- it('prints the notes and counts none of them', () => {
1938
- const dir = writePackage({
1939
- [MANIFEST]: manifest({components: './components'}),
1940
- 'components/AcmeWidget.doc.mjs': componentDoc('AcmeWidget'),
1941
- 'components/AcmeWidget.doc.js': componentDoc('AcmeWidget'),
1942
- 'components/AcmeWidget.tsx': componentSource('AcmeWidget'),
1943
- });
1944
-
1945
- const run = spawnSync(
1946
- process.execPath,
1947
- [CLI, 'doctor', 'integration', 'validate'],
1948
- {cwd: dir, encoding: 'utf-8', timeout: 60_000},
1949
- );
1950
- expect(run.status, run.stderr).toBe(0);
1951
- expect(run.stdout).toContain(
1952
- 'note (duplicate_component_doc): [next minor] Component "AcmeWidget" has 2 docs:',
1953
- );
1954
- expect(run.stdout).toContain('Summary: 0 errors, 0 warnings');
1955
- });
1956
- });
1957
-
1958
- describe('name findings listed until the next minor release', () => {
1959
- /** @param {string} extra */
1960
- const block = extra =>
1961
- `export default {type: 'block', name: 'Account card', displayName: 'Account card', aspectRatio: 1,${extra}};\n`;
1962
- const docLayout = () =>
1963
- writeNamed({
1964
- [MANIFEST]: manifest({components: './components'}),
1965
- 'components/AcmeWidget.doc.mjs': namedDoc('AcmeWidget', 'AcmeWidgets'),
1966
- 'components/AcmeWidget.tsx': componentSource('AcmeWidget'),
1967
- });
1968
- const blockLayout = () =>
1969
- writePackage({
1970
- [MANIFEST]: manifest({templates: './templates'}),
1971
- 'templates/account-card.doc.mjs': block(" componentsUsed: ['AcmeGizmo']"),
1972
- 'templates/account-card.tsx': templateSource,
1973
- });
1974
-
1975
- it.each([
1976
- ['doc_name_mismatch', docLayout, 'docNames'],
1977
- ['unknown_block_component', blockLayout, 'blockComponents'],
1978
- ])(
1979
- 'lists %s as a note beside the issues, and integration check --strict passes',
1980
- async (code, make, report) => {
1981
- const dir = make();
1982
- const {data} = await validateIntegration(undefined, {cwd: dir});
1983
- expect(data.issues).toEqual([]);
1984
- expect(/** @type {any} */ (data)[report].findings).toEqual([]);
1985
- expect(others(data.notes).map(note => note.code)).toEqual([code]);
1986
- expect(others(data.notes)[0].message).toContain('Fix: ');
1987
-
1988
- const result = await integrationCheck({cwd: dir, strict: true});
1989
- expect(result.data.failures).toEqual([]);
1990
- expect(result.data.failed).toBe(false);
1991
- },
1992
- );
1993
-
1994
- it('prints the name notes and counts none', () => {
1995
- const dir = blockLayout();
1996
- const run = spawnSync(
1997
- process.execPath,
1998
- [CLI, 'doctor', 'integration', 'validate'],
1999
- {cwd: dir, encoding: 'utf-8', timeout: 60_000},
2000
- );
2001
- expect(run.status, run.stderr).toBe(0);
2002
- expect(run.stdout).toContain(
2003
- 'note (unknown_block_component): [next minor] Template "account-card" names "AcmeGizmo" in componentsUsed',
2004
- );
2005
- expect(run.stdout).toContain('Summary: 0 errors, 0 warnings');
2006
- });
2007
- });