packtory 0.0.8 → 0.0.10

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 (347) hide show
  1. package/artifacts/artifacts-builder.d.ts +7 -5
  2. package/artifacts/artifacts-builder.d.ts.map +1 -1
  3. package/artifacts/artifacts-builder.js +1 -47
  4. package/artifacts/artifacts-builder.js.map +1 -1
  5. package/bundle-emitter/emitter.d.ts +12 -2
  6. package/bundle-emitter/emitter.d.ts.map +1 -1
  7. package/bundle-emitter/emitter.js +2 -31
  8. package/bundle-emitter/emitter.js.map +1 -1
  9. package/bundle-emitter/extract-package-tarball.js +0 -12
  10. package/bundle-emitter/extract-package-tarball.js.map +1 -1
  11. package/bundle-emitter/publish-settings-bridge.js +133 -0
  12. package/bundle-emitter/publish-settings-bridge.js.map +1 -0
  13. package/bundle-emitter/registry-client.d.ts +13 -6
  14. package/bundle-emitter/registry-client.d.ts.map +1 -1
  15. package/bundle-emitter/registry-client.js +1 -90
  16. package/bundle-emitter/registry-client.js.map +1 -1
  17. package/bundle-emitter/repository-coherence.js +54 -0
  18. package/bundle-emitter/repository-coherence.js.map +1 -0
  19. package/bundle-emitter/repository-url-normalizer.js +2 -0
  20. package/bundle-emitter/repository-url-normalizer.js.map +1 -0
  21. package/checks/check-runner.js +1 -12
  22. package/checks/check-runner.js.map +1 -1
  23. package/checks/rule.js +5 -0
  24. package/checks/rule.js.map +1 -0
  25. package/checks/rules/max-bundle-size.js +9 -0
  26. package/checks/rules/max-bundle-size.js.map +1 -0
  27. package/checks/rules/no-dev-dependency-imports.js +9 -0
  28. package/checks/rules/no-dev-dependency-imports.js.map +1 -0
  29. package/checks/rules/no-duplicated-files.js +6 -38
  30. package/checks/rules/no-duplicated-files.js.map +1 -1
  31. package/checks/rules/no-side-effects.js +9 -0
  32. package/checks/rules/no-side-effects.js.map +1 -0
  33. package/checks/rules/no-unused-bundle-dependencies.js +9 -0
  34. package/checks/rules/no-unused-bundle-dependencies.js.map +1 -0
  35. package/checks/rules/registry.js +8 -0
  36. package/checks/rules/registry.js.map +1 -0
  37. package/checks/rules/required-files.js +10 -0
  38. package/checks/rules/required-files.js.map +1 -0
  39. package/checks/rules/unique-target-paths.js +9 -0
  40. package/checks/rules/unique-target-paths.js.map +1 -0
  41. package/common/clock.d.ts +7 -0
  42. package/common/clock.d.ts.map +1 -0
  43. package/common/clock.js +11 -0
  44. package/common/clock.js.map +1 -0
  45. package/common/code-files.js +5 -0
  46. package/common/code-files.js.map +1 -0
  47. package/config/additional-files.js +0 -4
  48. package/config/additional-files.js.map +1 -1
  49. package/config/additional-package-json-attributes-schema.js +7 -0
  50. package/config/additional-package-json-attributes-schema.js.map +1 -0
  51. package/config/automatic-versioning-settings.js +3 -0
  52. package/config/automatic-versioning-settings.js.map +1 -0
  53. package/config/checks-schema.d.ts +74 -0
  54. package/config/checks-schema.d.ts.map +1 -0
  55. package/config/checks-schema.js +27 -0
  56. package/config/checks-schema.js.map +1 -0
  57. package/config/common-package-settings-schemas.js +20 -0
  58. package/config/common-package-settings-schemas.js.map +1 -0
  59. package/config/config.d.ts +16 -704
  60. package/config/config.d.ts.map +1 -1
  61. package/config/config.js +1 -71
  62. package/config/config.js.map +1 -1
  63. package/config/dead-code-elimination-settings.d.ts +12 -0
  64. package/config/dead-code-elimination-settings.d.ts.map +1 -0
  65. package/config/dead-code-elimination-settings.js +3 -0
  66. package/config/dead-code-elimination-settings.js.map +1 -0
  67. package/config/dependency-policy.d.ts +6 -0
  68. package/config/dependency-policy.d.ts.map +1 -0
  69. package/config/dependency-policy.js +3 -0
  70. package/config/dependency-policy.js.map +1 -0
  71. package/config/main-package-json-schema.js +13 -0
  72. package/config/main-package-json-schema.js.map +1 -0
  73. package/config/manual-versioning-settings.js +3 -0
  74. package/config/manual-versioning-settings.js.map +1 -0
  75. package/config/optional-package-settings-schema.js +15 -0
  76. package/config/optional-package-settings-schema.js.map +1 -0
  77. package/config/package-config.d.ts +49 -0
  78. package/config/package-config.d.ts.map +1 -0
  79. package/config/package-config.js +1 -0
  80. package/config/package-config.js.map +1 -0
  81. package/config/package-interface.d.ts +36 -0
  82. package/config/package-interface.d.ts.map +1 -0
  83. package/config/package-interface.js +3 -0
  84. package/config/package-interface.js.map +1 -0
  85. package/config/package-json.d.ts +10 -10
  86. package/config/package-json.d.ts.map +1 -1
  87. package/config/package-json.js +0 -24
  88. package/config/package-json.js.map +1 -1
  89. package/config/package-schemas.js +10 -0
  90. package/config/package-schemas.js.map +1 -0
  91. package/config/packtory-config-schema.js +4 -0
  92. package/config/packtory-config-schema.js.map +1 -0
  93. package/config/packtory-config-without-registry-schema.js +32 -0
  94. package/config/packtory-config-without-registry-schema.js.map +1 -0
  95. package/config/per-package-settings-schema.js +22 -0
  96. package/config/per-package-settings-schema.js.map +1 -0
  97. package/config/publish-settings.d.ts +22 -0
  98. package/config/publish-settings.d.ts.map +1 -0
  99. package/config/publish-settings.js +4 -0
  100. package/config/publish-settings.js.map +1 -0
  101. package/config/publish-settings.report.js +17 -0
  102. package/config/publish-settings.report.js.map +1 -0
  103. package/config/registry-settings.d.ts +63 -1
  104. package/config/registry-settings.d.ts.map +1 -1
  105. package/config/registry-settings.js +0 -4
  106. package/config/registry-settings.js.map +1 -1
  107. package/config/registry-settings.report.js +41 -0
  108. package/config/registry-settings.report.js.map +1 -0
  109. package/config/root.d.ts +7 -0
  110. package/config/root.d.ts.map +1 -0
  111. package/config/root.js +3 -0
  112. package/config/root.js.map +1 -0
  113. package/config/sbom-settings.js +2 -0
  114. package/config/sbom-settings.js.map +1 -0
  115. package/config/validation.d.ts +2 -2
  116. package/config/validation.d.ts.map +1 -1
  117. package/config/validation.js +4 -118
  118. package/config/validation.js.map +1 -1
  119. package/config/versioning-settings.d.ts.map +1 -1
  120. package/config/versioning-settings.js +2 -10
  121. package/config/versioning-settings.js.map +1 -1
  122. package/dead-code-eliminator/analyzed-bundle.d.ts +29 -0
  123. package/dead-code-eliminator/analyzed-bundle.d.ts.map +1 -0
  124. package/dead-code-eliminator/analyzed-bundle.js +1 -0
  125. package/dead-code-eliminator/analyzed-bundle.js.map +1 -0
  126. package/dead-code-eliminator/cross-bundle/cross-bundle-seeds.js +126 -0
  127. package/dead-code-eliminator/cross-bundle/cross-bundle-seeds.js.map +1 -0
  128. package/dead-code-eliminator/elimination-emitter.js +53 -0
  129. package/dead-code-eliminator/elimination-emitter.js.map +1 -0
  130. package/dead-code-eliminator/eliminator.js +142 -0
  131. package/dead-code-eliminator/eliminator.js.map +1 -0
  132. package/dead-code-eliminator/load-bundle.js +53 -0
  133. package/dead-code-eliminator/load-bundle.js.map +1 -0
  134. package/dead-code-eliminator/reachability/binding-extractor.js +88 -0
  135. package/dead-code-eliminator/reachability/binding-extractor.js.map +1 -0
  136. package/dead-code-eliminator/reachability/impure-statements.js +12 -0
  137. package/dead-code-eliminator/reachability/impure-statements.js.map +1 -0
  138. package/dead-code-eliminator/reachability/reachability.js +141 -0
  139. package/dead-code-eliminator/reachability/reachability.js.map +1 -0
  140. package/dead-code-eliminator/side-effect-classifier.js +406 -0
  141. package/dead-code-eliminator/side-effect-classifier.js.map +1 -0
  142. package/dead-code-eliminator/side-effects-field.js +25 -0
  143. package/dead-code-eliminator/side-effects-field.js.map +1 -0
  144. package/dead-code-eliminator/transform/atom-translator.js +13 -0
  145. package/dead-code-eliminator/transform/atom-translator.js.map +1 -0
  146. package/dead-code-eliminator/transform/declaration-remover.js +92 -0
  147. package/dead-code-eliminator/transform/declaration-remover.js.map +1 -0
  148. package/dead-code-eliminator/transform/line-index.js +27 -0
  149. package/dead-code-eliminator/transform/line-index.js.map +1 -0
  150. package/dead-code-eliminator/transform/source-map-composer.js +68 -0
  151. package/dead-code-eliminator/transform/source-map-composer.js.map +1 -0
  152. package/dependency-scanner/dependency-graph.d.ts +1 -3
  153. package/dependency-scanner/dependency-graph.d.ts.map +1 -1
  154. package/dependency-scanner/dependency-graph.js +1 -76
  155. package/dependency-scanner/dependency-graph.js.map +1 -1
  156. package/dependency-scanner/external-dependencies.d.ts +0 -1
  157. package/dependency-scanner/external-dependencies.d.ts.map +1 -1
  158. package/dependency-scanner/external-dependencies.js +1 -17
  159. package/dependency-scanner/external-dependencies.js.map +1 -1
  160. package/dependency-scanner/scanner.d.ts +7 -7
  161. package/dependency-scanner/scanner.d.ts.map +1 -1
  162. package/dependency-scanner/scanner.js +1 -75
  163. package/dependency-scanner/scanner.js.map +1 -1
  164. package/dependency-scanner/source-file-references.js +2 -73
  165. package/dependency-scanner/source-file-references.js.map +1 -1
  166. package/dependency-scanner/source-map-file-locator.d.ts.map +1 -1
  167. package/dependency-scanner/source-map-file-locator.js +0 -20
  168. package/dependency-scanner/source-map-file-locator.js.map +1 -1
  169. package/dependency-scanner/typescript-file-host.d.ts +2 -0
  170. package/dependency-scanner/typescript-file-host.d.ts.map +1 -1
  171. package/dependency-scanner/typescript-file-host.js +1 -48
  172. package/dependency-scanner/typescript-file-host.js.map +1 -1
  173. package/dependency-scanner/typescript-project-analyzer.d.ts +4 -6
  174. package/dependency-scanner/typescript-project-analyzer.d.ts.map +1 -1
  175. package/dependency-scanner/typescript-project-analyzer.js +0 -64
  176. package/dependency-scanner/typescript-project-analyzer.js.map +1 -1
  177. package/directed-graph/graph.d.ts +1 -2
  178. package/directed-graph/graph.d.ts.map +1 -1
  179. package/directed-graph/graph.js +0 -194
  180. package/directed-graph/graph.js.map +1 -1
  181. package/file-manager/compare.js +1 -16
  182. package/file-manager/compare.js.map +1 -1
  183. package/file-manager/equal.js +0 -5
  184. package/file-manager/equal.js.map +1 -1
  185. package/file-manager/file-manager.d.ts +1 -1
  186. package/file-manager/file-manager.d.ts.map +1 -1
  187. package/file-manager/file-manager.js +0 -46
  188. package/file-manager/file-manager.js.map +1 -1
  189. package/file-manager/permissions.js +0 -12
  190. package/file-manager/permissions.js.map +1 -1
  191. package/linker/linked-bundle.d.ts +5 -3
  192. package/linker/linked-bundle.d.ts.map +1 -1
  193. package/linker/linker.d.ts.map +1 -1
  194. package/linker/linker.js +0 -22
  195. package/linker/linker.js.map +1 -1
  196. package/linker/resource-graph.js +1 -29
  197. package/linker/resource-graph.js.map +1 -1
  198. package/linker/source-modifier/import-paths.js +0 -33
  199. package/linker/source-modifier/import-paths.js.map +1 -1
  200. package/linker/substitute-bundles.js +1 -73
  201. package/linker/substitute-bundles.js.map +1 -1
  202. package/linker/substituted-resource-graph.js +1 -76
  203. package/linker/substituted-resource-graph.js.map +1 -1
  204. package/npm-oidc-id-token-resolver.js +56 -0
  205. package/npm-oidc-id-token-resolver.js.map +1 -0
  206. package/package-surface/modules.js +89 -0
  207. package/package-surface/modules.js.map +1 -0
  208. package/package-surface/public-module-usage.js +37 -0
  209. package/package-surface/public-module-usage.js.map +1 -0
  210. package/package-surface/surface.d.ts +12 -0
  211. package/package-surface/surface.d.ts.map +1 -0
  212. package/package-surface/surface.js +1 -0
  213. package/package-surface/surface.js.map +1 -0
  214. package/package.json +53 -11
  215. package/packages/package-processor.composition.js +127 -0
  216. package/packages/package-processor.composition.js.map +1 -0
  217. package/packages/packtory/packtory.entry-point.d.ts +10 -5
  218. package/packages/packtory/packtory.entry-point.d.ts.map +1 -1
  219. package/packages/packtory/packtory.entry-point.js +7 -43
  220. package/packages/packtory/packtory.entry-point.js.map +1 -1
  221. package/packtory/map-config.d.ts +7 -16
  222. package/packtory/map-config.d.ts.map +1 -1
  223. package/packtory/map-config.js +1 -70
  224. package/packtory/map-config.js.map +1 -1
  225. package/packtory/normalize-paths.js +0 -24
  226. package/packtory/normalize-paths.js.map +1 -1
  227. package/packtory/package-processor-build.js +3 -0
  228. package/packtory/package-processor-build.js.map +1 -0
  229. package/packtory/package-processor-publish.d.ts +18 -0
  230. package/packtory/package-processor-publish.d.ts.map +1 -0
  231. package/packtory/package-processor-publish.js +1 -0
  232. package/packtory/package-processor-publish.js.map +1 -0
  233. package/packtory/package-processor.d.ts +17 -21
  234. package/packtory/package-processor.d.ts.map +1 -1
  235. package/packtory/package-processor.js +2 -85
  236. package/packtory/package-processor.js.map +1 -1
  237. package/packtory/packtory-publish.js +66 -0
  238. package/packtory/packtory-publish.js.map +1 -0
  239. package/packtory/packtory-resolve.js +84 -0
  240. package/packtory/packtory-resolve.js.map +1 -0
  241. package/packtory/packtory-results.d.ts +47 -0
  242. package/packtory/packtory-results.d.ts.map +1 -0
  243. package/packtory/packtory-results.js +1 -0
  244. package/packtory/packtory-results.js.map +1 -0
  245. package/packtory/packtory.d.ts +16 -37
  246. package/packtory/packtory.d.ts.map +1 -1
  247. package/packtory/packtory.js +33 -114
  248. package/packtory/packtory.js.map +1 -1
  249. package/packtory/prepare-package-options.d.ts +16 -0
  250. package/packtory/prepare-package-options.d.ts.map +1 -0
  251. package/packtory/prepare-package-options.js +5 -0
  252. package/packtory/prepare-package-options.js.map +1 -0
  253. package/packtory/report-attachment.js +25 -0
  254. package/packtory/report-attachment.js.map +1 -0
  255. package/packtory/resolved-package.d.ts +17 -0
  256. package/packtory/resolved-package.d.ts.map +1 -0
  257. package/packtory/resolved-package.js +4 -0
  258. package/packtory/resolved-package.js.map +1 -0
  259. package/packtory/scheduler.d.ts.map +1 -1
  260. package/packtory/scheduler.js +17 -15
  261. package/packtory/scheduler.js.map +1 -1
  262. package/progress/progress-broadcaster.d.ts +128 -5
  263. package/progress/progress-broadcaster.d.ts.map +1 -1
  264. package/progress/progress-broadcaster.js +0 -16
  265. package/progress/progress-broadcaster.js.map +1 -1
  266. package/report/artifact-entry-merger.js +2 -0
  267. package/report/artifact-entry-merger.js.map +1 -0
  268. package/report/config-redactor.js +27 -0
  269. package/report/config-redactor.js.map +1 -0
  270. package/report/decorators.js +68 -0
  271. package/report/decorators.js.map +1 -0
  272. package/report/inspectors.js +1 -0
  273. package/report/inspectors.js.map +1 -0
  274. package/report/report-aggregator.d.ts +61 -0
  275. package/report/report-aggregator.d.ts.map +1 -0
  276. package/report/report-aggregator.js +2 -0
  277. package/report/report-aggregator.js.map +1 -0
  278. package/resource-resolver/content.js +1 -40
  279. package/resource-resolver/content.js.map +1 -1
  280. package/resource-resolver/resolved-bundle.d.ts +4 -2
  281. package/resource-resolver/resolved-bundle.d.ts.map +1 -1
  282. package/resource-resolver/resource-resolve-options.d.ts +12 -5
  283. package/resource-resolver/resource-resolve-options.d.ts.map +1 -1
  284. package/resource-resolver/resource-resolve-options.js +2 -0
  285. package/resource-resolver/resource-resolve-options.js.map +1 -0
  286. package/resource-resolver/resource-resolver.d.ts +1 -1
  287. package/resource-resolver/resource-resolver.d.ts.map +1 -1
  288. package/resource-resolver/resource-resolver.js +1 -64
  289. package/resource-resolver/resource-resolver.js.map +1 -1
  290. package/sbom/extract-license.js +2 -0
  291. package/sbom/extract-license.js.map +1 -0
  292. package/sbom/license-resolver.d.ts +14 -0
  293. package/sbom/license-resolver.d.ts.map +1 -0
  294. package/sbom/license-resolver.js +3 -0
  295. package/sbom/license-resolver.js.map +1 -0
  296. package/sbom/sbom-builder.js +68 -0
  297. package/sbom/sbom-builder.js.map +1 -0
  298. package/sbom/sbom-file.d.ts +19 -0
  299. package/sbom/sbom-file.d.ts.map +1 -0
  300. package/sbom/sbom-file.js +3 -0
  301. package/sbom/sbom-file.js.map +1 -0
  302. package/sbom/sbom-serializer.d.ts +6 -0
  303. package/sbom/sbom-serializer.d.ts.map +1 -0
  304. package/sbom/sbom-serializer.js +2 -0
  305. package/sbom/sbom-serializer.js.map +1 -0
  306. package/sbom/tool-version.js +44 -0
  307. package/sbom/tool-version.js.map +1 -0
  308. package/sbom.cdx.json +390 -0
  309. package/tar/extract-tar.js +0 -13
  310. package/tar/extract-tar.js.map +1 -1
  311. package/tar/tarball-builder.d.ts.map +1 -1
  312. package/tar/tarball-builder.js +10 -7
  313. package/tar/tarball-builder.js.map +1 -1
  314. package/version-manager/manager.d.ts +5 -1
  315. package/version-manager/manager.d.ts.map +1 -1
  316. package/version-manager/manager.js +1 -39
  317. package/version-manager/manager.js.map +1 -1
  318. package/version-manager/manifest/builder.js +2 -12
  319. package/version-manager/manifest/builder.js.map +1 -1
  320. package/version-manager/manifest/serialize.js +1 -55
  321. package/version-manager/manifest/serialize.js.map +1 -1
  322. package/version-manager/manifest/sort-values.js +1 -0
  323. package/version-manager/manifest/sort-values.js.map +1 -0
  324. package/version-manager/specifier-classifier.js +2 -0
  325. package/version-manager/specifier-classifier.js.map +1 -0
  326. package/version-manager/specifier-errors.js +1 -0
  327. package/version-manager/specifier-errors.js.map +1 -0
  328. package/version-manager/versioned-bundle-dependencies.js +5 -0
  329. package/version-manager/versioned-bundle-dependencies.js.map +1 -0
  330. package/version-manager/versioned-bundle-imports.d.ts +4 -0
  331. package/version-manager/versioned-bundle-imports.d.ts.map +1 -0
  332. package/version-manager/versioned-bundle-imports.js +3 -0
  333. package/version-manager/versioned-bundle-imports.js.map +1 -0
  334. package/version-manager/versioned-bundle.d.ts +16 -9
  335. package/version-manager/versioned-bundle.d.ts.map +1 -1
  336. package/version-manager/versioned-bundle.js +4 -78
  337. package/version-manager/versioned-bundle.js.map +1 -1
  338. package/config/entry-point.d.ts +0 -7
  339. package/config/entry-point.d.ts.map +0 -1
  340. package/config/entry-point.js +0 -7
  341. package/config/entry-point.js.map +0 -1
  342. package/file-manager/sort.js +0 -13
  343. package/file-manager/sort.js.map +0 -1
  344. package/list/unique-list.js +0 -5
  345. package/list/unique-list.js.map +0 -1
  346. package/version-manager/manifest/builder.d.ts +0 -5
  347. package/version-manager/manifest/builder.d.ts.map +0 -1
