nx 21.1.0-canary.20250507-30a7709 → 21.1.0-canary.20250509-8c50b7f
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/bin/nx.js +1 -20
- package/package.json +11 -11
- package/src/command-line/affected/command-object.js +1 -1
- package/src/core/graph/main.js +1 -1
- package/src/core/graph/styles.js +1 -1
- package/src/executors/run-commands/running-tasks.js +1 -1
- package/src/executors/run-script/run-script.impl.js +2 -1
- package/src/native/index.d.ts +1 -1
- package/src/native/nx.wasm32-wasi.wasm +0 -0
- package/src/plugins/js/project-graph/build-dependencies/target-project-locator.js +1 -1
- package/src/tasks-runner/forked-process-task-runner.d.ts +1 -0
- package/src/tasks-runner/forked-process-task-runner.js +15 -12
- package/src/tasks-runner/life-cycle.d.ts +2 -2
- package/src/tasks-runner/life-cycle.js +2 -2
- package/src/tasks-runner/life-cycles/tui-summary-life-cycle.js +23 -9
- package/src/tasks-runner/pseudo-terminal.d.ts +1 -1
- package/src/tasks-runner/pseudo-terminal.js +5 -13
- package/src/tasks-runner/task-orchestrator.js +9 -2
- package/src/utils/exit-codes.d.ts +4 -0
- package/src/utils/exit-codes.js +16 -0
package/src/core/graph/styles.js
CHANGED
@@ -1 +1 @@
|
|
1
|
-
"use strict";(self.webpackChunk=self.webpackChunk||[]).push([[869],{
|
1
|
+
"use strict";(self.webpackChunk=self.webpackChunk||[]).push([[869],{4941:()=>{}},s=>{var e;e=4941,s(s.s=e)}]);
|
@@ -231,7 +231,7 @@ class RunningNodeProcess {
|
|
231
231
|
}
|
232
232
|
kill(signal) {
|
233
233
|
return new Promise((res, rej) => {
|
234
|
-
if (process.platform === 'win32'
|
234
|
+
if (process.platform === 'win32') {
|
235
235
|
if (this.childProcess.kill(signal)) {
|
236
236
|
res();
|
237
237
|
}
|
@@ -38,11 +38,12 @@ function nodeProcess(command, cwd, env) {
|
|
38
38
|
windowsHide: false,
|
39
39
|
});
|
40
40
|
}
|
41
|
+
let cp;
|
41
42
|
async function ptyProcess(command, cwd, env) {
|
42
43
|
const terminal = (0, pseudo_terminal_1.createPseudoTerminal)();
|
43
44
|
await terminal.init();
|
44
45
|
return new Promise((res, rej) => {
|
45
|
-
|
46
|
+
cp = terminal.runCommand(command, { cwd, jsEnv: env });
|
46
47
|
cp.onExit((code) => {
|
47
48
|
if (code === 0) {
|
48
49
|
res();
|
package/src/native/index.d.ts
CHANGED
@@ -18,7 +18,7 @@ export declare class AppLifeCycle {
|
|
18
18
|
__init(doneCallback: () => any): void
|
19
19
|
registerRunningTask(taskId: string, parserAndWriter: ExternalObject<[ParserArc, WriterArc]>): void
|
20
20
|
registerRunningTaskWithEmptyParser(taskId: string): void
|
21
|
-
appendTaskOutput(taskId: string, output: string): void
|
21
|
+
appendTaskOutput(taskId: string, output: string, isPtyOutput: boolean): void
|
22
22
|
setTaskStatus(taskId: string, status: TaskStatus): void
|
23
23
|
registerForcedShutdownCallback(forcedShutdownCallback: () => any): void
|
24
24
|
__setCloudMessage(message: string): Promise<void>
|
Binary file
|
@@ -273,7 +273,7 @@ class TargetProjectLocator {
|
|
273
273
|
return;
|
274
274
|
}
|
275
275
|
resolveImportWithRequire(normalizedImportExpr, filePath) {
|
276
|
-
return node_path_1.
|
276
|
+
return (0, node_path_1.relative)(workspace_root_1.workspaceRoot, require.resolve(normalizedImportExpr, {
|
277
277
|
paths: [(0, node_path_1.dirname)(filePath)],
|
278
278
|
}));
|
279
279
|
}
|
@@ -136,7 +136,7 @@ class ForkedProcessTaskRunner {
|
|
136
136
|
terminalOutput += msg;
|
137
137
|
});
|
138
138
|
p.onExit((code) => {
|
139
|
-
if (code > 128) {
|
139
|
+
if (!this.tuiEnabled && code > 128) {
|
140
140
|
process.exit(code);
|
141
141
|
}
|
142
142
|
this.pseudoTerminals.delete(pseudoTerminal);
|
@@ -233,6 +233,12 @@ class ForkedProcessTaskRunner {
|
|
233
233
|
writeTerminalOutput(outputPath, content) {
|
234
234
|
(0, fs_1.writeFileSync)(outputPath, content);
|
235
235
|
}
|
236
|
+
cleanup(signal) {
|
237
|
+
this.processes.forEach((p) => {
|
238
|
+
p.kill(signal);
|
239
|
+
});
|
240
|
+
this.cleanUpBatchProcesses();
|
241
|
+
}
|
236
242
|
setupProcessEventListeners() {
|
237
243
|
const messageHandler = (message) => {
|
238
244
|
this.pseudoTerminals.forEach((p) => {
|
@@ -246,29 +252,26 @@ class ForkedProcessTaskRunner {
|
|
246
252
|
};
|
247
253
|
// When the nx process gets a message, it will be sent into the task's process
|
248
254
|
process.on('message', messageHandler);
|
249
|
-
const cleanUp = (signal) => {
|
250
|
-
this.processes.forEach((p) => {
|
251
|
-
p.kill(signal);
|
252
|
-
});
|
253
|
-
process.off('message', messageHandler);
|
254
|
-
this.cleanUpBatchProcesses();
|
255
|
-
};
|
256
255
|
// Terminate any task processes on exit
|
257
256
|
process.once('exit', () => {
|
258
|
-
|
257
|
+
this.cleanup();
|
258
|
+
process.off('message', messageHandler);
|
259
259
|
});
|
260
260
|
process.once('SIGINT', () => {
|
261
|
-
|
261
|
+
this.cleanup('SIGTERM');
|
262
|
+
process.off('message', messageHandler);
|
262
263
|
// we exit here because we don't need to write anything to cache.
|
263
264
|
process.exit((0, exit_codes_1.signalToCode)('SIGINT'));
|
264
265
|
});
|
265
266
|
process.once('SIGTERM', () => {
|
266
|
-
|
267
|
+
this.cleanup('SIGTERM');
|
268
|
+
process.off('message', messageHandler);
|
267
269
|
// no exit here because we expect child processes to terminate which
|
268
270
|
// will store results to the cache and will terminate this process
|
269
271
|
});
|
270
272
|
process.once('SIGHUP', () => {
|
271
|
-
|
273
|
+
this.cleanup('SIGTERM');
|
274
|
+
process.off('message', messageHandler);
|
272
275
|
// no exit here because we expect child processes to terminate which
|
273
276
|
// will store results to the cache and will terminate this process
|
274
277
|
});
|
@@ -38,7 +38,7 @@ export interface LifeCycle {
|
|
38
38
|
printTaskTerminalOutput?(task: Task, status: TaskStatus, output: string): void;
|
39
39
|
registerRunningTask?(taskId: string, parserAndWriter: ExternalObject<[any, any]>): void;
|
40
40
|
registerRunningTaskWithEmptyParser?(taskId: string): void;
|
41
|
-
appendTaskOutput?(taskId: string, output: string): void;
|
41
|
+
appendTaskOutput?(taskId: string, output: string, isPtyTask: boolean): void;
|
42
42
|
setTaskStatus?(taskId: string, status: NativeTaskStatus): void;
|
43
43
|
registerForcedShutdownCallback?(callback: () => void): void;
|
44
44
|
}
|
@@ -55,7 +55,7 @@ export declare class CompositeLifeCycle implements LifeCycle {
|
|
55
55
|
printTaskTerminalOutput(task: Task, status: TaskStatus, output: string): void;
|
56
56
|
registerRunningTask(taskId: string, parserAndWriter: ExternalObject<[any, any]>): void;
|
57
57
|
registerRunningTaskWithEmptyParser(taskId: string): void;
|
58
|
-
appendTaskOutput(taskId: string, output: string): void;
|
58
|
+
appendTaskOutput(taskId: string, output: string, isPtyTask: boolean): void;
|
59
59
|
setTaskStatus(taskId: string, status: NativeTaskStatus): void;
|
60
60
|
registerForcedShutdownCallback(callback: () => void): void;
|
61
61
|
}
|
@@ -81,10 +81,10 @@ class CompositeLifeCycle {
|
|
81
81
|
}
|
82
82
|
}
|
83
83
|
}
|
84
|
-
appendTaskOutput(taskId, output) {
|
84
|
+
appendTaskOutput(taskId, output, isPtyTask) {
|
85
85
|
for (let l of this.lifeCycles) {
|
86
86
|
if (l.appendTaskOutput) {
|
87
|
-
l.appendTaskOutput(taskId, output);
|
87
|
+
l.appendTaskOutput(taskId, output, isPtyTask);
|
88
88
|
}
|
89
89
|
}
|
90
90
|
}
|
@@ -26,15 +26,21 @@ function getTuiTerminalSummaryLifeCycle({ projectNames, tasks, taskGraph, args,
|
|
26
26
|
const inProgressTasks = new Set();
|
27
27
|
const stoppedTasks = new Set();
|
28
28
|
const tasksToTerminalOutputs = {};
|
29
|
-
const
|
29
|
+
const tasksToTaskStatus = {};
|
30
|
+
const taskIdsInTheOrderTheyStart = [];
|
30
31
|
lifeCycle.startTasks = (tasks) => {
|
31
32
|
for (let t of tasks) {
|
33
|
+
tasksToTerminalOutputs[t.id] ??= '';
|
34
|
+
taskIdsInTheOrderTheyStart.push(t.id);
|
32
35
|
inProgressTasks.add(t.id);
|
33
36
|
}
|
34
37
|
};
|
35
|
-
lifeCycle.
|
36
|
-
|
37
|
-
|
38
|
+
lifeCycle.appendTaskOutput = (taskId, output) => {
|
39
|
+
tasksToTerminalOutputs[taskId] += output;
|
40
|
+
};
|
41
|
+
// TODO(@AgentEnder): The following 2 methods should be one but will need more refactoring
|
42
|
+
lifeCycle.printTaskTerminalOutput = (task, taskStatus) => {
|
43
|
+
tasksToTaskStatus[task.id] = taskStatus;
|
38
44
|
};
|
39
45
|
lifeCycle.setTaskStatus = (taskId, taskStatus) => {
|
40
46
|
if (taskStatus === 9 /* NativeTaskStatus.Stopped */) {
|
@@ -103,8 +109,9 @@ function getTuiTerminalSummaryLifeCycle({ projectNames, tasks, taskGraph, args,
|
|
103
109
|
let lines = [];
|
104
110
|
// Prints task outputs in the order they were completed
|
105
111
|
// above the summary, since run-one should print all task results.
|
106
|
-
for (const taskId of
|
107
|
-
const
|
112
|
+
for (const taskId of taskIdsInTheOrderTheyStart) {
|
113
|
+
const taskStatus = tasksToTaskStatus[taskId];
|
114
|
+
const terminalOutput = tasksToTerminalOutputs[taskId];
|
108
115
|
output_1.output.logCommandOutput(taskId, taskStatus, terminalOutput);
|
109
116
|
}
|
110
117
|
lines.push(...output_1.output.getVerticalSeparatorLines(failure ? 'red' : 'green'));
|
@@ -157,9 +164,16 @@ function getTuiTerminalSummaryLifeCycle({ projectNames, tasks, taskGraph, args,
|
|
157
164
|
const printRunManySummary = ({ failure, cancelled, }) => {
|
158
165
|
console.log('');
|
159
166
|
const lines = [''];
|
160
|
-
for (const taskId of
|
161
|
-
const
|
162
|
-
|
167
|
+
for (const taskId of taskIdsInTheOrderTheyStart) {
|
168
|
+
const taskStatus = tasksToTaskStatus[taskId];
|
169
|
+
const terminalOutput = tasksToTerminalOutputs[taskId];
|
170
|
+
// Task Status is null?
|
171
|
+
if (!taskStatus) {
|
172
|
+
output_1.output.logCommandOutput(taskId, taskStatus, terminalOutput);
|
173
|
+
output_1.output.addNewline();
|
174
|
+
lines.push(`${LEFT_PAD}${output_1.output.colors.cyan(figures.squareSmallFilled)}${SPACER}${output_1.output.colors.gray('nx run ')}${taskId}`);
|
175
|
+
}
|
176
|
+
else if (taskStatus === 'failure') {
|
163
177
|
output_1.output.logCommandOutput(taskId, taskStatus, terminalOutput);
|
164
178
|
output_1.output.addNewline();
|
165
179
|
lines.push(`${LEFT_PAD}${output_1.output.colors.red(figures.cross)}${SPACER}${output_1.output.colors.gray('nx run ')}${taskId}`);
|
@@ -12,7 +12,7 @@ export declare class PseudoTerminal {
|
|
12
12
|
static isSupported(): boolean;
|
13
13
|
constructor(rustPseudoTerminal: RustPseudoTerminal);
|
14
14
|
init(): Promise<void>;
|
15
|
-
shutdown(
|
15
|
+
shutdown(code: number): void;
|
16
16
|
runCommand(command: string, { cwd, execArgv, jsEnv, quiet, tty, }?: {
|
17
17
|
cwd?: string;
|
18
18
|
execArgv?: string[];
|
@@ -6,19 +6,11 @@ const os = require("os");
|
|
6
6
|
const socket_utils_1 = require("../daemon/socket-utils");
|
7
7
|
const native_1 = require("../native");
|
8
8
|
const pseudo_ipc_1 = require("./pseudo-ipc");
|
9
|
+
const exit_codes_1 = require("../utils/exit-codes");
|
9
10
|
// Register single event listeners for all pseudo-terminal instances
|
10
11
|
const pseudoTerminalShutdownCallbacks = [];
|
11
|
-
process.on('
|
12
|
-
pseudoTerminalShutdownCallbacks.forEach((cb) => cb(
|
13
|
-
});
|
14
|
-
process.on('SIGTERM', () => {
|
15
|
-
pseudoTerminalShutdownCallbacks.forEach((cb) => cb('SIGTERM'));
|
16
|
-
});
|
17
|
-
process.on('SIGHUP', () => {
|
18
|
-
pseudoTerminalShutdownCallbacks.forEach((cb) => cb('SIGHUP'));
|
19
|
-
});
|
20
|
-
process.on('exit', () => {
|
21
|
-
pseudoTerminalShutdownCallbacks.forEach((cb) => cb());
|
12
|
+
process.on('exit', (code) => {
|
13
|
+
pseudoTerminalShutdownCallbacks.forEach((cb) => cb(code));
|
22
14
|
});
|
23
15
|
function createPseudoTerminal(skipSupportCheck = false) {
|
24
16
|
if (!skipSupportCheck && !PseudoTerminal.isSupported()) {
|
@@ -47,10 +39,10 @@ class PseudoTerminal {
|
|
47
39
|
await this.pseudoIPC.init();
|
48
40
|
this.initialized = true;
|
49
41
|
}
|
50
|
-
shutdown(
|
42
|
+
shutdown(code) {
|
51
43
|
for (const cp of this.childProcesses) {
|
52
44
|
try {
|
53
|
-
cp.kill(
|
45
|
+
cp.kill((0, exit_codes_1.codeToSignal)(code));
|
54
46
|
}
|
55
47
|
catch { }
|
56
48
|
}
|
@@ -333,11 +333,14 @@ class TaskOrchestrator {
|
|
333
333
|
if (runningTask instanceof pseudo_terminal_1.PseudoTtyProcess) {
|
334
334
|
// This is an external of a the pseudo terminal where a task is running and can be passed to the TUI
|
335
335
|
this.options.lifeCycle.registerRunningTask(task.id, runningTask.getParserAndWriter());
|
336
|
+
runningTask.onOutput((output) => {
|
337
|
+
this.options.lifeCycle.appendTaskOutput(task.id, output, true);
|
338
|
+
});
|
336
339
|
}
|
337
340
|
else {
|
338
341
|
this.options.lifeCycle.registerRunningTaskWithEmptyParser(task.id);
|
339
342
|
runningTask.onOutput((output) => {
|
340
|
-
this.options.lifeCycle.appendTaskOutput(task.id, output);
|
343
|
+
this.options.lifeCycle.appendTaskOutput(task.id, output, false);
|
341
344
|
});
|
342
345
|
}
|
343
346
|
}
|
@@ -391,11 +394,14 @@ class TaskOrchestrator {
|
|
391
394
|
if (runningTask instanceof pseudo_terminal_1.PseudoTtyProcess) {
|
392
395
|
// This is an external of a the pseudo terminal where a task is running and can be passed to the TUI
|
393
396
|
this.options.lifeCycle.registerRunningTask(task.id, runningTask.getParserAndWriter());
|
397
|
+
runningTask.onOutput((output) => {
|
398
|
+
this.options.lifeCycle.appendTaskOutput(task.id, output, true);
|
399
|
+
});
|
394
400
|
}
|
395
401
|
else if ('onOutput' in runningTask) {
|
396
402
|
this.options.lifeCycle.registerRunningTaskWithEmptyParser(task.id);
|
397
403
|
runningTask.onOutput((output) => {
|
398
|
-
this.options.lifeCycle.appendTaskOutput(task.id, output);
|
404
|
+
this.options.lifeCycle.appendTaskOutput(task.id, output, false);
|
399
405
|
});
|
400
406
|
}
|
401
407
|
}
|
@@ -645,6 +651,7 @@ class TaskOrchestrator {
|
|
645
651
|
}
|
646
652
|
// endregion utils
|
647
653
|
async cleanup() {
|
654
|
+
this.forkedProcessTaskRunner.cleanup();
|
648
655
|
await Promise.all([
|
649
656
|
...Array.from(this.runningContinuousTasks).map(async ([taskId, t]) => {
|
650
657
|
try {
|
package/src/utils/exit-codes.js
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
3
|
exports.signalToCode = signalToCode;
|
4
|
+
exports.codeToSignal = codeToSignal;
|
4
5
|
/**
|
5
6
|
* Translates NodeJS signals to numeric exit code
|
6
7
|
* @param signal
|
@@ -17,3 +18,18 @@ function signalToCode(signal) {
|
|
17
18
|
return 128;
|
18
19
|
}
|
19
20
|
}
|
21
|
+
/**
|
22
|
+
* Translates numeric exit codes to NodeJS signals
|
23
|
+
*/
|
24
|
+
function codeToSignal(code) {
|
25
|
+
switch (code) {
|
26
|
+
case 128 + 1:
|
27
|
+
return 'SIGHUP';
|
28
|
+
case 128 + 2:
|
29
|
+
return 'SIGINT';
|
30
|
+
case 128 + 15:
|
31
|
+
return 'SIGTERM';
|
32
|
+
default:
|
33
|
+
return 'SIGTERM';
|
34
|
+
}
|
35
|
+
}
|