@nrwl/workspace 12.10.0-beta.6 → 13.0.0-beta.3
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/index.d.ts +1 -1
- package/index.js +2 -3
- package/index.js.map +1 -1
- package/migrations.json +6 -0
- package/package.json +5 -5
- package/src/command-line/dep-graph.js +17 -21
- package/src/command-line/dep-graph.js.map +1 -1
- package/src/command-line/examples.js +38 -38
- package/src/command-line/examples.js.map +1 -1
- package/src/command-line/lint.js +5 -4
- package/src/command-line/lint.js.map +1 -1
- package/src/command-line/nx-commands.js +26 -3
- package/src/command-line/nx-commands.js.map +1 -1
- package/src/command-line/supported-nx-commands.js +1 -0
- package/src/command-line/supported-nx-commands.js.map +1 -1
- package/src/command-line/utils.js +1 -1
- package/src/command-line/utils.js.map +1 -1
- package/src/core/dep-graph/main.es5.js +1 -1
- package/src/core/dep-graph/main.esm.js +1 -1
- package/src/core/dep-graph/polyfills.es5.js +1 -1
- package/src/core/dep-graph/polyfills.esm.js +1 -1
- package/src/core/dep-graph/runtime.es5.js +1 -1
- package/src/core/dep-graph/runtime.esm.js +1 -1
- package/src/core/file-utils.d.ts +11 -4
- package/src/core/file-utils.js +103 -15
- package/src/core/file-utils.js.map +1 -1
- package/src/core/hasher/file-hasher.d.ts +1 -16
- package/src/core/hasher/file-hasher.js +4 -20
- package/src/core/hasher/file-hasher.js.map +1 -1
- package/src/core/nx-deps/nx-deps-cache.d.ts +6 -6
- package/src/core/nx-deps/nx-deps-cache.js +9 -5
- package/src/core/nx-deps/nx-deps-cache.js.map +1 -1
- package/src/core/project-graph/build-dependencies/build-explicit-typescript-and-package-json-dependencies.d.ts +2 -0
- package/src/core/project-graph/build-dependencies/build-explicit-typescript-and-package-json-dependencies.js +12 -0
- package/src/core/project-graph/build-dependencies/build-explicit-typescript-and-package-json-dependencies.js.map +1 -0
- package/src/core/project-graph/build-dependencies/explicit-package-json-dependencies.d.ts +3 -2
- package/src/core/project-graph/build-dependencies/explicit-package-json-dependencies.js +14 -8
- package/src/core/project-graph/build-dependencies/explicit-package-json-dependencies.js.map +1 -1
- package/src/core/project-graph/build-dependencies/explicit-project-dependencies.d.ts +3 -2
- package/src/core/project-graph/build-dependencies/explicit-project-dependencies.js +12 -6
- package/src/core/project-graph/build-dependencies/explicit-project-dependencies.js.map +1 -1
- package/src/core/project-graph/build-project-graph.d.ts +7 -0
- package/src/core/project-graph/build-project-graph.js +221 -0
- package/src/core/project-graph/build-project-graph.js.map +1 -0
- package/src/core/project-graph/daemon/cache.d.ts +5 -13
- package/src/core/project-graph/daemon/cache.js +39 -16
- package/src/core/project-graph/daemon/cache.js.map +1 -1
- package/src/core/project-graph/daemon/client/client.js +32 -55
- package/src/core/project-graph/daemon/client/client.js.map +1 -1
- package/src/core/project-graph/daemon/client/exec-is-server-available.d.ts +1 -0
- package/src/core/project-graph/daemon/client/exec-is-server-available.js +13 -0
- package/src/core/project-graph/daemon/client/exec-is-server-available.js.map +1 -0
- package/src/core/project-graph/daemon/client/generate-help-output.d.ts +1 -0
- package/src/core/project-graph/daemon/client/generate-help-output.js +28 -0
- package/src/core/project-graph/daemon/client/generate-help-output.js.map +1 -0
- package/src/core/project-graph/daemon/server/logger.d.ts +19 -0
- package/src/core/project-graph/daemon/server/logger.js +41 -0
- package/src/core/project-graph/daemon/server/logger.js.map +1 -0
- package/src/core/project-graph/daemon/server/server.d.ts +1 -5
- package/src/core/project-graph/daemon/server/server.js +160 -193
- package/src/core/project-graph/daemon/server/server.js.map +1 -1
- package/src/core/project-graph/daemon/server/shutdown-utils.d.ts +13 -0
- package/src/core/project-graph/daemon/server/shutdown-utils.js +28 -0
- package/src/core/project-graph/daemon/server/shutdown-utils.js.map +1 -0
- package/src/core/project-graph/daemon/server/start.js +1 -8
- package/src/core/project-graph/daemon/server/start.js.map +1 -1
- package/src/core/project-graph/daemon/server/stop.js +1 -11
- package/src/core/project-graph/daemon/server/stop.js.map +1 -1
- package/src/core/project-graph/daemon/server/watcher.d.ts +1 -1
- package/src/core/project-graph/daemon/server/watcher.js +1 -1
- package/src/core/project-graph/daemon/socket-utils.d.ts +13 -0
- package/src/core/project-graph/daemon/socket-utils.js +39 -10
- package/src/core/project-graph/daemon/socket-utils.js.map +1 -1
- package/src/core/project-graph/daemon/tmp-dir.d.ts +7 -0
- package/src/core/project-graph/daemon/tmp-dir.js +59 -0
- package/src/core/project-graph/daemon/tmp-dir.js.map +1 -0
- package/src/core/project-graph/index.d.ts +1 -1
- package/src/core/project-graph/index.js +1 -3
- package/src/core/project-graph/index.js.map +1 -1
- package/src/core/project-graph/operators.js +1 -1
- package/src/core/project-graph/operators.js.map +1 -1
- package/src/core/project-graph/project-graph-worker.d.ts +1 -0
- package/src/core/project-graph/project-graph-worker.js +17 -0
- package/src/core/project-graph/project-graph-worker.js.map +1 -0
- package/src/core/project-graph/project-graph.d.ts +1 -30
- package/src/core/project-graph/project-graph.js +5 -195
- package/src/core/project-graph/project-graph.js.map +1 -1
- package/src/generators/init/init.js +27 -27
- package/src/generators/init/init.js.map +1 -1
- package/src/generators/new/new.js +1 -1
- package/src/generators/new/new.js.map +1 -1
- package/src/migrations/update-10-0-0/update-10-0-0.js +1 -1
- package/src/migrations/update-10-0-0/update-10-0-0.js.map +1 -1
- package/src/migrations/update-13-0-0/set-default-base-if-not-set.d.ts +3 -0
- package/src/migrations/update-13-0-0/set-default-base-if-not-set.js +30 -0
- package/src/migrations/update-13-0-0/set-default-base-if-not-set.js.map +1 -0
- package/src/utilities/default-base.js +2 -2
- package/src/utilities/default-base.js.map +1 -1
- package/src/utilities/run-webpack.d.ts +3 -2
- package/src/utilities/run-webpack.js +18 -34
- package/src/utilities/run-webpack.js.map +1 -1
- package/src/utils/ast-utils.d.ts +1 -10
- package/src/utils/ast-utils.js +1 -19
- package/src/utils/ast-utils.js.map +1 -1
- package/src/utils/testing-utils.js +1 -1
- package/src/utils/testing-utils.js.map +1 -1
- package/src/utils/versions.js +1 -1
- package/src/core/file-graph/index.d.ts +0 -1
- package/src/core/file-graph/index.js +0 -5
- package/src/core/file-graph/index.js.map +0 -1
- package/src/core/file-graph/project-file-map.d.ts +0 -3
- package/src/core/file-graph/project-file-map.js +0 -35
- package/src/core/file-graph/project-file-map.js.map +0 -1
- package/src/utilities/create-project-graph-from-tree.d.ts +0 -5
- package/src/utilities/create-project-graph-from-tree.js +0 -13
- package/src/utilities/create-project-graph-from-tree.js.map +0 -1
|
@@ -1,8 +1,4 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
import { Server } from 'net';
|
|
3
|
-
|
|
4
|
-
serverLogOutputFile?: string;
|
|
5
|
-
}
|
|
6
|
-
export declare function startServer({ serverLogOutputFile, }: StartServerOptions): Promise<Server>;
|
|
3
|
+
export declare function startServer(): Promise<Server>;
|
|
7
4
|
export declare function stopServer(): Promise<void>;
|
|
8
|
-
export {};
|
|
@@ -4,250 +4,221 @@ exports.stopServer = exports.startServer = void 0;
|
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
const devkit_1 = require("@nrwl/devkit");
|
|
6
6
|
const app_root_1 = require("@nrwl/tao/src/utils/app-root");
|
|
7
|
-
const fs_1 = require("fs");
|
|
8
7
|
const net_1 = require("net");
|
|
8
|
+
const path_1 = require("path");
|
|
9
9
|
const perf_hooks_1 = require("perf_hooks");
|
|
10
|
+
const file_utils_1 = require("../../../file-utils");
|
|
10
11
|
const file_hasher_1 = require("../../../hasher/file-hasher");
|
|
11
12
|
const git_hasher_1 = require("../../../hasher/git-hasher");
|
|
12
|
-
const project_graph_1 = require("../../project-graph");
|
|
13
13
|
const socket_utils_1 = require("../socket-utils");
|
|
14
|
+
const logger_1 = require("./logger");
|
|
15
|
+
const shutdown_utils_1 = require("./shutdown-utils");
|
|
14
16
|
const watcher_1 = require("./watcher");
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
*
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
*
|
|
51
|
-
* We keep those two "triggers" left aligned at the top level and then indent subsequent logs so that there is a
|
|
52
|
-
* logical hierarchy/grouping.
|
|
53
|
-
*/
|
|
54
|
-
function requestLog(...s) {
|
|
55
|
-
serverLog(`[REQUEST]: ${s.join(' ')}`);
|
|
56
|
-
}
|
|
57
|
-
function watcherLog(...s) {
|
|
58
|
-
serverLog(`[WATCHER]: ${s.join(' ')}`);
|
|
59
|
-
}
|
|
60
|
-
function nestedLog(...s) {
|
|
61
|
-
serverLog(` ${s.join(' ')}`);
|
|
17
|
+
const build_project_graph_1 = require("../../build-project-graph");
|
|
18
|
+
const workspace_1 = require("@nrwl/tao/src/shared/workspace");
|
|
19
|
+
const nx_deps_cache_1 = require("../../../nx-deps/nx-deps-cache");
|
|
20
|
+
const configName = workspace_1.workspaceConfigName(app_root_1.appRootPath);
|
|
21
|
+
let cachedSerializedProjectGraphPromise;
|
|
22
|
+
let projectFileMapWithFiles;
|
|
23
|
+
let currentProjectGraphCache;
|
|
24
|
+
function createAndSerializeProjectGraph(updatedFiles, deletedFiles, shouldWriteCache) {
|
|
25
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
26
|
+
try {
|
|
27
|
+
perf_hooks_1.performance.mark('create-project-graph-start');
|
|
28
|
+
const workspaceJson = file_utils_1.readWorkspaceJson();
|
|
29
|
+
projectFileMapWithFiles = projectFileMapWithFiles
|
|
30
|
+
? file_utils_1.updateProjectFileMap(workspaceJson, projectFileMapWithFiles.projectFileMap, projectFileMapWithFiles.allWorkspaceFiles, updatedFiles, deletedFiles)
|
|
31
|
+
: file_utils_1.createProjectFileMap(workspaceJson);
|
|
32
|
+
const { projectGraph, projectGraphCache } = yield build_project_graph_1.buildProjectGraphUsingProjectFileMap(workspaceJson, projectFileMapWithFiles.projectFileMap, projectFileMapWithFiles.allWorkspaceFiles, currentProjectGraphCache || nx_deps_cache_1.readCache(), shouldWriteCache, '4.0');
|
|
33
|
+
currentProjectGraphCache = projectGraphCache;
|
|
34
|
+
perf_hooks_1.performance.mark('create-project-graph-end');
|
|
35
|
+
perf_hooks_1.performance.measure('total execution time for createProjectGraph()', 'create-project-graph-start', 'create-project-graph-end');
|
|
36
|
+
perf_hooks_1.performance.mark('json-stringify-start');
|
|
37
|
+
const serializedProjectGraph = JSON.stringify(projectGraph);
|
|
38
|
+
perf_hooks_1.performance.mark('json-stringify-end');
|
|
39
|
+
perf_hooks_1.performance.measure('serialize graph', 'json-stringify-start', 'json-stringify-end');
|
|
40
|
+
return {
|
|
41
|
+
error: null,
|
|
42
|
+
serializedProjectGraph,
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
catch (err) {
|
|
46
|
+
return {
|
|
47
|
+
error: err,
|
|
48
|
+
serializedProjectGraph: null,
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
});
|
|
62
52
|
}
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
* best case scenario we can skip all graph construction and serialization work entirely.
|
|
70
|
-
*/
|
|
71
|
-
let cachedSerializedProjectGraph;
|
|
72
|
-
function createAndSerializeProjectGraph() {
|
|
73
|
-
perf_hooks_1.performance.mark('create-project-graph-start');
|
|
74
|
-
const projectGraph = project_graph_1.createProjectGraph(undefined, undefined, undefined, '4.0');
|
|
75
|
-
perf_hooks_1.performance.mark('create-project-graph-end');
|
|
76
|
-
perf_hooks_1.performance.measure('total execution time for createProjectGraph()', 'create-project-graph-start', 'create-project-graph-end');
|
|
77
|
-
perf_hooks_1.performance.mark('json-stringify-start');
|
|
78
|
-
const serializedProjectGraph = JSON.stringify(projectGraph);
|
|
79
|
-
perf_hooks_1.performance.mark('json-stringify-end');
|
|
80
|
-
perf_hooks_1.performance.measure('serialize graph', 'json-stringify-start', 'json-stringify-end');
|
|
81
|
-
return serializedProjectGraph;
|
|
53
|
+
function respondToClient(socket, message) {
|
|
54
|
+
socket.write(message, () => {
|
|
55
|
+
// Close the connection once all data has been written so that the client knows when to read it.
|
|
56
|
+
socket.end();
|
|
57
|
+
logger_1.serverLogger.nestedLog(`Closed Connection to Client`);
|
|
58
|
+
});
|
|
82
59
|
}
|
|
83
|
-
/**
|
|
84
|
-
* File watcher subscription.
|
|
85
|
-
*/
|
|
86
60
|
let watcherSubscription;
|
|
87
|
-
/**
|
|
88
|
-
* We need to make sure that we instantiate the PerformanceObserver only once, otherwise
|
|
89
|
-
* we will end up with duplicate entries in the server logs.
|
|
90
|
-
*/
|
|
91
61
|
let performanceObserver;
|
|
92
62
|
const server = net_1.createServer((socket) => {
|
|
63
|
+
shutdown_utils_1.resetInactivityTimeout(handleInactivityTimeout);
|
|
93
64
|
if (!performanceObserver) {
|
|
94
65
|
performanceObserver = new perf_hooks_1.PerformanceObserver((list) => {
|
|
95
66
|
const entry = list.getEntries()[0];
|
|
96
|
-
|
|
97
|
-
nestedLog(`Time taken for '${entry.name}'`, `${entry.duration}ms`);
|
|
67
|
+
logger_1.serverLogger.nestedLog(`Time taken for '${entry.name}'`, `${entry.duration}ms`);
|
|
98
68
|
});
|
|
99
69
|
performanceObserver.observe({ entryTypes: ['measure'], buffered: false });
|
|
100
70
|
}
|
|
101
|
-
socket.on('data', (data) => {
|
|
102
|
-
|
|
103
|
-
* If anything other than the known project graph creation request payload is sent to
|
|
104
|
-
* the server, we throw an error.
|
|
105
|
-
*/
|
|
71
|
+
socket.on('data', (data) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
|
|
72
|
+
shutdown_utils_1.resetInactivityTimeout(handleInactivityTimeout);
|
|
106
73
|
const payload = data.toString();
|
|
107
74
|
if (payload !== 'REQUEST_PROJECT_GRAPH_PAYLOAD') {
|
|
108
75
|
throw new Error(`Unsupported payload sent to daemon server: ${payload}`);
|
|
109
76
|
}
|
|
110
77
|
perf_hooks_1.performance.mark('server-connection');
|
|
111
|
-
requestLog('Client Request for Project Graph Received');
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
/**
|
|
115
|
-
* Cached HEAD has changed, we must perform full file-hashing initialization work and
|
|
116
|
-
* recompute the project graph
|
|
117
|
-
*/
|
|
118
|
-
if (currentGitHead !== cachedGitHead) {
|
|
119
|
-
cachedSerializedProjectGraph = undefined;
|
|
120
|
-
nestedLog(`Cached HEAD does not match current (${currentGitHead}), performing full file hash init and recomputing project graph...`);
|
|
121
|
-
file_hasher_1.defaultFileHasher.init();
|
|
122
|
-
cachedGitHead = currentGitHead;
|
|
123
|
-
serializedProjectGraph = createAndSerializeProjectGraph();
|
|
78
|
+
logger_1.serverLogger.requestLog('Client Request for Project Graph Received');
|
|
79
|
+
if (!cachedSerializedProjectGraphPromise) {
|
|
80
|
+
cachedSerializedProjectGraphPromise = createAndSerializeProjectGraph(new Map(), [], true);
|
|
124
81
|
}
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
}
|
|
139
|
-
else {
|
|
140
|
-
// Update the file-hasher's knowledge of the untracked and uncommitted changes in order to recompute the project graph
|
|
141
|
-
file_hasher_1.defaultFileHasher.incrementalUpdate(git_hasher_1.getUntrackedAndUncommittedFileHashes(app_root_1.appRootPath));
|
|
142
|
-
nestedLog(`Unknown untracked/uncommitted file state, recomputing project graph...`);
|
|
143
|
-
serializedProjectGraph = createAndSerializeProjectGraph();
|
|
144
|
-
}
|
|
82
|
+
const result = yield cachedSerializedProjectGraphPromise;
|
|
83
|
+
if (result.error) {
|
|
84
|
+
cachedSerializedProjectGraphPromise = undefined;
|
|
85
|
+
logger_1.serverLogger.nestedLog(`Error when preparing serialized project graph: ${result.error.message}`);
|
|
86
|
+
respondToClient(socket, socket_utils_1.serializeResult(result.error, result.serializedProjectGraph));
|
|
87
|
+
return;
|
|
88
|
+
}
|
|
89
|
+
const serializedResult = socket_utils_1.serializeResult(result.error, result.serializedProjectGraph);
|
|
90
|
+
if (!serializedResult) {
|
|
91
|
+
cachedSerializedProjectGraphPromise = undefined;
|
|
92
|
+
logger_1.serverLogger.nestedLog(`Error when serializing project graph result`);
|
|
93
|
+
respondToClient(socket, socket_utils_1.serializeResult(new Error('Critical error when serializing server result, check server logs'), null));
|
|
94
|
+
return;
|
|
145
95
|
}
|
|
146
|
-
/**
|
|
147
|
-
* Cache the latest version of the project graph in memory so that we can potentially skip a lot
|
|
148
|
-
* of expensive work on the next client request.
|
|
149
|
-
*
|
|
150
|
-
* For reference, on the very large test repo https://github.com/vsavkin/interstellar the project
|
|
151
|
-
* graph nxdeps.json file is about 32MB, so memory utilization should not be a huge concern.
|
|
152
|
-
*/
|
|
153
|
-
cachedSerializedProjectGraph = serializedProjectGraph;
|
|
154
96
|
perf_hooks_1.performance.mark('serialized-project-graph-ready');
|
|
155
97
|
perf_hooks_1.performance.measure('total for creating and serializing project graph', 'server-connection', 'serialized-project-graph-ready');
|
|
156
|
-
socket.write(
|
|
98
|
+
socket.write(serializedResult, () => {
|
|
157
99
|
perf_hooks_1.performance.mark('serialized-project-graph-written-to-client');
|
|
158
100
|
perf_hooks_1.performance.measure('write project graph to socket', 'serialized-project-graph-ready', 'serialized-project-graph-written-to-client');
|
|
159
|
-
|
|
160
|
-
* Close the connection once all data has been written to the socket so that the client
|
|
161
|
-
* knows when to read it.
|
|
162
|
-
*/
|
|
101
|
+
// Close the connection once all data has been written so that the client knows when to read it.
|
|
163
102
|
socket.end();
|
|
164
103
|
perf_hooks_1.performance.measure('total for server response', 'server-connection', 'serialized-project-graph-written-to-client');
|
|
165
|
-
const bytesWritten = Buffer.byteLength(serializedProjectGraph, 'utf-8');
|
|
166
|
-
nestedLog(`Closed Connection to Client (${bytesWritten} bytes transferred)`);
|
|
104
|
+
const bytesWritten = Buffer.byteLength(result.serializedProjectGraph, 'utf-8');
|
|
105
|
+
logger_1.serverLogger.nestedLog(`Closed Connection to Client (${bytesWritten} bytes transferred)`);
|
|
167
106
|
});
|
|
168
|
-
});
|
|
107
|
+
}));
|
|
169
108
|
});
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
server.close();
|
|
176
|
-
/**
|
|
177
|
-
* Tear down any file watchers that may be running.
|
|
178
|
-
*/
|
|
179
|
-
if (watcherSubscription) {
|
|
180
|
-
yield watcherSubscription.unsubscribe();
|
|
181
|
-
watcherLog(`Unsubscribed from changes within: ${app_root_1.appRootPath}`);
|
|
182
|
-
}
|
|
183
|
-
serverLog('Server Stopped');
|
|
184
|
-
devkit_1.logger.info('NX Daemon Server - Stopped');
|
|
185
|
-
process.exit(0);
|
|
109
|
+
function handleInactivityTimeout() {
|
|
110
|
+
shutdown_utils_1.handleServerProcessTermination({
|
|
111
|
+
server,
|
|
112
|
+
watcherSubscription,
|
|
113
|
+
reason: `${shutdown_utils_1.SERVER_INACTIVITY_TIMEOUT_MS}ms of inactivity`,
|
|
186
114
|
});
|
|
187
115
|
}
|
|
188
116
|
process
|
|
189
|
-
.on('SIGINT', handleServerProcessTermination
|
|
190
|
-
|
|
191
|
-
|
|
117
|
+
.on('SIGINT', () => shutdown_utils_1.handleServerProcessTermination({
|
|
118
|
+
server,
|
|
119
|
+
watcherSubscription,
|
|
120
|
+
reason: 'received process SIGINT',
|
|
121
|
+
}))
|
|
122
|
+
.on('SIGTERM', () => shutdown_utils_1.handleServerProcessTermination({
|
|
123
|
+
server,
|
|
124
|
+
watcherSubscription,
|
|
125
|
+
reason: 'received process SIGTERM',
|
|
126
|
+
}))
|
|
127
|
+
.on('SIGHUP', () => shutdown_utils_1.handleServerProcessTermination({
|
|
128
|
+
server,
|
|
129
|
+
watcherSubscription,
|
|
130
|
+
reason: 'received process SIGHUP',
|
|
131
|
+
}));
|
|
132
|
+
function requireUncached(module) {
|
|
133
|
+
delete require.cache[require.resolve(module)];
|
|
134
|
+
return require(module);
|
|
135
|
+
}
|
|
136
|
+
/**
|
|
137
|
+
* We need to ensure that the server shuts down if the Nx installation changes.
|
|
138
|
+
*/
|
|
139
|
+
let cachedNxVersion = resolveCurrentNxVersion();
|
|
140
|
+
function resolveCurrentNxVersion() {
|
|
141
|
+
const nrwlWorkspacePackageJsonPath = devkit_1.normalizePath(path_1.join(app_root_1.appRootPath, 'node_modules/@nrwl/workspace/package.json'));
|
|
142
|
+
try {
|
|
143
|
+
const { version } = requireUncached(nrwlWorkspacePackageJsonPath);
|
|
144
|
+
return version;
|
|
145
|
+
}
|
|
146
|
+
catch (_a) {
|
|
147
|
+
logger_1.serverLogger.nestedLog(`Error: Could not determine the current Nx version by inspecting: ${nrwlWorkspacePackageJsonPath}`);
|
|
148
|
+
return null;
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
function isNxVersionSame(currentNxVersion) {
|
|
152
|
+
if (currentNxVersion === null) {
|
|
153
|
+
// Something has gone wrong with figuring out the Nx version, declare the version as having changed
|
|
154
|
+
return false;
|
|
155
|
+
}
|
|
156
|
+
return currentNxVersion === cachedNxVersion;
|
|
157
|
+
}
|
|
192
158
|
/**
|
|
193
159
|
* When applicable files in the workspaces are changed (created, updated, deleted),
|
|
194
160
|
* we need to recompute the cached serialized project graph so that it is readily
|
|
195
161
|
* available for the next client request to the server.
|
|
196
162
|
*/
|
|
197
|
-
const handleWorkspaceChanges = (err, changeEvents) => {
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
163
|
+
const handleWorkspaceChanges = (err, changeEvents) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
|
|
164
|
+
shutdown_utils_1.resetInactivityTimeout(handleInactivityTimeout);
|
|
165
|
+
if (!isNxVersionSame(resolveCurrentNxVersion())) {
|
|
166
|
+
yield shutdown_utils_1.handleServerProcessTermination({
|
|
167
|
+
server,
|
|
168
|
+
watcherSubscription,
|
|
169
|
+
reason: '@nrwl/workspace installation changed',
|
|
170
|
+
});
|
|
171
|
+
return;
|
|
172
|
+
}
|
|
203
173
|
if (err || !changeEvents || !changeEvents.length) {
|
|
204
|
-
watcherLog('Unexpected Error');
|
|
174
|
+
logger_1.serverLogger.watcherLog('Unexpected Error');
|
|
205
175
|
console.error(err);
|
|
206
176
|
return;
|
|
207
177
|
}
|
|
208
|
-
watcherLog(watcher_1.convertChangeEventsToLogMessage(changeEvents));
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
178
|
+
logger_1.serverLogger.watcherLog(watcher_1.convertChangeEventsToLogMessage(changeEvents));
|
|
179
|
+
cachedSerializedProjectGraphPromise = new Promise((res) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
|
|
180
|
+
try {
|
|
181
|
+
const filesToHash = [];
|
|
182
|
+
const deletedFiles = [];
|
|
183
|
+
for (const event of changeEvents) {
|
|
184
|
+
if (event.type === 'delete') {
|
|
185
|
+
deletedFiles.push(event.path);
|
|
186
|
+
}
|
|
187
|
+
else {
|
|
188
|
+
filesToHash.push(event.path);
|
|
189
|
+
}
|
|
219
190
|
}
|
|
220
|
-
|
|
221
|
-
|
|
191
|
+
perf_hooks_1.performance.mark('hash-watched-changes-start');
|
|
192
|
+
const updatedFiles = git_hasher_1.getGitHashForFiles(filesToHash, app_root_1.appRootPath);
|
|
193
|
+
perf_hooks_1.performance.mark('hash-watched-changes-end');
|
|
194
|
+
perf_hooks_1.performance.measure('hash changed files from watcher', 'hash-watched-changes-start', 'hash-watched-changes-end');
|
|
195
|
+
file_hasher_1.defaultFileHasher.incrementalUpdate(updatedFiles, deletedFiles);
|
|
196
|
+
logger_1.serverLogger.nestedLog(`Updated file-hasher based on watched changes, recomputing project graph...`);
|
|
197
|
+
// when workspace.json changes we cannot be sure about the correctness of the project file map
|
|
198
|
+
if (updatedFiles.has(configName) ||
|
|
199
|
+
deletedFiles.indexOf(configName) > -1) {
|
|
200
|
+
projectFileMapWithFiles = undefined;
|
|
222
201
|
}
|
|
202
|
+
res(yield createAndSerializeProjectGraph(updatedFiles, deletedFiles, true));
|
|
223
203
|
}
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
cachedSerializedProjectGraph = createAndSerializeProjectGraph();
|
|
232
|
-
}
|
|
233
|
-
catch (err) {
|
|
234
|
-
serverLog(`Unexpected Error`);
|
|
235
|
-
console.error(err);
|
|
236
|
-
}
|
|
237
|
-
};
|
|
238
|
-
function startServer({ serverLogOutputFile, }) {
|
|
204
|
+
catch (err) {
|
|
205
|
+
logger_1.serverLogger.log(`Unexpected Error`);
|
|
206
|
+
console.error(err);
|
|
207
|
+
}
|
|
208
|
+
}));
|
|
209
|
+
});
|
|
210
|
+
function startServer() {
|
|
239
211
|
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
240
|
-
|
|
241
|
-
// See notes above on OS differences regarding clean up of existings connections.
|
|
212
|
+
// See notes in socket-utils.ts on OS differences regarding clean up of existings connections.
|
|
242
213
|
if (!socket_utils_1.isWindows) {
|
|
243
214
|
socket_utils_1.killSocketOrPath();
|
|
244
215
|
}
|
|
245
216
|
return new Promise((resolve) => {
|
|
246
217
|
server.listen(socket_utils_1.FULL_OS_SOCKET_PATH, () => tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
247
|
-
|
|
218
|
+
logger_1.serverLogger.log(`Started listening on: ${socket_utils_1.FULL_OS_SOCKET_PATH}`);
|
|
248
219
|
if (!watcherSubscription) {
|
|
249
220
|
watcherSubscription = yield watcher_1.subscribeToWorkspaceChanges(handleWorkspaceChanges);
|
|
250
|
-
watcherLog(`Subscribed to changes within: ${app_root_1.appRootPath}`);
|
|
221
|
+
logger_1.serverLogger.watcherLog(`Subscribed to changes within: ${app_root_1.appRootPath}`);
|
|
251
222
|
}
|
|
252
223
|
return resolve(server);
|
|
253
224
|
}));
|
|
@@ -270,10 +241,6 @@ function stopServer() {
|
|
|
270
241
|
}
|
|
271
242
|
}
|
|
272
243
|
socket_utils_1.killSocketOrPath();
|
|
273
|
-
/**
|
|
274
|
-
* The distinction regarding background process or not is not relevant for stopping the server,
|
|
275
|
-
* always pretty print the message to stdout.
|
|
276
|
-
*/
|
|
277
244
|
devkit_1.logger.info('NX Daemon Server - Stopped');
|
|
278
245
|
return resolve();
|
|
279
246
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server.js","sourceRoot":"","sources":["../../../../../../../../packages/workspace/src/core/project-graph/daemon/server/server.ts"],"names":[],"mappings":";;;;AAAA,
|
|
1
|
+
{"version":3,"file":"server.js","sourceRoot":"","sources":["../../../../../../../../packages/workspace/src/core/project-graph/daemon/server/server.ts"],"names":[],"mappings":";;;;AAAA,yCAA+E;AAC/E,2DAA2D;AAC3D,6BAAmD;AACnD,+BAA4B;AAC5B,2CAA8D;AAC9D,oDAI6B;AAC7B,6DAAgE;AAChE,2DAAgE;AAChE,kDAKyB;AACzB,qCAAwC;AACxC,qDAI0B;AAC1B,uCAKmB;AACnB,mEAAiF;AACjF,8DAAqE;AAErE,kEAA2D;AAO3D,MAAM,UAAU,GAAG,+BAAmB,CAAC,sBAAW,CAAC,CAAC;AACpD,IAAI,mCAAuE,CAAC;AAC5E,IAAI,uBAES,CAAC;AACd,IAAI,wBAAuD,CAAC;AAE5D,SAAe,8BAA8B,CAC3C,YAAiC,EACjC,YAAsB,EACtB,gBAAyB;;QAEz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UAAU;;QAC9B,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;YACrC,MAAM,CAAC,KAAK,CAAC,CAAC,GAAG,EAAE,EAAE;gBACnB,IAAI,GAAG,EAAE;oBACP;;;;uBAIG;oBACH,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,UAAU,CAAC,uBAAuB,CAAC,EAAE;wBACpD,OAAO,MAAM,CAAC,GAAG,CAAC,CAAC;qBACpB;iBACF;gBAED,+BAAgB,EAAE,CAAC;gBACnB,eAAM,CAAC,IAAI,CAAC,4BAA4B,CAAC,CAAC;gBAC1C,OAAO,OAAO,EAAE,CAAC;YACnB,CAAC,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;IACL,CAAC;CAAA;AAnBD,gCAmBC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import type { Server } from 'net';
|
|
3
|
+
import type { WatcherSubscription } from './watcher';
|
|
4
|
+
export declare const SERVER_INACTIVITY_TIMEOUT_MS: 10800000;
|
|
5
|
+
declare type ServerTerminationReason = `received process ${NodeJS.Signals}` | '@nrwl/workspace installation changed' | `${typeof SERVER_INACTIVITY_TIMEOUT_MS}ms of inactivity`;
|
|
6
|
+
interface HandleServerProcessTerminationParams {
|
|
7
|
+
server: Server;
|
|
8
|
+
reason: ServerTerminationReason;
|
|
9
|
+
watcherSubscription: WatcherSubscription | undefined;
|
|
10
|
+
}
|
|
11
|
+
export declare function handleServerProcessTermination({ server, reason, watcherSubscription, }: HandleServerProcessTerminationParams): Promise<void>;
|
|
12
|
+
export declare function resetInactivityTimeout(cb: () => void): void;
|
|
13
|
+
export {};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.resetInactivityTimeout = exports.handleServerProcessTermination = exports.SERVER_INACTIVITY_TIMEOUT_MS = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const app_root_1 = require("@nrwl/tao/src/utils/app-root");
|
|
6
|
+
const logger_1 = require("./logger");
|
|
7
|
+
exports.SERVER_INACTIVITY_TIMEOUT_MS = 10800000; // 10800000 ms = 3 hours
|
|
8
|
+
function handleServerProcessTermination({ server, reason, watcherSubscription, }) {
|
|
9
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
10
|
+
server.close();
|
|
11
|
+
if (watcherSubscription) {
|
|
12
|
+
yield watcherSubscription.unsubscribe();
|
|
13
|
+
logger_1.serverLogger.watcherLog(`Unsubscribed from changes within: ${app_root_1.appRootPath}`);
|
|
14
|
+
}
|
|
15
|
+
logger_1.serverLogger.log(`Server stopped because: "${reason}"`);
|
|
16
|
+
process.exit(0);
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
exports.handleServerProcessTermination = handleServerProcessTermination;
|
|
20
|
+
let serverInactivityTimerId;
|
|
21
|
+
function resetInactivityTimeout(cb) {
|
|
22
|
+
if (serverInactivityTimerId) {
|
|
23
|
+
clearTimeout(serverInactivityTimerId);
|
|
24
|
+
}
|
|
25
|
+
serverInactivityTimerId = setTimeout(cb, exports.SERVER_INACTIVITY_TIMEOUT_MS);
|
|
26
|
+
}
|
|
27
|
+
exports.resetInactivityTimeout = resetInactivityTimeout;
|
|
28
|
+
//# sourceMappingURL=shutdown-utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"shutdown-utils.js","sourceRoot":"","sources":["../../../../../../../../packages/workspace/src/core/project-graph/daemon/server/shutdown-utils.ts"],"names":[],"mappings":";;;;AAAA,2DAA2D;AAE3D,qCAAwC;AAG3B,QAAA,4BAA4B,GAAG,QAAiB,CAAC,CAAC,wBAAwB;AAavF,SAAsB,8BAA8B,CAAC,EACnD,MAAM,EACN,MAAM,EACN,mBAAmB,GACkB;;QACrC,MAAM,CAAC,KAAK,EAAE,CAAC;QACf,IAAI,mBAAmB,EAAE;YACvB,MAAM,mBAAmB,CAAC,WAAW,EAAE,CAAC;YACxC,qBAAY,CAAC,UAAU,CAAC,qCAAqC,sBAAW,EAAE,CAAC,CAAC;SAC7E;QACD,qBAAY,CAAC,GAAG,CAAC,4BAA4B,MAAM,GAAG,CAAC,CAAC;QACxD,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC;CAAA;AAZD,wEAYC;AAED,IAAI,uBAAmD,CAAC;AAExD,SAAgB,sBAAsB,CAAC,EAAc;IACnD,IAAI,uBAAuB,EAAE;QAC3B,YAAY,CAAC,uBAAuB,CAAC,CAAC;KACvC;IACD,uBAAuB,GAAG,UAAU,CAAC,EAAE,EAAE,oCAA4B,CAAC,CAAC;AACzE,CAAC;AALD,wDAKC"}
|
|
@@ -1,18 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const tslib_1 = require("tslib");
|
|
4
|
-
/**
|
|
5
|
-
* NOTE: This file is intended to be executed as a script by utilities found in ./index.ts
|
|
6
|
-
*/
|
|
7
4
|
const devkit_1 = require("@nrwl/devkit");
|
|
8
5
|
const server_1 = require("./server");
|
|
9
|
-
const serverLogOutputFile = process.argv[2];
|
|
10
6
|
(() => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
|
|
11
7
|
try {
|
|
12
|
-
|
|
13
|
-
devkit_1.logger.info('NOTE: Running Daemon Server in current process, all logs are shown inline below:\n');
|
|
14
|
-
}
|
|
15
|
-
yield server_1.startServer({ serverLogOutputFile });
|
|
8
|
+
yield server_1.startServer();
|
|
16
9
|
}
|
|
17
10
|
catch (err) {
|
|
18
11
|
devkit_1.logger.error(err);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"start.js","sourceRoot":"","sources":["../../../../../../../../packages/workspace/src/core/project-graph/daemon/server/start.ts"],"names":[],"mappings":";;;AAAA
|
|
1
|
+
{"version":3,"file":"start.js","sourceRoot":"","sources":["../../../../../../../../packages/workspace/src/core/project-graph/daemon/server/start.ts"],"names":[],"mappings":";;;AAAA,yCAAsC;AACtC,qCAAuC;AAEvC,CAAC,GAAS,EAAE;IACV,IAAI;QACF,MAAM,oBAAW,EAAE,CAAC;KACrB;IAAC,OAAO,GAAG,EAAE;QACZ,eAAM,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;KACnB;AACH,CAAC,CAAA,CAAC,EAAE,CAAC"}
|
|
@@ -1,23 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const tslib_1 = require("tslib");
|
|
4
|
-
/**
|
|
5
|
-
* NOTE: This file is intended to be executed as a script by utilities found in ./index.ts
|
|
6
|
-
*/
|
|
7
4
|
const devkit_1 = require("@nrwl/devkit");
|
|
8
5
|
const cache_1 = require("../cache");
|
|
9
6
|
const server_1 = require("./server");
|
|
10
7
|
(() => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
|
|
11
8
|
try {
|
|
12
9
|
yield server_1.stopServer();
|
|
13
|
-
|
|
14
|
-
const cachedDaemonJson = yield cache_1.readDaemonJsonCache();
|
|
15
|
-
if (cachedDaemonJson) {
|
|
16
|
-
if (cachedDaemonJson.backgroundProcessId) {
|
|
17
|
-
process.kill(cachedDaemonJson.backgroundProcessId);
|
|
18
|
-
}
|
|
19
|
-
cache_1.deleteDaemonJsonCache();
|
|
20
|
-
}
|
|
10
|
+
yield cache_1.safelyCleanUpExistingProcess();
|
|
21
11
|
}
|
|
22
12
|
catch (err) {
|
|
23
13
|
devkit_1.logger.error(err);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"stop.js","sourceRoot":"","sources":["../../../../../../../../packages/workspace/src/core/project-graph/daemon/server/stop.ts"],"names":[],"mappings":";;;AAAA
|
|
1
|
+
{"version":3,"file":"stop.js","sourceRoot":"","sources":["../../../../../../../../packages/workspace/src/core/project-graph/daemon/server/stop.ts"],"names":[],"mappings":";;;AAAA,yCAAsC;AACtC,oCAAwD;AACxD,qCAAsC;AAEtC,CAAC,GAAS,EAAE;IACV,IAAI;QACF,MAAM,mBAAU,EAAE,CAAC;QACnB,MAAM,oCAA4B,EAAE,CAAC;KACtC;IAAC,OAAO,GAAG,EAAE;QACZ,eAAM,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;KACnB;AACH,CAAC,CAAA,CAAC,EAAE,CAAC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { AsyncSubscription, Event } from '@parcel/watcher';
|
|
2
2
|
export declare type WatcherSubscription = AsyncSubscription;
|
|
3
|
-
export declare type SubscribeToWorkspaceChangesCallback = (err: Error | null, changeEvents: Event[] | null) => void
|
|
3
|
+
export declare type SubscribeToWorkspaceChangesCallback = (err: Error | null, changeEvents: Event[] | null) => Promise<void>;
|
|
4
4
|
export declare function subscribeToWorkspaceChanges(cb: SubscribeToWorkspaceChangesCallback): Promise<AsyncSubscription>;
|
|
5
5
|
/**
|
|
6
6
|
* NOTE: An event type of "create" will also apply to the case where the user has restored
|
|
@@ -18,7 +18,7 @@ const socket_utils_1 = require("../socket-utils");
|
|
|
18
18
|
/**
|
|
19
19
|
* This configures the files and directories which we always want to ignore as part of file watching
|
|
20
20
|
* and which we know the location of statically (meaning irrespective of user configuration files).
|
|
21
|
-
* This has the advantage of being ignored directly within the C++ layer of `@parcel/
|
|
21
|
+
* This has the advantage of being ignored directly within the C++ layer of `@parcel/watcher` so there
|
|
22
22
|
* is less pressure on the main JavaScript thread.
|
|
23
23
|
*
|
|
24
24
|
* Other ignored entries will need to be determined dynamically by reading and evaluating the user's
|
|
@@ -1,3 +1,16 @@
|
|
|
1
|
+
import type { ProjectGraph } from '@nrwl/devkit';
|
|
1
2
|
export declare const isWindows: boolean;
|
|
3
|
+
/**
|
|
4
|
+
* For IPC with the daemon server we use unix sockets or windows named pipes, depending on the user's operating system.
|
|
5
|
+
*
|
|
6
|
+
* See https://nodejs.org/dist/latest-v14.x/docs/api/net.html#net_identifying_paths_for_ipc_connections for a full breakdown
|
|
7
|
+
* of OS differences between Unix domain sockets and named pipes.
|
|
8
|
+
*/
|
|
2
9
|
export declare const FULL_OS_SOCKET_PATH: string;
|
|
3
10
|
export declare function killSocketOrPath(): void;
|
|
11
|
+
export interface ProjectGraphServerResult {
|
|
12
|
+
error: Error | null;
|
|
13
|
+
projectGraph: ProjectGraph | null;
|
|
14
|
+
}
|
|
15
|
+
export declare function serializeResult(error: Error | null, serializedProjectGraph: string | null): string | null;
|
|
16
|
+
export declare function deserializeResult(serializedResult: string): ProjectGraphServerResult;
|