nx 18.1.0-canary.20240309-235ca8c → 18.1.0-canary.20240313-81df848
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/post-install.js +5 -7
- package/package.json +12 -12
- package/src/adapter/angular-json.d.ts +1 -2
- package/src/adapter/angular-json.js +0 -1
- package/src/adapter/ngcli-adapter.js +3 -3
- package/src/command-line/generate/generator-utils.js +2 -2
- package/src/command-line/run/executor-utils.js +2 -2
- package/src/config/schema-utils.js +2 -2
- package/src/core/graph/3rdpartylicenses.txt +51 -0
- package/src/core/graph/main.js +1 -1
- package/src/core/graph/polyfills.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 +7 -8
- package/src/daemon/server/shutdown-utils.js +0 -2
- package/src/devkit-exports.d.ts +1 -2
- package/src/executors/run-commands/run-commands.impl.d.ts +3 -0
- package/src/executors/run-commands/run-commands.impl.js +77 -38
- package/src/executors/utils/convert-nx-executor.js +1 -4
- package/src/generators/utils/project-configuration.js +2 -2
- package/src/hasher/hash-task.js +2 -2
- package/src/migrations/update-15-1-0/set-project-names.js +2 -2
- package/src/plugins/js/index.d.ts +1 -1
- package/src/plugins/js/lock-file/lock-file.d.ts +1 -1
- package/src/plugins/js/lock-file/npm-parser.d.ts +1 -1
- package/src/plugins/js/lock-file/pnpm-parser.d.ts +1 -1
- package/src/plugins/js/lock-file/yarn-parser.d.ts +1 -1
- package/src/plugins/js/project-graph/build-dependencies/build-dependencies.d.ts +1 -1
- package/src/plugins/js/project-graph/build-dependencies/explicit-package-json-dependencies.d.ts +1 -1
- package/src/plugins/js/project-graph/build-dependencies/explicit-project-dependencies.d.ts +1 -1
- package/src/plugins/js/utils/register.js +3 -1
- package/src/plugins/package-json-workspaces/create-nodes.d.ts +2 -2
- package/src/plugins/package-json-workspaces/create-nodes.js +31 -24
- package/src/plugins/package-json-workspaces/index.d.ts +0 -1
- package/src/plugins/package-json-workspaces/index.js +0 -2
- package/src/plugins/project-json/build-nodes/package-json-next-to-project-json.d.ts +1 -2
- package/src/plugins/project-json/build-nodes/package-json-next-to-project-json.js +0 -1
- package/src/plugins/project-json/build-nodes/project-json.d.ts +1 -2
- package/src/plugins/project-json/build-nodes/project-json.js +0 -1
- package/src/plugins/target-defaults/target-defaults-plugin.d.ts +1 -2
- package/src/plugins/target-defaults/target-defaults-plugin.js +0 -1
- package/src/project-graph/affected/locators/project-glob-changes.js +3 -3
- package/src/project-graph/build-project-graph.d.ts +1 -2
- package/src/project-graph/build-project-graph.js +13 -12
- package/src/project-graph/file-utils.js +3 -3
- package/src/project-graph/project-graph-builder.d.ts +1 -1
- package/src/project-graph/project-graph.js +15 -19
- package/src/project-graph/utils/normalize-project-nodes.d.ts +1 -1
- package/src/project-graph/utils/project-configuration-utils.d.ts +2 -2
- package/src/project-graph/utils/project-configuration-utils.js +55 -11
- package/src/project-graph/utils/retrieve-workspace-files.d.ts +8 -6
- package/src/project-graph/utils/retrieve-workspace-files.js +21 -18
- package/src/tasks-runner/task-orchestrator.js +45 -8
- package/src/tasks-runner/tasks-schedule.js +3 -3
- package/src/tasks-runner/utils.d.ts +7 -6
- package/src/tasks-runner/utils.js +11 -7
- package/src/utils/logger.d.ts +0 -1
- package/src/utils/logger.js +0 -5
- package/src/{project-graph/plugins/public-api.d.ts → utils/nx-plugin.d.ts} +41 -7
- package/src/utils/nx-plugin.deprecated.d.ts +2 -4
- package/src/utils/nx-plugin.deprecated.js +4 -4
- package/src/utils/nx-plugin.js +293 -0
- package/src/utils/output.js +1 -1
- package/src/utils/plugins/plugin-capabilities.d.ts +1 -1
- package/src/utils/plugins/plugin-capabilities.js +9 -10
- package/src/daemon/server/plugins.d.ts +0 -3
- package/src/daemon/server/plugins.js +0 -22
- package/src/project-graph/plugins/index.d.ts +0 -2
- package/src/project-graph/plugins/index.js +0 -8
- package/src/project-graph/plugins/internal-api.d.ts +0 -22
- package/src/project-graph/plugins/internal-api.js +0 -64
- package/src/project-graph/plugins/messaging.d.ts +0 -94
- package/src/project-graph/plugins/messaging.js +0 -23
- package/src/project-graph/plugins/plugin-pool.d.ts +0 -3
- package/src/project-graph/plugins/plugin-pool.js +0 -189
- package/src/project-graph/plugins/plugin-worker.d.ts +0 -1
- package/src/project-graph/plugins/plugin-worker.js +0 -101
- package/src/project-graph/plugins/public-api.js +0 -4
- package/src/project-graph/plugins/utils.d.ts +0 -9
- package/src/project-graph/plugins/utils.js +0 -55
- package/src/project-graph/plugins/worker-api.d.ts +0 -28
- package/src/project-graph/plugins/worker-api.js +0 -195
@@ -1,5 +1,5 @@
|
|
1
1
|
import { TargetConfiguration } from '../../config/workspace-json-project-json';
|
2
|
-
import { NxPluginV2 } from '../../
|
2
|
+
import { NxPluginV2 } from '../../utils/nx-plugin';
|
3
3
|
/**
|
4
4
|
* This marks that a target provides information which should modify a target already registered
|
5
5
|
* on the project via other plugins. If the target has not already been registered, and this symbol is true,
|
@@ -18,7 +18,6 @@ export declare const ONLY_MODIFIES_EXISTING_TARGET = "NX_ONLY_MODIFIES_EXISTING_
|
|
18
18
|
*/
|
19
19
|
export declare const OVERRIDE_SOURCE_FILE = "NX_OVERRIDE_SOURCE_FILE";
|
20
20
|
export declare const TargetDefaultsPlugin: NxPluginV2;
|
21
|
-
export default TargetDefaultsPlugin;
|
22
21
|
/**
|
23
22
|
* This fn gets target info that would make a target uniquely compatible
|
24
23
|
* with what is described by project.json or package.json. As the merge process
|
@@ -3,14 +3,14 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.getTouchedProjectsFromProjectGlobChanges = void 0;
|
4
4
|
const minimatch_1 = require("minimatch");
|
5
5
|
const workspace_root_1 = require("../../../utils/workspace-root");
|
6
|
+
const installation_directory_1 = require("../../../utils/installation-directory");
|
6
7
|
const path_1 = require("path");
|
7
8
|
const fs_1 = require("fs");
|
8
9
|
const retrieve_workspace_files_1 = require("../../utils/retrieve-workspace-files");
|
9
|
-
const
|
10
|
+
const nx_plugin_1 = require("../../../utils/nx-plugin");
|
10
11
|
const globs_1 = require("../../../utils/globs");
|
11
12
|
const getTouchedProjectsFromProjectGlobChanges = async (touchedFiles, projectGraphNodes, nxJson) => {
|
12
|
-
const
|
13
|
-
const globPattern = (0, globs_1.combineGlobPatterns)((0, retrieve_workspace_files_1.configurationGlobs)(plugins.map((p) => p.plugin)));
|
13
|
+
const globPattern = (0, globs_1.combineGlobPatterns)((0, retrieve_workspace_files_1.configurationGlobs)(await (0, nx_plugin_1.loadNxPlugins)(nxJson?.plugins, (0, installation_directory_1.getNxRequirePaths)(workspace_root_1.workspaceRoot), workspace_root_1.workspaceRoot)));
|
14
14
|
const touchedProjects = new Set();
|
15
15
|
for (const touchedFile of touchedFiles) {
|
16
16
|
const isProjectFile = (0, minimatch_1.minimatch)(touchedFile.file, globPattern, {
|
@@ -1,6 +1,5 @@
|
|
1
1
|
import { FileData } from './file-utils';
|
2
2
|
import { FileMapCache } from './nx-deps-cache';
|
3
|
-
import { RemotePlugin } from './plugins/internal-api';
|
4
3
|
import { FileMap, ProjectGraph, ProjectGraphExternalNode } from '../config/project-graph';
|
5
4
|
import { ProjectConfiguration } from '../config/workspace-json-project-json';
|
6
5
|
import { NxWorkspaceFilesExternals } from '../native';
|
@@ -9,7 +8,7 @@ export declare function getFileMap(): {
|
|
9
8
|
allWorkspaceFiles: FileData[];
|
10
9
|
rustReferences: NxWorkspaceFilesExternals | null;
|
11
10
|
};
|
12
|
-
export declare function buildProjectGraphUsingProjectFileMap(projects: Record<string, ProjectConfiguration>, externalNodes: Record<string, ProjectGraphExternalNode>, fileMap: FileMap, allWorkspaceFiles: FileData[], rustReferences: NxWorkspaceFilesExternals, fileMapCache: FileMapCache | null, shouldWriteCache: boolean
|
11
|
+
export declare function buildProjectGraphUsingProjectFileMap(projects: Record<string, ProjectConfiguration>, externalNodes: Record<string, ProjectGraphExternalNode>, fileMap: FileMap, allWorkspaceFiles: FileData[], rustReferences: NxWorkspaceFilesExternals, fileMapCache: FileMapCache | null, shouldWriteCache: boolean): Promise<{
|
13
12
|
projectGraph: ProjectGraph;
|
14
13
|
projectFileMapCache: FileMapCache;
|
15
14
|
}>;
|
@@ -8,12 +8,13 @@ const assert_workspace_validity_1 = require("../utils/assert-workspace-validity"
|
|
8
8
|
const nx_deps_cache_1 = require("./nx-deps-cache");
|
9
9
|
const implicit_project_dependencies_1 = require("./utils/implicit-project-dependencies");
|
10
10
|
const normalize_project_nodes_1 = require("./utils/normalize-project-nodes");
|
11
|
-
const
|
11
|
+
const nx_plugin_1 = require("../utils/nx-plugin");
|
12
12
|
const typescript_1 = require("../plugins/js/utils/typescript");
|
13
13
|
const fileutils_1 = require("../utils/fileutils");
|
14
14
|
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
|
+
const installation_directory_1 = require("../utils/installation-directory");
|
17
18
|
const output_1 = require("../utils/output");
|
18
19
|
let storedFileMap = null;
|
19
20
|
let storedAllWorkspaceFiles = null;
|
@@ -38,7 +39,7 @@ function getFileMap() {
|
|
38
39
|
}
|
39
40
|
}
|
40
41
|
exports.getFileMap = getFileMap;
|
41
|
-
async function buildProjectGraphUsingProjectFileMap(projects, externalNodes, fileMap, allWorkspaceFiles, rustReferences, fileMapCache, shouldWriteCache
|
42
|
+
async function buildProjectGraphUsingProjectFileMap(projects, externalNodes, fileMap, allWorkspaceFiles, rustReferences, fileMapCache, shouldWriteCache) {
|
42
43
|
storedFileMap = fileMap;
|
43
44
|
storedAllWorkspaceFiles = allWorkspaceFiles;
|
44
45
|
storedRustReferences = rustReferences;
|
@@ -64,7 +65,7 @@ async function buildProjectGraphUsingProjectFileMap(projects, externalNodes, fil
|
|
64
65
|
};
|
65
66
|
}
|
66
67
|
const context = createContext(projects, nxJson, externalNodes, fileMap, filesToProcess);
|
67
|
-
let projectGraph = await buildProjectGraphUsingContext(nxJson, externalNodes, context, cachedFileData, projectGraphVersion
|
68
|
+
let projectGraph = await buildProjectGraphUsingContext(nxJson, externalNodes, context, cachedFileData, projectGraphVersion);
|
68
69
|
const projectFileMapCache = (0, nx_deps_cache_1.createProjectFileMapCache)(nxJson, packageJsonDeps, fileMap, rootTsConfig);
|
69
70
|
if (shouldWriteCache) {
|
70
71
|
(0, nx_deps_cache_1.writeCache)(projectFileMapCache, projectGraph);
|
@@ -91,7 +92,7 @@ function readCombinedDeps() {
|
|
91
92
|
...installationPackageJson.devDependencies,
|
92
93
|
};
|
93
94
|
}
|
94
|
-
async function buildProjectGraphUsingContext(nxJson, knownExternalNodes, ctx, cachedFileData, projectGraphVersion
|
95
|
+
async function buildProjectGraphUsingContext(nxJson, knownExternalNodes, ctx, cachedFileData, projectGraphVersion) {
|
95
96
|
perf_hooks_1.performance.mark('build project graph:start');
|
96
97
|
const builder = new project_graph_builder_1.ProjectGraphBuilder(null, ctx.fileMap.projectFileMap);
|
97
98
|
builder.setVersion(projectGraphVersion);
|
@@ -100,7 +101,7 @@ async function buildProjectGraphUsingContext(nxJson, knownExternalNodes, ctx, ca
|
|
100
101
|
}
|
101
102
|
await (0, normalize_project_nodes_1.normalizeProjectNodes)(ctx, builder);
|
102
103
|
const initProjectGraph = builder.getUpdatedProjectGraph();
|
103
|
-
const r = await updateProjectGraphWithPlugins(ctx, initProjectGraph
|
104
|
+
const r = await updateProjectGraphWithPlugins(ctx, initProjectGraph);
|
104
105
|
const updatedBuilder = new project_graph_builder_1.ProjectGraphBuilder(r, ctx.fileMap.projectFileMap);
|
105
106
|
for (const proj of Object.keys(cachedFileData.projectFileMap)) {
|
106
107
|
for (const f of ctx.fileMap.projectFileMap[proj] || []) {
|
@@ -138,11 +139,12 @@ function createContext(projects, nxJson, externalNodes, fileMap, filesToProcess)
|
|
138
139
|
filesToProcess,
|
139
140
|
};
|
140
141
|
}
|
141
|
-
async function updateProjectGraphWithPlugins(context, initProjectGraph
|
142
|
+
async function updateProjectGraphWithPlugins(context, initProjectGraph) {
|
143
|
+
const plugins = await (0, nx_plugin_1.loadNxPlugins)(context.nxJsonConfiguration?.plugins, (0, installation_directory_1.getNxRequirePaths)(), context.workspaceRoot, context.projects);
|
142
144
|
let graph = initProjectGraph;
|
143
|
-
for (const plugin of plugins) {
|
145
|
+
for (const { plugin } of plugins) {
|
144
146
|
try {
|
145
|
-
if ((0,
|
147
|
+
if ((0, nx_plugin_1.isNxPluginV1)(plugin) &&
|
146
148
|
plugin.processProjectGraph &&
|
147
149
|
!plugin.createDependencies) {
|
148
150
|
output_1.output.warn({
|
@@ -180,12 +182,11 @@ async function updateProjectGraphWithPlugins(context, initProjectGraph, plugins)
|
|
180
182
|
}
|
181
183
|
}
|
182
184
|
const builder = new project_graph_builder_1.ProjectGraphBuilder(graph, context.fileMap.projectFileMap, context.fileMap.nonProjectFiles);
|
183
|
-
const createDependencyPlugins = plugins.filter((plugin) => (0,
|
184
|
-
await Promise.all(createDependencyPlugins.map(async (plugin) => {
|
185
|
+
const createDependencyPlugins = plugins.filter(({ plugin }) => (0, nx_plugin_1.isNxPluginV2)(plugin) && plugin.createDependencies);
|
186
|
+
await Promise.all(createDependencyPlugins.map(async ({ plugin, options }) => {
|
185
187
|
perf_hooks_1.performance.mark(`${plugin.name}:createDependencies - start`);
|
186
188
|
try {
|
187
|
-
|
188
|
-
const dependencies = await plugin.createDependencies(null, {
|
189
|
+
const dependencies = await plugin.createDependencies(options, {
|
189
190
|
...context,
|
190
191
|
});
|
191
192
|
for (const dep of dependencies) {
|
@@ -147,21 +147,21 @@ Object.defineProperty(exports, "workspaceLayout", { enumerable: true, get: funct
|
|
147
147
|
* TODO(v19): Remove this function.
|
148
148
|
*/
|
149
149
|
function getProjectsSyncNoInference(root, nxJson) {
|
150
|
-
const projectFiles = (0, retrieve_workspace_files_1.retrieveProjectConfigurationPaths)(root, (0, nx_plugin_deprecated_1.getDefaultPluginsSync)(root)
|
150
|
+
const projectFiles = (0, retrieve_workspace_files_1.retrieveProjectConfigurationPaths)(root, (0, nx_plugin_deprecated_1.getDefaultPluginsSync)(root));
|
151
151
|
const plugins = [
|
152
152
|
{ plugin: package_json_next_to_project_json_1.PackageJsonProjectsNextToProjectJsonPlugin },
|
153
153
|
...(0, nx_plugin_deprecated_1.getDefaultPluginsSync)(root),
|
154
154
|
];
|
155
155
|
const projectRootMap = new Map();
|
156
156
|
// We iterate over plugins first - this ensures that plugins specified first take precedence.
|
157
|
-
for (const { plugin } of plugins) {
|
157
|
+
for (const { plugin, options } of plugins) {
|
158
158
|
const [pattern, createNodes] = plugin.createNodes ?? [];
|
159
159
|
if (!pattern) {
|
160
160
|
continue;
|
161
161
|
}
|
162
162
|
for (const file of projectFiles) {
|
163
163
|
if ((0, minimatch_1.minimatch)(file, pattern, { dot: true })) {
|
164
|
-
let r = createNodes(file,
|
164
|
+
let r = createNodes(file, options, {
|
165
165
|
nxJsonConfiguration: nxJson,
|
166
166
|
workspaceRoot: root,
|
167
167
|
});
|
@@ -2,7 +2,7 @@
|
|
2
2
|
* Builder for adding nodes and dependencies to a {@link ProjectGraph}
|
3
3
|
*/
|
4
4
|
import { DependencyType, FileMap, ProjectFileMap, ProjectGraph, ProjectGraphExternalNode, ProjectGraphProjectNode } from '../config/project-graph';
|
5
|
-
import { CreateDependenciesContext } from '
|
5
|
+
import { CreateDependenciesContext } from '../utils/nx-plugin';
|
6
6
|
/**
|
7
7
|
* A class which builds up a project graph
|
8
8
|
* @deprecated The {@link ProjectGraphProcessor} has been deprecated. Use a {@link CreateNodes} and/or a {@link CreateDependencies} instead. This will be removed in Nx 19.
|
@@ -12,7 +12,7 @@ const workspace_root_1 = require("../utils/workspace-root");
|
|
12
12
|
const perf_hooks_1 = require("perf_hooks");
|
13
13
|
const retrieve_workspace_files_1 = require("./utils/retrieve-workspace-files");
|
14
14
|
const nx_json_1 = require("../config/nx-json");
|
15
|
-
const
|
15
|
+
const nx_plugin_1 = require("../utils/nx-plugin");
|
16
16
|
/**
|
17
17
|
* Synchronously reads the latest cached copy of the workspace's ProjectGraph.
|
18
18
|
* @throws {Error} if there is no cached ProjectGraph to read from
|
@@ -66,26 +66,22 @@ function readProjectsConfigurationFromProjectGraph(projectGraph) {
|
|
66
66
|
}
|
67
67
|
exports.readProjectsConfigurationFromProjectGraph = readProjectsConfigurationFromProjectGraph;
|
68
68
|
async function buildProjectGraphAndSourceMapsWithoutDaemon() {
|
69
|
+
// Set this globally to allow plugins to know if they are being called from the project graph creation
|
69
70
|
global.NX_GRAPH_CREATION = true;
|
70
71
|
const nxJson = (0, nx_json_1.readNxJson)();
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
return { projectGraph, sourceMaps };
|
85
|
-
}
|
86
|
-
finally {
|
87
|
-
cleanup();
|
88
|
-
}
|
72
|
+
perf_hooks_1.performance.mark('retrieve-project-configurations:start');
|
73
|
+
const { projects, externalNodes, sourceMaps, projectRootMap } = await (0, retrieve_workspace_files_1.retrieveProjectConfigurations)(workspace_root_1.workspaceRoot, nxJson);
|
74
|
+
perf_hooks_1.performance.mark('retrieve-project-configurations:end');
|
75
|
+
perf_hooks_1.performance.mark('retrieve-workspace-files:start');
|
76
|
+
const { allWorkspaceFiles, fileMap, rustReferences } = await (0, retrieve_workspace_files_1.retrieveWorkspaceFiles)(workspace_root_1.workspaceRoot, projectRootMap);
|
77
|
+
perf_hooks_1.performance.mark('retrieve-workspace-files:end');
|
78
|
+
const cacheEnabled = process.env.NX_CACHE_PROJECT_GRAPH !== 'false';
|
79
|
+
perf_hooks_1.performance.mark('build-project-graph-using-project-file-map:start');
|
80
|
+
const projectGraph = (await (0, build_project_graph_1.buildProjectGraphUsingProjectFileMap)(projects, externalNodes, fileMap, allWorkspaceFiles, rustReferences, cacheEnabled ? (0, nx_deps_cache_1.readFileMapCache)() : null, cacheEnabled)).projectGraph;
|
81
|
+
perf_hooks_1.performance.mark('build-project-graph-using-project-file-map:end');
|
82
|
+
(0, nx_plugin_1.unregisterPluginTSTranspiler)();
|
83
|
+
delete global.NX_GRAPH_CREATION;
|
84
|
+
return { projectGraph, sourceMaps };
|
89
85
|
}
|
90
86
|
exports.buildProjectGraphAndSourceMapsWithoutDaemon = buildProjectGraphAndSourceMapsWithoutDaemon;
|
91
87
|
function handleProjectGraphError(opts, e) {
|
@@ -1,7 +1,7 @@
|
|
1
1
|
import { ProjectGraphProjectNode } from '../../config/project-graph';
|
2
2
|
import { ProjectGraphBuilder } from '../project-graph-builder';
|
3
3
|
import { ProjectConfiguration, TargetConfiguration } from '../../config/workspace-json-project-json';
|
4
|
-
import { CreateDependenciesContext } from '
|
4
|
+
import { CreateDependenciesContext } from '../../utils/nx-plugin';
|
5
5
|
export declare function normalizeProjectNodes(ctx: CreateDependenciesContext, builder: ProjectGraphBuilder): Promise<void>;
|
6
6
|
/**
|
7
7
|
* Apply target defaults and normalization
|
@@ -1,8 +1,8 @@
|
|
1
1
|
import { NxJsonConfiguration, TargetDefaults } from '../../config/nx-json';
|
2
2
|
import { ProjectGraphExternalNode } from '../../config/project-graph';
|
3
3
|
import { ProjectConfiguration, TargetConfiguration } from '../../config/workspace-json-project-json';
|
4
|
+
import { LoadedNxPlugin } from '../../utils/nx-plugin';
|
4
5
|
import { ONLY_MODIFIES_EXISTING_TARGET } from '../../plugins/target-defaults/target-defaults-plugin';
|
5
|
-
import { RemotePlugin } from '../plugins/internal-api';
|
6
6
|
export type SourceInformation = [file: string, plugin: string];
|
7
7
|
export type ConfigurationSourceMaps = Record<string, Record<string, SourceInformation>>;
|
8
8
|
export declare function mergeProjectConfigurationIntoRootMap(projectRootMap: Map<string, ProjectConfiguration>, project: ProjectConfiguration & {
|
@@ -25,7 +25,7 @@ export type ConfigurationResult = {
|
|
25
25
|
* @param root The workspace root
|
26
26
|
*/
|
27
27
|
export declare function buildProjectsConfigurationsFromProjectPathsAndPlugins(nxJson: NxJsonConfiguration, projectFiles: string[], // making this parameter allows devkit to pick up newly created projects
|
28
|
-
plugins:
|
28
|
+
plugins: LoadedNxPlugin[], root?: string): Promise<ConfigurationResult>;
|
29
29
|
export declare function readProjectConfigurationsFromRootMap(projectRootMap: Map<string, ProjectConfiguration>): Record<string, ProjectConfiguration>;
|
30
30
|
/**
|
31
31
|
* Merges two targets.
|
@@ -7,7 +7,6 @@ const workspace_root_1 = require("../../utils/workspace-root");
|
|
7
7
|
const target_defaults_plugin_1 = require("../../plugins/target-defaults/target-defaults-plugin");
|
8
8
|
const minimatch_1 = require("minimatch");
|
9
9
|
const path_1 = require("path");
|
10
|
-
const utils_1 = require("../plugins/utils");
|
11
10
|
function mergeProjectConfigurationIntoRootMap(projectRootMap, project, configurationSourceMaps, sourceInformation,
|
12
11
|
// This function is used when reading project configuration
|
13
12
|
// in generators, where we don't want to do this.
|
@@ -133,23 +132,54 @@ function buildProjectsConfigurationsFromProjectPathsAndPlugins(nxJson, projectFi
|
|
133
132
|
plugins, root = workspace_root_1.workspaceRoot) {
|
134
133
|
const results = [];
|
135
134
|
// We iterate over plugins first - this ensures that plugins specified first take precedence.
|
136
|
-
for (const plugin of plugins) {
|
135
|
+
for (const { plugin, options } of plugins) {
|
137
136
|
const [pattern, createNodes] = plugin.createNodes ?? [];
|
137
|
+
const pluginResults = [];
|
138
|
+
performance.mark(`${plugin.name}:createNodes - start`);
|
138
139
|
if (!pattern) {
|
139
140
|
continue;
|
140
141
|
}
|
141
|
-
const matchedFiles = [];
|
142
|
-
performance.mark(`${plugin.name}:createNodes - start`);
|
143
142
|
for (const file of projectFiles) {
|
143
|
+
performance.mark(`${plugin.name}:createNodes:${file} - start`);
|
144
144
|
if ((0, minimatch_1.minimatch)(file, pattern, { dot: true })) {
|
145
|
-
|
145
|
+
try {
|
146
|
+
let r = createNodes(file, options, {
|
147
|
+
nxJsonConfiguration: nxJson,
|
148
|
+
workspaceRoot: root,
|
149
|
+
});
|
150
|
+
if (r instanceof Promise) {
|
151
|
+
pluginResults.push(r
|
152
|
+
.catch((e) => {
|
153
|
+
performance.mark(`${plugin.name}:createNodes:${file} - end`);
|
154
|
+
throw new CreateNodesError(`Unable to create nodes for ${file} using plugin ${plugin.name}.`, e);
|
155
|
+
})
|
156
|
+
.then((r) => {
|
157
|
+
performance.mark(`${plugin.name}:createNodes:${file} - end`);
|
158
|
+
performance.measure(`${plugin.name}:createNodes:${file}`, `${plugin.name}:createNodes:${file} - start`, `${plugin.name}:createNodes:${file} - end`);
|
159
|
+
return { ...r, file, pluginName: plugin.name };
|
160
|
+
}));
|
161
|
+
}
|
162
|
+
else {
|
163
|
+
performance.mark(`${plugin.name}:createNodes:${file} - end`);
|
164
|
+
performance.measure(`${plugin.name}:createNodes:${file}`, `${plugin.name}:createNodes:${file} - start`, `${plugin.name}:createNodes:${file} - end`);
|
165
|
+
pluginResults.push({
|
166
|
+
...r,
|
167
|
+
file,
|
168
|
+
pluginName: plugin.name,
|
169
|
+
});
|
170
|
+
}
|
171
|
+
}
|
172
|
+
catch (e) {
|
173
|
+
throw new CreateNodesError(`Unable to create nodes for ${file} using plugin ${plugin.name}.`, e);
|
174
|
+
}
|
146
175
|
}
|
147
176
|
}
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
177
|
+
// If there are no promises (counter undefined) or all promises have resolved (counter === 0)
|
178
|
+
results.push(Promise.all(pluginResults).then((results) => {
|
179
|
+
performance.mark(`${plugin.name}:createNodes - end`);
|
180
|
+
performance.measure(`${plugin.name}:createNodes`, `${plugin.name}:createNodes - start`, `${plugin.name}:createNodes - end`);
|
181
|
+
return results;
|
182
|
+
}));
|
153
183
|
}
|
154
184
|
return Promise.all(results).then((results) => {
|
155
185
|
performance.mark('createNodes:merge - start');
|
@@ -171,7 +201,7 @@ plugins, root = workspace_root_1.workspaceRoot) {
|
|
171
201
|
mergeProjectConfigurationIntoRootMap(projectRootMap, project, configurationSourceMaps, sourceInfo);
|
172
202
|
}
|
173
203
|
catch (e) {
|
174
|
-
throw new
|
204
|
+
throw new CreateNodesError(`Unable to merge project information for "${project.root}" from ${result.file} using plugin ${result.pluginName}.`, e);
|
175
205
|
}
|
176
206
|
}
|
177
207
|
Object.assign(externalNodes, pluginExternalNodes);
|
@@ -231,6 +261,20 @@ function readProjectConfigurationsFromRootMap(projectRootMap) {
|
|
231
261
|
return projects;
|
232
262
|
}
|
233
263
|
exports.readProjectConfigurationsFromRootMap = readProjectConfigurationsFromRootMap;
|
264
|
+
class CreateNodesError extends Error {
|
265
|
+
constructor(msg, cause) {
|
266
|
+
const message = `${msg} ${!cause
|
267
|
+
? ''
|
268
|
+
: cause instanceof Error
|
269
|
+
? `\n\n\t Inner Error: ${cause.stack}`
|
270
|
+
: cause}`;
|
271
|
+
// These errors are thrown during a JS callback which is invoked via rust.
|
272
|
+
// The errors messaging gets lost in the rust -> js -> rust transition, but
|
273
|
+
// logging the error here will ensure that it is visible in the console.
|
274
|
+
console.error(message);
|
275
|
+
super(message, { cause });
|
276
|
+
}
|
277
|
+
}
|
234
278
|
/**
|
235
279
|
* Merges two targets.
|
236
280
|
*
|
@@ -2,8 +2,7 @@ import { ProjectConfiguration } from '../../config/workspace-json-project-json';
|
|
2
2
|
import { NxJsonConfiguration } from '../../config/nx-json';
|
3
3
|
import { ProjectGraphExternalNode } from '../../config/project-graph';
|
4
4
|
import { ConfigurationSourceMaps } from './project-configuration-utils';
|
5
|
-
import {
|
6
|
-
import { NxPlugin } from '../plugins';
|
5
|
+
import { LoadedNxPlugin } from '../../utils/nx-plugin';
|
7
6
|
/**
|
8
7
|
* Walks the workspace directory to create the `projectFileMap`, `ProjectConfigurations` and `allWorkspaceFiles`
|
9
8
|
* @throws
|
@@ -20,8 +19,11 @@ export declare function retrieveWorkspaceFiles(workspaceRoot: string, projectRoo
|
|
20
19
|
}>;
|
21
20
|
/**
|
22
21
|
* Walk through the workspace and return `ProjectConfigurations`. Only use this if the projectFileMap is not needed.
|
22
|
+
*
|
23
|
+
* @param workspaceRoot
|
24
|
+
* @param nxJson
|
23
25
|
*/
|
24
|
-
export declare function retrieveProjectConfigurations(
|
26
|
+
export declare function retrieveProjectConfigurations(workspaceRoot: string, nxJson: NxJsonConfiguration): Promise<RetrievedGraphNodes>;
|
25
27
|
export declare function retrieveProjectConfigurationsWithAngularProjects(workspaceRoot: string, nxJson: NxJsonConfiguration): Promise<RetrievedGraphNodes>;
|
26
28
|
export type RetrievedGraphNodes = {
|
27
29
|
externalNodes: Record<string, ProjectGraphExternalNode>;
|
@@ -29,7 +31,7 @@ export type RetrievedGraphNodes = {
|
|
29
31
|
sourceMaps: ConfigurationSourceMaps;
|
30
32
|
projectRootMap: Record<string, string>;
|
31
33
|
};
|
32
|
-
export declare function retrieveProjectConfigurationPaths(root: string, plugins:
|
34
|
+
export declare function retrieveProjectConfigurationPaths(root: string, plugins: LoadedNxPlugin[]): string[];
|
33
35
|
export declare function retrieveProjectConfigurationsWithoutPluginInference(root: string): Promise<Record<string, ProjectConfiguration>>;
|
34
|
-
export declare function createProjectConfigurations(workspaceRoot: string, nxJson: NxJsonConfiguration, configFiles: string[], plugins:
|
35
|
-
export declare function configurationGlobs(plugins:
|
36
|
+
export declare function createProjectConfigurations(workspaceRoot: string, nxJson: NxJsonConfiguration, configFiles: string[], plugins: LoadedNxPlugin[]): Promise<RetrievedGraphNodes>;
|
37
|
+
export declare function configurationGlobs(plugins: LoadedNxPlugin[]): string[];
|
@@ -2,13 +2,15 @@
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
3
|
exports.configurationGlobs = exports.createProjectConfigurations = exports.retrieveProjectConfigurationsWithoutPluginInference = exports.retrieveProjectConfigurationPaths = exports.retrieveProjectConfigurationsWithAngularProjects = exports.retrieveProjectConfigurations = exports.retrieveWorkspaceFiles = void 0;
|
4
4
|
const perf_hooks_1 = require("perf_hooks");
|
5
|
+
const installation_directory_1 = require("../../utils/installation-directory");
|
5
6
|
const angular_json_1 = require("../../adapter/angular-json");
|
6
7
|
const nx_json_1 = require("../../config/nx-json");
|
8
|
+
const package_json_workspaces_1 = require("../../plugins/package-json-workspaces");
|
7
9
|
const project_configuration_utils_1 = require("./project-configuration-utils");
|
8
|
-
const
|
10
|
+
const nx_plugin_1 = require("../../utils/nx-plugin");
|
11
|
+
const project_json_1 = require("../../plugins/project-json/build-nodes/project-json");
|
9
12
|
const workspace_context_1 = require("../../utils/workspace-context");
|
10
13
|
const build_all_workspace_files_1 = require("./build-all-workspace-files");
|
11
|
-
const path_1 = require("path");
|
12
14
|
/**
|
13
15
|
* Walks the workspace directory to create the `projectFileMap`, `ProjectConfigurations` and `allWorkspaceFiles`
|
14
16
|
* @throws
|
@@ -35,23 +37,22 @@ async function retrieveWorkspaceFiles(workspaceRoot, projectRootMap) {
|
|
35
37
|
exports.retrieveWorkspaceFiles = retrieveWorkspaceFiles;
|
36
38
|
/**
|
37
39
|
* Walk through the workspace and return `ProjectConfigurations`. Only use this if the projectFileMap is not needed.
|
40
|
+
*
|
41
|
+
* @param workspaceRoot
|
42
|
+
* @param nxJson
|
38
43
|
*/
|
39
|
-
async function retrieveProjectConfigurations(
|
40
|
-
const
|
41
|
-
return
|
44
|
+
async function retrieveProjectConfigurations(workspaceRoot, nxJson) {
|
45
|
+
const plugins = await (0, nx_plugin_1.loadNxPlugins)(nxJson?.plugins ?? [], (0, installation_directory_1.getNxRequirePaths)(workspaceRoot), workspaceRoot);
|
46
|
+
return _retrieveProjectConfigurations(workspaceRoot, nxJson, plugins);
|
42
47
|
}
|
43
48
|
exports.retrieveProjectConfigurations = retrieveProjectConfigurations;
|
44
49
|
async function retrieveProjectConfigurationsWithAngularProjects(workspaceRoot, nxJson) {
|
45
|
-
const
|
50
|
+
const plugins = await (0, nx_plugin_1.loadNxPlugins)(nxJson?.plugins ?? [], (0, installation_directory_1.getNxRequirePaths)(workspaceRoot), workspaceRoot);
|
46
51
|
if ((0, angular_json_1.shouldMergeAngularProjects)(workspaceRoot, true) &&
|
47
|
-
!
|
48
|
-
|
49
|
-
pluginsToLoad.push((0, path_1.join)(__dirname, '../../adapter/angular-json'));
|
52
|
+
!plugins.some((p) => p.plugin.name === angular_json_1.NX_ANGULAR_JSON_PLUGIN_NAME)) {
|
53
|
+
plugins.push({ plugin: angular_json_1.NxAngularJsonPlugin });
|
50
54
|
}
|
51
|
-
|
52
|
-
const res = _retrieveProjectConfigurations(workspaceRoot, nxJson, await plugins);
|
53
|
-
cleanup();
|
54
|
-
return res;
|
55
|
+
return _retrieveProjectConfigurations(workspaceRoot, nxJson, plugins);
|
55
56
|
}
|
56
57
|
exports.retrieveProjectConfigurationsWithAngularProjects = retrieveProjectConfigurationsWithAngularProjects;
|
57
58
|
function _retrieveProjectConfigurations(workspaceRoot, nxJson, plugins) {
|
@@ -68,16 +69,18 @@ const projectsWithoutPluginCache = new Map();
|
|
68
69
|
// TODO: This function is called way too often, it should be optimized without this cache
|
69
70
|
async function retrieveProjectConfigurationsWithoutPluginInference(root) {
|
70
71
|
const nxJson = (0, nx_json_1.readNxJson)(root);
|
71
|
-
const
|
72
|
+
const plugins = await (0, nx_plugin_1.getDefaultPlugins)(root);
|
72
73
|
const projectGlobPatterns = retrieveProjectConfigurationPaths(root, plugins);
|
73
74
|
const cacheKey = root + ',' + projectGlobPatterns.join(',');
|
74
75
|
if (projectsWithoutPluginCache.has(cacheKey)) {
|
75
76
|
return projectsWithoutPluginCache.get(cacheKey);
|
76
77
|
}
|
77
78
|
const projectFiles = (0, workspace_context_1.globWithWorkspaceContext)(root, projectGlobPatterns);
|
78
|
-
const { projects } = await createProjectConfigurations(root, nxJson, projectFiles,
|
79
|
+
const { projects } = await createProjectConfigurations(root, nxJson, projectFiles, [
|
80
|
+
{ plugin: (0, package_json_workspaces_1.getNxPackageJsonWorkspacesPlugin)(root) },
|
81
|
+
{ plugin: project_json_1.ProjectJsonProjectsPlugin },
|
82
|
+
]);
|
79
83
|
projectsWithoutPluginCache.set(cacheKey, projects);
|
80
|
-
cleanup();
|
81
84
|
return projects;
|
82
85
|
}
|
83
86
|
exports.retrieveProjectConfigurationsWithoutPluginInference = retrieveProjectConfigurationsWithoutPluginInference;
|
@@ -96,8 +99,8 @@ async function createProjectConfigurations(workspaceRoot, nxJson, configFiles, p
|
|
96
99
|
exports.createProjectConfigurations = createProjectConfigurations;
|
97
100
|
function configurationGlobs(plugins) {
|
98
101
|
const globPatterns = [];
|
99
|
-
for (const plugin of plugins) {
|
100
|
-
if (
|
102
|
+
for (const { plugin } of plugins) {
|
103
|
+
if (plugin.createNodes) {
|
101
104
|
globPatterns.push(plugin.createNodes[0]);
|
102
105
|
}
|
103
106
|
}
|
@@ -3,6 +3,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.TaskOrchestrator = void 0;
|
4
4
|
const events_1 = require("events");
|
5
5
|
const perf_hooks_1 = require("perf_hooks");
|
6
|
+
const path_1 = require("path");
|
7
|
+
const run_commands_impl_1 = require("../executors/run-commands/run-commands.impl");
|
6
8
|
const forked_process_task_runner_1 = require("./forked-process-task-runner");
|
7
9
|
const cache_1 = require("./cache");
|
8
10
|
const utils_1 = require("./utils");
|
@@ -10,6 +12,9 @@ const tasks_schedule_1 = require("./tasks-schedule");
|
|
10
12
|
const hash_task_1 = require("../hasher/hash-task");
|
11
13
|
const task_env_1 = require("./task-env");
|
12
14
|
const os = require("os");
|
15
|
+
const workspace_root_1 = require("../utils/workspace-root");
|
16
|
+
const output_1 = require("../utils/output");
|
17
|
+
const params_1 = require("../utils/params");
|
13
18
|
class TaskOrchestrator {
|
14
19
|
// endregion internal state
|
15
20
|
constructor(hasher, initiatingProject, projectGraph, taskGraph, options, bail, daemon) {
|
@@ -205,13 +210,45 @@ class TaskOrchestrator {
|
|
205
210
|
let results = doNotSkipCache ? await this.applyCachedResults([task]) : [];
|
206
211
|
// the task wasn't cached
|
207
212
|
if (results.length === 0) {
|
208
|
-
|
209
|
-
const
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
213
|
+
const shouldPrefix = streamOutput && process.env.NX_PREFIX_OUTPUT === 'true';
|
214
|
+
const targetConfiguration = (0, utils_1.getTargetConfigurationForTask)(task, this.projectGraph);
|
215
|
+
if (process.env.NX_RUN_COMMANDS_DIRECTLY !== 'false' &&
|
216
|
+
targetConfiguration.executor === 'nx:run-commands' &&
|
217
|
+
!shouldPrefix) {
|
218
|
+
const { schema } = (0, utils_1.getExecutorForTask)(task, this.projectGraph);
|
219
|
+
const isRunOne = this.initiatingProject != null;
|
220
|
+
const combinedOptions = (0, params_1.combineOptionsForExecutor)(task.overrides, task.target.configuration ?? targetConfiguration.defaultConfiguration, targetConfiguration, schema, task.target.project, (0, path_1.relative)(task.projectRoot ?? workspace_root_1.workspaceRoot, process.cwd()), process.env.NX_VERBOSE_LOGGING === 'true');
|
221
|
+
if (streamOutput) {
|
222
|
+
const args = (0, utils_1.getPrintableCommandArgsForTask)(task);
|
223
|
+
output_1.output.logCommand(args.join(' '));
|
224
|
+
}
|
225
|
+
const { success, terminalOutput } = await (0, run_commands_impl_1.default)({
|
226
|
+
...combinedOptions,
|
227
|
+
env,
|
228
|
+
usePty: isRunOne && !this.tasksSchedule.hasTasks(),
|
229
|
+
streamOutput,
|
230
|
+
}, {
|
231
|
+
root: workspace_root_1.workspaceRoot, // only root is needed in runCommandsImpl
|
232
|
+
});
|
233
|
+
const status = success ? 'success' : 'failure';
|
234
|
+
if (!streamOutput) {
|
235
|
+
this.options.lifeCycle.printTaskTerminalOutput(task, status, terminalOutput);
|
236
|
+
}
|
237
|
+
results.push({
|
238
|
+
task,
|
239
|
+
status,
|
240
|
+
terminalOutput,
|
241
|
+
});
|
242
|
+
}
|
243
|
+
else {
|
244
|
+
// cache prep
|
245
|
+
const { code, terminalOutput } = await this.runTaskInForkedProcess(task, env, pipeOutput, temporaryOutputPath, streamOutput);
|
246
|
+
results.push({
|
247
|
+
task,
|
248
|
+
status: code === 0 ? 'success' : 'failure',
|
249
|
+
terminalOutput,
|
250
|
+
});
|
251
|
+
}
|
215
252
|
}
|
216
253
|
await this.postRunSteps([task], results, doNotSkipCache, { groupId });
|
217
254
|
}
|
@@ -338,7 +375,7 @@ class TaskOrchestrator {
|
|
338
375
|
if (process.env.NX_NATIVE_COMMAND_RUNNER !== 'false') {
|
339
376
|
return true;
|
340
377
|
}
|
341
|
-
const { schema } =
|
378
|
+
const { schema } = (0, utils_1.getExecutorForTask)(task, this.projectGraph);
|
342
379
|
return (schema.outputCapture === 'pipe' ||
|
343
380
|
process.env.NX_STREAM_OUTPUT === 'true');
|
344
381
|
}
|
@@ -89,7 +89,7 @@ class TasksSchedule {
|
|
89
89
|
const batchMap = {};
|
90
90
|
for (const root of this.notScheduledTaskGraph.roots) {
|
91
91
|
const rootTask = this.notScheduledTaskGraph.tasks[root];
|
92
|
-
const executorName =
|
92
|
+
const executorName = (0, utils_1.getExecutorNameForTask)(rootTask, this.projectGraph);
|
93
93
|
await this.processTaskForBatches(batchMap, rootTask, executorName, true);
|
94
94
|
}
|
95
95
|
for (const [executorName, taskGraph] of Object.entries(batchMap)) {
|
@@ -105,8 +105,8 @@ class TasksSchedule {
|
|
105
105
|
if (!this.canBatchTaskBeScheduled(task.id, batches[rootExecutorName])) {
|
106
106
|
return;
|
107
107
|
}
|
108
|
-
const { batchImplementationFactory } =
|
109
|
-
const executorName =
|
108
|
+
const { batchImplementationFactory } = (0, utils_1.getExecutorForTask)(task, this.projectGraph);
|
109
|
+
const executorName = (0, utils_1.getExecutorNameForTask)(task, this.projectGraph);
|
110
110
|
if (rootExecutorName !== executorName) {
|
111
111
|
return;
|
112
112
|
}
|
@@ -1,7 +1,7 @@
|
|
1
1
|
import { Task, TaskGraph } from '../config/task-graph';
|
2
2
|
import { ProjectGraph, ProjectGraphProjectNode } from '../config/project-graph';
|
3
|
-
import { TargetDependencyConfig } from '../config/workspace-json-project-json';
|
4
|
-
import { CustomHasher } from '../config/misc-interfaces';
|
3
|
+
import { TargetConfiguration, TargetDependencyConfig } from '../config/workspace-json-project-json';
|
4
|
+
import { CustomHasher, ExecutorConfig } from '../config/misc-interfaces';
|
5
5
|
export declare function getCommandAsString(execCommand: string, task: Task): string;
|
6
6
|
export declare function getDependencyConfigs({ project, target }: {
|
7
7
|
project: string;
|
@@ -23,12 +23,13 @@ export declare function transformLegacyOutputs(projectRoot: string, error: Inval
|
|
23
23
|
export declare function getOutputsForTargetAndConfiguration(task: Task, node: ProjectGraphProjectNode): string[];
|
24
24
|
export declare function getOutputsForTargetAndConfiguration(target: Task['target'] | Task, overrides: Task['overrides'] | ProjectGraphProjectNode, node: ProjectGraphProjectNode): string[];
|
25
25
|
export declare function interpolate(template: string, data: any): string;
|
26
|
-
export declare function
|
27
|
-
export declare function
|
26
|
+
export declare function getTargetConfigurationForTask(task: Task, projectGraph: ProjectGraph): TargetConfiguration | undefined;
|
27
|
+
export declare function getExecutorNameForTask(task: Task, projectGraph: ProjectGraph): string;
|
28
|
+
export declare function getExecutorForTask(task: Task, projectGraph: ProjectGraph): ExecutorConfig & {
|
28
29
|
isNgCompat: boolean;
|
29
30
|
isNxExecutor: boolean;
|
30
|
-
}
|
31
|
-
export declare function getCustomHasher(task: Task, projectGraph: ProjectGraph):
|
31
|
+
};
|
32
|
+
export declare function getCustomHasher(task: Task, projectGraph: ProjectGraph): CustomHasher | null;
|
32
33
|
export declare function removeTasksFromTaskGraph(graph: TaskGraph, ids: string[]): TaskGraph;
|
33
34
|
export declare function removeIdsFromGraph<T>(graph: {
|
34
35
|
roots: string[];
|