packtory 0.0.15 → 0.0.17

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 (430) hide show
  1. package/artifacts/artifacts-builder.d.ts +3 -1
  2. package/artifacts/artifacts-builder.d.ts.map +1 -1
  3. package/artifacts/artifacts-builder.js +20 -74
  4. package/artifacts/artifacts-builder.js.map +1 -1
  5. package/artifacts/content-collection.js +60 -0
  6. package/artifacts/content-collection.js.map +1 -0
  7. package/artifacts/folder-writer.js +24 -0
  8. package/artifacts/folder-writer.js.map +1 -0
  9. package/bundle-emitter/emitter.d.ts +3 -2
  10. package/bundle-emitter/emitter.d.ts.map +1 -1
  11. package/bundle-emitter/emitter.js +10 -8
  12. package/bundle-emitter/emitter.js.map +1 -1
  13. package/bundle-emitter/fetch-published-artifacts.d.ts +10 -0
  14. package/bundle-emitter/fetch-published-artifacts.d.ts.map +1 -0
  15. package/bundle-emitter/fetch-published-artifacts.js +16 -0
  16. package/bundle-emitter/fetch-published-artifacts.js.map +1 -0
  17. package/bundle-emitter/publish-error/auto-mode-error-matching.js +30 -0
  18. package/bundle-emitter/publish-error/auto-mode-error-matching.js.map +1 -0
  19. package/bundle-emitter/publish-error/error-shape-helpers.js +10 -0
  20. package/bundle-emitter/publish-error/error-shape-helpers.js.map +1 -0
  21. package/bundle-emitter/publish-error/file-mode-error-matching.js +28 -0
  22. package/bundle-emitter/publish-error/file-mode-error-matching.js.map +1 -0
  23. package/bundle-emitter/publish-error/publish-error-messages.js +37 -0
  24. package/bundle-emitter/publish-error/publish-error-messages.js.map +1 -0
  25. package/bundle-emitter/registry/metadata-auth-retry.js +26 -0
  26. package/bundle-emitter/registry/metadata-auth-retry.js.map +1 -0
  27. package/bundle-emitter/registry/oidc-token-exchange.js +83 -0
  28. package/bundle-emitter/registry/oidc-token-exchange.js.map +1 -0
  29. package/bundle-emitter/registry/package-metadata-fetcher.d.ts +4 -0
  30. package/bundle-emitter/registry/package-metadata-fetcher.d.ts.map +1 -0
  31. package/bundle-emitter/registry/package-metadata-fetcher.js +99 -0
  32. package/bundle-emitter/registry/package-metadata-fetcher.js.map +1 -0
  33. package/bundle-emitter/registry/publish-settings-bridge.js +39 -0
  34. package/bundle-emitter/registry/publish-settings-bridge.js.map +1 -0
  35. package/bundle-emitter/registry/registry-auth-config.js +82 -0
  36. package/bundle-emitter/registry/registry-auth-config.js.map +1 -0
  37. package/bundle-emitter/registry/registry-client.d.ts +10 -0
  38. package/bundle-emitter/registry/registry-client.d.ts.map +1 -0
  39. package/bundle-emitter/registry/registry-client.js +38 -0
  40. package/bundle-emitter/registry/registry-client.js.map +1 -0
  41. package/bundle-emitter/registry/registry-response-schemas.js +45 -0
  42. package/bundle-emitter/registry/registry-response-schemas.js.map +1 -0
  43. package/bundle-emitter/repository-url-normalizer.js +2 -4
  44. package/bundle-emitter/repository-url-normalizer.js.map +1 -1
  45. package/checks/rules/duplicate-detection.js +26 -0
  46. package/checks/rules/duplicate-detection.js.map +1 -0
  47. package/checks/rules/duplicate-messages.js +26 -0
  48. package/checks/rules/duplicate-messages.js.map +1 -0
  49. package/checks/rules/file-ownership.js +16 -0
  50. package/checks/rules/file-ownership.js.map +1 -0
  51. package/checks/rules/no-duplicated-files.js +2 -76
  52. package/checks/rules/no-duplicated-files.js.map +1 -1
  53. package/checks/rules/required-files.js +2 -1
  54. package/checks/rules/required-files.js.map +1 -1
  55. package/checks/rules/set-intersection.js +14 -0
  56. package/checks/rules/set-intersection.js.map +1 -0
  57. package/checks/rules/unique-target-paths.js +11 -10
  58. package/checks/rules/unique-target-paths.js.map +1 -1
  59. package/common/code-files.js +21 -0
  60. package/common/code-files.js.map +1 -1
  61. package/common/max-date.js +6 -0
  62. package/common/max-date.js.map +1 -0
  63. package/common/sort-values.js.map +1 -0
  64. package/common/stable-json.js +42 -0
  65. package/common/stable-json.js.map +1 -0
  66. package/common/typed-diff.d.ts +3 -0
  67. package/common/typed-diff.d.ts.map +1 -0
  68. package/common/typed-diff.js +5 -0
  69. package/common/typed-diff.js.map +1 -0
  70. package/config/config.d.ts +0 -3
  71. package/config/config.d.ts.map +1 -1
  72. package/config/cross-package-validation.js +18 -0
  73. package/config/cross-package-validation.js.map +1 -0
  74. package/config/dependency-existence-validation.js +20 -0
  75. package/config/dependency-existence-validation.js.map +1 -0
  76. package/config/package-config.d.ts +0 -2
  77. package/config/package-config.d.ts.map +1 -1
  78. package/config/package-graph-builder.js +15 -0
  79. package/config/package-graph-builder.js.map +1 -0
  80. package/config/pre-graph-validation.js +19 -0
  81. package/config/pre-graph-validation.js.map +1 -0
  82. package/config/root-config-validation.js +126 -0
  83. package/config/root-config-validation.js.map +1 -0
  84. package/config/settings-validation.js +29 -0
  85. package/config/settings-validation.js.map +1 -0
  86. package/config/validation.d.ts +2 -2
  87. package/config/validation.d.ts.map +1 -1
  88. package/config/validation.js +9 -231
  89. package/config/validation.js.map +1 -1
  90. package/dead-code-eliminator/class-purity.js +33 -0
  91. package/dead-code-eliminator/class-purity.js.map +1 -0
  92. package/dead-code-eliminator/code-file-analyzer.js +56 -0
  93. package/dead-code-eliminator/code-file-analyzer.js.map +1 -0
  94. package/dead-code-eliminator/cross-bundle/bundle-index.js +31 -0
  95. package/dead-code-eliminator/cross-bundle/bundle-index.js.map +1 -0
  96. package/dead-code-eliminator/cross-bundle/cross-bundle-seeds.js +4 -111
  97. package/dead-code-eliminator/cross-bundle/cross-bundle-seeds.js.map +1 -1
  98. package/dead-code-eliminator/cross-bundle/import-export-walker.js +69 -0
  99. package/dead-code-eliminator/cross-bundle/import-export-walker.js.map +1 -0
  100. package/dead-code-eliminator/cross-bundle/seed-store.js +19 -0
  101. package/dead-code-eliminator/cross-bundle/seed-store.js.map +1 -0
  102. package/dead-code-eliminator/eliminator.js +3 -83
  103. package/dead-code-eliminator/eliminator.js.map +1 -1
  104. package/dead-code-eliminator/expression-unwrapping.js +17 -0
  105. package/dead-code-eliminator/expression-unwrapping.js.map +1 -0
  106. package/dead-code-eliminator/imported-expression-origin.js +95 -0
  107. package/dead-code-eliminator/imported-expression-origin.js.map +1 -0
  108. package/dead-code-eliminator/load-bundle.js +1 -1
  109. package/dead-code-eliminator/load-bundle.js.map +1 -1
  110. package/dead-code-eliminator/pure-expression.js +116 -0
  111. package/dead-code-eliminator/pure-expression.js.map +1 -0
  112. package/dead-code-eliminator/reachability/bfs-closure.js +40 -0
  113. package/dead-code-eliminator/reachability/bfs-closure.js.map +1 -0
  114. package/dead-code-eliminator/reachability/binding-id.js +33 -0
  115. package/dead-code-eliminator/reachability/binding-id.js.map +1 -0
  116. package/dead-code-eliminator/reachability/identifier-target-collector.js +36 -0
  117. package/dead-code-eliminator/reachability/identifier-target-collector.js.map +1 -0
  118. package/dead-code-eliminator/reachability/local-seed-gathering.js +24 -0
  119. package/dead-code-eliminator/reachability/local-seed-gathering.js.map +1 -0
  120. package/dead-code-eliminator/reachability/reachability.js +19 -130
  121. package/dead-code-eliminator/reachability/reachability.js.map +1 -1
  122. package/dead-code-eliminator/side-effect-classifier.js +2 -394
  123. package/dead-code-eliminator/side-effect-classifier.js.map +1 -1
  124. package/dead-code-eliminator/source-map-recomposition.js +27 -0
  125. package/dead-code-eliminator/source-map-recomposition.js.map +1 -0
  126. package/dead-code-eliminator/statement-classifiers.js +67 -0
  127. package/dead-code-eliminator/statement-classifiers.js.map +1 -0
  128. package/dead-code-eliminator/syntax-kind-sets.js +67 -0
  129. package/dead-code-eliminator/syntax-kind-sets.js.map +1 -0
  130. package/dead-code-eliminator/transform/declaration-removal.js +34 -0
  131. package/dead-code-eliminator/transform/declaration-removal.js.map +1 -0
  132. package/dead-code-eliminator/transform/declaration-remover.js +2 -72
  133. package/dead-code-eliminator/transform/declaration-remover.js.map +1 -1
  134. package/dead-code-eliminator/transform/named-declaration-kinds.js +13 -0
  135. package/dead-code-eliminator/transform/named-declaration-kinds.js.map +1 -0
  136. package/dead-code-eliminator/transform/survivor-capture.js +33 -0
  137. package/dead-code-eliminator/transform/survivor-capture.js.map +1 -0
  138. package/dependency-scanner/dependency-graph.js +46 -28
  139. package/dependency-scanner/dependency-graph.js.map +1 -1
  140. package/dependency-scanner/file-host-predicates.js +10 -0
  141. package/dependency-scanner/file-host-predicates.js.map +1 -0
  142. package/dependency-scanner/host-method-binding.js +19 -0
  143. package/dependency-scanner/host-method-binding.js.map +1 -0
  144. package/dependency-scanner/node-modules-manifest-synthesizer.js +55 -0
  145. package/dependency-scanner/node-modules-manifest-synthesizer.js.map +1 -0
  146. package/dependency-scanner/package-owned-asset-file-path.js +21 -0
  147. package/dependency-scanner/package-owned-asset-file-path.js.map +1 -0
  148. package/dependency-scanner/scanner.d.ts +1 -1
  149. package/dependency-scanner/scanner.d.ts.map +1 -1
  150. package/dependency-scanner/scanner.js +34 -39
  151. package/dependency-scanner/scanner.js.map +1 -1
  152. package/dependency-scanner/source-file-references.d.ts +3 -0
  153. package/dependency-scanner/source-file-references.d.ts.map +1 -0
  154. package/dependency-scanner/source-file-references.js +106 -7
  155. package/dependency-scanner/source-file-references.js.map +1 -1
  156. package/dependency-scanner/typescript-compiler-options.d.ts +3 -0
  157. package/dependency-scanner/typescript-compiler-options.d.ts.map +1 -0
  158. package/dependency-scanner/typescript-compiler-options.js +22 -0
  159. package/dependency-scanner/typescript-compiler-options.js.map +1 -0
  160. package/dependency-scanner/typescript-file-host.d.ts.map +1 -1
  161. package/dependency-scanner/typescript-file-host.js +15 -81
  162. package/dependency-scanner/typescript-file-host.js.map +1 -1
  163. package/dependency-scanner/typescript-project-analyzer.d.ts +3 -3
  164. package/dependency-scanner/typescript-project-analyzer.d.ts.map +1 -1
  165. package/dependency-scanner/typescript-project-analyzer.js +6 -26
  166. package/dependency-scanner/typescript-project-analyzer.js.map +1 -1
  167. package/dependency-scanner/virtual-package-json-host.js +45 -0
  168. package/dependency-scanner/virtual-package-json-host.js.map +1 -0
  169. package/directed-graph/graph.js +19 -8
  170. package/directed-graph/graph.js.map +1 -1
  171. package/file-manager/file-description.d.ts.map +1 -1
  172. package/file-manager/file-description.js +4 -0
  173. package/file-manager/file-description.js.map +1 -0
  174. package/file-manager/file-manager.js +30 -1
  175. package/file-manager/file-manager.js.map +1 -1
  176. package/file-manager/permissions.js +5 -4
  177. package/file-manager/permissions.js.map +1 -1
  178. package/linker/linked-bundle.d.ts.map +1 -1
  179. package/linker/linked-bundle.js +6 -0
  180. package/linker/linked-bundle.js.map +1 -0
  181. package/linker/linker.d.ts +1 -1
  182. package/linker/linker.d.ts.map +1 -1
  183. package/linker/linker.js +2 -1
  184. package/linker/linker.js.map +1 -1
  185. package/linker/replacement-lookup.js +41 -0
  186. package/linker/replacement-lookup.js.map +1 -0
  187. package/linker/resource-graph.js +2 -1
  188. package/linker/resource-graph.js.map +1 -1
  189. package/linker/substitute-bundles.js +4 -42
  190. package/linker/substitute-bundles.js.map +1 -1
  191. package/linker/substituted-resource-graph.js +2 -1
  192. package/linker/substituted-resource-graph.js.map +1 -1
  193. package/pack-emitter/pack-emitter.d.ts +8 -0
  194. package/pack-emitter/pack-emitter.d.ts.map +1 -0
  195. package/pack-emitter/pack-emitter.js +28 -0
  196. package/pack-emitter/pack-emitter.js.map +1 -0
  197. package/package-surface/bin-field.js +9 -0
  198. package/package-surface/bin-field.js.map +1 -0
  199. package/package-surface/explicit-bin.js +25 -0
  200. package/package-surface/explicit-bin.js.map +1 -0
  201. package/package-surface/explicit-exports.js +12 -0
  202. package/package-surface/explicit-exports.js.map +1 -0
  203. package/package-surface/explicit-specifier-build.js +28 -0
  204. package/package-surface/explicit-specifier-build.js.map +1 -0
  205. package/package-surface/explicit-specifier-resolve.js +17 -0
  206. package/package-surface/explicit-specifier-resolve.js.map +1 -0
  207. package/package-surface/export-map.js +10 -0
  208. package/package-surface/export-map.js.map +1 -0
  209. package/package-surface/implicit-bin.js +23 -0
  210. package/package-surface/implicit-bin.js.map +1 -0
  211. package/package-surface/implicit-exports.js +11 -0
  212. package/package-surface/implicit-exports.js.map +1 -0
  213. package/package-surface/implicit-root-exports.js +14 -0
  214. package/package-surface/implicit-root-exports.js.map +1 -0
  215. package/package-surface/implicit-specifier-build.js +26 -0
  216. package/package-surface/implicit-specifier-build.js.map +1 -0
  217. package/package-surface/implicit-specifier-resolve.js +17 -0
  218. package/package-surface/implicit-specifier-resolve.js.map +1 -0
  219. package/package-surface/package-json-export.js +10 -0
  220. package/package-surface/package-json-export.js.map +1 -0
  221. package/package-surface/package-shape.js +10 -0
  222. package/package-surface/package-shape.js.map +1 -0
  223. package/package-surface/public-module-usage.js +1 -1
  224. package/package-surface/public-module-usage.js.map +1 -1
  225. package/package-surface/public-specifiers.js +17 -0
  226. package/package-surface/public-specifiers.js.map +1 -0
  227. package/package-surface/root-registry.js +35 -0
  228. package/package-surface/root-registry.js.map +1 -0
  229. package/package-surface/specifier-syntax.js +24 -0
  230. package/package-surface/specifier-syntax.js.map +1 -0
  231. package/package-surface/substitution-exports.js +67 -0
  232. package/package-surface/substitution-exports.js.map +1 -0
  233. package/package.json +25 -12
  234. package/packages/package-processor.composition.js +54 -25
  235. package/packages/package-processor.composition.js.map +1 -1
  236. package/packages/packtory/packtory.entry-point.d.ts +24 -14
  237. package/packages/packtory/packtory.entry-point.d.ts.map +1 -1
  238. package/packages/packtory/packtory.entry-point.js +7 -3
  239. package/packages/packtory/packtory.entry-point.js.map +1 -1
  240. package/packtory/map-config.d.ts +3 -2
  241. package/packtory/map-config.d.ts.map +1 -1
  242. package/packtory/map-config.js +2 -1
  243. package/packtory/map-config.js.map +1 -1
  244. package/packtory/options/bundle-dependency-resolution.js +20 -0
  245. package/packtory/options/bundle-dependency-resolution.js.map +1 -0
  246. package/packtory/options/dead-code-elimination-resolution.js +11 -0
  247. package/packtory/options/dead-code-elimination-resolution.js.map +1 -0
  248. package/packtory/options/prepare-package-options.d.ts +18 -0
  249. package/packtory/options/prepare-package-options.d.ts.map +1 -0
  250. package/packtory/options/prepare-package-options.js +46 -0
  251. package/packtory/options/prepare-package-options.js.map +1 -0
  252. package/packtory/options/required-value-helpers.js +18 -0
  253. package/packtory/options/required-value-helpers.js.map +1 -0
  254. package/packtory/options/setting-resolvers.d.ts +6 -0
  255. package/packtory/options/setting-resolvers.d.ts.map +1 -0
  256. package/packtory/options/setting-resolvers.js +42 -0
  257. package/packtory/options/setting-resolvers.js.map +1 -0
  258. package/packtory/options/surface-resolution.js +16 -0
  259. package/packtory/options/surface-resolution.js.map +1 -0
  260. package/packtory/options/version-trigger.js +31 -0
  261. package/packtory/options/version-trigger.js.map +1 -0
  262. package/packtory/package-processor-build.js +2 -1
  263. package/packtory/package-processor-build.js.map +1 -1
  264. package/packtory/package-processor-publish.d.ts +5 -0
  265. package/packtory/package-processor-publish.d.ts.map +1 -1
  266. package/packtory/package-processor-publish.js +25 -40
  267. package/packtory/package-processor-publish.js.map +1 -1
  268. package/packtory/packtory-pack.js +221 -0
  269. package/packtory/packtory-pack.js.map +1 -0
  270. package/packtory/packtory-publish.js +3 -51
  271. package/packtory/packtory-publish.js.map +1 -1
  272. package/packtory/packtory-release-analysis.js +69 -0
  273. package/packtory/packtory-release-analysis.js.map +1 -0
  274. package/packtory/packtory-release-diff.js +48 -0
  275. package/packtory/packtory-release-diff.js.map +1 -0
  276. package/packtory/packtory-resolve.js +3 -71
  277. package/packtory/packtory-resolve.js.map +1 -1
  278. package/packtory/packtory-results.d.ts +73 -1
  279. package/packtory/packtory-results.d.ts.map +1 -1
  280. package/packtory/packtory-results.js +15 -0
  281. package/packtory/packtory-results.js.map +1 -1
  282. package/packtory/packtory.d.ts +15 -1
  283. package/packtory/packtory.d.ts.map +1 -1
  284. package/packtory/packtory.js +58 -5
  285. package/packtory/packtory.js.map +1 -1
  286. package/packtory/publish-failure-mapping.js +7 -0
  287. package/packtory/publish-failure-mapping.js.map +1 -0
  288. package/packtory/release-analysis.js +147 -0
  289. package/packtory/release-analysis.js.map +1 -0
  290. package/packtory/release-diff-failure-mapping.js +7 -0
  291. package/packtory/release-diff-failure-mapping.js.map +1 -0
  292. package/packtory/report-attachment.js +12 -1
  293. package/packtory/report-attachment.js.map +1 -1
  294. package/packtory/stages/package-analysis-stage.js +24 -0
  295. package/packtory/stages/package-analysis-stage.js.map +1 -0
  296. package/packtory/stages/package-resolution-stage.js +44 -0
  297. package/packtory/stages/package-resolution-stage.js.map +1 -0
  298. package/packtory/stages/publish-stage.js +44 -0
  299. package/packtory/stages/publish-stage.js.map +1 -0
  300. package/packtory/stages/release-diff-stage.js +84 -0
  301. package/packtory/stages/release-diff-stage.js.map +1 -0
  302. package/published-package/published-package.d.ts +39 -0
  303. package/published-package/published-package.d.ts.map +1 -0
  304. package/published-package/published-package.js +11 -0
  305. package/published-package/published-package.js.map +1 -0
  306. package/readme.md +27 -12
  307. package/report/aggregator/artifact-entry-merger.js.map +1 -0
  308. package/report/aggregator/package-report-materialization.js +63 -0
  309. package/report/aggregator/package-report-materialization.js.map +1 -0
  310. package/report/aggregator/report-aggregator.js +36 -0
  311. package/report/aggregator/report-aggregator.js.map +1 -0
  312. package/report/{report-aggregator.js → aggregator/report-event-handlers.js} +8 -95
  313. package/report/aggregator/report-event-handlers.js.map +1 -0
  314. package/report/{report-aggregator.d.ts → aggregator/report-types.d.ts} +2 -2
  315. package/report/aggregator/report-types.d.ts.map +1 -0
  316. package/report/aggregator/report-types.js +4 -0
  317. package/report/aggregator/report-types.js.map +1 -0
  318. package/report/config-redactor.js.map +1 -1
  319. package/report/inspectors/inspect-artifact-sizes.js +34 -0
  320. package/report/inspectors/inspect-artifact-sizes.js.map +1 -0
  321. package/report/inspectors/inspect-linker-rewrites.js +15 -0
  322. package/report/inspectors/inspect-linker-rewrites.js.map +1 -0
  323. package/report/inspectors/inspect-package-json-provenance.js +16 -0
  324. package/report/inspectors/inspect-package-json-provenance.js.map +1 -0
  325. package/report/inspectors/inspect-scan-results.js +10 -0
  326. package/report/inspectors/inspect-scan-results.js.map +1 -0
  327. package/report/preview/preview-document-diff.d.ts +13 -0
  328. package/report/preview/preview-document-diff.d.ts.map +1 -0
  329. package/report/preview/preview-document-diff.js +29 -0
  330. package/report/preview/preview-document-diff.js.map +1 -0
  331. package/report/release-diff/file-hunks.js +10 -0
  332. package/report/release-diff/file-hunks.js.map +1 -0
  333. package/report/release-diff/file-set-diff.d.ts +49 -0
  334. package/report/release-diff/file-set-diff.d.ts.map +1 -0
  335. package/report/release-diff/file-set-diff.js +71 -0
  336. package/report/release-diff/file-set-diff.js.map +1 -0
  337. package/report/release-diff/release-version-transition.js +17 -0
  338. package/report/release-diff/release-version-transition.js.map +1 -0
  339. package/resource-resolver/bundle-resource-lookup.js +24 -0
  340. package/resource-resolver/bundle-resource-lookup.js.map +1 -0
  341. package/resource-resolver/content.js +8 -4
  342. package/resource-resolver/content.js.map +1 -1
  343. package/resource-resolver/dependency-resolution-walker.js +25 -0
  344. package/resource-resolver/dependency-resolution-walker.js.map +1 -0
  345. package/resource-resolver/resolved-bundle.d.ts +1 -0
  346. package/resource-resolver/resolved-bundle.d.ts.map +1 -1
  347. package/resource-resolver/resolved-bundle.js +4 -0
  348. package/resource-resolver/resolved-bundle.js.map +1 -0
  349. package/resource-resolver/resource-resolve-options.js.map +1 -1
  350. package/resource-resolver/resource-resolver.d.ts.map +1 -1
  351. package/resource-resolver/resource-resolver.js +22 -57
  352. package/resource-resolver/resource-resolver.js.map +1 -1
  353. package/sbom/sbom-canonicalizer.js +46 -0
  354. package/sbom/sbom-canonicalizer.js.map +1 -0
  355. package/sbom/sbom-file.d.ts +2 -2
  356. package/sbom/sbom-file.d.ts.map +1 -1
  357. package/sbom/sbom-file.js +2 -5
  358. package/sbom/sbom-file.js.map +1 -1
  359. package/tar/extract-tar.js +11 -8
  360. package/tar/extract-tar.js.map +1 -1
  361. package/tar/tarball-builder.d.ts +4 -0
  362. package/tar/tarball-builder.d.ts.map +1 -1
  363. package/tar/tarball-builder.js +24 -11
  364. package/tar/tarball-builder.js.map +1 -1
  365. package/vendor-materializer/vendor-entry.d.ts +1 -0
  366. package/vendor-materializer/vendor-entry.d.ts.map +1 -0
  367. package/vendor-materializer/vendor-entry.js +8 -0
  368. package/vendor-materializer/vendor-entry.js.map +1 -0
  369. package/vendor-materializer/vendor-materializer.d.ts +5 -0
  370. package/vendor-materializer/vendor-materializer.d.ts.map +1 -0
  371. package/vendor-materializer/vendor-materializer.js +232 -0
  372. package/vendor-materializer/vendor-materializer.js.map +1 -0
  373. package/version-manager/dependencies/bundle-dependency-grouping.js +23 -0
  374. package/version-manager/dependencies/bundle-dependency-grouping.js.map +1 -0
  375. package/version-manager/dependencies/dependency-groups.js +12 -0
  376. package/version-manager/dependencies/dependency-groups.js.map +1 -0
  377. package/version-manager/{versioned-bundle-dependencies.js → dependencies/external-dependency-classification.js} +4 -42
  378. package/version-manager/dependencies/external-dependency-classification.js.map +1 -0
  379. package/version-manager/dependencies/versioned-bundle-dependencies.js +9 -0
  380. package/version-manager/dependencies/versioned-bundle-dependencies.js.map +1 -0
  381. package/version-manager/imports/hash-import-scanner.js +21 -0
  382. package/version-manager/imports/hash-import-scanner.js.map +1 -0
  383. package/version-manager/imports/imports-key-matcher.js +21 -0
  384. package/version-manager/imports/imports-key-matcher.js.map +1 -0
  385. package/version-manager/{versioned-bundle-imports.js → imports/versioned-bundle-imports.js} +3 -36
  386. package/version-manager/imports/versioned-bundle-imports.js.map +1 -0
  387. package/version-manager/manager.js +1 -1
  388. package/version-manager/manager.js.map +1 -1
  389. package/version-manager/manifest/builder.js +3 -5
  390. package/version-manager/manifest/builder.js.map +1 -1
  391. package/version-manager/manifest/serialize.js +2 -41
  392. package/version-manager/manifest/serialize.js.map +1 -1
  393. package/version-manager/optional-bundle-fields.js +9 -0
  394. package/version-manager/optional-bundle-fields.js.map +1 -0
  395. package/version-manager/representative-root.js +30 -0
  396. package/version-manager/representative-root.js.map +1 -0
  397. package/version-manager/specifier-classifier.js +14 -11
  398. package/version-manager/specifier-classifier.js.map +1 -1
  399. package/version-manager/versioned-bundle.d.ts +7 -23
  400. package/version-manager/versioned-bundle.d.ts.map +1 -1
  401. package/version-manager/versioned-bundle.js +7 -40
  402. package/version-manager/versioned-bundle.js.map +1 -1
  403. package/zip/zip-builder.d.ts +5 -0
  404. package/zip/zip-builder.d.ts.map +1 -0
  405. package/zip/zip-builder.js +80 -0
  406. package/zip/zip-builder.js.map +1 -0
  407. package/bundle-emitter/publish-settings-bridge.js +0 -133
  408. package/bundle-emitter/publish-settings-bridge.js.map +0 -1
  409. package/bundle-emitter/registry-client.d.ts +0 -9
  410. package/bundle-emitter/registry-client.d.ts.map +0 -1
  411. package/bundle-emitter/registry-client.js +0 -265
  412. package/bundle-emitter/registry-client.js.map +0 -1
  413. package/package-surface/modules.js +0 -319
  414. package/package-surface/modules.js.map +0 -1
  415. package/packtory/prepare-package-options.d.ts +0 -14
  416. package/packtory/prepare-package-options.d.ts.map +0 -1
  417. package/packtory/prepare-package-options.js +0 -128
  418. package/packtory/prepare-package-options.js.map +0 -1
  419. package/report/artifact-entry-merger.js.map +0 -1
  420. package/report/inspectors.js +0 -74
  421. package/report/inspectors.js.map +0 -1
  422. package/report/report-aggregator.d.ts.map +0 -1
  423. package/report/report-aggregator.js.map +0 -1
  424. package/version-manager/manifest/sort-values.js.map +0 -1
  425. package/version-manager/versioned-bundle-dependencies.js.map +0 -1
  426. package/version-manager/versioned-bundle-imports.d.ts +0 -4
  427. package/version-manager/versioned-bundle-imports.d.ts.map +0 -1
  428. package/version-manager/versioned-bundle-imports.js.map +0 -1
  429. /package/{version-manager/manifest → common}/sort-values.js +0 -0
  430. /package/report/{artifact-entry-merger.js → aggregator/artifact-entry-merger.js} +0 -0
