nx 17.0.3 → 17.0.5
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/LICENSE +1 -1
- package/README.md +9 -4
- package/bin/init-local.js +10 -60
- package/bin/nx-cloud.js +6 -0
- package/bin/nx.js +1 -9
- package/bin/post-install.js +5 -1
- package/bin/run-executor.js +1 -1
- package/migrations.json +18 -0
- package/package.json +21 -18
- package/plugins/package-json.js +1 -1
- package/{changelog-renderer → release/changelog-renderer}/index.d.ts +18 -3
- package/{changelog-renderer → release/changelog-renderer}/index.js +78 -34
- package/release/index.d.ts +4 -0
- package/release/index.js +11 -0
- package/schemas/nx-schema.json +203 -19
- package/schemas/project-schema.json +20 -0
- package/src/adapter/angular-json.js +28 -18
- package/src/adapter/compat.d.ts +2 -2
- package/src/adapter/compat.js +6 -1
- package/src/adapter/ngcli-adapter.d.ts +16 -4
- package/src/adapter/ngcli-adapter.js +85 -28
- package/src/command-line/add/add.d.ts +2 -0
- package/src/command-line/add/add.js +169 -0
- package/src/command-line/add/command-object.d.ts +7 -0
- package/src/command-line/add/command-object.js +24 -0
- package/src/command-line/affected/affected.js +0 -3
- package/src/command-line/affected/command-object.d.ts +4 -4
- package/src/command-line/affected/command-object.js +53 -26
- package/src/command-line/affected/print-affected.js +10 -1
- package/src/command-line/connect/command-object.d.ts +1 -2
- package/src/command-line/connect/command-object.js +3 -7
- package/src/command-line/connect/connect-to-nx-cloud.d.ts +4 -5
- package/src/command-line/connect/connect-to-nx-cloud.js +43 -31
- package/src/command-line/connect/view-logs.js +5 -21
- package/src/command-line/examples.js +18 -0
- package/src/command-line/exec/command-object.js +2 -1
- package/src/command-line/exec/exec.d.ts +1 -1
- package/src/command-line/exec/exec.js +78 -35
- package/src/command-line/format/format.js +13 -4
- package/src/command-line/generate/generate.js +9 -9
- package/src/command-line/generate/generator-utils.d.ts +3 -2
- package/src/command-line/generate/generator-utils.js +5 -5
- package/src/command-line/graph/graph.d.ts +1 -1
- package/src/command-line/graph/graph.js +82 -37
- package/src/command-line/init/command-object.js +70 -43
- package/src/command-line/init/implementation/add-nx-to-monorepo.d.ts +4 -2
- package/src/command-line/init/implementation/add-nx-to-monorepo.js +11 -2
- package/src/command-line/init/implementation/add-nx-to-nest.d.ts +1 -1
- package/src/command-line/init/implementation/add-nx-to-nest.js +9 -6
- package/src/command-line/init/implementation/add-nx-to-npm-repo.d.ts +4 -2
- package/src/command-line/init/implementation/add-nx-to-npm-repo.js +14 -4
- package/src/command-line/init/implementation/angular/index.js +4 -1
- package/src/command-line/init/implementation/angular/legacy-angular-versions.js +10 -5
- package/src/command-line/init/implementation/angular/standalone-workspace.js +1 -1
- package/src/command-line/init/implementation/angular/types.d.ts +1 -1
- package/src/command-line/init/implementation/dot-nx/nxw.js +47 -16
- package/src/command-line/init/implementation/react/index.d.ts +1 -1
- package/src/command-line/init/implementation/react/index.js +4 -2
- package/src/command-line/init/implementation/react/rename-js-to-jsx.js +4 -2
- package/src/command-line/init/implementation/utils.d.ts +5 -5
- package/src/command-line/init/implementation/utils.js +46 -44
- package/src/command-line/init/{init.js → init-v1.js} +5 -13
- package/src/command-line/init/init-v2.d.ts +7 -0
- package/src/command-line/init/init-v2.js +201 -0
- package/src/command-line/list/list.js +6 -5
- package/src/command-line/migrate/command-object.js +19 -4
- package/src/command-line/migrate/migrate.js +21 -17
- package/src/command-line/new/new.js +1 -1
- package/src/command-line/nx-commands.js +4 -1
- package/src/command-line/release/changelog.d.ts +22 -1
- package/src/command-line/release/changelog.js +459 -257
- package/src/command-line/release/command-object.d.ts +29 -7
- package/src/command-line/release/command-object.js +120 -20
- package/src/command-line/release/config/config.d.ts +26 -21
- package/src/command-line/release/config/config.js +416 -59
- package/src/command-line/release/config/conventional-commits.d.ts +2 -0
- package/src/command-line/release/config/conventional-commits.js +98 -0
- package/src/command-line/release/config/filter-release-groups.d.ts +1 -2
- package/src/command-line/release/config/filter-release-groups.js +38 -1
- package/src/command-line/release/index.d.ts +16 -0
- package/src/command-line/release/index.js +23 -0
- package/src/command-line/release/publish.d.ts +7 -3
- package/src/command-line/release/publish.js +89 -37
- package/src/command-line/release/release.d.ts +4 -0
- package/src/command-line/release/release.js +176 -0
- package/src/command-line/release/utils/batch-projects-by-generator-config.d.ts +7 -0
- package/src/command-line/release/utils/batch-projects-by-generator-config.js +37 -0
- package/src/command-line/release/utils/exec-command.d.ts +1 -0
- package/src/command-line/release/utils/exec-command.js +34 -0
- package/src/command-line/release/utils/git.d.ts +34 -1
- package/src/command-line/release/utils/git.js +238 -34
- package/src/command-line/release/utils/github.d.ts +5 -5
- package/src/command-line/release/utils/github.js +155 -8
- package/src/command-line/release/utils/markdown.js +6 -1
- package/src/command-line/release/utils/print-changes.d.ts +1 -1
- package/src/command-line/release/utils/print-changes.js +3 -3
- package/src/command-line/release/utils/resolve-nx-json-error-message.js +4 -1
- package/src/command-line/release/utils/resolve-semver-specifier.d.ts +4 -0
- package/src/command-line/release/utils/resolve-semver-specifier.js +58 -0
- package/src/command-line/release/utils/semver.d.ts +8 -0
- package/src/command-line/release/utils/semver.js +30 -1
- package/src/command-line/release/utils/shared.d.ts +39 -0
- package/src/command-line/release/utils/shared.js +213 -0
- package/src/command-line/release/version.d.ts +37 -3
- package/src/command-line/release/version.js +312 -117
- package/src/command-line/repair/repair.js +13 -9
- package/src/command-line/report/report.d.ts +3 -0
- package/src/command-line/report/report.js +22 -5
- package/src/command-line/run/command-object.d.ts +4 -0
- package/src/command-line/run/command-object.js +18 -2
- package/src/command-line/run/executor-utils.d.ts +2 -1
- package/src/command-line/run/executor-utils.js +4 -4
- package/src/command-line/run/run-one.js +3 -6
- package/src/command-line/run/run.js +34 -9
- package/src/command-line/run-many/command-object.js +4 -1
- package/src/command-line/run-many/run-many.js +0 -3
- package/src/command-line/show/command-object.d.ts +3 -0
- package/src/command-line/show/command-object.js +29 -2
- package/src/command-line/show/show.js +9 -0
- package/src/command-line/yargs-utils/shared-options.d.ts +4 -1
- package/src/command-line/yargs-utils/shared-options.js +23 -9
- package/src/commands-runner/command-graph.d.ts +13 -0
- package/src/commands-runner/command-graph.js +2 -0
- package/src/commands-runner/create-command-graph.d.ts +4 -0
- package/src/commands-runner/create-command-graph.js +44 -0
- package/src/commands-runner/get-command-projects.d.ts +3 -0
- package/src/commands-runner/get-command-projects.js +19 -0
- package/src/config/nx-json.d.ts +160 -25
- package/src/config/project-graph.d.ts +3 -3
- package/src/config/workspace-json-project-json.d.ts +23 -1
- package/src/config/workspaces.d.ts +1 -1
- package/src/config/workspaces.js +4 -6
- package/src/core/graph/3rdpartylicenses.txt +144 -74
- package/src/core/graph/environment.js +1 -1
- package/src/core/graph/index.html +4 -6
- package/src/core/graph/main.js +1 -1
- package/src/core/graph/runtime.js +1 -1
- package/src/core/graph/styles.css +3 -3
- package/src/core/graph/styles.js +1 -1
- package/src/daemon/client/client.d.ts +5 -1
- package/src/daemon/client/client.js +27 -8
- package/src/daemon/client/{socket-messenger.d.ts → daemon-socket-messenger.d.ts} +1 -1
- package/src/daemon/client/{socket-messenger.js → daemon-socket-messenger.js} +3 -3
- package/src/daemon/daemon-project-graph-error.d.ts +8 -0
- package/src/daemon/daemon-project-graph-error.js +13 -0
- package/src/daemon/server/handle-hash-tasks.js +12 -2
- package/src/daemon/server/handle-request-project-graph.js +1 -1
- package/src/daemon/server/project-graph-incremental-recomputation.d.ts +14 -13
- package/src/daemon/server/project-graph-incremental-recomputation.js +98 -33
- package/src/daemon/server/shutdown-utils.js +2 -4
- package/src/daemon/server/watcher.js +0 -3
- package/src/daemon/socket-utils.d.ts +2 -1
- package/src/daemon/socket-utils.js +15 -4
- package/src/daemon/tmp-dir.d.ts +1 -0
- package/src/daemon/tmp-dir.js +4 -4
- package/src/devkit-exports.d.ts +2 -2
- package/src/devkit-exports.js +3 -2
- package/src/devkit-internals.d.ts +3 -0
- package/src/devkit-internals.js +7 -1
- package/src/executors/noop/schema.json +1 -1
- package/src/executors/run-commands/run-commands.impl.d.ts +10 -2
- package/src/executors/run-commands/run-commands.impl.js +152 -48
- package/src/executors/run-commands/schema.json +11 -1
- package/src/executors/run-script/run-script.impl.js +43 -11
- package/src/executors/utils/convert-nx-executor.js +1 -1
- package/src/generators/internal-utils/format-changed-files-with-prettier-if-available.d.ts +3 -1
- package/src/generators/internal-utils/format-changed-files-with-prettier-if-available.js +4 -2
- package/src/generators/testing-utils/create-tree-with-empty-workspace.js +0 -6
- package/src/generators/tree.d.ts +1 -0
- package/src/generators/utils/glob.js +2 -2
- package/src/generators/utils/project-configuration.js +28 -9
- package/src/hasher/create-task-hasher.d.ts +4 -0
- package/src/hasher/create-task-hasher.js +16 -0
- package/src/hasher/hash-task.js +9 -3
- package/src/hasher/native-task-hasher-impl.d.ts +19 -0
- package/src/hasher/native-task-hasher-impl.js +37 -0
- package/src/hasher/node-task-hasher-impl.d.ts +49 -0
- package/src/hasher/node-task-hasher-impl.js +431 -0
- package/src/hasher/task-hasher.d.ts +33 -21
- package/src/hasher/task-hasher.js +30 -428
- package/src/migrations/update-15-0-0/migrate-to-inputs.js +5 -5
- package/src/migrations/update-15-1-0/set-project-names.js +2 -1
- package/src/migrations/update-15-8-2/update-nxw.js +2 -6
- package/src/migrations/update-17-0-0/rm-default-collection-npm-scope.js +3 -3
- package/src/migrations/update-17-0-0/use-minimal-config-for-tasks-runner-options.js +49 -13
- package/src/migrations/update-17-2-0/move-default-base.d.ts +5 -0
- package/src/migrations/update-17-2-0/move-default-base.js +21 -0
- package/src/migrations/update-17-3-0/nx-release-path.d.ts +3 -0
- package/src/migrations/update-17-3-0/nx-release-path.js +48 -0
- package/src/migrations/update-17-3-0/update-nxw.d.ts +2 -0
- package/src/migrations/update-17-3-0/update-nxw.js +7 -0
- package/src/migrations/update-18-0-0/disable-crystal-for-existing-workspaces.d.ts +2 -0
- package/src/migrations/update-18-0-0/disable-crystal-for-existing-workspaces.js +9 -0
- package/src/native/index.d.ts +65 -15
- package/src/native/index.js +6 -2
- package/src/native/transform-objects.js +2 -0
- package/src/nx-cloud/generators/connect-to-nx-cloud/connect-to-nx-cloud.d.ts +1 -0
- package/src/nx-cloud/generators/connect-to-nx-cloud/connect-to-nx-cloud.js +13 -12
- package/src/nx-cloud/generators/connect-to-nx-cloud/schema.json +6 -1
- package/src/nx-cloud/update-manager.js +2 -1
- package/src/plugins/js/index.d.ts +1 -1
- package/src/plugins/js/index.js +3 -3
- package/src/plugins/js/lock-file/lock-file.d.ts +2 -2
- package/src/plugins/js/lock-file/lock-file.js +15 -3
- package/src/plugins/js/package-json/create-package-json.js +1 -1
- package/src/plugins/js/project-graph/build-dependencies/strip-source-code.d.ts +1 -1
- package/src/plugins/js/project-graph/build-dependencies/strip-source-code.js +1 -1
- package/src/plugins/js/project-graph/build-dependencies/typescript-import-locator.d.ts +1 -1
- package/src/plugins/js/project-graph/build-dependencies/typescript-import-locator.js +1 -1
- package/src/plugins/js/utils/register.d.ts +1 -1
- package/src/plugins/js/utils/register.js +28 -8
- package/src/plugins/js/versions.d.ts +1 -1
- package/src/plugins/js/versions.js +1 -1
- package/{plugins/package-json-workspaces.d.ts → src/plugins/package-json-workspaces/create-nodes.d.ts} +4 -4
- package/{plugins/package-json-workspaces.js → src/plugins/package-json-workspaces/create-nodes.js} +34 -12
- package/src/plugins/package-json-workspaces/index.d.ts +1 -0
- package/src/plugins/package-json-workspaces/index.js +4 -0
- package/src/plugins/project-json/build-nodes/package-json-next-to-project-json.d.ts +2 -0
- package/src/plugins/project-json/build-nodes/package-json-next-to-project-json.js +47 -0
- package/src/plugins/project-json/build-nodes/project-json.d.ts +2 -5
- package/src/plugins/project-json/build-nodes/project-json.js +6 -44
- package/src/plugins/target-defaults/target-defaults-plugin.d.ts +66 -0
- package/src/plugins/target-defaults/target-defaults-plugin.js +182 -0
- package/src/project-graph/affected/locators/project-glob-changes.js +3 -3
- package/src/project-graph/affected/locators/workspace-projects.d.ts +0 -2
- package/src/project-graph/affected/locators/workspace-projects.js +16 -29
- package/src/project-graph/build-project-graph.d.ts +20 -1
- package/src/project-graph/build-project-graph.js +91 -33
- package/src/project-graph/file-map-utils.d.ts +9 -5
- package/src/project-graph/file-map-utils.js +16 -63
- package/src/project-graph/file-utils.d.ts +1 -1
- package/src/project-graph/file-utils.js +44 -2
- package/src/project-graph/nx-deps-cache.js +1 -1
- package/src/project-graph/project-graph-builder.d.ts +1 -1
- package/src/project-graph/project-graph-builder.js +1 -1
- package/src/project-graph/project-graph.d.ts +32 -1
- package/src/project-graph/project-graph.js +147 -23
- package/src/project-graph/utils/build-all-workspace-files.d.ts +2 -0
- package/src/project-graph/utils/build-all-workspace-files.js +15 -0
- package/src/project-graph/utils/normalize-project-nodes.d.ts +2 -3
- package/src/project-graph/utils/normalize-project-nodes.js +7 -33
- package/src/project-graph/utils/project-configuration-utils.d.ts +66 -4
- package/src/project-graph/utils/project-configuration-utils.js +509 -62
- package/src/project-graph/utils/retrieve-workspace-files.d.ts +12 -31
- package/src/project-graph/utils/retrieve-workspace-files.js +27 -90
- package/src/tasks-runner/batch/run-batch.js +3 -3
- package/src/tasks-runner/cache.js +6 -3
- package/src/tasks-runner/create-task-graph.js +1 -1
- package/src/tasks-runner/fork.d.ts +1 -0
- package/src/tasks-runner/fork.js +23 -0
- package/src/tasks-runner/forked-process-task-runner.d.ts +13 -5
- package/src/tasks-runner/forked-process-task-runner.js +112 -21
- package/src/tasks-runner/init-tasks-runner.js +1 -1
- package/src/tasks-runner/life-cycles/dynamic-run-many-terminal-output-life-cycle.js +28 -28
- package/src/tasks-runner/life-cycles/dynamic-run-one-terminal-output-life-cycle.js +19 -22
- package/src/tasks-runner/life-cycles/empty-terminal-output-life-cycle.js +1 -3
- package/src/tasks-runner/life-cycles/invoke-runner-terminal-output-life-cycle.js +1 -3
- package/src/tasks-runner/life-cycles/static-run-many-terminal-output-life-cycle.js +2 -4
- package/src/tasks-runner/life-cycles/static-run-one-terminal-output-life-cycle.d.ts +1 -0
- package/src/tasks-runner/life-cycles/static-run-one-terminal-output-life-cycle.js +11 -5
- package/src/tasks-runner/life-cycles/view-logs-utils.js +1 -1
- package/src/tasks-runner/pseudo-ipc.d.ts +49 -0
- package/src/tasks-runner/pseudo-ipc.js +140 -0
- package/src/tasks-runner/pseudo-terminal.d.ts +43 -0
- package/src/tasks-runner/pseudo-terminal.js +159 -0
- package/src/tasks-runner/run-command.d.ts +1 -1
- package/src/tasks-runner/run-command.js +13 -19
- package/src/tasks-runner/task-env.js +1 -2
- package/src/tasks-runner/task-graph-utils.d.ts +7 -3
- package/src/tasks-runner/task-graph-utils.js +15 -15
- package/src/tasks-runner/task-orchestrator.js +68 -12
- package/src/tasks-runner/tasks-schedule.js +3 -3
- package/src/tasks-runner/utils.d.ts +16 -7
- package/src/tasks-runner/utils.js +30 -16
- package/src/utils/ab-testing.d.ts +36 -2
- package/src/utils/ab-testing.js +34 -16
- package/src/utils/assert-workspace-validity.js +1 -1
- package/src/utils/cache-directory.d.ts +1 -0
- package/src/utils/cache-directory.js +5 -1
- package/src/utils/child-process.d.ts +15 -1
- package/src/utils/child-process.js +91 -1
- package/src/utils/command-line-utils.js +2 -1
- package/src/utils/exit-codes.d.ts +6 -0
- package/src/utils/exit-codes.js +20 -0
- package/src/utils/fileutils.d.ts +1 -0
- package/src/utils/find-matching-projects.js +5 -5
- package/src/utils/find-workspace-root.js +1 -0
- package/src/utils/ignore.js +8 -1
- package/src/utils/json-diff.d.ts +1 -0
- package/src/utils/json-diff.js +2 -1
- package/src/utils/json.js +3 -1
- package/src/utils/logger.js +1 -1
- package/src/utils/nx-cloud-utils.d.ts +1 -1
- package/src/utils/nx-cloud-utils.js +9 -4
- package/src/utils/nx-plugin.d.ts +32 -15
- package/src/utils/nx-plugin.deprecated.d.ts +10 -5
- package/src/utils/nx-plugin.deprecated.js +23 -0
- package/src/utils/nx-plugin.js +71 -80
- package/src/utils/output.d.ts +4 -2
- package/src/utils/output.js +44 -9
- package/src/utils/package-json.d.ts +4 -4
- package/src/utils/package-json.js +18 -12
- package/src/utils/package-manager.d.ts +7 -0
- package/src/utils/package-manager.js +24 -4
- package/src/utils/params.d.ts +12 -4
- package/src/utils/params.js +37 -4
- package/src/utils/plugins/core-plugins.js +8 -0
- package/src/utils/plugins/installed-plugins.d.ts +2 -1
- package/src/utils/plugins/installed-plugins.js +2 -2
- package/src/utils/plugins/local-plugins.js +1 -1
- package/src/utils/plugins/plugin-capabilities.d.ts +3 -2
- package/src/utils/plugins/plugin-capabilities.js +7 -7
- package/src/utils/typescript.js +1 -1
- package/src/utils/update-nxw.d.ts +2 -0
- package/src/utils/update-nxw.js +12 -0
- package/src/utils/workspace-configuration-check.js +1 -1
- package/src/utils/workspace-context.d.ts +6 -4
- package/src/utils/workspace-context.js +19 -9
- package/src/core/graph/polyfills.js +0 -1
- /package/src/command-line/init/{init.d.ts → init-v1.d.ts} +0 -0
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.PseudoTtyProcessWithSend = exports.PseudoTtyProcess = exports.PseudoTerminal = exports.getPseudoTerminal = void 0;
|
|
4
|
+
const native_1 = require("../native");
|
|
5
|
+
const pseudo_ipc_1 = require("./pseudo-ipc");
|
|
6
|
+
const socket_utils_1 = require("../daemon/socket-utils");
|
|
7
|
+
const os = require("os");
|
|
8
|
+
let pseudoTerminal;
|
|
9
|
+
function getPseudoTerminal(skipSupportCheck = false) {
|
|
10
|
+
if (!skipSupportCheck && !PseudoTerminal.isSupported()) {
|
|
11
|
+
throw new Error('Pseudo terminal is not supported on this platform.');
|
|
12
|
+
}
|
|
13
|
+
pseudoTerminal ??= new PseudoTerminal(new native_1.RustPseudoTerminal());
|
|
14
|
+
return pseudoTerminal;
|
|
15
|
+
}
|
|
16
|
+
exports.getPseudoTerminal = getPseudoTerminal;
|
|
17
|
+
class PseudoTerminal {
|
|
18
|
+
static isSupported() {
|
|
19
|
+
return process.stdout.isTTY && supportedPtyPlatform();
|
|
20
|
+
}
|
|
21
|
+
constructor(rustPseudoTerminal) {
|
|
22
|
+
this.rustPseudoTerminal = rustPseudoTerminal;
|
|
23
|
+
this.pseudoIPCPath = (0, socket_utils_1.FORKED_PROCESS_OS_SOCKET_PATH)(process.pid.toString());
|
|
24
|
+
this.pseudoIPC = new pseudo_ipc_1.PseudoIPCServer(this.pseudoIPCPath);
|
|
25
|
+
this.initialized = false;
|
|
26
|
+
this.setupProcessListeners();
|
|
27
|
+
}
|
|
28
|
+
async init() {
|
|
29
|
+
if (this.initialized) {
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
32
|
+
await this.pseudoIPC.init();
|
|
33
|
+
this.initialized = true;
|
|
34
|
+
}
|
|
35
|
+
runCommand(command, { cwd, jsEnv, quiet, } = {}) {
|
|
36
|
+
return new PseudoTtyProcess(this.rustPseudoTerminal.runCommand(command, cwd, jsEnv, quiet));
|
|
37
|
+
}
|
|
38
|
+
async fork(id, script, { cwd, jsEnv, quiet, }) {
|
|
39
|
+
if (!this.initialized) {
|
|
40
|
+
throw new Error('Call init() before forking processes');
|
|
41
|
+
}
|
|
42
|
+
const cp = new PseudoTtyProcessWithSend(this.rustPseudoTerminal.fork(id, script, this.pseudoIPCPath, cwd, jsEnv, quiet), id, this.pseudoIPC);
|
|
43
|
+
await this.pseudoIPC.waitForChildReady(id);
|
|
44
|
+
return cp;
|
|
45
|
+
}
|
|
46
|
+
sendMessageToChildren(message) {
|
|
47
|
+
this.pseudoIPC.sendMessageToChildren(message);
|
|
48
|
+
}
|
|
49
|
+
onMessageFromChildren(callback) {
|
|
50
|
+
this.pseudoIPC.onMessageFromChildren(callback);
|
|
51
|
+
}
|
|
52
|
+
setupProcessListeners() {
|
|
53
|
+
const shutdown = () => {
|
|
54
|
+
this.shutdownPseudoIPC();
|
|
55
|
+
};
|
|
56
|
+
process.on('SIGINT', () => {
|
|
57
|
+
this.shutdownPseudoIPC();
|
|
58
|
+
});
|
|
59
|
+
process.on('SIGTERM', () => {
|
|
60
|
+
this.shutdownPseudoIPC();
|
|
61
|
+
});
|
|
62
|
+
process.on('SIGHUP', () => {
|
|
63
|
+
this.shutdownPseudoIPC();
|
|
64
|
+
});
|
|
65
|
+
process.on('exit', () => {
|
|
66
|
+
this.shutdownPseudoIPC();
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
shutdownPseudoIPC() {
|
|
70
|
+
if (this.initialized) {
|
|
71
|
+
this.pseudoIPC.close();
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
exports.PseudoTerminal = PseudoTerminal;
|
|
76
|
+
class PseudoTtyProcess {
|
|
77
|
+
constructor(childProcess) {
|
|
78
|
+
this.childProcess = childProcess;
|
|
79
|
+
this.isAlive = true;
|
|
80
|
+
this.exitCallbacks = [];
|
|
81
|
+
childProcess.onExit((message) => {
|
|
82
|
+
this.isAlive = false;
|
|
83
|
+
const exitCode = messageToCode(message);
|
|
84
|
+
this.exitCallbacks.forEach((cb) => cb(exitCode));
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
onExit(callback) {
|
|
88
|
+
this.exitCallbacks.push(callback);
|
|
89
|
+
}
|
|
90
|
+
onOutput(callback) {
|
|
91
|
+
this.childProcess.onOutput(callback);
|
|
92
|
+
}
|
|
93
|
+
kill() {
|
|
94
|
+
try {
|
|
95
|
+
this.childProcess.kill();
|
|
96
|
+
}
|
|
97
|
+
catch {
|
|
98
|
+
// when the child process completes before we explicitly call kill, this will throw
|
|
99
|
+
// do nothing
|
|
100
|
+
}
|
|
101
|
+
finally {
|
|
102
|
+
if (this.isAlive == true) {
|
|
103
|
+
this.isAlive = false;
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
exports.PseudoTtyProcess = PseudoTtyProcess;
|
|
109
|
+
class PseudoTtyProcessWithSend extends PseudoTtyProcess {
|
|
110
|
+
constructor(_childProcess, id, pseudoIpc) {
|
|
111
|
+
super(_childProcess);
|
|
112
|
+
this.id = id;
|
|
113
|
+
this.pseudoIpc = pseudoIpc;
|
|
114
|
+
}
|
|
115
|
+
send(message) {
|
|
116
|
+
this.pseudoIpc.sendMessageToChild(this.id, message);
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
exports.PseudoTtyProcessWithSend = PseudoTtyProcessWithSend;
|
|
120
|
+
function messageToCode(message) {
|
|
121
|
+
if (message.startsWith('Terminated by ')) {
|
|
122
|
+
switch (message.replace('Terminated by ', '').trim()) {
|
|
123
|
+
case 'Termination':
|
|
124
|
+
return 143;
|
|
125
|
+
case 'Interrupt':
|
|
126
|
+
return 130;
|
|
127
|
+
default:
|
|
128
|
+
return 128;
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
else if (message.startsWith('Exited with code ')) {
|
|
132
|
+
return parseInt(message.replace('Exited with code ', '').trim());
|
|
133
|
+
}
|
|
134
|
+
else if (message === 'Success') {
|
|
135
|
+
return 0;
|
|
136
|
+
}
|
|
137
|
+
else {
|
|
138
|
+
return 1;
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
function supportedPtyPlatform() {
|
|
142
|
+
if (process.platform !== 'win32') {
|
|
143
|
+
return true;
|
|
144
|
+
}
|
|
145
|
+
let windowsVersion = os.release().split('.');
|
|
146
|
+
let windowsBuild = windowsVersion[2];
|
|
147
|
+
if (!windowsBuild) {
|
|
148
|
+
return false;
|
|
149
|
+
}
|
|
150
|
+
// Mininum supported Windows version:
|
|
151
|
+
// https://en.wikipedia.org/wiki/Windows_10,_version_1809
|
|
152
|
+
// https://learn.microsoft.com/en-us/windows/console/createpseudoconsole#requirements
|
|
153
|
+
if (+windowsBuild < 17763) {
|
|
154
|
+
return false;
|
|
155
|
+
}
|
|
156
|
+
else {
|
|
157
|
+
return true;
|
|
158
|
+
}
|
|
159
|
+
}
|
|
@@ -20,7 +20,7 @@ export declare function invokeTasksRunner({ tasks, projectGraph, taskGraph, life
|
|
|
20
20
|
nxArgs: NxArgs;
|
|
21
21
|
loadDotEnvFiles: boolean;
|
|
22
22
|
initiatingProject: string | null;
|
|
23
|
-
}): Promise<
|
|
23
|
+
}): Promise<1 | 0>;
|
|
24
24
|
export declare function getRunner(nxArgs: NxArgs, nxJson: NxJsonConfiguration): {
|
|
25
25
|
tasksRunner: TasksRunner;
|
|
26
26
|
runnerOptions: any;
|
|
@@ -17,12 +17,10 @@ const dynamic_run_one_terminal_output_life_cycle_1 = require("./life-cycles/dyna
|
|
|
17
17
|
const create_task_graph_1 = require("./create-task-graph");
|
|
18
18
|
const task_graph_utils_1 = require("./task-graph-utils");
|
|
19
19
|
const params_1 = require("../utils/params");
|
|
20
|
-
const task_hasher_1 = require("../hasher/task-hasher");
|
|
21
20
|
const hash_task_1 = require("../hasher/hash-task");
|
|
22
21
|
const client_1 = require("../daemon/client/client");
|
|
23
22
|
const store_run_information_life_cycle_1 = require("./life-cycles/store-run-information-life-cycle");
|
|
24
|
-
const
|
|
25
|
-
const perf_hooks_1 = require("perf_hooks");
|
|
23
|
+
const create_task_hasher_1 = require("../hasher/create-task-hasher");
|
|
26
24
|
async function getTerminalOutputLifeCycle(initiatingProject, projectNames, tasks, nxArgs, nxJson, overrides) {
|
|
27
25
|
const { runnerOptions } = getRunner(nxArgs, nxJson);
|
|
28
26
|
const isRunOne = initiatingProject != null;
|
|
@@ -121,21 +119,11 @@ function setEnvVarsBasedOnArgs(nxArgs, loadDotEnvFiles) {
|
|
|
121
119
|
async function invokeTasksRunner({ tasks, projectGraph, taskGraph, lifeCycle, nxJson, nxArgs, loadDotEnvFiles, initiatingProject, }) {
|
|
122
120
|
setEnvVarsBasedOnArgs(nxArgs, loadDotEnvFiles);
|
|
123
121
|
const { tasksRunner, runnerOptions } = getRunner(nxArgs, nxJson);
|
|
124
|
-
let hasher;
|
|
125
|
-
if (client_1.daemonClient.enabled()) {
|
|
126
|
-
hasher = new task_hasher_1.DaemonBasedTaskHasher(client_1.daemonClient, runnerOptions);
|
|
127
|
-
}
|
|
128
|
-
else {
|
|
129
|
-
const { fileMap, allWorkspaceFiles } = (0, build_project_graph_1.getFileMap)();
|
|
130
|
-
hasher = new task_hasher_1.InProcessTaskHasher(fileMap?.projectFileMap, allWorkspaceFiles, projectGraph, nxJson, runnerOptions);
|
|
131
|
-
}
|
|
122
|
+
let hasher = (0, create_task_hasher_1.createTaskHasher)(projectGraph, nxJson, runnerOptions);
|
|
132
123
|
// this is used for two reasons: to fetch all remote cache hits AND
|
|
133
124
|
// to submit everything that is known in advance to Nx Cloud to run in
|
|
134
125
|
// a distributed fashion
|
|
135
|
-
perf_hooks_1.performance.mark('hashing:start');
|
|
136
126
|
await (0, hash_task_1.hashTasksThatDoNotDependOnOutputsOfOtherTasks)(hasher, projectGraph, taskGraph, nxJson);
|
|
137
|
-
perf_hooks_1.performance.mark('hashing:end');
|
|
138
|
-
perf_hooks_1.performance.measure('hashing', 'hashing:start', 'hashing:end');
|
|
139
127
|
const promiseOrObservable = tasksRunner(tasks, {
|
|
140
128
|
...runnerOptions,
|
|
141
129
|
lifeCycle: new life_cycle_1.CompositeLifeCycle(constructLifeCycles(lifeCycle)),
|
|
@@ -152,7 +140,7 @@ async function invokeTasksRunner({ tasks, projectGraph, taskGraph, lifeCycle, nx
|
|
|
152
140
|
title: `TaskGraph is now required as an argument to hashTask`,
|
|
153
141
|
bodyLines: [
|
|
154
142
|
`The TaskGraph object can be retrieved from the context`,
|
|
155
|
-
'This will result in an error in Nx
|
|
143
|
+
'This will result in an error in Nx 19',
|
|
156
144
|
],
|
|
157
145
|
});
|
|
158
146
|
taskGraph_ = taskGraph;
|
|
@@ -162,7 +150,7 @@ async function invokeTasksRunner({ tasks, projectGraph, taskGraph, lifeCycle, nx
|
|
|
162
150
|
title: `The environment variables are now required as an argument to hashTask`,
|
|
163
151
|
bodyLines: [
|
|
164
152
|
`Please pass the environment variables used when running the task`,
|
|
165
|
-
'This will result in an error in Nx
|
|
153
|
+
'This will result in an error in Nx 19',
|
|
166
154
|
],
|
|
167
155
|
});
|
|
168
156
|
env = process.env;
|
|
@@ -175,7 +163,7 @@ async function invokeTasksRunner({ tasks, projectGraph, taskGraph, lifeCycle, nx
|
|
|
175
163
|
title: `TaskGraph is now required as an argument to hashTasks`,
|
|
176
164
|
bodyLines: [
|
|
177
165
|
`The TaskGraph object can be retrieved from the context`,
|
|
178
|
-
'This will result in an error in Nx
|
|
166
|
+
'This will result in an error in Nx 19',
|
|
179
167
|
],
|
|
180
168
|
});
|
|
181
169
|
taskGraph_ = taskGraph;
|
|
@@ -185,7 +173,7 @@ async function invokeTasksRunner({ tasks, projectGraph, taskGraph, lifeCycle, nx
|
|
|
185
173
|
title: `The environment variables are now required as an argument to hashTasks`,
|
|
186
174
|
bodyLines: [
|
|
187
175
|
`Please pass the environment variables used when running the tasks`,
|
|
188
|
-
'This will result in an error in Nx
|
|
176
|
+
'This will result in an error in Nx 19',
|
|
189
177
|
],
|
|
190
178
|
});
|
|
191
179
|
env = process.env;
|
|
@@ -318,7 +306,9 @@ function getTasksRunnerPath(runner, nxJson) {
|
|
|
318
306
|
// No tasksRunnerOptions for given --runner
|
|
319
307
|
nxJson.nxCloudAccessToken ||
|
|
320
308
|
// No runner prop in tasks runner options, check if access token is set.
|
|
321
|
-
nxJson.tasksRunnerOptions?.[runner]?.options?.accessToken
|
|
309
|
+
nxJson.tasksRunnerOptions?.[runner]?.options?.accessToken ||
|
|
310
|
+
// Cloud access token specified in env var.
|
|
311
|
+
process.env.NX_CLOUD_ACCESS_TOKEN;
|
|
322
312
|
return isCloudRunner ? 'nx-cloud' : require.resolve('./default-tasks-runner');
|
|
323
313
|
}
|
|
324
314
|
function getRunnerOptions(runner, nxJson, nxArgs, isCloudDefault) {
|
|
@@ -332,6 +322,10 @@ function getRunnerOptions(runner, nxJson, nxArgs, isCloudDefault) {
|
|
|
332
322
|
...nxJson.tasksRunnerOptions?.[runner]?.options,
|
|
333
323
|
...nxArgs,
|
|
334
324
|
};
|
|
325
|
+
// NOTE: we don't pull from env here because the cloud package
|
|
326
|
+
// supports it within nx-cloud's implementation. We could
|
|
327
|
+
// normalize it here, and that may make more sense, but
|
|
328
|
+
// leaving it as is for now.
|
|
335
329
|
if (nxJson.nxCloudAccessToken && isCloudDefault) {
|
|
336
330
|
result.accessToken ??= nxJson.nxCloudAccessToken;
|
|
337
331
|
}
|
|
@@ -35,8 +35,7 @@ function getEnvVariablesForTask(task, taskSpecificEnv, forceColor, skipNxCache,
|
|
|
35
35
|
delete res.NX_STREAM_OUTPUT;
|
|
36
36
|
delete res.NX_PREFIX_OUTPUT;
|
|
37
37
|
}
|
|
38
|
-
|
|
39
|
-
delete res.NX_HEAD;
|
|
38
|
+
// we don't reset NX_BASE or NX_HEAD because those are set by the user and should be preserved
|
|
40
39
|
delete res.NX_SET_CLI;
|
|
41
40
|
return res;
|
|
42
41
|
}
|
|
@@ -1,3 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
export declare function findCycle(taskGraph: {
|
|
2
|
+
dependencies: Record<string, string[]>;
|
|
3
|
+
}): string[] | null;
|
|
4
|
+
export declare function makeAcyclic(graph: {
|
|
5
|
+
roots: string[];
|
|
6
|
+
dependencies: Record<string, string[]>;
|
|
7
|
+
}): void;
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.makeAcyclic = exports.findCycle = void 0;
|
|
4
|
-
function _findCycle(
|
|
5
|
-
if (visited[
|
|
4
|
+
function _findCycle(graph, id, visited, path) {
|
|
5
|
+
if (visited[id])
|
|
6
6
|
return null;
|
|
7
|
-
visited[
|
|
8
|
-
for (const d of
|
|
7
|
+
visited[id] = true;
|
|
8
|
+
for (const d of graph.dependencies[id]) {
|
|
9
9
|
if (path.includes(d))
|
|
10
10
|
return [...path, d];
|
|
11
|
-
const cycle = _findCycle(
|
|
11
|
+
const cycle = _findCycle(graph, d, visited, [...path, d]);
|
|
12
12
|
if (cycle)
|
|
13
13
|
return cycle;
|
|
14
14
|
}
|
|
@@ -27,29 +27,29 @@ function findCycle(taskGraph) {
|
|
|
27
27
|
return null;
|
|
28
28
|
}
|
|
29
29
|
exports.findCycle = findCycle;
|
|
30
|
-
function _makeAcyclic(
|
|
31
|
-
if (visited[
|
|
30
|
+
function _makeAcyclic(graph, id, visited, path) {
|
|
31
|
+
if (visited[id])
|
|
32
32
|
return;
|
|
33
|
-
visited[
|
|
34
|
-
const deps =
|
|
33
|
+
visited[id] = true;
|
|
34
|
+
const deps = graph.dependencies[id];
|
|
35
35
|
for (const d of [...deps]) {
|
|
36
36
|
if (path.includes(d)) {
|
|
37
37
|
deps.splice(deps.indexOf(d), 1);
|
|
38
38
|
}
|
|
39
39
|
else {
|
|
40
|
-
_makeAcyclic(
|
|
40
|
+
_makeAcyclic(graph, d, visited, [...path, d]);
|
|
41
41
|
}
|
|
42
42
|
}
|
|
43
43
|
return null;
|
|
44
44
|
}
|
|
45
|
-
function makeAcyclic(
|
|
45
|
+
function makeAcyclic(graph) {
|
|
46
46
|
const visited = {};
|
|
47
|
-
for (const t of Object.keys(
|
|
47
|
+
for (const t of Object.keys(graph.dependencies)) {
|
|
48
48
|
visited[t] = false;
|
|
49
49
|
}
|
|
50
|
-
for (const t of Object.keys(
|
|
51
|
-
_makeAcyclic(
|
|
50
|
+
for (const t of Object.keys(graph.dependencies)) {
|
|
51
|
+
_makeAcyclic(graph, t, visited, [t]);
|
|
52
52
|
}
|
|
53
|
-
|
|
53
|
+
graph.roots = Object.keys(graph.dependencies).filter((t) => graph.dependencies[t].length === 0);
|
|
54
54
|
}
|
|
55
55
|
exports.makeAcyclic = makeAcyclic;
|
|
@@ -3,12 +3,18 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.TaskOrchestrator = void 0;
|
|
4
4
|
const events_1 = require("events");
|
|
5
5
|
const perf_hooks_1 = require("perf_hooks");
|
|
6
|
+
const path_1 = require("path");
|
|
7
|
+
const fs_1 = require("fs");
|
|
8
|
+
const run_commands_impl_1 = require("../executors/run-commands/run-commands.impl");
|
|
6
9
|
const forked_process_task_runner_1 = require("./forked-process-task-runner");
|
|
7
10
|
const cache_1 = require("./cache");
|
|
8
11
|
const utils_1 = require("./utils");
|
|
9
12
|
const tasks_schedule_1 = require("./tasks-schedule");
|
|
10
13
|
const hash_task_1 = require("../hasher/hash-task");
|
|
11
14
|
const task_env_1 = require("./task-env");
|
|
15
|
+
const workspace_root_1 = require("../utils/workspace-root");
|
|
16
|
+
const output_1 = require("../utils/output");
|
|
17
|
+
const params_1 = require("../utils/params");
|
|
12
18
|
class TaskOrchestrator {
|
|
13
19
|
// endregion internal state
|
|
14
20
|
constructor(hasher, initiatingProject, projectGraph, taskGraph, options, bail, daemon) {
|
|
@@ -33,6 +39,8 @@ class TaskOrchestrator {
|
|
|
33
39
|
this.bailed = false;
|
|
34
40
|
}
|
|
35
41
|
async run() {
|
|
42
|
+
// Init the ForkedProcessTaskRunner
|
|
43
|
+
await this.forkedProcessTaskRunner.init();
|
|
36
44
|
// initial scheduling
|
|
37
45
|
await this.scheduleNextTasks();
|
|
38
46
|
perf_hooks_1.performance.mark('task-execution:start');
|
|
@@ -193,7 +201,7 @@ class TaskOrchestrator {
|
|
|
193
201
|
// obtain metadata
|
|
194
202
|
const temporaryOutputPath = this.cache.temporaryOutputPath(task);
|
|
195
203
|
const streamOutput = (0, utils_1.shouldStreamOutput)(task, this.initiatingProject);
|
|
196
|
-
|
|
204
|
+
let env = pipeOutput
|
|
197
205
|
? (0, task_env_1.getEnvVariablesForTask)(task, taskSpecificEnv, process.env.FORCE_COLOR === undefined
|
|
198
206
|
? 'true'
|
|
199
207
|
: process.env.FORCE_COLOR, this.options.skipNxCache, this.options.captureStderr, null, null)
|
|
@@ -201,29 +209,74 @@ class TaskOrchestrator {
|
|
|
201
209
|
let results = doNotSkipCache ? await this.applyCachedResults([task]) : [];
|
|
202
210
|
// the task wasn't cached
|
|
203
211
|
if (results.length === 0) {
|
|
204
|
-
|
|
205
|
-
const
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
212
|
+
const shouldPrefix = streamOutput && process.env.NX_PREFIX_OUTPUT === 'true';
|
|
213
|
+
const targetConfiguration = (0, utils_1.getTargetConfigurationForTask)(task, this.projectGraph);
|
|
214
|
+
if (process.env.NX_RUN_COMMANDS_DIRECTLY !== 'false' &&
|
|
215
|
+
targetConfiguration.executor === 'nx:run-commands' &&
|
|
216
|
+
!shouldPrefix) {
|
|
217
|
+
const { schema } = (0, utils_1.getExecutorForTask)(task, this.projectGraph);
|
|
218
|
+
const isRunOne = this.initiatingProject != null;
|
|
219
|
+
const combinedOptions = (0, params_1.combineOptionsForExecutor)(task.overrides, task.target.configuration ?? targetConfiguration.defaultConfiguration, targetConfiguration, schema, task.target.project, (0, path_1.relative)(task.projectRoot ?? workspace_root_1.workspaceRoot, process.cwd()), process.env.NX_VERBOSE_LOGGING === 'true');
|
|
220
|
+
if (combinedOptions.env) {
|
|
221
|
+
env = {
|
|
222
|
+
...env,
|
|
223
|
+
...combinedOptions.env,
|
|
224
|
+
};
|
|
225
|
+
}
|
|
226
|
+
if (streamOutput) {
|
|
227
|
+
const args = (0, utils_1.getPrintableCommandArgsForTask)(task);
|
|
228
|
+
output_1.output.logCommand(args.join(' '));
|
|
229
|
+
}
|
|
230
|
+
const { success, terminalOutput } = await (0, run_commands_impl_1.default)({
|
|
231
|
+
...combinedOptions,
|
|
232
|
+
env,
|
|
233
|
+
usePty: isRunOne && !this.tasksSchedule.hasTasks(),
|
|
234
|
+
streamOutput,
|
|
235
|
+
}, {
|
|
236
|
+
root: workspace_root_1.workspaceRoot, // only root is needed in runCommandsImpl
|
|
237
|
+
});
|
|
238
|
+
const status = success ? 'success' : 'failure';
|
|
239
|
+
if (!streamOutput) {
|
|
240
|
+
this.options.lifeCycle.printTaskTerminalOutput(task, status, terminalOutput);
|
|
241
|
+
}
|
|
242
|
+
(0, fs_1.writeFileSync)(temporaryOutputPath, terminalOutput);
|
|
243
|
+
results.push({
|
|
244
|
+
task,
|
|
245
|
+
status,
|
|
246
|
+
terminalOutput,
|
|
247
|
+
});
|
|
248
|
+
}
|
|
249
|
+
else {
|
|
250
|
+
// cache prep
|
|
251
|
+
const { code, terminalOutput } = await this.runTaskInForkedProcess(task, env, pipeOutput, temporaryOutputPath, streamOutput);
|
|
252
|
+
results.push({
|
|
253
|
+
task,
|
|
254
|
+
status: code === 0 ? 'success' : 'failure',
|
|
255
|
+
terminalOutput,
|
|
256
|
+
});
|
|
257
|
+
}
|
|
211
258
|
}
|
|
212
259
|
await this.postRunSteps([task], results, doNotSkipCache, { groupId });
|
|
213
260
|
}
|
|
214
261
|
async runTaskInForkedProcess(task, env, pipeOutput, temporaryOutputPath, streamOutput) {
|
|
215
262
|
try {
|
|
263
|
+
const usePtyFork = process.env.NX_NATIVE_COMMAND_RUNNER !== 'false';
|
|
264
|
+
// Disable the pseudo terminal if this is a run-many
|
|
265
|
+
const disablePseudoTerminal = !this.initiatingProject;
|
|
216
266
|
// execution
|
|
217
|
-
const { code, terminalOutput } =
|
|
218
|
-
? await this.forkedProcessTaskRunner.
|
|
267
|
+
const { code, terminalOutput } = usePtyFork
|
|
268
|
+
? await this.forkedProcessTaskRunner.forkProcess(task, {
|
|
219
269
|
temporaryOutputPath,
|
|
220
270
|
streamOutput,
|
|
271
|
+
pipeOutput,
|
|
221
272
|
taskGraph: this.taskGraph,
|
|
222
273
|
env,
|
|
274
|
+
disablePseudoTerminal,
|
|
223
275
|
})
|
|
224
|
-
: await this.forkedProcessTaskRunner.
|
|
276
|
+
: await this.forkedProcessTaskRunner.forkProcessLegacy(task, {
|
|
225
277
|
temporaryOutputPath,
|
|
226
278
|
streamOutput,
|
|
279
|
+
pipeOutput,
|
|
227
280
|
taskGraph: this.taskGraph,
|
|
228
281
|
env,
|
|
229
282
|
});
|
|
@@ -327,7 +380,10 @@ class TaskOrchestrator {
|
|
|
327
380
|
// region utils
|
|
328
381
|
async pipeOutputCapture(task) {
|
|
329
382
|
try {
|
|
330
|
-
|
|
383
|
+
if (process.env.NX_NATIVE_COMMAND_RUNNER !== 'false') {
|
|
384
|
+
return true;
|
|
385
|
+
}
|
|
386
|
+
const { schema } = (0, utils_1.getExecutorForTask)(task, this.projectGraph);
|
|
331
387
|
return (schema.outputCapture === 'pipe' ||
|
|
332
388
|
process.env.NX_STREAM_OUTPUT === 'true');
|
|
333
389
|
}
|
|
@@ -89,7 +89,7 @@ class TasksSchedule {
|
|
|
89
89
|
const batchMap = {};
|
|
90
90
|
for (const root of this.notScheduledTaskGraph.roots) {
|
|
91
91
|
const rootTask = this.notScheduledTaskGraph.tasks[root];
|
|
92
|
-
const executorName =
|
|
92
|
+
const executorName = (0, utils_1.getExecutorNameForTask)(rootTask, this.projectGraph);
|
|
93
93
|
await this.processTaskForBatches(batchMap, rootTask, executorName, true);
|
|
94
94
|
}
|
|
95
95
|
for (const [executorName, taskGraph] of Object.entries(batchMap)) {
|
|
@@ -105,8 +105,8 @@ class TasksSchedule {
|
|
|
105
105
|
if (!this.canBatchTaskBeScheduled(task.id, batches[rootExecutorName])) {
|
|
106
106
|
return;
|
|
107
107
|
}
|
|
108
|
-
const { batchImplementationFactory } =
|
|
109
|
-
const executorName =
|
|
108
|
+
const { batchImplementationFactory } = (0, utils_1.getExecutorForTask)(task, this.projectGraph);
|
|
109
|
+
const executorName = (0, utils_1.getExecutorNameForTask)(task, this.projectGraph);
|
|
110
110
|
if (rootExecutorName !== executorName) {
|
|
111
111
|
return;
|
|
112
112
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Task, TaskGraph } from '../config/task-graph';
|
|
2
2
|
import { ProjectGraph, ProjectGraphProjectNode } from '../config/project-graph';
|
|
3
|
-
import { TargetDependencyConfig } from '../config/workspace-json-project-json';
|
|
4
|
-
import { CustomHasher } from '../config/misc-interfaces';
|
|
3
|
+
import { TargetConfiguration, TargetDependencyConfig } from '../config/workspace-json-project-json';
|
|
4
|
+
import { CustomHasher, ExecutorConfig } from '../config/misc-interfaces';
|
|
5
5
|
export declare function getCommandAsString(execCommand: string, task: Task): string;
|
|
6
6
|
export declare function getDependencyConfigs({ project, target }: {
|
|
7
7
|
project: string;
|
|
@@ -18,18 +18,27 @@ declare class InvalidOutputsError extends Error {
|
|
|
18
18
|
export declare function validateOutputs(outputs: string[]): void;
|
|
19
19
|
export declare function transformLegacyOutputs(projectRoot: string, error: InvalidOutputsError): string[];
|
|
20
20
|
/**
|
|
21
|
-
* @deprecated Pass the target and overrides instead. This will be removed in
|
|
21
|
+
* @deprecated Pass the target and overrides instead. This will be removed in v19.
|
|
22
22
|
*/
|
|
23
23
|
export declare function getOutputsForTargetAndConfiguration(task: Task, node: ProjectGraphProjectNode): string[];
|
|
24
24
|
export declare function getOutputsForTargetAndConfiguration(target: Task['target'] | Task, overrides: Task['overrides'] | ProjectGraphProjectNode, node: ProjectGraphProjectNode): string[];
|
|
25
25
|
export declare function interpolate(template: string, data: any): string;
|
|
26
|
-
export declare function
|
|
27
|
-
export declare function
|
|
26
|
+
export declare function getTargetConfigurationForTask(task: Task, projectGraph: ProjectGraph): TargetConfiguration | undefined;
|
|
27
|
+
export declare function getExecutorNameForTask(task: Task, projectGraph: ProjectGraph): string;
|
|
28
|
+
export declare function getExecutorForTask(task: Task, projectGraph: ProjectGraph): ExecutorConfig & {
|
|
28
29
|
isNgCompat: boolean;
|
|
29
30
|
isNxExecutor: boolean;
|
|
30
|
-
}
|
|
31
|
-
export declare function getCustomHasher(task: Task, projectGraph: ProjectGraph):
|
|
31
|
+
};
|
|
32
|
+
export declare function getCustomHasher(task: Task, projectGraph: ProjectGraph): CustomHasher | null;
|
|
32
33
|
export declare function removeTasksFromTaskGraph(graph: TaskGraph, ids: string[]): TaskGraph;
|
|
34
|
+
export declare function removeIdsFromGraph<T>(graph: {
|
|
35
|
+
roots: string[];
|
|
36
|
+
dependencies: Record<string, string[]>;
|
|
37
|
+
}, ids: string[], mapWithIds: Record<string, T>): {
|
|
38
|
+
mapWithIds: Record<string, T>;
|
|
39
|
+
roots: string[];
|
|
40
|
+
dependencies: Record<string, string[]>;
|
|
41
|
+
};
|
|
33
42
|
export declare function calculateReverseDeps(taskGraph: TaskGraph): Record<string, string[]>;
|
|
34
43
|
export declare function getCliPath(): string;
|
|
35
44
|
export declare function getPrintableCommandArgsForTask(task: Task): string[];
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.unparse = exports.isCacheableTask = exports.shouldStreamOutput = exports.getSerializedArgsForTask = exports.getPrintableCommandArgsForTask = exports.getCliPath = exports.calculateReverseDeps = exports.removeTasksFromTaskGraph = exports.getCustomHasher = exports.getExecutorForTask = exports.getExecutorNameForTask = exports.interpolate = exports.getOutputsForTargetAndConfiguration = exports.transformLegacyOutputs = exports.validateOutputs = exports.getOutputs = exports.expandDependencyConfigSyntaxSugar = exports.getDependencyConfigs = exports.getCommandAsString = void 0;
|
|
3
|
+
exports.unparse = exports.isCacheableTask = exports.shouldStreamOutput = exports.getSerializedArgsForTask = exports.getPrintableCommandArgsForTask = exports.getCliPath = exports.calculateReverseDeps = exports.removeIdsFromGraph = exports.removeTasksFromTaskGraph = exports.getCustomHasher = exports.getExecutorForTask = exports.getExecutorNameForTask = exports.getTargetConfigurationForTask = exports.interpolate = exports.getOutputsForTargetAndConfiguration = exports.transformLegacyOutputs = exports.validateOutputs = exports.getOutputs = exports.expandDependencyConfigSyntaxSugar = exports.getDependencyConfigs = exports.getCommandAsString = void 0;
|
|
4
4
|
const output_1 = require("../utils/output");
|
|
5
5
|
const path_1 = require("path");
|
|
6
6
|
const workspace_root_1 = require("../utils/workspace-root");
|
|
@@ -9,6 +9,7 @@ const fileutils_1 = require("../utils/fileutils");
|
|
|
9
9
|
const serialize_overrides_into_command_line_1 = require("../utils/serialize-overrides-into-command-line");
|
|
10
10
|
const split_target_1 = require("../utils/split-target");
|
|
11
11
|
const executor_utils_1 = require("../command-line/run/executor-utils");
|
|
12
|
+
const project_graph_1 = require("../project-graph/project-graph");
|
|
12
13
|
function getCommandAsString(execCommand, task) {
|
|
13
14
|
const args = getPrintableCommandArgsForTask(task);
|
|
14
15
|
return [execCommand, 'nx', ...args].join(' ').trim();
|
|
@@ -127,7 +128,7 @@ function getOutputsForTargetAndConfiguration(taskTargetOrTask, overridesOrNode,
|
|
|
127
128
|
return interpolate(output, {
|
|
128
129
|
projectRoot: node.data.root,
|
|
129
130
|
projectName: node.name,
|
|
130
|
-
project: { ...node.data, name: node.name },
|
|
131
|
+
project: { ...node.data, name: node.name }, // this is legacy
|
|
131
132
|
options,
|
|
132
133
|
});
|
|
133
134
|
})
|
|
@@ -176,39 +177,52 @@ function interpolate(template, data) {
|
|
|
176
177
|
});
|
|
177
178
|
}
|
|
178
179
|
exports.interpolate = interpolate;
|
|
179
|
-
|
|
180
|
+
function getTargetConfigurationForTask(task, projectGraph) {
|
|
180
181
|
const project = projectGraph.nodes[task.target.project].data;
|
|
181
|
-
return project.targets[task.target.target]
|
|
182
|
+
return project.targets[task.target.target];
|
|
183
|
+
}
|
|
184
|
+
exports.getTargetConfigurationForTask = getTargetConfigurationForTask;
|
|
185
|
+
function getExecutorNameForTask(task, projectGraph) {
|
|
186
|
+
return getTargetConfigurationForTask(task, projectGraph)?.executor;
|
|
182
187
|
}
|
|
183
188
|
exports.getExecutorNameForTask = getExecutorNameForTask;
|
|
184
|
-
|
|
185
|
-
const executor =
|
|
189
|
+
function getExecutorForTask(task, projectGraph) {
|
|
190
|
+
const executor = getExecutorNameForTask(task, projectGraph);
|
|
186
191
|
const [nodeModule, executorName] = executor.split(':');
|
|
187
|
-
return (0, executor_utils_1.getExecutorInformation)(nodeModule, executorName, workspace_root_1.workspaceRoot);
|
|
192
|
+
return (0, executor_utils_1.getExecutorInformation)(nodeModule, executorName, workspace_root_1.workspaceRoot, (0, project_graph_1.readProjectsConfigurationFromProjectGraph)(projectGraph).projects);
|
|
188
193
|
}
|
|
189
194
|
exports.getExecutorForTask = getExecutorForTask;
|
|
190
|
-
|
|
191
|
-
const factory =
|
|
195
|
+
function getCustomHasher(task, projectGraph) {
|
|
196
|
+
const factory = getExecutorForTask(task, projectGraph).hasherFactory;
|
|
192
197
|
return factory ? factory() : null;
|
|
193
198
|
}
|
|
194
199
|
exports.getCustomHasher = getCustomHasher;
|
|
195
200
|
function removeTasksFromTaskGraph(graph, ids) {
|
|
196
|
-
const
|
|
201
|
+
const newGraph = removeIdsFromGraph(graph, ids, graph.tasks);
|
|
202
|
+
return {
|
|
203
|
+
dependencies: newGraph.dependencies,
|
|
204
|
+
roots: newGraph.roots,
|
|
205
|
+
tasks: newGraph.mapWithIds,
|
|
206
|
+
};
|
|
207
|
+
}
|
|
208
|
+
exports.removeTasksFromTaskGraph = removeTasksFromTaskGraph;
|
|
209
|
+
function removeIdsFromGraph(graph, ids, mapWithIds) {
|
|
210
|
+
const filteredMapWithIds = {};
|
|
197
211
|
const dependencies = {};
|
|
198
212
|
const removedSet = new Set(ids);
|
|
199
|
-
for (let
|
|
200
|
-
if (!removedSet.has(
|
|
201
|
-
|
|
202
|
-
dependencies[
|
|
213
|
+
for (let id of Object.keys(mapWithIds)) {
|
|
214
|
+
if (!removedSet.has(id)) {
|
|
215
|
+
filteredMapWithIds[id] = mapWithIds[id];
|
|
216
|
+
dependencies[id] = graph.dependencies[id].filter((depId) => !removedSet.has(depId));
|
|
203
217
|
}
|
|
204
218
|
}
|
|
205
219
|
return {
|
|
206
|
-
|
|
220
|
+
mapWithIds: filteredMapWithIds,
|
|
207
221
|
dependencies: dependencies,
|
|
208
222
|
roots: Object.keys(dependencies).filter((k) => dependencies[k].length === 0),
|
|
209
223
|
};
|
|
210
224
|
}
|
|
211
|
-
exports.
|
|
225
|
+
exports.removeIdsFromGraph = removeIdsFromGraph;
|
|
212
226
|
function calculateReverseDeps(taskGraph) {
|
|
213
227
|
const reverseTaskDeps = {};
|
|
214
228
|
Object.keys(taskGraph.tasks).forEach((t) => {
|