@@ -1,77 +1,5 @@
1
1
  import { Maybe } from 'true-myth';
2
+ import { getPublicModuleSpecifierForSourcePath } from "../package-surface/modules.js";
2
3
  import { createSubstitutedResourceGraph } from "./substituted-resource-graph.js";
3
4
  import { replaceImportPaths } from "./source-modifier/import-paths.js";
4
- function findReplacement(file, bundleDependencies) {
5
- for (const bundle of bundleDependencies) {
6
- const matchingContent = bundle.contents.find((content) => {
7
- return content.fileDescription.sourceFilePath === file;
8
- });
9
- if (matchingContent !== undefined) {
10
- const targetPath = `${bundle.name}/${matchingContent.fileDescription.targetFilePath}`;
11
- return Maybe.just({
12
- targetPath,
13
- packageName: bundle.name
14
- });
15
- }
16
- }
17
- return Maybe.nothing();
18
- }
19
- function findAllPathReplacements(files, bundleDependencies) {
20
- const allReplacements = new Map();
21
- const usedBundleDependencies = [];
22
- for (const file of files) {
23
- const result = findReplacement(file, bundleDependencies);
24
- if (result.isJust) {
25
- const { targetPath, packageName } = result.value;
26
- allReplacements.set(file, targetPath);
27
- usedBundleDependencies.push(packageName);
28
- }
29
- }
30
- return { importPathReplacements: allReplacements, bundleDependencies: usedBundleDependencies };
31
- }
32
- export function substituteDependencies(resourceGraph, bundleDependencies) {
33
- const substitutedGraph = createSubstitutedResourceGraph();
34
- const outstandingConnections = [];
35
- resourceGraph.traverse((node) => {
36
- if (!substitutedGraph.isKnown(node.id)) {
37
- const directDependencies = Array.from(node.adjacentNodeIds);
38
- const replacements = findAllPathReplacements(directDependencies, bundleDependencies);
39
- for (const file of directDependencies) {
40
- if (!replacements.importPathReplacements.has(file)) {
41
- outstandingConnections.push({ from: node.id, to: file });
42
- }
43
- }
44
- if (replacements.importPathReplacements.size > 0) {
45
- const substitutionContent = replaceImportPaths(node.data.project, node.data.fileDescription.sourceFilePath, node.data.fileDescription.content, replacements.importPathReplacements);
46
- substitutedGraph.add(node.id, {
47
- fileDescription: {
48
- sourceFilePath: node.data.fileDescription.sourceFilePath,
49
- targetFilePath: node.data.fileDescription.targetFilePath,
50
- isExecutable: node.data.fileDescription.isExecutable,
51
- content: substitutionContent
52
- },
53
- externalDependencies: node.data.externalDependencies,
54
- bundleDependencies: replacements.bundleDependencies,
55
- isSubstituted: true,
56
- isExplicitlyIncluded: node.data.isExplicitlyIncluded
57
- });
58
- }
59
- else {
60
- substitutedGraph.add(node.id, {
61
- fileDescription: node.data.fileDescription,
62
- externalDependencies: node.data.externalDependencies,
63
- bundleDependencies: [],
64
- isSubstituted: false,
65
- isExplicitlyIncluded: node.data.isExplicitlyIncluded
66
- });
67
- }
68
- }
69
- });
70
- for (const connection of outstandingConnections) {
71
- if (!substitutedGraph.hasConnection(connection.from, connection.to)) {
72
- substitutedGraph.connect(connection.from, connection.to);
73
- }
74
- }
75
- return substitutedGraph;
76
- }
77
5
  //# sourceMappingURL=substitute-bundles.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"substitute-bundles.js","sourceRoot":"","sources":["../../../../source/linker/substitute-bundles.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,WAAW,CAAC;AAGlC,OAAO,EAAE,8BAA8B,EAAiC,MAAM,iCAAiC,CAAC;AAChH,OAAO,EAAE,kBAAkB,EAAE,MAAM,mCAAmC,CAAC;AAOvE,SAAS,eAAe,CAAC,IAAY,EAAE,kBAAuD;IAC1F,KAAK,MAAM,MAAM,IAAI,kBAAkB,EAAE,CAAC;QACtC,MAAM,eAAe,GAAG,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,OAAO,EAAE,EAAE;YACrD,OAAO,OAAO,CAAC,eAAe,CAAC,cAAc,KAAK,IAAI,CAAC;QAC3D,CAAC,CAAC,CAAC;QACH,IAAI,eAAe,KAAK,SAAS,EAAE,CAAC;YAChC,MAAM,UAAU,GAAG,GAAG,MAAM,CAAC,IAAI,IAAI,eAAe,CAAC,eAAe,CAAC,cAAc,EAAE,CAAC;YACtF,OAAO,KAAK,CAAC,IAAI,CAAC;gBACd,UAAU;gBACV,WAAW,EAAE,MAAM,CAAC,IAAI;aAC3B,CAAC,CAAC;QACP,CAAC;IACL,CAAC;IAED,OAAO,KAAK,CAAC,OAAO,EAAE,CAAC;AAC3B,CAAC;AAOD,SAAS,uBAAuB,CAC5B,KAAwB,EACxB,kBAAuD;IAEvD,MAAM,eAAe,GAAG,IAAI,GAAG,EAAkB,CAAC;IAClD,MAAM,sBAAsB,GAAa,EAAE,CAAC;IAE5C,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;QACvB,MAAM,MAAM,GAAG,eAAe,CAAC,IAAI,EAAE,kBAAkB,CAAC,CAA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;AAC5B,CAAC"}
