nx 21.0.1 → 21.0.2

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nx",
3
- "version": "21.0.1",
3
+ "version": "21.0.2",
4
4
  "private": false,
5
5
  "description": "The core Nx plugin contains the core functionality of Nx like the project graph, nx commands and task orchestration.",
6
6
  "repository": {
@@ -83,16 +83,16 @@
83
83
  }
84
84
  },
85
85
  "optionalDependencies": {
86
- "@nx/nx-darwin-arm64": "21.0.1",
87
- "@nx/nx-darwin-x64": "21.0.1",
88
- "@nx/nx-freebsd-x64": "21.0.1",
89
- "@nx/nx-linux-arm-gnueabihf": "21.0.1",
90
- "@nx/nx-linux-arm64-gnu": "21.0.1",
91
- "@nx/nx-linux-arm64-musl": "21.0.1",
92
- "@nx/nx-linux-x64-gnu": "21.0.1",
93
- "@nx/nx-linux-x64-musl": "21.0.1",
94
- "@nx/nx-win32-arm64-msvc": "21.0.1",
95
- "@nx/nx-win32-x64-msvc": "21.0.1"
86
+ "@nx/nx-darwin-arm64": "21.0.2",
87
+ "@nx/nx-darwin-x64": "21.0.2",
88
+ "@nx/nx-freebsd-x64": "21.0.2",
89
+ "@nx/nx-linux-arm-gnueabihf": "21.0.2",
90
+ "@nx/nx-linux-arm64-gnu": "21.0.2",
91
+ "@nx/nx-linux-arm64-musl": "21.0.2",
92
+ "@nx/nx-linux-x64-gnu": "21.0.2",
93
+ "@nx/nx-linux-x64-musl": "21.0.2",
94
+ "@nx/nx-win32-arm64-msvc": "21.0.2",
95
+ "@nx/nx-win32-x64-msvc": "21.0.2"
96
96
  },
97
97
  "nx-migrations": {
98
98
  "migrations": "./migrations.json",
@@ -5,6 +5,7 @@ const child_process_1 = require("child_process");
5
5
  const path = require("path");
6
6
  const pseudo_terminal_1 = require("../../tasks-runner/pseudo-terminal");
7
7
  const package_manager_1 = require("../../utils/package-manager");
8
+ const exit_codes_1 = require("../../utils/exit-codes");
8
9
  async function default_1(options, context) {
9
10
  const pm = (0, package_manager_1.getPackageManagerCommand)();
10
11
  try {
@@ -38,11 +39,12 @@ function nodeProcess(command, cwd, env) {
38
39
  windowsHide: false,
39
40
  });
40
41
  }
42
+ let cp;
41
43
  async function ptyProcess(command, cwd, env) {
42
44
  const terminal = (0, pseudo_terminal_1.createPseudoTerminal)();
43
45
  await terminal.init();
44
46
  return new Promise((res, rej) => {
45
- const cp = terminal.runCommand(command, { cwd, jsEnv: env });
47
+ cp = terminal.runCommand(command, { cwd, jsEnv: env });
46
48
  cp.onExit((code) => {
47
49
  if (code === 0) {
48
50
  res();
@@ -56,3 +58,16 @@ async function ptyProcess(command, cwd, env) {
56
58
  });
57
59
  });
58
60
  }
61
+ // TODO: This only works because pseudo terminal registers signal handlers first but we need a service to handle this
62
+ process.on('SIGHUP', () => {
63
+ cp.kill('SIGHUP');
64
+ process.exit((0, exit_codes_1.signalToCode)('SIGHUP'));
65
+ });
66
+ process.on('SIGTERM', () => {
67
+ cp.kill('SIGTERM');
68
+ process.exit((0, exit_codes_1.signalToCode)('SIGTERM'));
69
+ });
70
+ process.on('SIGINT', () => {
71
+ cp.kill('SIGINT');
72
+ process.exit((0, exit_codes_1.signalToCode)('SIGINT'));
73
+ });
@@ -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
@@ -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);
@@ -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 taskIdsInOrderOfCompletion = [];
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.printTaskTerminalOutput = (task, taskStatus, terminalOutput) => {
36
- taskIdsInOrderOfCompletion.push(task.id);
37
- tasksToTerminalOutputs[task.id] = { terminalOutput, taskStatus };
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 taskIdsInOrderOfCompletion) {
107
- const { terminalOutput, taskStatus } = tasksToTerminalOutputs[taskId];
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 taskIdsInOrderOfCompletion) {
161
- const { terminalOutput, taskStatus } = tasksToTerminalOutputs[taskId];
162
- if (taskStatus === 'failure') {
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}`);
@@ -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
  }