nx 19.8.13 → 19.8.15
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/nx.js +20 -5
- package/bin/post-install.js +5 -3
- package/package.json +12 -12
- package/plugins/package-json.d.ts +5 -1
- package/plugins/package-json.js +26 -2
- package/src/command-line/affected/affected.js +3 -1
- package/src/command-line/format/format.js +4 -2
- package/src/command-line/show/project.js +4 -0
- package/src/command-line/show/projects.js +4 -0
- package/src/daemon/server/project-graph-incremental-recomputation.js +4 -4
- package/src/daemon/server/server.js +2 -2
- package/src/daemon/server/shutdown-utils.js +2 -2
- package/src/executors/utils/convert-nx-executor.js +2 -3
- package/src/native/nx.wasm32-wasi.wasm +0 -0
- package/src/plugins/package-json/create-nodes.d.ts +3 -4
- package/src/plugins/package-json/create-nodes.js +19 -2
- package/src/project-graph/affected/affected-project-graph.js +3 -0
- package/src/project-graph/affected/locators/project-glob-changes.js +16 -4
- package/src/project-graph/build-project-graph.d.ts +1 -0
- package/src/project-graph/build-project-graph.js +12 -3
- package/src/project-graph/error-types.d.ts +1 -1
- package/src/project-graph/plugins/get-plugins.d.ts +4 -0
- package/src/{daemon/server/plugins.js → project-graph/plugins/get-plugins.js} +19 -1
- package/src/project-graph/plugins/index.js +1 -0
- package/src/project-graph/plugins/internal-api.d.ts +4 -0
- package/src/project-graph/plugins/internal-api.js +14 -7
- package/src/project-graph/plugins/isolation/index.js +1 -7
- package/src/project-graph/plugins/isolation/plugin-worker.js +2 -2
- package/src/project-graph/plugins/loader.d.ts +1 -1
- package/src/project-graph/plugins/loader.js +1 -4
- package/src/project-graph/project-graph.js +19 -11
- package/src/project-graph/utils/retrieve-workspace-files.d.ts +2 -6
- package/src/project-graph/utils/retrieve-workspace-files.js +3 -5
- package/src/tasks-runner/default-tasks-runner.js +20 -2
- package/src/daemon/server/plugins.d.ts +0 -3
package/bin/nx.js
CHANGED
@@ -17,6 +17,7 @@ const perf_hooks_1 = require("perf_hooks");
|
|
17
17
|
const workspace_context_1 = require("../src/utils/workspace-context");
|
18
18
|
const client_1 = require("../src/daemon/client/client");
|
19
19
|
const db_connection_1 = require("../src/utils/db-connection");
|
20
|
+
const exit_codes_1 = require("../src/utils/exit-codes");
|
20
21
|
function main() {
|
21
22
|
if (process.argv[2] !== 'report' &&
|
22
23
|
process.argv[2] !== '--version' &&
|
@@ -224,11 +225,25 @@ const getLatestVersionOfNx = ((fn) => {
|
|
224
225
|
let cache = null;
|
225
226
|
return () => cache || (cache = fn());
|
226
227
|
})(_getLatestVersionOfNx);
|
227
|
-
function nxCleanup() {
|
228
|
+
function nxCleanup(signal) {
|
228
229
|
(0, db_connection_1.removeDbConnections)();
|
230
|
+
if (signal) {
|
231
|
+
process.exit((0, exit_codes_1.signalToCode)(signal));
|
232
|
+
}
|
233
|
+
else {
|
234
|
+
process.exit();
|
235
|
+
}
|
229
236
|
}
|
230
|
-
process.on('exit',
|
231
|
-
|
232
|
-
|
233
|
-
process.on('
|
237
|
+
process.on('exit', () => {
|
238
|
+
nxCleanup();
|
239
|
+
});
|
240
|
+
process.on('SIGINT', () => {
|
241
|
+
nxCleanup('SIGINT');
|
242
|
+
});
|
243
|
+
process.on('SIGTERM', () => {
|
244
|
+
nxCleanup('SIGTERM');
|
245
|
+
});
|
246
|
+
process.on('SIGHUP', () => {
|
247
|
+
nxCleanup('SIGHUP');
|
248
|
+
});
|
234
249
|
main();
|
package/bin/post-install.js
CHANGED
@@ -18,10 +18,12 @@ const workspace_context_1 = require("../src/utils/workspace-context");
|
|
18
18
|
if (isMainNxPackage() && (0, fileutils_1.fileExists)((0, path_1.join)(workspace_root_1.workspaceRoot, 'nx.json'))) {
|
19
19
|
(0, assert_supported_platform_1.assertSupportedPlatform)();
|
20
20
|
(0, workspace_context_1.setupWorkspaceContext)(workspace_root_1.workspaceRoot);
|
21
|
-
|
22
|
-
|
21
|
+
if (client_1.daemonClient.enabled()) {
|
22
|
+
try {
|
23
|
+
await client_1.daemonClient.stop();
|
24
|
+
}
|
25
|
+
catch (e) { }
|
23
26
|
}
|
24
|
-
catch (e) { }
|
25
27
|
const tasks = [
|
26
28
|
(0, project_graph_1.buildProjectGraphAndSourceMapsWithoutDaemon)(),
|
27
29
|
];
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "nx",
|
3
|
-
"version": "19.8.
|
3
|
+
"version": "19.8.15",
|
4
4
|
"private": false,
|
5
5
|
"description": "The core Nx plugin contains the core functionality of Nx like the project graph, nx commands and task orchestration.",
|
6
6
|
"repository": {
|
@@ -67,7 +67,7 @@
|
|
67
67
|
"yargs-parser": "21.1.1",
|
68
68
|
"node-machine-id": "1.1.12",
|
69
69
|
"ora": "5.3.0",
|
70
|
-
"@nrwl/tao": "19.8.
|
70
|
+
"@nrwl/tao": "19.8.15"
|
71
71
|
},
|
72
72
|
"peerDependencies": {
|
73
73
|
"@swc-node/register": "^1.8.0",
|
@@ -82,16 +82,16 @@
|
|
82
82
|
}
|
83
83
|
},
|
84
84
|
"optionalDependencies": {
|
85
|
-
"@nx/nx-darwin-x64": "19.8.
|
86
|
-
"@nx/nx-darwin-arm64": "19.8.
|
87
|
-
"@nx/nx-linux-x64-gnu": "19.8.
|
88
|
-
"@nx/nx-linux-x64-musl": "19.8.
|
89
|
-
"@nx/nx-win32-x64-msvc": "19.8.
|
90
|
-
"@nx/nx-linux-arm64-gnu": "19.8.
|
91
|
-
"@nx/nx-linux-arm64-musl": "19.8.
|
92
|
-
"@nx/nx-linux-arm-gnueabihf": "19.8.
|
93
|
-
"@nx/nx-win32-arm64-msvc": "19.8.
|
94
|
-
"@nx/nx-freebsd-x64": "19.8.
|
85
|
+
"@nx/nx-darwin-x64": "19.8.15",
|
86
|
+
"@nx/nx-darwin-arm64": "19.8.15",
|
87
|
+
"@nx/nx-linux-x64-gnu": "19.8.15",
|
88
|
+
"@nx/nx-linux-x64-musl": "19.8.15",
|
89
|
+
"@nx/nx-win32-x64-msvc": "19.8.15",
|
90
|
+
"@nx/nx-linux-arm64-gnu": "19.8.15",
|
91
|
+
"@nx/nx-linux-arm64-musl": "19.8.15",
|
92
|
+
"@nx/nx-linux-arm-gnueabihf": "19.8.15",
|
93
|
+
"@nx/nx-win32-arm64-msvc": "19.8.15",
|
94
|
+
"@nx/nx-freebsd-x64": "19.8.15"
|
95
95
|
},
|
96
96
|
"nx-migrations": {
|
97
97
|
"migrations": "./migrations.json",
|
@@ -1 +1,5 @@
|
|
1
|
-
|
1
|
+
import { ProjectConfiguration } from '../src/config/workspace-json-project-json';
|
2
|
+
export type PackageJsonConfigurationCache = {
|
3
|
+
[hash: string]: ProjectConfiguration;
|
4
|
+
};
|
5
|
+
export declare function readPackageJsonConfigurationCache(): PackageJsonConfigurationCache;
|
package/plugins/package-json.js
CHANGED
@@ -1,12 +1,36 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.readPackageJsonConfigurationCache = readPackageJsonConfigurationCache;
|
4
|
+
const plugins_1 = require("../src/project-graph/plugins");
|
3
5
|
const workspace_root_1 = require("../src/utils/workspace-root");
|
4
6
|
const package_json_1 = require("../src/plugins/package-json");
|
7
|
+
const cache_directory_1 = require("../src/utils/cache-directory");
|
8
|
+
const path_1 = require("path");
|
9
|
+
const fileutils_1 = require("../src/utils/fileutils");
|
10
|
+
const cachePath = (0, path_1.join)(cache_directory_1.workspaceDataDirectory, 'package-json.hash');
|
11
|
+
function readPackageJsonConfigurationCache() {
|
12
|
+
try {
|
13
|
+
return (0, fileutils_1.readJsonFile)(cachePath);
|
14
|
+
}
|
15
|
+
catch (e) {
|
16
|
+
return {};
|
17
|
+
}
|
18
|
+
}
|
19
|
+
function writeCache(cache) {
|
20
|
+
(0, fileutils_1.writeJsonFile)(cachePath, cache);
|
21
|
+
}
|
5
22
|
const plugin = {
|
6
23
|
name: 'nx-all-package-jsons-plugin',
|
7
|
-
|
24
|
+
createNodesV2: [
|
8
25
|
'*/**/package.json',
|
9
|
-
(
|
26
|
+
(configFiles, options, context) => {
|
27
|
+
const cache = readPackageJsonConfigurationCache();
|
28
|
+
const result = (0, plugins_1.createNodesFromFiles)((f) => (0, package_json_1.createNodeFromPackageJson)(f, workspace_root_1.workspaceRoot, cache), configFiles, options, context);
|
29
|
+
writeCache(cache);
|
30
|
+
return result;
|
31
|
+
},
|
10
32
|
],
|
11
33
|
};
|
12
34
|
module.exports = plugin;
|
35
|
+
module.exports.readPackageJsonConfigurationCache =
|
36
|
+
readPackageJsonConfigurationCache;
|
@@ -28,7 +28,9 @@ async function affected(command, args, extraTargetDependencies = {}, extraOption
|
|
28
28
|
printWarnings: command !== 'print-affected' && !args.plain && args.graph !== 'stdout',
|
29
29
|
}, nxJson);
|
30
30
|
await (0, connect_to_nx_cloud_1.connectToNxCloudIfExplicitlyAsked)(nxArgs);
|
31
|
-
const projectGraph = await (0, project_graph_1.createProjectGraphAsync)({
|
31
|
+
const projectGraph = await (0, project_graph_1.createProjectGraphAsync)({
|
32
|
+
exitOnError: true,
|
33
|
+
});
|
32
34
|
const projects = await getAffectedGraphNodes(nxArgs, projectGraph);
|
33
35
|
try {
|
34
36
|
switch (command) {
|
@@ -34,7 +34,7 @@ async function format(command, args) {
|
|
34
34
|
const patterns = (await getPatterns({ ...args, ...nxArgs })).map(
|
35
35
|
// prettier removes one of the \
|
36
36
|
// prettier-ignore
|
37
|
-
(p) => `"${p.replace(/\$/g,
|
37
|
+
(p) => `"${p.replace(/\$/g, '\\\$')}"`);
|
38
38
|
// Chunkify the patterns array to prevent crashing the windows terminal
|
39
39
|
const chunkList = (0, chunkify_1.chunkify)(patterns);
|
40
40
|
switch (command) {
|
@@ -108,7 +108,9 @@ async function getPatterns(args) {
|
|
108
108
|
}
|
109
109
|
}
|
110
110
|
async function getPatternsFromApps(affectedFiles, allWorkspaceFiles, projectGraph) {
|
111
|
-
const graph = await (0, project_graph_1.createProjectGraphAsync)({
|
111
|
+
const graph = await (0, project_graph_1.createProjectGraphAsync)({
|
112
|
+
exitOnError: true,
|
113
|
+
});
|
112
114
|
const affectedGraph = await (0, affected_project_graph_1.filterAffected)(graph, (0, file_utils_1.calculateFileChanges)(affectedFiles, allWorkspaceFiles));
|
113
115
|
return getPatternsFromProjects(Object.keys(affectedGraph.nodes), projectGraph);
|
114
116
|
}
|
@@ -5,6 +5,8 @@ const output_1 = require("../../utils/output");
|
|
5
5
|
const project_graph_1 = require("../../project-graph/project-graph");
|
6
6
|
const graph_1 = require("../graph/graph");
|
7
7
|
async function showProjectHandler(args) {
|
8
|
+
performance.mark('code-loading:end');
|
9
|
+
performance.measure('code-loading', 'init-local', 'code-loading:end');
|
8
10
|
const graph = await (0, project_graph_1.createProjectGraphAsync)();
|
9
11
|
const node = graph.nodes[args.projectName];
|
10
12
|
if (!node) {
|
@@ -56,5 +58,7 @@ async function showProjectHandler(args) {
|
|
56
58
|
}
|
57
59
|
}
|
58
60
|
}
|
61
|
+
// TODO: Find a better fix for this
|
62
|
+
await new Promise((res) => setImmediate(res));
|
59
63
|
await output_1.output.drain();
|
60
64
|
}
|
@@ -11,6 +11,8 @@ const all_file_data_1 = require("../../utils/all-file-data");
|
|
11
11
|
const command_line_utils_1 = require("../../utils/command-line-utils");
|
12
12
|
const find_matching_projects_1 = require("../../utils/find-matching-projects");
|
13
13
|
async function showProjectsHandler(args) {
|
14
|
+
performance.mark('code-loading:end');
|
15
|
+
performance.measure('code-loading', 'init-local', 'code-loading:end');
|
14
16
|
let graph = await (0, project_graph_1.createProjectGraphAsync)();
|
15
17
|
const nxJson = (0, nx_json_1.readNxJson)();
|
16
18
|
const { nxArgs } = (0, command_line_utils_1.splitArgsIntoNxArgsAndOverrides)(args, 'affected', {
|
@@ -59,6 +61,8 @@ async function showProjectsHandler(args) {
|
|
59
61
|
console.log(project);
|
60
62
|
}
|
61
63
|
}
|
64
|
+
// TODO: Find a better fix for this
|
65
|
+
await new Promise((res) => setImmediate(res));
|
62
66
|
await output_1.output.drain();
|
63
67
|
}
|
64
68
|
function getGraphNodesMatchingPatterns(graph, patterns) {
|
@@ -16,8 +16,8 @@ const workspace_context_1 = require("../../utils/workspace-context");
|
|
16
16
|
const workspace_root_1 = require("../../utils/workspace-root");
|
17
17
|
const file_watcher_sockets_1 = require("./file-watching/file-watcher-sockets");
|
18
18
|
const logger_1 = require("./logger");
|
19
|
-
const plugins_1 = require("./plugins");
|
20
19
|
const error_types_1 = require("../../project-graph/error-types");
|
20
|
+
const get_plugins_1 = require("../../project-graph/plugins/get-plugins");
|
21
21
|
let cachedSerializedProjectGraphPromise;
|
22
22
|
const collectedUpdatedFiles = new Set();
|
23
23
|
const collectedDeletedFiles = new Set();
|
@@ -38,7 +38,7 @@ async function getCachedSerializedProjectGraphPromise() {
|
|
38
38
|
// reset the wait time
|
39
39
|
waitPeriod = 100;
|
40
40
|
await resetInternalStateIfNxDepsMissing();
|
41
|
-
const plugins = await (0,
|
41
|
+
const plugins = await (0, get_plugins_1.getPlugins)();
|
42
42
|
if (collectedUpdatedFiles.size == 0 && collectedDeletedFiles.size == 0) {
|
43
43
|
if (!cachedSerializedProjectGraphPromise) {
|
44
44
|
cachedSerializedProjectGraphPromise =
|
@@ -90,7 +90,7 @@ function addUpdatedAndDeletedFiles(createdFiles, updatedFiles, deletedFiles) {
|
|
90
90
|
waitPeriod = waitPeriod * 2;
|
91
91
|
}
|
92
92
|
cachedSerializedProjectGraphPromise =
|
93
|
-
processFilesAndCreateAndSerializeProjectGraph(await (0,
|
93
|
+
processFilesAndCreateAndSerializeProjectGraph(await (0, get_plugins_1.getPlugins)());
|
94
94
|
const { projectGraph } = await cachedSerializedProjectGraphPromise;
|
95
95
|
if (createdFiles.length > 0) {
|
96
96
|
(0, file_watcher_sockets_1.notifyFileWatcherSockets)(createdFiles, null, null);
|
@@ -238,7 +238,7 @@ async function createAndSerializeProjectGraph({ projects, sourceMaps, }) {
|
|
238
238
|
const fileMap = copyFileMap(exports.fileMapWithFiles.fileMap);
|
239
239
|
const allWorkspaceFiles = copyFileData(exports.fileMapWithFiles.allWorkspaceFiles);
|
240
240
|
const rustReferences = exports.fileMapWithFiles.rustReferences;
|
241
|
-
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,
|
241
|
+
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, get_plugins_1.getPlugins)(), sourceMaps);
|
242
242
|
exports.currentProjectFileMapCache = projectFileMapCache;
|
243
243
|
exports.currentProjectGraph = projectGraph;
|
244
244
|
perf_hooks_1.performance.mark('create-project-graph-end');
|
@@ -181,8 +181,8 @@ async function handleResult(socket, type, hrFn) {
|
|
181
181
|
logger_1.serverLogger.log(`Handled ${type}. Handling time: ${doneHandlingMark.getTime() - startMark.getTime()}. Response time: ${endMark.getTime() - doneHandlingMark.getTime()}.`);
|
182
182
|
}
|
183
183
|
function handleInactivityTimeout() {
|
184
|
-
if (
|
185
|
-
logger_1.serverLogger.log(`There are
|
184
|
+
if ((0, file_watcher_sockets_1.hasRegisteredFileWatcherSockets)()) {
|
185
|
+
logger_1.serverLogger.log(`There are open file watchers. Resetting inactivity timer.`);
|
186
186
|
(0, shutdown_utils_1.resetInactivityTimeout)(handleInactivityTimeout);
|
187
187
|
}
|
188
188
|
else {
|
@@ -13,9 +13,9 @@ const workspace_root_1 = require("../../utils/workspace-root");
|
|
13
13
|
const logger_1 = require("./logger");
|
14
14
|
const socket_utils_1 = require("../socket-utils");
|
15
15
|
const cache_1 = require("../cache");
|
16
|
-
const plugins_1 = require("./plugins");
|
17
16
|
const error_types_1 = require("../../project-graph/error-types");
|
18
17
|
const db_connection_1 = require("../../utils/db-connection");
|
18
|
+
const get_plugins_1 = require("../../project-graph/plugins/get-plugins");
|
19
19
|
exports.SERVER_INACTIVITY_TIMEOUT_MS = 10800000; // 10800000 ms = 3 hours
|
20
20
|
let watcherInstance;
|
21
21
|
function storeWatcherInstance(instance) {
|
@@ -50,7 +50,7 @@ async function handleServerProcessTermination({ server, reason, sockets, }) {
|
|
50
50
|
logger_1.serverLogger.watcherLog(`Stopping the watcher for ${workspace_root_1.workspaceRoot} (outputs)`);
|
51
51
|
}
|
52
52
|
(0, cache_1.deleteDaemonJsonProcessCache)();
|
53
|
-
(0,
|
53
|
+
(0, get_plugins_1.cleanupPlugins)();
|
54
54
|
(0, db_connection_1.removeDbConnections)();
|
55
55
|
logger_1.serverLogger.log(`Server stopped because: "${reason}"`);
|
56
56
|
}
|
@@ -7,7 +7,7 @@ exports.convertNxExecutor = convertNxExecutor;
|
|
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
9
|
const project_configuration_utils_1 = require("../../project-graph/utils/project-configuration-utils");
|
10
|
-
const
|
10
|
+
const get_plugins_1 = require("../../project-graph/plugins/get-plugins");
|
11
11
|
/**
|
12
12
|
* Convert an Nx Executor into an Angular Devkit Builder
|
13
13
|
*
|
@@ -17,12 +17,11 @@ function convertNxExecutor(executor) {
|
|
17
17
|
const builderFunction = (options, builderContext) => {
|
18
18
|
const promise = async () => {
|
19
19
|
const nxJsonConfiguration = (0, nx_json_1.readNxJson)(builderContext.workspaceRoot);
|
20
|
-
const
|
20
|
+
const plugins = await (0, get_plugins_1.getPlugins)();
|
21
21
|
const projectsConfigurations = {
|
22
22
|
version: 2,
|
23
23
|
projects: (0, project_configuration_utils_1.readProjectConfigurationsFromRootMap)((await (0, retrieve_workspace_files_1.retrieveProjectConfigurations)(plugins, builderContext.workspaceRoot, nxJsonConfiguration)).projects),
|
24
24
|
};
|
25
|
-
cleanup();
|
26
25
|
const context = {
|
27
26
|
root: builderContext.workspaceRoot,
|
28
27
|
projectName: builderContext.target.project,
|
Binary file
|
@@ -2,13 +2,12 @@ import { NxJsonConfiguration } from '../../config/nx-json';
|
|
2
2
|
import { ProjectConfiguration } from '../../config/workspace-json-project-json';
|
3
3
|
import { PackageJson } from '../../utils/package-json';
|
4
4
|
import { CreateNodesV2 } from '../../project-graph/plugins';
|
5
|
+
import { PackageJsonConfigurationCache } from '../../../plugins/package-json';
|
5
6
|
export declare const createNodesV2: CreateNodesV2;
|
6
7
|
export declare function buildPackageJsonWorkspacesMatcher(workspaceRoot: string, readJson: (string: any) => any): (p: string) => boolean;
|
7
|
-
export declare function createNodeFromPackageJson(pkgJsonPath: string, workspaceRoot: string): {
|
8
|
+
export declare function createNodeFromPackageJson(pkgJsonPath: string, workspaceRoot: string, cache: PackageJsonConfigurationCache): {
|
8
9
|
projects: {
|
9
|
-
[x: string]: ProjectConfiguration
|
10
|
-
name: string;
|
11
|
-
};
|
10
|
+
[x: string]: ProjectConfiguration;
|
12
11
|
};
|
13
12
|
};
|
14
13
|
export declare function buildProjectConfigurationFromPackageJson(packageJson: PackageJson, workspaceRoot: string, packageJsonPath: string, nxJson: NxJsonConfiguration): ProjectConfiguration & {
|
@@ -18,6 +18,8 @@ const package_json_1 = require("../../utils/package-json");
|
|
18
18
|
const path_1 = require("../../utils/path");
|
19
19
|
const plugins_1 = require("../../project-graph/plugins");
|
20
20
|
const path_2 = require("path");
|
21
|
+
const file_hasher_1 = require("../../hasher/file-hasher");
|
22
|
+
const package_json_2 = require("../../../plugins/package-json");
|
21
23
|
exports.createNodesV2 = [
|
22
24
|
(0, globs_1.combineGlobPatterns)('package.json', '**/package.json', 'project.json', '**/project.json'),
|
23
25
|
(configFiles, _, context) => {
|
@@ -27,13 +29,14 @@ exports.createNodesV2 = [
|
|
27
29
|
const isNextToProjectJson = (packageJsonPath) => {
|
28
30
|
return projectJsonRoots.has((0, node_path_1.dirname)(packageJsonPath));
|
29
31
|
};
|
32
|
+
const cache = (0, package_json_2.readPackageJsonConfigurationCache)();
|
30
33
|
return (0, plugins_1.createNodesFromFiles)((packageJsonPath, options, context) => {
|
31
34
|
if (!isInPackageJsonWorkspaces(packageJsonPath) &&
|
32
35
|
!isNextToProjectJson(packageJsonPath)) {
|
33
36
|
// Skip if package.json is not part of the package.json workspaces and not next to a project.json.
|
34
37
|
return null;
|
35
38
|
}
|
36
|
-
return createNodeFromPackageJson(packageJsonPath, context.workspaceRoot);
|
39
|
+
return createNodeFromPackageJson(packageJsonPath, context.workspaceRoot, cache);
|
37
40
|
}, packageJsons, _, context);
|
38
41
|
},
|
39
42
|
];
|
@@ -75,9 +78,23 @@ function buildPackageJsonWorkspacesMatcher(workspaceRoot, readJson) {
|
|
75
78
|
*/
|
76
79
|
negativePatterns.every((negative) => (0, minimatch_1.minimatch)(p, negative));
|
77
80
|
}
|
78
|
-
function createNodeFromPackageJson(pkgJsonPath, workspaceRoot) {
|
81
|
+
function createNodeFromPackageJson(pkgJsonPath, workspaceRoot, cache) {
|
79
82
|
const json = (0, fileutils_1.readJsonFile)((0, node_path_1.join)(workspaceRoot, pkgJsonPath));
|
83
|
+
const projectRoot = (0, node_path_1.dirname)(pkgJsonPath);
|
84
|
+
const hash = (0, file_hasher_1.hashObject)({
|
85
|
+
...json,
|
86
|
+
root: projectRoot,
|
87
|
+
});
|
88
|
+
const cached = cache[hash];
|
89
|
+
if (cached) {
|
90
|
+
return {
|
91
|
+
projects: {
|
92
|
+
[cached.root]: cached,
|
93
|
+
},
|
94
|
+
};
|
95
|
+
}
|
80
96
|
const project = buildProjectConfigurationFromPackageJson(json, workspaceRoot, pkgJsonPath, (0, nx_json_1.readNxJson)(workspaceRoot));
|
97
|
+
cache[hash] = project;
|
81
98
|
return {
|
82
99
|
projects: {
|
83
100
|
[project.root]: project,
|
@@ -17,7 +17,10 @@ async function filterAffected(graph, touchedFiles, nxJson = (0, configuration_1.
|
|
17
17
|
];
|
18
18
|
const touchedProjects = [];
|
19
19
|
for (const locator of touchedProjectLocators) {
|
20
|
+
performance.mark(locator.name + ':start');
|
20
21
|
const projects = await locator(touchedFiles, graph.nodes, nxJson, packageJson, graph);
|
22
|
+
performance.mark(locator.name + ':end');
|
23
|
+
performance.measure(locator.name, locator.name + ':start', locator.name + ':end');
|
21
24
|
touchedProjects.push(...projects);
|
22
25
|
}
|
23
26
|
return filterAffectedProjects(graph, {
|
@@ -6,11 +6,23 @@ const workspace_root_1 = require("../../../utils/workspace-root");
|
|
6
6
|
const path_1 = require("path");
|
7
7
|
const fs_1 = require("fs");
|
8
8
|
const retrieve_workspace_files_1 = require("../../utils/retrieve-workspace-files");
|
9
|
-
const internal_api_1 = require("../../plugins/internal-api");
|
10
9
|
const globs_1 = require("../../../utils/globs");
|
11
|
-
const
|
12
|
-
|
13
|
-
const globPattern =
|
10
|
+
const get_plugins_1 = require("../../plugins/get-plugins");
|
11
|
+
const getTouchedProjectsFromProjectGlobChanges = async (touchedFiles, projectGraphNodes) => {
|
12
|
+
const globPattern = await (async () => {
|
13
|
+
// TODO: We need a quicker way to get patterns that should not
|
14
|
+
// require starting up plugin workers
|
15
|
+
if (process.env.NX_FORCE_REUSE_CACHED_GRAPH === 'true') {
|
16
|
+
return (0, globs_1.combineGlobPatterns)([
|
17
|
+
'**/package.json',
|
18
|
+
'**/project.json',
|
19
|
+
'project.json',
|
20
|
+
'package.json',
|
21
|
+
]);
|
22
|
+
}
|
23
|
+
const plugins = await (0, get_plugins_1.getPlugins)();
|
24
|
+
return (0, globs_1.combineGlobPatterns)((0, retrieve_workspace_files_1.configurationGlobs)(plugins));
|
25
|
+
})();
|
14
26
|
const touchedProjects = new Set();
|
15
27
|
for (const touchedFile of touchedFiles) {
|
16
28
|
const isProjectFile = (0, minimatch_1.minimatch)(touchedFile.file, globPattern, {
|
@@ -12,6 +12,7 @@ export declare function getFileMap(): {
|
|
12
12
|
allWorkspaceFiles: FileData[];
|
13
13
|
rustReferences: NxWorkspaceFilesExternals | null;
|
14
14
|
};
|
15
|
+
export declare function hydrateFileMap(fileMap: FileMap, allWorkspaceFiles: FileData[], rustReferences: NxWorkspaceFilesExternals): void;
|
15
16
|
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<{
|
16
17
|
projectGraph: ProjectGraph;
|
17
18
|
projectFileMapCache: FileMapCache;
|
@@ -1,6 +1,7 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
3
|
exports.getFileMap = getFileMap;
|
4
|
+
exports.hydrateFileMap = hydrateFileMap;
|
4
5
|
exports.buildProjectGraphUsingProjectFileMap = buildProjectGraphUsingProjectFileMap;
|
5
6
|
exports.applyProjectMetadata = applyProjectMetadata;
|
6
7
|
const workspace_root_1 = require("../utils/workspace-root");
|
@@ -41,6 +42,11 @@ function getFileMap() {
|
|
41
42
|
};
|
42
43
|
}
|
43
44
|
}
|
45
|
+
function hydrateFileMap(fileMap, allWorkspaceFiles, rustReferences) {
|
46
|
+
storedFileMap = fileMap;
|
47
|
+
storedAllWorkspaceFiles = allWorkspaceFiles;
|
48
|
+
storedRustReferences = rustReferences;
|
49
|
+
}
|
44
50
|
async function buildProjectGraphUsingProjectFileMap(projectRootMap, externalNodes, fileMap, allWorkspaceFiles, rustReferences, fileMapCache, plugins, sourceMap) {
|
45
51
|
storedFileMap = fileMap;
|
46
52
|
storedAllWorkspaceFiles = allWorkspaceFiles;
|
@@ -121,7 +127,6 @@ function readCombinedDeps() {
|
|
121
127
|
};
|
122
128
|
}
|
123
129
|
async function buildProjectGraphUsingContext(knownExternalNodes, ctx, cachedFileData, projectGraphVersion, plugins, sourceMap) {
|
124
|
-
perf_hooks_1.performance.mark('build project graph:start');
|
125
130
|
const builder = new project_graph_builder_1.ProjectGraphBuilder(null, ctx.fileMap.projectFileMap);
|
126
131
|
builder.setVersion(projectGraphVersion);
|
127
132
|
for (const node in knownExternalNodes) {
|
@@ -160,8 +165,6 @@ async function buildProjectGraphUsingContext(knownExternalNodes, ctx, cachedFile
|
|
160
165
|
}
|
161
166
|
(0, implicit_project_dependencies_1.applyImplicitDependencies)(ctx.projects, updatedBuilder);
|
162
167
|
const finalGraph = updatedBuilder.getUpdatedProjectGraph();
|
163
|
-
perf_hooks_1.performance.mark('build project graph:end');
|
164
|
-
perf_hooks_1.performance.measure('build project graph', 'build project graph:start', 'build project graph:end');
|
165
168
|
if (!error) {
|
166
169
|
return finalGraph;
|
167
170
|
}
|
@@ -220,6 +223,7 @@ async function updateProjectGraphWithPlugins(context, initProjectGraph, plugins,
|
|
220
223
|
}
|
221
224
|
const builder = new project_graph_builder_1.ProjectGraphBuilder(graph, context.fileMap.projectFileMap, context.fileMap.nonProjectFiles);
|
222
225
|
const createDependencyPlugins = plugins.filter((plugin) => (0, utils_1.isNxPluginV2)(plugin) && plugin.createDependencies);
|
226
|
+
perf_hooks_1.performance.mark('createDependencies:start');
|
223
227
|
await Promise.all(createDependencyPlugins.map(async (plugin) => {
|
224
228
|
perf_hooks_1.performance.mark(`${plugin.name}:createDependencies - start`);
|
225
229
|
try {
|
@@ -238,6 +242,8 @@ async function updateProjectGraphWithPlugins(context, initProjectGraph, plugins,
|
|
238
242
|
perf_hooks_1.performance.mark(`${plugin.name}:createDependencies - end`);
|
239
243
|
perf_hooks_1.performance.measure(`${plugin.name}:createDependencies`, `${plugin.name}:createDependencies - start`, `${plugin.name}:createDependencies - end`);
|
240
244
|
}));
|
245
|
+
perf_hooks_1.performance.mark('createDependencies:end');
|
246
|
+
perf_hooks_1.performance.measure(`createDependencies`, `createDependencies:start`, `createDependencies:end`);
|
241
247
|
const graphWithDeps = builder.getUpdatedProjectGraph();
|
242
248
|
const { errors: metadataErrors, graph: updatedGraph } = await applyProjectMetadata(graphWithDeps, plugins, {
|
243
249
|
nxJsonConfiguration: context.nxJsonConfiguration,
|
@@ -263,6 +269,7 @@ function readRootTsConfig() {
|
|
263
269
|
async function applyProjectMetadata(graph, plugins, context, sourceMap) {
|
264
270
|
const results = [];
|
265
271
|
const errors = [];
|
272
|
+
perf_hooks_1.performance.mark('createMetadata:start');
|
266
273
|
const promises = plugins.map(async (plugin) => {
|
267
274
|
if ((0, utils_1.isNxPluginV2)(plugin) && plugin.createMetadata) {
|
268
275
|
perf_hooks_1.performance.mark(`${plugin.name}:createMetadata - start`);
|
@@ -288,5 +295,7 @@ async function applyProjectMetadata(graph, plugins, context, sourceMap) {
|
|
288
295
|
}
|
289
296
|
}
|
290
297
|
}
|
298
|
+
perf_hooks_1.performance.mark('createMetadata:end');
|
299
|
+
perf_hooks_1.performance.measure(`createMetadata`, `createMetadata:start`, `createMetadata:end`);
|
291
300
|
return { errors, graph };
|
292
301
|
}
|
@@ -1,7 +1,7 @@
|
|
1
1
|
import { ConfigurationResult, ConfigurationSourceMaps } from './utils/project-configuration-utils';
|
2
2
|
import { ProjectConfiguration } from '../config/workspace-json-project-json';
|
3
3
|
import { ProjectGraph } from '../config/project-graph';
|
4
|
-
import { CreateNodesFunctionV2 } from './plugins';
|
4
|
+
import { CreateNodesFunctionV2 } from './plugins/public-api';
|
5
5
|
export declare class ProjectGraphError extends Error {
|
6
6
|
#private;
|
7
7
|
constructor(errors: Array<AggregateCreateNodesError | MergeNodesError | ProjectsWithNoNameError | MultipleProjectsWithSameNameError | ProcessDependenciesError | ProcessProjectGraphError | CreateMetadataError | WorkspaceValidityError>, partialProjectGraph: ProjectGraph, partialSourceMaps: ConfigurationSourceMaps);
|
@@ -1,10 +1,11 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
3
|
exports.getPlugins = getPlugins;
|
4
|
+
exports.getOnlyDefaultPlugins = getOnlyDefaultPlugins;
|
4
5
|
exports.cleanupPlugins = cleanupPlugins;
|
5
6
|
const file_hasher_1 = require("../../hasher/file-hasher");
|
6
7
|
const nx_json_1 = require("../../config/nx-json");
|
7
|
-
const internal_api_1 = require("
|
8
|
+
const internal_api_1 = require("./internal-api");
|
8
9
|
const workspace_root_1 = require("../../utils/workspace-root");
|
9
10
|
let currentPluginsConfigurationHash;
|
10
11
|
let loadedPlugins;
|
@@ -27,6 +28,23 @@ async function getPlugins() {
|
|
27
28
|
loadedPlugins = result;
|
28
29
|
return result;
|
29
30
|
}
|
31
|
+
let loadedDefaultPlugins;
|
32
|
+
let cleanupDefaultPlugins;
|
33
|
+
async function getOnlyDefaultPlugins() {
|
34
|
+
// If the plugins configuration has not changed, reuse the current plugins
|
35
|
+
if (loadedDefaultPlugins) {
|
36
|
+
return loadedPlugins;
|
37
|
+
}
|
38
|
+
// Cleanup current plugins before loading new ones
|
39
|
+
if (cleanupDefaultPlugins) {
|
40
|
+
cleanupDefaultPlugins();
|
41
|
+
}
|
42
|
+
const [result, cleanupFn] = await (0, internal_api_1.loadNxPlugins)([], workspace_root_1.workspaceRoot);
|
43
|
+
cleanupDefaultPlugins = cleanupFn;
|
44
|
+
loadedPlugins = result;
|
45
|
+
return result;
|
46
|
+
}
|
30
47
|
function cleanupPlugins() {
|
31
48
|
cleanup();
|
49
|
+
cleanupDefaultPlugins();
|
32
50
|
}
|
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.createNodesFromFiles = exports.registerPluginTSTranspiler = exports.readPluginPackageJson = void 0;
|
4
4
|
const tslib_1 = require("tslib");
|
5
5
|
tslib_1.__exportStar(require("./public-api"), exports);
|
6
|
+
// export * from './get-plugins';
|
6
7
|
var loader_1 = require("./loader");
|
7
8
|
Object.defineProperty(exports, "readPluginPackageJson", { enumerable: true, get: function () { return loader_1.readPluginPackageJson; } });
|
8
9
|
Object.defineProperty(exports, "registerPluginTSTranspiler", { enumerable: true, get: function () { return loader_1.registerPluginTSTranspiler; } });
|
@@ -21,5 +21,9 @@ export type CreateNodesResultWithContext = CreateNodesResult & {
|
|
21
21
|
pluginName: string;
|
22
22
|
};
|
23
23
|
export type NormalizedPlugin = NxPluginV2 & Pick<NxPluginV1, 'processProjectGraph'>;
|
24
|
+
/**
|
25
|
+
* Use `getPlugins` instead.
|
26
|
+
* @deprecated Do not use this. Use `getPlugins` instead.
|
27
|
+
*/
|
24
28
|
export declare function loadNxPlugins(plugins: PluginConfiguration[], root?: string): Promise<readonly [LoadedNxPlugin[], () => void]>;
|
25
29
|
export declare function getDefaultPlugins(root: string): Promise<string[]>;
|
@@ -81,21 +81,28 @@ function isIsolationEnabled() {
|
|
81
81
|
// Default value
|
82
82
|
return true;
|
83
83
|
}
|
84
|
+
/**
|
85
|
+
* Use `getPlugins` instead.
|
86
|
+
* @deprecated Do not use this. Use `getPlugins` instead.
|
87
|
+
*/
|
84
88
|
async function loadNxPlugins(plugins, root = workspace_root_1.workspaceRoot) {
|
85
89
|
performance.mark('loadNxPlugins:start');
|
86
90
|
const loadingMethod = isIsolationEnabled()
|
87
91
|
? isolation_1.loadNxPluginInIsolation
|
88
92
|
: loader_1.loadNxPlugin;
|
89
93
|
plugins = await normalizePlugins(plugins, root);
|
90
|
-
const result = new Array(plugins?.length);
|
91
94
|
const cleanupFunctions = [];
|
92
|
-
await Promise.all(plugins.map(async (plugin, idx) => {
|
93
|
-
const [loadedPluginPromise, cleanup] = await loadingMethod(plugin, root);
|
94
|
-
result[idx] = loadedPluginPromise;
|
95
|
-
cleanupFunctions.push(cleanup);
|
96
|
-
}));
|
97
95
|
const ret = [
|
98
|
-
await Promise.all(
|
96
|
+
await Promise.all(plugins.map(async (plugin) => {
|
97
|
+
const pluginPath = typeof plugin === 'string' ? plugin : plugin.plugin;
|
98
|
+
performance.mark(`Load Nx Plugin: ${pluginPath} - start`);
|
99
|
+
const [loadedPluginPromise, cleanup] = await loadingMethod(plugin, root);
|
100
|
+
cleanupFunctions.push(cleanup);
|
101
|
+
const res = await loadedPluginPromise;
|
102
|
+
performance.mark(`Load Nx Plugin: ${pluginPath} - end`);
|
103
|
+
performance.measure(`Load Nx Plugin: ${pluginPath}`, `Load Nx Plugin: ${pluginPath} - start`, `Load Nx Plugin: ${pluginPath} - end`);
|
104
|
+
return res;
|
105
|
+
})),
|
99
106
|
() => {
|
100
107
|
for (const fn of cleanupFunctions) {
|
101
108
|
fn();
|
@@ -4,11 +4,5 @@ exports.loadNxPluginInIsolation = loadNxPluginInIsolation;
|
|
4
4
|
const workspace_root_1 = require("../../../utils/workspace-root");
|
5
5
|
const plugin_pool_1 = require("./plugin-pool");
|
6
6
|
async function loadNxPluginInIsolation(plugin, root = workspace_root_1.workspaceRoot) {
|
7
|
-
|
8
|
-
return [
|
9
|
-
loadingPlugin,
|
10
|
-
() => {
|
11
|
-
cleanup();
|
12
|
-
},
|
13
|
-
];
|
7
|
+
return (0, plugin_pool_1.loadRemoteNxPlugin)(plugin, root);
|
14
8
|
}
|
@@ -1,7 +1,6 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
3
|
const messaging_1 = require("./messaging");
|
4
|
-
const loader_1 = require("../loader");
|
5
4
|
const serializable_error_1 = require("../../../utils/serializable-error");
|
6
5
|
const consume_messages_from_socket_1 = require("../../../utils/consume-messages-from-socket");
|
7
6
|
const net_1 = require("net");
|
@@ -34,7 +33,8 @@ const server = (0, net_1.createServer)((socket) => {
|
|
34
33
|
clearTimeout(loadTimeout);
|
35
34
|
process.chdir(root);
|
36
35
|
try {
|
37
|
-
const
|
36
|
+
const { loadNxPlugin } = await Promise.resolve().then(() => require('../loader'));
|
37
|
+
const [promise] = loadNxPlugin(pluginConfiguration, root);
|
38
38
|
plugin = await promise;
|
39
39
|
return {
|
40
40
|
type: 'load-result',
|
@@ -1,6 +1,6 @@
|
|
1
1
|
import { ProjectConfiguration } from '../../config/workspace-json-project-json';
|
2
2
|
import { PackageJson } from '../../utils/package-json';
|
3
|
-
import { PluginConfiguration } from '../../config/nx-json';
|
3
|
+
import type { PluginConfiguration } from '../../config/nx-json';
|
4
4
|
import { LoadedNxPlugin } from './internal-api';
|
5
5
|
export declare function readPluginPackageJson(pluginName: string, projects: Record<string, ProjectConfiguration>, paths?: string[]): {
|
6
6
|
path: string;
|
@@ -196,12 +196,9 @@ async function loadNxPluginAsync(pluginConfiguration, paths, root) {
|
|
196
196
|
projectsWithoutInference ??=
|
197
197
|
await (0, retrieve_workspace_files_1.retrieveProjectConfigurationsWithoutPluginInference)(root);
|
198
198
|
}
|
199
|
-
|
200
|
-
let { pluginPath, name } = await getPluginPathAndName(moduleName, paths, projectsWithoutInference, root);
|
199
|
+
const { pluginPath, name } = getPluginPathAndName(moduleName, paths, projectsWithoutInference, root);
|
201
200
|
const plugin = (0, utils_1.normalizeNxPlugin)(await importPluginModule(pluginPath));
|
202
201
|
plugin.name ??= name;
|
203
|
-
performance.mark(`Load Nx Plugin: ${moduleName} - end`);
|
204
|
-
performance.measure(`Load Nx Plugin: ${moduleName}`, `Load Nx Plugin: ${moduleName} - start`, `Load Nx Plugin: ${moduleName} - end`);
|
205
202
|
return new internal_api_1.LoadedNxPlugin(plugin, pluginConfiguration);
|
206
203
|
}
|
207
204
|
catch (e) {
|
@@ -18,8 +18,9 @@ const workspace_root_1 = require("../utils/workspace-root");
|
|
18
18
|
const build_project_graph_1 = require("./build-project-graph");
|
19
19
|
const error_types_1 = require("./error-types");
|
20
20
|
const nx_deps_cache_1 = require("./nx-deps-cache");
|
21
|
-
const internal_api_1 = require("./plugins/internal-api");
|
22
21
|
const retrieve_workspace_files_1 = require("./utils/retrieve-workspace-files");
|
22
|
+
const get_plugins_1 = require("./plugins/get-plugins");
|
23
|
+
const logger_1 = require("../utils/logger");
|
23
24
|
/**
|
24
25
|
* Synchronously reads the latest cached copy of the workspace's ProjectGraph.
|
25
26
|
* @throws {Error} if there is no cached ProjectGraph to read from
|
@@ -75,7 +76,7 @@ async function buildProjectGraphAndSourceMapsWithoutDaemon() {
|
|
75
76
|
perf_hooks_1.performance.mark('retrieve-project-configurations:start');
|
76
77
|
let configurationResult;
|
77
78
|
let projectConfigurationsError;
|
78
|
-
const
|
79
|
+
const plugins = await (0, get_plugins_1.getPlugins)();
|
79
80
|
try {
|
80
81
|
configurationResult = await (0, retrieve_workspace_files_1.retrieveProjectConfigurations)(plugins, workspace_root_1.workspaceRoot, nxJson);
|
81
82
|
}
|
@@ -112,15 +113,6 @@ async function buildProjectGraphAndSourceMapsWithoutDaemon() {
|
|
112
113
|
throw e;
|
113
114
|
}
|
114
115
|
}
|
115
|
-
finally {
|
116
|
-
// When plugins are isolated we don't clean them up during
|
117
|
-
// a single run of the CLI. They are cleaned up when the CLI
|
118
|
-
// process exits. Cleaning them here could cause issues if pending
|
119
|
-
// promises are not resolved.
|
120
|
-
if (process.env.NX_ISOLATE_PLUGINS !== 'true') {
|
121
|
-
cleanup();
|
122
|
-
}
|
123
|
-
}
|
124
116
|
const { projectGraph, projectFileMapCache } = projectGraphResult;
|
125
117
|
perf_hooks_1.performance.mark('build-project-graph-using-project-file-map:end');
|
126
118
|
delete global.NX_GRAPH_CREATION;
|
@@ -195,6 +187,22 @@ async function createProjectGraphAsync(opts = {
|
|
195
187
|
exitOnError: false,
|
196
188
|
resetDaemonClient: false,
|
197
189
|
}) {
|
190
|
+
if (process.env.NX_FORCE_REUSE_CACHED_GRAPH === 'true') {
|
191
|
+
try {
|
192
|
+
const graph = readCachedProjectGraph();
|
193
|
+
const projectRootMap = Object.fromEntries(Object.entries(graph.nodes).map(([project, { data }]) => [
|
194
|
+
data.root,
|
195
|
+
project,
|
196
|
+
]));
|
197
|
+
const { allWorkspaceFiles, fileMap, rustReferences } = await (0, retrieve_workspace_files_1.retrieveWorkspaceFiles)(workspace_root_1.workspaceRoot, projectRootMap);
|
198
|
+
(0, build_project_graph_1.hydrateFileMap)(fileMap, allWorkspaceFiles, rustReferences);
|
199
|
+
return graph;
|
200
|
+
// If no cached graph is found, we will fall through to the normal flow
|
201
|
+
}
|
202
|
+
catch (e) {
|
203
|
+
logger_1.logger.verbose('Unable to use cached project graph', e);
|
204
|
+
}
|
205
|
+
}
|
198
206
|
const projectGraphAndSourceMaps = await createProjectGraphAndSourceMapsAsync(opts);
|
199
207
|
return projectGraphAndSourceMaps.projectGraph;
|
200
208
|
}
|
@@ -21,10 +21,6 @@ export declare function retrieveWorkspaceFiles(workspaceRoot: string, projectRoo
|
|
21
21
|
*/
|
22
22
|
export declare function retrieveProjectConfigurations(plugins: LoadedNxPlugin[], workspaceRoot: string, nxJson: NxJsonConfiguration): Promise<ConfigurationResult>;
|
23
23
|
export declare function retrieveProjectConfigurationsWithAngularProjects(workspaceRoot: string, nxJson: NxJsonConfiguration): Promise<ConfigurationResult>;
|
24
|
-
export declare function retrieveProjectConfigurationPaths(root: string, plugins: Array<
|
25
|
-
createNodes?: readonly [string, ...unknown[]];
|
26
|
-
} & unknown>): Promise<string[]>;
|
24
|
+
export declare function retrieveProjectConfigurationPaths(root: string, plugins: Array<LoadedNxPlugin>): Promise<string[]>;
|
27
25
|
export declare function retrieveProjectConfigurationsWithoutPluginInference(root: string): Promise<Record<string, ProjectConfiguration>>;
|
28
|
-
export declare function configurationGlobs(plugins: Array<
|
29
|
-
createNodes?: readonly [string, ...unknown[]];
|
30
|
-
}>): string[];
|
26
|
+
export declare function configurationGlobs(plugins: Array<LoadedNxPlugin>): string[];
|
@@ -10,10 +10,10 @@ const perf_hooks_1 = require("perf_hooks");
|
|
10
10
|
const angular_json_1 = require("../../adapter/angular-json");
|
11
11
|
const nx_json_1 = require("../../config/nx-json");
|
12
12
|
const project_configuration_utils_1 = require("./project-configuration-utils");
|
13
|
-
const internal_api_1 = require("../plugins/internal-api");
|
14
13
|
const workspace_context_1 = require("../../utils/workspace-context");
|
15
14
|
const build_all_workspace_files_1 = require("./build-all-workspace-files");
|
16
15
|
const path_1 = require("path");
|
16
|
+
const get_plugins_1 = require("../plugins/get-plugins");
|
17
17
|
/**
|
18
18
|
* Walks the workspace directory to create the `projectFileMap`, `ProjectConfigurations` and `allWorkspaceFiles`
|
19
19
|
* @throws
|
@@ -52,9 +52,8 @@ async function retrieveProjectConfigurationsWithAngularProjects(workspaceRoot, n
|
|
52
52
|
(typeof p === 'object' && p.plugin === angular_json_1.NX_ANGULAR_JSON_PLUGIN_NAME))) {
|
53
53
|
pluginsToLoad.push((0, path_1.join)(__dirname, '../../adapter/angular-json'));
|
54
54
|
}
|
55
|
-
const
|
55
|
+
const plugins = await (0, get_plugins_1.getPlugins)();
|
56
56
|
const res = await retrieveProjectConfigurations(plugins, workspaceRoot, nxJson);
|
57
|
-
cleanup();
|
58
57
|
return res;
|
59
58
|
}
|
60
59
|
function retrieveProjectConfigurationPaths(root, plugins) {
|
@@ -65,7 +64,7 @@ const projectsWithoutPluginCache = new Map();
|
|
65
64
|
// TODO: This function is called way too often, it should be optimized without this cache
|
66
65
|
async function retrieveProjectConfigurationsWithoutPluginInference(root) {
|
67
66
|
const nxJson = (0, nx_json_1.readNxJson)(root);
|
68
|
-
const
|
67
|
+
const plugins = await (0, get_plugins_1.getOnlyDefaultPlugins)(); // only load default plugins
|
69
68
|
const projectGlobPatterns = await retrieveProjectConfigurationPaths(root, plugins);
|
70
69
|
const cacheKey = root + ',' + projectGlobPatterns.join(',');
|
71
70
|
if (projectsWithoutPluginCache.has(cacheKey)) {
|
@@ -74,7 +73,6 @@ async function retrieveProjectConfigurationsWithoutPluginInference(root) {
|
|
74
73
|
const projectFiles = (await (0, workspace_context_1.globWithWorkspaceContext)(root, projectGlobPatterns)) ?? [];
|
75
74
|
const { projects } = await (0, project_configuration_utils_1.createProjectConfigurations)(root, nxJson, projectFiles, plugins);
|
76
75
|
projectsWithoutPluginCache.set(cacheKey, projects);
|
77
|
-
cleanup();
|
78
76
|
return projects;
|
79
77
|
}
|
80
78
|
function configurationGlobs(plugins) {
|
@@ -18,7 +18,7 @@ class RemoteCacheV2 {
|
|
18
18
|
(0, promises_1.readFile)((0, path_1.join)(cacheDirectory, hash, 'code'), 'utf-8').then((s) => +s),
|
19
19
|
]);
|
20
20
|
return {
|
21
|
-
outputsPath: cacheDirectory,
|
21
|
+
outputsPath: (0, path_1.join)(cacheDirectory, hash, 'outputs'),
|
22
22
|
terminalOutput: terminalOutput ?? oldTerminalOutput,
|
23
23
|
code,
|
24
24
|
};
|
@@ -27,8 +27,26 @@ class RemoteCacheV2 {
|
|
27
27
|
return null;
|
28
28
|
}
|
29
29
|
},
|
30
|
-
store: async (hash, cacheDirectory,
|
30
|
+
store: async (hash, cacheDirectory, terminalOutput, code) => {
|
31
|
+
// The new db cache places the outputs directly into the cacheDirectory + hash.
|
32
|
+
// old instances of Nx Cloud expect these outputs to be in cacheDirectory + hash + outputs
|
33
|
+
// this ensures that everything that was in the cache directory is moved to the outputs directory
|
34
|
+
const cacheDir = (0, path_1.join)(cacheDirectory, hash);
|
35
|
+
const outputDir = (0, path_1.join)(cacheDir, 'outputs');
|
36
|
+
await (0, promises_1.mkdir)(outputDir, { recursive: true });
|
37
|
+
const files = await (0, promises_1.readdir)(cacheDir);
|
38
|
+
await Promise.all(files.map(async (file) => {
|
39
|
+
const filePath = (0, path_1.join)(cacheDir, file);
|
40
|
+
// we don't want to move these files to the outputs directory because they are not artifacts of the task
|
41
|
+
if (filePath === outputDir ||
|
42
|
+
file === 'code' ||
|
43
|
+
file === 'terminalOutput') {
|
44
|
+
return;
|
45
|
+
}
|
46
|
+
await (0, promises_1.rename)(filePath, (0, path_1.join)(outputDir, file));
|
47
|
+
}));
|
31
48
|
await (0, promises_1.writeFile)((0, path_1.join)(cacheDirectory, hash, 'code'), code.toString());
|
49
|
+
await (0, promises_1.writeFile)((0, path_1.join)(cacheDirectory, hash, 'terminalOutput'), terminalOutput);
|
32
50
|
return cache.store(hash, cacheDirectory);
|
33
51
|
},
|
34
52
|
};
|