nx 20.0.0-beta.6 → 20.0.0-beta.8
Sign up to get free protection for your applications and to get access to all the features.
- package/bin/init-local.js +0 -39
- package/bin/nx.js +3 -13
- package/migrations.json +5 -0
- package/package.json +11 -11
- package/release/changelog-renderer/index.d.ts +60 -38
- package/release/changelog-renderer/index.js +260 -236
- package/src/adapter/compat.d.ts +1 -1
- package/src/adapter/compat.js +1 -1
- package/src/command-line/add/add.js +2 -2
- package/src/command-line/affected/affected.js +0 -2
- package/src/command-line/nx-commands.js +31 -10
- package/src/command-line/release/changelog.d.ts +2 -2
- package/src/command-line/release/changelog.js +28 -29
- package/src/command-line/release/utils/git.js +2 -2
- package/src/command-line/release/utils/resolve-changelog-renderer.d.ts +2 -2
- package/src/command-line/release/utils/resolve-changelog-renderer.js +3 -3
- package/src/command-line/run/run-one.js +0 -2
- package/src/command-line/run/run.js +0 -1
- package/src/command-line/run-many/run-many.js +1 -4
- package/src/command-line/yargs-utils/shared-options.js +2 -2
- package/src/config/misc-interfaces.d.ts +3 -15
- package/src/config/nx-json.d.ts +4 -3
- package/src/config/project-graph.d.ts +0 -2
- package/src/core/graph/main.js +1 -1
- package/src/daemon/client/client.js +1 -3
- package/src/devkit-exports.d.ts +3 -4
- package/src/devkit-exports.js +3 -6
- package/src/executors/utils/convert-nx-executor.js +0 -1
- package/src/generators/utils/nx-json.d.ts +1 -1
- package/src/migrations/update-20-0-0/move-use-daemon-process.d.ts +2 -0
- package/src/migrations/update-20-0-0/move-use-daemon-process.js +25 -0
- package/src/native/nx.wasm32-wasi.wasm +0 -0
- package/src/plugins/js/project-graph/build-dependencies/target-project-locator.js +2 -12
- package/src/project-graph/build-project-graph.js +3 -41
- package/src/project-graph/error-types.d.ts +4 -10
- package/src/project-graph/error-types.js +1 -12
- package/src/project-graph/file-utils.js +1 -1
- package/src/project-graph/nx-deps-cache.d.ts +0 -1
- package/src/project-graph/nx-deps-cache.js +0 -1
- package/src/project-graph/plugins/internal-api.d.ts +2 -5
- package/src/project-graph/plugins/internal-api.js +0 -1
- package/src/project-graph/plugins/isolation/messaging.d.ts +3 -23
- package/src/project-graph/plugins/isolation/plugin-pool.js +0 -23
- package/src/project-graph/plugins/isolation/plugin-worker.js +0 -19
- package/src/project-graph/plugins/loader.js +2 -3
- package/src/project-graph/plugins/public-api.d.ts +6 -7
- package/src/project-graph/plugins/utils.d.ts +1 -7
- package/src/project-graph/plugins/utils.js +0 -37
- package/src/project-graph/utils/project-configuration-utils.js +1 -1
- package/src/tasks-runner/batch/run-batch.js +0 -1
- package/src/tasks-runner/cache.d.ts +2 -0
- package/src/tasks-runner/cache.js +7 -2
- package/src/tasks-runner/create-task-graph.js +4 -4
- package/src/tasks-runner/init-tasks-runner.js +0 -2
- package/src/tasks-runner/run-command.js +15 -2
- package/src/utils/command-line-utils.d.ts +3 -0
- package/src/utils/command-line-utils.js +24 -33
- package/src/utils/plugins/plugin-capabilities.js +2 -3
- package/src/utils/app-root.d.ts +0 -8
- package/src/utils/app-root.js +0 -12
- package/src/utils/nx-plugin.deprecated.d.ts +0 -31
- package/src/utils/nx-plugin.deprecated.js +0 -20
- package/src/utils/workspace-configuration-check.d.ts +0 -1
- package/src/utils/workspace-configuration-check.js +0 -36
@@ -57,9 +57,7 @@ class DaemonClient {
|
|
57
57
|
}
|
58
58
|
enabled() {
|
59
59
|
if (this._enabled === undefined) {
|
60
|
-
|
61
|
-
const useDaemonProcessOption = this.nxJson?.useDaemonProcess ??
|
62
|
-
this.nxJson?.tasksRunnerOptions?.['default']?.options?.useDaemonProcess;
|
60
|
+
const useDaemonProcessOption = this.nxJson?.useDaemonProcess;
|
63
61
|
const env = process.env.NX_DAEMON;
|
64
62
|
// env takes precedence
|
65
63
|
// option=true,env=false => no daemon
|
package/src/devkit-exports.d.ts
CHANGED
@@ -18,7 +18,6 @@ export { workspaceLayout } from './config/configuration';
|
|
18
18
|
export type { NxPlugin, NxPluginV2, CreateNodes, CreateNodesFunction, CreateNodesResult, CreateNodesContext, CreateNodesContextV2, CreateNodesFunctionV2, CreateNodesResultV2, CreateNodesV2, CreateDependencies, CreateDependenciesContext, CreateMetadata, CreateMetadataContext, ProjectsMetadata, } from './project-graph/plugins';
|
19
19
|
export { AggregateCreateNodesError } from './project-graph/error-types';
|
20
20
|
export { createNodesFromFiles } from './project-graph/plugins';
|
21
|
-
export type { NxPluginV1, ProjectTargetConfigurator, } from './utils/nx-plugin.deprecated';
|
22
21
|
/**
|
23
22
|
* @category Workspace
|
24
23
|
*/
|
@@ -66,7 +65,7 @@ export { readNxJson, updateNxJson, } from './generators/utils/project-configurat
|
|
66
65
|
/**
|
67
66
|
* @category Project Graph
|
68
67
|
*/
|
69
|
-
export type { ProjectFileMap, FileMap, FileData, ProjectGraph, ProjectGraphDependency,
|
68
|
+
export type { ProjectFileMap, FileMap, FileData, ProjectGraph, ProjectGraphDependency, ProjectGraphProjectNode, ProjectGraphExternalNode, } from './config/project-graph';
|
70
69
|
export type { GraphJson } from './command-line/graph/graph';
|
71
70
|
/**
|
72
71
|
* @category Project Graph
|
@@ -75,7 +74,7 @@ export { DependencyType } from './config/project-graph';
|
|
75
74
|
/**
|
76
75
|
* @category Project Graph
|
77
76
|
*/
|
78
|
-
export {
|
77
|
+
export { RawProjectGraphDependency, DynamicDependency, ImplicitDependency, StaticDependency, validateDependency, } from './project-graph/project-graph-builder';
|
79
78
|
/**
|
80
79
|
* @category Generators
|
81
80
|
*/
|
@@ -103,7 +102,7 @@ export { joinPathFragments, normalizePath } from './utils/path';
|
|
103
102
|
/**
|
104
103
|
* @category Utils
|
105
104
|
*/
|
106
|
-
export { workspaceRoot
|
105
|
+
export { workspaceRoot } from './utils/workspace-root';
|
107
106
|
/**
|
108
107
|
* @category Utils
|
109
108
|
*/
|
package/src/devkit-exports.js
CHANGED
@@ -4,7 +4,7 @@
|
|
4
4
|
* Try hard to not add to this API to reduce the surface area we need to maintain.
|
5
5
|
*/
|
6
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
7
|
-
exports.isDaemonEnabled = exports.createProjectFileMapUsingProjectGraph = exports.cacheDir = exports.hashArray = exports.defaultTasksRunner = exports.getOutputsForTargetAndConfiguration = exports.readProjectsConfigurationFromProjectGraph = exports.readCachedProjectGraph = exports.createProjectGraphAsync = exports.reverse = exports.
|
7
|
+
exports.isDaemonEnabled = exports.createProjectFileMapUsingProjectGraph = exports.cacheDir = exports.hashArray = exports.defaultTasksRunner = exports.getOutputsForTargetAndConfiguration = exports.readProjectsConfigurationFromProjectGraph = exports.readCachedProjectGraph = exports.createProjectGraphAsync = exports.reverse = exports.workspaceRoot = exports.normalizePath = exports.joinPathFragments = exports.stripIndents = exports.writeJsonFile = exports.readJsonFile = exports.stripJsonComments = exports.serializeJson = exports.parseJson = exports.updateJson = exports.writeJson = exports.readJson = exports.validateDependency = exports.DependencyType = exports.updateNxJson = exports.readNxJson = exports.globAsync = exports.glob = exports.getProjects = exports.updateProjectConfiguration = exports.removeProjectConfiguration = exports.readProjectConfiguration = exports.addProjectConfiguration = exports.runExecutor = exports.isWorkspacesEnabled = exports.getPackageManagerVersion = exports.detectPackageManager = exports.getPackageManagerCommand = exports.output = exports.logger = exports.createNodesFromFiles = exports.AggregateCreateNodesError = exports.workspaceLayout = void 0;
|
8
8
|
var configuration_1 = require("./config/configuration");
|
9
9
|
Object.defineProperty(exports, "workspaceLayout", { enumerable: true, get: function () { return configuration_1.workspaceLayout; } });
|
10
10
|
var error_types_1 = require("./project-graph/error-types");
|
@@ -64,7 +64,6 @@ Object.defineProperty(exports, "DependencyType", { enumerable: true, get: functi
|
|
64
64
|
* @category Project Graph
|
65
65
|
*/
|
66
66
|
var project_graph_builder_1 = require("./project-graph/project-graph-builder");
|
67
|
-
Object.defineProperty(exports, "ProjectGraphBuilder", { enumerable: true, get: function () { return project_graph_builder_1.ProjectGraphBuilder; } });
|
68
67
|
Object.defineProperty(exports, "validateDependency", { enumerable: true, get: function () { return project_graph_builder_1.validateDependency; } });
|
69
68
|
/**
|
70
69
|
* @category Generators
|
@@ -97,13 +96,11 @@ Object.defineProperty(exports, "stripIndents", { enumerable: true, get: function
|
|
97
96
|
var path_1 = require("./utils/path");
|
98
97
|
Object.defineProperty(exports, "joinPathFragments", { enumerable: true, get: function () { return path_1.joinPathFragments; } });
|
99
98
|
Object.defineProperty(exports, "normalizePath", { enumerable: true, get: function () { return path_1.normalizePath; } });
|
100
|
-
// TODO(v16): Change this to export from './utils/workspace-root'
|
101
99
|
/**
|
102
100
|
* @category Utils
|
103
101
|
*/
|
104
|
-
var
|
105
|
-
Object.defineProperty(exports, "workspaceRoot", { enumerable: true, get: function () { return
|
106
|
-
Object.defineProperty(exports, "appRootPath", { enumerable: true, get: function () { return app_root_1.appRootPath; } });
|
102
|
+
var workspace_root_1 = require("./utils/workspace-root");
|
103
|
+
Object.defineProperty(exports, "workspaceRoot", { enumerable: true, get: function () { return workspace_root_1.workspaceRoot; } });
|
107
104
|
/**
|
108
105
|
* @category Utils
|
109
106
|
*/
|
@@ -29,7 +29,6 @@ function convertNxExecutor(executor) {
|
|
29
29
|
targetName: builderContext.target.target,
|
30
30
|
target: builderContext.target.target,
|
31
31
|
configurationName: builderContext.target.configuration,
|
32
|
-
workspace: { ...nxJsonConfiguration, ...projectsConfigurations },
|
33
32
|
projectsConfigurations,
|
34
33
|
nxJsonConfiguration,
|
35
34
|
cwd: process.cwd(),
|
@@ -1,7 +1,7 @@
|
|
1
1
|
import type { NxJsonConfiguration } from '../../config/nx-json';
|
2
2
|
import type { Tree } from '../tree';
|
3
3
|
/**
|
4
|
-
* @deprecated You must pass a {@link Tree}
|
4
|
+
* @deprecated You must pass a {@link Tree}. This will be removed in Nx 21.
|
5
5
|
*/
|
6
6
|
export declare function readNxJson(): NxJsonConfiguration | null;
|
7
7
|
export declare function readNxJson(tree: Tree): NxJsonConfiguration | null;
|
@@ -0,0 +1,25 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.default = update;
|
4
|
+
const format_changed_files_with_prettier_if_available_1 = require("../../generators/internal-utils/format-changed-files-with-prettier-if-available");
|
5
|
+
const nx_json_1 = require("../../generators/utils/nx-json");
|
6
|
+
async function update(tree) {
|
7
|
+
const nxJson = (0, nx_json_1.readNxJson)(tree);
|
8
|
+
if (nxJson?.tasksRunnerOptions?.['default']?.options?.useDaemonProcess !==
|
9
|
+
undefined) {
|
10
|
+
nxJson.useDaemonProcess =
|
11
|
+
nxJson.tasksRunnerOptions['default'].options.useDaemonProcess;
|
12
|
+
delete nxJson.tasksRunnerOptions['default'].options.useDaemonProcess;
|
13
|
+
if (Object.keys(nxJson.tasksRunnerOptions['default'].options).length === 0) {
|
14
|
+
delete nxJson.tasksRunnerOptions['default'].options;
|
15
|
+
}
|
16
|
+
if (Object.keys(nxJson.tasksRunnerOptions['default']).length === 0) {
|
17
|
+
delete nxJson.tasksRunnerOptions['default'];
|
18
|
+
}
|
19
|
+
if (Object.keys(nxJson.tasksRunnerOptions).length === 0) {
|
20
|
+
delete nxJson.tasksRunnerOptions;
|
21
|
+
}
|
22
|
+
(0, nx_json_1.updateNxJson)(tree, nxJson);
|
23
|
+
}
|
24
|
+
await (0, format_changed_files_with_prettier_if_available_1.formatChangedFilesWithPrettierIfAvailable)(tree);
|
25
|
+
}
|
Binary file
|
@@ -15,20 +15,10 @@ const get_package_name_from_import_path_1 = require("../../../../utils/get-packa
|
|
15
15
|
* Use a shared cache to avoid repeated npm package resolution work within the TargetProjectLocator.
|
16
16
|
*/
|
17
17
|
const defaultNpmResolutionCache = new Map();
|
18
|
-
const
|
19
|
-
...node_module_1.builtinModules,
|
20
|
-
...node_module_1.builtinModules.map((x) => `node:${x}`),
|
21
|
-
// These are missing in the builtinModules list
|
22
|
-
// See: https://github.com/nodejs/node/issues/42785
|
23
|
-
// TODO(v20): We should be safe to use `isBuiltin` function instead of keep the set here (https://nodejs.org/api/module.html#moduleisbuiltinmodulename)
|
24
|
-
'test',
|
25
|
-
'node:test',
|
26
|
-
'node:sea',
|
27
|
-
'node:sqlite',
|
28
|
-
]);
|
18
|
+
const experimentalNodeModules = new Set(['node:sqlite']);
|
29
19
|
function isBuiltinModuleImport(importExpr) {
|
30
20
|
const packageName = (0, get_package_name_from_import_path_1.getPackageNameFromImportPath)(importExpr);
|
31
|
-
return
|
21
|
+
return (0, node_module_1.isBuiltin)(packageName) || experimentalNodeModules.has(packageName);
|
32
22
|
}
|
33
23
|
class TargetProjectLocator {
|
34
24
|
constructor(nodes, externalNodes = {}, npmResolutionCache = defaultNpmResolutionCache) {
|
@@ -10,13 +10,11 @@ const assert_workspace_validity_1 = require("../utils/assert-workspace-validity"
|
|
10
10
|
const nx_deps_cache_1 = require("./nx-deps-cache");
|
11
11
|
const implicit_project_dependencies_1 = require("./utils/implicit-project-dependencies");
|
12
12
|
const normalize_project_nodes_1 = require("./utils/normalize-project-nodes");
|
13
|
-
const utils_1 = require("./plugins/utils");
|
14
13
|
const typescript_1 = require("../plugins/js/utils/typescript");
|
15
14
|
const fileutils_1 = require("../utils/fileutils");
|
16
15
|
const project_graph_builder_1 = require("./project-graph-builder");
|
17
16
|
const configuration_1 = require("../config/configuration");
|
18
17
|
const fs_1 = require("fs");
|
19
|
-
const output_1 = require("../utils/output");
|
20
18
|
const error_types_1 = require("./error-types");
|
21
19
|
const project_configuration_utils_1 = require("./utils/project-configuration-utils");
|
22
20
|
let storedFileMap = null;
|
@@ -182,44 +180,8 @@ function createContext(projects, nxJson, externalNodes, fileMap, filesToProcess)
|
|
182
180
|
async function updateProjectGraphWithPlugins(context, initProjectGraph, plugins, sourceMap) {
|
183
181
|
let graph = initProjectGraph;
|
184
182
|
const errors = [];
|
185
|
-
for (const plugin of plugins) {
|
186
|
-
try {
|
187
|
-
if ((0, utils_1.isNxPluginV1)(plugin) &&
|
188
|
-
plugin.processProjectGraph &&
|
189
|
-
!plugin.createDependencies) {
|
190
|
-
output_1.output.warn({
|
191
|
-
title: `${plugin.name} is a v1 plugin.`,
|
192
|
-
bodyLines: [
|
193
|
-
'Nx has recently released a v2 model for project graph plugins. The `processProjectGraph` method is deprecated. Plugins should use some combination of `createNodes` and `createDependencies` instead.',
|
194
|
-
],
|
195
|
-
});
|
196
|
-
perf_hooks_1.performance.mark(`${plugin.name}:processProjectGraph - start`);
|
197
|
-
graph = await plugin.processProjectGraph(graph, {
|
198
|
-
...context,
|
199
|
-
projectsConfigurations: {
|
200
|
-
projects: context.projects,
|
201
|
-
version: 2,
|
202
|
-
},
|
203
|
-
fileMap: context.fileMap.projectFileMap,
|
204
|
-
filesToProcess: context.filesToProcess.projectFileMap,
|
205
|
-
workspace: {
|
206
|
-
version: 2,
|
207
|
-
projects: context.projects,
|
208
|
-
...context.nxJsonConfiguration,
|
209
|
-
},
|
210
|
-
});
|
211
|
-
perf_hooks_1.performance.mark(`${plugin.name}:processProjectGraph - end`);
|
212
|
-
perf_hooks_1.performance.measure(`${plugin.name}:processProjectGraph`, `${plugin.name}:processProjectGraph - start`, `${plugin.name}:processProjectGraph - end`);
|
213
|
-
}
|
214
|
-
}
|
215
|
-
catch (e) {
|
216
|
-
errors.push(new error_types_1.ProcessProjectGraphError(plugin.name, {
|
217
|
-
cause: e,
|
218
|
-
}));
|
219
|
-
}
|
220
|
-
}
|
221
183
|
const builder = new project_graph_builder_1.ProjectGraphBuilder(graph, context.fileMap.projectFileMap, context.fileMap.nonProjectFiles);
|
222
|
-
const createDependencyPlugins = plugins.filter((plugin) =>
|
184
|
+
const createDependencyPlugins = plugins.filter((plugin) => plugin.createDependencies);
|
223
185
|
await Promise.all(createDependencyPlugins.map(async (plugin) => {
|
224
186
|
perf_hooks_1.performance.mark(`${plugin.name}:createDependencies - start`);
|
225
187
|
try {
|
@@ -264,10 +226,10 @@ async function applyProjectMetadata(graph, plugins, context, sourceMap) {
|
|
264
226
|
const results = [];
|
265
227
|
const errors = [];
|
266
228
|
const promises = plugins.map(async (plugin) => {
|
267
|
-
if (
|
229
|
+
if (plugin.createMetadata) {
|
268
230
|
perf_hooks_1.performance.mark(`${plugin.name}:createMetadata - start`);
|
269
231
|
try {
|
270
|
-
const metadata = await plugin.createMetadata(graph,
|
232
|
+
const metadata = await plugin.createMetadata(graph, context);
|
271
233
|
results.push({ metadata, pluginName: plugin.name });
|
272
234
|
}
|
273
235
|
catch (e) {
|
@@ -4,7 +4,7 @@ import { ProjectGraph } from '../config/project-graph';
|
|
4
4
|
import { CreateNodesFunctionV2 } from './plugins';
|
5
5
|
export declare class ProjectGraphError extends Error {
|
6
6
|
#private;
|
7
|
-
constructor(errors: Array<AggregateCreateNodesError | MergeNodesError | ProjectsWithNoNameError | MultipleProjectsWithSameNameError | ProcessDependenciesError |
|
7
|
+
constructor(errors: Array<AggregateCreateNodesError | MergeNodesError | ProjectsWithNoNameError | MultipleProjectsWithSameNameError | ProcessDependenciesError | CreateMetadataError | WorkspaceValidityError>, partialProjectGraph: ProjectGraph, partialSourceMaps: ConfigurationSourceMaps);
|
8
8
|
/**
|
9
9
|
* The daemon cannot throw errors which contain methods as they are not serializable.
|
10
10
|
*
|
@@ -18,7 +18,7 @@ export declare class ProjectGraphError extends Error {
|
|
18
18
|
*/
|
19
19
|
getPartialProjectGraph(): ProjectGraph;
|
20
20
|
getPartialSourcemaps(): ConfigurationSourceMaps;
|
21
|
-
getErrors(): (AggregateCreateNodesError | MergeNodesError | ProjectsWithNoNameError | MultipleProjectsWithSameNameError | CreateMetadataError | ProcessDependenciesError |
|
21
|
+
getErrors(): (AggregateCreateNodesError | MergeNodesError | ProjectsWithNoNameError | MultipleProjectsWithSameNameError | CreateMetadataError | ProcessDependenciesError | WorkspaceValidityError)[];
|
22
22
|
}
|
23
23
|
export declare class MultipleProjectsWithSameNameError extends Error {
|
24
24
|
conflicts: Map<string, string[]>;
|
@@ -108,16 +108,10 @@ export declare class WorkspaceValidityError extends Error {
|
|
108
108
|
constructor(message: string);
|
109
109
|
}
|
110
110
|
export declare function isWorkspaceValidityError(e: unknown): e is WorkspaceValidityError;
|
111
|
-
export declare class ProcessProjectGraphError extends Error {
|
112
|
-
readonly pluginName: string;
|
113
|
-
constructor(pluginName: string, { cause }: {
|
114
|
-
cause: any;
|
115
|
-
});
|
116
|
-
}
|
117
111
|
export declare class AggregateProjectGraphError extends Error {
|
118
|
-
readonly errors: Array<CreateMetadataError | ProcessDependenciesError |
|
112
|
+
readonly errors: Array<CreateMetadataError | ProcessDependenciesError | WorkspaceValidityError>;
|
119
113
|
readonly partialProjectGraph: ProjectGraph;
|
120
|
-
constructor(errors: Array<CreateMetadataError | ProcessDependenciesError |
|
114
|
+
constructor(errors: Array<CreateMetadataError | ProcessDependenciesError | WorkspaceValidityError>, partialProjectGraph: ProjectGraph);
|
121
115
|
}
|
122
116
|
export declare function isAggregateProjectGraphError(e: unknown): e is AggregateProjectGraphError;
|
123
117
|
export declare function isCreateMetadataError(e: unknown): e is CreateMetadataError;
|
@@ -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.AggregateProjectGraphError = exports.
|
4
|
+
exports.LoadPluginError = exports.DaemonProjectGraphError = exports.AggregateProjectGraphError = exports.WorkspaceValidityError = exports.ProcessDependenciesError = exports.CreateMetadataError = exports.MergeNodesError = exports.AggregateCreateNodesError = exports.ProjectConfigurationsError = exports.ProjectWithNoNameError = exports.ProjectsWithNoNameError = exports.ProjectWithExistingNameError = exports.MultipleProjectsWithSameNameError = exports.ProjectGraphError = void 0;
|
5
5
|
exports.isProjectWithExistingNameError = isProjectWithExistingNameError;
|
6
6
|
exports.isMultipleProjectsWithSameNameError = isMultipleProjectsWithSameNameError;
|
7
7
|
exports.isProjectsWithNoNameError = isProjectsWithNoNameError;
|
@@ -227,17 +227,6 @@ function isWorkspaceValidityError(e) {
|
|
227
227
|
'name' in e &&
|
228
228
|
e?.name === WorkspaceValidityError.name));
|
229
229
|
}
|
230
|
-
class ProcessProjectGraphError extends Error {
|
231
|
-
constructor(pluginName, { cause }) {
|
232
|
-
super(`The "${pluginName}" plugin threw an error while processing the project graph:`, {
|
233
|
-
cause,
|
234
|
-
});
|
235
|
-
this.pluginName = pluginName;
|
236
|
-
this.name = this.constructor.name;
|
237
|
-
this.stack = `${this.message}\n${indentString(cause, 2)}`;
|
238
|
-
}
|
239
|
-
}
|
240
|
-
exports.ProcessProjectGraphError = ProcessProjectGraphError;
|
241
230
|
class AggregateProjectGraphError extends Error {
|
242
231
|
constructor(errors, partialProjectGraph) {
|
243
232
|
super('Failed to create project graph. See above for errors');
|
@@ -4,7 +4,6 @@ import { ProjectConfiguration } from '../config/workspace-json-project-json';
|
|
4
4
|
export interface FileMapCache {
|
5
5
|
version: string;
|
6
6
|
nxVersion: string;
|
7
|
-
deps: Record<string, string>;
|
8
7
|
pathMappings: Record<string, any>;
|
9
8
|
nxJsonPlugins: PluginData[];
|
10
9
|
pluginsConfig?: any;
|
@@ -77,7 +77,6 @@ function createProjectFileMapCache(nxJson, packageJsonDeps, fileMap, tsConfig) {
|
|
77
77
|
const newValue = {
|
78
78
|
version: '6.0',
|
79
79
|
nxVersion: versions_1.nxVersion,
|
80
|
-
deps: packageJsonDeps, // TODO(v19): We can remove this in favor of nxVersion
|
81
80
|
// compilerOptions may not exist, especially for package-based repos
|
82
81
|
pathMappings: tsConfig?.compilerOptions?.paths || {},
|
83
82
|
nxJsonPlugins,
|
@@ -1,7 +1,6 @@
|
|
1
1
|
import { PluginConfiguration } from '../../config/nx-json';
|
2
|
-
import { NxPluginV1 } from '../../utils/nx-plugin.deprecated';
|
3
2
|
import { CreateDependencies, CreateDependenciesContext, CreateMetadata, CreateMetadataContext, CreateNodesContextV2, CreateNodesResult, NxPluginV2 } from './public-api';
|
4
|
-
import { ProjectGraph
|
3
|
+
import { ProjectGraph } from '../../config/project-graph';
|
5
4
|
export declare class LoadedNxPlugin {
|
6
5
|
readonly name: string;
|
7
6
|
readonly createNodes?: [
|
@@ -10,17 +9,15 @@ export declare class LoadedNxPlugin {
|
|
10
9
|
];
|
11
10
|
readonly createDependencies?: (context: CreateDependenciesContext) => ReturnType<CreateDependencies>;
|
12
11
|
readonly createMetadata?: (graph: ProjectGraph, context: CreateMetadataContext) => ReturnType<CreateMetadata>;
|
13
|
-
readonly processProjectGraph?: ProjectGraphProcessor;
|
14
12
|
readonly options?: unknown;
|
15
13
|
readonly include?: string[];
|
16
14
|
readonly exclude?: string[];
|
17
|
-
constructor(plugin:
|
15
|
+
constructor(plugin: NxPluginV2, pluginDefinition: PluginConfiguration);
|
18
16
|
}
|
19
17
|
export type CreateNodesResultWithContext = CreateNodesResult & {
|
20
18
|
file: string;
|
21
19
|
pluginName: string;
|
22
20
|
};
|
23
|
-
export type NormalizedPlugin = NxPluginV2 & Pick<NxPluginV1, 'processProjectGraph'>;
|
24
21
|
export declare const nxPluginCache: Map<unknown, [
|
25
22
|
Promise<LoadedNxPlugin>,
|
26
23
|
() => void
|
@@ -62,7 +62,6 @@ class LoadedNxPlugin {
|
|
62
62
|
if (plugin.createMetadata) {
|
63
63
|
this.createMetadata = (graph, context) => plugin.createMetadata(graph, this.options, context);
|
64
64
|
}
|
65
|
-
this.processProjectGraph = plugin.processProjectGraph;
|
66
65
|
}
|
67
66
|
}
|
68
67
|
exports.LoadedNxPlugin = LoadedNxPlugin;
|
@@ -1,4 +1,4 @@
|
|
1
|
-
import { ProjectGraph
|
1
|
+
import { ProjectGraph } from '../../../config/project-graph';
|
2
2
|
import { PluginConfiguration } from '../../../config/nx-json';
|
3
3
|
import { CreateDependenciesContext, CreateMetadataContext, CreateNodesContextV2 } from '../public-api';
|
4
4
|
import { LoadedNxPlugin } from '../internal-api';
|
@@ -86,32 +86,12 @@ export interface PluginCreateMetadataResult {
|
|
86
86
|
tx: string;
|
87
87
|
};
|
88
88
|
}
|
89
|
-
export interface PluginWorkerProcessProjectGraphMessage {
|
90
|
-
type: 'processProjectGraph';
|
91
|
-
payload: {
|
92
|
-
graph: ProjectGraph;
|
93
|
-
ctx: ProjectGraphProcessorContext;
|
94
|
-
tx: string;
|
95
|
-
};
|
96
|
-
}
|
97
|
-
export interface PluginWorkerProcessProjectGraphResult {
|
98
|
-
type: 'processProjectGraphResult';
|
99
|
-
payload: {
|
100
|
-
graph: ProjectGraph;
|
101
|
-
success: true;
|
102
|
-
tx: string;
|
103
|
-
} | {
|
104
|
-
success: false;
|
105
|
-
error: Error;
|
106
|
-
tx: string;
|
107
|
-
};
|
108
|
-
}
|
109
89
|
export interface PluginWorkerShutdownMessage {
|
110
90
|
type: 'shutdown';
|
111
91
|
payload: {};
|
112
92
|
}
|
113
|
-
export type PluginWorkerMessage = PluginWorkerLoadMessage | PluginWorkerShutdownMessage | PluginWorkerCreateNodesMessage | PluginCreateDependenciesMessage |
|
114
|
-
export type PluginWorkerResult = PluginWorkerLoadResult | PluginWorkerCreateNodesResult | PluginCreateDependenciesResult |
|
93
|
+
export type PluginWorkerMessage = PluginWorkerLoadMessage | PluginWorkerShutdownMessage | PluginWorkerCreateNodesMessage | PluginCreateDependenciesMessage | PluginCreateMetadataMessage;
|
94
|
+
export type PluginWorkerResult = PluginWorkerLoadResult | PluginWorkerCreateNodesResult | PluginCreateDependenciesResult | PluginCreateMetadataResult;
|
115
95
|
export declare function isPluginWorkerMessage(message: Serializable): message is PluginWorkerMessage;
|
116
96
|
export declare function isPluginWorkerResult(message: Serializable): message is PluginWorkerResult;
|
117
97
|
type MaybePromise<T> = T | Promise<T>;
|
@@ -115,20 +115,6 @@ function createWorkerHandler(worker, pending, onload, onloadError, socket) {
|
|
115
115
|
});
|
116
116
|
}
|
117
117
|
: undefined,
|
118
|
-
processProjectGraph: result.hasProcessProjectGraph
|
119
|
-
? (graph, ctx) => {
|
120
|
-
const tx = pluginName + worker.pid + ':processProjectGraph:' + txId++;
|
121
|
-
return registerPendingPromise(tx, pending, () => {
|
122
|
-
(0, messaging_1.sendMessageOverSocket)(socket, {
|
123
|
-
type: 'processProjectGraph',
|
124
|
-
payload: { graph, ctx, tx },
|
125
|
-
});
|
126
|
-
}, {
|
127
|
-
operation: 'processProjectGraph',
|
128
|
-
plugin: pluginName,
|
129
|
-
});
|
130
|
-
}
|
131
|
-
: undefined,
|
132
118
|
createMetadata: result.hasCreateMetadata
|
133
119
|
? (graph, ctx) => {
|
134
120
|
const tx = pluginName + worker.pid + ':createMetadata:' + txId++;
|
@@ -167,15 +153,6 @@ function createWorkerHandler(worker, pending, onload, onloadError, socket) {
|
|
167
153
|
rejector(result.error);
|
168
154
|
}
|
169
155
|
},
|
170
|
-
processProjectGraphResult: ({ tx, ...result }) => {
|
171
|
-
const { resolver, rejector } = pending.get(tx);
|
172
|
-
if (result.success) {
|
173
|
-
resolver(result.graph);
|
174
|
-
}
|
175
|
-
else if (result.success === false) {
|
176
|
-
rejector(result.error);
|
177
|
-
}
|
178
|
-
},
|
179
156
|
createMetadataResult: ({ tx, ...result }) => {
|
180
157
|
const { resolver, rejector } = pending.get(tx);
|
181
158
|
if (result.success) {
|
@@ -102,25 +102,6 @@ const server = (0, net_1.createServer)((socket) => {
|
|
102
102
|
};
|
103
103
|
}
|
104
104
|
},
|
105
|
-
processProjectGraph: async ({ graph, ctx, tx }) => {
|
106
|
-
try {
|
107
|
-
const result = await plugin.processProjectGraph(graph, ctx);
|
108
|
-
return {
|
109
|
-
type: 'processProjectGraphResult',
|
110
|
-
payload: { graph: result, success: true, tx },
|
111
|
-
};
|
112
|
-
}
|
113
|
-
catch (e) {
|
114
|
-
return {
|
115
|
-
type: 'processProjectGraphResult',
|
116
|
-
payload: {
|
117
|
-
success: false,
|
118
|
-
error: (0, serializable_error_1.createSerializableError)(e),
|
119
|
-
tx,
|
120
|
-
},
|
121
|
-
};
|
122
|
-
}
|
123
|
-
},
|
124
105
|
createMetadata: async ({ graph, context, tx }) => {
|
125
106
|
try {
|
126
107
|
const result = await plugin.createMetadata(graph, context);
|
@@ -20,7 +20,6 @@ const path_1 = require("../../utils/path");
|
|
20
20
|
const logger_1 = require("../../utils/logger");
|
21
21
|
const node_path_1 = require("node:path");
|
22
22
|
const retrieve_workspace_files_1 = require("../utils/retrieve-workspace-files");
|
23
|
-
const utils_1 = require("./utils");
|
24
23
|
const internal_api_1 = require("./internal-api");
|
25
24
|
const error_types_1 = require("../error-types");
|
26
25
|
const path = require("node:path/posix");
|
@@ -197,8 +196,8 @@ async function loadNxPluginAsync(pluginConfiguration, paths, root) {
|
|
197
196
|
await (0, retrieve_workspace_files_1.retrieveProjectConfigurationsWithoutPluginInference)(root);
|
198
197
|
}
|
199
198
|
performance.mark(`Load Nx Plugin: ${moduleName} - start`);
|
200
|
-
|
201
|
-
const plugin =
|
199
|
+
const { pluginPath, name } = getPluginPathAndName(moduleName, paths, projectsWithoutInference, root);
|
200
|
+
const plugin = await importPluginModule(pluginPath);
|
202
201
|
plugin.name ??= name;
|
203
202
|
performance.mark(`Load Nx Plugin: ${moduleName} - end`);
|
204
203
|
performance.measure(`Load Nx Plugin: ${moduleName}`, `Load Nx Plugin: ${moduleName} - start`, `Load Nx Plugin: ${moduleName} - end`);
|
@@ -1,4 +1,3 @@
|
|
1
|
-
import { NxPluginV1 } from '../../utils/nx-plugin.deprecated';
|
2
1
|
import { FileMap, ProjectGraph, ProjectGraphExternalNode } from '../../config/project-graph';
|
3
2
|
import { ProjectConfiguration } from '../../config/workspace-json-project-json';
|
4
3
|
import { NxJsonConfiguration } from '../../config/nx-json';
|
@@ -38,12 +37,12 @@ export interface CreateNodesResult {
|
|
38
37
|
* A pair of file patterns and {@link CreateNodesFunction}
|
39
38
|
*
|
40
39
|
* Nx 19.2+: Both original `CreateNodes` and `CreateNodesV2` are supported. Nx will only invoke `CreateNodesV2` if it is present.
|
41
|
-
* Nx
|
40
|
+
* Nx 21.X : The `CreateNodesV2` will be the only supported API. This typing will still exist, but be identical to `CreateNodesV2`.
|
42
41
|
Nx **will not** invoke the original `plugin.createNodes` callback. This should give plugin authors a window to transition.
|
43
42
|
Plugin authors should update their plugin's `createNodes` function to align with `CreateNodesV2` / the updated `CreateNodes`.
|
44
43
|
The plugin should contain something like: `export createNodes = createNodesV2;` during this period. This will allow the plugin
|
45
44
|
to maintain compatibility with Nx 19.2 and up.
|
46
|
-
* Nx
|
45
|
+
* Nx 22.X : The `CreateNodesV2` typing will be removed, as it has replaced `CreateNodes`.
|
47
46
|
*
|
48
47
|
* @deprecated Use {@link CreateNodesV2} instead. CreateNodesV2 will replace this API. Read more about the transition above.
|
49
48
|
*/
|
@@ -53,7 +52,7 @@ export type CreateNodes<T = unknown> = readonly [
|
|
53
52
|
];
|
54
53
|
/**
|
55
54
|
* A pair of file patterns and {@link CreateNodesFunctionV2}
|
56
|
-
* In Nx
|
55
|
+
* In Nx 21 {@link CreateNodes} will be replaced with this type. In Nx 22, this type will be removed.
|
57
56
|
*/
|
58
57
|
export type CreateNodesV2<T = unknown> = readonly [
|
59
58
|
projectFilePattern: string,
|
@@ -105,14 +104,14 @@ export type NxPluginV2<TOptions = unknown> = {
|
|
105
104
|
* Provides a file pattern and function that retrieves configuration info from
|
106
105
|
* those files. e.g. { '**\/*.csproj': buildProjectsFromCsProjFile }
|
107
106
|
*
|
108
|
-
* @deprecated Use {@link createNodesV2} instead. In Nx
|
107
|
+
* @deprecated Use {@link createNodesV2} instead. In Nx 21 support for calling createNodes with a single file for the first argument will be removed.
|
109
108
|
*/
|
110
109
|
createNodes?: CreateNodes<TOptions>;
|
111
110
|
/**
|
112
111
|
* Provides a file pattern and function that retrieves configuration info from
|
113
112
|
* those files. e.g. { '**\/*.csproj': buildProjectsFromCsProjFiles }
|
114
113
|
*
|
115
|
-
* In Nx
|
114
|
+
* In Nx 21 {@link createNodes} will be replaced with this property. In Nx 22, this property will be removed.
|
116
115
|
*/
|
117
116
|
createNodesV2?: CreateNodesV2<TOptions>;
|
118
117
|
/**
|
@@ -127,4 +126,4 @@ export type NxPluginV2<TOptions = unknown> = {
|
|
127
126
|
/**
|
128
127
|
* A plugin for Nx
|
129
128
|
*/
|
130
|
-
export type NxPlugin =
|
129
|
+
export type NxPlugin = NxPluginV2;
|
@@ -1,8 +1,2 @@
|
|
1
|
-
import
|
2
|
-
import type { LoadedNxPlugin, NormalizedPlugin } from './internal-api';
|
3
|
-
import { CreateNodesContextV2, CreateNodesFunction, CreateNodesResult, type NxPlugin, type NxPluginV2 } from './public-api';
|
4
|
-
export declare function isNxPluginV2(plugin: NxPlugin): plugin is NxPluginV2;
|
5
|
-
export declare function isNxPluginV1(plugin: NxPlugin | LoadedNxPlugin): plugin is NxPluginV1;
|
6
|
-
export declare function normalizeNxPlugin(plugin: NxPlugin): NormalizedPlugin;
|
7
|
-
export type AsyncFn<T extends Function> = T extends (...args: infer A) => infer R ? (...args: A) => Promise<Awaited<R>> : never;
|
1
|
+
import { CreateNodesContextV2, CreateNodesFunction, CreateNodesResult } from './public-api';
|
8
2
|
export declare function createNodesFromFiles<T = unknown>(createNodes: CreateNodesFunction<T>, configFiles: readonly string[], options: T, context: CreateNodesContextV2): Promise<[file: string, value: CreateNodesResult][]>;
|
@@ -1,44 +1,7 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
exports.isNxPluginV2 = isNxPluginV2;
|
4
|
-
exports.isNxPluginV1 = isNxPluginV1;
|
5
|
-
exports.normalizeNxPlugin = normalizeNxPlugin;
|
6
3
|
exports.createNodesFromFiles = createNodesFromFiles;
|
7
|
-
const node_path_1 = require("node:path");
|
8
|
-
const to_project_name_1 = require("../../config/to-project-name");
|
9
|
-
const globs_1 = require("../../utils/globs");
|
10
4
|
const error_types_1 = require("../error-types");
|
11
|
-
function isNxPluginV2(plugin) {
|
12
|
-
return 'createNodes' in plugin || 'createDependencies' in plugin;
|
13
|
-
}
|
14
|
-
function isNxPluginV1(plugin) {
|
15
|
-
return 'processProjectGraph' in plugin || 'projectFilePatterns' in plugin;
|
16
|
-
}
|
17
|
-
function normalizeNxPlugin(plugin) {
|
18
|
-
if (isNxPluginV2(plugin)) {
|
19
|
-
return plugin;
|
20
|
-
}
|
21
|
-
if (isNxPluginV1(plugin) && plugin.projectFilePatterns) {
|
22
|
-
return {
|
23
|
-
...plugin,
|
24
|
-
createNodes: [
|
25
|
-
`*/**/${(0, globs_1.combineGlobPatterns)(plugin.projectFilePatterns)}`,
|
26
|
-
(configFilePath) => {
|
27
|
-
const root = (0, node_path_1.dirname)(configFilePath);
|
28
|
-
return {
|
29
|
-
projects: {
|
30
|
-
[root]: {
|
31
|
-
name: (0, to_project_name_1.toProjectName)(configFilePath),
|
32
|
-
targets: plugin.registerProjectTargets?.(configFilePath),
|
33
|
-
},
|
34
|
-
},
|
35
|
-
};
|
36
|
-
},
|
37
|
-
],
|
38
|
-
};
|
39
|
-
}
|
40
|
-
return plugin;
|
41
|
-
}
|
42
5
|
async function createNodesFromFiles(createNodes, configFiles, options, context) {
|
43
6
|
const results = [];
|
44
7
|
const errors = [];
|
@@ -184,7 +184,7 @@ function mergeMetadata(sourceMap, sourceInformation, baseSourceMapPath, metadata
|
|
184
184
|
}
|
185
185
|
}
|
186
186
|
else {
|
187
|
-
result[metadataKey] = value;
|
187
|
+
result[metadataKey][key] = value[key];
|
188
188
|
if (sourceMap) {
|
189
189
|
sourceMap[`${baseSourceMapPath}.${metadataKey}`] =
|
190
190
|
sourceInformation;
|
@@ -23,7 +23,6 @@ async function runTasks(executorName, batchTaskGraph, fullTaskGraph) {
|
|
23
23
|
cwd: process.cwd(),
|
24
24
|
projectsConfigurations,
|
25
25
|
nxJsonConfiguration,
|
26
|
-
workspace: { ...projectsConfigurations, ...nxJsonConfiguration },
|
27
26
|
isVerbose: false,
|
28
27
|
projectGraph,
|
29
28
|
taskGraph: fullTaskGraph,
|
@@ -1,5 +1,6 @@
|
|
1
1
|
import { DefaultTasksRunnerOptions, RemoteCache } from './default-tasks-runner';
|
2
2
|
import { Task } from '../config/task-graph';
|
3
|
+
import { NxJsonConfiguration } from '../config/nx-json';
|
3
4
|
export type CachedResult = {
|
4
5
|
terminalOutput: string;
|
5
6
|
outputsPath: string;
|
@@ -10,6 +11,7 @@ export type TaskWithCachedResult = {
|
|
10
11
|
task: Task;
|
11
12
|
cachedResult: CachedResult;
|
12
13
|
};
|
14
|
+
export declare function dbCacheEnabled(nxJson?: NxJsonConfiguration): boolean;
|
13
15
|
export declare function getCache(options: DefaultTasksRunnerOptions): DbCache | Cache;
|
14
16
|
export declare class DbCache {
|
15
17
|
private readonly options;
|