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
|
@@ -14,6 +14,7 @@ export declare function loadPnpmHoistedDepsDefinition(): any;
|
|
|
14
14
|
* Parsing and mapping logic from pnpm lockfile `read` function
|
|
15
15
|
*/
|
|
16
16
|
export declare function parseAndNormalizePnpmLockfile(content: string): Lockfile;
|
|
17
|
+
export declare function extractMainLockfileDocument(content: string): string;
|
|
17
18
|
/**
|
|
18
19
|
* Mapping and writing logic from pnpm lockfile `write` function
|
|
19
20
|
*/
|
|
@@ -8,6 +8,7 @@ exports.isV5Syntax = isV5Syntax;
|
|
|
8
8
|
exports.usesLeadingDash = usesLeadingDash;
|
|
9
9
|
exports.loadPnpmHoistedDepsDefinition = loadPnpmHoistedDepsDefinition;
|
|
10
10
|
exports.parseAndNormalizePnpmLockfile = parseAndNormalizePnpmLockfile;
|
|
11
|
+
exports.extractMainLockfileDocument = extractMainLockfileDocument;
|
|
11
12
|
exports.stringifyToPnpmYaml = stringifyToPnpmYaml;
|
|
12
13
|
const node_fs_1 = require("node:fs");
|
|
13
14
|
const semver_1 = require("semver");
|
|
@@ -48,12 +49,16 @@ function parseAndNormalizePnpmLockfile(content) {
|
|
|
48
49
|
// https://github.com/pnpm/pnpm/blob/main/lockfile/fs/src/yamlDocuments.ts
|
|
49
50
|
const YAML_DOCUMENT_START = '---\n';
|
|
50
51
|
const YAML_DOCUMENT_SEPARATOR = '\n---\n';
|
|
51
|
-
// pnpm 11 writes a two-document lockfile when `
|
|
52
|
-
//
|
|
53
|
-
//
|
|
54
|
-
//
|
|
52
|
+
// pnpm 11 writes a two-document lockfile when `shouldPersistLockfile` holds
|
|
53
|
+
// (the package manager came from `devEngines`, or declares major 12 or above):
|
|
54
|
+
// the first document holds package-manager metadata, and the second holds the
|
|
55
|
+
// workspace lockfile. Mirror pnpm's own positional extraction so we always read
|
|
56
|
+
// the workspace document.
|
|
55
57
|
// https://github.com/pnpm/pnpm/blob/main/lockfile/fs/src/yamlDocuments.ts
|
|
56
58
|
function extractMainLockfileDocument(content) {
|
|
59
|
+
// Lockfiles written on Windows may use CRLF line endings, which would never
|
|
60
|
+
// match the LF-only document markers.
|
|
61
|
+
content = content.replace(/\r\n/g, '\n');
|
|
57
62
|
if (!content.startsWith(YAML_DOCUMENT_START)) {
|
|
58
63
|
return content;
|
|
59
64
|
}
|
|
@@ -664,7 +669,6 @@ function normalizeLockfile(lockfile, opts) {
|
|
|
664
669
|
if (!lockfileToSave.pnpmfileChecksum) {
|
|
665
670
|
delete lockfileToSave.pnpmfileChecksum;
|
|
666
671
|
}
|
|
667
|
-
delete lockfileToSave['catalogs'];
|
|
668
672
|
return lockfileToSave;
|
|
669
673
|
}
|
|
670
674
|
const ROOT_KEYS = [
|
|
@@ -13,6 +13,7 @@ const getTouchedNpmPackages = (touchedFiles, _, nxJson, packageJson, projectGrap
|
|
|
13
13
|
let touched = [];
|
|
14
14
|
const changes = packageJsonChange.getChanges();
|
|
15
15
|
const npmPackages = Object.values(projectGraph.externalNodes);
|
|
16
|
+
let packagesByName;
|
|
16
17
|
const missingTouchedNpmPackages = [];
|
|
17
18
|
for (const c of changes) {
|
|
18
19
|
if ((0, json_diff_1.isJsonChange)(c) &&
|
|
@@ -53,26 +54,20 @@ const getTouchedNpmPackages = (touchedFiles, _, nxJson, packageJson, projectGrap
|
|
|
53
54
|
(c.path[0] === 'overrides' ||
|
|
54
55
|
c.path[0] === 'resolutions' ||
|
|
55
56
|
(c.path[0] === 'pnpm' && c.path[1] === 'overrides'))) {
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
if ('packageName' in npmPackage.data &&
|
|
66
|
-
globalPackages.has(npmPackage.data.packageName)) {
|
|
67
|
-
return Object.keys(projectGraph.nodes);
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
else {
|
|
71
|
-
// If the package isn't found in external nodes, it might affect all projects
|
|
72
|
-
// since overrides can affect transitive dependencies
|
|
73
|
-
return Object.keys(projectGraph.nodes);
|
|
74
|
-
}
|
|
57
|
+
const packageSelector = getPackageSelector(c);
|
|
58
|
+
if (!packageSelector)
|
|
59
|
+
continue;
|
|
60
|
+
packagesByName ??= groupPackagesByName(npmPackages);
|
|
61
|
+
const matchingNpmPackages = findPackagesForSelector(packageSelector, packagesByName, c.path[0] === 'pnpm');
|
|
62
|
+
// An unresolved selector can still target a transitive dependency,
|
|
63
|
+
// so fall back to marking every project affected.
|
|
64
|
+
if (!matchingNpmPackages.length) {
|
|
65
|
+
return Object.keys(projectGraph.nodes);
|
|
75
66
|
}
|
|
67
|
+
if (matchingNpmPackages.some((pkg) => globalPackages.has(pkg.data.packageName))) {
|
|
68
|
+
return Object.keys(projectGraph.nodes);
|
|
69
|
+
}
|
|
70
|
+
touched.push(...matchingNpmPackages.map((pkg) => pkg.name));
|
|
76
71
|
}
|
|
77
72
|
else if ((0, file_utils_1.isWholeFileChange)(c)) {
|
|
78
73
|
// Whole file was touched, so all npm packages are touched.
|
|
@@ -83,9 +78,45 @@ const getTouchedNpmPackages = (touchedFiles, _, nxJson, packageJson, projectGrap
|
|
|
83
78
|
if (missingTouchedNpmPackages.length) {
|
|
84
79
|
logger_1.logger.warn(`The affected projects might have not been identified properly. The package(s) ${missingTouchedNpmPackages.join(', ')} were not found. Please open an issue in GitHub including the package.json file.`);
|
|
85
80
|
}
|
|
86
|
-
return touched;
|
|
81
|
+
return [...new Set(touched)];
|
|
87
82
|
};
|
|
88
83
|
exports.getTouchedNpmPackages = getTouchedNpmPackages;
|
|
84
|
+
function getPackageSelector(change) {
|
|
85
|
+
if (typeof change.value.lhs !== 'string' &&
|
|
86
|
+
typeof change.value.rhs !== 'string') {
|
|
87
|
+
return;
|
|
88
|
+
}
|
|
89
|
+
const selectorIndex = change.path[0] === 'pnpm' ? 2 : change.path.length - 1;
|
|
90
|
+
const selector = change.path[selectorIndex];
|
|
91
|
+
return selector === '.' ? change.path[selectorIndex - 1] : selector;
|
|
92
|
+
}
|
|
93
|
+
function groupPackagesByName(npmPackages) {
|
|
94
|
+
const packagesByName = new Map();
|
|
95
|
+
for (const pkg of npmPackages) {
|
|
96
|
+
const packageName = pkg.data.packageName;
|
|
97
|
+
if (!packageName)
|
|
98
|
+
continue;
|
|
99
|
+
const packages = packagesByName.get(packageName);
|
|
100
|
+
if (packages) {
|
|
101
|
+
packages.push(pkg);
|
|
102
|
+
}
|
|
103
|
+
else {
|
|
104
|
+
packagesByName.set(packageName, [pkg]);
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
return packagesByName;
|
|
108
|
+
}
|
|
109
|
+
function findPackagesForSelector(selector, packagesByName, isPnpmOverride) {
|
|
110
|
+
if (isPnpmOverride) {
|
|
111
|
+
// Pnpm does not treat `>` as a parent delimiter when it starts a range.
|
|
112
|
+
const parentDelimiterIndex = selector.search(/[^ |@]>/);
|
|
113
|
+
if (parentDelimiterIndex !== -1) {
|
|
114
|
+
selector = selector.slice(parentDelimiterIndex + 2);
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
const packageName = selector.match(/(?:^|\/)(@[^/@>\s]+\/[^/@>\s]+|[^/@>\s]+)(?:@[^/]*)?$/)?.[1];
|
|
118
|
+
return packageName ? (packagesByName.get(packageName) ?? []) : [];
|
|
119
|
+
}
|
|
89
120
|
function getGlobalPackages(plugins) {
|
|
90
121
|
return (plugins ?? [])
|
|
91
122
|
.map((p) => (0, get_package_name_from_import_path_1.getPackageNameFromImportPath)(typeof p === 'string' ? p : p.plugin))
|
|
@@ -8,6 +8,7 @@ const semver_1 = require("semver");
|
|
|
8
8
|
const find_project_for_path_1 = require("../../../../project-graph/utils/find-project-for-path");
|
|
9
9
|
const fileutils_1 = require("../../../../utils/fileutils");
|
|
10
10
|
const get_package_name_from_import_path_1 = require("../../../../utils/get-package-name-from-import-path");
|
|
11
|
+
const path_1 = require("../../../../utils/path");
|
|
11
12
|
const workspace_root_1 = require("../../../../utils/workspace-root");
|
|
12
13
|
const packages_1 = require("../../utils/packages");
|
|
13
14
|
const resolve_relative_to_dir_1 = require("../../utils/resolve-relative-to-dir");
|
|
@@ -161,11 +162,19 @@ class TargetProjectLocator {
|
|
|
161
162
|
return externalNodeName;
|
|
162
163
|
}
|
|
163
164
|
const version = (0, semver_1.clean)(externalPackageJson.version);
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
165
|
+
const isAliasImport = packageName !== externalPackageJson.name;
|
|
166
|
+
let matchingExternalNode = null;
|
|
167
|
+
if (isAliasImport) {
|
|
168
|
+
// Prefer the alias node when both the alias import and the resolved package
|
|
169
|
+
// exist in the graph, otherwise generated package.json files lose the alias key.
|
|
167
170
|
const aliasNpmProjectKey = `npm:${packageName}@npm:${externalPackageJson.name}@${version}`;
|
|
168
|
-
matchingExternalNode =
|
|
171
|
+
matchingExternalNode =
|
|
172
|
+
this.npmProjects[aliasNpmProjectKey] ??
|
|
173
|
+
this.npmProjects[`npm:${packageName}`];
|
|
174
|
+
}
|
|
175
|
+
if (!matchingExternalNode) {
|
|
176
|
+
matchingExternalNode =
|
|
177
|
+
this.npmProjects[`npm:${externalPackageJson.name}@${version}`];
|
|
169
178
|
}
|
|
170
179
|
if (!matchingExternalNode) {
|
|
171
180
|
// Fallback to package name as key. This can happen if the version in project graph is not the same as in the resolved package.json.
|
|
@@ -338,6 +347,7 @@ class TargetProjectLocator {
|
|
|
338
347
|
}));
|
|
339
348
|
}
|
|
340
349
|
findProjectOfResolvedModule(resolvedModule) {
|
|
350
|
+
resolvedModule = (0, path_1.normalizePath)(resolvedModule);
|
|
341
351
|
if (resolvedModule.startsWith('node_modules/') ||
|
|
342
352
|
resolvedModule.includes('/node_modules/')) {
|
|
343
353
|
return undefined;
|
|
@@ -7,5 +7,5 @@ export interface AffectedProjectGraphContext {
|
|
|
7
7
|
touchedProjects: string[];
|
|
8
8
|
}
|
|
9
9
|
export interface TouchedProjectLocator<T extends Change = Change> {
|
|
10
|
-
(fileChanges: FileChange<T>[], projectGraphNodes?: Record<string, ProjectGraphProjectNode>, nxJson?: NxJsonConfiguration<any>, packageJson?: any, projectGraph?: ProjectGraph): string[] | Promise<string[]>;
|
|
10
|
+
(fileChanges: FileChange<T>[], projectGraphNodes?: Record<string, ProjectGraphProjectNode>, nxJson?: NxJsonConfiguration<any>, packageJson?: any, projectGraph?: ProjectGraph, projectDeletionAffectsAllProjects?: boolean): string[] | Promise<string[]>;
|
|
11
11
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { FileChange } from '../file-utils';
|
|
2
2
|
import { NxJsonConfiguration } from '../../config/nx-json';
|
|
3
3
|
import { ProjectGraph } from '../../config/project-graph';
|
|
4
|
-
export declare function filterAffected(graph: ProjectGraph, touchedFiles: FileChange[], nxJson?: NxJsonConfiguration, packageJson?: any): Promise<ProjectGraph>;
|
|
4
|
+
export declare function filterAffected(graph: ProjectGraph, touchedFiles: FileChange[], nxJson?: NxJsonConfiguration, packageJson?: any, projectDeletionAffectsAllProjects?: boolean): Promise<ProjectGraph>;
|
|
@@ -7,7 +7,7 @@ const touched_projects_1 = require("../../plugins/js/project-graph/affected/touc
|
|
|
7
7
|
const operators_1 = require("../operators");
|
|
8
8
|
const configuration_1 = require("../../config/configuration");
|
|
9
9
|
const project_glob_changes_1 = require("./locators/project-glob-changes");
|
|
10
|
-
async function filterAffected(graph, touchedFiles, nxJson = (0, configuration_1.readNxJson)(), packageJson = (0, file_utils_1.readPackageJson)()) {
|
|
10
|
+
async function filterAffected(graph, touchedFiles, nxJson = (0, configuration_1.readNxJson)(), packageJson = (0, file_utils_1.readPackageJson)(), projectDeletionAffectsAllProjects = true) {
|
|
11
11
|
// Additional affected logic should be in this array.
|
|
12
12
|
const touchedProjectLocators = [
|
|
13
13
|
workspace_projects_1.getTouchedProjects,
|
|
@@ -18,7 +18,7 @@ async function filterAffected(graph, touchedFiles, nxJson = (0, configuration_1.
|
|
|
18
18
|
const touchedProjects = [];
|
|
19
19
|
for (const locator of touchedProjectLocators) {
|
|
20
20
|
performance.mark(locator.name + ':start');
|
|
21
|
-
const projects = await locator(touchedFiles, graph.nodes, nxJson, packageJson, graph);
|
|
21
|
+
const projects = await locator(touchedFiles, graph.nodes, nxJson, packageJson, graph, projectDeletionAffectsAllProjects);
|
|
22
22
|
performance.mark(locator.name + ':end');
|
|
23
23
|
performance.measure(locator.name, locator.name + ':start', locator.name + ':end');
|
|
24
24
|
touchedProjects.push(...projects);
|
|
@@ -9,7 +9,7 @@ const fs_1 = require("fs");
|
|
|
9
9
|
const retrieve_workspace_files_1 = require("../../utils/retrieve-workspace-files");
|
|
10
10
|
const globs_1 = require("../../../utils/globs");
|
|
11
11
|
const get_plugins_1 = require("../../plugins/get-plugins");
|
|
12
|
-
const getTouchedProjectsFromProjectGlobChanges = async (touchedFiles, projectGraphNodes) => {
|
|
12
|
+
const getTouchedProjectsFromProjectGlobChanges = async (touchedFiles, projectGraphNodes, _nxJson, _packageJson, _projectGraph, projectDeletionAffectsAllProjects = true) => {
|
|
13
13
|
const globPattern = await (async () => {
|
|
14
14
|
// TODO: We need a quicker way to get patterns that should not
|
|
15
15
|
// require starting up plugin workers
|
|
@@ -33,7 +33,10 @@ const getTouchedProjectsFromProjectGlobChanges = async (touchedFiles, projectGra
|
|
|
33
33
|
// If the file no longer exists on disk, then it was deleted
|
|
34
34
|
if (!(0, fs_1.existsSync)((0, path_1.join)(workspace_root_1.workspaceRoot, touchedFile.file))) {
|
|
35
35
|
// If any project has been deleted, we must assume all projects were affected
|
|
36
|
-
|
|
36
|
+
if (projectDeletionAffectsAllProjects) {
|
|
37
|
+
return Object.keys(projectGraphNodes);
|
|
38
|
+
}
|
|
39
|
+
continue;
|
|
37
40
|
}
|
|
38
41
|
// Modified project config files are under a project's root, and implicitly
|
|
39
42
|
// mark it as affected. Thus, we don't need to handle it here.
|
|
@@ -7,6 +7,7 @@ exports.applyProjectMetadata = applyProjectMetadata;
|
|
|
7
7
|
const fs_1 = require("fs");
|
|
8
8
|
const path_1 = require("path");
|
|
9
9
|
const perf_hooks_1 = require("perf_hooks");
|
|
10
|
+
const analytics_1 = require("../analytics");
|
|
10
11
|
const configuration_1 = require("../config/configuration");
|
|
11
12
|
const file_hasher_1 = require("../hasher/file-hasher");
|
|
12
13
|
const typescript_1 = require("../plugins/js/utils/typescript");
|
|
@@ -222,7 +223,12 @@ async function updateProjectGraphWithPlugins(context, initProjectGraph, plugins,
|
|
|
222
223
|
perf_hooks_1.performance.measure(`${plugin.name}:createDependencies`, {
|
|
223
224
|
start: `${plugin.name}:createDependencies - start`,
|
|
224
225
|
end: `${plugin.name}:createDependencies - end`,
|
|
225
|
-
detail: {
|
|
226
|
+
detail: {
|
|
227
|
+
track: true,
|
|
228
|
+
...(analytics_1.customDimensions && {
|
|
229
|
+
[analytics_1.customDimensions.sampleRate]: analytics_1.PERF_SPAN_SAMPLE_RATE,
|
|
230
|
+
}),
|
|
231
|
+
},
|
|
226
232
|
});
|
|
227
233
|
}));
|
|
228
234
|
perf_hooks_1.performance.mark('createDependencies:end');
|
|
@@ -3,6 +3,7 @@ import { ProjectConfiguration } from '../config/workspace-json-project-json';
|
|
|
3
3
|
import { CreateNodesFunction } from './plugins/public-api';
|
|
4
4
|
import { ConfigurationResult } from './utils/project-configuration-utils';
|
|
5
5
|
import type { ConfigurationSourceMaps } from './utils/project-configuration/source-maps';
|
|
6
|
+
import type { WorktreeConflictAdvice } from '../utils/git-worktrees';
|
|
6
7
|
export type ProjectGraphErrorTypes = AggregateCreateNodesError | MergeNodesError | CreateMetadataError | ProjectsWithNoNameError | MultipleProjectsWithSameNameError | ProcessDependenciesError | WorkspaceValidityError;
|
|
7
8
|
export declare class StaleProjectGraphCacheError extends Error {
|
|
8
9
|
constructor();
|
|
@@ -29,7 +30,17 @@ export declare class ProjectGraphError extends Error {
|
|
|
29
30
|
export declare class MultipleProjectsWithSameNameError extends Error {
|
|
30
31
|
conflicts: Map<string, string[]>;
|
|
31
32
|
projects: Record<string, ProjectConfiguration>;
|
|
32
|
-
|
|
33
|
+
/**
|
|
34
|
+
* Set when some of the duplicates come from git worktrees nested in the
|
|
35
|
+
* workspace, which is a different fix than renaming them.
|
|
36
|
+
*/
|
|
37
|
+
worktreeAdvice?: WorktreeConflictAdvice;
|
|
38
|
+
constructor(conflicts: Map<string, string[]>, projects: Record<string, ProjectConfiguration>,
|
|
39
|
+
/**
|
|
40
|
+
* Set when some of the duplicates come from git worktrees nested in the
|
|
41
|
+
* workspace, which is a different fix than renaming them.
|
|
42
|
+
*/
|
|
43
|
+
worktreeAdvice?: WorktreeConflictAdvice);
|
|
33
44
|
}
|
|
34
45
|
export declare class ProjectWithExistingNameError extends Error {
|
|
35
46
|
projectName: string;
|
|
@@ -92,19 +92,44 @@ class ProjectGraphError extends Error {
|
|
|
92
92
|
exports.ProjectGraphError = ProjectGraphError;
|
|
93
93
|
_ProjectGraphError_partialProjectGraph = new WeakMap(), _ProjectGraphError_partialSourceMaps = new WeakMap();
|
|
94
94
|
class MultipleProjectsWithSameNameError extends Error {
|
|
95
|
-
constructor(conflicts, projects
|
|
95
|
+
constructor(conflicts, projects,
|
|
96
|
+
/**
|
|
97
|
+
* Set when some of the duplicates come from git worktrees nested in the
|
|
98
|
+
* workspace, which is a different fix than renaming them.
|
|
99
|
+
*/
|
|
100
|
+
worktreeAdvice) {
|
|
96
101
|
super([
|
|
97
102
|
`The following projects are defined in multiple locations:`,
|
|
98
103
|
...Array.from(conflicts.entries()).map(([project, roots]) => [`- ${project}: `, ...roots.map((r) => ` - ${r}`)].join('\n')),
|
|
99
104
|
'',
|
|
100
|
-
|
|
105
|
+
...(worktreeAdvice?.ignoreTargets.length
|
|
106
|
+
? [
|
|
107
|
+
'Some of these are inside git worktrees nested in this workspace. A worktree is a full checkout, so every project in it collides with the one it was checked out from.',
|
|
108
|
+
'',
|
|
109
|
+
// Which `.gitignore` matters: a leading slash anchors to the
|
|
110
|
+
// directory holding the file, and these paths are relative to
|
|
111
|
+
// the workspace, which is not always the repository root.
|
|
112
|
+
'To fix those, add the following to the .gitignore in the workspace root:',
|
|
113
|
+
...worktreeAdvice.ignoreTargets.map((target) => ` ${target}`),
|
|
114
|
+
// Ignoring the worktrees settles only the duplicates they
|
|
115
|
+
// explain; anything left is an ordinary name collision and still
|
|
116
|
+
// needs the ordinary answer.
|
|
117
|
+
...(worktreeAdvice.explainsAllConflicts
|
|
118
|
+
? []
|
|
119
|
+
: ['', `The rest are not from worktrees. ${RENAME_ADVICE}`]),
|
|
120
|
+
]
|
|
121
|
+
: [
|
|
122
|
+
`To fix this, ${RENAME_ADVICE[0].toLowerCase()}${RENAME_ADVICE.slice(1)}`,
|
|
123
|
+
]),
|
|
101
124
|
].join('\n'));
|
|
102
125
|
this.conflicts = conflicts;
|
|
103
126
|
this.projects = projects;
|
|
127
|
+
this.worktreeAdvice = worktreeAdvice;
|
|
104
128
|
this.name = this.constructor.name;
|
|
105
129
|
}
|
|
106
130
|
}
|
|
107
131
|
exports.MultipleProjectsWithSameNameError = MultipleProjectsWithSameNameError;
|
|
132
|
+
const RENAME_ADVICE = "Set a unique name for each project in a project.json inside the project's root. If the project does not currently have a project.json, you can create one that contains only a name.";
|
|
108
133
|
class ProjectWithExistingNameError extends Error {
|
|
109
134
|
constructor(projectName, projectRoot) {
|
|
110
135
|
super(`The project "${projectName}" is defined in multiple locations.`);
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.IsolatedPlugin = void 0;
|
|
4
|
+
exports.getPluginWorkerSocketId = getPluginWorkerSocketId;
|
|
4
5
|
const child_process_1 = require("child_process");
|
|
6
|
+
const crypto_1 = require("crypto");
|
|
5
7
|
const net_1 = require("net");
|
|
6
8
|
const path = require("path");
|
|
7
9
|
const logger_1 = require("../../../daemon/logger");
|
|
@@ -12,6 +14,7 @@ const installation_directory_1 = require("../../../utils/installation-directory"
|
|
|
12
14
|
const logger_2 = require("../../../utils/logger");
|
|
13
15
|
const progress_topics_1 = require("../../../utils/progress-topics");
|
|
14
16
|
const wait_for_socket_connection_1 = require("../../../utils/wait-for-socket-connection");
|
|
17
|
+
const workspace_root_1 = require("../../../utils/workspace-root");
|
|
15
18
|
const resolve_plugin_1 = require("../resolve-plugin");
|
|
16
19
|
const messaging_1 = require("./messaging");
|
|
17
20
|
const plugin_lifecycle_manager_1 = require("./plugin-lifecycle-manager");
|
|
@@ -336,6 +339,10 @@ class IsolatedPlugin {
|
|
|
336
339
|
exports.IsolatedPlugin = IsolatedPlugin;
|
|
337
340
|
// --- Worker Spawning Utilities ---
|
|
338
341
|
global.nxPluginWorkerCount ??= 0;
|
|
342
|
+
function getPluginWorkerSocketId() {
|
|
343
|
+
const counter = global.nxPluginWorkerCount++;
|
|
344
|
+
return `${process.pid}-${counter.toString(36)}-${(0, crypto_1.randomBytes)(4).toString('hex')}`;
|
|
345
|
+
}
|
|
339
346
|
async function startPluginWorker(name) {
|
|
340
347
|
performance.mark(`start-plugin-worker:${name}`);
|
|
341
348
|
const isWorkerTypescript = path.extname(__filename) === '.ts';
|
|
@@ -352,7 +359,14 @@ async function startPluginWorker(name) {
|
|
|
352
359
|
}
|
|
353
360
|
: {}),
|
|
354
361
|
};
|
|
355
|
-
|
|
362
|
+
// Keep the host pid readable for diagnostics, the counter collision-free
|
|
363
|
+
// within this process, and entropy for a reused pid across process runs. The
|
|
364
|
+
// suffix is a base36 counter plus four random bytes: eleven characters after
|
|
365
|
+
// the pid until the counter passes 36, and fixed-length where the
|
|
366
|
+
// `performance.now()` stamp it replaced varied with process uptime. That
|
|
367
|
+
// keeps the socket path inside the 95-character budget `assertValidSocketPath`
|
|
368
|
+
// enforces.
|
|
369
|
+
const ipcPath = (0, socket_utils_1.getPluginOsSocketPath)(getPluginWorkerSocketId());
|
|
356
370
|
const worker = (0, child_process_1.spawn)(process.execPath, [
|
|
357
371
|
// Spawn the worker with the same resolve conditions Nx uses for plugin
|
|
358
372
|
// entries so the plugin's transitive workspace imports resolve to source.
|
|
@@ -361,6 +375,9 @@ async function startPluginWorker(name) {
|
|
|
361
375
|
workerPath,
|
|
362
376
|
ipcPath,
|
|
363
377
|
name,
|
|
378
|
+
// The host's root. The worker validates against this rather than re-resolving,
|
|
379
|
+
// so the two agree by construction.
|
|
380
|
+
workspace_root_1.workspaceRoot,
|
|
364
381
|
], {
|
|
365
382
|
stdio: ['ignore', 'pipe', 'pipe'],
|
|
366
383
|
env,
|
|
@@ -107,10 +107,23 @@ type PluginMessageDefs = DefineMessages<{
|
|
|
107
107
|
};
|
|
108
108
|
};
|
|
109
109
|
}>;
|
|
110
|
+
/**
|
|
111
|
+
* The sender's workspace root. Only the *worker* asserts on it, for host→worker
|
|
112
|
+
* messages; results and notifications carry the field but the host does not
|
|
113
|
+
* check it. The daemon channel is checked in the same one direction — the
|
|
114
|
+
* server validates inbound client messages and the client does not validate
|
|
115
|
+
* responses — so the two are alike rather than one being weaker.
|
|
116
|
+
* Optional and stamped centrally in `sendMessageOverSocket`, so the many
|
|
117
|
+
* message constructors need not set it; undefined is treated as not foreign,
|
|
118
|
+
* which is why this detects a shared socket directory rather than an attacker.
|
|
119
|
+
*/
|
|
120
|
+
export type WorkspaceStampedMessage = {
|
|
121
|
+
workspaceRoot?: string;
|
|
122
|
+
};
|
|
110
123
|
/** Union of all plugin worker message types */
|
|
111
|
-
export type PluginWorkerMessage = AllMessages<PluginMessageDefs
|
|
124
|
+
export type PluginWorkerMessage = AllMessages<PluginMessageDefs> & WorkspaceStampedMessage;
|
|
112
125
|
/** Union of all plugin worker result types */
|
|
113
|
-
export type PluginWorkerResult = AllResults<PluginMessageDefs
|
|
126
|
+
export type PluginWorkerResult = AllResults<PluginMessageDefs> & WorkspaceStampedMessage;
|
|
114
127
|
/** Result type for the load message */
|
|
115
128
|
export type PluginWorkerLoadResult = ResultOf<PluginMessageDefs, 'load'>;
|
|
116
129
|
/**
|
|
@@ -122,7 +135,7 @@ export type PluginWorkerEmitLogNotification = {
|
|
|
122
135
|
type: 'emitLog';
|
|
123
136
|
level: 'log' | 'warn' | 'error';
|
|
124
137
|
message: string;
|
|
125
|
-
};
|
|
138
|
+
} & WorkspaceStampedMessage;
|
|
126
139
|
export type PluginWorkerNotification = PluginWorkerEmitLogNotification;
|
|
127
140
|
export declare function isPluginWorkerNotification(message: Serializable): message is PluginWorkerNotification;
|
|
128
141
|
export declare function isPluginWorkerMessage(message: Serializable): message is PluginWorkerMessage;
|
|
@@ -7,6 +7,7 @@ exports.consumeMessage = consumeMessage;
|
|
|
7
7
|
exports.sendMessageOverSocket = sendMessageOverSocket;
|
|
8
8
|
const socket_utils_1 = require("../../../daemon/socket-utils");
|
|
9
9
|
const consume_messages_from_socket_1 = require("../../../utils/consume-messages-from-socket");
|
|
10
|
+
const workspace_root_1 = require("../../../utils/workspace-root");
|
|
10
11
|
const NOTIFICATION_TYPES = [
|
|
11
12
|
'emitLog',
|
|
12
13
|
];
|
|
@@ -81,6 +82,8 @@ async function consumeMessage(socket, raw, handlers) {
|
|
|
81
82
|
* Sends a message over the socket with proper formatting.
|
|
82
83
|
*/
|
|
83
84
|
function sendMessageOverSocket(socket, message) {
|
|
85
|
+
// Stamped here rather than in each constructor, mirroring the daemon.
|
|
86
|
+
message.workspaceRoot = workspace_root_1.workspaceRoot;
|
|
84
87
|
socket.write((0, socket_utils_1.serialize)(message));
|
|
85
88
|
socket.write(consume_messages_from_socket_1.MESSAGE_END_SEQ);
|
|
86
89
|
}
|
|
@@ -7,6 +7,7 @@ node_perf_hooks_1.performance.mark(`plugin worker ${process.pid} code loading --
|
|
|
7
7
|
const consume_messages_from_socket_1 = require("../../../utils/consume-messages-from-socket");
|
|
8
8
|
const logger_1 = require("../../../utils/logger");
|
|
9
9
|
const serializable_error_1 = require("../../../utils/serializable-error");
|
|
10
|
+
const daemon_message_1 = require("../../../daemon/message-types/daemon-message");
|
|
10
11
|
const messaging_1 = require("./messaging");
|
|
11
12
|
const worker_streaming_1 = require("./worker-streaming");
|
|
12
13
|
const fs_1 = require("fs");
|
|
@@ -23,6 +24,19 @@ global.NX_PLUGIN_WORKER = true;
|
|
|
23
24
|
let plugin;
|
|
24
25
|
const socketPath = process.argv[2];
|
|
25
26
|
const expectedPluginName = process.argv[3];
|
|
27
|
+
// The host's root, passed explicitly rather than re-resolved: a host that set
|
|
28
|
+
// its root at runtime would resolve a different one here and drop every
|
|
29
|
+
// legitimate message as foreign.
|
|
30
|
+
const hostWorkspaceRoot = process.argv[4];
|
|
31
|
+
// Positional, so inserting an argument host-side shifts all of them — and the
|
|
32
|
+
// symptom is silent and total: an undefined hostWorkspaceRoot makes every
|
|
33
|
+
// message look foreign while the host waits out its plugin timeout.
|
|
34
|
+
if (!socketPath || !expectedPluginName || !hostWorkspaceRoot) {
|
|
35
|
+
console.error(`[plugin-worker] started with an incomplete argument list ` +
|
|
36
|
+
`(socketPath=${socketPath}, pluginName=${expectedPluginName}, hostWorkspaceRoot=${hostWorkspaceRoot}). ` +
|
|
37
|
+
`This is an Nx bug — please report it at https://github.com/nrwl/nx/issues.`);
|
|
38
|
+
process.exit(1);
|
|
39
|
+
}
|
|
26
40
|
const CONNECT_TIMEOUT_MS = 30_000;
|
|
27
41
|
let connectErrorTimeout = setErrorTimeout(CONNECT_TIMEOUT_MS, `The plugin worker for ${expectedPluginName} is exiting as it was not connected to within ${CONNECT_TIMEOUT_MS / 1000} seconds. ` +
|
|
28
42
|
'Plugin workers expect to receive a socket connection from the parent process shortly after being started. ' +
|
|
@@ -45,6 +59,16 @@ const server = (0, net_1.createServer)((socket) => {
|
|
|
45
59
|
if (!(0, messaging_1.isPluginWorkerMessage)(message)) {
|
|
46
60
|
return;
|
|
47
61
|
}
|
|
62
|
+
// Same check the daemon applies to its own socket. Dropped rather than thrown:
|
|
63
|
+
// a stray foreign message must not kill a worker serving its host. The daemon
|
|
64
|
+
// has a response channel and surfaces it to the client instead.
|
|
65
|
+
try {
|
|
66
|
+
(0, daemon_message_1.assertNotForeignWorkspaceMessage)(message, hostWorkspaceRoot, `The Nx plugin worker "${expectedPluginName}" (pid: ${process.pid})`);
|
|
67
|
+
}
|
|
68
|
+
catch (e) {
|
|
69
|
+
logger_1.logger.verbose(`[plugin-worker] ignored a "${message.type}" message: ${e instanceof Error ? e.message : e}`);
|
|
70
|
+
return;
|
|
71
|
+
}
|
|
48
72
|
return (0, messaging_1.consumeMessage)(socket, message, {
|
|
49
73
|
load: async ({ plugin: pluginConfiguration, root, name, pluginPath, shouldRegisterTSTranspiler, }) => {
|
|
50
74
|
loadErrorTimeout?.clear();
|
|
@@ -104,8 +128,24 @@ const server = (0, net_1.createServer)((socket) => {
|
|
|
104
128
|
process.exit(0);
|
|
105
129
|
});
|
|
106
130
|
});
|
|
107
|
-
server.
|
|
108
|
-
|
|
131
|
+
server.on('error', (err) => {
|
|
132
|
+
// Without this the host only sees "exited before the connection was
|
|
133
|
+
// established"; the errno distinguishes a denied bind from EADDRINUSE.
|
|
134
|
+
console.error(`[plugin-worker] "${expectedPluginName}" (pid: ${process.pid}) failed to listen on ${socketPath}: ${err.message}`);
|
|
135
|
+
process.exit(1);
|
|
136
|
+
});
|
|
137
|
+
// A worker killed without its 'end' handler leaves the socket behind. Colliding
|
|
138
|
+
// takes a recycled host pid landing on the same counter *and* the same 4 random
|
|
139
|
+
// bytes; the random component is what this unlink rests on, and on Windows it is
|
|
140
|
+
// the only barrier, since the endpoint is a namespace object and the mode never
|
|
141
|
+
// applies. A failed bind surfaces through the error handler above.
|
|
142
|
+
try {
|
|
143
|
+
(0, fs_1.unlinkSync)(socketPath);
|
|
144
|
+
}
|
|
145
|
+
catch { }
|
|
146
|
+
server.listen(socketPath, () => {
|
|
147
|
+
logger_1.logger.verbose(`[plugin-worker] "${expectedPluginName}" (pid: ${process.pid}) listening on ${socketPath}`);
|
|
148
|
+
});
|
|
109
149
|
async function withErrorHandling(cb) {
|
|
110
150
|
try {
|
|
111
151
|
const result = await cb();
|
|
@@ -136,15 +176,25 @@ function setErrorTimeout(timeoutMs, errorMessage) {
|
|
|
136
176
|
},
|
|
137
177
|
};
|
|
138
178
|
}
|
|
139
|
-
const
|
|
179
|
+
const cleanup = () => {
|
|
140
180
|
server.close();
|
|
141
181
|
try {
|
|
142
182
|
(0, fs_1.unlinkSync)(socketPath);
|
|
143
183
|
}
|
|
144
184
|
catch (e) { }
|
|
145
|
-
process.exit(exitCode);
|
|
146
185
|
};
|
|
147
|
-
const events = ['SIGINT', 'SIGTERM', 'SIGQUIT'
|
|
148
|
-
events.forEach((event) => process.once(event,
|
|
149
|
-
|
|
150
|
-
process.
|
|
186
|
+
const events = ['SIGINT', 'SIGTERM', 'SIGQUIT'];
|
|
187
|
+
events.forEach((event) => process.once(event, () => {
|
|
188
|
+
cleanup();
|
|
189
|
+
process.exit(0);
|
|
190
|
+
}));
|
|
191
|
+
// Cleanup only: process.exit() here would override the real exit code.
|
|
192
|
+
process.once('exit', cleanup);
|
|
193
|
+
const fatalHandler = (error) => {
|
|
194
|
+
// Registering this handler suppresses Node's default reporting.
|
|
195
|
+
console.error(error);
|
|
196
|
+
cleanup();
|
|
197
|
+
process.exit(1);
|
|
198
|
+
};
|
|
199
|
+
process.once('uncaughtException', fatalHandler);
|
|
200
|
+
process.once('unhandledRejection', fatalHandler);
|
|
@@ -244,6 +244,7 @@ async function createProjectGraphAndSourceMapsAsync(opts = {
|
|
|
244
244
|
track: true,
|
|
245
245
|
...(analytics_1.customDimensions && {
|
|
246
246
|
[analytics_1.customDimensions.projectCount]: Object.keys(currentProjectGraph.nodes).length,
|
|
247
|
+
[analytics_1.customDimensions.sampleRate]: analytics_1.PERF_SPAN_SAMPLE_RATE,
|
|
247
248
|
}),
|
|
248
249
|
},
|
|
249
250
|
});
|
|
@@ -310,6 +311,7 @@ async function createProjectGraphAndSourceMapsAsync(opts = {
|
|
|
310
311
|
...(analytics_1.customDimensions && {
|
|
311
312
|
[analytics_1.customDimensions.projectCount]: Object.keys(res.projectGraph.nodes)
|
|
312
313
|
.length,
|
|
314
|
+
[analytics_1.customDimensions.sampleRate]: analytics_1.PERF_SPAN_SAMPLE_RATE,
|
|
313
315
|
}),
|
|
314
316
|
},
|
|
315
317
|
});
|
|
@@ -333,6 +335,7 @@ async function createProjectGraphAndSourceMapsAsync(opts = {
|
|
|
333
335
|
track: true,
|
|
334
336
|
...(analytics_1.customDimensions && {
|
|
335
337
|
[analytics_1.customDimensions.projectCount]: Object.keys(projectGraphAndSourceMaps.projectGraph.nodes).length,
|
|
338
|
+
[analytics_1.customDimensions.sampleRate]: analytics_1.PERF_SPAN_SAMPLE_RATE,
|
|
336
339
|
}),
|
|
337
340
|
},
|
|
338
341
|
});
|
|
@@ -351,6 +354,26 @@ async function createProjectGraphAndSourceMapsAsync(opts = {
|
|
|
351
354
|
(0, tmp_dir_1.markDaemonAsDisabled)(e.message);
|
|
352
355
|
return buildProjectGraphAndSourceMapsWithoutDaemon();
|
|
353
356
|
}
|
|
357
|
+
if (e.daemonPermissionError) {
|
|
358
|
+
// Deliberately not disabled: unlike the inotify limit above, a socket
|
|
359
|
+
// owned by someone else stops being there when it is removed or the
|
|
360
|
+
// machine reboots, and disabling until `nx reset` would outlive the
|
|
361
|
+
// cause and hide the fix from anyone who followed the advice.
|
|
362
|
+
// The first line carries the errno, and it is the one token that tells
|
|
363
|
+
// the two causes apart: EACCES is a socket owned by someone else (delete
|
|
364
|
+
// it), EPERM is a sandbox refusing the connect syscall (allow unix
|
|
365
|
+
// sockets under the Nx socket root). The message hedges between exactly
|
|
366
|
+
// those two because it cannot tell them apart, and this branch does not
|
|
367
|
+
// call writeDaemonLogs, so dropping the line loses the errno for good.
|
|
368
|
+
const [summary, ...details] = e.message.split('\n');
|
|
369
|
+
output_1.output.note({
|
|
370
|
+
title: `${summary} Continuing without the daemon.`,
|
|
371
|
+
// The blank line after the summary separates paragraphs when the
|
|
372
|
+
// message is printed as one blob; as bodyLines it is a leading gap.
|
|
373
|
+
bodyLines: details[0] === '' ? details.slice(1) : details,
|
|
374
|
+
});
|
|
375
|
+
return buildProjectGraphAndSourceMapsWithoutDaemon();
|
|
376
|
+
}
|
|
354
377
|
if (e.internalDaemonError) {
|
|
355
378
|
const errorLogFile = (0, tmp_dir_1.writeDaemonLogs)(e.message);
|
|
356
379
|
output_1.output.warn({
|
|
@@ -34,6 +34,7 @@ export declare function isUsageRef(value: unknown): value is UsageRef;
|
|
|
34
34
|
export declare class ProjectNameInNodePropsManager {
|
|
35
35
|
private getNameMap;
|
|
36
36
|
private pendingByName;
|
|
37
|
+
private nameHistory;
|
|
37
38
|
constructor(getNameMap?: () => Record<string, ProjectConfiguration>);
|
|
38
39
|
registerNameRefs(pluginResultProjects?: Record<string, Omit<ProjectConfiguration, 'root'> & Partial<ProjectConfiguration>>): void;
|
|
39
40
|
private processInputs;
|