1
+ {"version":3,"file":"substitute-bundles.js","sourceRoot":"","sources":["../../../../source/linker/substitute-bundles.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,WAAW;AACjC,OAAO,EAAE,qCAAqC,EAAE,MAAM,+BAA+B;AAGrF,OAAO,EAAE,8BAA8B,EAAiC,MAAM,iCAAiC;AAC/G,OAAO,EAAE,kBAAkB,EAAE,MAAM,mCAAmC"}
@@ -1,78 +1,3 @@
1
+ import { unique } from 'remeda';
1
2
  import { createDirectedGraph } from "../directed-graph/graph.js";
2
- import { uniqueList } from "../list/unique-list.js";
3
- function addOrCreateReference(externalDependencyName, reference, externalDependency) {
4
- if (externalDependency === undefined) {
5
- return {
6
- name: externalDependencyName,
7
- referencedFrom: [reference]
8
- };
9
- }
10
- return {
11
- name: externalDependencyName,
12
- referencedFrom: uniqueList([...externalDependency.referencedFrom, reference])
13
- };
14
- }
15
- function createFlattenCollectors() {
16
- const contents = [];
17
- const linkedBundleDependencies = new Map();
18
- const externalDependencies = new Map();
19
- const visited = new Set();
20
- function collect(filePath, data, directDependencies) {
21
- if (visited.has(filePath)) {
22
- return;
23
- }
24
- visited.add(filePath);
25
- contents.push({
26
- fileDescription: data.fileDescription,
27
- directDependencies,
28
- isSubstituted: data.isSubstituted,
29
- isExplicitlyIncluded: data.isExplicitlyIncluded
30
- });
31
- for (const bundleDependencyName of data.bundleDependencies) {
32
- const bundleDependency = linkedBundleDependencies.get(bundleDependencyName);
33
- linkedBundleDependencies.set(bundleDependencyName, addOrCreateReference(bundleDependencyName, filePath, bundleDependency));
34
- }
35
- for (const externalDependencyName of data.externalDependencies) {
36
- const externalDependency = externalDependencies.get(externalDependencyName);
37
- externalDependencies.set(externalDependencyName, addOrCreateReference(externalDependencyName, filePath, externalDependency));
38
- }
39
- }
40
- return { collect, contents, linkedBundleDependencies, externalDependencies };
41
- }
42
- export function createSubstitutedResourceGraph() {
43
- const graph = createDirectedGraph();
44
- const nodeDataByFilePath = new Map();
45
- return {
46
- add(filePath, data) {
47
- graph.addNode(filePath, data);
48
- nodeDataByFilePath.set(filePath, data);
49
- },
50
- isKnown: graph.hasNode,
51
- connect(fromFilePath, toFilePath) {
52
- graph.connect({ from: fromFilePath, to: toFilePath });
53
- },
54
- hasConnection(fromFilePath, toFilePath) {
55
- return graph.hasConnection({ from: fromFilePath, to: toFilePath });
56
- },
57
- flatten(entryPoints) {
58
- const { collect, contents, linkedBundleDependencies, externalDependencies } = createFlattenCollectors();
59
- for (const entryPoint of entryPoints) {
60
- graph.visitBreadthFirstSearch(entryPoint, (node) => {
61
- collect(node.id, node.data, node.adjacentNodeIds);
62
- });
63
- }
64
- for (const [filePath, data] of nodeDataByFilePath) {
65
- if (data.isExplicitlyIncluded) {
66
- const directDependencies = graph.getAdjacentIds(filePath);
67
- collect(filePath, data, directDependencies);
68
- }
69
- }
70
- return {
71
- contents,
72
- linkedBundleDependencies,
73
- externalDependencies
74
- };
75
- }
76
- };
77
- }
78
3
  //# sourceMappingURL=substituted-resource-graph.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"substituted-resource-graph.js","sourceRoot":"","sources":["../../../../source/linker/substituted-resource-graph.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AACjE,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AAiBpD,SAAS,oBAAoB,CACzB,sBAA8B,EAC9B,SAAiB,EACjB,kBAAuC;IAEvC,IAAI,kBAAkB,KAAK,SAAS,EAAE,CAAC;QACnC,OAAO;YACH,IAAI,EAAE,sBAAsB;YAC5B,cAAc,EAAE,CAAC,SAAS,CAAC;SAC9B,CAAC;IACN,CAAC;IAED,OAAO;QACH,IAAI,EAAE,sBAAsB;QAC5B,cAAc,EAAE,UAAU,CAAC,CAAC,GAAG,kBAAkB,CAAC,cAAc,EAAE,SAAS,CAAC,CAAC;KAChF,CAAC;AACN,CAAC;AAaD,SAAS,u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,CAAC,CAAC;gBAChD,CAAC;YACL,CAAC;YAED,OAAO;gBACH,QAAQ;gBACR,wBAAwB;gBACxB,oBAAoB;aACvB,CAAC;QACN,CAAC;KACJ,CAAC;AACN,CAAC"}
1
+ {"version":3,"file":"substituted-resource-graph.js","sourceRoot":"","sources":["../../../../source/linker/substituted-resource-graph.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ;AAG/B,OAAO,EAAE,mBAAmB,EAAE,MAAM,4BAA4B"}
@@ -0,0 +1,56 @@
1
+ import { z } from 'zod/mini';
2
+ const githubActionsAudience = 'npm:registry.npmjs.org';
3
+ const defaultOidcIdTokenEnvVariableName = 'NPM_ID_TOKEN';
4
+ const gitHubActionsIdTokenResponseSchema = z.object({
5
+ value: z.string().check(z.minLength(1))
6
+ });
7
+ async function parseJsonResponse(response) {
8
+ return response.json();
9
+ }
10
+ function getGitHubActionsRequestConfig(getEnvironmentVariable) {
11
+ const requestUrl = getEnvironmentVariable('ACTIONS_ID_TOKEN_REQUEST_URL');
12
+ const requestToken = getEnvironmentVariable('ACTIONS_ID_TOKEN_REQUEST_TOKEN');
13
+ if (requestUrl === undefined || requestToken === undefined) {
14
+ throw new Error('GitHub Actions OIDC requires ACTIONS_ID_TOKEN_REQUEST_URL and ACTIONS_ID_TOKEN_REQUEST_TOKEN');
15
+ }
16
+ return { requestUrl, requestToken };
17
+ }
18
+ function parseGitHubActionsIdTokenResponse(body) {
19
+ const result = gitHubActionsIdTokenResponseSchema.safeParse(body);
20
+ if (!result.success) {
21
+ throw new Error('GitHub Actions OIDC token response did not contain a usable id_token');
22
+ }
23
+ return result.data.value;
24
+ }
25
+ function usesGitHubActionsProvider(auth, getEnvironmentVariable) {
26
+ const provider = auth.provider ?? 'auto';
27
+ const runsInGitHubActions = getEnvironmentVariable('GITHUB_ACTIONS') === 'true';
28
+ return provider === 'github-actions' || (provider === 'auto' && runsInGitHubActions);
29
+ }
30
+ export function createNpmOidcIdTokenResolver(dependencies) {
31
+ const { fetch: fetchImplementation, getEnvironmentVariable } = dependencies;
32
+ async function fetchGitHubActionsIdToken() {
33
+ const { requestUrl, requestToken } = getGitHubActionsRequestConfig(getEnvironmentVariable);
34
+ const url = new URL(requestUrl);
35
+ url.searchParams.set('audience', githubActionsAudience);
36
+ const response = await fetchImplementation(url, {
37
+ headers: { Authorization: `Bearer ${requestToken}` }
38
+ });
39
+ if (!response.ok) {
40
+ throw new Error(`GitHub Actions OIDC token request failed with status ${response.status}`);
41
+ }
42
+ return parseGitHubActionsIdTokenResponse(await parseJsonResponse(response));
43
+ }
44
+ return async (auth) => {
45
+ if (usesGitHubActionsProvider(auth, getEnvironmentVariable)) {
46
+ return fetchGitHubActionsIdToken();
47
+ }
48
+ const variableName = auth.idTokenEnvVar ?? defaultOidcIdTokenEnvVariableName;
49
+ const value = getEnvironmentVariable(variableName);
50
+ if (value === undefined) {
51
+ throw new Error(`OIDC id_token environment variable "${variableName}" is missing`);
52
+ }
53
+ return value;
54
+ };
55
+ }
56
+ //# sourceMappingURL=npm-oidc-id-token-resolver.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"npm-oidc-id-token-resolver.js","sourceRoot":"","sources":["../../../source/npm-oidc-id-token-resolver.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,UAAU,CAAC;AAG7B,MAAM,qBAAqB,GAAG,wBAAwB,CAAC;AACvD,MAAM,iCAAiC,GAAG,cAAc,CAAC;AAWzD,MAAM,kCAAkC,GAAG,CAAC,CAAC,MAAM,CAAC;IAChD,KAAK,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC;CAC1C,CAAC,CAAC;AAEH,KAAK,UAAU,iBAAiB,CAAC,QAAkB;IAC/C,OAAO,QAAQ,CAAC,IAAI,EAAsB,CAAC;AAC/C,CAAC;AAED,SAAS,6BAA6B,CAAC,sBAAoE;IAIvG,MA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AM,QAAQ,GAAG,MAAM,mBAAmB,CAAC,GAAG,EAAE;YAC5C,OAAO,EAAE,EAAE,aAAa,EAAE,UAAU,YAAY,EAAE,EAAE;SACvD,CAAC,CAAC;QAEH,IAAI,CAAC,QAAQ,CAAC,EAAE,EAAE,CAAC;YACf,MAAM,IAAI,KAAK,CAAC,wDAAwD,QAAQ,CAAC,MAAM,EAAE,CAAC,CAAC;QAC/F,CAAC;QAED,OAAO,iCAAiC,CAAC,MAAM,iBAAiB,CAAC,QAAQ,CAAC,CAAC,CAAC;IAChF,CAAC;IAED,OAAO,KAAK,EAAE,IAAI,EAAE,EAAE;QAClB,IAAI,yBAAyB,CAAC,IAAI,EAAE,sBAAsB,CAAC,EAAE,CAAC;YAC1D,OAAO,yBAAyB,EAAE,CAAC;QACvC,CAAC;QAED,MAAM,YAAY,GAAG,IAAI,CAAC,aAAa,IAAI,iCAAiC,CAAC;QAC7E,MAAM,KAAK,GAAG,sBAAsB,CAAC,YAAY,CAAC,CAAC;QACnD,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;YACtB,MAAM,IAAI,KAAK,CAAC,uCAAuC,YAAY,cAAc,CAAC,CAAC;QACvF,CAAC;QAED,OAAO,KAAK,CAAC;IACjB,CAAC,CAAC;AACN,CAAC"}
@@ -0,0 +1,89 @@
1
+ import { isImplicitPackageSurface } from "./surface.js";
2
+
3
+ function getRoot(bundle, rootId) {
4
+ const root = bundle.roots[rootId];
5
+ if (root === undefined) {
6
+ throw new Error(`Package "${bundle.name}" references unknown root "${rootId}"`);
7
+ }
8
+ return root;
9
+ }
10
+
11
+ function resolveExplicitExportKey(packageName, specifier) {
12
+ if (specifier === packageName) {
13
+ return '.';
14
+ }
15
+ if (specifier.startsWith(`${packageName}/`)) {
16
+ return `./${specifier.slice(packageName.length + 1)}`;
17
+ }
18
+ return undefined;
19
+ }
20
+
21
+ function resolveExplicitPublicModuleSourceFilePath(bundle, surface, specifier) {
22
+ const exportKey = resolveExplicitExportKey(bundle.name, specifier);
23
+ if (exportKey === undefined) {
24
+ return undefined;
25
+ }
26
+ const { modules } = surface.packageInterface;
27
+ if (modules === undefined) {
28
+ return undefined;
29
+ }
30
+ const matchingEntry = modules.find((entry) => {
31
+ return entry.export === exportKey;
32
+ });
33
+ return matchingEntry === undefined ? undefined : getRoot(bundle, matchingEntry.root).js.sourceFilePath;
34
+ }
35
+ function resolveImplicitSpecifier(bundleName, specifier) {
36
+ if (specifier === bundleName) {
37
+ return ['root'];
38
+ }
39
+ const prefix = `${bundleName}/`;
40
+ if (!specifier.startsWith(prefix)) {
41
+ return ['private'];
42
+ }
43
+ return ['content', specifier.slice(prefix.length)];
44
+ }
45
+ function resolveImplicitPublicModuleSourceFilePath(bundle, surface, specifier) {
46
+ const [kind, targetFilePath] = resolveImplicitSpecifier(bundle.name, specifier);
47
+ const handlers = {
48
+ root: () => {
49
+ return getRoot(bundle, surface.defaultModuleRoot).js.sourceFilePath;
50
+ },
51
+ content: () => {
52
+ return bundle.contents.find((entry) => {
53
+ return entry.fileDescription.targetFilePath === targetFilePath;
54
+ })?.fileDescription.sourceFilePath;
55
+ }
56
+ };
57
+ return kind === 'private' ? undefined : handlers[kind]();
58
+ }
59
+ export function getPublicRootIds(bundle) {
60
+ if (isImplicitPackageSurface(bundle.surface)) {
61
+ return new Set(Object.keys(bundle.roots));
62
+ }
63
+ const rootIds = new Set();
64
+ for (const entry of bundle.surface.packageInterface.modules ?? []) {
65
+ rootIds.add(entry.root);
66
+ }
67
+ for (const entry of bundle.surface.packageInterface.bins ?? []) {
68
+ rootIds.add(entry.root);
69
+ }
70
+ return rootIds;
71
+ }
72
+ export function getEntryRootIds(bundle) {
73
+ if (isImplicitPackageSurface(bundle.surface)) {
74
+ return new Set(Object.keys(bundle.roots));
75
+ }
76
+ return new Set([
77
+ ...getPublicRootIds(bundle),
78
+ ...(bundle.surface.packageInterface.privateRoots ?? [])
79
+ ]);
80
+ }
81
+
82
+ export function resolvePublicModuleSourceFilePath(bundle, specifier) {
83
+ if (bundle.surface.mode === 'explicit') {
84
+ return resolveExplicitPublicModuleSourceFilePath(bundle, bundle.surface, specifier);
85
+ }
86
+ return resolveImplicitPublicModuleSourceFilePath(bundle, bundle.surface, specifier);
87
+ }
88
+
89
+ //# sourceMappingURL=modules.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"modules.js","sourceRoot":"","sources":["../../../../source/package-surface/modules.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,wBAAwB,EAAuB,MAAM,cAAc;;AA+B5E,SAAS,OAAO,CAAC,MAA0C,EAAE,MAAc;IACvE,MAAM,IAAI,GAAG,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;IAClC,IAAI,IAAI,KAAK,SAAS,EAAE,CAAC;QACrB,MAAM,IAAI,KAAK,CAAC,YAAY,MAAM,CAAC,IAAI,8BAA8B,MAAM,GAAG,CAAC,CAAC;IACpF,CAAC;IACD,OAAO,IAAI,CAAC;AAChB;;AAUA,SAAS,wBAAwB,CAAC,WAAmB,EAAE,SAAiB;IACpE,IAAI,SAAS,KAAK,WAAW,EAAE,CAAC;QAC5B,OAAO,GAAG,CAAC;IACf,CAAC;IACD,IAAI,SAAS,CAAC,UAAU,CAAC,GAAG,WAAW,GAAG,CAAC,EAAE,CAAC;QAC1C,OAAO,KAAK,SAAS,CAAC,KAAK,CAAC,WAAW,CAAC,MAAM,GAAG,CAAC,CAAC,EAAE,CAAC;IAC1D,CAAC;IACD,OAAO,SAAS,CAAC;AACrB;;AAwTA,SAAS,yCAAyC,CAC9C,MAAkB,EAClB,OAAwB,EACxB,SAAiB;IAEjB,MAAM,SAAS,GAAG,wBAAwB,CAAC,MAAM,CAAC,IAAI,EAAE,SAAS,CAAC,CAAC;IACnE,IAAI,SAAS,KAAK,SAAS,EAAE,CAAC;QAC1B,OAAO,SAAS,CAAC;IACrB,CAAC;IAED,MAAM,EAAE,OAAO,EAAE,GAAG,OAAO,CAAC,gBAAgB,CAAC;IAC7C,IAAI,OAAO,KA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,CAAC,MAAkB,EAAE,SAAiB;IACnF,IAAI,MAAM,CAAC,OAAO,CAAC,IAAI,KAAK,UAAU,EAAE,CAAC;QACrC,OAAO,yCAAyC,CAAC,MAAM,EAAE,MAAM,CAAC,OAAO,EAAE,SAAS,CAAC,CAAC;IACxF,CAAC;IACD,OAAO,yCAAyC,CAAC,MAAM,EAAE,MAAM,CAAC,OAAO,EAAE,SAAS,CAAC,CAAC;AACxF"}
@@ -0,0 +1,37 @@
1
+ import { ts as typescript } from 'ts-morph';
2
+ import { isCodeFile } from "../common/code-files.js";
3
+ import { resolvePublicModuleSourceFilePath } from "./modules.js";
4
+ function recordUsage(usages, bundleName, sourceFilePath) {
5
+ const existing = usages.get(bundleName) ?? new Set();
6
+ existing.add(sourceFilePath);
7
+ usages.set(bundleName, existing);
8
+ }
9
+ function* collectModuleSpecifiers(bundle) {
10
+ for (const resource of bundle.contents) {
11
+ const { targetFilePath, content } = resource.fileDescription;
12
+ if (isCodeFile(targetFilePath)) {
13
+ const parsedFile = typescript.preProcessFile(content, true);
14
+ for (const literal of parsedFile.importedFiles) {
15
+ yield literal.fileName;
16
+ }
17
+ }
18
+ }
19
+ }
20
+ export function collectPublicModuleUsage(bundles) {
21
+ const usages = new Map();
22
+ for (const consumer of bundles) {
23
+ const specifiers = collectModuleSpecifiers(consumer);
24
+ for (const specifier of specifiers) {
25
+ for (const target of bundles) {
26
+ if (target.name !== consumer.name) {
27
+ const sourceFilePath = resolvePublicModuleSourceFilePath(target, specifier);
28
+ if (sourceFilePath !== undefined) {
29
+ recordUsage(usages, target.name, sourceFilePath);
30
+ }
31
+ }
32
+ }
33
+ }
34
+ }
35
+ return usages;
36
+ }
37
+ //# sourceMappingURL=public-module-usage.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"public-module-usage.js","sourceRoot":"","sources":["../../../../source/package-surface/public-module-usage.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,IAAI,UAAU,EAAE,MAAM,UAAU,CAAC;A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CAAC,MAAM,EAAE,SAAS,CAAC,CAAC;oBAC5E,IAAI,cAAc,KAAK,SAAS,EAAE,CAAC;wBAC/B,WAAW,CAAC,MAAM,EAAE,MAAM,CAAC,IAAI,EAAE,cAAc,CAAC,CAAC;oBACrD,CAAC;gBACL,CAAC;YACL,CAAC;QACL,CAAC;IACL,CAAC;IAED,OAAO,MAAM,CAAC;AAClB,CAAC"}
@@ -0,0 +1,12 @@
1
+ import type { PackageInterface } from '../config/package-interface.ts';
2
+ export type ImplicitPackageSurface = {
3
+ readonly mode: 'implicit';
4
+ readonly defaultModuleRoot: string;
5
+ };
6
+ export type ExplicitPackageSurface = {
7
+ readonly mode: 'explicit';
8
+ readonly packageInterface: PackageInterface;
9
+ };
10
+ export type PackageSurface = ExplicitPackageSurface | ImplicitPackageSurface;
11
+ export declare function isImplicitPackageSurface(packageSurface: PackageSurface): packageSurface is ImplicitPackageSurface;
12
+ //# sourceMappingURL=surface.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"surface.d.ts","sourceRoot":"","sources":["../../../../source/package-surface/surface.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,gCAAgC;AAEtE,MAAM,MAAM,sBAAsB,GAAG;IACjC,QAAQ,CAAC,IAAI,EAAE,UAAU,CAAC;IAC1B,QAAQ,CAAC,iBAAiB,EAAE,MAAM,CAAC;CACtC;AAED,MAAM,MAAM,sBAAsB,GAAG;IACjC,QAAQ,CAAC,IAAI,EAAE,UAAU,CAAC;IAC1B,QAAQ,CAAC,gBAAgB,EAAE,gBAAgB,CAAC;CAC/C;AAED,MAAM,MAAM,cAAc,GAAG,sBAAsB,GAAG,sBAAsB;AAgB5E,wBAAgB,wBAAwB,CAAC,cAAc,EAAE,cAAc,GAAG,cAAc,IAAI,sBAAsB"}
@@ -0,0 +1 @@
1
+ //# sourceMappingURL=surface.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"surface.js","sourceRoot":"","sources":["../../../../source/package-surface/surface.ts"],"names":[],"mappings":""}
package/package.json CHANGED
@@ -4,27 +4,58 @@
4
4
  "Christian Rackerseder <github@echooff.de>"
5
5
  ],
6
6
  "dependencies": {
7
+ "@cyclonedx/cyclonedx-library": "10.0.0",
8
+ "@jridgewell/gen-mapping": "0.3.13",
9
+ "@jridgewell/trace-mapping": "0.3.31",
7
10
  "@schema-hub/zod-error-formatter": "0.0.11",
8
- "@ts-morph/common": "0.28.1",
11
+ "@ts-morph/common": "0.29.0",
9
12
  "@types/libnpmpublish": "9.0.1",
10
13
  "@types/npm-registry-fetch": "8.0.9",
11
14
  "common-tags": "1.8.2",
12
- "effect": "2.2.5",
15
+ "hosted-git-info": "10.1.0",
13
16
  "libnpmpublish": "11.1.3",
14
- "mitt": "3.0.1",
17
+ "npm-package-arg": "14.0.0",
15
18
  "npm-registry-fetch": "19.1.1",
16
- "semver": "7.7.4",
17
- "ssri": "13.0.1",
19
+ "remeda": "2.34.1",
20
+ "semver": "7.8.0",
21
+ "spdx-expression-parse": "4.0.0",
18
22
  "tar-stream": "3.1.8",
19
23
  "true-myth": "9.3.1",
20
24
  "ts-morph": "27.0.2",
21
- "type-fest": "5.4.4",
25
+ "type-fest": "5.6.0",
22
26
  "unix-permissions": "6.0.1",
23
- "zod": "4.3.6"
27
+ "zod": "4.4.3"
24
28
  },
25
29
  "description": "Enable customized npm package bundling and publishing using packtory’s versatile API.",
26
30
  "engines": {
27
- "node": "^22 || ^24"
31
+ "node": "^24 || ^26"
32
+ },
33
+ "exports": {
34
+ ".": {
35
+ "import": "./packages/packtory/packtory.entry-point.js",
36
+ "types": "./packages/packtory/packtory.entry-point.d.ts"
37
+ },
38
+ "./bundle-emitter/repository-coherence.js": {
39
+ "import": "./bundle-emitter/repository-coherence.js"
40
+ },
41
+ "./common/clock.js": {
42
+ "import": "./common/clock.js",
43
+ "types": "./common/clock.d.ts"
44
+ },
45
+ "./common/code-files.js": {
46
+ "import": "./common/code-files.js"
47
+ },
48
+ "./packages/package-processor.composition.js": {
49
+ "import": "./packages/package-processor.composition.js"
50
+ },
51
+ "./packtory/packtory.js": {
52
+ "import": "./packtory/packtory.js",
53
+ "types": "./packtory/packtory.d.ts"
54
+ },
55
+ "./packtory/scheduler.js": {
56
+ "import": "./packtory/scheduler.js",
57
+ "types": "./packtory/scheduler.d.ts"
58
+ }
28
59
  },
29
60
  "keywords": [
30
61
  "bundler",
@@ -39,13 +70,24 @@
39
70
  "versioning"
40
71
  ],
41
72
  "license": "MIT",
42
- "main": "packages/packtory/packtory.entry-point.js",
43
73
  "name": "packtory",
44
74
  "repository": {
45
75
  "type": "git",
46
76
  "url": "git+ssh://git@github.com/enormora/packtory.git"
47
77
  },
78
+ "sideEffects": [
79
+ "./bundle-emitter/publish-settings-bridge.js",
80
+ "./bundle-emitter/repository-coherence.js",
81
+ "./config/checks-schema.js",
82
+ "./config/package-schemas.js",
83
+ "./config/packtory-config-without-registry-schema.js",
84
+ "./dead-code-eliminator/side-effect-classifier.js",
85
+ "./dead-code-eliminator/transform/declaration-remover.js",
86
+ "./packages/package-processor.composition.js",
87
+ "./packages/packtory/packtory.entry-point.js",
88
+ "./sbom/sbom-builder.js",
89
+ "./tar/tarball-builder.js"
90
+ ],
48
91
  "type": "module",
49
- "types": "packages/packtory/packtory.entry-point.d.ts",
50
- "version": "0.0.8"
92
+ "version": "0.0.10"
51
93
  }
