nx 23.2.0-beta.1 → 23.2.0-beta.11
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/README.md +2 -2
- package/dist/bin/init-local.js +3 -5
- package/dist/bin/nx.js +2 -0
- package/dist/release/changelog-renderer/index.js +4 -5
- package/dist/release/index.d.ts +1 -1
- package/dist/src/adapter/ngcli-adapter.js +60 -1
- package/dist/src/ai/set-up-ai-agents/set-up-ai-agents.js +35 -15
- package/dist/src/analytics/analytics.d.ts +6 -0
- package/dist/src/analytics/analytics.js +16 -10
- package/dist/src/analytics/index.d.ts +1 -1
- package/dist/src/analytics/index.js +2 -1
- package/dist/src/command-line/add/add.js +5 -0
- package/dist/src/command-line/affected/affected.js +1 -0
- package/dist/src/command-line/completion/command-object.js +7 -12
- package/dist/src/command-line/configure-ai-agents/configure-ai-agents.js +19 -25
- package/dist/src/command-line/format/format.js +84 -101
- package/dist/src/command-line/generate/generate.js +35 -35
- package/dist/src/command-line/graph/graph.d.ts +1 -0
- package/dist/src/command-line/graph/graph.js +15 -6
- package/dist/src/command-line/import/import.js +30 -40
- package/dist/src/command-line/init/ai-agent-prompts.js +5 -11
- package/dist/src/command-line/init/command-object.js +4 -2
- package/dist/src/command-line/init/configure-plugins.js +4 -1
- package/dist/src/command-line/init/implementation/add-nx-to-monorepo.js +12 -32
- package/dist/src/command-line/init/implementation/add-nx-to-nest.js +17 -21
- package/dist/src/command-line/init/implementation/add-nx-to-npm-repo.js +8 -21
- package/dist/src/command-line/init/implementation/add-nx-to-turborepo.js +3 -17
- package/dist/src/command-line/init/implementation/angular/index.js +10 -15
- package/dist/src/command-line/init/implementation/angular/integrated-workspace.js +2 -5
- package/dist/src/command-line/init/implementation/angular/legacy-angular-versions.js +5 -0
- package/dist/src/command-line/init/implementation/angular/standalone-workspace.js +8 -2
- package/dist/src/command-line/init/implementation/check-compatible-with-plugins.js +2 -0
- package/dist/src/command-line/init/implementation/dot-nx/add-nx-scripts.js +9 -1
- package/dist/src/command-line/init/implementation/format.d.ts +18 -0
- package/dist/src/command-line/init/implementation/format.js +114 -0
- package/dist/src/command-line/init/implementation/utils.js +8 -0
- package/dist/src/command-line/init/init-v1.js +15 -18
- package/dist/src/command-line/init/init-v2.js +40 -57
- package/dist/src/command-line/migrate/agentic/definitions.js +36 -9
- package/dist/src/command-line/migrate/agentic/handoff-gitignore.d.ts +37 -22
- package/dist/src/command-line/migrate/agentic/handoff-gitignore.js +30 -39
- package/dist/src/command-line/migrate/agentic/handoff.d.ts +7 -7
- package/dist/src/command-line/migrate/agentic/handoff.js +13 -10
- package/dist/src/command-line/migrate/agentic/print-dropped-agent-context.d.ts +7 -12
- package/dist/src/command-line/migrate/agentic/print-dropped-agent-context.js +7 -0
- package/dist/src/command-line/migrate/agentic/run-step.d.ts +10 -0
- package/dist/src/command-line/migrate/agentic/run-step.js +1 -0
- package/dist/src/command-line/migrate/agentic/runner.js +24 -24
- package/dist/src/command-line/migrate/agentic/select.d.ts +10 -2
- package/dist/src/command-line/migrate/agentic/select.js +30 -32
- package/dist/src/command-line/migrate/agentic/types.d.ts +33 -3
- package/dist/src/command-line/migrate/agentic/types.js +35 -0
- package/dist/src/command-line/migrate/command-object.d.ts +6 -0
- package/dist/src/command-line/migrate/command-object.js +19 -1
- package/dist/src/command-line/migrate/execute-migration.d.ts +28 -9
- package/dist/src/command-line/migrate/execute-migration.js +112 -27
- package/dist/src/command-line/migrate/migrate-analytics.d.ts +35 -0
- package/dist/src/command-line/migrate/migrate-analytics.js +64 -0
- package/dist/src/command-line/migrate/migrate-commits.d.ts +38 -8
- package/dist/src/command-line/migrate/migrate-commits.js +130 -15
- package/dist/src/command-line/migrate/migrate-config.d.ts +13 -12
- package/dist/src/command-line/migrate/migrate-config.js +22 -14
- package/dist/src/command-line/migrate/migrate-output.d.ts +45 -7
- package/dist/src/command-line/migrate/migrate-output.js +52 -8
- package/dist/src/command-line/migrate/migrate-ui-api.d.ts +2 -1
- package/dist/src/command-line/migrate/migrate-ui-api.js +16 -7
- package/dist/src/command-line/migrate/migrate.d.ts +28 -68
- package/dist/src/command-line/migrate/migrate.js +657 -293
- package/dist/src/command-line/migrate/migration-shape.d.ts +8 -0
- package/dist/src/command-line/migrate/multi-major.js +7 -10
- package/dist/src/command-line/migrate/resolve-package-version.js +4 -8
- package/dist/src/command-line/migrate/run/agent-output.d.ts +20 -0
- package/dist/src/command-line/migrate/run/agent-output.js +65 -0
- package/dist/src/command-line/migrate/run/index.d.ts +9 -0
- package/dist/src/command-line/migrate/run/index.js +23 -0
- package/dist/src/command-line/migrate/run/orchestrator.d.ts +20 -0
- package/dist/src/command-line/migrate/run/orchestrator.js +1200 -0
- package/dist/src/command-line/migrate/run/run-id.d.ts +16 -0
- package/dist/src/command-line/migrate/run/run-id.js +56 -0
- package/dist/src/command-line/migrate/run/run-state.d.ts +157 -0
- package/dist/src/command-line/migrate/run/run-state.js +438 -0
- package/dist/src/command-line/migrate/run/state-lock.d.ts +25 -0
- package/dist/src/command-line/migrate/run/state-lock.js +76 -0
- package/dist/src/command-line/migrate/run/state-machine.d.ts +84 -0
- package/dist/src/command-line/migrate/run/state-machine.js +315 -0
- package/dist/src/command-line/migrate/run/util.d.ts +59 -0
- package/dist/src/command-line/migrate/run/util.js +148 -0
- package/dist/src/command-line/migrate/run/worker.d.ts +16 -0
- package/dist/src/command-line/migrate/run/worker.js +682 -0
- package/dist/src/command-line/migrate/run-migration-process.js +6 -5
- package/dist/src/command-line/migrate/safe-prompt.d.ts +14 -26
- package/dist/src/command-line/migrate/safe-prompt.js +32 -43
- package/dist/src/command-line/migrate/sort-migrations.d.ts +16 -0
- package/dist/src/command-line/migrate/sort-migrations.js +32 -0
- package/dist/src/command-line/migrate/step-actions.d.ts +5 -0
- package/dist/src/command-line/migrate/step-actions.js +12 -0
- package/dist/src/command-line/migrate/text.d.ts +18 -0
- package/dist/src/command-line/migrate/text.js +26 -0
- package/dist/src/command-line/migrate/version-skew-guard.d.ts +60 -0
- package/dist/src/command-line/migrate/version-skew-guard.js +175 -0
- package/dist/src/command-line/nx-cloud/connect/connect-to-nx-cloud.js +17 -21
- package/dist/src/command-line/nx-cloud/connect/view-logs.js +2 -0
- package/dist/src/command-line/nx-cloud/start-nx-agents/command-object.d.ts +2 -0
- package/dist/src/command-line/nx-cloud/start-nx-agents/command-object.js +16 -0
- package/dist/src/command-line/nx-cloud/start-nx-agents/start-nx-agents.d.ts +4 -0
- package/dist/src/command-line/nx-cloud/start-nx-agents/start-nx-agents.js +13 -0
- package/dist/src/command-line/nx-commands.js +26 -24
- package/dist/src/command-line/release/changelog.js +11 -17
- package/dist/src/command-line/release/index.d.ts +1 -1
- package/dist/src/command-line/release/plan.js +15 -28
- package/dist/src/command-line/release/publish.js +5 -0
- package/dist/src/command-line/release/release.js +6 -17
- package/dist/src/command-line/release/utils/git.js +1 -1
- package/dist/src/command-line/release/utils/release-graph.d.ts +18 -0
- package/dist/src/command-line/release/utils/release-graph.js +81 -21
- package/dist/src/command-line/release/utils/remote-release-clients/github.js +17 -23
- package/dist/src/command-line/release/utils/remote-release-clients/gitlab.js +14 -23
- package/dist/src/command-line/release/utils/resolve-semver-specifier.js +19 -41
- package/dist/src/command-line/release/version/release-group-processor.d.ts +24 -0
- package/dist/src/command-line/release/version/release-group-processor.js +80 -6
- package/dist/src/command-line/release/version/resolve-current-version.js +7 -10
- package/dist/src/command-line/release/version/version-actions.d.ts +27 -2
- package/dist/src/command-line/release/version/version-actions.js +9 -1
- package/dist/src/command-line/release/version.js +10 -6
- package/dist/src/command-line/reset/reset.js +6 -1
- package/dist/src/command-line/run/run-one.js +1 -0
- package/dist/src/command-line/run-many/run-many.js +1 -0
- package/dist/src/command-line/show/show-target/inputs.js +50 -153
- package/dist/src/command-line/show/show-target/outputs.js +48 -173
- package/dist/src/command-line/show/show-target/utils.d.ts +28 -0
- package/dist/src/command-line/show/show-target/utils.js +83 -3
- package/dist/src/command-line/watch/watch.js +13 -0
- package/dist/src/command-line/yargs-utils/shared-options.d.ts +2 -2
- package/dist/src/command-line/yargs-utils/shared-options.js +3 -1
- package/dist/src/config/misc-interfaces.d.ts +19 -7
- package/dist/src/config/nx-json.d.ts +4 -2
- package/dist/src/core/graph/main.js +1 -1
- package/dist/src/core/graph/styles.js +1 -1
- package/dist/src/daemon/client/client.d.ts +52 -1
- package/dist/src/daemon/client/client.js +160 -36
- package/dist/src/daemon/client/daemon-environment.d.ts +17 -0
- package/dist/src/daemon/client/daemon-environment.js +110 -2
- package/dist/src/daemon/client/daemon-socket-messenger.js +4 -0
- package/dist/src/daemon/message-types/daemon-message.d.ts +32 -0
- package/dist/src/daemon/message-types/daemon-message.js +25 -0
- package/dist/src/daemon/server/file-watching/file-watcher-sockets.d.ts +5 -0
- package/dist/src/daemon/server/file-watching/file-watcher-sockets.js +16 -0
- package/dist/src/daemon/server/handle-tasks-execution-hooks.d.ts +1 -1
- package/dist/src/daemon/server/latest-nx.js +5 -2
- package/dist/src/daemon/server/server.js +31 -4
- package/dist/src/daemon/server/shutdown-utils.d.ts +5 -0
- package/dist/src/daemon/server/shutdown-utils.js +11 -4
- package/dist/src/daemon/socket-utils.d.ts +1 -0
- package/dist/src/daemon/socket-utils.js +24 -3
- package/dist/src/daemon/tmp-dir.d.ts +43 -3
- package/dist/src/daemon/tmp-dir.js +437 -15
- package/dist/src/devkit-internals.d.ts +106 -8
- package/dist/src/devkit-internals.js +225 -7
- package/dist/src/executors/run-commands/running-tasks.js +46 -29
- package/dist/src/generators/internal-utils/format-changed-files.d.ts +24 -0
- package/dist/src/generators/internal-utils/format-changed-files.js +163 -0
- package/dist/src/generators/testing-utils/create-tree-with-empty-workspace.d.ts +15 -0
- package/dist/src/generators/testing-utils/create-tree-with-empty-workspace.js +21 -3
- package/dist/src/generators/tree.d.ts +4 -2
- package/dist/src/hasher/check-task-files.d.ts +86 -0
- package/dist/src/hasher/check-task-files.js +378 -0
- package/dist/src/migrations/update-15-0-0/prefix-outputs.js +2 -2
- package/dist/src/migrations/update-16-0-0/remove-nrwl-cli.js +2 -2
- package/dist/src/migrations/update-16-0-0/update-depends-on-to-tokens.js +2 -2
- package/dist/src/migrations/update-16-0-0/update-nx-cloud-runner.js +2 -2
- package/dist/src/migrations/update-16-2-0/remove-run-commands-output-path.js +2 -2
- package/dist/src/migrations/update-17-0-0/rm-default-collection-npm-scope.js +2 -2
- package/dist/src/migrations/update-17-0-0/use-minimal-config-for-tasks-runner-options.js +2 -2
- package/dist/src/migrations/update-17-2-0/move-default-base.js +2 -2
- package/dist/src/migrations/update-18-0-0/disable-crystal-for-existing-workspaces.js +2 -2
- package/dist/src/migrations/update-19-2-4/set-project-name.js +2 -2
- package/dist/src/migrations/update-20-0-0/move-use-daemon-process.js +2 -2
- package/dist/src/migrations/update-20-0-1/use-legacy-cache.js +2 -2
- package/dist/src/migrations/update-21-0-0/release-changelog-config-changes.js +2 -2
- package/dist/src/migrations/update-21-0-0/release-version-config-changes.js +2 -2
- package/dist/src/migrations/update-21-0-0/remove-custom-tasks-runner.js +2 -2
- package/dist/src/migrations/update-21-0-0/remove-legacy-cache.js +2 -2
- package/dist/src/migrations/update-22-0-0/consolidate-release-tag-config.js +2 -2
- package/dist/src/migrations/update-22-0-0/release-version-config-changes.js +2 -2
- package/dist/src/migrations/update-22-2-0/add-self-healing-to-gitignore.js +2 -2
- package/dist/src/migrations/update-22-6-0/add-claude-settings-local-to-git-ignore.js +2 -2
- package/dist/src/migrations/update-22-6-0/add-claude-worktrees-to-git-ignore.js +2 -2
- package/dist/src/migrations/update-22-7-0/add-polygraph-to-git-ignore.js +2 -2
- package/dist/src/migrations/update-23-0-0/add-migrate-runs-to-git-ignore.js +2 -2
- package/dist/src/migrations/update-23-2-0/set-cache-on-executor-target-defaults.d.ts +12 -0
- package/dist/src/migrations/update-23-2-0/set-cache-on-executor-target-defaults.js +250 -0
- package/dist/src/migrations/update-23-2-0/set-cache-on-executor-target-defaults.md +50 -0
- package/dist/src/native/index.d.ts +37 -4
- package/dist/src/native/index.js +71 -28
- package/dist/src/native/native-bindings.js +3 -0
- package/dist/src/native/native-file-cache-location.d.ts +17 -1
- package/dist/src/native/native-file-cache-location.js +86 -12
- package/dist/src/native/nx.wasm32-wasi.debug.wasm +0 -0
- package/dist/src/native/nx.wasm32-wasi.wasm +0 -0
- package/dist/src/nx-cloud/generators/connect-to-nx-cloud/connect-to-nx-cloud.js +3 -3
- package/dist/src/nx-cloud/utilities/get-cloud-options.js +5 -2
- package/dist/src/nx-cloud/utilities/onboarding.js +5 -2
- package/dist/src/nx-cloud/utilities/url-shorten.d.ts +1 -4
- package/dist/src/nx-cloud/utilities/url-shorten.js +9 -8
- package/dist/src/plugins/js/lock-file/bun-parser.js +43 -10
- package/dist/src/plugins/js/lock-file/lock-file.d.ts +46 -4
- package/dist/src/plugins/js/lock-file/lock-file.js +192 -15
- package/dist/src/plugins/js/lock-file/pnpm-parser.js +420 -64
- package/dist/src/plugins/js/lock-file/project-graph-pruning.d.ts +25 -1
- package/dist/src/plugins/js/lock-file/project-graph-pruning.js +92 -12
- package/dist/src/plugins/js/lock-file/pruned-output.d.ts +330 -0
- package/dist/src/plugins/js/lock-file/pruned-output.js +1441 -0
- package/dist/src/plugins/js/lock-file/utils/pnpm-normalizer.d.ts +1 -0
- package/dist/src/plugins/js/lock-file/utils/pnpm-normalizer.js +9 -5
- package/dist/src/plugins/js/project-graph/affected/npm-packages.js +51 -20
- package/dist/src/plugins/js/project-graph/build-dependencies/target-project-locator.js +14 -4
- package/dist/src/project-graph/affected/affected-project-graph-models.d.ts +1 -1
- package/dist/src/project-graph/affected/affected-project-graph.d.ts +1 -1
- package/dist/src/project-graph/affected/affected-project-graph.js +2 -2
- package/dist/src/project-graph/affected/locators/project-glob-changes.js +5 -2
- package/dist/src/project-graph/build-project-graph.js +7 -1
- package/dist/src/project-graph/error-types.d.ts +12 -1
- package/dist/src/project-graph/error-types.js +27 -2
- package/dist/src/project-graph/plugins/isolation/isolated-plugin.d.ts +1 -0
- package/dist/src/project-graph/plugins/isolation/isolated-plugin.js +18 -1
- package/dist/src/project-graph/plugins/isolation/messaging.d.ts +16 -3
- package/dist/src/project-graph/plugins/isolation/messaging.js +3 -0
- package/dist/src/project-graph/plugins/isolation/plugin-worker.js +58 -8
- package/dist/src/project-graph/plugins/loaded-nx-plugin.js +1 -0
- package/dist/src/project-graph/project-graph.js +23 -0
- package/dist/src/project-graph/utils/project-configuration/name-substitution-manager.d.ts +1 -0
- package/dist/src/project-graph/utils/project-configuration/name-substitution-manager.js +16 -2
- package/dist/src/project-graph/utils/project-configuration/project-nodes-manager.d.ts +12 -8
- package/dist/src/project-graph/utils/project-configuration/project-nodes-manager.js +30 -21
- package/dist/src/project-graph/utils/project-configuration/source-maps.d.ts +12 -5
- package/dist/src/project-graph/utils/project-configuration/source-maps.js +21 -7
- package/dist/src/project-graph/utils/project-configuration/target-defaults.d.ts +1 -1
- package/dist/src/project-graph/utils/project-configuration/target-defaults.js +26 -27
- package/dist/src/project-graph/utils/project-configuration/target-merging.js +50 -8
- package/dist/src/project-graph/utils/project-configuration/target-normalization.js +149 -6
- package/dist/src/project-graph/utils/project-configuration/utils.d.ts +15 -0
- package/dist/src/project-graph/utils/project-configuration/utils.js +42 -6
- package/dist/src/project-graph/utils/project-configuration-utils.d.ts +15 -12
- package/dist/src/project-graph/utils/project-configuration-utils.js +79 -99
- package/dist/src/tasks-runner/is-tui-enabled.js +3 -1
- package/dist/src/tasks-runner/life-cycle.d.ts +2 -2
- package/dist/src/tasks-runner/life-cycle.js +2 -2
- package/dist/src/tasks-runner/life-cycles/performance-report.d.ts +12 -0
- package/dist/src/tasks-runner/life-cycles/performance-report.js +62 -3
- package/dist/src/tasks-runner/life-cycles/static-run-many-terminal-output-life-cycle.d.ts +26 -1
- package/dist/src/tasks-runner/life-cycles/static-run-many-terminal-output-life-cycle.js +99 -5
- package/dist/src/tasks-runner/life-cycles/static-run-one-terminal-output-life-cycle.d.ts +26 -0
- package/dist/src/tasks-runner/life-cycles/static-run-one-terminal-output-life-cycle.js +113 -17
- package/dist/src/tasks-runner/pseudo-terminal.d.ts +17 -3
- package/dist/src/tasks-runner/pseudo-terminal.js +22 -10
- package/dist/src/tasks-runner/run-command.js +28 -35
- package/dist/src/tasks-runner/running-tasks/batch-process.d.ts +55 -0
- package/dist/src/tasks-runner/running-tasks/batch-process.js +161 -8
- package/dist/src/tasks-runner/task-env.d.ts +9 -0
- package/dist/src/tasks-runner/task-env.js +31 -4
- package/dist/src/tasks-runner/task-orchestrator.d.ts +72 -1
- package/dist/src/tasks-runner/task-orchestrator.js +182 -18
- package/dist/src/tasks-runner/utils.js +2 -6
- package/dist/src/utils/acknowledge-build-scripts.js +7 -5
- package/dist/src/utils/analytics-enabled.d.ts +7 -0
- package/dist/src/utils/analytics-enabled.js +11 -0
- package/dist/src/utils/analytics-prompt.d.ts +0 -6
- package/dist/src/utils/analytics-prompt.js +4 -58
- package/dist/src/utils/assert-workspace-validity.js +7 -2
- package/dist/src/utils/catalog/bun-manager-utils.d.ts +8 -0
- package/dist/src/utils/catalog/bun-manager-utils.js +174 -0
- package/dist/src/utils/catalog/bun-manager.d.ts +28 -0
- package/dist/src/utils/catalog/bun-manager.js +130 -0
- package/dist/src/utils/catalog/index.d.ts +1 -1
- package/dist/src/utils/catalog/index.js +1 -1
- package/dist/src/utils/catalog/manager-factory.js +3 -0
- package/dist/src/utils/catalog/manager-utils.d.ts +8 -1
- package/dist/src/utils/catalog/manager-utils.js +9 -4
- package/dist/src/utils/catalog/manager.d.ts +13 -1
- package/dist/src/utils/catalog/manager.js +30 -0
- package/dist/src/utils/catalog/pnpm-manager.d.ts +2 -1
- package/dist/src/utils/catalog/pnpm-manager.js +3 -0
- package/dist/src/utils/catalog/types.d.ts +4 -0
- package/dist/src/utils/catalog/yarn-manager.d.ts +6 -2
- package/dist/src/utils/catalog/yarn-manager.js +23 -32
- package/dist/src/utils/child-process.d.ts +31 -1
- package/dist/src/utils/child-process.js +103 -0
- package/dist/src/utils/chunkify.d.ts +7 -1
- package/dist/src/utils/chunkify.js +10 -3
- package/dist/src/utils/exit-codes.d.ts +9 -0
- package/dist/src/utils/exit-codes.js +19 -0
- package/dist/src/utils/fileutils.d.ts +5 -0
- package/dist/src/utils/fileutils.js +7 -2
- package/dist/src/utils/formatters/index.d.ts +13 -0
- package/dist/src/utils/formatters/index.js +74 -0
- package/dist/src/utils/formatters/oxfmt.d.ts +32 -0
- package/dist/src/utils/formatters/oxfmt.js +764 -0
- package/dist/src/utils/formatters/prettier.d.ts +26 -0
- package/dist/src/utils/formatters/prettier.js +201 -0
- package/dist/src/utils/formatters/shared.d.ts +5 -0
- package/dist/src/utils/formatters/shared.js +8 -0
- package/dist/src/utils/git-utils.d.ts +48 -2
- package/dist/src/utils/git-utils.js +220 -14
- package/dist/src/utils/git-worktrees.d.ts +30 -0
- package/dist/src/utils/git-worktrees.js +212 -0
- package/dist/src/utils/has-nx-js-plugin.d.ts +1 -1
- package/dist/src/utils/has-nx-js-plugin.js +1 -1
- package/dist/src/utils/ignore.d.ts +170 -1
- package/dist/src/utils/ignore.js +263 -11
- package/dist/src/utils/kill-child-on-host-exit.d.ts +7 -0
- package/dist/src/utils/kill-child-on-host-exit.js +42 -0
- package/dist/src/utils/long-running-target.d.ts +10 -0
- package/dist/src/utils/long-running-target.js +19 -0
- package/dist/src/utils/min-release-age/behavior/bun.js +7 -11
- package/dist/src/utils/min-release-age/behavior/npm.js +5 -2
- package/dist/src/utils/min-release-age/packument.js +1 -1
- package/dist/src/utils/nx-console-prompt.js +3 -6
- package/dist/src/utils/nx-tmp-dir.d.ts +18 -0
- package/dist/src/utils/nx-tmp-dir.js +40 -0
- package/dist/src/utils/output.d.ts +153 -0
- package/dist/src/utils/output.js +289 -5
- package/dist/src/utils/owned-private-dir.d.ts +132 -0
- package/dist/src/utils/owned-private-dir.js +323 -0
- package/dist/src/utils/package-json.d.ts +2 -0
- package/dist/src/utils/package-json.js +11 -7
- package/dist/src/utils/package-manager-config/bunfig.d.ts +14 -0
- package/dist/src/utils/package-manager-config/bunfig.js +49 -0
- package/dist/src/utils/package-manager-config/npmrc.d.ts +23 -0
- package/dist/src/utils/package-manager-config/npmrc.js +124 -0
- package/dist/src/utils/package-manager-config/pnpm-config.d.ts +17 -0
- package/dist/src/utils/package-manager-config/pnpm-config.js +60 -0
- package/dist/src/utils/package-manager.d.ts +23 -2
- package/dist/src/utils/package-manager.js +262 -42
- package/dist/src/utils/params.d.ts +7 -1
- package/dist/src/utils/params.js +64 -6
- package/dist/src/utils/plugins/core-plugins.js +4 -0
- package/dist/src/utils/prompt-helpers.d.ts +53 -0
- package/dist/src/utils/prompt-helpers.js +111 -0
- package/dist/src/utils/provenance.js +6 -14
- package/dist/src/utils/registry-config/bun.d.ts +2 -0
- package/dist/src/utils/registry-config/bun.js +257 -0
- package/dist/src/utils/registry-config/index.d.ts +13 -0
- package/dist/src/utils/registry-config/index.js +102 -0
- package/dist/src/utils/registry-config/pnpm.d.ts +2 -0
- package/dist/src/utils/registry-config/pnpm.js +1551 -0
- package/dist/src/utils/registry-config/utils.d.ts +195 -0
- package/dist/src/utils/registry-config/utils.js +496 -0
- package/dist/src/utils/registry-config/yarn-berry.d.ts +2 -0
- package/dist/src/utils/registry-config/yarn-berry.js +612 -0
- package/dist/src/utils/registry-config/yarn-classic.d.ts +2 -0
- package/dist/src/utils/registry-config/yarn-classic.js +1001 -0
- package/dist/src/utils/safe-spawn.d.ts +24 -0
- package/dist/src/utils/safe-spawn.js +104 -0
- package/dist/src/utils/shell-quoting.d.ts +15 -0
- package/dist/src/utils/shell-quoting.js +35 -0
- package/dist/src/utils/wait-for-socket-connection.d.ts +11 -0
- package/dist/src/utils/wait-for-socket-connection.js +14 -8
- package/dist/src/utils/workspace-id.d.ts +20 -0
- package/dist/src/utils/workspace-id.js +54 -0
- package/dist/src/utils/write-formatted-json-file.d.ts +3 -2
- package/dist/src/utils/write-formatted-json-file.js +5 -4
- package/migrations.json +6 -0
- package/package.json +29 -19
- package/dist/src/generators/internal-utils/format-changed-files-with-prettier-if-available.d.ts +0 -19
- package/dist/src/generators/internal-utils/format-changed-files-with-prettier-if-available.js +0 -81
- package/dist/src/utils/is-using-prettier.d.ts +0 -3
- package/dist/src/utils/is-using-prettier.js +0 -62
- package/dist/src/utils/min-release-age/npmrc.d.ts +0 -15
- package/dist/src/utils/min-release-age/npmrc.js +0 -45
|
@@ -10,15 +10,19 @@ const project_graph_builder_1 = require("../../../project-graph/project-graph-bu
|
|
|
10
10
|
const project_graph_1 = require("../../../config/project-graph");
|
|
11
11
|
const file_hasher_1 = require("../../../hasher/file-hasher");
|
|
12
12
|
const catalog_1 = require("../../../utils/catalog");
|
|
13
|
+
const pruned_output_1 = require("./pruned-output");
|
|
13
14
|
const project_graph_pruning_1 = require("./project-graph-pruning");
|
|
14
15
|
const path_1 = require("path");
|
|
16
|
+
const workspace_root_1 = require("../../../utils/workspace-root");
|
|
17
|
+
const node_fs_1 = require("node:fs");
|
|
18
|
+
const logger_1 = require("../../../utils/logger");
|
|
15
19
|
const get_workspace_packages_from_graph_1 = require("../utils/get-workspace-packages-from-graph");
|
|
16
20
|
const semver_1 = require("semver");
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
];
|
|
21
|
+
// The dep types walked when pulling a copied module's own workspace deps into
|
|
22
|
+
// the pruned lockfile: production sections only, since a dependency's
|
|
23
|
+
// devDependencies are never installed. The root importer is different: it
|
|
24
|
+
// mirrors every manifest section, devDependencies included (see mapRootSnapshot).
|
|
25
|
+
const WORKSPACE_DEP_TYPES = ['dependencies', 'optionalDependencies'];
|
|
22
26
|
let currentLockFileHash;
|
|
23
27
|
let parsedLockFile;
|
|
24
28
|
function parsePnpmLockFile(lockFileContent, lockFileHash) {
|
|
@@ -133,6 +137,17 @@ function findPatchHash(patchEntriesByPackage, packageName, version) {
|
|
|
133
137
|
const nameOnlyMatch = entries.find((entry) => entry.versionSpecifier === null);
|
|
134
138
|
return nameOnlyMatch?.hash;
|
|
135
139
|
}
|
|
140
|
+
// Segment-aware: `..` and `../x` escape, a directory literally named `..cache`
|
|
141
|
+
// does not. Absolute targets are resolved against the workspace root.
|
|
142
|
+
function linkTargetEscapesWorkspace(importerPath, depVersion) {
|
|
143
|
+
const rawTarget = depVersion.slice('link:'.length);
|
|
144
|
+
if (path_1.posix.isAbsolute(rawTarget) || (0, path_1.isAbsolute)(rawTarget)) {
|
|
145
|
+
const rel = (0, path_1.relative)(workspace_root_1.workspaceRoot, rawTarget);
|
|
146
|
+
return rel === '..' || rel.startsWith(`..${path_1.sep}`) || (0, path_1.isAbsolute)(rel);
|
|
147
|
+
}
|
|
148
|
+
const combined = path_1.posix.normalize(path_1.posix.join(importerPath === '.' ? '' : importerPath, rawTarget));
|
|
149
|
+
return combined === '..' || combined.startsWith('../');
|
|
150
|
+
}
|
|
136
151
|
function getNodes(data, isV5) {
|
|
137
152
|
cachedInvertedRecords.clear();
|
|
138
153
|
const keyMap = new Map();
|
|
@@ -183,7 +198,8 @@ function getNodes(data, isV5) {
|
|
|
183
198
|
}
|
|
184
199
|
}
|
|
185
200
|
const packageNames = new Set();
|
|
186
|
-
for
|
|
201
|
+
// pnpm omits the packages block for workspace-only lockfiles (no external deps)
|
|
202
|
+
for (const [key, snapshot] of Object.entries(data.packages ?? {})) {
|
|
187
203
|
let packageNameObj;
|
|
188
204
|
const originalPackageName = extractNameFromKey(key, isV5);
|
|
189
205
|
if (!originalPackageName) {
|
|
@@ -344,6 +360,54 @@ function getNodes(data, isV5) {
|
|
|
344
360
|
results[node.name] = node;
|
|
345
361
|
});
|
|
346
362
|
}
|
|
363
|
+
// `link:` dependencies pointing outside the workspace never appear in the
|
|
364
|
+
// packages section, so nothing above minted a node for them — and a task
|
|
365
|
+
// input naming one via `externalDependencies` fails hashing with "could not
|
|
366
|
+
// be found". Mint a node under the bare `npm:<name>`, hashed on the link
|
|
367
|
+
// path: the hash changes only when the path does, not when the linked
|
|
368
|
+
// content does, which is how linked dependencies behave everywhere else in
|
|
369
|
+
// Nx. Links that resolve inside the workspace are workspace projects, not
|
|
370
|
+
// externals, and are skipped.
|
|
371
|
+
//
|
|
372
|
+
// One node per package name, chosen deterministically by visiting importers
|
|
373
|
+
// root-first, then lexicographically. An `externalDependencies` input names
|
|
374
|
+
// a package, not a link target, so it could not distinguish two linked
|
|
375
|
+
// targets anyway.
|
|
376
|
+
const importerPaths = Object.keys(data.importers ?? {}).sort((a, b) => a === '.' ? -1 : b === '.' ? 1 : a.localeCompare(b));
|
|
377
|
+
for (const importerPath of importerPaths) {
|
|
378
|
+
const importer = data.importers[importerPath];
|
|
379
|
+
for (const depType of [
|
|
380
|
+
'dependencies',
|
|
381
|
+
'devDependencies',
|
|
382
|
+
'optionalDependencies',
|
|
383
|
+
]) {
|
|
384
|
+
const deps = importer[depType];
|
|
385
|
+
if (!deps) {
|
|
386
|
+
continue;
|
|
387
|
+
}
|
|
388
|
+
for (const [depName, depVersion] of Object.entries(deps)) {
|
|
389
|
+
if (typeof depVersion !== 'string' || !depVersion.startsWith('link:')) {
|
|
390
|
+
continue;
|
|
391
|
+
}
|
|
392
|
+
if (!linkTargetEscapesWorkspace(importerPath, depVersion)) {
|
|
393
|
+
continue; // inside the workspace -> a workspace project
|
|
394
|
+
}
|
|
395
|
+
const bareName = `npm:${depName}`;
|
|
396
|
+
if (results[bareName]) {
|
|
397
|
+
continue; // a hoisted registry version or an earlier link wins
|
|
398
|
+
}
|
|
399
|
+
results[bareName] = {
|
|
400
|
+
type: 'npm',
|
|
401
|
+
name: bareName,
|
|
402
|
+
data: {
|
|
403
|
+
version: depVersion,
|
|
404
|
+
packageName: depName,
|
|
405
|
+
hash: (0, file_hasher_1.hashArray)([depName, depVersion]),
|
|
406
|
+
},
|
|
407
|
+
};
|
|
408
|
+
}
|
|
409
|
+
}
|
|
410
|
+
}
|
|
347
411
|
return { nodes: results, keyMap };
|
|
348
412
|
}
|
|
349
413
|
function getHoistedVersion(packageName, isV5, hoistedKeysByPackage) {
|
|
@@ -364,7 +428,8 @@ function getHoistedVersion(packageName, isV5, hoistedKeysByPackage) {
|
|
|
364
428
|
}
|
|
365
429
|
function getDependencies(data, keyMap, isV5, ctx) {
|
|
366
430
|
const results = [];
|
|
367
|
-
|
|
431
|
+
// pnpm omits the packages block for workspace-only lockfiles (no external deps)
|
|
432
|
+
Object.keys(data.packages ?? {}).forEach((key) => {
|
|
368
433
|
const snapshot = data.packages[key];
|
|
369
434
|
const nodes = keyMap.get(key);
|
|
370
435
|
nodes.forEach((node) => {
|
|
@@ -400,69 +465,310 @@ function stringifyPnpmLockfile(graph, rootLockFileContent, packageJson, workspac
|
|
|
400
465
|
// pnpm omits the packages block for workspace-only lockfiles (no external deps)
|
|
401
466
|
const packages = data.packages ?? {};
|
|
402
467
|
const packageIndex = indexPackagesByName(packages, +lockfileVersion);
|
|
403
|
-
const { snapshot: rootSnapshot, importers: requiredImporters } = mapRootSnapshot(packageJson, importers, packages, packageIndex, graph, +lockfileVersion, workspaceRoot);
|
|
404
|
-
const snapshots = mapSnapshots(packages, packageIndex, graph.externalNodes, +lockfileVersion);
|
|
405
468
|
const workspaceModules = (0, get_workspace_packages_from_graph_1.getWorkspacePackagesFromGraph)(graph);
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
469
|
+
const manifestPeersCache = new Map();
|
|
470
|
+
const getManifestPeers = (importerPath) => {
|
|
471
|
+
let peers = manifestPeersCache.get(importerPath);
|
|
472
|
+
if (peers) {
|
|
473
|
+
return peers;
|
|
474
|
+
}
|
|
475
|
+
peers = { workspaceSiblings: [], localPathPeers: [] };
|
|
476
|
+
const manifestPath = (0, path_1.join)(workspaceRoot, importerPath, 'package.json');
|
|
477
|
+
if ((0, node_fs_1.existsSync)(manifestPath)) {
|
|
478
|
+
try {
|
|
479
|
+
const manifest = JSON.parse((0, node_fs_1.readFileSync)(manifestPath, 'utf-8'));
|
|
480
|
+
for (const [name, spec] of Object.entries(manifest.peerDependencies ?? {})) {
|
|
481
|
+
if (workspaceModules.has(name)) {
|
|
482
|
+
peers.workspaceSiblings.push(name);
|
|
483
|
+
}
|
|
484
|
+
else if (typeof spec === 'string' && (0, project_graph_pruning_1.isLocalPathSpecifier)(spec)) {
|
|
485
|
+
peers.localPathPeers.push([name, spec]);
|
|
486
|
+
}
|
|
487
|
+
}
|
|
488
|
+
}
|
|
489
|
+
catch {
|
|
490
|
+
// Fall back to the lockfile importer only.
|
|
491
|
+
logger_1.logger.warn(`Could not read ${manifestPath} while pruning the pnpm lockfile; a peer dependency it declares may be missing from the pruned lockfile.`);
|
|
492
|
+
}
|
|
493
|
+
}
|
|
494
|
+
manifestPeersCache.set(importerPath, peers);
|
|
495
|
+
return peers;
|
|
496
|
+
};
|
|
497
|
+
const { snapshot: rootSnapshot, importers: requiredImporters } = mapRootSnapshot(packageJson, importers, packages, packageIndex, graph, workspaceModules, +lockfileVersion, workspaceRoot);
|
|
498
|
+
const snapshots = mapSnapshots(packages, packageIndex, graph.externalNodes, +lockfileVersion);
|
|
499
|
+
// Walk transitive workspace deps so every module copy-workspace-modules
|
|
500
|
+
// writes to disk gets a matching directory-package entry. Without this, pnpm
|
|
501
|
+
// errors with ERR_PNPM_OUTDATED_LOCKFILE on transitive workspace chains.
|
|
409
502
|
const allRequiredImporters = { ...requiredImporters };
|
|
410
503
|
const queue = Object.keys(requiredImporters);
|
|
504
|
+
const enqueueWorkspaceModule = (depName) => {
|
|
505
|
+
if (workspaceModules.has(depName) && !(depName in allRequiredImporters)) {
|
|
506
|
+
allRequiredImporters[depName] = workspaceModules.get(depName).data.root;
|
|
507
|
+
queue.push(depName);
|
|
508
|
+
}
|
|
509
|
+
};
|
|
411
510
|
while (queue.length > 0) {
|
|
412
511
|
const pkgName = queue.shift();
|
|
413
|
-
const
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
allRequiredImporters[depName] =
|
|
423
|
-
workspaceModules.get(depName).data.root;
|
|
424
|
-
queue.push(depName);
|
|
512
|
+
const importerPath = allRequiredImporters[pkgName];
|
|
513
|
+
const importer = importers[importerPath];
|
|
514
|
+
if (importer) {
|
|
515
|
+
for (const depType of WORKSPACE_DEP_TYPES) {
|
|
516
|
+
const deps = importer[depType];
|
|
517
|
+
if (!deps)
|
|
518
|
+
continue;
|
|
519
|
+
for (const depName of Object.keys(deps)) {
|
|
520
|
+
enqueueWorkspaceModule(depName);
|
|
425
521
|
}
|
|
426
522
|
}
|
|
427
523
|
}
|
|
524
|
+
// Peers pnpm did not auto-install are absent from the importer above; pull
|
|
525
|
+
// them from the manifest so their directory package is emitted too.
|
|
526
|
+
for (const depName of getManifestPeers(importerPath).workspaceSiblings) {
|
|
527
|
+
enqueueWorkspaceModule(depName);
|
|
528
|
+
}
|
|
428
529
|
}
|
|
429
|
-
|
|
530
|
+
// Emit each copied workspace module as a pnpm `file:` directory dependency,
|
|
531
|
+
// the shape `pnpm install` produces natively for a file: dependency. A module
|
|
532
|
+
// becomes a package keyed `<name>@file:workspace_modules/<name>` with a
|
|
533
|
+
// directory resolution and its resolved production closure; inter-module edges
|
|
534
|
+
// become `file:` refs. This is what a standalone production install expects:
|
|
535
|
+
// the modules resolve as file: directory packages, not workspace packages, so
|
|
536
|
+
// no `packages:` workspace file and no importer blocks for them.
|
|
537
|
+
const workspaceModulePackages = {};
|
|
538
|
+
// `<name>@file:<relocated-path>` keys for backfilled file: peers, mapped to
|
|
539
|
+
// the relocated target path; entries are synthesized after the loop.
|
|
540
|
+
const localPathPeerEntries = new Map();
|
|
541
|
+
// Output paths for the copied workspace modules, so the relocation pass can
|
|
542
|
+
// recognize them by identity. A workspace directory named `workspace_modules`
|
|
543
|
+
// is a real source that must relocate, and only the assembly knows which of
|
|
544
|
+
// the two a path is.
|
|
545
|
+
const synthesizedModulePaths = new Set();
|
|
546
|
+
// Snapshots whose manifest-declared peers are backfilled after the relocation
|
|
547
|
+
// pass, so the refs that pass writes are not relocated a second time.
|
|
548
|
+
const pendingPeerBackfills = [];
|
|
430
549
|
for (const [packageName, importerPath] of Object.entries(allRequiredImporters)) {
|
|
431
550
|
const baseImporter = importers[importerPath];
|
|
432
551
|
if (!baseImporter)
|
|
433
552
|
continue;
|
|
434
|
-
const
|
|
553
|
+
const snapshot = {
|
|
554
|
+
resolution: {
|
|
555
|
+
directory: `workspace_modules/${packageName}`,
|
|
556
|
+
type: 'directory',
|
|
557
|
+
},
|
|
558
|
+
};
|
|
435
559
|
for (const depType of WORKSPACE_DEP_TYPES) {
|
|
436
|
-
const deps =
|
|
560
|
+
const deps = baseImporter[depType];
|
|
437
561
|
if (!deps)
|
|
438
562
|
continue;
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
//
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
importer
|
|
449
|
-
|
|
450
|
-
|
|
563
|
+
const resolved = {};
|
|
564
|
+
for (const [depName, ref] of Object.entries(deps)) {
|
|
565
|
+
// Sibling workspace modules resolve to their own directory package; npm
|
|
566
|
+
// deps (resolved peers included) keep the ref from the source importer.
|
|
567
|
+
if (workspaceModules.has(depName)) {
|
|
568
|
+
resolved[depName] = `file:workspace_modules/${depName}`;
|
|
569
|
+
}
|
|
570
|
+
else if (ref.startsWith('link:')) {
|
|
571
|
+
// pnpm reads a snapshot link: ref relative to the lockfile dir, so
|
|
572
|
+
// rebase the importer-relative ref onto the deploy root, relocated to
|
|
573
|
+
// its shipped location (file: refs are lockfile-dir-relative and get
|
|
574
|
+
// contained by containShippedLocalFilePaths below; an unshippable
|
|
575
|
+
// target keeps its ref, matching the copied manifest).
|
|
576
|
+
const relocation = (0, pruned_output_1.relocatePrunedLocalPathSpec)(ref, importerPath, '');
|
|
577
|
+
resolved[depName] = relocation?.spec ?? ref;
|
|
578
|
+
}
|
|
579
|
+
else {
|
|
580
|
+
resolved[depName] = ref;
|
|
581
|
+
}
|
|
451
582
|
}
|
|
583
|
+
snapshot[depType] = resolved;
|
|
452
584
|
}
|
|
453
|
-
|
|
585
|
+
pendingPeerBackfills.push({ snapshot, importerPath });
|
|
586
|
+
synthesizedModulePaths.add(`workspace_modules/${packageName}`);
|
|
587
|
+
workspaceModulePackages[`${packageName}@file:workspace_modules/${packageName}`] = snapshot;
|
|
454
588
|
}
|
|
589
|
+
// Relocate the source snapshots' link: refs before the merge below, while the
|
|
590
|
+
// assembly's own already-relocated entries are still separate from them.
|
|
591
|
+
(0, pruned_output_1.containShippedLocalLinkRefs)(snapshots);
|
|
455
592
|
const output = {
|
|
456
593
|
...data,
|
|
457
594
|
lockfileVersion,
|
|
458
595
|
importers: {
|
|
459
596
|
'.': rootSnapshot,
|
|
460
|
-
...workspaceDependencyImporters,
|
|
461
597
|
},
|
|
462
|
-
packages:
|
|
598
|
+
packages: { ...snapshots, ...workspaceModulePackages },
|
|
463
599
|
};
|
|
600
|
+
// Relocate vendored file: refs (keys, resolutions, snapshot/importer refs) to
|
|
601
|
+
// their shipped location under LOCAL_PATH_MODULES_DIR; link: refs and the
|
|
602
|
+
// manifest are already relocated upstream. Everything assembled below is
|
|
603
|
+
// relocated at its synthesis site, which is why it is added afterwards: a
|
|
604
|
+
// second pass over an already-relocated path cannot tell it apart from a
|
|
605
|
+
// workspace path that genuinely starts with the shipped directory's name.
|
|
606
|
+
// TODO(v24): throw on this collision like the colliding-patches case; today
|
|
607
|
+
// the copied workspace module silently supersedes the file: dependency.
|
|
608
|
+
(0, pruned_output_1.warnOnWorkspaceModulePathCollision)(snapshots, synthesizedModulePaths);
|
|
609
|
+
(0, pruned_output_1.containShippedLocalFilePaths)(output, synthesizedModulePaths);
|
|
610
|
+
// Peers pnpm left out of the importer (autoInstallPeers off) still ship as
|
|
611
|
+
// real dependencies, matching the copied manifest that moves every
|
|
612
|
+
// peer-declared workspace module or local path into dependencies. A
|
|
613
|
+
// local-path peer gets the snapshot edge pnpm records when it auto-installs
|
|
614
|
+
// the peer, relocated to its shipped location; an unshippable target keeps
|
|
615
|
+
// its spec, matching the copied manifest (copy-workspace-modules already
|
|
616
|
+
// warned).
|
|
617
|
+
for (const { snapshot, importerPath } of pendingPeerBackfills) {
|
|
618
|
+
const { workspaceSiblings, localPathPeers } = getManifestPeers(importerPath);
|
|
619
|
+
if (workspaceSiblings.length === 0 && localPathPeers.length === 0) {
|
|
620
|
+
continue;
|
|
621
|
+
}
|
|
622
|
+
snapshot.dependencies ??= {};
|
|
623
|
+
for (const depName of workspaceSiblings) {
|
|
624
|
+
snapshot.dependencies[depName] ??= `file:workspace_modules/${depName}`;
|
|
625
|
+
}
|
|
626
|
+
for (const [depName, spec] of localPathPeers) {
|
|
627
|
+
if (snapshot.dependencies[depName]) {
|
|
628
|
+
continue;
|
|
629
|
+
}
|
|
630
|
+
const relocation = (0, pruned_output_1.relocatePrunedLocalPathSpec)(spec, importerPath, '');
|
|
631
|
+
const ref = relocation?.spec ?? spec;
|
|
632
|
+
snapshot.dependencies[depName] = ref;
|
|
633
|
+
if (ref.startsWith('file:') && !relocation?.reason) {
|
|
634
|
+
localPathPeerEntries.set(`${depName}@${ref}`, ref.slice('file:'.length));
|
|
635
|
+
}
|
|
636
|
+
}
|
|
637
|
+
}
|
|
638
|
+
// A backfilled file: peer has no package entry to carry (pnpm never resolved
|
|
639
|
+
// it), so synthesize the entry pnpm itself writes when it auto-installs the
|
|
640
|
+
// peer: a directory resolution for a directory target, a tarball resolution
|
|
641
|
+
// for a packed file (integrity is optional for a local tarball). link: refs
|
|
642
|
+
// need no entry. Entries the prune already carries win, compared against the
|
|
643
|
+
// relocated keys since both sides are relocated by this point.
|
|
644
|
+
for (const [key, shippedPath] of localPathPeerEntries) {
|
|
645
|
+
if (key in output.packages) {
|
|
646
|
+
continue;
|
|
647
|
+
}
|
|
648
|
+
let isFile = false;
|
|
649
|
+
try {
|
|
650
|
+
// Read the source from its original workspace location; the ref, and so
|
|
651
|
+
// the entry the output ships, names the relocated location.
|
|
652
|
+
isFile = (0, node_fs_1.statSync)((0, path_1.join)(workspaceRoot, (0, pruned_output_1.uncontainLocalPath)(shippedPath))).isFile();
|
|
653
|
+
}
|
|
654
|
+
catch {
|
|
655
|
+
// Missing target: emit the directory shape; the install surfaces the
|
|
656
|
+
// missing path either way.
|
|
657
|
+
}
|
|
658
|
+
output.packages[key] = {
|
|
659
|
+
resolution: isFile
|
|
660
|
+
? { tarball: `file:${shippedPath}` }
|
|
661
|
+
: { directory: shippedPath, type: 'directory' },
|
|
662
|
+
};
|
|
663
|
+
}
|
|
664
|
+
output.packages = (0, object_sort_1.sortObjectByKeys)(output.packages);
|
|
665
|
+
stripStandaloneLockfileConfig(output);
|
|
464
666
|
return (0, pnpm_normalizer_1.stringifyToPnpmYaml)(output);
|
|
465
667
|
}
|
|
668
|
+
/**
|
|
669
|
+
* Removes settings a standalone, pruned lockfile cannot satisfy on its own.
|
|
670
|
+
*
|
|
671
|
+
* A pruned build output ships `package.json`, the lockfile, and the copied
|
|
672
|
+
* `workspace_modules/` directories. It carries no resolution-time pnpm config:
|
|
673
|
+
* any `pnpm-workspace.yaml` it emits holds only install-time settings
|
|
674
|
+
* (build-script approvals, `supportedArchitectures`), never `overrides`,
|
|
675
|
+
* `packageExtensions`, or catalogs. pnpm 11 also no longer reads the `pnpm` field
|
|
676
|
+
* from `package.json`, so the lockfile's stored config (`overrides`, `settings`,
|
|
677
|
+
* `catalogs`, ...) has no backing source in the output. pnpm validates these
|
|
678
|
+
* against that (now absent) config and aborts `pnpm install --frozen-lockfile`
|
|
679
|
+
* with ERR_PNPM_LOCKFILE_CONFIG_MISMATCH. Their effect is already baked into the
|
|
680
|
+
* resolved snapshots, so removing them keeps the install identical.
|
|
681
|
+
*
|
|
682
|
+
* The fields come from `PNPM_RESOLUTION_CONFIG` in `pruned-output`, which pairs
|
|
683
|
+
* each one with the `pnpm.*` manifest key `stripPrunedLockfilePnpmConfig` drops
|
|
684
|
+
* from the emitted `package.json`, so the two strips cannot drift.
|
|
685
|
+
*
|
|
686
|
+
* `patchedDependencies` is kept, but scoped to the patches whose package
|
|
687
|
+
* survives the prune: an entry for a dropped package has no snapshot to attach
|
|
688
|
+
* to and aborts the install with a config mismatch. The `.patch` files and the
|
|
689
|
+
* matching config are carried into the pruned output separately (see
|
|
690
|
+
* `getPrunedPnpmPatchArtifacts` in pruned-output).
|
|
691
|
+
*/
|
|
692
|
+
function stripStandaloneLockfileConfig(lockfile) {
|
|
693
|
+
// `catalogs` is absent from the Lockfile type but present in pnpm 10+ files.
|
|
694
|
+
const config = lockfile;
|
|
695
|
+
for (const field of pruned_output_1.PNPM_LOCKFILE_RESOLUTION_CONFIG_FIELDS) {
|
|
696
|
+
delete config[field];
|
|
697
|
+
}
|
|
698
|
+
filterPatchedDependenciesToPrunedPackages(lockfile);
|
|
699
|
+
}
|
|
700
|
+
/**
|
|
701
|
+
* Drops `patchedDependencies` entries whose package is no longer in the pruned
|
|
702
|
+
* lockfile. pnpm matches each entry against an installed package, so a dangling
|
|
703
|
+
* entry aborts `pnpm install --frozen-lockfile` with a config mismatch.
|
|
704
|
+
*
|
|
705
|
+
* A patch key is `name`, `name@version`, or `name@range` (pnpm records the key
|
|
706
|
+
* verbatim, so a range key stays a range). Package keys are always versioned
|
|
707
|
+
* (`name@version`, with an optional `(peer@ver)`/`(patch_hash=...)` suffix), so
|
|
708
|
+
* matching mirrors `findPatchHash`: a name-only key matches any surviving
|
|
709
|
+
* version, otherwise the resolved version must equal the key's version or
|
|
710
|
+
* satisfy its range.
|
|
711
|
+
*/
|
|
712
|
+
function filterPatchedDependenciesToPrunedPackages(lockfile) {
|
|
713
|
+
if (!lockfile.patchedDependencies) {
|
|
714
|
+
return;
|
|
715
|
+
}
|
|
716
|
+
const packageKeys = Object.keys(lockfile.packages ?? {});
|
|
717
|
+
for (const patchKey of Object.keys(lockfile.patchedDependencies)) {
|
|
718
|
+
if (!patchKeyMatchesPrunedPackage(patchKey, packageKeys)) {
|
|
719
|
+
delete lockfile.patchedDependencies[patchKey];
|
|
720
|
+
continue;
|
|
721
|
+
}
|
|
722
|
+
// pnpm 9-10 record the patch path in the lockfile (object form), and pnpm
|
|
723
|
+
// --frozen-lockfile aborts with ERR_PNPM_LOCKFILE_CONFIG_MISMATCH when it
|
|
724
|
+
// disagrees with the emitted config. Rewrite it to the same `patches/<...>`
|
|
725
|
+
// path the pruned output ships via the shared `normalizePrunedPatchPath`, so
|
|
726
|
+
// the lockfile and the config stay identical. pnpm 11 records a bare hash, so
|
|
727
|
+
// there is no path.
|
|
728
|
+
const entry = lockfile.patchedDependencies[patchKey];
|
|
729
|
+
if (entry && typeof entry === 'object' && 'path' in entry) {
|
|
730
|
+
const patch = entry;
|
|
731
|
+
patch.path = (0, pruned_output_1.normalizePrunedPatchPath)(patch.path);
|
|
732
|
+
}
|
|
733
|
+
}
|
|
734
|
+
if (Object.keys(lockfile.patchedDependencies).length === 0) {
|
|
735
|
+
delete lockfile.patchedDependencies;
|
|
736
|
+
}
|
|
737
|
+
}
|
|
738
|
+
/**
|
|
739
|
+
* Whether a `patchedDependencies` key still targets a package that survived the
|
|
740
|
+
* prune. Decomposes both the key and each package key into name + version and
|
|
741
|
+
* applies the same exact/range/name-only rules as `findPatchHash`.
|
|
742
|
+
*/
|
|
743
|
+
function patchKeyMatchesPrunedPackage(patchKey, packageKeys) {
|
|
744
|
+
const patchName = extractNameFromKey(patchKey, false);
|
|
745
|
+
const versionSpec = patchName === patchKey ? null : getVersion(patchKey, patchName);
|
|
746
|
+
return packageKeys.some((key) => {
|
|
747
|
+
if (extractNameFromKey(key, false) !== patchName) {
|
|
748
|
+
return false;
|
|
749
|
+
}
|
|
750
|
+
// Strip any `(peer@ver)`/`(patch_hash=...)` suffix to get the resolved version.
|
|
751
|
+
const version = getVersion(key, patchName).split('(')[0];
|
|
752
|
+
// A `file:` directory package is a copied workspace module, never the target
|
|
753
|
+
// of a patchedDependencies entry (which patches a versioned npm package); a
|
|
754
|
+
// name-only patch key must not latch onto a same-named workspace module.
|
|
755
|
+
if (version.startsWith('file:')) {
|
|
756
|
+
return false;
|
|
757
|
+
}
|
|
758
|
+
if (versionSpec === null) {
|
|
759
|
+
return true;
|
|
760
|
+
}
|
|
761
|
+
if (version === versionSpec) {
|
|
762
|
+
return true;
|
|
763
|
+
}
|
|
764
|
+
try {
|
|
765
|
+
return ((0, semver_1.validRange)(versionSpec) !== null && (0, semver_1.satisfies)(version, versionSpec));
|
|
766
|
+
}
|
|
767
|
+
catch {
|
|
768
|
+
return false;
|
|
769
|
+
}
|
|
770
|
+
});
|
|
771
|
+
}
|
|
466
772
|
function mapSnapshots(packages, packageIndex, nodes, lockfileVersion) {
|
|
467
773
|
const result = {};
|
|
468
774
|
Object.values(nodes).forEach((node) => {
|
|
@@ -535,8 +841,12 @@ function findOriginalKeys(packages, packageIndex, node, lockfileVersion, { retur
|
|
|
535
841
|
: Object.entries(packages);
|
|
536
842
|
const matchedKeys = [];
|
|
537
843
|
for (const [key, snapshot] of candidates) {
|
|
538
|
-
// tarball package
|
|
539
|
-
|
|
844
|
+
// tarball package (legacy lockfile formats key these differently; on v9+ the
|
|
845
|
+
// version-keyed branch below returns the correct full `name@<spec>` key, so
|
|
846
|
+
// restricting this to <9 avoids emitting a duplicate, name-stripped key for
|
|
847
|
+
// file:/https: tarball packages).
|
|
848
|
+
if (lockfileVersion < 9 &&
|
|
849
|
+
key.startsWith(`${packageName}@${version}`) &&
|
|
540
850
|
snapshot.resolution?.['tarball']) {
|
|
541
851
|
matchedKeys.push([getVersion(key, packageName), snapshot]);
|
|
542
852
|
}
|
|
@@ -593,11 +903,10 @@ function versionIsAlias(key, versionExpr, lockfileVersion) {
|
|
|
593
903
|
? key.startsWith(`${packageName}/${version}`)
|
|
594
904
|
: key.startsWith(`${packageName}@${version}`);
|
|
595
905
|
}
|
|
596
|
-
function mapRootSnapshot(packageJson, rootImporters, packages, packageIndex, graph, lockfileVersion, workspaceRoot) {
|
|
597
|
-
const
|
|
906
|
+
function mapRootSnapshot(packageJson, rootImporters, packages, packageIndex, graph, workspaceModules, lockfileVersion, workspaceRoot) {
|
|
907
|
+
const catalogManager = (0, catalog_1.getCatalogManager)(workspaceRoot);
|
|
598
908
|
const snapshot = { specifiers: {} };
|
|
599
909
|
const importers = {};
|
|
600
|
-
const manager = (0, catalog_1.getCatalogManager)(workspaceRoot);
|
|
601
910
|
[
|
|
602
911
|
'dependencies',
|
|
603
912
|
'optionalDependencies',
|
|
@@ -607,43 +916,90 @@ function mapRootSnapshot(packageJson, rootImporters, packages, packageIndex, gra
|
|
|
607
916
|
if (packageJson[depType]) {
|
|
608
917
|
Object.keys(packageJson[depType]).forEach((packageName) => {
|
|
609
918
|
let version = packageJson[depType][packageName];
|
|
610
|
-
if (
|
|
611
|
-
|
|
612
|
-
if (!
|
|
919
|
+
if (catalogManager?.isCatalogReference(version)) {
|
|
920
|
+
const resolved = catalogManager.resolveCatalogReference(workspaceRoot, packageName, version);
|
|
921
|
+
if (!resolved) {
|
|
613
922
|
throw new Error(`Could not resolve catalog reference for package ${packageName}@${version}.`);
|
|
614
923
|
}
|
|
924
|
+
version = resolved;
|
|
615
925
|
}
|
|
616
926
|
if (workspaceModules.has(packageName)) {
|
|
927
|
+
// The app may declare the module under dependencies,
|
|
928
|
+
// optionalDependencies, devDependencies, or peerDependencies. Route
|
|
929
|
+
// the lockfile entry into the matching section; peerDependencies
|
|
930
|
+
// collapse to dependencies to match the pruned manifest, which moves a
|
|
931
|
+
// peer-declared workspace module into dependencies (pnpm rejects a
|
|
932
|
+
// file: spec under peerDependencies).
|
|
933
|
+
const targetSection = depType === 'optionalDependencies'
|
|
934
|
+
? 'optionalDependencies'
|
|
935
|
+
: depType === 'devDependencies'
|
|
936
|
+
? 'devDependencies'
|
|
937
|
+
: 'dependencies';
|
|
938
|
+
let importerKeyForPackage;
|
|
617
939
|
for (const [importerPath, importerSnapshot] of Object.entries(rootImporters)) {
|
|
618
|
-
const workspaceDep = importerSnapshot.dependencies &&
|
|
619
|
-
importerSnapshot.dependencies[packageName]
|
|
940
|
+
const workspaceDep = (importerSnapshot.dependencies &&
|
|
941
|
+
importerSnapshot.dependencies[packageName]) ||
|
|
942
|
+
(importerSnapshot.optionalDependencies &&
|
|
943
|
+
importerSnapshot.optionalDependencies[packageName]) ||
|
|
944
|
+
(importerSnapshot.devDependencies &&
|
|
945
|
+
importerSnapshot.devDependencies[packageName]);
|
|
620
946
|
if (workspaceDep) {
|
|
621
|
-
|
|
622
|
-
const importerKeyForPackage = (0, path_1.join)(importerPath, workspaceDepImporterPath);
|
|
623
|
-
importers[packageName] = importerKeyForPackage;
|
|
624
|
-
snapshot.specifiers[packageName] =
|
|
625
|
-
`file:./workspace_modules/${packageName}`;
|
|
626
|
-
snapshot.dependencies = snapshot.dependencies || {};
|
|
627
|
-
snapshot.dependencies[packageName] =
|
|
628
|
-
`link:./workspace_modules/${packageName}`;
|
|
947
|
+
importerKeyForPackage = (0, path_1.join)(importerPath, workspaceDep.replace('link:', ''));
|
|
629
948
|
break;
|
|
630
949
|
}
|
|
631
950
|
}
|
|
951
|
+
// pnpm records no importer entry for a workspace peer when
|
|
952
|
+
// autoInstallPeers is off, so fall back to the module's own root. The
|
|
953
|
+
// pruned manifest still moves the peer into dependencies, so the root
|
|
954
|
+
// importer must reference its directory package either way.
|
|
955
|
+
importerKeyForPackage ??=
|
|
956
|
+
workspaceModules.get(packageName)?.data.root;
|
|
957
|
+
if (importerKeyForPackage) {
|
|
958
|
+
importers[packageName] = importerKeyForPackage;
|
|
959
|
+
// Specifier matches the app manifest's file: ref; the version is
|
|
960
|
+
// the directory package key's ref (no leading `./`).
|
|
961
|
+
snapshot.specifiers[packageName] =
|
|
962
|
+
`file:./workspace_modules/${packageName}`;
|
|
963
|
+
snapshot[targetSection] = snapshot[targetSection] || {};
|
|
964
|
+
snapshot[targetSection][packageName] =
|
|
965
|
+
`file:workspace_modules/${packageName}`;
|
|
966
|
+
}
|
|
632
967
|
}
|
|
633
968
|
else {
|
|
634
|
-
|
|
969
|
+
let node = graph.externalNodes[`npm:${packageName}@${version}`] ||
|
|
635
970
|
(graph.externalNodes[`npm:${packageName}`] &&
|
|
636
971
|
graph.externalNodes[`npm:${packageName}`].data.version === version
|
|
637
972
|
? graph.externalNodes[`npm:${packageName}`]
|
|
638
973
|
: (0, project_graph_pruning_1.findNodeMatchingVersion)(graph, packageName, version));
|
|
974
|
+
// A file:/link: local-path dependency records a path where a version
|
|
975
|
+
// would go, so the lookups above never match it; findLocalPathNode
|
|
976
|
+
// matches it on that path instead.
|
|
977
|
+
if (!node && (0, project_graph_pruning_1.isLocalPathSpecifier)(version)) {
|
|
978
|
+
node = (0, project_graph_pruning_1.findLocalPathNode)(graph, packageName, version);
|
|
979
|
+
}
|
|
980
|
+
// peer dependencies are mapped to dependencies
|
|
981
|
+
const section = depType === 'peerDependencies' ? 'dependencies' : depType;
|
|
639
982
|
if (!node) {
|
|
983
|
+
if (version.startsWith('link:')) {
|
|
984
|
+
// A link: needs no packages: entry; emit the manifest value
|
|
985
|
+
// (relocated to its shipped location by the pre-lockfile rewrite)
|
|
986
|
+
// directly.
|
|
987
|
+
snapshot.specifiers[packageName] = version;
|
|
988
|
+
snapshot[section] = snapshot[section] || {};
|
|
989
|
+
snapshot[section][packageName] = version;
|
|
990
|
+
return;
|
|
991
|
+
}
|
|
640
992
|
throw new Error(`Could not find external node for package ${packageName}@${version}.`);
|
|
641
993
|
}
|
|
642
994
|
snapshot.specifiers[packageName] = version;
|
|
643
|
-
// peer dependencies are mapped to dependencies
|
|
644
|
-
let section = depType === 'peerDependencies' ? 'dependencies' : depType;
|
|
645
995
|
snapshot[section] = snapshot[section] || {};
|
|
646
|
-
|
|
996
|
+
// pnpm keys a package by its real name, so an aliased dependency's ref
|
|
997
|
+
// carries the full key rather than the bare version the name-sharing
|
|
998
|
+
// case uses. A local-path alias reaches here (an `npm:` one is matched
|
|
999
|
+
// as an alias and already keeps its key), and dropping the name would
|
|
1000
|
+
// leave the ref pointing at no entry in the packages section.
|
|
1001
|
+
const aliased = lockfileVersion >= 9 && node.data.packageName !== packageName;
|
|
1002
|
+
snapshot[section][packageName] = findOriginalKeys(packages, packageIndex, node, lockfileVersion, { returnFullKey: aliased })[0][0];
|
|
647
1003
|
}
|
|
648
1004
|
});
|
|
649
1005
|
}
|
|
@@ -1,11 +1,35 @@
|
|
|
1
1
|
import { ProjectGraph, ProjectGraphExternalNode, ProjectGraphProjectNode } from '../../../config/project-graph';
|
|
2
2
|
import { ProjectGraphBuilder } from '../../../project-graph/project-graph-builder';
|
|
3
3
|
import { PackageJson } from '../../../utils/package-json';
|
|
4
|
+
import { PackageManager } from '../../../utils/package-manager';
|
|
4
5
|
/**
|
|
5
6
|
* Prune project graph's external nodes and their dependencies
|
|
6
7
|
* based on the pruned package.json
|
|
7
8
|
*/
|
|
8
|
-
export declare function pruneProjectGraph(graph: ProjectGraph, prunedPackageJson: PackageJson, workspaceRootPath?: string): ProjectGraph;
|
|
9
|
+
export declare function pruneProjectGraph(graph: ProjectGraph, prunedPackageJson: PackageJson, workspaceRootPath?: string, packageManager?: PackageManager): ProjectGraph;
|
|
10
|
+
/**
|
|
11
|
+
* A `file:` (local tarball or directory) or `link:` specifier resolves to a
|
|
12
|
+
* single local package. pnpm records its path relative to the workspace root in
|
|
13
|
+
* the lockfile, while the manifest records it relative to the declaring package,
|
|
14
|
+
* so the two never match by string.
|
|
15
|
+
*/
|
|
16
|
+
export declare function isLocalPathSpecifier(versionExpr: string): boolean;
|
|
17
|
+
/**
|
|
18
|
+
* The external node for a `file:`/`link:` local-path dependency.
|
|
19
|
+
*
|
|
20
|
+
* The target path is what identifies one: an aliased dependency (`"alias":
|
|
21
|
+
* "file:libs/x"`) is keyed in the lockfile by the target's real package name, so
|
|
22
|
+
* the manifest's own name matches nothing. A manifest the pruned output already
|
|
23
|
+
* rewrote carries a workspace-root-relative path, relocated under the shipped
|
|
24
|
+
* output directory, which strips back to the path the lockfile records.
|
|
25
|
+
*
|
|
26
|
+
* A manifest that was not rewritten records the path relative to the declaring
|
|
27
|
+
* package instead, and this has no way to resolve that against the workspace
|
|
28
|
+
* root, so it falls back to the package name. Two local-path packages sharing a
|
|
29
|
+
* name cannot be told apart by it, so that throws rather than risking a match to
|
|
30
|
+
* the wrong one.
|
|
31
|
+
*/
|
|
32
|
+
export declare function findLocalPathNode(graph: ProjectGraph, packageName: string, versionExpr: string): ProjectGraphExternalNode | undefined;
|
|
9
33
|
export declare function findNodeMatchingVersion(graph: ProjectGraph, packageName: string, versionExpr: string): ProjectGraphExternalNode;
|
|
10
34
|
export declare function addNodesAndDependencies(graph: ProjectGraph, packageJsonDeps: Record<string, string>, workspacePackages: Map<string, ProjectGraphProjectNode>, builder: ProjectGraphBuilder): void;
|
|
11
35
|
export declare function rehoistNodes(graph: ProjectGraph, packageJsonDeps: Record<string, string>, builder: ProjectGraphBuilder): void;
|