@astryxdesign/cli 0.7.6-canary.0d71e8d → 0.7.6-canary.0dbd1bd

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 (500) hide show
  1. package/assets/docs/motion.doc.mjs +1 -1
  2. package/foundation/discovery/package-tsconfig.mjs +34 -0
  3. package/package.json +24 -10
  4. package/api/api-docs-parse.test.mjs +0 -47
  5. package/api/blog/_adapter.test.mjs +0 -183
  6. package/api/blog/blog.test.mjs +0 -144
  7. package/api/blog/detail/detail.test.mjs +0 -118
  8. package/api/blog/list/list.test.mjs +0 -81
  9. package/api/build/blocks/blocks.test.mjs +0 -238
  10. package/api/build/build.test.mjs +0 -569
  11. package/api/build/kit/answer.test.mjs +0 -108
  12. package/api/build/kit/rank.test.mjs +0 -380
  13. package/api/build/kit/weights.test.mjs +0 -286
  14. package/api/build/tree.test.mjs +0 -185
  15. package/api/component/component-replacement.test.mjs +0 -616
  16. package/api/component/component.test.mjs +0 -532
  17. package/api/component/doc-links.test.mjs +0 -419
  18. package/api/component/integration-export-name.test.mjs +0 -644
  19. package/api/component/integration-import-agreement.test.mjs +0 -474
  20. package/api/discover/_adapter.test.mjs +0 -839
  21. package/api/discover/_catalog-view.test.mjs +0 -129
  22. package/api/discover/_package-scanner.test.mjs +0 -117
  23. package/api/discover/detail/detail.test.mjs +0 -145
  24. package/api/discover/detail/doc/doc.test.mjs +0 -93
  25. package/api/discover/detail/item/item.test.mjs +0 -75
  26. package/api/discover/discover.test.mjs +0 -100
  27. package/api/discover/list/list.test.mjs +0 -107
  28. package/api/discover/search/search.test.mjs +0 -319
  29. package/api/docs/compiled-topics.test.mjs +0 -94
  30. package/api/docs/detail/section/section.test.mjs +0 -92
  31. package/api/docs/docOverlays.test.mjs +0 -189
  32. package/api/docs/docs-homes.test.mjs +0 -127
  33. package/api/docs/docs.depth.test.mjs +0 -134
  34. package/api/docs/docs.test.mjs +0 -315
  35. package/api/docs/guide-route-targets.test.mjs +0 -1002
  36. package/api/docs/index/index.test.mjs +0 -67
  37. package/api/docs/integration-tree.test.mjs +0 -616
  38. package/api/docs/integrationDocs.test.mjs +0 -546
  39. package/api/docs/namespace-section.test.mjs +0 -260
  40. package/api/docs/react-version-sync.test.mjs +0 -79
  41. package/api/docs/reference-blocks.test.mjs +0 -404
  42. package/api/docs/token-tables.test.mjs +0 -93
  43. package/api/doctor/built-checks.test.mjs +0 -537
  44. package/api/doctor/doctor.test.mjs +0 -1651
  45. package/api/doctor/icon-sets.test.mjs +0 -111
  46. package/api/doctor/release-checks.test.mjs +0 -156
  47. package/api/doctor/theme-checks.test.mjs +0 -884
  48. package/api/gap-report/gap-report.test.mjs +0 -1549
  49. package/api/hook/detail/detail.test.mjs +0 -53
  50. package/api/hook/detail/params/params.test.mjs +0 -39
  51. package/api/hook/hook.test.mjs +0 -75
  52. package/api/icon/all-or-nothing.test.mjs +0 -283
  53. package/api/icon/error-codes.test.mjs +0 -341
  54. package/api/icon/experimental-markers.test.mjs +0 -93
  55. package/api/icon/icon.test.mjs +0 -506
  56. package/api/icon/new-definition/new-definition.undo.test.mjs +0 -97
  57. package/api/icon/new-set/new-set.test.mjs +0 -398
  58. package/api/icon/option-pairs.test.mjs +0 -368
  59. package/api/init/init.test.mjs +0 -319
  60. package/api/init/remove/remove.test.mjs +0 -124
  61. package/api/init/user/user.test.mjs +0 -232
  62. package/api/integration/add-contribution.component-names.test.mjs +0 -186
  63. package/api/integration/add-contribution.test.mjs +0 -990
  64. package/api/integration/add-helpers.test.mjs +0 -161
  65. package/api/integration/add-theme.test.mjs +0 -676
  66. package/api/integration/authoring-checks.test.mjs +0 -1691
  67. package/api/integration/check/check.test.mjs +0 -538
  68. package/api/integration/doc-stability.test.mjs +0 -216
  69. package/api/integration/example-checks.no-npm.test.mjs +0 -140
  70. package/api/integration/example-checks.test.mjs +0 -776
  71. package/api/integration/integration-block-exports.test.mjs +0 -248
  72. package/api/integration/pack-check.component-replaces.test.mjs +0 -126
  73. package/api/integration/pack-check.lifecycle-output.test.mjs +0 -149
  74. package/api/integration/pack-check.test.mjs +0 -2512
  75. package/api/integration/public-api.test.mjs +0 -21
  76. package/api/integration/template-conflict-compatibility.test.mjs +0 -73
  77. package/api/integration/validate-installed-icon-sets.test.mjs +0 -67
  78. package/api/integration/validate-integration-case-disk.test.mjs +0 -123
  79. package/api/integration/validate-integration-fixes.test.mjs +0 -1457
  80. package/api/integration/validate-integration-gaps.test.mjs +0 -2007
  81. package/api/integration/validate-integration.test.mjs +0 -835
  82. package/api/integration/validate-unread-theme-folders.test.mjs +0 -111
  83. package/api/json/envelope-types.test.mjs +0 -76
  84. package/api/json/parse.test.mjs +0 -76
  85. package/api/render/render.test.mjs +0 -1155
  86. package/api/search/_adapter.test.mjs +0 -192
  87. package/api/search/_doc-searcher.test.mjs +0 -36
  88. package/api/search/_entries.test.mjs +0 -48
  89. package/api/search/_main-searcher.test.mjs +0 -106
  90. package/api/search/_order.test.mjs +0 -72
  91. package/api/search/_template-searcher.test.mjs +0 -40
  92. package/api/search/search-return-type.test.mjs +0 -54
  93. package/api/search/search.domain-priority.test.mjs +0 -351
  94. package/api/search/search.family-members.test.mjs +0 -124
  95. package/api/search/search.family-word.test.mjs +0 -146
  96. package/api/search/search.integration-block.test.mjs +0 -100
  97. package/api/search/search.integration-check.test.mjs +0 -24
  98. package/api/search/search.test.mjs +0 -1007
  99. package/api/search/search.tie-order.test.mjs +0 -39
  100. package/api/search/tree.test.mjs +0 -66
  101. package/api/swizzle/_github.test.mjs +0 -53
  102. package/api/swizzle/copy/copy.test.mjs +0 -60
  103. package/api/swizzle/swizzle.test.mjs +0 -157
  104. package/api/template/cdn/cdn.test.mjs +0 -108
  105. package/api/template/checkout-wizard.test.mjs +0 -87
  106. package/api/template/copy/copy.receipt.test.mjs +0 -77
  107. package/api/template/copy/copy.test.mjs +0 -77
  108. package/api/template/data-token-fallbacks.test.mjs +0 -85
  109. package/api/template/discover-integration-templates.test.mjs +0 -56
  110. package/api/template/form-wizard-dialog.test.mjs +0 -47
  111. package/api/template/inline-wizard-template.test.mjs +0 -24
  112. package/api/template/list/list.test.mjs +0 -52
  113. package/api/template/show/show.test.mjs +0 -76
  114. package/api/template/table-filter-view-tabs.test.mjs +0 -45
  115. package/api/template/table-floating-bulk-actions.test.mjs +0 -66
  116. package/api/template/template-integration.test.mjs +0 -1274
  117. package/api/template/template-suffix.test.mjs +0 -286
  118. package/api/template/template.test.mjs +0 -222
  119. package/api/template/tokenizer-showcase.test.mjs +0 -47
  120. package/api/template/unknown-name.test.mjs +0 -63
  121. package/api/theme/add/add.test.mjs +0 -363
  122. package/api/theme/add/add.types.test.mjs +0 -150
  123. package/api/theme/build/build.adaptation-core-compat.test.mjs +0 -394
  124. package/api/theme/build/build.adaptation-enrollment.test.mjs +0 -219
  125. package/api/theme/build/build.core-on-demand.test.mjs +0 -113
  126. package/api/theme/build/build.family.test.mjs +0 -503
  127. package/api/theme/build/build.font-warning.test.mjs +0 -170
  128. package/api/theme/build/build.heading-core-compat.test.mjs +0 -68
  129. package/api/theme/build/build.icon-entry-variants.test.mjs +0 -134
  130. package/api/theme/build/build.icon-function-entries.test.mjs +0 -499
  131. package/api/theme/build/build.icon-lineage.test.mjs +0 -117
  132. package/api/theme/build/build.icon-preservation.test.mjs +0 -639
  133. package/api/theme/build/build.icon-variants.test.mjs +0 -105
  134. package/api/theme/build/build.icons-specifier.test.mjs +0 -149
  135. package/api/theme/build/build.packed-old-core.test.mjs +0 -1512
  136. package/api/theme/build/build.project-core.test.mjs +0 -220
  137. package/api/theme/build/build.public-component-vars.test.mjs +0 -151
  138. package/api/theme/build/build.receipt-doc.test.mjs +0 -111
  139. package/api/theme/build/build.rollback.test.mjs +0 -148
  140. package/api/theme/build/build.test.mjs +0 -1258
  141. package/api/theme/build/font-warning.test.mjs +0 -268
  142. package/api/theme/eject/eject.binary.test.mjs +0 -90
  143. package/api/theme/eject/eject.copy-compat.test.mjs +0 -168
  144. package/api/theme/eject/eject.rollback.test.mjs +0 -158
  145. package/api/theme/eject/eject.staging.test.mjs +0 -83
  146. package/api/theme/eject/eject.test.mjs +0 -160
  147. package/api/theme/integration-themes.test.mjs +0 -218
  148. package/api/theme/list/list.test.mjs +0 -271
  149. package/api/theme/palette/generate/generate.test.mjs +0 -445
  150. package/api/theme/palette/generate/generator.test.mjs +0 -385
  151. package/api/theme/palette/generate/preview.test.mjs +0 -55
  152. package/api/theme/remove/remove.test.mjs +0 -94
  153. package/api/theme/targets/targets.test.mjs +0 -91
  154. package/api/theme/template/template.test.mjs +0 -102
  155. package/api/theme/use/use.test.mjs +0 -98
  156. package/api/upgrade/list/list.test.mjs +0 -73
  157. package/api/upgrade/project-context.test.mjs +0 -272
  158. package/api/upgrade/provider-agreement.test.mjs +0 -152
  159. package/api/upgrade/registry/registry.test.mjs +0 -911
  160. package/api/upgrade/run/authoring-codemod-reachable.test.mjs +0 -99
  161. package/api/upgrade/run/cli-behind-core.test.mjs +0 -438
  162. package/api/upgrade/run/failure-receipt.test.mjs +0 -212
  163. package/api/upgrade/run/files-changed.test.mjs +0 -111
  164. package/api/upgrade/run/outcomes.test.mjs +0 -646
  165. package/api/upgrade/run/run.test.mjs +0 -511
  166. package/api/upgrade/upgrade.test.mjs +0 -594
  167. package/assets/codemods/__tests__/registry.test.mjs +0 -77
  168. package/assets/codemods/__tests__/rename-imperative-ref-to-handleRef.test.mjs +0 -65
  169. package/assets/codemods/__tests__/rename-isStreaming-to-isStopShown.test.mjs +0 -58
  170. package/assets/codemods/__tests__/rename-section-wash-to-muted.test.mjs +0 -103
  171. package/assets/codemods/__tests__/runner.symlinks.test.mjs +0 -205
  172. package/assets/codemods/__tests__/runner.test.mjs +0 -559
  173. package/assets/codemods/__tests__/runner.unparseable.test.mjs +0 -457
  174. package/assets/codemods/__tests__/toolbar-density-to-size.test.mjs +0 -69
  175. package/assets/codemods/__tests__/validation.test.mjs +0 -108
  176. package/assets/codemods/file-count.test.mjs +0 -163
  177. package/assets/codemods/integration-discovery.test.mjs +0 -360
  178. package/assets/codemods/integration-runner.protection.test.mjs +0 -206
  179. package/assets/codemods/outcome.test.mjs +0 -40
  180. package/assets/codemods/term-log.test.mjs +0 -80
  181. package/assets/codemods/transform-prop.test.mjs +0 -130
  182. package/assets/codemods/transforms/v0.0.10/__tests__/remove-size-props.test.mjs +0 -144
  183. package/assets/codemods/transforms/v0.0.12/__tests__/add-is-icon-only.test.mjs +0 -193
  184. package/assets/codemods/transforms/v0.0.13/__tests__/icon-name-deprecations.test.mjs +0 -81
  185. package/assets/codemods/transforms/v0.0.13/__tests__/rename-attachments-to-drawer.test.mjs +0 -126
  186. package/assets/codemods/transforms/v0.0.14/__tests__/rename-action-props.test.mjs +0 -129
  187. package/assets/codemods/transforms/v0.0.14/__tests__/rename-status-variants.test.mjs +0 -126
  188. package/assets/codemods/transforms/v0.0.15/__tests__/migrate-item-children-to-endcontent.test.mjs +0 -95
  189. package/assets/codemods/transforms/v0.0.15/__tests__/migrate-selector-children-to-render-option.test.mjs +0 -109
  190. package/assets/codemods/transforms/v0.0.15/__tests__/migrate-theme-selectors-to-data-attrs.test.mjs +0 -44
  191. package/assets/codemods/transforms/v0.0.15/__tests__/rename-date-picker-to-input.test.mjs +0 -110
  192. package/assets/codemods/transforms/v0.0.15/__tests__/rename-stack-element-to-as.test.mjs +0 -71
  193. package/assets/codemods/transforms/v0.0.2/__tests__/migrate-badge-dot-to-statusdot.test.mjs +0 -137
  194. package/assets/codemods/transforms/v0.0.2/__tests__/migrate-gap-to-numeric.test.mjs +0 -161
  195. package/assets/codemods/transforms/v0.0.2/__tests__/migrate-isFullBleed-to-padding.test.mjs +0 -137
  196. package/assets/codemods/transforms/v0.0.2/__tests__/migrate-useXDSIcon-to-getIcon.test.mjs +0 -110
  197. package/assets/codemods/transforms/v0.0.2/__tests__/rename-banner-endButton-to-endContent.test.mjs +0 -61
  198. package/assets/codemods/transforms/v0.0.2/__tests__/rename-form-tooltip-startIcon.test.mjs +0 -130
  199. package/assets/codemods/transforms/v0.0.2/__tests__/rename-isShown-to-isOpen.test.mjs +0 -89
  200. package/assets/codemods/transforms/v0.0.2/__tests__/rename-selector-items-to-options.test.mjs +0 -74
  201. package/assets/codemods/transforms/v0.0.2/__tests__/rename-sidenav-header-to-heading.test.mjs +0 -140
  202. package/assets/codemods/transforms/v0.0.2/__tests__/rename-topnav-title-to-heading.test.mjs +0 -116
  203. package/assets/codemods/transforms/v0.0.2/__tests__/unify-uncontrolled-to-defaultX.test.mjs +0 -79
  204. package/assets/codemods/transforms/v0.0.2/__tests__/unify-visibility-to-onOpenChange.test.mjs +0 -130
  205. package/assets/codemods/transforms/v0.0.6/__tests__/migrate-badge-children-to-label.test.mjs +0 -46
  206. package/assets/codemods/transforms/v0.0.6/__tests__/migrate-collapse-to-collapsible.test.mjs +0 -72
  207. package/assets/codemods/transforms/v0.0.6/__tests__/migrate-radius-tokens.test.mjs +0 -98
  208. package/assets/codemods/transforms/v0.0.6/__tests__/migrate-shadow-tokens.test.mjs +0 -117
  209. package/assets/codemods/transforms/v0.0.6/__tests__/migrate-skeleton-radius.test.mjs +0 -75
  210. package/assets/codemods/transforms/v0.0.6/__tests__/migrate-token-names.test.mjs +0 -275
  211. package/assets/codemods/transforms/v0.0.7/__tests__/rename-banner-variant-to-container.test.mjs +0 -85
  212. package/assets/codemods/transforms/v0.0.8/__tests__/migrate-token-renames.test.mjs +0 -327
  213. package/assets/codemods/transforms/v0.0.8/__tests__/rename-endslot-to-endcontent.test.mjs +0 -98
  214. package/assets/codemods/transforms/v0.1.0/__tests__/drop-xds-prefix-imports.test.mjs +0 -460
  215. package/assets/codemods/transforms/v0.1.0/__tests__/migrate-xds-css-surfaces.test.mjs +0 -103
  216. package/assets/codemods/transforms/v0.1.0/__tests__/migrate-xds-declare-module.test.mjs +0 -61
  217. package/assets/codemods/transforms/v0.1.0/__tests__/migrate-xds-module-specifiers.test.mjs +0 -123
  218. package/assets/codemods/transforms/v0.1.0/__tests__/v0.1.0-ordering.test.mjs +0 -104
  219. package/assets/codemods/transforms/v0.1.2/__tests__/rename-text-color-active-to-accent.test.mjs +0 -120
  220. package/assets/codemods/transforms/v0.1.3/__tests__/migrate-layout-components-to-experimental.test.mjs +0 -574
  221. package/assets/codemods/transforms/v0.1.5/__tests__/rename-switch-label-spacing-default-to-hug.test.mjs +0 -93
  222. package/assets/codemods/transforms/v0.1.7/__tests__/migrate-table-tableprops-to-direct-props.test.mjs +0 -120
  223. package/assets/codemods/transforms/v0.1.7/__tests__/rename-table-renderprops-styles-to-xstyle.test.mjs +0 -112
  224. package/assets/codemods/transforms/v0.1.8/__tests__/rename-avatar-size-scale.test.mjs +0 -129
  225. package/assets/codemods/transforms/v0.2.0/__tests__/remove-tablist-orientation.test.mjs +0 -81
  226. package/assets/codemods/transforms/v0.2.1/__tests__/migrate-dialog-position-to-logical.test.mjs +0 -119
  227. package/assets/codemods/transforms/v0.3.0/__tests__/authoring-migration.e2e.test.mjs +0 -296
  228. package/assets/codemods/transforms/v0.3.0/__tests__/authoring-migration.tsc.test.mjs +0 -139
  229. package/assets/codemods/transforms/v0.3.0/__tests__/migrate-authoring-imports.test.mjs +0 -80
  230. package/assets/codemods/transforms/v0.3.0/__tests__/migrate-grid-minchildwidth-to-columns.test.mjs +0 -82
  231. package/assets/codemods/transforms/v0.3.0/__tests__/next-codemods.test.mjs +0 -64
  232. package/assets/codemods/transforms/v0.3.0/__tests__/rename-authoring-doctypes.test.mjs +0 -94
  233. package/assets/codemods/transforms/v0.3.0/__tests__/rename-radiogroup-arialabel-to-label.test.mjs +0 -86
  234. package/assets/codemods/transforms/v0.3.0/__tests__/unwrap-authoring-factories.test.mjs +0 -170
  235. package/assets/codemods/transforms/v0.4.0/__tests__/migrate-table-rowexpansion-to-tree.test.mjs +0 -201
  236. package/assets/codemods/transforms/v0.4.0/__tests__/next-codemods.test.mjs +0 -154
  237. package/assets/codemods/transforms/v0.5.0/__tests__/next-codemods.test.mjs +0 -127
  238. package/assets/codemods/transforms/v0.6.0/__tests__/migrate-astryx-theme-selectors-to-data-attrs.test.mjs +0 -398
  239. package/assets/codemods/transforms/v0.6.0/__tests__/next-codemods.test.mjs +0 -270
  240. package/assets/codemods/transforms/v0.6.4/__tests__/migrate-native-picker-to-presentation.test.mjs +0 -63
  241. package/assets/codemods/transforms/v0.6.4/__tests__/migrate-theme-catalog-to-descriptors.test.mjs +0 -220
  242. package/assets/codemods/transforms/v0.6.7/__tests__/migrate-copied-themes-to-descriptors.test.mjs +0 -129
  243. package/assets/codemods/transforms/v0.7.0/__tests__/migrate-deprecated-theme-surface.test.mjs +0 -523
  244. package/assets/codemods/transforms/v0.7.0/__tests__/migrate-field-input-styling.test.mjs +0 -108
  245. package/assets/codemods/transforms/v0.7.0/__tests__/preserve-bottom-sheet-content-padding.test.mjs +0 -178
  246. package/assets/codemods/transforms/v0.7.0/__tests__/rename-empty-search-results-text.test.mjs +0 -202
  247. package/assets/codemods/transforms/v0.7.0/__tests__/validate-data-token-ownership.test.mjs +0 -168
  248. package/assets/codemods/transforms/v0.7.2/__tests__/migrate-list-edge-compensation-to-edge.test.mjs +0 -120
  249. package/assets/codemods/transforms/v0.7.5/__tests__/migrate-codeblock-tokenizer-to-language.test.mjs +0 -130
  250. package/authoring/_shared/errors.test.mjs +0 -49
  251. package/authoring/codemod/parse.test.mjs +0 -99
  252. package/authoring/config/debug-composition.test.mjs +0 -92
  253. package/authoring/config/parse.test.mjs +0 -121
  254. package/authoring/debug/parse.test.mjs +0 -187
  255. package/authoring/discover/parse.test.mjs +0 -158
  256. package/authoring/doctypes/doc-stability-types.test.mjs +0 -91
  257. package/authoring/doctypes/doctypes-new.test.mjs +0 -162
  258. package/authoring/doctypes/icon-definition/parse.test.mjs +0 -78
  259. package/authoring/doctypes/icon-set/icon-names.test.mjs +0 -26
  260. package/authoring/doctypes/icon-set/parse.test.mjs +0 -179
  261. package/authoring/doctypes/load-contract.test.mjs +0 -246
  262. package/authoring/doctypes/namespace/parse.test.mjs +0 -163
  263. package/authoring/doctypes/parse.test.mjs +0 -422
  264. package/authoring/doctypes/template/parse.test.mjs +0 -198
  265. package/authoring/gap-report/parse.test.mjs +0 -172
  266. package/authoring/integration/parse.test.mjs +0 -184
  267. package/authoring/shadcn/receipt.test.mjs +0 -187
  268. package/authoring/shadcn/source-variants.test.mjs +0 -120
  269. package/clients/cli/__tests__/cliManifest.test.ts +0 -37
  270. package/clients/cli/cli-command.test.mjs +0 -166
  271. package/clients/cli/cli-exit-codes.test.mjs +0 -163
  272. package/clients/cli/command-load-failure.test.mjs +0 -83
  273. package/clients/cli/command-result-coverage.test.mjs +0 -136
  274. package/clients/cli/commands/blog.test.mjs +0 -138
  275. package/clients/cli/commands/build-theme.adaptations.test.mjs +0 -773
  276. package/clients/cli/commands/build-theme.ascii-output.test.mjs +0 -198
  277. package/clients/cli/commands/build-theme.batch-report.test.mjs +0 -349
  278. package/clients/cli/commands/build-theme.color-scheme.test.mjs +0 -136
  279. package/clients/cli/commands/build-theme.data-tokens.test.mjs +0 -92
  280. package/clients/cli/commands/build-theme.flag-docs.test.mjs +0 -110
  281. package/clients/cli/commands/build-theme.font-warning.test.mjs +0 -170
  282. package/clients/cli/commands/build-theme.icons-specifier.test.mjs +0 -350
  283. package/clients/cli/commands/build-theme.import-path.test.mjs +0 -103
  284. package/clients/cli/commands/build-theme.multi.test.mjs +0 -148
  285. package/clients/cli/commands/build-theme.outside-project.test.mjs +0 -140
  286. package/clients/cli/commands/build-theme.path-safety.test.mjs +0 -398
  287. package/clients/cli/commands/build-theme.prose.test.mjs +0 -103
  288. package/clients/cli/commands/build-theme.registry.test.mjs +0 -160
  289. package/clients/cli/commands/build-theme.variants.test.mjs +0 -560
  290. package/clients/cli/commands/build-theme.watch.test.mjs +0 -320
  291. package/clients/cli/commands/build.error-codes.test.mjs +0 -50
  292. package/clients/cli/commands/build.exit-codes-doc.test.mjs +0 -54
  293. package/clients/cli/commands/build.playbook.test.mjs +0 -75
  294. package/clients/cli/commands/build.text-fields.test.mjs +0 -81
  295. package/clients/cli/commands/cli-postinstall.test.mjs +0 -90
  296. package/clients/cli/commands/component-batch.test.mjs +0 -341
  297. package/clients/cli/commands/component-ownership.test.mjs +0 -384
  298. package/clients/cli/commands/component-package.test.mjs +0 -169
  299. package/clients/cli/commands/component-replacement.text.test.mjs +0 -316
  300. package/clients/cli/commands/component-resolution.test.mjs +0 -204
  301. package/clients/cli/commands/component.test.mjs +0 -612
  302. package/clients/cli/commands/debug-result-summary.test.mjs +0 -214
  303. package/clients/cli/commands/detail-levels.test.mjs +0 -145
  304. package/clients/cli/commands/dialog-adaptive-template.test.mjs +0 -24
  305. package/clients/cli/commands/discover.broken-integration.test.mjs +0 -163
  306. package/clients/cli/commands/discover.components-flag.test.mjs +0 -97
  307. package/clients/cli/commands/discover.icon-sets.test.mjs +0 -133
  308. package/clients/cli/commands/discover.no-source.test.mjs +0 -490
  309. package/clients/cli/commands/discover.sources.test.mjs +0 -292
  310. package/clients/cli/commands/discover.text-projection.test.mjs +0 -103
  311. package/clients/cli/commands/docs.depth.test.mjs +0 -219
  312. package/clients/cli/commands/docs.test.mjs +0 -385
  313. package/clients/cli/commands/doctor-integration.package-json.test.mjs +0 -53
  314. package/clients/cli/commands/doctor-integration.test.mjs +0 -1483
  315. package/clients/cli/commands/doctor.test.mjs +0 -509
  316. package/clients/cli/commands/empty-argument.test.mjs +0 -16
  317. package/clients/cli/commands/external-showcase.test.mjs +0 -121
  318. package/clients/cli/commands/gap-report.test.mjs +0 -412
  319. package/clients/cli/commands/hook.text-projection.test.mjs +0 -45
  320. package/clients/cli/commands/icon-authoring.test.mjs +0 -2845
  321. package/clients/cli/commands/icon-options-wiring.test.mjs +0 -158
  322. package/clients/cli/commands/icon-sets-guide.test.mjs +0 -186
  323. package/clients/cli/commands/icon.test.mjs +0 -96
  324. package/clients/cli/commands/import-hint-correctness.test.mjs +0 -293
  325. package/clients/cli/commands/init.behavior.test.mjs +0 -434
  326. package/clients/cli/commands/init.flag-help.test.mjs +0 -151
  327. package/clients/cli/commands/init.next-steps.test.mjs +0 -41
  328. package/clients/cli/commands/integration-add.controls.test.mjs +0 -132
  329. package/clients/cli/commands/integration-authoring.test.mjs +0 -288
  330. package/clients/cli/commands/integration-check.test.mjs +0 -522
  331. package/clients/cli/commands/integration-real-world.test.mjs +0 -661
  332. package/clients/cli/commands/interactive-guard.test.mjs +0 -143
  333. package/clients/cli/commands/json-contract.test.mjs +0 -216
  334. package/clients/cli/commands/no-prompt-wording.test.mjs +0 -94
  335. package/clients/cli/commands/option-pair-refusals.test.mjs +0 -37
  336. package/clients/cli/commands/outside-project.test.mjs +0 -874
  337. package/clients/cli/commands/search.test.mjs +0 -514
  338. package/clients/cli/commands/setup-nudge.test.mjs +0 -280
  339. package/clients/cli/commands/silent-success-refusals.test.mjs +0 -15
  340. package/clients/cli/commands/swizzle.path-safety.test.mjs +0 -137
  341. package/clients/cli/commands/swizzle.routing.test.mjs +0 -342
  342. package/clients/cli/commands/template-cdn.behavior.test.mjs +0 -113
  343. package/clients/cli/commands/template.copy-receipt.test.mjs +0 -60
  344. package/clients/cli/commands/template.flag-help.test.mjs +0 -124
  345. package/clients/cli/commands/template.icons.test.mjs +0 -132
  346. package/clients/cli/commands/template.path-help.test.mjs +0 -40
  347. package/clients/cli/commands/template.path-safety.test.mjs +0 -82
  348. package/clients/cli/commands/template.show-media.test.mjs +0 -62
  349. package/clients/cli/commands/template.test.mjs +0 -62
  350. package/clients/cli/commands/text-json-parity.test.mjs +0 -850
  351. package/clients/cli/commands/theme-add-lifecycle.test.mjs +0 -228
  352. package/clients/cli/commands/theme-list.behavior.test.mjs +0 -51
  353. package/clients/cli/commands/theme-palette-generate.test.mjs +0 -154
  354. package/clients/cli/commands/theme-targets.behavior.test.mjs +0 -84
  355. package/clients/cli/commands/theme-template.behavior.test.mjs +0 -97
  356. package/clients/cli/commands/upgrade.ascii-output.test.mjs +0 -101
  357. package/clients/cli/commands/upgrade.config-ordering.test.mjs +0 -342
  358. package/clients/cli/commands/upgrade.file-protection.test.mjs +0 -404
  359. package/clients/cli/commands/upgrade.flag-help.test.mjs +0 -221
  360. package/clients/cli/commands/upgrade.hook-output.test.mjs +0 -89
  361. package/clients/cli/commands/upgrade.integration-policy.test.mjs +0 -581
  362. package/clients/cli/commands/upgrade.older-cli.test.mjs +0 -160
  363. package/clients/cli/commands/upgrade.outcomes.test.mjs +0 -350
  364. package/clients/cli/commands/upgrade.subfolder-path.test.mjs +0 -97
  365. package/clients/cli/commands/upgrade.test.mjs +0 -361
  366. package/clients/cli/commands/validate-nothing-exits-nonzero.test.mjs +0 -67
  367. package/clients/cli/commands/write-failure.test.mjs +0 -175
  368. package/clients/cli/e2e-smoke.test.mjs +0 -162
  369. package/clients/cli/error-envelope-code.test.mjs +0 -38
  370. package/clients/cli/formatters/index.test.mjs +0 -262
  371. package/clients/cli/latest-version-env.test.mjs +0 -50
  372. package/clients/cli/lib/cli-error.test.mjs +0 -206
  373. package/clients/cli/lib/component-format.test.mjs +0 -246
  374. package/clients/cli/lib/define-command.test.mjs +0 -103
  375. package/clients/cli/lib/doc-text-ascii.test.mjs +0 -85
  376. package/clients/cli/lib/exit-codes.test.mjs +0 -111
  377. package/clients/cli/lib/hook-format.test.mjs +0 -35
  378. package/clients/cli/lib/json-shim.test.mjs +0 -268
  379. package/clients/cli/lib/manifest.test.mjs +0 -346
  380. package/clients/cli/lib/parse-error-format.test.mjs +0 -81
  381. package/clients/cli/lib/resolve-theme.test.mjs +0 -543
  382. package/foundation/agent-docs/agent-docs.path-safety.test.mjs +0 -1550
  383. package/foundation/agent-docs/agent-docs.test.mjs +0 -1937
  384. package/foundation/agent-docs/app-theme-workflow.test.mjs +0 -16
  385. package/foundation/agent-docs/computer-agent-text.test.mjs +0 -699
  386. package/foundation/config/config-cache.test.mjs +0 -83
  387. package/foundation/config/config-writer.test.mjs +0 -84
  388. package/foundation/config/integration-debug.test.mjs +0 -218
  389. package/foundation/config/project-themes.test.mjs +0 -119
  390. package/foundation/config/project.test.mjs +0 -931
  391. package/foundation/config/theme-private-vars.test.mjs +0 -76
  392. package/foundation/config/theme-state.test.mjs +0 -182
  393. package/foundation/debug/debug-fields.test.mjs +0 -327
  394. package/foundation/debug/integration-handlers.test.mjs +0 -267
  395. package/foundation/debug/on-event.test.mjs +0 -643
  396. package/foundation/debug/privacy-contract.test.mjs +0 -195
  397. package/foundation/debug/redact.test.mjs +0 -534
  398. package/foundation/discovery/authoring-self-docs.test.mjs +0 -202
  399. package/foundation/discovery/authoring-surface.test.mjs +0 -392
  400. package/foundation/discovery/cli-self-docs.test.mjs +0 -396
  401. package/foundation/discovery/component-discovery.export-names.test.mjs +0 -832
  402. package/foundation/discovery/component-discovery.importpath.test.mjs +0 -59
  403. package/foundation/discovery/component-discovery.test.mjs +0 -336
  404. package/foundation/discovery/component-loader.test.mjs +0 -190
  405. package/foundation/discovery/component-replacement.test.mjs +0 -520
  406. package/foundation/discovery/componentDocOverlay.test.mjs +0 -159
  407. package/foundation/discovery/copied-passages.test.mjs +0 -124
  408. package/foundation/discovery/doc-consistency.test.mjs +0 -347
  409. package/foundation/discovery/doc-fluff.test.mjs +0 -142
  410. package/foundation/discovery/doc-types.test.mjs +0 -774
  411. package/foundation/discovery/docs-discovery.test.mjs +0 -707
  412. package/foundation/discovery/docs-section-key.test.mjs +0 -246
  413. package/foundation/discovery/hook-discovery.test.mjs +0 -216
  414. package/foundation/discovery/icon-set-checks.test.mjs +0 -1018
  415. package/foundation/discovery/icon-set-discovery.test.mjs +0 -320
  416. package/foundation/discovery/icon-set-writer.test.mjs +0 -26
  417. package/foundation/discovery/integration-doc-files.test.mjs +0 -275
  418. package/foundation/discovery/module-exports.test.mjs +0 -209
  419. package/foundation/discovery/package-tsconfig.test.mjs +0 -210
  420. package/foundation/discovery/prop-drift.test.mjs +0 -2337
  421. package/foundation/discovery/runner-commands.test.mjs +0 -131
  422. package/foundation/discovery/stray-pointers.test.mjs +0 -92
  423. package/foundation/discovery/template-adapter.fixture-refs.test.mjs +0 -284
  424. package/foundation/discovery/template-adapter.integration-isolation.test.mjs +0 -94
  425. package/foundation/discovery/template-adapter.test.mjs +0 -223
  426. package/foundation/discovery/template-conflict-release.test.mjs +0 -40
  427. package/foundation/discovery/template-icons.test.mjs +0 -560
  428. package/foundation/discovery/template-needs.test.mjs +0 -306
  429. package/foundation/discovery/theme-discovery.test.mjs +0 -775
  430. package/foundation/discovery/theme-imports.test.mjs +0 -173
  431. package/foundation/discovery/theming-targets.test.mjs +0 -328
  432. package/foundation/discovery/type-match.test.mjs +0 -169
  433. package/foundation/discovery/type-text.test.mjs +0 -196
  434. package/foundation/discovery/unresolved-references.test.mjs +0 -567
  435. package/foundation/doc-compiler/bundle.test.mjs +0 -266
  436. package/foundation/doc-compiler/doc-compiler.test.mjs +0 -714
  437. package/foundation/doc-compiler/doc-loads.test.mjs +0 -1762
  438. package/foundation/doc-compiler/doc-syntax.test.mjs +0 -383
  439. package/foundation/doc-compiler/inputs.test.mjs +0 -298
  440. package/foundation/doc-compiler/links.test.mjs +0 -285
  441. package/foundation/doc-compiler/lower-doc.test.mjs +0 -495
  442. package/foundation/doc-compiler/read.test.mjs +0 -380
  443. package/foundation/doc-compiler/split-topic-keywords.test.mjs +0 -74
  444. package/foundation/doc-compiler/tree.test.mjs +0 -691
  445. package/foundation/env/cli-command.test.mjs +0 -129
  446. package/foundation/env/node-version.test.mjs +0 -103
  447. package/foundation/env/package-manager.global.test.mjs +0 -66
  448. package/foundation/env/package-manager.test.mjs +0 -910
  449. package/foundation/env/search-path.test.mjs +0 -122
  450. package/foundation/env/semver.test.mjs +0 -111
  451. package/foundation/env/user-dirs.test.mjs +0 -72
  452. package/foundation/env/user-settings.test.mjs +0 -64
  453. package/foundation/fs/file-protection.test.mjs +0 -250
  454. package/foundation/fs/listing-cache.test.mjs +0 -88
  455. package/foundation/fs/module-loader.stdout.test.mjs +0 -333
  456. package/foundation/fs/module-loader.test.mjs +0 -410
  457. package/foundation/fs/path-safety.test.mjs +0 -222
  458. package/foundation/fs/paths.test.mjs +0 -725
  459. package/foundation/fs/publish-file-eperm-mutation.test.mjs +0 -64
  460. package/foundation/fs/publish-file-hardlink-unavailable.test.mjs +0 -142
  461. package/foundation/fs/publish-file.test.mjs +0 -136
  462. package/foundation/fs/read-record.test.mjs +0 -164
  463. package/foundation/identity/provider-identity.test.mjs +0 -254
  464. package/foundation/integrations/autolink.test.mjs +0 -430
  465. package/foundation/integrations/cli-peer-version.test.mjs +0 -354
  466. package/foundation/integrations/cli-requirement.test.mjs +0 -383
  467. package/foundation/integrations/computer-integrations.test.mjs +0 -292
  468. package/foundation/integrations/contribution-inventory.test.mjs +0 -420
  469. package/foundation/integrations/integration-warnings.test.mjs +0 -191
  470. package/foundation/integrations/integrations.test.mjs +0 -818
  471. package/foundation/integrations/manifest-writer.test.mjs +0 -271
  472. package/foundation/integrations/provider-conflicts.test.mjs +0 -125
  473. package/foundation/integrations/provider-ledger.test.mjs +0 -275
  474. package/foundation/integrations/provider-resolution.test.mjs +0 -369
  475. package/foundation/integrations/public-imports.test.mjs +0 -1818
  476. package/foundation/release/cache.test.mjs +0 -923
  477. package/foundation/release/choose.test.mjs +0 -427
  478. package/foundation/release/global-state.test.mjs +0 -381
  479. package/foundation/release/handoff.e2e.test.mjs +0 -278
  480. package/foundation/release/notices.test.mjs +0 -586
  481. package/foundation/release/project.test.mjs +0 -288
  482. package/foundation/render/render.test.mjs +0 -117
  483. package/foundation/response/error-codes.test.mjs +0 -297
  484. package/foundation/response/json-contract.test.mjs +0 -235
  485. package/foundation/response/json-serialize.test.mjs +0 -66
  486. package/foundation/response/response-types.doc.test.mjs +0 -278
  487. package/foundation/route/route.test.mjs +0 -153
  488. package/foundation/runtime/hosted-runtime.test.mjs +0 -403
  489. package/foundation/runtime/package-set.test.mjs +0 -432
  490. package/foundation/text/copyright-header.test.mjs +0 -58
  491. package/foundation/text/levenshtein.test.mjs +0 -53
  492. package/foundation/text/string-utils.test.mjs +0 -175
  493. package/foundation/text/suggest-order.test.mjs +0 -312
  494. package/foundation/xle/browser-imports.test.mjs +0 -74
  495. package/foundation/xle/expand.test.mjs +0 -54
  496. package/foundation/xle/print.test.mjs +0 -50
  497. package/foundation/xle/registry.test.mjs +0 -28
  498. package/foundation/xle/xle.test.mjs +0 -382
  499. package/host/door-conformance.test.mjs +0 -274
  500. package/host/index.test.mjs +0 -302
