nx 21.0.0-canary.20250206-8bd0bcd → 21.0.0-canary.20250418-8619c1d
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/package.json +13 -12
- package/release/index.d.ts +1 -1
- package/release/index.js +2 -1
- package/schemas/nx-schema.json +186 -35
- 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/graph/graph.js +2 -0
- 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 +47 -35
- 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 +4 -1
- package/src/command-line/init/implementation/utils.js +108 -44
- 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 +68 -38
- package/src/command-line/migrate/migrate-ui-api.d.ts +56 -0
- package/src/command-line/migrate/migrate-ui-api.js +188 -0
- package/src/command-line/migrate/migrate.d.ts +17 -0
- package/src/command-line/migrate/migrate.js +106 -63
- 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 +2 -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 +129 -42
- 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 +251 -0
- package/src/command-line/release/version/release-group-processor.js +1040 -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 +95 -0
- package/src/command-line/release/version/test-utils.js +416 -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 +170 -0
- package/src/command-line/release/version/version-actions.js +183 -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 +80 -262
- 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/run.js +1 -1
- 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/commands-runner/get-command-projects.js +17 -2
- package/src/config/misc-interfaces.d.ts +10 -0
- package/src/config/nx-json.d.ts +153 -15
- package/src/config/project-graph.d.ts +4 -2
- package/src/config/project-graph.js +8 -0
- package/src/config/task-graph.d.ts +5 -0
- package/src/config/workspace-json-project-json.d.ts +6 -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-internals.d.ts +2 -1
- package/src/devkit-internals.js +4 -1
- package/src/executors/run-commands/run-commands.impl.d.ts +18 -17
- package/src/executors/run-commands/run-commands.impl.js +25 -292
- package/src/executors/run-commands/running-tasks.d.ts +40 -0
- package/src/executors/run-commands/running-tasks.js +386 -0
- 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/native/index.d.ts +94 -19
- package/src/native/index.js +16 -2
- package/src/native/native-bindings.js +6 -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/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 +2 -1
- 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 +3 -1
- 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/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/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 +1 -1
- package/src/project-graph/utils/project-configuration-utils.js +25 -11
- 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 +2 -3
- package/src/tasks-runner/cache.d.ts +20 -6
- package/src/tasks-runner/cache.js +104 -20
- package/src/tasks-runner/create-task-graph.d.ts +4 -1
- package/src/tasks-runner/create-task-graph.js +48 -16
- package/src/tasks-runner/default-tasks-runner.js +4 -13
- package/src/tasks-runner/forked-process-task-runner.d.ts +13 -14
- package/src/tasks-runner/forked-process-task-runner.js +160 -303
- package/src/tasks-runner/init-tasks-runner.d.ts +15 -1
- package/src/tasks-runner/init-tasks-runner.js +59 -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 +10 -3
- package/src/tasks-runner/life-cycle.js +23 -2
- package/src/tasks-runner/life-cycles/task-history-life-cycle-old.js +7 -2
- package/src/tasks-runner/life-cycles/task-history-life-cycle.js +6 -1
- package/src/tasks-runner/life-cycles/tui-summary-life-cycle.d.ts +17 -0
- package/src/tasks-runner/life-cycles/tui-summary-life-cycle.js +221 -0
- package/src/tasks-runner/pseudo-terminal.d.ts +17 -8
- package/src/tasks-runner/pseudo-terminal.js +63 -47
- package/src/tasks-runner/run-command.d.ts +1 -0
- package/src/tasks-runner/run-command.js +180 -23
- package/src/tasks-runner/running-tasks/batch-process.d.ts +14 -0
- package/src/tasks-runner/running-tasks/batch-process.js +70 -0
- package/src/tasks-runner/running-tasks/node-child-process.d.ts +36 -0
- package/src/tasks-runner/running-tasks/node-child-process.js +184 -0
- package/src/tasks-runner/running-tasks/noop-child-process.d.ts +15 -0
- package/src/tasks-runner/running-tasks/noop-child-process.js +19 -0
- package/src/tasks-runner/running-tasks/running-task.d.ts +8 -0
- package/src/tasks-runner/running-tasks/running-task.js +6 -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-orchestrator.d.ts +25 -7
- package/src/tasks-runner/task-orchestrator.js +237 -95
- package/src/tasks-runner/tasks-schedule.js +5 -1
- package/src/tasks-runner/utils.d.ts +2 -10
- package/src/tasks-runner/utils.js +27 -15
- 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-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/utils/powerpack.d.ts +0 -5
- package/src/utils/powerpack.js +0 -33
@@ -3,104 +3,77 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.ForkedProcessTaskRunner = void 0;
|
4
4
|
const fs_1 = require("fs");
|
5
5
|
const child_process_1 = require("child_process");
|
6
|
-
const chalk = require("chalk");
|
7
6
|
const output_1 = require("../utils/output");
|
8
7
|
const utils_1 = require("./utils");
|
9
8
|
const path_1 = require("path");
|
10
9
|
const batch_messages_1 = require("./batch/batch-messages");
|
11
10
|
const strip_indents_1 = require("../utils/strip-indents");
|
12
|
-
const stream_1 = require("stream");
|
13
11
|
const pseudo_terminal_1 = require("./pseudo-terminal");
|
14
12
|
const exit_codes_1 = require("../utils/exit-codes");
|
13
|
+
const node_child_process_1 = require("./running-tasks/node-child-process");
|
14
|
+
const batch_process_1 = require("./running-tasks/batch-process");
|
15
|
+
const native_1 = require("../native");
|
15
16
|
const forkScript = (0, path_1.join)(__dirname, './fork.js');
|
16
17
|
const workerPath = (0, path_1.join)(__dirname, './batch/run-batch.js');
|
17
18
|
class ForkedProcessTaskRunner {
|
18
|
-
constructor(options) {
|
19
|
+
constructor(options, tuiEnabled) {
|
19
20
|
this.options = options;
|
21
|
+
this.tuiEnabled = tuiEnabled;
|
20
22
|
this.cliPath = (0, utils_1.getCliPath)();
|
21
23
|
this.verbose = process.env.NX_VERBOSE_LOGGING === 'true';
|
22
24
|
this.processes = new Set();
|
23
|
-
this.
|
24
|
-
|
25
|
-
: null;
|
25
|
+
this.finishedProcesses = new Set();
|
26
|
+
this.pseudoTerminals = new Set();
|
26
27
|
}
|
27
28
|
async init() {
|
28
|
-
if (this.pseudoTerminal) {
|
29
|
-
await this.pseudoTerminal.init();
|
30
|
-
}
|
31
29
|
this.setupProcessEventListeners();
|
32
30
|
}
|
33
31
|
// TODO: vsavkin delegate terminal output printing
|
34
|
-
forkProcessForBatch({ executorName, taskGraph: batchTaskGraph }, fullTaskGraph, env) {
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
stdio: ['inherit', 'inherit', 'inherit', 'ipc'],
|
47
|
-
env,
|
48
|
-
});
|
49
|
-
this.processes.add(p);
|
50
|
-
p.once('exit', (code, signal) => {
|
51
|
-
this.processes.delete(p);
|
52
|
-
if (code === null)
|
53
|
-
code = (0, exit_codes_1.signalToCode)(signal);
|
54
|
-
if (code !== 0) {
|
55
|
-
const results = {};
|
56
|
-
for (const rootTaskId of batchTaskGraph.roots) {
|
57
|
-
results[rootTaskId] = {
|
58
|
-
success: false,
|
59
|
-
terminalOutput: '',
|
60
|
-
};
|
61
|
-
}
|
62
|
-
rej(new Error(`"${executorName}" exited unexpectedly with code: ${code}`));
|
63
|
-
}
|
64
|
-
});
|
65
|
-
p.on('message', (message) => {
|
66
|
-
switch (message.type) {
|
67
|
-
case batch_messages_1.BatchMessageType.CompleteBatchExecution: {
|
68
|
-
res(message.results);
|
69
|
-
break;
|
70
|
-
}
|
71
|
-
case batch_messages_1.BatchMessageType.RunTasks: {
|
72
|
-
break;
|
73
|
-
}
|
74
|
-
default: {
|
75
|
-
// Re-emit any non-batch messages from the task process
|
76
|
-
if (process.send) {
|
77
|
-
process.send(message);
|
78
|
-
}
|
79
|
-
}
|
80
|
-
}
|
81
|
-
});
|
82
|
-
// Start the tasks
|
83
|
-
p.send({
|
84
|
-
type: batch_messages_1.BatchMessageType.RunTasks,
|
85
|
-
executorName,
|
86
|
-
batchTaskGraph,
|
87
|
-
fullTaskGraph,
|
88
|
-
});
|
89
|
-
}
|
90
|
-
catch (e) {
|
91
|
-
rej(e);
|
92
|
-
}
|
32
|
+
async forkProcessForBatch({ executorName, taskGraph: batchTaskGraph }, projectGraph, fullTaskGraph, env) {
|
33
|
+
const count = Object.keys(batchTaskGraph.tasks).length;
|
34
|
+
if (count > 1) {
|
35
|
+
output_1.output.logSingleLine(`Running ${output_1.output.bold(count)} ${output_1.output.bold('tasks')} with ${output_1.output.bold(executorName)}`);
|
36
|
+
}
|
37
|
+
else {
|
38
|
+
const args = (0, utils_1.getPrintableCommandArgsForTask)(Object.values(batchTaskGraph.tasks)[0]);
|
39
|
+
output_1.output.logCommand(args.join(' '));
|
40
|
+
}
|
41
|
+
const p = (0, child_process_1.fork)(workerPath, {
|
42
|
+
stdio: ['inherit', 'inherit', 'inherit', 'ipc'],
|
43
|
+
env,
|
93
44
|
});
|
45
|
+
const cp = new batch_process_1.BatchProcess(p, executorName);
|
46
|
+
this.processes.add(cp);
|
47
|
+
cp.onExit(() => {
|
48
|
+
this.processes.delete(cp);
|
49
|
+
});
|
50
|
+
// Start the tasks
|
51
|
+
cp.send({
|
52
|
+
type: batch_messages_1.BatchMessageType.RunTasks,
|
53
|
+
executorName,
|
54
|
+
projectGraph,
|
55
|
+
batchTaskGraph,
|
56
|
+
fullTaskGraph,
|
57
|
+
});
|
58
|
+
return cp;
|
59
|
+
}
|
60
|
+
cleanUpBatchProcesses() {
|
61
|
+
if (this.finishedProcesses.size > 0) {
|
62
|
+
this.finishedProcesses.forEach((p) => {
|
63
|
+
p.kill();
|
64
|
+
});
|
65
|
+
this.finishedProcesses.clear();
|
66
|
+
}
|
94
67
|
}
|
95
68
|
async forkProcessLegacy(task, { temporaryOutputPath, streamOutput, pipeOutput, taskGraph, env, }) {
|
96
69
|
return pipeOutput
|
97
|
-
?
|
70
|
+
? this.forkProcessWithPrefixAndNotTTY(task, {
|
98
71
|
temporaryOutputPath,
|
99
72
|
streamOutput,
|
100
73
|
taskGraph,
|
101
74
|
env,
|
102
75
|
})
|
103
|
-
:
|
76
|
+
: this.forkProcessDirectOutputCapture(task, {
|
104
77
|
temporaryOutputPath,
|
105
78
|
streamOutput,
|
106
79
|
taskGraph,
|
@@ -108,14 +81,15 @@ class ForkedProcessTaskRunner {
|
|
108
81
|
});
|
109
82
|
}
|
110
83
|
async forkProcess(task, { temporaryOutputPath, streamOutput, taskGraph, env, disablePseudoTerminal, }) {
|
111
|
-
const shouldPrefix = streamOutput &&
|
84
|
+
const shouldPrefix = streamOutput &&
|
85
|
+
process.env.NX_PREFIX_OUTPUT === 'true' &&
|
86
|
+
!this.tuiEnabled;
|
112
87
|
// streamOutput would be false if we are running multiple targets
|
113
88
|
// there's no point in running the commands in a pty if we are not streaming the output
|
114
|
-
if (
|
115
|
-
disablePseudoTerminal
|
116
|
-
|
117
|
-
|
118
|
-
return this.forkProcessWithPrefixAndNotTTY(task, {
|
89
|
+
if (pseudo_terminal_1.PseudoTerminal.isSupported() &&
|
90
|
+
!disablePseudoTerminal &&
|
91
|
+
(this.tuiEnabled || (streamOutput && !shouldPrefix))) {
|
92
|
+
return this.forkProcessWithPseudoTerminal(task, {
|
119
93
|
temporaryOutputPath,
|
120
94
|
streamOutput,
|
121
95
|
taskGraph,
|
@@ -123,7 +97,7 @@ class ForkedProcessTaskRunner {
|
|
123
97
|
});
|
124
98
|
}
|
125
99
|
else {
|
126
|
-
return this.
|
100
|
+
return this.forkProcessWithPrefixAndNotTTY(task, {
|
127
101
|
temporaryOutputPath,
|
128
102
|
streamOutput,
|
129
103
|
taskGraph,
|
@@ -131,13 +105,19 @@ class ForkedProcessTaskRunner {
|
|
131
105
|
});
|
132
106
|
}
|
133
107
|
}
|
108
|
+
async createPseudoTerminal() {
|
109
|
+
const terminal = new pseudo_terminal_1.PseudoTerminal(new native_1.RustPseudoTerminal());
|
110
|
+
await terminal.init();
|
111
|
+
terminal.onMessageFromChildren((message) => {
|
112
|
+
process.send(message);
|
113
|
+
});
|
114
|
+
return terminal;
|
115
|
+
}
|
134
116
|
async forkProcessWithPseudoTerminal(task, { temporaryOutputPath, streamOutput, taskGraph, env, }) {
|
135
|
-
const args = (0, utils_1.getPrintableCommandArgsForTask)(task);
|
136
|
-
if (streamOutput) {
|
137
|
-
output_1.output.logCommand(args.join(' '));
|
138
|
-
}
|
139
117
|
const childId = task.id;
|
140
|
-
const
|
118
|
+
const pseudoTerminal = await this.createPseudoTerminal();
|
119
|
+
this.pseudoTerminals.add(pseudoTerminal);
|
120
|
+
const p = await pseudoTerminal.fork(childId, forkScript, {
|
141
121
|
cwd: process.cwd(),
|
142
122
|
execArgv: process.execArgv,
|
143
123
|
jsEnv: env,
|
@@ -154,263 +134,140 @@ class ForkedProcessTaskRunner {
|
|
154
134
|
p.onOutput((msg) => {
|
155
135
|
terminalOutput += msg;
|
156
136
|
});
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
res({
|
165
|
-
code,
|
166
|
-
terminalOutput,
|
167
|
-
});
|
168
|
-
});
|
169
|
-
});
|
170
|
-
}
|
171
|
-
forkProcessPipeOutputCapture(task, { streamOutput, temporaryOutputPath, taskGraph, env, }) {
|
172
|
-
return this.forkProcessWithPrefixAndNotTTY(task, {
|
173
|
-
streamOutput,
|
174
|
-
temporaryOutputPath,
|
175
|
-
taskGraph,
|
176
|
-
env,
|
137
|
+
p.onExit((code) => {
|
138
|
+
if (code > 128) {
|
139
|
+
process.exit(code);
|
140
|
+
}
|
141
|
+
this.pseudoTerminals.delete(pseudoTerminal);
|
142
|
+
this.processes.delete(p);
|
143
|
+
this.writeTerminalOutput(temporaryOutputPath, terminalOutput);
|
177
144
|
});
|
145
|
+
return p;
|
178
146
|
}
|
179
147
|
forkProcessWithPrefixAndNotTTY(task, { streamOutput, temporaryOutputPath, taskGraph, env, }) {
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
if (process.env.NX_PREFIX_OUTPUT === 'true') {
|
206
|
-
const color = getColor(task.target.project);
|
207
|
-
const prefixText = `${task.target.project}:`;
|
208
|
-
p.stdout
|
209
|
-
.pipe(logClearLineToPrefixTransformer(color.bold(prefixText) + ' '))
|
210
|
-
.pipe(addPrefixTransformer(color.bold(prefixText)))
|
211
|
-
.pipe(process.stdout);
|
212
|
-
p.stderr
|
213
|
-
.pipe(logClearLineToPrefixTransformer(color(prefixText) + ' '))
|
214
|
-
.pipe(addPrefixTransformer(color(prefixText)))
|
215
|
-
.pipe(process.stderr);
|
216
|
-
}
|
217
|
-
else {
|
218
|
-
p.stdout.pipe(addPrefixTransformer()).pipe(process.stdout);
|
219
|
-
p.stderr.pipe(addPrefixTransformer()).pipe(process.stderr);
|
220
|
-
}
|
148
|
+
try {
|
149
|
+
const args = (0, utils_1.getPrintableCommandArgsForTask)(task);
|
150
|
+
if (streamOutput) {
|
151
|
+
output_1.output.logCommand(args.join(' '));
|
152
|
+
}
|
153
|
+
const p = (0, child_process_1.fork)(this.cliPath, {
|
154
|
+
stdio: ['inherit', 'pipe', 'pipe', 'ipc'],
|
155
|
+
env,
|
156
|
+
});
|
157
|
+
// Send message to run the executor
|
158
|
+
p.send({
|
159
|
+
targetDescription: task.target,
|
160
|
+
overrides: task.overrides,
|
161
|
+
taskGraph,
|
162
|
+
isVerbose: this.verbose,
|
163
|
+
});
|
164
|
+
const cp = new node_child_process_1.NodeChildProcessWithNonDirectOutput(p, {
|
165
|
+
streamOutput,
|
166
|
+
prefix: task.target.project,
|
167
|
+
});
|
168
|
+
this.processes.add(cp);
|
169
|
+
cp.onExit((code, terminalOutput) => {
|
170
|
+
this.processes.delete(cp);
|
171
|
+
if (!streamOutput) {
|
172
|
+
this.options.lifeCycle.printTaskTerminalOutput(task, code === 0 ? 'success' : 'failure', terminalOutput);
|
221
173
|
}
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
174
|
+
this.writeTerminalOutput(temporaryOutputPath, terminalOutput);
|
175
|
+
});
|
176
|
+
return cp;
|
177
|
+
}
|
178
|
+
catch (e) {
|
179
|
+
console.error(e);
|
180
|
+
throw e;
|
181
|
+
}
|
182
|
+
}
|
183
|
+
forkProcessDirectOutputCapture(task, { streamOutput, temporaryOutputPath, taskGraph, env, }) {
|
184
|
+
try {
|
185
|
+
const args = (0, utils_1.getPrintableCommandArgsForTask)(task);
|
186
|
+
if (streamOutput) {
|
187
|
+
output_1.output.logCommand(args.join(' '));
|
188
|
+
}
|
189
|
+
const p = (0, child_process_1.fork)(this.cliPath, {
|
190
|
+
stdio: ['inherit', 'inherit', 'inherit', 'ipc'],
|
191
|
+
env,
|
192
|
+
});
|
193
|
+
const cp = new node_child_process_1.NodeChildProcessWithDirectOutput(p, temporaryOutputPath);
|
194
|
+
this.processes.add(cp);
|
195
|
+
// Send message to run the executor
|
196
|
+
p.send({
|
197
|
+
targetDescription: task.target,
|
198
|
+
overrides: task.overrides,
|
199
|
+
taskGraph,
|
200
|
+
isVerbose: this.verbose,
|
201
|
+
});
|
202
|
+
cp.onExit((code, signal) => {
|
203
|
+
this.processes.delete(cp);
|
204
|
+
// we didn't print any output as we were running the command
|
205
|
+
// print all the collected output
|
206
|
+
try {
|
207
|
+
const terminalOutput = cp.getTerminalOutput();
|
236
208
|
if (!streamOutput) {
|
237
209
|
this.options.lifeCycle.printTaskTerminalOutput(task, code === 0 ? 'success' : 'failure', terminalOutput);
|
238
210
|
}
|
239
|
-
this.writeTerminalOutput(temporaryOutputPath, terminalOutput);
|
240
|
-
res({ code, terminalOutput });
|
241
|
-
});
|
242
|
-
}
|
243
|
-
catch (e) {
|
244
|
-
console.error(e);
|
245
|
-
rej(e);
|
246
|
-
}
|
247
|
-
});
|
248
|
-
}
|
249
|
-
forkProcessDirectOutputCapture(task, { streamOutput, temporaryOutputPath, taskGraph, env, }) {
|
250
|
-
return new Promise((res, rej) => {
|
251
|
-
try {
|
252
|
-
const args = (0, utils_1.getPrintableCommandArgsForTask)(task);
|
253
|
-
if (streamOutput) {
|
254
|
-
output_1.output.logCommand(args.join(' '));
|
255
211
|
}
|
256
|
-
|
257
|
-
|
258
|
-
env,
|
259
|
-
});
|
260
|
-
this.processes.add(p);
|
261
|
-
// Re-emit any messages from the task process
|
262
|
-
p.on('message', (message) => {
|
263
|
-
if (process.send) {
|
264
|
-
process.send(message);
|
265
|
-
}
|
266
|
-
});
|
267
|
-
// Send message to run the executor
|
268
|
-
p.send({
|
269
|
-
targetDescription: task.target,
|
270
|
-
overrides: task.overrides,
|
271
|
-
taskGraph,
|
272
|
-
isVerbose: this.verbose,
|
273
|
-
});
|
274
|
-
p.on('exit', (code, signal) => {
|
275
|
-
if (code === null)
|
276
|
-
code = (0, exit_codes_1.signalToCode)(signal);
|
277
|
-
// we didn't print any output as we were running the command
|
278
|
-
// print all the collected output
|
279
|
-
let terminalOutput = '';
|
280
|
-
try {
|
281
|
-
terminalOutput = this.readTerminalOutput(temporaryOutputPath);
|
282
|
-
if (!streamOutput) {
|
283
|
-
this.options.lifeCycle.printTaskTerminalOutput(task, code === 0 ? 'success' : 'failure', terminalOutput);
|
284
|
-
}
|
285
|
-
}
|
286
|
-
catch (e) {
|
287
|
-
console.log((0, strip_indents_1.stripIndents) `
|
212
|
+
catch (e) {
|
213
|
+
console.log((0, strip_indents_1.stripIndents) `
|
288
214
|
Unable to print terminal output for Task "${task.id}".
|
289
215
|
Task failed with Exit Code ${code} and Signal "${signal}".
|
290
216
|
|
291
217
|
Received error message:
|
292
218
|
${e.message}
|
293
219
|
`);
|
294
|
-
|
295
|
-
|
296
|
-
|
297
|
-
|
298
|
-
|
299
|
-
|
300
|
-
|
301
|
-
|
302
|
-
console.error(e);
|
303
|
-
rej(e);
|
304
|
-
}
|
305
|
-
});
|
306
|
-
}
|
307
|
-
readTerminalOutput(outputPath) {
|
308
|
-
return (0, fs_1.readFileSync)(outputPath).toString();
|
220
|
+
}
|
221
|
+
});
|
222
|
+
return cp;
|
223
|
+
}
|
224
|
+
catch (e) {
|
225
|
+
console.error(e);
|
226
|
+
throw e;
|
227
|
+
}
|
309
228
|
}
|
310
229
|
writeTerminalOutput(outputPath, content) {
|
311
230
|
(0, fs_1.writeFileSync)(outputPath, content);
|
312
231
|
}
|
313
232
|
setupProcessEventListeners() {
|
314
|
-
|
315
|
-
this.
|
316
|
-
|
233
|
+
const messageHandler = (message) => {
|
234
|
+
this.pseudoTerminals.forEach((p) => {
|
235
|
+
p.sendMessageToChildren(message);
|
317
236
|
});
|
318
|
-
}
|
319
|
-
// When the nx process gets a message, it will be sent into the task's process
|
320
|
-
process.on('message', (message) => {
|
321
|
-
// this.publisher.publish(message.toString());
|
322
|
-
if (this.pseudoTerminal) {
|
323
|
-
this.pseudoTerminal.sendMessageToChildren(message);
|
324
|
-
}
|
325
237
|
this.processes.forEach((p) => {
|
326
|
-
if ('connected' in p && p.connected) {
|
238
|
+
if ('connected' in p && p.connected && 'send' in p) {
|
327
239
|
p.send(message);
|
328
240
|
}
|
329
241
|
});
|
330
|
-
}
|
331
|
-
//
|
332
|
-
process.on('
|
242
|
+
};
|
243
|
+
// When the nx process gets a message, it will be sent into the task's process
|
244
|
+
process.on('message', messageHandler);
|
245
|
+
const cleanUp = (signal) => {
|
333
246
|
this.processes.forEach((p) => {
|
334
|
-
|
335
|
-
p.kill();
|
336
|
-
}
|
247
|
+
p.kill(signal);
|
337
248
|
});
|
249
|
+
process.off('message', messageHandler);
|
250
|
+
this.cleanUpBatchProcesses();
|
251
|
+
};
|
252
|
+
// Terminate any task processes on exit
|
253
|
+
process.once('exit', () => {
|
254
|
+
cleanUp();
|
338
255
|
});
|
339
|
-
process.
|
340
|
-
|
341
|
-
if ('connected' in p ? p.connected : p.isAlive) {
|
342
|
-
p.kill('SIGTERM');
|
343
|
-
}
|
344
|
-
});
|
256
|
+
process.once('SIGINT', () => {
|
257
|
+
cleanUp('SIGTERM');
|
345
258
|
// we exit here because we don't need to write anything to cache.
|
346
259
|
process.exit((0, exit_codes_1.signalToCode)('SIGINT'));
|
347
260
|
});
|
348
|
-
process.
|
349
|
-
|
350
|
-
if ('connected' in p ? p.connected : p.isAlive) {
|
351
|
-
p.kill('SIGTERM');
|
352
|
-
}
|
353
|
-
});
|
261
|
+
process.once('SIGTERM', () => {
|
262
|
+
cleanUp('SIGTERM');
|
354
263
|
// no exit here because we expect child processes to terminate which
|
355
264
|
// will store results to the cache and will terminate this process
|
356
265
|
});
|
357
|
-
process.
|
358
|
-
|
359
|
-
if ('connected' in p ? p.connected : p.isAlive) {
|
360
|
-
p.kill('SIGTERM');
|
361
|
-
}
|
362
|
-
});
|
266
|
+
process.once('SIGHUP', () => {
|
267
|
+
cleanUp('SIGTERM');
|
363
268
|
// no exit here because we expect child processes to terminate which
|
364
269
|
// will store results to the cache and will terminate this process
|
365
270
|
});
|
366
271
|
}
|
367
272
|
}
|
368
273
|
exports.ForkedProcessTaskRunner = ForkedProcessTaskRunner;
|
369
|
-
const colors = [
|
370
|
-
chalk.green,
|
371
|
-
chalk.greenBright,
|
372
|
-
chalk.red,
|
373
|
-
chalk.redBright,
|
374
|
-
chalk.cyan,
|
375
|
-
chalk.cyanBright,
|
376
|
-
chalk.yellow,
|
377
|
-
chalk.yellowBright,
|
378
|
-
chalk.magenta,
|
379
|
-
chalk.magentaBright,
|
380
|
-
];
|
381
|
-
function getColor(projectName) {
|
382
|
-
let code = 0;
|
383
|
-
for (let i = 0; i < projectName.length; ++i) {
|
384
|
-
code += projectName.charCodeAt(i);
|
385
|
-
}
|
386
|
-
const colorIndex = code % colors.length;
|
387
|
-
return colors[colorIndex];
|
388
|
-
}
|
389
|
-
/**
|
390
|
-
* Prevents terminal escape sequence from clearing line prefix.
|
391
|
-
*/
|
392
|
-
function logClearLineToPrefixTransformer(prefix) {
|
393
|
-
let prevChunk = null;
|
394
|
-
return new stream_1.Transform({
|
395
|
-
transform(chunk, _encoding, callback) {
|
396
|
-
if (prevChunk && prevChunk.toString() === '\x1b[2K') {
|
397
|
-
chunk = chunk.toString().replace(/\x1b\[1G/g, (m) => m + prefix);
|
398
|
-
}
|
399
|
-
this.push(chunk);
|
400
|
-
prevChunk = chunk;
|
401
|
-
callback();
|
402
|
-
},
|
403
|
-
});
|
404
|
-
}
|
405
|
-
function addPrefixTransformer(prefix) {
|
406
|
-
const newLineSeparator = process.platform.startsWith('win') ? '\r\n' : '\n';
|
407
|
-
return new stream_1.Transform({
|
408
|
-
transform(chunk, _encoding, callback) {
|
409
|
-
const list = chunk.toString().split(/\r\n|[\n\v\f\r\x85\u2028\u2029]/g);
|
410
|
-
list
|
411
|
-
.filter(Boolean)
|
412
|
-
.forEach((m) => this.push(prefix ? prefix + ' ' + m + newLineSeparator : m + newLineSeparator));
|
413
|
-
callback();
|
414
|
-
},
|
415
|
-
});
|
416
|
-
}
|
@@ -1,6 +1,13 @@
|
|
1
1
|
import { NxArgs } from '../utils/command-line-utils';
|
2
2
|
import { Task, TaskGraph } from '../config/task-graph';
|
3
|
-
import { TaskResult } from './life-cycle';
|
3
|
+
import { LifeCycle, TaskResult } from './life-cycle';
|
4
|
+
import type { ProjectGraph } from '../config/project-graph';
|
5
|
+
import type { NxJsonConfiguration } from '../config/nx-json';
|
6
|
+
import { RunningTask } from './running-tasks/running-task';
|
7
|
+
/**
|
8
|
+
* This function is deprecated. Do not use this
|
9
|
+
* @deprecated This function is deprecated. Do not use this
|
10
|
+
*/
|
4
11
|
export declare function initTasksRunner(nxArgs: NxArgs): Promise<{
|
5
12
|
invoke: (opts: {
|
6
13
|
tasks: Task[];
|
@@ -11,3 +18,10 @@ export declare function initTasksRunner(nxArgs: NxArgs): Promise<{
|
|
11
18
|
taskResults: Record<string, TaskResult>;
|
12
19
|
}>;
|
13
20
|
}>;
|
21
|
+
export declare function runDiscreteTasks(tasks: Task[], projectGraph: ProjectGraph, taskGraphForHashing: TaskGraph, nxJson: NxJsonConfiguration, lifeCycle: LifeCycle): Promise<Promise<{
|
22
|
+
task: Task;
|
23
|
+
code: number;
|
24
|
+
status: import("./tasks-runner").TaskStatus;
|
25
|
+
terminalOutput?: string;
|
26
|
+
}>[]>;
|
27
|
+
export declare function runContinuousTasks(tasks: Task[], projectGraph: ProjectGraph, taskGraphForHashing: TaskGraph, nxJson: NxJsonConfiguration, lifeCycle: LifeCycle): Promise<Record<string, Promise<RunningTask>>>;
|