nx 18.3.1 → 18.3.3
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 +4 -0
- package/bin/nx.js +7 -19
- package/migrations.json +2 -1
- package/package.json +12 -12
- package/src/command-line/add/add.js +3 -1
- package/src/command-line/add/command-object.d.ts +1 -0
- package/src/command-line/add/command-object.js +6 -1
- package/src/command-line/graph/command-object.js +1 -1
- package/src/command-line/init/implementation/react/check-for-uncommitted-changes.js +6 -3
- package/src/command-line/show/command-object.js +1 -5
- package/src/command-line/yargs-utils/shared-options.d.ts +3 -0
- package/src/command-line/yargs-utils/shared-options.js +15 -6
- package/src/daemon/cache.js +18 -0
- package/src/daemon/client/client.js +3 -4
- package/src/daemon/server/handle-hash-tasks.js +2 -2
- package/src/daemon/server/project-graph-incremental-recomputation.js +1 -2
- package/src/daemon/server/server.js +1 -4
- package/src/daemon/socket-utils.js +2 -14
- package/src/executors/run-commands/run-commands.impl.js +62 -11
- package/src/native/index.d.ts +1 -4
- package/src/native/index.js +67 -259
- package/src/native/native-bindings.js +268 -0
- package/src/native/transform-objects.js +1 -0
- package/src/project-graph/error-types.d.ts +31 -1
- package/src/project-graph/error-types.js +62 -1
- package/src/project-graph/plugins/isolation/index.js +8 -4
- package/src/project-graph/plugins/isolation/messaging.d.ts +9 -6
- package/src/project-graph/plugins/isolation/messaging.js +27 -10
- package/src/project-graph/plugins/isolation/plugin-pool.d.ts +1 -1
- package/src/project-graph/plugins/isolation/plugin-pool.js +15 -24
- package/src/project-graph/plugins/isolation/plugin-worker.js +21 -5
- package/src/project-graph/plugins/loader.js +22 -18
- package/src/project-graph/project-graph.d.ts +2 -24
- package/src/project-graph/project-graph.js +11 -52
- package/src/project-graph/utils/retrieve-workspace-files.d.ts +3 -3
- package/src/tasks-runner/init-tasks-runner.js +2 -0
- package/src/tasks-runner/life-cycles/dynamic-run-many-terminal-output-life-cycle.js +4 -0
- package/src/tasks-runner/life-cycles/dynamic-run-one-terminal-output-life-cycle.js +4 -0
- package/src/tasks-runner/pseudo-terminal.js +6 -0
- package/src/tasks-runner/task-orchestrator.js +47 -29
- package/src/utils/dotenv.d.ts +7 -0
- package/src/utils/dotenv.js +22 -0
- package/src/utils/params.js +20 -17
- package/src/utils/serializable-error.d.ts +4 -0
- package/src/utils/serializable-error.js +28 -0
- package/src/daemon/daemon-project-graph-error.d.ts +0 -8
- package/src/daemon/daemon-project-graph-error.js +0 -13
@@ -1,6 +1,47 @@
|
|
1
1
|
"use strict";
|
2
|
+
var _ProjectGraphError_errors, _ProjectGraphError_partialProjectGraph, _ProjectGraphError_partialSourceMaps;
|
2
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
exports.isMergeNodesError = exports.isAggregateCreateNodesError = exports.isCreateNodesError = exports.MergeNodesError = exports.AggregateCreateNodesError = exports.CreateNodesError = exports.ProjectConfigurationsError = exports.isProjectsWithNoNameError = exports.ProjectsWithNoNameError = exports.isProjectsWithConflictingNamesError = exports.ProjectsWithConflictingNamesError = void 0;
|
4
|
+
exports.LoadPluginError = exports.DaemonProjectGraphError = exports.isMergeNodesError = exports.isAggregateCreateNodesError = exports.isCreateNodesError = exports.MergeNodesError = exports.AggregateCreateNodesError = exports.CreateNodesError = exports.ProjectConfigurationsError = exports.isProjectsWithNoNameError = exports.ProjectsWithNoNameError = exports.isProjectsWithConflictingNamesError = exports.ProjectsWithConflictingNamesError = exports.ProjectGraphError = void 0;
|
5
|
+
const tslib_1 = require("tslib");
|
6
|
+
class ProjectGraphError extends Error {
|
7
|
+
constructor(errors, partialProjectGraph, partialSourceMaps) {
|
8
|
+
super(`Failed to process project graph.`);
|
9
|
+
_ProjectGraphError_errors.set(this, void 0);
|
10
|
+
_ProjectGraphError_partialProjectGraph.set(this, void 0);
|
11
|
+
_ProjectGraphError_partialSourceMaps.set(this, void 0);
|
12
|
+
this.name = this.constructor.name;
|
13
|
+
tslib_1.__classPrivateFieldSet(this, _ProjectGraphError_errors, errors, "f");
|
14
|
+
tslib_1.__classPrivateFieldSet(this, _ProjectGraphError_partialProjectGraph, partialProjectGraph, "f");
|
15
|
+
tslib_1.__classPrivateFieldSet(this, _ProjectGraphError_partialSourceMaps, partialSourceMaps, "f");
|
16
|
+
this.stack = `${this.message}\n ${errors
|
17
|
+
.map((error) => error.stack.split('\n').join('\n '))
|
18
|
+
.join('\n')}`;
|
19
|
+
}
|
20
|
+
/**
|
21
|
+
* The daemon cannot throw errors which contain methods as they are not serializable.
|
22
|
+
*
|
23
|
+
* This method creates a new {@link ProjectGraphError} from a {@link DaemonProjectGraphError} with the methods based on the same serialized data.
|
24
|
+
*/
|
25
|
+
static fromDaemonProjectGraphError(e) {
|
26
|
+
return new ProjectGraphError(e.errors, e.projectGraph, e.sourceMaps);
|
27
|
+
}
|
28
|
+
/**
|
29
|
+
* This gets the partial project graph despite the errors which occured.
|
30
|
+
* This partial project graph may be missing nodes, properties of nodes, or dependencies.
|
31
|
+
* This is useful mostly for visualization/debugging. It should not be used for running tasks.
|
32
|
+
*/
|
33
|
+
getPartialProjectGraph() {
|
34
|
+
return tslib_1.__classPrivateFieldGet(this, _ProjectGraphError_partialProjectGraph, "f");
|
35
|
+
}
|
36
|
+
getPartialSourcemaps() {
|
37
|
+
return tslib_1.__classPrivateFieldGet(this, _ProjectGraphError_partialSourceMaps, "f");
|
38
|
+
}
|
39
|
+
getErrors() {
|
40
|
+
return tslib_1.__classPrivateFieldGet(this, _ProjectGraphError_errors, "f");
|
41
|
+
}
|
42
|
+
}
|
43
|
+
exports.ProjectGraphError = ProjectGraphError;
|
44
|
+
_ProjectGraphError_errors = new WeakMap(), _ProjectGraphError_partialProjectGraph = new WeakMap(), _ProjectGraphError_partialSourceMaps = new WeakMap();
|
4
45
|
class ProjectsWithConflictingNamesError extends Error {
|
5
46
|
constructor(conflicts, projects) {
|
6
47
|
super([
|
@@ -94,3 +135,23 @@ function isMergeNodesError(e) {
|
|
94
135
|
(typeof e === 'object' && 'name' in e && e?.name === MergeNodesError.name));
|
95
136
|
}
|
96
137
|
exports.isMergeNodesError = isMergeNodesError;
|
138
|
+
class DaemonProjectGraphError extends Error {
|
139
|
+
constructor(errors, projectGraph, sourceMaps) {
|
140
|
+
super(`The Daemon Process threw an error while calculating the project graph. Convert this error to a ProjectGraphError to get more information.`);
|
141
|
+
this.errors = errors;
|
142
|
+
this.projectGraph = projectGraph;
|
143
|
+
this.sourceMaps = sourceMaps;
|
144
|
+
this.name = this.constructor.name;
|
145
|
+
}
|
146
|
+
}
|
147
|
+
exports.DaemonProjectGraphError = DaemonProjectGraphError;
|
148
|
+
class LoadPluginError extends Error {
|
149
|
+
constructor(plugin, cause) {
|
150
|
+
super(`Could not load plugin ${plugin}`, {
|
151
|
+
cause,
|
152
|
+
});
|
153
|
+
this.plugin = plugin;
|
154
|
+
this.name = this.constructor.name;
|
155
|
+
}
|
156
|
+
}
|
157
|
+
exports.LoadPluginError = LoadPluginError;
|
@@ -3,14 +3,18 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.loadNxPluginInIsolation = void 0;
|
4
4
|
const workspace_root_1 = require("../../../utils/workspace-root");
|
5
5
|
const plugin_pool_1 = require("./plugin-pool");
|
6
|
+
/**
|
7
|
+
* Used to ensure 1 plugin : 1 worker
|
8
|
+
*/
|
6
9
|
const remotePluginCache = new Map();
|
7
10
|
function loadNxPluginInIsolation(plugin, root = workspace_root_1.workspaceRoot) {
|
8
11
|
const cacheKey = JSON.stringify(plugin);
|
9
12
|
if (remotePluginCache.has(cacheKey)) {
|
10
|
-
return remotePluginCache.get(cacheKey);
|
13
|
+
return [remotePluginCache.get(cacheKey), () => { }];
|
11
14
|
}
|
12
|
-
const
|
13
|
-
remotePluginCache.set(cacheKey,
|
14
|
-
|
15
|
+
const loadingPlugin = (0, plugin_pool_1.loadRemoteNxPlugin)(plugin, root);
|
16
|
+
remotePluginCache.set(cacheKey, loadingPlugin);
|
17
|
+
// We clean up plugin workers when Nx process completes.
|
18
|
+
return [loadingPlugin, () => { }];
|
15
19
|
}
|
16
20
|
exports.loadNxPluginInIsolation = loadNxPluginInIsolation;
|
@@ -1,7 +1,9 @@
|
|
1
|
+
/// <reference types="node" />
|
1
2
|
import { ProjectGraph, ProjectGraphProcessorContext } from '../../../config/project-graph';
|
2
3
|
import { PluginConfiguration } from '../../../config/nx-json';
|
3
4
|
import { CreateDependenciesContext, CreateNodesContext } from '../public-api';
|
4
5
|
import { LoadedNxPlugin } from '../internal-api';
|
6
|
+
import { Serializable } from 'child_process';
|
5
7
|
export interface PluginWorkerLoadMessage {
|
6
8
|
type: 'load';
|
7
9
|
payload: {
|
@@ -19,7 +21,7 @@ export interface PluginWorkerLoadResult {
|
|
19
21
|
success: true;
|
20
22
|
} | {
|
21
23
|
success: false;
|
22
|
-
error:
|
24
|
+
error: Error;
|
23
25
|
};
|
24
26
|
}
|
25
27
|
export interface PluginWorkerCreateNodesMessage {
|
@@ -38,7 +40,7 @@ export interface PluginWorkerCreateNodesResult {
|
|
38
40
|
tx: string;
|
39
41
|
} | {
|
40
42
|
success: false;
|
41
|
-
error:
|
43
|
+
error: Error;
|
42
44
|
tx: string;
|
43
45
|
};
|
44
46
|
}
|
@@ -57,7 +59,7 @@ export interface PluginCreateDependenciesResult {
|
|
57
59
|
tx: string;
|
58
60
|
} | {
|
59
61
|
success: false;
|
60
|
-
error:
|
62
|
+
error: Error;
|
61
63
|
tx: string;
|
62
64
|
};
|
63
65
|
}
|
@@ -77,18 +79,19 @@ export interface PluginWorkerProcessProjectGraphResult {
|
|
77
79
|
tx: string;
|
78
80
|
} | {
|
79
81
|
success: false;
|
80
|
-
error:
|
82
|
+
error: Error;
|
81
83
|
tx: string;
|
82
84
|
};
|
83
85
|
}
|
84
86
|
export type PluginWorkerMessage = PluginWorkerLoadMessage | PluginWorkerCreateNodesMessage | PluginCreateDependenciesMessage | PluginWorkerProcessProjectGraphMessage;
|
85
87
|
export type PluginWorkerResult = PluginWorkerLoadResult | PluginWorkerCreateNodesResult | PluginCreateDependenciesResult | PluginWorkerProcessProjectGraphResult;
|
88
|
+
export declare function isPluginWorkerMessage(message: Serializable): message is PluginWorkerMessage;
|
89
|
+
export declare function isPluginWorkerResult(message: Serializable): message is PluginWorkerResult;
|
86
90
|
type MaybePromise<T> = T | Promise<T>;
|
87
91
|
type MessageHandlerReturn<T extends PluginWorkerMessage | PluginWorkerResult> = T extends PluginWorkerResult ? MaybePromise<PluginWorkerMessage | void> : MaybePromise<PluginWorkerResult | void>;
|
88
|
-
export declare function consumeMessage<T extends PluginWorkerMessage | PluginWorkerResult>(raw:
|
92
|
+
export declare function consumeMessage<T extends PluginWorkerMessage | PluginWorkerResult>(raw: T, handlers: {
|
89
93
|
[K in T['type']]: (payload: Extract<T, {
|
90
94
|
type: K;
|
91
95
|
}>['payload']) => MessageHandlerReturn<T>;
|
92
96
|
}): Promise<void>;
|
93
|
-
export declare function createMessage(message: PluginWorkerMessage | PluginWorkerResult): string;
|
94
97
|
export {};
|
@@ -1,23 +1,40 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
exports.
|
3
|
+
exports.consumeMessage = exports.isPluginWorkerResult = exports.isPluginWorkerMessage = void 0;
|
4
|
+
function isPluginWorkerMessage(message) {
|
5
|
+
return (typeof message === 'object' &&
|
6
|
+
'type' in message &&
|
7
|
+
typeof message.type === 'string' &&
|
8
|
+
[
|
9
|
+
'load',
|
10
|
+
'createNodes',
|
11
|
+
'createDependencies',
|
12
|
+
'processProjectGraph',
|
13
|
+
].includes(message.type));
|
14
|
+
}
|
15
|
+
exports.isPluginWorkerMessage = isPluginWorkerMessage;
|
16
|
+
function isPluginWorkerResult(message) {
|
17
|
+
return (typeof message === 'object' &&
|
18
|
+
'type' in message &&
|
19
|
+
typeof message.type === 'string' &&
|
20
|
+
[
|
21
|
+
'load-result',
|
22
|
+
'createNodesResult',
|
23
|
+
'createDependenciesResult',
|
24
|
+
'processProjectGraphResult',
|
25
|
+
].includes(message.type));
|
26
|
+
}
|
27
|
+
exports.isPluginWorkerResult = isPluginWorkerResult;
|
4
28
|
// Takes a message and a map of handlers and calls the appropriate handler
|
5
29
|
// type safe and requires all handlers to be handled
|
6
30
|
async function consumeMessage(raw, handlers) {
|
7
|
-
const message =
|
31
|
+
const message = raw;
|
8
32
|
const handler = handlers[message.type];
|
9
33
|
if (handler) {
|
10
34
|
const response = await handler(message.payload);
|
11
35
|
if (response) {
|
12
|
-
process.send(
|
36
|
+
process.send(response);
|
13
37
|
}
|
14
38
|
}
|
15
|
-
else {
|
16
|
-
throw new Error(`Unhandled message type: ${message.type}`);
|
17
|
-
}
|
18
39
|
}
|
19
40
|
exports.consumeMessage = consumeMessage;
|
20
|
-
function createMessage(message) {
|
21
|
-
return JSON.stringify(message);
|
22
|
-
}
|
23
|
-
exports.createMessage = createMessage;
|
@@ -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):
|
3
|
+
export declare function loadRemoteNxPlugin(plugin: PluginConfiguration, root: string): Promise<LoadedNxPlugin>;
|
@@ -32,7 +32,7 @@ function loadRemoteNxPlugin(plugin, root) {
|
|
32
32
|
...(isWorkerTypescript ? ['-r', 'ts-node/register'] : []),
|
33
33
|
],
|
34
34
|
});
|
35
|
-
worker.send(
|
35
|
+
worker.send({ type: 'load', payload: { plugin, root } });
|
36
36
|
// logger.verbose(`[plugin-worker] started worker: ${worker.pid}`);
|
37
37
|
const pendingPromises = new Map();
|
38
38
|
const exitHandler = createWorkerExitHandler(worker, pendingPromises);
|
@@ -41,16 +41,10 @@ function loadRemoteNxPlugin(plugin, root) {
|
|
41
41
|
shutdownPluginWorker(worker, pendingPromises);
|
42
42
|
};
|
43
43
|
cleanupFunctions.add(cleanupFunction);
|
44
|
-
return
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
}),
|
49
|
-
() => {
|
50
|
-
cleanupFunction();
|
51
|
-
cleanupFunctions.delete(cleanupFunction);
|
52
|
-
},
|
53
|
-
];
|
44
|
+
return new Promise((res, rej) => {
|
45
|
+
worker.on('message', createWorkerHandler(worker, pendingPromises, res, rej));
|
46
|
+
worker.on('exit', exitHandler);
|
47
|
+
});
|
54
48
|
}
|
55
49
|
exports.loadRemoteNxPlugin = loadRemoteNxPlugin;
|
56
50
|
async function shutdownPluginWorker(worker, pendingPromises) {
|
@@ -73,13 +67,10 @@ async function shutdownPluginWorker(worker, pendingPromises) {
|
|
73
67
|
function createWorkerHandler(worker, pending, onload, onloadError) {
|
74
68
|
let pluginName;
|
75
69
|
return function (message) {
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
// }`
|
81
|
-
// );
|
82
|
-
(0, messaging_1.consumeMessage)(parsed, {
|
70
|
+
if (!(0, messaging_1.isPluginWorkerResult)(message)) {
|
71
|
+
return;
|
72
|
+
}
|
73
|
+
return (0, messaging_1.consumeMessage)(message, {
|
83
74
|
'load-result': (result) => {
|
84
75
|
if (result.success) {
|
85
76
|
const { name, createNodesPattern } = result;
|
@@ -93,10 +84,10 @@ function createWorkerHandler(worker, pending, onload, onloadError) {
|
|
93
84
|
(configFiles, ctx) => {
|
94
85
|
const tx = pluginName + ':createNodes:' + performance.now();
|
95
86
|
return registerPendingPromise(tx, pending, () => {
|
96
|
-
worker.send(
|
87
|
+
worker.send({
|
97
88
|
type: 'createNodes',
|
98
89
|
payload: { configFiles, context: ctx, tx },
|
99
|
-
})
|
90
|
+
});
|
100
91
|
});
|
101
92
|
},
|
102
93
|
]
|
@@ -105,10 +96,10 @@ function createWorkerHandler(worker, pending, onload, onloadError) {
|
|
105
96
|
? (ctx) => {
|
106
97
|
const tx = pluginName + ':createDependencies:' + performance.now();
|
107
98
|
return registerPendingPromise(tx, pending, () => {
|
108
|
-
worker.send(
|
99
|
+
worker.send({
|
109
100
|
type: 'createDependencies',
|
110
101
|
payload: { context: ctx, tx },
|
111
|
-
})
|
102
|
+
});
|
112
103
|
});
|
113
104
|
}
|
114
105
|
: undefined,
|
@@ -116,10 +107,10 @@ function createWorkerHandler(worker, pending, onload, onloadError) {
|
|
116
107
|
? (graph, ctx) => {
|
117
108
|
const tx = pluginName + ':processProjectGraph:' + performance.now();
|
118
109
|
return registerPendingPromise(tx, pending, () => {
|
119
|
-
worker.send(
|
110
|
+
worker.send({
|
120
111
|
type: 'processProjectGraph',
|
121
112
|
payload: { graph, ctx, tx },
|
122
|
-
})
|
113
|
+
});
|
123
114
|
});
|
124
115
|
}
|
125
116
|
: undefined,
|
@@ -2,10 +2,14 @@
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
3
|
const messaging_1 = require("./messaging");
|
4
4
|
const loader_1 = require("../loader");
|
5
|
+
const serializable_error_1 = require("../../../utils/serializable-error");
|
5
6
|
global.NX_GRAPH_CREATION = true;
|
6
7
|
let plugin;
|
7
8
|
process.on('message', async (message) => {
|
8
|
-
(0, messaging_1.
|
9
|
+
if (!(0, messaging_1.isPluginWorkerMessage)(message)) {
|
10
|
+
return;
|
11
|
+
}
|
12
|
+
return (0, messaging_1.consumeMessage)(message, {
|
9
13
|
load: async ({ plugin: pluginConfiguration, root }) => {
|
10
14
|
process.chdir(root);
|
11
15
|
try {
|
@@ -27,7 +31,7 @@ process.on('message', async (message) => {
|
|
27
31
|
type: 'load-result',
|
28
32
|
payload: {
|
29
33
|
success: false,
|
30
|
-
error:
|
34
|
+
error: (0, serializable_error_1.createSerializableError)(e),
|
31
35
|
},
|
32
36
|
};
|
33
37
|
}
|
@@ -43,7 +47,11 @@ process.on('message', async (message) => {
|
|
43
47
|
catch (e) {
|
44
48
|
return {
|
45
49
|
type: 'createNodesResult',
|
46
|
-
payload: {
|
50
|
+
payload: {
|
51
|
+
success: false,
|
52
|
+
error: (0, serializable_error_1.createSerializableError)(e),
|
53
|
+
tx,
|
54
|
+
},
|
47
55
|
};
|
48
56
|
}
|
49
57
|
},
|
@@ -58,7 +66,11 @@ process.on('message', async (message) => {
|
|
58
66
|
catch (e) {
|
59
67
|
return {
|
60
68
|
type: 'createDependenciesResult',
|
61
|
-
payload: {
|
69
|
+
payload: {
|
70
|
+
success: false,
|
71
|
+
error: (0, serializable_error_1.createSerializableError)(e),
|
72
|
+
tx,
|
73
|
+
},
|
62
74
|
};
|
63
75
|
}
|
64
76
|
},
|
@@ -73,7 +85,11 @@ process.on('message', async (message) => {
|
|
73
85
|
catch (e) {
|
74
86
|
return {
|
75
87
|
type: 'processProjectGraphResult',
|
76
|
-
payload: {
|
88
|
+
payload: {
|
89
|
+
success: false,
|
90
|
+
error: (0, serializable_error_1.createSerializableError)(e),
|
91
|
+
tx,
|
92
|
+
},
|
77
93
|
};
|
78
94
|
}
|
79
95
|
},
|
@@ -14,10 +14,11 @@ const find_project_for_path_1 = require("../utils/find-project-for-path");
|
|
14
14
|
const path_1 = require("../../utils/path");
|
15
15
|
const logger_1 = require("../../utils/logger");
|
16
16
|
const node_path_1 = require("node:path");
|
17
|
-
const path = require("node:path/posix");
|
18
17
|
const retrieve_workspace_files_1 = require("../utils/retrieve-workspace-files");
|
19
18
|
const utils_1 = require("./utils");
|
20
19
|
const internal_api_1 = require("./internal-api");
|
20
|
+
const error_types_1 = require("../error-types");
|
21
|
+
const path = require("node:path/posix");
|
21
22
|
function readPluginPackageJson(pluginName, projects, paths = (0, installation_directory_1.getNxRequirePaths)()) {
|
22
23
|
try {
|
23
24
|
const result = (0, package_json_1.readModulePackageJsonWithoutFallbacks)(pluginName, paths);
|
@@ -174,26 +175,29 @@ function loadNxPlugin(plugin, root) {
|
|
174
175
|
}
|
175
176
|
exports.loadNxPlugin = loadNxPlugin;
|
176
177
|
async function loadNxPluginAsync(pluginConfiguration, paths, root) {
|
177
|
-
try {
|
178
|
-
require.resolve(typeof pluginConfiguration === 'string'
|
179
|
-
? pluginConfiguration
|
180
|
-
: pluginConfiguration.plugin);
|
181
|
-
}
|
182
|
-
catch {
|
183
|
-
// If a plugin cannot be resolved, we will need projects to resolve it
|
184
|
-
projectsWithoutInference ??=
|
185
|
-
await (0, retrieve_workspace_files_1.retrieveProjectConfigurationsWithoutPluginInference)(root);
|
186
|
-
}
|
187
178
|
const moduleName = typeof pluginConfiguration === 'string'
|
188
179
|
? pluginConfiguration
|
189
180
|
: pluginConfiguration.plugin;
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
181
|
+
try {
|
182
|
+
try {
|
183
|
+
require.resolve(moduleName);
|
184
|
+
}
|
185
|
+
catch {
|
186
|
+
// If a plugin cannot be resolved, we will need projects to resolve it
|
187
|
+
projectsWithoutInference ??=
|
188
|
+
await (0, retrieve_workspace_files_1.retrieveProjectConfigurationsWithoutPluginInference)(root);
|
189
|
+
}
|
190
|
+
performance.mark(`Load Nx Plugin: ${moduleName} - start`);
|
191
|
+
let { pluginPath, name } = await getPluginPathAndName(moduleName, paths, projectsWithoutInference, root);
|
192
|
+
const plugin = (0, utils_1.normalizeNxPlugin)(await importPluginModule(pluginPath));
|
193
|
+
plugin.name ??= name;
|
194
|
+
performance.mark(`Load Nx Plugin: ${moduleName} - end`);
|
195
|
+
performance.measure(`Load Nx Plugin: ${moduleName}`, `Load Nx Plugin: ${moduleName} - start`, `Load Nx Plugin: ${moduleName} - end`);
|
196
|
+
return new internal_api_1.LoadedNxPlugin(plugin, pluginConfiguration);
|
197
|
+
}
|
198
|
+
catch (e) {
|
199
|
+
throw new error_types_1.LoadPluginError(moduleName, e);
|
200
|
+
}
|
197
201
|
}
|
198
202
|
exports.loadNxPluginAsync = loadNxPluginAsync;
|
199
203
|
async function importPluginModule(pluginPath) {
|
@@ -1,9 +1,5 @@
|
|
1
|
-
import { ProcessDependenciesError, ProcessProjectGraphError } from './build-project-graph';
|
2
1
|
import { ProjectGraph } from '../config/project-graph';
|
3
2
|
import { ProjectConfiguration, ProjectsConfigurations } from '../config/workspace-json-project-json';
|
4
|
-
import { ConfigurationSourceMaps } from './utils/project-configuration-utils';
|
5
|
-
import { CreateNodesError, MergeNodesError, ProjectsWithNoNameError, ProjectsWithConflictingNamesError } from './error-types';
|
6
|
-
import { DaemonProjectGraphError } from '../daemon/daemon-project-graph-error';
|
7
3
|
/**
|
8
4
|
* Synchronously reads the latest cached copy of the workspace's ProjectGraph.
|
9
5
|
* @throws {Error} if there is no cached ProjectGraph to read from
|
@@ -16,26 +12,8 @@ export declare function readCachedProjectConfiguration(projectName: string): Pro
|
|
16
12
|
export declare function readProjectsConfigurationFromProjectGraph(projectGraph: ProjectGraph): ProjectsConfigurations;
|
17
13
|
export declare function buildProjectGraphAndSourceMapsWithoutDaemon(): Promise<{
|
18
14
|
projectGraph: ProjectGraph;
|
19
|
-
sourceMaps: ConfigurationSourceMaps;
|
15
|
+
sourceMaps: import("./utils/project-configuration-utils").ConfigurationSourceMaps;
|
20
16
|
}>;
|
21
|
-
export declare class ProjectGraphError extends Error {
|
22
|
-
#private;
|
23
|
-
constructor(errors: Array<CreateNodesError | MergeNodesError | ProjectsWithNoNameError | ProjectsWithConflictingNamesError | ProcessDependenciesError | ProcessProjectGraphError>, partialProjectGraph: ProjectGraph, partialSourceMaps: ConfigurationSourceMaps);
|
24
|
-
/**
|
25
|
-
* The daemon cannot throw errors which contain methods as they are not serializable.
|
26
|
-
*
|
27
|
-
* This method creates a new {@link ProjectGraphError} from a {@link DaemonProjectGraphError} with the methods based on the same serialized data.
|
28
|
-
*/
|
29
|
-
static fromDaemonProjectGraphError(e: DaemonProjectGraphError): ProjectGraphError;
|
30
|
-
/**
|
31
|
-
* This gets the partial project graph despite the errors which occured.
|
32
|
-
* This partial project graph may be missing nodes, properties of nodes, or dependencies.
|
33
|
-
* This is useful mostly for visualization/debugging. It should not be used for running tasks.
|
34
|
-
*/
|
35
|
-
getPartialProjectGraph(): ProjectGraph;
|
36
|
-
getPartialSourcemaps(): ConfigurationSourceMaps;
|
37
|
-
getErrors(): (ProjectsWithConflictingNamesError | ProjectsWithNoNameError | MergeNodesError | CreateNodesError | ProcessDependenciesError | ProcessProjectGraphError)[];
|
38
|
-
}
|
39
17
|
/**
|
40
18
|
* Computes and returns a ProjectGraph.
|
41
19
|
*
|
@@ -66,5 +44,5 @@ export declare function createProjectGraphAndSourceMapsAsync(opts?: {
|
|
66
44
|
resetDaemonClient?: boolean;
|
67
45
|
}): Promise<{
|
68
46
|
projectGraph: ProjectGraph;
|
69
|
-
sourceMaps: ConfigurationSourceMaps;
|
47
|
+
sourceMaps: import("./utils/project-configuration-utils").ConfigurationSourceMaps;
|
70
48
|
}>;
|
@@ -1,21 +1,19 @@
|
|
1
1
|
"use strict";
|
2
|
-
var _ProjectGraphError_errors, _ProjectGraphError_partialProjectGraph, _ProjectGraphError_partialSourceMaps;
|
3
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
4
|
-
exports.createProjectGraphAndSourceMapsAsync = exports.createProjectGraphAsync = exports.
|
5
|
-
const
|
6
|
-
const
|
7
|
-
const build_project_graph_1 = require("./build-project-graph");
|
8
|
-
const output_1 = require("../utils/output");
|
9
|
-
const tmp_dir_1 = require("../daemon/tmp-dir");
|
10
|
-
const strip_indents_1 = require("../utils/strip-indents");
|
3
|
+
exports.createProjectGraphAndSourceMapsAsync = exports.createProjectGraphAsync = exports.buildProjectGraphAndSourceMapsWithoutDaemon = exports.readProjectsConfigurationFromProjectGraph = exports.readCachedProjectConfiguration = exports.readCachedProjectGraph = void 0;
|
4
|
+
const perf_hooks_1 = require("perf_hooks");
|
5
|
+
const nx_json_1 = require("../config/nx-json");
|
11
6
|
const client_1 = require("../daemon/client/client");
|
7
|
+
const tmp_dir_1 = require("../daemon/tmp-dir");
|
12
8
|
const fileutils_1 = require("../utils/fileutils");
|
9
|
+
const output_1 = require("../utils/output");
|
10
|
+
const strip_indents_1 = require("../utils/strip-indents");
|
13
11
|
const workspace_root_1 = require("../utils/workspace-root");
|
14
|
-
const
|
15
|
-
const
|
16
|
-
const nx_json_1 = require("../config/nx-json");
|
12
|
+
const build_project_graph_1 = require("./build-project-graph");
|
13
|
+
const nx_deps_cache_1 = require("./nx-deps-cache");
|
17
14
|
const error_types_1 = require("./error-types");
|
18
15
|
const internal_api_1 = require("./plugins/internal-api");
|
16
|
+
const retrieve_workspace_files_1 = require("./utils/retrieve-workspace-files");
|
19
17
|
/**
|
20
18
|
* Synchronously reads the latest cached copy of the workspace's ProjectGraph.
|
21
19
|
* @throws {Error} if there is no cached ProjectGraph to read from
|
@@ -122,7 +120,7 @@ async function buildProjectGraphAndSourceMapsWithoutDaemon() {
|
|
122
120
|
...(createDependenciesError?.errors ?? []),
|
123
121
|
];
|
124
122
|
if (errors.length > 0) {
|
125
|
-
throw new ProjectGraphError(errors, projectGraph, sourceMaps);
|
123
|
+
throw new error_types_1.ProjectGraphError(errors, projectGraph, sourceMaps);
|
126
124
|
}
|
127
125
|
else {
|
128
126
|
if (cacheEnabled) {
|
@@ -132,49 +130,10 @@ async function buildProjectGraphAndSourceMapsWithoutDaemon() {
|
|
132
130
|
}
|
133
131
|
}
|
134
132
|
exports.buildProjectGraphAndSourceMapsWithoutDaemon = buildProjectGraphAndSourceMapsWithoutDaemon;
|
135
|
-
class ProjectGraphError extends Error {
|
136
|
-
constructor(errors, partialProjectGraph, partialSourceMaps) {
|
137
|
-
super(`Failed to process project graph.`);
|
138
|
-
_ProjectGraphError_errors.set(this, void 0);
|
139
|
-
_ProjectGraphError_partialProjectGraph.set(this, void 0);
|
140
|
-
_ProjectGraphError_partialSourceMaps.set(this, void 0);
|
141
|
-
this.name = this.constructor.name;
|
142
|
-
tslib_1.__classPrivateFieldSet(this, _ProjectGraphError_errors, errors, "f");
|
143
|
-
tslib_1.__classPrivateFieldSet(this, _ProjectGraphError_partialProjectGraph, partialProjectGraph, "f");
|
144
|
-
tslib_1.__classPrivateFieldSet(this, _ProjectGraphError_partialSourceMaps, partialSourceMaps, "f");
|
145
|
-
this.stack = `${this.message}\n ${errors
|
146
|
-
.map((error) => error.stack.split('\n').join('\n '))
|
147
|
-
.join('\n')}`;
|
148
|
-
}
|
149
|
-
/**
|
150
|
-
* The daemon cannot throw errors which contain methods as they are not serializable.
|
151
|
-
*
|
152
|
-
* This method creates a new {@link ProjectGraphError} from a {@link DaemonProjectGraphError} with the methods based on the same serialized data.
|
153
|
-
*/
|
154
|
-
static fromDaemonProjectGraphError(e) {
|
155
|
-
return new ProjectGraphError(e.errors, e.projectGraph, e.sourceMaps);
|
156
|
-
}
|
157
|
-
/**
|
158
|
-
* This gets the partial project graph despite the errors which occured.
|
159
|
-
* This partial project graph may be missing nodes, properties of nodes, or dependencies.
|
160
|
-
* This is useful mostly for visualization/debugging. It should not be used for running tasks.
|
161
|
-
*/
|
162
|
-
getPartialProjectGraph() {
|
163
|
-
return tslib_1.__classPrivateFieldGet(this, _ProjectGraphError_partialProjectGraph, "f");
|
164
|
-
}
|
165
|
-
getPartialSourcemaps() {
|
166
|
-
return tslib_1.__classPrivateFieldGet(this, _ProjectGraphError_partialSourceMaps, "f");
|
167
|
-
}
|
168
|
-
getErrors() {
|
169
|
-
return tslib_1.__classPrivateFieldGet(this, _ProjectGraphError_errors, "f");
|
170
|
-
}
|
171
|
-
}
|
172
|
-
exports.ProjectGraphError = ProjectGraphError;
|
173
|
-
_ProjectGraphError_errors = new WeakMap(), _ProjectGraphError_partialProjectGraph = new WeakMap(), _ProjectGraphError_partialSourceMaps = new WeakMap();
|
174
133
|
function handleProjectGraphError(opts, e) {
|
175
134
|
if (opts.exitOnError) {
|
176
135
|
const isVerbose = process.env.NX_VERBOSE_LOGGING === 'true';
|
177
|
-
if (e instanceof ProjectGraphError) {
|
136
|
+
if (e instanceof error_types_1.ProjectGraphError) {
|
178
137
|
let title = e.message;
|
179
138
|
if (isVerbose) {
|
180
139
|
title += ' See errors below.';
|
@@ -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("
|
12
|
+
allWorkspaceFiles: import("../file-utils").FileData[];
|
13
13
|
fileMap: {
|
14
14
|
projectFileMap: ProjectFiles;
|
15
|
-
nonProjectFiles: import("
|
15
|
+
nonProjectFiles: import("../../native").FileData[];
|
16
16
|
};
|
17
|
-
rustReferences: import("
|
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.
|
@@ -8,8 +8,10 @@ const run_command_1 = require("./run-command");
|
|
8
8
|
const invoke_runner_terminal_output_life_cycle_1 = require("./life-cycles/invoke-runner-terminal-output-life-cycle");
|
9
9
|
const perf_hooks_1 = require("perf_hooks");
|
10
10
|
const utils_1 = require("./utils");
|
11
|
+
const dotenv_1 = require("../utils/dotenv");
|
11
12
|
async function initTasksRunner(nxArgs) {
|
12
13
|
perf_hooks_1.performance.mark('init-local');
|
14
|
+
(0, dotenv_1.loadRootEnvFiles)();
|
13
15
|
(0, workspace_configuration_check_1.workspaceConfigurationCheck)();
|
14
16
|
const nxJson = (0, configuration_1.readNxJson)();
|
15
17
|
if (nxArgs.verbose) {
|
@@ -24,6 +24,10 @@ const EXTENDED_LEFT_PAD = ` `;
|
|
24
24
|
*/
|
25
25
|
async function createRunManyDynamicOutputRenderer({ projectNames, tasks, args, overrides, }) {
|
26
26
|
cliCursor.hide();
|
27
|
+
// Show the cursor again after the process exits
|
28
|
+
process.on('exit', () => {
|
29
|
+
cliCursor.show();
|
30
|
+
});
|
27
31
|
let resolveRenderIsDonePromise;
|
28
32
|
const renderIsDone = new Promise((resolve) => (resolveRenderIsDonePromise = resolve)).then(() => {
|
29
33
|
clearRenderInterval();
|
@@ -24,6 +24,10 @@ const EXTENDED_LEFT_PAD = ` `;
|
|
24
24
|
*/
|
25
25
|
async function createRunOneDynamicOutputRenderer({ initiatingProject, tasks, args, overrides, }) {
|
26
26
|
cliCursor.hide();
|
27
|
+
// Show the cursor again after the process exits
|
28
|
+
process.on('exit', () => {
|
29
|
+
cliCursor.show();
|
30
|
+
});
|
27
31
|
let resolveRenderIsDonePromise;
|
28
32
|
const renderIsDone = new Promise((resolve) => (resolveRenderIsDonePromise = resolve)).then(() => {
|
29
33
|
clearRenderInterval();
|
@@ -142,6 +142,12 @@ function supportedPtyPlatform() {
|
|
142
142
|
if (process.platform !== 'win32') {
|
143
143
|
return true;
|
144
144
|
}
|
145
|
+
// TODO: Re-enable Windows support when it's stable
|
146
|
+
// Currently, there's an issue with control chars.
|
147
|
+
// See: https://github.com/nrwl/nx/issues/22358
|
148
|
+
if (process.env.NX_WINDOWS_PTY_SUPPORT !== 'true') {
|
149
|
+
return false;
|
150
|
+
}
|
145
151
|
let windowsVersion = os.release().split('.');
|
146
152
|
let windowsBuild = windowsVersion[2];
|
147
153
|
if (!windowsBuild) {
|