nx 19.0.0-canary.20240430-458f2cc → 19.0.0-canary.20240503-dbad02a
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/migrations.json +0 -24
- 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/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/to-project-name.d.ts +5 -0
- package/src/config/to-project-name.js +13 -0
- package/src/core/graph/main.js +1 -1
- package/src/core/graph/styles.css +2 -2
- package/src/daemon/client/client.d.ts +1 -0
- package/src/daemon/client/client.js +11 -1
- package/src/daemon/server/project-graph-incremental-recomputation.js +1 -1
- package/src/devkit-exports.d.ts +0 -4
- package/src/devkit-exports.js +1 -7
- package/src/generators/utils/project-configuration.js +1 -6
- package/src/hasher/task-hasher.d.ts +4 -4
- 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/build-project-graph.js +29 -4
- package/src/project-graph/error-types.d.ts +27 -8
- package/src/project-graph/error-types.js +66 -10
- package/src/project-graph/file-utils.d.ts +2 -3
- package/src/project-graph/file-utils.js +4 -8
- package/src/project-graph/plugins/loader.js +1 -1
- package/src/project-graph/plugins/utils.js +6 -5
- package/src/project-graph/project-graph.d.ts +3 -0
- package/src/project-graph/project-graph.js +2 -1
- package/src/project-graph/utils/normalize-project-nodes.js +0 -6
- package/src/project-graph/utils/project-configuration-utils.d.ts +3 -1
- package/src/project-graph/utils/project-configuration-utils.js +109 -34
- package/src/tasks-runner/create-task-graph.js +0 -1
- package/src/tasks-runner/life-cycles/dynamic-run-many-terminal-output-life-cycle.js +1 -1
- 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/nx-plugin.deprecated.d.ts +1 -1
- package/src/utils/nx-plugin.deprecated.js +1 -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/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,7 +1,7 @@
|
|
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.isCreateMetadataError = exports.isAggregateProjectGraphError = exports.AggregateProjectGraphError = exports.ProcessProjectGraphError = exports.ProcessDependenciesError = exports.CreateMetadataError = exports.MergeNodesError = exports.AggregateCreateNodesError = exports.CreateNodesError = exports.ProjectConfigurationsError = exports.isProjectsWithNoNameError = exports.ProjectsWithNoNameError = exports.
|
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.isProjectConfigurationsError = exports.ProjectConfigurationsError = exports.isProjectWithNoNameError = exports.ProjectWithNoNameError = exports.isProjectsWithNoNameError = exports.ProjectsWithNoNameError = exports.isMultipleProjectsWithSameNameError = exports.isProjectWithExistingNameError = exports.ProjectWithExistingNameError = exports.MultipleProjectsWithSameNameError = exports.ProjectGraphError = void 0;
|
5
5
|
const tslib_1 = require("tslib");
|
6
6
|
class ProjectGraphError extends Error {
|
7
7
|
constructor(errors, partialProjectGraph, partialSourceMaps) {
|
@@ -42,7 +42,7 @@ class ProjectGraphError extends Error {
|
|
42
42
|
}
|
43
43
|
exports.ProjectGraphError = ProjectGraphError;
|
44
44
|
_ProjectGraphError_errors = new WeakMap(), _ProjectGraphError_partialProjectGraph = new WeakMap(), _ProjectGraphError_partialSourceMaps = new WeakMap();
|
45
|
-
class
|
45
|
+
class MultipleProjectsWithSameNameError extends Error {
|
46
46
|
constructor(conflicts, projects) {
|
47
47
|
super([
|
48
48
|
`The following projects are defined in multiple locations:`,
|
@@ -50,21 +50,39 @@ class ProjectsWithConflictingNamesError extends Error {
|
|
50
50
|
'',
|
51
51
|
"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.",
|
52
52
|
].join('\n'));
|
53
|
+
this.conflicts = conflicts;
|
53
54
|
this.projects = projects;
|
54
55
|
this.name = this.constructor.name;
|
55
56
|
}
|
56
57
|
}
|
57
|
-
exports.
|
58
|
-
|
59
|
-
|
58
|
+
exports.MultipleProjectsWithSameNameError = MultipleProjectsWithSameNameError;
|
59
|
+
class ProjectWithExistingNameError extends Error {
|
60
|
+
constructor(projectName, projectRoot) {
|
61
|
+
super(`The project "${projectName}" is defined in multiple locations.`);
|
62
|
+
this.projectName = projectName;
|
63
|
+
this.projectRoot = projectRoot;
|
64
|
+
this.name = this.constructor.name;
|
65
|
+
}
|
66
|
+
}
|
67
|
+
exports.ProjectWithExistingNameError = ProjectWithExistingNameError;
|
68
|
+
function isProjectWithExistingNameError(e) {
|
69
|
+
return (e instanceof ProjectWithExistingNameError ||
|
70
|
+
(typeof e === 'object' &&
|
71
|
+
'name' in e &&
|
72
|
+
e?.name === ProjectWithExistingNameError.name));
|
73
|
+
}
|
74
|
+
exports.isProjectWithExistingNameError = isProjectWithExistingNameError;
|
75
|
+
function isMultipleProjectsWithSameNameError(e) {
|
76
|
+
return (e instanceof MultipleProjectsWithSameNameError ||
|
60
77
|
(typeof e === 'object' &&
|
61
78
|
'name' in e &&
|
62
|
-
e?.name ===
|
79
|
+
e?.name === MultipleProjectsWithSameNameError.name));
|
63
80
|
}
|
64
|
-
exports.
|
81
|
+
exports.isMultipleProjectsWithSameNameError = isMultipleProjectsWithSameNameError;
|
65
82
|
class ProjectsWithNoNameError extends Error {
|
66
83
|
constructor(projectRoots, projects) {
|
67
84
|
super(`The projects in the following directories have no name provided:\n - ${projectRoots.join('\n - ')}`);
|
85
|
+
this.projectRoots = projectRoots;
|
68
86
|
this.projects = projects;
|
69
87
|
this.name = this.constructor.name;
|
70
88
|
}
|
@@ -74,9 +92,24 @@ function isProjectsWithNoNameError(e) {
|
|
74
92
|
return (e instanceof ProjectsWithNoNameError ||
|
75
93
|
(typeof e === 'object' &&
|
76
94
|
'name' in e &&
|
77
|
-
e?.name === ProjectsWithNoNameError.
|
95
|
+
e?.name === ProjectsWithNoNameError.name));
|
78
96
|
}
|
79
97
|
exports.isProjectsWithNoNameError = isProjectsWithNoNameError;
|
98
|
+
class ProjectWithNoNameError extends Error {
|
99
|
+
constructor(projectRoot) {
|
100
|
+
super(`The project in ${projectRoot} has no name provided.`);
|
101
|
+
this.projectRoot = projectRoot;
|
102
|
+
this.name = this.constructor.name;
|
103
|
+
}
|
104
|
+
}
|
105
|
+
exports.ProjectWithNoNameError = ProjectWithNoNameError;
|
106
|
+
function isProjectWithNoNameError(e) {
|
107
|
+
return (e instanceof ProjectWithNoNameError ||
|
108
|
+
(typeof e === 'object' &&
|
109
|
+
'name' in e &&
|
110
|
+
e?.name === ProjectWithNoNameError.name));
|
111
|
+
}
|
112
|
+
exports.isProjectWithNoNameError = isProjectWithNoNameError;
|
80
113
|
class ProjectConfigurationsError extends Error {
|
81
114
|
constructor(errors, partialProjectConfigurationsResult) {
|
82
115
|
super('Failed to create project configurations');
|
@@ -86,6 +119,13 @@ class ProjectConfigurationsError extends Error {
|
|
86
119
|
}
|
87
120
|
}
|
88
121
|
exports.ProjectConfigurationsError = ProjectConfigurationsError;
|
122
|
+
function isProjectConfigurationsError(e) {
|
123
|
+
return (e instanceof ProjectConfigurationsError ||
|
124
|
+
(typeof e === 'object' &&
|
125
|
+
'name' in e &&
|
126
|
+
e?.name === ProjectConfigurationsError.name));
|
127
|
+
}
|
128
|
+
exports.isProjectConfigurationsError = isProjectConfigurationsError;
|
89
129
|
class CreateNodesError extends Error {
|
90
130
|
constructor({ file, pluginName, error, }) {
|
91
131
|
const msg = `The "${pluginName}" plugin threw an error while creating nodes from ${file}:`;
|
@@ -140,6 +180,22 @@ class ProcessDependenciesError extends Error {
|
|
140
180
|
}
|
141
181
|
}
|
142
182
|
exports.ProcessDependenciesError = ProcessDependenciesError;
|
183
|
+
class WorkspaceValidityError extends Error {
|
184
|
+
constructor(message) {
|
185
|
+
message = `Configuration Error\n${message}`;
|
186
|
+
super(message);
|
187
|
+
this.message = message;
|
188
|
+
this.name = this.constructor.name;
|
189
|
+
}
|
190
|
+
}
|
191
|
+
exports.WorkspaceValidityError = WorkspaceValidityError;
|
192
|
+
function isWorkspaceValidityError(e) {
|
193
|
+
return (e instanceof WorkspaceValidityError ||
|
194
|
+
(typeof e === 'object' &&
|
195
|
+
'name' in e &&
|
196
|
+
e?.name === WorkspaceValidityError.name));
|
197
|
+
}
|
198
|
+
exports.isWorkspaceValidityError = isWorkspaceValidityError;
|
143
199
|
class ProcessProjectGraphError extends Error {
|
144
200
|
constructor(pluginName, { cause }) {
|
145
201
|
super(`The "${pluginName}" plugin threw an error while processing the project graph:`, {
|
@@ -164,14 +220,14 @@ function isAggregateProjectGraphError(e) {
|
|
164
220
|
return (e instanceof AggregateProjectGraphError ||
|
165
221
|
(typeof e === 'object' &&
|
166
222
|
'name' in e &&
|
167
|
-
e?.name === AggregateProjectGraphError.
|
223
|
+
e?.name === AggregateProjectGraphError.name));
|
168
224
|
}
|
169
225
|
exports.isAggregateProjectGraphError = isAggregateProjectGraphError;
|
170
226
|
function isCreateMetadataError(e) {
|
171
227
|
return (e instanceof CreateMetadataError ||
|
172
228
|
(typeof e === 'object' &&
|
173
229
|
'name' in e &&
|
174
|
-
e?.name === CreateMetadataError.
|
230
|
+
e?.name === CreateMetadataError.name));
|
175
231
|
}
|
176
232
|
exports.isCreateMetadataError = isCreateMetadataError;
|
177
233
|
function isCreateNodesError(e) {
|
@@ -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));
|
@@ -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);
|
@@ -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,7 +41,7 @@ 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
47
|
const promises = configFiles.map(async (file) => {
|
@@ -63,8 +64,8 @@ async function runCreateNodesInParallel(configFiles, plugin, options, context) {
|
|
63
64
|
}
|
64
65
|
});
|
65
66
|
await Promise.all(promises).then(() => {
|
66
|
-
performance.mark(`${plugin.name}:createNodes - end`);
|
67
|
-
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`);
|
68
69
|
});
|
69
70
|
if (errors.length > 0) {
|
70
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");
|
@@ -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
|
*
|
@@ -2,7 +2,6 @@
|
|
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
|
-
const project_configuration_utils_1 = require("../utils/project-configuration-utils");
|
6
5
|
async function normalizeProjectNodes({ projects }, builder) {
|
7
6
|
// Sorting projects by name to make sure that the order of projects in the graph is deterministic.
|
8
7
|
// This is important to ensure that expanded properties referencing projects (e.g. implicit dependencies)
|
@@ -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
|
}
|
@@ -9,7 +9,7 @@ export declare function mergeProjectConfigurationIntoRootMap(projectRootMap: Rec
|
|
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
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;
|
14
14
|
export type ConfigurationResult = {
|
15
15
|
/**
|
@@ -43,6 +43,7 @@ export type ConfigurationResult = {
|
|
43
43
|
export declare function createProjectConfigurations(root: string, nxJson: NxJsonConfiguration, projectFiles: string[], // making this parameter allows devkit to pick up newly created projects
|
44
44
|
plugins: LoadedNxPlugin[]): Promise<ConfigurationResult>;
|
45
45
|
export declare function readProjectConfigurationsFromRootMap(projectRootMap: Record<string, ProjectConfiguration>): Record<string, ProjectConfiguration>;
|
46
|
+
export declare function validateProject(project: ProjectConfiguration, knownProjects: Record<string, ProjectConfiguration>): void;
|
46
47
|
/**
|
47
48
|
* Merges two targets.
|
48
49
|
*
|
@@ -67,3 +68,4 @@ export declare function mergeTargetConfigurations(target: TargetConfiguration, b
|
|
67
68
|
export declare function isCompatibleTarget(a: TargetConfiguration, b: TargetConfiguration): boolean;
|
68
69
|
export declare function resolveNxTokensInOptions<T extends Object | Array<unknown>>(object: T, project: ProjectConfiguration, key: string): T;
|
69
70
|
export declare function readTargetDefaultsForTarget(targetName: string, targetDefaults: TargetDefaults, executor?: string): TargetDefaults[string];
|
71
|
+
export declare function normalizeTarget(target: TargetConfiguration, project: ProjectConfiguration): TargetConfiguration<any>;
|
@@ -1,6 +1,6 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
exports.readTargetDefaultsForTarget = exports.resolveNxTokensInOptions = exports.isCompatibleTarget = exports.mergeTargetConfigurations = exports.readProjectConfigurationsFromRootMap = exports.createProjectConfigurations = exports.mergeMetadata = exports.mergeProjectConfigurationIntoRootMap = void 0;
|
3
|
+
exports.normalizeTarget = exports.readTargetDefaultsForTarget = exports.resolveNxTokensInOptions = exports.isCompatibleTarget = exports.mergeTargetConfigurations = exports.validateProject = exports.readProjectConfigurationsFromRootMap = exports.createProjectConfigurations = exports.mergeMetadata = 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");
|
@@ -12,7 +12,7 @@ const error_types_1 = require("../error-types");
|
|
12
12
|
function mergeProjectConfigurationIntoRootMap(projectRootMap, project, configurationSourceMaps, sourceInformation,
|
13
13
|
// This function is used when reading project configuration
|
14
14
|
// in generators, where we don't want to do this.
|
15
|
-
|
15
|
+
skipTargetNormalization) {
|
16
16
|
if (configurationSourceMaps && !configurationSourceMaps[project.root]) {
|
17
17
|
configurationSourceMaps[project.root] = {};
|
18
18
|
}
|
@@ -129,9 +129,10 @@ skipCommandNormalization) {
|
|
129
129
|
!matchingProject.targets?.[targetName]) {
|
130
130
|
continue;
|
131
131
|
}
|
132
|
-
const
|
132
|
+
const normalizedTarget = skipTargetNormalization
|
133
133
|
? target
|
134
|
-
: resolveCommandSyntacticSugar(target, project.root)
|
134
|
+
: resolveCommandSyntacticSugar(target, project.root);
|
135
|
+
const mergedTarget = mergeTargetConfigurations(normalizedTarget, matchingProject.targets?.[targetName], sourceMap, sourceInformation, `targets.${targetName}`);
|
135
136
|
// We don't want the symbol to live on past the merge process
|
136
137
|
if (mergedTarget?.[symbols_1.ONLY_MODIFIES_EXISTING_TARGET])
|
137
138
|
delete mergedTarget?.[symbols_1.ONLY_MODIFIES_EXISTING_TARGET];
|
@@ -294,16 +295,11 @@ plugins) {
|
|
294
295
|
Object.assign(externalNodes, pluginExternalNodes);
|
295
296
|
}
|
296
297
|
try {
|
297
|
-
|
298
|
-
// only contains valid project names. This is a safety check.
|
299
|
-
//
|
300
|
-
// The signature itself can't be changed as we need it to return
|
301
|
-
// project configurations for use in devkit.
|
302
|
-
readProjectConfigurationsFromRootMap(projectRootMap);
|
298
|
+
validateAndNormalizeProjectRootMap(projectRootMap);
|
303
299
|
}
|
304
300
|
catch (e) {
|
305
301
|
if ((0, error_types_1.isProjectsWithNoNameError)(e) ||
|
306
|
-
(0, error_types_1.
|
302
|
+
(0, error_types_1.isMultipleProjectsWithSameNameError)(e)) {
|
307
303
|
errors.push(e);
|
308
304
|
}
|
309
305
|
else {
|
@@ -344,34 +340,33 @@ function readProjectConfigurationsFromRootMap(projectRootMap) {
|
|
344
340
|
const conflicts = new Map();
|
345
341
|
const projectRootsWithNoName = [];
|
346
342
|
for (const root in projectRootMap) {
|
347
|
-
const
|
343
|
+
const project = projectRootMap[root];
|
348
344
|
// We're setting `// targets` as a comment `targets` is empty due to Project Crystal.
|
349
345
|
// Strip it before returning configuration for usage.
|
350
|
-
if (
|
351
|
-
delete
|
352
|
-
|
353
|
-
|
354
|
-
|
355
|
-
|
346
|
+
if (project['// targets'])
|
347
|
+
delete project['// targets'];
|
348
|
+
try {
|
349
|
+
validateProject(project, projects);
|
350
|
+
projects[project.name] = project;
|
351
|
+
}
|
352
|
+
catch (e) {
|
353
|
+
if ((0, error_types_1.isProjectWithNoNameError)(e)) {
|
354
|
+
projectRootsWithNoName.push(e.projectRoot);
|
356
355
|
}
|
357
|
-
|
358
|
-
|
356
|
+
else if ((0, error_types_1.isProjectWithExistingNameError)(e)) {
|
357
|
+
const rootErrors = conflicts.get(e.projectName) ?? [
|
358
|
+
projects[e.projectName].root,
|
359
|
+
];
|
360
|
+
rootErrors.push(e.projectRoot);
|
361
|
+
conflicts.set(e.projectName, rootErrors);
|
362
|
+
}
|
363
|
+
else {
|
364
|
+
throw e;
|
359
365
|
}
|
360
|
-
}
|
361
|
-
if (configuration.name in projects) {
|
362
|
-
let rootErrors = conflicts.get(configuration.name) ?? [
|
363
|
-
projects[configuration.name].root,
|
364
|
-
];
|
365
|
-
rootErrors.push(root);
|
366
|
-
conflicts.set(configuration.name, rootErrors);
|
367
|
-
projects[configuration.name] = configuration;
|
368
|
-
}
|
369
|
-
else {
|
370
|
-
projects[configuration.name] = configuration;
|
371
366
|
}
|
372
367
|
}
|
373
368
|
if (conflicts.size > 0) {
|
374
|
-
throw new error_types_1.
|
369
|
+
throw new error_types_1.MultipleProjectsWithSameNameError(conflicts, projects);
|
375
370
|
}
|
376
371
|
if (projectRootsWithNoName.length > 0) {
|
377
372
|
throw new error_types_1.ProjectsWithNoNameError(projectRootsWithNoName, projects);
|
@@ -379,6 +374,76 @@ function readProjectConfigurationsFromRootMap(projectRootMap) {
|
|
379
374
|
return projects;
|
380
375
|
}
|
381
376
|
exports.readProjectConfigurationsFromRootMap = readProjectConfigurationsFromRootMap;
|
377
|
+
function validateAndNormalizeProjectRootMap(projectRootMap) {
|
378
|
+
// Name -> Project, used to validate that all projects have unique names
|
379
|
+
const projects = {};
|
380
|
+
// If there are projects that have the same name, that is an error.
|
381
|
+
// This object tracks name -> (all roots of projects with that name)
|
382
|
+
// to provide better error messaging.
|
383
|
+
const conflicts = new Map();
|
384
|
+
const projectRootsWithNoName = [];
|
385
|
+
for (const root in projectRootMap) {
|
386
|
+
const project = projectRootMap[root];
|
387
|
+
// We're setting `// targets` as a comment `targets` is empty due to Project Crystal.
|
388
|
+
// Strip it before returning configuration for usage.
|
389
|
+
if (project['// targets'])
|
390
|
+
delete project['// targets'];
|
391
|
+
try {
|
392
|
+
validateProject(project, projects);
|
393
|
+
projects[project.name] = project;
|
394
|
+
}
|
395
|
+
catch (e) {
|
396
|
+
if ((0, error_types_1.isProjectWithNoNameError)(e)) {
|
397
|
+
projectRootsWithNoName.push(e.projectRoot);
|
398
|
+
}
|
399
|
+
else if ((0, error_types_1.isProjectWithExistingNameError)(e)) {
|
400
|
+
const rootErrors = conflicts.get(e.projectName) ?? [
|
401
|
+
projects[e.projectName].root,
|
402
|
+
];
|
403
|
+
rootErrors.push(e.projectRoot);
|
404
|
+
conflicts.set(e.projectName, rootErrors);
|
405
|
+
}
|
406
|
+
else {
|
407
|
+
throw e;
|
408
|
+
}
|
409
|
+
}
|
410
|
+
for (const targetName in project.targets) {
|
411
|
+
project.targets[targetName] = normalizeTarget(project.targets[targetName], project);
|
412
|
+
if (!project.targets[targetName].executor &&
|
413
|
+
!project.targets[targetName].command) {
|
414
|
+
delete project.targets[targetName];
|
415
|
+
}
|
416
|
+
}
|
417
|
+
}
|
418
|
+
if (conflicts.size > 0) {
|
419
|
+
throw new error_types_1.MultipleProjectsWithSameNameError(conflicts, projects);
|
420
|
+
}
|
421
|
+
if (projectRootsWithNoName.length > 0) {
|
422
|
+
throw new error_types_1.ProjectsWithNoNameError(projectRootsWithNoName, projects);
|
423
|
+
}
|
424
|
+
return projectRootMap;
|
425
|
+
}
|
426
|
+
function validateProject(project,
|
427
|
+
// name -> project
|
428
|
+
knownProjects) {
|
429
|
+
if (!project.name) {
|
430
|
+
try {
|
431
|
+
const { name } = (0, fileutils_1.readJsonFile)((0, path_1.join)(project.root, 'package.json'));
|
432
|
+
if (!name) {
|
433
|
+
throw new Error(`Project at ${project.root} has no name provided.`);
|
434
|
+
}
|
435
|
+
project.name = name;
|
436
|
+
}
|
437
|
+
catch {
|
438
|
+
throw new error_types_1.ProjectWithNoNameError(project.root);
|
439
|
+
}
|
440
|
+
}
|
441
|
+
else if (knownProjects[project.name] &&
|
442
|
+
knownProjects[project.name].root !== project.root) {
|
443
|
+
throw new error_types_1.ProjectWithExistingNameError(project.name, project.root);
|
444
|
+
}
|
445
|
+
}
|
446
|
+
exports.validateProject = validateProject;
|
382
447
|
/**
|
383
448
|
* Merges two targets.
|
384
449
|
*
|
@@ -459,8 +524,8 @@ function isCompatibleTarget(a, b) {
|
|
459
524
|
return false;
|
460
525
|
const isRunCommands = a.executor === 'nx:run-commands';
|
461
526
|
if (isRunCommands) {
|
462
|
-
const aCommand = a.options?.command ?? a.options?.commands
|
463
|
-
const bCommand = b.options?.command ?? b.options?.commands
|
527
|
+
const aCommand = a.options?.command ?? a.options?.commands?.join(' && ');
|
528
|
+
const bCommand = b.options?.command ?? b.options?.commands?.join(' && ');
|
464
529
|
const oneHasNoCommand = !aCommand || !bCommand;
|
465
530
|
const hasSameCommand = aCommand === bCommand;
|
466
531
|
return oneHasNoCommand || hasSameCommand;
|
@@ -577,3 +642,13 @@ function resolveCommandSyntacticSugar(target, key) {
|
|
577
642
|
};
|
578
643
|
}
|
579
644
|
}
|
645
|
+
function normalizeTarget(target, project) {
|
646
|
+
target = resolveCommandSyntacticSugar(target, project.root);
|
647
|
+
target.options = resolveNxTokensInOptions(target.options, project, `${project.root}:${target}`);
|
648
|
+
target.configurations ??= {};
|
649
|
+
for (const configuration in target.configurations) {
|
650
|
+
target.configurations[configuration] = resolveNxTokensInOptions(target.configurations[configuration], project, `${project.root}:${target}:${configuration}`);
|
651
|
+
}
|
652
|
+
return target;
|
653
|
+
}
|
654
|
+
exports.normalizeTarget = normalizeTarget;
|
@@ -170,7 +170,6 @@ class ProcessTasks {
|
|
170
170
|
projectRoot: project.data.root,
|
171
171
|
overrides: interpolatedOverrides,
|
172
172
|
outputs: (0, utils_1.getOutputs)(this.projectGraph.nodes, qualifiedTarget, interpolatedOverrides),
|
173
|
-
// TODO(v19): Remove cast here after typing is moved back onto TargetConfiguration
|
174
173
|
cache: project.data.targets[target].cache,
|
175
174
|
};
|
176
175
|
}
|
@@ -265,7 +265,7 @@ async function createRunManyDynamicOutputRenderer({ projectNames, tasks, args, o
|
|
265
265
|
'',
|
266
266
|
`${failedTasksForPrinting
|
267
267
|
.map((t) => `${EXTENDED_LEFT_PAD}${output_1.output.colors.red('-')} ${output_1.output.formatCommand(t.toString())}`)
|
268
|
-
.join('\n
|
268
|
+
.join('\n')}`,
|
269
269
|
];
|
270
270
|
if (failedTasks.size > numFailedToPrint) {
|
271
271
|
failureSummaryRows.push(output_1.output.dim(`${EXTENDED_LEFT_PAD}...and ${failedTasks.size - numFailedToPrint} more...`));
|
@@ -140,7 +140,7 @@ async function invokeTasksRunner({ tasks, projectGraph, taskGraph, lifeCycle, nx
|
|
140
140
|
title: `TaskGraph is now required as an argument to hashTask`,
|
141
141
|
bodyLines: [
|
142
142
|
`The TaskGraph object can be retrieved from the context`,
|
143
|
-
'This will result in an error in Nx
|
143
|
+
'This will result in an error in Nx 20',
|
144
144
|
],
|
145
145
|
});
|
146
146
|
taskGraph_ = taskGraph;
|
@@ -150,7 +150,7 @@ async function invokeTasksRunner({ tasks, projectGraph, taskGraph, lifeCycle, nx
|
|
150
150
|
title: `The environment variables are now required as an argument to hashTask`,
|
151
151
|
bodyLines: [
|
152
152
|
`Please pass the environment variables used when running the task`,
|
153
|
-
'This will result in an error in Nx
|
153
|
+
'This will result in an error in Nx 20',
|
154
154
|
],
|
155
155
|
});
|
156
156
|
env = process.env;
|
@@ -163,7 +163,7 @@ async function invokeTasksRunner({ tasks, projectGraph, taskGraph, lifeCycle, nx
|
|
163
163
|
title: `TaskGraph is now required as an argument to hashTasks`,
|
164
164
|
bodyLines: [
|
165
165
|
`The TaskGraph object can be retrieved from the context`,
|
166
|
-
'This will result in an error in Nx
|
166
|
+
'This will result in an error in Nx 20',
|
167
167
|
],
|
168
168
|
});
|
169
169
|
taskGraph_ = taskGraph;
|
@@ -173,7 +173,7 @@ async function invokeTasksRunner({ tasks, projectGraph, taskGraph, lifeCycle, nx
|
|
173
173
|
title: `The environment variables are now required as an argument to hashTasks`,
|
174
174
|
bodyLines: [
|
175
175
|
`Please pass the environment variables used when running the tasks`,
|
176
|
-
'This will result in an error in Nx
|
176
|
+
'This will result in an error in Nx 20',
|
177
177
|
],
|
178
178
|
});
|
179
179
|
env = process.env;
|
@@ -78,7 +78,24 @@ class InvalidOutputsError extends Error {
|
|
78
78
|
return `The following outputs are invalid:${invalidOutputsList}\nPlease run "nx repair" to repair your configuration`;
|
79
79
|
}
|
80
80
|
}
|
81
|
+
function assertOutputsAreValidType(outputs) {
|
82
|
+
if (!Array.isArray(outputs)) {
|
83
|
+
throw new Error("The 'outputs' field must be an array");
|
84
|
+
}
|
85
|
+
const typesArray = [];
|
86
|
+
let hasInvalidType = false;
|
87
|
+
for (const output of outputs) {
|
88
|
+
if (typeof output !== 'string') {
|
89
|
+
hasInvalidType = true;
|
90
|
+
}
|
91
|
+
typesArray.push(typeof output);
|
92
|
+
}
|
93
|
+
if (hasInvalidType) {
|
94
|
+
throw new Error(`The 'outputs' field must contain only strings, but received types: [${typesArray.join(', ')}]`);
|
95
|
+
}
|
96
|
+
}
|
81
97
|
function validateOutputs(outputs) {
|
98
|
+
assertOutputsAreValidType(outputs);
|
82
99
|
const invalidOutputs = new Set();
|
83
100
|
for (const output of outputs) {
|
84
101
|
if (!/^!?{[\s\S]+}/.test(output)) {
|
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.assertWorkspaceValidity = void 0;
|
4
4
|
const find_matching_projects_1 = require("./find-matching-projects");
|
5
5
|
const output_1 = require("./output");
|
6
|
+
const devkit_internals_1 = require("../devkit-internals");
|
6
7
|
function assertWorkspaceValidity(projects, nxJson) {
|
7
8
|
const projectNames = Object.keys(projects);
|
8
9
|
const projectGraphNodes = projectNames.reduce((graph, project) => {
|
@@ -67,7 +68,7 @@ function assertWorkspaceValidity(projects, nxJson) {
|
|
67
68
|
})
|
68
69
|
.join('\n\n');
|
69
70
|
}
|
70
|
-
throw new
|
71
|
+
throw new devkit_internals_1.WorkspaceValidityError(message);
|
71
72
|
}
|
72
73
|
exports.assertWorkspaceValidity = assertWorkspaceValidity;
|
73
74
|
function detectAndSetInvalidProjectGlobValues(map, sourceName, desiredImplicitDeps, projectConfigurations, projects) {
|
@@ -26,6 +26,6 @@ export type NxPluginV1 = {
|
|
26
26
|
projectFilePatterns?: string[];
|
27
27
|
};
|
28
28
|
/**
|
29
|
-
* @todo(@agentender)
|
29
|
+
* @todo(@agentender) v20: Remove this fn when we remove readWorkspaceConfig
|
30
30
|
*/
|
31
31
|
export declare function getDefaultPluginsSync(root: string): NxPluginV2[];
|
@@ -6,7 +6,7 @@ const project_json_1 = require("../plugins/project-json/build-nodes/project-json
|
|
6
6
|
const target_defaults_plugin_1 = require("../plugins/target-defaults/target-defaults-plugin");
|
7
7
|
const PackageJsonWorkspacesPlugin = require("../plugins/package-json-workspaces");
|
8
8
|
/**
|
9
|
-
* @todo(@agentender)
|
9
|
+
* @todo(@agentender) v20: Remove this fn when we remove readWorkspaceConfig
|
10
10
|
*/
|
11
11
|
function getDefaultPluginsSync(root) {
|
12
12
|
const plugins = [
|