nx 19.0.0-beta.1 → 19.0.0-beta.11
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 +49 -7
- package/src/project-graph/error-types.js +121 -9
- 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 +24 -6
- package/src/project-graph/utils/project-configuration-utils.js +125 -41
- 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
@@ -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
|
});
|
@@ -8,7 +8,6 @@ const package_json_1 = require("../../utils/package-json");
|
|
8
8
|
const fileutils_1 = require("../../utils/fileutils");
|
9
9
|
const workspace_root_1 = require("../../utils/workspace-root");
|
10
10
|
const node_fs_1 = require("node:fs");
|
11
|
-
const typescript_1 = require("../../utils/typescript");
|
12
11
|
const register_1 = require("../../plugins/js/utils/register");
|
13
12
|
const find_project_for_path_1 = require("../utils/find-project-for-path");
|
14
13
|
const path_1 = require("../../utils/path");
|
@@ -19,6 +18,7 @@ const utils_1 = require("./utils");
|
|
19
18
|
const internal_api_1 = require("./internal-api");
|
20
19
|
const error_types_1 = require("../error-types");
|
21
20
|
const path = require("node:path/posix");
|
21
|
+
const typescript_1 = require("../../plugins/js/utils/typescript");
|
22
22
|
function readPluginPackageJson(pluginName, projects, paths = (0, installation_directory_1.getNxRequirePaths)()) {
|
23
23
|
try {
|
24
24
|
const result = (0, package_json_1.readModulePackageJsonWithoutFallbacks)(pluginName, paths);
|
@@ -32,6 +32,9 @@ function readPluginPackageJson(pluginName, projects, paths = (0, installation_di
|
|
32
32
|
const localPluginPath = resolveLocalNxPlugin(pluginName, projects);
|
33
33
|
if (localPluginPath) {
|
34
34
|
const localPluginPackageJson = path.join(localPluginPath.path, 'package.json');
|
35
|
+
if (!exports.unregisterPluginTSTranspiler) {
|
36
|
+
registerPluginTSTranspiler();
|
37
|
+
}
|
35
38
|
return {
|
36
39
|
path: localPluginPackageJson,
|
37
40
|
json: (0, fileutils_1.readJsonFile)(localPluginPackageJson),
|
@@ -77,22 +80,27 @@ function registerPluginTSTranspiler() {
|
|
77
80
|
}
|
78
81
|
exports.registerPluginTSTranspiler = registerPluginTSTranspiler;
|
79
82
|
function lookupLocalPlugin(importPath, projects, root = workspace_root_1.workspaceRoot) {
|
80
|
-
const
|
81
|
-
if (!
|
83
|
+
const projectConfig = findNxProjectForImportPath(importPath, projects, root);
|
84
|
+
if (!projectConfig) {
|
82
85
|
return null;
|
83
86
|
}
|
84
|
-
const projectConfig = projects[plugin];
|
85
87
|
return { path: path.join(root, projectConfig.root), projectConfig };
|
86
88
|
}
|
87
89
|
function findNxProjectForImportPath(importPath, projects, root = workspace_root_1.workspaceRoot) {
|
88
90
|
const tsConfigPaths = readTsConfigPaths(root);
|
89
91
|
const possiblePaths = tsConfigPaths[importPath]?.map((p) => (0, path_1.normalizePath)(path.relative(root, path.join(root, p))));
|
90
92
|
if (possiblePaths?.length) {
|
91
|
-
const projectRootMappings =
|
93
|
+
const projectRootMappings = new Map();
|
94
|
+
const projectNameMap = new Map();
|
95
|
+
for (const projectRoot in projects) {
|
96
|
+
const project = projects[projectRoot];
|
97
|
+
projectRootMappings.set(project.root, project.name);
|
98
|
+
projectNameMap.set(project.name, project);
|
99
|
+
}
|
92
100
|
for (const tsConfigPath of possiblePaths) {
|
93
101
|
const nxProject = (0, find_project_for_path_1.findProjectForPath)(tsConfigPath, projectRootMappings);
|
94
102
|
if (nxProject) {
|
95
|
-
return nxProject;
|
103
|
+
return projectNameMap.get(nxProject);
|
96
104
|
}
|
97
105
|
}
|
98
106
|
logger_1.logger.verbose('Unable to find local plugin', possiblePaths, projectRootMappings);
|
@@ -12,7 +12,7 @@ export interface CreateNodesContext {
|
|
12
12
|
/**
|
13
13
|
* The subset of configuration files which match the createNodes pattern
|
14
14
|
*/
|
15
|
-
readonly configFiles: string[];
|
15
|
+
readonly configFiles: readonly string[];
|
16
16
|
}
|
17
17
|
/**
|
18
18
|
* A function which parses a configuration file into a set of nodes.
|
@@ -68,6 +68,12 @@ export interface CreateDependenciesContext {
|
|
68
68
|
* Use {@link validateDependency} to validate dependencies
|
69
69
|
*/
|
70
70
|
export type CreateDependencies<T = unknown> = (options: T | undefined, context: CreateDependenciesContext) => RawProjectGraphDependency[] | Promise<RawProjectGraphDependency[]>;
|
71
|
+
export type CreateMetadataContext = {
|
72
|
+
readonly nxJsonConfiguration: NxJsonConfiguration;
|
73
|
+
readonly workspaceRoot: string;
|
74
|
+
};
|
75
|
+
export type ProjectsMetadata = Record<string, Pick<ProjectConfiguration, 'metadata'>>;
|
76
|
+
export type CreateMetadata<T = unknown> = (graph: ProjectGraph, options: T | undefined, context: CreateMetadataContext) => ProjectsMetadata | Promise<ProjectsMetadata>;
|
71
77
|
/**
|
72
78
|
* A plugin for Nx which creates nodes and dependencies for the {@link ProjectGraph}
|
73
79
|
*/
|
@@ -82,6 +88,10 @@ export type NxPluginV2<TOptions = unknown> = {
|
|
82
88
|
* Provides a function to analyze files to create dependencies for the {@link ProjectGraph}
|
83
89
|
*/
|
84
90
|
createDependencies?: CreateDependencies<TOptions>;
|
91
|
+
/**
|
92
|
+
* Provides a function to create metadata for the {@link ProjectGraph}
|
93
|
+
*/
|
94
|
+
createMetadata?: CreateMetadata<TOptions>;
|
85
95
|
};
|
86
96
|
/**
|
87
97
|
* A plugin for Nx
|
@@ -1,7 +1,7 @@
|
|
1
1
|
import type { NxPluginV1 } from '../../utils/nx-plugin.deprecated';
|
2
2
|
import type { CreateNodesResultWithContext, LoadedNxPlugin, NormalizedPlugin } from './internal-api';
|
3
|
-
import type
|
3
|
+
import { type CreateNodesContext, type NxPlugin, type NxPluginV2 } from './public-api';
|
4
4
|
export declare function isNxPluginV2(plugin: NxPlugin): plugin is NxPluginV2;
|
5
5
|
export declare function isNxPluginV1(plugin: NxPlugin | LoadedNxPlugin): plugin is NxPluginV1;
|
6
6
|
export declare function normalizeNxPlugin(plugin: NxPlugin): NormalizedPlugin;
|
7
|
-
export declare function runCreateNodesInParallel(configFiles: string[], plugin: NormalizedPlugin, options: unknown, context: CreateNodesContext): Promise<CreateNodesResultWithContext[]>;
|
7
|
+
export declare function runCreateNodesInParallel(configFiles: readonly string[], plugin: NormalizedPlugin, options: unknown, context: CreateNodesContext): Promise<CreateNodesResultWithContext[]>;
|
@@ -2,9 +2,10 @@
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
3
|
exports.runCreateNodesInParallel = exports.normalizeNxPlugin = exports.isNxPluginV1 = exports.isNxPluginV2 = void 0;
|
4
4
|
const node_path_1 = require("node:path");
|
5
|
-
const
|
5
|
+
const to_project_name_1 = require("../../config/to-project-name");
|
6
6
|
const globs_1 = require("../../utils/globs");
|
7
7
|
const error_types_1 = require("../error-types");
|
8
|
+
const perf_hooks_1 = require("perf_hooks");
|
8
9
|
function isNxPluginV2(plugin) {
|
9
10
|
return 'createNodes' in plugin || 'createDependencies' in plugin;
|
10
11
|
}
|
@@ -27,7 +28,7 @@ function normalizeNxPlugin(plugin) {
|
|
27
28
|
return {
|
28
29
|
projects: {
|
29
30
|
[root]: {
|
30
|
-
name: (0,
|
31
|
+
name: (0, to_project_name_1.toProjectName)(configFilePath),
|
31
32
|
targets: plugin.registerProjectTargets?.(configFilePath),
|
32
33
|
},
|
33
34
|
},
|
@@ -40,37 +41,31 @@ function normalizeNxPlugin(plugin) {
|
|
40
41
|
}
|
41
42
|
exports.normalizeNxPlugin = normalizeNxPlugin;
|
42
43
|
async function runCreateNodesInParallel(configFiles, plugin, options, context) {
|
43
|
-
performance.mark(`${plugin.name}:createNodes - start`);
|
44
|
+
perf_hooks_1.performance.mark(`${plugin.name}:createNodes - start`);
|
44
45
|
const errors = [];
|
45
46
|
const results = [];
|
46
|
-
const promises = configFiles.map((file) => {
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
47
|
+
const promises = configFiles.map(async (file) => {
|
48
|
+
try {
|
49
|
+
const value = await plugin.createNodes[1](file, options, context);
|
50
|
+
if (value) {
|
51
|
+
results.push({
|
52
|
+
...value,
|
53
|
+
file,
|
54
|
+
pluginName: plugin.name,
|
55
|
+
});
|
56
|
+
}
|
57
|
+
}
|
58
|
+
catch (e) {
|
54
59
|
errors.push(new error_types_1.CreateNodesError({
|
55
60
|
error: e,
|
56
61
|
pluginName: plugin.name,
|
57
62
|
file,
|
58
63
|
}));
|
59
|
-
|
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, file, pluginName: plugin.name });
|
68
|
-
}
|
69
|
-
});
|
64
|
+
}
|
70
65
|
});
|
71
66
|
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`);
|
67
|
+
perf_hooks_1.performance.mark(`${plugin.name}:createNodes - end`);
|
68
|
+
perf_hooks_1.performance.measure(`${plugin.name}:createNodes`, `${plugin.name}:createNodes - start`, `${plugin.name}:createNodes - end`);
|
74
69
|
});
|
75
70
|
if (errors.length > 0) {
|
76
71
|
throw new error_types_1.AggregateCreateNodesError(plugin.name, errors, results);
|
@@ -14,6 +14,9 @@ export declare function buildProjectGraphAndSourceMapsWithoutDaemon(): Promise<{
|
|
14
14
|
projectGraph: ProjectGraph;
|
15
15
|
sourceMaps: import("./utils/project-configuration-utils").ConfigurationSourceMaps;
|
16
16
|
}>;
|
17
|
+
export declare function handleProjectGraphError(opts: {
|
18
|
+
exitOnError: boolean;
|
19
|
+
}, e: any): void;
|
17
20
|
/**
|
18
21
|
* Computes and returns a ProjectGraph.
|
19
22
|
*
|
@@ -1,6 +1,6 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
exports.createProjectGraphAndSourceMapsAsync = exports.createProjectGraphAsync = exports.buildProjectGraphAndSourceMapsWithoutDaemon = exports.readProjectsConfigurationFromProjectGraph = exports.readCachedProjectConfiguration = exports.readCachedProjectGraph = void 0;
|
3
|
+
exports.createProjectGraphAndSourceMapsAsync = exports.createProjectGraphAsync = exports.handleProjectGraphError = exports.buildProjectGraphAndSourceMapsWithoutDaemon = exports.readProjectsConfigurationFromProjectGraph = exports.readCachedProjectConfiguration = exports.readCachedProjectGraph = void 0;
|
4
4
|
const perf_hooks_1 = require("perf_hooks");
|
5
5
|
const nx_json_1 = require("../config/nx-json");
|
6
6
|
const client_1 = require("../daemon/client/client");
|
@@ -10,8 +10,8 @@ const output_1 = require("../utils/output");
|
|
10
10
|
const strip_indents_1 = require("../utils/strip-indents");
|
11
11
|
const workspace_root_1 = require("../utils/workspace-root");
|
12
12
|
const build_project_graph_1 = require("./build-project-graph");
|
13
|
-
const nx_deps_cache_1 = require("./nx-deps-cache");
|
14
13
|
const error_types_1 = require("./error-types");
|
14
|
+
const nx_deps_cache_1 = require("./nx-deps-cache");
|
15
15
|
const internal_api_1 = require("./plugins/internal-api");
|
16
16
|
const retrieve_workspace_files_1 = require("./utils/retrieve-workspace-files");
|
17
17
|
/**
|
@@ -92,18 +92,18 @@ async function buildProjectGraphAndSourceMapsWithoutDaemon() {
|
|
92
92
|
perf_hooks_1.performance.mark('retrieve-workspace-files:end');
|
93
93
|
const cacheEnabled = process.env.NX_CACHE_PROJECT_GRAPH !== 'false';
|
94
94
|
perf_hooks_1.performance.mark('build-project-graph-using-project-file-map:start');
|
95
|
-
let
|
95
|
+
let projectGraphError;
|
96
96
|
let projectGraphResult;
|
97
97
|
try {
|
98
|
-
projectGraphResult = await (0, build_project_graph_1.buildProjectGraphUsingProjectFileMap)(projects, externalNodes, fileMap, allWorkspaceFiles, rustReferences, cacheEnabled ? (0, nx_deps_cache_1.readFileMapCache)() : null, plugins);
|
98
|
+
projectGraphResult = await (0, build_project_graph_1.buildProjectGraphUsingProjectFileMap)(projects, externalNodes, fileMap, allWorkspaceFiles, rustReferences, cacheEnabled ? (0, nx_deps_cache_1.readFileMapCache)() : null, plugins, sourceMaps);
|
99
99
|
}
|
100
100
|
catch (e) {
|
101
|
-
if (
|
101
|
+
if ((0, error_types_1.isAggregateProjectGraphError)(e)) {
|
102
102
|
projectGraphResult = {
|
103
103
|
projectGraph: e.partialProjectGraph,
|
104
104
|
projectFileMapCache: null,
|
105
105
|
};
|
106
|
-
|
106
|
+
projectGraphError = e;
|
107
107
|
}
|
108
108
|
else {
|
109
109
|
throw e;
|
@@ -117,7 +117,7 @@ async function buildProjectGraphAndSourceMapsWithoutDaemon() {
|
|
117
117
|
delete global.NX_GRAPH_CREATION;
|
118
118
|
const errors = [
|
119
119
|
...(projectConfigurationsError?.errors ?? []),
|
120
|
-
...(
|
120
|
+
...(projectGraphError?.errors ?? []),
|
121
121
|
];
|
122
122
|
if (errors.length > 0) {
|
123
123
|
throw new error_types_1.ProjectGraphError(errors, projectGraph, sourceMaps);
|
@@ -162,6 +162,7 @@ function handleProjectGraphError(opts, e) {
|
|
162
162
|
throw e;
|
163
163
|
}
|
164
164
|
}
|
165
|
+
exports.handleProjectGraphError = handleProjectGraphError;
|
165
166
|
/**
|
166
167
|
* Computes and returns a ProjectGraph.
|
167
168
|
*
|
@@ -9,9 +9,8 @@ const path_2 = require("../../utils/path");
|
|
9
9
|
*/
|
10
10
|
function createProjectRootMappingsFromProjectConfigurations(projects) {
|
11
11
|
const projectRootMappings = new Map();
|
12
|
-
for (const
|
13
|
-
|
14
|
-
projectRootMappings.set(normalizeProjectRoot(root), projectName);
|
12
|
+
for (const { name, root } of Object.values(projects)) {
|
13
|
+
projectRootMappings.set(normalizeProjectRoot(root), name);
|
15
14
|
}
|
16
15
|
return projectRootMappings;
|
17
16
|
}
|
@@ -2,7 +2,7 @@ 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
4
|
import { CreateDependenciesContext } from '../plugins';
|
5
|
-
export declare function normalizeProjectNodes(
|
5
|
+
export declare function normalizeProjectNodes({ projects }: CreateDependenciesContext, builder: ProjectGraphBuilder): Promise<void>;
|
6
6
|
/**
|
7
7
|
* Apply target defaults and normalization
|
8
8
|
*/
|
@@ -2,16 +2,14 @@
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
3
|
exports.normalizeImplicitDependencies = exports.normalizeProjectTargets = exports.normalizeProjectNodes = void 0;
|
4
4
|
const find_matching_projects_1 = require("../../utils/find-matching-projects");
|
5
|
-
|
6
|
-
async function normalizeProjectNodes(ctx, builder) {
|
7
|
-
const toAdd = [];
|
5
|
+
async function normalizeProjectNodes({ projects }, builder) {
|
8
6
|
// Sorting projects by name to make sure that the order of projects in the graph is deterministic.
|
9
7
|
// This is important to ensure that expanded properties referencing projects (e.g. implicit dependencies)
|
10
8
|
// are also deterministic, and thus don't cause the calculated project configuration hash to shift.
|
11
|
-
const
|
9
|
+
const sortedProjectNames = Object.keys(projects).sort();
|
12
10
|
// Used for expanding implicit dependencies (e.g. `@proj/*` or `tag:foo`)
|
13
|
-
const partialProjectGraphNodes =
|
14
|
-
const projectConfiguration =
|
11
|
+
const partialProjectGraphNodes = sortedProjectNames.reduce((graph, project) => {
|
12
|
+
const projectConfiguration = projects[project];
|
15
13
|
graph[project] = {
|
16
14
|
name: project,
|
17
15
|
type: projectConfiguration.projectType === 'library' ? 'lib' : 'app', // missing fallback to `e2e`
|
@@ -21,8 +19,9 @@ async function normalizeProjectNodes(ctx, builder) {
|
|
21
19
|
};
|
22
20
|
return graph;
|
23
21
|
}, {});
|
24
|
-
|
25
|
-
|
22
|
+
const toAdd = [];
|
23
|
+
for (const key of sortedProjectNames) {
|
24
|
+
const p = projects[key];
|
26
25
|
p.implicitDependencies = normalizeImplicitDependencies(key, p.implicitDependencies, partialProjectGraphNodes);
|
27
26
|
p.targets = normalizeProjectTargets(p, key);
|
28
27
|
// TODO: remove in v16
|
@@ -31,7 +30,7 @@ async function normalizeProjectNodes(ctx, builder) {
|
|
31
30
|
? 'e2e'
|
32
31
|
: 'app'
|
33
32
|
: 'lib';
|
34
|
-
const tags =
|
33
|
+
const tags = p.tags || [];
|
35
34
|
toAdd.push({
|
36
35
|
name: key,
|
37
36
|
type: projectType,
|
@@ -69,11 +68,6 @@ function normalizeProjectTargets(project, projectName) {
|
|
69
68
|
delete targets[target];
|
70
69
|
continue;
|
71
70
|
}
|
72
|
-
targets[target].options = (0, project_configuration_utils_1.resolveNxTokensInOptions)(targets[target].options, project, `${projectName}:${target}`);
|
73
|
-
targets[target].configurations ??= {};
|
74
|
-
for (const configuration in targets[target].configurations) {
|
75
|
-
targets[target].configurations[configuration] = (0, project_configuration_utils_1.resolveNxTokensInOptions)(targets[target].configurations[configuration], project, `${projectName}:${target}:${configuration}`);
|
76
|
-
}
|
77
71
|
}
|
78
72
|
return targets;
|
79
73
|
}
|
@@ -1,20 +1,36 @@
|
|
1
1
|
import { NxJsonConfiguration, TargetDefaults } from '../../config/nx-json';
|
2
2
|
import { ProjectGraphExternalNode } from '../../config/project-graph';
|
3
|
-
import { ProjectConfiguration, TargetConfiguration } from '../../config/workspace-json-project-json';
|
3
|
+
import { ProjectConfiguration, ProjectMetadata, TargetConfiguration, TargetMetadata } from '../../config/workspace-json-project-json';
|
4
4
|
import { ONLY_MODIFIES_EXISTING_TARGET } from '../../plugins/target-defaults/symbols';
|
5
5
|
import { LoadedNxPlugin } from '../plugins/internal-api';
|
6
|
-
export type SourceInformation = [file: string, plugin: string];
|
6
|
+
export type SourceInformation = [file: string | null, plugin: string];
|
7
7
|
export type ConfigurationSourceMaps = Record<string, Record<string, SourceInformation>>;
|
8
|
-
export declare function mergeProjectConfigurationIntoRootMap(projectRootMap:
|
8
|
+
export declare function mergeProjectConfigurationIntoRootMap(projectRootMap: Record<string, ProjectConfiguration>, project: ProjectConfiguration & {
|
9
9
|
targets?: Record<string, TargetConfiguration & {
|
10
10
|
[ONLY_MODIFIES_EXISTING_TARGET]?: boolean;
|
11
11
|
}>;
|
12
|
-
}, configurationSourceMaps?: ConfigurationSourceMaps, sourceInformation?: SourceInformation,
|
12
|
+
}, configurationSourceMaps?: ConfigurationSourceMaps, sourceInformation?: SourceInformation, skipTargetNormalization?: boolean): void;
|
13
|
+
export declare function mergeMetadata<T = ProjectMetadata | TargetMetadata>(sourceMap: Record<string, [file: string, plugin: string]>, sourceInformation: [file: string, plugin: string], baseSourceMapPath: string, metadata: T, matchingMetadata?: T): T;
|
13
14
|
export type ConfigurationResult = {
|
14
|
-
|
15
|
+
/**
|
16
|
+
* A map of project configurations, keyed by project root.
|
17
|
+
*/
|
18
|
+
projects: {
|
19
|
+
[projectRoot: string]: ProjectConfiguration;
|
20
|
+
};
|
21
|
+
/**
|
22
|
+
* Node Name -> Node info
|
23
|
+
*/
|
15
24
|
externalNodes: Record<string, ProjectGraphExternalNode>;
|
25
|
+
/**
|
26
|
+
* Project Root -> Project Name
|
27
|
+
*/
|
16
28
|
projectRootMap: Record<string, string>;
|
17
29
|
sourceMaps: ConfigurationSourceMaps;
|
30
|
+
/**
|
31
|
+
* The list of files that were used to create project configurations
|
32
|
+
*/
|
33
|
+
matchingProjectFiles: string[];
|
18
34
|
};
|
19
35
|
/**
|
20
36
|
* Transforms a list of project paths into a map of project configurations.
|
@@ -26,7 +42,8 @@ export type ConfigurationResult = {
|
|
26
42
|
*/
|
27
43
|
export declare function createProjectConfigurations(root: string, nxJson: NxJsonConfiguration, projectFiles: string[], // making this parameter allows devkit to pick up newly created projects
|
28
44
|
plugins: LoadedNxPlugin[]): Promise<ConfigurationResult>;
|
29
|
-
export declare function readProjectConfigurationsFromRootMap(projectRootMap:
|
45
|
+
export declare function readProjectConfigurationsFromRootMap(projectRootMap: Record<string, ProjectConfiguration>): Record<string, ProjectConfiguration>;
|
46
|
+
export declare function validateProject(project: ProjectConfiguration, knownProjects: Record<string, ProjectConfiguration>): void;
|
30
47
|
/**
|
31
48
|
* Merges two targets.
|
32
49
|
*
|
@@ -51,3 +68,4 @@ export declare function mergeTargetConfigurations(target: TargetConfiguration, b
|
|
51
68
|
export declare function isCompatibleTarget(a: TargetConfiguration, b: TargetConfiguration): boolean;
|
52
69
|
export declare function resolveNxTokensInOptions<T extends Object | Array<unknown>>(object: T, project: ProjectConfiguration, key: string): T;
|
53
70
|
export declare function readTargetDefaultsForTarget(targetName: string, targetDefaults: TargetDefaults, executor?: string): TargetDefaults[string];
|
71
|
+
export declare function normalizeTarget(target: TargetConfiguration, project: ProjectConfiguration): TargetConfiguration<any>;
|