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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (504) hide show
  1. package/api/search/_adapter.d.mts +3 -1
  2. package/api/search/_adapter.mjs +19 -19
  3. package/assets/docs/motion.doc.mjs +1 -1
  4. package/foundation/discovery/package-tsconfig.mjs +34 -0
  5. package/foundation/fs/read-record.d.mts +4 -1
  6. package/foundation/fs/read-record.mjs +9 -5
  7. package/package.json +24 -10
  8. package/api/api-docs-parse.test.mjs +0 -47
  9. package/api/blog/_adapter.test.mjs +0 -183
  10. package/api/blog/blog.test.mjs +0 -144
  11. package/api/blog/detail/detail.test.mjs +0 -118
  12. package/api/blog/list/list.test.mjs +0 -81
  13. package/api/build/blocks/blocks.test.mjs +0 -238
  14. package/api/build/build.test.mjs +0 -569
  15. package/api/build/kit/answer.test.mjs +0 -108
  16. package/api/build/kit/rank.test.mjs +0 -380
  17. package/api/build/kit/weights.test.mjs +0 -286
  18. package/api/build/tree.test.mjs +0 -185
  19. package/api/component/component-replacement.test.mjs +0 -616
  20. package/api/component/component.test.mjs +0 -532
  21. package/api/component/doc-links.test.mjs +0 -419
  22. package/api/component/integration-export-name.test.mjs +0 -644
  23. package/api/component/integration-import-agreement.test.mjs +0 -474
  24. package/api/discover/_adapter.test.mjs +0 -839
  25. package/api/discover/_catalog-view.test.mjs +0 -129
  26. package/api/discover/_package-scanner.test.mjs +0 -117
  27. package/api/discover/detail/detail.test.mjs +0 -145
  28. package/api/discover/detail/doc/doc.test.mjs +0 -93
  29. package/api/discover/detail/item/item.test.mjs +0 -75
  30. package/api/discover/discover.test.mjs +0 -100
  31. package/api/discover/list/list.test.mjs +0 -107
  32. package/api/discover/search/search.test.mjs +0 -319
  33. package/api/docs/compiled-topics.test.mjs +0 -94
  34. package/api/docs/detail/section/section.test.mjs +0 -92
  35. package/api/docs/docOverlays.test.mjs +0 -189
  36. package/api/docs/docs-homes.test.mjs +0 -127
  37. package/api/docs/docs.depth.test.mjs +0 -134
  38. package/api/docs/docs.test.mjs +0 -315
  39. package/api/docs/guide-route-targets.test.mjs +0 -1002
  40. package/api/docs/index/index.test.mjs +0 -67
  41. package/api/docs/integration-tree.test.mjs +0 -616
  42. package/api/docs/integrationDocs.test.mjs +0 -546
  43. package/api/docs/namespace-section.test.mjs +0 -260
  44. package/api/docs/react-version-sync.test.mjs +0 -79
  45. package/api/docs/reference-blocks.test.mjs +0 -404
  46. package/api/docs/token-tables.test.mjs +0 -93
  47. package/api/doctor/built-checks.test.mjs +0 -531
  48. package/api/doctor/doctor.test.mjs +0 -1651
  49. package/api/doctor/icon-sets.test.mjs +0 -111
  50. package/api/doctor/release-checks.test.mjs +0 -156
  51. package/api/doctor/theme-checks.test.mjs +0 -884
  52. package/api/gap-report/gap-report.test.mjs +0 -1549
  53. package/api/hook/detail/detail.test.mjs +0 -53
  54. package/api/hook/detail/params/params.test.mjs +0 -39
  55. package/api/hook/hook.test.mjs +0 -75
  56. package/api/icon/all-or-nothing.test.mjs +0 -283
  57. package/api/icon/error-codes.test.mjs +0 -341
  58. package/api/icon/experimental-markers.test.mjs +0 -93
  59. package/api/icon/icon.test.mjs +0 -506
  60. package/api/icon/new-definition/new-definition.undo.test.mjs +0 -97
  61. package/api/icon/new-set/new-set.test.mjs +0 -398
  62. package/api/icon/option-pairs.test.mjs +0 -368
  63. package/api/init/init.test.mjs +0 -319
  64. package/api/init/remove/remove.test.mjs +0 -124
  65. package/api/init/user/user.test.mjs +0 -232
  66. package/api/integration/add-contribution.component-names.test.mjs +0 -186
  67. package/api/integration/add-contribution.test.mjs +0 -990
  68. package/api/integration/add-helpers.test.mjs +0 -161
  69. package/api/integration/add-theme.test.mjs +0 -676
  70. package/api/integration/authoring-checks.test.mjs +0 -1683
  71. package/api/integration/check/check.test.mjs +0 -538
  72. package/api/integration/doc-stability.test.mjs +0 -216
  73. package/api/integration/example-checks.no-npm.test.mjs +0 -140
  74. package/api/integration/example-checks.test.mjs +0 -776
  75. package/api/integration/integration-block-exports.test.mjs +0 -248
  76. package/api/integration/pack-check.component-replaces.test.mjs +0 -126
  77. package/api/integration/pack-check.lifecycle-output.test.mjs +0 -149
  78. package/api/integration/pack-check.test.mjs +0 -2512
  79. package/api/integration/public-api.test.mjs +0 -21
  80. package/api/integration/template-conflict-compatibility.test.mjs +0 -73
  81. package/api/integration/validate-installed-icon-sets.test.mjs +0 -67
  82. package/api/integration/validate-integration-case-disk.test.mjs +0 -123
  83. package/api/integration/validate-integration-fixes.test.mjs +0 -1457
  84. package/api/integration/validate-integration-gaps.test.mjs +0 -1999
  85. package/api/integration/validate-integration.test.mjs +0 -835
  86. package/api/integration/validate-unread-theme-folders.test.mjs +0 -111
  87. package/api/json/envelope-types.test.mjs +0 -76
  88. package/api/json/parse.test.mjs +0 -76
  89. package/api/render/render.test.mjs +0 -1155
  90. package/api/search/_adapter.test.mjs +0 -192
  91. package/api/search/_doc-searcher.test.mjs +0 -36
  92. package/api/search/_entries.test.mjs +0 -48
  93. package/api/search/_main-searcher.test.mjs +0 -106
  94. package/api/search/_order.test.mjs +0 -72
  95. package/api/search/_template-searcher.test.mjs +0 -40
  96. package/api/search/search-return-type.test.mjs +0 -54
  97. package/api/search/search.domain-priority.test.mjs +0 -351
  98. package/api/search/search.family-members.test.mjs +0 -124
  99. package/api/search/search.family-word.test.mjs +0 -146
  100. package/api/search/search.integration-block.test.mjs +0 -100
  101. package/api/search/search.integration-check.test.mjs +0 -24
  102. package/api/search/search.test.mjs +0 -1007
  103. package/api/search/search.tie-order.test.mjs +0 -39
  104. package/api/search/tree.test.mjs +0 -66
  105. package/api/swizzle/_github.test.mjs +0 -53
  106. package/api/swizzle/copy/copy.test.mjs +0 -60
  107. package/api/swizzle/swizzle.test.mjs +0 -157
  108. package/api/template/cdn/cdn.test.mjs +0 -108
  109. package/api/template/checkout-wizard.test.mjs +0 -87
  110. package/api/template/copy/copy.receipt.test.mjs +0 -77
  111. package/api/template/copy/copy.test.mjs +0 -77
  112. package/api/template/data-token-fallbacks.test.mjs +0 -85
  113. package/api/template/discover-integration-templates.test.mjs +0 -56
  114. package/api/template/form-wizard-dialog.test.mjs +0 -47
  115. package/api/template/inline-wizard-template.test.mjs +0 -24
  116. package/api/template/list/list.test.mjs +0 -52
  117. package/api/template/show/show.test.mjs +0 -76
  118. package/api/template/table-filter-view-tabs.test.mjs +0 -45
  119. package/api/template/table-floating-bulk-actions.test.mjs +0 -66
  120. package/api/template/template-integration.test.mjs +0 -1274
  121. package/api/template/template-suffix.test.mjs +0 -286
  122. package/api/template/template.test.mjs +0 -222
  123. package/api/template/tokenizer-showcase.test.mjs +0 -47
  124. package/api/template/unknown-name.test.mjs +0 -63
  125. package/api/theme/add/add.test.mjs +0 -363
  126. package/api/theme/add/add.types.test.mjs +0 -150
  127. package/api/theme/build/build.adaptation-core-compat.test.mjs +0 -394
  128. package/api/theme/build/build.adaptation-enrollment.test.mjs +0 -219
  129. package/api/theme/build/build.core-on-demand.test.mjs +0 -113
  130. package/api/theme/build/build.family.test.mjs +0 -503
  131. package/api/theme/build/build.font-warning.test.mjs +0 -170
  132. package/api/theme/build/build.heading-core-compat.test.mjs +0 -68
  133. package/api/theme/build/build.icon-entry-variants.test.mjs +0 -134
  134. package/api/theme/build/build.icon-function-entries.test.mjs +0 -499
  135. package/api/theme/build/build.icon-lineage.test.mjs +0 -117
  136. package/api/theme/build/build.icon-preservation.test.mjs +0 -639
  137. package/api/theme/build/build.icon-variants.test.mjs +0 -105
  138. package/api/theme/build/build.icons-specifier.test.mjs +0 -149
  139. package/api/theme/build/build.packed-old-core.test.mjs +0 -1512
  140. package/api/theme/build/build.project-core.test.mjs +0 -220
  141. package/api/theme/build/build.public-component-vars.test.mjs +0 -151
  142. package/api/theme/build/build.receipt-doc.test.mjs +0 -111
  143. package/api/theme/build/build.rollback.test.mjs +0 -148
  144. package/api/theme/build/build.test.mjs +0 -1258
  145. package/api/theme/build/font-warning.test.mjs +0 -268
  146. package/api/theme/eject/eject.binary.test.mjs +0 -90
  147. package/api/theme/eject/eject.copy-compat.test.mjs +0 -168
  148. package/api/theme/eject/eject.rollback.test.mjs +0 -158
  149. package/api/theme/eject/eject.staging.test.mjs +0 -83
  150. package/api/theme/eject/eject.test.mjs +0 -160
  151. package/api/theme/integration-themes.test.mjs +0 -218
  152. package/api/theme/list/list.test.mjs +0 -271
  153. package/api/theme/palette/generate/generate.test.mjs +0 -445
  154. package/api/theme/palette/generate/generator.test.mjs +0 -385
  155. package/api/theme/palette/generate/preview.test.mjs +0 -55
  156. package/api/theme/remove/remove.test.mjs +0 -94
  157. package/api/theme/targets/targets.test.mjs +0 -91
  158. package/api/theme/template/template.test.mjs +0 -102
  159. package/api/theme/use/use.test.mjs +0 -98
  160. package/api/upgrade/list/list.test.mjs +0 -73
  161. package/api/upgrade/project-context.test.mjs +0 -272
  162. package/api/upgrade/provider-agreement.test.mjs +0 -152
  163. package/api/upgrade/registry/registry.test.mjs +0 -911
  164. package/api/upgrade/run/authoring-codemod-reachable.test.mjs +0 -99
  165. package/api/upgrade/run/cli-behind-core.test.mjs +0 -438
  166. package/api/upgrade/run/failure-receipt.test.mjs +0 -212
  167. package/api/upgrade/run/files-changed.test.mjs +0 -111
  168. package/api/upgrade/run/outcomes.test.mjs +0 -646
  169. package/api/upgrade/run/run.test.mjs +0 -511
  170. package/api/upgrade/upgrade.test.mjs +0 -594
  171. package/assets/codemods/__tests__/registry.test.mjs +0 -77
  172. package/assets/codemods/__tests__/rename-imperative-ref-to-handleRef.test.mjs +0 -65
  173. package/assets/codemods/__tests__/rename-isStreaming-to-isStopShown.test.mjs +0 -58
  174. package/assets/codemods/__tests__/rename-section-wash-to-muted.test.mjs +0 -103
  175. package/assets/codemods/__tests__/runner.symlinks.test.mjs +0 -205
  176. package/assets/codemods/__tests__/runner.test.mjs +0 -559
  177. package/assets/codemods/__tests__/runner.unparseable.test.mjs +0 -457
  178. package/assets/codemods/__tests__/toolbar-density-to-size.test.mjs +0 -69
  179. package/assets/codemods/__tests__/validation.test.mjs +0 -108
  180. package/assets/codemods/file-count.test.mjs +0 -163
  181. package/assets/codemods/integration-discovery.test.mjs +0 -360
  182. package/assets/codemods/integration-runner.protection.test.mjs +0 -206
  183. package/assets/codemods/outcome.test.mjs +0 -40
  184. package/assets/codemods/term-log.test.mjs +0 -80
  185. package/assets/codemods/transform-prop.test.mjs +0 -130
  186. package/assets/codemods/transforms/v0.0.10/__tests__/remove-size-props.test.mjs +0 -144
  187. package/assets/codemods/transforms/v0.0.12/__tests__/add-is-icon-only.test.mjs +0 -193
  188. package/assets/codemods/transforms/v0.0.13/__tests__/icon-name-deprecations.test.mjs +0 -81
  189. package/assets/codemods/transforms/v0.0.13/__tests__/rename-attachments-to-drawer.test.mjs +0 -126
  190. package/assets/codemods/transforms/v0.0.14/__tests__/rename-action-props.test.mjs +0 -129
  191. package/assets/codemods/transforms/v0.0.14/__tests__/rename-status-variants.test.mjs +0 -126
  192. package/assets/codemods/transforms/v0.0.15/__tests__/migrate-item-children-to-endcontent.test.mjs +0 -95
  193. package/assets/codemods/transforms/v0.0.15/__tests__/migrate-selector-children-to-render-option.test.mjs +0 -109
  194. package/assets/codemods/transforms/v0.0.15/__tests__/migrate-theme-selectors-to-data-attrs.test.mjs +0 -44
  195. package/assets/codemods/transforms/v0.0.15/__tests__/rename-date-picker-to-input.test.mjs +0 -110
  196. package/assets/codemods/transforms/v0.0.15/__tests__/rename-stack-element-to-as.test.mjs +0 -71
  197. package/assets/codemods/transforms/v0.0.2/__tests__/migrate-badge-dot-to-statusdot.test.mjs +0 -137
  198. package/assets/codemods/transforms/v0.0.2/__tests__/migrate-gap-to-numeric.test.mjs +0 -161
  199. package/assets/codemods/transforms/v0.0.2/__tests__/migrate-isFullBleed-to-padding.test.mjs +0 -137
  200. package/assets/codemods/transforms/v0.0.2/__tests__/migrate-useXDSIcon-to-getIcon.test.mjs +0 -110
  201. package/assets/codemods/transforms/v0.0.2/__tests__/rename-banner-endButton-to-endContent.test.mjs +0 -61
  202. package/assets/codemods/transforms/v0.0.2/__tests__/rename-form-tooltip-startIcon.test.mjs +0 -130
  203. package/assets/codemods/transforms/v0.0.2/__tests__/rename-isShown-to-isOpen.test.mjs +0 -89
  204. package/assets/codemods/transforms/v0.0.2/__tests__/rename-selector-items-to-options.test.mjs +0 -74
  205. package/assets/codemods/transforms/v0.0.2/__tests__/rename-sidenav-header-to-heading.test.mjs +0 -140
  206. package/assets/codemods/transforms/v0.0.2/__tests__/rename-topnav-title-to-heading.test.mjs +0 -116
  207. package/assets/codemods/transforms/v0.0.2/__tests__/unify-uncontrolled-to-defaultX.test.mjs +0 -79
  208. package/assets/codemods/transforms/v0.0.2/__tests__/unify-visibility-to-onOpenChange.test.mjs +0 -130
  209. package/assets/codemods/transforms/v0.0.6/__tests__/migrate-badge-children-to-label.test.mjs +0 -46
  210. package/assets/codemods/transforms/v0.0.6/__tests__/migrate-collapse-to-collapsible.test.mjs +0 -72
  211. package/assets/codemods/transforms/v0.0.6/__tests__/migrate-radius-tokens.test.mjs +0 -98
  212. package/assets/codemods/transforms/v0.0.6/__tests__/migrate-shadow-tokens.test.mjs +0 -117
  213. package/assets/codemods/transforms/v0.0.6/__tests__/migrate-skeleton-radius.test.mjs +0 -75
  214. package/assets/codemods/transforms/v0.0.6/__tests__/migrate-token-names.test.mjs +0 -275
  215. package/assets/codemods/transforms/v0.0.7/__tests__/rename-banner-variant-to-container.test.mjs +0 -85
  216. package/assets/codemods/transforms/v0.0.8/__tests__/migrate-token-renames.test.mjs +0 -327
  217. package/assets/codemods/transforms/v0.0.8/__tests__/rename-endslot-to-endcontent.test.mjs +0 -98
  218. package/assets/codemods/transforms/v0.1.0/__tests__/drop-xds-prefix-imports.test.mjs +0 -460
  219. package/assets/codemods/transforms/v0.1.0/__tests__/migrate-xds-css-surfaces.test.mjs +0 -103
  220. package/assets/codemods/transforms/v0.1.0/__tests__/migrate-xds-declare-module.test.mjs +0 -61
  221. package/assets/codemods/transforms/v0.1.0/__tests__/migrate-xds-module-specifiers.test.mjs +0 -123
  222. package/assets/codemods/transforms/v0.1.0/__tests__/v0.1.0-ordering.test.mjs +0 -104
  223. package/assets/codemods/transforms/v0.1.2/__tests__/rename-text-color-active-to-accent.test.mjs +0 -120
  224. package/assets/codemods/transforms/v0.1.3/__tests__/migrate-layout-components-to-experimental.test.mjs +0 -574
  225. package/assets/codemods/transforms/v0.1.5/__tests__/rename-switch-label-spacing-default-to-hug.test.mjs +0 -93
  226. package/assets/codemods/transforms/v0.1.7/__tests__/migrate-table-tableprops-to-direct-props.test.mjs +0 -120
  227. package/assets/codemods/transforms/v0.1.7/__tests__/rename-table-renderprops-styles-to-xstyle.test.mjs +0 -112
  228. package/assets/codemods/transforms/v0.1.8/__tests__/rename-avatar-size-scale.test.mjs +0 -129
  229. package/assets/codemods/transforms/v0.2.0/__tests__/remove-tablist-orientation.test.mjs +0 -81
  230. package/assets/codemods/transforms/v0.2.1/__tests__/migrate-dialog-position-to-logical.test.mjs +0 -119
  231. package/assets/codemods/transforms/v0.3.0/__tests__/authoring-migration.e2e.test.mjs +0 -296
  232. package/assets/codemods/transforms/v0.3.0/__tests__/authoring-migration.tsc.test.mjs +0 -139
  233. package/assets/codemods/transforms/v0.3.0/__tests__/migrate-authoring-imports.test.mjs +0 -80
  234. package/assets/codemods/transforms/v0.3.0/__tests__/migrate-grid-minchildwidth-to-columns.test.mjs +0 -82
  235. package/assets/codemods/transforms/v0.3.0/__tests__/next-codemods.test.mjs +0 -64
  236. package/assets/codemods/transforms/v0.3.0/__tests__/rename-authoring-doctypes.test.mjs +0 -94
  237. package/assets/codemods/transforms/v0.3.0/__tests__/rename-radiogroup-arialabel-to-label.test.mjs +0 -86
  238. package/assets/codemods/transforms/v0.3.0/__tests__/unwrap-authoring-factories.test.mjs +0 -170
  239. package/assets/codemods/transforms/v0.4.0/__tests__/migrate-table-rowexpansion-to-tree.test.mjs +0 -201
  240. package/assets/codemods/transforms/v0.4.0/__tests__/next-codemods.test.mjs +0 -154
  241. package/assets/codemods/transforms/v0.5.0/__tests__/next-codemods.test.mjs +0 -127
  242. package/assets/codemods/transforms/v0.6.0/__tests__/migrate-astryx-theme-selectors-to-data-attrs.test.mjs +0 -398
  243. package/assets/codemods/transforms/v0.6.0/__tests__/next-codemods.test.mjs +0 -270
  244. package/assets/codemods/transforms/v0.6.4/__tests__/migrate-native-picker-to-presentation.test.mjs +0 -63
  245. package/assets/codemods/transforms/v0.6.4/__tests__/migrate-theme-catalog-to-descriptors.test.mjs +0 -220
  246. package/assets/codemods/transforms/v0.6.7/__tests__/migrate-copied-themes-to-descriptors.test.mjs +0 -129
  247. package/assets/codemods/transforms/v0.7.0/__tests__/migrate-deprecated-theme-surface.test.mjs +0 -523
  248. package/assets/codemods/transforms/v0.7.0/__tests__/migrate-field-input-styling.test.mjs +0 -108
  249. package/assets/codemods/transforms/v0.7.0/__tests__/preserve-bottom-sheet-content-padding.test.mjs +0 -178
  250. package/assets/codemods/transforms/v0.7.0/__tests__/rename-empty-search-results-text.test.mjs +0 -202
  251. package/assets/codemods/transforms/v0.7.0/__tests__/validate-data-token-ownership.test.mjs +0 -168
  252. package/assets/codemods/transforms/v0.7.2/__tests__/migrate-list-edge-compensation-to-edge.test.mjs +0 -120
  253. package/assets/codemods/transforms/v0.7.5/__tests__/migrate-codeblock-tokenizer-to-language.test.mjs +0 -130
  254. package/authoring/_shared/errors.test.mjs +0 -49
  255. package/authoring/codemod/parse.test.mjs +0 -99
  256. package/authoring/config/debug-composition.test.mjs +0 -92
  257. package/authoring/config/parse.test.mjs +0 -121
  258. package/authoring/debug/parse.test.mjs +0 -187
  259. package/authoring/discover/parse.test.mjs +0 -158
  260. package/authoring/doctypes/doc-stability-types.test.mjs +0 -91
  261. package/authoring/doctypes/doctypes-new.test.mjs +0 -162
  262. package/authoring/doctypes/icon-definition/parse.test.mjs +0 -78
  263. package/authoring/doctypes/icon-set/icon-names.test.mjs +0 -26
  264. package/authoring/doctypes/icon-set/parse.test.mjs +0 -179
  265. package/authoring/doctypes/load-contract.test.mjs +0 -246
  266. package/authoring/doctypes/namespace/parse.test.mjs +0 -163
  267. package/authoring/doctypes/parse.test.mjs +0 -422
  268. package/authoring/doctypes/template/parse.test.mjs +0 -198
  269. package/authoring/gap-report/parse.test.mjs +0 -172
  270. package/authoring/integration/parse.test.mjs +0 -184
  271. package/authoring/shadcn/receipt.test.mjs +0 -187
  272. package/authoring/shadcn/source-variants.test.mjs +0 -120
  273. package/clients/cli/__tests__/cliManifest.test.ts +0 -37
  274. package/clients/cli/cli-command.test.mjs +0 -166
  275. package/clients/cli/cli-exit-codes.test.mjs +0 -163
  276. package/clients/cli/command-load-failure.test.mjs +0 -83
  277. package/clients/cli/command-result-coverage.test.mjs +0 -136
  278. package/clients/cli/commands/blog.test.mjs +0 -138
  279. package/clients/cli/commands/build-theme.adaptations.test.mjs +0 -773
  280. package/clients/cli/commands/build-theme.ascii-output.test.mjs +0 -198
  281. package/clients/cli/commands/build-theme.batch-report.test.mjs +0 -349
  282. package/clients/cli/commands/build-theme.color-scheme.test.mjs +0 -136
  283. package/clients/cli/commands/build-theme.data-tokens.test.mjs +0 -92
  284. package/clients/cli/commands/build-theme.flag-docs.test.mjs +0 -110
  285. package/clients/cli/commands/build-theme.font-warning.test.mjs +0 -170
  286. package/clients/cli/commands/build-theme.icons-specifier.test.mjs +0 -350
  287. package/clients/cli/commands/build-theme.import-path.test.mjs +0 -103
  288. package/clients/cli/commands/build-theme.multi.test.mjs +0 -148
  289. package/clients/cli/commands/build-theme.outside-project.test.mjs +0 -140
  290. package/clients/cli/commands/build-theme.path-safety.test.mjs +0 -398
  291. package/clients/cli/commands/build-theme.prose.test.mjs +0 -103
  292. package/clients/cli/commands/build-theme.registry.test.mjs +0 -160
  293. package/clients/cli/commands/build-theme.variants.test.mjs +0 -560
  294. package/clients/cli/commands/build-theme.watch.test.mjs +0 -320
  295. package/clients/cli/commands/build.error-codes.test.mjs +0 -50
  296. package/clients/cli/commands/build.exit-codes-doc.test.mjs +0 -54
  297. package/clients/cli/commands/build.playbook.test.mjs +0 -75
  298. package/clients/cli/commands/build.text-fields.test.mjs +0 -81
  299. package/clients/cli/commands/cli-postinstall.test.mjs +0 -90
  300. package/clients/cli/commands/component-batch.test.mjs +0 -341
  301. package/clients/cli/commands/component-ownership.test.mjs +0 -384
  302. package/clients/cli/commands/component-package.test.mjs +0 -169
  303. package/clients/cli/commands/component-replacement.text.test.mjs +0 -316
  304. package/clients/cli/commands/component-resolution.test.mjs +0 -204
  305. package/clients/cli/commands/component.test.mjs +0 -612
  306. package/clients/cli/commands/debug-result-summary.test.mjs +0 -214
  307. package/clients/cli/commands/detail-levels.test.mjs +0 -145
  308. package/clients/cli/commands/dialog-adaptive-template.test.mjs +0 -24
  309. package/clients/cli/commands/discover.broken-integration.test.mjs +0 -163
  310. package/clients/cli/commands/discover.components-flag.test.mjs +0 -97
  311. package/clients/cli/commands/discover.icon-sets.test.mjs +0 -133
  312. package/clients/cli/commands/discover.no-source.test.mjs +0 -490
  313. package/clients/cli/commands/discover.sources.test.mjs +0 -292
  314. package/clients/cli/commands/discover.text-projection.test.mjs +0 -103
  315. package/clients/cli/commands/docs.depth.test.mjs +0 -219
  316. package/clients/cli/commands/docs.test.mjs +0 -385
  317. package/clients/cli/commands/doctor-integration.package-json.test.mjs +0 -53
  318. package/clients/cli/commands/doctor-integration.test.mjs +0 -1483
  319. package/clients/cli/commands/doctor.test.mjs +0 -509
  320. package/clients/cli/commands/empty-argument.test.mjs +0 -16
  321. package/clients/cli/commands/external-showcase.test.mjs +0 -121
  322. package/clients/cli/commands/gap-report.test.mjs +0 -412
  323. package/clients/cli/commands/hook.text-projection.test.mjs +0 -45
  324. package/clients/cli/commands/icon-authoring.test.mjs +0 -2845
  325. package/clients/cli/commands/icon-options-wiring.test.mjs +0 -158
  326. package/clients/cli/commands/icon-sets-guide.test.mjs +0 -186
  327. package/clients/cli/commands/icon.test.mjs +0 -96
  328. package/clients/cli/commands/import-hint-correctness.test.mjs +0 -293
  329. package/clients/cli/commands/init.behavior.test.mjs +0 -434
  330. package/clients/cli/commands/init.flag-help.test.mjs +0 -151
  331. package/clients/cli/commands/init.next-steps.test.mjs +0 -41
  332. package/clients/cli/commands/integration-add.controls.test.mjs +0 -132
  333. package/clients/cli/commands/integration-authoring.test.mjs +0 -288
  334. package/clients/cli/commands/integration-check.test.mjs +0 -522
  335. package/clients/cli/commands/integration-real-world.test.mjs +0 -661
  336. package/clients/cli/commands/interactive-guard.test.mjs +0 -143
  337. package/clients/cli/commands/json-contract.test.mjs +0 -216
  338. package/clients/cli/commands/no-prompt-wording.test.mjs +0 -94
  339. package/clients/cli/commands/option-pair-refusals.test.mjs +0 -37
  340. package/clients/cli/commands/outside-project.test.mjs +0 -874
  341. package/clients/cli/commands/search.test.mjs +0 -514
  342. package/clients/cli/commands/setup-nudge.test.mjs +0 -280
  343. package/clients/cli/commands/silent-success-refusals.test.mjs +0 -15
  344. package/clients/cli/commands/swizzle.path-safety.test.mjs +0 -137
  345. package/clients/cli/commands/swizzle.routing.test.mjs +0 -342
  346. package/clients/cli/commands/template-cdn.behavior.test.mjs +0 -113
  347. package/clients/cli/commands/template.copy-receipt.test.mjs +0 -60
  348. package/clients/cli/commands/template.flag-help.test.mjs +0 -124
  349. package/clients/cli/commands/template.icons.test.mjs +0 -132
  350. package/clients/cli/commands/template.path-help.test.mjs +0 -40
  351. package/clients/cli/commands/template.path-safety.test.mjs +0 -82
  352. package/clients/cli/commands/template.show-media.test.mjs +0 -62
  353. package/clients/cli/commands/template.test.mjs +0 -62
  354. package/clients/cli/commands/text-json-parity.test.mjs +0 -850
  355. package/clients/cli/commands/theme-add-lifecycle.test.mjs +0 -228
  356. package/clients/cli/commands/theme-list.behavior.test.mjs +0 -51
  357. package/clients/cli/commands/theme-palette-generate.test.mjs +0 -154
  358. package/clients/cli/commands/theme-targets.behavior.test.mjs +0 -84
  359. package/clients/cli/commands/theme-template.behavior.test.mjs +0 -97
  360. package/clients/cli/commands/upgrade.ascii-output.test.mjs +0 -101
  361. package/clients/cli/commands/upgrade.config-ordering.test.mjs +0 -342
  362. package/clients/cli/commands/upgrade.file-protection.test.mjs +0 -404
  363. package/clients/cli/commands/upgrade.flag-help.test.mjs +0 -221
  364. package/clients/cli/commands/upgrade.hook-output.test.mjs +0 -89
  365. package/clients/cli/commands/upgrade.integration-policy.test.mjs +0 -581
  366. package/clients/cli/commands/upgrade.older-cli.test.mjs +0 -160
  367. package/clients/cli/commands/upgrade.outcomes.test.mjs +0 -350
  368. package/clients/cli/commands/upgrade.subfolder-path.test.mjs +0 -97
  369. package/clients/cli/commands/upgrade.test.mjs +0 -361
  370. package/clients/cli/commands/validate-nothing-exits-nonzero.test.mjs +0 -67
  371. package/clients/cli/commands/write-failure.test.mjs +0 -175
  372. package/clients/cli/e2e-smoke.test.mjs +0 -162
  373. package/clients/cli/error-envelope-code.test.mjs +0 -38
  374. package/clients/cli/formatters/index.test.mjs +0 -262
  375. package/clients/cli/latest-version-env.test.mjs +0 -50
  376. package/clients/cli/lib/cli-error.test.mjs +0 -206
  377. package/clients/cli/lib/component-format.test.mjs +0 -246
  378. package/clients/cli/lib/define-command.test.mjs +0 -103
  379. package/clients/cli/lib/doc-text-ascii.test.mjs +0 -85
  380. package/clients/cli/lib/exit-codes.test.mjs +0 -111
  381. package/clients/cli/lib/hook-format.test.mjs +0 -35
  382. package/clients/cli/lib/json-shim.test.mjs +0 -268
  383. package/clients/cli/lib/manifest.test.mjs +0 -346
  384. package/clients/cli/lib/parse-error-format.test.mjs +0 -81
  385. package/clients/cli/lib/resolve-theme.test.mjs +0 -543
  386. package/foundation/agent-docs/agent-docs.path-safety.test.mjs +0 -1550
  387. package/foundation/agent-docs/agent-docs.test.mjs +0 -1937
  388. package/foundation/agent-docs/app-theme-workflow.test.mjs +0 -16
  389. package/foundation/agent-docs/computer-agent-text.test.mjs +0 -699
  390. package/foundation/config/config-cache.test.mjs +0 -83
  391. package/foundation/config/config-writer.test.mjs +0 -84
  392. package/foundation/config/integration-debug.test.mjs +0 -218
  393. package/foundation/config/project-themes.test.mjs +0 -119
  394. package/foundation/config/project.test.mjs +0 -931
  395. package/foundation/config/theme-private-vars.test.mjs +0 -76
  396. package/foundation/config/theme-state.test.mjs +0 -182
  397. package/foundation/debug/debug-fields.test.mjs +0 -327
  398. package/foundation/debug/integration-handlers.test.mjs +0 -267
  399. package/foundation/debug/on-event.test.mjs +0 -643
  400. package/foundation/debug/privacy-contract.test.mjs +0 -195
  401. package/foundation/debug/redact.test.mjs +0 -534
  402. package/foundation/discovery/authoring-self-docs.test.mjs +0 -202
  403. package/foundation/discovery/authoring-surface.test.mjs +0 -392
  404. package/foundation/discovery/cli-self-docs.test.mjs +0 -396
  405. package/foundation/discovery/component-discovery.export-names.test.mjs +0 -832
  406. package/foundation/discovery/component-discovery.importpath.test.mjs +0 -59
  407. package/foundation/discovery/component-discovery.test.mjs +0 -336
  408. package/foundation/discovery/component-loader.test.mjs +0 -190
  409. package/foundation/discovery/component-replacement.test.mjs +0 -520
  410. package/foundation/discovery/componentDocOverlay.test.mjs +0 -159
  411. package/foundation/discovery/copied-passages.test.mjs +0 -124
  412. package/foundation/discovery/doc-consistency.test.mjs +0 -347
  413. package/foundation/discovery/doc-fluff.test.mjs +0 -142
  414. package/foundation/discovery/doc-types.test.mjs +0 -774
  415. package/foundation/discovery/docs-discovery.test.mjs +0 -707
  416. package/foundation/discovery/docs-section-key.test.mjs +0 -246
  417. package/foundation/discovery/hook-discovery.test.mjs +0 -216
  418. package/foundation/discovery/icon-set-checks.test.mjs +0 -1018
  419. package/foundation/discovery/icon-set-discovery.test.mjs +0 -320
  420. package/foundation/discovery/icon-set-writer.test.mjs +0 -26
  421. package/foundation/discovery/integration-doc-files.test.mjs +0 -275
  422. package/foundation/discovery/module-exports.test.mjs +0 -209
  423. package/foundation/discovery/package-tsconfig.test.mjs +0 -210
  424. package/foundation/discovery/prop-drift.test.mjs +0 -2337
  425. package/foundation/discovery/runner-commands.test.mjs +0 -131
  426. package/foundation/discovery/stray-pointers.test.mjs +0 -92
  427. package/foundation/discovery/template-adapter.fixture-refs.test.mjs +0 -284
  428. package/foundation/discovery/template-adapter.integration-isolation.test.mjs +0 -94
  429. package/foundation/discovery/template-adapter.test.mjs +0 -223
  430. package/foundation/discovery/template-conflict-release.test.mjs +0 -40
  431. package/foundation/discovery/template-icons.test.mjs +0 -560
  432. package/foundation/discovery/template-needs.test.mjs +0 -306
  433. package/foundation/discovery/theme-discovery.test.mjs +0 -775
  434. package/foundation/discovery/theme-imports.test.mjs +0 -173
  435. package/foundation/discovery/theming-targets.test.mjs +0 -328
  436. package/foundation/discovery/type-match.test.mjs +0 -169
  437. package/foundation/discovery/type-text.test.mjs +0 -196
  438. package/foundation/discovery/unresolved-references.test.mjs +0 -567
  439. package/foundation/doc-compiler/bundle.test.mjs +0 -266
  440. package/foundation/doc-compiler/doc-compiler.test.mjs +0 -714
  441. package/foundation/doc-compiler/doc-loads.test.mjs +0 -1762
  442. package/foundation/doc-compiler/doc-syntax.test.mjs +0 -383
  443. package/foundation/doc-compiler/inputs.test.mjs +0 -298
  444. package/foundation/doc-compiler/links.test.mjs +0 -285
  445. package/foundation/doc-compiler/lower-doc.test.mjs +0 -495
  446. package/foundation/doc-compiler/read.test.mjs +0 -380
  447. package/foundation/doc-compiler/split-topic-keywords.test.mjs +0 -74
  448. package/foundation/doc-compiler/tree.test.mjs +0 -691
  449. package/foundation/env/cli-command.test.mjs +0 -129
  450. package/foundation/env/node-version.test.mjs +0 -103
  451. package/foundation/env/package-manager.global.test.mjs +0 -66
  452. package/foundation/env/package-manager.test.mjs +0 -910
  453. package/foundation/env/search-path.test.mjs +0 -122
  454. package/foundation/env/semver.test.mjs +0 -111
  455. package/foundation/env/user-dirs.test.mjs +0 -72
  456. package/foundation/env/user-settings.test.mjs +0 -64
  457. package/foundation/fs/file-protection.test.mjs +0 -250
  458. package/foundation/fs/listing-cache.test.mjs +0 -88
  459. package/foundation/fs/module-loader.stdout.test.mjs +0 -333
  460. package/foundation/fs/module-loader.test.mjs +0 -410
  461. package/foundation/fs/path-safety.test.mjs +0 -222
  462. package/foundation/fs/paths.test.mjs +0 -725
  463. package/foundation/fs/publish-file-eperm-mutation.test.mjs +0 -64
  464. package/foundation/fs/publish-file-hardlink-unavailable.test.mjs +0 -142
  465. package/foundation/fs/publish-file.test.mjs +0 -136
  466. package/foundation/fs/read-record.test.mjs +0 -164
  467. package/foundation/identity/provider-identity.test.mjs +0 -254
  468. package/foundation/integrations/autolink.test.mjs +0 -430
  469. package/foundation/integrations/cli-peer-version.test.mjs +0 -354
  470. package/foundation/integrations/cli-requirement.test.mjs +0 -383
  471. package/foundation/integrations/computer-integrations.test.mjs +0 -292
  472. package/foundation/integrations/contribution-inventory.test.mjs +0 -420
  473. package/foundation/integrations/integration-warnings.test.mjs +0 -191
  474. package/foundation/integrations/integrations.test.mjs +0 -818
  475. package/foundation/integrations/manifest-writer.test.mjs +0 -271
  476. package/foundation/integrations/provider-conflicts.test.mjs +0 -125
  477. package/foundation/integrations/provider-ledger.test.mjs +0 -275
  478. package/foundation/integrations/provider-resolution.test.mjs +0 -369
  479. package/foundation/integrations/public-imports.test.mjs +0 -1818
  480. package/foundation/release/cache.test.mjs +0 -923
  481. package/foundation/release/choose.test.mjs +0 -427
  482. package/foundation/release/global-state.test.mjs +0 -381
  483. package/foundation/release/handoff.e2e.test.mjs +0 -278
  484. package/foundation/release/notices.test.mjs +0 -586
  485. package/foundation/release/project.test.mjs +0 -288
  486. package/foundation/render/render.test.mjs +0 -117
  487. package/foundation/response/error-codes.test.mjs +0 -297
  488. package/foundation/response/json-contract.test.mjs +0 -235
  489. package/foundation/response/json-serialize.test.mjs +0 -66
  490. package/foundation/response/response-types.doc.test.mjs +0 -278
  491. package/foundation/route/route.test.mjs +0 -153
  492. package/foundation/runtime/hosted-runtime.test.mjs +0 -403
  493. package/foundation/runtime/package-set.test.mjs +0 -432
  494. package/foundation/text/copyright-header.test.mjs +0 -58
  495. package/foundation/text/levenshtein.test.mjs +0 -53
  496. package/foundation/text/string-utils.test.mjs +0 -175
  497. package/foundation/text/suggest-order.test.mjs +0 -312
  498. package/foundation/xle/browser-imports.test.mjs +0 -74
  499. package/foundation/xle/expand.test.mjs +0 -54
  500. package/foundation/xle/print.test.mjs +0 -50
  501. package/foundation/xle/registry.test.mjs +0 -28
  502. package/foundation/xle/xle.test.mjs +0 -382
  503. package/host/door-conformance.test.mjs +0 -274
  504. package/host/index.test.mjs +0 -302
