nx 19.4.0-canary.20240626-3a2e8d4 → 19.4.0-canary.20240627-c2c6a13

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.
Files changed (34) hide show
  1. package/package.json +14 -14
  2. package/src/command-line/connect/connect-to-nx-cloud.d.ts +1 -1
  3. package/src/command-line/connect/connect-to-nx-cloud.js +16 -25
  4. package/src/command-line/graph/graph.d.ts +1 -0
  5. package/src/command-line/graph/graph.js +12 -1
  6. package/src/command-line/run/command-object.js +2 -1
  7. package/src/config/workspace-json-project-json.d.ts +1 -0
  8. package/src/core/graph/main.js +1 -1
  9. package/src/core/graph/styles.css +1 -1
  10. package/src/daemon/socket-utils.d.ts +1 -0
  11. package/src/daemon/socket-utils.js +6 -1
  12. package/src/executors/run-commands/run-commands.impl.js +19 -14
  13. package/src/nx-cloud/generators/connect-to-nx-cloud/connect-to-nx-cloud.d.ts +1 -0
  14. package/src/nx-cloud/generators/connect-to-nx-cloud/connect-to-nx-cloud.js +68 -33
  15. package/src/nx-cloud/generators/connect-to-nx-cloud/schema.json +5 -0
  16. package/src/nx-cloud/utilities/url-shorten.d.ts +2 -1
  17. package/src/nx-cloud/utilities/url-shorten.js +47 -11
  18. package/src/plugins/project-json/build-nodes/package-json-next-to-project-json.js +9 -2
  19. package/src/plugins/target-defaults/target-defaults-plugin.d.ts +5 -0
  20. package/src/project-graph/plugins/internal-api.js +1 -1
  21. package/src/project-graph/plugins/isolation/index.d.ts +1 -1
  22. package/src/project-graph/plugins/isolation/index.js +3 -15
  23. package/src/project-graph/plugins/isolation/messaging.d.ts +6 -3
  24. package/src/project-graph/plugins/isolation/messaging.js +9 -3
  25. package/src/project-graph/plugins/isolation/plugin-pool.d.ts +1 -1
  26. package/src/project-graph/plugins/isolation/plugin-pool.js +125 -51
  27. package/src/project-graph/plugins/isolation/plugin-worker.js +128 -107
  28. package/src/project-graph/utils/retrieve-workspace-files.d.ts +3 -3
  29. package/src/tasks-runner/task-env.d.ts +13 -0
  30. package/src/tasks-runner/task-env.js +41 -26
  31. package/src/utils/git-utils.d.ts +1 -1
  32. package/src/utils/git-utils.js +13 -2
  33. package/src/utils/nx-cloud-utils.d.ts +1 -1
  34. package/src/utils/nx-cloud-utils.js +1 -1
@@ -1,9 +1,11 @@
1
1
  /// <reference types="node" />
2
+ /// <reference types="node" />
2
3
  import { ProjectGraph, ProjectGraphProcessorContext } from '../../../config/project-graph';
3
4
  import { PluginConfiguration } from '../../../config/nx-json';
4
- import { CreateDependenciesContext, CreateMetadataContext, CreateNodesContext } from '../public-api';
5
+ import { CreateDependenciesContext, CreateMetadataContext, CreateNodesContextV2 } from '../public-api';
5
6
  import { LoadedNxPlugin } from '../internal-api';
6
7
  import { Serializable } from 'child_process';
