@depup/nx 23.2.1-depup.7 → 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 +8 -19
- package/changes.json +10 -54
- 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 +38 -100
- 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
|
@@ -0,0 +1,386 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.selectsAffectedTasks = selectsAffectedTasks;
|
|
4
|
+
exports.computeAffectedTasks = computeAffectedTasks;
|
|
5
|
+
exports.selectAffectedTasks = selectAffectedTasks;
|
|
6
|
+
const native_1 = require("../../native");
|
|
7
|
+
const overrides_1 = require("../../ultracache/overrides");
|
|
8
|
+
const store_1 = require("../../ultracache/store");
|
|
9
|
+
const create_task_graph_1 = require("../../tasks-runner/create-task-graph");
|
|
10
|
+
const project_graph_utils_1 = require("../../utils/project-graph-utils");
|
|
11
|
+
const utils_1 = require("../../tasks-runner/utils");
|
|
12
|
+
const project_graph_1 = require("../project-graph");
|
|
13
|
+
const file_utils_1 = require("../file-utils");
|
|
14
|
+
const find_matching_projects_1 = require("../../utils/find-matching-projects");
|
|
15
|
+
const logger_1 = require("../../utils/logger");
|
|
16
|
+
const error_types_1 = require("../error-types");
|
|
17
|
+
const affected_reasons_1 = require("./affected-reasons");
|
|
18
|
+
const workspace_root_1 = require("../../utils/workspace-root");
|
|
19
|
+
const task_planning_context_1 = require("../../hasher/task-planning-context");
|
|
20
|
+
const client_1 = require("../../daemon/client/client");
|
|
21
|
+
const is_on_daemon_1 = require("../../daemon/is-on-daemon");
|
|
22
|
+
const affected_projects_1 = require("./affected-projects");
|
|
23
|
+
const lock_file_changes_1 = require("../../plugins/js/project-graph/affected/lock-file-changes");
|
|
24
|
+
const npm_packages_1 = require("../../plugins/js/project-graph/affected/npm-packages");
|
|
25
|
+
const lock_file_1 = require("../../plugins/js/lock-file/lock-file");
|
|
26
|
+
/**
|
|
27
|
+
* Whether `nx affected` selects the individual tasks whose inputs a change
|
|
28
|
+
* reaches, rather than whole projects. Off by default while the task path
|
|
29
|
+
* settles.
|
|
30
|
+
*
|
|
31
|
+
* Env-var only, so `nx show projects --affected` and `nx affected` in one CI
|
|
32
|
+
* script agree. The run also executes the selected tasks' dependencies.
|
|
33
|
+
*/
|
|
34
|
+
function selectsAffectedTasks() {
|
|
35
|
+
return process.env.NX_LEGACY_AFFECTED === 'false';
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Selects the tasks a change reaches, rather than the projects that own a
|
|
39
|
+
* changed file.
|
|
40
|
+
*
|
|
41
|
+
* With the daemon on, the daemon selects: it hashes the run's tasks, so its
|
|
42
|
+
* planner is the one that remembers the plans. It returns the graph it selected
|
|
43
|
+
* against, which the command must run with.
|
|
44
|
+
*/
|
|
45
|
+
async function computeAffectedTasks(opts) {
|
|
46
|
+
const request = {
|
|
47
|
+
targets: opts.targets,
|
|
48
|
+
changedFiles: opts.touchedFiles.map((f) => f.file),
|
|
49
|
+
fileChangeArgs: opts.fileChangeArgs,
|
|
50
|
+
configuration: opts.configuration,
|
|
51
|
+
overrides: opts.overrides ?? {},
|
|
52
|
+
extraTargetDependencies: opts.extraTargetDependencies ?? {},
|
|
53
|
+
excludeTaskDependencies: opts.excludeTaskDependencies ?? false,
|
|
54
|
+
exclude: opts.exclude ?? [],
|
|
55
|
+
selectivelyHashTsConfig: opts.selectivelyHashTsConfig,
|
|
56
|
+
explain: opts.explain,
|
|
57
|
+
};
|
|
58
|
+
const ultracacheConfigurations = (0, store_1.configurationsOf)(opts.ultracacheConfigurationOutcome ?? null);
|
|
59
|
+
if (ultracacheConfigurations) {
|
|
60
|
+
request.ultracacheConfigurationsVersion = {
|
|
61
|
+
commit: ultracacheConfigurations.commit,
|
|
62
|
+
fetchedAt: ultracacheConfigurations.resolution.fetchedAt,
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
if (!(0, is_on_daemon_1.isOnDaemon)() && client_1.daemonClient.enabled()) {
|
|
66
|
+
try {
|
|
67
|
+
const selection = await client_1.daemonClient.selectAffectedTasks(request);
|
|
68
|
+
return {
|
|
69
|
+
...selection,
|
|
70
|
+
affectedTaskIds: new Set(selection.affectedTaskIds),
|
|
71
|
+
explanation: selection.explanation && (0, affected_reasons_1.hydrateExplanation)(selection.explanation),
|
|
72
|
+
taskSelection: {
|
|
73
|
+
...selection.taskSelection,
|
|
74
|
+
ultracacheConfigurationOutcome: opts.ultracacheConfigurationOutcome,
|
|
75
|
+
},
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
catch (e) {
|
|
79
|
+
if (e?.name === error_types_1.DaemonProjectGraphError.name) {
|
|
80
|
+
throw error_types_1.ProjectGraphError.fromDaemonProjectGraphError(e);
|
|
81
|
+
}
|
|
82
|
+
// Not rethrown: the graph fetch handles an unreachable daemon, and a
|
|
83
|
+
// selection error recurs in-process below.
|
|
84
|
+
logger_1.logger.verbose(`Selecting affected tasks in the daemon failed: ${e}`);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
const projectGraph = opts.projectGraph ?? (await (0, project_graph_1.createProjectGraphAsync)({ exitOnError: true }));
|
|
88
|
+
const planningContext = (0, task_planning_context_1.createTaskPlanningContext)(projectGraph, opts.nxJson);
|
|
89
|
+
const selection = await selectAffectedTasks(projectGraph, opts.nxJson, planningContext, request, {
|
|
90
|
+
touchedFiles: opts.touchedFiles,
|
|
91
|
+
packageJson: opts.packageJson,
|
|
92
|
+
ultracacheConfigurations,
|
|
93
|
+
});
|
|
94
|
+
return {
|
|
95
|
+
projectGraph,
|
|
96
|
+
affectedTaskIds: selection.affectedTaskIds,
|
|
97
|
+
taskGraph: selection.taskGraph,
|
|
98
|
+
explanation: selection.explanation && (0, affected_reasons_1.hydrateExplanation)(selection.explanation),
|
|
99
|
+
taskSelection: {
|
|
100
|
+
...selection.taskSelection,
|
|
101
|
+
// The planner remembers what selection planned, so the run's hashing reuses it.
|
|
102
|
+
planningContext,
|
|
103
|
+
ultracacheConfigurationOutcome: opts.ultracacheConfigurationOutcome,
|
|
104
|
+
},
|
|
105
|
+
};
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* Plans the targets' full task graph and matches the changed paths against
|
|
109
|
+
* every plan. No project-level prefilter: under Ultracache configurations a
|
|
110
|
+
* task can read files no affected project owns. Shared by the client and the
|
|
111
|
+
* daemon.
|
|
112
|
+
*/
|
|
113
|
+
async function selectAffectedTasks(projectGraph, nxJson, planningContext, request, { touchedFiles = (0, file_utils_1.calculateFileChanges)(request.changedFiles, request.fileChangeArgs), packageJson, ultracacheConfigurations, } = {}) {
|
|
114
|
+
const { targets } = request;
|
|
115
|
+
// Only projects that have one of the targets: with a single target,
|
|
116
|
+
// createTaskGraph tries to create a task for projects that lack it and
|
|
117
|
+
// createTask throws.
|
|
118
|
+
const candidates = [...(0, project_graph_utils_1.runnableForTarget)(projectGraph.nodes, targets)];
|
|
119
|
+
if (!candidates.length) {
|
|
120
|
+
const empty = {
|
|
121
|
+
roots: [],
|
|
122
|
+
tasks: {},
|
|
123
|
+
dependencies: {},
|
|
124
|
+
continuousDependencies: {},
|
|
125
|
+
};
|
|
126
|
+
return {
|
|
127
|
+
affectedTaskIds: new Set(),
|
|
128
|
+
taskGraph: empty,
|
|
129
|
+
taskSelection: { taskGraph: empty, initiatingTaskIds: [], taskIds: [] },
|
|
130
|
+
explanation: request.explain
|
|
131
|
+
? {
|
|
132
|
+
inputs: [],
|
|
133
|
+
affected: {},
|
|
134
|
+
upstream: {},
|
|
135
|
+
touched: [],
|
|
136
|
+
requested: { targets, total: 0 },
|
|
137
|
+
}
|
|
138
|
+
: undefined,
|
|
139
|
+
};
|
|
140
|
+
}
|
|
141
|
+
const { taskGraph, dependencyOverrides } = (0, create_task_graph_1.createTaskGraphWithDependencyOverrides)(projectGraph, request.extraTargetDependencies, candidates, targets, request.configuration, request.overrides,
|
|
142
|
+
// Dependencies carry a change even when they won't run; `keep` drops them.
|
|
143
|
+
false);
|
|
144
|
+
const taskIds = Object.keys(taskGraph.tasks);
|
|
145
|
+
const plans = ultracacheConfigurations
|
|
146
|
+
? planningContext.planner.getPlansReference(taskIds, taskGraph, ultracacheConfigurations, (0, overrides_1.ultracacheEligibilityOptions)(projectGraph, taskGraph))
|
|
147
|
+
: planningContext.planner.getPlansReference(taskIds, taskGraph);
|
|
148
|
+
const dependencies = dependencyChanges(projectGraph, touchedFiles, nxJson, packageJson);
|
|
149
|
+
const namedProjects = new Set(dependencies.projects);
|
|
150
|
+
const projects = (0, project_graph_1.readProjectsConfigurationFromProjectGraph)(projectGraph).projects;
|
|
151
|
+
const customHashed = new Set(taskIds.filter((id) => hasCustomHasher(taskGraph.tasks[id], projects)));
|
|
152
|
+
const options = {
|
|
153
|
+
projectGlobPatterns: await (0, affected_projects_1.getProjectGlobPatterns)(nxJson),
|
|
154
|
+
workspaceRoot: workspace_root_1.workspaceRoot,
|
|
155
|
+
alwaysTouchedTaskIds: taskIds.filter((id) => namedProjects.has(taskGraph.tasks[id].target.project) ||
|
|
156
|
+
customHashed.has(id)),
|
|
157
|
+
changedExternals: dependencies.externals,
|
|
158
|
+
changedExternalTypes: dependencies.changedExternalTypes,
|
|
159
|
+
excludedProjects: request.exclude.length
|
|
160
|
+
? (0, find_matching_projects_1.findMatchingProjects)(request.exclude, projectGraph.nodes)
|
|
161
|
+
: [],
|
|
162
|
+
targets,
|
|
163
|
+
revisions: fileRevisions(request.fileChangeArgs),
|
|
164
|
+
selectivelyHashTsConfig: request.selectivelyHashTsConfig ?? false,
|
|
165
|
+
explain: request.explain ?? false,
|
|
166
|
+
};
|
|
167
|
+
const selection = (0, native_1.affectedTasks)(planningContext.projectGraphRef, plans, taskGraph, request.changedFiles, options);
|
|
168
|
+
// The run builds from the owning projects, so only their requested tasks
|
|
169
|
+
// take the CLI overrides there; every other task is a dependency.
|
|
170
|
+
const owning = new Set(selection.affected.map((id) => taskGraph.tasks[id].target.project));
|
|
171
|
+
const initial = new Set(taskIds.filter((id) => {
|
|
172
|
+
const { project, target } = taskGraph.tasks[id].target;
|
|
173
|
+
return owning.has(project) && targets.includes(target);
|
|
174
|
+
}));
|
|
175
|
+
// Without dependencies the run builds its initial tasks and nothing else.
|
|
176
|
+
const keep = request.excludeTaskDependencies
|
|
177
|
+
? selection.required.filter((id) => initial.has(id))
|
|
178
|
+
: selection.required;
|
|
179
|
+
return {
|
|
180
|
+
affectedTaskIds: new Set(selection.affected),
|
|
181
|
+
taskGraph,
|
|
182
|
+
explanation: selection.explanation && {
|
|
183
|
+
...explainTasks(selection.affected, selection.explanation, dependencies, request.changedFiles, taskGraph, customHashed, keep),
|
|
184
|
+
requested: requestedTasks(taskIds, taskGraph, targets, options),
|
|
185
|
+
},
|
|
186
|
+
taskSelection: {
|
|
187
|
+
// Edges that disagree on a dependency's overrides leave it to a build
|
|
188
|
+
// from the owning projects, which settles them the way the run always has.
|
|
189
|
+
taskGraph: (0, create_task_graph_1.filterTaskGraphToSelection)(projectGraph, taskGraph, dependencyOverrides, initial, new Set(keep)) ??
|
|
190
|
+
(0, utils_1.pruneToSelectedTasks)((0, create_task_graph_1.createTaskGraph)(projectGraph, request.extraTargetDependencies, [...owning], targets, request.configuration, request.overrides, request.excludeTaskDependencies), keep),
|
|
191
|
+
initiatingTaskIds: keep.filter((id) => initial.has(id)),
|
|
192
|
+
taskIds: keep,
|
|
193
|
+
},
|
|
194
|
+
};
|
|
195
|
+
}
|
|
196
|
+
/** Unset for `--files`, which names files without a diff to compare. */
|
|
197
|
+
function fileRevisions(args) {
|
|
198
|
+
return args?.base && !args.files?.length
|
|
199
|
+
? { base: args.base, head: args.head }
|
|
200
|
+
: undefined;
|
|
201
|
+
}
|
|
202
|
+
/**
|
|
203
|
+
* A custom hasher hashes outside the task's plan, so no instruction says what
|
|
204
|
+
* reaches it and the task is always selected. An executor that cannot be
|
|
205
|
+
* resolved cannot run either, so it is left to the plan.
|
|
206
|
+
*/
|
|
207
|
+
function hasCustomHasher(task, projects) {
|
|
208
|
+
try {
|
|
209
|
+
return !!(0, utils_1.getExecutorForTask)(task, projects).hasherFactory;
|
|
210
|
+
}
|
|
211
|
+
catch {
|
|
212
|
+
return false;
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
function dependencyChanges(projectGraph, touchedFiles, nxJson, packageJson = (0, file_utils_1.readPackageJson)()) {
|
|
216
|
+
const lockFile = (0, lock_file_changes_1.lockFileDependencyChanges)(touchedFiles, projectGraph.nodes, nxJson, packageJson, projectGraph);
|
|
217
|
+
const packageJsonChanges = (0, npm_packages_1.packageJsonDependencyChanges)(touchedFiles, nxJson, projectGraph);
|
|
218
|
+
const changes = [lockFile, packageJsonChanges];
|
|
219
|
+
const named = new Map();
|
|
220
|
+
const name = (project, reason) => named.set(project, [...(named.get(project) ?? []), reason]);
|
|
221
|
+
const changedLockFile = touchedFiles.find((f) => lock_file_1.AUTO_AFFECTED_LOCK_FILES.includes(f.file))?.file;
|
|
222
|
+
for (const project of lockFile.projects) {
|
|
223
|
+
name(project, { kind: 'lockfile', file: changedLockFile });
|
|
224
|
+
}
|
|
225
|
+
for (const project of packageJsonChanges.projects) {
|
|
226
|
+
name(project, {
|
|
227
|
+
kind: 'npm-package',
|
|
228
|
+
// The name package.json uses, which need not be the project's.
|
|
229
|
+
package: projectGraph.nodes[project]?.data.metadata?.js?.packageName ?? project,
|
|
230
|
+
file: 'package.json',
|
|
231
|
+
});
|
|
232
|
+
}
|
|
233
|
+
const movedBy = new Map();
|
|
234
|
+
for (const external of packageJsonChanges.externals) {
|
|
235
|
+
movedBy.set(external, 'package.json');
|
|
236
|
+
}
|
|
237
|
+
for (const external of lockFile.externals) {
|
|
238
|
+
movedBy.set(external, changedLockFile);
|
|
239
|
+
}
|
|
240
|
+
const ecosystemMovedBy = new Map();
|
|
241
|
+
for (const [changes, file] of [
|
|
242
|
+
[packageJsonChanges, 'package.json'],
|
|
243
|
+
[lockFile, changedLockFile],
|
|
244
|
+
]) {
|
|
245
|
+
for (const ecosystem of changes.changedExternalTypes) {
|
|
246
|
+
ecosystemMovedBy.set(ecosystem, [
|
|
247
|
+
...(ecosystemMovedBy.get(ecosystem) ?? []),
|
|
248
|
+
file,
|
|
249
|
+
]);
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
return {
|
|
253
|
+
externals: [...new Set(changes.flatMap((c) => c.externals))],
|
|
254
|
+
changedExternalTypes: [
|
|
255
|
+
...new Set(changes.flatMap((c) => c.changedExternalTypes)),
|
|
256
|
+
],
|
|
257
|
+
projects: [...new Set(changes.flatMap((c) => c.projects))],
|
|
258
|
+
named,
|
|
259
|
+
movedBy,
|
|
260
|
+
ecosystemMovedBy,
|
|
261
|
+
};
|
|
262
|
+
}
|
|
263
|
+
/**
|
|
264
|
+
* Why each selected task is in the answer, and why each task outside it that
|
|
265
|
+
* a reason names as a producer is too.
|
|
266
|
+
*
|
|
267
|
+
* Every reason that applies is listed: a task can match a changed file, hash a package that
|
|
268
|
+
* moved, and read an affected producer, all at once.
|
|
269
|
+
*/
|
|
270
|
+
function explainTasks(affected, explanation, dependencies, changedPaths, taskGraph, customHashed,
|
|
271
|
+
/** What the run keeps: a reached task in it is listed even if nothing reads its outputs. */
|
|
272
|
+
keep) {
|
|
273
|
+
// What a plan hashing every external saw change.
|
|
274
|
+
const dependencyFiles = changedPaths.filter((file) => file === 'package.json' ||
|
|
275
|
+
lock_file_1.AUTO_AFFECTED_LOCK_FILES.includes(file));
|
|
276
|
+
const named = dependencies.named;
|
|
277
|
+
// Each matching instruction's reasons, built once and shared by every task
|
|
278
|
+
// whose plan holds it.
|
|
279
|
+
const inputs = explanation.inputMatches.map((matches) => {
|
|
280
|
+
const reasons = [];
|
|
281
|
+
for (const match of matches.files) {
|
|
282
|
+
reasons.push({
|
|
283
|
+
kind: 'input-file',
|
|
284
|
+
file: match.file,
|
|
285
|
+
pattern: match.pattern,
|
|
286
|
+
});
|
|
287
|
+
}
|
|
288
|
+
for (const pkg of matches.packages) {
|
|
289
|
+
reasons.push({
|
|
290
|
+
kind: 'npm-package',
|
|
291
|
+
package: pkg,
|
|
292
|
+
file: dependencies.movedBy.get(pkg),
|
|
293
|
+
});
|
|
294
|
+
}
|
|
295
|
+
for (const ecosystem of matches.movedEcosystems) {
|
|
296
|
+
// Only the files that could not be narrowed: a package.json naming its
|
|
297
|
+
// packages beside an unreadable lockfile did not move everything.
|
|
298
|
+
const files = dependencyFiles.filter((file) => dependencies.ecosystemMovedBy.get(ecosystem)?.includes(file));
|
|
299
|
+
for (const file of files.length ? files : [undefined]) {
|
|
300
|
+
reasons.push({ kind: 'moved-ecosystem', ecosystem, file });
|
|
301
|
+
}
|
|
302
|
+
}
|
|
303
|
+
if (matches.allExternals) {
|
|
304
|
+
for (const file of dependencyFiles) {
|
|
305
|
+
reasons.push({ kind: 'external-dependencies', file });
|
|
306
|
+
}
|
|
307
|
+
}
|
|
308
|
+
for (const file of matches.projectConfigs) {
|
|
309
|
+
reasons.push({ kind: 'project-configuration', file });
|
|
310
|
+
}
|
|
311
|
+
return reasons;
|
|
312
|
+
});
|
|
313
|
+
const reasonsFor = (taskId) => {
|
|
314
|
+
const forTask = [];
|
|
315
|
+
const matched = (explanation.taskInputMatches[taskId] ?? []).filter((index) => inputs[index].length);
|
|
316
|
+
if (matched.length) {
|
|
317
|
+
forTask.push({ kind: 'inputs', inputs: matched });
|
|
318
|
+
}
|
|
319
|
+
// Only the reached producers: the walk records the edges it crossed.
|
|
320
|
+
for (const producer of explanation.producersOf[taskId] ?? []) {
|
|
321
|
+
forTask.push({ kind: 'dependent-output', producer });
|
|
322
|
+
}
|
|
323
|
+
const project = taskGraph.tasks[taskId]?.target.project;
|
|
324
|
+
for (const reason of (project && named.get(project)) ?? []) {
|
|
325
|
+
forTask.push(reason);
|
|
326
|
+
}
|
|
327
|
+
if (customHashed.has(taskId)) {
|
|
328
|
+
forTask.push({ kind: 'custom-hasher' });
|
|
329
|
+
}
|
|
330
|
+
// A deleted config seeded every task. Only worth saying when nothing
|
|
331
|
+
// narrower applies, or it would repeat on every line.
|
|
332
|
+
if (!forTask.length) {
|
|
333
|
+
for (const file of explanation.deletedProjectConfigs) {
|
|
334
|
+
forTask.push({ kind: 'deleted-project-configuration', file });
|
|
335
|
+
}
|
|
336
|
+
}
|
|
337
|
+
return forTask;
|
|
338
|
+
};
|
|
339
|
+
const result = {
|
|
340
|
+
inputs,
|
|
341
|
+
affected: Object.fromEntries(affected.map((id) => [id, reasonsFor(id)])),
|
|
342
|
+
upstream: {},
|
|
343
|
+
touched: [],
|
|
344
|
+
};
|
|
345
|
+
// Reached: touched, or carried to through outputs, which leaves an edge.
|
|
346
|
+
const reached = new Set([
|
|
347
|
+
...explanation.touched,
|
|
348
|
+
...Object.keys(explanation.producersOf),
|
|
349
|
+
]);
|
|
350
|
+
for (const id of keep) {
|
|
351
|
+
if (reached.has(id) && !(id in result.affected)) {
|
|
352
|
+
result.upstream[id] = reasonsFor(id);
|
|
353
|
+
}
|
|
354
|
+
}
|
|
355
|
+
const producers = [
|
|
356
|
+
...Object.keys(result.affected),
|
|
357
|
+
...Object.keys(result.upstream),
|
|
358
|
+
].flatMap((id) => explanation.producersOf[id] ?? []);
|
|
359
|
+
while (producers.length) {
|
|
360
|
+
const id = producers.pop();
|
|
361
|
+
if (id in result.affected || id in result.upstream)
|
|
362
|
+
continue;
|
|
363
|
+
result.upstream[id] = reasonsFor(id);
|
|
364
|
+
producers.push(...(explanation.producersOf[id] ?? []));
|
|
365
|
+
}
|
|
366
|
+
result.touched = explanation.touched.filter((id) => id in result.affected || id in result.upstream);
|
|
367
|
+
for (const [pkg, file] of dependencies.movedBy) {
|
|
368
|
+
result.moved ??= {};
|
|
369
|
+
(result.moved[file] ??= []).push(pkg);
|
|
370
|
+
}
|
|
371
|
+
return result;
|
|
372
|
+
}
|
|
373
|
+
/**
|
|
374
|
+
* How many tasks of the requested targets selection chose among. Tasks of
|
|
375
|
+
* excluded projects are left out, since they were never candidates.
|
|
376
|
+
*/
|
|
377
|
+
function requestedTasks(taskIds, taskGraph, targets, options) {
|
|
378
|
+
const excluded = new Set(options.excludedProjects);
|
|
379
|
+
return {
|
|
380
|
+
targets,
|
|
381
|
+
total: taskIds.filter((id) => {
|
|
382
|
+
const { project, target } = taskGraph.tasks[id].target;
|
|
383
|
+
return targets.includes(target) && !excluded.has(project);
|
|
384
|
+
}).length,
|
|
385
|
+
};
|
|
386
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { AffectedExplanation } from './affected-reasons';
|
|
2
|
+
/**
|
|
3
|
+
* Prints `--explain` output.
|
|
4
|
+
*
|
|
5
|
+
* `destination` is what the flag was given, following `--graph`: `true` is a
|
|
6
|
+
* bare `--explain` and prints the human form, `"stdout"` prints JSON, and any
|
|
7
|
+
* other string is a file to write the JSON to.
|
|
8
|
+
*/
|
|
9
|
+
export declare function printAffectedExplanation(explanation: AffectedExplanation, heading: string, destination: string | boolean | undefined, options?: {
|
|
10
|
+
verbose?: boolean;
|
|
11
|
+
}): void;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.printAffectedExplanation = printAffectedExplanation;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const fs_1 = require("fs");
|
|
6
|
+
const pc = tslib_1.__importStar(require("picocolors"));
|
|
7
|
+
const output_1 = require("../../utils/output");
|
|
8
|
+
const affected_reasons_1 = require("./affected-reasons");
|
|
9
|
+
/**
|
|
10
|
+
* Prints `--explain` output.
|
|
11
|
+
*
|
|
12
|
+
* `destination` is what the flag was given, following `--graph`: `true` is a
|
|
13
|
+
* bare `--explain` and prints the human form, `"stdout"` prints JSON, and any
|
|
14
|
+
* other string is a file to write the JSON to.
|
|
15
|
+
*/
|
|
16
|
+
function printAffectedExplanation(explanation, heading, destination, options = {}) {
|
|
17
|
+
if (destination === 'stdout') {
|
|
18
|
+
console.log(JSON.stringify(explanation, null, 2));
|
|
19
|
+
return;
|
|
20
|
+
}
|
|
21
|
+
if (typeof destination === 'string' && destination) {
|
|
22
|
+
(0, fs_1.writeFileSync)(destination, JSON.stringify(explanation, null, 2));
|
|
23
|
+
output_1.output.success({ title: `Reasons written to ${destination}` });
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
const rendered = (0, affected_reasons_1.formatAffectedExplanation)(explanation, heading, {
|
|
27
|
+
...options,
|
|
28
|
+
styleTask,
|
|
29
|
+
dim: pc.dim,
|
|
30
|
+
bold: pc.bold,
|
|
31
|
+
});
|
|
32
|
+
if (!Object.keys(explanation.affected).length) {
|
|
33
|
+
output_1.output.log({ title: rendered });
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
const [title, , ...bodyLines] = rendered.split('\n');
|
|
37
|
+
output_1.output.log({ title: title.replace(/:$/, ''), bodyLines });
|
|
38
|
+
}
|
|
39
|
+
// Colored like `nx show target`, with the tasks asked for in bold.
|
|
40
|
+
function styleTask(id, requested) {
|
|
41
|
+
const split = id.indexOf(':');
|
|
42
|
+
const colored = `${pc.cyan(id.slice(0, split))}:${pc.green(id.slice(split + 1))}`;
|
|
43
|
+
return requested ? pc.bold(colored) : colored;
|
|
44
|
+
}
|
|
@@ -66,6 +66,10 @@ export declare class ProjectConfigurationsError extends Error {
|
|
|
66
66
|
constructor(errors: Array<MergeNodesError | AggregateCreateNodesError | ProjectsWithNoNameError | MultipleProjectsWithSameNameError | WorkspaceValidityError>, partialProjectConfigurationsResult: ConfigurationResult);
|
|
67
67
|
}
|
|
68
68
|
export declare function isProjectConfigurationsError(e: unknown): e is ProjectConfigurationsError;
|
|
69
|
+
export declare function formatProjectGraphError(error: ProjectGraphError | ProjectConfigurationsError, isVerbose: boolean): {
|
|
70
|
+
title: string;
|
|
71
|
+
bodyLines: string[];
|
|
72
|
+
};
|
|
69
73
|
/**
|
|
70
74
|
* This error should be thrown when a `createNodesV2` function hits a recoverable error.
|
|
71
75
|
* It allows Nx to recieve partial results and continue processing for better UX.
|
|
@@ -149,3 +153,4 @@ export declare class LoadPluginError extends Error {
|
|
|
149
153
|
plugin: string;
|
|
150
154
|
constructor(plugin: string, cause: Error);
|
|
151
155
|
}
|
|
156
|
+
export declare function formatErrorStackAndCause(error: Error): string;
|
|
@@ -7,12 +7,14 @@ exports.isMultipleProjectsWithSameNameError = isMultipleProjectsWithSameNameErro
|
|
|
7
7
|
exports.isProjectsWithNoNameError = isProjectsWithNoNameError;
|
|
8
8
|
exports.isProjectWithNoNameError = isProjectWithNoNameError;
|
|
9
9
|
exports.isProjectConfigurationsError = isProjectConfigurationsError;
|
|
10
|
+
exports.formatProjectGraphError = formatProjectGraphError;
|
|
10
11
|
exports.formatAggregateCreateNodesError = formatAggregateCreateNodesError;
|
|
11
12
|
exports.isWorkspaceValidityError = isWorkspaceValidityError;
|
|
12
13
|
exports.isAggregateProjectGraphError = isAggregateProjectGraphError;
|
|
13
14
|
exports.isCreateMetadataError = isCreateMetadataError;
|
|
14
15
|
exports.isAggregateCreateNodesError = isAggregateCreateNodesError;
|
|
15
16
|
exports.isMergeNodesError = isMergeNodesError;
|
|
17
|
+
exports.formatErrorStackAndCause = formatErrorStackAndCause;
|
|
16
18
|
const tslib_1 = require("tslib");
|
|
17
19
|
class StaleProjectGraphCacheError extends Error {
|
|
18
20
|
constructor() {
|
|
@@ -222,6 +224,27 @@ function isProjectConfigurationsError(e) {
|
|
|
222
224
|
'name' in e &&
|
|
223
225
|
e?.name === ProjectConfigurationsError.name));
|
|
224
226
|
}
|
|
227
|
+
function formatProjectGraphError(error, isVerbose) {
|
|
228
|
+
const errors = isProjectConfigurationsError(error)
|
|
229
|
+
? error.errors
|
|
230
|
+
: error.getErrors();
|
|
231
|
+
let title = error.message;
|
|
232
|
+
if (error.cause &&
|
|
233
|
+
typeof error.cause === 'object' &&
|
|
234
|
+
'message' in error.cause) {
|
|
235
|
+
title += ' ' + error.cause.message + '.';
|
|
236
|
+
}
|
|
237
|
+
return {
|
|
238
|
+
title,
|
|
239
|
+
bodyLines: isVerbose
|
|
240
|
+
? [formatErrorStackAndCause(error)]
|
|
241
|
+
: [
|
|
242
|
+
...errors.map((e) => e.message),
|
|
243
|
+
'',
|
|
244
|
+
'Pass --verbose to see the stacktraces.',
|
|
245
|
+
],
|
|
246
|
+
};
|
|
247
|
+
}
|
|
225
248
|
/**
|
|
226
249
|
* This error should be thrown when a `createNodesV2` function hits a recoverable error.
|
|
227
250
|
* It allows Nx to recieve partial results and continue processing for better UX.
|
|
@@ -476,9 +499,25 @@ function indentString(str, indent) {
|
|
|
476
499
|
.join('\n'));
|
|
477
500
|
}
|
|
478
501
|
function formatErrorStackAndCause(error) {
|
|
479
|
-
const cause = error.cause
|
|
480
|
-
return (error.stack +
|
|
481
|
-
(cause
|
|
482
|
-
|
|
483
|
-
|
|
502
|
+
const cause = describeCause(error.cause);
|
|
503
|
+
return ((error.stack ?? error.message) +
|
|
504
|
+
(cause ? `\nCaused by: \n${indentString(cause, 2)}` : ''));
|
|
505
|
+
}
|
|
506
|
+
function describeCause(cause) {
|
|
507
|
+
if (!cause) {
|
|
508
|
+
return null;
|
|
509
|
+
}
|
|
510
|
+
if (cause instanceof Error) {
|
|
511
|
+
return cause.stack ?? cause.message;
|
|
512
|
+
}
|
|
513
|
+
if (typeof cause === 'object') {
|
|
514
|
+
const { stack, message } = cause;
|
|
515
|
+
if (typeof stack === 'string') {
|
|
516
|
+
return stack;
|
|
517
|
+
}
|
|
518
|
+
if (typeof message === 'string') {
|
|
519
|
+
return message;
|
|
520
|
+
}
|
|
521
|
+
}
|
|
522
|
+
return String(cause);
|
|
484
523
|
}
|
|
@@ -22,6 +22,8 @@ export declare class LockFileChange implements Change {
|
|
|
22
22
|
export declare function isWholeFileChange(change: Change): change is WholeFileChange;
|
|
23
23
|
export declare function isDeletedFileChange(change: Change): change is DeletedFileChange;
|
|
24
24
|
export declare function isLockFileChange(change: Change): change is LockFileChange;
|
|
25
|
+
/** Whether a touched file was deleted. Much cheaper than `getChanges()`. */
|
|
26
|
+
export declare function isDeletedFile(file: string): boolean;
|
|
25
27
|
export declare function calculateFileChanges(files: string[], nxArgs?: NxArgs, readFileAtRevision?: {
|
|
26
28
|
(f: string, r: string | void): string;
|
|
27
29
|
}, ignore?: ReturnType<typeof ignore>): FileChange[];
|
|
@@ -4,6 +4,7 @@ exports.TEN_MEGABYTES = exports.LockFileChange = exports.DeletedFileChange = exp
|
|
|
4
4
|
exports.isWholeFileChange = isWholeFileChange;
|
|
5
5
|
exports.isDeletedFileChange = isDeletedFileChange;
|
|
6
6
|
exports.isLockFileChange = isLockFileChange;
|
|
7
|
+
exports.isDeletedFile = isDeletedFile;
|
|
7
8
|
exports.calculateFileChanges = calculateFileChanges;
|
|
8
9
|
exports.defaultFileRead = defaultFileRead;
|
|
9
10
|
exports.readPackageJson = readPackageJson;
|
|
@@ -14,6 +15,7 @@ const path_1 = require("path");
|
|
|
14
15
|
const fileutils_1 = require("../utils/fileutils");
|
|
15
16
|
const git_revision_1 = require("../utils/git-revision");
|
|
16
17
|
const ignore_1 = require("../utils/ignore");
|
|
18
|
+
const native_1 = require("../native");
|
|
17
19
|
const json_diff_1 = require("../utils/json-diff");
|
|
18
20
|
const workspace_root_1 = require("../utils/workspace-root");
|
|
19
21
|
class WholeFileChange {
|
|
@@ -53,6 +55,10 @@ const TEXT_LOCK_FILES = new Set([
|
|
|
53
55
|
'bun.lock',
|
|
54
56
|
]);
|
|
55
57
|
const BINARY_LOCK_FILES = new Set(['bun.lockb']);
|
|
58
|
+
/** Whether a touched file was deleted. Much cheaper than `getChanges()`. */
|
|
59
|
+
function isDeletedFile(file) {
|
|
60
|
+
return !(0, fs_1.existsSync)((0, path_1.join)(workspace_root_1.workspaceRoot, file));
|
|
61
|
+
}
|
|
56
62
|
function calculateFileChanges(files, nxArgs, readFileAtRevision = defaultReadFileAtRevision, ignore = (0, ignore_1.getIgnoreObject)()) {
|
|
57
63
|
files = files.filter((f) => !ignore.ignores(f));
|
|
58
64
|
return files.map((f) => {
|
|
@@ -61,7 +67,7 @@ function calculateFileChanges(files, nxArgs, readFileAtRevision = defaultReadFil
|
|
|
61
67
|
return {
|
|
62
68
|
file: f,
|
|
63
69
|
getChanges: () => {
|
|
64
|
-
if (
|
|
70
|
+
if (isDeletedFile(f)) {
|
|
65
71
|
return [new DeletedFileChange()];
|
|
66
72
|
}
|
|
67
73
|
if (!nxArgs) {
|
|
@@ -85,7 +91,10 @@ function calculateFileChanges(files, nxArgs, readFileAtRevision = defaultReadFil
|
|
|
85
91
|
try {
|
|
86
92
|
const atBase = readFileAtRevision(f, nxArgs.base);
|
|
87
93
|
const atHead = readFileAtRevision(f, nxArgs.head);
|
|
88
|
-
|
|
94
|
+
// Unset when either side is not strict JSON.
|
|
95
|
+
return ((0, native_1.diffJson)(atBase, atHead) ?? [
|
|
96
|
+
new WholeFileChange(),
|
|
97
|
+
]);
|
|
89
98
|
}
|
|
90
99
|
catch (e) {
|
|
91
100
|
return [new WholeFileChange()];
|
|
@@ -123,7 +132,7 @@ function defaultReadFileAtRevision(file, revision) {
|
|
|
123
132
|
try {
|
|
124
133
|
const filePathInGitRepository = getFilePathInGitRepository(file);
|
|
125
134
|
return !revision
|
|
126
|
-
? (0, fs_1.readFileSync)(file, 'utf-8')
|
|
135
|
+
? (0, fs_1.readFileSync)((0, path_1.join)(workspace_root_1.workspaceRoot, file), 'utf-8')
|
|
127
136
|
: (0, child_process_1.execFileSync)('git', ['show', `${revision}:${filePathInGitRepository}`], {
|
|
128
137
|
maxBuffer: exports.TEN_MEGABYTES,
|
|
129
138
|
stdio: ['pipe', 'pipe', 'ignore'],
|
|
@@ -17,7 +17,10 @@ export declare const nxFileMap: string;
|
|
|
17
17
|
export declare const nxSourceMaps: string;
|
|
18
18
|
export declare function ensureCacheDirectory(): void;
|
|
19
19
|
export declare function readFileMapCache(): null | FileMapCache;
|
|
20
|
-
export declare function readProjectGraphCache(minimumComputedAt?: number): null |
|
|
20
|
+
export declare function readProjectGraphCache(minimumComputedAt?: number): null | {
|
|
21
|
+
projectGraph: ProjectGraph;
|
|
22
|
+
computedAt: number | undefined;
|
|
23
|
+
};
|
|
21
24
|
export declare function readSourceMapsCache(): null | ConfigurationSourceMaps;
|
|
22
25
|
export declare function createProjectFileMapCache(nxJson: NxJsonConfiguration<'*' | string[]>, packageJsonDeps: Record<string, string>, fileMap: FileMap, tsConfig: {
|
|
23
26
|
compilerOptions?: {
|
|
@@ -26,7 +29,7 @@ export declare function createProjectFileMapCache(nxJson: NxJsonConfiguration<'*
|
|
|
26
29
|
};
|
|
27
30
|
};
|
|
28
31
|
}, externalNodesHash: string): FileMapCache;
|
|
29
|
-
export declare function writeCache(cache: FileMapCache, projectGraph: ProjectGraph, sourceMaps: ConfigurationSourceMaps, errors: ProjectGraphErrorTypes[]): void;
|
|
32
|
+
export declare function writeCache(cache: FileMapCache, projectGraph: ProjectGraph, sourceMaps: ConfigurationSourceMaps, errors: ProjectGraphErrorTypes[], computedAt: number): void;
|
|
30
33
|
/**
|
|
31
34
|
* Writes the cache only if the on-disk cache file has been modified since
|
|
32
35
|
* this process last wrote it (i.e. an external process overwrote it), or
|
|
@@ -83,7 +83,7 @@ function readProjectGraphCache(minimumComputedAt) {
|
|
|
83
83
|
}
|
|
84
84
|
throw new error_types_1.ProjectGraphError(errors, projectGraphCache, readSourceMapsCache());
|
|
85
85
|
}
|
|
86
|
-
return projectGraphCache;
|
|
86
|
+
return { projectGraph: projectGraphCache, computedAt };
|
|
87
87
|
}
|
|
88
88
|
else {
|
|
89
89
|
return null;
|
|
@@ -140,7 +140,7 @@ function createProjectFileMapCache(nxJson, packageJsonDeps, fileMap, tsConfig, e
|
|
|
140
140
|
* when no external process has modified the cache file since the last write.
|
|
141
141
|
*/
|
|
142
142
|
let lastWrittenCacheMtimeMs;
|
|
143
|
-
function writeCache(cache, projectGraph, sourceMaps, errors) {
|
|
143
|
+
function writeCache(cache, projectGraph, sourceMaps, errors, computedAt) {
|
|
144
144
|
perf_hooks_1.performance.mark('write cache:start');
|
|
145
145
|
let retry = 1;
|
|
146
146
|
let done = false;
|
|
@@ -158,7 +158,7 @@ function writeCache(cache, projectGraph, sourceMaps, errors) {
|
|
|
158
158
|
(0, fileutils_1.writeJsonFile)(tmpProjectGraphPath, {
|
|
159
159
|
...projectGraph,
|
|
160
160
|
errors,
|
|
161
|
-
computedAt
|
|
161
|
+
computedAt,
|
|
162
162
|
});
|
|
163
163
|
(0, node_fs_1.renameSync)(tmpProjectGraphPath, exports.nxProjectGraph);
|
|
164
164
|
(0, fileutils_1.writeJsonFile)(tmpSourceMapPath, sourceMaps);
|
|
@@ -221,7 +221,7 @@ function writeCacheIfStale(cache, projectGraph, sourceMaps, errors) {
|
|
|
221
221
|
// File doesn't exist or can't be stat'd — proceed with write
|
|
222
222
|
}
|
|
223
223
|
}
|
|
224
|
-
writeCache(cache, projectGraph, sourceMaps, errors);
|
|
224
|
+
writeCache(cache, projectGraph, sourceMaps, errors, Date.now());
|
|
225
225
|
}
|
|
226
226
|
function shouldRecomputeWholeGraph(cache, packageJsonDeps, projects, nxJson, tsConfig, externalNodesHash) {
|
|
227
227
|
if (cache.version !== '6.0') {
|