@angular/cli 22.2.2 → 22.3.0-next.1
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/bin/ng.js +7 -10
- package/bin/version.js +98 -0
- package/index.d.ts +19 -0
- package/lib/chunk-5AASRQKS.js +85 -0
- package/lib/chunk-A2VIYA2E.js +165 -0
- package/lib/chunk-CAZUOCTC.js +225 -0
- package/lib/chunk-DHWVZMLH.js +206 -0
- package/lib/chunk-FZ5GFCWU.js +483 -0
- package/lib/chunk-G7TRU43D.js +42 -0
- package/lib/chunk-GHUUJYOY.js +40 -0
- package/lib/chunk-JBLF2TH3.js +267 -0
- package/lib/chunk-Q67GOPL7.js +380 -0
- package/lib/chunk-SN4KY4Z3.js +24 -0
- package/lib/chunk-XFL2J3CJ.js +24 -0
- package/lib/chunk-XG3HVNIL.js +59 -0
- package/lib/chunk-YM7ILCS5.js +2573 -0
- package/lib/cli/index.js +353 -105
- package/lib/cli-4CMZ6KMR.js +48 -0
- package/lib/cli-4Q7DGTBA.js +33 -0
- package/lib/cli-6AHY7ADW.js +96 -0
- package/lib/cli-A5UAJDO6.js +135 -0
- package/lib/cli-ACLGUIBI.js +2531 -0
- package/lib/cli-BQRFWIMG.js +35 -0
- package/lib/cli-CWICUPZW.js +42 -0
- package/lib/cli-DWQUM3M2.js +29 -0
- package/lib/cli-L4TM4JH3.js +88 -0
- package/lib/cli-LYBZEMDR.js +96 -0
- package/lib/cli-PDCEX7HQ.js +605 -0
- package/lib/cli-PJVTDBQM.js +51 -0
- package/lib/cli-PRIRL3WP.js +185 -0
- package/lib/cli-PU5VH7JB.js +189 -0
- package/lib/cli-QUH44NUB.js +68 -0
- package/lib/cli-VVITNTBC.js +50 -0
- package/lib/cli-XM4L4PP4.js +1651 -0
- package/lib/cli-Y2ECUR33.js +33 -0
- package/lib/cli-YDSMJOSO.js +182 -0
- package/lib/color-SJPGXZVA.js +8 -0
- package/lib/config/schema.json +204 -0
- package/lib/config-QXK7SSVG.js +22 -0
- package/lib/init.js +91 -180
- package/package.json +20 -15
- package/lib/cli/index.d.ts +0 -11
- package/lib/cli/index.js.map +0 -1
- package/lib/config/workspace-schema.d.ts +0 -1025
- package/lib/config/workspace-schema.js +0 -131
- package/lib/config/workspace-schema.js.map +0 -1
- package/lib/init.d.ts +0 -8
- package/lib/init.js.map +0 -1
- package/src/analytics/analytics-collector.d.ts +0 -35
- package/src/analytics/analytics-collector.js +0 -195
- package/src/analytics/analytics-collector.js.map +0 -1
- package/src/analytics/analytics-parameters.d.ts +0 -101
- package/src/analytics/analytics-parameters.js +0 -107
- package/src/analytics/analytics-parameters.js.map +0 -1
- package/src/analytics/analytics.d.ts +0 -27
- package/src/analytics/analytics.js +0 -183
- package/src/analytics/analytics.js.map +0 -1
- package/src/command-builder/architect-base-command-module.d.ts +0 -30
- package/src/command-builder/architect-base-command-module.js +0 -244
- package/src/command-builder/architect-base-command-module.js.map +0 -1
- package/src/command-builder/architect-command-module.d.ts +0 -28
- package/src/command-builder/architect-command-module.js +0 -218
- package/src/command-builder/architect-command-module.js.map +0 -1
- package/src/command-builder/command-module.d.ts +0 -73
- package/src/command-builder/command-module.js +0 -260
- package/src/command-builder/command-module.js.map +0 -1
- package/src/command-builder/command-runner.d.ts +0 -9
- package/src/command-builder/command-runner.js +0 -202
- package/src/command-builder/command-runner.js.map +0 -1
- package/src/command-builder/definitions.d.ts +0 -41
- package/src/command-builder/definitions.js +0 -20
- package/src/command-builder/definitions.js.map +0 -1
- package/src/command-builder/schematics-command-module.d.ts +0 -41
- package/src/command-builder/schematics-command-module.js +0 -408
- package/src/command-builder/schematics-command-module.js.map +0 -1
- package/src/command-builder/utilities/command.d.ts +0 -13
- package/src/command-builder/utilities/command.js +0 -39
- package/src/command-builder/utilities/command.js.map +0 -1
- package/src/command-builder/utilities/json-help.d.ts +0 -37
- package/src/command-builder/utilities/json-help.js +0 -92
- package/src/command-builder/utilities/json-help.js.map +0 -1
- package/src/command-builder/utilities/json-schema.d.ts +0 -64
- package/src/command-builder/utilities/json-schema.js +0 -349
- package/src/command-builder/utilities/json-schema.js.map +0 -1
- package/src/command-builder/utilities/normalize-options-middleware.d.ts +0 -18
- package/src/command-builder/utilities/normalize-options-middleware.js +0 -37
- package/src/command-builder/utilities/normalize-options-middleware.js.map +0 -1
- package/src/command-builder/utilities/schematic-engine-host.d.ts +0 -15
- package/src/command-builder/utilities/schematic-engine-host.js +0 -179
- package/src/command-builder/utilities/schematic-engine-host.js.map +0 -1
- package/src/command-builder/utilities/schematic-workflow.d.ts +0 -14
- package/src/command-builder/utilities/schematic-workflow.js +0 -70
- package/src/command-builder/utilities/schematic-workflow.js.map +0 -1
- package/src/commands/add/cli.d.ts +0 -41
- package/src/commands/add/cli.js +0 -705
- package/src/commands/add/cli.js.map +0 -1
- package/src/commands/add/long-description.md +0 -7
- package/src/commands/analytics/cli.d.ts +0 -16
- package/src/commands/analytics/cli.js +0 -34
- package/src/commands/analytics/cli.js.map +0 -1
- package/src/commands/analytics/info/cli.d.ts +0 -16
- package/src/commands/analytics/info/cli.js +0 -25
- package/src/commands/analytics/info/cli.js.map +0 -1
- package/src/commands/analytics/long-description.md +0 -20
- package/src/commands/analytics/settings/cli.d.ts +0 -35
- package/src/commands/analytics/settings/cli.js +0 -54
- package/src/commands/analytics/settings/cli.js.map +0 -1
- package/src/commands/build/cli.d.ts +0 -16
- package/src/commands/build/cli.js +0 -21
- package/src/commands/build/cli.js.map +0 -1
- package/src/commands/build/long-description.md +0 -18
- package/src/commands/cache/clean/cli.d.ts +0 -17
- package/src/commands/cache/clean/cli.js +0 -32
- package/src/commands/cache/clean/cli.js.map +0 -1
- package/src/commands/cache/cli.d.ts +0 -17
- package/src/commands/cache/cli.js +0 -36
- package/src/commands/cache/cli.js.map +0 -1
- package/src/commands/cache/info/cli.d.ts +0 -20
- package/src/commands/cache/info/cli.js +0 -139
- package/src/commands/cache/info/cli.js.map +0 -1
- package/src/commands/cache/long-description.md +0 -53
- package/src/commands/cache/settings/cli.d.ts +0 -27
- package/src/commands/cache/settings/cli.js +0 -41
- package/src/commands/cache/settings/cli.js.map +0 -1
- package/src/commands/cache/utilities.d.ts +0 -11
- package/src/commands/cache/utilities.js +0 -90
- package/src/commands/cache/utilities.js.map +0 -1
- package/src/commands/command-config.d.ts +0 -17
- package/src/commands/command-config.js +0 -116
- package/src/commands/command-config.js.map +0 -1
- package/src/commands/completion/cli.d.ts +0 -16
- package/src/commands/completion/cli.js +0 -61
- package/src/commands/completion/cli.js.map +0 -1
- package/src/commands/completion/long-description.md +0 -67
- package/src/commands/config/cli.d.ts +0 -24
- package/src/commands/config/cli.js +0 -150
- package/src/commands/config/cli.js.map +0 -1
- package/src/commands/config/long-description.md +0 -13
- package/src/commands/deploy/cli.d.ts +0 -17
- package/src/commands/deploy/cli.js +0 -38
- package/src/commands/deploy/cli.js.map +0 -1
- package/src/commands/deploy/long-description.md +0 -22
- package/src/commands/e2e/cli.d.ts +0 -18
- package/src/commands/e2e/cli.js +0 -42
- package/src/commands/e2e/cli.js.map +0 -1
- package/src/commands/extract-i18n/cli.d.ts +0 -17
- package/src/commands/extract-i18n/cli.js +0 -48
- package/src/commands/extract-i18n/cli.js.map +0 -1
- package/src/commands/generate/cli.d.ts +0 -47
- package/src/commands/generate/cli.js +0 -189
- package/src/commands/generate/cli.js.map +0 -1
- package/src/commands/lint/cli.d.ts +0 -17
- package/src/commands/lint/cli.js +0 -25
- package/src/commands/lint/cli.js.map +0 -1
- package/src/commands/lint/long-description.md +0 -20
- package/src/commands/make-this-awesome/cli.d.ts +0 -17
- package/src/commands/make-this-awesome/cli.js +0 -36
- package/src/commands/make-this-awesome/cli.js.map +0 -1
- package/src/commands/mcp/cli.d.ts +0 -21
- package/src/commands/mcp/cli.js +0 -74
- package/src/commands/mcp/cli.js.map +0 -1
- package/src/commands/mcp/constants.d.ts +0 -10
- package/src/commands/mcp/constants.js +0 -16
- package/src/commands/mcp/constants.js.map +0 -1
- package/src/commands/mcp/devserver.d.ts +0 -85
- package/src/commands/mcp/devserver.js +0 -109
- package/src/commands/mcp/devserver.js.map +0 -1
- package/src/commands/mcp/host.d.ts +0 -103
- package/src/commands/mcp/host.js +0 -270
- package/src/commands/mcp/host.js.map +0 -1
- package/src/commands/mcp/mcp-server.d.ts +0 -38
- package/src/commands/mcp/mcp-server.js +0 -176
- package/src/commands/mcp/mcp-server.js.map +0 -1
- package/src/commands/mcp/resources/ai-tutor.md +0 -822
- package/src/commands/mcp/resources/best-practices.md +0 -59
- package/src/commands/mcp/resources/instructions.d.ts +0 -9
- package/src/commands/mcp/resources/instructions.js +0 -26
- package/src/commands/mcp/resources/instructions.js.map +0 -1
- package/src/commands/mcp/shared-options.d.ts +0 -12
- package/src/commands/mcp/shared-options.js +0 -22
- package/src/commands/mcp/shared-options.js.map +0 -1
- package/src/commands/mcp/tools/ai-tutor.d.ts +0 -12
- package/src/commands/mcp/tools/ai-tutor.js +0 -59
- package/src/commands/mcp/tools/ai-tutor.js.map +0 -1
- package/src/commands/mcp/tools/best-practices.d.ts +0 -13
- package/src/commands/mcp/tools/best-practices.js +0 -196
- package/src/commands/mcp/tools/best-practices.js.map +0 -1
- package/src/commands/mcp/tools/devserver/devserver-start.d.ts +0 -32
- package/src/commands/mcp/tools/devserver/devserver-start.js +0 -110
- package/src/commands/mcp/tools/devserver/devserver-start.js.map +0 -1
- package/src/commands/mcp/tools/devserver/devserver-stop.d.ts +0 -31
- package/src/commands/mcp/tools/devserver/devserver-stop.js +0 -69
- package/src/commands/mcp/tools/devserver/devserver-stop.js.map +0 -1
- package/src/commands/mcp/tools/devserver/devserver-wait-for-build.d.ts +0 -41
- package/src/commands/mcp/tools/devserver/devserver-wait-for-build.js +0 -105
- package/src/commands/mcp/tools/devserver/devserver-wait-for-build.js.map +0 -1
- package/src/commands/mcp/tools/doc-search.d.ts +0 -21
- package/src/commands/mcp/tools/doc-search.js +0 -307
- package/src/commands/mcp/tools/doc-search.js.map +0 -1
- package/src/commands/mcp/tools/onpush-zoneless-migration/analyze-for-unsupported-zone-uses.d.ts +0 -17
- package/src/commands/mcp/tools/onpush-zoneless-migration/analyze-for-unsupported-zone-uses.js +0 -62
- package/src/commands/mcp/tools/onpush-zoneless-migration/analyze-for-unsupported-zone-uses.js.map +0 -1
- package/src/commands/mcp/tools/onpush-zoneless-migration/migrate-single-file.d.ts +0 -12
- package/src/commands/mcp/tools/onpush-zoneless-migration/migrate-single-file.js +0 -70
- package/src/commands/mcp/tools/onpush-zoneless-migration/migrate-single-file.js.map +0 -1
- package/src/commands/mcp/tools/onpush-zoneless-migration/migrate-test-file.d.ts +0 -12
- package/src/commands/mcp/tools/onpush-zoneless-migration/migrate-test-file.js +0 -60
- package/src/commands/mcp/tools/onpush-zoneless-migration/migrate-test-file.js.map +0 -1
- package/src/commands/mcp/tools/onpush-zoneless-migration/prompts.d.ts +0 -15
- package/src/commands/mcp/tools/onpush-zoneless-migration/prompts.js +0 -238
- package/src/commands/mcp/tools/onpush-zoneless-migration/prompts.js.map +0 -1
- package/src/commands/mcp/tools/onpush-zoneless-migration/send-debug-message.d.ts +0 -9
- package/src/commands/mcp/tools/onpush-zoneless-migration/send-debug-message.js +0 -14
- package/src/commands/mcp/tools/onpush-zoneless-migration/send-debug-message.js.map +0 -1
- package/src/commands/mcp/tools/onpush-zoneless-migration/ts-utils.d.ts +0 -36
- package/src/commands/mcp/tools/onpush-zoneless-migration/ts-utils.js +0 -135
- package/src/commands/mcp/tools/onpush-zoneless-migration/ts-utils.js.map +0 -1
- package/src/commands/mcp/tools/onpush-zoneless-migration/types.d.ts +0 -13
- package/src/commands/mcp/tools/onpush-zoneless-migration/types.js +0 -10
- package/src/commands/mcp/tools/onpush-zoneless-migration/types.js.map +0 -1
- package/src/commands/mcp/tools/onpush-zoneless-migration/zoneless-migration.d.ts +0 -16
- package/src/commands/mcp/tools/onpush-zoneless-migration/zoneless-migration.js +0 -215
- package/src/commands/mcp/tools/onpush-zoneless-migration/zoneless-migration.js.map +0 -1
- package/src/commands/mcp/tools/projects.d.ts +0 -48
- package/src/commands/mcp/tools/projects.js +0 -541
- package/src/commands/mcp/tools/projects.js.map +0 -1
- package/src/commands/mcp/tools/run-target/build-target-strategy.d.ts +0 -14
- package/src/commands/mcp/tools/run-target/build-target-strategy.js +0 -53
- package/src/commands/mcp/tools/run-target/build-target-strategy.js.map +0 -1
- package/src/commands/mcp/tools/run-target/generic-target-strategy.d.ts +0 -14
- package/src/commands/mcp/tools/run-target/generic-target-strategy.js +0 -63
- package/src/commands/mcp/tools/run-target/generic-target-strategy.js.map +0 -1
- package/src/commands/mcp/tools/run-target/options-serializer.d.ts +0 -13
- package/src/commands/mcp/tools/run-target/options-serializer.js +0 -41
- package/src/commands/mcp/tools/run-target/options-serializer.js.map +0 -1
- package/src/commands/mcp/tools/run-target/run-target.d.ts +0 -34
- package/src/commands/mcp/tools/run-target/run-target.js +0 -69
- package/src/commands/mcp/tools/run-target/run-target.js.map +0 -1
- package/src/commands/mcp/tools/run-target/strategy.d.ts +0 -15
- package/src/commands/mcp/tools/run-target/strategy.js +0 -10
- package/src/commands/mcp/tools/run-target/strategy.js.map +0 -1
- package/src/commands/mcp/tools/run-target/types.d.ts +0 -39
- package/src/commands/mcp/tools/run-target/types.js +0 -41
- package/src/commands/mcp/tools/run-target/types.js.map +0 -1
- package/src/commands/mcp/tools/run-target/unit-test-strategy.d.ts +0 -14
- package/src/commands/mcp/tools/run-target/unit-test-strategy.js +0 -56
- package/src/commands/mcp/tools/run-target/unit-test-strategy.js.map +0 -1
- package/src/commands/mcp/tools/tool-registry.d.ts +0 -40
- package/src/commands/mcp/tools/tool-registry.js +0 -40
- package/src/commands/mcp/tools/tool-registry.js.map +0 -1
- package/src/commands/mcp/utils.d.ts +0 -25
- package/src/commands/mcp/utils.js +0 -44
- package/src/commands/mcp/utils.js.map +0 -1
- package/src/commands/mcp/workspace-utils.d.ts +0 -55
- package/src/commands/mcp/workspace-utils.js +0 -181
- package/src/commands/mcp/workspace-utils.js.map +0 -1
- package/src/commands/new/cli.d.ts +0 -27
- package/src/commands/new/cli.js +0 -76
- package/src/commands/new/cli.js.map +0 -1
- package/src/commands/new/long-description.md +0 -15
- package/src/commands/run/cli.d.ts +0 -25
- package/src/commands/run/cli.js +0 -89
- package/src/commands/run/cli.js.map +0 -1
- package/src/commands/run/long-description.md +0 -10
- package/src/commands/serve/cli.d.ts +0 -16
- package/src/commands/serve/cli.js +0 -20
- package/src/commands/serve/cli.js.map +0 -1
- package/src/commands/test/cli.d.ts +0 -16
- package/src/commands/test/cli.js +0 -21
- package/src/commands/test/cli.js.map +0 -1
- package/src/commands/test/long-description.md +0 -2
- package/src/commands/update/cli.d.ts +0 -50
- package/src/commands/update/cli.js +0 -586
- package/src/commands/update/cli.js.map +0 -1
- package/src/commands/update/long-description.md +0 -22
- package/src/commands/update/update-resolver.d.ts +0 -75
- package/src/commands/update/update-resolver.js +0 -918
- package/src/commands/update/update-resolver.js.map +0 -1
- package/src/commands/update/utilities/cli-version.d.ts +0 -48
- package/src/commands/update/utilities/cli-version.js +0 -196
- package/src/commands/update/utilities/cli-version.js.map +0 -1
- package/src/commands/update/utilities/constants.d.ts +0 -12
- package/src/commands/update/utilities/constants.js +0 -16
- package/src/commands/update/utilities/constants.js.map +0 -1
- package/src/commands/update/utilities/git.d.ts +0 -36
- package/src/commands/update/utilities/git.js +0 -148
- package/src/commands/update/utilities/git.js.map +0 -1
- package/src/commands/update/utilities/migration.d.ts +0 -32
- package/src/commands/update/utilities/migration.js +0 -271
- package/src/commands/update/utilities/migration.js.map +0 -1
- package/src/commands/version/cli.d.ts +0 -36
- package/src/commands/version/cli.js +0 -117
- package/src/commands/version/cli.js.map +0 -1
- package/src/commands/version/version-info.d.ts +0 -46
- package/src/commands/version/version-info.js +0 -101
- package/src/commands/version/version-info.js.map +0 -1
- package/src/package-managers/discovery.d.ts +0 -23
- package/src/package-managers/discovery.js +0 -104
- package/src/package-managers/discovery.js.map +0 -1
- package/src/package-managers/error.d.ts +0 -43
- package/src/package-managers/error.js +0 -41
- package/src/package-managers/error.js.map +0 -1
- package/src/package-managers/factory.d.ts +0 -30
- package/src/package-managers/factory.js +0 -137
- package/src/package-managers/factory.js.map +0 -1
- package/src/package-managers/host.d.ts +0 -86
- package/src/package-managers/host.js +0 -91
- package/src/package-managers/host.js.map +0 -1
- package/src/package-managers/index.d.ts +0 -13
- package/src/package-managers/index.js +0 -17
- package/src/package-managers/index.js.map +0 -1
- package/src/package-managers/logger.d.ts +0 -27
- package/src/package-managers/logger.js +0 -10
- package/src/package-managers/logger.js.map +0 -1
- package/src/package-managers/package-manager-descriptor.d.ts +0 -269
- package/src/package-managers/package-manager-descriptor.js +0 -210
- package/src/package-managers/package-manager-descriptor.js.map +0 -1
- package/src/package-managers/package-manager.d.ts +0 -200
- package/src/package-managers/package-manager.js +0 -720
- package/src/package-managers/package-manager.js.map +0 -1
- package/src/package-managers/package-metadata.d.ts +0 -91
- package/src/package-managers/package-metadata.js +0 -10
- package/src/package-managers/package-metadata.js.map +0 -1
- package/src/package-managers/package-tree.d.ts +0 -23
- package/src/package-managers/package-tree.js +0 -10
- package/src/package-managers/package-tree.js.map +0 -1
- package/src/package-managers/parsers.d.ts +0 -167
- package/src/package-managers/parsers.js +0 -674
- package/src/package-managers/parsers.js.map +0 -1
- package/src/utilities/color.d.ts +0 -23
- package/src/utilities/color.js +0 -41
- package/src/utilities/color.js.map +0 -1
- package/src/utilities/completion.d.ts +0 -30
- package/src/utilities/completion.js +0 -270
- package/src/utilities/completion.js.map +0 -1
- package/src/utilities/config.d.ts +0 -38
- package/src/utilities/config.js +0 -368
- package/src/utilities/config.js.map +0 -1
- package/src/utilities/environment-options.d.ts +0 -25
- package/src/utilities/environment-options.js +0 -60
- package/src/utilities/environment-options.js.map +0 -1
- package/src/utilities/eol.d.ts +0 -20
- package/src/utilities/eol.js +0 -35
- package/src/utilities/eol.js.map +0 -1
- package/src/utilities/error.d.ts +0 -18
- package/src/utilities/error.js +0 -41
- package/src/utilities/error.js.map +0 -1
- package/src/utilities/find-up.d.ts +0 -21
- package/src/utilities/find-up.js +0 -67
- package/src/utilities/find-up.js.map +0 -1
- package/src/utilities/json-file.d.ts +0 -24
- package/src/utilities/json-file.js +0 -179
- package/src/utilities/json-file.js.map +0 -1
- package/src/utilities/log-file.d.ts +0 -13
- package/src/utilities/log-file.js +0 -28
- package/src/utilities/log-file.js.map +0 -1
- package/src/utilities/memoize.d.ts +0 -15
- package/src/utilities/memoize.js +0 -64
- package/src/utilities/memoize.js.map +0 -1
- package/src/utilities/node-version.d.ts +0 -21
- package/src/utilities/node-version.js +0 -65
- package/src/utilities/node-version.js.map +0 -1
- package/src/utilities/prettier.d.ts +0 -19
- package/src/utilities/prettier.js +0 -105
- package/src/utilities/prettier.js.map +0 -1
- package/src/utilities/project.d.ts +0 -8
- package/src/utilities/project.js +0 -81
- package/src/utilities/project.js.map +0 -1
- package/src/utilities/prompt.d.ts +0 -17
- package/src/utilities/prompt.js +0 -90
- package/src/utilities/prompt.js.map +0 -1
- package/src/utilities/tty.d.ts +0 -16
- package/src/utilities/tty.js +0 -23
- package/src/utilities/tty.js.map +0 -1
- package/src/utilities/version.d.ts +0 -16
- package/src/utilities/version.js +0 -26
- package/src/utilities/version.js.map +0 -1
|
@@ -1,720 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* @license
|
|
4
|
-
* Copyright Google LLC All Rights Reserved.
|
|
5
|
-
*
|
|
6
|
-
* Use of this source code is governed by an MIT-style license that can be
|
|
7
|
-
* found in the LICENSE file at https://angular.dev/license
|
|
8
|
-
*/
|
|
9
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
10
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
11
|
-
};
|
|
12
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
-
exports.PackageManager = exports.MANIFEST_FIELDS = void 0;
|
|
14
|
-
/**
|
|
15
|
-
* @fileoverview This file contains the `PackageManager` class, which is the
|
|
16
|
-
* core execution engine for all package manager commands. It is designed to be
|
|
17
|
-
* a flexible and secure abstraction over the various package managers.
|
|
18
|
-
*/
|
|
19
|
-
const node_path_1 = require("node:path");
|
|
20
|
-
const npm_package_arg_1 = __importDefault(require("npm-package-arg"));
|
|
21
|
-
const semver_1 = require("semver");
|
|
22
|
-
const error_1 = require("./error");
|
|
23
|
-
/**
|
|
24
|
-
* The fields to request from the registry for package metadata.
|
|
25
|
-
* This is a performance optimization to avoid downloading the full manifest
|
|
26
|
-
* when only summary data (like versions and tags) is needed.
|
|
27
|
-
*/
|
|
28
|
-
const METADATA_FIELDS = ['name', 'dist-tags', 'versions', 'time'];
|
|
29
|
-
/**
|
|
30
|
-
* The fields to request from the registry for a package's manifest.
|
|
31
|
-
* This is a performance optimization to avoid downloading unnecessary data.
|
|
32
|
-
* These fields are the ones required by the CLI for operations like `ng add` and `ng update`.
|
|
33
|
-
*/
|
|
34
|
-
exports.MANIFEST_FIELDS = [
|
|
35
|
-
'name',
|
|
36
|
-
'version',
|
|
37
|
-
'deprecated',
|
|
38
|
-
'dependencies',
|
|
39
|
-
'peerDependencies',
|
|
40
|
-
'devDependencies',
|
|
41
|
-
'homepage',
|
|
42
|
-
'schematics',
|
|
43
|
-
'ng-add',
|
|
44
|
-
'ng-update',
|
|
45
|
-
];
|
|
46
|
-
/**
|
|
47
|
-
* A class that provides a high-level, package-manager-agnostic API for
|
|
48
|
-
* interacting with a project's dependencies.
|
|
49
|
-
*
|
|
50
|
-
* This class is an implementation of the Strategy design pattern. It is
|
|
51
|
-
* instantiated with a `PackageManagerDescriptor` that defines the specific
|
|
52
|
-
* commands and flags for a given package manager.
|
|
53
|
-
*/
|
|
54
|
-
class PackageManager {
|
|
55
|
-
host;
|
|
56
|
-
cwd;
|
|
57
|
-
descriptor;
|
|
58
|
-
options;
|
|
59
|
-
#manifestCache = new Map();
|
|
60
|
-
#metadataCache = new Map();
|
|
61
|
-
#initializationError;
|
|
62
|
-
#dependencyCache = null;
|
|
63
|
-
#version;
|
|
64
|
-
#minimumReleaseAge;
|
|
65
|
-
#activeTasks = 0;
|
|
66
|
-
#pendingTasks = [];
|
|
67
|
-
#maxConcurrent = 5;
|
|
68
|
-
/**
|
|
69
|
-
* Creates a new `PackageManager` instance.
|
|
70
|
-
* @param host A `Host` instance for interacting with the file system and running commands.
|
|
71
|
-
* @param cwd The absolute path to the project's working directory.
|
|
72
|
-
* @param descriptor A `PackageManagerDescriptor` that defines the commands for a specific package manager.
|
|
73
|
-
* @param options An options object to configure the instance.
|
|
74
|
-
*/
|
|
75
|
-
constructor(host, cwd, descriptor, options = {}) {
|
|
76
|
-
this.host = host;
|
|
77
|
-
this.cwd = cwd;
|
|
78
|
-
this.descriptor = descriptor;
|
|
79
|
-
this.options = options;
|
|
80
|
-
if (this.options.dryRun && !this.options.logger) {
|
|
81
|
-
throw new Error('A logger must be provided when dryRun is enabled.');
|
|
82
|
-
}
|
|
83
|
-
this.#version = options.version;
|
|
84
|
-
this.#initializationError = options.initializationError;
|
|
85
|
-
}
|
|
86
|
-
/**
|
|
87
|
-
* The name of the package manager's binary.
|
|
88
|
-
*/
|
|
89
|
-
get name() {
|
|
90
|
-
return this.descriptor.binary;
|
|
91
|
-
}
|
|
92
|
-
/**
|
|
93
|
-
* Ensures that the package manager is installed and available in the PATH.
|
|
94
|
-
* If it is not, this method will throw an error with instructions on how to install it.
|
|
95
|
-
*
|
|
96
|
-
* @throws {Error} If the package manager is not installed.
|
|
97
|
-
*/
|
|
98
|
-
ensureInstalled() {
|
|
99
|
-
if (this.#initializationError) {
|
|
100
|
-
throw this.#initializationError;
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
/**
|
|
104
|
-
* A private method to lazily populate the dependency cache.
|
|
105
|
-
* This is a performance optimization to avoid running `npm list` multiple times.
|
|
106
|
-
* @returns A promise that resolves to the dependency cache map.
|
|
107
|
-
*/
|
|
108
|
-
async #populateDependencyCache() {
|
|
109
|
-
if (this.#dependencyCache !== null) {
|
|
110
|
-
return this.#dependencyCache;
|
|
111
|
-
}
|
|
112
|
-
const args = this.descriptor.listDependenciesCommand;
|
|
113
|
-
const workspacePackageName = await this.getCurrentPackageName();
|
|
114
|
-
const dependencies = await this.#fetchAndParse(args, (stdout, logger) => this.descriptor.outputParsers.listDependencies(stdout, logger, { workspacePackageName }));
|
|
115
|
-
return (this.#dependencyCache = dependencies ?? new Map());
|
|
116
|
-
}
|
|
117
|
-
/**
|
|
118
|
-
* A private method to run a command using the package manager's binary.
|
|
119
|
-
* @param args The arguments to pass to the command.
|
|
120
|
-
* @param options Options for the child process.
|
|
121
|
-
* @returns A promise that resolves with the standard output and standard error of the command.
|
|
122
|
-
*/
|
|
123
|
-
async #runWithThrottle(action) {
|
|
124
|
-
if (this.#activeTasks >= this.#maxConcurrent) {
|
|
125
|
-
await new Promise((resolve) => {
|
|
126
|
-
this.#pendingTasks.push(resolve);
|
|
127
|
-
});
|
|
128
|
-
}
|
|
129
|
-
else {
|
|
130
|
-
this.#activeTasks++;
|
|
131
|
-
}
|
|
132
|
-
try {
|
|
133
|
-
return await action();
|
|
134
|
-
}
|
|
135
|
-
finally {
|
|
136
|
-
const next = this.#pendingTasks.shift();
|
|
137
|
-
if (next) {
|
|
138
|
-
next();
|
|
139
|
-
}
|
|
140
|
-
else {
|
|
141
|
-
this.#activeTasks--;
|
|
142
|
-
}
|
|
143
|
-
}
|
|
144
|
-
}
|
|
145
|
-
async #run(args, options = {}) {
|
|
146
|
-
return this.#runWithThrottle(async () => {
|
|
147
|
-
this.ensureInstalled();
|
|
148
|
-
const { registry, cwd, ...runOptions } = options;
|
|
149
|
-
const finalArgs = [...args];
|
|
150
|
-
let finalEnv;
|
|
151
|
-
if (registry) {
|
|
152
|
-
const registryOptions = this.descriptor.getRegistryOptions?.(registry);
|
|
153
|
-
if (!registryOptions) {
|
|
154
|
-
throw new Error(`The configured package manager, '${this.descriptor.binary}', does not support a custom registry.`);
|
|
155
|
-
}
|
|
156
|
-
if (registryOptions.args) {
|
|
157
|
-
finalArgs.push(...registryOptions.args);
|
|
158
|
-
}
|
|
159
|
-
if (registryOptions.env) {
|
|
160
|
-
finalEnv = registryOptions.env;
|
|
161
|
-
}
|
|
162
|
-
}
|
|
163
|
-
const executionDirectory = cwd ?? this.cwd;
|
|
164
|
-
if (this.options.dryRun) {
|
|
165
|
-
this.options.logger?.info(`[DRY RUN] Would execute in [${executionDirectory}]: ${this.descriptor.binary} ${finalArgs.join(' ')}`);
|
|
166
|
-
return { stdout: '', stderr: '' };
|
|
167
|
-
}
|
|
168
|
-
const commandResult = await this.host.runCommand(this.descriptor.binary, finalArgs, {
|
|
169
|
-
...runOptions,
|
|
170
|
-
cwd: executionDirectory,
|
|
171
|
-
stdio: 'pipe',
|
|
172
|
-
env: finalEnv,
|
|
173
|
-
});
|
|
174
|
-
return { stdout: commandResult.stdout.trim(), stderr: commandResult.stderr.trim() };
|
|
175
|
-
});
|
|
176
|
-
}
|
|
177
|
-
/**
|
|
178
|
-
* A private, generic method to encapsulate the common logic of running a command,
|
|
179
|
-
* handling errors, and parsing the output.
|
|
180
|
-
* @param args The arguments to pass to the command.
|
|
181
|
-
* @param parser A function that parses the command's stdout.
|
|
182
|
-
* @param options Options for the command, including caching.
|
|
183
|
-
* @returns A promise that resolves to the parsed data, or null if not found.
|
|
184
|
-
*/
|
|
185
|
-
async #fetchAndParse(args, parser, options = {}) {
|
|
186
|
-
const { cache, cacheKey, bypassCache, ...runOptions } = options;
|
|
187
|
-
if (!bypassCache && cache && cacheKey && cache.has(cacheKey)) {
|
|
188
|
-
return cache.get(cacheKey);
|
|
189
|
-
}
|
|
190
|
-
let stdout;
|
|
191
|
-
let stderr;
|
|
192
|
-
let exitCode;
|
|
193
|
-
let thrownError;
|
|
194
|
-
try {
|
|
195
|
-
({ stdout, stderr } = await this.#run(args, runOptions));
|
|
196
|
-
exitCode = 0;
|
|
197
|
-
}
|
|
198
|
-
catch (e) {
|
|
199
|
-
thrownError = e;
|
|
200
|
-
if (e instanceof error_1.PackageManagerError) {
|
|
201
|
-
stdout = e.stdout;
|
|
202
|
-
stderr = e.stderr;
|
|
203
|
-
exitCode = e.exitCode;
|
|
204
|
-
}
|
|
205
|
-
else {
|
|
206
|
-
// Re-throw unexpected errors
|
|
207
|
-
throw e;
|
|
208
|
-
}
|
|
209
|
-
}
|
|
210
|
-
// Yarn classic can exit with code 0 even when an error occurs.
|
|
211
|
-
// To ensure we capture these cases, we will always attempt to parse a
|
|
212
|
-
// structured error from the output, regardless of the exit code.
|
|
213
|
-
const getError = this.descriptor.outputParsers.getError;
|
|
214
|
-
const parsedError = getError?.(stdout, this.options.logger) ?? getError?.(stderr, this.options.logger) ?? null;
|
|
215
|
-
if (parsedError) {
|
|
216
|
-
this.options.logger?.debug(`[${this.descriptor.binary}] Structured error (code: ${parsedError.code}): ${parsedError.summary}`);
|
|
217
|
-
// Special case for 'not found' errors (e.g., E404). Return null for these.
|
|
218
|
-
if (this.descriptor.isNotFound(parsedError)) {
|
|
219
|
-
if (cache && cacheKey) {
|
|
220
|
-
cache.set(cacheKey, null);
|
|
221
|
-
}
|
|
222
|
-
return null;
|
|
223
|
-
}
|
|
224
|
-
else {
|
|
225
|
-
// For all other structured errors, throw a more informative error.
|
|
226
|
-
throw new error_1.PackageManagerError(parsedError.summary, stdout, stderr, exitCode);
|
|
227
|
-
}
|
|
228
|
-
}
|
|
229
|
-
// If an error was originally thrown and we didn't parse a more specific
|
|
230
|
-
// structured error, re-throw the original error now.
|
|
231
|
-
if (thrownError) {
|
|
232
|
-
throw thrownError;
|
|
233
|
-
}
|
|
234
|
-
// If we reach this point, the command succeeded and no structured error was found.
|
|
235
|
-
// We can now safely parse the successful output.
|
|
236
|
-
try {
|
|
237
|
-
const result = parser(stdout, this.options.logger);
|
|
238
|
-
if (cache && cacheKey) {
|
|
239
|
-
cache.set(cacheKey, result);
|
|
240
|
-
}
|
|
241
|
-
return result;
|
|
242
|
-
}
|
|
243
|
-
catch (e) {
|
|
244
|
-
const message = `Failed to parse package manager output: ${e instanceof Error ? e.message : ''}`;
|
|
245
|
-
throw new error_1.PackageManagerError(message, stdout, stderr, exitCode);
|
|
246
|
-
}
|
|
247
|
-
}
|
|
248
|
-
/**
|
|
249
|
-
* Adds a package to the project's dependencies.
|
|
250
|
-
* @param packageName The name of the package to add.
|
|
251
|
-
* @param save The save strategy to use.
|
|
252
|
-
* - `exact`: The package will be saved with an exact version.
|
|
253
|
-
* - `tilde`: The package will be saved with a tilde version range (`~`).
|
|
254
|
-
* - `none`: The package will be saved with the default version range (`^`).
|
|
255
|
-
* @param asDevDependency Whether to install the package as a dev dependency.
|
|
256
|
-
* @param noLockfile Whether to skip updating the lockfile.
|
|
257
|
-
* @param options Extra options for the command.
|
|
258
|
-
* @returns A promise that resolves when the command is complete.
|
|
259
|
-
*/
|
|
260
|
-
async add(packageName, save, asDevDependency, noLockfile, ignoreScripts, options = {}) {
|
|
261
|
-
const flags = [
|
|
262
|
-
asDevDependency ? this.descriptor.saveDevFlag : '',
|
|
263
|
-
save === 'exact' ? this.descriptor.saveExactFlag : '',
|
|
264
|
-
save === 'tilde' ? this.descriptor.saveTildeFlag : '',
|
|
265
|
-
noLockfile ? this.descriptor.noLockfileFlag : '',
|
|
266
|
-
ignoreScripts ? this.descriptor.ignoreScriptsFlag : '',
|
|
267
|
-
].filter((flag) => flag);
|
|
268
|
-
const specifier = this.host.requiresQuoting ? `"${packageName}"` : packageName;
|
|
269
|
-
const args = [this.descriptor.addCommand, specifier, ...flags];
|
|
270
|
-
await this.#run(args, options);
|
|
271
|
-
this.#dependencyCache = null;
|
|
272
|
-
}
|
|
273
|
-
/**
|
|
274
|
-
* Installs all dependencies in the project.
|
|
275
|
-
* @param options Options for the installation.
|
|
276
|
-
* @param options.timeout The maximum time in milliseconds to wait for the command to complete.
|
|
277
|
-
* @param options.force If true, forces a clean install, potentially overwriting existing modules.
|
|
278
|
-
* @param options.registry The registry to use for the installation.
|
|
279
|
-
* @param options.ignoreScripts If true, prevents lifecycle scripts from being executed.
|
|
280
|
-
* @returns A promise that resolves when the command is complete.
|
|
281
|
-
*/
|
|
282
|
-
async install(options = { ignoreScripts: true }) {
|
|
283
|
-
const flags = [
|
|
284
|
-
options.force ? this.descriptor.forceFlag : '',
|
|
285
|
-
options.ignoreScripts ? this.descriptor.ignoreScriptsFlag : '',
|
|
286
|
-
options.ignorePeerDependencies ? (this.descriptor.ignorePeerDependenciesFlag ?? '') : '',
|
|
287
|
-
].filter((flag) => flag);
|
|
288
|
-
const args = [...this.descriptor.installCommand, ...flags];
|
|
289
|
-
await this.#run(args, options);
|
|
290
|
-
this.#dependencyCache = null;
|
|
291
|
-
}
|
|
292
|
-
/**
|
|
293
|
-
* Gets the name of the package in the current project.
|
|
294
|
-
*/
|
|
295
|
-
async getCurrentPackageName() {
|
|
296
|
-
if (this.descriptor.getPackageNameCommand) {
|
|
297
|
-
try {
|
|
298
|
-
const { stdout } = await this.#run(this.descriptor.getPackageNameCommand);
|
|
299
|
-
if (stdout) {
|
|
300
|
-
return JSON.parse(stdout);
|
|
301
|
-
}
|
|
302
|
-
}
|
|
303
|
-
catch {
|
|
304
|
-
// Fall back to reading file if command fails
|
|
305
|
-
}
|
|
306
|
-
}
|
|
307
|
-
try {
|
|
308
|
-
const content = await this.host.readFile((0, node_path_1.join)(this.cwd, 'package.json'));
|
|
309
|
-
const pkgJson = JSON.parse(content);
|
|
310
|
-
return pkgJson.name;
|
|
311
|
-
}
|
|
312
|
-
catch {
|
|
313
|
-
return undefined;
|
|
314
|
-
}
|
|
315
|
-
}
|
|
316
|
-
/**
|
|
317
|
-
* Gets the version of the package manager binary.
|
|
318
|
-
*/
|
|
319
|
-
async getVersion() {
|
|
320
|
-
if (this.#version) {
|
|
321
|
-
return this.#version;
|
|
322
|
-
}
|
|
323
|
-
const { stdout } = await this.#run(this.descriptor.versionCommand);
|
|
324
|
-
this.#version = stdout.trim();
|
|
325
|
-
if (!(0, semver_1.valid)(this.#version)) {
|
|
326
|
-
throw new Error(`Invalid semver version for ${this.name}: "${this.#version}"`);
|
|
327
|
-
}
|
|
328
|
-
return this.#version;
|
|
329
|
-
}
|
|
330
|
-
/**
|
|
331
|
-
* Gets the installed details of a package from the project's dependencies.
|
|
332
|
-
* @param packageName The name of the package to check.
|
|
333
|
-
* @returns A promise that resolves to the installed package details, or `null` if the package is not installed.
|
|
334
|
-
*/
|
|
335
|
-
async getInstalledPackage(packageName) {
|
|
336
|
-
const cache = await this.#populateDependencyCache();
|
|
337
|
-
return cache.get(packageName) ?? null;
|
|
338
|
-
}
|
|
339
|
-
/**
|
|
340
|
-
* Gets a map of all top-level dependencies installed in the project.
|
|
341
|
-
* @returns A promise that resolves to a map of package names to their installed package details.
|
|
342
|
-
*/
|
|
343
|
-
async getProjectDependencies() {
|
|
344
|
-
const cache = await this.#populateDependencyCache();
|
|
345
|
-
// Return a copy to prevent external mutations of the cache.
|
|
346
|
-
return new Map(cache);
|
|
347
|
-
}
|
|
348
|
-
/**
|
|
349
|
-
* Fetches the registry metadata for a package. This is the full metadata,
|
|
350
|
-
* including all versions and distribution tags.
|
|
351
|
-
* @param packageName The name of the package to fetch the metadata for.
|
|
352
|
-
* @param options Options for the fetch.
|
|
353
|
-
* @param options.timeout The maximum time in milliseconds to wait for the command to complete.
|
|
354
|
-
* @param options.registry The registry to use for the fetch.
|
|
355
|
-
* @param options.bypassCache If true, ignores the in-memory cache and fetches fresh data.
|
|
356
|
-
* @returns A promise that resolves to the `PackageMetadata` object, or `null` if the package is not found.
|
|
357
|
-
*/
|
|
358
|
-
async getRegistryMetadata(packageName, options = {}) {
|
|
359
|
-
const cacheKey = options.registry ? `${packageName}|${options.registry}` : packageName;
|
|
360
|
-
if (!options.bypassCache) {
|
|
361
|
-
const cached = this.#metadataCache.get(cacheKey);
|
|
362
|
-
if (cached !== undefined) {
|
|
363
|
-
return cached;
|
|
364
|
-
}
|
|
365
|
-
}
|
|
366
|
-
let metadata;
|
|
367
|
-
if (this.descriptor.getRegistryMetadata) {
|
|
368
|
-
metadata = await this.descriptor.getRegistryMetadata(packageName, (args, parser) => this.#fetchAndParse(args, parser, options));
|
|
369
|
-
}
|
|
370
|
-
else {
|
|
371
|
-
const commandArgs = [...this.descriptor.getManifestCommand, packageName];
|
|
372
|
-
const formatter = this.descriptor.viewCommandFieldArgFormatter;
|
|
373
|
-
if (formatter) {
|
|
374
|
-
commandArgs.push(...formatter(METADATA_FIELDS));
|
|
375
|
-
}
|
|
376
|
-
metadata = await this.#fetchAndParse(commandArgs, (stdout, logger) => this.descriptor.outputParsers.getRegistryMetadata(stdout, logger), options);
|
|
377
|
-
}
|
|
378
|
-
this.#metadataCache.set(cacheKey, metadata);
|
|
379
|
-
return metadata;
|
|
380
|
-
}
|
|
381
|
-
/**
|
|
382
|
-
* Fetches the registry manifest for a specific version of a package.
|
|
383
|
-
* The manifest is similar to the package's `package.json` file.
|
|
384
|
-
* @param packageName The name of the package to fetch the manifest for.
|
|
385
|
-
* @param version The version of the package to fetch the manifest for.
|
|
386
|
-
* @param options Options for the fetch.
|
|
387
|
-
* @param options.timeout The maximum time in milliseconds to wait for the command to complete.
|
|
388
|
-
* @param options.registry The registry to use for the fetch.
|
|
389
|
-
* @param options.bypassCache If true, ignores the in-memory cache and fetches fresh data.
|
|
390
|
-
* @returns A promise that resolves to the `PackageManifest` object, or `null` if the package is not found.
|
|
391
|
-
*/
|
|
392
|
-
async getRegistryManifest(packageName, version, options = {}) {
|
|
393
|
-
const specifier = this.host.requiresQuoting
|
|
394
|
-
? `"${packageName}@${version}"`
|
|
395
|
-
: `${packageName}@${version}`;
|
|
396
|
-
const commandArgs = [...this.descriptor.getManifestCommand, specifier];
|
|
397
|
-
const formatter = this.descriptor.viewCommandFieldArgFormatter;
|
|
398
|
-
if (formatter) {
|
|
399
|
-
commandArgs.push(...formatter(exports.MANIFEST_FIELDS));
|
|
400
|
-
}
|
|
401
|
-
const cacheKey = options.registry ? `${specifier}|${options.registry}` : specifier;
|
|
402
|
-
const manifest = await this.#fetchAndParse(commandArgs, (stdout, logger) => this.descriptor.outputParsers.getRegistryManifest(stdout, logger), { ...options, cache: this.#manifestCache, cacheKey });
|
|
403
|
-
// If the provided version was not a specific version, also cache the specific fetched version
|
|
404
|
-
if (manifest && manifest.version !== version) {
|
|
405
|
-
const manifestSpecifier = `${manifest.name}@${manifest.version}`;
|
|
406
|
-
const manifestCacheKey = options.registry
|
|
407
|
-
? `${manifestSpecifier}|${options.registry}`
|
|
408
|
-
: manifestSpecifier;
|
|
409
|
-
this.#manifestCache.set(manifestCacheKey, manifest);
|
|
410
|
-
}
|
|
411
|
-
return manifest;
|
|
412
|
-
}
|
|
413
|
-
/**
|
|
414
|
-
* Fetches the manifest for a package.
|
|
415
|
-
*
|
|
416
|
-
* This method can resolve manifests for packages from the registry, as well
|
|
417
|
-
* as those specified by file paths, directory paths, and remote tarballs.
|
|
418
|
-
* Caching is only supported for registry packages.
|
|
419
|
-
*
|
|
420
|
-
* @param specifier The package specifier to resolve the manifest for.
|
|
421
|
-
* @param options Options for the fetch.
|
|
422
|
-
* @returns A promise that resolves to the `PackageManifest` object, or `null` if the package is not found.
|
|
423
|
-
*/
|
|
424
|
-
async getManifest(specifier, options = {}) {
|
|
425
|
-
const { name, type, fetchSpec } = typeof specifier === 'string' ? (0, npm_package_arg_1.default)(specifier) : specifier;
|
|
426
|
-
switch (type) {
|
|
427
|
-
case 'range':
|
|
428
|
-
case 'version':
|
|
429
|
-
case 'tag': {
|
|
430
|
-
if (!name) {
|
|
431
|
-
throw new Error(`Could not parse package name from specifier: ${specifier}`);
|
|
432
|
-
}
|
|
433
|
-
// `fetchSpec` is the version, range, or tag.
|
|
434
|
-
let versionSpec = fetchSpec ?? 'latest';
|
|
435
|
-
if (this.descriptor.requiresManifestVersionLookup) {
|
|
436
|
-
if (type === 'tag' || !fetchSpec) {
|
|
437
|
-
const metadata = await this.getRegistryMetadata(name, options);
|
|
438
|
-
if (!metadata) {
|
|
439
|
-
return null;
|
|
440
|
-
}
|
|
441
|
-
versionSpec = metadata['dist-tags'][versionSpec];
|
|
442
|
-
}
|
|
443
|
-
else if (type === 'range') {
|
|
444
|
-
const metadata = await this.getRegistryMetadata(name, options);
|
|
445
|
-
if (!metadata) {
|
|
446
|
-
return null;
|
|
447
|
-
}
|
|
448
|
-
versionSpec = (0, semver_1.maxSatisfying)(metadata.versions, fetchSpec) ?? '';
|
|
449
|
-
}
|
|
450
|
-
if (!versionSpec) {
|
|
451
|
-
return null;
|
|
452
|
-
}
|
|
453
|
-
}
|
|
454
|
-
return this.getRegistryManifest(name, versionSpec, options);
|
|
455
|
-
}
|
|
456
|
-
case 'directory': {
|
|
457
|
-
if (!fetchSpec) {
|
|
458
|
-
throw new Error(`Could not parse directory path from specifier: ${specifier}`);
|
|
459
|
-
}
|
|
460
|
-
const manifestPath = (0, node_path_1.join)(fetchSpec, 'package.json');
|
|
461
|
-
const manifest = await this.host.readFile(manifestPath);
|
|
462
|
-
return JSON.parse(manifest);
|
|
463
|
-
}
|
|
464
|
-
case 'file':
|
|
465
|
-
case 'remote':
|
|
466
|
-
case 'git': {
|
|
467
|
-
if (!fetchSpec) {
|
|
468
|
-
throw new Error(`Could not parse location from specifier: ${specifier}`);
|
|
469
|
-
}
|
|
470
|
-
// Caching is not supported for non-registry specifiers.
|
|
471
|
-
const { workingDirectory, cleanup } = await this.acquireTempPackage(fetchSpec, {
|
|
472
|
-
...options,
|
|
473
|
-
ignoreScripts: true,
|
|
474
|
-
});
|
|
475
|
-
try {
|
|
476
|
-
// Discover the package name by reading the temporary `package.json` file.
|
|
477
|
-
// The package manager will have added the package to the `dependencies`.
|
|
478
|
-
const tempManifest = await this.host.readFile((0, node_path_1.join)(workingDirectory, 'package.json'));
|
|
479
|
-
const { dependencies } = JSON.parse(tempManifest);
|
|
480
|
-
const packageName = dependencies && Object.keys(dependencies)[0];
|
|
481
|
-
if (!packageName) {
|
|
482
|
-
throw new Error(`Could not determine package name for specifier: ${specifier}`);
|
|
483
|
-
}
|
|
484
|
-
// The package will be installed in `<temp>/node_modules/<name>`.
|
|
485
|
-
const packagePath = (0, node_path_1.join)(workingDirectory, 'node_modules', packageName);
|
|
486
|
-
const manifestPath = (0, node_path_1.join)(packagePath, 'package.json');
|
|
487
|
-
const manifest = await this.host.readFile(manifestPath);
|
|
488
|
-
return JSON.parse(manifest);
|
|
489
|
-
}
|
|
490
|
-
finally {
|
|
491
|
-
await cleanup();
|
|
492
|
-
}
|
|
493
|
-
}
|
|
494
|
-
default:
|
|
495
|
-
throw new Error(`Unsupported package specifier type: ${type}`);
|
|
496
|
-
}
|
|
497
|
-
}
|
|
498
|
-
async getTemporaryDirectory() {
|
|
499
|
-
const { tempDirectory } = this.options;
|
|
500
|
-
if (tempDirectory && !(0, node_path_1.relative)(this.cwd, tempDirectory).startsWith('..')) {
|
|
501
|
-
try {
|
|
502
|
-
await this.host.stat(tempDirectory);
|
|
503
|
-
}
|
|
504
|
-
catch {
|
|
505
|
-
// If the cache directory doesn't exist, create it.
|
|
506
|
-
await this.host.mkdir(tempDirectory, { recursive: true });
|
|
507
|
-
}
|
|
508
|
-
return tempDirectory;
|
|
509
|
-
}
|
|
510
|
-
const tempOptions = ['node_modules'];
|
|
511
|
-
for (const tempOption of tempOptions) {
|
|
512
|
-
try {
|
|
513
|
-
const directory = (0, node_path_1.resolve)(this.cwd, tempOption);
|
|
514
|
-
if ((await this.host.stat(directory)).isDirectory()) {
|
|
515
|
-
return directory;
|
|
516
|
-
}
|
|
517
|
-
}
|
|
518
|
-
catch { }
|
|
519
|
-
}
|
|
520
|
-
}
|
|
521
|
-
/**
|
|
522
|
-
* Acquires a package by installing it into a temporary directory. The caller is
|
|
523
|
-
* responsible for managing the lifecycle of the temporary directory by calling
|
|
524
|
-
* the returned `cleanup` function.
|
|
525
|
-
*
|
|
526
|
-
* @param specifier The specifier of the package to install.
|
|
527
|
-
* @param options Options for the installation.
|
|
528
|
-
* @returns A promise that resolves to an object containing the temporary path
|
|
529
|
-
* and a cleanup function.
|
|
530
|
-
*/
|
|
531
|
-
async acquireTempPackage(specifier, options = {}) {
|
|
532
|
-
const workingDirectory = await this.host.createTempDirectory(await this.getTemporaryDirectory());
|
|
533
|
-
const cleanup = () => this.host.deleteDirectory(workingDirectory);
|
|
534
|
-
// Some package managers, like yarn classic, do not write a package.json when adding a package.
|
|
535
|
-
// This can cause issues with subsequent `require.resolve` calls.
|
|
536
|
-
// Writing a package.json file beforehand prevents this. To ensure corepack
|
|
537
|
-
// resolves the correct package manager version, copy the project's packageManager field.
|
|
538
|
-
let packageManagerVersion;
|
|
539
|
-
try {
|
|
540
|
-
packageManagerVersion = await this.getVersion();
|
|
541
|
-
}
|
|
542
|
-
catch {
|
|
543
|
-
// Ignore version lookup errors.
|
|
544
|
-
}
|
|
545
|
-
const tempPackageJson = packageManagerVersion
|
|
546
|
-
? { packageManager: `${this.name}@${packageManagerVersion}` }
|
|
547
|
-
: {};
|
|
548
|
-
await this.host.writeFile((0, node_path_1.join)(workingDirectory, 'package.json'), JSON.stringify(tempPackageJson, null, 2));
|
|
549
|
-
// To prevent pnpm from traversing up the directory tree and modifying the project's workspace lockfile,
|
|
550
|
-
// copy the project's `pnpm-workspace.yaml` (excluding monorepo local overrides/packages)
|
|
551
|
-
// to the temporary directory if it exists, or write an empty one to act as a workspace boundary.
|
|
552
|
-
if (this.name === 'pnpm') {
|
|
553
|
-
try {
|
|
554
|
-
const workspaceConfigPath = (0, node_path_1.join)(this.cwd, 'pnpm-workspace.yaml');
|
|
555
|
-
const content = await this.host.readFile(workspaceConfigPath);
|
|
556
|
-
await this.host.writeFile((0, node_path_1.join)(workingDirectory, 'pnpm-workspace.yaml'), sanitizePnpmWorkspace(content));
|
|
557
|
-
}
|
|
558
|
-
catch {
|
|
559
|
-
await this.host.writeFile((0, node_path_1.join)(workingDirectory, 'pnpm-workspace.yaml'), "packages:\n - '.'\n");
|
|
560
|
-
}
|
|
561
|
-
}
|
|
562
|
-
// To prevent Yarn modern from traversing up the directory tree and failing because the temporary
|
|
563
|
-
// directory is not part of the project's workspace, write an empty `yarn.lock` to act as a project boundary.
|
|
564
|
-
if (this.name === 'yarn') {
|
|
565
|
-
await this.host.writeFile((0, node_path_1.join)(workingDirectory, 'yarn.lock'), '');
|
|
566
|
-
}
|
|
567
|
-
// Copy configuration files if the package manager requires it (e.g., bun, yarn).
|
|
568
|
-
if (this.descriptor.copyConfigFromProject) {
|
|
569
|
-
let copiedYarnConfig = false;
|
|
570
|
-
for (const configFile of this.descriptor.configFiles) {
|
|
571
|
-
try {
|
|
572
|
-
const configPath = (0, node_path_1.join)(this.cwd, configFile);
|
|
573
|
-
let content = await this.host.readFile(configPath);
|
|
574
|
-
if (this.name === 'yarn') {
|
|
575
|
-
content = sanitizeYarnRc(content);
|
|
576
|
-
}
|
|
577
|
-
await this.host.writeFile((0, node_path_1.join)(workingDirectory, configFile), content);
|
|
578
|
-
if (this.name === 'yarn') {
|
|
579
|
-
copiedYarnConfig = true;
|
|
580
|
-
}
|
|
581
|
-
}
|
|
582
|
-
catch {
|
|
583
|
-
// Ignore missing config files.
|
|
584
|
-
}
|
|
585
|
-
}
|
|
586
|
-
if (this.name === 'yarn' && !copiedYarnConfig) {
|
|
587
|
-
await this.host.writeFile((0, node_path_1.join)(workingDirectory, '.yarnrc.yml'), 'nodeLinker: node-modules\n');
|
|
588
|
-
}
|
|
589
|
-
}
|
|
590
|
-
const flags = [options.ignoreScripts ? this.descriptor.ignoreScriptsFlag : ''].filter((flag) => flag);
|
|
591
|
-
const args = [this.descriptor.addCommand, specifier, ...flags];
|
|
592
|
-
try {
|
|
593
|
-
await this.#run(args, { ...options, cwd: workingDirectory });
|
|
594
|
-
}
|
|
595
|
-
catch (e) {
|
|
596
|
-
// If the command fails, clean up the temporary directory immediately.
|
|
597
|
-
await cleanup();
|
|
598
|
-
throw e;
|
|
599
|
-
}
|
|
600
|
-
return { workingDirectory, cleanup };
|
|
601
|
-
}
|
|
602
|
-
/**
|
|
603
|
-
* Gets the active release age gate limit in milliseconds.
|
|
604
|
-
* @returns A promise that resolves to the limit in milliseconds, or `0` if not set.
|
|
605
|
-
*/
|
|
606
|
-
async getMinimumReleaseAge() {
|
|
607
|
-
if (this.#minimumReleaseAge === undefined) {
|
|
608
|
-
this.#minimumReleaseAge = this.#resolveMinimumReleaseAge();
|
|
609
|
-
}
|
|
610
|
-
return this.#minimumReleaseAge;
|
|
611
|
-
}
|
|
612
|
-
/**
|
|
613
|
-
* Resolves the active minimum release age by querying the package manager configuration
|
|
614
|
-
* and parsing the resulting setting.
|
|
615
|
-
* @returns A promise that resolves to the limit in milliseconds, or `0` if not set.
|
|
616
|
-
*/
|
|
617
|
-
async #resolveMinimumReleaseAge() {
|
|
618
|
-
if (this.descriptor.getReleaseAgeConfigCommand && this.descriptor.outputParsers.getReleaseAge) {
|
|
619
|
-
try {
|
|
620
|
-
const { stdout } = await this.#run(this.descriptor.getReleaseAgeConfigCommand);
|
|
621
|
-
const version = await this.getVersion();
|
|
622
|
-
return this.descriptor.outputParsers.getReleaseAge(stdout, version);
|
|
623
|
-
}
|
|
624
|
-
catch {
|
|
625
|
-
// Ignore failures and fallback to 0
|
|
626
|
-
}
|
|
627
|
-
}
|
|
628
|
-
return 0;
|
|
629
|
-
}
|
|
630
|
-
}
|
|
631
|
-
exports.PackageManager = PackageManager;
|
|
632
|
-
/**
|
|
633
|
-
* Sanitizes a `pnpm-workspace.yaml` file content to be safely used inside
|
|
634
|
-
* a temporary installation directory.
|
|
635
|
-
*
|
|
636
|
-
* This function removes monorepo-specific settings that would fail or cause
|
|
637
|
-
* unintended behaviors in a standalone, temporary project environment:
|
|
638
|
-
* 1. Removes the `overrides:` block, as it may contain `workspace:` protocol
|
|
639
|
-
* resolutions which cannot be resolved in a standalone folder.
|
|
640
|
-
* 2. Rewrites the `packages:` block to include only the current directory (`'.'`),
|
|
641
|
-
* isolating the temporary installation from other projects in the monorepo.
|
|
642
|
-
*
|
|
643
|
-
* All other settings (such as `minimumReleaseAge`, package extensions, etc.)
|
|
644
|
-
* are preserved intact.
|
|
645
|
-
*
|
|
646
|
-
* @param content The original `pnpm-workspace.yaml` content.
|
|
647
|
-
* @returns The sanitized YAML content.
|
|
648
|
-
*/
|
|
649
|
-
function sanitizePnpmWorkspace(content) {
|
|
650
|
-
const lines = content.split(/\r?\n/);
|
|
651
|
-
const result = [];
|
|
652
|
-
let inBlockToRemove = false;
|
|
653
|
-
let blockIndent = 0;
|
|
654
|
-
for (const line of lines) {
|
|
655
|
-
const trimmed = line.trim();
|
|
656
|
-
if (!trimmed) {
|
|
657
|
-
result.push(line);
|
|
658
|
-
continue;
|
|
659
|
-
}
|
|
660
|
-
// Determine the current line's indentation level.
|
|
661
|
-
const indent = line.length - line.trimStart().length;
|
|
662
|
-
// If we are currently parsing a block to remove, skip any lines with larger indentation.
|
|
663
|
-
if (inBlockToRemove) {
|
|
664
|
-
if (indent > blockIndent) {
|
|
665
|
-
continue;
|
|
666
|
-
}
|
|
667
|
-
inBlockToRemove = false;
|
|
668
|
-
}
|
|
669
|
-
// Identify blocks we want to remove or customize (e.g. 'overrides' or 'packages').
|
|
670
|
-
if (trimmed.startsWith('overrides:') || trimmed.startsWith('packages:')) {
|
|
671
|
-
inBlockToRemove = true;
|
|
672
|
-
blockIndent = indent;
|
|
673
|
-
if (trimmed.startsWith('packages:')) {
|
|
674
|
-
// Replace packages list to restrict it strictly to the current standalone folder.
|
|
675
|
-
result.push(line.replace(/packages:.*/, "packages:\n - '.'"));
|
|
676
|
-
}
|
|
677
|
-
continue;
|
|
678
|
-
}
|
|
679
|
-
result.push(line);
|
|
680
|
-
}
|
|
681
|
-
return result.join('\n');
|
|
682
|
-
}
|
|
683
|
-
/**
|
|
684
|
-
* Sanitizes the contents of `.yarnrc.yml` or `.yarnrc.yaml` for temporary package installation.
|
|
685
|
-
* It removes `yarnPath`, `plugins`, and `nodeLinker` fields, and appends `nodeLinker: node-modules`.
|
|
686
|
-
* @param content The original Yarn configuration content.
|
|
687
|
-
* @returns The sanitized Yarn configuration content.
|
|
688
|
-
*/
|
|
689
|
-
function sanitizeYarnRc(content) {
|
|
690
|
-
const lines = content.split(/\r?\n/);
|
|
691
|
-
const result = [];
|
|
692
|
-
let inBlockToRemove = false;
|
|
693
|
-
let blockIndent = 0;
|
|
694
|
-
for (const line of lines) {
|
|
695
|
-
const trimmed = line.trim();
|
|
696
|
-
if (!trimmed) {
|
|
697
|
-
result.push(line);
|
|
698
|
-
continue;
|
|
699
|
-
}
|
|
700
|
-
const indent = line.length - line.trimStart().length;
|
|
701
|
-
if (inBlockToRemove) {
|
|
702
|
-
if (indent > blockIndent) {
|
|
703
|
-
continue;
|
|
704
|
-
}
|
|
705
|
-
inBlockToRemove = false;
|
|
706
|
-
}
|
|
707
|
-
if (indent === 0 &&
|
|
708
|
-
(trimmed.startsWith('yarnPath:') ||
|
|
709
|
-
trimmed.startsWith('nodeLinker:') ||
|
|
710
|
-
trimmed.startsWith('plugins:'))) {
|
|
711
|
-
inBlockToRemove = true;
|
|
712
|
-
blockIndent = indent;
|
|
713
|
-
continue;
|
|
714
|
-
}
|
|
715
|
-
result.push(line);
|
|
716
|
-
}
|
|
717
|
-
result.push('nodeLinker: node-modules');
|
|
718
|
-
return result.join('\n');
|
|
719
|
-
}
|
|
720
|
-
//# sourceMappingURL=package-manager.js.map
|