nx 19.0.0-canary.20240420-9ca53b7 → 19.0.0-canary.20240425-cec57c4
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/package.json +12 -12
- package/src/command-line/init/implementation/react/index.js +1 -1
- package/src/config/nx-json.d.ts +2 -2
- 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.js +1 -1
- package/src/daemon/server/project-graph-incremental-recomputation.js +8 -8
- package/src/devkit-exports.d.ts +1 -1
- 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 +1 -0
- package/src/executors/run-commands/run-commands.impl.js +2 -1
- package/src/executors/run-commands/schema.json +5 -0
- package/src/executors/utils/convert-nx-executor.js +2 -1
- package/src/generators/utils/project-configuration.js +2 -2
- package/src/project-graph/build-project-graph.d.ts +8 -18
- package/src/project-graph/build-project-graph.js +58 -54
- package/src/project-graph/error-types.d.ts +26 -3
- package/src/project-graph/error-types.js +57 -1
- package/src/project-graph/file-utils.js +1 -1
- 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 +24 -3
- package/src/project-graph/plugins/isolation/plugin-pool.js +20 -0
- package/src/project-graph/plugins/isolation/plugin-worker.js +16 -0
- package/src/project-graph/plugins/loader.js +13 -5
- package/src/project-graph/plugins/public-api.d.ts +10 -0
- package/src/project-graph/project-graph.js +6 -6
- 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 -8
- package/src/project-graph/utils/project-configuration-utils.d.ts +21 -5
- package/src/project-graph/utils/project-configuration-utils.js +24 -15
- package/src/project-graph/utils/retrieve-workspace-files.d.ts +3 -3
- package/src/core/graph/3rdpartylicenses.txt +0 -785
@@ -1 +1 @@
|
|
1
|
-
(()=>{"use strict";var e,r={},t={};function o(e){var n=t[e];if(void 0!==n)return n.exports;var i=t[e]={id:e,loaded:!1,exports:{}};return r[e].call(i.exports,i,i.exports,o),i.loaded=!0,i.exports}o.m=r,e=[],o.O=(r,t,n,i)=>{if(!t){var l=1/0;for(f=0;f<e.length;f++){for(var[t,n,i]=e[f],a=!0,u=0;u<t.length;u++)(!1&i||l>=i)&&Object.keys(o.O).every((e=>o.O[e](t[u])))?t.splice(u--,1):(a=!1,i<l&&(l=i));if(a){e.splice(f--,1);var d=n();void 0!==d&&(r=d)}}return r}i=i||0;for(var f=e.length;f>0&&e[f-1][2]>i;f--)e[f]=e[f-1];e[f]=[t,n,i]},o.n=e=>{var r=e&&e.__esModule?()=>e.default:()=>e;return o.d(r,{a:r}),r},o.d=(e,r)=>{for(var t in r)o.o(r,t)&&!o.o(e,t)&&Object.defineProperty(e,t,{enumerable:!0,get:r[t]})},o.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}(),o.o=(e,r)=>Object.prototype.hasOwnProperty.call(e,r),o.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},o.nmd=e=>(e.paths=[],e.children||(e.children=[]),e),(()=>{var e={
|
1
|
+
(()=>{"use strict";var e,r={},t={};function o(e){var n=t[e];if(void 0!==n)return n.exports;var i=t[e]={id:e,loaded:!1,exports:{}};return r[e].call(i.exports,i,i.exports,o),i.loaded=!0,i.exports}o.m=r,e=[],o.O=(r,t,n,i)=>{if(!t){var l=1/0;for(f=0;f<e.length;f++){for(var[t,n,i]=e[f],a=!0,u=0;u<t.length;u++)(!1&i||l>=i)&&Object.keys(o.O).every((e=>o.O[e](t[u])))?t.splice(u--,1):(a=!1,i<l&&(l=i));if(a){e.splice(f--,1);var d=n();void 0!==d&&(r=d)}}return r}i=i||0;for(var f=e.length;f>0&&e[f-1][2]>i;f--)e[f]=e[f-1];e[f]=[t,n,i]},o.n=e=>{var r=e&&e.__esModule?()=>e.default:()=>e;return o.d(r,{a:r}),r},o.d=(e,r)=>{for(var t in r)o.o(r,t)&&!o.o(e,t)&&Object.defineProperty(e,t,{enumerable:!0,get:r[t]})},o.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}(),o.o=(e,r)=>Object.prototype.hasOwnProperty.call(e,r),o.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},o.nmd=e=>(e.paths=[],e.children||(e.children=[]),e),(()=>{var e={666:0};o.O.j=r=>0===e[r];var r=(r,t)=>{var n,i,[l,a,u]=t,d=0;if(l.some((r=>0!==e[r]))){for(n in a)o.o(a,n)&&(o.m[n]=a[n]);if(u)var f=u(o)}for(r&&r(t);d<l.length;d++)i=l[d],o.o(e,i)&&e[i]&&e[i][0](),e[i]=0;return o.O(f)},t=self.webpackChunk=self.webpackChunk||[];t.forEach(r.bind(null,0)),t.push=r.bind(null,t.push.bind(t))})()})();
|
package/src/core/graph/styles.js
CHANGED
@@ -1 +1 @@
|
|
1
|
-
"use strict";(self.webpackChunk=self.webpackChunk||[]).push([[
|
1
|
+
"use strict";(self.webpackChunk=self.webpackChunk||[]).push([[532],{96467:()=>{}},s=>{var e;e=96467,s(s.s=e)}]);
|
@@ -142,26 +142,26 @@ async function processFilesAndCreateAndSerializeProjectGraph(plugins) {
|
|
142
142
|
logger_1.serverLogger.requestLog([...deletedFiles]);
|
143
143
|
const nxJson = (0, nx_json_1.readNxJson)(workspace_root_1.workspaceRoot);
|
144
144
|
global.NX_GRAPH_CREATION = true;
|
145
|
-
let
|
145
|
+
let projectConfigurationsResult;
|
146
146
|
let projectConfigurationsError;
|
147
147
|
try {
|
148
|
-
|
148
|
+
projectConfigurationsResult = await (0, retrieve_workspace_files_1.retrieveProjectConfigurations)(plugins, workspace_root_1.workspaceRoot, nxJson);
|
149
149
|
}
|
150
150
|
catch (e) {
|
151
151
|
if (e instanceof error_types_1.ProjectConfigurationsError) {
|
152
|
-
|
152
|
+
projectConfigurationsResult = e.partialProjectConfigurationsResult;
|
153
153
|
projectConfigurationsError = e;
|
154
154
|
}
|
155
155
|
else {
|
156
156
|
throw e;
|
157
157
|
}
|
158
158
|
}
|
159
|
-
await processCollectedUpdatedAndDeletedFiles(
|
160
|
-
const g = await createAndSerializeProjectGraph(
|
159
|
+
await processCollectedUpdatedAndDeletedFiles(projectConfigurationsResult, updatedFileHashes, deletedFiles);
|
160
|
+
const g = await createAndSerializeProjectGraph(projectConfigurationsResult);
|
161
161
|
delete global.NX_GRAPH_CREATION;
|
162
162
|
const errors = [...(projectConfigurationsError?.errors ?? [])];
|
163
163
|
if (g.error) {
|
164
|
-
if (g.error
|
164
|
+
if ((0, error_types_1.isAggregateProjectGraphError)(g.error)) {
|
165
165
|
errors.push(...g.error.errors);
|
166
166
|
}
|
167
167
|
else {
|
@@ -179,7 +179,7 @@ async function processFilesAndCreateAndSerializeProjectGraph(plugins) {
|
|
179
179
|
}
|
180
180
|
if (errors.length > 0) {
|
181
181
|
return {
|
182
|
-
error: new error_types_1.DaemonProjectGraphError(errors, g.projectGraph,
|
182
|
+
error: new error_types_1.DaemonProjectGraphError(errors, g.projectGraph, projectConfigurationsResult.sourceMaps),
|
183
183
|
projectGraph: null,
|
184
184
|
projectFileMapCache: null,
|
185
185
|
fileMap: null,
|
@@ -226,7 +226,7 @@ async function createAndSerializeProjectGraph({ projects, sourceMaps, }) {
|
|
226
226
|
const fileMap = copyFileMap(exports.fileMapWithFiles.fileMap);
|
227
227
|
const allWorkspaceFiles = copyFileData(exports.fileMapWithFiles.allWorkspaceFiles);
|
228
228
|
const rustReferences = exports.fileMapWithFiles.rustReferences;
|
229
|
-
const { projectGraph, projectFileMapCache } = await (0, build_project_graph_1.buildProjectGraphUsingProjectFileMap)(projects, knownExternalNodes, fileMap, allWorkspaceFiles, rustReferences, exports.currentProjectFileMapCache || (0, nx_deps_cache_1.readFileMapCache)(), await (0, plugins_1.getPlugins)());
|
229
|
+
const { projectGraph, projectFileMapCache } = await (0, build_project_graph_1.buildProjectGraphUsingProjectFileMap)(projects, knownExternalNodes, fileMap, allWorkspaceFiles, rustReferences, exports.currentProjectFileMapCache || (0, nx_deps_cache_1.readFileMapCache)(), await (0, plugins_1.getPlugins)(), sourceMaps);
|
230
230
|
exports.currentProjectFileMapCache = projectFileMapCache;
|
231
231
|
exports.currentProjectGraph = projectGraph;
|
232
232
|
perf_hooks_1.performance.mark('create-project-graph-end');
|
package/src/devkit-exports.d.ts
CHANGED
@@ -19,7 +19,7 @@ export type { Generator, GeneratorCallback, Executor, ExecutorContext, TaskGraph
|
|
19
19
|
*/
|
20
20
|
export { Workspaces } from './config/workspaces';
|
21
21
|
export { workspaceLayout } from './config/configuration';
|
22
|
-
export type { NxPlugin, NxPluginV2, CreateNodes, CreateNodesFunction, CreateNodesResult, CreateNodesContext, CreateDependencies, CreateDependenciesContext, } from './project-graph/plugins';
|
22
|
+
export type { NxPlugin, NxPluginV2, CreateNodes, CreateNodesFunction, CreateNodesResult, CreateNodesContext, CreateDependencies, CreateDependenciesContext, CreateMetadata, CreateMetadataContext, ProjectsMetadata, } from './project-graph/plugins';
|
23
23
|
export type { NxPluginV1, ProjectTargetConfigurator, } from './utils/nx-plugin.deprecated';
|
24
24
|
/**
|
25
25
|
* @category Workspace
|
@@ -8,6 +8,8 @@ export { getExecutorInformation } from './command-line/run/executor-utils';
|
|
8
8
|
export { readNxJson as readNxJsonFromDisk } from './config/nx-json';
|
9
9
|
export { calculateDefaultProjectName } from './config/calculate-default-project-name';
|
10
10
|
export { retrieveProjectConfigurationsWithAngularProjects } from './project-graph/utils/retrieve-workspace-files';
|
11
|
+
export { mergeTargetConfigurations } from './project-graph/utils/project-configuration-utils';
|
12
|
+
export { readProjectConfigurationsFromRootMap } from './project-graph/utils/project-configuration-utils';
|
11
13
|
export { splitTarget } from './utils/split-target';
|
12
14
|
export { combineOptionsForExecutor } from './utils/params';
|
13
15
|
export { sortObjectByKeys } from './utils/object-sort';
|
package/src/devkit-internals.js
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
exports.registerTsProject = exports.LoadedNxPlugin = exports.retrieveProjectConfigurations = exports.findProjectForPath = exports.createProjectRootMappingsFromProjectConfigurations = exports.hashWithWorkspaceContext = exports.hashObject = exports.splitByColons = exports.readModulePackageJson = exports.stripIndent = exports.sortObjectByKeys = exports.combineOptionsForExecutor = exports.splitTarget = exports.retrieveProjectConfigurationsWithAngularProjects = exports.calculateDefaultProjectName = exports.readNxJsonFromDisk = exports.getExecutorInformation = exports.createTempNpmDirectory = void 0;
|
3
|
+
exports.registerTsProject = exports.LoadedNxPlugin = exports.retrieveProjectConfigurations = exports.findProjectForPath = exports.createProjectRootMappingsFromProjectConfigurations = exports.hashWithWorkspaceContext = exports.hashObject = exports.splitByColons = exports.readModulePackageJson = exports.stripIndent = exports.sortObjectByKeys = exports.combineOptionsForExecutor = exports.splitTarget = exports.readProjectConfigurationsFromRootMap = exports.mergeTargetConfigurations = exports.retrieveProjectConfigurationsWithAngularProjects = exports.calculateDefaultProjectName = exports.readNxJsonFromDisk = exports.getExecutorInformation = exports.createTempNpmDirectory = void 0;
|
4
4
|
const tslib_1 = require("tslib");
|
5
5
|
/**
|
6
6
|
* Note to developers: STOP! These exports are available via requireNx in @nx/devkit.
|
@@ -17,6 +17,10 @@ var calculate_default_project_name_1 = require("./config/calculate-default-proje
|
|
17
17
|
Object.defineProperty(exports, "calculateDefaultProjectName", { enumerable: true, get: function () { return calculate_default_project_name_1.calculateDefaultProjectName; } });
|
18
18
|
var retrieve_workspace_files_1 = require("./project-graph/utils/retrieve-workspace-files");
|
19
19
|
Object.defineProperty(exports, "retrieveProjectConfigurationsWithAngularProjects", { enumerable: true, get: function () { return retrieve_workspace_files_1.retrieveProjectConfigurationsWithAngularProjects; } });
|
20
|
+
var project_configuration_utils_1 = require("./project-graph/utils/project-configuration-utils");
|
21
|
+
Object.defineProperty(exports, "mergeTargetConfigurations", { enumerable: true, get: function () { return project_configuration_utils_1.mergeTargetConfigurations; } });
|
22
|
+
var project_configuration_utils_2 = require("./project-graph/utils/project-configuration-utils");
|
23
|
+
Object.defineProperty(exports, "readProjectConfigurationsFromRootMap", { enumerable: true, get: function () { return project_configuration_utils_2.readProjectConfigurationsFromRootMap; } });
|
20
24
|
var split_target_1 = require("./utils/split-target");
|
21
25
|
Object.defineProperty(exports, "splitTarget", { enumerable: true, get: function () { return split_target_1.splitTarget; } });
|
22
26
|
var params_1 = require("./utils/params");
|
@@ -39,6 +39,7 @@ const propKeys = [
|
|
39
39
|
'usePty',
|
40
40
|
'streamOutput',
|
41
41
|
'verbose',
|
42
|
+
'forwardAllArgs',
|
42
43
|
];
|
43
44
|
async function default_1(options, context) {
|
44
45
|
registerProcessListener();
|
@@ -135,7 +136,7 @@ function normalizeOptions(options) {
|
|
135
136
|
options.parsedArgs = parseArgs(unparsedCommandArgs, options.unknownOptions, options.args);
|
136
137
|
options.unparsedCommandArgs = unparsedCommandArgs;
|
137
138
|
options.commands.forEach((c) => {
|
138
|
-
c.command = interpolateArgsIntoCommand(c.command, options, c.forwardAllArgs ?? true);
|
139
|
+
c.command = interpolateArgsIntoCommand(c.command, options, c.forwardAllArgs ?? options.forwardAllArgs ?? true);
|
139
140
|
});
|
140
141
|
return options;
|
141
142
|
}
|
@@ -135,6 +135,11 @@
|
|
135
135
|
"$source": "unparsed"
|
136
136
|
},
|
137
137
|
"x-priority": "internal"
|
138
|
+
},
|
139
|
+
"forwardAllArgs": {
|
140
|
+
"type": "boolean",
|
141
|
+
"description": "Whether arguments should be forwarded when interpolation is not present.",
|
142
|
+
"default": true
|
138
143
|
}
|
139
144
|
},
|
140
145
|
"additionalProperties": true,
|
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.convertNxExecutor = void 0;
|
7
7
|
const nx_json_1 = require("../../config/nx-json");
|
8
8
|
const retrieve_workspace_files_1 = require("../../project-graph/utils/retrieve-workspace-files");
|
9
|
+
const project_configuration_utils_1 = require("../../project-graph/utils/project-configuration-utils");
|
9
10
|
const internal_api_1 = require("../../project-graph/plugins/internal-api");
|
10
11
|
/**
|
11
12
|
* Convert an Nx Executor into an Angular Devkit Builder
|
@@ -19,7 +20,7 @@ function convertNxExecutor(executor) {
|
|
19
20
|
const [plugins, cleanup] = await (0, internal_api_1.loadNxPlugins)(nxJsonConfiguration.plugins, builderContext.workspaceRoot);
|
20
21
|
const projectsConfigurations = {
|
21
22
|
version: 2,
|
22
|
-
projects: (await (0, retrieve_workspace_files_1.retrieveProjectConfigurations)(plugins, builderContext.workspaceRoot, nxJsonConfiguration)).projects,
|
23
|
+
projects: (0, project_configuration_utils_1.readProjectConfigurationsFromRootMap)((await (0, retrieve_workspace_files_1.retrieveProjectConfigurations)(plugins, builderContext.workspaceRoot, nxJsonConfiguration)).projects),
|
23
24
|
};
|
24
25
|
cleanup();
|
25
26
|
const context = {
|
@@ -143,7 +143,7 @@ function readAndCombineAllProjectConfigurations(tree) {
|
|
143
143
|
const createdFiles = findCreatedProjectFiles(tree, patterns);
|
144
144
|
const deletedFiles = findDeletedProjectFiles(tree, patterns);
|
145
145
|
const projectFiles = [...globbedFiles, ...createdFiles].filter((r) => deletedFiles.indexOf(r) === -1);
|
146
|
-
const rootMap =
|
146
|
+
const rootMap = {};
|
147
147
|
for (const projectFile of projectFiles) {
|
148
148
|
if ((0, path_1.basename)(projectFile) === 'project.json') {
|
149
149
|
const json = (0, json_1.readJson)(tree, projectFile);
|
@@ -153,7 +153,7 @@ function readAndCombineAllProjectConfigurations(tree) {
|
|
153
153
|
else if ((0, path_1.basename)(projectFile) === 'package.json') {
|
154
154
|
const packageJson = (0, json_1.readJson)(tree, projectFile);
|
155
155
|
const config = (0, package_json_workspaces_1.buildProjectConfigurationFromPackageJson)(packageJson, projectFile, (0, nx_json_1.readNxJson)(tree));
|
156
|
-
if (!rootMap
|
156
|
+
if (!rootMap[config.root]) {
|
157
157
|
(0, project_configuration_utils_1.mergeProjectConfigurationIntoRootMap)(rootMap,
|
158
158
|
// Inferred targets, tags, etc don't show up when running generators
|
159
159
|
// This is to help avoid running into issues when trying to update the workspace
|
@@ -1,32 +1,22 @@
|
|
1
1
|
import { FileData } from './file-utils';
|
2
2
|
import { FileMapCache } from './nx-deps-cache';
|
3
3
|
import { LoadedNxPlugin } from './plugins/internal-api';
|
4
|
+
import { CreateMetadataContext } from './plugins';
|
4
5
|
import { FileMap, ProjectGraph, ProjectGraphExternalNode } from '../config/project-graph';
|
5
6
|
import { ProjectConfiguration } from '../config/workspace-json-project-json';
|
6
7
|
import { NxWorkspaceFilesExternals } from '../native';
|
8
|
+
import { CreateMetadataError } from './error-types';
|
9
|
+
import { ConfigurationSourceMaps } from './utils/project-configuration-utils';
|
7
10
|
export declare function getFileMap(): {
|
8
11
|
fileMap: FileMap;
|
9
12
|
allWorkspaceFiles: FileData[];
|
10
13
|
rustReferences: NxWorkspaceFilesExternals | null;
|
11
14
|
};
|
12
|
-
export declare function buildProjectGraphUsingProjectFileMap(
|
15
|
+
export declare function buildProjectGraphUsingProjectFileMap(projectRootMap: Record<string, ProjectConfiguration>, externalNodes: Record<string, ProjectGraphExternalNode>, fileMap: FileMap, allWorkspaceFiles: FileData[], rustReferences: NxWorkspaceFilesExternals, fileMapCache: FileMapCache | null, plugins: LoadedNxPlugin[], sourceMap: ConfigurationSourceMaps): Promise<{
|
13
16
|
projectGraph: ProjectGraph;
|
14
17
|
projectFileMapCache: FileMapCache;
|
15
18
|
}>;
|
16
|
-
export declare
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
});
|
21
|
-
}
|
22
|
-
export declare class ProcessProjectGraphError extends Error {
|
23
|
-
readonly pluginName: string;
|
24
|
-
constructor(pluginName: string, { cause }: {
|
25
|
-
cause: any;
|
26
|
-
});
|
27
|
-
}
|
28
|
-
export declare class CreateDependenciesError extends Error {
|
29
|
-
readonly errors: Array<ProcessDependenciesError | ProcessProjectGraphError>;
|
30
|
-
readonly partialProjectGraph: ProjectGraph;
|
31
|
-
constructor(errors: Array<ProcessDependenciesError | ProcessProjectGraphError>, partialProjectGraph: ProjectGraph);
|
32
|
-
}
|
19
|
+
export declare function applyProjectMetadata(graph: ProjectGraph, plugins: LoadedNxPlugin[], context: CreateMetadataContext, sourceMap: ConfigurationSourceMaps): Promise<{
|
20
|
+
graph: ProjectGraph;
|
21
|
+
errors?: CreateMetadataError[];
|
22
|
+
}>;
|
@@ -1,6 +1,6 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
exports.
|
3
|
+
exports.applyProjectMetadata = exports.buildProjectGraphUsingProjectFileMap = exports.getFileMap = void 0;
|
4
4
|
const workspace_root_1 = require("../utils/workspace-root");
|
5
5
|
const path_1 = require("path");
|
6
6
|
const perf_hooks_1 = require("perf_hooks");
|
@@ -15,6 +15,8 @@ const project_graph_builder_1 = require("./project-graph-builder");
|
|
15
15
|
const configuration_1 = require("../config/configuration");
|
16
16
|
const fs_1 = require("fs");
|
17
17
|
const output_1 = require("../utils/output");
|
18
|
+
const error_types_1 = require("./error-types");
|
19
|
+
const project_configuration_utils_1 = require("./utils/project-configuration-utils");
|
18
20
|
let storedFileMap = null;
|
19
21
|
let storedAllWorkspaceFiles = null;
|
20
22
|
let storedRustReferences = null;
|
@@ -38,10 +40,15 @@ function getFileMap() {
|
|
38
40
|
}
|
39
41
|
}
|
40
42
|
exports.getFileMap = getFileMap;
|
41
|
-
async function buildProjectGraphUsingProjectFileMap(
|
43
|
+
async function buildProjectGraphUsingProjectFileMap(projectRootMap, externalNodes, fileMap, allWorkspaceFiles, rustReferences, fileMapCache, plugins, sourceMap) {
|
42
44
|
storedFileMap = fileMap;
|
43
45
|
storedAllWorkspaceFiles = allWorkspaceFiles;
|
44
46
|
storedRustReferences = rustReferences;
|
47
|
+
const projects = {};
|
48
|
+
for (const root in projectRootMap) {
|
49
|
+
const project = projectRootMap[root];
|
50
|
+
projects[project.name] = project;
|
51
|
+
}
|
45
52
|
const nxJson = (0, configuration_1.readNxJson)();
|
46
53
|
const projectGraphVersion = '6.0';
|
47
54
|
(0, assert_workspace_validity_1.assertWorkspaceValidity)(projects, nxJson);
|
@@ -64,7 +71,7 @@ async function buildProjectGraphUsingProjectFileMap(projects, externalNodes, fil
|
|
64
71
|
};
|
65
72
|
}
|
66
73
|
const context = createContext(projects, nxJson, externalNodes, fileMap, filesToProcess);
|
67
|
-
let projectGraph = await buildProjectGraphUsingContext(externalNodes, context, cachedFileData, projectGraphVersion, plugins);
|
74
|
+
let projectGraph = await buildProjectGraphUsingContext(externalNodes, context, cachedFileData, projectGraphVersion, plugins, sourceMap);
|
68
75
|
const projectFileMapCache = (0, nx_deps_cache_1.createProjectFileMapCache)(nxJson, packageJsonDeps, fileMap, rootTsConfig);
|
69
76
|
return {
|
70
77
|
projectGraph,
|
@@ -88,7 +95,7 @@ function readCombinedDeps() {
|
|
88
95
|
...installationPackageJson.devDependencies,
|
89
96
|
};
|
90
97
|
}
|
91
|
-
async function buildProjectGraphUsingContext(knownExternalNodes, ctx, cachedFileData, projectGraphVersion, plugins) {
|
98
|
+
async function buildProjectGraphUsingContext(knownExternalNodes, ctx, cachedFileData, projectGraphVersion, plugins, sourceMap) {
|
92
99
|
perf_hooks_1.performance.mark('build project graph:start');
|
93
100
|
const builder = new project_graph_builder_1.ProjectGraphBuilder(null, ctx.fileMap.projectFileMap);
|
94
101
|
builder.setVersion(projectGraphVersion);
|
@@ -100,10 +107,10 @@ async function buildProjectGraphUsingContext(knownExternalNodes, ctx, cachedFile
|
|
100
107
|
let updatedGraph;
|
101
108
|
let error;
|
102
109
|
try {
|
103
|
-
updatedGraph = await updateProjectGraphWithPlugins(ctx, initProjectGraph, plugins);
|
110
|
+
updatedGraph = await updateProjectGraphWithPlugins(ctx, initProjectGraph, plugins, sourceMap);
|
104
111
|
}
|
105
112
|
catch (e) {
|
106
|
-
if (
|
113
|
+
if ((0, error_types_1.isAggregateProjectGraphError)(e)) {
|
107
114
|
updatedGraph = e.partialProjectGraph;
|
108
115
|
error = e;
|
109
116
|
}
|
@@ -134,26 +141,20 @@ async function buildProjectGraphUsingContext(knownExternalNodes, ctx, cachedFile
|
|
134
141
|
return finalGraph;
|
135
142
|
}
|
136
143
|
else {
|
137
|
-
throw new
|
144
|
+
throw new error_types_1.AggregateProjectGraphError(error.errors, finalGraph);
|
138
145
|
}
|
139
146
|
}
|
140
147
|
function createContext(projects, nxJson, externalNodes, fileMap, filesToProcess) {
|
141
|
-
const clonedProjects = Object.keys(projects).reduce((map, projectName) => {
|
142
|
-
map[projectName] = {
|
143
|
-
...projects[projectName],
|
144
|
-
};
|
145
|
-
return map;
|
146
|
-
}, {});
|
147
148
|
return {
|
148
149
|
nxJsonConfiguration: nxJson,
|
149
|
-
projects
|
150
|
+
projects,
|
150
151
|
externalNodes,
|
151
152
|
workspaceRoot: workspace_root_1.workspaceRoot,
|
152
153
|
fileMap,
|
153
154
|
filesToProcess,
|
154
155
|
};
|
155
156
|
}
|
156
|
-
async function updateProjectGraphWithPlugins(context, initProjectGraph, plugins) {
|
157
|
+
async function updateProjectGraphWithPlugins(context, initProjectGraph, plugins, sourceMap) {
|
157
158
|
let graph = initProjectGraph;
|
158
159
|
const errors = [];
|
159
160
|
for (const plugin of plugins) {
|
@@ -187,7 +188,7 @@ async function updateProjectGraphWithPlugins(context, initProjectGraph, plugins)
|
|
187
188
|
}
|
188
189
|
}
|
189
190
|
catch (e) {
|
190
|
-
errors.push(new ProcessProjectGraphError(plugin.name, {
|
191
|
+
errors.push(new error_types_1.ProcessProjectGraphError(plugin.name, {
|
191
192
|
cause: e,
|
192
193
|
}));
|
193
194
|
}
|
@@ -205,52 +206,24 @@ async function updateProjectGraphWithPlugins(context, initProjectGraph, plugins)
|
|
205
206
|
}
|
206
207
|
}
|
207
208
|
catch (cause) {
|
208
|
-
errors.push(new ProcessDependenciesError(plugin.name, {
|
209
|
+
errors.push(new error_types_1.ProcessDependenciesError(plugin.name, {
|
209
210
|
cause,
|
210
211
|
}));
|
211
212
|
}
|
212
213
|
perf_hooks_1.performance.mark(`${plugin.name}:createDependencies - end`);
|
213
214
|
perf_hooks_1.performance.measure(`${plugin.name}:createDependencies`, `${plugin.name}:createDependencies - start`, `${plugin.name}:createDependencies - end`);
|
214
215
|
}));
|
215
|
-
const
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
class ProcessDependenciesError extends Error {
|
224
|
-
constructor(pluginName, { cause }) {
|
225
|
-
super(`The "${pluginName}" plugin threw an error while creating dependencies:`, {
|
226
|
-
cause,
|
227
|
-
});
|
228
|
-
this.pluginName = pluginName;
|
229
|
-
this.name = this.constructor.name;
|
230
|
-
this.stack = `${this.message}\n ${cause.stack.split('\n').join('\n ')}`;
|
231
|
-
}
|
232
|
-
}
|
233
|
-
exports.ProcessDependenciesError = ProcessDependenciesError;
|
234
|
-
class ProcessProjectGraphError extends Error {
|
235
|
-
constructor(pluginName, { cause }) {
|
236
|
-
super(`The "${pluginName}" plugin threw an error while processing the project graph:`, {
|
237
|
-
cause,
|
238
|
-
});
|
239
|
-
this.pluginName = pluginName;
|
240
|
-
this.name = this.constructor.name;
|
241
|
-
this.stack = `${this.message}\n ${cause.stack.split('\n').join('\n ')}`;
|
242
|
-
}
|
243
|
-
}
|
244
|
-
exports.ProcessProjectGraphError = ProcessProjectGraphError;
|
245
|
-
class CreateDependenciesError extends Error {
|
246
|
-
constructor(errors, partialProjectGraph) {
|
247
|
-
super('Failed to create dependencies. See above for errors');
|
248
|
-
this.errors = errors;
|
249
|
-
this.partialProjectGraph = partialProjectGraph;
|
250
|
-
this.name = this.constructor.name;
|
216
|
+
const graphWithDeps = builder.getUpdatedProjectGraph();
|
217
|
+
const { errors: metadataErrors, graph: updatedGraph } = await applyProjectMetadata(graphWithDeps, plugins, {
|
218
|
+
nxJsonConfiguration: context.nxJsonConfiguration,
|
219
|
+
workspaceRoot: workspace_root_1.workspaceRoot,
|
220
|
+
}, sourceMap);
|
221
|
+
errors.push(...metadataErrors);
|
222
|
+
if (errors.length > 0) {
|
223
|
+
throw new error_types_1.AggregateProjectGraphError(errors, updatedGraph);
|
251
224
|
}
|
225
|
+
return updatedGraph;
|
252
226
|
}
|
253
|
-
exports.CreateDependenciesError = CreateDependenciesError;
|
254
227
|
function readRootTsConfig() {
|
255
228
|
try {
|
256
229
|
const tsConfigPath = (0, typescript_1.getRootTsConfigPath)();
|
@@ -262,3 +235,34 @@ function readRootTsConfig() {
|
|
262
235
|
return {};
|
263
236
|
}
|
264
237
|
}
|
238
|
+
async function applyProjectMetadata(graph, plugins, context, sourceMap) {
|
239
|
+
const results = [];
|
240
|
+
const errors = [];
|
241
|
+
const promises = plugins.map(async (plugin) => {
|
242
|
+
if ((0, utils_1.isNxPluginV2)(plugin) && plugin.createMetadata) {
|
243
|
+
perf_hooks_1.performance.mark(`${plugin.name}:createMetadata - start`);
|
244
|
+
try {
|
245
|
+
const metadata = await plugin.createMetadata(graph, undefined, context);
|
246
|
+
results.push({ metadata, pluginName: plugin.name });
|
247
|
+
}
|
248
|
+
catch (e) {
|
249
|
+
errors.push(new error_types_1.CreateMetadataError(e, plugin.name));
|
250
|
+
}
|
251
|
+
finally {
|
252
|
+
perf_hooks_1.performance.mark(`${plugin.name}:createMetadata - end`);
|
253
|
+
perf_hooks_1.performance.measure(`${plugin.name}:createMetadata`, `${plugin.name}:createMetadata - start`, `${plugin.name}:createMetadata - end`);
|
254
|
+
}
|
255
|
+
}
|
256
|
+
});
|
257
|
+
await Promise.all(promises);
|
258
|
+
for (const { metadata: projectsMetadata, pluginName } of results) {
|
259
|
+
for (const project in projectsMetadata) {
|
260
|
+
const projectConfiguration = graph.nodes[project]?.data;
|
261
|
+
if (projectConfiguration) {
|
262
|
+
projectConfiguration.metadata = (0, project_configuration_utils_1.mergeMetadata)(sourceMap[project], [null, pluginName], 'metadata', projectsMetadata[project].metadata, projectConfiguration.metadata);
|
263
|
+
}
|
264
|
+
}
|
265
|
+
}
|
266
|
+
return { errors, graph };
|
267
|
+
}
|
268
|
+
exports.applyProjectMetadata = applyProjectMetadata;
|
@@ -1,11 +1,10 @@
|
|
1
1
|
import { CreateNodesResultWithContext } from './plugins/internal-api';
|
2
2
|
import { ConfigurationResult, ConfigurationSourceMaps } from './utils/project-configuration-utils';
|
3
3
|
import { ProjectConfiguration } from '../config/workspace-json-project-json';
|
4
|
-
import { ProcessDependenciesError, ProcessProjectGraphError } from './build-project-graph';
|
5
4
|
import { ProjectGraph } from '../config/project-graph';
|
6
5
|
export declare class ProjectGraphError extends Error {
|
7
6
|
#private;
|
8
|
-
constructor(errors: Array<CreateNodesError | MergeNodesError | ProjectsWithNoNameError | ProjectsWithConflictingNamesError | ProcessDependenciesError | ProcessProjectGraphError>, partialProjectGraph: ProjectGraph, partialSourceMaps: ConfigurationSourceMaps);
|
7
|
+
constructor(errors: Array<CreateNodesError | MergeNodesError | ProjectsWithNoNameError | ProjectsWithConflictingNamesError | ProcessDependenciesError | ProcessProjectGraphError | CreateMetadataError>, partialProjectGraph: ProjectGraph, partialSourceMaps: ConfigurationSourceMaps);
|
9
8
|
/**
|
10
9
|
* The daemon cannot throw errors which contain methods as they are not serializable.
|
11
10
|
*
|
@@ -19,7 +18,7 @@ export declare class ProjectGraphError extends Error {
|
|
19
18
|
*/
|
20
19
|
getPartialProjectGraph(): ProjectGraph;
|
21
20
|
getPartialSourcemaps(): ConfigurationSourceMaps;
|
22
|
-
getErrors(): (
|
21
|
+
getErrors(): (CreateNodesError | MergeNodesError | CreateMetadataError | ProjectsWithNoNameError | ProjectsWithConflictingNamesError | ProcessDependenciesError | ProcessProjectGraphError)[];
|
23
22
|
}
|
24
23
|
export declare class ProjectsWithConflictingNamesError extends Error {
|
25
24
|
projects: Record<string, ProjectConfiguration>;
|
@@ -60,6 +59,30 @@ export declare class MergeNodesError extends Error {
|
|
60
59
|
error: Error;
|
61
60
|
});
|
62
61
|
}
|
62
|
+
export declare class CreateMetadataError extends Error {
|
63
|
+
readonly error: Error;
|
64
|
+
readonly plugin: string;
|
65
|
+
constructor(error: Error, plugin: string);
|
66
|
+
}
|
67
|
+
export declare class ProcessDependenciesError extends Error {
|
68
|
+
readonly pluginName: string;
|
69
|
+
constructor(pluginName: string, { cause }: {
|
70
|
+
cause: any;
|
71
|
+
});
|
72
|
+
}
|
73
|
+
export declare class ProcessProjectGraphError extends Error {
|
74
|
+
readonly pluginName: string;
|
75
|
+
constructor(pluginName: string, { cause }: {
|
76
|
+
cause: any;
|
77
|
+
});
|
78
|
+
}
|
79
|
+
export declare class AggregateProjectGraphError extends Error {
|
80
|
+
readonly errors: Array<CreateMetadataError | ProcessDependenciesError | ProcessProjectGraphError>;
|
81
|
+
readonly partialProjectGraph: ProjectGraph;
|
82
|
+
constructor(errors: Array<CreateMetadataError | ProcessDependenciesError | ProcessProjectGraphError>, partialProjectGraph: ProjectGraph);
|
83
|
+
}
|
84
|
+
export declare function isAggregateProjectGraphError(e: unknown): e is AggregateProjectGraphError;
|
85
|
+
export declare function isCreateMetadataError(e: unknown): e is CreateMetadataError;
|
63
86
|
export declare function isCreateNodesError(e: unknown): e is CreateNodesError;
|
64
87
|
export declare function isAggregateCreateNodesError(e: unknown): e is AggregateCreateNodesError;
|
65
88
|
export declare function isMergeNodesError(e: unknown): e is MergeNodesError;
|
@@ -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.MergeNodesError = exports.AggregateCreateNodesError = exports.CreateNodesError = exports.ProjectConfigurationsError = exports.isProjectsWithNoNameError = exports.ProjectsWithNoNameError = exports.isProjectsWithConflictingNamesError = exports.ProjectsWithConflictingNamesError = exports.ProjectGraphError = void 0;
|
4
|
+
exports.LoadPluginError = exports.DaemonProjectGraphError = exports.isMergeNodesError = exports.isAggregateCreateNodesError = exports.isCreateNodesError = exports.isCreateMetadataError = exports.isAggregateProjectGraphError = exports.AggregateProjectGraphError = exports.ProcessProjectGraphError = exports.ProcessDependenciesError = exports.CreateMetadataError = exports.MergeNodesError = exports.AggregateCreateNodesError = exports.CreateNodesError = exports.ProjectConfigurationsError = exports.isProjectsWithNoNameError = exports.ProjectsWithNoNameError = exports.isProjectsWithConflictingNamesError = exports.ProjectsWithConflictingNamesError = exports.ProjectGraphError = void 0;
|
5
5
|
const tslib_1 = require("tslib");
|
6
6
|
class ProjectGraphError extends Error {
|
7
7
|
constructor(errors, partialProjectGraph, partialSourceMaps) {
|
@@ -118,6 +118,62 @@ class MergeNodesError extends Error {
|
|
118
118
|
}
|
119
119
|
}
|
120
120
|
exports.MergeNodesError = MergeNodesError;
|
121
|
+
class CreateMetadataError extends Error {
|
122
|
+
constructor(error, plugin) {
|
123
|
+
super(`The "${plugin}" plugin threw an error while creating metadata:`, {
|
124
|
+
cause: error,
|
125
|
+
});
|
126
|
+
this.error = error;
|
127
|
+
this.plugin = plugin;
|
128
|
+
this.name = this.constructor.name;
|
129
|
+
}
|
130
|
+
}
|
131
|
+
exports.CreateMetadataError = CreateMetadataError;
|
132
|
+
class ProcessDependenciesError extends Error {
|
133
|
+
constructor(pluginName, { cause }) {
|
134
|
+
super(`The "${pluginName}" plugin threw an error while creating dependencies:`, {
|
135
|
+
cause,
|
136
|
+
});
|
137
|
+
this.pluginName = pluginName;
|
138
|
+
this.name = this.constructor.name;
|
139
|
+
this.stack = `${this.message}\n ${cause.stack.split('\n').join('\n ')}`;
|
140
|
+
}
|
141
|
+
}
|
142
|
+
exports.ProcessDependenciesError = ProcessDependenciesError;
|
143
|
+
class ProcessProjectGraphError extends Error {
|
144
|
+
constructor(pluginName, { cause }) {
|
145
|
+
super(`The "${pluginName}" plugin threw an error while processing the project graph:`, {
|
146
|
+
cause,
|
147
|
+
});
|
148
|
+
this.pluginName = pluginName;
|
149
|
+
this.name = this.constructor.name;
|
150
|
+
this.stack = `${this.message}\n ${cause.stack.split('\n').join('\n ')}`;
|
151
|
+
}
|
152
|
+
}
|
153
|
+
exports.ProcessProjectGraphError = ProcessProjectGraphError;
|
154
|
+
class AggregateProjectGraphError extends Error {
|
155
|
+
constructor(errors, partialProjectGraph) {
|
156
|
+
super('Failed to create project graph. See above for errors');
|
157
|
+
this.errors = errors;
|
158
|
+
this.partialProjectGraph = partialProjectGraph;
|
159
|
+
this.name = this.constructor.name;
|
160
|
+
}
|
161
|
+
}
|
162
|
+
exports.AggregateProjectGraphError = AggregateProjectGraphError;
|
163
|
+
function isAggregateProjectGraphError(e) {
|
164
|
+
return (e instanceof AggregateProjectGraphError ||
|
165
|
+
(typeof e === 'object' &&
|
166
|
+
'name' in e &&
|
167
|
+
e?.name === AggregateProjectGraphError.prototype.name));
|
168
|
+
}
|
169
|
+
exports.isAggregateProjectGraphError = isAggregateProjectGraphError;
|
170
|
+
function isCreateMetadataError(e) {
|
171
|
+
return (e instanceof CreateMetadataError ||
|
172
|
+
(typeof e === 'object' &&
|
173
|
+
'name' in e &&
|
174
|
+
e?.name === CreateMetadataError.prototype.name));
|
175
|
+
}
|
176
|
+
exports.isCreateMetadataError = isCreateMetadataError;
|
121
177
|
function isCreateNodesError(e) {
|
122
178
|
return (e instanceof CreateNodesError ||
|
123
179
|
(typeof e === 'object' && 'name' in e && e?.name === CreateNodesError.name));
|
@@ -152,7 +152,7 @@ function getProjectsSyncNoInference(root, nxJson) {
|
|
152
152
|
package_json_next_to_project_json_1.PackageJsonProjectsNextToProjectJsonPlugin,
|
153
153
|
...(0, nx_plugin_deprecated_1.getDefaultPluginsSync)(root),
|
154
154
|
];
|
155
|
-
const projectRootMap =
|
155
|
+
const projectRootMap = {};
|
156
156
|
// We iterate over plugins first - this ensures that plugins specified first take precedence.
|
157
157
|
for (const plugin of plugins) {
|
158
158
|
const [pattern, createNodes] = plugin.createNodes ?? [];
|
@@ -1,7 +1,7 @@
|
|
1
1
|
import { PluginConfiguration } from '../../config/nx-json';
|
2
2
|
import { NxPluginV1 } from '../../utils/nx-plugin.deprecated';
|
3
|
-
import { CreateDependencies, CreateDependenciesContext, CreateNodesContext, CreateNodesResult, NxPluginV2 } from './public-api';
|
4
|
-
import { ProjectGraphProcessor } from '../../config/project-graph';
|
3
|
+
import { CreateDependencies, CreateDependenciesContext, CreateMetadata, CreateMetadataContext, CreateNodesContext, CreateNodesResult, NxPluginV2 } from './public-api';
|
4
|
+
import { ProjectGraph, ProjectGraphProcessor } from '../../config/project-graph';
|
5
5
|
export declare class LoadedNxPlugin {
|
6
6
|
readonly name: string;
|
7
7
|
readonly createNodes?: [
|
@@ -9,6 +9,7 @@ export declare class LoadedNxPlugin {
|
|
9
9
|
fn: (matchedFiles: string[], context: CreateNodesContext) => Promise<CreateNodesResultWithContext[]>
|
10
10
|
];
|
11
11
|
readonly createDependencies?: (context: CreateDependenciesContext) => ReturnType<CreateDependencies>;
|
12
|
+
readonly createMetadata?: (graph: ProjectGraph, context: CreateMetadataContext) => ReturnType<CreateMetadata>;
|
12
13
|
readonly processProjectGraph?: ProjectGraphProcessor;
|
13
14
|
readonly options?: unknown;
|
14
15
|
readonly include?: string[];
|
@@ -26,6 +26,9 @@ class LoadedNxPlugin {
|
|
26
26
|
if (plugin.createDependencies) {
|
27
27
|
this.createDependencies = (context) => plugin.createDependencies(this.options, context);
|
28
28
|
}
|
29
|
+
if (plugin.createMetadata) {
|
30
|
+
this.createMetadata = (graph, context) => plugin.createMetadata(graph, this.options, context);
|
31
|
+
}
|
29
32
|
this.processProjectGraph = plugin.processProjectGraph;
|
30
33
|
}
|
31
34
|
}
|