@nrwl/workspace 12.10.0 → 13.0.0-beta.4
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 +31 -57
- 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/project-graph-incremental-recomputation.d.ts +6 -0
- package/src/core/project-graph/daemon/server/project-graph-incremental-recomputation.js +119 -0
- package/src/core/project-graph/daemon/server/project-graph-incremental-recomputation.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 +97 -184
- 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/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
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export declare function getCachedSerializedProjectGraphPromise(): Promise<{
|
|
2
|
+
error: Error;
|
|
3
|
+
serializedProjectGraph: string;
|
|
4
|
+
}>;
|
|
5
|
+
export declare function addUpdatedAndDeletedFiles(updatedFiles: string[], deletedFiles: string[]): void;
|
|
6
|
+
export declare function resetAfterError(): void;
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.resetAfterError = exports.addUpdatedAndDeletedFiles = exports.getCachedSerializedProjectGraphPromise = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const app_root_1 = require("@nrwl/tao/src/utils/app-root");
|
|
6
|
+
const perf_hooks_1 = require("perf_hooks");
|
|
7
|
+
const file_utils_1 = require("../../../file-utils");
|
|
8
|
+
const file_hasher_1 = require("../../../hasher/file-hasher");
|
|
9
|
+
const git_hasher_1 = require("../../../hasher/git-hasher");
|
|
10
|
+
const logger_1 = require("./logger");
|
|
11
|
+
const build_project_graph_1 = require("../../build-project-graph");
|
|
12
|
+
const workspace_1 = require("@nrwl/tao/src/shared/workspace");
|
|
13
|
+
const nx_deps_cache_1 = require("../../../nx-deps/nx-deps-cache");
|
|
14
|
+
const configName = workspace_1.workspaceConfigName(app_root_1.appRootPath);
|
|
15
|
+
let cachedSerializedProjectGraphPromise;
|
|
16
|
+
let projectFileMapWithFiles;
|
|
17
|
+
let currentProjectGraphCache;
|
|
18
|
+
const collectedUpdatedFiles = new Set();
|
|
19
|
+
const collectedDeletedFiles = new Set();
|
|
20
|
+
let waitPeriod = 100;
|
|
21
|
+
let scheduledTimeoutId;
|
|
22
|
+
function getCachedSerializedProjectGraphPromise() {
|
|
23
|
+
// recomputing it now on demand. we can ignore the scheduled timeout
|
|
24
|
+
if (scheduledTimeoutId) {
|
|
25
|
+
clearTimeout(scheduledTimeoutId);
|
|
26
|
+
}
|
|
27
|
+
// reset the wait time
|
|
28
|
+
waitPeriod = 100;
|
|
29
|
+
if (collectedUpdatedFiles.size == 0 && collectedDeletedFiles.size == 0) {
|
|
30
|
+
if (!cachedSerializedProjectGraphPromise) {
|
|
31
|
+
cachedSerializedProjectGraphPromise = createAndSerializeProjectGraph();
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
else {
|
|
35
|
+
processCollectedUpdatedAndDeletedFiles();
|
|
36
|
+
cachedSerializedProjectGraphPromise = createAndSerializeProjectGraph();
|
|
37
|
+
}
|
|
38
|
+
return cachedSerializedProjectGraphPromise;
|
|
39
|
+
}
|
|
40
|
+
exports.getCachedSerializedProjectGraphPromise = getCachedSerializedProjectGraphPromise;
|
|
41
|
+
function addUpdatedAndDeletedFiles(updatedFiles, deletedFiles) {
|
|
42
|
+
for (let f of updatedFiles) {
|
|
43
|
+
collectedDeletedFiles.delete(f);
|
|
44
|
+
collectedUpdatedFiles.add(f);
|
|
45
|
+
}
|
|
46
|
+
for (let f of deletedFiles) {
|
|
47
|
+
collectedUpdatedFiles.delete(f);
|
|
48
|
+
collectedDeletedFiles.add(f);
|
|
49
|
+
}
|
|
50
|
+
if (!scheduledTimeoutId) {
|
|
51
|
+
scheduledTimeoutId = setTimeout(() => {
|
|
52
|
+
scheduledTimeoutId = undefined;
|
|
53
|
+
if (waitPeriod < 4000) {
|
|
54
|
+
waitPeriod = waitPeriod * 2;
|
|
55
|
+
}
|
|
56
|
+
processCollectedUpdatedAndDeletedFiles();
|
|
57
|
+
cachedSerializedProjectGraphPromise = createAndSerializeProjectGraph();
|
|
58
|
+
}, waitPeriod);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
exports.addUpdatedAndDeletedFiles = addUpdatedAndDeletedFiles;
|
|
62
|
+
function processCollectedUpdatedAndDeletedFiles() {
|
|
63
|
+
perf_hooks_1.performance.mark('hash-watched-changes-start');
|
|
64
|
+
const updatedFiles = git_hasher_1.getGitHashForFiles([...collectedUpdatedFiles.values()], app_root_1.appRootPath);
|
|
65
|
+
const deletedFiles = [...collectedDeletedFiles.values()];
|
|
66
|
+
collectedUpdatedFiles.clear();
|
|
67
|
+
collectedDeletedFiles.clear();
|
|
68
|
+
perf_hooks_1.performance.mark('hash-watched-changes-end');
|
|
69
|
+
perf_hooks_1.performance.measure('hash changed files from watcher', 'hash-watched-changes-start', 'hash-watched-changes-end');
|
|
70
|
+
file_hasher_1.defaultFileHasher.incrementalUpdate(updatedFiles, deletedFiles);
|
|
71
|
+
const workspaceJson = file_utils_1.readWorkspaceJson();
|
|
72
|
+
logger_1.serverLogger.nestedLog(`Updated file-hasher based on watched changes, recomputing project graph...`);
|
|
73
|
+
// when workspace.json changes we cannot be sure about the correctness of the project file map
|
|
74
|
+
if (collectedUpdatedFiles.has(configName) ||
|
|
75
|
+
collectedDeletedFiles.has(configName)) {
|
|
76
|
+
projectFileMapWithFiles = file_utils_1.createProjectFileMap(workspaceJson);
|
|
77
|
+
}
|
|
78
|
+
else {
|
|
79
|
+
projectFileMapWithFiles = projectFileMapWithFiles
|
|
80
|
+
? file_utils_1.updateProjectFileMap(workspaceJson, projectFileMapWithFiles.projectFileMap, projectFileMapWithFiles.allWorkspaceFiles, updatedFiles, deletedFiles)
|
|
81
|
+
: file_utils_1.createProjectFileMap(workspaceJson);
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
function createAndSerializeProjectGraph() {
|
|
85
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
86
|
+
try {
|
|
87
|
+
perf_hooks_1.performance.mark('create-project-graph-start');
|
|
88
|
+
const workspaceJson = file_utils_1.readWorkspaceJson();
|
|
89
|
+
const { projectGraph, projectGraphCache } = yield build_project_graph_1.buildProjectGraphUsingProjectFileMap(workspaceJson, projectFileMapWithFiles.projectFileMap, projectFileMapWithFiles.allWorkspaceFiles, currentProjectGraphCache || nx_deps_cache_1.readCache(), true, '4.0');
|
|
90
|
+
currentProjectGraphCache = projectGraphCache;
|
|
91
|
+
perf_hooks_1.performance.mark('create-project-graph-end');
|
|
92
|
+
perf_hooks_1.performance.measure('total execution time for createProjectGraph()', 'create-project-graph-start', 'create-project-graph-end');
|
|
93
|
+
perf_hooks_1.performance.mark('json-stringify-start');
|
|
94
|
+
const serializedProjectGraph = JSON.stringify(projectGraph);
|
|
95
|
+
perf_hooks_1.performance.mark('json-stringify-end');
|
|
96
|
+
perf_hooks_1.performance.measure('serialize graph', 'json-stringify-start', 'json-stringify-end');
|
|
97
|
+
return {
|
|
98
|
+
error: null,
|
|
99
|
+
serializedProjectGraph,
|
|
100
|
+
};
|
|
101
|
+
}
|
|
102
|
+
catch (err) {
|
|
103
|
+
return {
|
|
104
|
+
error: err,
|
|
105
|
+
serializedProjectGraph: null,
|
|
106
|
+
};
|
|
107
|
+
}
|
|
108
|
+
});
|
|
109
|
+
}
|
|
110
|
+
function resetAfterError() {
|
|
111
|
+
cachedSerializedProjectGraphPromise = undefined;
|
|
112
|
+
projectFileMapWithFiles = undefined;
|
|
113
|
+
currentProjectGraphCache = undefined;
|
|
114
|
+
collectedUpdatedFiles.clear();
|
|
115
|
+
collectedDeletedFiles.clear();
|
|
116
|
+
waitPeriod = 100;
|
|
117
|
+
}
|
|
118
|
+
exports.resetAfterError = resetAfterError;
|
|
119
|
+
//# sourceMappingURL=project-graph-incremental-recomputation.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"project-graph-incremental-recomputation.js","sourceRoot":"","sources":["../../../../../../../../packages/workspace/src/core/project-graph/daemon/server/project-graph-incremental-recomputation.ts"],"names":[],"mappings":";;;;AACA,2DAA2D;AAC3D,2CAAyC;AACzC,oDAI6B;AAC7B,6DAAgE;AAChE,2DAAgE;AAChE,qCAAwC;AACxC,mEAAiF;AACjF,8DAAqE;AACrE,kEAA8E;AAE9E,MAAM,UAAU,GAAG,+BAAmB,CAAC,sBAAW,CAAC,CAAC;AACpD,IAAI,mCAGF,CAAC;AACH,IAAI,uBAES,CAAC;AACd,IAAI,wBAAuD,CAAC;AAE5D,MAAM,qBAAqB,GAAG,IAAI,GAAG,EAAU,CAAC;AAChD,MAAM,qBAAqB,GAAG,IAAI,GAAG,EAAU,CAAC;AAChD,IAAI,UAAU,GAAG,GAAG,CAAC;AACrB,IAAI,kBAAkB,CAAC;AAEvB,SAAgB,sCAAsC;IACpD,oEAAoE;IACpE,IAAI,kBAAkB,EAAE;QACtB,YAAY,CAAC,kBAAkB,CAAC,CAAC;KAClC;IAED,sBAAsB;IACtB,UAAU,GAAG,GAAG,CAAC;IAEjB,IAAI,qBAAqB,CAAC,IAAI,IAAI,CAAC,IAAI,qBAAqB,CAAC,IAAI,IAAI,CAAC,EAAE;QACtE,IAAI,CAAC,mCAAmC,EAAE;YACxC,mCAAmC,GAAG,8BAA8B,EAAE,CAAC;SACxE;KACF;SAAM;QACL,sCAAsC,EAAE,CAAC;QACzC,mCAAmC,GAAG,8BAA8B,EAAE,CAAC;KACxE;IACD,OAAO,mCAAmC,CAAC;AAC7C,CAAC;AAlBD,wFAkBC;AAED,SAAgB,yBAAyB,CACvC,YAAsB,EACtB,YAAsB;IAEtB,KAAK,IAAI,CAAC,IAAI,YAAY,EAAE;QAC1B,qBAAqB,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;QAChC,qBAAqB,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;KAC9B;IAED,KAAK,IAAI,CAAC,IAAI,YAAY,EAAE;Q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C;IAChD,uBAAuB,GAAG,SAAS,CAAC;IACpC,wBAAwB,GAAG,SAAS,CAAC;IACrC,qBAAqB,CAAC,KAAK,EAAE,CAAC;IAC9B,qBAAqB,CAAC,KAAK,EAAE,CAAC;IAC9B,UAAU,GAAG,GAAG,CAAC;AACnB,CAAC;AAPD,0CAOC"}
|
|
@@ -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,212 +4,137 @@ 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_hasher_1 = require("../../../hasher/file-hasher");
|
|
11
|
-
const git_hasher_1 = require("../../../hasher/git-hasher");
|
|
12
|
-
const project_graph_1 = require("../../project-graph");
|
|
13
10
|
const socket_utils_1 = require("../socket-utils");
|
|
11
|
+
const logger_1 = require("./logger");
|
|
12
|
+
const shutdown_utils_1 = require("./shutdown-utils");
|
|
14
13
|
const watcher_1 = require("./watcher");
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
* For (1) we do not want to log things from the daemon server to stdout/stderr, so we instead write to a file.
|
|
23
|
-
*
|
|
24
|
-
* This file location will be set by the `./exec/index.ts` utilities when starting the server so that we can
|
|
25
|
-
* provide feedback to the user as to its location via stdout on the parent process and still not cause the child
|
|
26
|
-
* process to be "undetachable".
|
|
27
|
-
*
|
|
28
|
-
* For (2) we simply log to stdout.
|
|
29
|
-
*/
|
|
30
|
-
let _serverLogOutputFile;
|
|
31
|
-
function serverLog(...s) {
|
|
32
|
-
/**
|
|
33
|
-
* If _serverLogOutputFile has not be set when starting the server, it means we are
|
|
34
|
-
* running it in the current process and we should log to stdout.
|
|
35
|
-
*/
|
|
36
|
-
if (!_serverLogOutputFile) {
|
|
37
|
-
console.log(formatLogMessage(`${s.join(' ')}`));
|
|
38
|
-
return;
|
|
39
|
-
}
|
|
40
|
-
fs_1.appendFileSync(_serverLogOutputFile, formatLogMessage(`${s.join(' ')}\n`));
|
|
41
|
-
}
|
|
42
|
-
function formatLogMessage(message) {
|
|
43
|
-
return `[NX Daemon Server] - ${new Date().toISOString()} - ${message}`;
|
|
44
|
-
}
|
|
45
|
-
/**
|
|
46
|
-
* To improve the overall readibility of the logs, we categorize things by "trigger":
|
|
47
|
-
*
|
|
48
|
-
* - [REQUEST] meaning that the current set of actions were triggered by a client request to the server
|
|
49
|
-
* - [WATCHER] meaning the the current set of actions were triggered by handling changes to the workspace files
|
|
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(' ')}`);
|
|
62
|
-
}
|
|
63
|
-
/**
|
|
64
|
-
* We cache the latest known HEAD value so that we can potentially skip some initialization work.
|
|
65
|
-
*/
|
|
66
|
-
let cachedGitHead;
|
|
67
|
-
/**
|
|
68
|
-
* We cache the latest copy of the serialized project graph itself in memory so that in the
|
|
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;
|
|
14
|
+
const project_graph_incremental_recomputation_1 = require("./project-graph-incremental-recomputation");
|
|
15
|
+
function respondToClient(socket, message) {
|
|
16
|
+
socket.write(message, () => {
|
|
17
|
+
// Close the connection once all data has been written so that the client knows when to read it.
|
|
18
|
+
socket.end();
|
|
19
|
+
logger_1.serverLogger.nestedLog(`Closed Connection to Client`);
|
|
20
|
+
});
|
|
82
21
|
}
|
|
83
|
-
/**
|
|
84
|
-
* File watcher subscription.
|
|
85
|
-
*/
|
|
86
22
|
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
23
|
let performanceObserver;
|
|
92
24
|
const server = net_1.createServer((socket) => {
|
|
25
|
+
shutdown_utils_1.resetInactivityTimeout(handleInactivityTimeout);
|
|
93
26
|
if (!performanceObserver) {
|
|
94
27
|
performanceObserver = new perf_hooks_1.PerformanceObserver((list) => {
|
|
95
28
|
const entry = list.getEntries()[0];
|
|
96
|
-
|
|
97
|
-
nestedLog(`Time taken for '${entry.name}'`, `${entry.duration}ms`);
|
|
29
|
+
logger_1.serverLogger.nestedLog(`Time taken for '${entry.name}'`, `${entry.duration}ms`);
|
|
98
30
|
});
|
|
99
31
|
performanceObserver.observe({ entryTypes: ['measure'], buffered: false });
|
|
100
32
|
}
|
|
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
|
-
*/
|
|
33
|
+
socket.on('data', (data) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
|
|
34
|
+
shutdown_utils_1.resetInactivityTimeout(handleInactivityTimeout);
|
|
106
35
|
const payload = data.toString();
|
|
107
36
|
if (payload !== 'REQUEST_PROJECT_GRAPH_PAYLOAD') {
|
|
108
37
|
throw new Error(`Unsupported payload sent to daemon server: ${payload}`);
|
|
109
38
|
}
|
|
110
39
|
perf_hooks_1.performance.mark('server-connection');
|
|
111
|
-
requestLog('Client Request for Project Graph Received');
|
|
112
|
-
const
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
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();
|
|
40
|
+
logger_1.serverLogger.requestLog('Client Request for Project Graph Received');
|
|
41
|
+
const result = yield project_graph_incremental_recomputation_1.getCachedSerializedProjectGraphPromise();
|
|
42
|
+
if (result.error) {
|
|
43
|
+
project_graph_incremental_recomputation_1.resetAfterError();
|
|
44
|
+
logger_1.serverLogger.nestedLog(`Error when preparing serialized project graph: ${result.error.message}`);
|
|
45
|
+
respondToClient(socket, socket_utils_1.serializeResult(result.error, result.serializedProjectGraph));
|
|
46
|
+
return;
|
|
124
47
|
}
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
*
|
|
132
|
-
* 2) We already have a cached serialized project graph (which we trust has been kept up to date
|
|
133
|
-
* by the file watching logic) so we can immediately resolve it to the client (faster)
|
|
134
|
-
*/
|
|
135
|
-
if (cachedSerializedProjectGraph) {
|
|
136
|
-
nestedLog(`State unchanged since last request, resolving in-memory cached project graph...`);
|
|
137
|
-
serializedProjectGraph = cachedSerializedProjectGraph;
|
|
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
|
-
}
|
|
48
|
+
const serializedResult = socket_utils_1.serializeResult(result.error, result.serializedProjectGraph);
|
|
49
|
+
if (!serializedResult) {
|
|
50
|
+
project_graph_incremental_recomputation_1.resetAfterError();
|
|
51
|
+
logger_1.serverLogger.nestedLog(`Error when serializing project graph result`);
|
|
52
|
+
respondToClient(socket, socket_utils_1.serializeResult(new Error('Critical error when serializing server result, check server logs'), null));
|
|
53
|
+
return;
|
|
145
54
|
}
|
|
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
55
|
perf_hooks_1.performance.mark('serialized-project-graph-ready');
|
|
155
56
|
perf_hooks_1.performance.measure('total for creating and serializing project graph', 'server-connection', 'serialized-project-graph-ready');
|
|
156
|
-
socket.write(
|
|
57
|
+
socket.write(serializedResult, () => {
|
|
157
58
|
perf_hooks_1.performance.mark('serialized-project-graph-written-to-client');
|
|
158
59
|
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
|
-
*/
|
|
60
|
+
// Close the connection once all data has been written so that the client knows when to read it.
|
|
163
61
|
socket.end();
|
|
164
62
|
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)`);
|
|
63
|
+
const bytesWritten = Buffer.byteLength(result.serializedProjectGraph, 'utf-8');
|
|
64
|
+
logger_1.serverLogger.nestedLog(`Closed Connection to Client (${bytesWritten} bytes transferred)`);
|
|
167
65
|
});
|
|
168
|
-
});
|
|
66
|
+
}));
|
|
169
67
|
});
|
|
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);
|
|
68
|
+
function handleInactivityTimeout() {
|
|
69
|
+
shutdown_utils_1.handleServerProcessTermination({
|
|
70
|
+
server,
|
|
71
|
+
watcherSubscription,
|
|
72
|
+
reason: `${shutdown_utils_1.SERVER_INACTIVITY_TIMEOUT_MS}ms of inactivity`,
|
|
186
73
|
});
|
|
187
74
|
}
|
|
188
75
|
process
|
|
189
|
-
.on('SIGINT', handleServerProcessTermination
|
|
190
|
-
|
|
191
|
-
|
|
76
|
+
.on('SIGINT', () => shutdown_utils_1.handleServerProcessTermination({
|
|
77
|
+
server,
|
|
78
|
+
watcherSubscription,
|
|
79
|
+
reason: 'received process SIGINT',
|
|
80
|
+
}))
|
|
81
|
+
.on('SIGTERM', () => shutdown_utils_1.handleServerProcessTermination({
|
|
82
|
+
server,
|
|
83
|
+
watcherSubscription,
|
|
84
|
+
reason: 'received process SIGTERM',
|
|
85
|
+
}))
|
|
86
|
+
.on('SIGHUP', () => shutdown_utils_1.handleServerProcessTermination({
|
|
87
|
+
server,
|
|
88
|
+
watcherSubscription,
|
|
89
|
+
reason: 'received process SIGHUP',
|
|
90
|
+
}));
|
|
91
|
+
function requireUncached(module) {
|
|
92
|
+
delete require.cache[require.resolve(module)];
|
|
93
|
+
return require(module);
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* We need to ensure that the server shuts down if the Nx installation changes.
|
|
97
|
+
*/
|
|
98
|
+
let cachedNxVersion = resolveCurrentNxVersion();
|
|
99
|
+
function resolveCurrentNxVersion() {
|
|
100
|
+
const nrwlWorkspacePackageJsonPath = devkit_1.normalizePath(path_1.join(app_root_1.appRootPath, 'node_modules/@nrwl/workspace/package.json'));
|
|
101
|
+
try {
|
|
102
|
+
const { version } = requireUncached(nrwlWorkspacePackageJsonPath);
|
|
103
|
+
return version;
|
|
104
|
+
}
|
|
105
|
+
catch (_a) {
|
|
106
|
+
logger_1.serverLogger.nestedLog(`Error: Could not determine the current Nx version by inspecting: ${nrwlWorkspacePackageJsonPath}`);
|
|
107
|
+
return null;
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
function isNxVersionSame(currentNxVersion) {
|
|
111
|
+
if (currentNxVersion === null) {
|
|
112
|
+
// Something has gone wrong with figuring out the Nx version, declare the version as having changed
|
|
113
|
+
return false;
|
|
114
|
+
}
|
|
115
|
+
return currentNxVersion === cachedNxVersion;
|
|
116
|
+
}
|
|
192
117
|
/**
|
|
193
118
|
* When applicable files in the workspaces are changed (created, updated, deleted),
|
|
194
119
|
* we need to recompute the cached serialized project graph so that it is readily
|
|
195
120
|
* available for the next client request to the server.
|
|
196
121
|
*/
|
|
197
|
-
const handleWorkspaceChanges = (err, changeEvents) => {
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
122
|
+
const handleWorkspaceChanges = (err, changeEvents) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
|
|
123
|
+
shutdown_utils_1.resetInactivityTimeout(handleInactivityTimeout);
|
|
124
|
+
if (!isNxVersionSame(resolveCurrentNxVersion())) {
|
|
125
|
+
yield shutdown_utils_1.handleServerProcessTermination({
|
|
126
|
+
server,
|
|
127
|
+
watcherSubscription,
|
|
128
|
+
reason: '@nrwl/workspace installation changed',
|
|
129
|
+
});
|
|
130
|
+
return;
|
|
131
|
+
}
|
|
203
132
|
if (err || !changeEvents || !changeEvents.length) {
|
|
204
|
-
watcherLog('Unexpected Error');
|
|
133
|
+
logger_1.serverLogger.watcherLog('Unexpected Error');
|
|
205
134
|
console.error(err);
|
|
206
135
|
return;
|
|
207
136
|
}
|
|
208
|
-
watcherLog(watcher_1.convertChangeEventsToLogMessage(changeEvents));
|
|
209
|
-
/**
|
|
210
|
-
* Update the file-hasher's knowledge of the non-deleted changed files in order to
|
|
211
|
-
* recompute and cache the project graph in memory.
|
|
212
|
-
*/
|
|
137
|
+
logger_1.serverLogger.watcherLog(watcher_1.convertChangeEventsToLogMessage(changeEvents));
|
|
213
138
|
try {
|
|
214
139
|
const filesToHash = [];
|
|
215
140
|
const deletedFiles = [];
|
|
@@ -221,33 +146,25 @@ const handleWorkspaceChanges = (err, changeEvents) => {
|
|
|
221
146
|
filesToHash.push(event.path);
|
|
222
147
|
}
|
|
223
148
|
}
|
|
224
|
-
|
|
225
|
-
const updatedHashes = git_hasher_1.getGitHashForFiles(filesToHash, app_root_1.appRootPath);
|
|
226
|
-
perf_hooks_1.performance.mark('hash-watched-changes-end');
|
|
227
|
-
perf_hooks_1.performance.measure('hash changed files from watcher', 'hash-watched-changes-start', 'hash-watched-changes-end');
|
|
228
|
-
file_hasher_1.defaultFileHasher.incrementalUpdate(updatedHashes);
|
|
229
|
-
file_hasher_1.defaultFileHasher.removeFiles(deletedFiles);
|
|
230
|
-
nestedLog(`Updated file-hasher based on watched changes, recomputing project graph...`);
|
|
231
|
-
cachedSerializedProjectGraph = createAndSerializeProjectGraph();
|
|
149
|
+
project_graph_incremental_recomputation_1.addUpdatedAndDeletedFiles(filesToHash, deletedFiles);
|
|
232
150
|
}
|
|
233
151
|
catch (err) {
|
|
234
|
-
|
|
152
|
+
logger_1.serverLogger.log(`Unexpected Error`);
|
|
235
153
|
console.error(err);
|
|
236
154
|
}
|
|
237
|
-
};
|
|
238
|
-
function startServer(
|
|
155
|
+
});
|
|
156
|
+
function startServer() {
|
|
239
157
|
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
240
|
-
|
|
241
|
-
// See notes above on OS differences regarding clean up of existings connections.
|
|
158
|
+
// See notes in socket-utils.ts on OS differences regarding clean up of existings connections.
|
|
242
159
|
if (!socket_utils_1.isWindows) {
|
|
243
160
|
socket_utils_1.killSocketOrPath();
|
|
244
161
|
}
|
|
245
162
|
return new Promise((resolve) => {
|
|
246
163
|
server.listen(socket_utils_1.FULL_OS_SOCKET_PATH, () => tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
247
|
-
|
|
164
|
+
logger_1.serverLogger.log(`Started listening on: ${socket_utils_1.FULL_OS_SOCKET_PATH}`);
|
|
248
165
|
if (!watcherSubscription) {
|
|
249
166
|
watcherSubscription = yield watcher_1.subscribeToWorkspaceChanges(handleWorkspaceChanges);
|
|
250
|
-
watcherLog(`Subscribed to changes within: ${app_root_1.appRootPath}`);
|
|
167
|
+
logger_1.serverLogger.watcherLog(`Subscribed to changes within: ${app_root_1.appRootPath}`);
|
|
251
168
|
}
|
|
252
169
|
return resolve(server);
|
|
253
170
|
}));
|
|
@@ -270,10 +187,6 @@ function stopServer() {
|
|
|
270
187
|
}
|
|
271
188
|
}
|
|
272
189
|
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
190
|
devkit_1.logger.info('NX Daemon Server - Stopped');
|
|
278
191
|
return resolve();
|
|
279
192
|
});
|
|
@@ -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,yCAAqD;AACrD,2DAA2D;AAC3D,6BAAmD;AACnD,+BAA4B;AAC5B,2CAA8D;AAC9D,kDAKyB;AACzB,qCAAwC;AACxC,qDAI0B;AAC1B,uCAKmB;AACnB,uGAImD;AAEnD,SAAS,eAAe,CAAC,MAAc,EAAE,OAAe;IACtD,MAAM,CAAC,KAAK,CAAC,OAAO,EAAE,GAAG,EAAE;QACzB,gGAAgG;QAChG,MAAM,CAAC,GAAG,EAAE,CAAC;QACb,qBAAY,CAAC,SAAS,CAAC,6BAA6B,CAAC,CAAC;IACxD,CAAC,CAAC,CAAC;AACL,CAAC;AAED,IAAI,mBAAoD,CAAC;AACzD,IAAI,mBAAoD,CAAC;AAEzD,MAAM,MAAM,GAAG,kBAAY,CAAC,CAAC,MAAM,EAAE,EAAE;IACrC,uCAAsB,CAAC,uBAAuB,CAAC,CAAC;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;iBACzE;gBAED,OAAO,OAAO,CAAC,MAAM,CAAC,CAAC;YACzB,CAAC,CAAA,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;IACL,CAAC;CAAA;AAnBD,kCAmBC;AAED,SAAsB,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);
|