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

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