nx 21.0.0-beta.1 → 21.0.0-beta.11
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/.eslintrc.json +5 -1
- package/migrations.json +15 -35
- package/package.json +12 -12
- package/release/index.d.ts +1 -1
- package/release/index.js +2 -1
- package/schemas/nx-schema.json +187 -35
- package/schemas/project-schema.json +5 -0
- package/src/adapter/angular-json.js +11 -0
- package/src/adapter/compat.d.ts +1 -1
- package/src/adapter/compat.js +3 -0
- package/src/command-line/add/add.js +6 -16
- package/src/command-line/affected/command-object.js +6 -6
- package/src/command-line/examples.js +0 -4
- package/src/command-line/exec/command-object.js +1 -1
- package/src/command-line/generate/generator-utils.js +8 -3
- package/src/command-line/import/import.js +1 -1
- package/src/command-line/init/command-object.js +18 -6
- package/src/command-line/init/configure-plugins.d.ts +6 -7
- package/src/command-line/init/configure-plugins.js +52 -38
- package/src/command-line/init/implementation/add-nx-to-turborepo.d.ts +4 -0
- package/src/command-line/init/implementation/add-nx-to-turborepo.js +49 -0
- package/src/command-line/init/implementation/check-compatible-with-plugins.js +7 -1
- package/src/command-line/init/implementation/deduce-default-base.d.ts +1 -0
- package/src/command-line/init/implementation/deduce-default-base.js +53 -0
- package/src/command-line/init/implementation/react/add-vite-commands-to-package-scripts.js +6 -4
- package/src/command-line/init/implementation/react/index.d.ts +1 -1
- package/src/command-line/init/implementation/react/index.js +32 -185
- package/src/command-line/init/implementation/react/write-vite-config.js +19 -3
- package/src/command-line/init/implementation/utils.d.ts +6 -2
- package/src/command-line/init/implementation/utils.js +110 -45
- package/src/command-line/init/init-v1.js +1 -1
- package/src/command-line/init/init-v2.d.ts +1 -0
- package/src/command-line/init/init-v2.js +70 -39
- package/src/command-line/migrate/migrate-ui-api.d.ts +58 -0
- package/src/command-line/migrate/migrate-ui-api.js +227 -0
- package/src/command-line/migrate/migrate.d.ts +23 -4
- package/src/command-line/migrate/migrate.js +138 -86
- package/src/command-line/nx-commands.js +19 -5
- package/src/command-line/register/command-object.d.ts +6 -0
- package/src/command-line/{activate-powerpack → register}/command-object.js +9 -9
- package/src/command-line/register/register.d.ts +2 -0
- package/src/command-line/register/register.js +9 -0
- package/src/command-line/release/changelog.js +18 -15
- package/src/command-line/release/command-object.d.ts +8 -0
- package/src/command-line/release/command-object.js +9 -0
- package/src/command-line/release/config/config.d.ts +8 -7
- package/src/command-line/release/config/config.js +139 -45
- package/src/command-line/release/config/use-legacy-versioning.d.ts +2 -0
- package/src/command-line/release/config/use-legacy-versioning.js +9 -0
- package/src/command-line/release/index.d.ts +4 -0
- package/src/command-line/release/index.js +6 -1
- package/src/command-line/release/plan-check.js +6 -3
- package/src/command-line/release/plan.js +7 -3
- package/src/command-line/release/publish.js +7 -3
- package/src/command-line/release/release.js +8 -3
- package/src/command-line/release/utils/batch-projects-by-generator-config.js +6 -3
- package/src/command-line/release/utils/git.d.ts +3 -2
- package/src/command-line/release/utils/git.js +65 -9
- package/src/command-line/release/utils/github.js +3 -1
- package/src/command-line/release/utils/resolve-semver-specifier.d.ts +2 -1
- package/src/command-line/release/utils/resolve-semver-specifier.js +2 -1
- package/src/command-line/release/utils/semver.d.ts +8 -0
- package/src/command-line/release/utils/semver.js +8 -0
- package/src/command-line/release/utils/shared-legacy.d.ts +25 -0
- package/src/command-line/release/utils/shared-legacy.js +2 -0
- package/src/command-line/release/utils/shared.d.ts +11 -17
- package/src/command-line/release/version/derive-specifier-from-conventional-commits.d.ts +7 -0
- package/src/command-line/release/version/derive-specifier-from-conventional-commits.js +47 -0
- package/src/command-line/release/version/deriver-specifier-from-version-plans.d.ts +8 -0
- package/src/command-line/release/version/deriver-specifier-from-version-plans.js +59 -0
- package/src/command-line/release/version/project-logger.d.ts +8 -0
- package/src/command-line/release/version/project-logger.js +45 -0
- package/src/command-line/release/version/release-group-processor.d.ts +252 -0
- package/src/command-line/release/version/release-group-processor.js +1057 -0
- package/src/command-line/release/version/resolve-current-version.d.ts +32 -0
- package/src/command-line/release/version/resolve-current-version.js +241 -0
- package/src/command-line/release/version/test-utils.d.ts +93 -0
- package/src/command-line/release/version/test-utils.js +415 -0
- package/src/command-line/release/version/topological-sort.d.ts +9 -0
- package/src/command-line/release/version/topological-sort.js +41 -0
- package/src/command-line/release/version/version-actions.d.ts +171 -0
- package/src/command-line/release/version/version-actions.js +195 -0
- package/src/command-line/release/version-legacy.d.ts +46 -0
- package/src/command-line/release/version-legacy.js +453 -0
- package/src/command-line/release/version.d.ts +0 -40
- package/src/command-line/release/version.js +84 -262
- package/src/command-line/repair/repair.js +8 -3
- package/src/command-line/report/report.d.ts +7 -3
- package/src/command-line/report/report.js +52 -18
- package/src/command-line/run/command-object.js +2 -2
- package/src/command-line/run/executor-utils.d.ts +6 -1
- package/src/command-line/run/executor-utils.js +10 -1
- package/src/command-line/run/run.js +2 -2
- package/src/command-line/run-many/command-object.js +2 -2
- package/src/command-line/yargs-utils/shared-options.d.ts +4 -0
- package/src/command-line/yargs-utils/shared-options.js +20 -0
- package/src/config/misc-interfaces.d.ts +20 -2
- package/src/config/nx-json.d.ts +158 -18
- package/src/config/project-graph.d.ts +4 -2
- package/src/config/project-graph.js +8 -0
- package/src/config/workspace-json-project-json.d.ts +2 -2
- package/src/core/graph/main.js +1 -1
- package/src/core/graph/runtime.js +1 -1
- package/src/core/graph/styles.css +2 -2
- package/src/core/graph/styles.js +1 -1
- package/src/daemon/client/client.d.ts +2 -0
- package/src/daemon/client/client.js +15 -0
- package/src/daemon/message-types/glob.d.ts +7 -0
- package/src/daemon/message-types/glob.js +9 -1
- package/src/daemon/message-types/hash-glob.d.ts +6 -0
- package/src/daemon/message-types/hash-glob.js +9 -1
- package/src/daemon/server/handle-glob.d.ts +1 -0
- package/src/daemon/server/handle-glob.js +8 -0
- package/src/daemon/server/handle-hash-glob.d.ts +1 -0
- package/src/daemon/server/handle-hash-glob.js +8 -0
- package/src/daemon/server/logger.js +2 -1
- package/src/daemon/server/server.js +7 -0
- package/src/devkit-exports.d.ts +1 -1
- package/src/devkit-internals.d.ts +3 -2
- package/src/devkit-internals.js +5 -1
- package/src/executors/run-commands/run-commands.impl.d.ts +2 -5
- package/src/executors/run-commands/run-commands.impl.js +14 -42
- package/src/executors/run-commands/running-tasks.d.ts +9 -4
- package/src/executors/run-commands/running-tasks.js +103 -30
- package/src/executors/run-script/run-script.impl.js +4 -3
- package/src/generators/internal-utils/format-changed-files-with-prettier-if-available.js +8 -0
- package/src/generators/testing-utils/create-tree.js +5 -1
- package/src/migrations/update-21-0-0/release-version-config-changes.d.ts +2 -0
- package/src/migrations/update-21-0-0/release-version-config-changes.js +111 -0
- package/src/migrations/update-21-0-0/remove-custom-tasks-runner.d.ts +2 -0
- package/src/migrations/update-21-0-0/remove-custom-tasks-runner.js +38 -0
- package/src/migrations/{update-18-0-0/disable-crystal-for-existing-workspaces.js → update-21-0-0/remove-legacy-cache.js} +10 -4
- package/src/native/index.d.ts +98 -19
- package/src/native/index.js +16 -2
- package/src/native/native-bindings.js +7 -0
- package/src/native/nx.wasi-browser.js +20 -19
- package/src/native/nx.wasi.cjs +20 -19
- package/src/native/nx.wasm32-wasi.wasm +0 -0
- package/src/nx-cloud/nx-cloud-tasks-runner-shell.js +3 -3
- package/src/plugins/js/index.d.ts +2 -1
- package/src/plugins/js/index.js +8 -1
- package/src/plugins/js/lock-file/lock-file.js +28 -13
- package/src/plugins/js/lock-file/utils/package-json.d.ts +1 -1
- package/src/plugins/js/lock-file/utils/package-json.js +8 -6
- package/src/plugins/js/lock-file/utils/pnpm-normalizer.js +3 -3
- package/src/plugins/js/lock-file/yarn-parser.js +85 -39
- package/src/plugins/js/project-graph/affected/lock-file-changes.js +1 -0
- package/src/plugins/js/project-graph/build-dependencies/explicit-project-dependencies.js +1 -1
- package/src/plugins/js/project-graph/build-dependencies/target-project-locator.d.ts +10 -1
- package/src/plugins/js/project-graph/build-dependencies/target-project-locator.js +59 -6
- package/src/plugins/js/utils/packages.js +22 -3
- package/src/plugins/js/utils/register.js +1 -0
- package/src/plugins/js/utils/typescript.js +3 -3
- package/src/plugins/package-json/create-nodes.d.ts +1 -1
- package/src/plugins/package-json/create-nodes.js +4 -2
- package/src/project-graph/affected/locators/project-glob-changes.js +2 -2
- package/src/project-graph/error-types.js +32 -2
- package/src/project-graph/file-utils.d.ts +1 -10
- package/src/project-graph/file-utils.js +2 -77
- package/src/project-graph/plugins/get-plugins.js +2 -1
- package/src/project-graph/plugins/in-process-loader.js +1 -1
- package/src/project-graph/plugins/isolation/plugin-worker.js +12 -6
- package/src/project-graph/plugins/loaded-nx-plugin.d.ts +2 -1
- package/src/project-graph/plugins/loaded-nx-plugin.js +1 -5
- package/src/project-graph/plugins/public-api.d.ts +1 -1
- package/src/project-graph/plugins/utils.d.ts +2 -2
- package/src/project-graph/plugins/utils.js +2 -2
- package/src/project-graph/project-graph.js +1 -1
- package/src/project-graph/utils/project-configuration-utils.d.ts +3 -3
- package/src/project-graph/utils/project-configuration-utils.js +54 -21
- package/src/project-graph/utils/retrieve-workspace-files.d.ts +1 -1
- package/src/project-graph/utils/retrieve-workspace-files.js +14 -18
- package/src/tasks-runner/batch/batch-messages.d.ts +2 -0
- package/src/tasks-runner/batch/run-batch.js +4 -5
- package/src/tasks-runner/cache.d.ts +21 -8
- package/src/tasks-runner/cache.js +106 -38
- package/src/tasks-runner/create-task-graph.d.ts +0 -1
- package/src/tasks-runner/create-task-graph.js +11 -11
- package/src/tasks-runner/default-tasks-runner.js +5 -14
- package/src/tasks-runner/forked-process-task-runner.d.ts +8 -3
- package/src/tasks-runner/forked-process-task-runner.js +59 -46
- package/src/tasks-runner/init-tasks-runner.d.ts +15 -1
- package/src/tasks-runner/init-tasks-runner.js +62 -2
- package/src/tasks-runner/is-tui-enabled.d.ts +2 -0
- package/src/tasks-runner/is-tui-enabled.js +64 -0
- package/src/tasks-runner/life-cycle.d.ts +14 -3
- package/src/tasks-runner/life-cycle.js +37 -2
- package/src/tasks-runner/life-cycles/task-history-life-cycle-old.d.ts +2 -0
- package/src/tasks-runner/life-cycles/task-history-life-cycle-old.js +15 -7
- package/src/tasks-runner/life-cycles/task-history-life-cycle.d.ts +5 -0
- package/src/tasks-runner/life-cycles/task-history-life-cycle.js +35 -5
- package/src/tasks-runner/life-cycles/tui-summary-life-cycle.d.ts +18 -0
- package/src/tasks-runner/life-cycles/tui-summary-life-cycle.js +230 -0
- package/src/tasks-runner/pseudo-terminal.d.ts +11 -7
- package/src/tasks-runner/pseudo-terminal.js +47 -35
- package/src/tasks-runner/run-command.d.ts +4 -1
- package/src/tasks-runner/run-command.js +219 -63
- package/src/tasks-runner/running-tasks/node-child-process.js +4 -11
- package/src/tasks-runner/running-tasks/running-task.d.ts +3 -0
- package/src/tasks-runner/running-tasks/shared-running-task.d.ts +14 -0
- package/src/tasks-runner/running-tasks/shared-running-task.js +30 -0
- package/src/tasks-runner/task-env.d.ts +1 -4
- package/src/tasks-runner/task-env.js +2 -0
- package/src/tasks-runner/task-graph-utils.d.ts +3 -0
- package/src/tasks-runner/task-graph-utils.js +31 -2
- package/src/tasks-runner/task-orchestrator.d.ts +26 -10
- package/src/tasks-runner/task-orchestrator.js +221 -57
- package/src/tasks-runner/tasks-runner.d.ts +1 -0
- package/src/tasks-runner/tasks-schedule.d.ts +1 -0
- package/src/tasks-runner/tasks-schedule.js +9 -0
- package/src/tasks-runner/utils.d.ts +2 -2
- package/src/tasks-runner/utils.js +18 -12
- package/src/utils/child-process.d.ts +4 -0
- package/src/utils/child-process.js +23 -30
- package/src/utils/command-line-utils.d.ts +1 -1
- package/src/utils/find-matching-projects.js +2 -2
- package/src/utils/git-utils.d.ts +1 -1
- package/src/utils/git-utils.js +8 -3
- package/src/utils/handle-errors.js +15 -0
- package/src/utils/is-ci.js +4 -1
- package/src/utils/is-using-prettier.d.ts +3 -0
- package/src/utils/is-using-prettier.js +62 -0
- package/src/utils/nx-key.d.ts +7 -0
- package/src/utils/nx-key.js +52 -0
- package/src/utils/package-json.d.ts +1 -1
- package/src/utils/package-json.js +16 -2
- package/src/utils/package-manager.js +2 -2
- package/src/utils/path.js +1 -1
- package/src/utils/require-nx-key.d.ts +1 -0
- package/src/utils/require-nx-key.js +22 -0
- package/src/utils/workspace-context.d.ts +2 -0
- package/src/utils/workspace-context.js +16 -0
- package/src/command-line/activate-powerpack/activate-powerpack.d.ts +0 -2
- package/src/command-line/activate-powerpack/activate-powerpack.js +0 -34
- package/src/command-line/activate-powerpack/command-object.d.ts +0 -6
- package/src/command-line/init/implementation/react/write-craco-config.d.ts +0 -1
- package/src/command-line/init/implementation/react/write-craco-config.js +0 -61
- package/src/migrations/update-17-0-0/move-cache-directory.d.ts +0 -2
- package/src/migrations/update-17-0-0/move-cache-directory.js +0 -35
- package/src/migrations/update-17-0-0/rm-default-collection-npm-scope.js +0 -72
- package/src/migrations/update-17-0-0/use-minimal-config-for-tasks-runner-options.d.ts +0 -2
- package/src/migrations/update-17-0-0/use-minimal-config-for-tasks-runner-options.js +0 -122
- package/src/migrations/update-17-2-0/move-default-base.d.ts +0 -5
- package/src/migrations/update-17-2-0/move-default-base.js +0 -21
- package/src/migrations/update-17-3-0/nx-release-path.d.ts +0 -3
- package/src/migrations/update-17-3-0/nx-release-path.js +0 -47
- package/src/migrations/update-18-0-0/disable-crystal-for-existing-workspaces.d.ts +0 -2
- package/src/utils/powerpack.d.ts +0 -5
- package/src/utils/powerpack.js +0 -33
- /package/src/migrations/{update-17-0-0/rm-default-collection-npm-scope.d.ts → update-21-0-0/remove-legacy-cache.d.ts} +0 -0
@@ -1,15 +1,18 @@
|
|
1
|
+
import { Serializable } from 'child_process';
|
1
2
|
import { ChildProcess, RustPseudoTerminal } from '../native';
|
2
3
|
import { PseudoIPCServer } from './pseudo-ipc';
|
3
|
-
import {
|
4
|
-
export declare function
|
4
|
+
import { RunningTask } from './running-tasks/running-task';
|
5
|
+
export declare function createPseudoTerminal(skipSupportCheck?: boolean): PseudoTerminal;
|
5
6
|
export declare class PseudoTerminal {
|
6
7
|
private rustPseudoTerminal;
|
7
8
|
private pseudoIPCPath;
|
8
9
|
private pseudoIPC;
|
9
10
|
private initialized;
|
11
|
+
private childProcesses;
|
10
12
|
static isSupported(): boolean;
|
11
13
|
constructor(rustPseudoTerminal: RustPseudoTerminal);
|
12
14
|
init(): Promise<void>;
|
15
|
+
shutdown(): void;
|
13
16
|
runCommand(command: string, { cwd, execArgv, jsEnv, quiet, tty, }?: {
|
14
17
|
cwd?: string;
|
15
18
|
execArgv?: string[];
|
@@ -25,16 +28,15 @@ export declare class PseudoTerminal {
|
|
25
28
|
}): Promise<PseudoTtyProcessWithSend>;
|
26
29
|
sendMessageToChildren(message: Serializable): void;
|
27
30
|
onMessageFromChildren(callback: (message: Serializable) => void): void;
|
28
|
-
private setupProcessListeners;
|
29
|
-
private shutdownPseudoIPC;
|
30
31
|
}
|
31
|
-
export declare class PseudoTtyProcess {
|
32
|
+
export declare class PseudoTtyProcess implements RunningTask {
|
33
|
+
rustPseudoTerminal: RustPseudoTerminal;
|
32
34
|
private childProcess;
|
33
35
|
isAlive: boolean;
|
34
36
|
private exitCallbacks;
|
35
37
|
private outputCallbacks;
|
36
38
|
private terminalOutput;
|
37
|
-
constructor(childProcess: ChildProcess);
|
39
|
+
constructor(rustPseudoTerminal: RustPseudoTerminal, childProcess: ChildProcess);
|
38
40
|
getResults(): Promise<{
|
39
41
|
code: number;
|
40
42
|
terminalOutput: string;
|
@@ -42,10 +44,12 @@ export declare class PseudoTtyProcess {
|
|
42
44
|
onExit(callback: (code: number) => void): void;
|
43
45
|
onOutput(callback: (message: string) => void): void;
|
44
46
|
kill(): void;
|
47
|
+
getParserAndWriter(): import("../native").ExternalObject<[ParserArc, WriterArc]>;
|
45
48
|
}
|
46
49
|
export declare class PseudoTtyProcessWithSend extends PseudoTtyProcess {
|
50
|
+
rustPseudoTerminal: RustPseudoTerminal;
|
47
51
|
private id;
|
48
52
|
private pseudoIpc;
|
49
|
-
constructor(_childProcess: ChildProcess, id: string, pseudoIpc: PseudoIPCServer);
|
53
|
+
constructor(rustPseudoTerminal: RustPseudoTerminal, _childProcess: ChildProcess, id: string, pseudoIpc: PseudoIPCServer);
|
50
54
|
send(message: Serializable): void;
|
51
55
|
}
|
@@ -1,29 +1,44 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
3
|
exports.PseudoTtyProcessWithSend = exports.PseudoTtyProcess = exports.PseudoTerminal = void 0;
|
4
|
-
exports.
|
4
|
+
exports.createPseudoTerminal = createPseudoTerminal;
|
5
|
+
const os = require("os");
|
6
|
+
const socket_utils_1 = require("../daemon/socket-utils");
|
5
7
|
const native_1 = require("../native");
|
6
8
|
const pseudo_ipc_1 = require("./pseudo-ipc");
|
7
|
-
|
8
|
-
const
|
9
|
-
|
10
|
-
|
9
|
+
// Register single event listeners for all pseudo-terminal instances
|
10
|
+
const pseudoTerminalShutdownCallbacks = [];
|
11
|
+
process.on('SIGINT', () => {
|
12
|
+
pseudoTerminalShutdownCallbacks.forEach((cb) => cb());
|
13
|
+
});
|
14
|
+
process.on('SIGTERM', () => {
|
15
|
+
pseudoTerminalShutdownCallbacks.forEach((cb) => cb());
|
16
|
+
});
|
17
|
+
process.on('SIGHUP', () => {
|
18
|
+
pseudoTerminalShutdownCallbacks.forEach((cb) => cb());
|
19
|
+
});
|
20
|
+
process.on('exit', () => {
|
21
|
+
pseudoTerminalShutdownCallbacks.forEach((cb) => cb());
|
22
|
+
});
|
23
|
+
function createPseudoTerminal(skipSupportCheck = false) {
|
11
24
|
if (!skipSupportCheck && !PseudoTerminal.isSupported()) {
|
12
25
|
throw new Error('Pseudo terminal is not supported on this platform.');
|
13
26
|
}
|
14
|
-
pseudoTerminal
|
27
|
+
const pseudoTerminal = new PseudoTerminal(new native_1.RustPseudoTerminal());
|
28
|
+
pseudoTerminalShutdownCallbacks.push(pseudoTerminal.shutdown.bind(pseudoTerminal));
|
15
29
|
return pseudoTerminal;
|
16
30
|
}
|
31
|
+
let id = 0;
|
17
32
|
class PseudoTerminal {
|
18
33
|
static isSupported() {
|
19
34
|
return process.stdout.isTTY && supportedPtyPlatform();
|
20
35
|
}
|
21
36
|
constructor(rustPseudoTerminal) {
|
22
37
|
this.rustPseudoTerminal = rustPseudoTerminal;
|
23
|
-
this.pseudoIPCPath = (0, socket_utils_1.getForkedProcessOsSocketPath)(process.pid.toString());
|
38
|
+
this.pseudoIPCPath = (0, socket_utils_1.getForkedProcessOsSocketPath)(process.pid.toString() + '-' + id++);
|
24
39
|
this.pseudoIPC = new pseudo_ipc_1.PseudoIPCServer(this.pseudoIPCPath);
|
25
40
|
this.initialized = false;
|
26
|
-
this.
|
41
|
+
this.childProcesses = new Set();
|
27
42
|
}
|
28
43
|
async init() {
|
29
44
|
if (this.initialized) {
|
@@ -32,14 +47,28 @@ class PseudoTerminal {
|
|
32
47
|
await this.pseudoIPC.init();
|
33
48
|
this.initialized = true;
|
34
49
|
}
|
50
|
+
shutdown() {
|
51
|
+
for (const cp of this.childProcesses) {
|
52
|
+
try {
|
53
|
+
cp.kill();
|
54
|
+
}
|
55
|
+
catch { }
|
56
|
+
}
|
57
|
+
if (this.initialized) {
|
58
|
+
this.pseudoIPC.close();
|
59
|
+
}
|
60
|
+
}
|
35
61
|
runCommand(command, { cwd, execArgv, jsEnv, quiet, tty, } = {}) {
|
36
|
-
|
62
|
+
const cp = new PseudoTtyProcess(this.rustPseudoTerminal, this.rustPseudoTerminal.runCommand(command, cwd, jsEnv, execArgv, quiet, tty));
|
63
|
+
this.childProcesses.add(cp);
|
64
|
+
return cp;
|
37
65
|
}
|
38
66
|
async fork(id, script, { cwd, execArgv, jsEnv, quiet, }) {
|
39
67
|
if (!this.initialized) {
|
40
68
|
throw new Error('Call init() before forking processes');
|
41
69
|
}
|
42
|
-
const cp = new PseudoTtyProcessWithSend(this.rustPseudoTerminal.fork(id, script, this.pseudoIPCPath, cwd, jsEnv, execArgv, quiet), id, this.pseudoIPC);
|
70
|
+
const cp = new PseudoTtyProcessWithSend(this.rustPseudoTerminal, this.rustPseudoTerminal.fork(id, script, this.pseudoIPCPath, cwd, jsEnv, execArgv, quiet), id, this.pseudoIPC);
|
71
|
+
this.childProcesses.add(cp);
|
43
72
|
await this.pseudoIPC.waitForChildReady(id);
|
44
73
|
return cp;
|
45
74
|
}
|
@@ -49,32 +78,11 @@ class PseudoTerminal {
|
|
49
78
|
onMessageFromChildren(callback) {
|
50
79
|
this.pseudoIPC.onMessageFromChildren(callback);
|
51
80
|
}
|
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
81
|
}
|
75
82
|
exports.PseudoTerminal = PseudoTerminal;
|
76
83
|
class PseudoTtyProcess {
|
77
|
-
constructor(childProcess) {
|
84
|
+
constructor(rustPseudoTerminal, childProcess) {
|
85
|
+
this.rustPseudoTerminal = rustPseudoTerminal;
|
78
86
|
this.childProcess = childProcess;
|
79
87
|
this.isAlive = true;
|
80
88
|
this.exitCallbacks = [];
|
@@ -118,11 +126,15 @@ class PseudoTtyProcess {
|
|
118
126
|
}
|
119
127
|
}
|
120
128
|
}
|
129
|
+
getParserAndWriter() {
|
130
|
+
return this.childProcess.getParserAndWriter();
|
131
|
+
}
|
121
132
|
}
|
122
133
|
exports.PseudoTtyProcess = PseudoTtyProcess;
|
123
134
|
class PseudoTtyProcessWithSend extends PseudoTtyProcess {
|
124
|
-
constructor(_childProcess, id, pseudoIpc) {
|
125
|
-
super(_childProcess);
|
135
|
+
constructor(rustPseudoTerminal, _childProcess, id, pseudoIpc) {
|
136
|
+
super(rustPseudoTerminal, _childProcess);
|
137
|
+
this.rustPseudoTerminal = rustPseudoTerminal;
|
126
138
|
this.id = id;
|
127
139
|
this.pseudoIpc = pseudoIpc;
|
128
140
|
}
|
@@ -17,7 +17,8 @@ export declare function runCommandForTasks(projectsToRun: ProjectGraphProjectNod
|
|
17
17
|
excludeTaskDependencies: boolean;
|
18
18
|
loadDotEnvFiles: boolean;
|
19
19
|
}): Promise<TaskResults>;
|
20
|
-
export declare function
|
20
|
+
export declare function setEnvVarsBasedOnArgs(nxArgs: NxArgs, loadDotEnvFiles: boolean): void;
|
21
|
+
export declare function invokeTasksRunner({ tasks, projectGraph, taskGraph, lifeCycle, nxJson, nxArgs, loadDotEnvFiles, initiatingProject, initiatingTasks, }: {
|
21
22
|
tasks: Task[];
|
22
23
|
projectGraph: ProjectGraph;
|
23
24
|
taskGraph: TaskGraph;
|
@@ -26,9 +27,11 @@ export declare function invokeTasksRunner({ tasks, projectGraph, taskGraph, life
|
|
26
27
|
nxArgs: NxArgs;
|
27
28
|
loadDotEnvFiles: boolean;
|
28
29
|
initiatingProject: string | null;
|
30
|
+
initiatingTasks: Task[];
|
29
31
|
}): Promise<{
|
30
32
|
[id: string]: TaskResult;
|
31
33
|
}>;
|
34
|
+
export declare function constructLifeCycles(lifeCycle: LifeCycle): LifeCycle[];
|
32
35
|
export declare function getRunner(nxArgs: NxArgs, nxJson: NxJsonConfiguration): {
|
33
36
|
tasksRunner: TasksRunner;
|
34
37
|
runnerOptions: any;
|
@@ -2,26 +2,30 @@
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
3
|
exports.runCommand = runCommand;
|
4
4
|
exports.runCommandForTasks = runCommandForTasks;
|
5
|
+
exports.setEnvVarsBasedOnArgs = setEnvVarsBasedOnArgs;
|
5
6
|
exports.invokeTasksRunner = invokeTasksRunner;
|
7
|
+
exports.constructLifeCycles = constructLifeCycles;
|
6
8
|
exports.getRunner = getRunner;
|
7
9
|
exports.getRunnerOptions = getRunnerOptions;
|
8
10
|
const enquirer_1 = require("enquirer");
|
11
|
+
const node_path_1 = require("node:path");
|
12
|
+
const node_util_1 = require("node:util");
|
9
13
|
const ora = require("ora");
|
10
|
-
const path_1 = require("path");
|
11
14
|
const nx_json_1 = require("../config/nx-json");
|
12
15
|
const client_1 = require("../daemon/client/client");
|
13
16
|
const create_task_hasher_1 = require("../hasher/create-task-hasher");
|
14
17
|
const hash_task_1 = require("../hasher/hash-task");
|
15
|
-
const
|
18
|
+
const tasks_execution_hooks_1 = require("../project-graph/plugins/tasks-execution-hooks");
|
16
19
|
const project_graph_1 = require("../project-graph/project-graph");
|
17
|
-
const
|
20
|
+
const handle_errors_1 = require("../utils/handle-errors");
|
18
21
|
const is_ci_1 = require("../utils/is-ci");
|
19
22
|
const nx_cloud_utils_1 = require("../utils/nx-cloud-utils");
|
23
|
+
const nx_key_1 = require("../utils/nx-key");
|
20
24
|
const output_1 = require("../utils/output");
|
21
|
-
const handle_errors_1 = require("../utils/handle-errors");
|
22
25
|
const sync_generators_1 = require("../utils/sync-generators");
|
23
26
|
const workspace_root_1 = require("../utils/workspace-root");
|
24
27
|
const create_task_graph_1 = require("./create-task-graph");
|
28
|
+
const is_tui_enabled_1 = require("./is-tui-enabled");
|
25
29
|
const life_cycle_1 = require("./life-cycle");
|
26
30
|
const dynamic_run_many_terminal_output_life_cycle_1 = require("./life-cycles/dynamic-run-many-terminal-output-life-cycle");
|
27
31
|
const dynamic_run_one_terminal_output_life_cycle_1 = require("./life-cycles/dynamic-run-one-terminal-output-life-cycle");
|
@@ -29,21 +33,180 @@ const static_run_many_terminal_output_life_cycle_1 = require("./life-cycles/stat
|
|
29
33
|
const static_run_one_terminal_output_life_cycle_1 = require("./life-cycles/static-run-one-terminal-output-life-cycle");
|
30
34
|
const store_run_information_life_cycle_1 = require("./life-cycles/store-run-information-life-cycle");
|
31
35
|
const task_history_life_cycle_1 = require("./life-cycles/task-history-life-cycle");
|
32
|
-
const task_history_life_cycle_old_1 = require("./life-cycles/task-history-life-cycle-old");
|
33
36
|
const task_profiling_life_cycle_1 = require("./life-cycles/task-profiling-life-cycle");
|
34
|
-
const task_timings_life_cycle_1 = require("./life-cycles/task-timings-life-cycle");
|
35
37
|
const task_results_life_cycle_1 = require("./life-cycles/task-results-life-cycle");
|
38
|
+
const task_timings_life_cycle_1 = require("./life-cycles/task-timings-life-cycle");
|
39
|
+
const tui_summary_life_cycle_1 = require("./life-cycles/tui-summary-life-cycle");
|
36
40
|
const task_graph_utils_1 = require("./task-graph-utils");
|
37
41
|
const utils_1 = require("./utils");
|
38
42
|
const chalk = require("chalk");
|
39
|
-
const
|
40
|
-
const
|
41
|
-
|
43
|
+
const originalStdoutWrite = process.stdout.write.bind(process.stdout);
|
44
|
+
const originalStderrWrite = process.stderr.write.bind(process.stderr);
|
45
|
+
const originalConsoleLog = console.log.bind(console);
|
46
|
+
const originalConsoleError = console.error.bind(console);
|
47
|
+
async function getTerminalOutputLifeCycle(initiatingProject, initiatingTasks, projectNames, tasks, taskGraph, nxArgs, nxJson, overrides) {
|
48
|
+
const overridesWithoutHidden = { ...overrides };
|
49
|
+
delete overridesWithoutHidden['__overrides_unparsed__'];
|
50
|
+
if ((0, is_tui_enabled_1.isTuiEnabled)(nxJson)) {
|
51
|
+
const interceptedNxCloudLogs = [];
|
52
|
+
const createPatchedConsoleMethod = (originalMethod) => {
|
53
|
+
return (...args) => {
|
54
|
+
// Check if the log came from the Nx Cloud client, otherwise invoke the original write method
|
55
|
+
const stackTrace = new Error().stack;
|
56
|
+
const isNxCloudLog = stackTrace.includes((0, node_path_1.join)(workspace_root_1.workspaceRoot, '.nx', 'cache', 'cloud'));
|
57
|
+
if (!isNxCloudLog) {
|
58
|
+
return originalMethod(...args);
|
59
|
+
}
|
60
|
+
// No-op the Nx Cloud client logs
|
61
|
+
};
|
62
|
+
};
|
63
|
+
// The cloud client calls console.log when NX_VERBOSE_LOGGING is set to true
|
64
|
+
console.log = createPatchedConsoleMethod(originalConsoleLog);
|
65
|
+
console.error = createPatchedConsoleMethod(originalConsoleError);
|
66
|
+
const patchedWrite = (_chunk, _encoding, callback) => {
|
67
|
+
// Preserve original behavior around callback and return value, just in case
|
68
|
+
if (callback) {
|
69
|
+
callback();
|
70
|
+
}
|
71
|
+
return true;
|
72
|
+
};
|
73
|
+
process.stdout.write = patchedWrite;
|
74
|
+
process.stderr.write = patchedWrite;
|
75
|
+
const { AppLifeCycle, restoreTerminal } = await Promise.resolve().then(() => require('../native'));
|
76
|
+
let appLifeCycle;
|
77
|
+
const isRunOne = initiatingProject != null;
|
78
|
+
const pinnedTasks = [];
|
79
|
+
const taskText = tasks.length === 1 ? 'task' : 'tasks';
|
80
|
+
const projectText = projectNames.length === 1 ? 'project' : 'projects';
|
81
|
+
let titleText = '';
|
82
|
+
if (isRunOne) {
|
83
|
+
const mainTaskId = initiatingTasks[0].id;
|
84
|
+
pinnedTasks.push(mainTaskId);
|
85
|
+
const mainContinuousDependencies = taskGraph.continuousDependencies[mainTaskId];
|
86
|
+
if (mainContinuousDependencies.length > 0) {
|
87
|
+
pinnedTasks.push(mainContinuousDependencies[0]);
|
88
|
+
}
|
89
|
+
const [project, target] = mainTaskId.split(':');
|
90
|
+
titleText = `${target} ${project}`;
|
91
|
+
if (tasks.length > 1) {
|
92
|
+
titleText += `, and ${tasks.length - 1} requisite ${taskText}`;
|
93
|
+
}
|
94
|
+
}
|
95
|
+
else {
|
96
|
+
titleText =
|
97
|
+
nxArgs.targets.join(', ') +
|
98
|
+
` for ${projectNames.length} ${projectText}`;
|
99
|
+
if (tasks.length > projectNames.length) {
|
100
|
+
titleText += `, and ${tasks.length - projectNames.length} requisite ${taskText}`;
|
101
|
+
}
|
102
|
+
}
|
103
|
+
let resolveRenderIsDonePromise;
|
104
|
+
// Default renderIsDone that will be overridden if the TUI is used
|
105
|
+
let renderIsDone = new Promise((resolve) => (resolveRenderIsDonePromise = resolve));
|
106
|
+
const { lifeCycle: tsLifeCycle, printSummary } = (0, tui_summary_life_cycle_1.getTuiTerminalSummaryLifeCycle)({
|
107
|
+
projectNames,
|
108
|
+
tasks,
|
109
|
+
args: nxArgs,
|
110
|
+
overrides: overridesWithoutHidden,
|
111
|
+
initiatingProject,
|
112
|
+
initiatingTasks,
|
113
|
+
resolveRenderIsDonePromise,
|
114
|
+
});
|
115
|
+
if (tasks.length === 0) {
|
116
|
+
renderIsDone = renderIsDone.then(() => {
|
117
|
+
// Revert the patched methods
|
118
|
+
process.stdout.write = originalStdoutWrite;
|
119
|
+
process.stderr.write = originalStderrWrite;
|
120
|
+
console.log = originalConsoleLog;
|
121
|
+
console.error = originalConsoleError;
|
122
|
+
});
|
123
|
+
}
|
124
|
+
const lifeCycles = [tsLifeCycle];
|
125
|
+
// Only run the TUI if there are tasks to run
|
126
|
+
if (tasks.length > 0) {
|
127
|
+
appLifeCycle = new AppLifeCycle(tasks, pinnedTasks, nxArgs ?? {}, nxJson.tui ?? {}, titleText);
|
128
|
+
lifeCycles.unshift(appLifeCycle);
|
129
|
+
/**
|
130
|
+
* Patch stdout.write and stderr.write methods to pass Nx Cloud client logs to the TUI via the lifecycle
|
131
|
+
*/
|
132
|
+
const createPatchedLogWrite = (originalWrite) => {
|
133
|
+
// @ts-ignore
|
134
|
+
return (chunk, encoding, callback) => {
|
135
|
+
// Check if the log came from the Nx Cloud client, otherwise invoke the original write method
|
136
|
+
const stackTrace = new Error().stack;
|
137
|
+
const isNxCloudLog = stackTrace.includes((0, node_path_1.join)(workspace_root_1.workspaceRoot, '.nx', 'cache', 'cloud'));
|
138
|
+
if (isNxCloudLog) {
|
139
|
+
interceptedNxCloudLogs.push(chunk);
|
140
|
+
// Do not bother to store logs with only whitespace characters, they aren't relevant for the TUI
|
141
|
+
const trimmedChunk = chunk.toString().trim();
|
142
|
+
if (trimmedChunk.length) {
|
143
|
+
// Remove ANSI escape codes, the TUI will control the formatting
|
144
|
+
appLifeCycle?.__setCloudMessage((0, node_util_1.stripVTControlCharacters)(trimmedChunk));
|
145
|
+
}
|
146
|
+
}
|
147
|
+
// Preserve original behavior around callback and return value, just in case
|
148
|
+
if (callback) {
|
149
|
+
callback();
|
150
|
+
}
|
151
|
+
return true;
|
152
|
+
};
|
153
|
+
};
|
154
|
+
const createPatchedConsoleMethod = (originalMethod) => {
|
155
|
+
return (...args) => {
|
156
|
+
// Check if the log came from the Nx Cloud client, otherwise invoke the original write method
|
157
|
+
const stackTrace = new Error().stack;
|
158
|
+
const isNxCloudLog = stackTrace.includes((0, node_path_1.join)(workspace_root_1.workspaceRoot, '.nx', 'cache', 'cloud'));
|
159
|
+
if (!isNxCloudLog) {
|
160
|
+
return originalMethod(...args);
|
161
|
+
}
|
162
|
+
// No-op the Nx Cloud client logs
|
163
|
+
};
|
164
|
+
};
|
165
|
+
process.stdout.write = createPatchedLogWrite(originalStdoutWrite);
|
166
|
+
process.stderr.write = createPatchedLogWrite(originalStderrWrite);
|
167
|
+
// The cloud client calls console.log when NX_VERBOSE_LOGGING is set to true
|
168
|
+
console.log = createPatchedConsoleMethod(originalConsoleLog);
|
169
|
+
console.error = createPatchedConsoleMethod(originalConsoleError);
|
170
|
+
renderIsDone = new Promise((resolve) => {
|
171
|
+
appLifeCycle.__init(() => {
|
172
|
+
resolve();
|
173
|
+
});
|
174
|
+
})
|
175
|
+
.then(() => {
|
176
|
+
restoreTerminal();
|
177
|
+
})
|
178
|
+
.finally(() => {
|
179
|
+
// Revert the patched methods
|
180
|
+
process.stdout.write = originalStdoutWrite;
|
181
|
+
process.stderr.write = originalStderrWrite;
|
182
|
+
console.log = originalConsoleLog;
|
183
|
+
console.error = originalConsoleError;
|
184
|
+
// Print the intercepted Nx Cloud logs
|
185
|
+
for (const log of interceptedNxCloudLogs) {
|
186
|
+
const logString = log.toString().trimStart();
|
187
|
+
process.stdout.write(logString);
|
188
|
+
if (logString) {
|
189
|
+
process.stdout.write('\n');
|
190
|
+
}
|
191
|
+
}
|
192
|
+
});
|
193
|
+
}
|
194
|
+
return {
|
195
|
+
lifeCycle: new life_cycle_1.CompositeLifeCycle(lifeCycles),
|
196
|
+
restoreTerminal: () => {
|
197
|
+
process.stdout.write = originalStdoutWrite;
|
198
|
+
process.stderr.write = originalStderrWrite;
|
199
|
+
console.log = originalConsoleLog;
|
200
|
+
console.error = originalConsoleError;
|
201
|
+
restoreTerminal();
|
202
|
+
},
|
203
|
+
printSummary,
|
204
|
+
renderIsDone,
|
205
|
+
};
|
206
|
+
}
|
42
207
|
const { runnerOptions } = getRunner(nxArgs, nxJson);
|
43
208
|
const isRunOne = initiatingProject != null;
|
44
209
|
const useDynamicOutput = shouldUseDynamicLifeCycle(tasks, runnerOptions, nxArgs.outputStyle);
|
45
|
-
const overridesWithoutHidden = { ...overrides };
|
46
|
-
delete overridesWithoutHidden['__overrides_unparsed__'];
|
47
210
|
if (isRunOne) {
|
48
211
|
if (useDynamicOutput) {
|
49
212
|
return await (0, dynamic_run_one_terminal_output_life_cycle_1.createRunOneDynamicOutputRenderer)({
|
@@ -77,6 +240,7 @@ async function getTerminalOutputLifeCycle(initiatingProject, projectNames, tasks
|
|
77
240
|
}
|
78
241
|
function createTaskGraphAndRunValidations(projectGraph, extraTargetDependencies, projectNames, nxArgs, overrides, extraOptions) {
|
79
242
|
const taskGraph = (0, create_task_graph_1.createTaskGraph)(projectGraph, extraTargetDependencies, projectNames, nxArgs.targets, nxArgs.configuration, overrides, extraOptions.excludeTaskDependencies);
|
243
|
+
(0, task_graph_utils_1.assertTaskGraphDoesNotContainInvalidTargets)(taskGraph);
|
80
244
|
const cycle = (0, task_graph_utils_1.findCycle)(taskGraph);
|
81
245
|
if (cycle) {
|
82
246
|
if (process.env.NX_IGNORE_CYCLES === 'true' || nxArgs.nxIgnoreCycles) {
|
@@ -127,26 +291,41 @@ async function runCommand(projectsToRun, currentProjectGraph, { nxJson }, nxArgs
|
|
127
291
|
}
|
128
292
|
async function runCommandForTasks(projectsToRun, currentProjectGraph, { nxJson }, nxArgs, overrides, initiatingProject, extraTargetDependencies, extraOptions) {
|
129
293
|
const projectNames = projectsToRun.map((t) => t.name);
|
294
|
+
const projectNameSet = new Set(projectNames);
|
130
295
|
const { projectGraph, taskGraph } = await ensureWorkspaceIsInSyncAndGetGraphs(currentProjectGraph, nxJson, projectNames, nxArgs, overrides, extraTargetDependencies, extraOptions);
|
131
296
|
const tasks = Object.values(taskGraph.tasks);
|
132
|
-
const
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
297
|
+
const initiatingTasks = tasks.filter((t) => projectNameSet.has(t.target.project) &&
|
298
|
+
nxArgs.targets.includes(t.target.target));
|
299
|
+
const { lifeCycle, renderIsDone, printSummary, restoreTerminal } = await getTerminalOutputLifeCycle(initiatingProject, initiatingTasks, projectNames, tasks, taskGraph, nxArgs, nxJson, overrides);
|
300
|
+
try {
|
301
|
+
const taskResults = await invokeTasksRunner({
|
302
|
+
tasks,
|
303
|
+
projectGraph,
|
304
|
+
taskGraph,
|
305
|
+
lifeCycle,
|
306
|
+
nxJson,
|
307
|
+
nxArgs,
|
308
|
+
loadDotEnvFiles: extraOptions.loadDotEnvFiles,
|
309
|
+
initiatingProject,
|
310
|
+
initiatingTasks,
|
311
|
+
});
|
312
|
+
await renderIsDone;
|
313
|
+
if (printSummary) {
|
314
|
+
printSummary();
|
315
|
+
}
|
316
|
+
await (0, nx_key_1.printNxKey)();
|
317
|
+
return taskResults;
|
318
|
+
}
|
319
|
+
catch (e) {
|
320
|
+
if (restoreTerminal) {
|
321
|
+
restoreTerminal();
|
322
|
+
}
|
323
|
+
throw e;
|
324
|
+
}
|
146
325
|
}
|
147
326
|
async function ensureWorkspaceIsInSyncAndGetGraphs(projectGraph, nxJson, projectNames, nxArgs, overrides, extraTargetDependencies, extraOptions) {
|
148
327
|
let taskGraph = createTaskGraphAndRunValidations(projectGraph, extraTargetDependencies ?? {}, projectNames, nxArgs, overrides, extraOptions);
|
149
|
-
if (nxArgs.skipSync) {
|
328
|
+
if (nxArgs.skipSync || (0, is_ci_1.isCI)()) {
|
150
329
|
return { projectGraph, taskGraph };
|
151
330
|
}
|
152
331
|
// collect unique syncGenerators from the tasks
|
@@ -166,9 +345,8 @@ async function ensureWorkspaceIsInSyncAndGetGraphs(projectGraph, nxJson, project
|
|
166
345
|
const outOfSyncTitle = 'The workspace is out of sync';
|
167
346
|
const resultBodyLines = (0, sync_generators_1.getSyncGeneratorSuccessResultsMessageLines)(results);
|
168
347
|
const fixMessage = 'Make sure to run `nx sync` to apply the identified changes or set `sync.applyChanges` to `true` in your `nx.json` to apply them automatically when running tasks in interactive environments.';
|
169
|
-
|
170
|
-
|
171
|
-
// If the user is running in CI or is running in a non-TTY environment we
|
348
|
+
if (!process.stdout.isTTY) {
|
349
|
+
// If the user is running a non-TTY environment we
|
172
350
|
// throw an error to stop the execution of the tasks.
|
173
351
|
if (areAllResultsFailures) {
|
174
352
|
output_1.output.error({
|
@@ -216,7 +394,6 @@ async function ensureWorkspaceIsInSyncAndGetGraphs(projectGraph, nxJson, project
|
|
216
394
|
...resultBodyLines,
|
217
395
|
'',
|
218
396
|
'Your workspace is set to not apply the identified changes automatically (`sync.applyChanges` is set to `false` in your `nx.json`).',
|
219
|
-
willErrorOnCiMessage,
|
220
397
|
fixMessage,
|
221
398
|
],
|
222
399
|
});
|
@@ -235,10 +412,12 @@ async function ensureWorkspaceIsInSyncAndGetGraphs(projectGraph, nxJson, project
|
|
235
412
|
title: outOfSyncTitle,
|
236
413
|
bodyLines: [
|
237
414
|
...resultBodyLines,
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
|
415
|
+
...(nxJson.sync?.applyChanges === true
|
416
|
+
? [
|
417
|
+
'',
|
418
|
+
'Proceeding to sync the identified changes automatically (`sync.applyChanges` is set to `true` in your `nx.json`).',
|
419
|
+
]
|
420
|
+
: []),
|
242
421
|
],
|
243
422
|
});
|
244
423
|
const applyChanges = nxJson.sync?.applyChanges === true ||
|
@@ -377,7 +556,7 @@ function setEnvVarsBasedOnArgs(nxArgs, loadDotEnvFiles) {
|
|
377
556
|
process.env.NX_LOAD_DOT_ENV_FILES = 'true';
|
378
557
|
}
|
379
558
|
}
|
380
|
-
async function invokeTasksRunner({ tasks, projectGraph, taskGraph, lifeCycle, nxJson, nxArgs, loadDotEnvFiles, initiatingProject, }) {
|
559
|
+
async function invokeTasksRunner({ tasks, projectGraph, taskGraph, lifeCycle, nxJson, nxArgs, loadDotEnvFiles, initiatingProject, initiatingTasks, }) {
|
381
560
|
setEnvVarsBasedOnArgs(nxArgs, loadDotEnvFiles);
|
382
561
|
// this needs to be done before we start to run the tasks
|
383
562
|
const taskDetails = (0, hash_task_1.getTaskDetails)();
|
@@ -397,6 +576,7 @@ async function invokeTasksRunner({ tasks, projectGraph, taskGraph, lifeCycle, nx
|
|
397
576
|
lifeCycle: compositedLifeCycle,
|
398
577
|
}, {
|
399
578
|
initiatingProject: nxArgs.outputStyle === 'compact' ? null : initiatingProject,
|
579
|
+
initiatingTasks,
|
400
580
|
projectGraph,
|
401
581
|
nxJson,
|
402
582
|
nxArgs,
|
@@ -467,10 +647,9 @@ function constructLifeCycles(lifeCycle) {
|
|
467
647
|
if (process.env.NX_PROFILE) {
|
468
648
|
lifeCycles.push(new task_profiling_life_cycle_1.TaskProfilingLifeCycle(process.env.NX_PROFILE));
|
469
649
|
}
|
470
|
-
|
471
|
-
|
472
|
-
|
473
|
-
: new task_history_life_cycle_old_1.LegacyTaskHistoryLifeCycle());
|
650
|
+
const historyLifeCycle = (0, task_history_life_cycle_1.getTasksHistoryLifeCycle)();
|
651
|
+
if (historyLifeCycle) {
|
652
|
+
lifeCycles.push(historyLifeCycle);
|
474
653
|
}
|
475
654
|
return lifeCycles;
|
476
655
|
}
|
@@ -533,15 +712,6 @@ function getRunner(nxArgs, nxJson) {
|
|
533
712
|
}
|
534
713
|
const modulePath = getTasksRunnerPath(runner, nxJson);
|
535
714
|
try {
|
536
|
-
if (isCustomRunnerPath(modulePath)) {
|
537
|
-
output_1.output.warn({
|
538
|
-
title: `Custom task runners will no longer be supported in Nx 21.`,
|
539
|
-
bodyLines: [
|
540
|
-
`Use Nx Cloud or the Nx Powerpack caches instead.`,
|
541
|
-
`For more information, see https://nx.dev/nx-enterprise/powerpack/custom-caching`,
|
542
|
-
],
|
543
|
-
});
|
544
|
-
}
|
545
715
|
const tasksRunner = loadTasksRunner(modulePath);
|
546
716
|
return {
|
547
717
|
tasksRunner,
|
@@ -554,18 +724,12 @@ function getRunner(nxArgs, nxJson) {
|
|
554
724
|
}
|
555
725
|
const defaultTasksRunnerPath = require.resolve('./default-tasks-runner');
|
556
726
|
function getTasksRunnerPath(runner, nxJson) {
|
557
|
-
let modulePath = nxJson.tasksRunnerOptions?.[runner]?.runner;
|
558
|
-
if (modulePath) {
|
559
|
-
if ((0, fileutils_1.isRelativePath)(modulePath)) {
|
560
|
-
return (0, path_1.join)(workspace_root_1.workspaceRoot, modulePath);
|
561
|
-
}
|
562
|
-
return modulePath;
|
563
|
-
}
|
564
727
|
const isCloudRunner =
|
565
728
|
// No tasksRunnerOptions for given --runner
|
566
729
|
nxJson.nxCloudAccessToken ||
|
567
730
|
// No runner prop in tasks runner options, check if access token is set.
|
568
731
|
nxJson.tasksRunnerOptions?.[runner]?.options?.accessToken ||
|
732
|
+
['nx-cloud', '@nrwl/nx-cloud'].includes(nxJson.tasksRunnerOptions?.[runner]?.runner) ||
|
569
733
|
// Cloud access token specified in env var.
|
570
734
|
process.env.NX_CLOUD_ACCESS_TOKEN ||
|
571
735
|
// Nx Cloud ID specified in nxJson
|
@@ -614,11 +778,3 @@ function getRunnerOptions(runner, nxJson, nxArgs, isCloudDefault) {
|
|
614
778
|
}
|
615
779
|
return result;
|
616
780
|
}
|
617
|
-
function isCustomRunnerPath(modulePath) {
|
618
|
-
return ![
|
619
|
-
'nx-cloud',
|
620
|
-
'@nrwl/nx-cloud',
|
621
|
-
'nx/tasks-runners/default',
|
622
|
-
defaultTasksRunnerPath,
|
623
|
-
].includes(modulePath);
|
624
|
-
}
|
@@ -153,18 +153,11 @@ class NodeChildProcessWithDirectOutput {
|
|
153
153
|
this.exitCallbacks.push(cb);
|
154
154
|
}
|
155
155
|
async getResults() {
|
156
|
-
|
157
|
-
|
158
|
-
return Promise.resolve({
|
159
|
-
code: this.exitCode,
|
160
|
-
terminalOutput,
|
161
|
-
});
|
156
|
+
if (!this.exited) {
|
157
|
+
await this.waitForExit();
|
162
158
|
}
|
163
|
-
|
164
|
-
return
|
165
|
-
code: this.exitCode,
|
166
|
-
terminalOutput,
|
167
|
-
});
|
159
|
+
const terminalOutput = this.getTerminalOutput();
|
160
|
+
return { code: this.exitCode, terminalOutput };
|
168
161
|
}
|
169
162
|
waitForExit() {
|
170
163
|
return new Promise((res) => {
|
@@ -1,3 +1,4 @@
|
|
1
|
+
import type { Serializable } from 'child_process';
|
1
2
|
export declare abstract class RunningTask {
|
2
3
|
abstract getResults(): Promise<{
|
3
4
|
code: number;
|
@@ -5,4 +6,6 @@ export declare abstract class RunningTask {
|
|
5
6
|
}>;
|
6
7
|
abstract onExit(cb: (code: number) => void): void;
|
7
8
|
abstract kill(signal?: NodeJS.Signals | number): Promise<void> | void;
|
9
|
+
abstract onOutput?(cb: (output: string) => void): void;
|
10
|
+
abstract send?(message: Serializable): void;
|
8
11
|
}
|
@@ -0,0 +1,14 @@
|
|
1
|
+
import { RunningTask } from './running-task';
|
2
|
+
import { RunningTasksService } from '../../native';
|
3
|
+
export declare class SharedRunningTask implements RunningTask {
|
4
|
+
private runningTasksService;
|
5
|
+
private exitCallbacks;
|
6
|
+
constructor(runningTasksService: RunningTasksService, taskId: string);
|
7
|
+
getResults(): Promise<{
|
8
|
+
code: number;
|
9
|
+
terminalOutput: string;
|
10
|
+
}>;
|
11
|
+
kill(): void;
|
12
|
+
onExit(cb: (code: number) => void): void;
|
13
|
+
private waitForTaskToFinish;
|
14
|
+
}
|