nx 18.3.0-beta.0 → 18.3.0-beta.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/post-install.js +7 -5
- package/package.json +12 -12
- package/src/adapter/angular-json.d.ts +2 -1
- package/src/adapter/angular-json.js +1 -0
- package/src/adapter/ngcli-adapter.d.ts +2 -2
- package/src/adapter/ngcli-adapter.js +13 -13
- package/src/command-line/generate/generator-utils.js +2 -2
- package/src/command-line/init/implementation/add-nx-to-monorepo.js +1 -1
- package/src/command-line/init/implementation/add-nx-to-npm-repo.js +1 -1
- package/src/command-line/init/implementation/react/index.js +1 -1
- package/src/command-line/init/implementation/utils.d.ts +1 -1
- package/src/command-line/init/implementation/utils.js +2 -7
- package/src/command-line/init/init-v2.js +29 -37
- package/src/command-line/release/command-object.js +1 -1
- package/src/command-line/run/executor-utils.js +2 -2
- package/src/config/nx-json.d.ts +2 -1
- package/src/config/schema-utils.js +2 -2
- package/src/core/graph/3rdpartylicenses.txt +23 -26
- package/src/core/graph/main.js +1 -1
- package/src/core/graph/runtime.js +1 -1
- package/src/core/graph/styles.js +1 -1
- package/src/daemon/client/client.js +1 -2
- package/src/daemon/server/plugins.d.ts +3 -0
- package/src/daemon/server/plugins.js +22 -0
- package/src/daemon/server/project-graph-incremental-recomputation.js +11 -10
- package/src/daemon/server/shutdown-utils.js +2 -0
- package/src/devkit-exports.d.ts +3 -2
- package/src/devkit-internals.d.ts +3 -0
- package/src/devkit-internals.js +7 -1
- package/src/executors/run-commands/run-commands.impl.d.ts +4 -1
- package/src/executors/run-commands/run-commands.impl.js +51 -4
- package/src/executors/utils/convert-nx-executor.js +4 -1
- package/src/generators/utils/project-configuration.js +2 -2
- package/src/migrations/update-15-1-0/set-project-names.js +4 -2
- package/src/native/assert-supported-platform.js +1 -1
- package/src/plugins/js/index.d.ts +1 -1
- package/src/plugins/js/lock-file/lock-file.d.ts +1 -1
- package/src/plugins/js/lock-file/npm-parser.d.ts +1 -1
- package/src/plugins/js/lock-file/pnpm-parser.d.ts +1 -1
- package/src/plugins/js/lock-file/yarn-parser.d.ts +1 -1
- package/src/plugins/js/project-graph/build-dependencies/build-dependencies.d.ts +1 -1
- package/src/plugins/js/project-graph/build-dependencies/explicit-package-json-dependencies.d.ts +1 -1
- package/src/plugins/js/project-graph/build-dependencies/explicit-project-dependencies.d.ts +1 -1
- package/src/plugins/package-json-workspaces/create-nodes.d.ts +2 -2
- package/src/plugins/package-json-workspaces/create-nodes.js +24 -31
- package/src/plugins/package-json-workspaces/index.d.ts +1 -0
- package/src/plugins/package-json-workspaces/index.js +2 -0
- package/src/plugins/project-json/build-nodes/package-json-next-to-project-json.d.ts +2 -1
- package/src/plugins/project-json/build-nodes/package-json-next-to-project-json.js +1 -0
- package/src/plugins/project-json/build-nodes/project-json.d.ts +2 -1
- package/src/plugins/project-json/build-nodes/project-json.js +1 -0
- package/src/plugins/target-defaults/symbols.d.ts +17 -0
- package/src/plugins/target-defaults/symbols.js +20 -0
- package/src/plugins/target-defaults/target-defaults-plugin.d.ts +2 -18
- package/src/plugins/target-defaults/target-defaults-plugin.js +5 -20
- package/src/project-graph/affected/locators/project-glob-changes.js +3 -3
- package/src/project-graph/build-project-graph.d.ts +2 -1
- package/src/project-graph/build-project-graph.js +11 -13
- package/src/project-graph/error-types.d.ts +45 -0
- package/src/project-graph/error-types.js +100 -0
- package/src/project-graph/file-utils.js +3 -3
- package/src/project-graph/plugins/index.d.ts +2 -0
- package/src/project-graph/plugins/index.js +8 -0
- package/src/project-graph/plugins/internal-api.d.ts +28 -0
- package/src/project-graph/plugins/internal-api.js +85 -0
- package/src/project-graph/plugins/isolation/index.d.ts +3 -0
- package/src/project-graph/plugins/isolation/index.js +16 -0
- package/src/project-graph/plugins/isolation/messaging.d.ts +94 -0
- package/src/project-graph/plugins/isolation/messaging.js +23 -0
- package/src/project-graph/plugins/isolation/plugin-pool.d.ts +3 -0
- package/src/project-graph/plugins/isolation/plugin-pool.js +189 -0
- package/src/project-graph/plugins/isolation/plugin-worker.d.ts +1 -0
- package/src/project-graph/plugins/isolation/plugin-worker.js +81 -0
- package/src/project-graph/plugins/loader.d.ts +24 -0
- package/src/project-graph/plugins/loader.js +206 -0
- package/src/{utils/nx-plugin.d.ts → project-graph/plugins/public-api.d.ts} +8 -44
- package/src/project-graph/plugins/public-api.js +4 -0
- package/src/project-graph/plugins/utils.d.ts +7 -0
- package/src/project-graph/plugins/utils.js +80 -0
- package/src/project-graph/project-graph-builder.d.ts +1 -1
- package/src/project-graph/project-graph.d.ts +4 -3
- package/src/project-graph/project-graph.js +9 -7
- package/src/project-graph/utils/normalize-project-nodes.d.ts +1 -1
- package/src/project-graph/utils/project-configuration-utils.d.ts +3 -26
- package/src/project-graph/utils/project-configuration-utils.js +54 -109
- package/src/project-graph/utils/retrieve-workspace-files.d.ts +11 -10
- package/src/project-graph/utils/retrieve-workspace-files.js +19 -26
- package/src/tasks-runner/cache.js +1 -1
- package/src/utils/is-ci.js +1 -1
- package/src/utils/logger.d.ts +1 -0
- package/src/utils/logger.js +5 -0
- package/src/utils/nx-plugin.deprecated.d.ts +2 -2
- package/src/utils/nx-plugin.deprecated.js +5 -7
- package/src/utils/plugins/plugin-capabilities.d.ts +1 -1
- package/src/utils/plugins/plugin-capabilities.js +18 -12
- package/src/utils/nx-plugin.js +0 -309
@@ -0,0 +1,80 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.runCreateNodesInParallel = exports.normalizeNxPlugin = exports.isNxPluginV1 = exports.isNxPluginV2 = void 0;
|
4
|
+
const node_path_1 = require("node:path");
|
5
|
+
const workspaces_1 = require("../../config/workspaces");
|
6
|
+
const globs_1 = require("../../utils/globs");
|
7
|
+
const error_types_1 = require("../error-types");
|
8
|
+
function isNxPluginV2(plugin) {
|
9
|
+
return 'createNodes' in plugin || 'createDependencies' in plugin;
|
10
|
+
}
|
11
|
+
exports.isNxPluginV2 = isNxPluginV2;
|
12
|
+
function isNxPluginV1(plugin) {
|
13
|
+
return 'processProjectGraph' in plugin || 'projectFilePatterns' in plugin;
|
14
|
+
}
|
15
|
+
exports.isNxPluginV1 = isNxPluginV1;
|
16
|
+
function normalizeNxPlugin(plugin) {
|
17
|
+
if (isNxPluginV2(plugin)) {
|
18
|
+
return plugin;
|
19
|
+
}
|
20
|
+
if (isNxPluginV1(plugin) && plugin.projectFilePatterns) {
|
21
|
+
return {
|
22
|
+
...plugin,
|
23
|
+
createNodes: [
|
24
|
+
`*/**/${(0, globs_1.combineGlobPatterns)(plugin.projectFilePatterns)}`,
|
25
|
+
(configFilePath) => {
|
26
|
+
const root = (0, node_path_1.dirname)(configFilePath);
|
27
|
+
return {
|
28
|
+
projects: {
|
29
|
+
[root]: {
|
30
|
+
name: (0, workspaces_1.toProjectName)(configFilePath),
|
31
|
+
targets: plugin.registerProjectTargets?.(configFilePath),
|
32
|
+
},
|
33
|
+
},
|
34
|
+
};
|
35
|
+
},
|
36
|
+
],
|
37
|
+
};
|
38
|
+
}
|
39
|
+
return plugin;
|
40
|
+
}
|
41
|
+
exports.normalizeNxPlugin = normalizeNxPlugin;
|
42
|
+
async function runCreateNodesInParallel(configFiles, plugin, options, context) {
|
43
|
+
performance.mark(`${plugin.name}:createNodes - start`);
|
44
|
+
const errors = [];
|
45
|
+
const results = [];
|
46
|
+
const promises = configFiles.map((file) => {
|
47
|
+
performance.mark(`${plugin.name}:createNodes:${file} - start`);
|
48
|
+
// Result is either static or a promise, using Promise.resolve lets us
|
49
|
+
// handle both cases with same logic
|
50
|
+
const value = Promise.resolve(plugin.createNodes[1](file, options, context));
|
51
|
+
return value
|
52
|
+
.catch((e) => {
|
53
|
+
performance.mark(`${plugin.name}:createNodes:${file} - end`);
|
54
|
+
errors.push(new error_types_1.CreateNodesError({
|
55
|
+
error: e,
|
56
|
+
pluginName: plugin.name,
|
57
|
+
file,
|
58
|
+
}));
|
59
|
+
return null;
|
60
|
+
})
|
61
|
+
.then((r) => {
|
62
|
+
performance.mark(`${plugin.name}:createNodes:${file} - end`);
|
63
|
+
performance.measure(`${plugin.name}:createNodes:${file}`, `${plugin.name}:createNodes:${file} - start`, `${plugin.name}:createNodes:${file} - end`);
|
64
|
+
// Existing behavior is to ignore null results of
|
65
|
+
// createNodes function.
|
66
|
+
if (r) {
|
67
|
+
results.push(r);
|
68
|
+
}
|
69
|
+
});
|
70
|
+
});
|
71
|
+
await Promise.all(promises).then(() => {
|
72
|
+
performance.mark(`${plugin.name}:createNodes - end`);
|
73
|
+
performance.measure(`${plugin.name}:createNodes`, `${plugin.name}:createNodes - start`, `${plugin.name}:createNodes - end`);
|
74
|
+
});
|
75
|
+
if (errors.length > 0) {
|
76
|
+
throw new error_types_1.AggregateCreateNodesError(plugin.name, errors, results);
|
77
|
+
}
|
78
|
+
return results;
|
79
|
+
}
|
80
|
+
exports.runCreateNodesInParallel = runCreateNodesInParallel;
|
@@ -2,7 +2,7 @@
|
|
2
2
|
* Builder for adding nodes and dependencies to a {@link ProjectGraph}
|
3
3
|
*/
|
4
4
|
import { DependencyType, FileMap, ProjectFileMap, ProjectGraph, ProjectGraphExternalNode, ProjectGraphProjectNode } from '../config/project-graph';
|
5
|
-
import { CreateDependenciesContext } from '
|
5
|
+
import { CreateDependenciesContext } from './plugins';
|
6
6
|
/**
|
7
7
|
* A class which builds up a project graph
|
8
8
|
* @deprecated The {@link ProjectGraphProcessor} has been deprecated. Use a {@link CreateNodes} and/or a {@link CreateDependencies} instead. This will be removed in Nx 19.
|
@@ -1,7 +1,8 @@
|
|
1
1
|
import { ProcessDependenciesError, ProcessProjectGraphError } from './build-project-graph';
|
2
2
|
import { ProjectGraph } from '../config/project-graph';
|
3
3
|
import { ProjectConfiguration, ProjectsConfigurations } from '../config/workspace-json-project-json';
|
4
|
-
import { ConfigurationSourceMaps
|
4
|
+
import { ConfigurationSourceMaps } from './utils/project-configuration-utils';
|
5
|
+
import { CreateNodesError, MergeNodesError, ProjectsWithNoNameError, ProjectsWithConflictingNamesError } from './error-types';
|
5
6
|
import { DaemonProjectGraphError } from '../daemon/daemon-project-graph-error';
|
6
7
|
/**
|
7
8
|
* Synchronously reads the latest cached copy of the workspace's ProjectGraph.
|
@@ -19,7 +20,7 @@ export declare function buildProjectGraphAndSourceMapsWithoutDaemon(): Promise<{
|
|
19
20
|
}>;
|
20
21
|
export declare class ProjectGraphError extends Error {
|
21
22
|
#private;
|
22
|
-
constructor(errors: Array<CreateNodesError | MergeNodesError | ProcessDependenciesError | ProcessProjectGraphError>, partialProjectGraph: ProjectGraph, partialSourceMaps: ConfigurationSourceMaps);
|
23
|
+
constructor(errors: Array<CreateNodesError | MergeNodesError | ProjectsWithNoNameError | ProjectsWithConflictingNamesError | ProcessDependenciesError | ProcessProjectGraphError>, partialProjectGraph: ProjectGraph, partialSourceMaps: ConfigurationSourceMaps);
|
23
24
|
/**
|
24
25
|
* The daemon cannot throw errors which contain methods as they are not serializable.
|
25
26
|
*
|
@@ -33,7 +34,7 @@ export declare class ProjectGraphError extends Error {
|
|
33
34
|
*/
|
34
35
|
getPartialProjectGraph(): ProjectGraph;
|
35
36
|
getPartialSourcemaps(): ConfigurationSourceMaps;
|
36
|
-
getErrors(): (
|
37
|
+
getErrors(): (ProjectsWithConflictingNamesError | ProjectsWithNoNameError | MergeNodesError | CreateNodesError | ProcessDependenciesError | ProcessProjectGraphError)[];
|
37
38
|
}
|
38
39
|
/**
|
39
40
|
* Computes and returns a ProjectGraph.
|
@@ -14,8 +14,8 @@ const workspace_root_1 = require("../utils/workspace-root");
|
|
14
14
|
const perf_hooks_1 = require("perf_hooks");
|
15
15
|
const retrieve_workspace_files_1 = require("./utils/retrieve-workspace-files");
|
16
16
|
const nx_json_1 = require("../config/nx-json");
|
17
|
-
const
|
18
|
-
const
|
17
|
+
const error_types_1 = require("./error-types");
|
18
|
+
const internal_api_1 = require("./plugins/internal-api");
|
19
19
|
/**
|
20
20
|
* Synchronously reads the latest cached copy of the workspace's ProjectGraph.
|
21
21
|
* @throws {Error} if there is no cached ProjectGraph to read from
|
@@ -69,17 +69,17 @@ function readProjectsConfigurationFromProjectGraph(projectGraph) {
|
|
69
69
|
}
|
70
70
|
exports.readProjectsConfigurationFromProjectGraph = readProjectsConfigurationFromProjectGraph;
|
71
71
|
async function buildProjectGraphAndSourceMapsWithoutDaemon() {
|
72
|
-
// Set this globally to allow plugins to know if they are being called from the project graph creation
|
73
72
|
global.NX_GRAPH_CREATION = true;
|
74
73
|
const nxJson = (0, nx_json_1.readNxJson)();
|
75
74
|
perf_hooks_1.performance.mark('retrieve-project-configurations:start');
|
76
75
|
let configurationResult;
|
77
76
|
let projectConfigurationsError;
|
77
|
+
const [plugins, cleanup] = await (0, internal_api_1.loadNxPlugins)(nxJson.plugins);
|
78
78
|
try {
|
79
|
-
configurationResult = await (0, retrieve_workspace_files_1.retrieveProjectConfigurations)(workspace_root_1.workspaceRoot, nxJson);
|
79
|
+
configurationResult = await (0, retrieve_workspace_files_1.retrieveProjectConfigurations)(plugins, workspace_root_1.workspaceRoot, nxJson);
|
80
80
|
}
|
81
81
|
catch (e) {
|
82
|
-
if (e instanceof
|
82
|
+
if (e instanceof error_types_1.ProjectConfigurationsError) {
|
83
83
|
projectConfigurationsError = e;
|
84
84
|
configurationResult = e.partialProjectConfigurationsResult;
|
85
85
|
}
|
@@ -97,7 +97,7 @@ async function buildProjectGraphAndSourceMapsWithoutDaemon() {
|
|
97
97
|
let createDependenciesError;
|
98
98
|
let projectGraphResult;
|
99
99
|
try {
|
100
|
-
projectGraphResult = await (0, build_project_graph_1.buildProjectGraphUsingProjectFileMap)(projects, externalNodes, fileMap, allWorkspaceFiles, rustReferences, cacheEnabled ? (0, nx_deps_cache_1.readFileMapCache)() : null);
|
100
|
+
projectGraphResult = await (0, build_project_graph_1.buildProjectGraphUsingProjectFileMap)(projects, externalNodes, fileMap, allWorkspaceFiles, rustReferences, cacheEnabled ? (0, nx_deps_cache_1.readFileMapCache)() : null, plugins);
|
101
101
|
}
|
102
102
|
catch (e) {
|
103
103
|
if (e instanceof build_project_graph_1.CreateDependenciesError) {
|
@@ -111,9 +111,11 @@ async function buildProjectGraphAndSourceMapsWithoutDaemon() {
|
|
111
111
|
throw e;
|
112
112
|
}
|
113
113
|
}
|
114
|
+
finally {
|
115
|
+
cleanup();
|
116
|
+
}
|
114
117
|
const { projectGraph, projectFileMapCache } = projectGraphResult;
|
115
118
|
perf_hooks_1.performance.mark('build-project-graph-using-project-file-map:end');
|
116
|
-
(0, nx_plugin_1.unregisterPluginTSTranspiler)();
|
117
119
|
delete global.NX_GRAPH_CREATION;
|
118
120
|
const errors = [
|
119
121
|
...(projectConfigurationsError?.errors ?? []),
|
@@ -1,7 +1,7 @@
|
|
1
1
|
import { ProjectGraphProjectNode } from '../../config/project-graph';
|
2
2
|
import { ProjectGraphBuilder } from '../project-graph-builder';
|
3
3
|
import { ProjectConfiguration, TargetConfiguration } from '../../config/workspace-json-project-json';
|
4
|
-
import { CreateDependenciesContext } from '
|
4
|
+
import { CreateDependenciesContext } from '../plugins';
|
5
5
|
export declare function normalizeProjectNodes(ctx: CreateDependenciesContext, builder: ProjectGraphBuilder): Promise<void>;
|
6
6
|
/**
|
7
7
|
* Apply target defaults and normalization
|
@@ -1,8 +1,8 @@
|
|
1
1
|
import { NxJsonConfiguration, TargetDefaults } from '../../config/nx-json';
|
2
2
|
import { ProjectGraphExternalNode } from '../../config/project-graph';
|
3
3
|
import { ProjectConfiguration, TargetConfiguration } from '../../config/workspace-json-project-json';
|
4
|
-
import {
|
5
|
-
import {
|
4
|
+
import { ONLY_MODIFIES_EXISTING_TARGET } from '../../plugins/target-defaults/symbols';
|
5
|
+
import { LoadedNxPlugin } from '../plugins/internal-api';
|
6
6
|
export type SourceInformation = [file: string, plugin: string];
|
7
7
|
export type ConfigurationSourceMaps = Record<string, Record<string, SourceInformation>>;
|
8
8
|
export declare function mergeProjectConfigurationIntoRootMap(projectRootMap: Map<string, ProjectConfiguration>, project: ProjectConfiguration & {
|
@@ -24,32 +24,9 @@ export type ConfigurationResult = {
|
|
24
24
|
* @param workspaceFiles A list of non-ignored workspace files
|
25
25
|
* @param plugins The plugins that should be used to infer project configuration
|
26
26
|
*/
|
27
|
-
export declare function createProjectConfigurations(root: string, nxJson: NxJsonConfiguration,
|
27
|
+
export declare function createProjectConfigurations(root: string, nxJson: NxJsonConfiguration, projectFiles: string[], // making this parameter allows devkit to pick up newly created projects
|
28
28
|
plugins: LoadedNxPlugin[]): Promise<ConfigurationResult>;
|
29
29
|
export declare function readProjectConfigurationsFromRootMap(projectRootMap: Map<string, ProjectConfiguration>): Record<string, ProjectConfiguration>;
|
30
|
-
export declare class ProjectConfigurationsError extends Error {
|
31
|
-
readonly errors: Array<MergeNodesError | CreateNodesError>;
|
32
|
-
readonly partialProjectConfigurationsResult: ConfigurationResult;
|
33
|
-
constructor(errors: Array<MergeNodesError | CreateNodesError>, partialProjectConfigurationsResult: ConfigurationResult);
|
34
|
-
}
|
35
|
-
export declare class CreateNodesError extends Error {
|
36
|
-
file: string;
|
37
|
-
pluginName: string;
|
38
|
-
constructor({ file, pluginName, error, }: {
|
39
|
-
file: string;
|
40
|
-
pluginName: string;
|
41
|
-
error: Error;
|
42
|
-
});
|
43
|
-
}
|
44
|
-
export declare class MergeNodesError extends Error {
|
45
|
-
file: string;
|
46
|
-
pluginName: string;
|
47
|
-
constructor({ file, pluginName, error, }: {
|
48
|
-
file: string;
|
49
|
-
pluginName: string;
|
50
|
-
error: Error;
|
51
|
-
});
|
52
|
-
}
|
53
30
|
/**
|
54
31
|
* Merges two targets.
|
55
32
|
*
|
@@ -1,13 +1,14 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
exports.readTargetDefaultsForTarget = exports.resolveNxTokensInOptions = exports.isCompatibleTarget = exports.mergeTargetConfigurations = exports.
|
3
|
+
exports.readTargetDefaultsForTarget = exports.resolveNxTokensInOptions = exports.isCompatibleTarget = exports.mergeTargetConfigurations = exports.readProjectConfigurationsFromRootMap = exports.createProjectConfigurations = exports.mergeProjectConfigurationIntoRootMap = void 0;
|
4
4
|
const logger_1 = require("../../utils/logger");
|
5
5
|
const fileutils_1 = require("../../utils/fileutils");
|
6
6
|
const workspace_root_1 = require("../../utils/workspace-root");
|
7
|
-
const
|
7
|
+
const symbols_1 = require("../../plugins/target-defaults/symbols");
|
8
8
|
const minimatch_1 = require("minimatch");
|
9
9
|
const path_1 = require("path");
|
10
10
|
const perf_hooks_1 = require("perf_hooks");
|
11
|
+
const error_types_1 = require("../error-types");
|
11
12
|
function mergeProjectConfigurationIntoRootMap(projectRootMap, project, configurationSourceMaps, sourceInformation,
|
12
13
|
// This function is used when reading project configuration
|
13
14
|
// in generators, where we don't want to do this.
|
@@ -119,12 +120,12 @@ skipCommandNormalization) {
|
|
119
120
|
// Always set source map info for the target, but don't overwrite info already there
|
120
121
|
// if augmenting an existing target.
|
121
122
|
const target = project.targets?.[targetName];
|
122
|
-
if (sourceMap && !target?.[
|
123
|
+
if (sourceMap && !target?.[symbols_1.ONLY_MODIFIES_EXISTING_TARGET]) {
|
123
124
|
sourceMap[`targets.${targetName}`] = sourceInformation;
|
124
125
|
}
|
125
126
|
// If ONLY_MODIFIES_EXISTING_TARGET is true, and its not on the matching project
|
126
127
|
// we shouldn't merge its info into the graph
|
127
|
-
if (target?.[
|
128
|
+
if (target?.[symbols_1.ONLY_MODIFIES_EXISTING_TARGET] &&
|
128
129
|
!matchingProject.targets?.[targetName]) {
|
129
130
|
continue;
|
130
131
|
}
|
@@ -132,8 +133,8 @@ skipCommandNormalization) {
|
|
132
133
|
? target
|
133
134
|
: resolveCommandSyntacticSugar(target, project.root), matchingProject.targets?.[targetName], sourceMap, sourceInformation, `targets.${targetName}`);
|
134
135
|
// We don't want the symbol to live on past the merge process
|
135
|
-
if (mergedTarget?.[
|
136
|
-
delete mergedTarget?.[
|
136
|
+
if (mergedTarget?.[symbols_1.ONLY_MODIFIES_EXISTING_TARGET])
|
137
|
+
delete mergedTarget?.[symbols_1.ONLY_MODIFIES_EXISTING_TARGET];
|
137
138
|
updatedProjectConfiguration.targets[targetName] = mergedTarget;
|
138
139
|
}
|
139
140
|
}
|
@@ -217,21 +218,19 @@ function mergeMetadata(sourceMap, sourceInformation, baseSourceMapPath, metadata
|
|
217
218
|
* @param workspaceFiles A list of non-ignored workspace files
|
218
219
|
* @param plugins The plugins that should be used to infer project configuration
|
219
220
|
*/
|
220
|
-
function createProjectConfigurations(root = workspace_root_1.workspaceRoot, nxJson,
|
221
|
+
async function createProjectConfigurations(root = workspace_root_1.workspaceRoot, nxJson, projectFiles, // making this parameter allows devkit to pick up newly created projects
|
221
222
|
plugins) {
|
222
223
|
perf_hooks_1.performance.mark('build-project-configs:start');
|
223
224
|
const results = [];
|
224
225
|
const errors = [];
|
225
226
|
// We iterate over plugins first - this ensures that plugins specified first take precedence.
|
226
|
-
for (const {
|
227
|
-
const [pattern, createNodes] =
|
228
|
-
const pluginResults = [];
|
229
|
-
perf_hooks_1.performance.mark(`${plugin.name}:createNodes - start`);
|
227
|
+
for (const { name: pluginName, createNodes: createNodesTuple, include, exclude, } of plugins) {
|
228
|
+
const [pattern, createNodes] = createNodesTuple ?? [];
|
230
229
|
if (!pattern) {
|
231
230
|
continue;
|
232
231
|
}
|
233
232
|
const matchingConfigFiles = [];
|
234
|
-
for (const file of
|
233
|
+
for (const file of projectFiles) {
|
235
234
|
if ((0, minimatch_1.minimatch)(file, pattern, { dot: true })) {
|
236
235
|
if (include) {
|
237
236
|
const included = include.some((includedPattern) => (0, minimatch_1.minimatch)(file, includedPattern, { dot: true }));
|
@@ -240,7 +239,7 @@ plugins) {
|
|
240
239
|
}
|
241
240
|
}
|
242
241
|
if (exclude) {
|
243
|
-
const excluded =
|
242
|
+
const excluded = exclude.some((excludedPattern) => (0, minimatch_1.minimatch)(file, excludedPattern, { dot: true }));
|
244
243
|
if (excluded) {
|
245
244
|
continue;
|
246
245
|
}
|
@@ -248,56 +247,20 @@ plugins) {
|
|
248
247
|
matchingConfigFiles.push(file);
|
249
248
|
}
|
250
249
|
}
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
if (r instanceof Promise) {
|
260
|
-
pluginResults.push(r
|
261
|
-
.catch((error) => {
|
262
|
-
perf_hooks_1.performance.mark(`${plugin.name}:createNodes:${file} - end`);
|
263
|
-
errors.push(new CreateNodesError({
|
264
|
-
file,
|
265
|
-
pluginName: plugin.name,
|
266
|
-
error,
|
267
|
-
}));
|
268
|
-
return {
|
269
|
-
projects: {},
|
270
|
-
};
|
271
|
-
})
|
272
|
-
.then((r) => {
|
273
|
-
perf_hooks_1.performance.mark(`${plugin.name}:createNodes:${file} - end`);
|
274
|
-
perf_hooks_1.performance.measure(`${plugin.name}:createNodes:${file}`, `${plugin.name}:createNodes:${file} - start`, `${plugin.name}:createNodes:${file} - end`);
|
275
|
-
return { ...r, file, pluginName: plugin.name };
|
276
|
-
}));
|
277
|
-
}
|
278
|
-
else {
|
279
|
-
perf_hooks_1.performance.mark(`${plugin.name}:createNodes:${file} - end`);
|
280
|
-
perf_hooks_1.performance.measure(`${plugin.name}:createNodes:${file}`, `${plugin.name}:createNodes:${file} - start`, `${plugin.name}:createNodes:${file} - end`);
|
281
|
-
pluginResults.push({
|
282
|
-
...r,
|
283
|
-
file,
|
284
|
-
pluginName: plugin.name,
|
285
|
-
});
|
286
|
-
}
|
250
|
+
let r = createNodes(matchingConfigFiles, {
|
251
|
+
nxJsonConfiguration: nxJson,
|
252
|
+
workspaceRoot: root,
|
253
|
+
configFiles: matchingConfigFiles,
|
254
|
+
}).catch((e) => {
|
255
|
+
if ((0, error_types_1.isAggregateCreateNodesError)(e)) {
|
256
|
+
errors.push(...e.errors);
|
257
|
+
return e.partialResults;
|
287
258
|
}
|
288
|
-
|
289
|
-
|
290
|
-
file,
|
291
|
-
pluginName: plugin.name,
|
292
|
-
error,
|
293
|
-
}));
|
259
|
+
else {
|
260
|
+
throw e;
|
294
261
|
}
|
295
|
-
}
|
296
|
-
results.push(
|
297
|
-
perf_hooks_1.performance.mark(`${plugin.name}:createNodes - end`);
|
298
|
-
perf_hooks_1.performance.measure(`${plugin.name}:createNodes`, `${plugin.name}:createNodes - start`, `${plugin.name}:createNodes - end`);
|
299
|
-
return results;
|
300
|
-
}));
|
262
|
+
});
|
263
|
+
results.push(r);
|
301
264
|
}
|
302
265
|
return Promise.all(results).then((results) => {
|
303
266
|
perf_hooks_1.performance.mark('createNodes:merge - start');
|
@@ -307,8 +270,8 @@ plugins) {
|
|
307
270
|
for (const result of results.flat()) {
|
308
271
|
const { projects: projectNodes, externalNodes: pluginExternalNodes, file, pluginName, } = result;
|
309
272
|
const sourceInfo = [file, pluginName];
|
310
|
-
if (result[
|
311
|
-
sourceInfo[0] = result[
|
273
|
+
if (result[symbols_1.OVERRIDE_SOURCE_FILE]) {
|
274
|
+
sourceInfo[0] = result[symbols_1.OVERRIDE_SOURCE_FILE];
|
312
275
|
}
|
313
276
|
for (const node in projectNodes) {
|
314
277
|
const project = {
|
@@ -319,7 +282,7 @@ plugins) {
|
|
319
282
|
mergeProjectConfigurationIntoRootMap(projectRootMap, project, configurationSourceMaps, sourceInfo);
|
320
283
|
}
|
321
284
|
catch (error) {
|
322
|
-
errors.push(new MergeNodesError({
|
285
|
+
errors.push(new error_types_1.MergeNodesError({
|
323
286
|
file,
|
324
287
|
pluginName,
|
325
288
|
error,
|
@@ -328,7 +291,20 @@ plugins) {
|
|
328
291
|
}
|
329
292
|
Object.assign(externalNodes, pluginExternalNodes);
|
330
293
|
}
|
331
|
-
|
294
|
+
let projects;
|
295
|
+
try {
|
296
|
+
projects = readProjectConfigurationsFromRootMap(projectRootMap);
|
297
|
+
}
|
298
|
+
catch (e) {
|
299
|
+
if ((0, error_types_1.isProjectsWithNoNameError)(e) ||
|
300
|
+
(0, error_types_1.isProjectsWithConflictingNamesError)(e)) {
|
301
|
+
projects = e.projects;
|
302
|
+
errors.push(e);
|
303
|
+
}
|
304
|
+
else {
|
305
|
+
throw e;
|
306
|
+
}
|
307
|
+
}
|
332
308
|
const rootMap = createRootMap(projectRootMap);
|
333
309
|
perf_hooks_1.performance.mark('createNodes:merge - end');
|
334
310
|
perf_hooks_1.performance.measure('createNodes:merge', 'createNodes:merge - start', 'createNodes:merge - end');
|
@@ -343,7 +319,7 @@ plugins) {
|
|
343
319
|
};
|
344
320
|
}
|
345
321
|
else {
|
346
|
-
throw new ProjectConfigurationsError(errors, {
|
322
|
+
throw new error_types_1.ProjectConfigurationsError(errors, {
|
347
323
|
projects,
|
348
324
|
externalNodes,
|
349
325
|
projectRootMap: rootMap,
|
@@ -358,7 +334,8 @@ function readProjectConfigurationsFromRootMap(projectRootMap) {
|
|
358
334
|
// If there are projects that have the same name, that is an error.
|
359
335
|
// This object tracks name -> (all roots of projects with that name)
|
360
336
|
// to provide better error messaging.
|
361
|
-
const
|
337
|
+
const conflicts = new Map();
|
338
|
+
const projectRootsWithNoName = [];
|
362
339
|
for (const [root, configuration] of projectRootMap.entries()) {
|
363
340
|
// We're setting `// targets` as a comment `targets` is empty due to Project Crystal.
|
364
341
|
// Strip it before returning configuration for usage.
|
@@ -370,62 +347,30 @@ function readProjectConfigurationsFromRootMap(projectRootMap) {
|
|
370
347
|
configuration.name = name;
|
371
348
|
}
|
372
349
|
catch {
|
373
|
-
|
350
|
+
projectRootsWithNoName.push(root);
|
374
351
|
}
|
375
352
|
}
|
376
353
|
if (configuration.name in projects) {
|
377
|
-
let rootErrors =
|
354
|
+
let rootErrors = conflicts.get(configuration.name) ?? [
|
378
355
|
projects[configuration.name].root,
|
379
356
|
];
|
380
357
|
rootErrors.push(root);
|
381
|
-
|
358
|
+
conflicts.set(configuration.name, rootErrors);
|
359
|
+
projects[configuration.name] = configuration;
|
382
360
|
}
|
383
361
|
else {
|
384
362
|
projects[configuration.name] = configuration;
|
385
363
|
}
|
386
364
|
}
|
387
|
-
if (
|
388
|
-
throw new
|
389
|
-
|
390
|
-
|
391
|
-
|
392
|
-
"To fix this, set a unique name for each project in a project.json inside the project's root. If the project does not currently have a project.json, you can create one that contains only a name.",
|
393
|
-
].join('\n'));
|
365
|
+
if (conflicts.size > 0) {
|
366
|
+
throw new error_types_1.ProjectsWithConflictingNamesError(conflicts, projects);
|
367
|
+
}
|
368
|
+
if (projectRootsWithNoName.length > 0) {
|
369
|
+
throw new error_types_1.ProjectsWithNoNameError(projectRootsWithNoName, projects);
|
394
370
|
}
|
395
371
|
return projects;
|
396
372
|
}
|
397
373
|
exports.readProjectConfigurationsFromRootMap = readProjectConfigurationsFromRootMap;
|
398
|
-
class ProjectConfigurationsError extends Error {
|
399
|
-
constructor(errors, partialProjectConfigurationsResult) {
|
400
|
-
super('Failed to create project configurations');
|
401
|
-
this.errors = errors;
|
402
|
-
this.partialProjectConfigurationsResult = partialProjectConfigurationsResult;
|
403
|
-
this.name = this.constructor.name;
|
404
|
-
}
|
405
|
-
}
|
406
|
-
exports.ProjectConfigurationsError = ProjectConfigurationsError;
|
407
|
-
class CreateNodesError extends Error {
|
408
|
-
constructor({ file, pluginName, error, }) {
|
409
|
-
const msg = `The "${pluginName}" plugin threw an error while creating nodes from ${file}:`;
|
410
|
-
super(msg, { cause: error });
|
411
|
-
this.name = this.constructor.name;
|
412
|
-
this.file = file;
|
413
|
-
this.pluginName = pluginName;
|
414
|
-
this.stack = `${this.message}\n ${error.stack.split('\n').join('\n ')}`;
|
415
|
-
}
|
416
|
-
}
|
417
|
-
exports.CreateNodesError = CreateNodesError;
|
418
|
-
class MergeNodesError extends Error {
|
419
|
-
constructor({ file, pluginName, error, }) {
|
420
|
-
const msg = `The nodes created from ${file} by the "${pluginName}" could not be merged into the project graph:`;
|
421
|
-
super(msg, { cause: error });
|
422
|
-
this.name = this.constructor.name;
|
423
|
-
this.file = file;
|
424
|
-
this.pluginName = pluginName;
|
425
|
-
this.stack = `${this.message}\n ${error.stack.split('\n').join('\n ')}`;
|
426
|
-
}
|
427
|
-
}
|
428
|
-
exports.MergeNodesError = MergeNodesError;
|
429
374
|
/**
|
430
375
|
* Merges two targets.
|
431
376
|
*
|
@@ -448,7 +393,7 @@ function mergeTargetConfigurations(target, baseTarget, projectConfigSourceMap, s
|
|
448
393
|
// with the new one. However, we have a special case for targets that have the
|
449
394
|
// ONLY_MODIFIES_EXISTING_TARGET symbol set. This prevents the merged target
|
450
395
|
// equaling info that should have only been used to modify the existing target.
|
451
|
-
if (!isCompatible && target[
|
396
|
+
if (!isCompatible && target[symbols_1.ONLY_MODIFIES_EXISTING_TARGET]) {
|
452
397
|
return baseTarget;
|
453
398
|
}
|
454
399
|
if (!isCompatible && projectConfigSourceMap) {
|
@@ -1,7 +1,7 @@
|
|
1
1
|
import { ProjectConfiguration } from '../../config/workspace-json-project-json';
|
2
2
|
import { NxJsonConfiguration } from '../../config/nx-json';
|
3
3
|
import { ConfigurationResult } from './project-configuration-utils';
|
4
|
-
import { LoadedNxPlugin } from '
|
4
|
+
import { LoadedNxPlugin } from '../plugins/internal-api';
|
5
5
|
/**
|
6
6
|
* Walks the workspace directory to create the `projectFileMap`, `ProjectConfigurations` and `allWorkspaceFiles`
|
7
7
|
* @throws
|
@@ -9,21 +9,22 @@ import { LoadedNxPlugin } from '../../utils/nx-plugin';
|
|
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.
|
21
|
-
*
|
22
|
-
* @param workspaceRoot
|
23
|
-
* @param nxJson
|
24
21
|
*/
|
25
|
-
export declare function retrieveProjectConfigurations(workspaceRoot: string, nxJson: NxJsonConfiguration): Promise<ConfigurationResult>;
|
22
|
+
export declare function retrieveProjectConfigurations(plugins: LoadedNxPlugin[], workspaceRoot: string, nxJson: NxJsonConfiguration): Promise<ConfigurationResult>;
|
26
23
|
export declare function retrieveProjectConfigurationsWithAngularProjects(workspaceRoot: string, nxJson: NxJsonConfiguration): Promise<ConfigurationResult>;
|
27
|
-
export declare function retrieveProjectConfigurationPaths(root: string, plugins:
|
24
|
+
export declare function retrieveProjectConfigurationPaths(root: string, plugins: Array<{
|
25
|
+
createNodes?: readonly [string, ...unknown[]];
|
26
|
+
} & unknown>): string[];
|
28
27
|
export declare function retrieveProjectConfigurationsWithoutPluginInference(root: string): Promise<Record<string, ProjectConfiguration>>;
|
29
|
-
export declare function configurationGlobs(plugins:
|
28
|
+
export declare function configurationGlobs(plugins: Array<{
|
29
|
+
createNodes?: readonly [string, ...unknown[]];
|
30
|
+
}>): string[];
|
@@ -2,15 +2,13 @@
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
3
|
exports.configurationGlobs = exports.retrieveProjectConfigurationsWithoutPluginInference = exports.retrieveProjectConfigurationPaths = exports.retrieveProjectConfigurationsWithAngularProjects = exports.retrieveProjectConfigurations = exports.retrieveWorkspaceFiles = void 0;
|
4
4
|
const perf_hooks_1 = require("perf_hooks");
|
5
|
-
const installation_directory_1 = require("../../utils/installation-directory");
|
6
5
|
const angular_json_1 = require("../../adapter/angular-json");
|
7
6
|
const nx_json_1 = require("../../config/nx-json");
|
8
|
-
const package_json_workspaces_1 = require("../../plugins/package-json-workspaces");
|
9
7
|
const project_configuration_utils_1 = require("./project-configuration-utils");
|
10
|
-
const
|
11
|
-
const project_json_1 = require("../../plugins/project-json/build-nodes/project-json");
|
8
|
+
const internal_api_1 = require("../plugins/internal-api");
|
12
9
|
const workspace_context_1 = require("../../utils/workspace-context");
|
13
10
|
const build_all_workspace_files_1 = require("./build-all-workspace-files");
|
11
|
+
const path_1 = require("path");
|
14
12
|
/**
|
15
13
|
* Walks the workspace directory to create the `projectFileMap`, `ProjectConfigurations` and `allWorkspaceFiles`
|
16
14
|
* @throws
|
@@ -37,29 +35,26 @@ async function retrieveWorkspaceFiles(workspaceRoot, projectRootMap) {
|
|
37
35
|
exports.retrieveWorkspaceFiles = retrieveWorkspaceFiles;
|
38
36
|
/**
|
39
37
|
* Walk through the workspace and return `ProjectConfigurations`. Only use this if the projectFileMap is not needed.
|
40
|
-
*
|
41
|
-
* @param workspaceRoot
|
42
|
-
* @param nxJson
|
43
38
|
*/
|
44
|
-
|
45
|
-
const
|
46
|
-
|
39
|
+
function retrieveProjectConfigurations(plugins, workspaceRoot, nxJson) {
|
40
|
+
const globPatterns = configurationGlobs(plugins);
|
41
|
+
const workspaceFiles = (0, workspace_context_1.globWithWorkspaceContext)(workspaceRoot, globPatterns);
|
42
|
+
return (0, project_configuration_utils_1.createProjectConfigurations)(workspaceRoot, nxJson, workspaceFiles, plugins);
|
47
43
|
}
|
48
44
|
exports.retrieveProjectConfigurations = retrieveProjectConfigurations;
|
49
45
|
async function retrieveProjectConfigurationsWithAngularProjects(workspaceRoot, nxJson) {
|
50
|
-
const
|
46
|
+
const pluginsToLoad = nxJson?.plugins ?? [];
|
51
47
|
if ((0, angular_json_1.shouldMergeAngularProjects)(workspaceRoot, true) &&
|
52
|
-
!
|
53
|
-
|
48
|
+
!pluginsToLoad.some((p) => p === angular_json_1.NX_ANGULAR_JSON_PLUGIN_NAME ||
|
49
|
+
(typeof p === 'object' && p.plugin === angular_json_1.NX_ANGULAR_JSON_PLUGIN_NAME))) {
|
50
|
+
pluginsToLoad.push((0, path_1.join)(__dirname, '../../adapter/angular-json'));
|
54
51
|
}
|
55
|
-
|
52
|
+
const [plugins, cleanup] = await (0, internal_api_1.loadNxPlugins)(nxJson?.plugins ?? [], workspaceRoot);
|
53
|
+
const res = retrieveProjectConfigurations(plugins, workspaceRoot, nxJson);
|
54
|
+
cleanup();
|
55
|
+
return res;
|
56
56
|
}
|
57
57
|
exports.retrieveProjectConfigurationsWithAngularProjects = retrieveProjectConfigurationsWithAngularProjects;
|
58
|
-
function _retrieveProjectConfigurations(workspaceRoot, nxJson, plugins) {
|
59
|
-
const globPatterns = configurationGlobs(plugins);
|
60
|
-
const workspaceFiles = (0, workspace_context_1.globWithWorkspaceContext)(workspaceRoot, globPatterns);
|
61
|
-
return (0, project_configuration_utils_1.createProjectConfigurations)(workspaceRoot, nxJson, workspaceFiles, plugins);
|
62
|
-
}
|
63
58
|
function retrieveProjectConfigurationPaths(root, plugins) {
|
64
59
|
const projectGlobPatterns = configurationGlobs(plugins);
|
65
60
|
return (0, workspace_context_1.globWithWorkspaceContext)(root, projectGlobPatterns);
|
@@ -69,25 +64,23 @@ const projectsWithoutPluginCache = new Map();
|
|
69
64
|
// TODO: This function is called way too often, it should be optimized without this cache
|
70
65
|
async function retrieveProjectConfigurationsWithoutPluginInference(root) {
|
71
66
|
const nxJson = (0, nx_json_1.readNxJson)(root);
|
72
|
-
const plugins = await (0,
|
67
|
+
const [plugins, cleanup] = await (0, internal_api_1.loadNxPlugins)([]); // only load default plugins
|
73
68
|
const projectGlobPatterns = retrieveProjectConfigurationPaths(root, plugins);
|
74
69
|
const cacheKey = root + ',' + projectGlobPatterns.join(',');
|
75
70
|
if (projectsWithoutPluginCache.has(cacheKey)) {
|
76
71
|
return projectsWithoutPluginCache.get(cacheKey);
|
77
72
|
}
|
78
73
|
const projectFiles = (0, workspace_context_1.globWithWorkspaceContext)(root, projectGlobPatterns) ?? [];
|
79
|
-
const { projects } = await (0, project_configuration_utils_1.createProjectConfigurations)(root, nxJson, projectFiles,
|
80
|
-
{ plugin: (0, package_json_workspaces_1.getNxPackageJsonWorkspacesPlugin)(root) },
|
81
|
-
{ plugin: project_json_1.ProjectJsonProjectsPlugin },
|
82
|
-
]);
|
74
|
+
const { projects } = await (0, project_configuration_utils_1.createProjectConfigurations)(root, nxJson, projectFiles, plugins);
|
83
75
|
projectsWithoutPluginCache.set(cacheKey, projects);
|
76
|
+
cleanup();
|
84
77
|
return projects;
|
85
78
|
}
|
86
79
|
exports.retrieveProjectConfigurationsWithoutPluginInference = retrieveProjectConfigurationsWithoutPluginInference;
|
87
80
|
function configurationGlobs(plugins) {
|
88
81
|
const globPatterns = [];
|
89
|
-
for (const
|
90
|
-
if (plugin.createNodes) {
|
82
|
+
for (const plugin of plugins) {
|
83
|
+
if ('createNodes' in plugin && plugin.createNodes) {
|
91
84
|
globPatterns.push(plugin.createNodes[0]);
|
92
85
|
}
|
93
86
|
}
|