8
+ import { Socket } from 'net';
7
9
  export interface PluginWorkerLoadMessage {
8
10
  type: 'load';
9
11
  payload: {
@@ -31,7 +33,7 @@ export interface PluginWorkerCreateNodesMessage {
31
33
  type: 'createNodes';
32
34
  payload: {
33
35
  configFiles: string[];
34
- context: CreateNodesContext;
36
+ context: CreateNodesContextV2;
35
37
  tx: string;
36
38
  };
37
39
  }
@@ -112,9 +114,10 @@ export declare function isPluginWorkerMessage(message: Serializable): message is
112
114
  export declare function isPluginWorkerResult(message: Serializable): message is PluginWorkerResult;
113
115
  type MaybePromise<T> = T | Promise<T>;
114
116
  type MessageHandlerReturn<T extends PluginWorkerMessage | PluginWorkerResult> = T extends PluginWorkerResult ? MaybePromise<PluginWorkerMessage | void> : MaybePromise<PluginWorkerResult | void>;
115
- export declare function consumeMessage<T extends PluginWorkerMessage | PluginWorkerResult>(raw: T, handlers: {
117
+ export declare function consumeMessage<T extends PluginWorkerMessage | PluginWorkerResult>(socket: Socket, raw: T, handlers: {
116
118
  [K in T['type']]: (payload: Extract<T, {
117
119
  type: K;
118
120
  }>['payload']) => MessageHandlerReturn<T>;
119
121
  }): Promise<void>;
122
+ export declare function sendMessageOverSocket(socket: Socket, message: PluginWorkerMessage | PluginWorkerResult): void;
120
123
  export {};
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.consumeMessage = exports.isPluginWorkerResult = exports.isPluginWorkerMessage = void 0;
3
+ exports.sendMessageOverSocket = exports.consumeMessage = exports.isPluginWorkerResult = exports.isPluginWorkerMessage = void 0;
4
4
  function isPluginWorkerMessage(message) {
5
5
  return (typeof message === 'object' &&
6
6
  'type' in message &&
@@ -10,6 +10,7 @@ function isPluginWorkerMessage(message) {
10
10
  'createNodes',
11
11
  'createDependencies',
12
12
  'processProjectGraph',
13
+ 'createMetadata',
13
14
  ].includes(message.type));
14
15
  }
15
16
  exports.isPluginWorkerMessage = isPluginWorkerMessage;
@@ -22,19 +23,24 @@ function isPluginWorkerResult(message) {
22
23
  'createNodesResult',
23
24
  'createDependenciesResult',
24
25
  'processProjectGraphResult',
26
+ 'createMetadataResult',
25
27
  ].includes(message.type));
26
28
  }
27
29
  exports.isPluginWorkerResult = isPluginWorkerResult;
28
30
  // Takes a message and a map of handlers and calls the appropriate handler
29
31
  // type safe and requires all handlers to be handled
30
- async function consumeMessage(raw, handlers) {
32
+ async function consumeMessage(socket, raw, handlers) {
31
33
  const message = raw;
32
34
  const handler = handlers[message.type];
33
35
  if (handler) {
34
36
  const response = await handler(message.payload);
35
37
  if (response) {
36
- process.send(response);
38
+ sendMessageOverSocket(socket, response);
37
39
  }
38
40
  }
39
41
  }
40
42
  exports.consumeMessage = consumeMessage;
43
+ function sendMessageOverSocket(socket, message) {
44
+ socket.write(JSON.stringify(message) + String.fromCodePoint(4));
45
+ }
46
+ exports.sendMessageOverSocket = sendMessageOverSocket;
@@ -1,3 +1,3 @@
1
1
  import { PluginConfiguration } from '../../../config/nx-json';
2
2
  import { LoadedNxPlugin } from '../internal-api';
3
- export declare function loadRemoteNxPlugin(plugin: PluginConfiguration, root: string): [Promise<LoadedNxPlugin>, () => void];
3
+ export declare function loadRemoteNxPlugin(plugin: PluginConfiguration, root: string): Promise<[Promise<LoadedNxPlugin>, () => void]>;
@@ -6,52 +6,46 @@ const path = require("path");
6
6
  // TODO (@AgentEnder): After scoped verbose logging is implemented, re-add verbose logs here.
7
7
  // import { logger } from '../../utils/logger';
8
8
  const internal_api_1 = require("../internal-api");
9
+ const socket_utils_1 = require("../../../daemon/socket-utils");
10
+ const consume_messages_from_socket_1 = require("../../../utils/consume-messages-from-socket");
9
11
  const messaging_1 = require("./messaging");
12
+ const net_1 = require("net");
10
13
  const cleanupFunctions = new Set();
11
14
  const pluginNames = new Map();
12
- function loadRemoteNxPlugin(plugin, root) {
13
- // this should only really be true when running unit tests within
14
- // the Nx repo. We still need to start the worker in this case,
15
- // but its typescript.
16
- const isWorkerTypescript = path.extname(__filename) === '.ts';
17
- const workerPath = path.join(__dirname, 'plugin-worker');
18
- const env = {
19
- ...process.env,
20
- ...(isWorkerTypescript
21
- ? {
22
- // Ensures that the worker uses the same tsconfig as the main process
23
- TS_NODE_PROJECT: path.join(__dirname, '../../../../tsconfig.lib.json'),
24
- }
25
- : {}),
26
- };
27
- const worker = (0, child_process_1.fork)(workerPath, [], {
28
- stdio: ['ignore', 'inherit', 'inherit', 'ipc'],
29
- env,
30
- execArgv: [
31
- ...process.execArgv,
32
- // If the worker is typescript, we need to register ts-node
33
- ...(isWorkerTypescript ? ['-r', 'ts-node/register'] : []),
34
- ],
35
- });
36
- worker.send({ type: 'load', payload: { plugin, root } });
37
- // logger.verbose(`[plugin-worker] started worker: ${worker.pid}`);
15
+ const MAX_MESSAGE_WAIT = 1000 * 60 * 5; // 5 minutes
16
+ const nxPluginWorkerCache = (global['nxPluginWorkerCache'] ??= new Map());
17
+ async function loadRemoteNxPlugin(plugin, root) {
18
+ const cacheKey = JSON.stringify({ plugin, root });
19
+ if (nxPluginWorkerCache.has(cacheKey)) {
20
+ return [nxPluginWorkerCache.get(cacheKey), () => { }];
21
+ }
22
+ const { worker, socket } = await startPluginWorker();
38
23
  const pendingPromises = new Map();
39
24
  const exitHandler = createWorkerExitHandler(worker, pendingPromises);
40
25
  const cleanupFunction = () => {
41
26
  worker.off('exit', exitHandler);
27
+ socket.destroy();
42
28
  shutdownPluginWorker(worker);
29
+ nxPluginWorkerCache.delete(cacheKey);
43
30
  };
44
31
  cleanupFunctions.add(cleanupFunction);
45
- return [
46
- new Promise((res, rej) => {
47
- worker.on('message', createWorkerHandler(worker, pendingPromises, res, rej));
48
- worker.on('exit', exitHandler);
49
- }),
50
- () => {
51
- cleanupFunction();
52
- cleanupFunctions.delete(cleanupFunction);
53
- },
54
- ];
32
+ const pluginPromise = new Promise((res, rej) => {
33
+ (0, messaging_1.sendMessageOverSocket)(socket, {
34
+ type: 'load',
35
+ payload: { plugin, root },
36
+ });
37
+ // logger.verbose(`[plugin-worker] started worker: ${worker.pid}`);
38
+ const loadTimeout = setTimeout(() => {
39
+ rej(new Error('Plugin worker timed out when loading plugin:' + plugin));
40
+ }, MAX_MESSAGE_WAIT);
41
+ socket.on('data', (0, consume_messages_from_socket_1.consumeMessagesFromSocket)(createWorkerHandler(worker, pendingPromises, (val) => {
42
+ clearTimeout(loadTimeout);
43
+ res(val);
44
+ }, rej, socket)));
45
+ worker.on('exit', exitHandler);
46
+ });
47
+ nxPluginWorkerCache.set(cacheKey, pluginPromise);
48
+ return [pluginPromise, cleanupFunction];
55
49
  }
56
50
  exports.loadRemoteNxPlugin = loadRemoteNxPlugin;
57
51
  function shutdownPluginWorker(worker) {
@@ -68,13 +62,15 @@ function shutdownPluginWorker(worker) {
68
62
  * @param onloadError Rejecter for RemotePlugin promise
69
63
  * @returns Function to handle messages from the worker
70
64
  */
71
- function createWorkerHandler(worker, pending, onload, onloadError) {
65
+ function createWorkerHandler(worker, pending, onload, onloadError, socket) {
72
66
  let pluginName;
73
- return function (message) {
67
+ let txId = 0;
68
+ return function (raw) {
69
+ const message = JSON.parse(raw);
74
70
  if (!(0, messaging_1.isPluginWorkerResult)(message)) {
75
71
  return;
76
72
  }
77
- return (0, messaging_1.consumeMessage)(message, {
73
+ return (0, messaging_1.consumeMessage)(socket, message, {
78
74
  'load-result': (result) => {
79
75
  if (result.success) {
80
76
  const { name, createNodesPattern, include, exclude } = result;
@@ -88,9 +84,9 @@ function createWorkerHandler(worker, pending, onload, onloadError) {
88
84
  ? [
89
85
  createNodesPattern,
90
86
  (configFiles, ctx) => {
91
- const tx = pluginName + ':createNodes:' + performance.now();
87
+ const tx = pluginName + worker.pid + ':createNodes:' + txId++;
92
88
  return registerPendingPromise(tx, pending, () => {
93
- worker.send({
89
+ (0, messaging_1.sendMessageOverSocket)(socket, {
94
90
  type: 'createNodes',
95
91
  payload: { configFiles, context: ctx, tx },
96
92
  });
@@ -100,9 +96,9 @@ function createWorkerHandler(worker, pending, onload, onloadError) {
100
96
  : undefined,
101
97
  createDependencies: result.hasCreateDependencies
102
98
  ? (ctx) => {
103
- const tx = pluginName + ':createDependencies:' + performance.now();
99
+ const tx = pluginName + worker.pid + ':createDependencies:' + txId++;
104
100
  return registerPendingPromise(tx, pending, () => {
105
- worker.send({
101
+ (0, messaging_1.sendMessageOverSocket)(socket, {
106
102
  type: 'createDependencies',
107
103
  payload: { context: ctx, tx },
108
104
  });
@@ -111,9 +107,9 @@ function createWorkerHandler(worker, pending, onload, onloadError) {
111
107
  : undefined,
112
108
  processProjectGraph: result.hasProcessProjectGraph
113
109
  ? (graph, ctx) => {
114
- const tx = pluginName + ':processProjectGraph:' + performance.now();
110
+ const tx = pluginName + worker.pid + ':processProjectGraph:' + txId++;
115
111
  return registerPendingPromise(tx, pending, () => {
116
- worker.send({
112
+ (0, messaging_1.sendMessageOverSocket)(socket, {
117
113
  type: 'processProjectGraph',
118
114
  payload: { graph, ctx, tx },
119
115
  });
@@ -122,9 +118,9 @@ function createWorkerHandler(worker, pending, onload, onloadError) {
122
118
  : undefined,
123
119
  createMetadata: result.hasCreateMetadata
124
120
  ? (graph, ctx) => {
125
- const tx = pluginName + ':createMetadata:' + performance.now();
121
+ const tx = pluginName + worker.pid + ':createMetadata:' + txId++;
126
122
  return registerPendingPromise(tx, pending, () => {
127
- worker.send({
123
+ (0, messaging_1.sendMessageOverSocket)(socket, {
128
124
  type: 'createMetadata',
129
125
  payload: { graph, context: ctx, tx },
130
126
  });
@@ -183,19 +179,30 @@ function createWorkerExitHandler(worker, pendingPromises) {
183
179
  }
184
180
  };
185
181
  }
186
- process.on('exit', () => {
182
+ let cleanedUp = false;
183
+ const exitHandler = () => {
184
+ if (cleanedUp)
185
+ return;
187
186
  for (const fn of cleanupFunctions) {
188
187
  fn();
189
188
  }
190
- });
189
+ cleanedUp = true;
190
+ };
191
+ process.on('exit', exitHandler);
192
+ process.on('SIGINT', exitHandler);
193
+ process.on('SIGTERM', exitHandler);
191
194
  function registerPendingPromise(tx, pending, callback) {
192
- let resolver, rejector;
195
+ let resolver, rejector, timeout;
193
196
  const promise = new Promise((res, rej) => {
194
- resolver = res;
195
197
  rejector = rej;
198
+ resolver = res;
199
+ timeout = setTimeout(() => {
200
+ rej(new Error(`Plugin worker timed out when processing message ${tx}`));
201
+ }, MAX_MESSAGE_WAIT);
196
202
  callback();
197
203
  }).finally(() => {
198
204
  pending.delete(tx);
205
+ clearTimeout(timeout);
199
206
  });
200
207
  pending.set(tx, {
201
208
  promise,
@@ -204,3 +211,70 @@ function registerPendingPromise(tx, pending, callback) {
204
211
  });
205
212
  return promise;
206
213
  }
214
+ global.nxPluginWorkerCount ??= 0;
215
+ async function startPluginWorker() {
216
+ // this should only really be true when running unit tests within
217
+ // the Nx repo. We still need to start the worker in this case,
218
+ // but its typescript.
219
+ const isWorkerTypescript = path.extname(__filename) === '.ts';
220
+ const workerPath = path.join(__dirname, 'plugin-worker');
221
+ const env = {
222
+ ...process.env,
223
+ ...(isWorkerTypescript
224
+ ? {
225
+ // Ensures that the worker uses the same tsconfig as the main process
226
+ TS_NODE_PROJECT: path.join(__dirname, '../../../../tsconfig.lib.json'),
227
+ }
228
+ : {}),
229
+ };
230
+ const ipcPath = (0, socket_utils_1.getPluginOsSocketPath)([process.pid, global.nxPluginWorkerCount++].join('-'));
231
+ const worker = (0, child_process_1.fork)(workerPath, [ipcPath], {
232
+ stdio: process.stdout.isTTY ? 'inherit' : 'ignore',
233
+ env,
234
+ execArgv: [
235
+ ...process.execArgv,
236
+ // If the worker is typescript, we need to register ts-node
237
+ ...(isWorkerTypescript ? ['-r', 'ts-node/register'] : []),
238
+ ],
239
+ detached: true,
240
+ });
241
+ worker.disconnect();
242
+ worker.unref();
243
+ let attempts = 0;
244
+ return new Promise((resolve, reject) => {
245
+ const id = setInterval(async () => {
246
+ const socket = await isServerAvailable(ipcPath);
247
+ if (socket) {
248
+ socket.unref();
249
+ clearInterval(id);
250
+ resolve({
251
+ worker,
252
+ socket,
253
+ });
254
+ }
255
+ else if (attempts > 1000) {
256
+ // daemon fails to start, the process probably exited
257
+ // we print the logs and exit the client
258
+ reject('Failed to start plugin worker.');
259
+ }
260
+ else {
261
+ attempts++;
262
+ }
263
+ }, 10);
264
+ });
265
+ }
266
+ function isServerAvailable(ipcPath) {
267
+ return new Promise((resolve) => {
268
+ try {
269
+ const socket = (0, net_1.connect)(ipcPath, () => {
270
+ resolve(socket);
271
+ });
272
+ socket.once('error', () => {
273
+ resolve(false);
274
+ });
275
+ }
276
+ catch (err) {
277
+ resolve(false);
278
+ }
279
+ });
280
+ }
@@ -3,116 +3,137 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const messaging_1 = require("./messaging");
4
4
  const loader_1 = require("../loader");
5
5
  const serializable_error_1 = require("../../../utils/serializable-error");
6
+ const net_1 = require("net");
7
+ const consume_messages_from_socket_1 = require("../../../utils/consume-messages-from-socket");
8
+ const fs_1 = require("fs");
6
9
  if (process.env.NX_PERF_LOGGING === 'true') {
7
10
  require('../../../utils/perf-logging');
8
11
  }
9
12
  global.NX_GRAPH_CREATION = true;
10
13
  let plugin;
11
- process.on('message', async (message) => {
12
- if (!(0, messaging_1.isPluginWorkerMessage)(message)) {
13
- return;
14
- }
15
- return (0, messaging_1.consumeMessage)(message, {
16
- load: async ({ plugin: pluginConfiguration, root }) => {
17
- process.chdir(root);
18
- try {
19
- const [promise] = (0, loader_1.loadNxPlugin)(pluginConfiguration, root);
20
- plugin = await promise;
21
- return {
22
- type: 'load-result',
23
- payload: {
24
- name: plugin.name,
25
- include: plugin.include,
26
- exclude: plugin.exclude,
27
- createNodesPattern: plugin.createNodes?.[0],
28
- hasCreateDependencies: 'createDependencies' in plugin && !!plugin.createDependencies,
29
- hasProcessProjectGraph: 'processProjectGraph' in plugin && !!plugin.processProjectGraph,
30
- hasCreateMetadata: 'createMetadata' in plugin && !!plugin.createMetadata,
31
- success: true,
32
- },
33
- };
34
- }
35
- catch (e) {
36
- return {
37
- type: 'load-result',
38
- payload: {
39
- success: false,
40
- error: (0, serializable_error_1.createSerializableError)(e),
41
- },
42
- };
43
- }
44
- },
45
- createNodes: async ({ configFiles, context, tx }) => {
46
- try {
47
- const result = await plugin.createNodes[1](configFiles, context);
48
- return {
49
- type: 'createNodesResult',
50
- payload: { result, success: true, tx },
51
- };
52
- }
53
- catch (e) {
54
- return {
55
- type: 'createNodesResult',
56
- payload: {
57
- success: false,
58
- error: (0, serializable_error_1.createSerializableError)(e),
59
- tx,
60
- },
61
- };
62
- }
63
- },
64
- createDependencies: async ({ context, tx }) => {
65
- try {
66
- const result = await plugin.createDependencies(context);
67
- return {
68
- type: 'createDependenciesResult',
69
- payload: { dependencies: result, success: true, tx },
70
- };
71
- }
72
- catch (e) {
73
- return {
74
- type: 'createDependenciesResult',
75
- payload: {
76
- success: false,
77
- error: (0, serializable_error_1.createSerializableError)(e),
78
- tx,
79
- },
80
- };
81
- }
82
- },
83
- processProjectGraph: async ({ graph, ctx, tx }) => {
84
- try {
85
- const result = await plugin.processProjectGraph(graph, ctx);
86
- return {
87
- type: 'processProjectGraphResult',
88
- payload: { graph: result, success: true, tx },
89
- };
90
- }
91
- catch (e) {
92
- return {
93
- type: 'processProjectGraphResult',
94
- payload: {
95
- success: false,
96
- error: (0, serializable_error_1.createSerializableError)(e),
97
- tx,
98
- },
99
- };
100
- }
101
- },
102
- createMetadata: async ({ graph, context, tx }) => {
103
- try {
104
- const result = await plugin.createMetadata(graph, context);
105
- return {
106
- type: 'createMetadataResult',
107
- payload: { metadata: result, success: true, tx },
108
- };
109
- }
110
- catch (e) {
111
- return {
112
- type: 'createMetadataResult',
113
- payload: { success: false, error: e.stack, tx },
114
- };
115
- }
116
- },
117
- });
14
+ const socketPath = process.argv[2];
15
+ const server = (0, net_1.createServer)((socket) => {
16
+ socket.on('data', (0, consume_messages_from_socket_1.consumeMessagesFromSocket)((raw) => {
17
+ const message = JSON.parse(raw.toString());
18
+ if (!(0, messaging_1.isPluginWorkerMessage)(message)) {
19
+ return;
20
+ }
21
+ return (0, messaging_1.consumeMessage)(socket, message, {
22
+ load: async ({ plugin: pluginConfiguration, root }) => {
23
+ process.chdir(root);
24
+ try {
25
+ const [promise] = (0, loader_1.loadNxPlugin)(pluginConfiguration, root);
26
+ plugin = await promise;
27
+ return {
28
+ type: 'load-result',
29
+ payload: {
30
+ name: plugin.name,
31
+ include: plugin.include,
32
+ exclude: plugin.exclude,
33
+ createNodesPattern: plugin.createNodes?.[0],
34
+ hasCreateDependencies: 'createDependencies' in plugin && !!plugin.createDependencies,
35
+ hasProcessProjectGraph: 'processProjectGraph' in plugin &&
36
+ !!plugin.processProjectGraph,
37
+ hasCreateMetadata: 'createMetadata' in plugin && !!plugin.createMetadata,
38
+ success: true,
39
+ },
40
+ };
41
+ }
42
+ catch (e) {
43
+ return {
44
+ type: 'load-result',
45
+ payload: {
46
+ success: false,
47
+ error: (0, serializable_error_1.createSerializableError)(e),
48
+ },
49
+ };
50
+ }
51
+ },
52
+ createNodes: async ({ configFiles, context, tx }) => {
53
+ try {
54
+ const result = await plugin.createNodes[1](configFiles, context);
55
+ return {
56
+ type: 'createNodesResult',
57
+ payload: { result, success: true, tx },
58
+ };
59
+ }
60
+ catch (e) {
61
+ return {
62
+ type: 'createNodesResult',
63
+ payload: {
64
+ success: false,
65
+ error: (0, serializable_error_1.createSerializableError)(e),
66
+ tx,
67
+ },
68
+ };
69
+ }
70
+ },
71
+ createDependencies: async ({ context, tx }) => {
72
+ try {
73
+ const result = await plugin.createDependencies(context);
74
+ return {
75
+ type: 'createDependenciesResult',
76
+ payload: { dependencies: result, success: true, tx },
77
+ };
78
+ }
79
+ catch (e) {
80
+ return {
81
+ type: 'createDependenciesResult',
82
+ payload: {
83
+ success: false,
84
+ error: (0, serializable_error_1.createSerializableError)(e),
85
+ tx,
86
+ },
87
+ };
88
+ }
89
+ },
90
+ processProjectGraph: async ({ graph, ctx, tx }) => {
91
+ try {
92
+ const result = await plugin.processProjectGraph(graph, ctx);
93
+ return {
94
+ type: 'processProjectGraphResult',
95
+ payload: { graph: result, success: true, tx },
96
+ };
97
+ }
98
+ catch (e) {
99
+ return {
100
+ type: 'processProjectGraphResult',
101
+ payload: {
102
+ success: false,
103
+ error: (0, serializable_error_1.createSerializableError)(e),
104
+ tx,
105
+ },
106
+ };
107
+ }
108
+ },
109
+ createMetadata: async ({ graph, context, tx }) => {
110
+ try {
111
+ const result = await plugin.createMetadata(graph, context);
112
+ return {
113
+ type: 'createMetadataResult',
114
+ payload: { metadata: result, success: true, tx },
115
+ };
116
+ }
117
+ catch (e) {
118
+ return {
119
+ type: 'createMetadataResult',
120
+ payload: { success: false, error: e.stack, tx },
121
+ };
122
+ }
123
+ },
124
+ });
125
+ }));
118
126
  });
127
+ server.listen(socketPath);
128
+ const exitHandler = (exitCode) => () => {
129
+ server.close();
130
+ try {
131
+ (0, fs_1.unlinkSync)(socketPath);
132
+ }
133
+ catch (e) { }
134
+ process.exit(exitCode);
135
+ };
136
+ const events = ['SIGINT', 'SIGTERM', 'SIGQUIT', 'exit'];
137
+ events.forEach((event) => process.once(event, exitHandler(0)));
138
+ process.once('uncaughtException', exitHandler(1));
139
+ process.once('unhandledRejection', exitHandler(1));
@@ -9,12 +9,12 @@ import { LoadedNxPlugin } from '../plugins/internal-api';
9
9
  * @param nxJson
10
10
  */
11
11
  export declare function retrieveWorkspaceFiles(workspaceRoot: string, projectRootMap: Record<string, string>): Promise<{
12
- allWorkspaceFiles: import("nx/src/devkit-exports").FileData[];
12
+ allWorkspaceFiles: import("../file-utils").FileData[];
13
13
  fileMap: {
14
14
  projectFileMap: ProjectFiles;
15
- nonProjectFiles: import("nx/src/native").FileData[];
15
+ nonProjectFiles: import("../../native").FileData[];
16
16
  };
17
- rustReferences: import("nx/src/native").NxWorkspaceFilesExternals;
17
+ rustReferences: import("../../native").NxWorkspaceFilesExternals;
18
18
  }>;
19
19
  /**
20
20
  * Walk through the workspace and return `ProjectConfigurations`. Only use this if the projectFileMap is not needed.
@@ -6,3 +6,16 @@ export declare function getEnvVariablesForTask(task: Task, taskSpecificEnv: Node
6
6
  [x: string]: string;
7
7
  TZ?: string;
8
8
  };
9
+ /**
10
+ * This function loads a .env file and expands the variables in it.
11
+ * It is going to override existing environmentVariables.
12
+ * @param filename
13
+ * @param environmentVariables
14
+ */
15
+ export declare function loadAndExpandDotEnvFile(filename: string, environmentVariables: NodeJS.ProcessEnv, override?: boolean): import("dotenv-expand").DotenvExpandOutput;
16
+ /**
17
+ * This function unloads a .env file and removes the variables in it from the environmentVariables.
18
+ * @param filename
19
+ * @param environmentVariables
20
+ */
21
+ export declare function unloadDotEnvFile(filename: string, environmentVariables: NodeJS.ProcessEnv, override?: boolean): void;