nx 18.1.0-canary.20240315-3b8cbae → 18.1.1

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.
@@ -0,0 +1,133 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.PseudoTtyProcessWithSend = exports.PseudoTtyProcess = exports.PseudoTerminal = exports.getPseudoTerminal = void 0;
4
+ const native_1 = require("../native");
5
+ const pseudo_ipc_1 = require("./pseudo-ipc");
6
+ const socket_utils_1 = require("../daemon/socket-utils");
7
+ let pseudoTerminal;
8
+ function getPseudoTerminal() {
9
+ pseudoTerminal ??= new PseudoTerminal(new native_1.RustPseudoTerminal());
10
+ return pseudoTerminal;
11
+ }
12
+ exports.getPseudoTerminal = getPseudoTerminal;
13
+ class PseudoTerminal {
14
+ constructor(rustPseudoTerminal) {
15
+ this.rustPseudoTerminal = rustPseudoTerminal;
16
+ this.pseudoIPCPath = (0, socket_utils_1.FORKED_PROCESS_OS_SOCKET_PATH)(process.pid.toString());
17
+ this.pseudoIPC = new pseudo_ipc_1.PseudoIPCServer(this.pseudoIPCPath);
18
+ this.initialized = false;
19
+ this.setupProcessListeners();
20
+ }
21
+ async init() {
22
+ if (this.initialized) {
23
+ return;
24
+ }
25
+ await this.pseudoIPC.init();
26
+ this.initialized = true;
27
+ }
28
+ runCommand(command, { cwd, jsEnv, quiet, } = {}) {
29
+ return new PseudoTtyProcess(this.rustPseudoTerminal.runCommand(command, cwd, jsEnv, quiet));
30
+ }
31
+ async fork(id, script, { cwd, jsEnv, quiet, }) {
32
+ if (!this.initialized) {
33
+ throw new Error('Call init() before forking processes');
34
+ }
35
+ const cp = new PseudoTtyProcessWithSend(this.rustPseudoTerminal.fork(id, script, this.pseudoIPCPath, cwd, jsEnv, quiet), id, this.pseudoIPC);
36
+ await this.pseudoIPC.waitForChildReady(id);
37
+ return cp;
38
+ }
39
+ sendMessageToChildren(message) {
40
+ this.pseudoIPC.sendMessageToChildren(message);
41
+ }
42
+ onMessageFromChildren(callback) {
43
+ this.pseudoIPC.onMessageFromChildren(callback);
44
+ }
45
+ setupProcessListeners() {
46
+ const shutdown = () => {
47
+ this.shutdownPseudoIPC();
48
+ };
49
+ process.on('SIGINT', () => {
50
+ this.shutdownPseudoIPC();
51
+ });
52
+ process.on('SIGTERM', () => {
53
+ this.shutdownPseudoIPC();
54
+ });
55
+ process.on('SIGHUP', () => {
56
+ this.shutdownPseudoIPC();
57
+ });
58
+ process.on('exit', () => {
59
+ this.shutdownPseudoIPC();
60
+ });
61
+ }
62
+ shutdownPseudoIPC() {
63
+ if (this.initialized) {
64
+ this.pseudoIPC.close();
65
+ }
66
+ }
67
+ }
68
+ exports.PseudoTerminal = PseudoTerminal;
69
+ class PseudoTtyProcess {
70
+ constructor(childProcess) {
71
+ this.childProcess = childProcess;
72
+ this.isAlive = true;
73
+ this.exitCallbacks = [];
74
+ childProcess.onExit((message) => {
75
+ this.isAlive = false;
76
+ const exitCode = messageToCode(message);
77
+ this.exitCallbacks.forEach((cb) => cb(exitCode));
78
+ });
79
+ }
80
+ onExit(callback) {
81
+ this.exitCallbacks.push(callback);
82
+ }
83
+ onOutput(callback) {
84
+ this.childProcess.onOutput(callback);
85
+ }
86
+ kill() {
87
+ try {
88
+ this.childProcess.kill();
89
+ }
90
+ catch {
91
+ // when the child process completes before we explicitly call kill, this will throw
92
+ // do nothing
93
+ }
94
+ finally {
95
+ if (this.isAlive == true) {
96
+ this.isAlive = false;
97
+ }
98
+ }
99
+ }
100
+ }
101
+ exports.PseudoTtyProcess = PseudoTtyProcess;
102
+ class PseudoTtyProcessWithSend extends PseudoTtyProcess {
103
+ constructor(_childProcess, id, pseudoIpc) {
104
+ super(_childProcess);
105
+ this.id = id;
106
+ this.pseudoIpc = pseudoIpc;
107
+ }
108
+ send(message) {
109
+ this.pseudoIpc.sendMessageToChild(this.id, message);
110
+ }
111
+ }
112
+ exports.PseudoTtyProcessWithSend = PseudoTtyProcessWithSend;
113
+ function messageToCode(message) {
114
+ if (message.startsWith('Terminated by ')) {
115
+ switch (message.replace('Terminated by ', '').trim()) {
116
+ case 'Termination':
117
+ return 143;
118
+ case 'Interrupt':
119
+ return 130;
120
+ default:
121
+ return 128;
122
+ }
123
+ }
124
+ else if (message.startsWith('Exited with code ')) {
125
+ return parseInt(message.replace('Exited with code ', '').trim());
126
+ }
127
+ else if (message === 'Success') {
128
+ return 0;
129
+ }
130
+ else {
131
+ return 1;
132
+ }
133
+ }
@@ -54,7 +54,6 @@ class TaskOrchestrator {
54
54
  await Promise.all(threads);
55
55
  perf_hooks_1.performance.mark('task-execution:end');
56
56
  perf_hooks_1.performance.measure('task-execution', 'task-execution:start', 'task-execution:end');
57
- this.forkedProcessTaskRunner.destroy();
58
57
  this.cache.removeOldCacheRecords();
59
58
  return this.completedTasks;
60
59
  }
@@ -27,7 +27,7 @@ function getIgnoredGlobs(root = workspace_root_1.workspaceRoot, prependRoot = tr
27
27
  }
28
28
  exports.getIgnoredGlobs = getIgnoredGlobs;
29
29
  function getAlwaysIgnore(root) {
30
- const paths = ['node_modules', '**/node_modules', '.git'];
30
+ const paths = ['node_modules', '**/node_modules', '.git', '.nx', '.vscode'];
31
31
  return root ? paths.map((x) => (0, path_1.joinPathFragments)(root, x)) : paths;
32
32
  }
33
33
  exports.getAlwaysIgnore = getAlwaysIgnore;
@@ -10,6 +10,10 @@ import { RawProjectGraphDependency } from '../project-graph/project-graph-builde
10
10
  export interface CreateNodesContext {
11
11
  readonly nxJsonConfiguration: NxJsonConfiguration;
12
12
  readonly workspaceRoot: string;
13
+ /**
14
+ * The subset of configuration files which match the createNodes pattern
15
+ */
16
+ readonly configFiles: string[];
13
17
  }
14
18
  /**
15
19
  * A function which parses a configuration file into a set of nodes.
@@ -30,7 +34,7 @@ export interface CreateNodesResult {
30
34
  * A pair of file patterns and {@link CreateNodesFunction}
31
35
  */
32
36
  export type CreateNodes<T = unknown> = readonly [
33
- projectFilePattern: string,
37
+ configFilePattern: string,
34
38
  createNodesFunction: CreateNodesFunction<T>
35
39
  ];
36
40
  /**