@@ -1,1683 +0,0 @@
1
- // Copyright (c) Meta Platforms, Inc. and affiliates.
2
-
3
- /**
4
- * @file Hermetic integration authoring checks against the real Core catalogs.
5
- * @input Integration fixtures and the post-0.7 conflict projection.
6
- * @output Coverage for replacement validation and public diagnostics.
7
- * @position Unit coverage; the 0.6.x compatibility shape has its own fixture.
8
- */
9
-
10
- import {afterEach, beforeEach, describe, expect, it, vi} from 'vitest';
11
-
12
- vi.mock('../../foundation/discovery/template-conflict-release.mjs', () => ({
13
- expandedTemplateConflictSchemaActive: () => true,
14
- }));
15
- import * as fs from 'node:fs';
16
- import * as path from 'node:path';
17
- import {validateIntegration} from './validate-integration.mjs';
18
- import {discoverCoreTemplates} from '../../foundation/discovery/template-adapter.mjs';
19
- import {discoverOwnedComponents} from '../../foundation/discovery/component-discovery.mjs';
20
- import {discoverBuiltinTopics} from '../../foundation/discovery/docs-discovery.mjs';
21
- import {findCoreDir} from '../../foundation/fs/paths.mjs';
22
- import {
23
- builtinGuideFiles,
24
- loadTopicModule,
25
- } from '../../foundation/discovery/docs-discovery.mjs';
26
- import {proseWords} from '../../foundation/discovery/copied-passages.mjs';
27
- import {
28
- integrationComponentConflicts,
29
- integrationDocConflicts,
30
- integrationTemplateConflicts,
31
- shellArg,
32
- } from './authoring-checks.mjs';
33
-
34
- let tmpDir;
35
-
36
- function writeIntegration({
37
- id,
38
- name,
39
- type = 'block',
40
- root = tmpDir,
41
- replacements,
42
- withSource = true,
43
- }) {
44
- fs.mkdirSync(root, {recursive: true});
45
- fs.writeFileSync(
46
- path.join(root, 'package.json'),
47
- JSON.stringify({name: '@acme/widgets', version: '1.2.3'}),
48
- );
49
- fs.writeFileSync(
50
- path.join(root, 'astryx.integration.mjs'),
51
- `export default {templates: './templates'};\n`,
52
- );
53
- const stem = path.join(root, 'templates', id);
54
- fs.mkdirSync(path.dirname(stem), {recursive: true});
55
- fs.writeFileSync(
56
- `${stem}.doc.mjs`,
57
- `export default {type: '${type}', name: ${JSON.stringify(name)}, description: 'fixture'${replacements?.[id] == null ? '' : `, replaces: ${JSON.stringify(replacements[id])}`}};\n`,
58
- );
59
- if (!withSource) return;
60
- fs.writeFileSync(
61
- `${stem}.tsx`,
62
- 'export default function Fixture() { return null; }\n',
63
- );
64
- }
65
-
66
- function writeComponentIntegration(componentName) {
67
- fs.writeFileSync(
68
- path.join(tmpDir, 'package.json'),
69
- JSON.stringify({name: '@acme/widgets', version: '1.2.3'}),
70
- );
71
- fs.writeFileSync(
72
- path.join(tmpDir, 'astryx.integration.mjs'),
73
- `export default {components: './components'};\n`,
74
- );
75
- fs.mkdirSync(path.join(tmpDir, 'components'), {recursive: true});
76
- fs.writeFileSync(
77
- path.join(tmpDir, 'components', `${componentName}.doc.mjs`),
78
- `export default {type: 'component', name: ${JSON.stringify(componentName)}, displayName: ${JSON.stringify(componentName)}, description: 'Fixture component.', props: []};\n`,
79
- );
80
- fs.writeFileSync(
81
- path.join(tmpDir, 'components', `${componentName}.tsx`),
82
- 'export default function Fixture() { return null; }\n',
83
- );
84
- }
85
-
86
- function writeDocIntegration({name, replaces, extendsTopic}) {
87
- fs.writeFileSync(
88
- path.join(tmpDir, 'package.json'),
89
- JSON.stringify({name: '@acme/widgets', version: '1.2.3'}),
90
- );
91
- fs.writeFileSync(
92
- path.join(tmpDir, 'astryx.integration.mjs'),
93
- `export default {docs: './docs'};\n`,
94
- );
95
- fs.mkdirSync(path.join(tmpDir, 'docs'), {recursive: true});
96
- const relationship =
97
- replaces != null
98
- ? `, replaces: ${JSON.stringify(replaces)}`
99
- : extendsTopic != null
100
- ? `, extends: ${JSON.stringify(extendsTopic)}`
101
- : '';
102
- fs.writeFileSync(
103
- path.join(tmpDir, 'docs', `${name}.doc.mjs`),
104
- `export default {type: 'generic', name: ${JSON.stringify(name)}, title: 'Fixture', description: 'Fixture topic.'${relationship}, sections: [{title: 'Overview', content: [{type: 'prose', text: 'Fixture.'}]}]};\n`,
105
- );
106
- }
107
-
108
- /**
109
- * A docs-only package with one generic topic per entry: its prose, and
110
- * optionally a code block and the Core topic it replaces.
111
- * @param {{name: string, text: string, code?: string, replaces?: string}[]} topics
112
- */
113
- function writeTopics(topics) {
114
- fs.writeFileSync(
115
- path.join(tmpDir, 'package.json'),
116
- JSON.stringify({name: '@acme/widgets', version: '1.2.3'}),
117
- );
118
- fs.writeFileSync(
119
- path.join(tmpDir, 'astryx.integration.mjs'),
120
- `export default {docs: './docs'};\n`,
121
- );
122
- fs.mkdirSync(path.join(tmpDir, 'docs'), {recursive: true});
123
- for (const {name, text, code, replaces, extendsTopic} of topics) {
124
- const blocks = [{type: 'prose', text}];
125
- if (code != null) blocks.push({type: 'code', lang: 'text', code});
126
- const doc = {
127
- type: 'generic',
128
- name,
129
- title: 'Fixture',
130
- description: 'Fixture topic.',
131
- ...(replaces == null ? {} : {replaces}),
132
- ...(extendsTopic == null ? {} : {extends: extendsTopic}),
133
- sections: [{title: 'Overview', content: blocks}],
134
- };
135
- fs.writeFileSync(
136
- path.join(tmpDir, 'docs', `${name}.doc.mjs`),
137
- `export default ${JSON.stringify(doc)};\n`,
138
- );
139
- }
140
- }
141
-
142
- const PASSAGE =
143
- 'Themes cannot style the layer that holds a menu or a popover, so a menu ' +
144
- 'keeps the default surface color until the next release adds a token for it.';
145
-
146
- beforeEach(() => {
147
- tmpDir = fs.mkdtempSync(
148
- path.join(process.cwd(), '.astryx-template-conflicts-'),
149
- );
150
- });
151
-
152
- afterEach(() => {
153
- fs.rmSync(tmpDir, {recursive: true, force: true});
154
- });
155
-
156
- describe('integrationTemplateConflicts', () => {
157
- it('warns on an id shared with Core and gives the package-qualified command', async () => {
158
- const [core] = await discoverCoreTemplates();
159
- expect(core).toBeDefined();
160
- writeIntegration({
161
- id: core.dirName,
162
- name: 'Integration override',
163
- type: core.type,
164
- });
165
-
166
- const result = await integrationTemplateConflicts(undefined, {cwd: tmpDir});
167
-
168
- expect(result.type).toBe('integration.template-conflicts');
169
- expect(result.data.name).toBe('@acme/widgets');
170
- expect(result.data.issues).toEqual([]);
171
- expect(result.data.conflicts).toHaveLength(1);
172
- expect(result.data.conflicts[0]).toMatchObject({
173
- id: core.dirName,
174
- severity: 'warning',
175
- integrationPackage: '@acme/widgets',
176
- integrationName: 'Integration override',
177
- });
178
- expect(result.data.conflicts[0].message).toContain('Consider renaming');
179
- expect(result.data.conflicts[0].command).toContain(
180
- `template ${core.dirName} --package @acme/widgets`,
181
- );
182
- });
183
-
184
- it('does not flag a shared display name when the ids differ', async () => {
185
- const [core] = await discoverCoreTemplates();
186
- expect(core).toBeDefined();
187
- writeIntegration({
188
- id: 'integration-only-id',
189
- name: core.name,
190
- type: core.type,
191
- });
192
-
193
- const result = await integrationTemplateConflicts(undefined, {cwd: tmpDir});
194
-
195
- expect(result.data.conflicts).toEqual([]);
196
- expect(result.data.issues).toEqual([]);
197
- });
198
-
199
- it('loads an installed integration through the same conflict path', async () => {
200
- const [core] = await discoverCoreTemplates();
201
- expect(core).toBeDefined();
202
- const installed = path.join(tmpDir, 'node_modules', '@acme', 'widgets');
203
- writeIntegration({
204
- id: core.dirName,
205
- name: 'Installed override',
206
- type: core.type,
207
- root: installed,
208
- });
209
-
210
- const result = await integrationTemplateConflicts('@acme/widgets', {
211
- cwd: tmpDir,
212
- });
213
-
214
- expect(result.data.name).toBe('@acme/widgets');
215
- expect(result.data.conflicts.map(conflict => conflict.id)).toContain(
216
- core.dirName,
217
- );
218
- });
219
-
220
- it('classifies a valid replacement and points to the Core original', async () => {
221
- const core = (await discoverCoreTemplates()).find(
222
- template => template.type === 'page',
223
- );
224
- expect(core).toBeDefined();
225
- writeIntegration({
226
- id: 'acme-app-shell',
227
- name: 'Acme app shell',
228
- type: core.type,
229
- replacements: {'acme-app-shell': core.dirName},
230
- });
231
-
232
- const result = await integrationTemplateConflicts(undefined, {cwd: tmpDir});
233
-
234
- expect(result.data.issues).toEqual([]);
235
- expect(result.data.conflicts).toEqual([
236
- expect.objectContaining({
237
- id: 'acme-app-shell',
238
- severity: 'info',
239
- relationship: 'replaces',
240
- replaces: core.dirName,
241
- }),
242
- ]);
243
- expect(result.data.conflicts[0].command).toContain(
244
- `template ${core.dirName} --package @astryxdesign/core`,
245
- );
246
- });
247
-
248
- it('reports a replacement target that Core does not provide', async () => {
249
- writeIntegration({
250
- id: 'acme-app-shell',
251
- name: 'Acme app shell',
252
- type: 'page',
253
- replacements: {'acme-app-shell': 'missing-core-shell'},
254
- });
255
-
256
- const result = await integrationTemplateConflicts(undefined, {cwd: tmpDir});
257
-
258
- expect(result.data.issues).toEqual(
259
- expect.arrayContaining([
260
- expect.objectContaining({
261
- code: 'missing_template_replacement_target',
262
- severity: 'error',
263
- }),
264
- ]),
265
- );
266
- });
267
-
268
- it('reports a replacement declared by a template that cannot be used', async () => {
269
- const [core] = await discoverCoreTemplates();
270
- expect(core).toBeDefined();
271
- writeIntegration({
272
- id: 'broken-template',
273
- name: 'Broken template',
274
- type: core.type,
275
- replacements: {'broken-template': core.dirName},
276
- withSource: false,
277
- });
278
-
279
- const result = await integrationTemplateConflicts(undefined, {cwd: tmpDir});
280
-
281
- expect(result.data.issues).toEqual(
282
- expect.arrayContaining([
283
- expect.objectContaining({
284
- code: 'invalid_template_replacement',
285
- severity: 'error',
286
- message: expect.stringContaining('cannot be used'),
287
- }),
288
- ]),
289
- );
290
- });
291
-
292
- it('reports two templates that replace the same Core target as ambiguous', async () => {
293
- const [core] = await discoverCoreTemplates();
294
- expect(core).toBeDefined();
295
- const replacements = {
296
- 'acme-app-shell-a': core.dirName,
297
- 'acme-app-shell-b': core.dirName,
298
- };
299
- writeIntegration({
300
- id: 'acme-app-shell-a',
301
- name: 'Acme app shell A',
302
- type: core.type,
303
- replacements,
304
- });
305
- writeIntegration({
306
- id: 'acme-app-shell-b',
307
- name: 'Acme app shell B',
308
- type: core.type,
309
- replacements,
310
- });
311
-
312
- const result = await integrationTemplateConflicts(undefined, {cwd: tmpDir});
313
-
314
- expect(result.data.issues).toEqual(
315
- expect.arrayContaining([
316
- expect.objectContaining({
317
- code: 'ambiguous_template_replacement',
318
- severity: 'error',
319
- }),
320
- ]),
321
- );
322
- });
323
-
324
- it('reports a replacement whose template kind differs from Core', async () => {
325
- const corePage = (await discoverCoreTemplates()).find(
326
- template => template.type === 'page',
327
- );
328
- expect(corePage).toBeDefined();
329
- writeIntegration({
330
- id: 'acme-app-shell',
331
- name: 'Acme app shell',
332
- type: 'block',
333
- replacements: {'acme-app-shell': corePage.dirName},
334
- });
335
-
336
- const result = await integrationTemplateConflicts(undefined, {cwd: tmpDir});
337
-
338
- expect(result.data.issues).toEqual(
339
- expect.arrayContaining([
340
- expect.objectContaining({
341
- code: 'invalid_template_replacement',
342
- severity: 'error',
343
- message: expect.stringContaining('same type'),
344
- }),
345
- ]),
346
- );
347
- });
348
-
349
- it('does not recommend an impossible replacement for a different Core kind', async () => {
350
- const corePage = (await discoverCoreTemplates()).find(
351
- template => template.type === 'page',
352
- );
353
- expect(corePage).toBeDefined();
354
- writeIntegration({
355
- id: corePage.dirName,
356
- name: 'Acme block with a page id',
357
- type: 'block',
358
- });
359
-
360
- const result = await integrationTemplateConflicts(undefined, {cwd: tmpDir});
361
- const conflict = result.data.conflicts.find(
362
- item => item.id === corePage.dirName,
363
- );
364
-
365
- expect(conflict?.relationship).toBe('accidental');
366
- expect(conflict?.message).toContain(
367
- 'cannot replace a different template kind',
368
- );
369
- expect(conflict?.message).toContain('Rename');
370
- expect(conflict?.message).not.toContain('set replaces');
371
- });
372
-
373
- it('shell-quotes unusual ids instead of allowing command substitution', () => {
374
- expect(shellArg('safe/id')).toBe('safe/id');
375
- expect(shellArg('my$thing')).toBe("'my$thing'");
376
- expect(shellArg("a'b")).toBe("'a'\\''b'");
377
- expect(shellArg('foo`id`')).toBe("'foo`id`'");
378
- });
379
-
380
- it('returns a malformed template once as an invalid_template issue', async () => {
381
- fs.writeFileSync(
382
- path.join(tmpDir, 'package.json'),
383
- JSON.stringify({name: '@acme/widgets', version: '1.2.3'}),
384
- );
385
- fs.writeFileSync(
386
- path.join(tmpDir, 'astryx.integration.mjs'),
387
- `export default {templates: './templates'};\n`,
388
- );
389
- fs.mkdirSync(path.join(tmpDir, 'templates'), {recursive: true});
390
- fs.writeFileSync(
391
- path.join(tmpDir, 'templates', 'broken.doc.mjs'),
392
- `throw new Error('broken fixture');\n`,
393
- );
394
- fs.writeFileSync(
395
- path.join(tmpDir, 'templates', 'broken.tsx'),
396
- 'export default function Broken() { return null; }\n',
397
- );
398
-
399
- const result = await integrationTemplateConflicts(undefined, {cwd: tmpDir});
400
- const invalid = result.data.issues.filter(
401
- issue => issue.code === 'invalid_template',
402
- );
403
-
404
- expect(result.data.conflicts).toEqual([]);
405
- expect(invalid).toHaveLength(1);
406
- expect(invalid[0].message).toContain('broken fixture');
407
- });
408
-
409
- it('returns structural issues instead of claiming a broken integration is clean', async () => {
410
- fs.writeFileSync(
411
- path.join(tmpDir, 'package.json'),
412
- JSON.stringify({name: '@acme/widgets', version: '1.2.3'}),
413
- );
414
- fs.writeFileSync(
415
- path.join(tmpDir, 'astryx.integration.mjs'),
416
- `export default {templates: './missing'};\n`,
417
- );
418
-
419
- const result = await integrationTemplateConflicts(undefined, {cwd: tmpDir});
420
-
421
- expect(result.data.conflicts).toEqual([]);
422
- expect(
423
- result.data.issues.some(issue => issue.code === 'missing_root'),
424
- ).toBe(true);
425
- });
426
- });
427
-
428
- describe('integrationComponentConflicts', () => {
429
- it('warns on a Core component name and gives the package-qualified command', async () => {
430
- const coreDir = findCoreDir(tmpDir);
431
- expect(coreDir).not.toBeNull();
432
- const [core] = discoverOwnedComponents(coreDir, []);
433
- expect(core).toBeDefined();
434
- writeComponentIntegration(core.name);
435
-
436
- const result = await integrationComponentConflicts(undefined, {
437
- cwd: tmpDir,
438
- });
439
-
440
- expect(result.type).toBe('integration.component-conflicts');
441
- expect(result.data.issues).toEqual([]);
442
- expect(result.data.conflicts).toEqual([
443
- expect.objectContaining({
444
- name: core.name,
445
- severity: 'warning',
446
- integrationPackage: '@acme/widgets',
447
- command: expect.stringContaining(
448
- `component ${core.name} --package @acme/widgets`,
449
- ),
450
- }),
451
- ]);
452
- });
453
-
454
- it('does not flag an integration-only component name', async () => {
455
- writeComponentIntegration('AcmeOnlyWidget');
456
-
457
- const result = await integrationComponentConflicts(undefined, {
458
- cwd: tmpDir,
459
- });
460
-
461
- expect(result.data.conflicts).toEqual([]);
462
- expect(result.data.issues).toEqual([]);
463
- });
464
-
465
- it("compares each component doc's props with the component's TypeScript props, as warnings", async () => {
466
- writeComponentIntegration('AcmeBadge');
467
- fs.writeFileSync(
468
- path.join(tmpDir, 'components', 'AcmeBadge.doc.mjs'),
469
- `export default {type: 'component', name: 'AcmeBadge', displayName: 'AcmeBadge', description: 'Fixture component.', props: [{name: 'label', type: 'string', description: 'Text.', required: true}, {name: 'size', type: "'sm' | 'md'", description: 'Size.'}]};\n`,
470
- );
471
- fs.writeFileSync(
472
- path.join(tmpDir, 'components', 'AcmeBadge.tsx'),
473
- 'export function AcmeBadge(props: {label: string; count?: number}) { return null; }\n',
474
- );
475
-
476
- const result = await integrationComponentConflicts(undefined, {
477
- cwd: tmpDir,
478
- });
479
-
480
- expect(result.data.issues).toEqual([]);
481
- expect(result.data.propDrift).toMatchObject({
482
- status: 'checked',
483
- components: 1,
484
- unchecked: [],
485
- });
486
- expect(
487
- result.data.propDrift?.findings.map(f => [f.prop, f.kind, f.severity]),
488
- ).toEqual([
489
- ['count', 'not_in_doc', 'warning'],
490
- ['size', 'not_in_code', 'warning'],
491
- ]);
492
- });
493
-
494
- it('leaves propDrift out when the package has no components root', async () => {
495
- writeDocIntegration({name: 'acme-setup'});
496
-
497
- const result = await integrationComponentConflicts(undefined, {
498
- cwd: tmpDir,
499
- });
500
-
501
- expect(result.data).not.toHaveProperty('propDrift');
502
- });
503
- });
504
-
505
- describe('integrationDocConflicts', () => {
506
- it('marks an explicit Core replacement as intentional', async () => {
507
- const [coreTopic] = Object.keys(discoverBuiltinTopics());
508
- expect(coreTopic).toBeDefined();
509
- writeDocIntegration({name: 'acme-setup', replaces: coreTopic});
510
-
511
- const result = await integrationDocConflicts(undefined, {cwd: tmpDir});
512
-
513
- expect(result.type).toBe('integration.doc-conflicts');
514
- expect(result.data.issues).toEqual([]);
515
- expect(result.data.findings).toEqual([
516
- expect.objectContaining({
517
- topic: 'acme-setup',
518
- severity: 'info',
519
- relationship: 'replaces',
520
- coreTopic,
521
- }),
522
- ]);
523
- });
524
-
525
- it('marks an explicit Core extension as intentional', async () => {
526
- const [coreTopic] = Object.keys(discoverBuiltinTopics());
527
- expect(coreTopic).toBeDefined();
528
- writeDocIntegration({name: 'acme-extra', extendsTopic: coreTopic});
529
-
530
- const result = await integrationDocConflicts(undefined, {cwd: tmpDir});
531
-
532
- expect(result.data.findings).toEqual([
533
- expect.objectContaining({
534
- topic: 'acme-extra',
535
- severity: 'info',
536
- relationship: 'extends',
537
- coreTopic,
538
- }),
539
- ]);
540
- });
541
-
542
- it('reports a same-name Core topic without a relationship as accidental', async () => {
543
- const [coreTopic] = Object.keys(discoverBuiltinTopics());
544
- expect(coreTopic).toBeDefined();
545
- writeDocIntegration({name: coreTopic});
546
-
547
- const result = await integrationDocConflicts(undefined, {cwd: tmpDir});
548
-
549
- expect(result.data.findings).toEqual([
550
- expect.objectContaining({
551
- topic: coreTopic,
552
- severity: 'error',
553
- relationship: 'accidental',
554
- coreTopic,
555
- }),
556
- ]);
557
- expect(result.data.findings[0].message).toContain(
558
- `replaces: '${coreTopic}'`,
559
- );
560
- expect(result.data.findings[0].message).toContain(
561
- `extends: '${coreTopic}'`,
562
- );
563
- });
564
-
565
- it('reports a Core name as accidental when replacing a different topic', async () => {
566
- const [replacedCore, nameCore] = Object.keys(discoverBuiltinTopics());
567
- expect(replacedCore).toBeDefined();
568
- expect(nameCore).toBeDefined();
569
- writeDocIntegration({name: nameCore, replaces: replacedCore});
570
-
571
- const result = await integrationDocConflicts(undefined, {cwd: tmpDir});
572
-
573
- expect(result.data.findings).toEqual(
574
- expect.arrayContaining([
575
- expect.objectContaining({
576
- topic: nameCore,
577
- severity: 'info',
578
- relationship: 'replaces',
579
- coreTopic: replacedCore,
580
- }),
581
- expect.objectContaining({
582
- topic: nameCore,
583
- severity: 'error',
584
- relationship: 'accidental',
585
- coreTopic: nameCore,
586
- }),
587
- ]),
588
- );
589
- });
590
-
591
- it('matches Core topic identity case-insensitively like docs lookup', async () => {
592
- const [coreTopic] = Object.keys(discoverBuiltinTopics());
593
- expect(coreTopic).toBeDefined();
594
- const mixedCase = coreTopic.toUpperCase();
595
- writeDocIntegration({name: mixedCase});
596
-
597
- const result = await integrationDocConflicts(undefined, {cwd: tmpDir});
598
-
599
- expect(result.data.findings).toEqual([
600
- expect.objectContaining({
601
- topic: mixedCase,
602
- severity: 'error',
603
- relationship: 'accidental',
604
- coreTopic,
605
- }),
606
- ]);
607
- });
608
- });
609
-
610
- describe('integrationDocConflicts copied passages', () => {
611
- const copied = (/** @type {any} */ result) => result.data.copiedPassages;
612
-
613
- it('lists a passage two of the package topics repeat, and warns about it', async () => {
614
- writeTopics([
615
- {name: 'acme-setup', text: `Read this first. ${PASSAGE}`},
616
- {name: 'acme-menus', text: `${PASSAGE} See the theme guide.`},
617
- ]);
618
-
619
- const result = await integrationDocConflicts(undefined, {cwd: tmpDir});
620
- const [issue, ...rest] = copied(result);
621
- expect(result.data.issues).toEqual([
622
- {code: 'copied_passage', severity: 'warning', message: issue.message},
623
- ]);
624
-
625
- expect(rest).toEqual([]);
626
- // The passage is about menus, so "acme-menus" keeps it.
627
- expect(issue).toMatchObject({
628
- topic: 'acme-setup',
629
- otherTopic: 'acme-menus',
630
- otherOwner: 'package',
631
- owner: 'acme-menus',
632
- section: 'Overview',
633
- line: 1,
634
- words: PASSAGE.split(' ').length,
635
- passages: 1,
636
- });
637
- expect(issue.message).toContain(`${PASSAGE.split(' ').length} words`);
638
- expect(issue.text).toBe(PASSAGE);
639
- expect(issue.message).toContain(`"${PASSAGE}"`);
640
- expect(issue.message).toContain(
641
- '"acme-menus" keeps it: its name, title or section fits the passage.',
642
- );
643
- expect(issue.message).toContain(
644
- 'In "acme-setup", replace that whole passage, from its first word to its last, code ticks included, with {@link generic:acme-menus}.',
645
- );
646
- });
647
-
648
- it('reports a passage copied from a Core topic, except into the topic that replaces it', async () => {
649
- const [file] = builtinGuideFiles();
650
- const coreDoc = /** @type {any} */ (await loadTopicModule(file));
651
- const coreText = proseWords(coreDoc)
652
- .slice(0, 30)
653
- .map(each => each.word)
654
- .join(' ');
655
-
656
- writeTopics([{name: 'acme-copy', text: coreText}]);
657
- const [issue] = copied(
658
- await integrationDocConflicts(undefined, {cwd: tmpDir}),
659
- );
660
- expect(issue.otherOwner).toBe('core');
661
- expect(issue.message).toContain(`the Core topic "${coreDoc.name}"`);
662
- expect(issue.owner).toBe(coreDoc.name);
663
- expect(issue.message).toContain(
664
- `code ticks included, with {@link @astryxdesign/cli:generic:${coreDoc.name}}.`,
665
- );
666
-
667
- fs.rmSync(path.join(tmpDir, 'docs'), {recursive: true, force: true});
668
- writeTopics([{name: 'acme-own', text: coreText, replaces: coreDoc.name}]);
669
- expect(
670
- copied(await integrationDocConflicts(undefined, {cwd: tmpDir})).filter(
671
- (/** @type {any} */ each) => each.message.includes(`"${coreDoc.name}"`),
672
- ),
673
- ).toEqual([]);
674
- });
675
-
676
- it('leaves out boilerplate that three topics share', async () => {
677
- writeTopics([
678
- {name: 'acme-fonts', text: PASSAGE},
679
- {name: 'acme-icons', text: PASSAGE},
680
- {name: 'acme-media', text: PASSAGE},
681
- ]);
682
-
683
- expect(
684
- copied(await integrationDocConflicts(undefined, {cwd: tmpDir})),
685
- ).toEqual([]);
686
- });
687
-
688
- it('leaves out a run of function words, which states no fact', async () => {
689
- const glue = 'and it is in the way that you can do it for them';
690
- writeTopics([
691
- {name: 'acme-a', text: `Start here. ${glue} first.`},
692
- {name: 'acme-b', text: `Then ${glue} again.`},
693
- ]);
694
-
695
- expect(
696
- copied(await integrationDocConflicts(undefined, {cwd: tmpDir})),
697
- ).toEqual([]);
698
- });
699
-
700
- it('leaves out a shared phrase under 10 words, and code', async () => {
701
- const short = PASSAGE.split(' ').slice(0, 9).join(' ');
702
- writeTopics([
703
- {name: 'acme-a', text: PASSAGE},
704
- {name: 'acme-b', text: short},
705
- {name: 'acme-c', text: 'Run it.', code: PASSAGE},
706
- ]);
707
-
708
- expect(
709
- copied(await integrationDocConflicts(undefined, {cwd: tmpDir})),
710
- ).toEqual([]);
711
- });
712
- });
713
-
714
- describe('integrationDocConflicts copied passages and extensions', () => {
715
- const copied = (/** @type {any} */ result) => result.data.copiedPassages;
716
-
717
- it('links to the page an extension shows on, not to the extension', async () => {
718
- writeTopics([
719
- {name: 'acme-menus', text: PASSAGE, extendsTopic: 'theme'},
720
- {name: 'acme-setup', text: `${PASSAGE} Then run setup.`},
721
- ]);
722
-
723
- const [issue] = copied(
724
- await integrationDocConflicts(undefined, {cwd: tmpDir}),
725
- );
726
-
727
- expect(issue).toMatchObject({topic: 'acme-setup', owner: 'acme-menus'});
728
- expect(issue.message).toContain(
729
- 'with {@link @astryxdesign/cli:generic:theme}.',
730
- );
731
- });
732
-
733
- it('says to delete a copy in a topic that extends its owner', async () => {
734
- writeTopics([
735
- {name: 'acme-base', text: PASSAGE},
736
- {name: 'acme-more', text: PASSAGE, extendsTopic: 'acme-base'},
737
- ]);
738
-
739
- const [issue] = copied(
740
- await integrationDocConflicts(undefined, {cwd: tmpDir}),
741
- );
742
-
743
- expect(issue).toMatchObject({topic: 'acme-more', owner: 'acme-base'});
744
- expect(issue.message).toContain(
745
- '"acme-more" and "acme-base" show on the same page ("acme-base"): delete the passage from "acme-more"',
746
- );
747
- expect(issue.message).not.toContain('{@link');
748
- });
749
-
750
- it('compares pages without regard to case, and for two extensions of one page', async () => {
751
- writeTopics([
752
- {name: 'acme-colors', text: PASSAGE, extendsTopic: 'Theme'},
753
- {name: 'acme-menus', text: PASSAGE, extendsTopic: 'theme'},
754
- ]);
755
-
756
- const [issue] = copied(
757
- await integrationDocConflicts(undefined, {cwd: tmpDir}),
758
- );
759
-
760
- expect(issue.message).toContain('show on the same page ("theme")');
761
- expect(issue.message).not.toContain('{@link');
762
- });
763
-
764
- it('finds the line of the string that holds the copy, whatever it opens with', async () => {
765
- writeTopics([{name: 'acme-menus', text: PASSAGE}]);
766
- fs.writeFileSync(
767
- path.join(tmpDir, 'docs', 'acme-setup.doc.mjs'),
768
- [
769
- 'export default {',
770
- " type: 'generic',",
771
- " name: 'acme-setup',",
772
- " title: 'Fixture',",
773
- " description: 'Fixture topic.',",
774
- " sections: [{title: 'Overview', content: [",
775
- " {type: 'prose', text: '`acme` (the CLI) opens here, as {@link generic:acme-menus} says.'},",
776
- ` {type: 'prose', text: '\`acme\` (the CLI) opens here: ${PASSAGE}'},`,
777
- ' ]}],',
778
- '};',
779
- '',
780
- ].join('\n'),
781
- );
782
-
783
- const [issue] = copied(
784
- await integrationDocConflicts(undefined, {cwd: tmpDir}),
785
- );
786
-
787
- expect(issue).toMatchObject({topic: 'acme-setup', line: 8});
788
- });
789
-
790
- it('does not list a 9-word sentence that ends in a link', async () => {
791
- const sentence =
792
- 'Theme tokens control every surface color, as explained in {@link generic:acme-theme}.';
793
- writeTopics([
794
- {name: 'acme-colors', text: `Colors first. ${sentence}`},
795
- {name: 'acme-menus', text: `Menus next. ${sentence}`},
796
- ]);
797
-
798
- expect(
799
- copied(await integrationDocConflicts(undefined, {cwd: tmpDir})),
800
- ).toEqual([]);
801
- });
802
-
803
- it('counts no function word toward which topic a passage fits', async () => {
804
- writeTopics([
805
- {name: 'acme-getting-started', text: `${PASSAGE} Then run setup.`},
806
- {name: 'acme-menus', text: PASSAGE},
807
- ]);
808
- // Titles that share only function words with the passage.
809
- for (const [name, title] of [
810
- ['acme-getting-started', 'Get started with the widgets'],
811
- ['acme-menus', 'Menus'],
812
- ]) {
813
- const file = path.join(tmpDir, 'docs', `${name}.doc.mjs`);
814
- fs.writeFileSync(
815
- file,
816
- fs
817
- .readFileSync(file, 'utf8')
818
- .replace('"title":"Fixture"', `"title":"${title}"`),
819
- );
820
- }
821
-
822
- const [issue] = copied(
823
- await integrationDocConflicts(undefined, {cwd: tmpDir}),
824
- );
825
-
826
- expect(issue).toMatchObject({
827
- owner: 'acme-menus',
828
- topic: 'acme-getting-started',
829
- });
830
- });
831
-
832
- it('finds a copy after a lead-in three topics share', async () => {
833
- const lead =
834
- 'Every package ships its integration docs as plain modules the CLI reads';
835
- writeTopics([
836
- {name: 'acme-menus', text: `${lead}. ${PASSAGE}`},
837
- {name: 'acme-setup', text: `${lead}. ${PASSAGE} Then run setup.`},
838
- {name: 'acme-other', text: `${lead}. Nothing else here is shared.`},
839
- ]);
840
-
841
- const found = copied(
842
- await integrationDocConflicts(undefined, {cwd: tmpDir}),
843
- );
844
-
845
- expect(found).toHaveLength(1);
846
- expect(found[0].text).toBe(PASSAGE);
847
- });
848
-
849
- it("links to a package topic that replaces Core's by its own name", async () => {
850
- writeTopics([
851
- {name: 'theme', text: PASSAGE, replaces: 'theme'},
852
- {name: 'acme-setup', text: `${PASSAGE} Then run setup.`},
853
- ]);
854
-
855
- const found = copied(
856
- await integrationDocConflicts(undefined, {cwd: tmpDir}),
857
- );
858
-
859
- for (const each of found) {
860
- expect(each.message).not.toContain('@astryxdesign/cli:generic:theme');
861
- }
862
- expect(
863
- found.some((/** @type {any} */ each) =>
864
- each.message.includes('with {@link generic:theme}.'),
865
- ),
866
- ).toBe(true);
867
- });
868
-
869
- it('prints no link to a Core topic one of the package topics replaces', async () => {
870
- const [file] = builtinGuideFiles();
871
- const coreDoc = /** @type {any} */ (await loadTopicModule(file));
872
- const coreText = proseWords(coreDoc)
873
- .slice(0, 30)
874
- .map(each => each.word)
875
- .join(' ');
876
- writeTopics([
877
- {name: 'acme-own', text: 'Our version.', replaces: coreDoc.name},
878
- {name: 'acme-copy', text: coreText},
879
- ]);
880
-
881
- const found = copied(
882
- await integrationDocConflicts(undefined, {cwd: tmpDir}),
883
- ).filter((/** @type {any} */ each) => each.owner === coreDoc.name);
884
-
885
- expect(found).toHaveLength(1);
886
- expect(found[0].message).toContain(
887
- `"acme-own" replaces the Core topic "${coreDoc.name}"`,
888
- );
889
- expect(found[0].message).not.toContain('{@link');
890
- });
891
- });
892
-
893
- describe('integrationDocConflicts fluff', () => {
894
- const fluff = (/** @type {any} */ result) => result.data.fluff;
895
-
896
- it('lists each padding phrase with its line and what to write instead', async () => {
897
- writeTopics([
898
- {
899
- name: 'acme-setup',
900
- text: 'In order to start, run the setup command once.',
901
- },
902
- ]);
903
-
904
- const result = await integrationDocConflicts(undefined, {cwd: tmpDir});
905
- const [hit, ...rest] = fluff(result);
906
-
907
- expect(rest).toEqual([]);
908
- expect(result.data.issues).toEqual([
909
- {code: 'doc_fluff', severity: 'warning', message: hit.message},
910
- ]);
911
- expect(hit).toMatchObject({
912
- topic: 'acme-setup',
913
- kind: 'phrase',
914
- phrase: 'in order to',
915
- section: 'Overview',
916
- file: 'docs/acme-setup.doc.mjs',
917
- line: 1,
918
- density: null,
919
- });
920
- expect(hit.message).toContain('Write "to" instead.');
921
- });
922
-
923
- it('finds each line within its own string, not in code or another field', async () => {
924
- writeTopics([]);
925
- fs.writeFileSync(
926
- path.join(tmpDir, 'docs', 'acme-lines.doc.mjs'),
927
- [
928
- 'export default {',
929
- " type: 'generic',",
930
- " name: 'acme-lines',",
931
- " title: 'Fixture',",
932
- " description: 'Build the package in order to publish it.',",
933
- " sections: [{title: 'Overview', content: [",
934
- " {type: 'code', lang: 'text', code: 'in order to build'},",
935
- " {type: 'prose', text: 'Note that the build runs once per package and writes its output.'},",
936
- " {type: 'prose', text: 'Run the build in order to refresh the generated files for the docs.'},",
937
- ' ]}],',
938
- '};',
939
- '',
940
- ].join('\n'),
941
- );
942
-
943
- const found = fluff(
944
- await integrationDocConflicts(undefined, {cwd: tmpDir}),
945
- ).map((/** @type {any} */ each) => [each.phrase, each.line]);
946
-
947
- expect(found).toEqual([
948
- ['in order to', 5],
949
- ['note that', 8],
950
- ['in order to', 9],
951
- ]);
952
- });
953
-
954
- it('gives each use its own line in multi-line and concatenated strings', async () => {
955
- writeTopics([]);
956
- fs.writeFileSync(
957
- path.join(tmpDir, 'docs', 'acme-multi.doc.mjs'),
958
- [
959
- 'export default {',
960
- " type: 'generic',",
961
- " name: 'acme-multi',",
962
- " title: 'Fixture',",
963
- " description: 'Fixture topic.',",
964
- " sections: [{title: 'Overview', content: [",
965
- " {type: 'prose', text: `Build the package first.",
966
- 'Run the build in order to refresh the files.',
967
- 'Run it again in order to check them.`},',
968
- " {type: 'prose', text: 'Publishing reads the built files ' +",
969
- " 'in order to ship them, so build before you publish.'},",
970
- ' ]}],',
971
- '};',
972
- '',
973
- ].join('\n'),
974
- );
975
-
976
- const found = fluff(
977
- await integrationDocConflicts(undefined, {cwd: tmpDir}),
978
- ).map((/** @type {any} */ each) => each.line);
979
-
980
- expect(found).toEqual([8, 9, 11]);
981
- });
982
-
983
- it('finds the line of strings that open or end with code, links, quotes or escapes', async () => {
984
- writeTopics([]);
985
- fs.writeFileSync(
986
- path.join(tmpDir, 'docs', 'acme-shapes.doc.mjs'),
987
- [
988
- 'export default {',
989
- " type: 'generic',",
990
- " name: 'acme-shapes',",
991
- " title: 'Fixture',",
992
- " description: 'Fixture topic.',",
993
- " sections: [{title: 'Overview', content: [",
994
- " {type: 'prose', text: '`build` runs first, in order to check it.'},",
995
- " {type: 'prose', text: '{@link generic:acme-shapes} runs it in order to ship.'},",
996
- " {type: 'prose', text: '\"Build\" is a step you run in order to test (and ship).'},",
997
- " {type: 'prose', text: '(Build) runs it once in order to publish the app\\'s files.'},",
998
- " {type: 'prose', text: 'Run the build in order to check the files.'},",
999
- " {type: 'prose', text: 'Run the build in order to publish the files.'},",
1000
- ' ]}],',
1001
- '};',
1002
- '',
1003
- ].join('\n'),
1004
- );
1005
-
1006
- const found = fluff(
1007
- await integrationDocConflicts(undefined, {cwd: tmpDir}),
1008
- ).map((/** @type {any} */ each) => each.line);
1009
-
1010
- expect(found).toEqual([7, 8, 9, 10, 11, 12]);
1011
- });
1012
-
1013
- it('lists a long topic that is mostly glue, and not a dense one', async () => {
1014
- const glue = Array.from(
1015
- {length: 12},
1016
- () =>
1017
- 'So that is why it is the one that you would want to use if you can.',
1018
- ).join(' ');
1019
- const dense = Array.from(
1020
- {length: 8},
1021
- (_, i) =>
1022
- `Name codemod folder ${i} after the Core version whose upgrade runs it.`,
1023
- ).join(' ');
1024
- writeTopics([
1025
- {name: 'acme-glue', text: glue},
1026
- {name: 'acme-dense', text: dense},
1027
- ]);
1028
-
1029
- const found = fluff(
1030
- await integrationDocConflicts(undefined, {cwd: tmpDir}),
1031
- );
1032
-
1033
- expect(found.map((/** @type {any} */ each) => each.topic)).toEqual([
1034
- 'acme-glue',
1035
- ]);
1036
- expect(found[0]).toMatchObject({kind: 'density', phrase: null});
1037
- expect(found[0].density).toBeLessThan(0.5);
1038
- expect(found[0].message).toContain("Core's guides have a median of");
1039
- expect(found[0].message).toContain('under the 50% floor');
1040
- });
1041
- });
1042
-
1043
- describe('integrationDocConflicts stray doc pointers', () => {
1044
- const stray = (/** @type {any} */ result) => result.data.strayPointers;
1045
-
1046
- it('lists a pointer to a topic whose name holds an underscore or capitals', async () => {
1047
- writeTopics([
1048
- {name: 'acme_setup', text: 'Install it first.'},
1049
- {name: 'AcmeGuide', text: 'Read on.'},
1050
- {
1051
- name: 'acme-menus',
1052
- text: 'Set it up as `astryx docs acme_setup` says, then `astryx docs AcmeGuide`; flags such as `astryx docs -h` are not pointers.',
1053
- },
1054
- ]);
1055
-
1056
- const found = stray(
1057
- await integrationDocConflicts(undefined, {cwd: tmpDir}),
1058
- );
1059
-
1060
- expect(found.map((/** @type {any} */ each) => each.link)).toEqual([
1061
- '{@link generic:acme_setup}',
1062
- '{@link generic:AcmeGuide}',
1063
- ]);
1064
- });
1065
-
1066
- it('links a pointer to an extension topic to the page it extends', async () => {
1067
- writeTopics([
1068
- {name: 'acme-theme', text: 'Acme colors.', extendsTopic: 'theme'},
1069
- {name: 'acme-menus', text: 'Colors are in `astryx docs acme-theme`.'},
1070
- ]);
1071
-
1072
- const [hit, ...rest] = stray(
1073
- await integrationDocConflicts(undefined, {cwd: tmpDir}),
1074
- );
1075
-
1076
- expect(rest).toEqual([]);
1077
- expect(hit).toMatchObject({
1078
- topic: 'acme-menus',
1079
- link: '{@link @astryxdesign/cli:generic:theme}',
1080
- });
1081
- });
1082
-
1083
- it('places a pointer-only list item on its own line, not an earlier summary or code block', async () => {
1084
- writeTopics([{name: 'acme-menus', text: 'Menus.'}]);
1085
- fs.writeFileSync(
1086
- path.join(tmpDir, 'docs', 'acme-setup.doc.mjs'),
1087
- [
1088
- 'export default {',
1089
- " type: 'generic',",
1090
- " name: 'acme-setup',",
1091
- " title: 'Fixture',",
1092
- " summary: 'See `astryx docs acme-menus`.',",
1093
- " description: 'Fixture topic.',",
1094
- " sections: [{title: 'Overview', content: [",
1095
- " {type: 'code', lang: 'bash', code: 'astryx docs acme-menus'},",
1096
- " {type: 'list', style: 'unordered', items: ['`astryx docs acme-menus`']},",
1097
- ' ]}],',
1098
- '};',
1099
- '',
1100
- ].join('\n'),
1101
- );
1102
-
1103
- const found = stray(
1104
- await integrationDocConflicts(undefined, {cwd: tmpDir}),
1105
- ).filter((/** @type {any} */ each) => each.topic === 'acme-setup');
1106
-
1107
- // The summary's own pointer is listed too, at its line.
1108
- expect(found.map((/** @type {any} */ each) => each.line)).toEqual([5, 9]);
1109
- });
1110
-
1111
- it('lists a written pointer to a doc with the link that replaces it, and warns', async () => {
1112
- writeTopics([
1113
- {name: 'acme-setup', text: 'Install it first.'},
1114
- {
1115
- name: 'acme-menus',
1116
- text: 'Set it up as `astryx docs acme-setup` says; the theme is in `astryx docs theme`.',
1117
- },
1118
- ]);
1119
-
1120
- const result = await integrationDocConflicts(undefined, {cwd: tmpDir});
1121
- const [own, core, ...rest] = stray(result);
1122
-
1123
- expect(rest).toEqual([]);
1124
- expect(own).toMatchObject({
1125
- topic: 'acme-menus',
1126
- section: 'Overview',
1127
- file: 'docs/acme-menus.doc.mjs',
1128
- line: 1,
1129
- pointer: 'astryx docs acme-setup',
1130
- link: '{@link generic:acme-setup}',
1131
- });
1132
- expect(own.message).toContain(
1133
- 'Replace `astryx docs acme-setup`, code ticks included, with {@link generic:acme-setup}',
1134
- );
1135
- expect(core.link).toBe('{@link @astryxdesign/cli:generic:theme}');
1136
- expect(result.data.issues).toEqual([
1137
- {code: 'stray_doc_pointer', severity: 'warning', message: own.message},
1138
- {code: 'stray_doc_pointer', severity: 'warning', message: core.message},
1139
- ]);
1140
- });
1141
-
1142
- it('names a namespace doc by its kind', async () => {
1143
- writeTopics([
1144
- {name: 'acme-setup', text: 'Lay it out as `astryx docs layout` says.'},
1145
- ]);
1146
-
1147
- const [hit] = stray(
1148
- await integrationDocConflicts(undefined, {cwd: tmpDir}),
1149
- );
1150
-
1151
- expect(hit.link).toBe('{@link @astryxdesign/cli:namespace:layout}');
1152
- });
1153
-
1154
- it('finds each line in the string that holds the pointer, not in code', async () => {
1155
- writeTopics([]);
1156
- fs.writeFileSync(
1157
- path.join(tmpDir, 'docs', 'acme-lines.doc.mjs'),
1158
- [
1159
- 'export default {',
1160
- " type: 'generic',",
1161
- " name: 'acme-lines',",
1162
- " title: 'Fixture',",
1163
- " description: 'Read `astryx docs theme` first.',",
1164
- " sections: [{title: 'Overview', content: [",
1165
- " {type: 'code', lang: 'bash', code: 'astryx docs theme'},",
1166
- " {type: 'prose', text: 'The colors your package sets show up in `astryx docs theme` for every app.'},",
1167
- ' ]}],',
1168
- '};',
1169
- '',
1170
- ].join('\n'),
1171
- );
1172
-
1173
- const found = stray(
1174
- await integrationDocConflicts(undefined, {cwd: tmpDir}),
1175
- );
1176
-
1177
- // The description resolves links too, so its pointer is its own finding.
1178
- expect(found.map((/** @type {any} */ each) => each.line)).toEqual([5, 8]);
1179
- });
1180
-
1181
- it('leaves a command for a doc that does not exist, and a walkthrough', async () => {
1182
- writeTopics([
1183
- {
1184
- name: 'acme-setup',
1185
- text: 'Run `astryx docs acme-nothing`, or `astryx docs acme-setup overview`.',
1186
- },
1187
- ]);
1188
-
1189
- expect(
1190
- stray(await integrationDocConflicts(undefined, {cwd: tmpDir})),
1191
- ).toEqual([]);
1192
- });
1193
- });
1194
-
1195
- /**
1196
- * A package with one component doc and, optionally, one topic.
1197
- * @param {{usage: string, topicDescription?: string}} fixture
1198
- */
1199
- function writeLinkedComponent({usage, topicDescription}) {
1200
- fs.writeFileSync(
1201
- path.join(tmpDir, 'package.json'),
1202
- JSON.stringify({name: '@acme/widgets', version: '1.2.3'}),
1203
- );
1204
- fs.writeFileSync(
1205
- path.join(tmpDir, 'astryx.integration.mjs'),
1206
- topicDescription == null
1207
- ? `export default {components: './components'};\n`
1208
- : `export default {components: './components', docs: './docs'};\n`,
1209
- );
1210
- fs.mkdirSync(path.join(tmpDir, 'components'), {recursive: true});
1211
- const doc = {
1212
- type: 'component',
1213
- name: 'AcmeButton',
1214
- displayName: 'Acme Button',
1215
- usage: {description: usage},
1216
- props: [],
1217
- };
1218
- fs.writeFileSync(
1219
- path.join(tmpDir, 'components', 'AcmeButton.doc.mjs'),
1220
- `export default ${JSON.stringify(doc, null, 2)};\n`,
1221
- );
1222
- fs.writeFileSync(
1223
- path.join(tmpDir, 'components', 'AcmeButton.tsx'),
1224
- 'export function AcmeButton() { return null; }\n',
1225
- );
1226
- if (topicDescription == null) return;
1227
- fs.mkdirSync(path.join(tmpDir, 'docs'), {recursive: true});
1228
- const topic = {
1229
- type: 'generic',
1230
- name: 'acme-setup',
1231
- title: 'Fixture',
1232
- description: topicDescription,
1233
- sections: [
1234
- {title: 'Overview', content: [{type: 'prose', text: 'Install it.'}]},
1235
- ],
1236
- };
1237
- fs.writeFileSync(
1238
- path.join(tmpDir, 'docs', 'acme-setup.doc.mjs'),
1239
- `export default ${JSON.stringify(topic, null, 2)};\n`,
1240
- );
1241
- }
1242
-
1243
- describe('links in component docs and topic descriptions', () => {
1244
- it("warns on a component doc's link that names no doc, and passes one to its own topic", async () => {
1245
- writeLinkedComponent({
1246
- usage:
1247
- 'Set it up as {@link generic:acme-setup} says, theme it with {@link @astryxdesign/cli:generic:theme}, then {@link generic:acme-nothing}.',
1248
- topicDescription: 'Install Acme.',
1249
- });
1250
-
1251
- const {data} = await integrationComponentConflicts(undefined, {
1252
- cwd: tmpDir,
1253
- });
1254
- const links = data.issues.filter(
1255
- (/** @type {any} */ issue) => issue.code === 'invalid_doc_graph',
1256
- );
1257
- expect(links).toEqual([
1258
- {
1259
- code: 'invalid_doc_graph',
1260
- severity: 'warning',
1261
- message: expect.stringMatching(
1262
- /^component AcmeButton \(usage\.description\): "generic:acme-nothing" names no doc\./,
1263
- ),
1264
- },
1265
- ]);
1266
- });
1267
-
1268
- it("warns on a topic description's link that names no doc", async () => {
1269
- writeLinkedComponent({
1270
- usage: 'A button.',
1271
- topicDescription: 'Install Acme; see {@link generic:acme-nothing}.',
1272
- });
1273
-
1274
- const {data} = await integrationDocConflicts(undefined, {cwd: tmpDir});
1275
- const links = data.issues.filter(
1276
- (/** @type {any} */ issue) => issue.code === 'invalid_doc_graph',
1277
- );
1278
- expect(links).toEqual([
1279
- {
1280
- code: 'invalid_doc_graph',
1281
- severity: 'warning',
1282
- message: expect.stringMatching(
1283
- /^acme-setup \(description\): "generic:acme-nothing" names no doc\./,
1284
- ),
1285
- },
1286
- ]);
1287
- });
1288
-
1289
- it('lists a written pointer in a component doc, with the link that replaces it', async () => {
1290
- writeLinkedComponent({usage: 'Theme it as `astryx docs theme` says.'});
1291
-
1292
- const {data} = await integrationDocConflicts(undefined, {cwd: tmpDir});
1293
- const [pointer, ...rest] = data.strayPointers;
1294
-
1295
- expect(rest).toEqual([]);
1296
- expect(pointer).toMatchObject({
1297
- topic: 'AcmeButton',
1298
- kind: 'component',
1299
- section: null,
1300
- field: 'usage.description',
1301
- file: 'components/AcmeButton.doc.mjs',
1302
- pointer: 'astryx docs theme',
1303
- link: '{@link @astryxdesign/cli:generic:theme}',
1304
- });
1305
- expect(pointer.line).toEqual(expect.any(Number));
1306
- expect(pointer.message).toBe(
1307
- `component "AcmeButton" (field usage.description, line ${pointer.line}) points at a doc with the written command \`astryx docs theme\`. ` +
1308
- 'Replace `astryx docs theme`, code ticks included, with {@link @astryxdesign/cli:generic:theme}: the CLI prints the command that opens the doc, and doctor checks the link.',
1309
- );
1310
- expect(data.issues).toContainEqual({
1311
- code: 'stray_doc_pointer',
1312
- severity: 'warning',
1313
- message: pointer.message,
1314
- });
1315
- });
1316
-
1317
- it("lists a written pointer in a topic's description", async () => {
1318
- writeLinkedComponent({
1319
- usage: 'A button.',
1320
- topicDescription: 'Install Acme; theme it as `astryx docs theme` says.',
1321
- });
1322
-
1323
- const {data} = await integrationDocConflicts(undefined, {cwd: tmpDir});
1324
-
1325
- expect(data.strayPointers).toEqual([
1326
- expect.objectContaining({
1327
- topic: 'acme-setup',
1328
- kind: 'topic',
1329
- field: 'description',
1330
- link: '{@link @astryxdesign/cli:generic:theme}',
1331
- }),
1332
- ]);
1333
- });
1334
- });
1335
-
1336
- describe('validateIntegration runner-command notes', () => {
1337
- /** The runner-command notes, read back into their parts. */
1338
- async function runnerNotes() {
1339
- const {data} = await validateIntegration(undefined, {cwd: tmpDir});
1340
- const notes = (data.notes ?? [])
1341
- .filter((/** @type {any} */ note) => note.code === 'runner_command')
1342
- .map((/** @type {any} */ note) => {
1343
- const m =
1344
- /^(\S+): "([^"]+)"(?: \(section "([^"]+)"\))? writes `([^`]+)`(?: \(line (\d+)\))?\./.exec(
1345
- note.message,
1346
- );
1347
- return {
1348
- file: m?.[1],
1349
- topic: m?.[2],
1350
- section: m?.[3] ?? null,
1351
- command: m?.[4],
1352
- line: m?.[5] ? Number(m[5]) : null,
1353
- message: note.message,
1354
- };
1355
- });
1356
- return {data, notes};
1357
- }
1358
-
1359
- function writeTopic(/** @type {string} */ text) {
1360
- fs.writeFileSync(
1361
- path.join(tmpDir, 'package.json'),
1362
- JSON.stringify({name: '@acme/widgets', version: '1.2.3'}),
1363
- );
1364
- fs.writeFileSync(
1365
- path.join(tmpDir, 'astryx.integration.mjs'),
1366
- `export default {docs: './docs'};\n`,
1367
- );
1368
- fs.mkdirSync(path.join(tmpDir, 'docs'), {recursive: true});
1369
- const doc = {
1370
- type: 'generic',
1371
- name: 'acme-setup',
1372
- title: 'Fixture',
1373
- description: 'Fixture topic.',
1374
- sections: [
1375
- {
1376
- title: 'Overview',
1377
- content: [
1378
- {type: 'prose', text},
1379
- {type: 'code', lang: 'bash', code: 'npx @astryxdesign/cli init'},
1380
- ],
1381
- },
1382
- ],
1383
- };
1384
- fs.writeFileSync(
1385
- path.join(tmpDir, 'docs', 'acme-setup.doc.mjs'),
1386
- `export default ${JSON.stringify(doc)};\n`,
1387
- );
1388
- }
1389
-
1390
- it('lists a runner command with its line and fix, and raises no issue', async () => {
1391
- writeTopic('Check it with `pnpm exec astryx doctor` first.');
1392
-
1393
- const {data, notes} = await runnerNotes();
1394
- const [hit, ...rest] = notes;
1395
-
1396
- expect(rest).toEqual([]);
1397
- expect(hit).toMatchObject({
1398
- topic: 'acme-setup',
1399
- section: 'Overview',
1400
- file: 'docs/acme-setup.doc.mjs',
1401
- line: 1,
1402
- command: 'pnpm exec astryx doctor',
1403
- });
1404
- expect(hit.message).toContain('Write the token `{@command doctor}`');
1405
- // A note only: no issue, so no exit changes on it.
1406
- expect(
1407
- data.issues.map((/** @type {any} */ issue) => issue.code),
1408
- ).not.toContain('runner_command');
1409
- });
1410
-
1411
- it('puts each copy of a repeated command on its own line', async () => {
1412
- fs.writeFileSync(
1413
- path.join(tmpDir, 'package.json'),
1414
- JSON.stringify({name: '@acme/widgets', version: '1.2.3'}),
1415
- );
1416
- fs.writeFileSync(
1417
- path.join(tmpDir, 'astryx.integration.mjs'),
1418
- `export default {docs: './docs'};\n`,
1419
- );
1420
- fs.mkdirSync(path.join(tmpDir, 'docs'), {recursive: true});
1421
- const doc = {
1422
- type: 'generic',
1423
- name: 'acme-setup',
1424
- title: 'Fixture',
1425
- description: 'Fixture topic.',
1426
- sections: [
1427
- {
1428
- title: 'First',
1429
- content: [{type: 'prose', text: 'Run `npx astryx doctor`.'}],
1430
- },
1431
- {
1432
- title: 'Second',
1433
- content: [{type: 'prose', text: 'Run `npx astryx doctor` again.'}],
1434
- },
1435
- {
1436
- title: 'Third',
1437
- content: [{type: 'prose', text: 'Or plain `npx astryx`.'}],
1438
- },
1439
- ],
1440
- };
1441
- fs.writeFileSync(
1442
- path.join(tmpDir, 'docs', 'acme-setup.doc.mjs'),
1443
- `export default ${JSON.stringify(doc, null, 2)};\n`,
1444
- );
1445
- const lines = fs
1446
- .readFileSync(path.join(tmpDir, 'docs', 'acme-setup.doc.mjs'), 'utf8')
1447
- .split('\n');
1448
- const lineHolding = (/** @type {string} */ text) =>
1449
- lines.findIndex(line => line.includes(text)) + 1;
1450
-
1451
- const {notes} = await runnerNotes();
1452
-
1453
- expect(
1454
- notes.map((/** @type {any} */ each) => [
1455
- each.section,
1456
- each.line,
1457
- each.command,
1458
- ]),
1459
- ).toEqual([
1460
- ['First', lineHolding('Run `npx astryx doctor`.'), 'npx astryx doctor'],
1461
- ['Second', lineHolding('again.'), 'npx astryx doctor'],
1462
- ['Third', lineHolding('Or plain'), 'npx astryx'],
1463
- ]);
1464
- });
1465
-
1466
- it('puts each copy of an identical one-line string on its own line', async () => {
1467
- fs.writeFileSync(
1468
- path.join(tmpDir, 'package.json'),
1469
- JSON.stringify({name: '@acme/widgets', version: '1.2.3'}),
1470
- );
1471
- fs.writeFileSync(
1472
- path.join(tmpDir, 'astryx.integration.mjs'),
1473
- `export default {docs: './docs'};\n`,
1474
- );
1475
- fs.mkdirSync(path.join(tmpDir, 'docs'), {recursive: true});
1476
- const block = {type: 'code', lang: 'bash', code: 'npx astryx doctor'};
1477
- const doc = {
1478
- type: 'generic',
1479
- name: 'acme-setup',
1480
- title: 'Fixture',
1481
- description: 'Fixture topic.',
1482
- sections: [
1483
- {title: 'First', content: [block]},
1484
- {title: 'Second', content: [block]},
1485
- ],
1486
- };
1487
- fs.writeFileSync(
1488
- path.join(tmpDir, 'docs', 'acme-setup.doc.mjs'),
1489
- `export default ${JSON.stringify(doc, null, 2)};\n`,
1490
- );
1491
- const lines = fs
1492
- .readFileSync(path.join(tmpDir, 'docs', 'acme-setup.doc.mjs'), 'utf8')
1493
- .split('\n');
1494
- const copies = lines.flatMap((line, at) =>
1495
- line.includes('"npx astryx doctor"') ? [at + 1] : [],
1496
- );
1497
-
1498
- const {notes} = await runnerNotes();
1499
-
1500
- expect(copies).toHaveLength(2);
1501
- expect(
1502
- notes.map((/** @type {any} */ each) => [each.section, each.line]),
1503
- ).toEqual([
1504
- ['First', copies[0]],
1505
- ['Second', copies[1]],
1506
- ]);
1507
- });
1508
-
1509
- it("places a section's command on its own line when the section sits in a constant above the doc", async () => {
1510
- fs.writeFileSync(
1511
- path.join(tmpDir, 'package.json'),
1512
- JSON.stringify({name: '@acme/widgets', version: '1.2.3'}),
1513
- );
1514
- fs.writeFileSync(
1515
- path.join(tmpDir, 'astryx.integration.mjs'),
1516
- `export default {docs: './docs'};\n`,
1517
- );
1518
- fs.mkdirSync(path.join(tmpDir, 'docs'), {recursive: true});
1519
- fs.writeFileSync(
1520
- path.join(tmpDir, 'docs', 'acme-setup.doc.mjs'),
1521
- [
1522
- "const install = {title: 'Install', content: [{type: 'prose', text: 'Run `npx astryx doctor`.'}]};",
1523
- '',
1524
- 'export default {',
1525
- " type: 'generic',",
1526
- " name: 'acme-setup',",
1527
- " title: 'Fixture',",
1528
- " description: 'Install first: `npx astryx doctor`.',",
1529
- ' sections: [install],',
1530
- '};',
1531
- '',
1532
- ].join('\n'),
1533
- );
1534
-
1535
- const {notes} = await runnerNotes();
1536
-
1537
- expect(
1538
- notes.map((/** @type {any} */ each) => [each.section, each.line]),
1539
- ).toEqual(
1540
- expect.arrayContaining([
1541
- [null, 7],
1542
- ['Install', 1],
1543
- ]),
1544
- );
1545
- });
1546
-
1547
- it('lists package-manager commands, bare commands and broken tokens with the token to write, all for the next minor', async () => {
1548
- writeTopic(
1549
- 'Add it with `npm install -D @acme/widgets`, run `astryx search acme`, then {@pm add x} and {@cmd docs}. Only npm: `npm pkg set name=x`.',
1550
- );
1551
-
1552
- const {data} = await validateIntegration(undefined, {cwd: tmpDir});
1553
- const notes = (data.notes ?? []).filter(
1554
- (/** @type {any} */ note) => note.code !== 'runner_command',
1555
- );
1556
-
1557
- expect(
1558
- notes.map((/** @type {any} */ note) => [note.code, note.next]),
1559
- ).toEqual([
1560
- ['package_manager_command', true],
1561
- ['plain_command', true],
1562
- ['doc_token', true],
1563
- ['doc_token', true],
1564
- ['package_manager_command', true],
1565
- // The fixture's install step, in its bash block.
1566
- ['package_manager_command', true],
1567
- ]);
1568
- const messages = notes.map((/** @type {any} */ note) => note.message);
1569
- expect(messages[0]).toContain('{@pm install @acme/widgets --dev}');
1570
- expect(messages[1]).toContain('{@command search acme}');
1571
- expect(messages[2]).toContain('{@pm}` starts with a verb');
1572
- expect(messages[3]).toContain('Doc tokens are');
1573
- expect(messages[4]).toContain(
1574
- '{@pm-only npm "<why only npm>" pkg set name=x}',
1575
- );
1576
- expect(messages[5]).toContain('{@pm dlx @astryxdesign/cli init}');
1577
- expect(data.issues.map((/** @type {any} */ issue) => issue.code)).toEqual(
1578
- [],
1579
- );
1580
- });
1581
-
1582
- it('reads a verb named alone as a mention, and TSDoc tags in a TypeScript sample as code', async () => {
1583
- writeTopic(
1584
- 'Scripts run with `npm run`, `pnpm dlx` fetches a package, and `npm i -g`, `yarn global add` and `npm pkg set` each take one.',
1585
- );
1586
- const file = path.join(tmpDir, 'docs', 'acme-setup.doc.mjs');
1587
- fs.writeFileSync(
1588
- file,
1589
- fs.readFileSync(file, 'utf8').replace(
1590
- /\{"type":"code"[^}]*\}/,
1591
- JSON.stringify({
1592
- type: 'code',
1593
- lang: 'ts',
1594
- code: '/** {@inheritDoc Base.render} */\nexport const x = 1;',
1595
- }),
1596
- ),
1597
- );
1598
-
1599
- const {data} = await validateIntegration(undefined, {cwd: tmpDir});
1600
- expect(
1601
- (data.notes ?? []).filter((/** @type {any} */ note) =>
1602
- ['package_manager_command', 'doc_token'].includes(note.code),
1603
- ),
1604
- ).toEqual([]);
1605
- });
1606
-
1607
- it('lists a token that never closes, in prose and in any code block', async () => {
1608
- writeTopic(
1609
- 'Install with {@pm install @acme/widgets --dev before you start.',
1610
- );
1611
- const file = path.join(tmpDir, 'docs', 'acme-setup.doc.mjs');
1612
- fs.writeFileSync(
1613
- file,
1614
- fs.readFileSync(file, 'utf8').replace(
1615
- /\{"type":"code"[^}]*\}/,
1616
- JSON.stringify({
1617
- type: 'code',
1618
- lang: 'tsx',
1619
- code: '// {@pm install @acme/widgets --dev\nexport const x = 1;',
1620
- }),
1621
- ),
1622
- );
1623
-
1624
- const {data} = await validateIntegration(undefined, {cwd: tmpDir});
1625
- const tokens = (data.notes ?? []).filter(
1626
- (/** @type {any} */ note) => note.code === 'doc_token',
1627
- );
1628
- expect(tokens).toHaveLength(2);
1629
- expect(tokens[0].message).toContain('never closes');
1630
- });
1631
-
1632
- it('lists a {@command} token that names no Astryx command', async () => {
1633
- writeTopic('Run {@command dcotor} before you ship.');
1634
-
1635
- const {data} = await validateIntegration(undefined, {cwd: tmpDir});
1636
- const tokens = (data.notes ?? []).filter(
1637
- (/** @type {any} */ note) => note.code === 'doc_token',
1638
- );
1639
- expect(tokens).toHaveLength(1);
1640
- expect(tokens[0].message).toContain('`dcotor` is not an Astryx command');
1641
- });
1642
-
1643
- it('reads the command after leading global flags in a {@command} token', async () => {
1644
- writeTopic(
1645
- 'Read it as data with {@command --json component Button} or {@command --detail full docs acme}, not {@command --json dcotor}, {@command --json nosuch docs} or {@command --detail full nosuch}. Check the version with {@command --version}; {@command --json} alone names nothing.',
1646
- );
1647
- const {data} = await validateIntegration(undefined, {cwd: tmpDir});
1648
- const tokens = (data.notes ?? []).filter(
1649
- (/** @type {any} */ note) => note.code === 'doc_token',
1650
- );
1651
- expect(
1652
- tokens.map(note => note.message.match(/`(\w+)` is not/)?.[1]),
1653
- ).toEqual(['dcotor', 'nosuch', 'nosuch', undefined]);
1654
- expect(tokens[3].message).toContain('names no Astryx command');
1655
- });
1656
-
1657
- it('lists nothing for a topic written in the doc syntax', async () => {
1658
- writeTopic(
1659
- 'Add it with {@pm install @acme/widgets --dev}, run {@command docs acme}, and {@pm-only npm "only npm has pkg" pkg set name=x}. Show the syntax: {@@pm install x}.',
1660
- );
1661
- // The fixture's bash block holds a scoped install step; write it as a token.
1662
- const file = path.join(tmpDir, 'docs', 'acme-setup.doc.mjs');
1663
- fs.writeFileSync(
1664
- file,
1665
- fs
1666
- .readFileSync(file, 'utf8')
1667
- .replace(
1668
- 'npx @astryxdesign/cli init',
1669
- '{@pm dlx @astryxdesign/cli init}',
1670
- ),
1671
- );
1672
-
1673
- const {data} = await validateIntegration(undefined, {cwd: tmpDir});
1674
- expect(data.notes ?? []).toEqual([]);
1675
- });
1676
-
1677
- it('lists nothing for bare commands and the scoped install step', async () => {
1678
- writeTopic('Check it with `astryx doctor` first.');
1679
-
1680
- const {notes} = await runnerNotes();
1681
- expect((await runnerNotes()).notes).toEqual([]);
1682
- });
1683
- });