@ohos-ports/nx 23.3.0-beta.3 → 24.0.2-beta.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 +3 -6
- package/dist/bin/nx.js +2 -2
- package/dist/bin/post-install.js +5 -3
- package/dist/nx-cloud-internals.d.ts +1 -0
- package/dist/nx-cloud-internals.js +7 -1
- package/dist/src/adapter/ngcli-adapter.js +2 -2
- package/dist/src/ai/clone-ai-config-repo.js +49 -12
- package/dist/src/command-line/add/add.d.ts +2 -0
- package/dist/src/command-line/add/add.js +24 -6
- package/dist/src/command-line/affected/affected.js +2 -2
- package/dist/src/command-line/configure-ai-agents/configure-ai-agents.js +1 -13
- package/dist/src/command-line/graph/graph.js +38 -10
- package/dist/src/command-line/init/command-object.js +0 -12
- package/dist/src/command-line/init/implementation/add-nx-to-nest.js +21 -62
- package/dist/src/command-line/init/init-v2.js +1 -3
- package/dist/src/command-line/migrate/agentic/close-agent-session.d.ts +1 -1
- package/dist/src/command-line/migrate/agentic/close-agent-session.js +4 -3
- package/dist/src/command-line/migrate/agentic/definitions.d.ts +1 -3
- package/dist/src/command-line/migrate/agentic/definitions.js +5 -97
- package/dist/src/command-line/migrate/agentic/handoff-gitignore.d.ts +7 -45
- package/dist/src/command-line/migrate/agentic/handoff-gitignore.js +9 -51
- package/dist/src/command-line/migrate/agentic/handoff.d.ts +1 -43
- package/dist/src/command-line/migrate/agentic/handoff.js +3 -119
- package/dist/src/command-line/migrate/agentic/instruction-files.d.ts +0 -21
- package/dist/src/command-line/migrate/agentic/instruction-files.js +6 -27
- package/dist/src/command-line/migrate/agentic/master/run-master-session.d.ts +19 -1
- package/dist/src/command-line/migrate/agentic/master/run-master-session.js +88 -49
- package/dist/src/command-line/migrate/agentic/master/spawn-master.d.ts +1 -0
- package/dist/src/command-line/migrate/agentic/master/spawn-master.js +86 -24
- package/dist/src/command-line/migrate/agentic/print-dropped-agent-context.d.ts +2 -2
- package/dist/src/command-line/migrate/agentic/print-dropped-agent-context.js +2 -2
- package/dist/src/command-line/migrate/agentic/prompts/fragments.d.ts +1 -12
- package/dist/src/command-line/migrate/agentic/prompts/fragments.js +8 -17
- package/dist/src/command-line/migrate/agentic/prompts/shared-rendering.d.ts +0 -15
- package/dist/src/command-line/migrate/agentic/prompts/shared-rendering.js +3 -100
- package/dist/src/command-line/migrate/agentic/select.d.ts +12 -6
- package/dist/src/command-line/migrate/agentic/select.js +38 -8
- package/dist/src/command-line/migrate/agentic/types.d.ts +9 -68
- package/dist/src/command-line/migrate/agentic/types.js +6 -8
- package/dist/src/command-line/migrate/command-object.js +6 -10
- package/dist/src/command-line/migrate/execute-migration.d.ts +6 -6
- package/dist/src/command-line/migrate/execute-migration.js +25 -15
- package/dist/src/command-line/migrate/migrate-analytics.d.ts +18 -1
- package/dist/src/command-line/migrate/migrate-analytics.js +38 -0
- package/dist/src/command-line/migrate/migrate-commits.d.ts +29 -17
- package/dist/src/command-line/migrate/migrate-commits.js +86 -32
- package/dist/src/command-line/migrate/migrate-config.d.ts +6 -6
- package/dist/src/command-line/migrate/migrate-config.js +12 -6
- package/dist/src/command-line/migrate/migrate-output.d.ts +1 -6
- package/dist/src/command-line/migrate/migrate-output.js +1 -10
- package/dist/src/command-line/migrate/migrate.d.ts +6 -30
- package/dist/src/command-line/migrate/migrate.js +257 -255
- package/dist/src/command-line/migrate/resolve-package-version.d.ts +2 -4
- package/dist/src/command-line/migrate/resolve-package-version.js +2 -35
- package/dist/src/command-line/migrate/run/agent-output.d.ts +2 -0
- package/dist/src/command-line/migrate/run/agent-output.js +9 -0
- package/dist/src/command-line/migrate/run/broker.d.ts +14 -5
- package/dist/src/command-line/migrate/run/broker.js +69 -21
- package/dist/src/command-line/migrate/run/clean-retry.js +4 -2
- package/dist/src/command-line/migrate/run/existing-run-report.d.ts +1 -1
- package/dist/src/command-line/migrate/run/existing-run-report.js +7 -5
- package/dist/src/command-line/migrate/run/give-up.d.ts +4 -3
- package/dist/src/command-line/migrate/run/give-up.js +8 -5
- package/dist/src/command-line/migrate/run/index.d.ts +7 -5
- package/dist/src/command-line/migrate/run/index.js +16 -1
- package/dist/src/command-line/migrate/run/issues.js +7 -2
- package/dist/src/command-line/migrate/run/orchestrator.d.ts +61 -4
- package/dist/src/command-line/migrate/run/orchestrator.js +397 -133
- package/dist/src/command-line/migrate/run/run-state.d.ts +17 -1
- package/dist/src/command-line/migrate/run/run-state.js +41 -2
- package/dist/src/command-line/migrate/run/runbook.d.ts +1 -0
- package/dist/src/command-line/migrate/run/runbook.js +115 -18
- package/dist/src/command-line/migrate/run/state-lock.d.ts +29 -4
- package/dist/src/command-line/migrate/run/state-lock.js +102 -10
- package/dist/src/command-line/migrate/run/state-machine.js +4 -1
- package/dist/src/command-line/migrate/run/util.d.ts +7 -2
- package/dist/src/command-line/migrate/run/util.js +30 -3
- package/dist/src/command-line/migrate/run/worker.d.ts +1 -1
- package/dist/src/command-line/migrate/run/worker.js +252 -250
- package/dist/src/command-line/migrate/sort-migrations.d.ts +1 -7
- package/dist/src/command-line/migrate/sort-migrations.js +1 -12
- package/dist/src/command-line/nx-cloud/connect/connect-to-nx-cloud.js +17 -12
- package/dist/src/command-line/release/changelog.js +9 -6
- package/dist/src/command-line/release/config/config.d.ts +1 -0
- package/dist/src/command-line/release/config/config.js +48 -9
- package/dist/src/command-line/release/release.js +2 -2
- package/dist/src/command-line/release/utils/git.js +8 -7
- package/dist/src/command-line/release/utils/interpolate-release-config.d.ts +6 -0
- package/dist/src/command-line/release/utils/interpolate-release-config.js +39 -0
- package/dist/src/command-line/release/utils/release-graph.d.ts +5 -0
- package/dist/src/command-line/release/utils/release-graph.js +1 -0
- package/dist/src/command-line/release/utils/remote-release-clients/github.js +5 -6
- package/dist/src/command-line/release/utils/remote-release-clients/gitlab.js +5 -6
- package/dist/src/command-line/release/utils/resolve-changelog-renderer.js +2 -2
- package/dist/src/command-line/release/utils/shared.js +10 -10
- package/dist/src/command-line/release/utils/version-plan-utils.d.ts +3 -12
- package/dist/src/command-line/release/utils/version-plan-utils.js +33 -55
- package/dist/src/command-line/release/version/version-actions.js +2 -1
- package/dist/src/command-line/release/version.js +5 -2
- package/dist/src/command-line/repair/repair.js +1 -1
- package/dist/src/command-line/report/report.js +1 -1
- package/dist/src/command-line/reset/reset.js +58 -62
- package/dist/src/command-line/run/executor-utils.js +1 -0
- package/dist/src/command-line/run/run-one.d.ts +20 -1
- package/dist/src/command-line/run/run-one.js +153 -5
- package/dist/src/command-line/run/run.js +2 -1
- package/dist/src/command-line/show/projects.js +5 -3
- package/dist/src/command-line/show/show-target/info.d.ts +10 -1
- package/dist/src/command-line/show/show-target/info.js +100 -15
- package/dist/src/command-line/show/show-target/inputs.js +10 -2
- package/dist/src/command-line/show/show-target/utils.js +1 -0
- package/dist/src/command-line/watch/command-object.js +3 -22
- package/dist/src/command-line/watch/watch.d.ts +0 -7
- package/dist/src/command-line/watch/watch.js +1 -1
- package/dist/src/command-line/yargs-utils/shared-options.js +1 -1
- package/dist/src/config/misc-interfaces.d.ts +18 -0
- package/dist/src/config/nx-json.d.ts +22 -11
- package/dist/src/config/task-graph.d.ts +1 -1
- package/dist/src/config/workspace-json-project-json.d.ts +88 -0
- package/dist/src/core/graph/main.js +1 -1
- package/dist/src/core/graph/runtime.js +1 -1
- package/dist/src/core/graph/styles.css +1 -1
- package/dist/src/core/graph/styles.js +1 -1
- package/dist/src/daemon/client/client.d.ts +15 -0
- package/dist/src/daemon/client/client.js +181 -71
- package/dist/src/daemon/client/daemon-socket-messenger.d.ts +1 -1
- package/dist/src/daemon/client/daemon-socket-messenger.js +2 -2
- package/dist/src/daemon/server/client-socket-context.js +1 -1
- package/dist/src/daemon/server/handle-configure-ai-agents.js +2 -2
- package/dist/src/daemon/server/handle-process-in-background.js +21 -9
- package/dist/src/daemon/server/handle-select-affected-tasks.d.ts +2 -1
- package/dist/src/daemon/server/handle-select-affected-tasks.js +21 -13
- package/dist/src/daemon/server/native-js-loader.d.ts +1 -0
- package/dist/src/daemon/server/native-js-loader.js +21 -0
- package/dist/src/daemon/server/nx-console-operations.js +2 -2
- package/dist/src/daemon/server/project-graph-incremental-recomputation.js +4 -8
- package/dist/src/daemon/server/server.d.ts +2 -1
- package/dist/src/daemon/server/server.js +17 -4
- package/dist/src/daemon/server/shutdown-utils.js +1 -4
- package/dist/src/daemon/server/start.d.ts +1 -0
- package/dist/src/daemon/server/start.js +2 -0
- package/dist/src/daemon/socket-utils.d.ts +11 -9
- package/dist/src/daemon/socket-utils.js +31 -61
- package/dist/src/daemon/tmp-dir.d.ts +19 -14
- package/dist/src/daemon/tmp-dir.js +142 -354
- package/dist/src/devkit-exports.d.ts +9 -1
- package/dist/src/devkit-exports.js +12 -1
- package/dist/src/devkit-internals.d.ts +6 -5
- package/dist/src/devkit-internals.js +13 -4
- package/dist/src/executors/run-commands/run-commands.impl.d.ts +4 -2
- package/dist/src/executors/run-commands/run-commands.impl.js +53 -27
- package/dist/src/executors/run-commands/running-tasks.d.ts +13 -4
- package/dist/src/executors/run-commands/running-tasks.js +148 -95
- package/dist/src/executors/run-commands/schema.json +1 -1
- package/dist/src/hasher/check-task-files.js +5 -8
- package/dist/src/hasher/file-hasher.js +9 -7
- package/dist/src/hasher/hash-task.js +4 -0
- package/dist/src/hasher/native-task-hasher-impl.js +3 -1
- package/dist/src/hasher/task-hasher.d.ts +2 -0
- package/dist/src/hasher/task-hasher.js +4 -1
- package/dist/src/migrations/update-23-2-0/set-cache-on-executor-target-defaults.d.ts +1 -2
- package/dist/src/migrations/update-23-2-0/set-cache-on-executor-target-defaults.js +6 -11
- package/dist/src/migrations/update-23-2-0/set-cache-on-executor-target-defaults.md +2 -2
- package/dist/src/migrations/update-24-0-0/enable-legacy-affected.d.ts +4 -0
- package/dist/src/migrations/update-24-0-0/enable-legacy-affected.js +15 -0
- package/dist/src/migrations/update-24-0-0/enable-legacy-affected.md +30 -0
- package/dist/src/migrations/update-24-0-0/find-custom-hashers.d.ts +3 -0
- package/dist/src/migrations/update-24-0-0/find-custom-hashers.js +100 -0
- package/dist/src/migrations/update-24-0-0/find-custom-hashers.md +63 -0
- package/dist/src/migrations/update-24-0-0/move-custom-hashers-to-inputs.md +146 -0
- package/dist/src/migrations/update-24-0-0/rename-ultracache-ignore-options.d.ts +3 -0
- package/dist/src/migrations/update-24-0-0/rename-ultracache-ignore-options.js +130 -0
- package/dist/src/migrations/update-24-0-0/rename-ultracache-ignore-options.md +62 -0
- package/dist/src/native/assert-supported-platform.js +1 -1
- package/dist/src/native/index.d.ts +238 -18
- package/dist/src/native/index.js +6 -1
- package/dist/src/native/native-bindings.js +15 -6
- package/dist/src/native/nx.openharmony-arm64.node +0 -0
- package/dist/src/native/nx.wasi-browser.js +1 -0
- package/dist/src/native/nx.wasi.cjs +1 -0
- package/dist/src/native/nx.wasm32-wasi.debug.wasm +0 -0
- package/dist/src/native/nx.wasm32-wasi.wasm +0 -0
- package/dist/src/nx-cloud/update-manager.d.ts +14 -0
- package/dist/src/nx-cloud/update-manager.js +237 -50
- package/dist/src/plugins/js/lock-file/pnpm-parser.js +3 -4
- package/dist/src/plugins/js/lock-file/pruned-output.d.ts +2 -2
- package/dist/src/plugins/js/lock-file/pruned-output.js +4 -4
- package/dist/src/plugins/js/utils/register.js +9 -4
- package/dist/src/project-graph/affected/affected-tasks.d.ts +9 -6
- package/dist/src/project-graph/affected/affected-tasks.js +31 -7
- package/dist/src/project-graph/plugins/isolation/isolated-plugin.js +7 -0
- package/dist/src/project-graph/plugins/loaded-nx-plugin.js +49 -6
- package/dist/src/project-graph/utils/project-configuration/target-merging.js +1 -1
- package/dist/src/project-graph/utils/project-configuration/target-normalization.js +12 -133
- package/dist/src/project-graph/utils/project-configuration-utils.js +2 -2
- package/dist/src/project-graph/utils/retrieve-workspace-files.js +27 -6
- package/dist/src/tasks-runner/create-task-graph.d.ts +8 -7
- package/dist/src/tasks-runner/create-task-graph.js +50 -27
- package/dist/src/tasks-runner/default-tasks-runner.js +1 -1
- package/dist/src/tasks-runner/init-tasks-runner.js +116 -59
- package/dist/src/tasks-runner/life-cycle.d.ts +4 -1
- package/dist/src/tasks-runner/life-cycle.js +7 -0
- package/dist/src/tasks-runner/life-cycles/performance-analysis.d.ts +5 -2
- package/dist/src/tasks-runner/life-cycles/performance-analysis.js +13 -7
- package/dist/src/tasks-runner/life-cycles/performance-life-cycle.d.ts +4 -3
- package/dist/src/tasks-runner/life-cycles/performance-life-cycle.js +9 -2
- package/dist/src/tasks-runner/life-cycles/static-run-many-terminal-output-life-cycle.js +5 -2
- package/dist/src/tasks-runner/life-cycles/static-run-one-terminal-output-life-cycle.js +4 -1
- package/dist/src/tasks-runner/life-cycles/summary-terminal-output-life-cycle.js +5 -1
- package/dist/src/tasks-runner/pseudo-ipc.d.ts +1 -0
- package/dist/src/tasks-runner/pseudo-ipc.js +4 -0
- package/dist/src/tasks-runner/pseudo-terminal.d.ts +1 -1
- package/dist/src/tasks-runner/pseudo-terminal.js +2 -2
- package/dist/src/tasks-runner/readiness/executor-ready-signal.d.ts +7 -0
- package/dist/src/tasks-runner/readiness/executor-ready-signal.js +43 -0
- package/dist/src/tasks-runner/readiness/probes.d.ts +14 -0
- package/dist/src/tasks-runner/readiness/probes.js +101 -0
- package/dist/src/tasks-runner/readiness/ready-signal-server.d.ts +18 -0
- package/dist/src/tasks-runner/readiness/ready-signal-server.js +72 -0
- package/dist/src/tasks-runner/readiness/ready-signal.d.ts +33 -0
- package/dist/src/tasks-runner/readiness/ready-signal.js +92 -0
- package/dist/src/tasks-runner/readiness/ready-when.d.ts +84 -0
- package/dist/src/tasks-runner/readiness/ready-when.js +371 -0
- package/dist/src/tasks-runner/readiness/startup-host.d.ts +1 -0
- package/dist/src/tasks-runner/readiness/startup-host.js +32 -0
- package/dist/src/tasks-runner/run-command.d.ts +6 -2
- package/dist/src/tasks-runner/run-command.js +21 -31
- package/dist/src/tasks-runner/run-outcome.d.ts +16 -0
- package/dist/src/tasks-runner/run-outcome.js +39 -0
- package/dist/src/tasks-runner/running-tasks/batch-process.js +6 -0
- package/dist/src/tasks-runner/running-tasks/node-child-process.js +5 -4
- package/dist/src/tasks-runner/running-tasks/running-task.d.ts +1 -1
- package/dist/src/tasks-runner/task-env.d.ts +10 -0
- package/dist/src/tasks-runner/task-env.js +37 -5
- package/dist/src/tasks-runner/task-graph-utils.d.ts +9 -6
- package/dist/src/tasks-runner/task-graph-utils.js +17 -12
- package/dist/src/tasks-runner/task-orchestrator.d.ts +62 -18
- package/dist/src/tasks-runner/task-orchestrator.js +750 -150
- package/dist/src/tasks-runner/tasks-runner.d.ts +1 -1
- package/dist/src/tasks-runner/tasks-schedule.d.ts +18 -1
- package/dist/src/tasks-runner/tasks-schedule.js +63 -6
- package/dist/src/tasks-runner/tokens.d.ts +54 -0
- package/dist/src/tasks-runner/tokens.js +161 -0
- package/dist/src/tasks-runner/utils.d.ts +35 -6
- package/dist/src/tasks-runner/utils.js +149 -68
- package/dist/src/ultracache/ci-status.d.ts +24 -0
- package/dist/src/ultracache/ci-status.js +87 -0
- package/dist/src/ultracache/config.d.ts +3 -3
- package/dist/src/ultracache/config.js +4 -4
- package/dist/src/ultracache/fetch.d.ts +2 -0
- package/dist/src/ultracache/fetch.js +1 -0
- package/dist/src/ultracache/overrides.js +4 -0
- package/dist/src/utils/acknowledge-build-scripts.d.ts +34 -1
- package/dist/src/utils/acknowledge-build-scripts.js +171 -32
- package/dist/src/utils/child-process.js +2 -1
- package/dist/src/utils/find-matching-projects.js +9 -6
- package/dist/src/utils/git-utils.d.ts +12 -5
- package/dist/src/utils/git-utils.js +69 -11
- package/dist/src/utils/long-running-target.d.ts +1 -3
- package/dist/src/utils/long-running-target.js +1 -3
- package/dist/src/utils/nx-package-group.js +1 -1
- package/dist/src/utils/output.d.ts +4 -3
- package/dist/src/utils/output.js +4 -3
- package/dist/src/utils/owned-private-dir.d.ts +1 -17
- package/dist/src/utils/owned-private-dir.js +10 -62
- package/dist/src/utils/package-json.js +1 -1
- package/dist/src/utils/package-manager.d.ts +8 -0
- package/dist/src/utils/package-manager.js +65 -8
- package/dist/src/utils/perf-hooks.d.ts +1 -0
- package/dist/src/utils/plugins/core-plugins.js +5 -1
- package/dist/src/utils/progress-topics.d.ts +1 -0
- package/dist/src/utils/progress-topics.js +1 -0
- package/dist/src/utils/safe-spawn.js +1 -5
- package/dist/src/utils/shell-quoting.d.ts +8 -1
- package/dist/src/utils/shell-quoting.js +12 -1
- package/dist/src/utils/spawn-without-terminal.d.ts +27 -0
- package/dist/src/utils/spawn-without-terminal.js +110 -0
- package/dist/src/utils/string-similarity.d.ts +38 -0
- package/dist/src/utils/string-similarity.js +108 -0
- package/dist/src/utils/versions.js +1 -1
- package/migrations.json +20 -6
- package/package.json +15 -24
- package/schemas/migrations-schema.json +11 -0
- package/schemas/nx-schema.json +133 -11
- package/schemas/project-schema.json +114 -4
- package/dist/src/command-line/migrate/agentic/prompts/generic-validation.d.ts +0 -56
- package/dist/src/command-line/migrate/agentic/prompts/generic-validation.js +0 -67
- package/dist/src/command-line/migrate/agentic/prompts/hybrid-prompt-migration.d.ts +0 -49
- package/dist/src/command-line/migrate/agentic/prompts/hybrid-prompt-migration.js +0 -53
- package/dist/src/command-line/migrate/agentic/prompts/prompt-migration.d.ts +0 -26
- package/dist/src/command-line/migrate/agentic/prompts/prompt-migration.js +0 -27
- package/dist/src/command-line/migrate/agentic/prompts/system-prompt.d.ts +0 -70
- package/dist/src/command-line/migrate/agentic/prompts/system-prompt.js +0 -113
- package/dist/src/command-line/migrate/agentic/run-step.d.ts +0 -68
- package/dist/src/command-line/migrate/agentic/run-step.js +0 -148
- package/dist/src/command-line/migrate/agentic/runner.d.ts +0 -21
- package/dist/src/command-line/migrate/agentic/runner.js +0 -262
- package/dist/src/migrations/update-23-0-0/consolidate-release-tag-config.d.ts +0 -9
- package/dist/src/migrations/update-23-0-0/consolidate-release-tag-config.js +0 -18
- package/dist/src/tasks-runner/legacy-depends-on-warning.d.ts +0 -18
- package/dist/src/tasks-runner/legacy-depends-on-warning.js +0 -109
|
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.NxCloudClientUnavailableError = exports.NxCloudEnterpriseOutdatedError = void 0;
|
|
4
4
|
exports.verifyOrUpdateNxCloudClient = verifyOrUpdateNxCloudClient;
|
|
5
5
|
exports.getBundleInstallDefaultLocation = getBundleInstallDefaultLocation;
|
|
6
|
+
exports.downloadAndExtractClientBundle = downloadAndExtractClientBundle;
|
|
6
7
|
const tslib_1 = require("tslib");
|
|
7
8
|
const fs_1 = require("fs");
|
|
8
9
|
const zlib_1 = require("zlib");
|
|
@@ -16,6 +17,7 @@ const tar = tslib_1.__importStar(require("tar-stream"));
|
|
|
16
17
|
const cache_directory_1 = require("../utils/cache-directory");
|
|
17
18
|
const is_ci_1 = require("../utils/is-ci");
|
|
18
19
|
const crypto_1 = require("crypto");
|
|
20
|
+
const native_1 = require("../native");
|
|
19
21
|
const workspace_root_1 = require("../utils/workspace-root");
|
|
20
22
|
class NxCloudEnterpriseOutdatedError extends Error {
|
|
21
23
|
constructor(url) {
|
|
@@ -74,13 +76,13 @@ async function verifyOrUpdateNxCloudClient(options) {
|
|
|
74
76
|
if (version === 'NX_ENTERPRISE_OUTDATED_IMAGE') {
|
|
75
77
|
throw new NxCloudEnterpriseOutdatedError(apiUrl);
|
|
76
78
|
}
|
|
77
|
-
const
|
|
78
|
-
(0, debug_logger_1.debugLog)('Done: ', fullPath);
|
|
79
|
-
const nxCloudClient = require(fullPath);
|
|
79
|
+
const installedBundle = await downloadAndExtractClientBundle(httpClient, version, url);
|
|
80
|
+
(0, debug_logger_1.debugLog)('Done: ', installedBundle.fullPath);
|
|
81
|
+
const nxCloudClient = require(installedBundle.fullPath);
|
|
80
82
|
if (nxCloudClient.commands === undefined) {
|
|
81
83
|
throw new NxCloudEnterpriseOutdatedError(apiUrl);
|
|
82
84
|
}
|
|
83
|
-
return { version, nxCloudClient };
|
|
85
|
+
return { version: installedBundle.version, nxCloudClient };
|
|
84
86
|
}
|
|
85
87
|
if (currentBundle === null) {
|
|
86
88
|
throw new NxCloudClientUnavailableError();
|
|
@@ -114,6 +116,25 @@ function getBundleInstallDefaultLocation() {
|
|
|
114
116
|
return (0, path_1.join)((0, is_ci_1.isCI)() ? (0, cache_directory_1.cacheDirectoryForWorkspace)(workspace_root_1.workspaceRoot) : cache_directory_1.cacheDir, 'cloud');
|
|
115
117
|
}
|
|
116
118
|
const runnerBundleInstallDirectory = getBundleInstallDefaultLocation();
|
|
119
|
+
// Control files live outside the install directory. Released nx versions load
|
|
120
|
+
// any directory there as a bundle, so they would `require` a state directory
|
|
121
|
+
// placed inside it.
|
|
122
|
+
const stateDirectory = (0, fs_1.existsSync)((0, path_1.join)(workspace_root_1.workspaceRoot, 'nx.json'))
|
|
123
|
+
? (0, path_1.join)(cache_directory_1.workspaceDataDirectory, 'nx-cloud')
|
|
124
|
+
: `${runnerBundleInstallDirectory}-state`;
|
|
125
|
+
function ensureStateDirectory() {
|
|
126
|
+
(0, fs_1.mkdirSync)(stateDirectory, { recursive: true });
|
|
127
|
+
}
|
|
128
|
+
const downloadLockFilePath = (0, path_1.join)(stateDirectory, 'download.lock');
|
|
129
|
+
// The record lives beside the lockfile rather than inside it. Windows
|
|
130
|
+
// byte-range locks are mandatory and handle-scoped, so writing to a file this
|
|
131
|
+
// process holds an exclusive lock on fails with ERROR_LOCK_VIOLATION. It also
|
|
132
|
+
// matches the convention elsewhere in nx: project-graph.lock and run.json.lock
|
|
133
|
+
// are never written to.
|
|
134
|
+
const downloadRecordFilePath = (0, path_1.join)(stateDirectory, 'download.record');
|
|
135
|
+
// A version names a directory that is created and later deleted, so a value
|
|
136
|
+
// from the server must not be able to escape the install directory.
|
|
137
|
+
const VALID_BUNDLE_VERSION = /^[A-Za-z0-9][A-Za-z0-9._-]*$/;
|
|
117
138
|
function getLatestInstalledRunnerBundle() {
|
|
118
139
|
if (!(0, fs_1.existsSync)(runnerBundleInstallDirectory)) {
|
|
119
140
|
(0, fs_1.mkdirSync)(runnerBundleInstallDirectory, { recursive: true });
|
|
@@ -121,7 +142,9 @@ function getLatestInstalledRunnerBundle() {
|
|
|
121
142
|
try {
|
|
122
143
|
const installedBundles = (0, fs_1.readdirSync)(runnerBundleInstallDirectory)
|
|
123
144
|
.filter((potentialDirectory) => {
|
|
124
|
-
|
|
145
|
+
// '.tmp-*' directories are in-progress or crashed downloads
|
|
146
|
+
return (!potentialDirectory.startsWith('.') &&
|
|
147
|
+
(0, fs_1.statSync)((0, path_1.join)(runnerBundleInstallDirectory, potentialDirectory)).isDirectory());
|
|
125
148
|
})
|
|
126
149
|
.map((fileOrDirectory) => ({
|
|
127
150
|
version: fileOrDirectory,
|
|
@@ -131,7 +154,13 @@ function getLatestInstalledRunnerBundle() {
|
|
|
131
154
|
// No installed bundles
|
|
132
155
|
return null;
|
|
133
156
|
}
|
|
134
|
-
|
|
157
|
+
// A contended install can leave several bundles on disk. The record names
|
|
158
|
+
// the directory an install last completed in, which is the one to run.
|
|
159
|
+
// Without a record the directory name is all there is to go on and is read
|
|
160
|
+
// as the version, which is right for a bundle an older nx installed and
|
|
161
|
+
// otherwise yields a version the server rejects, costing one more
|
|
162
|
+
// download.
|
|
163
|
+
return recordedBundle() ?? installedBundles[0];
|
|
135
164
|
}
|
|
136
165
|
catch (e) {
|
|
137
166
|
console.log('Could not read runner bundle path:', e.message);
|
|
@@ -170,7 +199,7 @@ async function verifyCurrentBundle(httpClient, currentBundle) {
|
|
|
170
199
|
});
|
|
171
200
|
}
|
|
172
201
|
function getLatestBundleVerificationTimestamp() {
|
|
173
|
-
const lockfilePath = (0, path_1.join)(
|
|
202
|
+
const lockfilePath = (0, path_1.join)(stateDirectory, 'verify.lock');
|
|
174
203
|
if ((0, fs_1.existsSync)(lockfilePath)) {
|
|
175
204
|
const timestampAsString = (0, fs_1.readFileSync)(lockfilePath, 'utf-8');
|
|
176
205
|
let timestampAsNumber;
|
|
@@ -185,7 +214,8 @@ function getLatestBundleVerificationTimestamp() {
|
|
|
185
214
|
return null;
|
|
186
215
|
}
|
|
187
216
|
function writeBundleVerificationLock() {
|
|
188
|
-
const lockfilePath = (0, path_1.join)(
|
|
217
|
+
const lockfilePath = (0, path_1.join)(stateDirectory, 'verify.lock');
|
|
218
|
+
ensureStateDirectory();
|
|
189
219
|
(0, fs_1.writeFileSync)(lockfilePath, new Date().getTime().toString(), 'utf-8');
|
|
190
220
|
}
|
|
191
221
|
function getBundleContentHash(bundle) {
|
|
@@ -211,7 +241,118 @@ function hashDirectory(dir) {
|
|
|
211
241
|
const combinedHashes = hashes.sort().join('');
|
|
212
242
|
return (0, crypto_1.createHash)('sha256').update(combinedHashes).digest('hex');
|
|
213
243
|
}
|
|
214
|
-
async function downloadAndExtractClientBundle(httpClient,
|
|
244
|
+
async function downloadAndExtractClientBundle(httpClient, version, url) {
|
|
245
|
+
// Parallel nx processes race to install bundles, possibly at different
|
|
246
|
+
// versions. The first to take the lock downloads; the rest wait and adopt
|
|
247
|
+
// its bundle when an install completed during the wait at the version the
|
|
248
|
+
// server asked them for. Otherwise they download their own as a contended
|
|
249
|
+
// install, which publishes its own directory and skips cleanup, so the
|
|
250
|
+
// holder's bundle stays on disk for the process running from it - at the
|
|
251
|
+
// same version as well as a different one. The flock is released by the
|
|
252
|
+
// kernel if the holder dies, so no stale-lock cleanup is needed. Under WASM
|
|
253
|
+
// the lock is unavailable and downloads run unserialized.
|
|
254
|
+
if (!VALID_BUNDLE_VERSION.test(version)) {
|
|
255
|
+
throw new Error(`Invalid Nx Cloud client bundle version: ${version}`);
|
|
256
|
+
}
|
|
257
|
+
const recordBeforeContending = readDownloadRecord();
|
|
258
|
+
const lock = !native_1.IS_WASM ? new native_1.FileLock(downloadLockFilePath) : null;
|
|
259
|
+
let locked = lock?.locked;
|
|
260
|
+
let contended = false;
|
|
261
|
+
while (locked) {
|
|
262
|
+
(0, debug_logger_1.debugLog)('Another process is downloading the client bundle, waiting for it to complete');
|
|
263
|
+
await lock.wait();
|
|
264
|
+
// The holder may be running from a bundle whose record predates this call,
|
|
265
|
+
// so the wait alone makes the install contended.
|
|
266
|
+
contended = true;
|
|
267
|
+
const installedBundle = bundleInstalledSince(recordBeforeContending);
|
|
268
|
+
if (installedBundle) {
|
|
269
|
+
if (installedBundle.version === version) {
|
|
270
|
+
(0, debug_logger_1.debugLog)('Using client bundle downloaded by another process: ', installedBundle.version);
|
|
271
|
+
return installedBundle;
|
|
272
|
+
}
|
|
273
|
+
(0, debug_logger_1.debugLog)('Another process installed a different bundle: ', installedBundle.version);
|
|
274
|
+
}
|
|
275
|
+
// The other process failed or installed an older version, so this process
|
|
276
|
+
// still needs to download.
|
|
277
|
+
locked = lock.check();
|
|
278
|
+
}
|
|
279
|
+
lock?.lock();
|
|
280
|
+
try {
|
|
281
|
+
// A process that acquired the lock between the check above and lock() may
|
|
282
|
+
// have completed an install already.
|
|
283
|
+
const installedBundle = bundleInstalledSince(recordBeforeContending);
|
|
284
|
+
if (installedBundle) {
|
|
285
|
+
if (installedBundle.version === version) {
|
|
286
|
+
(0, debug_logger_1.debugLog)('Using client bundle downloaded by another process: ', installedBundle.version);
|
|
287
|
+
return installedBundle;
|
|
288
|
+
}
|
|
289
|
+
// A different version means that process is running from a bundle this
|
|
290
|
+
// one must not delete.
|
|
291
|
+
contended = true;
|
|
292
|
+
(0, debug_logger_1.debugLog)('Another process installed a different bundle: ', installedBundle.version);
|
|
293
|
+
}
|
|
294
|
+
const fullPath = await downloadAndExtractBundle(httpClient, version, url, contended);
|
|
295
|
+
return { version, fullPath };
|
|
296
|
+
}
|
|
297
|
+
finally {
|
|
298
|
+
lock?.unlock();
|
|
299
|
+
}
|
|
300
|
+
}
|
|
301
|
+
// Records "<serverVersion> <directoryName>", written only once an install has
|
|
302
|
+
// COMPLETED. The directory is recorded separately because it cannot be derived
|
|
303
|
+
// from the version - every install publishes its own (see
|
|
304
|
+
// downloadAndExtractBundle), so several directories can carry the same
|
|
305
|
+
// version. That also makes every record distinct, so a waiter can tell "an
|
|
306
|
+
// install finished while I waited" from "this record is left over from a past
|
|
307
|
+
// run" by comparing the record it read before contending. Timestamps cannot
|
|
308
|
+
// answer that: filesystem mtime granularity is coarser than the race window.
|
|
309
|
+
function readDownloadRecord() {
|
|
310
|
+
try {
|
|
311
|
+
return (0, fs_1.readFileSync)(downloadRecordFilePath, 'utf-8').trim();
|
|
312
|
+
}
|
|
313
|
+
catch {
|
|
314
|
+
return '';
|
|
315
|
+
}
|
|
316
|
+
}
|
|
317
|
+
function writeDownloadRecord(version, directoryName) {
|
|
318
|
+
ensureStateDirectory();
|
|
319
|
+
(0, fs_1.writeFileSync)(downloadRecordFilePath, `${version} ${directoryName}`, 'utf-8');
|
|
320
|
+
}
|
|
321
|
+
/**
|
|
322
|
+
* The bundle the record names, if it is still on disk. A record whose second
|
|
323
|
+
* field does not name a live directory resolves to null and leaves selection
|
|
324
|
+
* on its fallback, which is what a one-field record or anything else
|
|
325
|
+
* unexpected in the file has to do.
|
|
326
|
+
*/
|
|
327
|
+
function recordedBundle() {
|
|
328
|
+
const [version, directoryName] = readDownloadRecord().split(' ');
|
|
329
|
+
if (!version ||
|
|
330
|
+
!directoryName ||
|
|
331
|
+
!VALID_BUNDLE_VERSION.test(version) ||
|
|
332
|
+
!VALID_BUNDLE_VERSION.test(directoryName)) {
|
|
333
|
+
return null;
|
|
334
|
+
}
|
|
335
|
+
const fullPath = (0, path_1.join)(runnerBundleInstallDirectory, directoryName);
|
|
336
|
+
return (0, fs_1.existsSync)(fullPath) ? { version, fullPath } : null;
|
|
337
|
+
}
|
|
338
|
+
/**
|
|
339
|
+
* The bundle an install completed during this call, or null. Requires the
|
|
340
|
+
* record to have changed since `recordBefore` was read: a directory existing
|
|
341
|
+
* proves only that some earlier run left one there, and an install
|
|
342
|
+
* interrupted on a released nx leaves exactly that.
|
|
343
|
+
*/
|
|
344
|
+
function bundleInstalledSince(recordBefore) {
|
|
345
|
+
return readDownloadRecord() === recordBefore ? null : recordedBundle();
|
|
346
|
+
}
|
|
347
|
+
async function downloadAndExtractBundle(httpClient, version, url, contended) {
|
|
348
|
+
// Every install publishes its own directory. Two processes can be asked for
|
|
349
|
+
// the same version while one of them is already running from a completed
|
|
350
|
+
// install of it, so replacing <installDir>/<version> in place would delete
|
|
351
|
+
// that bundle out from under it - and a holder loading its client in the gap
|
|
352
|
+
// fails with MODULE_NOT_FOUND, which drops the task runner to running
|
|
353
|
+
// without Nx Cloud. A directory nothing else has seen cannot be in use.
|
|
354
|
+
const bundleDirectoryName = `${version}-${(0, crypto_1.randomUUID)()}`;
|
|
355
|
+
const bundleExtractLocation = (0, path_1.join)(runnerBundleInstallDirectory, bundleDirectoryName);
|
|
215
356
|
let resp;
|
|
216
357
|
try {
|
|
217
358
|
resp = await httpClient.get(url, {
|
|
@@ -222,53 +363,99 @@ async function downloadAndExtractClientBundle(httpClient, runnerBundleInstallDir
|
|
|
222
363
|
console.error('Error while updating Nx Cloud client bundle');
|
|
223
364
|
throw e;
|
|
224
365
|
}
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
}
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
if (
|
|
235
|
-
(0,
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
}
|
|
240
|
-
else if (headers.type === 'file') {
|
|
241
|
-
const outputFilePath = (0, path_1.join)(bundleExtractLocation, headers.name);
|
|
242
|
-
const writeStream = (0, fs_1.createWriteStream)(outputFilePath);
|
|
243
|
-
// Surface disk errors through the pipeline instead of crashing
|
|
244
|
-
writeStream.on('error', (e) => extract.destroy(e));
|
|
245
|
-
stream.pipe(writeStream);
|
|
246
|
-
// Continue the tar stream after the write stream closes
|
|
247
|
-
writeStream.on('close', () => {
|
|
366
|
+
// Extract into a temp directory and rename into place afterwards, so a
|
|
367
|
+
// failed or interrupted download never leaves a partial bundle at the
|
|
368
|
+
// path other processes require it from.
|
|
369
|
+
const tempExtractLocation = (0, path_1.join)(runnerBundleInstallDirectory, `.tmp-${version}-${process.pid}`);
|
|
370
|
+
(0, fs_1.mkdirSync)(tempExtractLocation, { recursive: true });
|
|
371
|
+
try {
|
|
372
|
+
await new Promise((res, rej) => {
|
|
373
|
+
const extract = tar.extract();
|
|
374
|
+
extract.on('entry', function (headers, stream, next) {
|
|
375
|
+
if (headers.type === 'directory') {
|
|
376
|
+
const directoryPath = (0, path_1.join)(tempExtractLocation, headers.name);
|
|
377
|
+
if (!(0, fs_1.existsSync)(directoryPath)) {
|
|
378
|
+
(0, fs_1.mkdirSync)(directoryPath, { recursive: true });
|
|
379
|
+
}
|
|
248
380
|
next();
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
381
|
+
stream.resume();
|
|
382
|
+
}
|
|
383
|
+
else if (headers.type === 'file') {
|
|
384
|
+
const outputFilePath = (0, path_1.join)(tempExtractLocation, headers.name);
|
|
385
|
+
const writeStream = (0, fs_1.createWriteStream)(outputFilePath);
|
|
386
|
+
// Surface disk errors through the pipeline instead of crashing
|
|
387
|
+
writeStream.on('error', (e) => extract.destroy(e));
|
|
388
|
+
stream.pipe(writeStream);
|
|
389
|
+
// Continue the tar stream after the write stream closes
|
|
390
|
+
writeStream.on('close', () => {
|
|
391
|
+
next();
|
|
392
|
+
});
|
|
393
|
+
stream.resume();
|
|
394
|
+
}
|
|
395
|
+
else {
|
|
396
|
+
// Skipping the entry would publish an incomplete bundle.
|
|
397
|
+
extract.destroy(new Error(`Unsupported ${headers.type} entry in Nx Cloud client bundle: ${headers.name}`));
|
|
398
|
+
}
|
|
399
|
+
});
|
|
400
|
+
extract.on('finish', function () {
|
|
401
|
+
res();
|
|
402
|
+
});
|
|
403
|
+
// pipeline propagates download/gunzip errors that .pipe() would leave
|
|
404
|
+
// uncaught
|
|
405
|
+
(0, stream_1.pipeline)(resp.data, (0, zlib_1.createGunzip)(), extract, (e) => {
|
|
406
|
+
if (e)
|
|
407
|
+
rej(e);
|
|
408
|
+
});
|
|
263
409
|
});
|
|
264
|
-
|
|
410
|
+
(0, fs_1.renameSync)(tempExtractLocation, bundleExtractLocation);
|
|
411
|
+
// Recorded only now: the record is the signal that a bundle at this
|
|
412
|
+
// version was installed by this process, which is what lets a waiter
|
|
413
|
+
// adopt it instead of downloading again, and it carries the directory
|
|
414
|
+
// that selection has to load from.
|
|
415
|
+
writeDownloadRecord(version, bundleDirectoryName);
|
|
416
|
+
}
|
|
417
|
+
catch (e) {
|
|
418
|
+
(0, fs_1.rmSync)(tempExtractLocation, { recursive: true, force: true });
|
|
419
|
+
throw e;
|
|
420
|
+
}
|
|
421
|
+
// On a contended install another process may be running from any bundle on
|
|
422
|
+
// disk, now including one at this same version, so nothing here can be shown
|
|
423
|
+
// to be unused and collection waits for a later uncontended install. Repeat
|
|
424
|
+
// contention accumulates directories until one of those runs. Bounding that
|
|
425
|
+
// means knowing which bundles are still loaded, which nothing on disk
|
|
426
|
+
// records today.
|
|
427
|
+
if (!contended) {
|
|
428
|
+
removeOldClientBundles(bundleDirectoryName);
|
|
429
|
+
}
|
|
430
|
+
writeBundleVerificationLock();
|
|
431
|
+
return bundleExtractLocation;
|
|
265
432
|
}
|
|
266
|
-
function removeOldClientBundles(
|
|
433
|
+
function removeOldClientBundles(currentInstallDirectoryName) {
|
|
267
434
|
const filesAndFolders = (0, fs_1.readdirSync)(runnerBundleInstallDirectory);
|
|
268
435
|
for (let fileOrFolder of filesAndFolders) {
|
|
436
|
+
// A '.tmp-*' left by a crashed extract is reclaimed here, which is safe
|
|
437
|
+
// only because this runs after our own was renamed away and the download
|
|
438
|
+
// lock means no other process is extracting. Under WASM there is no lock,
|
|
439
|
+
// so a concurrent extract may still own that directory: leaving it costs
|
|
440
|
+
// disk, deleting it would fail that process's install.
|
|
441
|
+
if (fileOrFolder === currentInstallDirectoryName ||
|
|
442
|
+
(native_1.IS_WASM && fileOrFolder.startsWith('.tmp-'))) {
|
|
443
|
+
continue;
|
|
444
|
+
}
|
|
269
445
|
const fileOrFolderPath = (0, path_1.join)(runnerBundleInstallDirectory, fileOrFolder);
|
|
270
|
-
|
|
271
|
-
|
|
446
|
+
// Another process's cleanup can remove an entry between the readdir above
|
|
447
|
+
// and these calls, so both tolerate it already being gone.
|
|
448
|
+
let isBundle;
|
|
449
|
+
try {
|
|
450
|
+
// Only directories are bundles. Files here, like the verify.lock a
|
|
451
|
+
// released nx writes, are left alone.
|
|
452
|
+
isBundle = (0, fs_1.statSync)(fileOrFolderPath).isDirectory();
|
|
453
|
+
}
|
|
454
|
+
catch {
|
|
455
|
+
continue;
|
|
456
|
+
}
|
|
457
|
+
if (isBundle) {
|
|
458
|
+
(0, fs_1.rmSync)(fileOrFolderPath, { recursive: true, force: true });
|
|
272
459
|
}
|
|
273
460
|
}
|
|
274
461
|
}
|
|
@@ -438,7 +438,8 @@ function getDependencies(data, keyMap, isV5, ctx) {
|
|
|
438
438
|
Object.keys(section).forEach((name) => {
|
|
439
439
|
const versionRange = section[name];
|
|
440
440
|
const version = parseBaseVersion(findVersion(versionRange, name, isV5), isV5);
|
|
441
|
-
const target =
|
|
441
|
+
const target = keyMap.get(versionRange)?.values().next().value ||
|
|
442
|
+
ctx.externalNodes[`npm:${name}@${version}`] ||
|
|
442
443
|
ctx.externalNodes[`npm:${name}`];
|
|
443
444
|
if (target) {
|
|
444
445
|
const dep = {
|
|
@@ -603,9 +604,7 @@ function stringifyPnpmLockfile(graph, rootLockFileContent, packageJson, workspac
|
|
|
603
604
|
// relocated at its synthesis site, which is why it is added afterwards: a
|
|
604
605
|
// second pass over an already-relocated path cannot tell it apart from a
|
|
605
606
|
// workspace path that genuinely starts with the shipped directory's name.
|
|
606
|
-
|
|
607
|
-
// the copied workspace module silently supersedes the file: dependency.
|
|
608
|
-
(0, pruned_output_1.warnOnWorkspaceModulePathCollision)(snapshots, synthesizedModulePaths);
|
|
607
|
+
(0, pruned_output_1.assertNoWorkspaceModulePathCollision)(snapshots, synthesizedModulePaths);
|
|
609
608
|
(0, pruned_output_1.containShippedLocalFilePaths)(output, synthesizedModulePaths);
|
|
610
609
|
// Peers pnpm left out of the importer (autoInstallPeers off) still ship as
|
|
611
610
|
// real dependencies, matching the copied manifest that moves every
|
|
@@ -148,12 +148,12 @@ export declare function normalizeLocalPathSpec(spec: string): string;
|
|
|
148
148
|
*/
|
|
149
149
|
export declare function uncontainLocalPathSpec(spec: string): string;
|
|
150
150
|
/**
|
|
151
|
-
*
|
|
151
|
+
* Throws when a workspace directory occupies the output path of a copied
|
|
152
152
|
* workspace module. Both spell `workspace_modules/<name>`, so no later pass can
|
|
153
153
|
* tell them apart: the vendored source is read as the copied module and never
|
|
154
154
|
* ships, leaving the lockfile pointing at a path the output does not carry.
|
|
155
155
|
*/
|
|
156
|
-
export declare function
|
|
156
|
+
export declare function assertNoWorkspaceModulePathCollision(sourcePackages: Record<string, unknown> | undefined, synthesizedModulePaths: ReadonlySet<string>): void;
|
|
157
157
|
/**
|
|
158
158
|
* Relocates every shippable non-workspace `file:` local-path reference in a
|
|
159
159
|
* pruned lockfile (package keys, resolutions, and snapshot/importer dependency
|
|
@@ -11,7 +11,7 @@ exports.containLocalPath = containLocalPath;
|
|
|
11
11
|
exports.uncontainLocalPath = uncontainLocalPath;
|
|
12
12
|
exports.normalizeLocalPathSpec = normalizeLocalPathSpec;
|
|
13
13
|
exports.uncontainLocalPathSpec = uncontainLocalPathSpec;
|
|
14
|
-
exports.
|
|
14
|
+
exports.assertNoWorkspaceModulePathCollision = assertNoWorkspaceModulePathCollision;
|
|
15
15
|
exports.containShippedLocalFilePaths = containShippedLocalFilePaths;
|
|
16
16
|
exports.containShippedLocalLinkRefs = containShippedLocalLinkRefs;
|
|
17
17
|
exports.getPrunedPnpmLocalPathArtifacts = getPrunedPnpmLocalPathArtifacts;
|
|
@@ -772,18 +772,18 @@ function containFileToken(token, synthesized) {
|
|
|
772
772
|
: `${token.slice(0, pathStart)}${contained}`;
|
|
773
773
|
}
|
|
774
774
|
/**
|
|
775
|
-
*
|
|
775
|
+
* Throws when a workspace directory occupies the output path of a copied
|
|
776
776
|
* workspace module. Both spell `workspace_modules/<name>`, so no later pass can
|
|
777
777
|
* tell them apart: the vendored source is read as the copied module and never
|
|
778
778
|
* ships, leaving the lockfile pointing at a path the output does not carry.
|
|
779
779
|
*/
|
|
780
|
-
function
|
|
780
|
+
function assertNoWorkspaceModulePathCollision(sourcePackages, synthesizedModulePaths) {
|
|
781
781
|
for (const snapshot of Object.values(sourcePackages ?? {})) {
|
|
782
782
|
const directory = snapshot
|
|
783
783
|
?.resolution?.directory;
|
|
784
784
|
if (typeof directory === 'string' &&
|
|
785
785
|
synthesizedModulePaths.has((0, path_2.normalizePath)(directory))) {
|
|
786
|
-
|
|
786
|
+
throw new Error(`Cannot prune pnpm lockfile: local-path dependency "file:${directory}" sits where the standalone output copies a workspace module of the same name. Move it out of ${WORKSPACE_MODULES_DIR}/ so they do not collide.`);
|
|
787
787
|
}
|
|
788
788
|
}
|
|
789
789
|
}
|
|
@@ -744,12 +744,16 @@ function isNativeTypeStripError(err) {
|
|
|
744
744
|
* Module resolution failures - typically a tsconfig path alias that hasn't
|
|
745
745
|
* been registered yet, or a workspace lib not surfaced via package manager
|
|
746
746
|
* symlinks. CJS uses `MODULE_NOT_FOUND`, ESM uses `ERR_MODULE_NOT_FOUND`.
|
|
747
|
+
* `ERR_PACKAGE_PATH_NOT_EXPORTED` covers a linked package shadowing a path
|
|
748
|
+
* alias for a subpath its `exports` doesn't list.
|
|
747
749
|
*/
|
|
748
750
|
function isModuleNotFoundError(err) {
|
|
749
751
|
if (!err || typeof err !== 'object')
|
|
750
752
|
return false;
|
|
751
753
|
const code = err.code;
|
|
752
|
-
return code === 'MODULE_NOT_FOUND' ||
|
|
754
|
+
return (code === 'MODULE_NOT_FOUND' ||
|
|
755
|
+
code === 'ERR_MODULE_NOT_FOUND' ||
|
|
756
|
+
code === 'ERR_PACKAGE_PATH_NOT_EXPORTED');
|
|
753
757
|
}
|
|
754
758
|
/**
|
|
755
759
|
* A SyntaxError thrown while parsing a forced-CJS file (`.cts`/`.cjs`) as
|
|
@@ -1010,8 +1014,8 @@ function requireWithTsconfigFallback(filePath, tsConfigPath) {
|
|
|
1010
1014
|
* - ESM-redispatch signals callers expect to handle
|
|
1011
1015
|
* (`ERR_REQUIRE_ESM`, `ERR_REQUIRE_ASYNC_MODULE`)
|
|
1012
1016
|
* - plain module-resolution failures (`MODULE_NOT_FOUND`,
|
|
1013
|
-
* `ERR_MODULE_NOT_FOUND`) - disabling
|
|
1014
|
-
* module, the hint just misleads.
|
|
1017
|
+
* `ERR_MODULE_NOT_FOUND`, `ERR_PACKAGE_PATH_NOT_EXPORTED`) - disabling
|
|
1018
|
+
* strip-types doesn't fix a missing module, the hint just misleads.
|
|
1015
1019
|
*/
|
|
1016
1020
|
function augmentLoadFailure(filePath, err) {
|
|
1017
1021
|
if (!(err instanceof Error))
|
|
@@ -1020,7 +1024,8 @@ function augmentLoadFailure(filePath, err) {
|
|
|
1020
1024
|
if (code === 'ERR_REQUIRE_ESM' ||
|
|
1021
1025
|
code === 'ERR_REQUIRE_ASYNC_MODULE' ||
|
|
1022
1026
|
code === 'MODULE_NOT_FOUND' ||
|
|
1023
|
-
code === 'ERR_MODULE_NOT_FOUND'
|
|
1027
|
+
code === 'ERR_MODULE_NOT_FOUND' ||
|
|
1028
|
+
code === 'ERR_PACKAGE_PATH_NOT_EXPORTED') {
|
|
1024
1029
|
return err;
|
|
1025
1030
|
}
|
|
1026
1031
|
if (err.message.includes(NX_PREFER_NODE_STRIP_TYPES_DOCS_URL)) {
|
|
@@ -11,13 +11,14 @@ import { TaskPlanningContext } from '../../hasher/task-planning-context';
|
|
|
11
11
|
import type { TaskSelection } from '../../tasks-runner/run-command';
|
|
12
12
|
/**
|
|
13
13
|
* Whether `nx affected` selects the individual tasks whose inputs a change
|
|
14
|
-
* reaches, rather than whole projects.
|
|
15
|
-
*
|
|
14
|
+
* reaches, rather than whole projects. `NX_LEGACY_AFFECTED` overrides
|
|
15
|
+
* nx.json's `affected.legacy`.
|
|
16
16
|
*
|
|
17
|
-
*
|
|
18
|
-
* script agree. The run also executes the selected tasks' dependencies.
|
|
17
|
+
* The run also executes the selected tasks' dependencies.
|
|
19
18
|
*/
|
|
20
|
-
export declare function selectsAffectedTasks(): boolean;
|
|
19
|
+
export declare function selectsAffectedTasks(nxJson: NxJsonConfiguration): boolean;
|
|
20
|
+
/** What to change so {@link selectsAffectedTasks} returns true, for error messages. */
|
|
21
|
+
export declare function taskGranularityRequirement(): string;
|
|
21
22
|
export interface AffectedTasksResult {
|
|
22
23
|
/** The graph selection ran against, which the command should run with too. */
|
|
23
24
|
projectGraph: ProjectGraph;
|
|
@@ -91,7 +92,8 @@ export declare function computeAffectedTasks(opts: ComputeAffectedTasksOptions):
|
|
|
91
92
|
* task can read files no affected project owns. Shared by the client and the
|
|
92
93
|
* daemon.
|
|
93
94
|
*/
|
|
94
|
-
export declare function selectAffectedTasks(
|
|
95
|
+
export declare function selectAffectedTasks(...args: Parameters<typeof matchAffectedTasks>): ReturnType<typeof matchAffectedTasks>;
|
|
96
|
+
declare function matchAffectedTasks(projectGraph: ProjectGraph, nxJson: NxJsonConfiguration, planningContext: TaskPlanningContext, request: AffectedTasksRequest, { touchedFiles, packageJson, ultracacheConfigurations, }?: {
|
|
95
97
|
touchedFiles?: FileChange[];
|
|
96
98
|
packageJson?: any;
|
|
97
99
|
ultracacheConfigurations?: UltracacheConfigurations;
|
|
@@ -101,3 +103,4 @@ export declare function selectAffectedTasks(projectGraph: ProjectGraph, nxJson:
|
|
|
101
103
|
taskSelection: TaskSelection;
|
|
102
104
|
explanation?: InternedExplanation;
|
|
103
105
|
}>;
|
|
106
|
+
export {};
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.selectsAffectedTasks = selectsAffectedTasks;
|
|
4
|
+
exports.taskGranularityRequirement = taskGranularityRequirement;
|
|
4
5
|
exports.computeAffectedTasks = computeAffectedTasks;
|
|
5
6
|
exports.selectAffectedTasks = selectAffectedTasks;
|
|
6
7
|
const native_1 = require("../../native");
|
|
@@ -16,6 +17,8 @@ const logger_1 = require("../../utils/logger");
|
|
|
16
17
|
const error_types_1 = require("../error-types");
|
|
17
18
|
const affected_reasons_1 = require("./affected-reasons");
|
|
18
19
|
const workspace_root_1 = require("../../utils/workspace-root");
|
|
20
|
+
const delayed_spinner_1 = require("../../utils/delayed-spinner");
|
|
21
|
+
const progress_topics_1 = require("../../utils/progress-topics");
|
|
19
22
|
const task_planning_context_1 = require("../../hasher/task-planning-context");
|
|
20
23
|
const client_1 = require("../../daemon/client/client");
|
|
21
24
|
const is_on_daemon_1 = require("../../daemon/is-on-daemon");
|
|
@@ -25,14 +28,23 @@ const npm_packages_1 = require("../../plugins/js/project-graph/affected/npm-pack
|
|
|
25
28
|
const lock_file_1 = require("../../plugins/js/lock-file/lock-file");
|
|
26
29
|
/**
|
|
27
30
|
* Whether `nx affected` selects the individual tasks whose inputs a change
|
|
28
|
-
* reaches, rather than whole projects.
|
|
29
|
-
*
|
|
31
|
+
* reaches, rather than whole projects. `NX_LEGACY_AFFECTED` overrides
|
|
32
|
+
* nx.json's `affected.legacy`.
|
|
30
33
|
*
|
|
31
|
-
*
|
|
32
|
-
* script agree. The run also executes the selected tasks' dependencies.
|
|
34
|
+
* The run also executes the selected tasks' dependencies.
|
|
33
35
|
*/
|
|
34
|
-
function selectsAffectedTasks() {
|
|
35
|
-
|
|
36
|
+
function selectsAffectedTasks(nxJson) {
|
|
37
|
+
if (process.env.NX_LEGACY_AFFECTED === 'true')
|
|
38
|
+
return false;
|
|
39
|
+
if (process.env.NX_LEGACY_AFFECTED === 'false')
|
|
40
|
+
return true;
|
|
41
|
+
return !nxJson.affected?.legacy;
|
|
42
|
+
}
|
|
43
|
+
/** What to change so {@link selectsAffectedTasks} returns true, for error messages. */
|
|
44
|
+
function taskGranularityRequirement() {
|
|
45
|
+
return process.env.NX_LEGACY_AFFECTED === 'true'
|
|
46
|
+
? 'NX_LEGACY_AFFECTED unset or set to false'
|
|
47
|
+
: 'affected.legacy unset or false in nx.json';
|
|
36
48
|
}
|
|
37
49
|
/**
|
|
38
50
|
* Selects the tasks a change reaches, rather than the projects that own a
|
|
@@ -110,7 +122,18 @@ async function computeAffectedTasks(opts) {
|
|
|
110
122
|
* task can read files no affected project owns. Shared by the client and the
|
|
111
123
|
* daemon.
|
|
112
124
|
*/
|
|
113
|
-
async function selectAffectedTasks(
|
|
125
|
+
async function selectAffectedTasks(...args) {
|
|
126
|
+
const spinner = new delayed_spinner_1.DelayedSpinner('Calculating affected tasks', {
|
|
127
|
+
progressTopic: progress_topics_1.ProgressTopics.AffectedTasks,
|
|
128
|
+
});
|
|
129
|
+
try {
|
|
130
|
+
return await matchAffectedTasks(...args);
|
|
131
|
+
}
|
|
132
|
+
finally {
|
|
133
|
+
spinner.cleanup();
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
async function matchAffectedTasks(projectGraph, nxJson, planningContext, request, { touchedFiles = (0, file_utils_1.calculateFileChanges)(request.changedFiles, request.fileChangeArgs), packageJson, ultracacheConfigurations, } = {}) {
|
|
114
137
|
const { targets } = request;
|
|
115
138
|
// Only projects that have one of the targets: with a single target,
|
|
116
139
|
// createTaskGraph tries to create a task for projects that lack it and
|
|
@@ -148,6 +171,7 @@ async function selectAffectedTasks(projectGraph, nxJson, planningContext, reques
|
|
|
148
171
|
const dependencies = dependencyChanges(projectGraph, touchedFiles, nxJson, packageJson);
|
|
149
172
|
const namedProjects = new Set(dependencies.projects);
|
|
150
173
|
const projects = (0, project_graph_1.readProjectsConfigurationFromProjectGraph)(projectGraph).projects;
|
|
174
|
+
// TODO(v25): remove custom hasher support.
|
|
151
175
|
const customHashed = new Set(taskIds.filter((id) => hasCustomHasher(taskGraph.tasks[id], projects)));
|
|
152
176
|
const options = {
|
|
153
177
|
projectGlobPatterns: await (0, affected_projects_1.getProjectGlobPatterns)(nxJson),
|
|
@@ -351,6 +351,13 @@ class IsolatedPlugin {
|
|
|
351
351
|
this.shutdown();
|
|
352
352
|
}
|
|
353
353
|
async setWorkerEnv(env) {
|
|
354
|
+
// A restart may have spawned under the previous client env but not yet
|
|
355
|
+
// finished loading. Wait for that worker so it receives the update too.
|
|
356
|
+
// Do not start a stopped worker solely to forward env: its next spawn
|
|
357
|
+
// will inherit the daemon's already-updated environment.
|
|
358
|
+
if (!this._alive && this._connectPromise) {
|
|
359
|
+
await this._connectPromise;
|
|
360
|
+
}
|
|
354
361
|
if (!this._alive) {
|
|
355
362
|
return;
|
|
356
363
|
}
|