packtory 0.0.96 → 0.0.98
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.
- package/artifacts/artifacts-builder.js +37 -4
- package/artifacts/artifacts-builder.js.map +1 -1
- package/artifacts/content-collection.js +59 -2
- package/artifacts/content-collection.js.map +1 -1
- package/artifacts/folder-writer.js +25 -2
- package/artifacts/folder-writer.js.map +1 -1
- package/bundle-emitter/emitter.js +137 -6
- package/bundle-emitter/emitter.js.map +1 -1
- package/bundle-emitter/extract-package-tarball.js +13 -2
- package/bundle-emitter/extract-package-tarball.js.map +1 -1
- package/bundle-emitter/fetch-published-artifacts.js +19 -2
- package/bundle-emitter/fetch-published-artifacts.js.map +1 -1
- package/bundle-emitter/publication-outcome.js +5 -0
- package/bundle-emitter/publication-outcome.js.map +1 -1
- package/bundle-emitter/publish-error/auto-mode-error-matching.js +28 -2
- package/bundle-emitter/publish-error/auto-mode-error-matching.js.map +1 -1
- package/bundle-emitter/publish-error/error-shape-helpers.js +9 -0
- package/bundle-emitter/publish-error/error-shape-helpers.js.map +1 -1
- package/bundle-emitter/publish-error/file-mode-error-matching.js +33 -2
- package/bundle-emitter/publish-error/file-mode-error-matching.js.map +1 -1
- package/bundle-emitter/publish-error/publish-error-messages.js +24 -0
- package/bundle-emitter/publish-error/publish-error-messages.js.map +1 -1
- package/bundle-emitter/registry/metadata-auth-retry.js +24 -1
- package/bundle-emitter/registry/metadata-auth-retry.js.map +1 -1
- package/bundle-emitter/registry/oidc-token-exchange.js +68 -3
- package/bundle-emitter/registry/oidc-token-exchange.js.map +1 -1
- package/bundle-emitter/registry/package-metadata-fetcher.js +210 -7
- package/bundle-emitter/registry/package-metadata-fetcher.js.map +1 -1
- package/bundle-emitter/registry/publish-settings-bridge.js +34 -3
- package/bundle-emitter/registry/publish-settings-bridge.js.map +1 -1
- package/bundle-emitter/registry/registry-auth-config.js +106 -0
- package/bundle-emitter/registry/registry-auth-config.js.map +1 -1
- package/bundle-emitter/registry/registry-client.js +74 -4
- package/bundle-emitter/registry/registry-client.js.map +1 -1
- package/bundle-emitter/registry/registry-package-path.js +3 -0
- package/bundle-emitter/registry/registry-package-path.js.map +1 -1
- package/bundle-emitter/registry/registry-response-schemas.js +50 -2
- package/bundle-emitter/registry/registry-response-schemas.js.map +1 -1
- package/bundle-emitter/registry/tarball-integrity.js +31 -1
- package/bundle-emitter/registry/tarball-integrity.js.map +1 -1
- package/bundle-emitter/registry/validate-tarball-host.js +26 -1
- package/bundle-emitter/registry/validate-tarball-host.js.map +1 -1
- package/bundle-emitter/release-artifact-canonicalizer.js +31 -5
- package/bundle-emitter/release-artifact-canonicalizer.js.map +1 -1
- package/checks/check-runner.js +8 -0
- package/checks/check-runner.js.map +1 -1
- package/checks/rule.js +12 -2
- package/checks/rule.js.map +1 -1
- package/checks/rules/duplicate-detection.js +23 -1
- package/checks/rules/duplicate-detection.js.map +1 -1
- package/checks/rules/duplicate-messages.js +22 -0
- package/checks/rules/duplicate-messages.js.map +1 -1
- package/checks/rules/file-ownership.js +15 -0
- package/checks/rules/file-ownership.js.map +1 -1
- package/checks/rules/max-bundle-size.js +55 -1
- package/checks/rules/max-bundle-size.js.map +1 -1
- package/checks/rules/no-dev-dependency-imports.js +51 -1
- package/checks/rules/no-dev-dependency-imports.js.map +1 -1
- package/checks/rules/no-duplicated-files.js +53 -3
- package/checks/rules/no-duplicated-files.js.map +1 -1
- package/checks/rules/no-side-effects.js +50 -1
- package/checks/rules/no-side-effects.js.map +1 -1
- package/checks/rules/no-unexposed-executables.js +43 -2
- package/checks/rules/no-unexposed-executables.js.map +1 -1
- package/checks/rules/no-unused-bundle-dependencies.js +30 -2
- package/checks/rules/no-unused-bundle-dependencies.js.map +1 -1
- package/checks/rules/registry.js +22 -9
- package/checks/rules/registry.js.map +1 -1
- package/checks/rules/required-files.js +41 -3
- package/checks/rules/required-files.js.map +1 -1
- package/checks/rules/type-script-declaration-integrity.js +81 -3
- package/checks/rules/type-script-declaration-integrity.js.map +1 -1
- package/checks/rules/type-script-declaration-paths.js +55 -1
- package/checks/rules/type-script-declaration-paths.js.map +1 -1
- package/checks/rules/type-script-declaration-project.js +202 -3
- package/checks/rules/type-script-declaration-project.js.map +1 -1
- package/checks/rules/type-script-declaration-reachability.js +38 -2
- package/checks/rules/type-script-declaration-reachability.js.map +1 -1
- package/checks/rules/type-script-declaration-roots.js +29 -0
- package/checks/rules/type-script-declaration-roots.js.map +1 -1
- package/checks/rules/type-script-integrity.js +72 -2
- package/checks/rules/type-script-integrity.js.map +1 -1
- package/checks/rules/type-script-package-resolution.js +42 -1
- package/checks/rules/type-script-package-resolution.js.map +1 -1
- package/checks/rules/type-script-resolution-summary.js +53 -0
- package/checks/rules/type-script-resolution-summary.js.map +1 -1
- package/checks/rules/unique-target-paths.js +34 -2
- package/checks/rules/unique-target-paths.js.map +1 -1
- package/common/bundled-dependency-groups.js +27 -0
- package/common/bundled-dependency-groups.js.map +1 -1
- package/common/code-files.js +28 -0
- package/common/code-files.js.map +1 -1
- package/common/declaration-companion-paths.js +24 -0
- package/common/declaration-companion-paths.js.map +1 -1
- package/common/package-name-map.js +7 -0
- package/common/package-name-map.js.map +1 -1
- package/common/stable-json.js +42 -2
- package/common/stable-json.js.map +1 -1
- package/common/worklist.js +22 -0
- package/common/worklist.js.map +1 -1
- package/config/additional-files.js +6 -2
- package/config/additional-files.js.map +1 -1
- package/config/additional-package-json-attributes-schema.js +6 -2
- package/config/additional-package-json-attributes-schema.js.map +1 -1
- package/config/automatic-versioning-settings.js +6 -2
- package/config/automatic-versioning-settings.js.map +1 -1
- package/config/changelog-settings.js +120 -3
- package/config/changelog-settings.js.map +1 -1
- package/config/common-package-settings-schemas.js +19 -3
- package/config/common-package-settings-schemas.js.map +1 -1
- package/config/config.js +3 -1
- package/config/config.js.map +1 -1
- package/config/cross-package-validation.js +17 -0
- package/config/cross-package-validation.js.map +1 -1
- package/config/dead-code-elimination-settings.js +36 -2
- package/config/dead-code-elimination-settings.js.map +1 -1
- package/config/dependency-existence-validation.js +19 -1
- package/config/dependency-existence-validation.js.map +1 -1
- package/config/dependency-policy.js +5 -2
- package/config/dependency-policy.js.map +1 -1
- package/config/main-package-json-schema.js +11 -2
- package/config/main-package-json-schema.js.map +1 -1
- package/config/manual-versioning-settings.d.ts +12 -0
- package/config/manual-versioning-settings.d.ts.map +1 -1
- package/config/manual-versioning-settings.js +29 -2
- package/config/manual-versioning-settings.js.map +1 -1
- package/config/optional-package-settings-schema.js +16 -7
- package/config/optional-package-settings-schema.js.map +1 -1
- package/config/package-config.js +2 -1
- package/config/package-config.js.map +1 -1
- package/config/package-graph-builder.js +14 -2
- package/config/package-graph-builder.js.map +1 -1
- package/config/package-interface.js +25 -2
- package/config/package-interface.js.map +1 -1
- package/config/package-json.d.ts.map +1 -1
- package/config/package-json.js +16 -0
- package/config/package-json.js.map +1 -1
- package/config/packtory-config-without-registry-schema.js +6 -0
- package/config/packtory-config-without-registry-schema.js.map +1 -1
- package/config/per-package-settings-schema.js +22 -6
- package/config/per-package-settings-schema.js.map +1 -1
- package/config/pre-graph-validation.js +20 -5
- package/config/pre-graph-validation.js.map +1 -1
- package/config/publish-settings.js +25 -3
- package/config/publish-settings.js.map +1 -1
- package/config/publish-settings.report.js +17 -1
- package/config/publish-settings.report.js.map +1 -1
- package/config/registry-settings.js +40 -2
- package/config/registry-settings.js.map +1 -1
- package/config/registry-settings.report.js +46 -0
- package/config/registry-settings.report.js.map +1 -1
- package/config/root-config-validation.js +141 -0
- package/config/root-config-validation.js.map +1 -1
- package/config/root.js +6 -2
- package/config/root.js.map +1 -1
- package/config/sbom-settings.js +4 -1
- package/config/sbom-settings.js.map +1 -1
- package/config/settings-validation.js +28 -0
- package/config/settings-validation.js.map +1 -1
- package/config/versioning-settings.js +10 -3
- package/config/versioning-settings.js.map +1 -1
- package/dead-code-eliminator/analyzed-bundle.js +7 -0
- package/dead-code-eliminator/analyzed-bundle.js.map +1 -1
- package/dead-code-eliminator/artifact-module-reference-contract.js +27 -0
- package/dead-code-eliminator/artifact-module-reference-contract.js.map +1 -0
- package/dead-code-eliminator/bundle-analysis.js +38 -5
- package/dead-code-eliminator/bundle-analysis.js.map +1 -1
- package/dead-code-eliminator/class-purity.js +48 -2
- package/dead-code-eliminator/class-purity.js.map +1 -1
- package/dead-code-eliminator/code-file-analyzer.js +68 -4
- package/dead-code-eliminator/code-file-analyzer.js.map +1 -1
- package/dead-code-eliminator/cross-bundle/bundle-index.js +10 -0
- package/dead-code-eliminator/cross-bundle/bundle-index.js.map +1 -1
- package/dead-code-eliminator/cross-bundle/cross-bundle-seeds.js +22 -3
- package/dead-code-eliminator/cross-bundle/cross-bundle-seeds.js.map +1 -1
- package/dead-code-eliminator/cross-bundle/import-export-walker.js +164 -3
- package/dead-code-eliminator/cross-bundle/import-export-walker.js.map +1 -1
- package/dead-code-eliminator/cross-bundle/seed-store.js +10 -0
- package/dead-code-eliminator/cross-bundle/seed-store.js.map +1 -1
- package/dead-code-eliminator/dependency-metadata.js +172 -2
- package/dead-code-eliminator/dependency-metadata.js.map +1 -1
- package/dead-code-eliminator/elimination-emitter.js +52 -0
- package/dead-code-eliminator/elimination-emitter.js.map +1 -1
- package/dead-code-eliminator/eliminator.js +22 -4
- package/dead-code-eliminator/eliminator.js.map +1 -1
- package/dead-code-eliminator/expression-unwrapping.js +16 -1
- package/dead-code-eliminator/expression-unwrapping.js.map +1 -1
- package/dead-code-eliminator/imported-expression-origin.js +101 -2
- package/dead-code-eliminator/imported-expression-origin.js.map +1 -1
- package/dead-code-eliminator/liveness/asset-side-effects.js +9 -1
- package/dead-code-eliminator/liveness/asset-side-effects.js.map +1 -1
- package/dead-code-eliminator/liveness/boolean-facts.js +98 -2
- package/dead-code-eliminator/liveness/boolean-facts.js.map +1 -1
- package/dead-code-eliminator/liveness/external-purity-summary.js +314 -3
- package/dead-code-eliminator/liveness/external-purity-summary.js.map +1 -1
- package/dead-code-eliminator/liveness/external-purity.js +39 -3
- package/dead-code-eliminator/liveness/external-purity.js.map +1 -1
- package/dead-code-eliminator/liveness/module-analysis.js +27 -2
- package/dead-code-eliminator/liveness/module-analysis.js.map +1 -1
- package/dead-code-eliminator/liveness/resource-retention.js +91 -1
- package/dead-code-eliminator/liveness/resource-retention.js.map +1 -1
- package/dead-code-eliminator/liveness/runtime-code.js +15 -1
- package/dead-code-eliminator/liveness/runtime-code.js.map +1 -1
- package/dead-code-eliminator/load-bundle.js +86 -5
- package/dead-code-eliminator/load-bundle.js.map +1 -1
- package/dead-code-eliminator/pure-expression.js +178 -5
- package/dead-code-eliminator/pure-expression.js.map +1 -1
- package/dead-code-eliminator/reachability/bfs-closure.js +53 -0
- package/dead-code-eliminator/reachability/bfs-closure.js.map +1 -1
- package/dead-code-eliminator/reachability/binding-extractor.js +100 -2
- package/dead-code-eliminator/reachability/binding-extractor.js.map +1 -1
- package/dead-code-eliminator/reachability/binding-id.js +106 -1
- package/dead-code-eliminator/reachability/binding-id.js.map +1 -1
- package/dead-code-eliminator/reachability/identifier-target-collector.js +96 -1
- package/dead-code-eliminator/reachability/identifier-target-collector.js.map +1 -1
- package/dead-code-eliminator/reachability/impure-statements.js +11 -2
- package/dead-code-eliminator/reachability/impure-statements.js.map +1 -1
- package/dead-code-eliminator/reachability/local-seed-gathering.js +91 -4
- package/dead-code-eliminator/reachability/local-seed-gathering.js.map +1 -1
- package/dead-code-eliminator/reachability/reachability.js +70 -4
- package/dead-code-eliminator/reachability/reachability.js.map +1 -1
- package/dead-code-eliminator/side-effect-classifier.js +39 -4
- package/dead-code-eliminator/side-effect-classifier.js.map +1 -1
- package/dead-code-eliminator/side-effects-field.js +23 -1
- package/dead-code-eliminator/side-effects-field.js.map +1 -1
- package/dead-code-eliminator/source-map-recomposition.js +29 -2
- package/dead-code-eliminator/source-map-recomposition.js.map +1 -1
- package/dead-code-eliminator/statement-classifiers.js +94 -4
- package/dead-code-eliminator/statement-classifiers.js.map +1 -1
- package/dead-code-eliminator/syntax-kind-sets.js +16 -0
- package/dead-code-eliminator/syntax-kind-sets.js.map +1 -1
- package/dead-code-eliminator/transform/atom-translator.js +57 -2
- package/dead-code-eliminator/transform/atom-translator.js.map +1 -1
- package/dead-code-eliminator/transform/declaration-removal.js +183 -5
- package/dead-code-eliminator/transform/declaration-removal.js.map +1 -1
- package/dead-code-eliminator/transform/declaration-remover.js +17 -2
- package/dead-code-eliminator/transform/declaration-remover.js.map +1 -1
- package/dead-code-eliminator/transform/line-index.js +20 -0
- package/dead-code-eliminator/transform/line-index.js.map +1 -1
- package/dead-code-eliminator/transform/named-declaration-kinds.js +3 -0
- package/dead-code-eliminator/transform/named-declaration-kinds.js.map +1 -1
- package/dead-code-eliminator/transform/source-map-composer.js +84 -3
- package/dead-code-eliminator/transform/source-map-composer.js.map +1 -1
- package/dead-code-eliminator/variable-declaration-bindings.js +25 -1
- package/dead-code-eliminator/variable-declaration-bindings.js.map +1 -1
- package/dependency-scanner/dependency-graph.js +77 -3
- package/dependency-scanner/dependency-graph.js.map +1 -1
- package/dependency-scanner/external-dependencies.js +55 -1
- package/dependency-scanner/external-dependencies.js.map +1 -1
- package/dependency-scanner/file-host-predicates.js +9 -0
- package/dependency-scanner/file-host-predicates.js.map +1 -1
- package/dependency-scanner/host-method-binding.js +18 -0
- package/dependency-scanner/host-method-binding.js.map +1 -1
- package/dependency-scanner/injected-dynamic-imports.js +232 -1
- package/dependency-scanner/injected-dynamic-imports.js.map +1 -1
- package/dependency-scanner/node-modules-manifest-synthesizer.js +52 -4
- package/dependency-scanner/node-modules-manifest-synthesizer.js.map +1 -1
- package/dependency-scanner/package-owned-asset-file-path.js +9 -1
- package/dependency-scanner/package-owned-asset-file-path.js.map +1 -1
- package/dependency-scanner/scanner.js +109 -4
- package/dependency-scanner/scanner.js.map +1 -1
- package/dependency-scanner/source-file-references.js +171 -6
- package/dependency-scanner/source-file-references.js.map +1 -1
- package/dependency-scanner/source-map-file-locator.js +66 -2
- package/dependency-scanner/source-map-file-locator.js.map +1 -1
- package/dependency-scanner/typescript-compiler-options.js +21 -1
- package/dependency-scanner/typescript-compiler-options.js.map +1 -1
- package/dependency-scanner/typescript-file-host.js +49 -5
- package/dependency-scanner/typescript-file-host.js.map +1 -1
- package/dependency-scanner/typescript-module-resolution.js +214 -0
- package/dependency-scanner/typescript-module-resolution.js.map +1 -0
- package/dependency-scanner/typescript-project-analyzer.js +32 -3
- package/dependency-scanner/typescript-project-analyzer.js.map +1 -1
- package/dependency-scanner/virtual-package-json-host.js +45 -4
- package/dependency-scanner/virtual-package-json-host.js.map +1 -1
- package/directed-graph/graph.js +240 -1
- package/directed-graph/graph.js.map +1 -1
- package/file-manager/compare.js +23 -2
- package/file-manager/compare.js.map +1 -1
- package/file-manager/equal.js +5 -0
- package/file-manager/equal.js.map +1 -1
- package/file-manager/file-description.js +3 -0
- package/file-manager/file-description.js.map +1 -1
- package/file-manager/permissions.js +28 -1
- package/file-manager/permissions.js.map +1 -1
- package/git/current-git-head.js +24 -0
- package/git/current-git-head.js.map +1 -1
- package/git/git-command.js +49 -1
- package/git/git-command.js.map +1 -1
- package/linker/linked-bundle.js +5 -0
- package/linker/linked-bundle.js.map +1 -1
- package/linker/linker.js +51 -5
- package/linker/linker.js.map +1 -1
- package/linker/replacement-lookup.js +297 -8
- package/linker/replacement-lookup.js.map +1 -1
- package/linker/resource-graph.js +65 -2
- package/linker/resource-graph.js.map +1 -1
- package/linker/source-modifier/import-paths.js +80 -3
- package/linker/source-modifier/import-paths.js.map +1 -1
- package/linker/substitute-bundles.js +166 -3
- package/linker/substitute-bundles.js.map +1 -1
- package/linker/substituted-resource-graph.js +111 -2
- package/linker/substituted-resource-graph.js.map +1 -1
- package/npm-oidc-id-token-resolver.js +82 -0
- package/npm-oidc-id-token-resolver.js.map +1 -1
- package/pack-emitter/pack-emitter.js +27 -0
- package/pack-emitter/pack-emitter.js.map +1 -1
- package/package-surface/bin-field.js +8 -2
- package/package-surface/bin-field.js.map +1 -1
- package/package-surface/explicit-bin.js +24 -2
- package/package-surface/explicit-bin.js.map +1 -1
- package/package-surface/explicit-exports.js +26 -3
- package/package-surface/explicit-exports.js.map +1 -1
- package/package-surface/export-map.js +9 -2
- package/package-surface/export-map.js.map +1 -1
- package/package-surface/implicit-bin.js +25 -1
- package/package-surface/implicit-bin.js.map +1 -1
- package/package-surface/implicit-exports.js +10 -3
- package/package-surface/implicit-exports.js.map +1 -1
- package/package-surface/implicit-root-exports.js +13 -2
- package/package-surface/implicit-root-exports.js.map +1 -1
- package/package-surface/package-json-export.js +9 -0
- package/package-surface/package-json-export.js.map +1 -1
- package/package-surface/package-shape.js +10 -1
- package/package-surface/package-shape.js.map +1 -1
- package/package-surface/package-surface-index.js +165 -3
- package/package-surface/package-surface-index.js.map +1 -1
- package/package-surface/public-module-usage.js +46 -3
- package/package-surface/public-module-usage.js.map +1 -1
- package/package-surface/public-specifiers.js +7 -1
- package/package-surface/public-specifiers.js.map +1 -1
- package/package-surface/root-registry.js +26 -0
- package/package-surface/root-registry.js.map +1 -1
- package/package-surface/specifier-syntax.js +4 -0
- package/package-surface/specifier-syntax.js.map +1 -1
- package/package-surface/substitution-exports.js +101 -3
- package/package-surface/substitution-exports.js.map +1 -1
- package/package-surface/surface.js +12 -0
- package/package-surface/surface.js.map +1 -1
- package/package.json +2 -2
- package/packages/package-processor.composition.js +161 -34
- package/packages/package-processor.composition.js.map +1 -1
- package/packtory/map-config.js +35 -4
- package/packtory/map-config.js.map +1 -1
- package/packtory/normalize-paths.js +25 -1
- package/packtory/normalize-paths.js.map +1 -1
- package/packtory/options/bundle-dependency-resolution.js +17 -1
- package/packtory/options/bundle-dependency-resolution.js.map +1 -1
- package/packtory/options/dead-code-elimination-resolution.js +10 -1
- package/packtory/options/dead-code-elimination-resolution.js.map +1 -1
- package/packtory/options/prepare-package-options.js +46 -5
- package/packtory/options/prepare-package-options.js.map +1 -1
- package/packtory/options/required-value-helpers.js +17 -0
- package/packtory/options/required-value-helpers.js.map +1 -1
- package/packtory/options/setting-resolvers.js +47 -3
- package/packtory/options/setting-resolvers.js.map +1 -1
- package/packtory/options/surface-resolution.js +15 -2
- package/packtory/options/surface-resolution.js.map +1 -1
- package/packtory/options/version-provider-context.js +24 -2
- package/packtory/options/version-provider-context.js.map +1 -1
- package/packtory/options/version-trigger.js +39 -2
- package/packtory/options/version-trigger.js.map +1 -1
- package/packtory/pack-output-preflight.js +60 -3
- package/packtory/pack-output-preflight.js.map +1 -1
- package/packtory/package-processor-build.js +97 -3
- package/packtory/package-processor-build.js.map +1 -1
- package/packtory/package-processor-publish.js +297 -6
- package/packtory/package-processor-publish.js.map +1 -1
- package/packtory/package-processor.js +10 -2
- package/packtory/package-processor.js.map +1 -1
- package/packtory/packtory-pack.js +298 -10
- package/packtory/packtory-pack.js.map +1 -1
- package/packtory/packtory-package-dependencies.js +116 -2
- package/packtory/packtory-package-dependencies.js.map +1 -1
- package/packtory/packtory-package-inspection.js +26 -5
- package/packtory/packtory-package-inspection.js.map +1 -1
- package/packtory/packtory-package-side-effects.js +64 -3
- package/packtory/packtory-package-side-effects.js.map +1 -1
- package/packtory/packtory-package-tree.js +43 -4
- package/packtory/packtory-package-tree.js.map +1 -1
- package/packtory/packtory-publish.js +17 -4
- package/packtory/packtory-publish.js.map +1 -1
- package/packtory/packtory-release-analysis.js +64 -6
- package/packtory/packtory-release-analysis.js.map +1 -1
- package/packtory/packtory-release-diff.js +48 -5
- package/packtory/packtory-release-diff.js.map +1 -1
- package/packtory/packtory-release-plan.js +87 -6
- package/packtory/packtory-release-plan.js.map +1 -1
- package/packtory/packtory-resolve.js +16 -5
- package/packtory/packtory-resolve.js.map +1 -1
- package/packtory/packtory.js +242 -13
- package/packtory/packtory.js.map +1 -1
- package/packtory/publish-failure-mapping.js +6 -0
- package/packtory/publish-failure-mapping.js.map +1 -1
- package/packtory/publish-target-preflight.js +25 -3
- package/packtory/publish-target-preflight.js.map +1 -1
- package/packtory/published-release-state.js +11 -0
- package/packtory/published-release-state.js.map +1 -1
- package/packtory/release-analysis.js +153 -5
- package/packtory/release-analysis.js.map +1 -1
- package/packtory/release-diff-failure-mapping.js +6 -0
- package/packtory/release-diff-failure-mapping.js.map +1 -1
- package/packtory/release-plan.js +135 -7
- package/packtory/release-plan.js.map +1 -1
- package/packtory/report-attachment.js +35 -2
- package/packtory/report-attachment.js.map +1 -1
- package/packtory/resolved-package.js +97 -3
- package/packtory/resolved-package.js.map +1 -1
- package/packtory/scheduler.js +99 -1
- package/packtory/scheduler.js.map +1 -1
- package/packtory/stages/package-analysis-stage.js +50 -2
- package/packtory/stages/package-analysis-stage.js.map +1 -1
- package/packtory/stages/package-resolution-stage.js +80 -5
- package/packtory/stages/package-resolution-stage.js.map +1 -1
- package/packtory/stages/publish-stage.js +125 -4
- package/packtory/stages/publish-stage.js.map +1 -1
- package/packtory/stages/release-diff-stage.js +84 -5
- package/packtory/stages/release-diff-stage.js.map +1 -1
- package/progress/progress-broadcaster.js +45 -0
- package/progress/progress-broadcaster.js.map +1 -1
- package/published-package/published-package.js +12 -1
- package/published-package/published-package.js.map +1 -1
- package/report/aggregator/artifact-entry-merger.js +20 -0
- package/report/aggregator/artifact-entry-merger.js.map +1 -1
- package/report/aggregator/package-report-materialization.js +75 -2
- package/report/aggregator/package-report-materialization.js.map +1 -1
- package/report/aggregator/report-aggregator.js +37 -2
- package/report/aggregator/report-aggregator.js.map +1 -1
- package/report/aggregator/report-event-handlers.js +141 -2
- package/report/aggregator/report-event-handlers.js.map +1 -1
- package/report/aggregator/report-types.js +3 -0
- package/report/aggregator/report-types.js.map +1 -1
- package/report/config-redactor.js +29 -3
- package/report/config-redactor.js.map +1 -1
- package/report/decorators.js +85 -0
- package/report/decorators.js.map +1 -1
- package/report/inspectors/inspect-artifact-sizes.js +34 -1
- package/report/inspectors/inspect-artifact-sizes.js.map +1 -1
- package/report/inspectors/inspect-linker-rewrites.js +14 -1
- package/report/inspectors/inspect-linker-rewrites.js.map +1 -1
- package/report/inspectors/inspect-package-json-provenance.js +15 -0
- package/report/inspectors/inspect-package-json-provenance.js.map +1 -1
- package/report/inspectors/inspect-scan-results.js +15 -0
- package/report/inspectors/inspect-scan-results.js.map +1 -1
- package/report/release-diff/release-version-transition.js +18 -0
- package/report/release-diff/release-version-transition.js.map +1 -1
- package/resource-resolver/bundle-resource-lookup.js +25 -0
- package/resource-resolver/bundle-resource-lookup.js.map +1 -1
- package/resource-resolver/content.js +136 -4
- package/resource-resolver/content.js.map +1 -1
- package/resource-resolver/dependency-resolution-walker.js +73 -2
- package/resource-resolver/dependency-resolution-walker.js.map +1 -1
- package/resource-resolver/resolved-bundle.js +3 -0
- package/resource-resolver/resolved-bundle.js.map +1 -1
- package/resource-resolver/resource-resolve-options.js +13 -1
- package/resource-resolver/resource-resolve-options.js.map +1 -1
- package/resource-resolver/resource-resolver.js +128 -6
- package/resource-resolver/resource-resolver.js.map +1 -1
- package/sbom/extract-license.js +11 -1
- package/sbom/extract-license.js.map +1 -1
- package/sbom/license-resolver.js +23 -2
- package/sbom/license-resolver.js.map +1 -1
- package/sbom/sbom-builder.js +57 -2
- package/sbom/sbom-builder.js.map +1 -1
- package/sbom/sbom-canonicalizer.js +45 -3
- package/sbom/sbom-canonicalizer.js.map +1 -1
- package/sbom/sbom-file.js +54 -5
- package/sbom/sbom-file.js.map +1 -1
- package/sbom/sbom-serializer.js +14 -1
- package/sbom/sbom-serializer.js.map +1 -1
- package/sbom/tool-version.js +49 -1
- package/sbom/tool-version.js.map +1 -1
- package/sbom.cdx.json +10 -10
- package/tar/extract-tar.js +83 -3
- package/tar/extract-tar.js.map +1 -1
- package/tar/gzipped-pack.js +20 -0
- package/tar/gzipped-pack.js.map +1 -1
- package/tar/tarball-builder.js +44 -4
- package/tar/tarball-builder.js.map +1 -1
- package/vendor-materializer/vendor-entry.js +20 -1
- package/vendor-materializer/vendor-entry.js.map +1 -1
- package/vendor-materializer/vendor-materializer.js +240 -8
- package/vendor-materializer/vendor-materializer.js.map +1 -1
- package/version-manager/dependencies/bundle-dependency-grouping.js +32 -2
- package/version-manager/dependencies/bundle-dependency-grouping.js.map +1 -1
- package/version-manager/dependencies/dependency-groups.js +11 -1
- package/version-manager/dependencies/dependency-groups.js.map +1 -1
- package/version-manager/dependencies/external-dependency-classification.js +82 -3
- package/version-manager/dependencies/external-dependency-classification.js.map +1 -1
- package/version-manager/dependencies/versioned-bundle-dependencies.js +8 -3
- package/version-manager/dependencies/versioned-bundle-dependencies.js.map +1 -1
- package/version-manager/imports/hash-import-scanner.js +20 -2
- package/version-manager/imports/hash-import-scanner.js.map +1 -1
- package/version-manager/imports/imports-key-matcher.js +22 -0
- package/version-manager/imports/imports-key-matcher.js.map +1 -1
- package/version-manager/imports/versioned-bundle-imports.js +44 -2
- package/version-manager/imports/versioned-bundle-imports.js.map +1 -1
- package/version-manager/manager.js +46 -6
- package/version-manager/manager.js.map +1 -1
- package/version-manager/manifest/builder.js +51 -1
- package/version-manager/manifest/builder.js.map +1 -1
- package/version-manager/manifest/serialize.js +8 -1
- package/version-manager/manifest/serialize.js.map +1 -1
- package/version-manager/optional-bundle-fields.js +5 -1
- package/version-manager/optional-bundle-fields.js.map +1 -1
- package/version-manager/representative-root.js +9 -1
- package/version-manager/representative-root.js.map +1 -1
- package/version-manager/specifier-classifier.js +42 -2
- package/version-manager/specifier-classifier.js.map +1 -1
- package/version-manager/specifier-errors.js +58 -0
- package/version-manager/specifier-errors.js.map +1 -1
- package/version-manager/versioned-bundle.js +31 -6
- package/version-manager/versioned-bundle.js.map +1 -1
- package/zip/zip-builder.js +81 -2
- package/zip/zip-builder.js.map +1 -1
- package/dead-code-eliminator/liveness/external-module-resolution.js +0 -3
- package/dead-code-eliminator/liveness/external-module-resolution.js.map +0 -1
|
@@ -1,5 +1,38 @@
|
|
|
1
|
-
import "../report/inspectors/inspect-artifact-sizes.js";
|
|
2
|
-
import "../vendor-materializer/vendor-entry.js";
|
|
3
|
-
import "./content-collection.js";
|
|
4
|
-
import "./folder-writer.js";
|
|
1
|
+
import { inspectArtifactSizes } from "../report/inspectors/inspect-artifact-sizes.js";
|
|
2
|
+
import { applyPrefixToVendorEntry } from "../vendor-materializer/vendor-entry.js";
|
|
3
|
+
import { collectArtifactContents, describeArtifactsForReport } from "./content-collection.js";
|
|
4
|
+
import { writeArtifactsToFolder } from "./folder-writer.js";
|
|
5
|
+
export function createArtifactsBuilder(dependencies) {
|
|
6
|
+
const { fileManager, tarballBuilder, zipBuilder, progressBroadcaster } = dependencies;
|
|
7
|
+
function collectContents(bundle, prefix, extraFiles = []) {
|
|
8
|
+
const artifactContents = collectArtifactContents(bundle, prefix, extraFiles);
|
|
9
|
+
if (progressBroadcaster.hasSubscribers('artifactsCollected')) {
|
|
10
|
+
progressBroadcaster.emit('artifactsCollected', {
|
|
11
|
+
packageName: bundle.name,
|
|
12
|
+
entries: inspectArtifactSizes(describeArtifactsForReport(bundle, prefix, extraFiles))
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
return artifactContents;
|
|
16
|
+
}
|
|
17
|
+
return {
|
|
18
|
+
collectContents,
|
|
19
|
+
async buildTarball(bundle, extraFiles, vendorEntries = []) {
|
|
20
|
+
const contents = collectContents(bundle, 'package', extraFiles);
|
|
21
|
+
const prefixedVendor = vendorEntries.map(function (entry) {
|
|
22
|
+
return applyPrefixToVendorEntry('package', entry);
|
|
23
|
+
});
|
|
24
|
+
const tarData = await tarballBuilder.build(contents, prefixedVendor);
|
|
25
|
+
return { tarData };
|
|
26
|
+
},
|
|
27
|
+
async buildZip(bundle, extraFiles, vendorEntries = []) {
|
|
28
|
+
const contents = collectContents(bundle, undefined, extraFiles);
|
|
29
|
+
const zipData = await zipBuilder.build(contents, vendorEntries);
|
|
30
|
+
return { zipData };
|
|
31
|
+
},
|
|
32
|
+
async buildFolder(bundle, targetFolder, extraFiles, vendorEntries = []) {
|
|
33
|
+
const contents = collectContents(bundle, undefined, extraFiles);
|
|
34
|
+
await writeArtifactsToFolder(fileManager, targetFolder, contents, vendorEntries);
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
}
|
|
5
38
|
//# sourceMappingURL=artifacts-builder.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"artifacts-builder.js","sourceRoot":"","sources":["../../../../source/artifacts/artifacts-builder.ts"],"names":[],"mappings":"AAIA,
|
|
1
|
+
{"version":3,"file":"artifacts-builder.js","sourceRoot":"","sources":["../../../../source/artifacts/artifacts-builder.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,oBAAoB,EAAE,MAAM,gDAAgD,CAAC;AAEtF,OAAO,EAAE,wBAAwB,EAAoB,MAAM,wCAAwC,CAAC;AAEpG,OAAO,EAAE,uBAAuB,EAAE,0BAA0B,EAAE,MAAM,yBAAyB,CAAC;AAC9F,OAAO,EAAE,sBAAsB,EAAE,MAAM,oBAAoB,CAAC;AAyC5D,MAAM,UAAU,sBAAsB,CAAC,YAA0C;IAC7E,MAAM,EAAE,WAAW,EAAE,cAAc,EAAE,UAAU,EAAE,mBAAmB,EAAE,GAAG,YAAY,CAAC;IAEtF,SAAS,eAAe,CACpB,MAA6B,EAC7B,MAAe,EACf,aAAyC,EAAE;QAE3C,MAAM,gBAAgB,GAAG,uBAAuB,CAAC,MAAM,EAAE,MAAM,EAAE,UAAU,CAAC,CAAC;QAE7E,IAAI,mBAAmB,CAAC,cAAc,CAAC,oBAAoB,CAAC,EAAE,CAAC;YAC3D,mBAAmB,CAAC,IAAI,CAAC,oBAAoB,EAAE;gBAC3C,WAAW,EAAE,MAAM,CAAC,IAAI;gBACxB,OAAO,EAAE,oBAAoB,CAAC,0BAA0B,CAAC,MAAM,EAAE,MAAM,EAAE,UAAU,CAAC,CAAC;aACxF,CAAC,CAAC;QACP,CAAC;QAED,OAAO,gBAAgB,CAAC;IAC5B,CAAC;IAED,OAAO;QACH,eAAe;QAEf,KAAK,CAAC,YAAY,CAAC,MAAM,EAAE,UAAU,EAAE,aAAa,GAAG,EAAE;YACrD,MAAM,QAAQ,GAAG,eAAe,CAAC,MAAM,EAAE,SAAS,EAAE,UAAU,CAAC,CAAC;YAChE,MAAM,cAAc,GAAG,aAAa,CAAC,GAAG,CAAC,UAAU,KAAK;gBACpD,OAAO,wBAAwB,CAAC,SAAS,EAAE,KAAK,CAAC,CAAC;YACtD,CAAC,CAAC,CAAC;YACH,MAAM,OAAO,GAAG,MAAM,cAAc,CAAC,KAAK,CAAC,QAAQ,EAAE,cAAc,CAAC,CAAC;YACrE,OAAO,EAAE,OAAO,EAAE,CAAC;QACvB,CAAC;QAED,KAAK,CAAC,QAAQ,CAAC,MAAM,EAAE,UAAU,EAAE,aAAa,GAAG,EAAE;YACjD,MAAM,QAAQ,GAAG,eAAe,CAAC,MAAM,EAAE,SAAS,EAAE,UAAU,CAAC,CAAC;YAChE,MAAM,OAAO,GAAG,MAAM,UAAU,CAAC,KAAK,CAAC,QAAQ,EAAE,aAAa,CAAC,CAAC;YAChE,OAAO,EAAE,OAAO,EAAE,CAAC;QACvB,CAAC;QAED,KAAK,CAAC,WAAW,CAAC,MAAM,EAAE,YAAY,EAAE,UAAU,EAAE,aAAa,GAAG,EAAE;YAClE,MAAM,QAAQ,GAAG,eAAe,CAAC,MAAM,EAAE,SAAS,EAAE,UAAU,CAAC,CAAC;YAChE,MAAM,sBAAsB,CAAC,WAAW,EAAE,YAAY,EAAE,QAAQ,EAAE,aAAa,CAAC,CAAC;QACrF,CAAC;KACJ,CAAC;AACN,CAAC"}
|
|
@@ -1,3 +1,60 @@
|
|
|
1
|
-
import 'node:path';
|
|
2
|
-
import "../published-package/published-package.js";
|
|
1
|
+
import path from 'node:path';
|
|
2
|
+
import { explicitBinTargetPaths } from "../published-package/published-package.js";
|
|
3
|
+
function applyPrefix(filePath, prefix) {
|
|
4
|
+
return prefix === undefined ? filePath : path.join(prefix, filePath);
|
|
5
|
+
}
|
|
6
|
+
export function collectArtifactContents(bundle, prefix, extraFiles) {
|
|
7
|
+
const binTargets = explicitBinTargetPaths(bundle);
|
|
8
|
+
const artifactContents = [
|
|
9
|
+
{
|
|
10
|
+
...bundle.manifestFile,
|
|
11
|
+
filePath: applyPrefix(bundle.manifestFile.filePath, prefix)
|
|
12
|
+
}
|
|
13
|
+
];
|
|
14
|
+
for (const entry of bundle.contents) {
|
|
15
|
+
if (!entry.isGeneratedManifest) {
|
|
16
|
+
artifactContents.push({
|
|
17
|
+
filePath: applyPrefix(entry.fileDescription.targetFilePath, prefix),
|
|
18
|
+
content: entry.fileDescription.content,
|
|
19
|
+
isExecutable: entry.fileDescription.isExecutable || binTargets.has(entry.fileDescription.targetFilePath)
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
for (const extraFile of extraFiles) {
|
|
24
|
+
artifactContents.push({
|
|
25
|
+
filePath: applyPrefix(extraFile.filePath, prefix),
|
|
26
|
+
content: extraFile.content,
|
|
27
|
+
isExecutable: extraFile.isExecutable
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
return artifactContents;
|
|
31
|
+
}
|
|
32
|
+
export function describeArtifactsForReport(bundle, prefix, extraFiles) {
|
|
33
|
+
return [
|
|
34
|
+
{
|
|
35
|
+
...bundle.manifestFile,
|
|
36
|
+
filePath: applyPrefix(bundle.manifestFile.filePath, prefix)
|
|
37
|
+
},
|
|
38
|
+
...bundle.contents.flatMap(function (entry) {
|
|
39
|
+
if (entry.isGeneratedManifest) {
|
|
40
|
+
return [];
|
|
41
|
+
}
|
|
42
|
+
return [
|
|
43
|
+
{
|
|
44
|
+
filePath: applyPrefix(entry.fileDescription.targetFilePath, prefix),
|
|
45
|
+
content: entry.fileDescription.content,
|
|
46
|
+
isExecutable: entry.fileDescription.isExecutable,
|
|
47
|
+
inputFilePath: entry.fileDescription.inputFilePath,
|
|
48
|
+
isSubstituted: entry.isSubstituted
|
|
49
|
+
}
|
|
50
|
+
];
|
|
51
|
+
}),
|
|
52
|
+
...extraFiles.map(function (entry) {
|
|
53
|
+
return {
|
|
54
|
+
...entry,
|
|
55
|
+
filePath: applyPrefix(entry.filePath, prefix)
|
|
56
|
+
};
|
|
57
|
+
})
|
|
58
|
+
];
|
|
59
|
+
}
|
|
3
60
|
//# sourceMappingURL=content-collection.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"content-collection.js","sourceRoot":"","sources":["../../../../source/artifacts/content-collection.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"content-collection.js","sourceRoot":"","sources":["../../../../source/artifacts/content-collection.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,WAAW,CAAC;AAE7B,OAAO,EAAE,sBAAsB,EAA8B,MAAM,2CAA2C,CAAC;AAE/G,SAAS,WAAW,CAAC,QAAgB,EAAE,MAA0B;IAC7D,OAAO,MAAM,KAAK,SAAS,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC;AACzE,CAAC;AAUD,MAAM,UAAU,uBAAuB,CACnC,MAA6B,EAC7B,MAA0B,EAC1B,UAAsC;IAEtC,MAAM,UAAU,GAAG,sBAAsB,CAAC,MAAM,CAAC,CAAC;IAClD,MAAM,gBAAgB,GAAsB;QACxC;YACI,GAAG,MAAM,CAAC,YAAY;YACtB,QAAQ,EAAE,WAAW,CAAC,MAAM,CAAC,YAAY,CAAC,QAAQ,EAAE,MAAM,CAAC;SAC9D;KACJ,CAAC;IAEF,KAAK,MAAM,KAAK,IAAI,MAAM,CAAC,QAAQ,EAAE,CAAC;QAClC,IAAI,CAAC,KAAK,CAAC,mBAAmB,EAAE,CAAC;YAC7B,gBAAgB,CAAC,IAAI,CAAC;gBAClB,QAAQ,EAAE,WAAW,CAAC,KAAK,CAAC,eAAe,CAAC,cAAc,EAAE,MAAM,CAAC;gBACnE,OAAO,EAAE,KAAK,CAAC,eAAe,CAAC,OAAO;gBACtC,YAAY,EAAE,KAAK,CAAC,eAAe,CAAC,YAAY,IAAI,UAAU,CAAC,GAAG,CAAC,KAAK,CAAC,eAAe,CAAC,cAA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
|
-
import 'node:path';
|
|
2
|
-
import "../vendor-materializer/vendor-entry.js";
|
|
1
|
+
import path from 'node:path';
|
|
2
|
+
import { validateVendorEntrySource } from "../vendor-materializer/vendor-entry.js";
|
|
3
|
+
async function writeFileDescriptions(fileManager, targetFolder, contents) {
|
|
4
|
+
for (const entry of contents) {
|
|
5
|
+
const targetFilePath = path.join(targetFolder, entry.filePath);
|
|
6
|
+
await fileManager.writeFile(targetFilePath, entry.content);
|
|
7
|
+
await fileManager.setExecutable(targetFilePath, entry.isExecutable);
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
async function copyVendorEntries(fileManager, targetFolder, vendorEntries) {
|
|
11
|
+
for (const vendorEntry of vendorEntries) {
|
|
12
|
+
const targetFilePath = path.join(targetFolder, vendorEntry.targetRelativePath);
|
|
13
|
+
await validateVendorEntrySource(fileManager, vendorEntry);
|
|
14
|
+
await fileManager.copyFileBytes(vendorEntry.sourceAbsolutePath, targetFilePath);
|
|
15
|
+
await fileManager.setExecutable(targetFilePath, vendorEntry.isExecutable);
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
export async function writeArtifactsToFolder(fileManager, targetFolder, contents, vendorEntries = []) {
|
|
19
|
+
const readability = await fileManager.checkReadability(targetFolder);
|
|
20
|
+
if (readability.isReadable) {
|
|
21
|
+
throw new Error(`Folder ${targetFolder} already exists`);
|
|
22
|
+
}
|
|
23
|
+
await writeFileDescriptions(fileManager, targetFolder, contents);
|
|
24
|
+
await copyVendorEntries(fileManager, targetFolder, vendorEntries);
|
|
25
|
+
}
|
|
3
26
|
//# sourceMappingURL=folder-writer.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"folder-writer.js","sourceRoot":"","sources":["../../../../source/artifacts/folder-writer.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"folder-writer.js","sourceRoot":"","sources":["../../../../source/artifacts/folder-writer.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM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AAE,YAAY,EAAE,QAAQ,CAAC,CAAC;IACjE,MAAM,iBAAiB,CAAC,WAAW,EAAE,YAAY,EAAE,aAAa,CAAC,CAAC;AACtE,CAAC"}
|
|
@@ -1,7 +1,138 @@
|
|
|
1
|
-
import 'semver';
|
|
2
|
-
import 'true-myth';
|
|
3
|
-
import "../file-manager/compare.js";
|
|
4
|
-
import "./fetch-published-artifacts.js";
|
|
5
|
-
import "./release-artifact-canonicalizer.js";
|
|
6
|
-
import "./repository-coherence.js";
|
|
1
|
+
import semver from 'semver';
|
|
2
|
+
import { Maybe } from 'true-myth';
|
|
3
|
+
import { compareFileDescriptions, fileDescriptionComparisonStatus } from "../file-manager/compare.js";
|
|
4
|
+
import { fetchPublishedArtifacts, fetchPublishedArtifactsFromMetadata } from "./fetch-published-artifacts.js";
|
|
5
|
+
import { canonicalizeReleaseArtifactFiles } from "./release-artifact-canonicalizer.js";
|
|
6
|
+
import { assertRepositoryCoherence } from "./repository-coherence.js";
|
|
7
|
+
const stageRegistryUnsupportedMessage = 'npm staged publishing is only supported with the npmjs.org registry';
|
|
8
|
+
const stageFirstPublishUnsupportedMessage = 'npm staged publishing requires the package to already exist on the npm registry';
|
|
9
|
+
const npmRegistryUrl = 'https://registry.npmjs.org/';
|
|
10
|
+
function isNpmRegistry(registryUrl) {
|
|
11
|
+
const resolvedRegistryUrl = new URL(registryUrl ?? npmRegistryUrl);
|
|
12
|
+
return resolvedRegistryUrl.href === npmRegistryUrl;
|
|
13
|
+
}
|
|
14
|
+
function validateVersion(version) {
|
|
15
|
+
const normalized = semver.valid(version);
|
|
16
|
+
if (normalized === null) {
|
|
17
|
+
throw new Error(`Registry returned an invalid version "${version}" for staged publishing`);
|
|
18
|
+
}
|
|
19
|
+
return normalized;
|
|
20
|
+
}
|
|
21
|
+
function highestVersion(firstVersion, laterVersions) {
|
|
22
|
+
let highest = validateVersion(firstVersion);
|
|
23
|
+
for (const version of laterVersions) {
|
|
24
|
+
const candidate = validateVersion(version);
|
|
25
|
+
if (semver.gt(candidate, highest)) {
|
|
26
|
+
highest = candidate;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
return highest;
|
|
30
|
+
}
|
|
31
|
+
function hasVersionProvider(versioning) {
|
|
32
|
+
return Object.hasOwn(versioning, 'provideVersion');
|
|
33
|
+
}
|
|
34
|
+
function isCurrentHeadPackageVersion(versionDetails, currentGitHead) {
|
|
35
|
+
return versionDetails.gitHead === currentGitHead;
|
|
36
|
+
}
|
|
37
|
+
function collectPackageArtifacts(artifactsBuilder, bundle, extraFiles) {
|
|
38
|
+
return canonicalizeReleaseArtifactFiles(artifactsBuilder.collectContents(bundle, 'package', extraFiles));
|
|
39
|
+
}
|
|
40
|
+
function artifactsMatch(currentArtifacts, publishedArtifacts) {
|
|
41
|
+
const comparison = compareFileDescriptions(currentArtifacts, canonicalizeReleaseArtifactFiles(publishedArtifacts));
|
|
42
|
+
return comparison.status === fileDescriptionComparisonStatus.equal;
|
|
43
|
+
}
|
|
44
|
+
function packageTargetDescription(bundle) {
|
|
45
|
+
return `Package "${bundle.name}" version "${bundle.packageJson.version}"`;
|
|
46
|
+
}
|
|
47
|
+
function assertTargetArtifactsMatch(bundle, currentArtifacts, publishedArtifacts) {
|
|
48
|
+
if (!artifactsMatch(currentArtifacts, publishedArtifacts)) {
|
|
49
|
+
throw new Error(`${packageTargetDescription(bundle)} already exists with different artifacts`);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
function assertTargetIsTaggedLatest(bundle, latestVersion) {
|
|
53
|
+
if (latestVersion !== bundle.packageJson.version) {
|
|
54
|
+
throw new Error(`${packageTargetDescription(bundle)} already exists but is not tagged latest`);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
export function createBundleEmitter(dependencies) {
|
|
58
|
+
const { artifactsBuilder, registryClient, ciRepositoryUrl, readCurrentGitHead } = dependencies;
|
|
59
|
+
async function determineCurrentVersionForStageMode(name, registrySettings, versioning) {
|
|
60
|
+
if (!isNpmRegistry(registrySettings.registryUrl)) {
|
|
61
|
+
throw new Error(stageRegistryUnsupportedMessage);
|
|
62
|
+
}
|
|
63
|
+
const latestVersion = await registryClient.fetchLatestVersion(name, registrySettings);
|
|
64
|
+
if (latestVersion.isNothing) {
|
|
65
|
+
throw new Error(stageFirstPublishUnsupportedMessage);
|
|
66
|
+
}
|
|
67
|
+
if (!versioning.automatic && !hasVersionProvider(versioning)) {
|
|
68
|
+
return Maybe.just(versioning.version);
|
|
69
|
+
}
|
|
70
|
+
const stagedVersions = await registryClient.fetchStagedVersions(name, registrySettings);
|
|
71
|
+
return Maybe.just(highestVersion(latestVersion.value.version, stagedVersions));
|
|
72
|
+
}
|
|
73
|
+
return {
|
|
74
|
+
async determineCurrentVersion(options) {
|
|
75
|
+
const { versioning, registrySettings, name, stage } = options;
|
|
76
|
+
if (stage) {
|
|
77
|
+
return determineCurrentVersionForStageMode(name, registrySettings, versioning);
|
|
78
|
+
}
|
|
79
|
+
if (versioning.automatic || hasVersionProvider(versioning)) {
|
|
80
|
+
const latestVersion = await registryClient.fetchLatestVersion(name, registrySettings);
|
|
81
|
+
return latestVersion.map(function (version) {
|
|
82
|
+
return version.version;
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
return Maybe.just(versioning.version);
|
|
86
|
+
},
|
|
87
|
+
async findCurrentHeadPublishedVersion(options) {
|
|
88
|
+
const currentGitHead = await readCurrentGitHead();
|
|
89
|
+
if (currentGitHead === undefined) {
|
|
90
|
+
return undefined;
|
|
91
|
+
}
|
|
92
|
+
const latestVersion = await registryClient.fetchLatestVersion(options.name, options.registrySettings);
|
|
93
|
+
if (latestVersion.isNothing || !isCurrentHeadPackageVersion(latestVersion.value, currentGitHead)) {
|
|
94
|
+
return undefined;
|
|
95
|
+
}
|
|
96
|
+
return {
|
|
97
|
+
version: latestVersion.value.version,
|
|
98
|
+
gitHead: latestVersion.value.gitHead
|
|
99
|
+
};
|
|
100
|
+
},
|
|
101
|
+
async checkBundleAlreadyPublished(options) {
|
|
102
|
+
const { bundle, registrySettings, extraFiles } = options;
|
|
103
|
+
const previous = await fetchPublishedArtifacts(registryClient, bundle.name, registrySettings);
|
|
104
|
+
if (previous.isNothing) {
|
|
105
|
+
return { alreadyPublishedAsLatest: false, previousReleaseArtifacts: Maybe.nothing() };
|
|
106
|
+
}
|
|
107
|
+
const currentArtifacts = collectPackageArtifacts(artifactsBuilder, bundle, extraFiles);
|
|
108
|
+
return {
|
|
109
|
+
alreadyPublishedAsLatest: artifactsMatch(currentArtifacts, previous.value.files),
|
|
110
|
+
previousReleaseArtifacts: previous
|
|
111
|
+
};
|
|
112
|
+
},
|
|
113
|
+
async verifyBundlePublishTarget(options) {
|
|
114
|
+
const { bundle, registrySettings, extraFiles } = options;
|
|
115
|
+
const metadata = await registryClient.fetchVersionReleaseMetadata(bundle.name, bundle.packageJson.version, registrySettings);
|
|
116
|
+
if (metadata.isNothing) {
|
|
117
|
+
return { alreadyPublished: false, publishedArtifacts: Maybe.nothing() };
|
|
118
|
+
}
|
|
119
|
+
const publishedArtifacts = await fetchPublishedArtifactsFromMetadata(registryClient, registrySettings, metadata.value);
|
|
120
|
+
const currentArtifacts = collectPackageArtifacts(artifactsBuilder, bundle, extraFiles);
|
|
121
|
+
assertTargetArtifactsMatch(bundle, currentArtifacts, publishedArtifacts.files);
|
|
122
|
+
assertTargetIsTaggedLatest(bundle, metadata.value.latestVersion);
|
|
123
|
+
return { alreadyPublished: true, publishedArtifacts: Maybe.just(publishedArtifacts) };
|
|
124
|
+
},
|
|
125
|
+
async publish(options) {
|
|
126
|
+
if (options.publishSettings.access === 'public' && options.publishSettings.provenance?.type === 'auto') {
|
|
127
|
+
assertRepositoryCoherence(options.bundle.packageJson, ciRepositoryUrl);
|
|
128
|
+
}
|
|
129
|
+
const tarball = await artifactsBuilder.buildTarball(options.bundle, options.extraFiles);
|
|
130
|
+
const currentGitHead = await readCurrentGitHead();
|
|
131
|
+
const publishManifest = currentGitHead === undefined
|
|
132
|
+
? options.bundle.packageJson
|
|
133
|
+
: { ...options.bundle.packageJson, gitHead: currentGitHead };
|
|
134
|
+
return registryClient.publishPackage(publishManifest, tarball.tarData, options.registrySettings, options.publishSettings, options.stage);
|
|
135
|
+
}
|
|
136
|
+
};
|
|
137
|
+
}
|
|
7
138
|
//# sourceMappingURL=emitter.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"emitter.js","sourceRoot":"","sources":["../../../../source/bundle-emitter/emitter.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"emitter.js","sourceRoot":"","sources":["../../../../source/bundle-emitter/emitter.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,QAAQ,CAAC;AAC5B,OAAO,EAAE,KAAK,EAAE,MAAM,WAAW,CAAC;AAElC,OAAO,EAAE,uBAAuB,EAAE,+BAA+B,EAAE,MAAM,4BAA4B,CAAC;AAGtG,OAAO,EAAE,uBAAuB,EAAE,mCAAmC,EAAE,MAAM,gCAAgC,CAAC;AAC9G,OAAO,EAAE,gCAAgC,EAAE,MAAM,qCAAqC,CAAC;AAEvF,OAAO,EAAE,yBAAyB,EAAE,MAAM,2BAA2B,CAAC;AA0FtE,MAAM,+BAA+B,GAAG,qEAAqE,CAAC;AAC9G,MAAM,mCAAmC,GACrC,iFAAiF,CAAC;AACtF,MAAM,cAAc,GAAG,6BAA6B,CAAC;AAErD,SAAS,aAAa,CAAC,WAA+B;IAClD,MAAM,mBAAmB,GAAG,IAAI,GAAG,CAAC,WAAW,IAAI,cAAc,CAAC,CAAC;IACnE,OAAO,mBAAmB,CAAC,IAAI,KAAK,cAAc,CAAC;AACvD,CAAC;AAED,SAAS,eAAe,CAAC,OAAe;IACpC,MAAM,UAAU,GAAG,MAAM,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;IACzC,IAAI,UAAU,KAAK,IAAI,EAAE,CAAC;QACtB,MAAM,IAAI,KAAK,CAAC,yCAAyC,OAAO,yBAAyB,CAAC,CAAC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BAAkB,CAAC,KAAK,CAAC,CAAC;YAC/E,0BAA0B,CAAC,MAAM,EAAE,QAAQ,CAAC,KAAK,CAAC,aAAa,CAAC,CAAC;YAEjE,OAAO,EAAE,gBAAgB,EAAE,IAAI,EAAE,kBAAkB,EAAE,KAAK,CAAC,IAAI,CAAC,kBAAkB,CAAC,EAAE,CAAC;QAC1F,CAAC;QAED,KAAK,CAAC,OAAO,CAAC,OAAO;YACjB,IAAI,OAAO,CAAC,eAAe,CAAC,MAAM,KAAK,QAAQ,IAAI,OAAO,CAAC,eAAe,CAAC,UAAU,EAAE,IAAI,KAAK,MAAM,EAAE,CAAC;gBACrG,yBAAyB,CAAC,OAAO,CAAC,MAAM,CAAC,WAAW,EAAE,eAAe,CAAC,CAAC;YAC3E,CAAC;YAED,MAAM,OAAO,GAAG,MAAM,gBAAgB,CAAC,YAAY,CAAC,OAAO,CAAC,MAAM,EAAE,OAAO,CAAC,UAAU,CAAC,CAAC;YACxF,MAAM,cAAc,GAAG,MAAM,kBAAkB,EAAE,CAAC;YAClD,MAAM,eAAe,GAAG,cAAc,KAAK,SAAS;gBAChD,CAAC,CAAC,OAAO,CAAC,MAAM,CAAC,WAAW;gBAC5B,CAAC,CAAC,EAAE,GAAG,OAAO,CAAC,MAAM,CAAC,WAAW,EAAE,OAAO,EAAE,cAAc,EAAE,CAAC;YAEjE,OAAO,cAAc,CAAC,cAAc,CAChC,eAAe,EACf,OAAO,CAAC,OAAO,EACf,OAAO,CAAC,gBAAgB,EACxB,OAAO,CAAC,eAAe,EACvB,OAAO,CAAC,KAAK,CAChB,CAAC;QACN,CAAC;KACJ,CAAC;AACN,CAAC"}
|
|
@@ -1,3 +1,14 @@
|
|
|
1
|
-
import "../file-manager/permissions.js";
|
|
2
|
-
import "../tar/extract-tar.js";
|
|
1
|
+
import { isExecutableFileMode } from "../file-manager/permissions.js";
|
|
2
|
+
import { extractTarEntries } from "../tar/extract-tar.js";
|
|
3
|
+
function tarEntryToFileDescription(tarEntry) {
|
|
4
|
+
return {
|
|
5
|
+
filePath: tarEntry.header.name,
|
|
6
|
+
content: tarEntry.content,
|
|
7
|
+
isExecutable: isExecutableFileMode(Number(tarEntry.header.mode))
|
|
8
|
+
};
|
|
9
|
+
}
|
|
10
|
+
export async function extractPackageTarball(tarball) {
|
|
11
|
+
const tarEntries = await extractTarEntries(tarball);
|
|
12
|
+
return tarEntries.map(tarEntryToFileDescription);
|
|
13
|
+
}
|
|
3
14
|
//# sourceMappingURL=extract-package-tarball.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"extract-package-tarball.js","sourceRoot":"","sources":["../../../../source/bundle-emitter/extract-package-tarball.ts"],"names":[],"mappings":"AACA,
|
|
1
|
+
{"version":3,"file":"extract-package-tarball.js","sourceRoot":"","sources":["../../../../source/bundle-emitter/extract-package-tarball.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,oBAAoB,EAAE,MAAM,gCAAgC,CAAC;AACtE,OAAO,EAAE,iBAAiB,EAAiB,MAAM,uBAAuB,CAAC;AAEzE,SAAS,yBAAyB,CAAC,QAAkB;IACjD,OAAO;QACH,QAAQ,EAAE,QAAQ,CAAC,MAAM,CAAC,IAAI;QAC9B,OAAO,EAAE,QAAQ,CAAC,OAAO;QACzB,YAAY,EAAE,oBAAoB,CAAC,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;KACnE,CAAC;AACN,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,qBAAqB,CAAC,OAAe;IACvD,MAAM,UAAU,GAAG,MAAM,iBAAiB,CAAC,OAAO,CAAC,CAAC;IACpD,OAAO,UAAU,CAAC,GAAG,CAAC,yBAAyB,CAAC,CAAC;AACrD,CAAC"}
|
|
@@ -1,3 +1,20 @@
|
|
|
1
|
-
import 'true-myth';
|
|
2
|
-
import "./extract-package-tarball.js";
|
|
1
|
+
import { Maybe } from 'true-myth';
|
|
2
|
+
import { extractPackageTarball } from "./extract-package-tarball.js";
|
|
3
|
+
export async function fetchPublishedArtifactsFromMetadata(registryClient, registrySettings, metadata) {
|
|
4
|
+
const tarball = await registryClient.fetchTarball(metadata.tarballUrl, metadata.tarballIntegrity, registrySettings);
|
|
5
|
+
const files = await extractPackageTarball(tarball);
|
|
6
|
+
return {
|
|
7
|
+
version: metadata.version,
|
|
8
|
+
files,
|
|
9
|
+
publishedAt: metadata.publishedAt,
|
|
10
|
+
gitHead: metadata.gitHead
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
export async function fetchPublishedArtifacts(registryClient, name, registrySettings) {
|
|
14
|
+
const latestVersion = await registryClient.fetchLatestReleaseMetadata(name, registrySettings);
|
|
15
|
+
if (latestVersion.isNothing) {
|
|
16
|
+
return Maybe.nothing();
|
|
17
|
+
}
|
|
18
|
+
return Maybe.just(await fetchPublishedArtifactsFromMetadata(registryClient, registrySettings, latestVersion.value));
|
|
19
|
+
}
|
|
3
20
|
//# sourceMappingURL=fetch-published-artifacts.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fetch-published-artifacts.js","sourceRoot":"","sources":["../../../../source/bundle-emitter/fetch-published-artifacts.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"fetch-published-artifacts.js","sourceRoot":"","sources":["../../../../source/bundle-emitter/fetch-published-artifacts.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,WAAW,CAAC;AAGlC,OAAO,EAAE,qBAAqB,EAAE,MAAM,8BAA8B,CAAC;AAWrE,MAAM,CAAC,KAAK,UAAU,mCAAmC,CACrD,cAA8B,EAC9B,gBAAkC,EAClC,QAAgC;IAEhC,MAAM,OAAO,GAAG,MAAM,cAAc,CAAC,YAAY,CAC7C,QAAQ,CAAC,UAAU,EACnB,QAAQ,CAAC,gBAAgB,EACzB,gBAAgB,CACnB,CAAC;IACF,MAAM,KAAK,GAAG,MAAM,qBAAqB,CAAC,OAAO,CAAC,CAAC;IACnD,OAAO;QACH,OAAO,EAAE,QAAQ,CAAC,OAAO;QACzB,KAAK;QACL,WAAW,EAAE,QAAQ,CAAC,WAAW;QACjC,OAAO,EAAE,QAAQ,CAAC,OAAO;KAC5B,CAAC;AACN,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,uBAAuB,CACzC,cAA8B,EAC9B,IAAY,EACZ,gBAAkC;IAElC,MAAM,aAAa,GAAG,MAAM,cAAc,CAAC,0BAA0B,CAAC,IAAI,EAAE,gBAAgB,CAAC,CAAC;IAC9F,IAAI,aAAa,CAAC,SAAS,EAAE,CAAC;QAC1B,OAAO,KAAK,CAAC,OAAO,EAAE,CAAC;IAC3B,CAAC;IACD,OAAO,KAAK,CAAC,IAAI,CAAC,MAAM,mCAAmC,CAAC,cAAc,EAAE,gBAAgB,EAAE,aAAa,CAAC,KAAK,CAAC,CAAC,CAAC;AACxH,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"publication-outcome.js","sourceRoot":"","sources":["../../../../source/bundle-emitter/publication-outcome.ts"],"names":[],"mappings":""}
|
|
1
|
+
{"version":3,"file":"publication-outcome.js","sourceRoot":"","sources":["../../../../source/bundle-emitter/publication-outcome.ts"],"names":[],"mappings":"AAMA,MAAM,CAAC,MAAM,aAAa,GAAuB,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;AAClE,MAAM,CAAC,MAAM,mBAAmB,GAAuB,EAAE,IAAI,EAAE,WAAW,EAAE,CAAC;AAE7E,MAAM,UAAU,iBAAiB,CAAC,OAAe;IAC7C,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,OAAO,EAAE,CAAC;AACvC,CAAC"}
|
|
@@ -1,3 +1,29 @@
|
|
|
1
|
-
import "./error-shape-helpers.js";
|
|
2
|
-
import "./publish-error-messages.js";
|
|
1
|
+
import { isErrorLike } from "./error-shape-helpers.js";
|
|
2
|
+
import { buildUnsupportedProviderMessage, githubActionsIdTokenMessage, gitlabSigstoreIdTokenMessage, unsupportedProviderMarker } from "./publish-error-messages.js";
|
|
3
|
+
function getCiName(message) {
|
|
4
|
+
const providerSection = message
|
|
5
|
+
.slice(message.indexOf(unsupportedProviderMarker) + unsupportedProviderMarker.length)
|
|
6
|
+
.trimStart();
|
|
7
|
+
if (providerSection === '') {
|
|
8
|
+
return 'unknown';
|
|
9
|
+
}
|
|
10
|
+
const providerEnd = providerSection.search(/\s/u);
|
|
11
|
+
return providerEnd === -1 ? providerSection : providerSection.slice(0, providerEnd);
|
|
12
|
+
}
|
|
13
|
+
export function matchAutoModeError(error) {
|
|
14
|
+
if (!isErrorLike(error)) {
|
|
15
|
+
return undefined;
|
|
16
|
+
}
|
|
17
|
+
const { message } = error;
|
|
18
|
+
if (message.includes(unsupportedProviderMarker)) {
|
|
19
|
+
return new Error(buildUnsupportedProviderMessage(getCiName(message)), { cause: error });
|
|
20
|
+
}
|
|
21
|
+
if (message.includes('"write" access to the "id-token" permission')) {
|
|
22
|
+
return new Error(githubActionsIdTokenMessage, { cause: error });
|
|
23
|
+
}
|
|
24
|
+
if (message.includes('SIGSTORE_ID_TOKEN')) {
|
|
25
|
+
return new Error(gitlabSigstoreIdTokenMessage, { cause: error });
|
|
26
|
+
}
|
|
27
|
+
return undefined;
|
|
28
|
+
}
|
|
3
29
|
//# sourceMappingURL=auto-mode-error-matching.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auto-mode-error-matching.js","sourceRoot":"","sources":["../../../../../source/bundle-emitter/publish-error/auto-mode-error-matching.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"auto-mode-error-matching.js","sourceRoot":"","sources":["../../../../../source/bundle-emitter/publish-error/auto-mode-error-matching.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AACvD,OAAO,EACH,+BAA+B,EAC/B,2BAA2B,EAC3B,4BAA4B,EAC5B,yBAAyB,EAC5B,MAAM,6BAA6B,CAAC;AAErC,SAAS,SAAS,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|
|
2
|
+
return value instanceof Object;
|
|
3
|
+
}
|
|
4
|
+
export function isErrorLike(error) {
|
|
5
|
+
return isRecord(error) && typeof error.message === 'string';
|
|
6
|
+
}
|
|
7
|
+
export function ensureError(error) {
|
|
8
|
+
return error instanceof Error ? error : new Error(String(error));
|
|
9
|
+
}
|
|
1
10
|
//# sourceMappingURL=error-shape-helpers.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"error-shape-helpers.js","sourceRoot":"","sources":["../../../../../source/bundle-emitter/publish-error/error-shape-helpers.ts"],"names":[],"mappings":""}
|
|
1
|
+
{"version":3,"file":"error-shape-helpers.js","sourceRoot":"","sources":["../../../../../source/bundle-emitter/publish-error/error-shape-helpers.ts"],"names":[],"mappings":"AAEA,MAAM,UAAU,QAAQ,CAAC,KAAc;IACnC,OAAO,KAAK,YAAY,MAAM,CAAC;AACnC,CAAC;AAED,MAAM,UAAU,WAAW,CAAC,KAAc;IACtC,OAAO,QAAQ,CAAC,KAAK,CAAC,IAAI,OAAO,KAAK,CAAC,OAAO,KAAK,QAAQ,CAAC;AAChE,CAAC;AAED,MAAM,UAAU,WAAW,CAAC,KAAc;IACtC,OAAO,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC;AACrE,CAAC"}
|
|
@@ -1,3 +1,34 @@
|
|
|
1
|
-
import "./error-shape-helpers.js";
|
|
2
|
-
import "./publish-error-messages.js";
|
|
1
|
+
import { isErrorLike, isRecord } from "./error-shape-helpers.js";
|
|
2
|
+
import { buildInvalidProvenanceFileMessage, buildMissingProvenanceFileMessage, buildProvenanceDigestMismatchMessage } from "./publish-error-messages.js";
|
|
3
|
+
const provenanceBundleMarkers = [
|
|
4
|
+
'Bundle is invalid',
|
|
5
|
+
'Unsupported bundle format',
|
|
6
|
+
'Invalid bundle',
|
|
7
|
+
'subject does not match'
|
|
8
|
+
];
|
|
9
|
+
const provenanceDigestMismatchMarkers = ['subject', 'digest'];
|
|
10
|
+
function includesOneOf(message, markers) {
|
|
11
|
+
for (const marker of markers) {
|
|
12
|
+
if (message.includes(marker)) {
|
|
13
|
+
return true;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
return false;
|
|
17
|
+
}
|
|
18
|
+
export function matchFileModeError(error, filePath) {
|
|
19
|
+
if (isRecord(error) && error.code === 'ENOENT') {
|
|
20
|
+
return new Error(buildMissingProvenanceFileMessage(filePath), { cause: error });
|
|
21
|
+
}
|
|
22
|
+
if (!isErrorLike(error)) {
|
|
23
|
+
return undefined;
|
|
24
|
+
}
|
|
25
|
+
const { message } = error;
|
|
26
|
+
if (!includesOneOf(message, provenanceBundleMarkers)) {
|
|
27
|
+
return undefined;
|
|
28
|
+
}
|
|
29
|
+
if (includesOneOf(message, provenanceDigestMismatchMarkers)) {
|
|
30
|
+
return new Error(buildProvenanceDigestMismatchMessage(filePath), { cause: error });
|
|
31
|
+
}
|
|
32
|
+
return new Error(buildInvalidProvenanceFileMessage(filePath), { cause: error });
|
|
33
|
+
}
|
|
3
34
|
//# sourceMappingURL=file-mode-error-matching.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"file-mode-error-matching.js","sourceRoot":"","sources":["../../../../../source/bundle-emitter/publish-error/file-mode-error-matching.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"file-mode-error-matching.js","sourceRoot":"","sources":["../../../../../source/bundle-emitter/publish-error/file-mode-error-matching.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAAC;AACjE,OAAO,EACH,iCAAiC,EACjC,iCAAiC,EACjC,oCAAoC,EACvC,MAAM,6BAA6B,CAAC;AAErC,MAAM,uBAAuB,GAAG;IAC5B,mBAAmB;IACnB,2BAA2B;IAC3B,gBAAgB;IAChB,wBAAwB;CAClB,CAAC;AACX,MAAM,+BAA+B,GAAG,CAAE,SAAS,EAAE,QAAQ,CAAW,CAAC;AAEzE,SAAS,aAAa,CAAC,OAAe,EAAE,OAA0B;IAC9D,KAAK,MAAM,MAAM,IAAI,OAAO,EAAE,CAAC;QAC3B,IAAI,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAC,EAAE,CAAC;YAC3B,OAAO,IAAI,CAAC;QAChB,CAAC;IACL,CAAC;IAED,OAAO,KAAK,CAAC;AACjB,CAAC;AAED,MAAM,UAAU,kBAAkB,CAAC,KAAc,EAAE,QAAgB;IAC/D,IAAI,QAAQ,CAAC,KAAK,CAAC,IAAI,KAAK,CAAC,IAAI,KAAK,QAAQ,EAAE,CAAC;QAC7C,OAAO,IAAI,KAAK,CAAC,iCAAiC,CAAC,QAAQ,CAAC,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC,CAAC;IACpF,CAAC;IACD,IAAI,CAAC,WAAW,CAAC,KAAK,CAAC,EAAE,CAAC;QACtB,OAAO,SAAS,CAAC;IACrB,CAAC;IAED,MAAM,EAAE,OAAO,EAAE,GAAG,KAAK,CAAC;IAC1B,IAAI,CAAC,aAAa,CAAC,OAAO,EAAE,uBAAuB,CAAC,EAAE,CAAC;QACnD,OAAO,SAAS,CAAC;IACrB,CAAC;IACD,IAAI,aAAa,CAAC,OAAO,EAAE,+BAA+B,CAAC,EAAE,CAAC;QAC1D,OAAO,IAAI,KAAK,CAAC,oCAAoC,CAAC,QAAQ,CAAC,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC,CAAC;IACvF,CAAC;IACD,OAAO,IAAI,KAAK,CAAC,iCAAiC,CAAC,QAAQ,CAAC,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC,CAAC;AACpF,CAAC"}
|
|
@@ -1 +1,25 @@
|
|
|
1
|
+
export const unsupportedProviderMarker = 'not supported for provider:';
|
|
2
|
+
export const githubActionsIdTokenMessage = 'GitHub Actions provenance needs "permissions: id-token: write" on the workflow job. ' +
|
|
3
|
+
'See the packtory readme for the workflow snippet.';
|
|
4
|
+
export const gitlabSigstoreIdTokenMessage = 'GitLab CI provenance needs an "id_tokens" entry with audience "sigstore" ' +
|
|
5
|
+
'exposed as SIGSTORE_ID_TOKEN. See the packtory readme for the workflow snippet.';
|
|
6
|
+
export function buildUnsupportedProviderMessage(ciName) {
|
|
7
|
+
return ('Provenance auto mode requires GitHub Actions or GitLab CI. ' +
|
|
8
|
+
`Detected CI: ${ciName}. ` +
|
|
9
|
+
"Use provenance: { type: 'file' } for other environments.");
|
|
10
|
+
}
|
|
11
|
+
export function buildMissingProvenanceFileMessage(filePath) {
|
|
12
|
+
return (`Provenance bundle file "${filePath}" does not exist. ` +
|
|
13
|
+
"Generate it with your CI's attestation tool (e.g. actions/attest-build-provenance) " +
|
|
14
|
+
'before running packtory.');
|
|
15
|
+
}
|
|
16
|
+
export function buildInvalidProvenanceFileMessage(filePath) {
|
|
17
|
+
return (`Provenance bundle file "${filePath}" is not a valid sigstore bundle. ` +
|
|
18
|
+
'Re-generate it from the current build.');
|
|
19
|
+
}
|
|
20
|
+
export function buildProvenanceDigestMismatchMessage(filePath) {
|
|
21
|
+
return (`Provenance bundle at "${filePath}" was signed against a different tarball ` +
|
|
22
|
+
'than the one packtory built. Re-generate the bundle from the current source: ' +
|
|
23
|
+
'shipping a mismatched attestation would defeat the purpose of provenance.');
|
|
24
|
+
}
|
|
1
25
|
//# sourceMappingURL=publish-error-messages.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"publish-error-messages.js","sourceRoot":"","sources":["../../../../../source/bundle-emitter/publish-error/publish-error-messages.ts"],"names":[],"mappings":""}
|
|
1
|
+
{"version":3,"file":"publish-error-messages.js","sourceRoot":"","sources":["../../../../../source/bundle-emitter/publish-error/publish-error-messages.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,yBAAyB,GAAG,6BAA6B,CAAC;AAEvE,MAAM,CAAC,MAAM,2BAA2B,GACpC,sFAAsF;IACtF,mDAAmD,CAAC;AAExD,MAAM,CAAC,MAAM,4BAA4B,GACrC,2EAA2E;IAC3E,iFAAiF,CAAC;AAEtF,MAAM,UAAU,+BAA+B,CAAC,MAAc;IAC1D,OAAO,CACH,6DAA6D;QAC7D,gBAAgB,MAAM,IAAI;QAC1B,0DAA0D,CAC7D,CAAC;AACN,CAAC;AAED,MAAM,UAAU,iCAAiC,CAAC,QAAgB;IAC9D,OAAO,CACH,2BAA2B,QAAQ,oBAAoB;QACvD,qFAAqF;QACrF,0BAA0B,CAC7B,CAAC;AACN,CAAC;AAED,MAAM,UAAU,iCAAiC,CAAC,QAAgB;IAC9D,OAAO,CACH,2BAA2B,QAAQ,oCAAoC;QACvE,wCAAwC,CAC3C,CAAC;AACN,CAAC;AAED,MAAM,UAAU,oCAAoC,CAAC,QAAgB;IACjE,OAAO,CACH,yBAAyB,QAAQ,2CAA2C;QAC5E,+EAA+E;QAC/E,2EAA2E,CAC9E,CAAC;AACN,CAAC"}
|
|
@@ -1,2 +1,25 @@
|
|
|
1
|
-
import "./registry-auth-config.js";
|
|
1
|
+
import { buildAuthOptions, resolvePublishAuth } from "./registry-auth-config.js";
|
|
2
|
+
const unauthorizedStatusCode = 401;
|
|
3
|
+
const forbiddenStatusCode = 403;
|
|
4
|
+
function isAuthFailure(error) {
|
|
5
|
+
const statusCode = error instanceof Object && Object.hasOwn(error, 'statusCode')
|
|
6
|
+
? error.statusCode
|
|
7
|
+
: undefined;
|
|
8
|
+
return statusCode === forbiddenStatusCode || statusCode === unauthorizedStatusCode;
|
|
9
|
+
}
|
|
10
|
+
export async function retryWithFallbackAuth(registrySettings, auth, run) {
|
|
11
|
+
try {
|
|
12
|
+
return await run(auth.options);
|
|
13
|
+
}
|
|
14
|
+
catch (error) {
|
|
15
|
+
if (!auth.allowsAutomaticRetry || !isAuthFailure(error)) {
|
|
16
|
+
throw error;
|
|
17
|
+
}
|
|
18
|
+
const publishAuth = resolvePublishAuth(registrySettings);
|
|
19
|
+
if (publishAuth.type === 'npm-oidc') {
|
|
20
|
+
throw error;
|
|
21
|
+
}
|
|
22
|
+
return run(buildAuthOptions(publishAuth, registrySettings).options);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
2
25
|
//# sourceMappingURL=metadata-auth-retry.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"metadata-auth-retry.js","sourceRoot":"","sources":["../../../../../source/bundle-emitter/registry/metadata-auth-retry.ts"],"names":[],"mappings":"AACA,
|
|
1
|
+
{"version":3,"file":"metadata-auth-retry.js","sourceRoot":"","sources":["../../../../../source/bundle-emitter/registry/metadata-auth-retry.ts"],"names":[],"mappings":"AACA,OAAO,EACH,gBAAgB,EAChB,kBAAkB,EAGrB,MAAM,2BAA2B,CAAC;AAEnC,MAAM,sBAAsB,GAAG,GAAG,CAAC;AACnC,MAAM,mBAAmB,GAAG,GAAG,CAAC;AAEhC,SAAS,aAAa,CAAC,KAAc;IACjC,MAAM,UAAU,GAAG,KAAK,YAAY,MAAM,IAAI,MAAM,CAAC,MAAM,CAAC,KAAK,EAAE,YAAY,CAAC;QAC5E,CAAC,CAAE,KAA4C,CAAC,UAAU;QAC1D,CAAC,CAAC,SAAS,CAAC;IAChB,OAAO,UAAU,KAAK,mBAAmB,IAAI,UAAU,KAAK,sBAAsB,CAAC;AACvF,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,qBAAqB,CACvC,gBAA4C,EAC5C,IAAoB,EACpB,GAA6C;IAE7C,IAAI,CAAC;QACD,OAAO,MAAM,GAAG,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IACnC,CAAC;IAAC,OAAO,KAAc,EAAE,CAAC;QACtB,IAAI,CAAC,IAAI,CAAC,oBAAoB,IAAI,CAAC,aAAa,CAAC,KAAK,CAAC,EAAE,CAAC;YACtD,MAAM,KAAK,CAAC;QAChB,CAAC;QAED,MAAM,WAAW,GAAG,kBAAkB,CAAC,gBAAgB,CAAC,CAAC;QACzD,IAAI,WAAW,CAAC,IAAI,KAAK,UAAU,EAAE,CAAC;YAClC,MAAM,KAAK,CAAC;QAChB,CAAC;QAED,OAAO,GAAG,CAAC,gBAAgB,CAAC,WAAW,EAAE,gBAAgB,CAAC,CAAC,OAAO,CAAC,CAAC;IACxE,CAAC;AACL,CAAC"}
|
|
@@ -1,4 +1,69 @@
|
|
|
1
|
-
import "./registry-auth-config.js";
|
|
2
|
-
import "./registry-package-path.js";
|
|
3
|
-
import "./registry-response-schemas.js";
|
|
1
|
+
import { buildAuthOptions, createBaseOptions, isNpmRegistry, npmRegistryUrl, resolvePublishAuth, resolveRegistryUrl } from "./registry-auth-config.js";
|
|
2
|
+
import { toRegistryPackagePath } from "./registry-package-path.js";
|
|
3
|
+
import { parseOidcExchangeResponse } from "./registry-response-schemas.js";
|
|
4
|
+
const oidcExchangeRefreshThresholdInMilliseconds = 60_000;
|
|
5
|
+
export function createOidcTokenExchanger(dependencies) {
|
|
6
|
+
const { fetch: fetchImplementation, clock, resolveIdToken } = dependencies;
|
|
7
|
+
const cache = new Map();
|
|
8
|
+
function getCacheKey(packageName, registrySettings) {
|
|
9
|
+
return `${resolveRegistryUrl(registrySettings) ?? npmRegistryUrl}::${packageName}`;
|
|
10
|
+
}
|
|
11
|
+
function readCachedToken(cacheKey) {
|
|
12
|
+
const cachedToken = cache.get(cacheKey);
|
|
13
|
+
if (cachedToken === undefined) {
|
|
14
|
+
return undefined;
|
|
15
|
+
}
|
|
16
|
+
const currentTime = clock.getCurrentTimeInMilliseconds();
|
|
17
|
+
if (cachedToken.expiresAt - currentTime > oidcExchangeRefreshThresholdInMilliseconds) {
|
|
18
|
+
return cachedToken.token;
|
|
19
|
+
}
|
|
20
|
+
return undefined;
|
|
21
|
+
}
|
|
22
|
+
function parseExchangedToken(body) {
|
|
23
|
+
const parsed = parseOidcExchangeResponse(body);
|
|
24
|
+
if (!parsed.success) {
|
|
25
|
+
throw new TypeError(`OIDC token exchange returned an invalid response: ${parsed.issues.join('; ')}`);
|
|
26
|
+
}
|
|
27
|
+
return { token: parsed.data.token, expiresAt: parsed.data.expires.getTime() };
|
|
28
|
+
}
|
|
29
|
+
async function requestExchange(packageName, auth) {
|
|
30
|
+
const idToken = await resolveIdToken(auth);
|
|
31
|
+
const requestInit = {
|
|
32
|
+
method: 'POST',
|
|
33
|
+
headers: { Authorization: `Bearer ${idToken}` }
|
|
34
|
+
};
|
|
35
|
+
const exchangeResponse = await fetchImplementation(`${npmRegistryUrl}-/npm/v1/oidc/token/exchange/package/${toRegistryPackagePath(packageName)}`, requestInit);
|
|
36
|
+
if (!exchangeResponse.ok) {
|
|
37
|
+
throw new Error(`OIDC token exchange failed with status ${exchangeResponse.status}`);
|
|
38
|
+
}
|
|
39
|
+
return parseExchangedToken((await exchangeResponse.json()));
|
|
40
|
+
}
|
|
41
|
+
async function exchangeToken(packageName, registrySettings, auth) {
|
|
42
|
+
const cacheKey = getCacheKey(packageName, registrySettings);
|
|
43
|
+
const cached = readCachedToken(cacheKey);
|
|
44
|
+
if (cached !== undefined) {
|
|
45
|
+
return cached;
|
|
46
|
+
}
|
|
47
|
+
if (!isNpmRegistry(resolveRegistryUrl(registrySettings))) {
|
|
48
|
+
throw new Error('npm-oidc auth is only supported with the npmjs.org registry');
|
|
49
|
+
}
|
|
50
|
+
const exchanged = await requestExchange(packageName, auth);
|
|
51
|
+
cache.set(cacheKey, exchanged);
|
|
52
|
+
return exchanged.token;
|
|
53
|
+
}
|
|
54
|
+
return {
|
|
55
|
+
exchangeToken,
|
|
56
|
+
async resolveWriteAuthOptions(packageName, registrySettings) {
|
|
57
|
+
const auth = resolvePublishAuth(registrySettings);
|
|
58
|
+
if (auth.type !== 'npm-oidc') {
|
|
59
|
+
return buildAuthOptions(auth, registrySettings).options;
|
|
60
|
+
}
|
|
61
|
+
const token = await exchangeToken(packageName, registrySettings, auth);
|
|
62
|
+
return {
|
|
63
|
+
...createBaseOptions(registrySettings),
|
|
64
|
+
forceAuth: { token }
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
};
|
|
68
|
+
}
|
|
4
69
|
//# sourceMappingURL=oidc-token-exchange.js.map
|