@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
|
@@ -11,8 +11,9 @@ const create_task_hasher_1 = require("../hasher/create-task-hasher");
|
|
|
11
11
|
const client_1 = require("../daemon/client/client");
|
|
12
12
|
const shared_running_task_1 = require("./running-tasks/shared-running-task");
|
|
13
13
|
const task_results_life_cycle_1 = require("./life-cycles/task-results-life-cycle");
|
|
14
|
-
|
|
14
|
+
function createOrchestrator(tasks, projectGraph, fullTaskGraph, nxJson, lifeCycle, ultracacheConfigurations) {
|
|
15
15
|
(0, dotenv_1.loadRootEnvFiles)();
|
|
16
|
+
fullTaskGraph = withEdgeObjects(fullTaskGraph);
|
|
16
17
|
const invokeRunnerTerminalLifecycle = new invoke_runner_terminal_output_life_cycle_1.InvokeRunnerTerminalOutputLifeCycle(tasks);
|
|
17
18
|
const taskResultsLifecycle = new task_results_life_cycle_1.TaskResultsLifeCycle();
|
|
18
19
|
const compositedLifeCycle = new life_cycle_1.CompositeLifeCycle([
|
|
@@ -43,82 +44,138 @@ async function createOrchestrator(tasks, projectGraph, fullTaskGraph, nxJson, li
|
|
|
43
44
|
lifeCycle: compositedLifeCycle,
|
|
44
45
|
};
|
|
45
46
|
(0, run_command_1.setEnvVarsBasedOnArgs)(nxArgs, true);
|
|
46
|
-
|
|
47
|
+
return new task_orchestrator_1.TaskOrchestrator(hasher, null, tasks, projectGraph, taskGraph, nxJson, nxArgs, false, client_1.daemonClient,
|
|
47
48
|
// No argv on this path, so the output-style middleware never ran and both
|
|
48
49
|
// fields are unset - this always renders `static-failures-only`. `nx.json`'s
|
|
49
50
|
// `outputStyle` does not reach them; it merges under its own name.
|
|
50
51
|
nxArgs.specifiedOutputStyle, nxArgs.resolvedOutputStyle ?? 'static-failures-only', fullTaskGraph);
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
52
|
+
}
|
|
53
|
+
// A client bundle built before edges became objects hands plain task ids
|
|
54
|
+
function withEdgeObjects(taskGraph) {
|
|
55
|
+
const normalize = (edges) => Object.fromEntries(Object.entries(edges).map(([taskId, taskEdges]) => [
|
|
56
|
+
taskId,
|
|
57
|
+
taskEdges.map((edge) => typeof edge === 'string' ? { id: edge } : edge),
|
|
58
|
+
]));
|
|
59
|
+
return {
|
|
60
|
+
...taskGraph,
|
|
61
|
+
dependencies: normalize(taskGraph.dependencies),
|
|
62
|
+
continuousDependencies: normalize(taskGraph.continuousDependencies),
|
|
63
|
+
};
|
|
54
64
|
}
|
|
55
65
|
// Nothing awaits the dispose chains below, so an unhandled rejection would take
|
|
56
66
|
// down a long-lived agent process.
|
|
57
67
|
function logDisposeFailure(e) {
|
|
58
68
|
console.error('Failed to dispose the task orchestrator:', e);
|
|
59
69
|
}
|
|
70
|
+
// Agents never call `TaskOrchestrator.run()`, which sizes these limits for a CLI
|
|
71
|
+
// run. A call starts all its tasks at once while other calls' orchestrators stay
|
|
72
|
+
// alive, so each adds room for its tasks and its own orchestrator until disposed.
|
|
73
|
+
function reserveProcessListeners(tasks) {
|
|
74
|
+
const room = tasks.length + 1;
|
|
75
|
+
const adjust = (delta) => {
|
|
76
|
+
for (const emitter of [process, process.stdout, process.stderr]) {
|
|
77
|
+
const limit = emitter.getMaxListeners();
|
|
78
|
+
// 0 is unlimited
|
|
79
|
+
if (limit !== 0) {
|
|
80
|
+
emitter.setMaxListeners(limit + delta);
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
};
|
|
84
|
+
adjust(room);
|
|
85
|
+
return () => adjust(-room);
|
|
86
|
+
}
|
|
60
87
|
async function runDiscreteTasks(tasks, projectGraph, fullTaskGraph, nxJson, lifeCycle,
|
|
61
88
|
/** The set to hash from, e.g. from `importUltracacheConfigurations`; omitted hashes natively. */
|
|
62
89
|
ultracacheConfigurations) {
|
|
63
|
-
const orchestrator =
|
|
64
|
-
|
|
65
|
-
let nextBatch = orchestrator.nextBatch();
|
|
90
|
+
const orchestrator = createOrchestrator(tasks, projectGraph, fullTaskGraph, nxJson, lifeCycle, ultracacheConfigurations);
|
|
91
|
+
const releaseProcessListeners = reserveProcessListeners(tasks);
|
|
66
92
|
const batchResults = [];
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
93
|
+
try {
|
|
94
|
+
await orchestrator.init();
|
|
95
|
+
let groupId = 0;
|
|
96
|
+
let nextBatch = orchestrator.nextBatch();
|
|
97
|
+
/**
|
|
98
|
+
* Set of task ids that were part of batches
|
|
99
|
+
*/
|
|
100
|
+
const batchTasks = new Set();
|
|
101
|
+
while (nextBatch) {
|
|
102
|
+
for (const task in nextBatch.taskGraph.tasks) {
|
|
103
|
+
batchTasks.add(task);
|
|
104
|
+
}
|
|
105
|
+
batchResults.push(orchestrator.applyFromCacheOrRunBatch(true, nextBatch, groupId++));
|
|
106
|
+
nextBatch = orchestrator.nextBatch();
|
|
74
107
|
}
|
|
75
|
-
|
|
76
|
-
|
|
108
|
+
const discreteTasks = tasks.filter((task) => !batchTasks.has(task.id));
|
|
109
|
+
// Every task here starts directly, but the schedule hashes only the tasks it admits
|
|
110
|
+
orchestrator.processTasks(discreteTasks.map((task) => task.id));
|
|
111
|
+
// Bulk-resolve every discrete task's cache state in one shot —
|
|
112
|
+
// single SQL call plus parallel remote retrievals. Batches kicked
|
|
113
|
+
// off above continue running concurrently while we await this.
|
|
114
|
+
const cacheHits = await orchestrator.resolveCachedTasks(true, discreteTasks, groupId++);
|
|
115
|
+
const cacheHitsById = new Map(cacheHits.map((h) => [h.task.id, h]));
|
|
116
|
+
const taskResults = discreteTasks.map(async (task) => {
|
|
117
|
+
const hit = cacheHitsById.get(task.id);
|
|
118
|
+
if (hit)
|
|
119
|
+
return [hit];
|
|
120
|
+
return [await orchestrator.runTaskDirectly(true, task, groupId++)];
|
|
121
|
+
});
|
|
122
|
+
const results = [...batchResults, ...taskResults];
|
|
123
|
+
// Callers like Nx Cloud agents create an orchestrator per invocation in a
|
|
124
|
+
// long-lived process; release its process-level listeners once all tasks
|
|
125
|
+
// settle, otherwise every invocation's orchestrator stays reachable forever.
|
|
126
|
+
// Not awaited, so callers keep consuming handles as they settle; the forked
|
|
127
|
+
// runner's exit handler still reaps children until dispose() runs.
|
|
128
|
+
Promise.allSettled(results)
|
|
129
|
+
.then(() => orchestrator.dispose())
|
|
130
|
+
.finally(releaseProcessListeners)
|
|
131
|
+
.catch(logDisposeFailure);
|
|
132
|
+
return results;
|
|
133
|
+
}
|
|
134
|
+
catch (e) {
|
|
135
|
+
// A batch started before the failure can still fork a child, which only
|
|
136
|
+
// the orchestrator's exit handler reaps, so dispose once batches settle
|
|
137
|
+
Promise.allSettled(batchResults)
|
|
138
|
+
.then(() => orchestrator.dispose())
|
|
139
|
+
.finally(releaseProcessListeners)
|
|
140
|
+
.catch(logDisposeFailure);
|
|
141
|
+
throw e;
|
|
77
142
|
}
|
|
78
|
-
const discreteTasks = tasks.filter((task) => !batchTasks.has(task.id));
|
|
79
|
-
// Bulk-resolve every discrete task's cache state in one shot —
|
|
80
|
-
// single SQL call plus parallel remote retrievals. Batches kicked
|
|
81
|
-
// off above continue running concurrently while we await this.
|
|
82
|
-
const cacheHits = await orchestrator.resolveCachedTasks(true, discreteTasks, groupId++);
|
|
83
|
-
const cacheHitsById = new Map(cacheHits.map((h) => [h.task.id, h]));
|
|
84
|
-
const taskResults = discreteTasks.map(async (task) => {
|
|
85
|
-
const hit = cacheHitsById.get(task.id);
|
|
86
|
-
if (hit)
|
|
87
|
-
return [hit];
|
|
88
|
-
return [await orchestrator.runTaskDirectly(true, task, groupId++)];
|
|
89
|
-
});
|
|
90
|
-
const results = [...batchResults, ...taskResults];
|
|
91
|
-
// Callers like Nx Cloud agents create an orchestrator per invocation in a
|
|
92
|
-
// long-lived process; release its process-level listeners once all tasks
|
|
93
|
-
// settle, otherwise every invocation's orchestrator stays reachable forever.
|
|
94
|
-
// Not awaited, so callers keep consuming handles as they settle; the forked
|
|
95
|
-
// runner's exit handler still reaps children until dispose() runs.
|
|
96
|
-
Promise.allSettled(results)
|
|
97
|
-
.then(() => orchestrator.dispose())
|
|
98
|
-
.catch(logDisposeFailure);
|
|
99
|
-
return results;
|
|
100
143
|
}
|
|
101
144
|
async function runContinuousTasks(tasks, projectGraph, fullTaskGraph, nxJson, lifeCycle,
|
|
102
145
|
/** The set to hash from, e.g. from `importUltracacheConfigurations`; omitted hashes natively. */
|
|
103
146
|
ultracacheConfigurations) {
|
|
104
|
-
const orchestrator =
|
|
105
|
-
const
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
//
|
|
115
|
-
//
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
147
|
+
const orchestrator = createOrchestrator(tasks, projectGraph, fullTaskGraph, nxJson, lifeCycle, ultracacheConfigurations);
|
|
148
|
+
const releaseProcessListeners = reserveProcessListeners(tasks);
|
|
149
|
+
try {
|
|
150
|
+
await orchestrator.init();
|
|
151
|
+
orchestrator.processTasks(tasks.map((task) => task.id));
|
|
152
|
+
const runningTasks = tasks.reduce((current, task, index) => {
|
|
153
|
+
current[task.id] = orchestrator.startContinuousTask(task, index);
|
|
154
|
+
return current;
|
|
155
|
+
}, {});
|
|
156
|
+
// Unlike runDiscreteTasks, this must resolve at task start: callers keep
|
|
157
|
+
// the RunningTask handles to kill later, so disposal has to be deferred
|
|
158
|
+
// until every task actually exits.
|
|
159
|
+
Promise.allSettled(Object.entries(runningTasks).map(async ([taskId, promise]) => {
|
|
160
|
+
const runningTask = await promise;
|
|
161
|
+
// A shared task is owned by another nx process; this orchestrator has
|
|
162
|
+
// no child to protect for it, so disposal does not wait on it.
|
|
163
|
+
if (runningTask instanceof shared_running_task_1.SharedRunningTask) {
|
|
164
|
+
return;
|
|
165
|
+
}
|
|
166
|
+
await orchestrator.waitForContinuousTaskExit(taskId);
|
|
167
|
+
}))
|
|
168
|
+
.then(() => orchestrator.dispose())
|
|
169
|
+
.finally(releaseProcessListeners)
|
|
170
|
+
.catch(logDisposeFailure);
|
|
171
|
+
return runningTasks;
|
|
172
|
+
}
|
|
173
|
+
catch (e) {
|
|
174
|
+
// A failure before the disposal chain above never reaches it
|
|
175
|
+
orchestrator
|
|
176
|
+
.dispose()
|
|
177
|
+
.finally(releaseProcessListeners)
|
|
178
|
+
.catch(logDisposeFailure);
|
|
179
|
+
throw e;
|
|
180
|
+
}
|
|
124
181
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Task } from '../config/task-graph';
|
|
2
|
-
import { BatchInfo, BatchStatus, ExternalObject, PerformanceSummaryPayload, TaskResult, TaskStatus as NativeTaskStatus } from '../native';
|
|
2
|
+
import { BatchInfo, BatchStatus, ExternalObject, PerformanceSummaryPayload, TaskReadiness, TaskResult, TaskStatus as NativeTaskStatus } from '../native';
|
|
3
3
|
import { TaskStatus } from './tasks-runner';
|
|
4
4
|
/**
|
|
5
5
|
* The result of a completed {@link Task}.
|
|
@@ -48,6 +48,8 @@ export interface LifeCycle {
|
|
|
48
48
|
registerRunningTaskWithEmptyParser?(taskId: string): void;
|
|
49
49
|
appendTaskOutput?(taskId: string, output: string, isPtyTask: boolean): void;
|
|
50
50
|
setTaskStatus?(taskId: string, status: NativeTaskStatus): void;
|
|
51
|
+
/** Only continuous tasks that declare a `readyWhen` report readiness. */
|
|
52
|
+
setTaskReadiness?(taskId: string, readiness: TaskReadiness): void;
|
|
51
53
|
setTaskTiming?(taskId: string, startTime: number, endTime: number): void;
|
|
52
54
|
registerForcedShutdownCallback?(callback: () => void): void;
|
|
53
55
|
setEstimatedTaskTimings?(timings: Record<string, number>): void;
|
|
@@ -82,6 +84,7 @@ export declare class CompositeLifeCycle implements LifeCycle {
|
|
|
82
84
|
registerRunningTaskWithEmptyParser(taskId: string): void;
|
|
83
85
|
appendTaskOutput(taskId: string, output: string, isPtyTask: boolean): void;
|
|
84
86
|
setTaskStatus(taskId: string, status: NativeTaskStatus): void;
|
|
87
|
+
setTaskReadiness(taskId: string, readiness: TaskReadiness): void;
|
|
85
88
|
setTaskTiming(taskId: string, startTime: number, endTime: number): void;
|
|
86
89
|
registerForcedShutdownCallback(callback: () => void): void;
|
|
87
90
|
setEstimatedTaskTimings(timings: Record<string, number>): void;
|
|
@@ -95,6 +95,13 @@ class CompositeLifeCycle {
|
|
|
95
95
|
}
|
|
96
96
|
}
|
|
97
97
|
}
|
|
98
|
+
setTaskReadiness(taskId, readiness) {
|
|
99
|
+
for (let l of this.lifeCycles) {
|
|
100
|
+
if (l.setTaskReadiness) {
|
|
101
|
+
l.setTaskReadiness(taskId, readiness);
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
}
|
|
98
105
|
setTaskTiming(taskId, startTime, endTime) {
|
|
99
106
|
for (let l of this.lifeCycles) {
|
|
100
107
|
if (l.setTaskTiming) {
|
|
@@ -4,6 +4,8 @@ import { TaskResult } from '../life-cycle';
|
|
|
4
4
|
export interface TaskTiming {
|
|
5
5
|
startTime?: number;
|
|
6
6
|
endTime?: number;
|
|
7
|
+
/** When a continuous task passed its `readyWhen` check. */
|
|
8
|
+
readyTime?: number;
|
|
7
9
|
continuous: boolean;
|
|
8
10
|
}
|
|
9
11
|
/** A discrete task that ran, with its window and whether it monopolizes the pool (`parallelism: false`). */
|
|
@@ -122,8 +124,9 @@ export declare class PerformanceAnalysis {
|
|
|
122
124
|
private finishEstimate;
|
|
123
125
|
/**
|
|
124
126
|
* Earliest this task became eligible, independent of slots: the latest of run
|
|
125
|
-
* start, dependency ends, any continuous dependency's *start
|
|
126
|
-
*
|
|
127
|
+
* start, dependency ends, any continuous dependency's *start*, or its
|
|
128
|
+
* readiness when the edge waits for it (an ordering constraint, not
|
|
129
|
+
* contention), and any earlier batch sibling's end.
|
|
127
130
|
*/
|
|
128
131
|
private readyTime;
|
|
129
132
|
/**
|
|
@@ -101,7 +101,9 @@ class PerformanceAnalysis {
|
|
|
101
101
|
*/
|
|
102
102
|
predecessorsFor(id, durations) {
|
|
103
103
|
const start = this.timings.get(id)?.startTime ?? Infinity;
|
|
104
|
-
const deps = (this.taskGraph.dependencies[id] ?? [])
|
|
104
|
+
const deps = (this.taskGraph.dependencies[id] ?? [])
|
|
105
|
+
.map((d) => d.id)
|
|
106
|
+
.filter((d) => durations.has(d));
|
|
105
107
|
const siblings = (this.batchSiblings.get(id) ?? []).filter((s) => {
|
|
106
108
|
const sEnd = this.timings.get(s)?.endTime;
|
|
107
109
|
return durations.has(s) && sEnd != null && sEnd <= start;
|
|
@@ -142,22 +144,26 @@ class PerformanceAnalysis {
|
|
|
142
144
|
}
|
|
143
145
|
/**
|
|
144
146
|
* Earliest this task became eligible, independent of slots: the latest of run
|
|
145
|
-
* start, dependency ends, any continuous dependency's *start
|
|
146
|
-
*
|
|
147
|
+
* start, dependency ends, any continuous dependency's *start*, or its
|
|
148
|
+
* readiness when the edge waits for it (an ordering constraint, not
|
|
149
|
+
* contention), and any earlier batch sibling's end.
|
|
147
150
|
*/
|
|
148
151
|
readyTime(id, runStart) {
|
|
149
152
|
const start = this.timings.get(id)?.startTime;
|
|
150
153
|
let result = runStart;
|
|
151
154
|
for (const dep of this.taskGraph.dependencies[id] ?? []) {
|
|
152
|
-
const end = this.timings.get(dep)?.endTime;
|
|
155
|
+
const end = this.timings.get(dep.id)?.endTime;
|
|
153
156
|
if (end != null) {
|
|
154
157
|
result = Math.max(result, end);
|
|
155
158
|
}
|
|
156
159
|
}
|
|
157
160
|
for (const cdep of this.taskGraph.continuousDependencies?.[id] ?? []) {
|
|
158
|
-
const
|
|
159
|
-
|
|
160
|
-
|
|
161
|
+
const producer = this.timings.get(cdep.id);
|
|
162
|
+
const usable = cdep.waitFor === 'ready'
|
|
163
|
+
? (producer?.readyTime ?? producer?.startTime)
|
|
164
|
+
: producer?.startTime;
|
|
165
|
+
if (usable != null) {
|
|
166
|
+
result = Math.max(result, usable);
|
|
161
167
|
}
|
|
162
168
|
}
|
|
163
169
|
for (const sibling of this.batchSiblings.get(id) ?? []) {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { TaskReadiness, type BatchInfo, type PerformanceSummaryPayload } from '../../native';
|
|
2
2
|
import { TaskGraph } from '../../config/task-graph';
|
|
3
3
|
import { LifeCycle, TaskResult } from '../life-cycle';
|
|
4
4
|
import { type PerformanceLifeCycleOptions, type PerformanceSummary } from './performance-analysis';
|
|
@@ -14,8 +14,8 @@ import { type PerformanceLifeCycleOptions, type PerformanceSummary } from './per
|
|
|
14
14
|
* coordinator time (hashing, scheduling, continuous-dep waits).
|
|
15
15
|
*
|
|
16
16
|
* Scope: discrete tasks only. Continuous tasks (no end time) are excluded; a
|
|
17
|
-
* discrete task's wait for a continuous dependency to start
|
|
18
|
-
* contention.
|
|
17
|
+
* discrete task's wait for a continuous dependency to start, or to be ready, is
|
|
18
|
+
* eligibility, not contention.
|
|
19
19
|
*/
|
|
20
20
|
export declare class PerformanceLifeCycle implements LifeCycle {
|
|
21
21
|
private readonly taskGraph;
|
|
@@ -34,6 +34,7 @@ export declare class PerformanceLifeCycle implements LifeCycle {
|
|
|
34
34
|
*/
|
|
35
35
|
startCommand(_threadCount?: number, parallel?: number): void;
|
|
36
36
|
registerRunningBatch(_batchId: string, batchInfo: BatchInfo): void;
|
|
37
|
+
setTaskReadiness(taskId: string, readiness: TaskReadiness): void;
|
|
37
38
|
endTasks(taskResults: TaskResult[]): void;
|
|
38
39
|
private entry;
|
|
39
40
|
/** Analyze the collected timings into a structured summary, or `null` when no discrete task timings were recorded. */
|
|
@@ -20,8 +20,8 @@ const performance_analysis_1 = require("./performance-analysis");
|
|
|
20
20
|
* coordinator time (hashing, scheduling, continuous-dep waits).
|
|
21
21
|
*
|
|
22
22
|
* Scope: discrete tasks only. Continuous tasks (no end time) are excluded; a
|
|
23
|
-
* discrete task's wait for a continuous dependency to start
|
|
24
|
-
* contention.
|
|
23
|
+
* discrete task's wait for a continuous dependency to start, or to be ready, is
|
|
24
|
+
* eligibility, not contention.
|
|
25
25
|
*/
|
|
26
26
|
class PerformanceLifeCycle {
|
|
27
27
|
constructor(taskGraph, options = {}) {
|
|
@@ -51,6 +51,13 @@ class PerformanceLifeCycle {
|
|
|
51
51
|
this.batchSiblings.set(id, batchInfo.taskIds.filter((other) => other !== id));
|
|
52
52
|
}
|
|
53
53
|
}
|
|
54
|
+
setTaskReadiness(taskId, readiness) {
|
|
55
|
+
const entry = this.entry(taskId);
|
|
56
|
+
// Each waiter polling a shared producer reports Ready; the first one counts.
|
|
57
|
+
if (readiness === 1 /* TaskReadiness.Ready */ && entry.readyTime == null) {
|
|
58
|
+
entry.readyTime = Date.now();
|
|
59
|
+
}
|
|
60
|
+
}
|
|
54
61
|
endTasks(taskResults) {
|
|
55
62
|
// Called incrementally (per group/batch); accumulate so the last call sees every timing.
|
|
56
63
|
for (const { task, status } of taskResults) {
|
|
@@ -61,8 +61,11 @@ class StaticRunManyTerminalOutputLifeCycle {
|
|
|
61
61
|
}
|
|
62
62
|
// A stopped task was killed mid-flight, so the run did not complete even
|
|
63
63
|
// though nothing outright failed. `didCommandComplete` already treats it
|
|
64
|
-
// that way; reporting "Successfully ran" here would contradict it.
|
|
65
|
-
|
|
64
|
+
// that way; reporting "Successfully ran" here would contradict it. A
|
|
65
|
+
// discrete task that never reported was skipped, which fails the run too.
|
|
66
|
+
if (this.failedTasks.length === 0 &&
|
|
67
|
+
this.stoppedTasks.length === 0 &&
|
|
68
|
+
!this.skippedTasks().some((t) => !t.continuous)) {
|
|
66
69
|
output_1.output.addVerticalSeparatorWithoutNewLines('green');
|
|
67
70
|
const bodyLines = this.cachedTasks.length > 0
|
|
68
71
|
? [
|
|
@@ -71,7 +71,10 @@ class StaticRunOneTerminalOutputLifeCycle {
|
|
|
71
71
|
output_1.output.addNewline();
|
|
72
72
|
// A stopped task was killed mid-flight, so the run did not complete even
|
|
73
73
|
// though nothing outright failed — matching run-many and didCommandComplete.
|
|
74
|
-
|
|
74
|
+
// A discrete task that never reported was skipped, which fails the run too.
|
|
75
|
+
if (this.failedTasks.length === 0 &&
|
|
76
|
+
this.stoppedTasks.length === 0 &&
|
|
77
|
+
!this.skippedTasks().some((t) => !t.continuous)) {
|
|
75
78
|
output_1.output.addVerticalSeparatorWithoutNewLines('green');
|
|
76
79
|
const bodyLines = this.cachedTasks.length > 0
|
|
77
80
|
? [
|
|
@@ -100,7 +100,11 @@ class SummaryTerminalOutputLifeCycle {
|
|
|
100
100
|
}
|
|
101
101
|
bodyLines.push('', output_1.output.dim('Re-run with --output-style=static to inline logs.'));
|
|
102
102
|
const title = this.countsLine(skipped);
|
|
103
|
-
|
|
103
|
+
// A discrete task that never reported was skipped, which fails the run; a
|
|
104
|
+
// continuous one nothing needed is never started
|
|
105
|
+
if (this.failed.length > 0 ||
|
|
106
|
+
this.stopped.length > 0 ||
|
|
107
|
+
this.tasks.some((t) => !t.continuous && !this.completed.has(t.id))) {
|
|
104
108
|
output_1.output.error({ title, bodyLines });
|
|
105
109
|
}
|
|
106
110
|
else {
|
|
@@ -44,5 +44,6 @@ export declare class PseudoIPCClient {
|
|
|
44
44
|
sendMessageToParent(message: Serializable): void;
|
|
45
45
|
notifyChildIsReady(id: string): void;
|
|
46
46
|
onMessageFromParent(forkId: string, onMessage: (message: Serializable) => void, onClose?: () => void, onError?: (err: Error) => void): this;
|
|
47
|
+
unref(): this;
|
|
47
48
|
close(): void;
|
|
48
49
|
}
|
|
@@ -58,7 +58,7 @@ export declare class PseudoTtyProcess implements RunningTask {
|
|
|
58
58
|
terminalOutput: string;
|
|
59
59
|
}>;
|
|
60
60
|
onExit(callback: (code: number, terminalOutput: string) => void): void;
|
|
61
|
-
onOutput(callback: (message: string) => void): void;
|
|
61
|
+
onOutput(callback: (message: string, isCommandHeader: boolean) => void): void;
|
|
62
62
|
getPid(): number | undefined;
|
|
63
63
|
kill(s?: NodeJS.Signals): Promise<void>;
|
|
64
64
|
getPtyHandles(): import("../native").ExternalObject<[import("../native").ParserArc, import("../native").WriterArc, import("../native").MasterArc]>;
|
|
@@ -109,12 +109,12 @@ class PseudoTtyProcess {
|
|
|
109
109
|
this.exitCallbacks = [];
|
|
110
110
|
this.outputCallbacks = [];
|
|
111
111
|
this.terminalOutputChunks = [];
|
|
112
|
-
childProcess.onOutput((chunk) => {
|
|
112
|
+
childProcess.onOutput((chunk, isCommandHeader) => {
|
|
113
113
|
if (!this.quiet) {
|
|
114
114
|
output_1.output.noteExternalWrite(chunk);
|
|
115
115
|
}
|
|
116
116
|
this.terminalOutputChunks.push(chunk);
|
|
117
|
-
this.outputCallbacks.forEach((cb) => cb(chunk));
|
|
117
|
+
this.outputCallbacks.forEach((cb) => cb(chunk, isCommandHeader));
|
|
118
118
|
});
|
|
119
119
|
childProcess.onExit((message) => {
|
|
120
120
|
this.isAlive = false;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Passes the executor's results through unchanged and signals the task ready
|
|
3
|
+
* at the `baseUrl` of the first successful result that has one.
|
|
4
|
+
*/
|
|
5
|
+
export declare function signalReadyAtBaseUrl<T extends {
|
|
6
|
+
success: boolean;
|
|
7
|
+
}>(results: AsyncIterableIterator<T>): AsyncIterableIterator<T>;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.signalReadyAtBaseUrl = signalReadyAtBaseUrl;
|
|
4
|
+
const ready_signal_1 = require("./ready-signal");
|
|
5
|
+
/**
|
|
6
|
+
* Passes the executor's results through unchanged and signals the task ready
|
|
7
|
+
* at the `baseUrl` of the first successful result that has one.
|
|
8
|
+
*/
|
|
9
|
+
async function* signalReadyAtBaseUrl(results) {
|
|
10
|
+
const iterator = results[Symbol.asyncIterator]();
|
|
11
|
+
let signalled = false;
|
|
12
|
+
while (true) {
|
|
13
|
+
const result = await iterator.next();
|
|
14
|
+
if (result.done) {
|
|
15
|
+
return result.value;
|
|
16
|
+
}
|
|
17
|
+
if (!signalled) {
|
|
18
|
+
const url = getReadySignalUrl(result.value);
|
|
19
|
+
if (url) {
|
|
20
|
+
signalled = true;
|
|
21
|
+
(0, ready_signal_1.emitReadySignal)(url);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
yield result.value;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
function getReadySignalUrl(result) {
|
|
28
|
+
const { baseUrl } = result;
|
|
29
|
+
if (result.success !== true ||
|
|
30
|
+
typeof baseUrl !== 'string' ||
|
|
31
|
+
!URL.canParse(baseUrl)) {
|
|
32
|
+
return undefined;
|
|
33
|
+
}
|
|
34
|
+
const url = new URL(baseUrl);
|
|
35
|
+
// `localhost:4200` parses too, with `localhost:` as its protocol
|
|
36
|
+
if (url.protocol !== 'http:' && url.protocol !== 'https:') {
|
|
37
|
+
return undefined;
|
|
38
|
+
}
|
|
39
|
+
if (url.hostname === '0.0.0.0' || url.hostname === '[::]') {
|
|
40
|
+
url.hostname = 'localhost';
|
|
41
|
+
}
|
|
42
|
+
return url.href;
|
|
43
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { RunningTask } from '../running-tasks/running-task';
|
|
2
|
+
import type { ReadySignalServer } from './ready-signal-server';
|
|
3
|
+
import { type NormalizedReadyWhen } from './ready-when';
|
|
4
|
+
export interface ReadinessProbeContext {
|
|
5
|
+
taskId: string;
|
|
6
|
+
runningTask: RunningTask;
|
|
7
|
+
cwd: string;
|
|
8
|
+
signal: AbortSignal;
|
|
9
|
+
readySignal?: ReadySignalServer;
|
|
10
|
+
}
|
|
11
|
+
export interface Readiness {
|
|
12
|
+
url?: string;
|
|
13
|
+
}
|
|
14
|
+
export declare function waitForReadiness(readyWhen: NormalizedReadyWhen, context: ReadinessProbeContext): Promise<Readiness>;
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.waitForReadiness = waitForReadiness;
|
|
4
|
+
const native_1 = require("../../native");
|
|
5
|
+
const startup_host_1 = require("./startup-host");
|
|
6
|
+
const ready_when_1 = require("./ready-when");
|
|
7
|
+
// Never rejects for a transient probe error: every failure is retried until
|
|
8
|
+
// the deadline.
|
|
9
|
+
async function waitForReadiness(readyWhen, context) {
|
|
10
|
+
if (readyWhen.kind === 'signal') {
|
|
11
|
+
return waitForSignal(readyWhen, context);
|
|
12
|
+
}
|
|
13
|
+
await waitForCheck(readyWhen, context);
|
|
14
|
+
return {};
|
|
15
|
+
}
|
|
16
|
+
async function waitForCheck(readyWhen, context) {
|
|
17
|
+
if (native_1.IS_WASM) {
|
|
18
|
+
throw new Error(`The WASM build of Nx does not support "readyWhen", so "${context.taskId}" cannot be probed for readiness.`);
|
|
19
|
+
}
|
|
20
|
+
if (readyWhen.kind === 'logMatches') {
|
|
21
|
+
return waitForLogMatch(readyWhen, context);
|
|
22
|
+
}
|
|
23
|
+
const probe = new native_1.ReadinessProbe({
|
|
24
|
+
timeout: readyWhen.timeout,
|
|
25
|
+
interval: readyWhen.interval,
|
|
26
|
+
...(readyWhen.kind === 'url'
|
|
27
|
+
? { url: readyWhen.url }
|
|
28
|
+
: readyWhen.kind === 'port'
|
|
29
|
+
? { port: readyWhen.port, host: (0, startup_host_1.resolveStartupHost)(readyWhen.host) }
|
|
30
|
+
: { command: readyWhen.command, env: readyWhen.env }),
|
|
31
|
+
}, context.cwd);
|
|
32
|
+
const cancel = () => probe.cancel();
|
|
33
|
+
context.signal.addEventListener('abort', cancel);
|
|
34
|
+
if (context.signal.aborted) {
|
|
35
|
+
probe.cancel();
|
|
36
|
+
}
|
|
37
|
+
let ready;
|
|
38
|
+
try {
|
|
39
|
+
ready = await probe.wait();
|
|
40
|
+
}
|
|
41
|
+
finally {
|
|
42
|
+
context.signal.removeEventListener('abort', cancel);
|
|
43
|
+
}
|
|
44
|
+
if (!ready) {
|
|
45
|
+
throw context.signal.aborted
|
|
46
|
+
? (0, ready_when_1.notReadyError)(context.taskId, 'exited')
|
|
47
|
+
: (0, ready_when_1.readinessTimeoutError)(context.taskId, readyWhen);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
// Ready on the producer's `ready` message, which a message sent before the
|
|
51
|
+
// check started counts as
|
|
52
|
+
function waitForSignal(readyWhen, context) {
|
|
53
|
+
return new Promise((resolve, reject) => {
|
|
54
|
+
let unsubscribe = () => { };
|
|
55
|
+
let settled = false;
|
|
56
|
+
const settle = (error, readiness) => {
|
|
57
|
+
if (settled)
|
|
58
|
+
return;
|
|
59
|
+
settled = true;
|
|
60
|
+
clearTimeout(timer);
|
|
61
|
+
unsubscribe();
|
|
62
|
+
context.signal.removeEventListener('abort', onAbort);
|
|
63
|
+
error ? reject(error) : resolve(readiness);
|
|
64
|
+
};
|
|
65
|
+
const onAbort = () => settle((0, ready_when_1.notReadyError)(context.taskId, 'exited'));
|
|
66
|
+
const timer = setTimeout(() => settle((0, ready_when_1.readinessTimeoutError)(context.taskId, readyWhen)), readyWhen.timeout);
|
|
67
|
+
timer.unref();
|
|
68
|
+
context.signal.addEventListener('abort', onAbort);
|
|
69
|
+
if (context.signal.aborted) {
|
|
70
|
+
onAbort();
|
|
71
|
+
return;
|
|
72
|
+
}
|
|
73
|
+
const stop = context.readySignal?.subscribe(context.taskId, (message) => settle(null, message.url ? { url: message.url } : {}));
|
|
74
|
+
if (settled) {
|
|
75
|
+
stop?.();
|
|
76
|
+
return;
|
|
77
|
+
}
|
|
78
|
+
unsubscribe = stop ?? unsubscribe;
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
function waitForLogMatch(readyWhen, context) {
|
|
82
|
+
return new Promise((resolve, reject) => {
|
|
83
|
+
const matcher = new native_1.LogMatcher(readyWhen.logMatches);
|
|
84
|
+
let settled = false;
|
|
85
|
+
const settle = (error) => {
|
|
86
|
+
settled = true;
|
|
87
|
+
clearTimeout(timer);
|
|
88
|
+
context.signal.removeEventListener('abort', onAbort);
|
|
89
|
+
error ? reject(error) : resolve();
|
|
90
|
+
};
|
|
91
|
+
const onAbort = () => settle((0, ready_when_1.notReadyError)(context.taskId, 'exited'));
|
|
92
|
+
const timer = setTimeout(() => settle((0, ready_when_1.readinessTimeoutError)(context.taskId, readyWhen)), readyWhen.timeout);
|
|
93
|
+
timer.unref();
|
|
94
|
+
context.signal.addEventListener('abort', onAbort);
|
|
95
|
+
context.runningTask.onOutput((chunk, isCommandHeader) => {
|
|
96
|
+
if (!settled && !isCommandHeader && matcher.feed(chunk)) {
|
|
97
|
+
settle();
|
|
98
|
+
}
|
|
99
|
+
});
|
|
100
|
+
});
|
|
101
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { type ReadySignalMessage } from './ready-signal';
|
|
2
|
+
export type ReadySignalListener = (message: ReadySignalMessage) => void;
|
|
3
|
+
/**
|
|
4
|
+
* Receives the readiness signals of the producers this process starts. It
|
|
5
|
+
* does not depend on the pseudo terminal, which Windows and non-TTY runs lack.
|
|
6
|
+
*/
|
|
7
|
+
export declare class ReadySignalServer {
|
|
8
|
+
private readonly path;
|
|
9
|
+
private readonly server;
|
|
10
|
+
private started;
|
|
11
|
+
private listeners;
|
|
12
|
+
private early;
|
|
13
|
+
private issued;
|
|
14
|
+
env(taskId: string): Promise<NodeJS.ProcessEnv>;
|
|
15
|
+
subscribe(taskId: string, listener: ReadySignalListener): () => void;
|
|
16
|
+
close(): void;
|
|
17
|
+
private dispatch;
|
|
18
|
+
}
|