@depup/nx 23.2.1-depup.8 → 23.3.0-depup.0
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 +7 -18
- package/changes.json +9 -53
- package/dist/bin/init-local.js +7 -1
- package/dist/nx-cloud-internals.d.ts +1 -0
- package/dist/nx-cloud-internals.js +9 -0
- package/dist/plugins/package-json.js +1 -1
- package/dist/src/command-line/add/add.js +5 -1
- package/dist/src/command-line/affected/affected.js +70 -9
- package/dist/src/command-line/affected/command-object.js +1 -1
- package/dist/src/command-line/format/format.js +2 -18
- package/dist/src/command-line/graph/graph.d.ts +31 -0
- package/dist/src/command-line/graph/graph.js +113 -20
- package/dist/src/command-line/init/implementation/add-nx-to-monorepo.js +0 -3
- package/dist/src/command-line/init/implementation/add-nx-to-nest.js +0 -3
- package/dist/src/command-line/init/implementation/add-nx-to-npm-repo.js +0 -3
- package/dist/src/command-line/init/implementation/angular/index.js +0 -3
- package/dist/src/command-line/init/implementation/angular/legacy-angular-versions.js +0 -3
- package/dist/src/command-line/init/implementation/format.js +2 -3
- package/dist/src/command-line/init/implementation/utils.d.ts +0 -1
- package/dist/src/command-line/init/implementation/utils.js +6 -9
- package/dist/src/command-line/init/init-v2.js +0 -3
- package/dist/src/command-line/migrate/agentic/capture-generator-output.d.ts +25 -0
- package/dist/src/command-line/migrate/agentic/capture-generator-output.js +121 -5
- package/dist/src/command-line/migrate/agentic/close-agent-session.d.ts +21 -0
- package/dist/src/command-line/migrate/agentic/close-agent-session.js +126 -0
- package/dist/src/command-line/migrate/agentic/definitions.d.ts +24 -0
- package/dist/src/command-line/migrate/agentic/definitions.js +79 -20
- package/dist/src/command-line/migrate/agentic/format-command.d.ts +14 -0
- package/dist/src/command-line/migrate/agentic/format-command.js +44 -0
- package/dist/src/command-line/migrate/agentic/handoff-gitignore.d.ts +3 -3
- package/dist/src/command-line/migrate/agentic/handoff-gitignore.js +3 -3
- package/dist/src/command-line/migrate/agentic/handoff.d.ts +50 -17
- package/dist/src/command-line/migrate/agentic/handoff.js +166 -24
- package/dist/src/command-line/migrate/agentic/instruction-files.d.ts +23 -0
- package/dist/src/command-line/migrate/agentic/instruction-files.js +41 -0
- package/dist/src/command-line/migrate/agentic/master/invocations.d.ts +12 -0
- package/dist/src/command-line/migrate/agentic/master/invocations.js +54 -0
- package/dist/src/command-line/migrate/agentic/master/run-master-session.d.ts +16 -0
- package/dist/src/command-line/migrate/agentic/master/run-master-session.js +175 -0
- package/dist/src/command-line/migrate/agentic/master/spawn-master.d.ts +31 -0
- package/dist/src/command-line/migrate/agentic/master/spawn-master.js +222 -0
- package/dist/src/command-line/migrate/agentic/prompts/final-validation.d.ts +13 -0
- package/dist/src/command-line/migrate/agentic/prompts/final-validation.js +41 -0
- package/dist/src/command-line/migrate/agentic/prompts/fragments.d.ts +17 -0
- package/dist/src/command-line/migrate/agentic/prompts/fragments.js +90 -0
- package/dist/src/command-line/migrate/agentic/prompts/generic-validation.js +4 -3
- package/dist/src/command-line/migrate/agentic/prompts/system-prompt.d.ts +25 -1
- package/dist/src/command-line/migrate/agentic/prompts/system-prompt.js +57 -34
- package/dist/src/command-line/migrate/agentic/run-step.js +28 -4
- package/dist/src/command-line/migrate/agentic/runner.d.ts +3 -15
- package/dist/src/command-line/migrate/agentic/runner.js +57 -239
- package/dist/src/command-line/migrate/agentic/terminal-repair.d.ts +1 -0
- package/dist/src/command-line/migrate/agentic/terminal-repair.js +27 -0
- package/dist/src/command-line/migrate/agentic/types.d.ts +23 -8
- package/dist/src/command-line/migrate/agentic/types.js +10 -7
- package/dist/src/command-line/migrate/agentic/windows-cmd.d.ts +33 -0
- package/dist/src/command-line/migrate/agentic/windows-cmd.js +88 -0
- package/dist/src/command-line/migrate/command-object.d.ts +2 -0
- package/dist/src/command-line/migrate/command-object.js +11 -1
- package/dist/src/command-line/migrate/deferred-output.d.ts +44 -0
- package/dist/src/command-line/migrate/deferred-output.js +92 -0
- package/dist/src/command-line/migrate/execute-migration.d.ts +9 -3
- package/dist/src/command-line/migrate/execute-migration.js +53 -16
- package/dist/src/command-line/migrate/migrate-analytics.d.ts +34 -9
- package/dist/src/command-line/migrate/migrate-analytics.js +71 -10
- package/dist/src/command-line/migrate/migrate-commits.d.ts +5 -4
- package/dist/src/command-line/migrate/migrate-commits.js +16 -6
- package/dist/src/command-line/migrate/migrate-config.d.ts +5 -2
- package/dist/src/command-line/migrate/migrate-config.js +19 -11
- package/dist/src/command-line/migrate/migrate-output.d.ts +3 -7
- package/dist/src/command-line/migrate/migrate-output.js +3 -7
- package/dist/src/command-line/migrate/migrate.d.ts +3 -0
- package/dist/src/command-line/migrate/migrate.js +183 -46
- package/dist/src/command-line/migrate/resolve-package-version.js +2 -19
- package/dist/src/command-line/migrate/run/agent-output.d.ts +11 -0
- package/dist/src/command-line/migrate/run/agent-output.js +21 -2
- package/dist/src/command-line/migrate/run/agent-work-payload.d.ts +37 -0
- package/dist/src/command-line/migrate/run/agent-work-payload.js +156 -0
- package/dist/src/command-line/migrate/run/atomic-write.d.ts +8 -0
- package/dist/src/command-line/migrate/run/atomic-write.js +17 -0
- package/dist/src/command-line/migrate/run/broker.d.ts +150 -0
- package/dist/src/command-line/migrate/run/broker.js +568 -0
- package/dist/src/command-line/migrate/run/clean-retry.d.ts +12 -0
- package/dist/src/command-line/migrate/run/clean-retry.js +99 -0
- package/dist/src/command-line/migrate/run/existing-run-report.d.ts +55 -0
- package/dist/src/command-line/migrate/run/existing-run-report.js +227 -0
- package/dist/src/command-line/migrate/run/give-up.d.ts +41 -0
- package/dist/src/command-line/migrate/run/give-up.js +148 -0
- package/dist/src/command-line/migrate/run/index.d.ts +9 -6
- package/dist/src/command-line/migrate/run/index.js +21 -2
- package/dist/src/command-line/migrate/run/issues.d.ts +127 -0
- package/dist/src/command-line/migrate/run/issues.js +1121 -0
- package/dist/src/command-line/migrate/run/orchestrator.d.ts +59 -1
- package/dist/src/command-line/migrate/run/orchestrator.js +1529 -457
- package/dist/src/command-line/migrate/run/run-id.d.ts +0 -8
- package/dist/src/command-line/migrate/run/run-id.js +0 -30
- package/dist/src/command-line/migrate/run/run-state.d.ts +77 -17
- package/dist/src/command-line/migrate/run/run-state.js +263 -32
- package/dist/src/command-line/migrate/run/runbook.d.ts +18 -0
- package/dist/src/command-line/migrate/run/runbook.js +118 -0
- package/dist/src/command-line/migrate/run/state-lock.d.ts +33 -2
- package/dist/src/command-line/migrate/run/state-lock.js +128 -2
- package/dist/src/command-line/migrate/run/state-machine.d.ts +50 -1
- package/dist/src/command-line/migrate/run/state-machine.js +339 -26
- package/dist/src/command-line/migrate/run/util.d.ts +3 -1
- package/dist/src/command-line/migrate/run/util.js +24 -3
- package/dist/src/command-line/migrate/run/worker.js +290 -129
- package/dist/src/command-line/migrate/step-actions.d.ts +1 -1
- package/dist/src/command-line/migrate/step-actions.js +7 -1
- package/dist/src/command-line/migrate/text.d.ts +6 -0
- package/dist/src/command-line/migrate/text.js +25 -0
- package/dist/src/command-line/migrate/version-skew-guard.js +2 -0
- package/dist/src/command-line/nx-cloud/connect/connect-to-nx-cloud.js +5 -11
- package/dist/src/command-line/release/publish.js +11 -8
- package/dist/src/command-line/release/utils/get-touched-projects-for-group.js +3 -3
- package/dist/src/command-line/release/utils/release-graph.js +1 -1
- package/dist/src/command-line/release/utils/remote-release-clients/github.js +5 -8
- package/dist/src/command-line/release/utils/remote-release-clients/gitlab.js +3 -3
- package/dist/src/command-line/release/utils/remote-release-clients/remote-release-client.d.ts +4 -2
- package/dist/src/command-line/release/utils/remote-release-clients/remote-release-client.js +37 -3
- package/dist/src/command-line/release/version/version-actions.d.ts +3 -0
- package/dist/src/command-line/reset/reset.js +10 -4
- package/dist/src/command-line/run/run-one.js +5 -1
- package/dist/src/command-line/run-many/run-many.js +6 -12
- package/dist/src/command-line/show/command-object.js +1 -1
- package/dist/src/command-line/show/projects.js +52 -1
- package/dist/src/command-line/yargs-utils/shared-options.d.ts +5 -1
- package/dist/src/command-line/yargs-utils/shared-options.js +38 -4
- package/dist/src/config/task-graph.d.ts +1 -1
- package/dist/src/config/workspace-json-project-json.d.ts +23 -1
- package/dist/src/core/graph/main.js +1 -1
- package/dist/src/core/graph/runtime.js +1 -1
- package/dist/src/core/graph/styles.js +1 -1
- package/dist/src/daemon/client/client.d.ts +14 -8
- package/dist/src/daemon/client/client.js +41 -12
- package/dist/src/daemon/message-types/get-plugin-capabilities.d.ts +5 -0
- package/dist/src/daemon/message-types/get-plugin-capabilities.js +11 -0
- package/dist/src/daemon/message-types/run-tasks-execution-hooks.d.ts +3 -2
- package/dist/src/daemon/message-types/select-affected-tasks.d.ts +21 -0
- package/dist/src/daemon/message-types/select-affected-tasks.js +11 -0
- package/dist/src/daemon/message-types/ultracache-configuration-version.d.ts +8 -0
- package/dist/src/daemon/message-types/ultracache-configuration-version.js +2 -0
- package/dist/src/daemon/server/dotenv-graph-changes.d.ts +1 -1
- package/dist/src/daemon/server/dotenv-graph-changes.js +2 -2
- package/dist/src/daemon/server/handle-get-plugin-capabilities.d.ts +2 -0
- package/dist/src/daemon/server/handle-get-plugin-capabilities.js +13 -0
- package/dist/src/daemon/server/handle-hash-tasks.d.ts +10 -2
- package/dist/src/daemon/server/handle-hash-tasks.js +18 -3
- package/dist/src/daemon/server/handle-select-affected-tasks.d.ts +3 -0
- package/dist/src/daemon/server/handle-select-affected-tasks.js +26 -0
- package/dist/src/daemon/server/handle-tasks-execution-hooks.d.ts +3 -2
- package/dist/src/daemon/server/{handle-outputs-changes.d.ts → handle-watch-events.d.ts} +4 -4
- package/dist/src/daemon/server/{handle-outputs-changes.js → handle-watch-events.js} +36 -37
- package/dist/src/daemon/server/outputs-tracking.d.ts +7 -19
- package/dist/src/daemon/server/outputs-tracking.js +7 -107
- package/dist/src/daemon/server/planning-context.d.ts +8 -0
- package/dist/src/daemon/server/planning-context.js +18 -0
- package/dist/src/daemon/server/project-graph-incremental-recomputation.d.ts +22 -7
- package/dist/src/daemon/server/project-graph-incremental-recomputation.js +104 -74
- package/dist/src/daemon/server/restart-checks.d.ts +22 -0
- package/dist/src/daemon/server/restart-checks.js +77 -0
- package/dist/src/daemon/server/server.d.ts +1 -0
- package/dist/src/daemon/server/server.js +54 -30
- package/dist/src/daemon/server/shutdown-utils.d.ts +0 -5
- package/dist/src/daemon/server/shutdown-utils.js +3 -26
- package/dist/src/daemon/server/ultracache-configuration-state.d.ts +7 -0
- package/dist/src/daemon/server/ultracache-configuration-state.js +36 -0
- package/dist/src/devkit-internals.d.ts +3 -1
- package/dist/src/devkit-internals.js +8 -3
- package/dist/src/executors/run-commands/run-commands.impl.d.ts +2 -1
- package/dist/src/executors/run-commands/run-commands.impl.js +19 -5
- package/dist/src/executors/run-commands/running-tasks.d.ts +5 -4
- package/dist/src/executors/run-commands/running-tasks.js +13 -13
- package/dist/src/hasher/create-task-hasher.d.ts +8 -1
- package/dist/src/hasher/create-task-hasher.js +13 -3
- package/dist/src/hasher/hash-plan-inspector.js +2 -2
- package/dist/src/hasher/hash-task.d.ts +2 -2
- package/dist/src/hasher/hash-task.js +28 -17
- package/dist/src/hasher/native-task-hasher-impl.d.ts +20 -4
- package/dist/src/hasher/native-task-hasher-impl.js +75 -9
- package/dist/src/hasher/task-hasher.d.ts +24 -7
- package/dist/src/hasher/task-hasher.js +27 -8
- package/dist/src/hasher/task-planning-context.d.ts +13 -0
- package/dist/src/hasher/task-planning-context.js +12 -0
- package/dist/src/native/index.d.ts +582 -21
- package/dist/src/native/index.js +3 -3
- package/dist/src/native/native-bindings.js +13 -1
- package/dist/src/native/nx.wasm32-wasi.debug.wasm +0 -0
- package/dist/src/native/nx.wasm32-wasi.wasm +0 -0
- package/dist/src/native/transform-objects.d.ts +11 -2
- package/dist/src/native/transform-objects.js +46 -0
- package/dist/src/nx-cloud/generators/connect-to-nx-cloud/connect-to-nx-cloud.js +15 -8
- package/dist/src/nx-cloud/update-manager.d.ts +3 -0
- package/dist/src/nx-cloud/update-manager.js +19 -13
- package/dist/src/nx-cloud/utilities/client.d.ts +1 -1
- package/dist/src/nx-cloud/utilities/client.js +1 -1
- package/dist/src/nx-cloud/utilities/is-workspace-claimed.js +2 -1
- package/dist/src/nx-cloud/utilities/nx-cloud-http-client.d.ts +5 -0
- package/dist/src/nx-cloud/utilities/nx-cloud-http-client.js +16 -0
- package/dist/src/nx-cloud/utilities/url-shorten.js +17 -10
- package/dist/src/plugins/js/index.js +45 -64
- package/dist/src/plugins/js/lock-file/lock-file.d.ts +4 -4
- package/dist/src/plugins/js/lock-file/lock-file.js +6 -7
- package/dist/src/plugins/js/lock-file/pnpm-parser.js +1 -1
- package/dist/src/plugins/js/lock-file/utils/pnpm-normalizer.d.ts +2 -0
- package/dist/src/plugins/js/lock-file/utils/pnpm-normalizer.js +22 -0
- package/dist/src/plugins/js/project-graph/affected/lock-file-changes.d.ts +10 -2
- package/dist/src/plugins/js/project-graph/affected/lock-file-changes.js +51 -29
- package/dist/src/plugins/js/project-graph/affected/npm-packages.d.ts +10 -2
- package/dist/src/plugins/js/project-graph/affected/npm-packages.js +32 -11
- package/dist/src/plugins/js/project-graph/build-dependencies/target-project-locator.js +22 -18
- package/dist/src/plugins/js/utils/register.js +13 -4
- package/dist/src/plugins/package-json/create-nodes.d.ts +2 -2
- package/dist/src/plugins/package-json/create-nodes.js +13 -13
- package/dist/src/project-graph/affected/affected-project-graph-models.d.ts +14 -0
- package/dist/src/project-graph/affected/affected-project-graph.js +5 -18
- package/dist/src/project-graph/affected/affected-projects.d.ts +7 -0
- package/dist/src/project-graph/affected/affected-projects.js +42 -0
- package/dist/src/project-graph/affected/affected-reasons.d.ts +116 -0
- package/dist/src/project-graph/affected/affected-reasons.js +459 -0
- package/dist/src/project-graph/affected/affected-tasks.d.ts +103 -0
- package/dist/src/project-graph/affected/affected-tasks.js +386 -0
- package/dist/src/project-graph/affected/print-explanation.d.ts +11 -0
- package/dist/src/project-graph/affected/print-explanation.js +44 -0
- package/dist/src/project-graph/error-types.d.ts +5 -0
- package/dist/src/project-graph/error-types.js +44 -5
- package/dist/src/project-graph/file-utils.d.ts +2 -0
- package/dist/src/project-graph/file-utils.js +12 -3
- package/dist/src/project-graph/nx-deps-cache.d.ts +5 -2
- package/dist/src/project-graph/nx-deps-cache.js +4 -4
- package/dist/src/project-graph/plugins/get-plugins.d.ts +3 -1
- package/dist/src/project-graph/plugins/get-plugins.js +60 -82
- package/dist/src/project-graph/plugins/in-process-loader.d.ts +1 -1
- package/dist/src/project-graph/plugins/in-process-loader.js +1 -4
- package/dist/src/project-graph/plugins/isolation/index.d.ts +1 -1
- package/dist/src/project-graph/plugins/isolation/index.js +3 -1
- package/dist/src/project-graph/plugins/isolation/isolated-plugin.d.ts +8 -0
- package/dist/src/project-graph/plugins/isolation/isolated-plugin.js +42 -6
- package/dist/src/project-graph/plugins/isolation/load-isolated-plugin.d.ts +10 -1
- package/dist/src/project-graph/plugins/isolation/load-isolated-plugin.js +67 -17
- package/dist/src/project-graph/plugins/isolation/messaging.d.ts +3 -2
- package/dist/src/project-graph/plugins/isolation/plugin-worker.js +5 -1
- package/dist/src/project-graph/plugins/loaded-nx-plugin.d.ts +5 -2
- package/dist/src/project-graph/plugins/loaded-nx-plugin.js +14 -1
- package/dist/src/project-graph/plugins/nx-plugin-capabilities.d.ts +6 -0
- package/dist/src/project-graph/plugins/nx-plugin-capabilities.js +28 -0
- package/dist/src/project-graph/plugins/task-results-stub.d.ts +50 -0
- package/dist/src/project-graph/plugins/task-results-stub.js +111 -0
- package/dist/src/project-graph/plugins/tasks-execution-hooks.d.ts +3 -2
- package/dist/src/project-graph/plugins/tasks-execution-hooks.js +14 -1
- package/dist/src/project-graph/project-graph.js +43 -42
- package/dist/src/project-graph/utils/project-configuration/target-merging.js +67 -0
- package/dist/src/project-graph/utils/project-configuration/target-normalization.js +83 -0
- package/dist/src/project-graph/utils/project-configuration/utils.d.ts +1 -0
- package/dist/src/project-graph/utils/project-configuration/utils.js +1 -0
- package/dist/src/tasks-runner/batch/run-batch.js +15 -0
- package/dist/src/tasks-runner/cache.d.ts +37 -2
- package/dist/src/tasks-runner/cache.js +42 -1
- package/dist/src/tasks-runner/create-task-graph.d.ts +24 -1
- package/dist/src/tasks-runner/create-task-graph.js +57 -2
- package/dist/src/tasks-runner/default-tasks-runner.js +1 -1
- package/dist/src/tasks-runner/forked-process-task-runner.d.ts +1 -1
- package/dist/src/tasks-runner/forked-process-task-runner.js +11 -10
- package/dist/src/tasks-runner/init-tasks-runner.d.ts +7 -2
- package/dist/src/tasks-runner/init-tasks-runner.js +15 -7
- package/dist/src/tasks-runner/is-tui-enabled.js +4 -3
- package/dist/src/tasks-runner/life-cycle.d.ts +7 -0
- package/dist/src/tasks-runner/life-cycle.js +7 -0
- package/dist/src/tasks-runner/life-cycles/summary-terminal-output-life-cycle.d.ts +35 -0
- package/dist/src/tasks-runner/life-cycles/summary-terminal-output-life-cycle.js +146 -0
- package/dist/src/tasks-runner/prune-task-graph.d.ts +17 -0
- package/dist/src/tasks-runner/prune-task-graph.js +45 -0
- package/dist/src/tasks-runner/run-command.d.ts +41 -5
- package/dist/src/tasks-runner/run-command.js +98 -22
- package/dist/src/tasks-runner/running-tasks/batch-process.d.ts +93 -19
- package/dist/src/tasks-runner/running-tasks/batch-process.js +184 -88
- package/dist/src/tasks-runner/task-io-service.d.ts +11 -3
- package/dist/src/tasks-runner/task-io-service.js +14 -5
- package/dist/src/tasks-runner/task-orchestrator.d.ts +71 -4
- package/dist/src/tasks-runner/task-orchestrator.js +266 -66
- package/dist/src/tasks-runner/tasks-runner.d.ts +2 -0
- package/dist/src/tasks-runner/terminal-output-path.d.ts +11 -0
- package/dist/src/tasks-runner/terminal-output-path.js +18 -0
- package/dist/src/tasks-runner/utils.d.ts +5 -0
- package/dist/src/tasks-runner/utils.js +14 -2
- package/dist/src/ultracache/config.d.ts +21 -0
- package/dist/src/ultracache/config.js +29 -0
- package/dist/src/ultracache/fetch.d.ts +21 -0
- package/dist/src/ultracache/fetch.js +43 -0
- package/dist/src/ultracache/overrides.d.ts +17 -0
- package/dist/src/ultracache/overrides.js +61 -0
- package/dist/src/ultracache/report.d.ts +13 -0
- package/dist/src/ultracache/report.js +62 -0
- package/dist/src/ultracache/store.d.ts +41 -0
- package/dist/src/ultracache/store.js +158 -0
- package/dist/src/utils/ab-testing.d.ts +4 -1
- package/dist/src/utils/ab-testing.js +22 -19
- package/dist/src/utils/chunkify.d.ts +1 -7
- package/dist/src/utils/chunkify.js +2 -8
- package/dist/src/utils/command-line-utils.d.ts +20 -0
- package/dist/src/utils/command-line-utils.js +10 -3
- package/dist/src/utils/create-cli-options.d.ts +6 -0
- package/dist/src/utils/create-cli-options.js +29 -0
- package/dist/src/utils/db-connection.d.ts +2 -0
- package/dist/src/utils/db-connection.js +2 -0
- package/dist/src/utils/formatters/index.d.ts +6 -0
- package/dist/src/utils/formatters/index.js +5 -0
- package/dist/src/utils/formatters/prettier.d.ts +0 -8
- package/dist/src/utils/formatters/prettier.js +4 -26
- package/dist/src/utils/git-utils.d.ts +19 -0
- package/dist/src/utils/git-utils.js +97 -39
- package/dist/src/utils/handle-errors.js +5 -43
- package/dist/src/utils/http-client.d.ts +27 -0
- package/dist/src/utils/http-client.js +193 -0
- package/dist/src/utils/installed-nx-version.js +2 -48
- package/dist/src/utils/json-diff.d.ts +4 -2
- package/dist/src/utils/json-diff.js +6 -94
- package/dist/src/utils/min-release-age/packument.js +1 -1
- package/dist/src/utils/nx-cloud-utils.d.ts +2 -0
- package/dist/src/utils/nx-cloud-utils.js +6 -1
- package/dist/src/utils/output.d.ts +22 -3
- package/dist/src/utils/output.js +28 -5
- package/dist/src/utils/package-json.d.ts +25 -0
- package/dist/src/utils/package-json.js +49 -6
- package/dist/src/utils/package-manager.d.ts +6 -0
- package/dist/src/utils/package-manager.js +10 -0
- package/dist/src/utils/plugins/plugin-capabilities.js +7 -2
- package/dist/src/utils/project-graph-utils.d.ts +2 -0
- package/dist/src/utils/project-graph-utils.js +12 -0
- package/dist/src/utils/provenance.js +20 -4
- package/dist/src/utils/serialize-overrides-into-command-line.js +2 -4
- package/dist/src/utils/workspace-context.d.ts +51 -3
- package/dist/src/utils/workspace-context.js +174 -10
- package/package.json +36 -98
- package/schemas/nx-schema.json +38 -0
- package/schemas/project-schema.json +35 -0
- package/dist/src/daemon/server/file-watching/route-workspace-changes.d.ts +0 -9
- package/dist/src/daemon/server/file-watching/route-workspace-changes.js +0 -76
- package/dist/src/daemon/server/watcher.d.ts +0 -18
- package/dist/src/daemon/server/watcher.js +0 -126
- package/dist/src/nx-cloud/utilities/axios.d.ts +0 -4
- package/dist/src/nx-cloud/utilities/axios.js +0 -17
- package/dist/src/project-graph/affected/locators/project-glob-changes.d.ts +0 -2
- package/dist/src/project-graph/affected/locators/project-glob-changes.js +0 -47
- package/dist/src/project-graph/affected/locators/workspace-json-changes.d.ts +0 -4
- package/dist/src/project-graph/affected/locators/workspace-json-changes.js +0 -47
- package/dist/src/project-graph/affected/locators/workspace-projects.d.ts +0 -3
- package/dist/src/project-graph/affected/locators/workspace-projects.js +0 -74
- package/dist/src/utils/collapse-expanded-outputs.d.ts +0 -10
- package/dist/src/utils/collapse-expanded-outputs.js +0 -72
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { NxJsonConfiguration, PluginConfiguration } from '../../config/nx-json';
|
|
2
|
+
import { type NxPluginCapabilities } from './nx-plugin-capabilities';
|
|
2
3
|
import type { LoadedNxPlugin } from './loaded-nx-plugin';
|
|
3
4
|
export interface SeparatedPlugins {
|
|
4
5
|
specifiedPlugins: LoadedNxPlugin[];
|
|
@@ -21,7 +22,7 @@ export declare function resetIsolationFallbackForTesting(): void;
|
|
|
21
22
|
* threw is rethrown, because rerunning it in-process would bury its actual
|
|
22
23
|
* error.
|
|
23
24
|
*/
|
|
24
|
-
export declare const loadingMethod: (plugin: PluginConfiguration, root: string, index?: number) => Promise<
|
|
25
|
+
export declare const loadingMethod: (plugin: PluginConfiguration, root: string, index?: number) => Promise<LoadedNxPlugin>;
|
|
25
26
|
/**
|
|
26
27
|
* Returns all plugins (specified + default) as a flat list.
|
|
27
28
|
* Specified plugins come first, followed by default plugins.
|
|
@@ -48,4 +49,5 @@ export declare function getOnlyDefaultPlugins(root?: string): Promise<LoadedNxPl
|
|
|
48
49
|
*/
|
|
49
50
|
export declare function getPluginsIfLoadedOrLoading(): Promise<LoadedNxPlugin[]> | undefined;
|
|
50
51
|
export declare function cleanupPlugins(): void;
|
|
52
|
+
export declare function capabilitiesOfConfiguredPlugins(nxJson: NxJsonConfiguration, root?: string): Promise<NxPluginCapabilities[]>;
|
|
51
53
|
export declare function reasonToError(reason: unknown): Error;
|
|
@@ -7,6 +7,7 @@ exports.getPluginsSeparated = getPluginsSeparated;
|
|
|
7
7
|
exports.getOnlyDefaultPlugins = getOnlyDefaultPlugins;
|
|
8
8
|
exports.getPluginsIfLoadedOrLoading = getPluginsIfLoadedOrLoading;
|
|
9
9
|
exports.cleanupPlugins = cleanupPlugins;
|
|
10
|
+
exports.capabilitiesOfConfiguredPlugins = capabilitiesOfConfiguredPlugins;
|
|
10
11
|
exports.reasonToError = reasonToError;
|
|
11
12
|
const node_path_1 = require("node:path");
|
|
12
13
|
const angular_json_1 = require("../../adapter/angular-json");
|
|
@@ -15,6 +16,9 @@ const workspace_root_1 = require("../../utils/workspace-root");
|
|
|
15
16
|
const in_process_loader_1 = require("./in-process-loader");
|
|
16
17
|
const isolation_1 = require("./isolation");
|
|
17
18
|
const resolve_plugin_1 = require("./resolve-plugin");
|
|
19
|
+
const is_on_daemon_1 = require("../../daemon/is-on-daemon");
|
|
20
|
+
const client_1 = require("../../daemon/client/client");
|
|
21
|
+
const nx_plugin_capabilities_1 = require("./nx-plugin-capabilities");
|
|
18
22
|
const enabled_1 = require("./isolation/enabled");
|
|
19
23
|
const isolated_plugin_1 = require("./isolation/isolated-plugin");
|
|
20
24
|
const sandbox_socket_hint_1 = require("../../daemon/sandbox-socket-hint");
|
|
@@ -26,10 +30,15 @@ const transpiler_1 = require("./transpiler");
|
|
|
26
30
|
* Stuff for specified NX Plugins.
|
|
27
31
|
*/
|
|
28
32
|
let currentPluginsConfigurationHash;
|
|
29
|
-
let loadedPlugins;
|
|
30
33
|
let cachedSeparatedPlugins;
|
|
31
34
|
let pendingPluginsPromise;
|
|
32
|
-
|
|
35
|
+
/** Workers aren't disposed here; the next load's `wantPlugins` sweeps the ones it no longer names. */
|
|
36
|
+
function forgetSpecifiedPlugins() {
|
|
37
|
+
if ((0, transpiler_1.pluginTranspilerIsRegistered)()) {
|
|
38
|
+
(0, transpiler_1.cleanupPluginTSTranspiler)();
|
|
39
|
+
}
|
|
40
|
+
pendingPluginsPromise = undefined;
|
|
41
|
+
}
|
|
33
42
|
// In-flight separated-plugins load, tagged with its hash. Two roles: a
|
|
34
43
|
// concurrent caller for the same set shares this load instead of racing a
|
|
35
44
|
// second one, and it gates the cache commit — a load writes the cache only if
|
|
@@ -74,11 +83,10 @@ const loadingMethod = async (plugin, root, index) => {
|
|
|
74
83
|
if (!(0, enabled_1.isIsolationEnabled)() || isolationRefusedInThisProcess) {
|
|
75
84
|
return (0, in_process_loader_1.loadNxPlugin)(plugin, root, index);
|
|
76
85
|
}
|
|
77
|
-
const [isolatedPlugin, cleanup] = await (0, isolation_1.loadIsolatedNxPlugin)(plugin, root, index);
|
|
78
86
|
// Awaited here rather than handed on, because the worker failure surfaces on
|
|
79
87
|
// this promise and the fallback has to happen before the caller sees it.
|
|
80
88
|
try {
|
|
81
|
-
return
|
|
89
|
+
return await (0, isolation_1.loadIsolatedNxPlugin)(plugin, root, index);
|
|
82
90
|
}
|
|
83
91
|
catch (e) {
|
|
84
92
|
// Proof, kept separate from policy. The errno the worker saw is what makes
|
|
@@ -92,7 +100,6 @@ const loadingMethod = async (plugin, root, index) => {
|
|
|
92
100
|
!((provenRefusal && (0, native_1.isAiAgent)()) || (0, is_sandbox_1.isSandbox)())) {
|
|
93
101
|
throw e;
|
|
94
102
|
}
|
|
95
|
-
cleanup();
|
|
96
103
|
// Read and set in one synchronous step. Concurrently loaded plugins each
|
|
97
104
|
// arrive here with their own failure, so testing the latch after setting it
|
|
98
105
|
// is what keeps the advice to one copy.
|
|
@@ -152,13 +159,9 @@ async function getPluginsSeparated(nxJson, root = workspace_root_1.workspaceRoot
|
|
|
152
159
|
if (pendingSeparatedPlugins?.hash === pluginsConfigurationHash) {
|
|
153
160
|
return pendingSeparatedPlugins.promise;
|
|
154
161
|
}
|
|
155
|
-
// Plugins config changed (e.g. `nx add @nx/maven`
|
|
156
|
-
//
|
|
157
|
-
|
|
158
|
-
// by the `??=` below and serve the previous plugin set forever. Tear
|
|
159
|
-
// down the old workers and force a fresh load.
|
|
160
|
-
cleanupSpecifiedPlugins?.();
|
|
161
|
-
pendingPluginsPromise = undefined;
|
|
162
|
+
// Plugins config changed (e.g. `nx add @nx/maven`): drop the in-flight load,
|
|
163
|
+
// or the `??=` below would serve the previous plugin set forever.
|
|
164
|
+
forgetSpecifiedPlugins();
|
|
162
165
|
const loadPromise = (async () => {
|
|
163
166
|
const results = await Promise.allSettled([
|
|
164
167
|
getOnlyDefaultPlugins(root),
|
|
@@ -188,7 +191,6 @@ async function getPluginsSeparated(nxJson, root = workspace_root_1.workspaceRoot
|
|
|
188
191
|
if (pendingSeparatedPlugins?.promise === loadPromise) {
|
|
189
192
|
cachedSeparatedPlugins = separatedPlugins;
|
|
190
193
|
currentPluginsConfigurationHash = pluginsConfigurationHash;
|
|
191
|
-
loadedPlugins = specifiedPlugins.concat(defaultPlugins);
|
|
192
194
|
}
|
|
193
195
|
return separatedPlugins;
|
|
194
196
|
})();
|
|
@@ -212,7 +214,6 @@ async function getPluginsSeparated(nxJson, root = workspace_root_1.workspaceRoot
|
|
|
212
214
|
*/
|
|
213
215
|
let loadedDefaultPlugins;
|
|
214
216
|
let loadedDefaultPluginsHash;
|
|
215
|
-
let cleanupDefaultPlugins;
|
|
216
217
|
let pendingDefaultPluginPromise;
|
|
217
218
|
async function getOnlyDefaultPlugins(root = workspace_root_1.workspaceRoot) {
|
|
218
219
|
const hash = root;
|
|
@@ -220,19 +221,15 @@ async function getOnlyDefaultPlugins(root = workspace_root_1.workspaceRoot) {
|
|
|
220
221
|
if (loadedDefaultPlugins && hash === loadedDefaultPluginsHash) {
|
|
221
222
|
return loadedDefaultPlugins;
|
|
222
223
|
}
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
224
|
+
const loadPromise = (pendingDefaultPluginPromise ??=
|
|
225
|
+
loadDefaultNxPlugins(workspace_root_1.workspaceRoot));
|
|
226
|
+
const result = await loadPromise;
|
|
227
|
+
// Commit only while this is still the registered load, so a set released while
|
|
228
|
+
// it was loading is not handed back out as the current one.
|
|
229
|
+
if (pendingDefaultPluginPromise === loadPromise) {
|
|
230
|
+
loadedDefaultPlugins = result;
|
|
231
|
+
loadedDefaultPluginsHash = hash;
|
|
226
232
|
}
|
|
227
|
-
pendingDefaultPluginPromise ??= loadDefaultNxPlugins(workspace_root_1.workspaceRoot);
|
|
228
|
-
const [result, cleanupFn] = await pendingDefaultPluginPromise;
|
|
229
|
-
cleanupDefaultPlugins = () => {
|
|
230
|
-
loadedDefaultPlugins = undefined;
|
|
231
|
-
pendingDefaultPluginPromise = undefined;
|
|
232
|
-
cleanupFn();
|
|
233
|
-
};
|
|
234
|
-
loadedDefaultPlugins = result;
|
|
235
|
-
loadedDefaultPluginsHash = hash;
|
|
236
233
|
return result;
|
|
237
234
|
}
|
|
238
235
|
/**
|
|
@@ -252,9 +249,9 @@ function getPluginsIfLoadedOrLoading() {
|
|
|
252
249
|
return Promise.resolve(separated).then(({ specifiedPlugins, defaultPlugins }) => specifiedPlugins.concat(defaultPlugins));
|
|
253
250
|
}
|
|
254
251
|
function cleanupPlugins() {
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
252
|
+
(0, isolation_1.disposeIsolatedPlugins)();
|
|
253
|
+
forgetSpecifiedPlugins();
|
|
254
|
+
loadedDefaultPlugins = undefined;
|
|
258
255
|
pendingDefaultPluginPromise = undefined;
|
|
259
256
|
cachedSeparatedPlugins = undefined;
|
|
260
257
|
// Drop the in-flight load too: clearing the marker flips its commit gate to
|
|
@@ -264,19 +261,38 @@ function cleanupPlugins() {
|
|
|
264
261
|
/**
|
|
265
262
|
* Stuff for generic loading
|
|
266
263
|
*/
|
|
264
|
+
function pluginLabel(plugin) {
|
|
265
|
+
return typeof plugin === 'string' ? plugin : plugin.plugin;
|
|
266
|
+
}
|
|
267
|
+
async function loadPlugins(loader, pluginConfigurations, root, assignIndexes) {
|
|
268
|
+
const loads = pluginConfigurations.map((plugin, index) => ({
|
|
269
|
+
plugin,
|
|
270
|
+
index: assignIndexes ? index : undefined,
|
|
271
|
+
}));
|
|
272
|
+
(0, isolation_1.wantPlugins)(loader, loads, root);
|
|
273
|
+
return Promise.allSettled(loads.map(async ({ plugin, index }) => {
|
|
274
|
+
const label = pluginLabel(plugin);
|
|
275
|
+
performance.mark(`Load Nx Plugin: ${label} - start`);
|
|
276
|
+
const res = await (0, exports.loadingMethod)(plugin, root, index);
|
|
277
|
+
performance.mark(`Load Nx Plugin: ${label} - end`);
|
|
278
|
+
performance.measure(`Load Nx Plugin: ${label}`, `Load Nx Plugin: ${label} - start`, `Load Nx Plugin: ${label} - end`);
|
|
279
|
+
return res;
|
|
280
|
+
}));
|
|
281
|
+
}
|
|
282
|
+
async function capabilitiesOfConfiguredPlugins(nxJson, root = workspace_root_1.workspaceRoot) {
|
|
283
|
+
if (!(0, is_on_daemon_1.isOnDaemon)() && (0, client_1.isDaemonEnabled)()) {
|
|
284
|
+
return client_1.daemonClient.getPluginCapabilities();
|
|
285
|
+
}
|
|
286
|
+
const recorded = (0, nx_plugin_capabilities_1.capabilitiesOfNxPluginsReadFromCache)();
|
|
287
|
+
if (recorded) {
|
|
288
|
+
return recorded;
|
|
289
|
+
}
|
|
290
|
+
return (await getPlugins(nxJson, root)).map((plugin) => plugin.capabilities());
|
|
291
|
+
}
|
|
267
292
|
async function loadDefaultNxPlugins(root = workspace_root_1.workspaceRoot) {
|
|
268
293
|
performance.mark('loadDefaultNxPlugins:start');
|
|
269
294
|
const plugins = getDefaultPlugins(root);
|
|
270
|
-
const
|
|
271
|
-
const results = await Promise.allSettled(plugins.map(async (plugin) => {
|
|
272
|
-
performance.mark(`Load Nx Plugin: ${plugin} - start`);
|
|
273
|
-
const [loadedPluginPromise, cleanup] = await (0, exports.loadingMethod)(plugin, root);
|
|
274
|
-
cleanupFunctions.push(cleanup);
|
|
275
|
-
const res = await loadedPluginPromise;
|
|
276
|
-
performance.mark(`Load Nx Plugin: ${plugin} - end`);
|
|
277
|
-
performance.measure(`Load Nx Plugin: ${plugin}`, `Load Nx Plugin: ${plugin} - start`, `Load Nx Plugin: ${plugin} - end`);
|
|
278
|
-
return res;
|
|
279
|
-
}));
|
|
295
|
+
const results = await loadPlugins('default', plugins, root, false);
|
|
280
296
|
const defaultPluginResults = [];
|
|
281
297
|
const errors = [];
|
|
282
298
|
for (let i = 0; i < results.length; i++) {
|
|
@@ -292,52 +308,25 @@ async function loadDefaultNxPlugins(root = workspace_root_1.workspaceRoot) {
|
|
|
292
308
|
}
|
|
293
309
|
}
|
|
294
310
|
if (errors.length > 0) {
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
}
|
|
311
|
+
// Cleared so the next call retries instead of re-awaiting this rejection.
|
|
312
|
+
pendingDefaultPluginPromise = undefined;
|
|
298
313
|
const errorMessage = errors
|
|
299
314
|
.map((e) => ` - ${e.pluginName}: ${e.error.message}`)
|
|
300
315
|
.join('\n');
|
|
301
316
|
throw new AggregateError(errors.map((e) => e.error), `Failed to load ${errors.length} default Nx plugin(s):\n${errorMessage}`);
|
|
302
317
|
}
|
|
303
|
-
const ret = [
|
|
304
|
-
defaultPluginResults,
|
|
305
|
-
() => {
|
|
306
|
-
for (const fn of cleanupFunctions) {
|
|
307
|
-
fn();
|
|
308
|
-
}
|
|
309
|
-
if ((0, transpiler_1.pluginTranspilerIsRegistered)()) {
|
|
310
|
-
(0, transpiler_1.cleanupPluginTSTranspiler)();
|
|
311
|
-
}
|
|
312
|
-
},
|
|
313
|
-
];
|
|
314
318
|
performance.mark('loadDefaultNxPlugins:end');
|
|
315
319
|
performance.measure('loadDefaultNxPlugins', 'loadDefaultNxPlugins:start', 'loadDefaultNxPlugins:end');
|
|
316
|
-
return
|
|
320
|
+
return defaultPluginResults;
|
|
317
321
|
}
|
|
318
322
|
async function loadSpecifiedNxPlugins(pluginsConfigurations, root = workspace_root_1.workspaceRoot) {
|
|
319
|
-
// Returning existing plugins is handled by getPlugins,
|
|
320
|
-
// so, if we are here and there are existing plugins, they are stale
|
|
321
|
-
if (cleanupSpecifiedPlugins) {
|
|
322
|
-
cleanupSpecifiedPlugins();
|
|
323
|
-
}
|
|
324
323
|
performance.mark('loadSpecifiedNxPlugins:start');
|
|
325
324
|
pluginsConfigurations ??= [];
|
|
326
325
|
// Drop the cached workspace-layout snapshot local-plugin resolution uses:
|
|
327
326
|
// in a long-lived daemon it can predate a newly added local plugin and
|
|
328
327
|
// resolve it to the workspace root. Runs only when the plugin set changed.
|
|
329
328
|
(0, resolve_plugin_1.resetResolvePluginCache)();
|
|
330
|
-
const
|
|
331
|
-
const results = await Promise.allSettled(pluginsConfigurations.map(async (plugin, index) => {
|
|
332
|
-
const pluginPath = typeof plugin === 'string' ? plugin : plugin.plugin;
|
|
333
|
-
performance.mark(`Load Nx Plugin: ${pluginPath} - start`);
|
|
334
|
-
const [loadedPluginPromise, cleanup] = await (0, exports.loadingMethod)(plugin, root, index);
|
|
335
|
-
cleanupFunctions.push(cleanup);
|
|
336
|
-
const res = await loadedPluginPromise;
|
|
337
|
-
performance.mark(`Load Nx Plugin: ${pluginPath} - end`);
|
|
338
|
-
performance.measure(`Load Nx Plugin: ${pluginPath}`, `Load Nx Plugin: ${pluginPath} - start`, `Load Nx Plugin: ${pluginPath} - end`);
|
|
339
|
-
return res;
|
|
340
|
-
}));
|
|
329
|
+
const results = await loadPlugins('specified', pluginsConfigurations, root, true);
|
|
341
330
|
performance.mark('loadSpecifiedNxPlugins:end');
|
|
342
331
|
performance.measure('loadSpecifiedNxPlugins', 'loadSpecifiedNxPlugins:start', 'loadSpecifiedNxPlugins:end');
|
|
343
332
|
const plugins = [];
|
|
@@ -357,23 +346,12 @@ async function loadSpecifiedNxPlugins(pluginsConfigurations, root = workspace_ro
|
|
|
357
346
|
}
|
|
358
347
|
}
|
|
359
348
|
if (errors.length > 0) {
|
|
360
|
-
|
|
361
|
-
fn();
|
|
362
|
-
}
|
|
349
|
+
// Wants are not retracted: a newer load may own the declaration by now.
|
|
363
350
|
const errorMessage = errors
|
|
364
351
|
.map((e) => ` - ${e.pluginName}: ${e.error.message}`)
|
|
365
352
|
.join('\n');
|
|
366
353
|
throw new AggregateError(errors.map((e) => e.error), `Failed to load ${errors.length} Nx plugin(s):\n${errorMessage}`);
|
|
367
354
|
}
|
|
368
|
-
cleanupSpecifiedPlugins = () => {
|
|
369
|
-
for (const fn of cleanupFunctions) {
|
|
370
|
-
fn();
|
|
371
|
-
}
|
|
372
|
-
if ((0, transpiler_1.pluginTranspilerIsRegistered)()) {
|
|
373
|
-
(0, transpiler_1.cleanupPluginTSTranspiler)();
|
|
374
|
-
}
|
|
375
|
-
pendingPluginsPromise = undefined;
|
|
376
|
-
};
|
|
377
355
|
return plugins;
|
|
378
356
|
}
|
|
379
357
|
function reasonToError(reason) {
|
|
@@ -6,5 +6,5 @@ export declare function readPluginPackageJson(pluginName: string, projects: Reco
|
|
|
6
6
|
path: string;
|
|
7
7
|
json: PackageJson;
|
|
8
8
|
};
|
|
9
|
-
export declare function loadNxPlugin(plugin: PluginConfiguration, root: string, index?: number):
|
|
9
|
+
export declare function loadNxPlugin(plugin: PluginConfiguration, root: string, index?: number): Promise<LoadedNxPlugin>;
|
|
10
10
|
export declare function loadNxPluginAsync(pluginConfiguration: PluginConfiguration, paths: string[], root: string, index?: number): Promise<LoadedNxPlugin>;
|
|
@@ -38,10 +38,7 @@ function readPluginPackageJson(pluginName, projects, paths = (0, installation_di
|
|
|
38
38
|
}
|
|
39
39
|
}
|
|
40
40
|
function loadNxPlugin(plugin, root, index) {
|
|
41
|
-
return
|
|
42
|
-
loadNxPluginAsync(plugin, (0, installation_directory_1.getNxRequirePaths)(root), root, index),
|
|
43
|
-
() => { },
|
|
44
|
-
];
|
|
41
|
+
return loadNxPluginAsync(plugin, (0, installation_directory_1.getNxRequirePaths)(root), root, index);
|
|
45
42
|
}
|
|
46
43
|
async function loadNxPluginAsync(pluginConfiguration, paths, root, index) {
|
|
47
44
|
const moduleName = typeof pluginConfiguration === 'string'
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export { loadIsolatedNxPlugin } from './load-isolated-plugin';
|
|
1
|
+
export { disposeIsolatedPlugins, loadIsolatedNxPlugin, wantPlugins, } from './load-isolated-plugin';
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.loadIsolatedNxPlugin = void 0;
|
|
3
|
+
exports.wantPlugins = exports.loadIsolatedNxPlugin = exports.disposeIsolatedPlugins = void 0;
|
|
4
4
|
var load_isolated_plugin_1 = require("./load-isolated-plugin");
|
|
5
|
+
Object.defineProperty(exports, "disposeIsolatedPlugins", { enumerable: true, get: function () { return load_isolated_plugin_1.disposeIsolatedPlugins; } });
|
|
5
6
|
Object.defineProperty(exports, "loadIsolatedNxPlugin", { enumerable: true, get: function () { return load_isolated_plugin_1.loadIsolatedNxPlugin; } });
|
|
7
|
+
Object.defineProperty(exports, "wantPlugins", { enumerable: true, get: function () { return load_isolated_plugin_1.wantPlugins; } });
|
|
@@ -4,6 +4,7 @@ import type { PluginConfiguration } from '../../../config/nx-json';
|
|
|
4
4
|
import type { ProjectGraph } from '../../../config/project-graph';
|
|
5
5
|
import type { RawProjectGraphDependency } from '../../project-graph-builder';
|
|
6
6
|
import { LoadedNxPlugin } from '../loaded-nx-plugin';
|
|
7
|
+
import type { NxPluginCapabilities } from '../nx-plugin-capabilities';
|
|
7
8
|
import type { CreateDependenciesContext, CreateMetadataContext, CreateNodesContext, CreateNodesResult, PostTasksExecutionContext, PreTasksExecutionContext, ProjectsMetadata } from '../public-api';
|
|
8
9
|
import type { PluginWorkerLoadResult } from './messaging';
|
|
9
10
|
import { Hook, Phase } from './plugin-lifecycle-manager';
|
|
@@ -26,6 +27,7 @@ export declare class IsolatedPlugin implements LoadedNxPlugin {
|
|
|
26
27
|
private worker;
|
|
27
28
|
private socket;
|
|
28
29
|
private _alive;
|
|
30
|
+
private _released;
|
|
29
31
|
private _connectPromise;
|
|
30
32
|
private txId;
|
|
31
33
|
private pendingCount;
|
|
@@ -41,6 +43,7 @@ export declare class IsolatedPlugin implements LoadedNxPlugin {
|
|
|
41
43
|
*/
|
|
42
44
|
static load(plugin: PluginConfiguration, root: string, index?: number): Promise<IsolatedPlugin>;
|
|
43
45
|
private constructor();
|
|
46
|
+
capabilities(): NxPluginCapabilities;
|
|
44
47
|
private spawnAndConnect;
|
|
45
48
|
/**
|
|
46
49
|
* Drops the worker from service without judging why. The next hook call
|
|
@@ -66,6 +69,11 @@ export declare class IsolatedPlugin implements LoadedNxPlugin {
|
|
|
66
69
|
private shutdownIfInactive;
|
|
67
70
|
setWorkerEnv(env: Record<string, string>): Promise<void>;
|
|
68
71
|
notifyPhaseAborted(phase: Phase, lastCompletedHook: Hook): void;
|
|
72
|
+
/**
|
|
73
|
+
* Like `shutdown`, but for good: a later hook call still answers, then shuts
|
|
74
|
+
* the worker back down instead of leaving a respawned one running.
|
|
75
|
+
*/
|
|
76
|
+
dispose(): void;
|
|
69
77
|
shutdown(): void;
|
|
70
78
|
private registerProcessMetrics;
|
|
71
79
|
}
|
|
@@ -20,6 +20,7 @@ const installation_directory_1 = require("../../../utils/installation-directory"
|
|
|
20
20
|
const is_sandbox_1 = require("../../../utils/is-sandbox");
|
|
21
21
|
const logger_2 = require("../../../utils/logger");
|
|
22
22
|
const progress_topics_1 = require("../../../utils/progress-topics");
|
|
23
|
+
const task_results_stub_1 = require("../task-results-stub");
|
|
23
24
|
const wait_for_socket_connection_1 = require("../../../utils/wait-for-socket-connection");
|
|
24
25
|
const workspace_root_1 = require("../../../utils/workspace-root");
|
|
25
26
|
const resolve_plugin_1 = require("../resolve-plugin");
|
|
@@ -43,9 +44,16 @@ class IsolatedPlugin {
|
|
|
43
44
|
const moduleName = typeof plugin === 'string' ? plugin : plugin.plugin;
|
|
44
45
|
const { name, pluginPath, shouldRegisterTSTranspiler } = await (0, resolve_plugin_1.resolveNxPlugin)(moduleName, root, (0, installation_directory_1.getNxRequirePaths)(root));
|
|
45
46
|
const instance = new IsolatedPlugin(plugin, root, name, pluginPath, shouldRegisterTSTranspiler, index);
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
47
|
+
try {
|
|
48
|
+
const loadResult = await instance.spawnAndConnect();
|
|
49
|
+
instance.setupHooks(loadResult);
|
|
50
|
+
return instance;
|
|
51
|
+
}
|
|
52
|
+
catch (e) {
|
|
53
|
+
// A timed-out worker is still running, and the caller is about to drop this instance.
|
|
54
|
+
instance.shutdown();
|
|
55
|
+
throw e;
|
|
56
|
+
}
|
|
49
57
|
}
|
|
50
58
|
constructor(plugin, root, name, pluginPath, shouldRegisterTSTranspiler, index) {
|
|
51
59
|
this.index = index;
|
|
@@ -53,6 +61,7 @@ class IsolatedPlugin {
|
|
|
53
61
|
this.worker = null;
|
|
54
62
|
this.socket = null;
|
|
55
63
|
this._alive = false;
|
|
64
|
+
this._released = false;
|
|
56
65
|
this._connectPromise = null;
|
|
57
66
|
this.txId = 0;
|
|
58
67
|
this.pendingCount = 0;
|
|
@@ -90,6 +99,15 @@ class IsolatedPlugin {
|
|
|
90
99
|
this.pluginPath = pluginPath;
|
|
91
100
|
this.shouldRegisterTSTranspiler = shouldRegisterTSTranspiler;
|
|
92
101
|
}
|
|
102
|
+
capabilities() {
|
|
103
|
+
return {
|
|
104
|
+
createNodesPattern: this.createNodes?.[0],
|
|
105
|
+
hasCreateDependencies: !!this.createDependencies,
|
|
106
|
+
hasCreateMetadata: !!this.createMetadata,
|
|
107
|
+
hasPreTasksExecution: !!this.preTasksExecution,
|
|
108
|
+
hasPostTasksExecution: !!this.postTasksExecution,
|
|
109
|
+
};
|
|
110
|
+
}
|
|
93
111
|
async spawnAndConnect() {
|
|
94
112
|
const { worker, socket } = await startPluginWorker(this.name);
|
|
95
113
|
this.worker = worker;
|
|
@@ -214,7 +232,15 @@ class IsolatedPlugin {
|
|
|
214
232
|
const shutdown = (hookName) => this.shutdownIfInactive(hookName);
|
|
215
233
|
const wrap = (hook, hookFn) => this.lifecycle.wrapHook(hook, async (...args) => {
|
|
216
234
|
await this.ensureAlive();
|
|
217
|
-
|
|
235
|
+
try {
|
|
236
|
+
return await hookFn(...args);
|
|
237
|
+
}
|
|
238
|
+
finally {
|
|
239
|
+
// A released plugin still answers, then shuts its worker straight back down.
|
|
240
|
+
if (this._released) {
|
|
241
|
+
shutdown(hook);
|
|
242
|
+
}
|
|
243
|
+
}
|
|
218
244
|
}, () => shutdown(hook));
|
|
219
245
|
if (loadResult.createNodesPattern) {
|
|
220
246
|
this.createNodes = [
|
|
@@ -268,7 +294,7 @@ class IsolatedPlugin {
|
|
|
268
294
|
if (loadResult.hasPostTasksExecution) {
|
|
269
295
|
this.postTasksExecution = wrap('postTasksExecution', async (context) => {
|
|
270
296
|
const result = await this.sendRequest('postTasksExecution', {
|
|
271
|
-
context,
|
|
297
|
+
context: (0, task_results_stub_1.stubTerminalOutputs)(context),
|
|
272
298
|
});
|
|
273
299
|
if (result.success === false) {
|
|
274
300
|
throw result.error;
|
|
@@ -338,8 +364,18 @@ class IsolatedPlugin {
|
|
|
338
364
|
this.shutdownIfInactive(lastCompletedHook);
|
|
339
365
|
}
|
|
340
366
|
}
|
|
367
|
+
/**
|
|
368
|
+
* Like `shutdown`, but for good: a later hook call still answers, then shuts
|
|
369
|
+
* the worker back down instead of leaving a respawned one running.
|
|
370
|
+
*/
|
|
371
|
+
dispose() {
|
|
372
|
+
this._released = true;
|
|
373
|
+
this.shutdown();
|
|
374
|
+
}
|
|
341
375
|
shutdown() {
|
|
342
|
-
|
|
376
|
+
// Not `_alive`: that is only set once the worker answers a load, so gating
|
|
377
|
+
// on it would leave a worker that never got that far running.
|
|
378
|
+
if (!this.worker && !this.socket)
|
|
343
379
|
return;
|
|
344
380
|
this._alive = false;
|
|
345
381
|
this._connectPromise = null;
|
|
@@ -1,3 +1,12 @@
|
|
|
1
1
|
import { PluginConfiguration } from '../../../config/nx-json';
|
|
2
2
|
import type { LoadedNxPlugin } from '../loaded-nx-plugin';
|
|
3
|
-
|
|
3
|
+
/**
|
|
4
|
+
* Declares a loader's plugins and disposes any no loader wants. Call before loading.
|
|
5
|
+
* Anything that makes a running worker unfit for reuse must be in its cache key.
|
|
6
|
+
*/
|
|
7
|
+
export declare function wantPlugins(loader: string, plugins: Array<{
|
|
8
|
+
plugin: PluginConfiguration;
|
|
9
|
+
index?: number;
|
|
10
|
+
}>, root: string): void;
|
|
11
|
+
export declare function disposeIsolatedPlugins(): void;
|
|
12
|
+
export declare function loadIsolatedNxPlugin(plugin: PluginConfiguration, root: string, index?: number): Promise<LoadedNxPlugin>;
|
|
@@ -1,24 +1,74 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.wantPlugins = wantPlugins;
|
|
4
|
+
exports.disposeIsolatedPlugins = disposeIsolatedPlugins;
|
|
3
5
|
exports.loadIsolatedNxPlugin = loadIsolatedNxPlugin;
|
|
4
6
|
const isolated_plugin_1 = require("./isolated-plugin");
|
|
5
|
-
const
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
7
|
+
const loadedPlugins = (global['nxLoadedPlugins'] ??= new Map());
|
|
8
|
+
/**
|
|
9
|
+
* Keys each loader last asked for; a sweep keeps their union. Global like
|
|
10
|
+
* `loadedPlugins`, or one copy of Nx would sweep another's workers.
|
|
11
|
+
*/
|
|
12
|
+
const wantedBy = (global['nxWantedPlugins'] ??=
|
|
13
|
+
new Map());
|
|
14
|
+
/**
|
|
15
|
+
* Declares a loader's plugins and disposes any no loader wants. Call before loading.
|
|
16
|
+
* Anything that makes a running worker unfit for reuse must be in its cache key.
|
|
17
|
+
*/
|
|
18
|
+
function wantPlugins(loader, plugins, root) {
|
|
19
|
+
wantedBy.set(loader, new Set(plugins.map(({ plugin, index }) => getCacheKey(plugin, root, index))));
|
|
20
|
+
sweep();
|
|
21
|
+
}
|
|
22
|
+
function disposeIsolatedPlugins() {
|
|
23
|
+
wantedBy.clear();
|
|
24
|
+
sweep();
|
|
25
|
+
}
|
|
26
|
+
function loadIsolatedNxPlugin(plugin, root, index) {
|
|
27
|
+
const cacheKey = getCacheKey(plugin, root, index);
|
|
28
|
+
return (loadedPlugins.get(cacheKey) ??
|
|
29
|
+
register(cacheKey, isolated_plugin_1.IsolatedPlugin.load(plugin, root, index)));
|
|
30
|
+
}
|
|
31
|
+
function register(cacheKey, loading) {
|
|
32
|
+
const entry = loading.then((plugin) => {
|
|
33
|
+
// Swept while loading: nothing names it any more.
|
|
34
|
+
if (!isWanted(cacheKey)) {
|
|
35
|
+
plugin.dispose();
|
|
36
|
+
}
|
|
37
|
+
return plugin;
|
|
38
|
+
}, (err) => {
|
|
39
|
+
forget(cacheKey, entry);
|
|
14
40
|
throw err;
|
|
15
41
|
});
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
42
|
+
if (isWanted(cacheKey)) {
|
|
43
|
+
loadedPlugins.set(cacheKey, entry);
|
|
44
|
+
}
|
|
45
|
+
return entry;
|
|
46
|
+
}
|
|
47
|
+
function sweep() {
|
|
48
|
+
for (const [cacheKey, entry] of [...loadedPlugins]) {
|
|
49
|
+
if (isWanted(cacheKey)) {
|
|
50
|
+
continue;
|
|
51
|
+
}
|
|
52
|
+
loadedPlugins.delete(cacheKey);
|
|
53
|
+
entry.then((plugin) => plugin.dispose(),
|
|
54
|
+
// No worker to dispose; the caller reports the rejection.
|
|
55
|
+
() => { });
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
function isWanted(cacheKey) {
|
|
59
|
+
for (const keys of wantedBy.values()) {
|
|
60
|
+
if (keys.has(cacheKey)) {
|
|
61
|
+
return true;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
return false;
|
|
65
|
+
}
|
|
66
|
+
/** Includes the index: a plugin carries its nx.json position, which exclusions and errors point at. */
|
|
67
|
+
function getCacheKey(plugin, root, index) {
|
|
68
|
+
return JSON.stringify({ plugin, root, index });
|
|
69
|
+
}
|
|
70
|
+
function forget(cacheKey, entry) {
|
|
71
|
+
if (loadedPlugins.get(cacheKey) === entry) {
|
|
72
|
+
loadedPlugins.delete(cacheKey);
|
|
73
|
+
}
|
|
24
74
|
}
|
|
@@ -3,7 +3,8 @@ import type { Socket } from 'net';
|
|
|
3
3
|
import type { PluginConfiguration } from '../../../config/nx-json';
|
|
4
4
|
import type { ProjectGraph } from '../../../config/project-graph';
|
|
5
5
|
import type { LoadedNxPlugin } from '../loaded-nx-plugin';
|
|
6
|
-
import type {
|
|
6
|
+
import type { MaybeStubbedPostTasksExecutionContext } from '../task-results-stub';
|
|
7
|
+
import type { CreateDependenciesContext, CreateMetadataContext, CreateNodesContext, PreTasksExecutionContext } from '../public-api';
|
|
7
8
|
import type { AllMessages, AllResults, DefineMessages, Handlers, ResultOf, WithResult } from './message-types';
|
|
8
9
|
/**
|
|
9
10
|
* All plugin worker message definitions in one place.
|
|
@@ -88,7 +89,7 @@ type PluginMessageDefs = DefineMessages<{
|
|
|
88
89
|
};
|
|
89
90
|
postTasksExecution: {
|
|
90
91
|
payload: {
|
|
91
|
-
context:
|
|
92
|
+
context: MaybeStubbedPostTasksExecutionContext;
|
|
92
93
|
};
|
|
93
94
|
result: {
|
|
94
95
|
success: true;
|
|
@@ -42,6 +42,10 @@ if (!socketPath || !expectedPluginName || !hostWorkspaceRoot) {
|
|
|
42
42
|
process.exit(1);
|
|
43
43
|
}
|
|
44
44
|
const CONNECT_TIMEOUT_MS = 30_000;
|
|
45
|
+
// Runs in this worker's own loop from the moment it accepts, while the host is
|
|
46
|
+
// loading every plugin at once and may sit in a synchronous workspace walk for
|
|
47
|
+
// over ten seconds. A host that has died closes the socket; 'end' covers that.
|
|
48
|
+
const LOAD_TIMEOUT_MS = 60_000;
|
|
45
49
|
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. ` +
|
|
46
50
|
'Plugin workers expect to receive a socket connection from the parent process shortly after being started. ' +
|
|
47
51
|
'If you are seeing this issue, please report it to the Nx team at https://github.com/nrwl/nx/issues.');
|
|
@@ -55,7 +59,7 @@ const server = (0, net_1.createServer)((socket) => {
|
|
|
55
59
|
// This handles cases where the host process was killed
|
|
56
60
|
// after the worker connected but before the worker was
|
|
57
61
|
// instructed to load the plugin.
|
|
58
|
-
let loadErrorTimeout = setErrorTimeout(
|
|
62
|
+
let loadErrorTimeout = setErrorTimeout(LOAD_TIMEOUT_MS, `Plugin Worker for ${expectedPluginName} is exiting as it did not receive a load message within ${LOAD_TIMEOUT_MS / 1000} seconds of connecting. ` +
|
|
59
63
|
'This likely indicates that the host process was terminated before the worker could be instructed to load the plugin. ' +
|
|
60
64
|
'If you are seeing this issue, please report it to the Nx team at https://github.com/nrwl/nx/issues.');
|
|
61
65
|
socket.on('data', (0, consume_messages_from_socket_1.consumeMessagesFromSocket)((raw) => {
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import type { ProjectGraph } from '../../config/project-graph';
|
|
2
2
|
import { type PluginConfiguration } from '../../config/nx-json';
|
|
3
3
|
import type { RawProjectGraphDependency } from '../project-graph-builder';
|
|
4
|
-
import type { CreateDependenciesContext, CreateMetadataContext, CreateNodesContext, CreateNodesResult, NxPlugin,
|
|
4
|
+
import type { CreateDependenciesContext, CreateMetadataContext, CreateNodesContext, CreateNodesResult, NxPlugin, PreTasksExecutionContext, ProjectsMetadata } from './public-api';
|
|
5
|
+
import { type MaybeStubbedPostTasksExecutionContext } from './task-results-stub';
|
|
6
|
+
import type { NxPluginCapabilities } from './nx-plugin-capabilities';
|
|
5
7
|
/**
|
|
6
8
|
* NOTE: Avoid using `import type` with this class. It causes issues with
|
|
7
9
|
* jest's module resolution when running tests in projects that import
|
|
@@ -17,7 +19,7 @@ export declare class LoadedNxPlugin {
|
|
|
17
19
|
readonly createDependencies?: (context: CreateDependenciesContext) => Promise<RawProjectGraphDependency[]>;
|
|
18
20
|
readonly createMetadata?: (graph: ProjectGraph, context: CreateMetadataContext) => Promise<ProjectsMetadata>;
|
|
19
21
|
readonly preTasksExecution?: (context: PreTasksExecutionContext) => Promise<NodeJS.ProcessEnv>;
|
|
20
|
-
readonly postTasksExecution?: (context:
|
|
22
|
+
readonly postTasksExecution?: (context: MaybeStubbedPostTasksExecutionContext) => Promise<void>;
|
|
21
23
|
readonly options?: unknown;
|
|
22
24
|
readonly include?: string[];
|
|
23
25
|
readonly exclude?: string[];
|
|
@@ -38,4 +40,5 @@ export declare class LoadedNxPlugin {
|
|
|
38
40
|
*/
|
|
39
41
|
setWorkerEnv?(env: Record<string, string>): Promise<void>;
|
|
40
42
|
constructor(plugin: NxPlugin, pluginDefinition: PluginConfiguration, index?: number);
|
|
43
|
+
capabilities(): NxPluginCapabilities;
|
|
41
44
|
}
|
|
@@ -5,6 +5,7 @@ const analytics_1 = require("../../analytics");
|
|
|
5
5
|
const error_types_1 = require("../error-types");
|
|
6
6
|
const enabled_1 = require("./isolation/enabled");
|
|
7
7
|
const client_1 = require("../../daemon/client/client");
|
|
8
|
+
const task_results_stub_1 = require("./task-results-stub");
|
|
8
9
|
/**
|
|
9
10
|
* NOTE: Avoid using `import type` with this class. It causes issues with
|
|
10
11
|
* jest's module resolution when running tests in projects that import
|
|
@@ -97,8 +98,20 @@ class LoadedNxPlugin {
|
|
|
97
98
|
};
|
|
98
99
|
}
|
|
99
100
|
if (plugin.postTasksExecution) {
|
|
100
|
-
|
|
101
|
+
// The single rehydration point: every transport hands its context
|
|
102
|
+
// straight here, so a context bound for an isolated plugin stays stubbed
|
|
103
|
+
// across that second hop rather than being read and re-stubbed.
|
|
104
|
+
this.postTasksExecution = async (context) => plugin.postTasksExecution(this.options, await (0, task_results_stub_1.rehydrateTerminalOutputs)(context));
|
|
101
105
|
}
|
|
102
106
|
}
|
|
107
|
+
capabilities() {
|
|
108
|
+
return {
|
|
109
|
+
createNodesPattern: this.createNodes?.[0],
|
|
110
|
+
hasCreateDependencies: !!this.createDependencies,
|
|
111
|
+
hasCreateMetadata: !!this.createMetadata,
|
|
112
|
+
hasPreTasksExecution: !!this.preTasksExecution,
|
|
113
|
+
hasPostTasksExecution: !!this.postTasksExecution,
|
|
114
|
+
};
|
|
115
|
+
}
|
|
103
116
|
}
|
|
104
117
|
exports.LoadedNxPlugin = LoadedNxPlugin;
|