nx 22.2.0-canary.20251121-9a6c7ad → 22.2.0-canary.20251125-7e00ec4
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/executors.json +16 -16
- package/generators.json +13 -13
- package/migrations.json +143 -143
- package/package.json +14 -11
- package/presets/npm.json +4 -4
- package/release/changelog-renderer/index.d.ts +1 -0
- package/release/changelog-renderer/index.d.ts.map +1 -1
- package/release/changelog-renderer/index.js +12 -12
- package/schemas/nx-schema.json +1285 -1285
- package/schemas/project-schema.json +359 -359
- package/schemas/workspace-schema.json +165 -165
- package/src/ai/constants.d.ts +6 -1
- package/src/ai/constants.d.ts.map +1 -1
- package/src/ai/constants.js +14 -3
- package/src/ai/set-up-ai-agents/schema.json +31 -31
- package/src/ai/set-up-ai-agents/set-up-ai-agents.d.ts.map +1 -1
- package/src/ai/set-up-ai-agents/set-up-ai-agents.js +41 -7
- package/src/command-line/release/utils/resolve-semver-specifier.d.ts +1 -1
- package/src/command-line/release/utils/resolve-semver-specifier.d.ts.map +1 -1
- package/src/command-line/release/utils/resolve-semver-specifier.js +3 -3
- package/src/command-line/release/utils/shared.d.ts +2 -1
- package/src/command-line/release/utils/shared.d.ts.map +1 -1
- package/src/command-line/release/utils/shared.js +27 -1
- package/src/command-line/release/version/derive-specifier-from-conventional-commits.js +1 -1
- package/src/command-line/report/report.d.ts +4 -0
- package/src/command-line/report/report.d.ts.map +1 -1
- package/src/command-line/report/report.js +72 -1
- package/src/core/graph/main.js +1 -1
- package/src/daemon/cache.d.ts +2 -1
- package/src/daemon/cache.d.ts.map +1 -1
- package/src/daemon/cache.js +10 -26
- package/src/daemon/client/client.d.ts +2 -0
- package/src/daemon/client/client.d.ts.map +1 -1
- package/src/daemon/client/client.js +53 -26
- package/src/daemon/is-nx-version-mismatch.d.ts +3 -0
- package/src/daemon/is-nx-version-mismatch.d.ts.map +1 -0
- package/src/daemon/is-nx-version-mismatch.js +24 -0
- package/src/daemon/server/server.d.ts.map +1 -1
- package/src/daemon/server/server.js +7 -18
- package/src/daemon/tmp-dir.d.ts.map +1 -1
- package/src/daemon/tmp-dir.js +1 -0
- package/src/executors/noop/schema.json +8 -8
- package/src/executors/run-commands/schema.json +187 -187
- package/src/executors/run-script/schema.json +25 -25
- package/src/nx-cloud/generators/connect-to-nx-cloud/schema.json +38 -38
- package/src/tasks-runner/pseudo-terminal.js +1 -1
- package/src/tasks-runner/task-orchestrator.d.ts +1 -0
- package/src/tasks-runner/task-orchestrator.d.ts.map +1 -1
- package/src/tasks-runner/task-orchestrator.js +22 -5
- package/src/utils/package-manager.d.ts +1 -0
- package/src/utils/package-manager.d.ts.map +1 -1
- package/src/utils/package-manager.js +4 -0
package/src/daemon/cache.d.ts
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
export interface DaemonProcessJson {
|
|
2
2
|
processId: number;
|
|
3
|
+
socketPath: string;
|
|
4
|
+
nxVersion: string;
|
|
3
5
|
}
|
|
4
6
|
export declare const serverProcessJsonPath: string;
|
|
5
7
|
export declare function readDaemonProcessJsonCache(): DaemonProcessJson | null;
|
|
6
8
|
export declare function deleteDaemonJsonProcessCache(): void;
|
|
7
9
|
export declare function writeDaemonJsonProcessCache(daemonJson: DaemonProcessJson): Promise<void>;
|
|
8
|
-
export declare function waitForDaemonToExitAndCleanupProcessJson(): Promise<void>;
|
|
9
10
|
export declare function getDaemonProcessIdSync(): number | null;
|
|
10
11
|
//# sourceMappingURL=cache.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cache.d.ts","sourceRoot":"","sources":["../../../../../packages/nx/src/daemon/cache.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"cache.d.ts","sourceRoot":"","sources":["../../../../../packages/nx/src/daemon/cache.ts"],"names":[],"mappings":"AAMA,MAAM,WAAW,iBAAiB;IAChC,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,eAAO,MAAM,qBAAqB,QAGjC,CAAC;AAEF,wBAAgB,0BAA0B,IAAI,iBAAiB,GAAG,IAAI,CAWrE;AAED,wBAAgB,4BAA4B,IAAI,IAAI,CAMnD;AAED,wBAAsB,2BAA2B,CAC/C,UAAU,EAAE,iBAAiB,GAC5B,OAAO,CAAC,IAAI,CAAC,CAIf;AAGD,wBAAgB,sBAAsB,IAAI,MAAM,GAAG,IAAI,CAUtD"}
|
package/src/daemon/cache.js
CHANGED
|
@@ -4,18 +4,25 @@ exports.serverProcessJsonPath = void 0;
|
|
|
4
4
|
exports.readDaemonProcessJsonCache = readDaemonProcessJsonCache;
|
|
5
5
|
exports.deleteDaemonJsonProcessCache = deleteDaemonJsonProcessCache;
|
|
6
6
|
exports.writeDaemonJsonProcessCache = writeDaemonJsonProcessCache;
|
|
7
|
-
exports.waitForDaemonToExitAndCleanupProcessJson = waitForDaemonToExitAndCleanupProcessJson;
|
|
8
7
|
exports.getDaemonProcessIdSync = getDaemonProcessIdSync;
|
|
9
8
|
const node_fs_1 = require("node:fs");
|
|
10
9
|
const path_1 = require("path");
|
|
11
10
|
const tmp_dir_1 = require("./tmp-dir");
|
|
12
11
|
const fileutils_1 = require("../utils/fileutils");
|
|
12
|
+
const versions_1 = require("../utils/versions");
|
|
13
13
|
exports.serverProcessJsonPath = (0, path_1.join)(tmp_dir_1.DAEMON_DIR_FOR_CURRENT_WORKSPACE, 'server-process.json');
|
|
14
14
|
function readDaemonProcessJsonCache() {
|
|
15
|
-
|
|
15
|
+
try {
|
|
16
|
+
const daemonJson = (0, fileutils_1.readJsonFile)(exports.serverProcessJsonPath);
|
|
17
|
+
// If the daemon version doesn't match the client version, treat it as stale
|
|
18
|
+
if (daemonJson.nxVersion !== versions_1.nxVersion) {
|
|
19
|
+
return null;
|
|
20
|
+
}
|
|
21
|
+
return daemonJson;
|
|
22
|
+
}
|
|
23
|
+
catch {
|
|
16
24
|
return null;
|
|
17
25
|
}
|
|
18
|
-
return (0, fileutils_1.readJsonFile)(exports.serverProcessJsonPath);
|
|
19
26
|
}
|
|
20
27
|
function deleteDaemonJsonProcessCache() {
|
|
21
28
|
try {
|
|
@@ -30,29 +37,6 @@ async function writeDaemonJsonProcessCache(daemonJson) {
|
|
|
30
37
|
appendNewLine: true,
|
|
31
38
|
});
|
|
32
39
|
}
|
|
33
|
-
async function waitForDaemonToExitAndCleanupProcessJson() {
|
|
34
|
-
const daemonProcessJson = readDaemonProcessJsonCache();
|
|
35
|
-
if (daemonProcessJson && daemonProcessJson.processId) {
|
|
36
|
-
await new Promise((resolve, reject) => {
|
|
37
|
-
let count = 0;
|
|
38
|
-
const interval = setInterval(() => {
|
|
39
|
-
try {
|
|
40
|
-
// sending a signal 0 to a process checks if the process is running instead of actually killing it
|
|
41
|
-
process.kill(daemonProcessJson.processId, 0);
|
|
42
|
-
}
|
|
43
|
-
catch (e) {
|
|
44
|
-
clearInterval(interval);
|
|
45
|
-
resolve();
|
|
46
|
-
}
|
|
47
|
-
if ((count += 1) > 200) {
|
|
48
|
-
clearInterval(interval);
|
|
49
|
-
reject(`Daemon process ${daemonProcessJson.processId} didn't exit after 2 seconds.`);
|
|
50
|
-
}
|
|
51
|
-
}, 10);
|
|
52
|
-
});
|
|
53
|
-
deleteDaemonJsonProcessCache();
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
40
|
// Must be sync for the help output use case
|
|
57
41
|
function getDaemonProcessIdSync() {
|
|
58
42
|
if (!(0, node_fs_1.existsSync)(exports.serverProcessJsonPath)) {
|
|
@@ -28,6 +28,7 @@ export declare class DaemonClient {
|
|
|
28
28
|
private _err;
|
|
29
29
|
enabled(): boolean;
|
|
30
30
|
reset(): void;
|
|
31
|
+
private getSocketPath;
|
|
31
32
|
requestShutdown(): Promise<void>;
|
|
32
33
|
getProjectGraphAndSourceMaps(): Promise<{
|
|
33
34
|
projectGraph: ProjectGraph;
|
|
@@ -73,6 +74,7 @@ export declare class DaemonClient {
|
|
|
73
74
|
getNxConsoleStatus(): Promise<NxConsoleStatusResponse>;
|
|
74
75
|
setNxConsolePreferenceAndInstall(preference: boolean): Promise<SetNxConsolePreferenceAndInstallResponse>;
|
|
75
76
|
isServerAvailable(): Promise<boolean>;
|
|
77
|
+
private startDaemonIfNecessary;
|
|
76
78
|
private sendToDaemonViaQueue;
|
|
77
79
|
private setUpConnection;
|
|
78
80
|
private sendMessageToDaemon;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../../../../../packages/nx/src/daemon/client/client.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAS,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../../../../../packages/nx/src/daemon/client/client.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAS,MAAM,eAAe,CAAC;AAmBpD,OAAO,EAAE,QAAQ,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAQpE,OAAO,EAAE,IAAI,EAAE,MAAM,0BAA0B,CAAC;AAChD,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AAC1D,OAAO,EAAE,uBAAuB,EAAE,MAAM,uDAAuD,CAAC;AAKhG,OAAO,EAAW,gBAAgB,EAAE,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAoC9E,OAAO,KAAK,EACV,+BAA+B,EAC/B,sBAAsB,EACvB,MAAM,6BAA6B,CAAC;AAcrC,OAAO,EACL,yBAAyB,EACzB,wBAAwB,EACzB,MAAM,wCAAwC,CAAC;AAQhD,OAAO,EAIL,KAAK,uBAAuB,EAE5B,KAAK,wCAAwC,EAC9C,MAAM,6BAA6B,CAAC;AAcrC,MAAM,MAAM,kBAAkB,GAAG,MAAM,IAAI,CAAC;AAC5C,MAAM,MAAM,WAAW,GAAG;IACxB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,E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C,KAAK,CAAC,CAAC;IAwDjD,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;CAkB5B;AAED,eAAO,MAAM,YAAY,cAAqB,CAAC;AAE/C,wBAAgB,eAAe,YAE9B"}
|
|
@@ -10,7 +10,6 @@ const net_1 = require("net");
|
|
|
10
10
|
const path_1 = require("path");
|
|
11
11
|
const perf_hooks_1 = require("perf_hooks");
|
|
12
12
|
const output_1 = require("../../utils/output");
|
|
13
|
-
const socket_utils_1 = require("../socket-utils");
|
|
14
13
|
const tmp_dir_1 = require("../tmp-dir");
|
|
15
14
|
const is_ci_1 = require("../../utils/is-ci");
|
|
16
15
|
const nx_json_1 = require("../../config/nx-json");
|
|
@@ -18,6 +17,7 @@ const configuration_1 = require("../../config/configuration");
|
|
|
18
17
|
const promised_based_queue_1 = require("../../utils/promised-based-queue");
|
|
19
18
|
const daemon_socket_messenger_1 = require("./daemon-socket-messenger");
|
|
20
19
|
const cache_1 = require("../cache");
|
|
20
|
+
const is_nx_version_mismatch_1 = require("../is-nx-version-mismatch");
|
|
21
21
|
const error_types_1 = require("../../project-graph/error-types");
|
|
22
22
|
const native_1 = require("../../native");
|
|
23
23
|
const get_nx_workspace_files_1 = require("../message-types/get-nx-workspace-files");
|
|
@@ -82,7 +82,9 @@ class DaemonClient {
|
|
|
82
82
|
// docker=true,env=false => no daemon
|
|
83
83
|
// docker=true,env=true => daemon
|
|
84
84
|
// WASM => no daemon because file watching does not work
|
|
85
|
-
|
|
85
|
+
// version mismatch => no daemon because the installed nx version differs from the running one
|
|
86
|
+
if ((0, is_nx_version_mismatch_1.isNxVersionMismatch)() ||
|
|
87
|
+
(((0, is_ci_1.isCI)() || isDocker()) && env !== 'true') ||
|
|
86
88
|
(0, tmp_dir_1.isDaemonDisabled)() ||
|
|
87
89
|
nxJsonIsNotPresent() ||
|
|
88
90
|
(useDaemonProcessOption === undefined && env === 'false') ||
|
|
@@ -118,6 +120,15 @@ class DaemonClient {
|
|
|
118
120
|
this._daemonStatus = DaemonStatus.DISCONNECTED;
|
|
119
121
|
this._waitForDaemonReady = new Promise((resolve) => (this._daemonReady = resolve));
|
|
120
122
|
}
|
|
123
|
+
getSocketPath() {
|
|
124
|
+
const daemonProcessJson = (0, cache_1.readDaemonProcessJsonCache)();
|
|
125
|
+
if (daemonProcessJson?.socketPath) {
|
|
126
|
+
return daemonProcessJson.socketPath;
|
|
127
|
+
}
|
|
128
|
+
else {
|
|
129
|
+
throw daemonProcessException('Unable to connect to daemon: no socket path available');
|
|
130
|
+
}
|
|
131
|
+
}
|
|
121
132
|
async requestShutdown() {
|
|
122
133
|
return this.sendToDaemonViaQueue({ type: 'REQUEST_SHUTDOWN' });
|
|
123
134
|
}
|
|
@@ -174,8 +185,10 @@ class DaemonClient {
|
|
|
174
185
|
}
|
|
175
186
|
}
|
|
176
187
|
let messenger;
|
|
177
|
-
await this.queue.sendToQueue(() => {
|
|
178
|
-
|
|
188
|
+
await this.queue.sendToQueue(async () => {
|
|
189
|
+
await this.startDaemonIfNecessary();
|
|
190
|
+
const socketPath = this.getSocketPath();
|
|
191
|
+
messenger = new daemon_socket_messenger_1.DaemonSocketMessenger((0, net_1.connect)(socketPath)).listen((message) => {
|
|
179
192
|
try {
|
|
180
193
|
const parsedMessage = (0, consume_messages_from_socket_1.isJsonMessage)(message)
|
|
181
194
|
? JSON.parse(message)
|
|
@@ -196,8 +209,10 @@ class DaemonClient {
|
|
|
196
209
|
}
|
|
197
210
|
async registerProjectGraphRecomputationListener(callback) {
|
|
198
211
|
let messenger;
|
|
199
|
-
await this.queue.sendToQueue(() => {
|
|
200
|
-
|
|
212
|
+
await this.queue.sendToQueue(async () => {
|
|
213
|
+
await this.startDaemonIfNecessary();
|
|
214
|
+
const socketPath = this.getSocketPath();
|
|
215
|
+
messenger = new daemon_socket_messenger_1.DaemonSocketMessenger((0, net_1.connect)(socketPath)).listen((message) => {
|
|
201
216
|
try {
|
|
202
217
|
const parsedMessage = (0, consume_messages_from_socket_1.isJsonMessage)(message)
|
|
203
218
|
? JSON.parse(message)
|
|
@@ -376,7 +391,12 @@ class DaemonClient {
|
|
|
376
391
|
async isServerAvailable() {
|
|
377
392
|
return new Promise((resolve) => {
|
|
378
393
|
try {
|
|
379
|
-
const
|
|
394
|
+
const socketPath = this.getSocketPath();
|
|
395
|
+
if (!socketPath) {
|
|
396
|
+
resolve(false);
|
|
397
|
+
return;
|
|
398
|
+
}
|
|
399
|
+
const socket = (0, net_1.connect)(socketPath, () => {
|
|
380
400
|
socket.destroy();
|
|
381
401
|
resolve(true);
|
|
382
402
|
});
|
|
@@ -389,11 +409,35 @@ class DaemonClient {
|
|
|
389
409
|
}
|
|
390
410
|
});
|
|
391
411
|
}
|
|
412
|
+
async startDaemonIfNecessary() {
|
|
413
|
+
if (this._daemonStatus == DaemonStatus.CONNECTED) {
|
|
414
|
+
return;
|
|
415
|
+
}
|
|
416
|
+
// Ensure daemon is running and socket path is available
|
|
417
|
+
if (this._daemonStatus == DaemonStatus.DISCONNECTED) {
|
|
418
|
+
this._daemonStatus = DaemonStatus.CONNECTING;
|
|
419
|
+
let daemonPid = null;
|
|
420
|
+
if (!(await this.isServerAvailable())) {
|
|
421
|
+
daemonPid = await this.startInBackground();
|
|
422
|
+
}
|
|
423
|
+
this.setUpConnection();
|
|
424
|
+
this._daemonStatus = DaemonStatus.CONNECTED;
|
|
425
|
+
this._daemonReady();
|
|
426
|
+
daemonPid ??= (0, cache_1.getDaemonProcessIdSync)();
|
|
427
|
+
await this.registerDaemonProcessWithMetricsService(daemonPid);
|
|
428
|
+
}
|
|
429
|
+
else if (this._daemonStatus == DaemonStatus.CONNECTING) {
|
|
430
|
+
await this._waitForDaemonReady;
|
|
431
|
+
const daemonPid = (0, cache_1.getDaemonProcessIdSync)();
|
|
432
|
+
await this.registerDaemonProcessWithMetricsService(daemonPid);
|
|
433
|
+
}
|
|
434
|
+
}
|
|
392
435
|
async sendToDaemonViaQueue(messageToDaemon, force) {
|
|
393
436
|
return this.queue.sendToQueue(() => this.sendMessageToDaemon(messageToDaemon, force));
|
|
394
437
|
}
|
|
395
438
|
setUpConnection() {
|
|
396
|
-
|
|
439
|
+
const socketPath = this.getSocketPath();
|
|
440
|
+
this.socketMessenger = new daemon_socket_messenger_1.DaemonSocketMessenger((0, net_1.connect)(socketPath)).listen((message) => this.handleMessage(message), () => {
|
|
397
441
|
// it's ok for the daemon to terminate if the client doesn't wait on
|
|
398
442
|
// any messages from the daemon
|
|
399
443
|
if (this.queue.isEmpty()) {
|
|
@@ -421,7 +465,6 @@ class DaemonClient {
|
|
|
421
465
|
}
|
|
422
466
|
else if (err.message.startsWith('connect ECONNREFUSED')) {
|
|
423
467
|
error = daemonProcessException(`A server instance had not been fully shut down. Please try running the command again.`);
|
|
424
|
-
(0, socket_utils_1.killSocketOrPath)();
|
|
425
468
|
}
|
|
426
469
|
else if (err.message.startsWith('read ECONNRESET')) {
|
|
427
470
|
error = daemonProcessException(`Unable to connect to the daemon process.`);
|
|
@@ -433,23 +476,7 @@ class DaemonClient {
|
|
|
433
476
|
});
|
|
434
477
|
}
|
|
435
478
|
async sendMessageToDaemon(message, force) {
|
|
436
|
-
|
|
437
|
-
this._daemonStatus = DaemonStatus.CONNECTING;
|
|
438
|
-
let daemonPid = null;
|
|
439
|
-
if (!(await this.isServerAvailable())) {
|
|
440
|
-
daemonPid = await this.startInBackground();
|
|
441
|
-
}
|
|
442
|
-
this.setUpConnection();
|
|
443
|
-
this._daemonStatus = DaemonStatus.CONNECTED;
|
|
444
|
-
this._daemonReady();
|
|
445
|
-
daemonPid ??= (0, cache_1.getDaemonProcessIdSync)();
|
|
446
|
-
await this.registerDaemonProcessWithMetricsService(daemonPid);
|
|
447
|
-
}
|
|
448
|
-
else if (this._daemonStatus == DaemonStatus.CONNECTING) {
|
|
449
|
-
await this._waitForDaemonReady;
|
|
450
|
-
const daemonPid = (0, cache_1.getDaemonProcessIdSync)();
|
|
451
|
-
await this.registerDaemonProcessWithMetricsService(daemonPid);
|
|
452
|
-
}
|
|
479
|
+
await this.startDaemonIfNecessary();
|
|
453
480
|
// An open promise isn't enough to keep the event loop
|
|
454
481
|
// alive, so we set a timeout here and clear it when we hear
|
|
455
482
|
// back
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"is-nx-version-mismatch.d.ts","sourceRoot":"","sources":["../../../../../packages/nx/src/daemon/is-nx-version-mismatch.ts"],"names":[],"mappings":"AAMA,wBAAgB,qBAAqB,IAAI,MAAM,GAAG,IAAI,CAWrD;AAED,wBAAgB,mBAAmB,IAAI,OAAO,CAE7C"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getInstalledNxVersion = getInstalledNxVersion;
|
|
4
|
+
exports.isNxVersionMismatch = isNxVersionMismatch;
|
|
5
|
+
const fileutils_1 = require("../utils/fileutils");
|
|
6
|
+
const versions_1 = require("../utils/versions");
|
|
7
|
+
const workspace_root_1 = require("../utils/workspace-root");
|
|
8
|
+
const installation_directory_1 = require("../utils/installation-directory");
|
|
9
|
+
function getInstalledNxVersion() {
|
|
10
|
+
try {
|
|
11
|
+
const nxPackageJsonPath = require.resolve('nx/package.json', {
|
|
12
|
+
paths: (0, installation_directory_1.getNxRequirePaths)(workspace_root_1.workspaceRoot),
|
|
13
|
+
});
|
|
14
|
+
const { version } = (0, fileutils_1.readJsonFile)(nxPackageJsonPath);
|
|
15
|
+
return version;
|
|
16
|
+
}
|
|
17
|
+
catch {
|
|
18
|
+
// node modules are absent
|
|
19
|
+
return null;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
function isNxVersionMismatch() {
|
|
23
|
+
return getInstalledNxVersion() !== versions_1.nxVersion;
|
|
24
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../../../../../../packages/nx/src/daemon/server/server.ts"],"names":[],"mappings":"AACA,OAAO,EAAgB,MAAM,EAAE,MAAM,EAAE,MAAM,KAAK,CAAC;
|
|
1
|
+
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../../../../../../packages/nx/src/daemon/server/server.ts"],"names":[],"mappings":"AACA,OAAO,EAAgB,MAAM,EAAE,MAAM,EAAE,MAAM,KAAK,CAAC;AA+JnD,MAAM,MAAM,aAAa,GAAG;IAC1B,WAAW,EAAE,MAAM,CAAC;IACpB,KAAK,CAAC,EAAE,GAAG,CAAC;IACZ,QAAQ,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC;CACtC,CAAC;AAGF,eAAO,MAAM,WAAW,EAAE,GAAG,CAAC,MAAM,CAAa,CAAC;AA8RlD,wBAAsB,YAAY,CAChC,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,MAAM,OAAO,CAAC,aAAa,CAAC,EAClC,IAAI,EAAE,MAAM,GAAG,IAAI,iBA6BpB;AAoLD,wBAAsB,WAAW,IAAI,OAAO,CAAC,MAAM,CAAC,CAyEnD"}
|
|
@@ -10,11 +10,11 @@ const perf_hooks_1 = require("perf_hooks");
|
|
|
10
10
|
const file_hasher_1 = require("../../hasher/file-hasher");
|
|
11
11
|
const native_1 = require("../../native");
|
|
12
12
|
const consume_messages_from_socket_1 = require("../../utils/consume-messages-from-socket");
|
|
13
|
-
const fileutils_1 = require("../../utils/fileutils");
|
|
14
13
|
const versions_1 = require("../../utils/versions");
|
|
15
14
|
const workspace_context_1 = require("../../utils/workspace-context");
|
|
16
15
|
const workspace_root_1 = require("../../utils/workspace-root");
|
|
17
16
|
const cache_1 = require("../cache");
|
|
17
|
+
const is_nx_version_mismatch_1 = require("../is-nx-version-mismatch");
|
|
18
18
|
const socket_utils_1 = require("../socket-utils");
|
|
19
19
|
const file_watcher_sockets_1 = require("./file-watching/file-watcher-sockets");
|
|
20
20
|
const project_graph_listener_sockets_1 = require("./project-graph-listener-sockets");
|
|
@@ -265,7 +265,7 @@ function registerProcessTerminationListeners() {
|
|
|
265
265
|
}
|
|
266
266
|
let existingLockHash;
|
|
267
267
|
function daemonIsOutdated() {
|
|
268
|
-
if (
|
|
268
|
+
if ((0, is_nx_version_mismatch_1.isNxVersionMismatch)()) {
|
|
269
269
|
return 'NX_VERSION_CHANGED';
|
|
270
270
|
}
|
|
271
271
|
else if (lockFileHashChanged()) {
|
|
@@ -273,20 +273,6 @@ function daemonIsOutdated() {
|
|
|
273
273
|
}
|
|
274
274
|
return null;
|
|
275
275
|
}
|
|
276
|
-
function nxVersionChanged() {
|
|
277
|
-
return versions_1.nxVersion !== getInstalledNxVersion();
|
|
278
|
-
}
|
|
279
|
-
const nxPackageJsonPath = require.resolve('nx/package.json');
|
|
280
|
-
function getInstalledNxVersion() {
|
|
281
|
-
try {
|
|
282
|
-
const { version } = (0, fileutils_1.readJsonFile)(nxPackageJsonPath);
|
|
283
|
-
return version;
|
|
284
|
-
}
|
|
285
|
-
catch (e) {
|
|
286
|
-
// node modules are absent, so we can return null, which would shut down the daemon
|
|
287
|
-
return null;
|
|
288
|
-
}
|
|
289
|
-
}
|
|
290
276
|
function lockFileHashChanged() {
|
|
291
277
|
const lockHashes = [
|
|
292
278
|
(0, path_1.join)(workspace_root_1.workspaceRoot, 'package-lock.json'),
|
|
@@ -393,9 +379,12 @@ const handleOutputsChanges = async (err, changeEvents) => {
|
|
|
393
379
|
};
|
|
394
380
|
async function startServer() {
|
|
395
381
|
(0, workspace_context_1.setupWorkspaceContext)(workspace_root_1.workspaceRoot);
|
|
382
|
+
const socketPath = (0, socket_utils_1.getFullOsSocketPath)();
|
|
396
383
|
// Persist metadata about the background process so that it can be cleaned up later if needed
|
|
397
384
|
await (0, cache_1.writeDaemonJsonProcessCache)({
|
|
398
385
|
processId: process.pid,
|
|
386
|
+
socketPath,
|
|
387
|
+
nxVersion: versions_1.nxVersion,
|
|
399
388
|
});
|
|
400
389
|
// See notes in socket-command-line-utils.ts on OS differences regarding clean up of existings connections.
|
|
401
390
|
if (!socket_utils_1.isWindows) {
|
|
@@ -412,9 +401,9 @@ async function startServer() {
|
|
|
412
401
|
}, 20).unref();
|
|
413
402
|
return new Promise(async (resolve, reject) => {
|
|
414
403
|
try {
|
|
415
|
-
server.listen(
|
|
404
|
+
server.listen(socketPath, async () => {
|
|
416
405
|
try {
|
|
417
|
-
logger_1.serverLogger.log(`Started listening on: ${
|
|
406
|
+
logger_1.serverLogger.log(`Started listening on: ${socketPath}`);
|
|
418
407
|
// this triggers the storage of the lock file hash
|
|
419
408
|
daemonIsOutdated();
|
|
420
409
|
if (!(0, shutdown_utils_1.getWatcherInstance)()) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tmp-dir.d.ts","sourceRoot":"","sources":["../../../../../packages/nx/src/daemon/tmp-dir.ts"],"names":[],"mappings":"AAYA,eAAO,MAAM,gCAAgC,QAG5C,CAAC;AAEF,eAAO,MAAM,sBAAsB,QAGlC,CAAC;AAEF,eAAO,MAAM,kBAAkB,cAK5B,CAAC;AAEJ,wBAAgB,eAAe,CAAC,KAAK,CAAC,EAAE,MAAM,UAI7C;AAED,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,MAAM,QAElD;AAED,wBAAgB,gBAAgB,YAO/B;
|
|
1
|
+
{"version":3,"file":"tmp-dir.d.ts","sourceRoot":"","sources":["../../../../../packages/nx/src/daemon/tmp-dir.ts"],"names":[],"mappings":"AAYA,eAAO,MAAM,gCAAgC,QAG5C,CAAC;AAEF,eAAO,MAAM,sBAAsB,QAGlC,CAAC;AAEF,eAAO,MAAM,kBAAkB,cAK5B,CAAC;AAEJ,wBAAgB,eAAe,CAAC,KAAK,CAAC,EAAE,MAAM,UAI7C;AAED,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,MAAM,QAElD;AAED,wBAAgB,gBAAgB,YAO/B;AAUD;;;GAGG;AACH,wBAAgB,YAAY,CAAC,aAAa,UAAQ,UAYjD;AAED,wBAAgB,eAAe,SAI9B"}
|
package/src/daemon/tmp-dir.js
CHANGED
|
@@ -43,6 +43,7 @@ function isDaemonDisabled() {
|
|
|
43
43
|
function socketDirName() {
|
|
44
44
|
const hasher = (0, crypto_1.createHash)('sha256');
|
|
45
45
|
hasher.update(workspace_root_1.workspaceRoot.toLowerCase());
|
|
46
|
+
hasher.update(String(process.pid));
|
|
46
47
|
const unique = hasher.digest('hex').substring(0, 20);
|
|
47
48
|
return (0, path_1.join)(tmp_1.tmpdir, unique);
|
|
48
49
|
}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
2
|
+
"version": 2,
|
|
3
|
+
"title": "Noop",
|
|
4
|
+
"description": "An executor that does nothing.",
|
|
5
|
+
"type": "object",
|
|
6
|
+
"cli": "nx",
|
|
7
|
+
"outputCapture": "pipe",
|
|
8
|
+
"properties": {},
|
|
9
|
+
"additionalProperties": true
|
|
10
10
|
}
|