@@ -1,54 +1,49 @@
1
1
  import { Maybe } from 'true-myth/maybe';
2
- import { unique } from 'remeda';
2
+ import { isCodeFile } from "../common/code-files.js";
3
3
  import { createDependencyGraph } from "./dependency-graph.js";
4
- function isNodeModulesPath(filePath) {
5
- return filePath.includes('/node_modules/');
6
- }
7
- function isLocalPath(filePath) {
8
- return !isNodeModulesPath(filePath);
9
- }
10
- function extractModuleName(nodeModulePath) {
11
- const prefix = '/node_modules/';
12
- const pattern = /\/node_modules\/(?:[^@]+?|(?:@.+?\/.+?))\//;
13
- const result = pattern.exec(nodeModulePath);
14
- if (result === null) {
15
- throw new Error(`Couldn’t find node_modules package name for '${nodeModulePath}'`);
16
- }
17
- return result[0].slice(prefix.length, -1);
18
- }
19
- function determineLocalDependencies(dependencies) {
20
- return dependencies.filter(isLocalPath);
21
- }
22
- function determineExternalDependencies(dependencies) {
23
- const modulePaths = dependencies.filter(isNodeModulesPath);
24
- const moduleNames = modulePaths.map(extractModuleName);
25
- const uniqueModuleNames = unique(moduleNames);
26
- return uniqueModuleNames;
27
- }
28
4
  export function createDependencyScanner(dependencyScannerDependencies) {
29
5
  const { sourceMapFileLocator, typescriptProjectAnalyzer } = dependencyScannerDependencies;
30
- async function getDependencyNodeData(project, sourceFilePath, referencedFilePaths, options) {
31
- const sourceMapFilePath = options.includeSourceMapFiles
6
+ async function getDependencyNodeData(project, sourceFilePath, externalDependencies, options) {
7
+ const sourceMapFilePath = options.includeSourceMapFiles && isCodeFile(sourceFilePath)
32
8
  ? await sourceMapFileLocator.locate(sourceFilePath)
33
9
  : Maybe.nothing();
34
- const externalDependencies = determineExternalDependencies(referencedFilePaths);
35
10
  return {
36
11
  sourceMapFilePath,
37
12
  externalDependencies,
38
13
  project
39
14
  };
40
15
  }
41
- async function scanDependenciesOfSourceFile(project, sourceFilePath, graph, options) {
42
- const referencedFilePaths = project.getReferencedSourceFilePaths(sourceFilePath);
43
- const localFiles = determineLocalDependencies(referencedFilePaths);
44
- const nodeData = await getDependencyNodeData(project, sourceFilePath, referencedFilePaths, options);
45
- graph.addDependency(sourceFilePath, nodeData);
46
- for (const localeFile of localFiles) {
47
- if (!graph.isKnown(localeFile)) {
48
- await scanDependenciesOfSourceFile(project, localeFile, graph, options);
16
+ function localReferencesOf(references) {
17
+ return references.filter((reference) => {
18
+ return reference.kind !== 'external-package';
19
+ });
20
+ }
21
+ function externalDependenciesOf(references) {
22
+ return references.flatMap((reference) => {
23
+ return reference.kind === 'external-package' ? [reference.packageName] : [];
24
+ });
25
+ }
26
+ function referencedModulesOf(project, reference) {
27
+ return reference.kind === 'local-code' ? project.getReferencedModules(reference.filePath) : [];
28
+ }
29
+ function projectFor(reference, project) {
30
+ return reference.kind === 'local-code' ? project : undefined;
31
+ }
32
+ async function scanDependenciesOfReference(project, reference, graph, options) {
33
+ const sourceFilePath = reference.filePath;
34
+ const referencedModules = referencedModulesOf(project, reference);
35
+ const localReferences = localReferencesOf(referencedModules);
36
+ const nodeData = await getDependencyNodeData(projectFor(reference, project), sourceFilePath, externalDependenciesOf(referencedModules), options);
37
+ graph.addDependency(sourceFilePath, {
38
+ ...nodeData,
39
+ ...(reference.kind === 'generated-manifest' ? { isGeneratedManifest: true } : {})
40
+ });
41
+ for (const localReference of localReferences) {
42
+ if (!graph.isKnown(localReference.filePath)) {
43
+ await scanDependenciesOfReference(project, localReference, graph, options);
49
44
  }
50
- if (!graph.hasConnection(sourceFilePath, localeFile)) {
51
- graph.connect(sourceFilePath, localeFile);
45
+ if (!graph.hasConnection(sourceFilePath, localReference.filePath)) {
46
+ graph.connect(sourceFilePath, localReference.filePath);
52
47
  }
53
48
  }
54
49
  }
@@ -65,7 +60,7 @@ export function createDependencyScanner(dependencyScannerDependencies) {
65
60
  resolveDeclarationFiles: scanOptions.resolveDeclarationFiles,
66
61
  mainPackageJson: scanOptions.mainPackageJson
67
62
  });
68
- await scanDependenciesOfSourceFile(project, entryPointFile, graph, scanOptions);
63
+ await scanDependenciesOfReference(project, { kind: 'local-code', filePath: entryPointFile }, graph, scanOptions);
69
64
  return graph;
70
65
  }
71
66
  };
@@ -1 +1 @@
1
- {"version":3,"file":"scanner.js","sourceRoot":"","sources":["../../../../source/dependency-scanner/scanner.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAC;AACxC,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAIhC,OAAO,EAAE,qBAAqB,EAAsD,MAAM,u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CAAC,CAAC;QACH,KAAK,MAAM,cAAc,IAAI,eAAe,EAAE,CAAC;YAC3C,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,cAAc,CAAC,QAAQ,CAAC,EAAE,CAAC;gBAC1C,MAAM,2BAA2B,CAAC,OAAO,EAAE,cAAc,EAAE,KAAK,EAAE,OAAO,CAAC,CAAC;YAC/E,CAAC;YACD,IAAI,CAAC,KAAK,CAAC,aAAa,CAAC,cAAc,EAAE,cAAc,CAAC,QAAQ,CAAC,EAAE,CAAC;gBAChE,KAAK,CAAC,OAAO,CAAC,cAAc,EAAE,cAAc,CAAC,QAAQ,CAAC,CAAC;YAC3D,CAAC;QACL,CAAC;IACL,CAAC;IAED,OAAO;QACH,KAAK,CAAC,IAAI,CAAC,cAAc,EAAE,MAAM,EAAE,OAAO;YACtC,MAAM,EAAE,uBAAuB,GAAG,KAAK,EAAE,qBAAqB,GAAG,KAAK,EAAE,eAAe,EAAE,GAAG,OAAO,CAAC;YACpG,MAAM,WAAW,GAAG;gBAChB,qBAAqB;gBACrB,uBAAuB;gBACvB,eAAe;aAClB,CAAC;YAEF,MAAM,KAAK,GAAG,qBAAqB,EAAE,CAAC;YACtC,MAAM,OAAO,GAAG,yBAAyB,CAAC,cAAc,CAAC,MAAM,EAAE;gBAC7D,uBAAuB,EAAE,WAAW,CAAC,uBAAuB;gBAC5D,eAAe,EAAE,WAAW,CAAC,eAAe;aAC/C,CAAC,CAAC;YAEH,MAAM,2BAA2B,CAC7B,OAAO,EACP,EAAE,IAAI,EAAE,YAAY,EAAE,QAAQ,EAAE,cAAc,EAAE,EAChD,KAAK,EACL,WAAW,CACd,CAAC;YAEF,OAAO,KAAK,CAAC;QACjB,CAAC;KACJ,CAAC;AACN,CAAC"}
@@ -0,0 +1,3 @@
1
+ import { type SourceFile, type StringLiteral } from 'ts-morph';
2
+ export {};
3
+ //# sourceMappingURL=source-file-references.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"source-file-references.d.ts","sourceRoot":"","sources":["../../../../source/dependency-scanner/source-file-references.ts"],"names":[],"mappings":"AAGA,OAAO,EAAM,KAAK,UAAU,EAAE,KAAK,aAAa,EAAE,MAAM,UAAU"}
@@ -1,21 +1,120 @@
1
+ import path from 'node:path';
1
2
  import { isBuiltin } from 'node:module';
2
3
  import { isDefined } from 'remeda';
3
4
  import { ts } from 'ts-morph';
5
+ import { findPackageOwnedAssetFilePath } from "./package-owned-asset-file-path.js";
6
+ function isNodeModulesPath(filePath) {
7
+ return filePath.includes('/node_modules/');
8
+ }
9
+ function extractModuleName(nodeModulePath) {
10
+ const prefix = '/node_modules/';
11
+ const packagePath = nodeModulePath.slice(nodeModulePath.lastIndexOf(prefix) + prefix.length);
12
+ if (!packagePath.startsWith('@')) {
13
+ return packagePath.slice(0, `${packagePath}/`.indexOf('/'));
14
+ }
15
+ const [scope, name] = packagePath.split('/');
16
+ return `${scope}/${name}`;
17
+ }
18
+ function isRelativeOrAbsoluteSpecifier(specifier) {
19
+ return specifier.startsWith('./') || specifier.startsWith('../') || specifier.startsWith('/');
20
+ }
21
+ function packageNameFromSpecifier(specifier) {
22
+ if (specifier.startsWith('@')) {
23
+ const [scope, name] = specifier.split('/');
24
+ if (name === undefined) {
25
+ throw new Error(`Invalid package specifier "${specifier}"`);
26
+ }
27
+ return `${scope}/${name}`;
28
+ }
29
+ const separatorIndex = specifier.indexOf('/');
30
+ return separatorIndex === -1 ? specifier : specifier.slice(0, separatorIndex);
31
+ }
32
+ function resolvePackageOwnedWasmFilePath(literal, containingSourceFile) {
33
+ const importValue = literal.getLiteralValue();
34
+ const packageName = packageNameFromSpecifier(importValue);
35
+ const moduleResolutionHost = containingSourceFile.getProject().getModuleResolutionHost();
36
+ const filePath = findPackageOwnedAssetFilePath(importValue, path.dirname(containingSourceFile.getFilePath()), (candidatePath) => {
37
+ return moduleResolutionHost.fileExists(candidatePath);
38
+ });
39
+ if (filePath !== undefined) {
40
+ return { filePath, packageName };
41
+ }
42
+ return undefined;
43
+ }
44
+ function resolveLocalWasmFilePath(literal, containingSourceFile) {
45
+ const importValue = literal.getLiteralValue();
46
+ const candidatePath = path.resolve(path.dirname(containingSourceFile.getFilePath()), importValue);
47
+ const moduleResolutionHost = containingSourceFile.getProject().getModuleResolutionHost();
48
+ return moduleResolutionHost.fileExists(candidatePath) ? candidatePath : undefined;
49
+ }
50
+ function classifyLocalReference(resolvedFilePath, packageJsonPath) {
51
+ if (path.resolve(resolvedFilePath) === path.resolve(packageJsonPath)) {
52
+ return { kind: 'generated-manifest', filePath: resolvedFilePath };
53
+ }
54
+ const extension = path.extname(resolvedFilePath);
55
+ if (extension === '.json' || extension === '.wasm') {
56
+ return { kind: 'local-asset', filePath: resolvedFilePath };
57
+ }
58
+ return { kind: 'local-code', filePath: resolvedFilePath };
59
+ }
60
+ function resolvedModuleForLiteral(literal, containingSourceFile) {
61
+ const project = containingSourceFile.getProject();
62
+ return ts.resolveModuleName(literal.getLiteralValue(), containingSourceFile.getFilePath(), project.getCompilerOptions(), project.getModuleResolutionHost()).resolvedModule;
63
+ }
4
64
  export function resolveSourceFileForLiteral(literal, containingSourceFile) {
5
65
  const project = containingSourceFile.getProject();
6
- const result = ts.resolveModuleName(literal.getLiteralValue(), containingSourceFile.getFilePath(), project.getCompilerOptions(), project.getModuleResolutionHost());
7
- if (result.resolvedModule !== undefined) {
8
- const resolvedFilePath = result.resolvedModule.resolvedFileName;
66
+ const resolvedModule = resolvedModuleForLiteral(literal, containingSourceFile);
67
+ if (resolvedModule !== undefined) {
68
+ const resolvedFilePath = resolvedModule.resolvedFileName;
9
69
  return project.getSourceFile(resolvedFilePath);
10
70
  }
11
71
  return undefined;
12
72
  }
13
- export function getReferencedSourceFiles(sourceFile) {
73
+ function resolvedModuleBasedReference(literal, containingSourceFile, packageJsonPath) {
74
+ const resolvedModule = resolvedModuleForLiteral(literal, containingSourceFile);
75
+ if (resolvedModule === undefined) {
76
+ return undefined;
77
+ }
78
+ const resolvedFilePath = resolvedModule.resolvedFileName;
79
+ if (isNodeModulesPath(resolvedFilePath)) {
80
+ return {
81
+ kind: 'external-package',
82
+ packageName: extractModuleName(resolvedFilePath)
83
+ };
84
+ }
85
+ return classifyLocalReference(resolvedFilePath, packageJsonPath);
86
+ }
87
+ function fallbackModuleReference(literal, containingSourceFile, packageJsonPath) {
88
+ const importValue = literal.getLiteralValue();
89
+ if (!importValue.endsWith('.wasm')) {
90
+ return undefined;
91
+ }
92
+ if (isRelativeOrAbsoluteSpecifier(importValue)) {
93
+ const wasmFilePath = resolveLocalWasmFilePath(literal, containingSourceFile);
94
+ return wasmFilePath === undefined ? undefined : classifyLocalReference(wasmFilePath, packageJsonPath);
95
+ }
96
+ const packageOwnedWasm = resolvePackageOwnedWasmFilePath(literal, containingSourceFile);
97
+ if (packageOwnedWasm === undefined) {
98
+ return undefined;
99
+ }
100
+ return {
101
+ kind: 'external-package',
102
+ packageName: packageOwnedWasm.packageName
103
+ };
104
+ }
105
+ function resolveModuleReferenceForLiteral(literal, containingSourceFile, packageJsonPath) {
106
+ const directReference = resolvedModuleBasedReference(literal, containingSourceFile, packageJsonPath);
107
+ if (directReference !== undefined) {
108
+ return directReference;
109
+ }
110
+ return fallbackModuleReference(literal, containingSourceFile, packageJsonPath);
111
+ }
112
+ export function getReferencedModules(sourceFile, packageJsonPath) {
14
113
  const importStringLiterals = sourceFile.getImportStringLiterals();
15
114
  return importStringLiterals
16
115
  .map((literal) => {
17
- const referencedSourceFile = resolveSourceFileForLiteral(literal, sourceFile);
18
- if (referencedSourceFile === undefined) {
116
+ const referencedModule = resolveModuleReferenceForLiteral(literal, sourceFile, packageJsonPath);
117
+ if (referencedModule === undefined) {
19
118
  const importValue = literal.getLiteralValue();
20
119
  if (isBuiltin(importValue)) {
21
120
  return undefined;
@@ -23,7 +122,7 @@ export function getReferencedSourceFiles(sourceFile) {
23
122
  const message = `Failed to resolve import "${importValue}" in file "${sourceFile.getFilePath()}"`;
24
123
  throw new Error(message);
25
124
  }
26
- return referencedSourceFile;
125
+ return referencedModule;
27
126
  })
28
127
  .filter(isDefined);
29
128
  }
@@ -1 +1 @@
1
- {"version":3,"file":"source-file-references.js","sourceRoot":"","sources":["../../../../source/dependency-scanner/source-file-references.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,SAAS,EAAE,MAAM,QAAQ,CAAC;AACnC,OAAO,EAAE,EAAE,EAAuC,MAAM,UAAU,CAAC;AAEnE,MAAM,UAAU,2BAA2B,CACvC,OAAsB,EACtB,oBAA0C;IAE1C,MAAM,OAAO,GAAG,oBAAoB,CAAC,UAAU,EAAE,CAAC;IAClD,MAAM,MAAM,GAAG,EAAE,CAAC,iBAAiB,CAC/B,OAAO,CAAC,eAAe,EAAE,EACzB,oBAAoB,CAAC,WAAW,EAAE,EAClC,OAAO,CAAC,kBAAkB,EAAE,EAC5B,OAAO,CAAC,uBAAuB,EAAE,CACpC,CAAC;IAEF,IAAI,MAAM,CAAC,cAAc,KAAK,SAAS,EAAE,CAAC;QACtC,MAAM,gBAAgB,GAAG,MAAM,CAAC,cAAc,CAAC,gBAAgB,CAAC;QAChE,OAAO,OAAO,CAAC,aAAa,CAAC,gBAAgB,CAAC,CAAC;IACnD,CAAC;IAED,OAAO,SAAS,CAAC;AACrB,CAAC;AAED,MAAM,UAAU,wBAAwB,CAAC,UAAgC;IACrE,MAAM,oBAAoB,GAAG,UAAU,CAAC,uBAAuB,EAAE,CAAC;IAClE,OAAO,oBAAoB;SACtB,GAAG,CAAC,CAAC,OAAO,EAAE,EAAE;QACb,MAAM,oBAAoB,GAAG,2BAA2B,CAAC,OAAO,EAAE,UAAU,CAAC,CAAC;QAE9E,IAAI,oBAAoB,KAAK,SAAS,EAAE,CAAC;YACrC,MAAM,WAAW,GAAG,OAAO,CAAC,eAAe,EAAE,CAAC;YAE9C,IAAI,SAAS,CAAC,WAAW,CAAC,EAAE,CAAC;gBACzB,OAAO,SAAS,CAAC;YACrB,CAAC;YAED,MAAM,OAAO,GAAG,6BAA6B,WAAW,cAAc,UAAU,CAAC,WAAW,EAAE,GAAG,CAAC;YAElG,MAAM,IAAI,KAAK,CAAC,OAAO,CAAC,CAAC;QAC7B,CAAC;QAED,OAAO,oBAAoB,CAAC;IAChC,CAAC,CAAC;SACD,MAAM,CAAC,SAAS,CAAC,CAAC;AAC3B,CAAC"}
1
+ {"version":3,"file":"source-file-references.js","sourceRoot":"","sources":["../../../../source/dependency-scanner/source-file-references.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,SAAS,EAAE,MAAM,QAAQ,CAAC;AACnC,OAAO,EAAE,EAAE,EAAuC,MAAM,UAAU,CAAC;AACnE,OAAO,EAAE,6BAA6B,EAAE,MAAM,oCAAoC,CAAC;AA4BnF,SAAS,iBAAiB,CAAC,QAAgB;IACvC,OAAO,QAAQ,CAAC,QAAQ,CAAC,gBAAgB,CAAC,CAAC;AAC/C,CAAC;AAED,SAAS,iBAAiB,CAAC,cAAsB;IAC7C,MAAM,MAAM,GAAG,gBAAgB,CAAC;IAChC,MAAM,WAAW,GAAG,cAAc,CAAC,KAAK,CAAC,cAAc,CAAC,WAAW,CAAC,MAAM,CAAC,GAAG,MAAM,CAAC,MAAM,CAAC,CAAC;IAC7F,IAAI,CAAC,WAAW,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE,CAAC;QAC/B,OAAO,WAAW,CAAC,KAAK,CAAC,CAAC,EAAE,GAAG,WAAW,GAAG,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC;IAChE,CAAC;IAED,MAAM,CAAC,KAAK,EAAE,IAAI,CAAC,GAAG,WAAW,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IAC7C,OAAO,GAAG,KAAK,IAAI,IAAI,EAAE,CAAC;AAC9B,CAAC;AAED,SAAS,6BAA6B,CAAC,SAAiB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gBACzB,OAAO,SAAS,CAAC;YACrB,CAAC;YAED,MAAM,OAAO,GAAG,6BAA6B,WAAW,cAAc,UAAU,CAAC,WAAW,EAAE,GAAG,CAAC;YAElG,MAAM,IAAI,KAAK,CAAC,OAAO,CAAC,CAAC;QAC7B,CAAC;QAED,OAAO,gBAAgB,CAAC;IAC5B,CAAC,CAAC;SACD,MAAM,CAAC,SAAS,CAAC,CAAC;AAC3B,CAAC"}
@@ -0,0 +1,3 @@
1
+ import { type CompilerOptions } from 'ts-morph';
2
+ import type { MainPackageJson } from '../config/package-json.ts';
3
+ //# sourceMappingURL=typescript-compiler-options.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"typescript-compiler-options.d.ts","sourceRoot":"","sources":["../../../../source/dependency-scanner/typescript-compiler-options.ts"],"names":[],"mappings":"AAAA,OAAO,EAAoC,KAAK,eAAe,EAAE,MAAM,UAAU;AACjF,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,2BAA2B"}
@@ -0,0 +1,22 @@
1
+ import { ModuleKind, ModuleResolutionKind } from 'ts-morph';
2
+ export function analyzationOptionsToCompilerOptions(options) {
3
+ const { resolveDeclarationFiles } = options;
4
+ const compilerOptions = {
5
+ moduleResolution: ModuleResolutionKind.Node16,
6
+ esModuleInterop: true,
7
+ maxNodeModuleJsDepth: 1,
8
+ noEmit: true,
9
+ allowJs: true,
10
+ resolveJsonModule: true,
11
+ noLib: true,
12
+ skipLibCheck: true,
13
+ module: ModuleKind.Node16,
14
+ resolvePackageJsonImports: true
15
+ };
16
+ if (!resolveDeclarationFiles) {
17
+ compilerOptions.types = [];
18
+ compilerOptions.typeRoots = [];
19
+ }
20
+ return compilerOptions;
21
+ }
22
+ //# sourceMappingURL=typescript-compiler-options.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"typescript-compiler-options.js","sourceRoot":"","sources":["../../../../source/dependency-scanner/typescript-compiler-options.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,oBAAoB,EAAwB,MAAM,UAAU,CAAC;AAQlF,MAAM,UAAU,mCAAmC,CAAC,OAA2B;IAC3E,MAAM,EAAE,uBAAuB,EAAE,GAAG,OAAO,CAAC;IAE5C,MAAM,eAAe,GAAoB;QACrC,gBAAgB,EAAE,oBAAoB,CAAC,MAAM;QAC7C,eAAe,EAAE,IAAI;QACrB,oBAAoB,EAAE,CAAC;QACvB,MAAM,EAAE,IAAI;QACZ,OAAO,EAAE,IAAI;QACb,iBAAiB,EAAE,IAAI;QACvB,KAAK,EAAE,IAAI;QACX,YAAY,EAAE,IAAI;QAClB,MAAM,EAAE,UAAU,CAAC,MAAM;QACzB,yBAAyB,EAAE,IAAI;KAClC,CAAC;IAEF,IAAI,CAAC,uBAAuB,EAAE,CAAC;QAC3B,eAAe,CAAC,KAAK,GAAG,EAAE,CAAC;QAC3B,eAAe,CAAC,SAAS,GAAG,EAAE,CAAC;IACnC,CAAC;IAED,OAAO,eAAe,CAAC;AAC3B,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"typescript-file-host.d.ts","sourceRoot":"","sources":["../../../../source/dependency-scanner/typescript-file-host.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,UAAU;AAC9C,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,2BAA2B"}
1
+ {"version":3,"file":"typescript-file-host.d.ts","sourceRoot":"","sources":["../../../../source/dependency-scanner/typescript-file-host.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,UAAU;AAE9C,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,2BAA2B"}
@@ -1,83 +1,12 @@
1
- import path from 'node:path';
2
- function isDeclarationFile(filePath) {
3
- const lowerCasedFilePath = filePath.toLowerCase();
4
- return (lowerCasedFilePath.endsWith('.d.ts') ||
5
- lowerCasedFilePath.endsWith('.d.cts') ||
6
- lowerCasedFilePath.endsWith('.d.mts'));
7
- }
8
- function isTypesRootFolder(directoryPath) {
9
- return directoryPath.endsWith('/node_modules/@types') || directoryPath.includes('/node_modules/@types/');
10
- }
11
- const syncMethodNames = {
12
- fileExists: 'fileExistsSync',
13
- directoryExists: 'directoryExistsSync',
14
- readFile: 'readFileSync'
15
- };
16
- function bindRequiredMethod(object, methodName, expectedResultDescription, validateResult) {
17
- const method = Reflect.get(object, methodName);
18
- if (typeof method !== 'function') {
19
- throw new TypeError(`Expected ${methodName} to be a function`);
20
- }
21
- return (filePath) => {
22
- const result = Reflect.apply(method, object, [filePath]);
23
- if (!validateResult(result)) {
24
- throw new TypeError(`Expected ${methodName} to return ${expectedResultDescription}`);
25
- }
26
- return result;
27
- };
28
- }
29
- function isBoolean(value) {
30
- return typeof value === 'boolean';
31
- }
32
- function isString(value) {
33
- return typeof value === 'string';
34
- }
35
- const packageJsonIndentationSpaces = 2;
36
- function serializeMainPackageJson(mainPackageJson) {
37
- return JSON.stringify(mainPackageJson, null, packageJsonIndentationSpaces);
38
- }
39
- function createVirtualPackageJsonHost(fileSystemHost, folder, mainPackageJson) {
40
- const packageJsonPath = path.resolve(folder, 'package.json');
41
- const serializedPackageJson = serializeMainPackageJson(mainPackageJson);
42
- const fileExistsSync = bindRequiredMethod(fileSystemHost, syncMethodNames.fileExists, 'a boolean', isBoolean);
43
- const readFileSync = bindRequiredMethod(fileSystemHost, syncMethodNames.readFile, 'a string', isString);
44
- const virtualFileSystemHost = {
45
- ...fileSystemHost,
46
- fileExists: async (filePath) => {
47
- if (path.resolve(filePath) === packageJsonPath) {
48
- return true;
49
- }
50
- return fileSystemHost.fileExists(filePath);
51
- },
52
- [syncMethodNames.fileExists]: (filePath) => {
53
- if (path.resolve(filePath) === packageJsonPath) {
54
- return true;
55
- }
56
- // eslint-disable-next-line node/no-sync -- the ts-morph host interface requires this synchronous method
57
- return fileExistsSync(filePath);
58
- },
59
- readFile: async (filePath, encoding) => {
60
- if (path.resolve(filePath) === packageJsonPath) {
61
- return serializedPackageJson;
62
- }
63
- return fileSystemHost.readFile(filePath, encoding);
64
- },
65
- [syncMethodNames.readFile]: (filePath) => {
66
- if (path.resolve(filePath) === packageJsonPath) {
67
- return serializedPackageJson;
68
- }
69
- // eslint-disable-next-line node/no-sync -- the ts-morph host interface requires this synchronous method
70
- return readFileSync(filePath);
71
- }
72
- };
73
- Object.setPrototypeOf(virtualFileSystemHost, fileSystemHost);
74
- return virtualFileSystemHost;
75
- }
76
- export function createFileSystemAdapters(dependencies) {
77
- const { fileSystemHost } = dependencies;
1
+ import { isBoolean } from 'remeda';
2
+ import { isDeclarationFile, isTypesRootFolder } from "./file-host-predicates.js";
3
+ import { bindRequiredMethod, syncMethodNames } from "./host-method-binding.js";
4
+ import { createNodeModulesManifestSynthesizingHost } from "./node-modules-manifest-synthesizer.js";
5
+ import { createVirtualPackageJsonHost } from "./virtual-package-json-host.js";
6
+ function createDeclarationFilteringHost(fileSystemHost) {
78
7
  const fileExistsSync = bindRequiredMethod(fileSystemHost, syncMethodNames.fileExists, 'a boolean', isBoolean);
79
8
  const directoryExistsSync = bindRequiredMethod(fileSystemHost, syncMethodNames.directoryExists, 'a boolean', isBoolean);
80
- const fileSystemHostFilteringDeclarationFiles = {
9
+ const filteringHost = {
81
10
  ...fileSystemHost,
82
11
  fileExists: async (filePath) => {
83
12
  if (isDeclarationFile(filePath)) {
@@ -106,10 +35,15 @@ export function createFileSystemAdapters(dependencies) {
106
35
  return directoryExistsSync(directoryPath);
107
36
  }
108
37
  };
109
- Object.setPrototypeOf(fileSystemHostFilteringDeclarationFiles, fileSystemHost);
38
+ Object.setPrototypeOf(filteringHost, fileSystemHost);
39
+ return filteringHost;
40
+ }
41
+ export function createFileSystemAdapters(dependencies) {
42
+ const { fileSystemHost } = dependencies;
43
+ const synthesizingHost = createNodeModulesManifestSynthesizingHost(fileSystemHost);
110
44
  return {
111
- fileSystemHostWithoutFilter: fileSystemHost,
112
- fileSystemHostFilteringDeclarationFiles,
45
+ fileSystemHostWithoutFilter: synthesizingHost,
46
+ fileSystemHostFilteringDeclarationFiles: createDeclarationFilteringHost(synthesizingHost),
113
47
  withVirtualPackageJson: createVirtualPackageJsonHost
114
48
  };
115
49
  }
@@ -1 +1 @@
1
- {"version":3,"file":"typescript-file-host.js","sourceRoot":"","sources":["../../../../source/dependency-scanner/typescript-file-host.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,WAAW,CAAC;AAI7B,SAAS,iBAAiB,CAAC,QAAgB;IACvC,MAAM,kBAAkB,GAAG,QAAQ,CAAC,WAAW,EAAE,CAAC;IAClD,OAAO,CACH,kBAAkB,CAAC,QAAQ,CAAC,OAAO,CAAC;QACpC,kBAAkB,CAAC,QAAQ,CAAC,QAAQ,CAAC;QACrC,kBAAkB,CAAC,QAAQ,CAAC,QAAQ,CAAC,CACxC,CAAC;AACN,CAAC;AAED,SAAS,iBAAiB,CAAC,aAAqB;IAC5C,OAAO,aAAa,CAAC,QAAQ,CAAC,sBAAsB,CAAC,IAAI,aAAa,CAAC,QAAQ,CAAC,uBAAuB,CAAC,CAAC;AAC7G,CAAC;AAgBD,MAAM,eAAe,GAAG;IACpB,UAAU,EAAE,gBAAgB;IAC5B,eAAe,EAAE,qBAAqB;IACtC,QAAQ,EAAE,cAAc;CAClB,CAAC;AAEX,SAAS,kBAAkB,CACvB,MAAsB,EACtB,UAAkB,EAClB,yBAAiC,EACjC,cAAmD;IAEnD,MAAM,MAAM,GAAY,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC;IAExD,IAAI,OAAO,MAAM,KAAK,UAAU,EAAE,CAAC;QAC/B,MAAM,IAAI,SAAS,CAAC,YAAY,UAAU,mBAAmB,CAAC,CAAC;IACnE,CAAC;IAED,OAAO,CAAC,QAAQ,EAAE,EAAE;QAChB,MAAM,MAAM,GAAY,OAAO,CAAC,KAAK,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,QAAQ,CAAC,CAAC,CAAC;QAElE,IAAI,CAAC,cAAc,CAAC,MAAM,CAAC,EAAE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QAAQ,CAAC,EAAE,CAAC;gBAC9B,OAAO,KAAK,CAAC;YACjB,CAAC;YAED,OAAO,cAAc,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC;QAC/C,CAAC;QACD,CAAC,eAAe,CAAC,UAAU,CAAC,EAAE,CAAC,QAAgB,EAAW,EAAE;YACxD,IAAI,iBAAiB,CAAC,QAAQ,CAAC,EAAE,CAAC;gBAC9B,OAAO,KAAK,CAAC;YACjB,CAAC;YAED,wGAAwG;YACxG,OAAO,cAAc,CAAC,QAAQ,CAAC,CAAC;QACpC,CAAC;QACD,eAAe,EAAE,KAAK,EAAE,aAAqB,EAAoB,EAAE;YAC/D,IAAI,iBAAiB,CAAC,aAAa,CAAC,EAAE,CAAC;gBACnC,OAAO,KAAK,CAAC;YACjB,CAAC;YAED,OAAO,cAAc,CAAC,eAAe,CAAC,aAAa,CAAC,CAAC;QACzD,CAAC;QACD,CAAC,eAAe,CAAC,eAAe,CAAC,EAAE,CAAC,aAAqB,EAAW,EAAE;YAClE,IAAI,iBAAiB,CAAC,aAAa,CAAC,EAAE,CAAC;gBACnC,OAAO,KAAK,CAAC;YACjB,CAAC;YAED,wGAAwG;YACxG,OAAO,mBAAmB,CAAC,aAAa,CAAC,CAAC;QAC9C,CAAC;KACJ,CAAC;IACF,MAAM,CAAC,cAAc,CAAC,uCAAuC,EAAE,cAAc,CAAC,CAAC;IAE/E,OAAO;QACH,2BAA2B,EAAE,cAAc;QAC3C,uCAAuC;QACvC,sBAAsB,EAAE,4BAA4B;KACvD,CAAC;AACN,CAAC"}
1
+ {"version":3,"file":"typescript-file-host.js","sourceRoot":"","sources":["../../../../source/dependency-scanner/typescript-file-host.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,QAAQ,CAAC;AAEnC,OAAO,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;AACjF,OAAO,EAAE,kBAAkB,EAAE,eAAe,EAAE,MAAM,0BAA0B,C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C,aAAa,CAAC,CAAC;QAC9C,CAAC;KACJ,CAAC;IACF,MAAM,CAAC,cAAc,CAAC,aAAa,EAAE,cAAc,CAAC,CAAC;IACrD,OAAO,aAAa,CAAC;AACzB,CAAC;AAED,MAAM,UAAU,wBAAwB,CAAC,YAA4C;IACjF,MAAM,EAAE,cAAc,EAAE,GAAG,YAAY,CAAC;IACxC,MAAM,gBAAgB,GAAG,yCAAyC,CAAC,cAAc,CAAC,CAAC;IACnF,OAAO;QACH,2BAA2B,EAAE,gBAAgB;QAC7C,uCAAuC,EAAE,8BAA8B,CAAC,gBAAgB,CAAC;QACzF,sBAAsB,EAAE,4BAA4B;KACvD,CAAC;AACN,CAAC"}
@@ -1,5 +1,5 @@
1
- import { type Project as _Project, type SourceFile } from 'ts-morph';
2
- import type { MainPackageJson } from '../config/package-json.ts';
1
+ import type { Project as _Project, SourceFile } from 'ts-morph';
2
+ import type { ModuleReference } from './source-file-references.ts';
3
+ import { type AnalyzationOptions } from './typescript-compiler-options.ts';
3
4
  import type { FileSystemAdapters } from './typescript-file-host.ts';
4
- export {};
5
5
  //# sourceMappingURL=typescript-project-analyzer.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"typescript-project-analyzer.d.ts","sourceRoot":"","sources":["../../../../source/dependency-scanner/typescript-project-analyzer.ts"],"names":[],"mappings":"AACA,OAAO,EAEH,KAAK,OAAO,IAAI,QAAQ,EACxB,KAAK,UAAU,EAGlB,MAAM,UAAU;AACjB,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,2BAA2B;AAChE,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,2BAA2B"}
1
+ {"version":3,"file":"typescript-project-analyzer.d.ts","sourceRoot":"","sources":["../../../../source/dependency-scanner/typescript-project-analyzer.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,OAAO,IAAI,QAAQ,EAAE,UAAU,EAAE,MAAM,UAAU;AAC/D,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,6BAA6B;AAClE,OAAO,EAAuC,KAAK,kBAAkB,EAAE,MAAM,kCAAkC;AAC/G,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,2BAA2B"}
@@ -1,32 +1,13 @@
1
1
  import path from 'node:path';
2
- import { ModuleKind, ModuleResolutionKind } from 'ts-morph';
2
+ import { analyzationOptionsToCompilerOptions } from "./typescript-compiler-options.js";
3
3
  export function getSourcePathFromSourceFile(sourceFile) {
4
- const filePath = sourceFile.getFilePath();
5
- return filePath;
6
- }
7
- function analyzationOptionsToCompilerOptions(options) {
8
- const { resolveDeclarationFiles } = options;
9
- const compilerOptions = {
10
- moduleResolution: ModuleResolutionKind.Node16,
11
- esModuleInterop: true,
12
- maxNodeModuleJsDepth: 1,
13
- noEmit: true,
14
- allowJs: true,
15
- noLib: true,
16
- skipLibCheck: true,
17
- module: ModuleKind.Node16,
18
- resolvePackageJsonImports: true
19
- };
20
- if (!resolveDeclarationFiles) {
21
- compilerOptions.types = [];
22
- compilerOptions.typeRoots = [];
23
- }
24
- return compilerOptions;
4
+ return sourceFile.getFilePath();
25
5
  }
26
6
  export function createTypescriptProjectAnalyzer(dependencies) {
27
- const { fileSystemAdapters, Project, getReferencedSourceFiles } = dependencies;
7
+ const { fileSystemAdapters, Project, getReferencedModules } = dependencies;
28
8
  return {
29
9
  analyzeProject(folder, options) {
10
+ const packageJsonPath = path.join(folder, 'package.json');
30
11
  const project = new Project({
31
12
  compilerOptions: analyzationOptionsToCompilerOptions(options),
32
13
  fileSystem: fileSystemAdapters.withVirtualPackageJson(options.resolveDeclarationFiles
@@ -37,13 +18,12 @@ export function createTypescriptProjectAnalyzer(dependencies) {
37
18
  const filesPattern = path.join(folder, `**/*${fileExtension}`);
38
19
  project.addSourceFilesAtPaths([filesPattern]);
39
20
  return {
40
- getReferencedSourceFilePaths(containingSourceFilePath) {
21
+ getReferencedModules(containingSourceFilePath) {
41
22
  const currentSourceFile = project.getSourceFile(containingSourceFilePath);
42
23
  if (currentSourceFile === undefined) {
43
24
  return [];
44
25
  }
45
- const referencedSourceFilePaths = getReferencedSourceFiles(currentSourceFile).map(getSourcePathFromSourceFile);
46
- return referencedSourceFilePaths;
26
+ return getReferencedModules(currentSourceFile, packageJsonPath);
47
27
  },
48
28
  getProject() {
49
29
  return project;
@@ -1 +1 @@
1
- {"version":3,"file":"typescript-project-analyzer.js","sourceRoot":"","sources":["../../../../source/dependency-scanner/typescript-project-analyzer.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EACH,UAAU,EAGV,oBAAoB,EAEvB,MAAM,UAAU,CAAC;AAwBlB,MAAM,UAAU,2BAA2B,CAAC,UAAgC;IACxE,MAAM,QAAQ,GAAG,UAAU,CAAC,WAAW,EAAE,CAAC;IAE1C,OAAO,QAAQ,CAAC;AACpB,CAAC;AAED,SAAS,mCAAmC,CAAC,OAA2B;IACpE,MAAM,EAAE,uBAAuB,EAAE,GAAG,OAAO,CAAC;IAE5C,MAAM,eAAe,GAAoB;QACrC,gBAAgB,EAAE,oBAAoB,CAAC,MAAM;QAC7C,eAAe,EAAE,IAAI;QACrB,oBAAoB,EAAE,CAAC;QACvB,MAAM,EAAE,IAAI;QACZ,OAAO,EAAE,IAAI;QACb,KAAK,EAAE,IAAI;QACX,YAAY,EAAE,IAAI;QAClB,MAAM,EAAE,UAAU,CAAC,MAAM;QACzB,yBAAyB,EAAE,IAAI;KAClC,CAAC;IAEF,IAAI,CAAC,uBAAuB,EAAE,CAAC;QAC3B,eAAe,CAAC,KAAK,GAAG,EAAE,CAAC;QAC3B,eAAe,CAAC,SAAS,GAAG,EAAE,CAAC;IACnC,CAAC;IAED,OAAO,eAAe,CAAC;AAC3B,CAAC;AAED,MAAM,UAAU,+BAA+B,CAC3C,YAAmD;IAEnD,MAAM,EAAE,kBAAkB,EAAE,OAAO,EAAE,wBAAwB,EAAE,GAAG,YAAY,CAAC;IAE/E,OAAO;QACH,cAAc,CAAC,MAAM,EAAE,OAAO;YAC1B,MAAM,OAAO,GAAG,IAAI,OAAO,CAAC;gBACxB,eAAe,EAAE,mCAAmC,CAAC,OAAO,CAAC;gBAC7D,UAAU,EAAE,kBAAkB,CAAC,sBAAsB,CACjD,OAAO,CAAC,uBAAuB;oBAC3B,CAAC,CAAC,kBAAkB,CAAC,2BAA2B;oBAChD,CAAC,CAAC,kBAAkB,CAAC,uCAAuC,EAChE,MAAM,EACN,OAAO,CAAC,eAAe,CAC1B;aACJ,CAAC,CAAC;YAEH,MAAM,aAAa,GAAG,OAAO,CAAC,uBAAuB,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,KAAK,CAAC;YACxE,MAAM,YAAY,GAAG,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,OAAO,aAAa,EAAE,CAAC,CAAC;YAC/D,OAAO,CAAC,qBAAqB,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC;YAE9C,OAAO;gBACH,4BAA4B,CAAC,wBAAwB;oBACjD,MAAM,iBAAiB,GAAG,OAAO,CAAC,aAAa,CAAC,wBAAwB,CAAC,CAAC;oBAE1E,IAAI,iBAAiB,KAAK,SAAS,EAAE,CAAC;wBAClC,OAAO,EAAE,CAAC;oBACd,CAAC;oBAED,MAAM,yBAAyB,GAC3B,wBAAwB,CAAC,iBAAiB,CAAC,CAAC,GAAG,CAAC,2BAA2B,CAAC,CAAC;oBAEjF,OAAO,yBAAyB,CAAC;gBACrC,CAAC;gBAED,UAAU;oBACN,OAAO,OAAO,CAAC;gBACnB,CAAC;aACJ,CAAC;QACN,CAAC;KACJ,CAAC;AACN,CAAC"}
1
+ {"version":3,"file":"typescript-project-analyzer.js","sourceRoot":"","sources":["../../../../source/dependency-scanner/typescript-project-analyzer.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,WAAW,CAAC;AAG7B,OAAO,EAAE,mCAAmC,EAA2B,MAAM,kCAAkC,CAAC;AAqBhH,MAAM,UAAU,2BAA2B,CAAC,UAAgC;IACxE,OAAO,U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
+ import path from 'node:path';
2
+ import { isBoolean, isString } from 'remeda';
3
+ import { bindRequiredMethod, syncMethodNames } from "./host-method-binding.js";
4
+ const packageJsonIndentationSpaces = 2;
5
+ function serializeMainPackageJson(mainPackageJson) {
6
+ return JSON.stringify(mainPackageJson, null, packageJsonIndentationSpaces);
7
+ }
8
+ export function createVirtualPackageJsonHost(fileSystemHost, folder, mainPackageJson) {
9
+ const packageJsonPath = path.resolve(folder, 'package.json');
10
+ const serializedPackageJson = serializeMainPackageJson(mainPackageJson);
11
+ const fileExistsSync = bindRequiredMethod(fileSystemHost, syncMethodNames.fileExists, 'a boolean', isBoolean);
12
+ const readFileSync = bindRequiredMethod(fileSystemHost, syncMethodNames.readFile, 'a string', isString);
13
+ const virtualFileSystemHost = {
14
+ ...fileSystemHost,
15
+ fileExists: async (filePath) => {
16
+ if (path.resolve(filePath) === packageJsonPath) {
17
+ return true;
18
+ }
19
+ return fileSystemHost.fileExists(filePath);
20
+ },
21
+ [syncMethodNames.fileExists]: (filePath) => {
22
+ if (path.resolve(filePath) === packageJsonPath) {
23
+ return true;
24
+ }
25
+ // eslint-disable-next-line node/no-sync -- the ts-morph host interface requires this synchronous method
26
+ return fileExistsSync(filePath);
27
+ },
28
+ readFile: async (filePath, encoding) => {
29
+ if (path.resolve(filePath) === packageJsonPath) {
30
+ return serializedPackageJson;
31
+ }
32
+ return fileSystemHost.readFile(filePath, encoding);
33
+ },
34
+ [syncMethodNames.readFile]: (filePath) => {
35
+ if (path.resolve(filePath) === packageJsonPath) {
36
+ return serializedPackageJson;
37
+ }
38
+ // eslint-disable-next-line node/no-sync -- the ts-morph host interface requires this synchronous method
39
+ return readFileSync(filePath);
40
+ }
41
+ };
42
+ Object.setPrototypeOf(virtualFileSystemHost, fileSystemHost);
43
+ return virtualFileSystemHost;
44
+ }
45
+ //# sourceMappingURL=virtual-package-json-host.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"virtual-package-json-host.js","sourceRoot":"","sources":["../../../../source/d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