@@ -0,0 +1,127 @@
1
+ import fs from 'node:fs';
2
+ import { createRequire } from 'node:module';
3
+ import { RealFileSystemHost } from '@ts-morph/common';
4
+ import { publish } from 'libnpmpublish';
5
+ import npmFetch from 'npm-registry-fetch';
6
+ import { ModuleKind, ModuleResolutionKind, Project, ScriptTarget } from 'ts-morph';
7
+ import { createArtifactsBuilder } from "../artifacts/artifacts-builder.js";
8
+ import { createBundleEmitter } from "../bundle-emitter/emitter.js";
9
+ import { createRegistryClient } from "../bundle-emitter/registry-client.js";
10
+ import { getCiRepositoryUrl } from "../bundle-emitter/repository-coherence.js";
11
+ import { createDeadCodeEliminator } from "../dead-code-eliminator/eliminator.js";
12
+ import { createDependencyScanner } from "../dependency-scanner/scanner.js";
13
+ import { getReferencedSourceFiles } from "../dependency-scanner/source-file-references.js";
14
+ import { createSourceMapFileLocator } from "../dependency-scanner/source-map-file-locator.js";
15
+ import { createFileSystemAdapters } from "../dependency-scanner/typescript-file-host.js";
16
+ import { createTypescriptProjectAnalyzer } from "../dependency-scanner/typescript-project-analyzer.js";
17
+ import { createFileManager } from "../file-manager/file-manager.js";
18
+ import { createBundleLinker } from "../linker/linker.js";
19
+ import { createPackageProcessor } from "../packtory/package-processor.js";
20
+ import { createProgressBroadcaster } from "../progress/progress-broadcaster.js";
21
+ import { withStageTimings } from "../report/decorators.js";
22
+ import { createResourceResolver } from "../resource-resolver/resource-resolver.js";
23
+ import { createTarballBuilder } from "../tar/tarball-builder.js";
24
+ import { createVersionManager } from "../version-manager/manager.js";
25
+ import { createClock } from "../common/clock.js";
26
+ import { createNpmOidcIdTokenResolver } from "../npm-oidc-id-token-resolver.js";
27
+ import { createLicenseResolver } from "../sbom/license-resolver.js";
28
+ import { createSbomFileBuilder } from "../sbom/sbom-file.js";
29
+ import { createSbomSerializer } from "../sbom/sbom-serializer.js";
30
+ import { createPacktoryToolVersionResolver } from "../sbom/tool-version.js";
31
+ const localRequire = createRequire(import.meta.url);
32
+ function tryResolvePackagePath(specifier) {
33
+ try {
34
+ return localRequire.resolve(specifier);
35
+ }
36
+ catch {
37
+ return undefined;
38
+ }
39
+ }
40
+ function getEnvironmentVariable(variableName) {
41
+ const environment = process.env[variableName];
42
+ return environment === undefined || environment.length === 0 ? undefined : environment;
43
+ }
44
+ function createDependencyScannerWith(fileManager) {
45
+ const sourceMapFileLocator = createSourceMapFileLocator({ fileManager });
46
+ const fileSystemAdapters = createFileSystemAdapters({ fileSystemHost: new RealFileSystemHost() });
47
+ const typescriptProjectAnalyzer = createTypescriptProjectAnalyzer({
48
+ Project,
49
+ getReferencedSourceFiles,
50
+ fileSystemAdapters
51
+ });
52
+ return createDependencyScanner({ sourceMapFileLocator, typescriptProjectAnalyzer });
53
+ }
54
+ function buildRegistryClient(options, clock) {
55
+ return createRegistryClient({
56
+ npmFetch,
57
+ publish,
58
+ fetch: globalThis.fetch,
59
+ clock,
60
+ resolveIdToken: createNpmOidcIdTokenResolver({
61
+ fetch: globalThis.fetch,
62
+ getEnvironmentVariable
63
+ }),
64
+ promptForOneTimePassword: options.promptForOneTimePassword
65
+ });
66
+ }
67
+ function buildSbomFileBuilder(fileManager) {
68
+ return createSbomFileBuilder({
69
+ licenseResolver: createLicenseResolver({ fileManager }),
70
+ sbomSerializer: createSbomSerializer(),
71
+ toolVersionProvider: createPacktoryToolVersionResolver({
72
+ fileManager,
73
+ resolvePackagePath: tryResolvePackagePath
74
+ }),
75
+ projectFolder: process.cwd()
76
+ });
77
+ }
78
+ function buildBundleEmitter(options, fileManager, progressBroadcaster) {
79
+ const registryClient = buildRegistryClient(options, createClock());
80
+ const artifactsBuilder = createArtifactsBuilder({
81
+ fileManager,
82
+ tarballBuilder: createTarballBuilder(),
83
+ progressBroadcaster: progressBroadcaster.provider
84
+ });
85
+ return createBundleEmitter({
86
+ registryClient,
87
+ artifactsBuilder,
88
+ ciRepositoryUrl: getCiRepositoryUrl(options.ciEnvironment)
89
+ });
90
+ }
91
+ export function buildPackageProcessorComposition(options) {
92
+ const fileManager = createFileManager({ hostFileSystem: fs.promises });
93
+ const dependencyScanner = createDependencyScannerWith(fileManager);
94
+ const progressBroadcaster = createProgressBroadcaster();
95
+ const bundleEmitter = buildBundleEmitter(options, fileManager, progressBroadcaster);
96
+ const resourceResolver = createResourceResolver({ fileManager, dependencyScanner });
97
+ const sbomFileBuilder = buildSbomFileBuilder(fileManager);
98
+ const deadCodeEliminator = createDeadCodeEliminator({
99
+ progressBroadcaster: progressBroadcaster.provider,
100
+ createProject: () => {
101
+ return new Project({
102
+ compilerOptions: {
103
+ allowJs: true,
104
+ module: ModuleKind.Node16,
105
+ esModuleInterop: true,
106
+ noLib: true,
107
+ target: ScriptTarget.ES2022,
108
+ moduleResolution: ModuleResolutionKind.Node10
109
+ },
110
+ skipLoadingLibFiles: true,
111
+ useInMemoryFileSystem: true
112
+ });
113
+ }
114
+ });
115
+ const basePackageProcessor = createPackageProcessor({
116
+ progressBroadcaster: progressBroadcaster.provider,
117
+ versionManager: createVersionManager({ progressBroadcaster: progressBroadcaster.provider }),
118
+ bundleEmitter,
119
+ linker: createBundleLinker(),
120
+ resourceResolver,
121
+ sbomFileBuilder,
122
+ deadCodeEliminator
123
+ });
124
+ const packageProcessor = withStageTimings(basePackageProcessor, progressBroadcaster.provider);
125
+ return { packageProcessor, progressBroadcaster, deadCodeEliminator };
126
+ }
127
+ //# sourceMappingURL=package-processor.composition.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"package-processor.composition.js","sourceRoot":"","sources":["../../../../source/packages/package-processor.composition.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AACtD,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AACxC,OAAO,QAAQ,MAAM,oBAAoB,CAAC;AAC1C,OAAO,EAAE,UAAU,EAAE,oBAAoB,EAAE,OAAO,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AACnF,OAAO,EAAE,sBAAsB,EAAE,MAAM,mCAAmC,CAAC;AAC3E,OAAO,EAAE,mBAAmB,EAAE,MAAM,8BAA8B,CAAC;AACnE,OAAO,EAAE,oBAAoB,EAAE,MAAM,sCAAsC,CAAC;AAC5E,OAAO,EAAE,kBAAkB,EAAsB,MAAM,2CAA2C,CAAC;AACnG,OAAO,EAAE,wBAAwB,EAAE,MAAM,uCAAuC,CAAC;AACjF,OAAO,EAAE,uBAAuB,EAA0B,MAAM,kCAAkC,CAAC;AACnG,OAAO,EAAE,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