@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,1762 +0,0 @@
1
- // Copyright (c) Meta Platforms, Inc. and affiliates.
2
-
3
- /**
4
- * @file Every module in the CLI package that runs anything but its static
5
- * imports of other CLI code (a doc file, a module chosen at run time, a code
6
- * string, a thread, or a process) is listed here, site by site, with what it
7
- * runs. A doc read that goes around the doc compiler (./read.mjs) is such a
8
- * site, so it fails this test until it is listed; so does any other new
9
- * site, and a listed one that is gone.
10
- *
11
- * What it claims: every ordinary way a module runs code — the shapes code
12
- * review sees, whatever the local names. What it does not claim: that the
13
- * rule cannot be evaded on purpose. Deliberate obfuscation (a method name
14
- * built at run time, a runner stashed behind a computed key or a getter) is
15
- * out of scope; this test records what the CLI does, it does not sandbox it.
16
- * It checks where code runs, not what a computed site loads: each entry
17
- * says that.
18
- */
19
-
20
- import {describe, expect, it} from 'vitest';
21
- import * as fs from 'node:fs';
22
- import * as os from 'node:os';
23
- import * as path from 'node:path';
24
- import {isBuiltin} from 'node:module';
25
- import {parse} from '@babel/parser';
26
- import babelTypes from '@babel/types';
27
- import {CLI_ROOT} from '../fs/paths.mjs';
28
-
29
- const {VISITOR_KEYS, isReferenced, isTSType} = babelTypes;
30
-
31
- /**
32
- * Command modules build their help text from the raw exports of their own
33
- * self-docs, imported statically: those reads skip the compiler.
34
- */
35
- const SELF_DOCS = 'its self-docs, statically: raw exports build its help text';
36
-
37
- /**
38
- * Every module that runs anything but its static imports of other CLI code:
39
- * what it runs, and each site the scan finds in it (`×n` for a repeated one).
40
- * @type {Record<string, {runs: string, sites: string[]}>}
41
- */
42
- const RUNNERS = {
43
- 'api/doctor/doctor.mjs': {
44
- runs: "the project's astryx.config, for the config check",
45
- sites: ['import(<computed>)'],
46
- },
47
- 'api/gap-report/gap-report-worker.mjs': {
48
- runs: "an integration's gap-report handler, in the worker thread",
49
- sites: ['importUserModule'],
50
- },
51
- 'api/gap-report/gap-report.mjs': {
52
- runs: 'the gap-report worker thread, and `gh issue create` as the GitHub fallback',
53
- sites: ['import(node:child_process)', 'worker_threads.Worker'],
54
- },
55
- 'api/integration/pack-check.mjs': {
56
- runs: "`npm pack`, `tar`, and a Node script that resolves the packed specifiers, to check a package as published, and the package's doc modules, to see which need a newer CLI",
57
- sites: ['child_process.spawnSync ×3', 'loadTopicModule'],
58
- },
59
- 'api/swizzle/_github.mjs': {
60
- runs: '`gh auth status`, to check the GitHub CLI is signed in',
61
- sites: ['child_process.execFileSync'],
62
- },
63
- 'api/theme/_adapter.mjs': {
64
- runs: 'recorded built theme modules through the shared app-theme loader',
65
- sites: ['importThemeArtifact'],
66
- },
67
- 'api/theme/build/build.mjs': {
68
- runs: "theme source modules, through jiti; the project's installed Core",
69
- sites: [
70
- '.evalModule() ×2',
71
- '.import()',
72
- 'createJiti ×5',
73
- 'import(<computed>) ×3',
74
- ],
75
- },
76
- 'api/theme/build/core-interception.mjs': {
77
- runs: "@astryxdesign/core as a theme's CommonJS dependencies require it, to wrap defineTheme",
78
- sites: ['require(<computed>)'],
79
- },
80
- 'api/upgrade/_adapter.mjs': {
81
- runs: 'the commands a codemod declares as its post-codemod hooks',
82
- sites: ['child_process.execFile'],
83
- },
84
- 'assets/codemods/ensure-jscodeshift.mjs': {
85
- runs: 'the package manager, to install jscodeshift',
86
- sites: ['child_process.execSync'],
87
- },
88
- 'assets/codemods/integration-discovery.mjs': {
89
- runs: "each integration's codemods, through the codemod parser, to plan an upgrade",
90
- sites: ['loadModuleWithParser(..., parseCodemod)'],
91
- },
92
- 'authoring/shadcn/source-variants.mjs': {
93
- runs: "@babel/plugin-transform-typescript (CommonJS), to reproduce the ShadCN client's transform",
94
- sites: ['require(@babel/plugin-transform-typescript)'],
95
- },
96
- 'clients/cli/bin/astryx.mjs': {
97
- runs: "the CLI's own modules, by real path, so a linked bin finds them",
98
- sites: ['import(<computed>)'],
99
- },
100
- 'clients/cli/commands/blog.mjs': {
101
- runs: SELF_DOCS,
102
- sites: ['import ../../../api/blog/blog.doc.mjs', 'import ./blog.doc.mjs'],
103
- },
104
- 'clients/cli/commands/experimental/icon.mjs': {
105
- runs: SELF_DOCS,
106
- sites: [
107
- 'import ../../../../api/icon/icon.doc.mjs',
108
- 'import ../../../../api/icon/iconAdd.doc.mjs',
109
- 'import ../../../../api/icon/iconMap.doc.mjs',
110
- 'import ../../../../api/icon/iconNewDefinition.doc.mjs',
111
- 'import ../../../../api/icon/iconNewSet.doc.mjs',
112
- 'import ../../../../api/icon/iconUse.doc.mjs',
113
- 'import ../experimental-icon-add.doc.mjs',
114
- 'import ../experimental-icon-map.doc.mjs',
115
- 'import ../experimental-icon-new-definition.doc.mjs',
116
- 'import ../experimental-icon-new-set.doc.mjs',
117
- 'import ../experimental-icon-use.doc.mjs',
118
- 'import ../experimental-icon.doc.mjs',
119
- ],
120
- },
121
- 'clients/cli/commands/experimental/index.mjs': {
122
- runs: SELF_DOCS,
123
- sites: ['import ../experimental.doc.mjs'],
124
- },
125
- 'clients/cli/commands/experimental/render.mjs': {
126
- runs: SELF_DOCS,
127
- sites: [
128
- 'import ../../../../api/render/render.doc.mjs',
129
- 'import ../experimental-render.doc.mjs',
130
- ],
131
- },
132
- 'clients/cli/commands/manifest.mjs': {
133
- runs: SELF_DOCS,
134
- sites: ['import ./manifest.doc.mjs'],
135
- },
136
- 'clients/cli/commands/postinstall.mjs': {
137
- runs: SELF_DOCS,
138
- sites: ['import ./postinstall.doc.mjs'],
139
- },
140
- 'clients/cli/commands/theme.mjs': {
141
- runs: `${SELF_DOCS}; and \`astryx theme build\`, a child process per theme`,
142
- sites: [
143
- 'child_process.spawn',
144
- 'import ../../../api/theme/themeAdd.doc.mjs',
145
- 'import ../../../api/theme/themeBuild.doc.mjs',
146
- 'import ../../../api/theme/themeEject.doc.mjs',
147
- 'import ../../../api/theme/themeListAvailable.doc.mjs',
148
- 'import ../../../api/theme/themePaletteGenerate.doc.mjs',
149
- 'import ../../../api/theme/themeRemove.doc.mjs',
150
- 'import ../../../api/theme/themeTargets.doc.mjs',
151
- 'import ../../../api/theme/themeTemplate.doc.mjs',
152
- 'import ../../../api/theme/themeUse.doc.mjs',
153
- 'import ./theme-add.doc.mjs',
154
- 'import ./theme-build.doc.mjs',
155
- 'import ./theme-eject.doc.mjs',
156
- 'import ./theme-list.doc.mjs',
157
- 'import ./theme-palette-generate.doc.mjs',
158
- 'import ./theme-palette.doc.mjs',
159
- 'import ./theme-remove.doc.mjs',
160
- 'import ./theme-targets.doc.mjs',
161
- 'import ./theme-template.doc.mjs',
162
- 'import ./theme-use.doc.mjs',
163
- 'import ./theme.doc.mjs',
164
- ],
165
- },
166
- 'clients/cli/commands/build.mjs': {
167
- runs: SELF_DOCS,
168
- sites: [
169
- 'import ../../../api/build/build.doc.mjs',
170
- 'import ./build.doc.mjs',
171
- ],
172
- },
173
- 'clients/cli/commands/component.mjs': {
174
- runs: SELF_DOCS,
175
- sites: [
176
- 'import ../../../api/component/component.doc.mjs',
177
- 'import ./component.doc.mjs',
178
- ],
179
- },
180
- 'clients/cli/commands/discover.mjs': {
181
- runs: SELF_DOCS,
182
- sites: [
183
- 'import ../../../api/discover/discover.doc.mjs',
184
- 'import ./discover.doc.mjs',
185
- ],
186
- },
187
- 'clients/cli/commands/docs.mjs': {
188
- runs: SELF_DOCS,
189
- sites: ['import ../../../api/docs/docs.doc.mjs', 'import ./docs.doc.mjs'],
190
- },
191
- 'clients/cli/commands/doctor.mjs': {
192
- runs: SELF_DOCS,
193
- sites: [
194
- 'import ../../../api/doctor/doctor.doc.mjs',
195
- 'import ../../../api/integration/integrationComponentConflicts.doc.mjs',
196
- 'import ../../../api/integration/integrationDocConflicts.doc.mjs',
197
- 'import ../../../api/integration/integrationTemplateConflicts.doc.mjs',
198
- 'import ../../../api/integration/validateIntegration.doc.mjs',
199
- 'import ./doctor-integration-components.doc.mjs',
200
- 'import ./doctor-integration-docs.doc.mjs',
201
- 'import ./doctor-integration-templates.doc.mjs',
202
- 'import ./doctor-integration-validate.doc.mjs',
203
- 'import ./doctor-integration.doc.mjs',
204
- 'import ./doctor.doc.mjs',
205
- ],
206
- },
207
- 'clients/cli/commands/ensure-core-built.mjs': {
208
- runs: '`pnpm -F @astryxdesign/core build`: a test helper that builds core once for the theme-build suites',
209
- sites: ['child_process.execFileSync'],
210
- },
211
- 'clients/cli/commands/gap-report.mjs': {
212
- runs: SELF_DOCS,
213
- sites: [
214
- 'import ../../../api/gap-report/gap-report.doc.mjs',
215
- 'import ./gap-report.doc.mjs',
216
- ],
217
- },
218
- 'clients/cli/commands/hook.mjs': {
219
- runs: SELF_DOCS,
220
- sites: ['import ../../../api/hook/hook.doc.mjs', 'import ./hook.doc.mjs'],
221
- },
222
- 'clients/cli/commands/init.mjs': {
223
- runs: SELF_DOCS,
224
- sites: ['import ../../../api/init/init.doc.mjs', 'import ./init.doc.mjs'],
225
- },
226
- 'clients/cli/commands/integration.mjs': {
227
- runs: SELF_DOCS,
228
- sites: [
229
- 'import ../../../api/integration/integrationAdd.doc.mjs',
230
- 'import ../../../api/integration/integrationCheck.doc.mjs',
231
- 'import ../../../api/integration/integrationPackCheck.doc.mjs',
232
- 'import ./integration-add.doc.mjs',
233
- 'import ./integration-check.doc.mjs',
234
- 'import ./integration-pack.doc.mjs',
235
- 'import ./integration-verify.doc.mjs',
236
- 'import ./integration.doc.mjs',
237
- ],
238
- },
239
- 'clients/cli/commands/search.mjs': {
240
- runs: SELF_DOCS,
241
- sites: [
242
- 'import ../../../api/search/search.doc.mjs',
243
- 'import ./search.doc.mjs',
244
- ],
245
- },
246
- 'clients/cli/commands/swizzle.mjs': {
247
- runs: SELF_DOCS,
248
- sites: [
249
- 'import ../../../api/swizzle/swizzle.doc.mjs',
250
- 'import ./swizzle.doc.mjs',
251
- ],
252
- },
253
- 'clients/cli/commands/template.mjs': {
254
- runs: SELF_DOCS,
255
- sites: [
256
- 'import ../../../api/template/template.doc.mjs',
257
- 'import ./template.doc.mjs',
258
- ],
259
- },
260
- 'clients/cli/commands/upgrade.mjs': {
261
- runs: SELF_DOCS,
262
- sites: [
263
- 'import ../../../api/upgrade/upgrade.doc.mjs',
264
- 'import ./upgrade.doc.mjs',
265
- ],
266
- },
267
- 'clients/cli/index.mjs': {
268
- runs: 'the command modules, to register each command',
269
- sites: ['import(<computed>)'],
270
- },
271
- 'clients/cli/lib/manifest.mjs': {
272
- runs: 'the manifest command doc, for the exit codes the manifest reports',
273
- sites: ['import ../commands/manifest.doc.mjs'],
274
- },
275
- 'clients/cli/lib/resolve-theme.mjs': {
276
- runs: 'the generated record default theme, or the released package.json astryx.theme value when no record exists',
277
- sites: ['require(<computed>)'],
278
- },
279
- 'foundation/config/project.mjs': {
280
- runs: 'astryx.config, through the config parser',
281
- sites: ['loadModuleWithParser(..., parseConfig)'],
282
- },
283
- 'foundation/agent-docs/agent-docs.mjs': {
284
- runs: 'git, sl or hg, to read whether the repository ignores an untracked agent file',
285
- sites: ['child_process.spawnSync'],
286
- },
287
- 'foundation/fs/file-protection.mjs': {
288
- runs: 'the ignore matcher (CommonJS), loaded when a resolver first reads an ignore file',
289
- sites: ['require(ignore)'],
290
- },
291
- 'foundation/discovery/component-discovery.mjs': {
292
- runs: '@babel/parser, on first use, to read the members a family doc lists in its components without running the doc',
293
- sites: ['require(@babel/parser)'],
294
- },
295
- 'foundation/discovery/copied-passages.mjs': {
296
- runs: "the CLI's own guides and the package's topics, to compare their prose for passages two topics repeat",
297
- sites: ['builtinGuideFiles', 'loadTopicModule'],
298
- },
299
- 'foundation/discovery/doc-consistency.mjs': {
300
- runs: "a package's component docs and topics, to read the props, overlays, sections, and replaces/extends they declare",
301
- sites: ['importDocModule ×2'],
302
- },
303
- 'foundation/discovery/doc-stability.mjs': {
304
- runs: "an integration's template docs, to see which set `stability`",
305
- sites: ['loadTopicModule'],
306
- },
307
- 'foundation/discovery/template-icon-notes.mjs': {
308
- runs: "an integration's template docs, to read the icons each declares",
309
- sites: ['loadTopicModule'],
310
- },
311
- 'foundation/discovery/doc-fluff.mjs': {
312
- runs: "the CLI's own guides, to measure the median share of content words a topic's density is compared with",
313
- sites: ['builtinGuideFiles'],
314
- },
315
- 'foundation/discovery/docs-discovery.mjs': {
316
- runs: 'a contributed topic, for its catalog fields: name, title, description, category, and relationships',
317
- sites: ['importDocModule'],
318
- },
319
- 'foundation/discovery/runner-commands.mjs': {
320
- runs: "the package's topics, to find each Astryx command written with a package runner",
321
- sites: ['loadTopicModule'],
322
- },
323
- 'foundation/discovery/stray-pointers.mjs': {
324
- runs: "the CLI's own guides, for their names, to tell which written `astryx docs <name>` points at a doc that exists",
325
- sites: ['builtinGuideFiles'],
326
- },
327
- 'foundation/discovery/project-typescript.mjs': {
328
- runs: "the project's own typescript, for the author checks that read source and docs with it, and its package.json for the version of one they cannot use; beside TypeScript 7, which has no compiler API, the TypeScript 6 API package @typescript/typescript6",
329
- sites: [
330
- 'require(<computed>)',
331
- 'require(typescript)',
332
- 'require(typescript/package.json)',
333
- ],
334
- },
335
- 'foundation/discovery/template-adapter.mjs': {
336
- runs: '@babel/parser, to find the fixture references and page-local bindings in template source; and a template doc that does not validate, to read the replacement it declares',
337
- sites: ['importDocModule', 'require(@babel/parser)'],
338
- },
339
- 'foundation/discovery/theme-discovery.mjs': {
340
- runs: '@babel/parser and jscodeshift (CommonJS), each on first use, so listing bundled themes never loads jscodeshift',
341
- sites: ['require(@babel/parser)', 'require(jscodeshift)'],
342
- },
343
- 'foundation/doc-compiler/import.mjs': {
344
- runs: 'authored doc files, for the doc reader and discovery, and again after an edit',
345
- sites: [
346
- '.import() ×2',
347
- 'createJiti ×2',
348
- 'import(<computed>) ×4',
349
- 'importUserModule ×2',
350
- ],
351
- },
352
- 'foundation/doc-compiler/read.mjs': {
353
- runs: 'authored doc files, each one handed to the compiler, with the loader its reader has always used',
354
- sites: ['importDocModule', 'importNativeModule ×3', 'importTemplateModule'],
355
- },
356
- 'foundation/render/page-worker.mjs': {
357
- runs: 'the page `astryx experimental render` renders, its local modules, React, and the StyleX compiler, in a worker',
358
- sites: ['.import() ×3', 'createJiti ×2', 'require(@stylexjs/babel-plugin)'],
359
- },
360
- 'foundation/render/render-page.mjs': {
361
- runs: 'the render worker, so a page that never finishes can be stopped',
362
- sites: ['worker_threads.Worker'],
363
- },
364
- 'foundation/fs/module-loader.mjs': {
365
- runs: 'user modules (config, manifests, handlers, codemods): natively, through jiti, or by require for a fresh CommonJS read',
366
- sites: [
367
- '.import() ×3',
368
- 'createJiti ×3',
369
- 'import(<computed>)',
370
- 'require(<computed>)',
371
- 'require.cache',
372
- ],
373
- },
374
- 'foundation/fs/read-record.mjs': {
375
- runs: "nothing; it wraps node:fs's read calls to record the paths an operation reads, and republishes them to ESM imports",
376
- sites: ['module.syncBuiltinESMExports'],
377
- },
378
- 'foundation/fs/paths.mjs': {
379
- runs: "Yarn's pnpapi, under Plug'n'Play, to find an installed package",
380
- sites: ['require(pnpapi)'],
381
- },
382
- 'foundation/integrations/integrations.mjs': {
383
- runs: "each installed integration's manifest",
384
- sites: ['importUserModule'],
385
- },
386
- 'foundation/integrations/validate-contributions.mjs': {
387
- runs: "`npm pack --dry-run --json --ignore-scripts`, to read which files an integration's package holds when a template loads an asset (no lifecycle script runs, nothing is written)",
388
- sites: ['child_process.spawnSync'],
389
- },
390
- 'foundation/release/cache.mjs': {
391
- runs: 'npm (under npm-guard.mjs), to install and look up CLI releases in the per-user cache; each installed release once, to check it starts and reports its version; and ps (tasklist on Windows), to confirm the process a stale lock records is node or npm before ending it',
392
- sites: ['child_process.spawnSync ×5'],
393
- },
394
- 'foundation/release/npm-guard.mjs': {
395
- runs: 'npm, in a process group of its own that it ends at the time limit, on Ctrl-C, or when the run that started it goes away',
396
- sites: ['child_process.spawn'],
397
- },
398
- 'foundation/release/global-state.mjs': {
399
- runs: "the background check of the registry's `latest` release, the agent-text step, and the step that installs the global copy's own Core into the release cache, each detached",
400
- sites: ['child_process.spawn'],
401
- },
402
- 'foundation/release/handoff.mjs': {
403
- runs: "the CLI release that answers a project's run, when it is not this copy",
404
- sites: ['child_process.spawn'],
405
- },
406
- 'host/index.mjs': {
407
- runs: "another release's host entry, from one of the host's package sets, when that release answers a hosted run",
408
- sites: ['import(<computed>)'],
409
- },
410
- 'scripts/generate-cli-readme.mjs': {
411
- runs: '`astryx manifest` and the error-code and response-type docs, to write the README tables (build time, not shipped)',
412
- sites: ['child_process.spawnSync', 'import(<computed>)'],
413
- },
414
- 'scripts/sync-api-types.mjs': {
415
- runs: '`tsc`, to emit the API declarations (build time, not shipped)',
416
- sites: ['child_process.execFileSync'],
417
- },
418
- };
419
-
420
- /**
421
- * Modules that hand back whatever module or doc they are pointed at. Every
422
- * export is a loader except those named here, which hand back no module.
423
- * @type {Record<string, string[]>}
424
- */
425
- const LOADER_MODULES = {
426
- 'foundation/doc-compiler/import.mjs': [],
427
- 'foundation/fs/module-loader.mjs': ['findPresentFiles'],
428
- // loadTopicModule hands back a topic's raw doc.
429
- 'foundation/discovery/docs-discovery.mjs': [
430
- 'BUILTIN_DOCS_PACKAGE',
431
- 'DocsCatalog',
432
- 'discoverBuiltinTopics',
433
- 'discoverIntegrationDocs',
434
- 'GRAPH_BLOCK_TYPES',
435
- 'GRAPH_ONLY_FIELDS',
436
- 'isGuideRoute',
437
- 'mergeTopic',
438
- 'mergeTopicReport',
439
- 'problemsInTopic',
440
- 'withoutPosition',
441
- 'withSourceTitle',
442
- ],
443
- };
444
-
445
- /**
446
- * Built-ins that run code. Every export counts except those named here.
447
- * @type {Record<string, string[]>}
448
- */
449
- const RUNNER_BUILTINS = {
450
- child_process: [],
451
- cluster: [],
452
- inspector: [],
453
- 'inspector/promises': [],
454
- module: [
455
- 'builtinModules',
456
- 'constants',
457
- 'enableCompileCache',
458
- 'findPackageJSON',
459
- 'findSourceMap',
460
- 'flushCompileCache',
461
- 'getCompileCacheDir',
462
- 'isBuiltin',
463
- 'SourceMap',
464
- 'stripTypeScriptTypes',
465
- ],
466
- repl: [],
467
- test: [],
468
- vm: [],
469
- worker_threads: [
470
- 'BroadcastChannel',
471
- 'isMainThread',
472
- 'MessageChannel',
473
- 'MessagePort',
474
- 'parentPort',
475
- 'threadId',
476
- 'workerData',
477
- ],
478
- };
479
-
480
- /** Packages whose every export runs modules. */
481
- const RUNNER_PACKAGES = new Set(['jiti']);
482
-
483
- /** Globals that run code, and the objects they can be read from. */
484
- const RUNNER_GLOBALS = new Set([
485
- 'eval',
486
- 'Function',
487
- 'ShadowRealm',
488
- 'SharedWorker',
489
- 'Worker',
490
- ]);
491
- const GLOBAL_OBJECTS = new Set(['globalThis', 'global', 'self', 'window']);
492
-
493
- /** Members of `process` that run code. */
494
- const PROCESS_RUNNERS = new Set([
495
- 'binding',
496
- 'dlopen',
497
- 'execve',
498
- 'getBuiltinModule',
499
- ]);
500
-
501
- /** Members of `WebAssembly` that run code. */
502
- const WASM_RUNNERS = new Set([
503
- 'compile',
504
- 'compileStreaming',
505
- 'Instance',
506
- 'instantiate',
507
- 'instantiateStreaming',
508
- 'Module',
509
- ]);
510
-
511
- /** URL schemes that carry code rather than name a file in this package. */
512
- const CODE_URL = /^(?:data|blob|https?):/;
513
-
514
- /** Methods that run code whatever they are called on: jiti's, vm's, a realm's. */
515
- const RUNNER_METHODS = new Set([
516
- 'compileFunction',
517
- 'evalModule',
518
- 'import',
519
- 'importValue',
520
- 'runInContext',
521
- 'runInNewContext',
522
- 'runInThisContext',
523
- ]);
524
-
525
- /** A doc file specifier: `x.doc.mjs`, `x.doc.ts`, `x.doc.zh.mjs`, `x.doc`. */
526
- const DOC_FILE = /\.doc(?:\.[\w-]+)?(?:\.[cm]?[jt]sx?)?$/;
527
-
528
- /** Syntax that only types; it never runs. */
529
- const TYPE_ONLY = new Set([
530
- 'TSDeclareFunction',
531
- 'TSDeclareMethod',
532
- 'TSInterfaceDeclaration',
533
- 'TSTypeAliasDeclaration',
534
- 'TSTypeAnnotation',
535
- 'TSTypeParameterDeclaration',
536
- 'TSTypeParameterInstantiation',
537
- ]);
538
-
539
- /** Values whose `.constructor` reaches Function in a step or two. */
540
- const LITERALS = new Set([
541
- 'ArrayExpression',
542
- 'ArrowFunctionExpression',
543
- 'ClassExpression',
544
- 'FunctionExpression',
545
- 'NumericLiteral',
546
- 'ObjectExpression',
547
- 'RegExpLiteral',
548
- 'StringLiteral',
549
- 'TemplateLiteral',
550
- ]);
551
-
552
- /** A code file Node or jiti can run. */
553
- const CODE_FILE = /\.(?:[cm]?[jt]s|[jt]sx)$/;
554
- /** Directories that hold no code the CLI runs as itself, by name... */
555
- const UNSCANNED_NAMES = new Set(['node_modules', '__fixtures__', '__tests__']);
556
- /**
557
- * ...and the temporary folders tests create with mkdtemp (`__<prefix>_XXXXXX`)
558
- * and delete while this scan runs. Any other `__*` folder is scanned.
559
- */
560
- const TRANSIENT_DIR = /^__[a-z][a-z_]*_[A-Za-z0-9]{6}$/;
561
- /** ...and by path: tests, and the authored docs and templates. */
562
- const UNSCANNED_PATHS = new Set([
563
- 'assets/docs',
564
- 'assets/templates',
565
- 'test',
566
- 'test-utils',
567
- ]);
568
-
569
- /** @param {string} full @returns {string} */
570
- const relOf = full => path.relative(CLI_ROOT, full).split(path.sep).join('/');
571
-
572
- /**
573
- * Every code file under `dir` the CLI can run as itself: not a test, fixture,
574
- * dependency, generated `.d.mts`, or file in a hidden (transient) directory.
575
- * @param {string} dir
576
- * @returns {string[]}
577
- */
578
- function sources(dir) {
579
- return fs.readdirSync(dir, {withFileTypes: true}).flatMap(entry => {
580
- const full = path.join(dir, entry.name);
581
- if (entry.isDirectory()) {
582
- const skip =
583
- entry.name.startsWith('.') ||
584
- TRANSIENT_DIR.test(entry.name) ||
585
- UNSCANNED_NAMES.has(entry.name) ||
586
- UNSCANNED_PATHS.has(relOf(full));
587
- return skip ? [] : sources(full);
588
- }
589
- const code =
590
- CODE_FILE.test(entry.name) &&
591
- !/\.test\.[^.]+$/.test(entry.name) &&
592
- !entry.name.endsWith('.d.mts');
593
- return code ? [full] : [];
594
- });
595
- }
596
-
597
- /**
598
- * @param {string} source
599
- * @param {string} rel
600
- */
601
- function parseModule(source, rel) {
602
- const typescript = /\.[cm]?tsx?$/.test(rel);
603
- /** @type {import('@babel/parser').ParserPlugin[]} */
604
- const plugins = typescript
605
- ? [['typescript', {dts: /\.d\.[cm]?ts$/.test(rel)}]]
606
- : [];
607
- if (!typescript || rel.endsWith('x')) plugins.push('jsx');
608
- return parse(source, {
609
- sourceType: rel.endsWith('.cjs') ? 'script' : 'module',
610
- allowReturnOutsideFunction: rel.endsWith('.cjs'),
611
- plugins,
612
- });
613
- }
614
-
615
- /**
616
- * Visit every node that runs, depth first, with its ancestors.
617
- * @param {any} node
618
- * @param {any[]} ancestors
619
- * @param {(node: any, ancestors: any[]) => void} visit
620
- */
621
- function walk(node, ancestors, visit) {
622
- if (typeof node?.type !== 'string') return;
623
- if (TYPE_ONLY.has(node.type) || isTSType(node) || node.declare) return;
624
- if (node.importKind === 'type' || node.exportKind === 'type') return;
625
- visit(node, ancestors);
626
- ancestors.push(node);
627
- for (const key of VISITOR_KEYS[node.type] ?? []) {
628
- for (const child of [node[key]].flat()) walk(child, ancestors, visit);
629
- }
630
- ancestors.pop();
631
- }
632
-
633
- /** @param {any} node @returns {string | undefined} */
634
- function stringValue(node) {
635
- if (node?.type === 'StringLiteral') return node.value;
636
- if (node?.type === 'TemplateLiteral' && node.expressions.length === 0) {
637
- return node.quasis[0].value.cooked;
638
- }
639
- return undefined;
640
- }
641
-
642
- /** @param {any} node @returns {string} */
643
- const nameOf = node => (node.type === 'Identifier' ? node.name : node.value);
644
-
645
- /** @param {any} node @returns {boolean} */
646
- const isMember = node =>
647
- node?.type === 'MemberExpression' ||
648
- node?.type === 'OptionalMemberExpression';
649
-
650
- /** @param {any} node @returns {boolean} */
651
- const isCall = node =>
652
- node?.type === 'CallExpression' ||
653
- node?.type === 'OptionalCallExpression' ||
654
- node?.type === 'NewExpression';
655
-
656
- /** @param {any} member @returns {string | undefined} */
657
- const memberName = member =>
658
- member.computed ? stringValue(member.property) : member.property.name;
659
-
660
- /** @param {string} specifier */
661
- const withoutQuery = specifier => specifier.replace(/[?#].*$/, '');
662
-
663
- /**
664
- * @typedef {object} Target
665
- * @property {'doc' | 'url' | 'unscanned' | 'loader' | 'builtin' | 'package'}
666
- * kind — `url`: code carried by the specifier or fetched, not a file in this
667
- * package; `unscanned`: a file in a part of the package this test does not
668
- * scan
669
- * @property {string} key
670
- */
671
-
672
- /**
673
- * What an import specifier names, seen from `rel`, when it matters here.
674
- * @param {string} specifier
675
- * @param {string} rel
676
- * @returns {Target | null}
677
- */
678
- function targetOf(specifier, rel) {
679
- if (CODE_URL.test(specifier)) return {kind: 'url', key: specifier};
680
- let file = withoutQuery(specifier);
681
- const local = /^(?:\.|\/|file:)/.test(file);
682
- if (local) {
683
- try {
684
- file = decodeURIComponent(file);
685
- } catch {
686
- // A malformed escape names no file; compare it as written.
687
- }
688
- }
689
- if (DOC_FILE.test(file)) return {kind: 'doc', key: specifier};
690
- if (isBuiltin(file)) {
691
- const name = file.replace(/^node:/, '');
692
- return Object.hasOwn(RUNNER_BUILTINS, name)
693
- ? {kind: 'builtin', key: name}
694
- : null;
695
- }
696
- if (local) {
697
- const resolved = file.startsWith('.')
698
- ? path.posix.join(path.posix.dirname(rel), file)
699
- : file.replace(/^file:\/\//, '');
700
- // Extension-free and case-free: TypeScript and case-insensitive disks
701
- // resolve both.
702
- /** @param {string} p */
703
- const stem = p =>
704
- p.toLowerCase().replace(/(?:\/index)?\.[cm]?[jt]sx?$/, '');
705
- const loader = Object.keys(LOADER_MODULES).find(
706
- mod =>
707
- stem(resolved) === stem(mod) ||
708
- stem(resolved).endsWith(`/${stem(mod)}`),
709
- );
710
- if (loader) return {kind: 'loader', key: loader};
711
- const unscanned =
712
- [...UNSCANNED_PATHS].some(dir => resolved.startsWith(`${dir}/`)) ||
713
- resolved
714
- .split('/')
715
- .slice(0, -1)
716
- .some(
717
- part =>
718
- UNSCANNED_NAMES.has(part) ||
719
- TRANSIENT_DIR.test(part) ||
720
- (part.startsWith('.') && part !== '..'),
721
- ) ||
722
- /\.test\.[^./]+$/.test(resolved);
723
- return unscanned ? {kind: 'unscanned', key: specifier} : null;
724
- }
725
- const pkg = file
726
- .split('/')
727
- .slice(0, file.startsWith('@') ? 2 : 1)
728
- .join('/');
729
- return RUNNER_PACKAGES.has(pkg) ? {kind: 'package', key: pkg} : null;
730
- }
731
-
732
- /** Targets whose every export is code this test does not read. */
733
- const UNREAD = new Set(['doc', 'unscanned', 'url']);
734
-
735
- /** @param {Target} target @returns {string[]} */
736
- function inertExports(target) {
737
- if (target.kind === 'loader') return LOADER_MODULES[target.key];
738
- if (target.kind === 'builtin') return RUNNER_BUILTINS[target.key];
739
- return [];
740
- }
741
-
742
- /**
743
- * Every ordinary place `source` runs code outside its static imports, as
744
- * labels (deliberate obfuscation is out of scope, as the file header says):
745
- *
746
- * - a static import or re-export of a doc file, or of a file this test does
747
- * not scan;
748
- * - a use of a loader module's export under any local name: called, passed,
749
- * re-exported, or read off a namespace;
750
- * - `import()` of a computed specifier, a doc file, a loader module, or a
751
- * built-in or package that runs code;
752
- * - a require function, CommonJS or from createRequire, called or passed on
753
- * (resolving is not running);
754
- * - an export of jiti, or a code-running export of child_process, cluster,
755
- * inspector, module, repl, test, vm, or worker_threads, imported or
756
- * fetched with getBuiltinModule;
757
- * - eval, Function (also as any called `.constructor`), ShadowRealm, a
758
- * global Worker, `module.require`; a jiti, vm, or realm method on anything;
759
- * - a doc file resolved as a module.
760
- *
761
- * Names are matched without scope analysis, so a shadowing local cannot hide
762
- * a loader; it can only add a site.
763
- * @param {string} source
764
- * @param {string} rel path under packages/cli
765
- * @returns {{sites: string[], problems: string[]}}
766
- */
767
- function scanModule(source, rel) {
768
- const program = parseModule(source, rel).program;
769
- /** @type {string[]} */
770
- const sites = [];
771
- /** @type {string[]} */
772
- const problems = [];
773
- /** @type {Map<string, {target: Target, imported: string | null}>} */
774
- const bindings = new Map();
775
- /** Local names holding a require function; CommonJS has `require`. */
776
- const requires = new Set(['require']);
777
- /** Local names holding the global object. */
778
- const globals = new Set(GLOBAL_OBJECTS);
779
-
780
- walk(program, [], node => {
781
- if (node.type === 'ImportDeclaration') {
782
- const target = targetOf(node.source.value, rel);
783
- if (!target || UNREAD.has(target.kind)) return;
784
- for (const specifier of node.specifiers) {
785
- if (specifier.importKind === 'type') continue;
786
- const imported =
787
- specifier.type === 'ImportSpecifier'
788
- ? nameOf(specifier.imported)
789
- : null;
790
- bindings.set(specifier.local.name, {
791
- target,
792
- imported: imported === 'default' ? null : imported,
793
- });
794
- }
795
- } else if (
796
- node.type === 'TSImportEqualsDeclaration' &&
797
- node.moduleReference.type === 'TSExternalModuleReference'
798
- ) {
799
- const target = targetOf(node.moduleReference.expression.value, rel);
800
- if (target && !UNREAD.has(target.kind)) {
801
- bindings.set(node.id.name, {target, imported: null});
802
- }
803
- }
804
- });
805
-
806
- /** @param {any} expr `createRequire` from `module`, under any name */
807
- const isCreateRequire = expr => {
808
- const id = isMember(expr) ? expr.object : expr;
809
- const binding = id?.type === 'Identifier' ? bindings.get(id.name) : null;
810
- if (binding?.target.kind !== 'builtin' || binding.target.key !== 'module') {
811
- return false;
812
- }
813
- return isMember(expr)
814
- ? binding.imported === null && memberName(expr) === 'createRequire'
815
- : binding.imported === 'createRequire';
816
- };
817
- // A name bound to a require function or to the global object stands in for
818
- // it, and is bound before it is used.
819
- walk(program, [], node => {
820
- const [id, value] =
821
- node.type === 'VariableDeclarator'
822
- ? [node.id, node.init]
823
- : node.type === 'AssignmentExpression'
824
- ? [node.left, node.right]
825
- : [];
826
- if (id?.type !== 'Identifier') return;
827
- if (isCall(value) && isCreateRequire(value.callee)) requires.add(id.name);
828
- if (value?.type === 'Identifier' && globals.has(value.name)) {
829
- globals.add(id.name);
830
- }
831
- });
832
-
833
- /**
834
- * `const {eval: e} = globalThis`: taking the member is the site, whatever
835
- * the local name.
836
- * @param {any} pattern
837
- * @param {ReadonlySet<string>} runners
838
- * @param {string} owner
839
- */
840
- const destructured = (pattern, runners, owner) => {
841
- if (pattern?.type !== 'ObjectPattern') return;
842
- for (const property of pattern.properties) {
843
- const name =
844
- property.type === 'ObjectProperty'
845
- ? property.computed
846
- ? stringValue(property.key)
847
- : nameOf(property.key)
848
- : undefined;
849
- if (name === undefined) sites.push(`${owner}[<computed>]`);
850
- else if (runners.has(name)) sites.push(name);
851
- }
852
- };
853
-
854
- /** @param {any} node */
855
- const docResolve = node => {
856
- const specifier = stringValue(node);
857
- if (specifier !== undefined && DOC_FILE.test(withoutQuery(specifier))) {
858
- sites.push(`resolve(${specifier})`);
859
- }
860
- };
861
-
862
- /** @param {any} call */
863
- const requireCall = call => {
864
- const specifier = stringValue(call.arguments[0]);
865
- if (
866
- specifier !== undefined &&
867
- isBuiltin(specifier) &&
868
- !targetOf(specifier, rel)
869
- ) {
870
- return;
871
- }
872
- sites.push(`require(${specifier ?? '<computed>'})`);
873
- };
874
-
875
- /**
876
- * `process.getBuiltinModule`: a built-in without an import.
877
- * @param {any} call
878
- */
879
- const builtinGetter = call => {
880
- const specifier = stringValue(call.arguments[0]);
881
- if (specifier === undefined) sites.push('getBuiltinModule(<computed>)');
882
- else if (targetOf(specifier, rel)) {
883
- sites.push(`getBuiltinModule(${specifier})`);
884
- }
885
- };
886
-
887
- /**
888
- * `createRequire`: a site unless the require function it makes is kept by
889
- * name (tracked above), only resolves, or runs right here.
890
- * @param {any} ref
891
- * @param {any[]} ancestors
892
- */
893
- const createRequireSite = (ref, ancestors) => {
894
- const call = ancestors.at(-1);
895
- const up = ancestors.at(-2);
896
- const kept =
897
- (up?.type === 'VariableDeclarator' && up.init === call) ||
898
- (up?.type === 'AssignmentExpression' && up.right === call);
899
- if (!isCall(call) || call.callee !== ref) sites.push('createRequire');
900
- else if (isCall(up) && up.callee === call) requireCall(up);
901
- else if (isMember(up) && up.object === call) {
902
- if (memberName(up) !== 'resolve') sites.push('createRequire');
903
- } else if (!kept || (up.id ?? up.left).type !== 'Identifier') {
904
- sites.push('createRequire');
905
- }
906
- };
907
-
908
- /**
909
- * `loadModuleWithParser`: the parser it is handed says what it loads.
910
- * @param {any} ref
911
- * @param {any[]} ancestors
912
- */
913
- const parserSite = (ref, ancestors) => {
914
- const call = ancestors.at(-1);
915
- if (!isCall(call) || call.callee !== ref) {
916
- sites.push('loadModuleWithParser');
917
- return;
918
- }
919
- const parser = call.arguments[1];
920
- const text = parser
921
- ? source.slice(parser.start, parser.end).replace(/\s+/g, ' ')
922
- : '';
923
- sites.push(`loadModuleWithParser(..., ${text})`);
924
- let docParser = false;
925
- walk(parser, [], node => {
926
- const name = node.type === 'Identifier' ? node.name : stringValue(node);
927
- docParser ||= name !== undefined && DOC_PARSERS.has(name);
928
- });
929
- if (docParser) {
930
- problems.push(
931
- `${rel}: loadModuleWithParser(..., ${text}) loads a doc outside the compiler`,
932
- );
933
- }
934
- };
935
-
936
- /**
937
- * @param {Target} target
938
- * @param {string} name the export used
939
- * @param {any} ref the expression that reads it
940
- * @param {any[]} ancestors
941
- */
942
- const exportSite = (target, name, ref, ancestors) => {
943
- if (inertExports(target).includes(name)) return;
944
- if (target.key === 'module' && name === 'createRequire') {
945
- createRequireSite(ref, ancestors);
946
- } else if (target.kind === 'loader' && name === 'loadModuleWithParser') {
947
- parserSite(ref, ancestors);
948
- } else {
949
- sites.push(target.kind === 'builtin' ? `${target.key}.${name}` : name);
950
- }
951
- };
952
-
953
- /**
954
- * @param {any} id an identifier that is read
955
- * @param {any[]} ancestors
956
- */
957
- const reference = (id, ancestors) => {
958
- const parent = ancestors.at(-1);
959
- const binding = bindings.get(id.name);
960
- if (binding) {
961
- const {target, imported} = binding;
962
- if (imported !== null) {
963
- exportSite(target, imported, id, ancestors);
964
- } else if (isMember(parent) && parent.object === id) {
965
- const name = memberName(parent);
966
- if (name === undefined) sites.push(`${target.key}[<computed>]`);
967
- else exportSite(target, name, parent, ancestors.slice(0, -1));
968
- } else {
969
- sites.push(target.key);
970
- }
971
- } else if (requires.has(id.name)) {
972
- if (isCall(parent) && parent.callee === id) requireCall(parent);
973
- else if (!isMember(parent) || parent.object !== id) sites.push('require');
974
- else if (memberName(parent) !== 'resolve') {
975
- sites.push(`require.${memberName(parent) ?? '<computed>'}`);
976
- }
977
- } else if (id.name === 'getBuiltinModule') {
978
- if (isCall(parent) && parent.callee === id) builtinGetter(parent);
979
- else sites.push('getBuiltinModule');
980
- } else if (
981
- RUNNER_GLOBALS.has(id.name) &&
982
- !(parent.operator === 'instanceof' && parent.right === id)
983
- ) {
984
- sites.push(id.name);
985
- }
986
- };
987
-
988
- walk(program, [], (node, ancestors) => {
989
- switch (node.type) {
990
- case 'VariableDeclarator':
991
- case 'AssignmentExpression': {
992
- const [id, value] =
993
- node.type === 'VariableDeclarator'
994
- ? [node.id, node.init]
995
- : [node.left, node.right];
996
- if (value?.type !== 'Identifier') return;
997
- if (globals.has(value.name))
998
- destructured(id, RUNNER_GLOBALS, value.name);
999
- else if (value.name === 'process') {
1000
- destructured(id, PROCESS_RUNNERS, 'process');
1001
- }
1002
- return;
1003
- }
1004
- case 'ImportDeclaration':
1005
- case 'ExportAllDeclaration':
1006
- case 'ExportNamedDeclaration': {
1007
- if (!node.source) return;
1008
- const specifier = node.source.value;
1009
- const target = targetOf(specifier, rel);
1010
- if (!target) return;
1011
- if (UNREAD.has(target.kind)) {
1012
- const how =
1013
- node.type === 'ImportDeclaration' ? 'import' : 'export from';
1014
- sites.push(`${how} ${specifier}`);
1015
- } else if (node.type === 'ExportAllDeclaration') {
1016
- sites.push(`export * from ${specifier}`);
1017
- } else if (node.type === 'ExportNamedDeclaration') {
1018
- for (const s of node.specifiers) {
1019
- if (s.exportKind === 'type') continue;
1020
- const name = s.type === 'ExportSpecifier' ? nameOf(s.local) : '*';
1021
- if (!inertExports(target).includes(name)) {
1022
- sites.push(`export ${name} from ${specifier}`);
1023
- }
1024
- }
1025
- }
1026
- return;
1027
- }
1028
- case 'TSImportEqualsDeclaration': {
1029
- const ref = node.moduleReference;
1030
- if (ref.type !== 'TSExternalModuleReference') return;
1031
- const specifier = ref.expression.value;
1032
- const target = targetOf(specifier, rel);
1033
- if (target && UNREAD.has(target.kind)) {
1034
- sites.push(`import ${specifier}`);
1035
- } else if (target && node.isExport) {
1036
- sites.push(`export * from ${specifier}`);
1037
- }
1038
- return;
1039
- }
1040
- case 'ImportExpression':
1041
- case 'CallExpression':
1042
- case 'OptionalCallExpression': {
1043
- if (node.type === 'ImportExpression' || node.callee.type === 'Import') {
1044
- const specifier = stringValue(
1045
- node.type === 'ImportExpression' ? node.source : node.arguments[0],
1046
- );
1047
- if (specifier === undefined) sites.push('import(<computed>)');
1048
- else if (targetOf(specifier, rel)) sites.push(`import(${specifier})`);
1049
- return;
1050
- }
1051
- const callee = node.callee;
1052
- if (!isMember(callee)) return;
1053
- const name = memberName(callee);
1054
- const object = callee.object;
1055
- if (name === 'constructor') sites.push('.constructor()');
1056
- if (name === 'getBuiltinModule') builtinGetter(node);
1057
- if (
1058
- name === 'get' &&
1059
- object.type === 'Identifier' &&
1060
- object.name === 'Reflect'
1061
- ) {
1062
- const key = stringValue(node.arguments[1]);
1063
- if (
1064
- key !== undefined &&
1065
- (RUNNER_GLOBALS.has(key) || PROCESS_RUNNERS.has(key))
1066
- ) {
1067
- sites.push(key);
1068
- }
1069
- }
1070
- const resolver =
1071
- object.type === 'MetaProperty' ||
1072
- (object.type === 'Identifier' && requires.has(object.name)) ||
1073
- (isCall(object) && isCreateRequire(object.callee));
1074
- if (name === 'resolve' && resolver) docResolve(node.arguments[0]);
1075
- if (
1076
- name !== undefined &&
1077
- RUNNER_METHODS.has(name) &&
1078
- !(object.type === 'Identifier' && bindings.has(object.name))
1079
- ) {
1080
- sites.push(`.${name}()`);
1081
- }
1082
- return;
1083
- }
1084
- case 'NewExpression':
1085
- if (node.callee.type === 'Identifier' && node.callee.name === 'URL') {
1086
- docResolve(node.arguments[0]);
1087
- }
1088
- return;
1089
- case 'MemberExpression':
1090
- case 'OptionalMemberExpression': {
1091
- const object = node.object;
1092
- const name = memberName(node);
1093
- const global =
1094
- (object.type === 'Identifier' && globals.has(object.name)) ||
1095
- (isMember(object) &&
1096
- object.object.type === 'Identifier' &&
1097
- globals.has(object.object.name));
1098
- if (name === 'constructor' && LITERALS.has(object.type)) {
1099
- sites.push('.constructor');
1100
- } else if (
1101
- WASM_RUNNERS.has(name ?? '') &&
1102
- ((object.type === 'Identifier' && object.name === 'WebAssembly') ||
1103
- (isMember(object) && memberName(object) === 'WebAssembly'))
1104
- ) {
1105
- sites.push(`WebAssembly.${name}`);
1106
- } else if (isMember(object)) {
1107
- return;
1108
- } else if (object.type !== 'Identifier' || bindings.has(object.name)) {
1109
- return;
1110
- } else if (object.name === 'module') {
1111
- if (name === 'require' || name === 'constructor') {
1112
- sites.push(`module.${name}`);
1113
- }
1114
- } else if (object.name === 'process') {
1115
- if (name !== 'getBuiltinModule' && PROCESS_RUNNERS.has(name ?? '')) {
1116
- sites.push(`process.${name}`);
1117
- }
1118
- } else if (global) {
1119
- if (name === undefined) sites.push(`${object.name}[<computed>]`);
1120
- else if (RUNNER_GLOBALS.has(name)) sites.push(name);
1121
- }
1122
- return;
1123
- }
1124
- case 'Identifier': {
1125
- const parent = ancestors.at(-1);
1126
- if (parent?.type === 'TSImportEqualsDeclaration') return;
1127
- if (parent && isReferenced(node, parent, ancestors.at(-2))) {
1128
- reference(node, ancestors);
1129
- }
1130
- return;
1131
- }
1132
- }
1133
- });
1134
-
1135
- return {sites, problems};
1136
- }
1137
-
1138
- /**
1139
- * The names a module exports.
1140
- * @param {string} source
1141
- * @param {string} rel
1142
- * @returns {string[]}
1143
- */
1144
- function exportNames(source, rel) {
1145
- return parseModule(source, rel).program.body.flatMap(
1146
- (/** @type {any} */ node) => {
1147
- if (node.type === 'ExportDefaultDeclaration') return ['default'];
1148
- if (node.type !== 'ExportNamedDeclaration') return [];
1149
- const declaration = node.declaration;
1150
- return [
1151
- ...(declaration?.id ? [declaration.id.name] : []),
1152
- ...(declaration?.declarations ?? []).map(
1153
- (/** @type {any} */ d) => d.id.name,
1154
- ),
1155
- ...node.specifiers.map((/** @type {any} */ s) => nameOf(s.exported)),
1156
- ];
1157
- },
1158
- );
1159
- }
1160
-
1161
- /** @param {string} rel */
1162
- const read = rel => fs.readFileSync(path.join(CLI_ROOT, rel), 'utf8');
1163
-
1164
- /** Every doc kind's parser: the `parse*` exports under authoring/doctypes. */
1165
- const DOC_PARSERS = new Set(
1166
- sources(path.join(CLI_ROOT, 'authoring/doctypes')).flatMap(full =>
1167
- exportNames(read(relOf(full)), relOf(full)).filter(name =>
1168
- /^parse[A-Z]/.test(name),
1169
- ),
1170
- ),
1171
- );
1172
-
1173
- /**
1174
- * A module's sites as the list writes them: sorted, repeats counted.
1175
- * @param {string[]} sites
1176
- * @returns {string[]}
1177
- */
1178
- function tally(sites) {
1179
- /** @type {Map<string, number>} */
1180
- const counts = new Map();
1181
- for (const site of sites) counts.set(site, (counts.get(site) ?? 0) + 1);
1182
- return [...counts]
1183
- .map(([site, n]) => (n === 1 ? site : `${site} ×${n}`))
1184
- .sort();
1185
- }
1186
-
1187
- /**
1188
- * How one module breaks the list: sites other than its entry's, or a doc
1189
- * parser handed to a generic loader, which no entry can allow.
1190
- * @param {string} rel
1191
- * @param {string} source
1192
- * @param {readonly string[]} [entry] the listed sites
1193
- * @returns {string[]}
1194
- */
1195
- function violations(rel, source, entry = RUNNERS[rel]?.sites ?? []) {
1196
- const {sites, problems} = scanModule(source, rel);
1197
- const found = tally(sites);
1198
- const listed = [...entry].sort();
1199
- const same = found.join('\n') === listed.join('\n');
1200
- return same
1201
- ? problems
1202
- : [
1203
- ...problems,
1204
- `${rel} runs [${found.join(', ')}], listed [${listed.join(', ')}]`,
1205
- ];
1206
- }
1207
-
1208
- describe('every module that runs code outside its static imports is listed', () => {
1209
- const scanned = sources(CLI_ROOT).map(relOf);
1210
-
1211
- it('lists each one with exactly the sites it has', () => {
1212
- const found = scanned.flatMap(rel => {
1213
- try {
1214
- return violations(rel, read(rel));
1215
- } catch (error) {
1216
- return [
1217
- `${rel} does not parse: ${/** @type {Error} */ (error).message}`,
1218
- ];
1219
- }
1220
- });
1221
- expect(found).toEqual([]);
1222
- });
1223
-
1224
- it('lists no module that is gone', () => {
1225
- expect(Object.keys(RUNNERS).filter(rel => !scanned.includes(rel))).toEqual(
1226
- [],
1227
- );
1228
- });
1229
-
1230
- it('names only exports the loader modules still have', () => {
1231
- const stale = Object.entries(LOADER_MODULES).flatMap(([rel, inert]) => {
1232
- const names = exportNames(read(rel), rel);
1233
- return inert
1234
- .filter(name => !names.includes(name))
1235
- .map(n => `${rel}#${n}`);
1236
- });
1237
- expect(stale).toEqual([]);
1238
- });
1239
- });
1240
-
1241
- /** A module the list does not name. */
1242
- const LEAF = 'api/leaf/leaf.mjs';
1243
- const MODULE_LOADER = "'../../foundation/fs/module-loader.mjs'";
1244
- const IMPORTERS = "'../../foundation/doc-compiler/import.mjs'";
1245
-
1246
- /**
1247
- * A listed module's real source, edited.
1248
- * @param {string} rel
1249
- * @param {(source: string) => string} edit
1250
- */
1251
- const edited = (rel, edit) => {
1252
- const code = edit(read(rel));
1253
- if (code === read(rel)) throw new Error(`the edit to ${rel} changed nothing`);
1254
- return {file: rel, code};
1255
- };
1256
-
1257
- /**
1258
- * Ways to run a doc file (or any module) that the list must catch.
1259
- * @type {Array<{name: string, file: string, code: string}>}
1260
- */
1261
- const BYPASSES = [
1262
- // The 23 cases from review of the first scan.
1263
- ['computed import(file)', 'const m = await import(file);'],
1264
- [
1265
- 'importUserModule(docPath)',
1266
- `import {importUserModule} from ${MODULE_LOADER};\nawait importUserModule(docPath);`,
1267
- ],
1268
- [
1269
- 'a static import of a doc file',
1270
- "import {doc} from './Button.doc.mjs';\nconsole.log(doc);",
1271
- ],
1272
- [
1273
- 'a static default import of a doc file',
1274
- "import doc from '../../foundation/x/Button.doc.mjs';",
1275
- ],
1276
- [
1277
- 'a literal dynamic import of a doc file',
1278
- "await import('/abs/node_modules/@acme/kit/components/Foo.doc.mjs');",
1279
- ],
1280
- [
1281
- 'createRequire(...)(docPath)',
1282
- "import {createRequire} from 'node:module';\ncreateRequire(import.meta.url)(docPath);",
1283
- ],
1284
- [
1285
- 'require = createRequire(...); require(docPath)',
1286
- "import {createRequire} from 'node:module';\nconst require = createRequire(import.meta.url);\nrequire(docPath);",
1287
- ],
1288
- ["eval('import(docPath)')", "await eval('import(docPath)');"],
1289
- [
1290
- "new Function('p', 'return import(p)')",
1291
- "await new Function('p', 'return import(p)')(docPath);",
1292
- ],
1293
- [
1294
- "jiti['import'](docPath)",
1295
- "import {createJiti} from 'jiti';\nawait createJiti(import.meta.url)['import'](docPath);",
1296
- ],
1297
- [
1298
- 'a jiti instance called as require',
1299
- "import {createJiti} from 'jiti';\nconst jiti = createJiti(import.meta.url);\njiti(docPath);",
1300
- ],
1301
- [
1302
- 'loader.importUserModule(docPath) through a namespace import',
1303
- `import * as loader from ${MODULE_LOADER};\nawait loader.importUserModule(docPath);`,
1304
- ],
1305
- [
1306
- 'a renamed import of a loader',
1307
- `import {importUserModule as load} from ${MODULE_LOADER};\nawait load(docPath);`,
1308
- ],
1309
- [
1310
- 'files.map(importUserModule): a loader passed as a value',
1311
- `import {importUserModule} from ${MODULE_LOADER};\nawait Promise.all(files.map(importUserModule));`,
1312
- ],
1313
- [
1314
- 'importUserModule.call(null, docPath)',
1315
- `import {importUserModule} from ${MODULE_LOADER};\nawait importUserModule.call(null, docPath);`,
1316
- ],
1317
- [
1318
- 'a re-export of the doc importers',
1319
- `export {importDocModule} from ${IMPORTERS};`,
1320
- ],
1321
- [
1322
- 'a literal dynamic import of the doc importers',
1323
- `const {importDocModule} = await import(${IMPORTERS});\nawait importDocModule(docPath);`,
1324
- ],
1325
- [
1326
- 'loadModuleWithParser(file, parsers.parseDoc)',
1327
- `import {loadModuleWithParser} from ${MODULE_LOADER};\nawait loadModuleWithParser(file, parsers.parseDoc);`,
1328
- ],
1329
- [
1330
- 'loadModuleWithParser(file, x => parseDoc(x))',
1331
- `import {loadModuleWithParser} from ${MODULE_LOADER};\nawait loadModuleWithParser(file, x => parseDoc(x));`,
1332
- ],
1333
- [
1334
- 'new Worker(docPath)',
1335
- "import {Worker} from 'node:worker_threads';\nnew Worker(docPath);",
1336
- ],
1337
- [
1338
- 'child_process fork(docPath)',
1339
- "import {fork} from 'node:child_process';\nfork(docPath);",
1340
- ],
1341
- [
1342
- 'vm.runInThisContext(readFileSync(docPath))',
1343
- "import vm from 'node:vm';\nimport fs from 'node:fs';\nvm.runInThisContext(fs.readFileSync(docPath, 'utf8'));",
1344
- ],
1345
- [
1346
- 'import.meta.resolve of a doc file',
1347
- "const url = import.meta.resolve('./Button.doc.mjs');",
1348
- ],
1349
- // The same, reached another way.
1350
- [
1351
- 'importUserModule.apply(null, [docPath])',
1352
- `import {importUserModule} from ${MODULE_LOADER};\nawait importUserModule.apply(null, [docPath]);`,
1353
- ],
1354
- [
1355
- 'a dynamic import of import.mjs, then m.importDocModule(docPath)',
1356
- `const m = await import(${IMPORTERS});\nawait m.importDocModule(docPath);`,
1357
- ],
1358
- ['export * from import.mjs', `export * from ${IMPORTERS};`],
1359
- [
1360
- 'a namespace of import.mjs passed on',
1361
- `import * as importers from ${IMPORTERS};\nexport default importers;`,
1362
- ],
1363
- [
1364
- 'a computed member of a loader namespace',
1365
- `import * as loader from ${MODULE_LOADER};\nloader[name](docPath);`,
1366
- ],
1367
- [
1368
- 'a loader re-exported by a local export',
1369
- `import {importUserModule} from ${MODULE_LOADER};\nexport {importUserModule};`,
1370
- ],
1371
- [
1372
- 'a loader in an object shorthand',
1373
- `import {importUserModule} from ${MODULE_LOADER};\nexport const api = {importUserModule};`,
1374
- ],
1375
- [
1376
- 'a loader behind a block-scoped shadow',
1377
- `import {importUserModule as load} from ${MODULE_LOADER};\nexport function f(p) {\n { const load = () => {}; }\n return load(p);\n}`,
1378
- ],
1379
- [
1380
- 'a loader import with a query string',
1381
- "import {importDocModule} from '../../foundation/doc-compiler/import.mjs?v=1';\nimportDocModule(docPath);",
1382
- ],
1383
- [
1384
- 'a loader import with an escaped character',
1385
- "import {importDocModule} from '../../foundation/doc-compiler/%69mport.mjs';\nimportDocModule(docPath);",
1386
- ],
1387
- [
1388
- 'a raw topic loader from discovery',
1389
- "import {loadTopicModule} from '../../foundation/discovery/docs-discovery.mjs';\nawait loadTopicModule(docPath);",
1390
- ],
1391
- ['a side-effect import of a doc file', "import './Button.doc.mjs';"],
1392
- [
1393
- 'a static import of a doc overlay',
1394
- "import {docsZh} from './Button.doc.zh.mjs';",
1395
- ],
1396
- ['a re-export of a doc file', "export {doc} from './Button.doc.mjs';"],
1397
- [
1398
- 'Module.createRequire(...)(docPath) through a default import',
1399
- "import Module from 'node:module';\nModule.createRequire(import.meta.url)(docPath);",
1400
- ],
1401
- [
1402
- 'a require function passed on',
1403
- "import {createRequire} from 'node:module';\nconst r = createRequire(import.meta.url);\nconst q = r;\nq(docPath);",
1404
- ],
1405
- [
1406
- 'module.register',
1407
- "import {register} from 'node:module';\nregister('./hooks.mjs', import.meta.url);",
1408
- ],
1409
- ['(0, eval)(source)', '(0, eval)(source);'],
1410
- ['globalThis.eval(source)', 'globalThis.eval(source);'],
1411
- ["globalThis['ev' + 'al'](source)", "globalThis['ev' + 'al'](source);"],
1412
- [
1413
- "Function('return import(p)') without new",
1414
- "Function('return import(p)')();",
1415
- ],
1416
- [
1417
- "import('node:child_process')",
1418
- "const {fork} = await import('node:child_process');",
1419
- ],
1420
- [
1421
- "require('worker_threads').Worker",
1422
- "new (require('worker_threads').Worker)(docPath);",
1423
- ],
1424
- [
1425
- 'a default import of child_process',
1426
- "import cp from 'child_process';\ncp.fork(docPath);",
1427
- ],
1428
- ['jiti.evalModule(source)', 'jiti.evalModule(source);'],
1429
- [
1430
- 'process.getBuiltinModule, with no import',
1431
- "process.getBuiltinModule('node:child_process').fork(docPath);",
1432
- ],
1433
- [
1434
- 'getBuiltinModule taken off process',
1435
- "const {getBuiltinModule} = process;\ngetBuiltinModule('node:vm');",
1436
- ],
1437
- ['a ShadowRealm', 'const realm = new ShadowRealm();'],
1438
- ["a realm's importValue", "await realm.importValue(docPath, 'doc');"],
1439
- [
1440
- "an async function's constructor",
1441
- "await (async () => {}).constructor('return import(p)')();",
1442
- ],
1443
- [
1444
- 'node:test running files',
1445
- "import {run} from 'node:test';\nrun({files: [docPath]});",
1446
- ],
1447
- [
1448
- 'a helper from a directory the scan skips',
1449
- "import {runCli} from '../../test-utils/run-cli.mjs';\nrunCli(docPath);",
1450
- ],
1451
- [
1452
- 'a static import of a data: URL',
1453
- "import one from 'data:text/javascript,export default 1';\nexport {one};",
1454
- ],
1455
- [
1456
- 'a dynamic import of a data: URL',
1457
- "await import('data:text/javascript,export default 1');",
1458
- ],
1459
- [
1460
- 'a dynamic import over https',
1461
- "await import('https://example.test/x.mjs');",
1462
- ],
1463
- ['process.dlopen', 'process.dlopen({exports: {}}, file);'],
1464
- ['process.execve', 'process.execve(file, args);'],
1465
- [
1466
- 'dlopen destructured off process',
1467
- 'const {dlopen} = process;\ndlopen({exports: {}}, file);',
1468
- ],
1469
- ['WebAssembly.instantiate', 'await WebAssembly.instantiate(bytes);'],
1470
- [
1471
- 'WebAssembly.compile through globalThis',
1472
- 'await globalThis.WebAssembly.compile(bytes);',
1473
- ],
1474
- ['new WebAssembly.Module', 'new WebAssembly.Module(bytes);'],
1475
- ['Object.constructor(source)', 'Object.constructor(source)();'],
1476
- [
1477
- "a function literal's constructor, taken and kept",
1478
- 'const F = (() => {}).constructor;\nexport {F};',
1479
- ],
1480
- [
1481
- '[].constructor.constructor(source)',
1482
- '[].constructor.constructor(source)();',
1483
- ],
1484
- [
1485
- "''.constructor.constructor(source)",
1486
- "''.constructor.constructor(source)();",
1487
- ],
1488
- [
1489
- "a prototype's constructor",
1490
- 'Object.getPrototypeOf(async function () {}).constructor(source)();',
1491
- ],
1492
- [
1493
- 'eval destructured off globalThis',
1494
- 'const {eval: e} = globalThis;\ne(source);',
1495
- ],
1496
- [
1497
- 'Function destructured off globalThis',
1498
- 'const {Function: F} = globalThis;\nF(source)();',
1499
- ],
1500
- [
1501
- 'eval through an alias of globalThis',
1502
- 'const g = globalThis;\ng.eval(source);',
1503
- ],
1504
- [
1505
- 'eval through a chain of aliases',
1506
- 'const g = globalThis;\nconst h = g;\nh.eval(source);',
1507
- ],
1508
- [
1509
- 'a computed destructuring off globalThis',
1510
- "const {['ev' + 'al']: e} = globalThis;\ne(source);",
1511
- ],
1512
- [
1513
- "Reflect.get(globalThis, 'eval')",
1514
- "Reflect.get(globalThis, 'eval')(source);",
1515
- ],
1516
- [
1517
- 'a module under the authored templates',
1518
- "import helper from '../../assets/templates/x/helper.mjs';",
1519
- ],
1520
- [
1521
- 'a module in a hidden directory',
1522
- "import {load} from './.cache/load.mjs';\nload(docPath);",
1523
- ],
1524
- [
1525
- 'a module in a fixtures directory',
1526
- "import {load} from './__fixtures__/load.mjs';\nload(docPath);",
1527
- ],
1528
- ['a test module', "import {load} from './load.test.mjs';\nload(docPath);"],
1529
- [
1530
- 'the doc importers by absolute file URL',
1531
- "import {importDocModule} from 'file:///repo/packages/cli/foundation/doc-compiler/import.mjs';\nimportDocModule(docPath);",
1532
- ],
1533
- [
1534
- 'child_process imported as {default as cp}',
1535
- "import {default as cp} from 'node:child_process';\ncp.fork(docPath);",
1536
- ],
1537
- [
1538
- 'createRequire passed on',
1539
- "import {createRequire} from 'node:module';\nconst make = createRequire;\nmake(import.meta.url)(docPath);",
1540
- ],
1541
- ].map(([name, code]) => ({name, file: LEAF, code}));
1542
-
1543
- BYPASSES.push(
1544
- {
1545
- name: 'a require of a doc file, in CommonJS',
1546
- file: 'api/leaf/leaf.cjs',
1547
- code: "const {doc} = require('./Button.doc.cjs');",
1548
- },
1549
- {
1550
- name: 'an import-equals of a doc file, in TypeScript',
1551
- file: 'api/leaf/leaf.ts',
1552
- code: "import doc = require('./Button.doc.mjs');",
1553
- },
1554
- {
1555
- name: 'module.require, in CommonJS',
1556
- file: 'api/leaf/leaf.cjs',
1557
- code: 'module.require(docPath);',
1558
- },
1559
- {
1560
- name: 'a loader module re-exported by import-equals, in TypeScript',
1561
- file: 'api/leaf/leaf.ts',
1562
- code: `export import loader = require(${MODULE_LOADER});`,
1563
- },
1564
- {
1565
- name: 'an extension-free import of the doc importers, in TypeScript',
1566
- file: 'api/leaf/leaf.ts',
1567
- code: "import {importDocModule} from '../../foundation/doc-compiler/import';\nimportDocModule(docPath);",
1568
- },
1569
- {
1570
- name: 'import(docPath) in a listed module',
1571
- ...edited(
1572
- 'foundation/config/project.mjs',
1573
- s => `${s}\nawait import(docPath);`,
1574
- ),
1575
- },
1576
- {
1577
- name: 'a doc parser swapped into a listed loadModuleWithParser call',
1578
- ...edited('foundation/config/project.mjs', s =>
1579
- s.replace(
1580
- 'loadModuleWithParser(configPath, parseConfig',
1581
- 'loadModuleWithParser(configPath, parseDoc',
1582
- ),
1583
- ),
1584
- },
1585
- {
1586
- name: 'a second loader call in a listed module',
1587
- ...edited(
1588
- 'foundation/integrations/integrations.mjs',
1589
- s => `${s}\nawait importUserModule(docPath);`,
1590
- ),
1591
- },
1592
- );
1593
-
1594
- /**
1595
- * Code that runs nothing outside its static imports.
1596
- * @type {Array<{name: string, file: string, code: string}>}
1597
- */
1598
- const INNOCENT = [
1599
- ['a literal import of a built-in', "await import('node:fs');"],
1600
- ['a literal lazy import', "const m = await import('./other.mjs');"],
1601
- [
1602
- 'an inert loader-module export',
1603
- `import {findPresentFiles} from ${MODULE_LOADER};\nfindPresentFiles(dir, names);`,
1604
- ],
1605
- [
1606
- 'an inert export read off a loader namespace',
1607
- `import * as loader from ${MODULE_LOADER};\nloader.findPresentFiles(dir, names);`,
1608
- ],
1609
- [
1610
- 'a require function that only resolves',
1611
- "import {createRequire} from 'node:module';\nconst require = createRequire(import.meta.url);\nrequire.resolve('pkg/package.json');",
1612
- ],
1613
- [
1614
- 'createRequire(...).resolve',
1615
- "import {createRequire} from 'node:module';\ncreateRequire(import.meta.url).resolve('pkg');",
1616
- ],
1617
- [
1618
- 'a doc path as data',
1619
- "const target = name + '.doc.mjs';\nif (file.endsWith('.doc.mjs')) files.push(target);",
1620
- ],
1621
- [
1622
- 'an inert member of {default as x}',
1623
- "import {default as threads} from 'node:worker_threads';\nthreads.parentPort.postMessage(1);",
1624
- ],
1625
- [
1626
- 'the worker side of worker_threads',
1627
- "import {parentPort, workerData} from 'node:worker_threads';\nparentPort.postMessage(workerData);",
1628
- ],
1629
- ['x instanceof Function', 'if (x instanceof Function) f();'],
1630
- ['j.Function, an AST node type', 'root.find(j.Function);'],
1631
- [
1632
- 'a property that shares a loader name',
1633
- 'const o = {importUserModule: 1};\nconsole.log(o.importUserModule);',
1634
- ],
1635
- [
1636
- 'a read through the compiler',
1637
- "import {readDocView} from '../../foundation/doc-compiler/read.mjs';\nawait readDocView(file, {root: 'components'});",
1638
- ],
1639
- [
1640
- 'the docs catalog',
1641
- "import {DocsCatalog} from '../../foundation/discovery/docs-discovery.mjs';\nnew DocsCatalog();",
1642
- ],
1643
- [
1644
- 'an inert export of module',
1645
- "import {builtinModules} from 'node:module';\nbuiltinModules.includes(name);",
1646
- ],
1647
- [
1648
- 'a URL of a module that is not a doc',
1649
- "const worker = new URL('./worker.mjs', import.meta.url);",
1650
- ],
1651
- ['a string that mentions import()', "const text = 'await import(x)';"],
1652
- [
1653
- 'getBuiltinModule of an inert built-in',
1654
- "const fs = process.getBuiltinModule('node:fs');",
1655
- ],
1656
- ['an inert member of process', 'const dir = process.cwd();'],
1657
- ['an inert destructuring of process', 'const {env, argv} = process;'],
1658
- ['an inert member of globalThis', 'globalThis.crypto.randomUUID();'],
1659
- ['WebAssembly.validate', 'WebAssembly.validate(bytes);'],
1660
- ['a constructor read and passed on', 'patchPrototype(command.constructor);'],
1661
- [
1662
- "a constructor's name",
1663
- "const kind = proto?.constructor?.name ?? 'non-plain object';",
1664
- ],
1665
- ['a property named constructor', 'const o = {constructor: 1};\nread(o);'],
1666
- ].map(([name, code]) => ({name, file: LEAF, code}));
1667
-
1668
- INNOCENT.push(
1669
- {
1670
- name: 'a require of a built-in, in CommonJS',
1671
- file: 'api/leaf/leaf.cjs',
1672
- code: "const path = require('node:path');",
1673
- },
1674
- {
1675
- name: 'a type-only import of a doc file, in TypeScript',
1676
- file: 'api/leaf/leaf.ts',
1677
- code: "import type {Doc} from './Button.doc.mjs';\nexport type D = Doc;",
1678
- },
1679
- {
1680
- name: 'a loader named in a type, in TypeScript',
1681
- file: 'api/leaf/leaf.ts',
1682
- code: `import {importDocModule} from ${IMPORTERS};\nlet load: typeof importDocModule | undefined;`,
1683
- },
1684
- );
1685
-
1686
- describe('the scan', () => {
1687
- it('reads every code file but tests, fixtures, dependencies, and generated or hidden ones', () => {
1688
- const dir = fs.mkdtempSync(path.join(os.tmpdir(), 'doc-loads-'));
1689
- const code = [
1690
- 'a.cjs',
1691
- 'a.cts',
1692
- 'a.js',
1693
- 'a.jsx',
1694
- 'a.mjs',
1695
- 'a.mts',
1696
- 'a.ts',
1697
- 'a.tsx',
1698
- ];
1699
- const skipped = [
1700
- '.cache/a.mjs',
1701
- '__fixtures__/a.mjs',
1702
- '__tests__/a.mjs',
1703
- 'a.d.mts',
1704
- 'a.json',
1705
- 'a.test.mjs',
1706
- 'a.test.ts',
1707
- 'node_modules/a.mjs',
1708
- ];
1709
- try {
1710
- for (const file of [...code, ...skipped]) {
1711
- fs.mkdirSync(path.dirname(path.join(dir, file)), {recursive: true});
1712
- fs.writeFileSync(path.join(dir, file), '');
1713
- }
1714
- const found = sources(dir).map(full => path.relative(dir, full));
1715
- expect(found.sort()).toEqual(code);
1716
- } finally {
1717
- fs.rmSync(dir, {recursive: true, force: true});
1718
- }
1719
- });
1720
-
1721
- it.each(BYPASSES)('catches $name', ({file, code}) => {
1722
- expect(violations(file, code)).not.toEqual([]);
1723
- });
1724
-
1725
- it.each(INNOCENT)('passes $name', ({file, code}) => {
1726
- expect(scanModule(code, file)).toEqual({sites: [], problems: []});
1727
- });
1728
-
1729
- it('refuses a doc parser handed to a loader, even with the site listed', () => {
1730
- for (const parser of ['parsers.parseDoc', 'x => parseFunction(x)']) {
1731
- const code = `import {loadModuleWithParser} from ${MODULE_LOADER};\nloadModuleWithParser(file, ${parser});`;
1732
- const listed = tally(scanModule(code, LEAF).sites);
1733
- expect(violations(LEAF, code, listed)).toEqual([
1734
- `${LEAF}: loadModuleWithParser(..., ${parser}) loads a doc outside the compiler`,
1735
- ]);
1736
- }
1737
- });
1738
- });
1739
-
1740
- describe('the scan walks every folder that can ship', () => {
1741
- it('skips only test scaffolding and the temporary folders tests create', () => {
1742
- const root = fs.mkdtempSync(path.join(os.tmpdir(), 'doc-loads-walk-'));
1743
- try {
1744
- for (const dir of [
1745
- '__generated__',
1746
- '__tests__',
1747
- '__fixtures__',
1748
- '__import_hint_integration_Ab12Cd',
1749
- '.hidden',
1750
- 'node_modules',
1751
- ]) {
1752
- fs.mkdirSync(path.join(root, dir));
1753
- fs.writeFileSync(path.join(root, dir, 'run.mjs'), "eval('1');\n");
1754
- }
1755
- expect(
1756
- sources(root).map(file => path.basename(path.dirname(file))),
1757
- ).toEqual(['__generated__']);
1758
- } finally {
1759
- fs.rmSync(root, {recursive: true, force: true});
1760
- }
1761
- });
1762
- });