@astryxdesign/cli 0.7.6-canary.962dffe → 0.7.6-canary.9728cd7

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