nx 20.1.0-beta.1 → 20.1.0-beta.2
Sign up to get free protection for your applications and to get access to all the features.
- package/bin/nx.js +8 -0
- package/package.json +11 -11
- package/src/command-line/login/login.js +3 -0
- package/src/command-line/logout/logout.js +3 -0
- package/src/daemon/server/shutdown-utils.js +2 -0
- package/src/native/index.d.ts +2 -0
- package/src/native/native-bindings.js +1 -0
- package/src/native/nx.wasm32-wasi.wasm +0 -0
- package/src/tasks-runner/create-task-graph.d.ts +13 -16
- package/src/tasks-runner/create-task-graph.js +43 -47
- package/src/tasks-runner/task-graph-utils.d.ts +11 -0
- package/src/tasks-runner/task-graph-utils.js +23 -0
- package/src/utils/db-connection.d.ts +1 -0
- package/src/utils/db-connection.js +7 -0
package/bin/nx.js
CHANGED
@@ -16,6 +16,7 @@ const assert_supported_platform_1 = require("../src/native/assert-supported-plat
|
|
16
16
|
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
|
+
const db_connection_1 = require("../src/utils/db-connection");
|
19
20
|
function main() {
|
20
21
|
if (process.argv[2] !== 'report' &&
|
21
22
|
process.argv[2] !== '--version' &&
|
@@ -213,4 +214,11 @@ const getLatestVersionOfNx = ((fn) => {
|
|
213
214
|
let cache = null;
|
214
215
|
return () => cache || (cache = fn());
|
215
216
|
})(_getLatestVersionOfNx);
|
217
|
+
function nxCleanup() {
|
218
|
+
(0, db_connection_1.removeDbConnections)();
|
219
|
+
}
|
220
|
+
process.on('exit', nxCleanup);
|
221
|
+
process.on('SIGINT', nxCleanup);
|
222
|
+
process.on('SIGTERM', nxCleanup);
|
223
|
+
process.on('SIGHUP', nxCleanup);
|
216
224
|
main();
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "nx",
|
3
|
-
"version": "20.1.0-beta.
|
3
|
+
"version": "20.1.0-beta.2",
|
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": {
|
@@ -80,16 +80,16 @@
|
|
80
80
|
}
|
81
81
|
},
|
82
82
|
"optionalDependencies": {
|
83
|
-
"@nx/nx-darwin-x64": "20.1.0-beta.
|
84
|
-
"@nx/nx-darwin-arm64": "20.1.0-beta.
|
85
|
-
"@nx/nx-linux-x64-gnu": "20.1.0-beta.
|
86
|
-
"@nx/nx-linux-x64-musl": "20.1.0-beta.
|
87
|
-
"@nx/nx-win32-x64-msvc": "20.1.0-beta.
|
88
|
-
"@nx/nx-linux-arm64-gnu": "20.1.0-beta.
|
89
|
-
"@nx/nx-linux-arm64-musl": "20.1.0-beta.
|
90
|
-
"@nx/nx-linux-arm-gnueabihf": "20.1.0-beta.
|
91
|
-
"@nx/nx-win32-arm64-msvc": "20.1.0-beta.
|
92
|
-
"@nx/nx-freebsd-x64": "20.1.0-beta.
|
83
|
+
"@nx/nx-darwin-x64": "20.1.0-beta.2",
|
84
|
+
"@nx/nx-darwin-arm64": "20.1.0-beta.2",
|
85
|
+
"@nx/nx-linux-x64-gnu": "20.1.0-beta.2",
|
86
|
+
"@nx/nx-linux-x64-musl": "20.1.0-beta.2",
|
87
|
+
"@nx/nx-win32-x64-msvc": "20.1.0-beta.2",
|
88
|
+
"@nx/nx-linux-arm64-gnu": "20.1.0-beta.2",
|
89
|
+
"@nx/nx-linux-arm64-musl": "20.1.0-beta.2",
|
90
|
+
"@nx/nx-linux-arm-gnueabihf": "20.1.0-beta.2",
|
91
|
+
"@nx/nx-win32-arm64-msvc": "20.1.0-beta.2",
|
92
|
+
"@nx/nx-freebsd-x64": "20.1.0-beta.2"
|
93
93
|
},
|
94
94
|
"nx-migrations": {
|
95
95
|
"migrations": "./migrations.json",
|
@@ -4,6 +4,7 @@ exports.loginHandler = loginHandler;
|
|
4
4
|
const update_manager_1 = require("../../nx-cloud/update-manager");
|
5
5
|
const get_cloud_options_1 = require("../../nx-cloud/utilities/get-cloud-options");
|
6
6
|
const handle_errors_1 = require("../../utils/handle-errors");
|
7
|
+
const resolution_helpers_1 = require("../../nx-cloud/resolution-helpers");
|
7
8
|
function loginHandler(args) {
|
8
9
|
if (args.nxCloudUrl) {
|
9
10
|
process.env.NX_CLOUD_API = args.nxCloudUrl;
|
@@ -11,6 +12,8 @@ function loginHandler(args) {
|
|
11
12
|
return (0, handle_errors_1.handleErrors)(args.verbose, async () => {
|
12
13
|
const nxCloudClient = (await (0, update_manager_1.verifyOrUpdateNxCloudClient)((0, get_cloud_options_1.getCloudOptions)()))
|
13
14
|
.nxCloudClient;
|
15
|
+
const paths = (0, resolution_helpers_1.findAncestorNodeModules)(__dirname, []);
|
16
|
+
nxCloudClient.configureLightClientRequire()(paths);
|
14
17
|
await nxCloudClient.commands.login();
|
15
18
|
});
|
16
19
|
}
|
@@ -4,10 +4,13 @@ exports.logoutHandler = logoutHandler;
|
|
4
4
|
const update_manager_1 = require("../../nx-cloud/update-manager");
|
5
5
|
const get_cloud_options_1 = require("../../nx-cloud/utilities/get-cloud-options");
|
6
6
|
const handle_errors_1 = require("../../utils/handle-errors");
|
7
|
+
const resolution_helpers_1 = require("../../nx-cloud/resolution-helpers");
|
7
8
|
function logoutHandler(args) {
|
8
9
|
return (0, handle_errors_1.handleErrors)(args.verbose, async () => {
|
9
10
|
const nxCloudClient = (await (0, update_manager_1.verifyOrUpdateNxCloudClient)((0, get_cloud_options_1.getCloudOptions)()))
|
10
11
|
.nxCloudClient;
|
12
|
+
const paths = (0, resolution_helpers_1.findAncestorNodeModules)(__dirname, []);
|
13
|
+
nxCloudClient.configureLightClientRequire()(paths);
|
11
14
|
await nxCloudClient.commands.logout();
|
12
15
|
});
|
13
16
|
}
|
@@ -15,6 +15,7 @@ const socket_utils_1 = require("../socket-utils");
|
|
15
15
|
const cache_1 = require("../cache");
|
16
16
|
const plugins_1 = require("./plugins");
|
17
17
|
const error_types_1 = require("../../project-graph/error-types");
|
18
|
+
const db_connection_1 = require("../../utils/db-connection");
|
18
19
|
exports.SERVER_INACTIVITY_TIMEOUT_MS = 10800000; // 10800000 ms = 3 hours
|
19
20
|
let watcherInstance;
|
20
21
|
function storeWatcherInstance(instance) {
|
@@ -50,6 +51,7 @@ async function handleServerProcessTermination({ server, reason, sockets, }) {
|
|
50
51
|
}
|
51
52
|
(0, cache_1.deleteDaemonJsonProcessCache)();
|
52
53
|
(0, plugins_1.cleanupPlugins)();
|
54
|
+
(0, db_connection_1.removeDbConnections)();
|
53
55
|
logger_1.serverLogger.log(`Server stopped because: "${reason}"`);
|
54
56
|
}
|
55
57
|
finally {
|
package/src/native/index.d.ts
CHANGED
@@ -97,6 +97,8 @@ export interface CachedResult {
|
|
97
97
|
outputsPath: string
|
98
98
|
}
|
99
99
|
|
100
|
+
export declare export function closeDbConnection(connection: ExternalObject<NxDbConnection>): void
|
101
|
+
|
100
102
|
export declare export function connectToNxDb(cacheDir: string, nxVersion: string, dbName?: string | undefined | null): ExternalObject<NxDbConnection>
|
101
103
|
|
102
104
|
export declare export function copy(src: string, dest: string): void
|
@@ -371,6 +371,7 @@ module.exports.TaskDetails = nativeBinding.TaskDetails
|
|
371
371
|
module.exports.TaskHasher = nativeBinding.TaskHasher
|
372
372
|
module.exports.Watcher = nativeBinding.Watcher
|
373
373
|
module.exports.WorkspaceContext = nativeBinding.WorkspaceContext
|
374
|
+
module.exports.closeDbConnection = nativeBinding.closeDbConnection
|
374
375
|
module.exports.connectToNxDb = nativeBinding.connectToNxDb
|
375
376
|
module.exports.copy = nativeBinding.copy
|
376
377
|
module.exports.EventType = nativeBinding.EventType
|
Binary file
|
@@ -22,22 +22,19 @@ export declare class ProcessTasks {
|
|
22
22
|
createTask(id: string, project: ProjectGraphProjectNode, target: string, resolvedConfiguration: string | undefined, overrides: Object): Task;
|
23
23
|
resolveConfiguration(project: ProjectGraphProjectNode, target: string, configuration: string | undefined): string;
|
24
24
|
getId(project: string, target: string, configuration: string | undefined): string;
|
25
|
-
/**
|
26
|
-
* this function is used to get the non dummy dependencies of a task recursively
|
27
|
-
* For example, when we have the following dependencies:
|
28
|
-
* {
|
29
|
-
* 'app1:compile': [ 'app2:__nx_dummy_task__' ],
|
30
|
-
* 'app2:__nx_dummy_task__': [ 'app3:__nx_dummy_task__' ],
|
31
|
-
* 'app3:__nx_dummy_task__': [ 'app4:precompile' ],
|
32
|
-
* 'app4:precompile': []
|
33
|
-
* }
|
34
|
-
* getNonDummyDeps('app1:compile') will return ['app1:compile']
|
35
|
-
* getNonDummyDeps('app2:__nx_dummy_task__') will return ['app4:precompile']
|
36
|
-
* getNonDummyDeps('app3:__nx_dummy_task__') will return ['app4:precompile']
|
37
|
-
* getNonDummyDeps('app4:precompile') will return ['app4:precompile']
|
38
|
-
*/
|
39
|
-
private getNonDummyDeps;
|
40
|
-
private filterDummyTasks;
|
41
25
|
}
|
42
26
|
export declare function createTaskGraph(projectGraph: ProjectGraph, extraTargetDependencies: TargetDependencies, projectNames: string[], targets: string[], configuration: string | undefined, overrides: Object, excludeTaskDependencies?: boolean): TaskGraph;
|
43
27
|
export declare function mapTargetDefaultsToDependencies(defaults: TargetDefaults | undefined): TargetDependencies;
|
28
|
+
/**
|
29
|
+
* This function is used to filter out the dummy tasks from the dependencies
|
30
|
+
* It will manipulate the dependencies object in place
|
31
|
+
*/
|
32
|
+
export declare function filterDummyTasks(dependencies: {
|
33
|
+
[k: string]: string[];
|
34
|
+
}): void;
|
35
|
+
/**
|
36
|
+
* this function is used to get the non dummy dependencies of a task recursively
|
37
|
+
*/
|
38
|
+
export declare function getNonDummyDeps(currentTask: string, dependencies: {
|
39
|
+
[k: string]: string[];
|
40
|
+
}, cycles?: Set<string>, seen?: Set<string>): string[];
|
@@ -3,6 +3,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.ProcessTasks = void 0;
|
4
4
|
exports.createTaskGraph = createTaskGraph;
|
5
5
|
exports.mapTargetDefaultsToDependencies = mapTargetDefaultsToDependencies;
|
6
|
+
exports.filterDummyTasks = filterDummyTasks;
|
7
|
+
exports.getNonDummyDeps = getNonDummyDeps;
|
6
8
|
const utils_1 = require("./utils");
|
7
9
|
const project_graph_utils_1 = require("../utils/project-graph-utils");
|
8
10
|
const output_1 = require("../utils/output");
|
@@ -54,7 +56,7 @@ class ProcessTasks {
|
|
54
56
|
this.dependencies[d] = this.dependencies[d].filter((dd) => !!initialTasks[dd]);
|
55
57
|
}
|
56
58
|
}
|
57
|
-
this.
|
59
|
+
filterDummyTasks(this.dependencies);
|
58
60
|
for (const taskId of Object.keys(this.dependencies)) {
|
59
61
|
if (this.dependencies[taskId].length > 0) {
|
60
62
|
this.dependencies[taskId] = [
|
@@ -189,52 +191,6 @@ class ProcessTasks {
|
|
189
191
|
}
|
190
192
|
return id;
|
191
193
|
}
|
192
|
-
/**
|
193
|
-
* this function is used to get the non dummy dependencies of a task recursively
|
194
|
-
* For example, when we have the following dependencies:
|
195
|
-
* {
|
196
|
-
* 'app1:compile': [ 'app2:__nx_dummy_task__' ],
|
197
|
-
* 'app2:__nx_dummy_task__': [ 'app3:__nx_dummy_task__' ],
|
198
|
-
* 'app3:__nx_dummy_task__': [ 'app4:precompile' ],
|
199
|
-
* 'app4:precompile': []
|
200
|
-
* }
|
201
|
-
* getNonDummyDeps('app1:compile') will return ['app1:compile']
|
202
|
-
* getNonDummyDeps('app2:__nx_dummy_task__') will return ['app4:precompile']
|
203
|
-
* getNonDummyDeps('app3:__nx_dummy_task__') will return ['app4:precompile']
|
204
|
-
* getNonDummyDeps('app4:precompile') will return ['app4:precompile']
|
205
|
-
*/
|
206
|
-
getNonDummyDeps(currentTask, originalTask, cycle) {
|
207
|
-
if (currentTask === originalTask) {
|
208
|
-
return [];
|
209
|
-
}
|
210
|
-
else if (currentTask.endsWith(DUMMY_TASK_TARGET)) {
|
211
|
-
if (cycle?.length && cycle?.includes(currentTask)) {
|
212
|
-
return [];
|
213
|
-
}
|
214
|
-
// if not a cycle, recursively get the non dummy dependencies
|
215
|
-
return (this.dependencies[currentTask]?.flatMap((dep) => this.getNonDummyDeps(dep, originalTask, cycle)) ?? []);
|
216
|
-
}
|
217
|
-
else {
|
218
|
-
return [currentTask];
|
219
|
-
}
|
220
|
-
}
|
221
|
-
filterDummyTasks() {
|
222
|
-
const cycle = (0, task_graph_utils_1.findCycle)({ dependencies: this.dependencies });
|
223
|
-
for (const [key, deps] of Object.entries(this.dependencies)) {
|
224
|
-
if (!key.endsWith(DUMMY_TASK_TARGET)) {
|
225
|
-
const normalizedDeps = [];
|
226
|
-
for (const dep of deps) {
|
227
|
-
normalizedDeps.push(...this.getNonDummyDeps(dep, key, cycle));
|
228
|
-
}
|
229
|
-
this.dependencies[key] = normalizedDeps;
|
230
|
-
}
|
231
|
-
}
|
232
|
-
for (const key of Object.keys(this.dependencies)) {
|
233
|
-
if (key.endsWith(DUMMY_TASK_TARGET)) {
|
234
|
-
delete this.dependencies[key];
|
235
|
-
}
|
236
|
-
}
|
237
|
-
}
|
238
194
|
}
|
239
195
|
exports.ProcessTasks = ProcessTasks;
|
240
196
|
function createTaskGraph(projectGraph, extraTargetDependencies, projectNames, targets, configuration, overrides, excludeTaskDependencies = false) {
|
@@ -268,3 +224,43 @@ function interpolateOverrides(args, projectName, project) {
|
|
268
224
|
});
|
269
225
|
return interpolatedArgs;
|
270
226
|
}
|
227
|
+
/**
|
228
|
+
* This function is used to filter out the dummy tasks from the dependencies
|
229
|
+
* It will manipulate the dependencies object in place
|
230
|
+
*/
|
231
|
+
function filterDummyTasks(dependencies) {
|
232
|
+
const cycles = (0, task_graph_utils_1.findCycles)({ dependencies });
|
233
|
+
for (const [key, deps] of Object.entries(dependencies)) {
|
234
|
+
if (!key.endsWith(DUMMY_TASK_TARGET)) {
|
235
|
+
const normalizedDeps = [];
|
236
|
+
for (const dep of deps) {
|
237
|
+
normalizedDeps.push(...getNonDummyDeps(dep, dependencies, cycles, new Set([key])));
|
238
|
+
}
|
239
|
+
dependencies[key] = normalizedDeps;
|
240
|
+
}
|
241
|
+
}
|
242
|
+
for (const key of Object.keys(dependencies)) {
|
243
|
+
if (key.endsWith(DUMMY_TASK_TARGET)) {
|
244
|
+
delete dependencies[key];
|
245
|
+
}
|
246
|
+
}
|
247
|
+
}
|
248
|
+
/**
|
249
|
+
* this function is used to get the non dummy dependencies of a task recursively
|
250
|
+
*/
|
251
|
+
function getNonDummyDeps(currentTask, dependencies, cycles, seen = new Set()) {
|
252
|
+
if (seen.has(currentTask)) {
|
253
|
+
return [];
|
254
|
+
}
|
255
|
+
seen.add(currentTask);
|
256
|
+
if (currentTask.endsWith(DUMMY_TASK_TARGET)) {
|
257
|
+
if (cycles?.has(currentTask)) {
|
258
|
+
return [];
|
259
|
+
}
|
260
|
+
// if not a cycle, recursively get the non dummy dependencies
|
261
|
+
return (dependencies[currentTask]?.flatMap((dep) => getNonDummyDeps(dep, dependencies, cycles, seen)) ?? []);
|
262
|
+
}
|
263
|
+
else {
|
264
|
+
return [currentTask];
|
265
|
+
}
|
266
|
+
}
|
@@ -1,8 +1,19 @@
|
|
1
1
|
import { ProjectGraph } from '../config/project-graph';
|
2
2
|
import { TaskGraph } from '../config/task-graph';
|
3
|
+
/**
|
4
|
+
* This function finds a cycle in the graph.
|
5
|
+
* @returns the first cycle found, or null if no cycle is found.
|
6
|
+
*/
|
3
7
|
export declare function findCycle(graph: {
|
4
8
|
dependencies: Record<string, string[]>;
|
5
9
|
}): string[] | null;
|
10
|
+
/**
|
11
|
+
* This function finds all cycles in the graph.
|
12
|
+
* @returns a list of unique task ids in all cycles found, or null if no cycle is found.
|
13
|
+
*/
|
14
|
+
export declare function findCycles(graph: {
|
15
|
+
dependencies: Record<string, string[]>;
|
16
|
+
}): Set<string> | null;
|
6
17
|
export declare function makeAcyclic(graph: {
|
7
18
|
roots: string[];
|
8
19
|
dependencies: Record<string, string[]>;
|
@@ -1,6 +1,7 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
3
|
exports.findCycle = findCycle;
|
4
|
+
exports.findCycles = findCycles;
|
4
5
|
exports.makeAcyclic = makeAcyclic;
|
5
6
|
exports.validateNoAtomizedTasks = validateNoAtomizedTasks;
|
6
7
|
const output_1 = require("../utils/output");
|
@@ -17,6 +18,10 @@ function _findCycle(graph, id, visited, path) {
|
|
17
18
|
}
|
18
19
|
return null;
|
19
20
|
}
|
21
|
+
/**
|
22
|
+
* This function finds a cycle in the graph.
|
23
|
+
* @returns the first cycle found, or null if no cycle is found.
|
24
|
+
*/
|
20
25
|
function findCycle(graph) {
|
21
26
|
const visited = {};
|
22
27
|
for (const t of Object.keys(graph.dependencies)) {
|
@@ -29,6 +34,24 @@ function findCycle(graph) {
|
|
29
34
|
}
|
30
35
|
return null;
|
31
36
|
}
|
37
|
+
/**
|
38
|
+
* This function finds all cycles in the graph.
|
39
|
+
* @returns a list of unique task ids in all cycles found, or null if no cycle is found.
|
40
|
+
*/
|
41
|
+
function findCycles(graph) {
|
42
|
+
const visited = {};
|
43
|
+
const cycles = new Set();
|
44
|
+
for (const t of Object.keys(graph.dependencies)) {
|
45
|
+
visited[t] = false;
|
46
|
+
}
|
47
|
+
for (const t of Object.keys(graph.dependencies)) {
|
48
|
+
const cycle = _findCycle(graph, t, visited, [t]);
|
49
|
+
if (cycle) {
|
50
|
+
cycle.forEach((t) => cycles.add(t));
|
51
|
+
}
|
52
|
+
}
|
53
|
+
return cycles.size ? cycles : null;
|
54
|
+
}
|
32
55
|
function _makeAcyclic(graph, id, visited, path) {
|
33
56
|
if (visited[id])
|
34
57
|
return;
|
@@ -1,6 +1,7 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
3
|
exports.getDbConnection = getDbConnection;
|
4
|
+
exports.removeDbConnections = removeDbConnections;
|
4
5
|
const native_1 = require("../native");
|
5
6
|
const cache_directory_1 = require("./cache-directory");
|
6
7
|
const package_json_1 = require("../../package.json");
|
@@ -11,6 +12,12 @@ function getDbConnection(opts = {}) {
|
|
11
12
|
const connection = getEntryOrSet(dbConnectionMap, key, () => (0, native_1.connectToNxDb)(opts.directory, package_json_1.version, opts.dbName));
|
12
13
|
return connection;
|
13
14
|
}
|
15
|
+
function removeDbConnections() {
|
16
|
+
for (const connection of dbConnectionMap.values()) {
|
17
|
+
(0, native_1.closeDbConnection)(connection);
|
18
|
+
}
|
19
|
+
dbConnectionMap.clear();
|
20
|
+
}
|
14
21
|
function getEntryOrSet(map, key, defaultValue) {
|
15
22
|
const existing = map.get(key);
|
16
23
|
if (existing) {
|