@@ -1,1651 +0,0 @@
1
- // Copyright (c) Meta Platforms, Inc. and affiliates.
2
-
3
- /**
4
- * @file Colocated tests for the `doctor` leaf (api/doctor/doctor.mjs). `doctor`
5
- * had no api-level tests; this locks the envelope shape and the summary
6
- * invariant (the counts must always add up to the number of checks).
7
- */
8
-
9
- import {describe, it, expect, afterEach, vi} from 'vitest';
10
- import * as fs from 'node:fs';
11
- import * as os from 'node:os';
12
- import * as path from 'node:path';
13
- import {fileURLToPath} from 'node:url';
14
- import {DocsCatalog} from '../../foundation/discovery/docs-discovery.mjs';
15
- import {
16
- AUTHORING_ROOT,
17
- AUTHORING_SELF_DOCS,
18
- auditAuthoringSelfDocs,
19
- } from '../../foundation/discovery/authoring-self-docs.mjs';
20
- import {docs} from '../docs/docs.mjs';
21
- import {auditCliSelfDocs} from '../../foundation/discovery/cli-self-docs.mjs';
22
- import {
23
- doctor,
24
- checkCliCommand,
25
- checkAuthoringDocs,
26
- checkCliDocs,
27
- checkDocsTree,
28
- checkDocsProgressiveDisclosure,
29
- checkImplicitIntegrations,
30
- checkProviderIdentity,
31
- checkIntegrationIssues,
32
- checkVersionAlignment,
33
- checkPackageManager,
34
- checkComputerIntegrationsAvailable,
35
- } from './doctor.mjs';
36
- import {installCommandFor} from './_adapter.mjs';
37
- import {formatCliCommand} from '../../foundation/env/package-manager.mjs';
38
- import {Project} from '../../foundation/config/project.mjs';
39
-
40
- const REPO = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '../../../..');
41
- const cwd = REPO;
42
- const SLOW = 30_000;
43
-
44
- /** Throwaway project dirs, cleaned up after each test. */
45
- const tmpDirs = [];
46
- function mkProject(files) {
47
- const dir = fs.mkdtempSync(path.join(os.tmpdir(), 'astryx-doctor-'));
48
- tmpDirs.push(dir);
49
- for (const [rel, content] of Object.entries(files)) {
50
- const abs = path.join(dir, rel);
51
- fs.mkdirSync(path.dirname(abs), {recursive: true});
52
- fs.writeFileSync(abs, content);
53
- }
54
- return dir;
55
- }
56
- afterEach(() => {
57
- while (tmpDirs.length) {
58
- fs.rmSync(tmpDirs.pop(), {recursive: true, force: true});
59
- }
60
- });
61
-
62
- describe('doctor leaf', () => {
63
- it('returns a `doctor` envelope with checks + summary', async () => {
64
- const r = await doctor({cwd});
65
- expect(r.type).toBe('doctor');
66
- expect(Array.isArray(r.data.checks)).toBe(true);
67
- expect(r.data.checks.length).toBeGreaterThan(0);
68
- expect(r.data.summary).toBeDefined();
69
- }, SLOW);
70
-
71
- it('every check has an id, label, and a valid status', async () => {
72
- const r = await doctor({cwd});
73
- for (const c of r.data.checks) {
74
- expect(typeof c.id).toBe('string');
75
- expect(typeof c.label).toBe('string');
76
- expect(['pass', 'warn', 'fail', 'info']).toContain(c.status);
77
- }
78
- }, SLOW);
79
-
80
- it('summary counts sum to the number of checks (invariant)', async () => {
81
- const r = await doctor({cwd});
82
- const {pass, warn, fail, info} = r.data.summary;
83
- expect(pass + warn + fail + info).toBe(r.data.checks.length);
84
- }, SLOW);
85
-
86
- it('reports the core node-version and core-installed checks', async () => {
87
- const r = await doctor({cwd});
88
- const ids = r.data.checks.map(c => c.id);
89
- expect(ids).toContain('node-version');
90
- expect(ids).toContain('core-installed');
91
- }, SLOW);
92
- });
93
-
94
- describe('doctor never reads the carried Core (spec AST-081 FR3)', () => {
95
- it('loads the project to read only its installed Core, in a project with nothing installed', async () => {
96
- const dir = mkProject({
97
- 'package.json': JSON.stringify({
98
- name: 'fresh-clone',
99
- dependencies: {'@astryxdesign/core': '^0.7.0'},
100
- }),
101
- });
102
- const load = vi.spyOn(Project, 'load');
103
- const coreDir = vi.spyOn(Project.prototype, 'coreDir');
104
- try {
105
- await doctor({cwd: dir});
106
- // Doctor's own project reads only the installed Core, and no Core a
107
- // project read during the run is the carried one.
108
- expect(load.mock.calls.some(([, options]) => options?.core === 'project')).toBe(true);
109
- expect(coreDir).toHaveBeenCalled();
110
- for (const result of coreDir.mock.results) expect(result.value).toBeNull();
111
- } finally {
112
- load.mockRestore();
113
- coreDir.mockRestore();
114
- }
115
- });
116
- });
117
-
118
- describe('integration issue check', () => {
119
- it('surfaces cross-package replacement warnings', () => {
120
- const check = checkIntegrationIssues({
121
- integrationIssues: [
122
- {
123
- package: '@acme/later',
124
- code: 'ambiguous_template_replacement',
125
- severity: 'warning',
126
- message: 'Later configured replacement wins.',
127
- },
128
- ],
129
- });
130
-
131
- expect(check).toMatchObject({
132
- id: 'integration-issues',
133
- status: 'warn',
134
- message: expect.stringContaining('Later configured replacement wins.'),
135
- });
136
- });
137
- });
138
-
139
- describe('doctor leaf — degradation & error paths', () => {
140
- it('does not crash on multiple config files; reports a config FAIL', async () => {
141
- const dir = mkProject({
142
- 'package.json': '{"name":"x","dependencies":{"@astryxdesign/core":"*"}}',
143
- 'astryx.config.mjs': 'export default {};',
144
- 'astryx.config.js': 'export default {};',
145
- });
146
- const r = await doctor({cwd: dir});
147
- const config = r.data.checks.find(c => c.id === 'config');
148
- expect(config).toBeDefined();
149
- expect(config.status).toBe('fail');
150
- expect(config.message).toMatch(/multiple|exactly one/i);
151
- }, SLOW);
152
-
153
- it('reports a config FAIL (not a crash) when astryx.config.mjs throws on import', async () => {
154
- const dir = mkProject({
155
- 'package.json': '{"name":"x","dependencies":{"@astryxdesign/core":"*"}}',
156
- 'astryx.config.mjs': 'throw new Error("boom");\nexport default {};',
157
- });
158
- const r = await doctor({cwd: dir});
159
- const config = r.data.checks.find(c => c.id === 'config');
160
- expect(config.status).toBe('fail');
161
- expect(config.message).toMatch(/failed to load/i);
162
- }, SLOW);
163
-
164
- it('flags a non-object config default export as FAIL', async () => {
165
- const dir = mkProject({
166
- 'package.json': '{"name":"x","dependencies":{"@astryxdesign/core":"*"}}',
167
- 'astryx.config.mjs': 'export default 42;',
168
- });
169
- const r = await doctor({cwd: dir});
170
- const config = r.data.checks.find(c => c.id === 'config');
171
- expect(config.status).toBe('fail');
172
- expect(config.message).toMatch(/not an object/i);
173
- }, SLOW);
174
-
175
- it('degrades gracefully on invalid package.json', async () => {
176
- const dir = mkProject({'package.json': '{ not json }'});
177
- const r = await doctor({cwd: dir});
178
- const {pass, warn, fail, info} = r.data.summary;
179
- expect(pass + warn + fail + info).toBe(r.data.checks.length);
180
- }, SLOW);
181
- });
182
-
183
- describe('doctor — checkVersionAlignment', () => {
184
- it('skips (info) when the core version is not comparable semver', () => {
185
- const dir = mkProject({
186
- 'node_modules/@astryxdesign/core/package.json': JSON.stringify({
187
- name: '@astryxdesign/core',
188
- version: 'workspace:*',
189
- }),
190
- });
191
- const c = checkVersionAlignment({
192
- cwd: dir,
193
- coreDir: path.join(dir, 'node_modules/@astryxdesign/core'),
194
- nodeVersion: '',
195
- configPath: null,
196
- configTheme: null,
197
- });
198
- expect(c.status).toBe('info');
199
- expect(c.fix ?? '').not.toMatch(/NaN|undefined/);
200
- });
201
-
202
- it('does not leak NaN/undefined for a comparable semver core version', () => {
203
- const dir = mkProject({
204
- 'node_modules/@astryxdesign/core/package.json': JSON.stringify({
205
- name: '@astryxdesign/core',
206
- version: '0.0.1',
207
- }),
208
- });
209
- const c = checkVersionAlignment({
210
- cwd: dir,
211
- coreDir: path.join(dir, 'node_modules/@astryxdesign/core'),
212
- nodeVersion: '',
213
- configPath: null,
214
- configTheme: null,
215
- });
216
- expect(['pass', 'warn']).toContain(c.status);
217
- expect(c.message).not.toMatch(/NaN|undefined/);
218
- if (c.fix) expect(c.fix).not.toMatch(/NaN|undefined/);
219
- });
220
- });
221
-
222
- describe("doctor — the project's own CLI and Core on different releases", () => {
223
- const cli = JSON.parse(
224
- fs.readFileSync(new URL('../../package.json', import.meta.url), 'utf8'),
225
- ).version;
226
- /** @param {string} core */
227
- const at = core => {
228
- // A project as spec:AST-040 FR9 defines it: its package.json declares
229
- // an Astryx package.
230
- const dir = mkProject({
231
- 'package.json': JSON.stringify({
232
- name: 'app',
233
- dependencies: {'@astryxdesign/core': core},
234
- }),
235
- 'package-lock.json': '{}',
236
- 'node_modules/@astryxdesign/core/package.json': JSON.stringify({
237
- name: '@astryxdesign/core',
238
- version: core,
239
- }),
240
- });
241
- return checkVersionAlignment({
242
- cwd: dir,
243
- coreDir: path.join(dir, 'node_modules/@astryxdesign/core'),
244
- nodeVersion: '',
245
- configPath: null,
246
- configTheme: null,
247
- });
248
- };
249
-
250
- it('warns on any difference, patch included, and names the align command', () => {
251
- const older = at('0.0.1');
252
- expect(older.status).toBe('warn');
253
- expect(older.message).toContain(
254
- `This project's CLI ${cli} answers it, but its Core is 0.0.1`,
255
- );
256
- expect(older.fix).toBe(
257
- `To align them, run: npm install @astryxdesign/core@${cli}, then npx astryx upgrade --from 0.0.1 --apply.`,
258
- );
259
- const newer = at('99.0.0');
260
- expect(newer.fix).toBe(
261
- 'To align them, run: npm install @astryxdesign/cli@99.0.0.',
262
- );
263
- expect(at(cli).status).toBe('pass');
264
- });
265
-
266
- it('in a project with no CLI of its own, warns that the started copy answered and names the command that adds the CLI at Core', () => {
267
- const dir = mkProject({
268
- 'package.json': JSON.stringify({
269
- name: 'app',
270
- dependencies: {'@astryxdesign/core': '0.0.1'},
271
- }),
272
- 'package-lock.json': '{}',
273
- 'node_modules/@astryxdesign/core/package.json': JSON.stringify({
274
- name: '@astryxdesign/core',
275
- version: '0.0.1',
276
- }),
277
- });
278
- const c = checkVersionAlignment({
279
- cwd: dir,
280
- coreDir: path.join(dir, 'node_modules/@astryxdesign/core'),
281
- nodeVersion: '',
282
- configPath: null,
283
- configTheme: null,
284
- ownCli: false,
285
- });
286
- expect(c.status).toBe('warn');
287
- expect(c.message).toBe(
288
- `This project has no Astryx CLI installed; CLI ${cli}, the one you started, answered while its Core is 0.0.1.`,
289
- );
290
- expect(c.fix).toBe('To match, run: npm install @astryxdesign/cli@0.0.1.');
291
- });
292
- });
293
-
294
- describe('the command that adds an integration installed for the computer', () => {
295
- const app = () =>
296
- mkProject({
297
- 'package.json': JSON.stringify({
298
- name: 'app',
299
- dependencies: {'@astryxdesign/core': '0.7.0'},
300
- }),
301
- 'pnpm-lock.yaml': '',
302
- 'tools/codegen/package.json': JSON.stringify({name: 'codegen'}),
303
- });
304
-
305
- it('adds it in the project, with its package manager', () => {
306
- const dir = app();
307
- expect(installCommandFor(dir)?.('@acme/a')).toBe('pnpm add @acme/a');
308
- });
309
-
310
- // A package.json that is not the project's (spec AST-040 FR9): a run
311
- // there loads integrations from it, so a package added to the project
312
- // stays unused there. No command; the fix points at the project.
313
- it("from a tool folder inside the project, names no command and points at the project's folder", () => {
314
- const dir = app();
315
- expect(installCommandFor(path.join(dir, 'tools', 'codegen'))).toBeNull();
316
- const c = checkComputerIntegrationsAvailable({
317
- installed: new Set(),
318
- candidates: [/** @type {any} */ ({name: '@acme/a'})],
319
- install: null,
320
- elsewhere: true,
321
- });
322
- expect(c.fix).toBe(
323
- "Run this from the Astryx project's folder, or declare an Astryx package in this folder's package.json to make it a project of its own.",
324
- );
325
- });
326
-
327
- it('in a folder that belongs to no project, names no command', () => {
328
- const dir = mkProject({'package.json': JSON.stringify({name: 'tool'})});
329
- expect(installCommandFor(dir)).toBeNull();
330
- const c = checkComputerIntegrationsAvailable({
331
- installed: new Set(),
332
- candidates: [/** @type {any} */ ({name: '@acme/a'})],
333
- install: null,
334
- });
335
- expect(c.status).toBe('info');
336
- expect(c).not.toHaveProperty('fix');
337
- });
338
- });
339
-
340
- describe('checkCliCommand', () => {
341
- it('is informational when no integration declares a command', () => {
342
- const dir = mkProject({'pnpm-lock.yaml': ''});
343
- const c = checkCliCommand({cwd: dir, integrations: [{name: '@acme/a'}]});
344
- expect(c).toMatchObject({id: 'cli-command', status: 'info'});
345
- });
346
-
347
- it('passes and names the command and who declared it', () => {
348
- const c = checkCliCommand({
349
- cwd: mkProject({}),
350
- integrations: [{name: '@acme/a', cliCommand: 'acme astryx'}],
351
- });
352
- expect(c).toMatchObject({id: 'cli-command', status: 'pass'});
353
- expect(c.message).toContain('`acme astryx`');
354
- expect(c.message).toContain('@acme/a');
355
- });
356
-
357
- it('warns when integrations declare different commands', () => {
358
- const dir = mkProject({'pnpm-lock.yaml': ''});
359
- const c = checkCliCommand({
360
- cwd: dir,
361
- integrations: [
362
- {name: '@acme/a', cliCommand: 'acme astryx'},
363
- {name: '@acme/b', cliCommand: 'other astryx'},
364
- ],
365
- });
366
- expect(c).toMatchObject({id: 'cli-command', status: 'warn'});
367
- expect(c.message).toContain('@acme/a (`acme astryx`)');
368
- expect(c.message).toContain('@acme/b (`other astryx`)');
369
- expect(c.message).toContain('pnpm dlx @astryxdesign/cli');
370
- expect(c.fix).toContain('cliCommand');
371
- });
372
- });
373
-
374
- describe('checkPackageManager', () => {
375
- it('is informational when one lockfile answers', () => {
376
- const dir = mkProject({'pnpm-lock.yaml': ''});
377
- const c = checkPackageManager({cwd: dir});
378
- expect(c).toMatchObject({id: 'package-manager', status: 'info'});
379
- expect(c.message).toContain('pnpm');
380
- });
381
-
382
- it('fails when several lockfiles tie and nothing project-owned breaks it', () => {
383
- // Without this the CLI answers from array order, and every command it
384
- // prints — including the agent-docs invocation line — names a package
385
- // manager the project may not use at all. Silence is the bug; say it.
386
- const dir = mkProject({'pnpm-lock.yaml': '', 'yarn.lock': ''});
387
- const c = checkPackageManager({cwd: dir});
388
- expect(c.status).toBe('fail');
389
- expect(c.message).toContain('yarn');
390
- expect(c.message).toContain('pnpm');
391
- expect(c.fix).toContain('packageManager');
392
- });
393
-
394
- it('is informational when the declaration and the lockfile agree', () => {
395
- const dir = mkProject({
396
- 'pnpm-lock.yaml': '',
397
- 'package.json': JSON.stringify({packageManager: 'pnpm@11.10.0'}),
398
- });
399
- const c = checkPackageManager({cwd: dir});
400
- expect(c.status).toBe('info');
401
- expect(c.message).toContain('pnpm');
402
- expect(c.fix).toBeUndefined();
403
- });
404
-
405
- it('warns when a lockfile contradicts the declared packageManager', () => {
406
- // The regression: a stray yarn.lock used to OUTRANK the declaration, and
407
- // doctor then reported the project as healthy while every command the CLI
408
- // printed named the wrong package manager. The declaration now decides, and
409
- // the contradiction is reported instead of hidden.
410
- const dir = mkProject({
411
- 'yarn.lock': '',
412
- 'package.json': JSON.stringify({packageManager: 'pnpm@11.10.0'}),
413
- });
414
- const c = checkPackageManager({cwd: dir});
415
- expect(c.status).toBe('warn');
416
- expect(c.message).toContain('yarn.lock');
417
- expect(c.message).toContain('pnpm');
418
- expect(c.fix).toContain('yarn.lock');
419
- });
420
-
421
- it('still warns when the declaration resolved a multi-lockfile tie', () => {
422
- const dir = mkProject({
423
- 'pnpm-lock.yaml': '',
424
- 'yarn.lock': '',
425
- 'package.json': JSON.stringify({packageManager: 'pnpm@11.10.0'}),
426
- });
427
- const c = checkPackageManager({cwd: dir});
428
- expect(c.status).toBe('warn');
429
- expect(c.message).toContain('yarn.lock');
430
- });
431
- });
432
-
433
- describe('checkProviderIdentity', () => {
434
- /** @param {object} [fields] */
435
- const loaded = (fields = {}) => ({
436
- name: '@acme/widgets',
437
- providerId: '@acme/widgets',
438
- version: '1.0.0',
439
- __spec: '@acme/widgets',
440
- __packageDir: '/abs/node_modules/@acme/widgets',
441
- __manifestFile: '/abs/node_modules/@acme/widgets/astryx.integration.mjs',
442
- ...fields,
443
- });
444
-
445
- it('skips when the project could not be read', () => {
446
- expect(checkProviderIdentity({integrations: null}).status).toBe('info');
447
- });
448
-
449
- it('reports none when nothing is loaded', () => {
450
- const c = checkProviderIdentity({integrations: []});
451
- expect(c.status).toBe('info');
452
- expect(c.message).toContain('None');
453
- });
454
-
455
- it('passes when each loaded integration has its own provider ID', () => {
456
- const c = checkProviderIdentity({
457
- integrations: [
458
- loaded(),
459
- loaded({
460
- name: '@acme/charts',
461
- providerId: '@acme/charts',
462
- __spec: '@acme/charts',
463
- }),
464
- ],
465
- });
466
- expect(c.status).toBe('pass');
467
- expect(c.message).toContain('2 loaded integrations');
468
- });
469
-
470
- it('warns and names both packages when a later claimant is set aside', () => {
471
- const message =
472
- '@acme/renamed@2.0.0 and @acme/widgets@1.0.0 both claim provider ID ' +
473
- '"@acme/widgets". @acme/widgets@1.0.0 loads first and is used; ' +
474
- '@acme/renamed@2.0.0 contributes nothing until one package changes ' +
475
- 'its providerId.';
476
- const c = checkProviderIdentity({
477
- integrations: [
478
- loaded(),
479
- loaded({
480
- name: '@acme/renamed',
481
- version: '2.0.0',
482
- __spec: '@acme/renamed',
483
- __providerConflict: {
484
- providerId: '@acme/widgets',
485
- claimedBy: '@acme/widgets',
486
- message,
487
- },
488
- }),
489
- ],
490
- });
491
- expect(c.status).toBe('warn');
492
- expect(c.message).toBe(message);
493
- expect(c.fix).toContain('providerId');
494
- });
495
-
496
- it('is part of the report doctor returns', async () => {
497
- const r = await doctor({cwd});
498
- expect(r.data.checks.map(check => check.id)).toContain(
499
- 'provider-identity',
500
- );
501
- }, SLOW);
502
- });
503
-
504
- describe('checkImplicitIntegrations', () => {
505
- /** @param {object} [fields] */
506
- const autolinked = (fields = {}) => ({
507
- name: '@acme/widgets',
508
- version: '1.0.0',
509
- components: '/abs/components',
510
- __spec: '@acme/widgets',
511
- __autolinked: true,
512
- __dependencyField: 'dependencies',
513
- ...fields,
514
- });
515
-
516
- it('skips when the project could not be read', () => {
517
- const c = checkImplicitIntegrations({integrations: null});
518
- expect(c.status).toBe('info');
519
- expect(c.message).toContain('Skipped');
520
- });
521
-
522
- it('reports none when nothing is installed', () => {
523
- const c = checkImplicitIntegrations({integrations: []});
524
- expect(c.status).toBe('info');
525
- expect(c.message).toContain('no installed dependency');
526
- expect(c.fix).toBeUndefined();
527
- });
528
-
529
- it('reports none when every loaded integration is configured', () => {
530
- const c = checkImplicitIntegrations({
531
- integrations: [autolinked({__autolinked: false})],
532
- });
533
- expect(c.status).toBe('info');
534
- expect(c.message).toContain('named in astryx.config');
535
- });
536
-
537
- // A package with no astryx.config that loads its own manifest: there is no
538
- // config file, so the message must not say anything is named in one.
539
- it("names the package's own manifest instead of a config that does not exist", () => {
540
- const c = checkImplicitIntegrations({
541
- integrations: [autolinked({__autolinked: false, __local: true, name: '@acme/kit'})],
542
- });
543
- expect(c.status).toBe('info');
544
- expect(c.message).toBe(
545
- "None — the only loaded integration is this package's own manifest (@acme/kit).",
546
- );
547
- expect(c.message).not.toContain('astryx.config');
548
- });
549
-
550
- // An own manifest that failed to load keeps a `__local` record carrying
551
- // `__loadError`; it loaded nothing, so it is never named as loaded.
552
- it("does not name the package's own manifest as loaded when it failed to load", () => {
553
- const failed = autolinked({
554
- __autolinked: false,
555
- __local: true,
556
- name: '@acme/kit',
557
- __loadError: 'astryx.integration.mjs threw: boom',
558
- });
559
- const alone = checkImplicitIntegrations({integrations: [failed]});
560
- expect(alone.status).toBe('info');
561
- expect(alone.message).toBe('None loaded.');
562
- const beside = checkImplicitIntegrations({
563
- integrations: [autolinked({__autolinked: false}), failed],
564
- });
565
- expect(beside.message).toBe('None — every loaded integration is named in astryx.config.');
566
- });
567
-
568
- it('names both when configured integrations load beside the own manifest', () => {
569
- const c = checkImplicitIntegrations({
570
- integrations: [
571
- autolinked({__autolinked: false}),
572
- autolinked({__autolinked: false, __local: true, name: '@acme/kit'}),
573
- ],
574
- });
575
- expect(c.message).toBe(
576
- "None — every loaded integration is named in astryx.config or is this package's own manifest (@acme/kit).",
577
- );
578
- });
579
-
580
- it('names the package, the field, and what it contributes', () => {
581
- // Roots count only when they exist, so this one gives them real folders.
582
- const root = fs.mkdtempSync(path.join(os.tmpdir(), 'astryx-implicit-'));
583
- try {
584
- const dir = name => {
585
- fs.mkdirSync(path.join(root, name));
586
- return path.join(root, name);
587
- };
588
- const c = checkImplicitIntegrations({
589
- integrations: [
590
- autolinked({
591
- components: dir('components'),
592
- templates: dir('templates'),
593
- themes: dir('themes'),
594
- }),
595
- ],
596
- });
597
- expect(c.message).toContain('@acme/widgets@1.0.0');
598
- expect(c.message).toContain('from dependencies');
599
- expect(c.message).toContain(
600
- 'contributing components, templates, themes',
601
- );
602
- expect(c.message).not.toContain('missing on disk');
603
- } finally {
604
- fs.rmSync(root, {recursive: true, force: true});
605
- }
606
- });
607
-
608
- it('names the declared key too when an npm alias makes them differ', () => {
609
- const c = checkImplicitIntegrations({
610
- integrations: [
611
- autolinked({
612
- name: '@acme/ui',
613
- version: '0.1.22',
614
- __spec: '@acme/legacy-ui',
615
- }),
616
- ],
617
- });
618
- expect(c.message).toContain('@acme/ui@0.1.22');
619
- expect(c.message).toContain('declared as "@acme/legacy-ui"');
620
- });
621
-
622
- it('marks the dependency load-bearing for an unused-dependency check', () => {
623
- const c = checkImplicitIntegrations({integrations: [autolinked()]});
624
- expect(c.fix).toContain('unused-dependency check');
625
- expect(c.fix).toContain('astryx.config');
626
- });
627
-
628
- it('is always informational, so the CI gate stays green', () => {
629
- for (const integrations of [
630
- null,
631
- [],
632
- [autolinked()],
633
- [autolinked({components: undefined})],
634
- [autolinked({__autolinked: false})],
635
- ]) {
636
- expect(checkImplicitIntegrations({integrations}).status).toBe('info');
637
- }
638
- });
639
-
640
- it('is part of the report doctor returns', async () => {
641
- const r = await doctor({cwd});
642
- expect(r.data.checks.map(c => c.id)).toContain('implicit-integrations');
643
- }, SLOW);
644
- });
645
-
646
- describe('checkDocsProgressiveDisclosure', () => {
647
- it('passes when every topic index and section fits one read', async () => {
648
- const c = await checkDocsProgressiveDisclosure({
649
- docsCatalog: DocsCatalog.fromBuiltins(),
650
- docsCatalogIssues: [],
651
- });
652
- expect(c).toMatchObject({id: 'docs-progressive-disclosure', status: 'pass'});
653
- expect(c.message).toMatch(/^\d+ topics: /);
654
- }, SLOW);
655
-
656
- it('warns on an invalid doc an integration contributed', async () => {
657
- const c = await checkDocsProgressiveDisclosure({
658
- docsCatalogIssues: [
659
- {
660
- package: '@acme/widgets',
661
- code: 'invalid_doc',
662
- severity: 'error',
663
- message: 'bad.doc.mjs exports no doc',
664
- },
665
- ],
666
- });
667
- expect(c.status).toBe('warn');
668
- expect(c.message).toBe('@acme/widgets: bad.doc.mjs exports no doc');
669
- });
670
-
671
- it('warns when the docs catalog cannot be built', async () => {
672
- const c = await checkDocsProgressiveDisclosure({docsCatalogError: 'boom'});
673
- expect(c.status).toBe('warn');
674
- expect(c.message).toContain('boom');
675
- });
676
-
677
- it('names a section over the budget and a topic that fails to load', async () => {
678
- const dir = fs.mkdtempSync(path.join(process.cwd(), '.astryx-doctor-docs-'));
679
- tmpDirs.push(dir);
680
- const huge = {
681
- name: 'huge',
682
- title: 'Huge',
683
- description: 'Too big for one read.',
684
- sections: [
685
- {title: 'Small', content: [{type: 'prose', text: 'Fits.'}]},
686
- {title: 'Everything', content: [{type: 'prose', text: 'x'.repeat(40 * 1024)}]},
687
- ],
688
- };
689
- fs.writeFileSync(
690
- path.join(dir, 'huge.doc.mjs'),
691
- `export const docs = ${JSON.stringify(huge)};\n`,
692
- );
693
- fs.writeFileSync(path.join(dir, 'broken.doc.mjs'), 'export const docs = {;\n');
694
- const c = await checkDocsProgressiveDisclosure({
695
- docsCatalog: DocsCatalog.fromBuiltins({
696
- huge: path.join(dir, 'huge.doc.mjs'),
697
- broken: path.join(dir, 'broken.doc.mjs'),
698
- }),
699
- docsCatalogIssues: [],
700
- });
701
- expect(c.status).toBe('warn');
702
- expect(c.message).toMatch(/^2 problems: /);
703
- expect(c.message).toContain('huge everything: 41 KB, over the 32 KB one read may return');
704
- expect(c.message).toContain('broken: ');
705
- expect(c.message).not.toContain('huge small');
706
- });
707
- });
708
-
709
- describe('checkAuthoringDocs', () => {
710
- it('passes when every authoring self-doc is reachable and fits one read', async () => {
711
- const c = await checkAuthoringDocs();
712
- expect(c).toMatchObject({id: 'authoring-docs', status: 'pass'});
713
- expect(c.message).toContain(formatCliCommand('docs authoring/field-reference'));
714
- }, SLOW);
715
- });
716
-
717
- describe('checkCliDocs', () => {
718
- const CLI_DOCS_FIX =
719
- 'Set `namespace` on each CLI doc to the one that reads it: cli/commands for a command, cli/api for an API function or the output schema, error codes, and response types, and authoring for a file an author writes (and list it in AUTHORING_SELF_DOCS).';
720
-
721
- /** A doc tree under the working directory, as the CLI root. */
722
- function writeRoot(/** @type {Record<string, any>} */ docsByPath) {
723
- const root = fs.mkdtempSync(path.join(process.cwd(), '.astryx-doctor-cli-docs-'));
724
- tmpDirs.push(root);
725
- for (const [rel, doc] of Object.entries(docsByPath)) {
726
- const file = path.join(root, rel);
727
- fs.mkdirSync(path.dirname(file), {recursive: true});
728
- fs.writeFileSync(file, `export const doc = ${JSON.stringify(doc)};\n`);
729
- }
730
- return root;
731
- }
732
-
733
- it(
734
- 'passes on this repo, counting where each CLI doc is read',
735
- async () => {
736
- const audit = await auditCliSelfDocs();
737
- expect(await checkCliDocs()).toEqual({
738
- id: 'cli-docs',
739
- label: 'CLI docs',
740
- status: 'pass',
741
- // Experimental docs are checked but not counted (spec:AST-017 FR27).
742
- message: `All ${audit.docs - audit.experimental.docs} CLI docs are readable: ${audit.tree - audit.experimental.tree} in the \`${formatCliCommand('docs cli')}\` tree and ${audit.authoring - audit.experimental.authoring} in \`${formatCliCommand('docs authoring/field-reference')}\`.`,
743
- });
744
- },
745
- SLOW,
746
- );
747
-
748
- it(
749
- 'fails on a doc with no namespace and one no topic reads, and names the fix',
750
- async () => {
751
- const root = writeRoot({
752
- 'api/alpha/alpha.doc.mjs': {
753
- type: 'function',
754
- kind: 'api',
755
- name: 'alpha',
756
- displayName: 'alpha()',
757
- summary: 'The alpha function.',
758
- params: [],
759
- returns: [{type: 'alpha', description: 'The alpha.'}],
760
- },
761
- 'clients/cli/commands/beta.doc.mjs': {
762
- type: 'command',
763
- name: 'beta',
764
- displayName: 'astryx beta',
765
- namespace: 'cli',
766
- summary: 'Do beta',
767
- },
768
- });
769
- expect(
770
- await checkCliDocs(undefined, {root, authoringSources: []}),
771
- ).toEqual({
772
- id: 'cli-docs',
773
- label: 'CLI docs',
774
- status: 'fail',
775
- message:
776
- `2 problems: api/alpha/alpha.doc.mjs has no namespace, so no \`${formatCliCommand('docs')}\` topic reads it; clients/cli/commands/beta.doc.mjs has namespace "cli", which no \`${formatCliCommand('docs')}\` topic reads`,
777
- fix: CLI_DOCS_FIX,
778
- });
779
- },
780
- SLOW,
781
- );
782
- });
783
-
784
- describe('checkDocsTree', () => {
785
- it(
786
- 'passes on this repo: every CLI doc in a cli group has one route',
787
- async () => {
788
- const {loadDocsTree} = await import(
789
- '../../foundation/doc-compiler/tree.mjs'
790
- );
791
- const tree = await loadDocsTree({fresh: true});
792
- const nodes = [...tree.nodes.values()];
793
- const namespaces = nodes.filter(node => node.kind === 'namespace').length;
794
- expect(await checkDocsTree()).toEqual({
795
- id: 'docs-tree',
796
- label: 'Docs tree',
797
- status: 'pass',
798
- message: expect.stringMatching(
799
- /^The docs tree has \d+ docs in \d+ sections \(\d+ at the top\), each at one route\.$/,
800
- ),
801
- });
802
- },
803
- SLOW,
804
- );
805
-
806
- it('fails on a tree with a broken placement, and names the fix', async () => {
807
- const {buildDocsTree} = await import(
808
- '../../foundation/doc-compiler/tree.mjs'
809
- );
810
- const tree = buildDocsTree({
811
- namespaces: [
812
- {
813
- provider: '@acme/kit',
814
- providerId: '@acme/kit',
815
- source: '@acme/kit/tree/guides.doc.mjs',
816
- doc: {
817
- type: 'namespace',
818
- name: 'guides',
819
- title: 'Guides',
820
- summary: 'Every guide.',
821
- slots: {all: {title: 'All', accepts: {kinds: ['generic']}}},
822
- },
823
- },
824
- ],
825
- docs: [
826
- {
827
- provider: '@acme/kit',
828
- providerId: '@acme/kit',
829
- source: '@acme/kit/tree/setup.doc.mjs',
830
- kind: 'generic',
831
- name: 'setup',
832
- title: 'Setup',
833
- summary: 'Set it up.',
834
- group: null,
835
- placement: {parent: 'namespace:guidez'},
836
- },
837
- ],
838
- });
839
- const c = await checkDocsTree(undefined, {tree});
840
- // New findings warn (0.6 compatibility): a broken tree is named, not fatal.
841
- expect(c).toMatchObject({id: 'docs-tree', status: 'warn'});
842
- expect(c.message).toContain(
843
- '@acme/kit/tree/setup.doc.mjs: placement.parent "namespace:guidez" names no namespace; @acme/kit declares "guides".',
844
- );
845
- expect(c.fix).toMatch(/a placement names a namespace of its own package/);
846
- });
847
- });
848
-
849
- describe('checkAuthoringDocs against the public authoring surface', () => {
850
- const NAMESPACE = 'doctypes/namespace/namespace.doc.mjs';
851
- const NAMESPACE_TYPES =
852
- `NamespaceDoc, NamespaceProviderScope, NamespaceSlotAcceptance, NamespaceSlot, NamespaceAdoptionSource, NamespaceAdoptionRule from doctypes/namespace/type.ts have no doc in \`${formatCliCommand('docs authoring/field-reference')}\``;
853
- const SURFACE_FIX =
854
- 'Put a self-doc beside each module whose types @astryxdesign/cli/authoring exports and list it in AUTHORING_SELF_DOCS; export what each listed self-doc documents, or remove that self-doc.';
855
-
856
- /** A copy of this repo's authoring tree, to break one piece of at a time. */
857
- function copyAuthoring() {
858
- const root = fs.mkdtempSync(
859
- path.join(process.cwd(), '.astryx-doctor-authoring-'),
860
- );
861
- tmpDirs.push(root);
862
- fs.cpSync(AUTHORING_ROOT, root, {
863
- recursive: true,
864
- filter: src => !src.endsWith('.test.mjs'),
865
- });
866
- return root;
867
- }
868
-
869
- /** @param {string} source */
870
- const without = source => AUTHORING_SELF_DOCS.filter(s => s !== source);
871
-
872
- /** @param {string} text */
873
- const escape = text => text.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
874
-
875
- it(
876
- 'passes on this repo and prints exactly what it printed before',
877
- async () => {
878
- expect(await checkAuthoringDocs()).toEqual({
879
- id: 'authoring-docs',
880
- label: 'Authoring docs',
881
- status: 'pass',
882
- // The three experimental icon-set schemas are checked but not
883
- // counted (spec:AST-017 FR27).
884
- message: `All ${AUTHORING_SELF_DOCS.length - 3} authoring schemas are readable in \`${formatCliCommand('docs authoring/field-reference')}\`.`,
885
- });
886
- },
887
- SLOW,
888
- );
889
-
890
- it(
891
- 'passes on an unchanged copy of the tree, and writes nothing to it',
892
- async () => {
893
- const root = copyAuthoring();
894
- const before = snapshot(root);
895
- expect(await checkAuthoringDocs(undefined, {root})).toMatchObject({
896
- status: 'pass',
897
- });
898
- expect(snapshot(root)).toEqual(before);
899
- },
900
- SLOW,
901
- );
902
-
903
- it(
904
- 'fails when the NamespaceDoc self-doc is left out of AUTHORING_SELF_DOCS',
905
- async () => {
906
- const root = copyAuthoring();
907
- const c = await checkAuthoringDocs(undefined, {
908
- root,
909
- sources: without(NAMESPACE),
910
- });
911
- expect(c.status).toBe('fail');
912
- expect(c.message).toBe(
913
- `2 problems: ${NAMESPACE} is not in \`${formatCliCommand('docs authoring/field-reference')}\`; ${NAMESPACE_TYPES}: ${NAMESPACE} is not listed in AUTHORING_SELF_DOCS`,
914
- );
915
- },
916
- SLOW,
917
- );
918
-
919
- it(
920
- "fails when the topic's index no longer exposes the NamespaceDoc section",
921
- async () => {
922
- const index = await docs('authoring/field-reference', undefined, {index: true});
923
- const topicKeys = new Set(
924
- index.data.sections
925
- .map((/** @type {any} */ s) => s.id)
926
- .filter((/** @type {string} */ id) => id !== 'namespace-doc'),
927
- );
928
- const c = await checkAuthoringDocs(undefined, {topicKeys});
929
- expect(c).toMatchObject({
930
- status: 'fail',
931
- message: `${NAMESPACE_TYPES}: ${NAMESPACE} renders section "namespace-doc", which the topic's index does not list`,
932
- fix: SURFACE_FIX,
933
- });
934
- },
935
- SLOW,
936
- );
937
-
938
- it(
939
- 'fails when @astryxdesign/cli/authoring stops exporting NamespaceDoc',
940
- async () => {
941
- const root = copyAuthoring();
942
- const index = path.join(root, 'index.d.ts');
943
- const before = fs.readFileSync(index, 'utf8');
944
- const after = before.replace(
945
- /^export type \{NamespaceDoc\} from .*\n/m,
946
- '',
947
- );
948
- expect(after).not.toBe(before);
949
- fs.writeFileSync(index, after);
950
- expect(await checkAuthoringDocs(undefined, {root})).toMatchObject({
951
- status: 'fail',
952
- message: `${NAMESPACE} documents NamespaceDoc, which @astryxdesign/cli/authoring does not export`,
953
- fix: SURFACE_FIX,
954
- });
955
- },
956
- SLOW,
957
- );
958
-
959
- it.each([
960
- [
961
- 'the graph-fields doc',
962
- 'doctypes/base/graph-fields.doc.mjs',
963
- 'doctypes/base/type.ts',
964
- [
965
- 'AuthoredDocKind',
966
- 'DocAudience',
967
- 'DocPlacement',
968
- 'AuthoredDocGraphFields',
969
- ],
970
- ],
971
- [
972
- 'the identity doc',
973
- 'identity/identity.doc.mjs',
974
- 'identity/type.ts',
975
- [
976
- 'ProviderId',
977
- 'ArtifactId',
978
- 'DocId',
979
- 'ProviderInstance',
980
- 'AuthoredDocEntry',
981
- ],
982
- ],
983
- [
984
- 'the semantic-block doc',
985
- 'doctypes/reference/reference.doc.mjs',
986
- 'doctypes/reference/type.ts',
987
- [
988
- 'WorkflowStep',
989
- 'WorkflowDocBlock',
990
- 'CollectionDocBlock',
991
- 'ReferenceDocBlock',
992
- ],
993
- ],
994
- ])(
995
- 'fails when %s is removed, which the self-doc audit alone passes',
996
- async (_what, source, module, names) => {
997
- const root = copyAuthoring();
998
- fs.rmSync(path.join(root, source));
999
- const sources = without(source);
1000
- expect(await auditAuthoringSelfDocs({root, sources})).toEqual({
1001
- sections: sources.length - 3,
1002
- experimental: 3,
1003
- unreachable: [],
1004
- failed: [],
1005
- oversized: [],
1006
- });
1007
- const c = await checkAuthoringDocs(undefined, {root, sources});
1008
- expect(c.status).toBe('fail');
1009
- expect(c.fix).toBe(SURFACE_FIX);
1010
- expect(c.message).toMatch(
1011
- new RegExp(
1012
- `^[A-Za-z, ]+ from ${escape(module)} have no doc in \`${escape(formatCliCommand('docs authoring/field-reference'))}\`: no self-doc sits beside ${escape(module)}$`,
1013
- ),
1014
- );
1015
- for (const name of names) {
1016
- expect(c.message).toMatch(new RegExp(`(^|, )${name}(,| from)`));
1017
- }
1018
- },
1019
- SLOW,
1020
- );
1021
-
1022
- it(
1023
- 'keeps the message and fix of a failure only the self-doc audit reports',
1024
- async () => {
1025
- const root = copyAuthoring();
1026
- fs.writeFileSync(
1027
- path.join(root, 'identity', 'broken.doc.mjs'),
1028
- 'export const doc = {;\n',
1029
- );
1030
- const c = await checkAuthoringDocs(undefined, {
1031
- root,
1032
- sources: [...AUTHORING_SELF_DOCS, 'identity/broken.doc.mjs'],
1033
- });
1034
- expect(c.status).toBe('fail');
1035
- expect(c.message).toMatch(/^identity\/broken\.doc\.mjs failed to load: /);
1036
- expect(c.fix).toBe(
1037
- 'List every authoring self-doc in AUTHORING_SELF_DOCS, fix the one that fails to load, and split a section that is too large.',
1038
- );
1039
- },
1040
- SLOW,
1041
- );
1042
-
1043
- it(
1044
- 'reports a topic it cannot read rather than skipping the comparison',
1045
- async () => {
1046
- const spy = vi
1047
- .spyOn(DocsCatalog, 'fromBuiltins')
1048
- .mockImplementationOnce(() => {
1049
- throw new Error('no built-in docs');
1050
- });
1051
- try {
1052
- expect(await checkAuthoringDocs()).toMatchObject({
1053
- status: 'fail',
1054
- message:
1055
- `\`${formatCliCommand('docs authoring/field-reference')}\` could not be read: no built-in docs`,
1056
- fix: SURFACE_FIX,
1057
- });
1058
- } finally {
1059
- spy.mockRestore();
1060
- }
1061
- },
1062
- SLOW,
1063
- );
1064
-
1065
- it(
1066
- 'fails rather than passes when the surface exports no types at all',
1067
- async () => {
1068
- const root = copyAuthoring();
1069
- fs.writeFileSync(
1070
- path.join(root, 'index.d.ts'),
1071
- "export {parseDoc} from './doctypes/parse.mjs';\n",
1072
- );
1073
- const c = await checkAuthoringDocs(undefined, {root});
1074
- expect(c.status).toBe('fail');
1075
- expect(c.message).toContain(
1076
- `@astryxdesign/cli/authoring exports no types, so nothing was compared with \`${formatCliCommand('docs authoring/field-reference')}\``,
1077
- );
1078
- },
1079
- SLOW,
1080
- );
1081
- });
1082
-
1083
- /**
1084
- * Every file under `root` with its contents.
1085
- * @param {string} root
1086
- * @returns {Record<string, string>}
1087
- */
1088
- function snapshot(root) {
1089
- /** @type {Record<string, string>} */
1090
- const out = {};
1091
- /** @param {string} dir */
1092
- const walk = dir => {
1093
- for (const entry of fs.readdirSync(dir, {withFileTypes: true})) {
1094
- const full = path.join(dir, entry.name);
1095
- if (entry.isDirectory()) walk(full);
1096
- else out[path.relative(root, full)] = fs.readFileSync(full, 'utf8');
1097
- }
1098
- };
1099
- walk(root);
1100
- return out;
1101
- }
1102
-
1103
- describe('doctor docs checks', () => {
1104
- it('runs both docs checks and they pass on the repo', async () => {
1105
- const r = await doctor({cwd});
1106
- const byId = Object.fromEntries(r.data.checks.map(c => [c.id, c.status]));
1107
- expect(byId['authoring-docs']).toBe('pass');
1108
- expect(byId['docs-progressive-disclosure']).toBe('pass');
1109
- }, SLOW);
1110
- });
1111
-
1112
- describe('checkDocsProgressiveDisclosure languages', () => {
1113
- it('checks every overlay a topic ships, not only English', async () => {
1114
- const dir = fs.mkdtempSync(path.join(process.cwd(), '.astryx-doctor-lang-'));
1115
- tmpDirs.push(dir);
1116
- const deploying = {
1117
- name: 'deploying',
1118
- title: 'Deploying',
1119
- description: 'Ship it.',
1120
- sections: [{title: 'Overview', content: [{type: 'prose', text: 'Push the button.'}]}],
1121
- };
1122
- fs.writeFileSync(
1123
- path.join(dir, 'deploying.doc.mjs'),
1124
- `export const docs = ${JSON.stringify(deploying)};\n`,
1125
- );
1126
- fs.writeFileSync(
1127
- path.join(dir, 'deploying.doc.zh.mjs'),
1128
- "throw new Error('zh overlay broken');\n",
1129
- );
1130
- fs.writeFileSync(
1131
- path.join(dir, 'deploying.doc.dense.mjs'),
1132
- `export const docsDense = ${JSON.stringify({
1133
- sections: [
1134
- {
1135
- section: 'Overview',
1136
- title: 'Overview',
1137
- content: [{type: 'prose', text: 'x'.repeat(40 * 1024)}],
1138
- },
1139
- ],
1140
- })};\n`,
1141
- );
1142
- const c = await checkDocsProgressiveDisclosure({
1143
- docsCatalog: DocsCatalog.fromBuiltins({deploying: path.join(dir, 'deploying.doc.mjs')}),
1144
- docsCatalogIssues: [],
1145
- });
1146
- expect(c.status).toBe('warn');
1147
- expect(c.message).toContain('deploying [zh]: zh overlay broken');
1148
- expect(c.message).toContain('deploying [dense] overview: 41 KB');
1149
- expect(c.message).not.toMatch(/deploying overview:/);
1150
- });
1151
- });
1152
-
1153
- describe('doctor says what it could not check', () => {
1154
- const CORE = {
1155
- 'node_modules/@astryxdesign/core/package.json': JSON.stringify({
1156
- name: '@astryxdesign/core',
1157
- version: '0.6.3',
1158
- }),
1159
- };
1160
-
1161
- /** Installed dependency whose manifest declares roots that do not exist. */
1162
- const dangling = {
1163
- 'node_modules/@acme/dangling/package.json': JSON.stringify({
1164
- name: '@acme/dangling',
1165
- version: '2.0.0',
1166
- }),
1167
- 'node_modules/@acme/dangling/astryx.integration.mjs':
1168
- "export default {providerId: 'acme-dangling', components: './components', templates: './templates', docs: './docs'};\n",
1169
- };
1170
-
1171
- /** Installed dependency whose manifest cannot be parsed at all. */
1172
- const broken = {
1173
- 'node_modules/@acme/broken/package.json': JSON.stringify({
1174
- name: '@acme/broken',
1175
- version: '1.0.0',
1176
- }),
1177
- 'node_modules/@acme/broken/astryx.integration.mjs':
1178
- 'export default { this is not valid javascript ((\n',
1179
- };
1180
-
1181
- /** @param {Record<string, string>} extra @param {string[]} deps */
1182
- const project = (extra, deps) =>
1183
- mkProject({
1184
- 'package.json': JSON.stringify({
1185
- name: 'consumer',
1186
- version: '1.0.0',
1187
- dependencies: Object.fromEntries(
1188
- ['@astryxdesign/core', ...deps].map(d => [d, '1.0.0']),
1189
- ),
1190
- }),
1191
- ...CORE,
1192
- ...extra,
1193
- });
1194
-
1195
- // An unparseable manifest is kept out of the loaded set on purpose, and
1196
- // doctor used to report that no installed dependency ships a manifest.
1197
- it('names an installed dependency whose manifest cannot be loaded', async () => {
1198
- const report = (await doctor({cwd: project(broken, ['@acme/broken'])})).data;
1199
- const check = report.checks.find(c => c.id === 'implicit-integrations');
1200
-
1201
- expect(check.status).toBe('info');
1202
- expect(check.message).toContain('@acme/broken');
1203
- expect(check.message).toContain('could not be loaded');
1204
- expect(check.message).not.toContain('no installed dependency ships');
1205
- expect(report.summary.fail).toBe(0);
1206
- }, SLOW);
1207
-
1208
- it('does not claim contributions from roots that are missing on disk', async () => {
1209
- const report = (await doctor({cwd: project(dangling, ['@acme/dangling'])}))
1210
- .data;
1211
- const implicit = report.checks.find(c => c.id === 'implicit-integrations');
1212
- const issues = report.checks.find(c => c.id === 'integration-issues');
1213
-
1214
- expect(implicit.message).toContain('contributing nothing');
1215
- expect(implicit.message).toContain('missing on disk');
1216
- expect(implicit.message).not.toContain('contributing components');
1217
- expect(issues.status).toBe('warn');
1218
- expect(issues.message).toContain('@acme/dangling');
1219
- }, SLOW);
1220
-
1221
- it('still says no dependency ships a manifest when none does', async () => {
1222
- const report = (await doctor({cwd: project({}, [])})).data;
1223
- const check = report.checks.find(c => c.id === 'implicit-integrations');
1224
-
1225
- expect(check.message).toBe(
1226
- 'None — no installed dependency ships an astryx.integration.* manifest.',
1227
- );
1228
- }, SLOW);
1229
-
1230
- it('says how many integrations could not be read, rather than counting silently', () => {
1231
- /** @type {any} */
1232
- const ctx = {
1233
- cwd: '/x',
1234
- nodeVersion: process.versions.node,
1235
- coreDir: null,
1236
- configPath: null,
1237
- configTheme: null,
1238
- integrations: [
1239
- {name: '@acme/ok', __spec: '@acme/ok', providerId: 'ok'},
1240
- {name: '@acme/bad', __spec: '@acme/bad', __loadError: 'boom'},
1241
- ],
1242
- };
1243
- const check = checkProviderIdentity(ctx);
1244
-
1245
- expect(check.message).toContain('1 loaded integration has its own provider ID.');
1246
- expect(check.message).toContain('could not be read');
1247
- });
1248
- });
1249
-
1250
- describe('doctor says why it skipped and what it checked', () => {
1251
- const CORE_STUB = {
1252
- 'node_modules/@astryxdesign/core/package.json': JSON.stringify({
1253
- name: '@astryxdesign/core',
1254
- version: '0.6.3',
1255
- }),
1256
- };
1257
-
1258
- /** A project under the working directory, so its config can be imported. */
1259
- function cwdProject(files) {
1260
- const dir = fs.mkdtempSync(
1261
- path.join(process.cwd(), '.astryx-doctor-shape-'),
1262
- );
1263
- tmpDirs.push(dir);
1264
- for (const [rel, content] of Object.entries(files)) {
1265
- const abs = path.join(dir, rel);
1266
- fs.mkdirSync(path.dirname(abs), {recursive: true});
1267
- fs.writeFileSync(abs, content);
1268
- }
1269
- return dir;
1270
- }
1271
-
1272
- it(
1273
- 'fails, and quotes the reason, when the CLI cannot load the project from a config that imports',
1274
- async () => {
1275
- const dir = cwdProject({
1276
- 'package.json': '{"name":"app"}',
1277
- ...CORE_STUB,
1278
- 'astryx.config.mjs': "export default { integrations: 'oops' };\n",
1279
- });
1280
- const {checks, summary} = (await doctor({cwd: dir})).data;
1281
- const by = Object.fromEntries(checks.map(c => [c.id, c]));
1282
- expect(by.config.status).toBe('fail');
1283
- expect(by.config.message).toMatch(
1284
- /^astryx\.config\.mjs loads, but the CLI could not load the project from it: .*integrations/,
1285
- );
1286
- expect(by.config.fix).toContain(' docs authoring config`');
1287
- for (const id of ['implicit-integrations', 'provider-identity']) {
1288
- expect(by[id].message).toMatch(
1289
- /^Skipped — the project configuration could not be read: .*integrations/,
1290
- );
1291
- }
1292
- expect(by['integration-issues'].message).toMatch(
1293
- /^Skipped — the project integration graph could not be loaded: .*integrations/,
1294
- );
1295
- // The config check is the one failure; the skipped checks stay info.
1296
- expect(summary.fail).toBe(1);
1297
- },
1298
- SLOW,
1299
- );
1300
-
1301
- it(
1302
- 'passes the config check when the CLI loads the project from it',
1303
- async () => {
1304
- const dir = cwdProject({
1305
- 'package.json': '{"name":"app"}',
1306
- ...CORE_STUB,
1307
- 'astryx.config.mjs': 'export default { integrations: [] };\n',
1308
- });
1309
- const by = Object.fromEntries(
1310
- (await doctor({cwd: dir})).data.checks.map(c => [c.id, c]),
1311
- );
1312
- expect(by.config.status).toBe('pass');
1313
- expect(by['implicit-integrations'].message).not.toContain('Skipped');
1314
- },
1315
- SLOW,
1316
- );
1317
-
1318
- it('says there is nothing to check when no integration is loaded', () => {
1319
- expect(
1320
- checkIntegrationIssues({integrationIssues: [], integrations: []}),
1321
- ).toEqual({
1322
- id: 'integration-issues',
1323
- label: 'Integration contributions',
1324
- status: 'info',
1325
- message:
1326
- 'No integration is loaded, so there are no integration contributions to check.',
1327
- });
1328
- });
1329
-
1330
- it('names what it checked when every loaded integration is clean', () => {
1331
- expect(
1332
- checkIntegrationIssues({
1333
- integrationIssues: [],
1334
- integrations: [{name: '@acme/widgets'}],
1335
- }),
1336
- ).toMatchObject({
1337
- status: 'pass',
1338
- message:
1339
- '1 loaded integration checked (@acme/widgets): contributions and cross-package relationships are valid.',
1340
- });
1341
- });
1342
-
1343
- it('bounds the names it lists', () => {
1344
- const integrations = Array.from({length: 12}, (_, i) => ({
1345
- name: `@acme/kit-${i}`,
1346
- }));
1347
- const c = checkIntegrationIssues({integrationIssues: [], integrations});
1348
- expect(c.message).toMatch(
1349
- /^12 loaded integrations checked \(.* and 2 more\): /,
1350
- );
1351
- });
1352
- });
1353
-
1354
- describe('a configured integration that cannot load fails the gate', () => {
1355
- const CORE_STUB = {
1356
- 'node_modules/@astryxdesign/core/package.json': JSON.stringify({
1357
- name: '@astryxdesign/core',
1358
- version: '0.6.3',
1359
- }),
1360
- };
1361
- const WIDGETS = 'node_modules/@acme/widgets';
1362
- /** @param {string} [manifest] */
1363
- const widgets = (
1364
- manifest = "export default {components: './components'};\n",
1365
- ) => ({
1366
- [`${WIDGETS}/package.json`]: JSON.stringify({
1367
- name: '@acme/widgets',
1368
- version: '1.0.0',
1369
- }),
1370
- [`${WIDGETS}/astryx.integration.mjs`]: manifest,
1371
- [`${WIDGETS}/components/AcmeCard.doc.mjs`]:
1372
- "export default {type: 'component', name: 'AcmeCard', displayName: 'AcmeCard', description: 'Fixture.', props: []};\n",
1373
- [`${WIDGETS}/components/AcmeCard.tsx`]:
1374
- 'export default function AcmeCard() { return null; }\n',
1375
- });
1376
- const APP = {
1377
- 'package.json': '{"name":"app"}',
1378
- ...CORE_STUB,
1379
- 'astryx.config.mjs': "export default { integrations: ['@acme/widgets'] };\n",
1380
- };
1381
-
1382
- /**
1383
- * Run doctor on a project under the working directory, in its folder `at`.
1384
- * @param {Record<string, string>} files
1385
- * @param {string} [at]
1386
- */
1387
- async function report(files, at = '.') {
1388
- const dir = fs.mkdtempSync(path.join(process.cwd(), '.astryx-doctor-gate-'));
1389
- tmpDirs.push(dir);
1390
- for (const [rel, content] of Object.entries(files)) {
1391
- const abs = path.join(dir, rel);
1392
- fs.mkdirSync(path.dirname(abs), {recursive: true});
1393
- fs.writeFileSync(abs, content);
1394
- }
1395
- const {checks, summary} = (await doctor({cwd: path.join(dir, at)})).data;
1396
- return {by: Object.fromEntries(checks.map(c => [c.id, c])), summary};
1397
- }
1398
-
1399
- it.each([
1400
- ['not installed', {}, /Could not find installed integration package "@acme\/widgets"/],
1401
- [
1402
- 'installed without a manifest',
1403
- {[`${WIDGETS}/package.json`]: JSON.stringify({name: '@acme/widgets', version: '1.0.0'})},
1404
- /no conventional root manifest/,
1405
- ],
1406
- ['installed with a manifest that throws', widgets('export default { not valid ((\n'), /Unexpected/],
1407
- ])(
1408
- 'fails when a configured integration is %s, and names it',
1409
- async (_shape, extra, reason) => {
1410
- const {by, summary} = await report({...APP, ...extra});
1411
- const check = by['configured-integrations'];
1412
- expect(check.status).toBe('fail');
1413
- expect(check.message).toMatch(
1414
- /^1 of 1 integration named in astryx\.config could not be loaded, so it contributes nothing: @acme\/widgets \(/,
1415
- );
1416
- expect(check.message).toMatch(reason);
1417
- expect(check.fix).toContain(' doctor integration validate <package>`');
1418
- expect(summary.fail).toBe(1);
1419
- },
1420
- SLOW,
1421
- );
1422
-
1423
- it(
1424
- 'passes in a workspace member whose configured integration is hoisted to the root',
1425
- async () => {
1426
- const {by} = await report(
1427
- {
1428
- 'package.json': JSON.stringify({name: 'root', private: true, workspaces: ['apps/*']}),
1429
- ...CORE_STUB,
1430
- ...widgets(),
1431
- 'apps/web/package.json': '{"name":"web"}',
1432
- 'apps/web/astryx.config.mjs': "export default { integrations: ['@acme/widgets'] };\n",
1433
- },
1434
- 'apps/web',
1435
- );
1436
- expect(by['configured-integrations'].status).toBe('pass');
1437
- expect(by['configured-integrations'].message).toBe(
1438
- '1 integration named in astryx.config loaded: @acme/widgets.',
1439
- );
1440
- },
1441
- SLOW,
1442
- );
1443
-
1444
- it(
1445
- 'counts the package being authored when its own config names it',
1446
- async () => {
1447
- const {by} = await report({
1448
- ...CORE_STUB,
1449
- 'package.json': JSON.stringify({name: '@acme/widgets', version: '1.0.0'}),
1450
- 'astryx.integration.mjs': "export default {components: './components'};\n",
1451
- 'components/AcmeCard.doc.mjs':
1452
- "export default {type: 'component', name: 'AcmeCard', displayName: 'AcmeCard', description: 'Fixture.', props: []};\n",
1453
- 'components/AcmeCard.tsx': 'export default function AcmeCard() { return null; }\n',
1454
- 'astryx.config.mjs': "export default { integrations: ['@acme/widgets'] };\n",
1455
- });
1456
- expect(by['configured-integrations'].status).toBe('pass');
1457
- expect(by['configured-integrations'].message).toBe(
1458
- '1 integration named in astryx.config loaded: @acme/widgets.',
1459
- );
1460
- },
1461
- SLOW,
1462
- );
1463
-
1464
- it(
1465
- 'fails when the package being authored is named by its own config and its manifest throws',
1466
- async () => {
1467
- const {by, summary} = await report({
1468
- ...CORE_STUB,
1469
- 'package.json': JSON.stringify({name: '@acme/widgets', version: '1.0.0'}),
1470
- 'astryx.integration.mjs': 'export default { not valid ((\n',
1471
- 'astryx.config.mjs': "export default { integrations: ['@acme/widgets'] };\n",
1472
- });
1473
- const check = by['configured-integrations'];
1474
- expect(check.status).toBe('fail');
1475
- expect(check.message).toMatch(
1476
- /^1 of 1 integration named in astryx\.config could not be loaded, so it contributes nothing: @acme\/widgets \(/,
1477
- );
1478
- expect(summary.fail).toBe(1);
1479
- },
1480
- SLOW,
1481
- );
1482
-
1483
- it(
1484
- 'fails when node_modules links the configured name back to the authored package and its manifest throws',
1485
- async () => {
1486
- const dir = fs.mkdtempSync(path.join(process.cwd(), '.astryx-doctor-gate-'));
1487
- tmpDirs.push(dir);
1488
- const files = {
1489
- ...CORE_STUB,
1490
- 'package.json': JSON.stringify({name: '@acme/widgets', version: '1.0.0'}),
1491
- 'astryx.integration.mjs': 'export default { not valid ((\n',
1492
- 'astryx.config.mjs': "export default { integrations: ['@acme/widgets'] };\n",
1493
- };
1494
- for (const [rel, content] of Object.entries(files)) {
1495
- const abs = path.join(dir, rel);
1496
- fs.mkdirSync(path.dirname(abs), {recursive: true});
1497
- fs.writeFileSync(abs, content);
1498
- }
1499
- fs.mkdirSync(path.join(dir, 'node_modules/@acme'), {recursive: true});
1500
- fs.symlinkSync(dir, path.join(dir, 'node_modules/@acme/widgets'), 'dir');
1501
- const {checks, summary} = (await doctor({cwd: dir})).data;
1502
- const by = Object.fromEntries(checks.map(c => [c.id, c]));
1503
- expect(by['configured-integrations'].status).toBe('fail');
1504
- expect(by['configured-integrations'].message).toMatch(
1505
- /^1 of 1 integration named in astryx\.config could not be loaded/,
1506
- );
1507
- expect(summary.fail).toBe(1);
1508
- },
1509
- SLOW,
1510
- );
1511
-
1512
- it(
1513
- 'fails for the self-linked authored package when the working directory is itself a symlink',
1514
- async () => {
1515
- const real = fs.mkdtempSync(path.join(process.cwd(), '.astryx-doctor-gate-'));
1516
- tmpDirs.push(real);
1517
- const linkParent = fs.mkdtempSync(path.join(process.cwd(), '.astryx-doctor-gate-'));
1518
- tmpDirs.push(linkParent);
1519
- const cwd = path.join(linkParent, 'link');
1520
- fs.symlinkSync(real, cwd, 'dir');
1521
- const files = {
1522
- ...CORE_STUB,
1523
- 'package.json': JSON.stringify({name: '@acme/widgets', version: '1.0.0'}),
1524
- 'astryx.integration.mjs': 'export default { not valid ((\n',
1525
- 'astryx.config.mjs': "export default { integrations: ['@acme/widgets'] };\n",
1526
- };
1527
- for (const [rel, content] of Object.entries(files)) {
1528
- const abs = path.join(real, rel);
1529
- fs.mkdirSync(path.dirname(abs), {recursive: true});
1530
- fs.writeFileSync(abs, content);
1531
- }
1532
- fs.mkdirSync(path.join(real, 'node_modules/@acme'), {recursive: true});
1533
- fs.symlinkSync(real, path.join(real, 'node_modules/@acme/widgets'), 'dir');
1534
- const {checks, summary} = (await doctor({cwd})).data;
1535
- const by = Object.fromEntries(checks.map(c => [c.id, c]));
1536
- expect(by['configured-integrations'].status).toBe('fail');
1537
- expect(summary.fail).toBe(1);
1538
- },
1539
- SLOW,
1540
- );
1541
-
1542
- it(
1543
- 'still counts a configured package that was set aside for a provider conflict',
1544
- async () => {
1545
- const CHARTS = 'node_modules/@acme/charts';
1546
- const {by} = await report({
1547
- ...APP,
1548
- 'astryx.config.mjs':
1549
- "export default { integrations: ['@acme/widgets', '@acme/charts'] };\n",
1550
- ...widgets("export default {providerId: 'acme', components: './components'};\n"),
1551
- [`${CHARTS}/package.json`]: JSON.stringify({name: '@acme/charts', version: '1.0.0'}),
1552
- [`${CHARTS}/astryx.integration.mjs`]:
1553
- "export default {providerId: 'acme', components: './components'};\n",
1554
- [`${CHARTS}/components/AcmeChart.doc.mjs`]:
1555
- "export default {type: 'component', name: 'AcmeChart', displayName: 'AcmeChart', description: 'Fixture.', props: []};\n",
1556
- [`${CHARTS}/components/AcmeChart.tsx`]: 'export default function AcmeChart() { return null; }\n',
1557
- });
1558
- expect(by['configured-integrations'].status).toBe('pass');
1559
- expect(by['configured-integrations'].message).toMatch(/^2 integrations named in astryx\.config loaded: /);
1560
- expect(by['configured-integrations'].message).toContain('@acme/charts');
1561
- },
1562
- SLOW,
1563
- );
1564
-
1565
- it(
1566
- 'passes, naming each one, when every configured integration loads',
1567
- async () => {
1568
- const {by, summary} = await report({...APP, ...widgets()});
1569
- expect(by['configured-integrations']).toEqual({
1570
- id: 'configured-integrations',
1571
- label: 'Configured integrations',
1572
- status: 'pass',
1573
- message: '1 integration named in astryx.config loaded: @acme/widgets.',
1574
- });
1575
- expect(summary.fail).toBe(0);
1576
- },
1577
- SLOW,
1578
- );
1579
-
1580
- it.each([
1581
- [
1582
- 'an invalid component doc',
1583
- {[`${WIDGETS}/components/AcmeCard.doc.mjs`]: 'export default {;\n'},
1584
- ],
1585
- [
1586
- 'a declared root missing on disk',
1587
- {
1588
- [`${WIDGETS}/astryx.integration.mjs`]:
1589
- "export default {components: './components', templates: './templates'};\n",
1590
- },
1591
- ],
1592
- ])(
1593
- 'keeps %s a warning, because the rest of the integration still loads (spec:AST-035 FR9)',
1594
- async (_shape, extra) => {
1595
- const {by, summary} = await report({...APP, ...widgets(), ...extra});
1596
- expect(by['configured-integrations'].status).toBe('pass');
1597
- expect(by['integration-issues'].status).toBe('warn');
1598
- expect(summary.fail).toBe(0);
1599
- },
1600
- SLOW,
1601
- );
1602
-
1603
- it(
1604
- 'leaves an autolinked dependency that cannot load informational',
1605
- async () => {
1606
- const {by, summary} = await report({
1607
- 'package.json': JSON.stringify({
1608
- name: 'app',
1609
- dependencies: {'@acme/widgets': '1.0.0'},
1610
- }),
1611
- ...CORE_STUB,
1612
- ...widgets('export default { not valid ((\n'),
1613
- });
1614
- expect(by['configured-integrations']).toMatchObject({
1615
- status: 'info',
1616
- message: 'No integration is named in astryx.config.',
1617
- });
1618
- expect(by['implicit-integrations'].status).toBe('info');
1619
- expect(summary.fail).toBe(0);
1620
- },
1621
- SLOW,
1622
- );
1623
- });
1624
-
1625
- describe('no Astryx-owned environment variables (spec:AST-017 FR14)', () => {
1626
- it('no source file reads an ASTRYX_* env var', () => {
1627
- const cliDir = path.resolve(REPO, 'packages/cli');
1628
- const SKIP = new Set(['node_modules', 'dist', 'coverage']);
1629
- const ENV_READ = /process\.env(?:\.|\[\s*['"`])ASTRYX_/;
1630
- /** @type {string[]} */
1631
- const hits = [];
1632
- /** @param {string} dir */
1633
- const walk = dir => {
1634
- for (const entry of fs.readdirSync(dir, {withFileTypes: true})) {
1635
- if (SKIP.has(entry.name)) continue;
1636
- const full = path.join(dir, entry.name);
1637
- if (entry.isDirectory()) {
1638
- walk(full);
1639
- continue;
1640
- }
1641
- if (!/\.[cm]?[jt]sx?$/.test(entry.name)) continue;
1642
- if (/\.test\.|\.d\.[cm]?ts$/.test(entry.name)) continue;
1643
- if (ENV_READ.test(fs.readFileSync(full, 'utf8'))) {
1644
- hits.push(path.relative(cliDir, full));
1645
- }
1646
- }
1647
- };
1648
- walk(cliDir);
1649
- expect(hits).toEqual([]);
1650
- });
1651
- });