nx 21.0.0-canary.20250205-45d5140 → 21.0.0-canary.20250416-caa26a7
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.js +21 -18
- 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/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/nx-deps-cache.js +7 -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/loaded-nx-plugin.js +3 -7
- 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 +5 -2
- 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 +58 -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/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
@@ -2,25 +2,13 @@
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
3
|
exports.LARGE_BUFFER = void 0;
|
4
4
|
exports.default = default_1;
|
5
|
+
exports.runCommands = runCommands;
|
5
6
|
exports.interpolateArgsIntoCommand = interpolateArgsIntoCommand;
|
6
|
-
const child_process_1 = require("child_process");
|
7
|
-
const path = require("path");
|
8
7
|
const yargsParser = require("yargs-parser");
|
9
|
-
const
|
10
|
-
const chalk = require("chalk");
|
8
|
+
const is_tui_enabled_1 = require("../../tasks-runner/is-tui-enabled");
|
11
9
|
const pseudo_terminal_1 = require("../../tasks-runner/pseudo-terminal");
|
12
|
-
const
|
13
|
-
const task_env_1 = require("../../tasks-runner/task-env");
|
10
|
+
const running_tasks_1 = require("./running-tasks");
|
14
11
|
exports.LARGE_BUFFER = 1024 * 1000000;
|
15
|
-
let pseudoTerminal;
|
16
|
-
const childProcesses = new Set();
|
17
|
-
function loadEnvVarsFile(path, env = {}) {
|
18
|
-
(0, task_env_1.unloadDotEnvFile)(path, env);
|
19
|
-
const result = (0, task_env_1.loadAndExpandDotEnvFile)(path, env);
|
20
|
-
if (result.error) {
|
21
|
-
throw result.error;
|
22
|
-
}
|
23
|
-
}
|
24
12
|
const propKeys = [
|
25
13
|
'command',
|
26
14
|
'commands',
|
@@ -41,7 +29,14 @@ const propKeys = [
|
|
41
29
|
'tty',
|
42
30
|
];
|
43
31
|
async function default_1(options, context) {
|
44
|
-
|
32
|
+
const task = await runCommands(options, context);
|
33
|
+
const results = await task.getResults();
|
34
|
+
return {
|
35
|
+
...results,
|
36
|
+
success: results.code === 0,
|
37
|
+
};
|
38
|
+
}
|
39
|
+
async function runCommands(options, context) {
|
45
40
|
const normalized = normalizeOptions(options);
|
46
41
|
if (normalized.readyWhenStatus.length && !normalized.parallel) {
|
47
42
|
throw new Error('ERROR: Bad executor config for run-commands - "readyWhen" can only be used when "parallel=true".');
|
@@ -50,11 +45,21 @@ async function default_1(options, context) {
|
|
50
45
|
!options.parallel) {
|
51
46
|
throw new Error('ERROR: Bad executor config for run-commands - "prefix", "prefixColor", "color" and "bgColor" can only be set when "parallel=true".');
|
52
47
|
}
|
48
|
+
const isSingleCommand = normalized.commands.length === 1;
|
49
|
+
const usePseudoTerminal = (isSingleCommand || !options.parallel) && pseudo_terminal_1.PseudoTerminal.isSupported();
|
50
|
+
const isSingleCommandAndCanUsePseudoTerminal = isSingleCommand &&
|
51
|
+
usePseudoTerminal &&
|
52
|
+
process.env.NX_NATIVE_COMMAND_RUNNER !== 'false' &&
|
53
|
+
!normalized.commands[0].prefix &&
|
54
|
+
normalized.usePty;
|
55
|
+
const tuiEnabled = (0, is_tui_enabled_1.isTuiEnabled)();
|
53
56
|
try {
|
54
|
-
const
|
55
|
-
? await
|
56
|
-
:
|
57
|
-
|
57
|
+
const runningTask = isSingleCommandAndCanUsePseudoTerminal
|
58
|
+
? await (0, running_tasks_1.runSingleCommandWithPseudoTerminal)(normalized, context)
|
59
|
+
: options.parallel
|
60
|
+
? new running_tasks_1.ParallelRunningTasks(normalized, context, tuiEnabled)
|
61
|
+
: new running_tasks_1.SeriallyRunningTasks(normalized, context, tuiEnabled);
|
62
|
+
return runningTask;
|
58
63
|
}
|
59
64
|
catch (e) {
|
60
65
|
if (process.env.NX_VERBOSE_LOGGING === 'true') {
|
@@ -63,52 +68,6 @@ async function default_1(options, context) {
|
|
63
68
|
throw new Error(`ERROR: Something went wrong in run-commands - ${e.message}`);
|
64
69
|
}
|
65
70
|
}
|
66
|
-
async function runInParallel(options, context) {
|
67
|
-
const procs = options.commands.map((c) => createProcess(null, c, options.readyWhenStatus, options.color, calculateCwd(options.cwd, context), options.env ?? {}, true, options.usePty, options.streamOutput, options.tty, options.envFile).then((result) => ({
|
68
|
-
result,
|
69
|
-
command: c.command,
|
70
|
-
})));
|
71
|
-
let terminalOutput = '';
|
72
|
-
if (options.readyWhenStatus.length) {
|
73
|
-
const r = await Promise.race(procs);
|
74
|
-
terminalOutput += r.result.terminalOutput;
|
75
|
-
if (!r.result.success) {
|
76
|
-
const output = `Warning: command "${r.command}" exited with non-zero status code`;
|
77
|
-
terminalOutput += output;
|
78
|
-
if (options.streamOutput) {
|
79
|
-
process.stderr.write(output);
|
80
|
-
}
|
81
|
-
return { success: false, terminalOutput };
|
82
|
-
}
|
83
|
-
else {
|
84
|
-
return { success: true, terminalOutput };
|
85
|
-
}
|
86
|
-
}
|
87
|
-
else {
|
88
|
-
const r = await Promise.all(procs);
|
89
|
-
terminalOutput += r.map((f) => f.result.terminalOutput).join('');
|
90
|
-
const failed = r.filter((v) => !v.result.success);
|
91
|
-
if (failed.length > 0) {
|
92
|
-
const output = failed
|
93
|
-
.map((f) => `Warning: command "${f.command}" exited with non-zero status code`)
|
94
|
-
.join('\r\n');
|
95
|
-
terminalOutput += output;
|
96
|
-
if (options.streamOutput) {
|
97
|
-
process.stderr.write(output);
|
98
|
-
}
|
99
|
-
return {
|
100
|
-
success: false,
|
101
|
-
terminalOutput,
|
102
|
-
};
|
103
|
-
}
|
104
|
-
else {
|
105
|
-
return {
|
106
|
-
success: true,
|
107
|
-
terminalOutput,
|
108
|
-
};
|
109
|
-
}
|
110
|
-
}
|
111
|
-
}
|
112
71
|
function normalizeOptions(options) {
|
113
72
|
if (options.readyWhen && typeof options.readyWhen === 'string') {
|
114
73
|
options.readyWhenStatus = [
|
@@ -156,167 +115,6 @@ function normalizeOptions(options) {
|
|
156
115
|
});
|
157
116
|
return options;
|
158
117
|
}
|
159
|
-
async function runSerially(options, context) {
|
160
|
-
pseudoTerminal ??= pseudo_terminal_1.PseudoTerminal.isSupported() ? (0, pseudo_terminal_1.getPseudoTerminal)() : null;
|
161
|
-
let terminalOutput = '';
|
162
|
-
for (const c of options.commands) {
|
163
|
-
const result = await createProcess(pseudoTerminal, c, [], options.color, calculateCwd(options.cwd, context), options.processEnv ?? options.env ?? {}, false, options.usePty, options.streamOutput, options.tty, options.envFile);
|
164
|
-
terminalOutput += result.terminalOutput;
|
165
|
-
if (!result.success) {
|
166
|
-
const output = `Warning: command "${c.command}" exited with non-zero status code`;
|
167
|
-
result.terminalOutput += output;
|
168
|
-
if (options.streamOutput) {
|
169
|
-
process.stderr.write(output);
|
170
|
-
}
|
171
|
-
return { success: false, terminalOutput };
|
172
|
-
}
|
173
|
-
}
|
174
|
-
return { success: true, terminalOutput };
|
175
|
-
}
|
176
|
-
async function createProcess(pseudoTerminal, commandConfig, readyWhenStatus = [], color, cwd, env, isParallel, usePty = true, streamOutput = true, tty, envFile) {
|
177
|
-
env = processEnv(color, cwd, env, envFile);
|
178
|
-
// The rust runCommand is always a tty, so it will not look nice in parallel and if we need prefixes
|
179
|
-
// currently does not work properly in windows
|
180
|
-
if (pseudoTerminal &&
|
181
|
-
process.env.NX_NATIVE_COMMAND_RUNNER !== 'false' &&
|
182
|
-
!commandConfig.prefix &&
|
183
|
-
readyWhenStatus.length === 0 &&
|
184
|
-
!isParallel &&
|
185
|
-
usePty) {
|
186
|
-
let terminalOutput = chalk.dim('> ') + commandConfig.command + '\r\n\r\n';
|
187
|
-
if (streamOutput) {
|
188
|
-
process.stdout.write(terminalOutput);
|
189
|
-
}
|
190
|
-
const cp = pseudoTerminal.runCommand(commandConfig.command, {
|
191
|
-
cwd,
|
192
|
-
jsEnv: env,
|
193
|
-
quiet: !streamOutput,
|
194
|
-
tty,
|
195
|
-
});
|
196
|
-
childProcesses.add(cp);
|
197
|
-
return new Promise((res) => {
|
198
|
-
cp.onOutput((output) => {
|
199
|
-
terminalOutput += output;
|
200
|
-
});
|
201
|
-
cp.onExit((code) => {
|
202
|
-
if (code >= 128) {
|
203
|
-
process.exit(code);
|
204
|
-
}
|
205
|
-
else {
|
206
|
-
res({ success: code === 0, terminalOutput });
|
207
|
-
}
|
208
|
-
});
|
209
|
-
});
|
210
|
-
}
|
211
|
-
return nodeProcess(commandConfig, cwd, env, readyWhenStatus, streamOutput);
|
212
|
-
}
|
213
|
-
function nodeProcess(commandConfig, cwd, env, readyWhenStatus, streamOutput = true) {
|
214
|
-
let terminalOutput = chalk.dim('> ') + commandConfig.command + '\r\n\r\n';
|
215
|
-
if (streamOutput) {
|
216
|
-
process.stdout.write(terminalOutput);
|
217
|
-
}
|
218
|
-
return new Promise((res) => {
|
219
|
-
const childProcess = (0, child_process_1.exec)(commandConfig.command, {
|
220
|
-
maxBuffer: exports.LARGE_BUFFER,
|
221
|
-
env,
|
222
|
-
cwd,
|
223
|
-
windowsHide: false,
|
224
|
-
});
|
225
|
-
childProcesses.add(childProcess);
|
226
|
-
childProcess.stdout.on('data', (data) => {
|
227
|
-
const output = addColorAndPrefix(data, commandConfig);
|
228
|
-
terminalOutput += output;
|
229
|
-
if (streamOutput) {
|
230
|
-
process.stdout.write(output);
|
231
|
-
}
|
232
|
-
if (readyWhenStatus.length && isReady(readyWhenStatus, data.toString())) {
|
233
|
-
res({ success: true, terminalOutput });
|
234
|
-
}
|
235
|
-
});
|
236
|
-
childProcess.stderr.on('data', (err) => {
|
237
|
-
const output = addColorAndPrefix(err, commandConfig);
|
238
|
-
terminalOutput += output;
|
239
|
-
if (streamOutput) {
|
240
|
-
process.stderr.write(output);
|
241
|
-
}
|
242
|
-
if (readyWhenStatus.length && isReady(readyWhenStatus, err.toString())) {
|
243
|
-
res({ success: true, terminalOutput });
|
244
|
-
}
|
245
|
-
});
|
246
|
-
childProcess.on('error', (err) => {
|
247
|
-
const ouptput = addColorAndPrefix(err.toString(), commandConfig);
|
248
|
-
terminalOutput += ouptput;
|
249
|
-
if (streamOutput) {
|
250
|
-
process.stderr.write(ouptput);
|
251
|
-
}
|
252
|
-
res({ success: false, terminalOutput });
|
253
|
-
});
|
254
|
-
childProcess.on('exit', (code) => {
|
255
|
-
childProcesses.delete(childProcess);
|
256
|
-
if (!readyWhenStatus.length || isReady(readyWhenStatus)) {
|
257
|
-
res({ success: code === 0, terminalOutput });
|
258
|
-
}
|
259
|
-
});
|
260
|
-
});
|
261
|
-
}
|
262
|
-
function addColorAndPrefix(out, config) {
|
263
|
-
if (config.prefix) {
|
264
|
-
out = out
|
265
|
-
.split('\n')
|
266
|
-
.map((l) => {
|
267
|
-
let prefixText = config.prefix;
|
268
|
-
if (config.prefixColor && chalk[config.prefixColor]) {
|
269
|
-
prefixText = chalk[config.prefixColor](prefixText);
|
270
|
-
}
|
271
|
-
prefixText = chalk.bold(prefixText);
|
272
|
-
return l.trim().length > 0 ? `${prefixText} ${l}` : l;
|
273
|
-
})
|
274
|
-
.join('\n');
|
275
|
-
}
|
276
|
-
if (config.color && chalk[config.color]) {
|
277
|
-
out = chalk[config.color](out);
|
278
|
-
}
|
279
|
-
if (config.bgColor && chalk[config.bgColor]) {
|
280
|
-
out = chalk[config.bgColor](out);
|
281
|
-
}
|
282
|
-
return out;
|
283
|
-
}
|
284
|
-
function calculateCwd(cwd, context) {
|
285
|
-
if (!cwd)
|
286
|
-
return context.root;
|
287
|
-
if (path.isAbsolute(cwd))
|
288
|
-
return cwd;
|
289
|
-
return path.join(context.root, cwd);
|
290
|
-
}
|
291
|
-
/**
|
292
|
-
* Env variables are processed in the following order:
|
293
|
-
* - env option from executor options
|
294
|
-
* - env file from envFile option if provided
|
295
|
-
* - local env variables
|
296
|
-
*/
|
297
|
-
function processEnv(color, cwd, envOptionFromExecutor, envFile) {
|
298
|
-
let localEnv = (0, npm_run_path_1.env)({ cwd: cwd ?? process.cwd() });
|
299
|
-
localEnv = {
|
300
|
-
...process.env,
|
301
|
-
...localEnv,
|
302
|
-
};
|
303
|
-
if (process.env.NX_LOAD_DOT_ENV_FILES !== 'false' && envFile) {
|
304
|
-
loadEnvVarsFile(envFile, localEnv);
|
305
|
-
}
|
306
|
-
let res = {
|
307
|
-
...localEnv,
|
308
|
-
...envOptionFromExecutor,
|
309
|
-
};
|
310
|
-
// need to override PATH to make sure we are using the local node_modules
|
311
|
-
if (localEnv.PATH)
|
312
|
-
res.PATH = localEnv.PATH; // UNIX-like
|
313
|
-
if (localEnv.Path)
|
314
|
-
res.Path = localEnv.Path; // Windows
|
315
|
-
if (color) {
|
316
|
-
res.FORCE_COLOR = `${color}`;
|
317
|
-
}
|
318
|
-
return res;
|
319
|
-
}
|
320
118
|
function interpolateArgsIntoCommand(command, opts, forwardAllArgs) {
|
321
119
|
if (command.indexOf('{args.') > -1) {
|
322
120
|
const regex = /{args\.([^}]+)}/g;
|
@@ -403,60 +201,6 @@ function filterPropKeysFromUnParsedOptions(__unparsed__, parseArgs = {}) {
|
|
403
201
|
}
|
404
202
|
return parsedOptions;
|
405
203
|
}
|
406
|
-
let registered = false;
|
407
|
-
function registerProcessListener() {
|
408
|
-
if (registered) {
|
409
|
-
return;
|
410
|
-
}
|
411
|
-
registered = true;
|
412
|
-
// When the nx process gets a message, it will be sent into the task's process
|
413
|
-
process.on('message', (message) => {
|
414
|
-
// this.publisher.publish(message.toString());
|
415
|
-
if (pseudoTerminal) {
|
416
|
-
pseudoTerminal.sendMessageToChildren(message);
|
417
|
-
}
|
418
|
-
childProcesses.forEach((p) => {
|
419
|
-
if ('connected' in p && p.connected) {
|
420
|
-
p.send(message);
|
421
|
-
}
|
422
|
-
});
|
423
|
-
});
|
424
|
-
// Terminate any task processes on exit
|
425
|
-
process.on('exit', () => {
|
426
|
-
childProcesses.forEach((p) => {
|
427
|
-
if ('connected' in p ? p.connected : p.isAlive) {
|
428
|
-
p.kill();
|
429
|
-
}
|
430
|
-
});
|
431
|
-
});
|
432
|
-
process.on('SIGINT', () => {
|
433
|
-
childProcesses.forEach((p) => {
|
434
|
-
if ('connected' in p ? p.connected : p.isAlive) {
|
435
|
-
p.kill('SIGTERM');
|
436
|
-
}
|
437
|
-
});
|
438
|
-
// we exit here because we don't need to write anything to cache.
|
439
|
-
process.exit((0, exit_codes_1.signalToCode)('SIGINT'));
|
440
|
-
});
|
441
|
-
process.on('SIGTERM', () => {
|
442
|
-
childProcesses.forEach((p) => {
|
443
|
-
if ('connected' in p ? p.connected : p.isAlive) {
|
444
|
-
p.kill('SIGTERM');
|
445
|
-
}
|
446
|
-
});
|
447
|
-
// no exit here because we expect child processes to terminate which
|
448
|
-
// will store results to the cache and will terminate this process
|
449
|
-
});
|
450
|
-
process.on('SIGHUP', () => {
|
451
|
-
childProcesses.forEach((p) => {
|
452
|
-
if ('connected' in p ? p.connected : p.isAlive) {
|
453
|
-
p.kill('SIGTERM');
|
454
|
-
}
|
455
|
-
});
|
456
|
-
// no exit here because we expect child processes to terminate which
|
457
|
-
// will store results to the cache and will terminate this process
|
458
|
-
});
|
459
|
-
}
|
460
204
|
function wrapArgIntoQuotesIfNeeded(arg) {
|
461
205
|
if (arg.includes('=')) {
|
462
206
|
const [key, value] = arg.split('=');
|
@@ -474,14 +218,3 @@ function wrapArgIntoQuotesIfNeeded(arg) {
|
|
474
218
|
return arg;
|
475
219
|
}
|
476
220
|
}
|
477
|
-
function isReady(readyWhenStatus = [], data) {
|
478
|
-
if (data) {
|
479
|
-
for (const readyWhenElement of readyWhenStatus) {
|
480
|
-
if (data.toString().indexOf(readyWhenElement.stringToMatch) > -1) {
|
481
|
-
readyWhenElement.found = true;
|
482
|
-
break;
|
483
|
-
}
|
484
|
-
}
|
485
|
-
}
|
486
|
-
return readyWhenStatus.every((readyWhenElement) => readyWhenElement.found);
|
487
|
-
}
|
@@ -0,0 +1,40 @@
|
|
1
|
+
import { Serializable } from 'child_process';
|
2
|
+
import { ExecutorContext } from '../../config/misc-interfaces';
|
3
|
+
import { PseudoTtyProcess } from '../../tasks-runner/pseudo-terminal';
|
4
|
+
import { RunningTask } from '../../tasks-runner/running-tasks/running-task';
|
5
|
+
import { NormalizedRunCommandsOptions } from './run-commands.impl';
|
6
|
+
export declare class ParallelRunningTasks implements RunningTask {
|
7
|
+
private readonly tuiEnabled;
|
8
|
+
private readonly childProcesses;
|
9
|
+
private readyWhenStatus;
|
10
|
+
private readonly streamOutput;
|
11
|
+
private exitCallbacks;
|
12
|
+
constructor(options: NormalizedRunCommandsOptions, context: ExecutorContext, tuiEnabled: boolean);
|
13
|
+
getResults(): Promise<{
|
14
|
+
code: number;
|
15
|
+
terminalOutput: string;
|
16
|
+
}>;
|
17
|
+
onExit(cb: (code: number, terminalOutput: string) => void): void;
|
18
|
+
send(message: Serializable): void;
|
19
|
+
kill(signal?: NodeJS.Signals | number): Promise<void>;
|
20
|
+
private run;
|
21
|
+
}
|
22
|
+
export declare class SeriallyRunningTasks implements RunningTask {
|
23
|
+
private readonly tuiEnabled;
|
24
|
+
private terminalOutput;
|
25
|
+
private currentProcess;
|
26
|
+
private exitCallbacks;
|
27
|
+
private code;
|
28
|
+
private error;
|
29
|
+
constructor(options: NormalizedRunCommandsOptions, context: ExecutorContext, tuiEnabled: boolean);
|
30
|
+
getResults(): Promise<{
|
31
|
+
code: number;
|
32
|
+
terminalOutput: string;
|
33
|
+
}>;
|
34
|
+
onExit(cb: (code: number, terminalOutput: string) => void): void;
|
35
|
+
send(message: Serializable): void;
|
36
|
+
kill(signal?: NodeJS.Signals | number): void | Promise<void>;
|
37
|
+
private run;
|
38
|
+
private createProcess;
|
39
|
+
}
|
40
|
+
export declare function runSingleCommandWithPseudoTerminal(normalized: NormalizedRunCommandsOptions, context: ExecutorContext): Promise<PseudoTtyProcess>;
|