nx 19.0.0-beta.1 → 19.0.0-beta.10
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 +1 -1
- package/migrations.json +2 -25
- package/package.json +12 -12
- package/src/command-line/add/add.js +17 -16
- package/src/command-line/affected/affected.js +1 -1
- package/src/command-line/graph/graph.d.ts +11 -1
- package/src/command-line/graph/graph.js +97 -13
- package/src/command-line/init/implementation/react/index.js +1 -1
- package/src/command-line/release/changelog.js +1 -1
- package/src/command-line/release/command-object.js +2 -2
- package/src/command-line/release/publish.js +1 -1
- package/src/command-line/report/report.js +1 -1
- package/src/command-line/run/run-one.js +1 -1
- package/src/command-line/run-many/run-many.js +1 -1
- package/src/command-line/yargs-utils/shared-options.js +1 -1
- package/src/config/nx-json.d.ts +2 -2
- package/src/config/to-project-name.d.ts +5 -0
- package/src/config/to-project-name.js +13 -0
- package/src/core/graph/index.html +1 -2
- package/src/core/graph/main.js +1 -1
- package/src/core/graph/runtime.js +1 -1
- package/src/core/graph/styles.css +2 -2
- package/src/core/graph/styles.js +1 -1
- package/src/daemon/client/client.d.ts +2 -2
- package/src/daemon/client/client.js +21 -6
- package/src/daemon/server/project-graph-incremental-recomputation.js +8 -8
- package/src/daemon/server/shutdown-utils.js +7 -2
- package/src/daemon/tmp-dir.js +2 -2
- package/src/devkit-exports.d.ts +1 -5
- package/src/devkit-exports.js +1 -7
- package/src/devkit-internals.d.ts +2 -0
- package/src/devkit-internals.js +5 -1
- package/src/executors/run-commands/run-commands.impl.d.ts +2 -0
- package/src/executors/run-commands/run-commands.impl.js +69 -23
- package/src/executors/run-commands/schema.json +19 -2
- package/src/executors/utils/convert-nx-executor.js +2 -1
- package/src/generators/testing-utils/create-tree-with-empty-workspace.js +7 -0
- package/src/generators/utils/project-configuration.js +3 -8
- package/src/hasher/task-hasher.d.ts +4 -4
- package/src/native/index.d.ts +1 -1
- package/src/plugins/js/lock-file/pnpm-parser.js +109 -67
- package/src/plugins/package-json-workspaces/create-nodes.d.ts +1 -0
- package/src/plugins/package-json-workspaces/create-nodes.js +25 -20
- package/src/plugins/project-json/build-nodes/project-json.js +2 -2
- package/src/project-graph/affected/locators/workspace-projects.js +3 -1
- package/src/project-graph/build-project-graph.d.ts +8 -18
- package/src/project-graph/build-project-graph.js +86 -57
- package/src/project-graph/error-types.d.ts +31 -3
- package/src/project-graph/error-types.js +74 -2
- package/src/project-graph/file-utils.d.ts +2 -3
- package/src/project-graph/file-utils.js +5 -9
- package/src/project-graph/plugins/internal-api.d.ts +3 -2
- package/src/project-graph/plugins/internal-api.js +3 -0
- package/src/project-graph/plugins/isolation/messaging.d.ts +26 -3
- package/src/project-graph/plugins/isolation/plugin-pool.js +23 -1
- package/src/project-graph/plugins/isolation/plugin-worker.js +21 -0
- package/src/project-graph/plugins/loader.js +14 -6
- package/src/project-graph/plugins/public-api.d.ts +11 -1
- package/src/project-graph/plugins/utils.d.ts +2 -2
- package/src/project-graph/plugins/utils.js +19 -24
- package/src/project-graph/project-graph.d.ts +3 -0
- package/src/project-graph/project-graph.js +8 -7
- package/src/project-graph/utils/find-project-for-path.js +2 -3
- package/src/project-graph/utils/normalize-project-nodes.d.ts +1 -1
- package/src/project-graph/utils/normalize-project-nodes.js +8 -14
- package/src/project-graph/utils/project-configuration-utils.d.ts +23 -6
- package/src/project-graph/utils/project-configuration-utils.js +43 -20
- package/src/tasks-runner/create-task-graph.js +0 -1
- package/src/tasks-runner/life-cycles/dynamic-run-many-terminal-output-life-cycle.js +5 -1
- package/src/tasks-runner/life-cycles/dynamic-run-one-terminal-output-life-cycle.js +4 -0
- package/src/tasks-runner/pseudo-terminal.d.ts +2 -1
- package/src/tasks-runner/pseudo-terminal.js +8 -2
- package/src/tasks-runner/run-command.js +4 -4
- package/src/tasks-runner/utils.js +17 -0
- package/src/utils/assert-workspace-validity.js +2 -1
- package/src/utils/command-line-utils.d.ts +1 -1
- package/src/utils/nx-plugin.deprecated.d.ts +1 -1
- package/src/utils/nx-plugin.deprecated.js +1 -1
- package/src/utils/params.js +4 -0
- package/src/utils/perf-logging.js +3 -1
- package/src/command-line/repair.d.ts +0 -4
- package/src/command-line/repair.js +0 -7
- package/src/command-line/run-many.d.ts +0 -4
- package/src/command-line/run-many.js +0 -7
- package/src/command-line/run-one.d.ts +0 -4
- package/src/command-line/run-one.js +0 -7
- package/src/command-line/run.d.ts +0 -4
- package/src/command-line/run.js +0 -7
- package/src/command-line/watch.d.ts +0 -4
- package/src/command-line/watch.js +0 -7
- package/src/config/workspaces.d.ts +0 -18
- package/src/config/workspaces.js +0 -35
- package/src/core/graph/3rdpartylicenses.txt +0 -785
- package/src/migrations/update-15-1-0/set-project-names.d.ts +0 -2
- package/src/migrations/update-15-1-0/set-project-names.js +0 -34
- package/src/migrations/update-15-8-2/update-nxw.d.ts +0 -2
- package/src/migrations/update-15-8-2/update-nxw.js +0 -7
- package/src/utils/typescript.d.ts +0 -1
- package/src/utils/typescript.js +0 -5
@@ -1,6 +1,6 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
exports.
|
3
|
+
exports.applyProjectMetadata = exports.buildProjectGraphUsingProjectFileMap = exports.getFileMap = void 0;
|
4
4
|
const workspace_root_1 = require("../utils/workspace-root");
|
5
5
|
const path_1 = require("path");
|
6
6
|
const perf_hooks_1 = require("perf_hooks");
|
@@ -15,6 +15,8 @@ const project_graph_builder_1 = require("./project-graph-builder");
|
|
15
15
|
const configuration_1 = require("../config/configuration");
|
16
16
|
const fs_1 = require("fs");
|
17
17
|
const output_1 = require("../utils/output");
|
18
|
+
const error_types_1 = require("./error-types");
|
19
|
+
const project_configuration_utils_1 = require("./utils/project-configuration-utils");
|
18
20
|
let storedFileMap = null;
|
19
21
|
let storedAllWorkspaceFiles = null;
|
20
22
|
let storedRustReferences = null;
|
@@ -38,13 +40,26 @@ function getFileMap() {
|
|
38
40
|
}
|
39
41
|
}
|
40
42
|
exports.getFileMap = getFileMap;
|
41
|
-
async function buildProjectGraphUsingProjectFileMap(
|
43
|
+
async function buildProjectGraphUsingProjectFileMap(projectRootMap, externalNodes, fileMap, allWorkspaceFiles, rustReferences, fileMapCache, plugins, sourceMap) {
|
42
44
|
storedFileMap = fileMap;
|
43
45
|
storedAllWorkspaceFiles = allWorkspaceFiles;
|
44
46
|
storedRustReferences = rustReferences;
|
47
|
+
const projects = {};
|
48
|
+
for (const root in projectRootMap) {
|
49
|
+
const project = projectRootMap[root];
|
50
|
+
projects[project.name] = project;
|
51
|
+
}
|
52
|
+
const errors = [];
|
45
53
|
const nxJson = (0, configuration_1.readNxJson)();
|
46
54
|
const projectGraphVersion = '6.0';
|
47
|
-
|
55
|
+
try {
|
56
|
+
(0, assert_workspace_validity_1.assertWorkspaceValidity)(projects, nxJson);
|
57
|
+
}
|
58
|
+
catch (e) {
|
59
|
+
if ((0, error_types_1.isWorkspaceValidityError)(e)) {
|
60
|
+
errors.push(e);
|
61
|
+
}
|
62
|
+
}
|
48
63
|
const packageJsonDeps = readCombinedDeps();
|
49
64
|
const rootTsConfig = readRootTsConfig();
|
50
65
|
let filesToProcess;
|
@@ -63,9 +78,26 @@ async function buildProjectGraphUsingProjectFileMap(projects, externalNodes, fil
|
|
63
78
|
projectFileMap: {},
|
64
79
|
};
|
65
80
|
}
|
66
|
-
|
67
|
-
let
|
68
|
-
|
81
|
+
let projectGraph;
|
82
|
+
let projectFileMapCache;
|
83
|
+
try {
|
84
|
+
const context = createContext(projects, nxJson, externalNodes, fileMap, filesToProcess);
|
85
|
+
projectGraph = await buildProjectGraphUsingContext(externalNodes, context, cachedFileData, projectGraphVersion, plugins, sourceMap);
|
86
|
+
projectFileMapCache = (0, nx_deps_cache_1.createProjectFileMapCache)(nxJson, packageJsonDeps, fileMap, rootTsConfig);
|
87
|
+
}
|
88
|
+
catch (e) {
|
89
|
+
// we need to include the workspace validity errors in the final error
|
90
|
+
if ((0, error_types_1.isAggregateProjectGraphError)(e)) {
|
91
|
+
errors.push(...e.errors);
|
92
|
+
throw new error_types_1.AggregateProjectGraphError(errors, e.partialProjectGraph);
|
93
|
+
}
|
94
|
+
else {
|
95
|
+
throw e;
|
96
|
+
}
|
97
|
+
}
|
98
|
+
if (errors.length > 0) {
|
99
|
+
throw new error_types_1.AggregateProjectGraphError(errors, projectGraph);
|
100
|
+
}
|
69
101
|
return {
|
70
102
|
projectGraph,
|
71
103
|
projectFileMapCache,
|
@@ -88,7 +120,7 @@ function readCombinedDeps() {
|
|
88
120
|
...installationPackageJson.devDependencies,
|
89
121
|
};
|
90
122
|
}
|
91
|
-
async function buildProjectGraphUsingContext(knownExternalNodes, ctx, cachedFileData, projectGraphVersion, plugins) {
|
123
|
+
async function buildProjectGraphUsingContext(knownExternalNodes, ctx, cachedFileData, projectGraphVersion, plugins, sourceMap) {
|
92
124
|
perf_hooks_1.performance.mark('build project graph:start');
|
93
125
|
const builder = new project_graph_builder_1.ProjectGraphBuilder(null, ctx.fileMap.projectFileMap);
|
94
126
|
builder.setVersion(projectGraphVersion);
|
@@ -100,10 +132,10 @@ async function buildProjectGraphUsingContext(knownExternalNodes, ctx, cachedFile
|
|
100
132
|
let updatedGraph;
|
101
133
|
let error;
|
102
134
|
try {
|
103
|
-
updatedGraph = await updateProjectGraphWithPlugins(ctx, initProjectGraph, plugins);
|
135
|
+
updatedGraph = await updateProjectGraphWithPlugins(ctx, initProjectGraph, plugins, sourceMap);
|
104
136
|
}
|
105
137
|
catch (e) {
|
106
|
-
if (
|
138
|
+
if ((0, error_types_1.isAggregateProjectGraphError)(e)) {
|
107
139
|
updatedGraph = e.partialProjectGraph;
|
108
140
|
error = e;
|
109
141
|
}
|
@@ -134,26 +166,20 @@ async function buildProjectGraphUsingContext(knownExternalNodes, ctx, cachedFile
|
|
134
166
|
return finalGraph;
|
135
167
|
}
|
136
168
|
else {
|
137
|
-
throw new
|
169
|
+
throw new error_types_1.AggregateProjectGraphError(error.errors, finalGraph);
|
138
170
|
}
|
139
171
|
}
|
140
172
|
function createContext(projects, nxJson, externalNodes, fileMap, filesToProcess) {
|
141
|
-
const clonedProjects = Object.keys(projects).reduce((map, projectName) => {
|
142
|
-
map[projectName] = {
|
143
|
-
...projects[projectName],
|
144
|
-
};
|
145
|
-
return map;
|
146
|
-
}, {});
|
147
173
|
return {
|
148
174
|
nxJsonConfiguration: nxJson,
|
149
|
-
projects
|
175
|
+
projects,
|
150
176
|
externalNodes,
|
151
177
|
workspaceRoot: workspace_root_1.workspaceRoot,
|
152
178
|
fileMap,
|
153
179
|
filesToProcess,
|
154
180
|
};
|
155
181
|
}
|
156
|
-
async function updateProjectGraphWithPlugins(context, initProjectGraph, plugins) {
|
182
|
+
async function updateProjectGraphWithPlugins(context, initProjectGraph, plugins, sourceMap) {
|
157
183
|
let graph = initProjectGraph;
|
158
184
|
const errors = [];
|
159
185
|
for (const plugin of plugins) {
|
@@ -187,7 +213,7 @@ async function updateProjectGraphWithPlugins(context, initProjectGraph, plugins)
|
|
187
213
|
}
|
188
214
|
}
|
189
215
|
catch (e) {
|
190
|
-
errors.push(new ProcessProjectGraphError(plugin.name, {
|
216
|
+
errors.push(new error_types_1.ProcessProjectGraphError(plugin.name, {
|
191
217
|
cause: e,
|
192
218
|
}));
|
193
219
|
}
|
@@ -205,52 +231,24 @@ async function updateProjectGraphWithPlugins(context, initProjectGraph, plugins)
|
|
205
231
|
}
|
206
232
|
}
|
207
233
|
catch (cause) {
|
208
|
-
errors.push(new ProcessDependenciesError(plugin.name, {
|
234
|
+
errors.push(new error_types_1.ProcessDependenciesError(plugin.name, {
|
209
235
|
cause,
|
210
236
|
}));
|
211
237
|
}
|
212
238
|
perf_hooks_1.performance.mark(`${plugin.name}:createDependencies - end`);
|
213
239
|
perf_hooks_1.performance.measure(`${plugin.name}:createDependencies`, `${plugin.name}:createDependencies - start`, `${plugin.name}:createDependencies - end`);
|
214
240
|
}));
|
215
|
-
const
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
class ProcessDependenciesError extends Error {
|
224
|
-
constructor(pluginName, { cause }) {
|
225
|
-
super(`The "${pluginName}" plugin threw an error while creating dependencies:`, {
|
226
|
-
cause,
|
227
|
-
});
|
228
|
-
this.pluginName = pluginName;
|
229
|
-
this.name = this.constructor.name;
|
230
|
-
this.stack = `${this.message}\n ${cause.stack.split('\n').join('\n ')}`;
|
231
|
-
}
|
232
|
-
}
|
233
|
-
exports.ProcessDependenciesError = ProcessDependenciesError;
|
234
|
-
class ProcessProjectGraphError extends Error {
|
235
|
-
constructor(pluginName, { cause }) {
|
236
|
-
super(`The "${pluginName}" plugin threw an error while processing the project graph:`, {
|
237
|
-
cause,
|
238
|
-
});
|
239
|
-
this.pluginName = pluginName;
|
240
|
-
this.name = this.constructor.name;
|
241
|
-
this.stack = `${this.message}\n ${cause.stack.split('\n').join('\n ')}`;
|
242
|
-
}
|
243
|
-
}
|
244
|
-
exports.ProcessProjectGraphError = ProcessProjectGraphError;
|
245
|
-
class CreateDependenciesError extends Error {
|
246
|
-
constructor(errors, partialProjectGraph) {
|
247
|
-
super('Failed to create dependencies. See above for errors');
|
248
|
-
this.errors = errors;
|
249
|
-
this.partialProjectGraph = partialProjectGraph;
|
250
|
-
this.name = this.constructor.name;
|
241
|
+
const graphWithDeps = builder.getUpdatedProjectGraph();
|
242
|
+
const { errors: metadataErrors, graph: updatedGraph } = await applyProjectMetadata(graphWithDeps, plugins, {
|
243
|
+
nxJsonConfiguration: context.nxJsonConfiguration,
|
244
|
+
workspaceRoot: workspace_root_1.workspaceRoot,
|
245
|
+
}, sourceMap);
|
246
|
+
errors.push(...metadataErrors);
|
247
|
+
if (errors.length > 0) {
|
248
|
+
throw new error_types_1.AggregateProjectGraphError(errors, updatedGraph);
|
251
249
|
}
|
250
|
+
return updatedGraph;
|
252
251
|
}
|
253
|
-
exports.CreateDependenciesError = CreateDependenciesError;
|
254
252
|
function readRootTsConfig() {
|
255
253
|
try {
|
256
254
|
const tsConfigPath = (0, typescript_1.getRootTsConfigPath)();
|
@@ -262,3 +260,34 @@ function readRootTsConfig() {
|
|
262
260
|
return {};
|
263
261
|
}
|
264
262
|
}
|
263
|
+
async function applyProjectMetadata(graph, plugins, context, sourceMap) {
|
264
|
+
const results = [];
|
265
|
+
const errors = [];
|
266
|
+
const promises = plugins.map(async (plugin) => {
|
267
|
+
if ((0, utils_1.isNxPluginV2)(plugin) && plugin.createMetadata) {
|
268
|
+
perf_hooks_1.performance.mark(`${plugin.name}:createMetadata - start`);
|
269
|
+
try {
|
270
|
+
const metadata = await plugin.createMetadata(graph, undefined, context);
|
271
|
+
results.push({ metadata, pluginName: plugin.name });
|
272
|
+
}
|
273
|
+
catch (e) {
|
274
|
+
errors.push(new error_types_1.CreateMetadataError(e, plugin.name));
|
275
|
+
}
|
276
|
+
finally {
|
277
|
+
perf_hooks_1.performance.mark(`${plugin.name}:createMetadata - end`);
|
278
|
+
perf_hooks_1.performance.measure(`${plugin.name}:createMetadata`, `${plugin.name}:createMetadata - start`, `${plugin.name}:createMetadata - end`);
|
279
|
+
}
|
280
|
+
}
|
281
|
+
});
|
282
|
+
await Promise.all(promises);
|
283
|
+
for (const { metadata: projectsMetadata, pluginName } of results) {
|
284
|
+
for (const project in projectsMetadata) {
|
285
|
+
const projectConfiguration = graph.nodes[project]?.data;
|
286
|
+
if (projectConfiguration) {
|
287
|
+
projectConfiguration.metadata = (0, project_configuration_utils_1.mergeMetadata)(sourceMap[project], [null, pluginName], 'metadata', projectsMetadata[project].metadata, projectConfiguration.metadata);
|
288
|
+
}
|
289
|
+
}
|
290
|
+
}
|
291
|
+
return { errors, graph };
|
292
|
+
}
|
293
|
+
exports.applyProjectMetadata = applyProjectMetadata;
|
@@ -1,11 +1,10 @@
|
|
1
1
|
import { CreateNodesResultWithContext } from './plugins/internal-api';
|
2
2
|
import { ConfigurationResult, ConfigurationSourceMaps } from './utils/project-configuration-utils';
|
3
3
|
import { ProjectConfiguration } from '../config/workspace-json-project-json';
|
4
|
-
import { ProcessDependenciesError, ProcessProjectGraphError } from './build-project-graph';
|
5
4
|
import { ProjectGraph } from '../config/project-graph';
|
6
5
|
export declare class ProjectGraphError extends Error {
|
7
6
|
#private;
|
8
|
-
constructor(errors: Array<CreateNodesError | MergeNodesError | ProjectsWithNoNameError | ProjectsWithConflictingNamesError | ProcessDependenciesError | ProcessProjectGraphError>, partialProjectGraph: ProjectGraph, partialSourceMaps: ConfigurationSourceMaps);
|
7
|
+
constructor(errors: Array<CreateNodesError | MergeNodesError | ProjectsWithNoNameError | ProjectsWithConflictingNamesError | ProcessDependenciesError | ProcessProjectGraphError | CreateMetadataError | WorkspaceValidityError>, partialProjectGraph: ProjectGraph, partialSourceMaps: ConfigurationSourceMaps);
|
9
8
|
/**
|
10
9
|
* The daemon cannot throw errors which contain methods as they are not serializable.
|
11
10
|
*
|
@@ -19,7 +18,7 @@ export declare class ProjectGraphError extends Error {
|
|
19
18
|
*/
|
20
19
|
getPartialProjectGraph(): ProjectGraph;
|
21
20
|
getPartialSourcemaps(): ConfigurationSourceMaps;
|
22
|
-
getErrors(): (
|
21
|
+
getErrors(): (CreateNodesError | MergeNodesError | ProjectsWithNoNameError | ProjectsWithConflictingNamesError | CreateMetadataError | ProcessDependenciesError | ProcessProjectGraphError | WorkspaceValidityError)[];
|
23
22
|
}
|
24
23
|
export declare class ProjectsWithConflictingNamesError extends Error {
|
25
24
|
projects: Record<string, ProjectConfiguration>;
|
@@ -60,6 +59,35 @@ export declare class MergeNodesError extends Error {
|
|
60
59
|
error: Error;
|
61
60
|
});
|
62
61
|
}
|
62
|
+
export declare class CreateMetadataError extends Error {
|
63
|
+
readonly error: Error;
|
64
|
+
readonly plugin: string;
|
65
|
+
constructor(error: Error, plugin: string);
|
66
|
+
}
|
67
|
+
export declare class ProcessDependenciesError extends Error {
|
68
|
+
readonly pluginName: string;
|
69
|
+
constructor(pluginName: string, { cause }: {
|
70
|
+
cause: any;
|
71
|
+
});
|
72
|
+
}
|
73
|
+
export declare class WorkspaceValidityError extends Error {
|
74
|
+
message: string;
|
75
|
+
constructor(message: string);
|
76
|
+
}
|
77
|
+
export declare function isWorkspaceValidityError(e: unknown): e is WorkspaceValidityError;
|
78
|
+
export declare class ProcessProjectGraphError extends Error {
|
79
|
+
readonly pluginName: string;
|
80
|
+
constructor(pluginName: string, { cause }: {
|
81
|
+
cause: any;
|
82
|
+
});
|
83
|
+
}
|
84
|
+
export declare class AggregateProjectGraphError extends Error {
|
85
|
+
readonly errors: Array<CreateMetadataError | ProcessDependenciesError | ProcessProjectGraphError | WorkspaceValidityError>;
|
86
|
+
readonly partialProjectGraph: ProjectGraph;
|
87
|
+
constructor(errors: Array<CreateMetadataError | ProcessDependenciesError | ProcessProjectGraphError | WorkspaceValidityError>, partialProjectGraph: ProjectGraph);
|
88
|
+
}
|
89
|
+
export declare function isAggregateProjectGraphError(e: unknown): e is AggregateProjectGraphError;
|
90
|
+
export declare function isCreateMetadataError(e: unknown): e is CreateMetadataError;
|
63
91
|
export declare function isCreateNodesError(e: unknown): e is CreateNodesError;
|
64
92
|
export declare function isAggregateCreateNodesError(e: unknown): e is AggregateCreateNodesError;
|
65
93
|
export declare function isMergeNodesError(e: unknown): e is MergeNodesError;
|
@@ -1,11 +1,11 @@
|
|
1
1
|
"use strict";
|
2
2
|
var _ProjectGraphError_errors, _ProjectGraphError_partialProjectGraph, _ProjectGraphError_partialSourceMaps;
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
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;
|
4
|
+
exports.LoadPluginError = exports.DaemonProjectGraphError = exports.isMergeNodesError = exports.isAggregateCreateNodesError = exports.isCreateNodesError = exports.isCreateMetadataError = exports.isAggregateProjectGraphError = exports.AggregateProjectGraphError = exports.ProcessProjectGraphError = exports.isWorkspaceValidityError = exports.WorkspaceValidityError = exports.ProcessDependenciesError = exports.CreateMetadataError = exports.MergeNodesError = exports.AggregateCreateNodesError = exports.CreateNodesError = exports.ProjectConfigurationsError = exports.isProjectsWithNoNameError = exports.ProjectsWithNoNameError = exports.isProjectsWithConflictingNamesError = exports.ProjectsWithConflictingNamesError = exports.ProjectGraphError = void 0;
|
5
5
|
const tslib_1 = require("tslib");
|
6
6
|
class ProjectGraphError extends Error {
|
7
7
|
constructor(errors, partialProjectGraph, partialSourceMaps) {
|
8
|
-
super(`Failed to process project graph.`);
|
8
|
+
super(`Failed to process project graph. Run "nx reset" to fix this. Please report the issue if you keep seeing it.`);
|
9
9
|
_ProjectGraphError_errors.set(this, void 0);
|
10
10
|
_ProjectGraphError_partialProjectGraph.set(this, void 0);
|
11
11
|
_ProjectGraphError_partialSourceMaps.set(this, void 0);
|
@@ -118,6 +118,78 @@ class MergeNodesError extends Error {
|
|
118
118
|
}
|
119
119
|
}
|
120
120
|
exports.MergeNodesError = MergeNodesError;
|
121
|
+
class CreateMetadataError extends Error {
|
122
|
+
constructor(error, plugin) {
|
123
|
+
super(`The "${plugin}" plugin threw an error while creating metadata:`, {
|
124
|
+
cause: error,
|
125
|
+
});
|
126
|
+
this.error = error;
|
127
|
+
this.plugin = plugin;
|
128
|
+
this.name = this.constructor.name;
|
129
|
+
}
|
130
|
+
}
|
131
|
+
exports.CreateMetadataError = CreateMetadataError;
|
132
|
+
class ProcessDependenciesError extends Error {
|
133
|
+
constructor(pluginName, { cause }) {
|
134
|
+
super(`The "${pluginName}" plugin threw an error while creating dependencies:`, {
|
135
|
+
cause,
|
136
|
+
});
|
137
|
+
this.pluginName = pluginName;
|
138
|
+
this.name = this.constructor.name;
|
139
|
+
this.stack = `${this.message}\n ${cause.stack.split('\n').join('\n ')}`;
|
140
|
+
}
|
141
|
+
}
|
142
|
+
exports.ProcessDependenciesError = ProcessDependenciesError;
|
143
|
+
class WorkspaceValidityError extends Error {
|
144
|
+
constructor(message) {
|
145
|
+
message = `Configuration Error\n${message}`;
|
146
|
+
super(message);
|
147
|
+
this.message = message;
|
148
|
+
this.name = this.constructor.name;
|
149
|
+
}
|
150
|
+
}
|
151
|
+
exports.WorkspaceValidityError = WorkspaceValidityError;
|
152
|
+
function isWorkspaceValidityError(e) {
|
153
|
+
return (e instanceof WorkspaceValidityError ||
|
154
|
+
(typeof e === 'object' &&
|
155
|
+
'name' in e &&
|
156
|
+
e?.name === WorkspaceValidityError.name));
|
157
|
+
}
|
158
|
+
exports.isWorkspaceValidityError = isWorkspaceValidityError;
|
159
|
+
class ProcessProjectGraphError extends Error {
|
160
|
+
constructor(pluginName, { cause }) {
|
161
|
+
super(`The "${pluginName}" plugin threw an error while processing the project graph:`, {
|
162
|
+
cause,
|
163
|
+
});
|
164
|
+
this.pluginName = pluginName;
|
165
|
+
this.name = this.constructor.name;
|
166
|
+
this.stack = `${this.message}\n ${cause.stack.split('\n').join('\n ')}`;
|
167
|
+
}
|
168
|
+
}
|
169
|
+
exports.ProcessProjectGraphError = ProcessProjectGraphError;
|
170
|
+
class AggregateProjectGraphError extends Error {
|
171
|
+
constructor(errors, partialProjectGraph) {
|
172
|
+
super('Failed to create project graph. See above for errors');
|
173
|
+
this.errors = errors;
|
174
|
+
this.partialProjectGraph = partialProjectGraph;
|
175
|
+
this.name = this.constructor.name;
|
176
|
+
}
|
177
|
+
}
|
178
|
+
exports.AggregateProjectGraphError = AggregateProjectGraphError;
|
179
|
+
function isAggregateProjectGraphError(e) {
|
180
|
+
return (e instanceof AggregateProjectGraphError ||
|
181
|
+
(typeof e === 'object' &&
|
182
|
+
'name' in e &&
|
183
|
+
e?.name === AggregateProjectGraphError.prototype.name));
|
184
|
+
}
|
185
|
+
exports.isAggregateProjectGraphError = isAggregateProjectGraphError;
|
186
|
+
function isCreateMetadataError(e) {
|
187
|
+
return (e instanceof CreateMetadataError ||
|
188
|
+
(typeof e === 'object' &&
|
189
|
+
'name' in e &&
|
190
|
+
e?.name === CreateMetadataError.prototype.name));
|
191
|
+
}
|
192
|
+
exports.isCreateMetadataError = isCreateMetadataError;
|
121
193
|
function isCreateNodesError(e) {
|
122
194
|
return (e instanceof CreateNodesError ||
|
123
195
|
(typeof e === 'object' && 'name' in e && e?.name === CreateNodesError.name));
|
@@ -18,8 +18,8 @@ export declare function isDeletedFileChange(change: Change): change is DeletedFi
|
|
18
18
|
export declare function calculateFileChanges(files: string[], allWorkspaceFiles: FileData[], nxArgs?: NxArgs, readFileAtRevision?: (f: string, r: void | string) => string, ignore?: any): FileChange[];
|
19
19
|
export declare const TEN_MEGABYTES: number;
|
20
20
|
/**
|
21
|
-
* TODO(
|
22
|
-
* @deprecated To get projects use {@link retrieveProjectConfigurations} instead
|
21
|
+
* TODO(v20): Remove this function
|
22
|
+
* @deprecated To get projects use {@link retrieveProjectConfigurations} instead. This will be removed in v20.
|
23
23
|
*/
|
24
24
|
export declare function readWorkspaceConfig(opts: {
|
25
25
|
format: 'angularCli' | 'nx';
|
@@ -28,4 +28,3 @@ export declare function readWorkspaceConfig(opts: {
|
|
28
28
|
export declare function defaultFileRead(filePath: string): string | null;
|
29
29
|
export declare function readPackageJson(): any;
|
30
30
|
export { FileData };
|
31
|
-
export { readNxJson, workspaceLayout } from '../config/configuration';
|
@@ -1,6 +1,6 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
exports.
|
3
|
+
exports.readPackageJson = exports.defaultFileRead = exports.readWorkspaceConfig = exports.TEN_MEGABYTES = exports.calculateFileChanges = exports.isDeletedFileChange = exports.isWholeFileChange = exports.DeletedFileChange = exports.WholeFileChange = void 0;
|
4
4
|
const child_process_1 = require("child_process");
|
5
5
|
const fs_1 = require("fs");
|
6
6
|
const path_1 = require("path");
|
@@ -98,8 +98,8 @@ function defaultReadFileAtRevision(file, revision) {
|
|
98
98
|
}
|
99
99
|
}
|
100
100
|
/**
|
101
|
-
* TODO(
|
102
|
-
* @deprecated To get projects use {@link retrieveProjectConfigurations} instead
|
101
|
+
* TODO(v20): Remove this function
|
102
|
+
* @deprecated To get projects use {@link retrieveProjectConfigurations} instead. This will be removed in v20.
|
103
103
|
*/
|
104
104
|
function readWorkspaceConfig(opts) {
|
105
105
|
let configuration = null;
|
@@ -139,12 +139,8 @@ function readPackageJson() {
|
|
139
139
|
}
|
140
140
|
}
|
141
141
|
exports.readPackageJson = readPackageJson;
|
142
|
-
// TODO(17): Remove these exports
|
143
|
-
var configuration_2 = require("../config/configuration");
|
144
|
-
Object.defineProperty(exports, "readNxJson", { enumerable: true, get: function () { return configuration_2.readNxJson; } });
|
145
|
-
Object.defineProperty(exports, "workspaceLayout", { enumerable: true, get: function () { return configuration_2.workspaceLayout; } });
|
146
142
|
/**
|
147
|
-
* TODO(
|
143
|
+
* TODO(v20): Remove this function.
|
148
144
|
*/
|
149
145
|
function getProjectsSyncNoInference(root, nxJson) {
|
150
146
|
const allConfigFiles = (0, retrieve_workspace_files_1.retrieveProjectConfigurationPaths)(root, (0, nx_plugin_deprecated_1.getDefaultPluginsSync)(root));
|
@@ -152,7 +148,7 @@ function getProjectsSyncNoInference(root, nxJson) {
|
|
152
148
|
package_json_next_to_project_json_1.PackageJsonProjectsNextToProjectJsonPlugin,
|
153
149
|
...(0, nx_plugin_deprecated_1.getDefaultPluginsSync)(root),
|
154
150
|
];
|
155
|
-
const projectRootMap =
|
151
|
+
const projectRootMap = {};
|
156
152
|
// We iterate over plugins first - this ensures that plugins specified first take precedence.
|
157
153
|
for (const plugin of plugins) {
|
158
154
|
const [pattern, createNodes] = plugin.createNodes ?? [];
|
@@ -1,7 +1,7 @@
|
|
1
1
|
import { PluginConfiguration } from '../../config/nx-json';
|
2
2
|
import { NxPluginV1 } from '../../utils/nx-plugin.deprecated';
|
3
|
-
import { CreateDependencies, CreateDependenciesContext, CreateNodesContext, CreateNodesResult, NxPluginV2 } from './public-api';
|
4
|
-
import { ProjectGraphProcessor } from '../../config/project-graph';
|
3
|
+
import { CreateDependencies, CreateDependenciesContext, CreateMetadata, CreateMetadataContext, CreateNodesContext, CreateNodesResult, NxPluginV2 } from './public-api';
|
4
|
+
import { ProjectGraph, ProjectGraphProcessor } from '../../config/project-graph';
|
5
5
|
export declare class LoadedNxPlugin {
|
6
6
|
readonly name: string;
|
7
7
|
readonly createNodes?: [
|
@@ -9,6 +9,7 @@ export declare class LoadedNxPlugin {
|
|
9
9
|
fn: (matchedFiles: string[], context: CreateNodesContext) => Promise<CreateNodesResultWithContext[]>
|
10
10
|
];
|
11
11
|
readonly createDependencies?: (context: CreateDependenciesContext) => ReturnType<CreateDependencies>;
|
12
|
+
readonly createMetadata?: (graph: ProjectGraph, context: CreateMetadataContext) => ReturnType<CreateMetadata>;
|
12
13
|
readonly processProjectGraph?: ProjectGraphProcessor;
|
13
14
|
readonly options?: unknown;
|
14
15
|
readonly include?: string[];
|
@@ -26,6 +26,9 @@ class LoadedNxPlugin {
|
|
26
26
|
if (plugin.createDependencies) {
|
27
27
|
this.createDependencies = (context) => plugin.createDependencies(this.options, context);
|
28
28
|
}
|
29
|
+
if (plugin.createMetadata) {
|
30
|
+
this.createMetadata = (graph, context) => plugin.createMetadata(graph, this.options, context);
|
31
|
+
}
|
29
32
|
this.processProjectGraph = plugin.processProjectGraph;
|
30
33
|
}
|
31
34
|
}
|
@@ -1,7 +1,7 @@
|
|
1
1
|
/// <reference types="node" />
|
2
2
|
import { ProjectGraph, ProjectGraphProcessorContext } from '../../../config/project-graph';
|
3
3
|
import { PluginConfiguration } from '../../../config/nx-json';
|
4
|
-
import { CreateDependenciesContext, CreateNodesContext } from '../public-api';
|
4
|
+
import { CreateDependenciesContext, CreateMetadataContext, CreateNodesContext } from '../public-api';
|
5
5
|
import { LoadedNxPlugin } from '../internal-api';
|
6
6
|
import { Serializable } from 'child_process';
|
7
7
|
export interface PluginWorkerLoadMessage {
|
@@ -15,9 +15,12 @@ export interface PluginWorkerLoadResult {
|
|
15
15
|
type: 'load-result';
|
16
16
|
payload: {
|
17
17
|
name: string;
|
18
|
+
include?: string[];
|
19
|
+
exclude?: string[];
|
18
20
|
createNodesPattern: string;
|
19
21
|
hasCreateDependencies: boolean;
|
20
22
|
hasProcessProjectGraph: boolean;
|
23
|
+
hasCreateMetadata: boolean;
|
21
24
|
success: true;
|
22
25
|
} | {
|
23
26
|
success: false;
|
@@ -51,6 +54,14 @@ export interface PluginCreateDependenciesMessage {
|
|
51
54
|
tx: string;
|
52
55
|
};
|
53
56
|
}
|
57
|
+
export interface PluginCreateMetadataMessage {
|
58
|
+
type: 'createMetadata';
|
59
|
+
payload: {
|
60
|
+
graph: ProjectGraph;
|
61
|
+
context: CreateMetadataContext;
|
62
|
+
tx: string;
|
63
|
+
};
|
64
|
+
}
|
54
65
|
export interface PluginCreateDependenciesResult {
|
55
66
|
type: 'createDependenciesResult';
|
56
67
|
payload: {
|
@@ -63,6 +74,18 @@ export interface PluginCreateDependenciesResult {
|
|
63
74
|
tx: string;
|
64
75
|
};
|
65
76
|
}
|
77
|
+
export interface PluginCreateMetadataResult {
|
78
|
+
type: 'createMetadataResult';
|
79
|
+
payload: {
|
80
|
+
metadata: ReturnType<LoadedNxPlugin['createMetadata']>;
|
81
|
+
success: true;
|
82
|
+
tx: string;
|
83
|
+
} | {
|
84
|
+
success: false;
|
85
|
+
error: string;
|
86
|
+
tx: string;
|
87
|
+
};
|
88
|
+
}
|
66
89
|
export interface PluginWorkerProcessProjectGraphMessage {
|
67
90
|
type: 'processProjectGraph';
|
68
91
|
payload: {
|
@@ -83,8 +106,8 @@ export interface PluginWorkerProcessProjectGraphResult {
|
|
83
106
|
tx: string;
|
84
107
|
};
|
85
108
|
}
|
86
|
-
export type PluginWorkerMessage = PluginWorkerLoadMessage | PluginWorkerCreateNodesMessage | PluginCreateDependenciesMessage | PluginWorkerProcessProjectGraphMessage;
|
87
|
-
export type PluginWorkerResult = PluginWorkerLoadResult | PluginWorkerCreateNodesResult | PluginCreateDependenciesResult | PluginWorkerProcessProjectGraphResult;
|
109
|
+
export type PluginWorkerMessage = PluginWorkerLoadMessage | PluginWorkerCreateNodesMessage | PluginCreateDependenciesMessage | PluginWorkerProcessProjectGraphMessage | PluginCreateMetadataMessage;
|
110
|
+
export type PluginWorkerResult = PluginWorkerLoadResult | PluginWorkerCreateNodesResult | PluginCreateDependenciesResult | PluginWorkerProcessProjectGraphResult | PluginCreateMetadataResult;
|
88
111
|
export declare function isPluginWorkerMessage(message: Serializable): message is PluginWorkerMessage;
|
89
112
|
export declare function isPluginWorkerResult(message: Serializable): message is PluginWorkerResult;
|
90
113
|
type MaybePromise<T> = T | Promise<T>;
|
@@ -73,11 +73,13 @@ function createWorkerHandler(worker, pending, onload, onloadError) {
|
|
73
73
|
return (0, messaging_1.consumeMessage)(message, {
|
74
74
|
'load-result': (result) => {
|
75
75
|
if (result.success) {
|
76
|
-
const { name, createNodesPattern } = result;
|
76
|
+
const { name, createNodesPattern, include, exclude } = result;
|
77
77
|
pluginName = name;
|
78
78
|
pluginNames.set(worker, pluginName);
|
79
79
|
onload({
|
80
80
|
name,
|
81
|
+
include,
|
82
|
+
exclude,
|
81
83
|
createNodes: createNodesPattern
|
82
84
|
? [
|
83
85
|
createNodesPattern,
|
@@ -114,6 +116,17 @@ function createWorkerHandler(worker, pending, onload, onloadError) {
|
|
114
116
|
});
|
115
117
|
}
|
116
118
|
: undefined,
|
119
|
+
createMetadata: result.hasCreateMetadata
|
120
|
+
? (graph, ctx) => {
|
121
|
+
const tx = pluginName + ':createMetadata:' + performance.now();
|
122
|
+
return registerPendingPromise(tx, pending, () => {
|
123
|
+
worker.send({
|
124
|
+
type: 'createMetadata',
|
125
|
+
payload: { graph, context: ctx, tx },
|
126
|
+
});
|
127
|
+
});
|
128
|
+
}
|
129
|
+
: undefined,
|
117
130
|
});
|
118
131
|
}
|
119
132
|
else if (result.success === false) {
|
@@ -147,6 +160,15 @@ function createWorkerHandler(worker, pending, onload, onloadError) {
|
|
147
160
|
rejector(result.error);
|
148
161
|
}
|
149
162
|
},
|
163
|
+
createMetadataResult: ({ tx, ...result }) => {
|
164
|
+
const { resolver, rejector } = pending.get(tx);
|
165
|
+
if (result.success) {
|
166
|
+
resolver(result.metadata);
|
167
|
+
}
|
168
|
+
else if (result.success === false) {
|
169
|
+
rejector(result.error);
|
170
|
+
}
|
171
|
+
},
|
150
172
|
});
|
151
173
|
};
|
152
174
|
}
|
@@ -3,6 +3,9 @@ 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
|
+
if (process.env.NX_PERF_LOGGING === 'true') {
|
7
|
+
require('../../../utils/perf-logging');
|
8
|
+
}
|
6
9
|
global.NX_GRAPH_CREATION = true;
|
7
10
|
let plugin;
|
8
11
|
process.on('message', async (message) => {
|
@@ -19,9 +22,12 @@ process.on('message', async (message) => {
|
|
19
22
|
type: 'load-result',
|
20
23
|
payload: {
|
21
24
|
name: plugin.name,
|
25
|
+
include: plugin.include,
|
26
|
+
exclude: plugin.exclude,
|
22
27
|
createNodesPattern: plugin.createNodes?.[0],
|
23
28
|
hasCreateDependencies: 'createDependencies' in plugin && !!plugin.createDependencies,
|
24
29
|
hasProcessProjectGraph: 'processProjectGraph' in plugin && !!plugin.processProjectGraph,
|
30
|
+
hasCreateMetadata: 'createMetadata' in plugin && !!plugin.createMetadata,
|
25
31
|
success: true,
|
26
32
|
},
|
27
33
|
};
|
@@ -93,5 +99,20 @@ process.on('message', async (message) => {
|
|
93
99
|
};
|
94
100
|
}
|
95
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
|
+
},
|
96
117
|
});
|
97
118
|
});
|