@smoothbricks/nx-plugin 0.5.5 → 0.5.7
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/README.md +59 -11
- package/dist/ensure-built-receipt.d.ts +2 -2
- package/dist/ensure-built-receipt.d.ts.map +1 -1
- package/dist/ensure-built-receipt.js +7 -2
- package/dist/ensure-built-witness.d.ts +12 -1
- package/dist/ensure-built-witness.d.ts.map +1 -1
- package/dist/ensure-built-witness.js +32 -0
- package/dist/ensure-built.d.ts +2 -2
- package/dist/ensure-built.d.ts.map +1 -1
- package/dist/ensure-built.js +27 -5
- package/dist/executors/all-verdicts/executor.d.ts +35 -0
- package/dist/executors/all-verdicts/executor.d.ts.map +1 -0
- package/dist/executors/all-verdicts/executor.js +133 -0
- package/dist/executors/all-verdicts/schema.d.ts +10 -0
- package/dist/executors/all-verdicts/schema.d.ts.map +1 -0
- package/dist/executors/all-verdicts/schema.js +2 -0
- package/dist/executors/bounded-exec/executor.d.ts.map +1 -1
- package/dist/executors/bounded-exec/executor.js +48 -11
- package/dist/executors/bounded-exec/progress.d.ts +1 -3
- package/dist/executors/bounded-exec/progress.d.ts.map +1 -1
- package/dist/executors/bounded-exec/progress.js +1 -2
- package/dist/executors/bounded-exec/runner-hook.d.ts +2 -0
- package/dist/executors/bounded-exec/runner-hook.d.ts.map +1 -0
- package/dist/executors/bounded-exec/runner-hook.js +301 -0
- package/dist/executors/bounded-exec/runner-lifecycle.d.ts +18 -0
- package/dist/executors/bounded-exec/runner-lifecycle.d.ts.map +1 -0
- package/dist/executors/bounded-exec/runner-lifecycle.js +92 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -1
- package/dist/producer-receipts.d.ts +24 -1
- package/dist/producer-receipts.d.ts.map +1 -1
- package/dist/producer-receipts.js +91 -60
- package/executors.json +5 -0
- package/managed/raw/git-format-staged.yml +16 -3
- package/managed/raw/patches/nx@23.2.1.patch +397 -33
- package/package.json +2 -2
- package/src/ensure-built-receipt.ts +8 -2
- package/src/ensure-built-witness.ts +29 -1
- package/src/ensure-built.ts +39 -7
- package/src/executors/all-verdicts/executor.test.ts +135 -0
- package/src/executors/all-verdicts/executor.ts +164 -0
- package/src/executors/all-verdicts/schema.json +22 -0
- package/src/executors/all-verdicts/schema.ts +10 -0
- package/src/executors/bounded-exec/cargo-progress-host.test.ts +332 -0
- package/src/executors/bounded-exec/executor.test.ts +89 -42
- package/src/executors/bounded-exec/executor.ts +45 -11
- package/src/executors/bounded-exec/progress.test.ts +1 -14
- package/src/executors/bounded-exec/progress.ts +2 -5
- package/src/executors/bounded-exec/runner-hook.test.ts +193 -0
- package/src/executors/bounded-exec/runner-hook.ts +292 -0
- package/src/executors/bounded-exec/runner-lifecycle.test.ts +82 -0
- package/src/executors/bounded-exec/runner-lifecycle.ts +102 -0
- package/src/index.test.ts +7 -5
- package/src/index.ts +4 -1
- package/src/nx-daemon-start-never.test.ts +137 -0
- package/src/producer-receipts.test.ts +99 -0
- package/src/producer-receipts.ts +111 -58
- package/test-timings.json +101 -96
|
@@ -346,7 +346,7 @@ index 757fd200dbd83f335c9868987e4135d4b7b580cb..1bf7e571cc66d3483f8b2ebb7b73ad8b
|
|
|
346
346
|
}
|
|
347
347
|
// Must be sync for the help output use case
|
|
348
348
|
diff --git a/dist/src/daemon/client/client.d.ts b/dist/src/daemon/client/client.d.ts
|
|
349
|
-
index 9bd7b61bf9ad94c72a198dfe6f15fbcb68dfaac3..
|
|
349
|
+
index 9bd7b61bf9ad94c72a198dfe6f15fbcb68dfaac3..6b982fae848cc82a310eee9a1036be1a1cbb1985 100644
|
|
350
350
|
--- a/dist/src/daemon/client/client.d.ts
|
|
351
351
|
+++ b/dist/src/daemon/client/client.d.ts
|
|
352
352
|
@@ -2,7 +2,7 @@ import { ChildProcess } from 'child_process';
|
|
@@ -358,7 +358,22 @@ index 9bd7b61bf9ad94c72a198dfe6f15fbcb68dfaac3..c552b4b252c2d0496312ddb6ff481699
|
|
|
358
358
|
import { PostTasksExecutionContext, PreTasksExecutionContext } from '../../project-graph/plugins/public-api';
|
|
359
359
|
import { ConfigurationSourceMaps } from '../../project-graph/utils/project-configuration/source-maps';
|
|
360
360
|
import type { FlushSyncGeneratorChangesResult, SyncGeneratorRunResult } from '../../utils/sync-generators';
|
|
361
|
-
@@ -
|
|
361
|
+
@@ -48,6 +48,14 @@ export declare class DaemonClient {
|
|
362
|
+
private projectGraphListenerFramingFailures;
|
|
363
|
+
private projectGraphListenerCallbacks;
|
|
364
|
+
enabled(): boolean;
|
|
365
|
+
+ private continuedWithoutDaemon;
|
|
366
|
+
+ /**
|
|
367
|
+
+ * `viaDaemon()`, or `withoutDaemon()` in this process when the daemon stopped
|
|
368
|
+
+ * under a client that may never start one (NX_DAEMON_START=never).
|
|
369
|
+
+ */
|
|
370
|
+
+ orWithoutDaemon<T>(viaDaemon: () => Promise<T>, withoutDaemon: () => T | Promise<T>): Promise<T>;
|
|
371
|
+
+ /** Lets the stopped daemon's connection go, and says so once per process. */
|
|
372
|
+
+ continueWithoutDaemon(error: Error): void;
|
|
373
|
+
reset(): void;
|
|
374
|
+
private getSocketPath;
|
|
375
|
+
requestShutdown(): Promise<void>;
|
|
376
|
+
@@ -89,9 +97,6 @@ export declare class DaemonClient {
|
|
362
377
|
getFilesInDirectory(dir: string): Promise<string[]>;
|
|
363
378
|
hashGlob(globs: string[], exclude?: string[]): Promise<string>;
|
|
364
379
|
hashMultiGlob(globGroups: string[][]): Promise<string[]>;
|
|
@@ -369,7 +384,7 @@ index 9bd7b61bf9ad94c72a198dfe6f15fbcb68dfaac3..c552b4b252c2d0496312ddb6ff481699
|
|
|
369
384
|
flushSyncGeneratorChangesToDisk(generators: string[]): Promise<FlushSyncGeneratorChangesResult>;
|
|
370
385
|
getRegisteredSyncGenerators(): Promise<{
|
|
371
386
|
diff --git a/dist/src/daemon/client/client.js b/dist/src/daemon/client/client.js
|
|
372
|
-
index cebfd6d1f8ddb2c5b93dcb847904aa9ab0553de6..
|
|
387
|
+
index cebfd6d1f8ddb2c5b93dcb847904aa9ab0553de6..64c9d05890139ad8259e3d01ee86dd0de1f5005f 100644
|
|
373
388
|
--- a/dist/src/daemon/client/client.js
|
|
374
389
|
+++ b/dist/src/daemon/client/client.js
|
|
375
390
|
@@ -40,7 +40,6 @@ const nx_console_1 = require("../message-types/nx-console");
|
|
@@ -380,7 +395,7 @@ index cebfd6d1f8ddb2c5b93dcb847904aa9ab0553de6..a1aeb1ac56800af773219df4f55ee95e
|
|
|
380
395
|
const update_workspace_context_1 = require("../message-types/update-workspace-context");
|
|
381
396
|
const tmp_dir_1 = require("../tmp-dir");
|
|
382
397
|
const sandbox_socket_hint_1 = require("../sandbox-socket-hint");
|
|
383
|
-
@@ -135,
|
|
398
|
+
@@ -135,12 +134,51 @@ class DaemonClient {
|
|
384
399
|
});
|
|
385
400
|
this._enabled = false;
|
|
386
401
|
}
|
|
@@ -396,7 +411,43 @@ index cebfd6d1f8ddb2c5b93dcb847904aa9ab0553de6..a1aeb1ac56800af773219df4f55ee95e
|
|
|
396
411
|
else {
|
|
397
412
|
this._enabled = true;
|
|
398
413
|
}
|
|
399
|
-
|
|
414
|
+
}
|
|
415
|
+
return this._enabled;
|
|
416
|
+
}
|
|
417
|
+
+ /**
|
|
418
|
+
+ * `viaDaemon()`, or `withoutDaemon()` in this process when the daemon stopped
|
|
419
|
+
+ * under a client that may never start one (NX_DAEMON_START=never). That stop
|
|
420
|
+
+ * turned the daemon off for this process alone, so once the connection is let
|
|
421
|
+
+ * go `enabled()` is false, and a `withoutDaemon` that calls its own caller
|
|
422
|
+
+ * again takes that caller's in-process path.
|
|
423
|
+
+ */
|
|
424
|
+
+ async orWithoutDaemon(viaDaemon, withoutDaemon) {
|
|
425
|
+
+ try {
|
|
426
|
+
+ return await viaDaemon();
|
|
427
|
+
+ }
|
|
428
|
+
+ catch (e) {
|
|
429
|
+
+ if (!e?.daemonStartForbidden) {
|
|
430
|
+
+ throw e;
|
|
431
|
+
+ }
|
|
432
|
+
+ this.continueWithoutDaemon(e);
|
|
433
|
+
+ return withoutDaemon();
|
|
434
|
+
+ }
|
|
435
|
+
+ }
|
|
436
|
+
+ /**
|
|
437
|
+
+ * Lets the stopped daemon's connection go, and says so once per process: every
|
|
438
|
+
+ * request still queued for it fails the same way and continues the same way.
|
|
439
|
+
+ */
|
|
440
|
+
+ continueWithoutDaemon(error) {
|
|
441
|
+
+ if (!this.continuedWithoutDaemon) {
|
|
442
|
+
+ this.continuedWithoutDaemon = true;
|
|
443
|
+
+ output_1.output.note({ title: `${error.message} Continuing without the daemon.` });
|
|
444
|
+
+ }
|
|
445
|
+
+ this.reset();
|
|
446
|
+
+ }
|
|
447
|
+
reset() {
|
|
448
|
+
this.socketMessenger?.close();
|
|
449
|
+
this.socketMessenger = null;
|
|
450
|
+
@@ -668,27 +706,6 @@ class DaemonClient {
|
|
400
451
|
};
|
|
401
452
|
return this.sendToDaemonViaQueue(message);
|
|
402
453
|
}
|
|
@@ -424,24 +475,16 @@ index cebfd6d1f8ddb2c5b93dcb847904aa9ab0553de6..a1aeb1ac56800af773219df4f55ee95e
|
|
|
424
475
|
getSyncGeneratorChanges(generators) {
|
|
425
476
|
const message = {
|
|
426
477
|
type: get_sync_generator_changes_1.GET_SYNC_GENERATOR_CHANGES,
|
|
427
|
-
@@ -813,8 +
|
|
478
|
+
@@ -813,8 +830,15 @@ class DaemonClient {
|
|
428
479
|
}
|
|
429
480
|
}
|
|
430
481
|
if (!probe.available) {
|
|
431
482
|
- // Carried as a value so no other caller's probe can substitute for it.
|
|
432
483
|
- daemonPid = await this.startInBackground(probe.refusal);
|
|
433
484
|
+ if (process.env.NX_DAEMON_START === 'never') {
|
|
434
|
-
+ // The daemon enabled() found running has stopped since.
|
|
435
|
-
+ // successor is its starter's (cowshed's keeper) to start, never
|
|
436
|
-
+ // this client's. The stop belongs to that owner, not to the
|
|
437
|
-
+ // workspace, so the daemon is off for this process alone: no
|
|
438
|
-
+ // marker that an ordinary terminal would inherit.
|
|
439
|
-
+ const reason = 'The Nx daemon this client was using stopped, and NX_DAEMON_START=never: this client never starts a daemon.';
|
|
440
|
-
+ (0, tmp_dir_1.disableDaemonForThisProcess)(reason);
|
|
485
|
+
+ // The daemon enabled() found running has stopped since.
|
|
441
486
|
+ this._daemonStatus = DaemonStatus.DISCONNECTED;
|
|
442
|
-
+
|
|
443
|
-
+ error.daemonStartForbidden = true;
|
|
444
|
-
+ throw error;
|
|
487
|
+
+ throw daemonStartForbidden();
|
|
445
488
|
+ }
|
|
446
489
|
+ else {
|
|
447
490
|
+ // Carried as a value so no other caller's probe can substitute for it.
|
|
@@ -450,7 +493,7 @@ index cebfd6d1f8ddb2c5b93dcb847904aa9ab0553de6..a1aeb1ac56800af773219df4f55ee95e
|
|
|
450
493
|
}
|
|
451
494
|
this.setUpConnection();
|
|
452
495
|
this._daemonStatus = DaemonStatus.CONNECTED;
|
|
453
|
-
@@ -831,13 +
|
|
496
|
+
@@ -831,13 +855,24 @@ class DaemonClient {
|
|
454
497
|
}
|
|
455
498
|
}
|
|
456
499
|
async sendToDaemonViaQueue(messageToDaemon, parser) {
|
|
@@ -482,7 +525,7 @@ index cebfd6d1f8ddb2c5b93dcb847904aa9ab0553de6..a1aeb1ac56800af773219df4f55ee95e
|
|
|
482
525
|
}
|
|
483
526
|
setUpConnection() {
|
|
484
527
|
const socketPath = this.getSocketPath();
|
|
485
|
-
@@ -846,7 +
|
|
528
|
+
@@ -846,7 +881,13 @@ class DaemonClient {
|
|
486
529
|
// sendMessageToDaemon method uses a keep-alive setTimeout to
|
|
487
530
|
// explicitly hold the event loop open while awaiting a response.
|
|
488
531
|
socket.unref();
|
|
@@ -497,7 +540,29 @@ index cebfd6d1f8ddb2c5b93dcb847904aa9ab0553de6..a1aeb1ac56800af773219df4f55ee95e
|
|
|
497
540
|
// it's ok for the daemon to terminate if the client doesn't wait on
|
|
498
541
|
// any messages from the daemon
|
|
499
542
|
if (this.queue.isEmpty()) {
|
|
500
|
-
@@ -
|
|
543
|
+
@@ -892,6 +933,12 @@ class DaemonClient {
|
|
544
|
+
else {
|
|
545
|
+
error = daemonProcessException(err.toString());
|
|
546
|
+
}
|
|
547
|
+
+ if (process.env.NX_DAEMON_START === 'never' && !error.daemonPermissionError) {
|
|
548
|
+
+ // The daemon went away under this request (a restart ends the
|
|
549
|
+
+ // socket it was written to). A client that may never start one
|
|
550
|
+
+ // continues without it; what failed stays the error's cause.
|
|
551
|
+
+ error = daemonStartForbidden(error);
|
|
552
|
+
+ }
|
|
553
|
+
this.currentReject(error);
|
|
554
|
+
this.socketMessenger?.close();
|
|
555
|
+
});
|
|
556
|
+
@@ -936,7 +983,7 @@ class DaemonClient {
|
|
557
|
+
else {
|
|
558
|
+
// Failed to reconnect after all attempts, reject the pending request
|
|
559
|
+
if (this.currentReject) {
|
|
560
|
+
- this.currentReject(error);
|
|
561
|
+
+ this.currentReject(process.env.NX_DAEMON_START === 'never' ? daemonStartForbidden() : error);
|
|
562
|
+
}
|
|
563
|
+
}
|
|
564
|
+
}
|
|
565
|
+
@@ -1132,8 +1179,11 @@ class DaemonClient {
|
|
501
566
|
*/
|
|
502
567
|
const { available, refusal: polled } = await this.waitForServerToBeAvailable({ ignoreVersionMismatch: true });
|
|
503
568
|
if (available) {
|
|
@@ -511,7 +576,7 @@ index cebfd6d1f8ddb2c5b93dcb847904aa9ab0553de6..a1aeb1ac56800af773219df4f55ee95e
|
|
|
511
576
|
}
|
|
512
577
|
else {
|
|
513
578
|
// A permission refusal from either source wins, then the poll's errno,
|
|
514
|
-
@@ -1200,6 +
|
|
579
|
+
@@ -1200,6 +1250,26 @@ function isDocker() {
|
|
515
580
|
function nxJsonIsNotPresent() {
|
|
516
581
|
return !(0, nx_json_1.hasNxJson)(workspace_root_1.workspaceRoot);
|
|
517
582
|
}
|
|
@@ -538,6 +603,28 @@ index cebfd6d1f8ddb2c5b93dcb847904aa9ab0553de6..a1aeb1ac56800af773219df4f55ee95e
|
|
|
538
603
|
/**
|
|
539
604
|
* The operating system refused the connection. Most often the socket belongs to
|
|
540
605
|
* another user, which is the guarantee the owner-only socket directory buys —
|
|
606
|
+
@@ -1226,6 +1296,21 @@ function daemonPermissionException(socketPath, cause) {
|
|
607
|
+
error.daemonPermissionError = true;
|
|
608
|
+
return error;
|
|
609
|
+
}
|
|
610
|
+
+/**
|
|
611
|
+
+ * The daemon this client was using stopped, and the client may never start one
|
|
612
|
+
+ * (NX_DAEMON_START=never). Its successor is its starter's (cowshed's keeper) to
|
|
613
|
+
+ * start, never this client's. The stop belongs to that owner, not to the
|
|
614
|
+
+ * workspace, so the daemon is off for this process alone: no marker that an
|
|
615
|
+
+ * ordinary terminal would inherit. `cause` is the connection failure that
|
|
616
|
+
+ * showed the stop, when one did.
|
|
617
|
+
+ */
|
|
618
|
+
+function daemonStartForbidden(cause) {
|
|
619
|
+
+ const reason = 'The Nx daemon this client was using stopped, and NX_DAEMON_START=never: this client never starts a daemon.';
|
|
620
|
+
+ (0, tmp_dir_1.disableDaemonForThisProcess)(reason);
|
|
621
|
+
+ const error = cause === undefined ? new Error(reason) : new Error(reason, { cause });
|
|
622
|
+
+ error.daemonStartForbidden = true;
|
|
623
|
+
+ return error;
|
|
624
|
+
+}
|
|
625
|
+
/**
|
|
626
|
+
* Exported for testing: the `internalDaemonError` tag decides whether a daemon
|
|
627
|
+
* failure degrades to a daemonless graph build or aborts the command.
|
|
541
628
|
diff --git a/dist/src/daemon/message-types/daemon-message.d.ts b/dist/src/daemon/message-types/daemon-message.d.ts
|
|
542
629
|
index 9dd6123ad6d9adb20a07f7db56fc476be78cbcca..0b1ee217729d63a29806cf6c38d0fc5d4a2161a5 100644
|
|
543
630
|
--- a/dist/src/daemon/message-types/daemon-message.d.ts
|
|
@@ -1361,7 +1448,7 @@ index b1c143e244efd435b28642ed86e999d6c86f7d94..c68bcacb9bc46babaa86ea0ac212e79d
|
|
|
1361
1448
|
(0, shutdown_utils_1.storeOutputWatcherInstance)(await (0, watcher_1.watchOutputFiles)(server, handle_outputs_changes_1.handleOutputsChanges));
|
|
1362
1449
|
}
|
|
1363
1450
|
diff --git a/dist/src/daemon/server/shutdown-utils.d.ts b/dist/src/daemon/server/shutdown-utils.d.ts
|
|
1364
|
-
index 698fcf9e061b8e0b37057a6318614dbe6d290b9e..
|
|
1451
|
+
index 698fcf9e061b8e0b37057a6318614dbe6d290b9e..5470c4935d0a5f230dde3ece13bfb6ba9a58e10b 100644
|
|
1365
1452
|
--- a/dist/src/daemon/server/shutdown-utils.d.ts
|
|
1366
1453
|
+++ b/dist/src/daemon/server/shutdown-utils.d.ts
|
|
1367
1454
|
@@ -1,6 +1,6 @@
|
|
@@ -1372,20 +1459,83 @@ index 698fcf9e061b8e0b37057a6318614dbe6d290b9e..422d244931ceb3a7143fc06e23d113bc
|
|
|
1372
1459
|
export declare function storeWatcherInstance(instance: Watcher): void;
|
|
1373
1460
|
export declare function getWatcherInstance(): Watcher;
|
|
1374
1461
|
export declare function storeOutputWatcherInstance(instance: Watcher): void;
|
|
1462
|
+
@@ -12,6 +12,8 @@ interface HandleServerProcessTerminationParams {
|
|
1463
|
+
}
|
|
1464
|
+
export declare function handleServerProcessTermination({ server, reason, sockets, }: HandleServerProcessTerminationParams): Promise<void>;
|
|
1465
|
+
export declare function handleServerProcessTerminationWithRestart({ server, reason, sockets, }: HandleServerProcessTerminationParams): Promise<void>;
|
|
1466
|
+
+/** Starts a restarting daemon's successor. Exported for testing: the restart's log descriptors must not outlive it. */
|
|
1467
|
+
+export declare function startNewDaemonInBackground(): Promise<void>;
|
|
1468
|
+
export declare function resetInactivityTimeout(cb: () => void): void;
|
|
1469
|
+
export declare function respondToClient(socket: Socket, response: Buffer, description: string): Promise<unknown>;
|
|
1470
|
+
/**
|
|
1375
1471
|
diff --git a/dist/src/daemon/server/shutdown-utils.js b/dist/src/daemon/server/shutdown-utils.js
|
|
1376
|
-
index a449f2fb3c864bc9d3d710078418c8a05879aa84..
|
|
1472
|
+
index a449f2fb3c864bc9d3d710078418c8a05879aa84..17d9f2a7569a1332105b8e1106a2b8fdfb8a3e96 100644
|
|
1377
1473
|
--- a/dist/src/daemon/server/shutdown-utils.js
|
|
1378
1474
|
+++ b/dist/src/daemon/server/shutdown-utils.js
|
|
1379
|
-
@@ -
|
|
1475
|
+
@@ -11,6 +11,7 @@ exports.resetInactivityTimeout = resetInactivityTimeout;
|
|
1476
|
+
exports.respondToClient = respondToClient;
|
|
1477
|
+
exports.respondWithError = respondWithError;
|
|
1478
|
+
exports.respondWithErrorAndExit = respondWithErrorAndExit;
|
|
1479
|
+
+exports.startNewDaemonInBackground = startNewDaemonInBackground;
|
|
1480
|
+
const workspace_root_1 = require("../../utils/workspace-root");
|
|
1481
|
+
const logger_1 = require("../logger");
|
|
1482
|
+
const socket_utils_1 = require("../socket-utils");
|
|
1483
|
+
@@ -23,16 +24,20 @@ const analytics_1 = require("../../analytics");
|
|
1484
|
+
const child_process_1 = require("child_process");
|
|
1485
|
+
const path_1 = require("path");
|
|
1380
1486
|
const node_fs_1 = require("node:fs");
|
|
1381
|
-
|
|
1487
|
+
-const promises_1 = require("fs/promises");
|
|
1382
1488
|
const tmp_dir_1 = require("../tmp-dir");
|
|
1383
1489
|
-exports.SERVER_INACTIVITY_TIMEOUT_MS = 10800000; // 10800000 ms = 3 hours
|
|
1384
1490
|
+exports.SERVER_INACTIVITY_TIMEOUT_MS = 300000; // 300000 ms = 5 minutes
|
|
1385
1491
|
async function startNewDaemonInBackground() {
|
|
1386
1492
|
(0, node_fs_1.mkdirSync)(tmp_dir_1.DAEMON_DIR_FOR_CURRENT_WORKSPACE, { recursive: true });
|
|
1387
1493
|
if (!(0, node_fs_1.existsSync)(tmp_dir_1.DAEMON_OUTPUT_LOG_FILE)) {
|
|
1388
|
-
|
|
1494
|
+
(0, node_fs_1.writeFileSync)(tmp_dir_1.DAEMON_OUTPUT_LOG_FILE, '');
|
|
1495
|
+
}
|
|
1496
|
+
- const out = await (0, promises_1.open)(tmp_dir_1.DAEMON_OUTPUT_LOG_FILE, 'a');
|
|
1497
|
+
- const err = await (0, promises_1.open)(tmp_dir_1.DAEMON_OUTPUT_LOG_FILE, 'a');
|
|
1498
|
+
+ // Redirect the successor's stdout/stderr into the log file. The child dup's
|
|
1499
|
+
+ // these descriptors at spawn, so they are closed right after it, as the
|
|
1500
|
+
+ // client's start does: a `FileHandle` left to garbage collection is a fatal
|
|
1501
|
+
+ // ERR_INVALID_STATE on Node >=26, which ended the restarting daemon with the
|
|
1502
|
+
+ // socket its clients were still writing to.
|
|
1503
|
+
+ const out = (0, node_fs_1.openSync)(tmp_dir_1.DAEMON_OUTPUT_LOG_FILE, 'a');
|
|
1504
|
+
+ const err = (0, node_fs_1.openSync)(tmp_dir_1.DAEMON_OUTPUT_LOG_FILE, 'a');
|
|
1505
|
+
// Use require.resolve to find the currently installed version's start.js
|
|
1506
|
+
// instead of using __dirname which points to the old running daemon's path
|
|
1507
|
+
// Resolve from workspace root to pick up the correct symlink target
|
|
1508
|
+
@@ -50,14 +55,21 @@ async function startNewDaemonInBackground() {
|
|
1509
|
+
logger_1.serverLogger.log(`Restarting daemon with script: ${startScriptPath}`);
|
|
1510
|
+
logger_1.serverLogger.log(`Old daemon __dirname: ${__dirname}`);
|
|
1511
|
+
logger_1.serverLogger.log(`Current process.execPath: ${process.execPath}`);
|
|
1512
|
+
- const backgroundProcess = (0, child_process_1.spawn)(process.execPath, [startScriptPath], {
|
|
1513
|
+
- cwd: workspace_root_1.workspaceRoot,
|
|
1514
|
+
- stdio: ['ignore', out.fd, err.fd],
|
|
1515
|
+
- detached: true,
|
|
1516
|
+
- windowsHide: true,
|
|
1517
|
+
- shell: false,
|
|
1518
|
+
- env: process.env,
|
|
1519
|
+
- });
|
|
1520
|
+
+ let backgroundProcess;
|
|
1521
|
+
+ try {
|
|
1522
|
+
+ backgroundProcess = (0, child_process_1.spawn)(process.execPath, [startScriptPath], {
|
|
1523
|
+
+ cwd: workspace_root_1.workspaceRoot,
|
|
1524
|
+
+ stdio: ['ignore', out, err],
|
|
1525
|
+
+ detached: true,
|
|
1526
|
+
+ windowsHide: true,
|
|
1527
|
+
+ shell: false,
|
|
1528
|
+
+ env: process.env,
|
|
1529
|
+
+ });
|
|
1530
|
+
+ }
|
|
1531
|
+
+ finally {
|
|
1532
|
+
+ (0, node_fs_1.closeSync)(out);
|
|
1533
|
+
+ (0, node_fs_1.closeSync)(err);
|
|
1534
|
+
+ }
|
|
1535
|
+
backgroundProcess.unref();
|
|
1536
|
+
logger_1.serverLogger.log('Started new daemon process in background');
|
|
1537
|
+
}
|
|
1538
|
+
@@ -85,15 +97,31 @@ async function handleServerProcessTerminationWithRestart({ server, reason, socke
|
|
1389
1539
|
await startNewDaemonInBackground();
|
|
1390
1540
|
await performShutdown(server, reason, sockets);
|
|
1391
1541
|
}
|
|
@@ -1686,6 +1836,26 @@ index d21213e8de9eba5e1edcde9e7db474ec7266272b..584785648eefa62878cc914a2d91bace
|
|
|
1686
1836
|
const result = planResult[canonicalTaskId] ?? null;
|
|
1687
1837
|
hashInputsCache.set(taskId, result);
|
|
1688
1838
|
return result;
|
|
1839
|
+
diff --git a/dist/src/hasher/create-task-hasher.js b/dist/src/hasher/create-task-hasher.js
|
|
1840
|
+
index 91845891cea3e6ae16e241457f843647bc00859b..c481d7a73c1d3a0c6085cadb9e45e5533f246f0a 100644
|
|
1841
|
+
--- a/dist/src/hasher/create-task-hasher.js
|
|
1842
|
+
+++ b/dist/src/hasher/create-task-hasher.js
|
|
1843
|
+
@@ -6,7 +6,14 @@ const build_project_graph_1 = require("../project-graph/build-project-graph");
|
|
1844
|
+
const task_hasher_1 = require("./task-hasher");
|
|
1845
|
+
function createTaskHasher(projectGraph, nxJson, runnerOptions) {
|
|
1846
|
+
if (client_1.daemonClient.enabled()) {
|
|
1847
|
+
- return new task_hasher_1.DaemonBasedTaskHasher(client_1.daemonClient, runnerOptions);
|
|
1848
|
+
+ // A daemon that stops under a client that may never start one leaves the
|
|
1849
|
+
+ // run to hash in this process, over a graph built here: the in-process
|
|
1850
|
+
+ // hasher reads the file data of this process's build, which a graph from
|
|
1851
|
+
+ // the daemon never brought.
|
|
1852
|
+
+ return new task_hasher_1.DaemonBasedTaskHasher(client_1.daemonClient, runnerOptions, async () => {
|
|
1853
|
+
+ const { createProjectGraphAsync } = require('../project-graph/project-graph');
|
|
1854
|
+
+ return createTaskHasher(await createProjectGraphAsync({ exitOnError: false }), nxJson, runnerOptions);
|
|
1855
|
+
+ });
|
|
1856
|
+
}
|
|
1857
|
+
else {
|
|
1858
|
+
const { rustReferences } = (0, build_project_graph_1.getFileMap)();
|
|
1689
1859
|
diff --git a/dist/src/hasher/hash-plan-inspector.d.ts b/dist/src/hasher/hash-plan-inspector.d.ts
|
|
1690
1860
|
index edb5a7bf425cfd04ad243b0d30a21f1cf6061140..316ca4b91dbf788c9f41d5a2acfbb077590d5db2 100644
|
|
1691
1861
|
--- a/dist/src/hasher/hash-plan-inspector.d.ts
|
|
@@ -1724,6 +1894,58 @@ index 332accab74919348073538f4198693328bf68193..a56864600a5e7a9f9e40adea9a7bfc9e
|
|
|
1724
1894
|
const plansReference = this.planner.getPlansReference(taskIds, taskGraph);
|
|
1725
1895
|
return this.inspector.inspectInputs(plansReference);
|
|
1726
1896
|
}
|
|
1897
|
+
diff --git a/dist/src/hasher/task-hasher.d.ts b/dist/src/hasher/task-hasher.d.ts
|
|
1898
|
+
index cf08aa6c0fb9bcbb2fbf10e554f2e0397b1b13d7..f67c434e41a776343e11225bdd12f02cd7570d0c 100644
|
|
1899
|
+
--- a/dist/src/hasher/task-hasher.d.ts
|
|
1900
|
+
+++ b/dist/src/hasher/task-hasher.d.ts
|
|
1901
|
+
@@ -75,7 +75,14 @@ export type Hasher = TaskHasher;
|
|
1902
|
+
export declare class DaemonBasedTaskHasher implements TaskHasher {
|
|
1903
|
+
private readonly daemonClient;
|
|
1904
|
+
private readonly runnerOptions;
|
|
1905
|
+
- constructor(daemonClient: DaemonClient, runnerOptions: any);
|
|
1906
|
+
+ private readonly withoutDaemon;
|
|
1907
|
+
+ private inProcess;
|
|
1908
|
+
+ /**
|
|
1909
|
+
+ * `withoutDaemon` makes the hasher a run continues with in this process when
|
|
1910
|
+
+ * its daemon stops under a client that may never start one
|
|
1911
|
+
+ * (NX_DAEMON_START=never); it is made once, for every later hash.
|
|
1912
|
+
+ */
|
|
1913
|
+
+ constructor(daemonClient: DaemonClient, runnerOptions: any, withoutDaemon: () => Promise<TaskHasher>);
|
|
1914
|
+
hashTasks(tasks: Task[], taskGraph: TaskGraph, envOrPerTaskEnvs: NodeJS.ProcessEnv | Record<string, NodeJS.ProcessEnv>): Promise<Hash[]>;
|
|
1915
|
+
hashTask(task: Task, taskGraph?: TaskGraph, env?: NodeJS.ProcessEnv): Promise<Hash>;
|
|
1916
|
+
}
|
|
1917
|
+
diff --git a/dist/src/hasher/task-hasher.js b/dist/src/hasher/task-hasher.js
|
|
1918
|
+
index 482785eaf103f95831144f05f9b65a8677eca398..e1693b2163e2518b4889b0fa60227483028fc9af 100644
|
|
1919
|
+
--- a/dist/src/hasher/task-hasher.js
|
|
1920
|
+
+++ b/dist/src/hasher/task-hasher.js
|
|
1921
|
+
@@ -44,13 +44,25 @@ function normalizePerTaskEnvs(tasks, arg) {
|
|
1922
|
+
return arg;
|
|
1923
|
+
}
|
|
1924
|
+
class DaemonBasedTaskHasher {
|
|
1925
|
+
- constructor(daemonClient, runnerOptions) {
|
|
1926
|
+
+ /**
|
|
1927
|
+
+ * `withoutDaemon` makes the hasher a run continues with in this process when
|
|
1928
|
+
+ * its daemon stops under a client that may never start one
|
|
1929
|
+
+ * (NX_DAEMON_START=never); it is made once, for every later hash.
|
|
1930
|
+
+ */
|
|
1931
|
+
+ constructor(daemonClient, runnerOptions, withoutDaemon) {
|
|
1932
|
+
this.daemonClient = daemonClient;
|
|
1933
|
+
this.runnerOptions = runnerOptions;
|
|
1934
|
+
+ this.withoutDaemon = withoutDaemon;
|
|
1935
|
+
}
|
|
1936
|
+
async hashTasks(tasks, taskGraph, envOrPerTaskEnvs) {
|
|
1937
|
+
+ if (this.inProcess) {
|
|
1938
|
+
+ return (await this.inProcess).hashTasks(tasks, taskGraph, envOrPerTaskEnvs);
|
|
1939
|
+
+ }
|
|
1940
|
+
const collectInputs = (0, task_io_service_1.getTaskIOService)().hasTaskInputSubscribers();
|
|
1941
|
+
- return this.daemonClient.hashTasks(this.runnerOptions, tasks, taskGraph, normalizePerTaskEnvs(tasks, envOrPerTaskEnvs), process.cwd(), collectInputs);
|
|
1942
|
+
+ return this.daemonClient.orWithoutDaemon(() => this.daemonClient.hashTasks(this.runnerOptions, tasks, taskGraph, normalizePerTaskEnvs(tasks, envOrPerTaskEnvs), process.cwd(), collectInputs), () => {
|
|
1943
|
+
+ this.inProcess ??= this.withoutDaemon();
|
|
1944
|
+
+ return this.hashTasks(tasks, taskGraph, envOrPerTaskEnvs);
|
|
1945
|
+
+ });
|
|
1946
|
+
}
|
|
1947
|
+
async hashTask(task, taskGraph, env) {
|
|
1948
|
+
return (await this.hashTasks([task], taskGraph, {
|
|
1727
1949
|
diff --git a/dist/src/plugins/js/lock-file/bun-parser.js b/dist/src/plugins/js/lock-file/bun-parser.js
|
|
1728
1950
|
index 169563d598af64c8b74d00ab9815dd651650ec9d..0bd5e1f536b1e0e02843396e01b29dcece8293b0 100644
|
|
1729
1951
|
--- a/dist/src/plugins/js/lock-file/bun-parser.js
|
|
@@ -2215,8 +2437,33 @@ index 3659fdd1955d56e60cc0158d19ac55d59916d78e..92e6700adfc52a380b3e9e37b655fbc9
|
|
|
2215
2437
|
}
|
|
2216
2438
|
/**
|
|
2217
2439
|
* Returns the current session count for a phase. Useful for testing.
|
|
2440
|
+
diff --git a/dist/src/project-graph/plugins/tasks-execution-hooks.js b/dist/src/project-graph/plugins/tasks-execution-hooks.js
|
|
2441
|
+
index 83c97768834e3f56083d5e5c2ff52806f55e95a3..eb2a4b563448079be79b58540290f41c53d0025d 100644
|
|
2442
|
+
--- a/dist/src/project-graph/plugins/tasks-execution-hooks.js
|
|
2443
|
+
+++ b/dist/src/project-graph/plugins/tasks-execution-hooks.js
|
|
2444
|
+
@@ -31,8 +31,10 @@ async function runPreTasksExecution(pluginContext) {
|
|
2445
|
+
return envs;
|
|
2446
|
+
}
|
|
2447
|
+
else {
|
|
2448
|
+
- const envs = await client_1.daemonClient.runPreTasksExecution(pluginContext);
|
|
2449
|
+
- applyProcessEnvs(envs);
|
|
2450
|
+
+ return client_1.daemonClient.orWithoutDaemon(async () => {
|
|
2451
|
+
+ const envs = await client_1.daemonClient.runPreTasksExecution(pluginContext);
|
|
2452
|
+
+ applyProcessEnvs(envs);
|
|
2453
|
+
+ }, () => runPreTasksExecution(pluginContext));
|
|
2454
|
+
}
|
|
2455
|
+
}
|
|
2456
|
+
function applyProcessEnvs(envs) {
|
|
2457
|
+
@@ -62,6 +64,6 @@ async function runPostTasksExecution(context) {
|
|
2458
|
+
performance.measure(`postTasksExecution`, `postTasksExecution:start`, `postTasksExecution:end`);
|
|
2459
|
+
}
|
|
2460
|
+
else {
|
|
2461
|
+
- await client_1.daemonClient.runPostTasksExecution(context);
|
|
2462
|
+
+ await client_1.daemonClient.orWithoutDaemon(() => client_1.daemonClient.runPostTasksExecution(context), () => runPostTasksExecution(context));
|
|
2463
|
+
}
|
|
2464
|
+
}
|
|
2218
2465
|
diff --git a/dist/src/project-graph/project-graph.js b/dist/src/project-graph/project-graph.js
|
|
2219
|
-
index a23de7d0f27d7bc222ee09f4904f5d236510d01d..
|
|
2466
|
+
index a23de7d0f27d7bc222ee09f4904f5d236510d01d..b57c8ede62af0153311dd79bddb0b4b42507804d 100644
|
|
2220
2467
|
--- a/dist/src/project-graph/project-graph.js
|
|
2221
2468
|
+++ b/dist/src/project-graph/project-graph.js
|
|
2222
2469
|
@@ -149,14 +149,7 @@ function handleProjectGraphError(opts, e) {
|
|
@@ -2235,7 +2482,7 @@ index a23de7d0f27d7bc222ee09f4904f5d236510d01d..0d8514be79f2ed03c7cc2410ea0d91f7
|
|
|
2235
2482
|
}
|
|
2236
2483
|
else if (typeof e.message === 'string') {
|
|
2237
2484
|
const lines = e.message.split('\n');
|
|
2238
|
-
@@ -356,6 +349,
|
|
2485
|
+
@@ -356,6 +349,13 @@ async function createProjectGraphAndSourceMapsAsync(opts = {
|
|
2239
2486
|
(0, tmp_dir_1.markDaemonAsDisabled)(e.message);
|
|
2240
2487
|
return buildProjectGraphAndSourceMapsWithoutDaemon();
|
|
2241
2488
|
}
|
|
@@ -2243,8 +2490,7 @@ index a23de7d0f27d7bc222ee09f4904f5d236510d01d..0d8514be79f2ed03c7cc2410ea0d91f7
|
|
|
2243
2490
|
+ // The daemon stopped under a client that may not start one
|
|
2244
2491
|
+ // (NX_DAEMON_START=never). The client already turned the daemon off
|
|
2245
2492
|
+ // for this process alone; the command continues without it.
|
|
2246
|
-
+
|
|
2247
|
-
+ client_1.daemonClient.reset();
|
|
2493
|
+
+ client_1.daemonClient.continueWithoutDaemon(e);
|
|
2248
2494
|
+ return buildProjectGraphAndSourceMapsWithoutDaemon();
|
|
2249
2495
|
+ }
|
|
2250
2496
|
if (e.daemonPermissionError) {
|
|
@@ -3139,7 +3385,7 @@ index 6d3dd021b050be5c74803555b361b6502f9693c7..81e7fa2f866eb22eeabcc8d2802aec5e
|
|
|
3139
3385
|
private postRunSteps;
|
|
3140
3386
|
private scheduleNextTasksAndReleaseThreads;
|
|
3141
3387
|
diff --git a/dist/src/tasks-runner/task-orchestrator.js b/dist/src/tasks-runner/task-orchestrator.js
|
|
3142
|
-
index 0b446cbce811319a741165e42a0100e0570e0a2f..
|
|
3388
|
+
index 0b446cbce811319a741165e42a0100e0570e0a2f..e1989ccab6a0ddc3cea350ee60646bf092e3732b 100644
|
|
3143
3389
|
--- a/dist/src/tasks-runner/task-orchestrator.js
|
|
3144
3390
|
+++ b/dist/src/tasks-runner/task-orchestrator.js
|
|
3145
3391
|
@@ -29,6 +29,7 @@ const shared_running_task_1 = require("./running-tasks/shared-running-task");
|
|
@@ -3346,7 +3592,27 @@ index 0b446cbce811319a741165e42a0100e0570e0a2f..1fbd5f47637dd6fb1a7e7b073d062069
|
|
|
3346
3592
|
});
|
|
3347
3593
|
}));
|
|
3348
3594
|
await this.scheduleNextTasksAndReleaseThreads();
|
|
3349
|
-
@@ -
|
|
3595
|
+
@@ -1300,7 +1354,9 @@ class TaskOrchestrator {
|
|
3596
|
+
if (tasks.length === 0)
|
|
3597
|
+
return resultMap;
|
|
3598
|
+
if (this.daemon?.enabled()) {
|
|
3599
|
+
- const matches = await this.daemon.outputsHashesMatchBatch(tasks);
|
|
3600
|
+
+ // A daemon gone under a client that may never start one verifies
|
|
3601
|
+
+ // nothing: every output is copied, as below.
|
|
3602
|
+
+ const matches = await this.daemon.orWithoutDaemon(() => this.daemon.outputsHashesMatchBatch(tasks), () => tasks.map(() => false));
|
|
3603
|
+
for (let i = 0; i < tasks.length; i++) {
|
|
3604
|
+
resultMap.set(tasks[i].hash, !matches[i]);
|
|
3605
|
+
}
|
|
3606
|
+
@@ -1315,7 +1371,7 @@ class TaskOrchestrator {
|
|
3607
|
+
}
|
|
3608
|
+
async recordOutputsHashBatch(entries) {
|
|
3609
|
+
if (this.daemon?.enabled()) {
|
|
3610
|
+
- return this.daemon.recordOutputsHashBatch(entries);
|
|
3611
|
+
+ return this.daemon.orWithoutDaemon(() => this.daemon.recordOutputsHashBatch(entries), () => undefined);
|
|
3612
|
+
}
|
|
3613
|
+
}
|
|
3614
|
+
// endregion utils
|
|
3615
|
+
@@ -1376,6 +1432,7 @@ class TaskOrchestrator {
|
|
3350
3616
|
return this.cleanupPromise;
|
|
3351
3617
|
}
|
|
3352
3618
|
async performCleanup() {
|
|
@@ -3772,6 +4038,37 @@ index 7adf7fe48dbde78fa770ad37c5714985d78a7b8c..13e1858e5487a7d308a84cba1f379cde
|
|
|
3772
4038
|
if (!path) {
|
|
3773
4039
|
return null;
|
|
3774
4040
|
}
|
|
4041
|
+
diff --git a/dist/src/utils/sync-generators.js b/dist/src/utils/sync-generators.js
|
|
4042
|
+
index d753d65ac4e40380a4dda94a34bc60e0d233f452..796630a927c81afefc9a0ec8d4edb7a274cbe217 100644
|
|
4043
|
+
--- a/dist/src/utils/sync-generators.js
|
|
4044
|
+
+++ b/dist/src/utils/sync-generators.js
|
|
4045
|
+
@@ -40,7 +40,7 @@ async function getSyncGeneratorChanges(generators) {
|
|
4046
|
+
results = await runSyncGenerators(generators);
|
|
4047
|
+
}
|
|
4048
|
+
else {
|
|
4049
|
+
- results = await client_1.daemonClient.getSyncGeneratorChanges(generators);
|
|
4050
|
+
+ results = await client_1.daemonClient.orWithoutDaemon(() => client_1.daemonClient.getSyncGeneratorChanges(generators), () => runSyncGenerators(generators));
|
|
4051
|
+
}
|
|
4052
|
+
perf_hooks_1.performance.mark('get-sync-generators-changes:end');
|
|
4053
|
+
perf_hooks_1.performance.measure('get-sync-generators-changes', 'get-sync-generators-changes:start', 'get-sync-generators-changes:end');
|
|
4054
|
+
@@ -50,7 +50,7 @@ async function flushSyncGeneratorChanges(results) {
|
|
4055
|
+
if ((0, is_on_daemon_1.isOnDaemon)() || !client_1.daemonClient.enabled()) {
|
|
4056
|
+
return await flushSyncGeneratorChangesToDisk(results);
|
|
4057
|
+
}
|
|
4058
|
+
- return await client_1.daemonClient.flushSyncGeneratorChangesToDisk(results.map((r) => r.generatorName));
|
|
4059
|
+
+ return await client_1.daemonClient.orWithoutDaemon(() => client_1.daemonClient.flushSyncGeneratorChangesToDisk(results.map((r) => r.generatorName)), () => flushSyncGeneratorChanges(results));
|
|
4060
|
+
}
|
|
4061
|
+
async function collectAllRegisteredSyncGenerators(projectGraph, nxJson) {
|
|
4062
|
+
if (!client_1.daemonClient.enabled()) {
|
|
4063
|
+
@@ -61,7 +61,7 @@ async function collectAllRegisteredSyncGenerators(projectGraph, nxJson) {
|
|
4064
|
+
],
|
|
4065
|
+
};
|
|
4066
|
+
}
|
|
4067
|
+
- return await client_1.daemonClient.getRegisteredSyncGenerators();
|
|
4068
|
+
+ return await client_1.daemonClient.orWithoutDaemon(() => client_1.daemonClient.getRegisteredSyncGenerators(), () => collectAllRegisteredSyncGenerators(projectGraph, nxJson));
|
|
4069
|
+
}
|
|
4070
|
+
async function runSyncGenerator(tree, generatorSpecifier, projects) {
|
|
4071
|
+
try {
|
|
3775
4072
|
diff --git a/dist/src/utils/task-history.js b/dist/src/utils/task-history.js
|
|
3776
4073
|
index 34dbaa2a5a44e6b7d1f69a516756b30939877bd7..09f95b73572a0d411f26d42aac2cfbf0098311f4 100644
|
|
3777
4074
|
--- a/dist/src/utils/task-history.js
|
|
@@ -3819,7 +4116,7 @@ index 34dbaa2a5a44e6b7d1f69a516756b30939877bd7..09f95b73572a0d411f26d42aac2cfbf0
|
|
|
3819
4116
|
}
|
|
3820
4117
|
exports.TaskHistory = TaskHistory;
|
|
3821
4118
|
diff --git a/dist/src/utils/workspace-context.js b/dist/src/utils/workspace-context.js
|
|
3822
|
-
index a887d862c9c431d8cbbc0d44e26fd394b243fb9c..
|
|
4119
|
+
index a887d862c9c431d8cbbc0d44e26fd394b243fb9c..00460d17cea645491b99c2ffa06f1437fa6f7034 100644
|
|
3823
4120
|
--- a/dist/src/utils/workspace-context.js
|
|
3824
4121
|
+++ b/dist/src/utils/workspace-context.js
|
|
3825
4122
|
@@ -13,6 +13,9 @@ exports.getAllFileDataInContext = getAllFileDataInContext;
|
|
@@ -3832,7 +4129,7 @@ index a887d862c9c431d8cbbc0d44e26fd394b243fb9c..ead0324cffa7dac0a019a756ab990287
|
|
|
3832
4129
|
const perf_hooks_1 = require("perf_hooks");
|
|
3833
4130
|
const cache_directory_1 = require("./cache-directory");
|
|
3834
4131
|
const is_on_daemon_1 = require("../daemon/is-on-daemon");
|
|
3835
|
-
@@ -22,
|
|
4132
|
+
@@ -22,16 +25,98 @@ let workspaceContext;
|
|
3836
4133
|
function setupWorkspaceContext(workspaceRoot) {
|
|
3837
4134
|
const { WorkspaceContext } = require('../native');
|
|
3838
4135
|
perf_hooks_1.performance.mark('workspace-context');
|
|
@@ -3926,6 +4223,73 @@ index a887d862c9c431d8cbbc0d44e26fd394b243fb9c..ead0324cffa7dac0a019a756ab990287
|
|
|
3926
4223
|
async function getNxWorkspaceFilesFromContext(workspaceRoot, projectRootMap, useDaemonProcess = true) {
|
|
3927
4224
|
if (!useDaemonProcess || (0, is_on_daemon_1.isOnDaemon)() || !client_1.daemonClient.enabled()) {
|
|
3928
4225
|
ensureContextAvailable(workspaceRoot);
|
|
4226
|
+
return workspaceContext.getWorkspaceFiles(projectRootMap);
|
|
4227
|
+
}
|
|
4228
|
+
- return client_1.daemonClient.getWorkspaceFiles(projectRootMap);
|
|
4229
|
+
+ return client_1.daemonClient.orWithoutDaemon(() => client_1.daemonClient.getWorkspaceFiles(projectRootMap), () => getNxWorkspaceFilesFromContext(workspaceRoot, projectRootMap, useDaemonProcess));
|
|
4230
|
+
}
|
|
4231
|
+
/**
|
|
4232
|
+
* Sync method to get files matching globs from workspace context.
|
|
4233
|
+
@@ -50,7 +135,7 @@ async function globWithWorkspaceContext(workspaceRoot, globs, exclude) {
|
|
4234
|
+
return workspaceContext.glob(globs, exclude);
|
|
4235
|
+
}
|
|
4236
|
+
else {
|
|
4237
|
+
- return client_1.daemonClient.glob(globs, exclude);
|
|
4238
|
+
+ return client_1.daemonClient.orWithoutDaemon(() => client_1.daemonClient.glob(globs, exclude), () => globWithWorkspaceContext(workspaceRoot, globs, exclude));
|
|
4239
|
+
}
|
|
4240
|
+
}
|
|
4241
|
+
async function multiGlobWithWorkspaceContext(workspaceRoot, globs, exclude) {
|
|
4242
|
+
@@ -58,21 +143,21 @@ async function multiGlobWithWorkspaceContext(workspaceRoot, globs, exclude) {
|
|
4243
|
+
ensureContextAvailable(workspaceRoot);
|
|
4244
|
+
return workspaceContext.multiGlob(globs, exclude);
|
|
4245
|
+
}
|
|
4246
|
+
- return client_1.daemonClient.multiGlob(globs, exclude);
|
|
4247
|
+
+ return client_1.daemonClient.orWithoutDaemon(() => client_1.daemonClient.multiGlob(globs, exclude), () => multiGlobWithWorkspaceContext(workspaceRoot, globs, exclude));
|
|
4248
|
+
}
|
|
4249
|
+
async function hashWithWorkspaceContext(workspaceRoot, globs, exclude) {
|
|
4250
|
+
if ((0, is_on_daemon_1.isOnDaemon)() || !client_1.daemonClient.enabled()) {
|
|
4251
|
+
ensureContextAvailable(workspaceRoot);
|
|
4252
|
+
return workspaceContext.hashFilesMatchingGlob(globs, exclude);
|
|
4253
|
+
}
|
|
4254
|
+
- return client_1.daemonClient.hashGlob(globs, exclude);
|
|
4255
|
+
+ return client_1.daemonClient.orWithoutDaemon(() => client_1.daemonClient.hashGlob(globs, exclude), () => hashWithWorkspaceContext(workspaceRoot, globs, exclude));
|
|
4256
|
+
}
|
|
4257
|
+
async function hashMultiGlobWithWorkspaceContext(workspaceRoot, globGroups) {
|
|
4258
|
+
if ((0, is_on_daemon_1.isOnDaemon)() || !client_1.daemonClient.enabled()) {
|
|
4259
|
+
ensureContextAvailable(workspaceRoot);
|
|
4260
|
+
return workspaceContext.hashFilesMatchingGlobs(globGroups);
|
|
4261
|
+
}
|
|
4262
|
+
- return client_1.daemonClient.hashMultiGlob(globGroups);
|
|
4263
|
+
+ return client_1.daemonClient.orWithoutDaemon(() => client_1.daemonClient.hashMultiGlob(globGroups), () => hashMultiGlobWithWorkspaceContext(workspaceRoot, globGroups));
|
|
4264
|
+
}
|
|
4265
|
+
async function updateContextWithChangedFiles(workspaceRoot, createdFiles, updatedFiles, deletedFiles) {
|
|
4266
|
+
if (!client_1.daemonClient.enabled()) {
|
|
4267
|
+
@@ -86,7 +171,7 @@ async function updateContextWithChangedFiles(workspaceRoot, createdFiles, update
|
|
4268
|
+
}
|
|
4269
|
+
else {
|
|
4270
|
+
// daemon is enabled but we are not running on it, ask the daemon to update the context
|
|
4271
|
+
- await client_1.daemonClient.updateWorkspaceContext(createdFiles, updatedFiles, deletedFiles);
|
|
4272
|
+
+ await client_1.daemonClient.orWithoutDaemon(() => client_1.daemonClient.updateWorkspaceContext(createdFiles, updatedFiles, deletedFiles), () => updateContextWithChangedFiles(workspaceRoot, createdFiles, updatedFiles, deletedFiles));
|
|
4273
|
+
}
|
|
4274
|
+
}
|
|
4275
|
+
function updateFilesInContext(workspaceRoot, updatedFiles, deletedFiles) {
|
|
4276
|
+
@@ -98,14 +183,14 @@ async function getAllFileDataInContext(workspaceRoot) {
|
|
4277
|
+
ensureContextAvailable(workspaceRoot);
|
|
4278
|
+
return workspaceContext.allFileData();
|
|
4279
|
+
}
|
|
4280
|
+
- return client_1.daemonClient.getWorkspaceContextFileData();
|
|
4281
|
+
+ return client_1.daemonClient.orWithoutDaemon(() => client_1.daemonClient.getWorkspaceContextFileData(), () => getAllFileDataInContext(workspaceRoot));
|
|
4282
|
+
}
|
|
4283
|
+
async function getFilesInDirectoryUsingContext(workspaceRoot, dir) {
|
|
4284
|
+
if ((0, is_on_daemon_1.isOnDaemon)() || !client_1.daemonClient.enabled()) {
|
|
4285
|
+
ensureContextAvailable(workspaceRoot);
|
|
4286
|
+
return workspaceContext.getFilesInDirectory(dir);
|
|
4287
|
+
}
|
|
4288
|
+
- return client_1.daemonClient.getFilesInDirectory(dir);
|
|
4289
|
+
+ return client_1.daemonClient.orWithoutDaemon(() => client_1.daemonClient.getFilesInDirectory(dir), () => getFilesInDirectoryUsingContext(workspaceRoot, dir));
|
|
4290
|
+
}
|
|
4291
|
+
function updateProjectFiles(projectRootMappings, rustReferences, updatedFiles, deletedFiles) {
|
|
4292
|
+
return workspaceContext?.updateProjectFiles(projectRootMappings, rustReferences.projectFiles, rustReferences.globalFiles, updatedFiles, deletedFiles);
|
|
3929
4293
|
diff --git a/dist/src/utils/workspace-root.d.ts b/dist/src/utils/workspace-root.d.ts
|
|
3930
4294
|
index 74bf8f91928de190fda5886163a4b7cbd5add572..8034019f30f243d86a7a74abc42fd4ad5725b5ef 100644
|
|
3931
4295
|
--- a/dist/src/utils/workspace-root.d.ts
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@smoothbricks/nx-plugin",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.7",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"main": "./loader.js",
|
|
@@ -268,7 +268,7 @@
|
|
|
268
268
|
}
|
|
269
269
|
],
|
|
270
270
|
"options": {
|
|
271
|
-
"command": "bun test --timeout=0 ./src/executors/bounded-exec/ram-temp-host.test.ts ./src/executors/bounded-exec/executor-host.test.ts ./src/executors/bounded-exec/go-progress-host.test.ts",
|
|
271
|
+
"command": "bun test --timeout=0 ./src/executors/bounded-exec/ram-temp-host.test.ts ./src/executors/bounded-exec/executor-host.test.ts ./src/executors/bounded-exec/go-progress-host.test.ts ./src/executors/bounded-exec/cargo-progress-host.test.ts",
|
|
272
272
|
"cwd": "{projectRoot}",
|
|
273
273
|
"env": {
|
|
274
274
|
"COWSHED_EXECUTABLE": "{workspaceRoot}/packages/cowshed/bin/cowshed"
|
|
@@ -21,7 +21,7 @@ import type {
|
|
|
21
21
|
EnsureBuiltProducerReceipt,
|
|
22
22
|
EnsureBuiltReceipt,
|
|
23
23
|
} from './ensure-built.js';
|
|
24
|
-
import { censusStart, movedNodes, type NodeWitness, recordedStamp } from './ensure-built-witness.js';
|
|
24
|
+
import { censusStart, movedNodes, type NodeWitness, recordedStamp, type StampFields } from './ensure-built-witness.js';
|
|
25
25
|
|
|
26
26
|
export type ReceiptEvidence<T> =
|
|
27
27
|
| { readonly ok: true; readonly value: T }
|
|
@@ -147,12 +147,18 @@ export function receiptNode(
|
|
|
147
147
|
path: string,
|
|
148
148
|
name: string,
|
|
149
149
|
census?: { readonly start: bigint; readonly observed: NodeWitness[] },
|
|
150
|
+
recorded?: (path: string, stats: StampFields) => string | undefined,
|
|
150
151
|
): EnsureBuiltOutputReceipt {
|
|
151
152
|
const stats = lstatSync(path, { bigint: true });
|
|
152
153
|
census?.observed.push({ path, stamp: recordedStamp(stats, census.start) });
|
|
153
154
|
const mode = Number(stats.mode & 0o7777n);
|
|
154
155
|
if (stats.isFile())
|
|
155
|
-
return {
|
|
156
|
+
return {
|
|
157
|
+
path: name,
|
|
158
|
+
type: 'file',
|
|
159
|
+
mode,
|
|
160
|
+
sha256: recorded?.(path, stats) ?? hashFile(path, Number(stats.size), ['sha256'], false)[0],
|
|
161
|
+
};
|
|
156
162
|
if (stats.isSymbolicLink()) return { path: name, type: 'symlink', mode, linkText: readlinkSync(path) };
|
|
157
163
|
if (stats.isDirectory()) {
|
|
158
164
|
const entries = readdirSync(path).sort();
|