@smoothbricks/nx-plugin 0.6.3-0 → 0.7.0
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 +159 -121
- package/dist/.build-inputs.json +25 -20
- package/dist/bin/smoo-nx-go-test-build.d.ts +3 -0
- package/dist/bin/smoo-nx-go-test-build.d.ts.map +1 -0
- package/dist/bin/smoo-nx-go-test-build.js +79 -0
- package/dist/bin/smoo-nx-go-test-run.d.ts +3 -0
- package/dist/bin/smoo-nx-go-test-run.d.ts.map +1 -0
- package/dist/bin/smoo-nx-go-test-run.js +129 -0
- package/dist/bounded-test-policy.d.ts +1 -1
- package/dist/bounded-test-policy.d.ts.map +1 -1
- package/dist/bounded-test-policy.js +9 -8
- package/dist/cargo-workspace.d.ts +10 -20
- package/dist/cargo-workspace.d.ts.map +1 -1
- package/dist/cargo-workspace.js +12 -22
- package/dist/cross-check-policy.d.ts +2 -2
- package/dist/cross-check-policy.js +2 -2
- package/dist/deploy-policy.d.ts +6 -0
- package/dist/deploy-policy.d.ts.map +1 -1
- package/dist/deploy-policy.js +11 -0
- package/dist/executors/bounded-exec/executor.d.ts.map +1 -1
- package/dist/executors/bounded-exec/executor.js +49 -37
- package/dist/executors/bounded-exec/mbx-pool.d.ts +39 -10
- package/dist/executors/bounded-exec/mbx-pool.d.ts.map +1 -1
- package/dist/executors/bounded-exec/mbx-pool.js +78 -24
- package/dist/executors/bounded-exec/progress.js +5 -5
- package/dist/executors/bounded-exec/runner-sizing.d.ts +40 -2
- package/dist/executors/bounded-exec/runner-sizing.d.ts.map +1 -1
- package/dist/executors/bounded-exec/runner-sizing.js +55 -4
- package/dist/executors/bounded-exec/runtime-pin.js +1 -1
- package/dist/executors/bounded-exec/verdict.d.ts +6 -0
- package/dist/executors/bounded-exec/verdict.d.ts.map +1 -1
- package/dist/executors/bounded-exec/verdict.js +6 -0
- package/dist/executors/wrangler-deploy/deploy-hash.d.ts +10 -0
- package/dist/executors/wrangler-deploy/deploy-hash.d.ts.map +1 -0
- package/dist/executors/wrangler-deploy/deploy-hash.js +14 -0
- package/dist/executors/wrangler-deploy/executor.d.ts +24 -0
- package/dist/executors/wrangler-deploy/executor.d.ts.map +1 -0
- package/dist/executors/wrangler-deploy/executor.js +43 -0
- package/dist/executors/wrangler-deploy/hasher.d.ts +27 -0
- package/dist/executors/wrangler-deploy/hasher.d.ts.map +1 -0
- package/dist/executors/wrangler-deploy/hasher.js +90 -0
- package/dist/executors/wrangler-deploy/schema.d.ts +5 -0
- package/dist/executors/wrangler-deploy/schema.d.ts.map +1 -0
- package/dist/go-tests.d.ts +30 -0
- package/dist/go-tests.d.ts.map +1 -0
- package/dist/go-tests.js +43 -0
- package/dist/index.d.ts +9 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +271 -230
- package/dist/managed-files/files.d.ts.map +1 -1
- package/dist/managed-files/files.js +5 -0
- package/dist/process-group.js +2 -2
- package/dist/runtime-input-policy.d.ts +3 -3
- package/dist/runtime-input-policy.js +3 -3
- package/dist/test-timings.d.ts +23 -4
- package/dist/test-timings.d.ts.map +1 -1
- package/dist/test-timings.js +72 -12
- package/dist/version-actions.cjs +10 -11
- package/dist/version-actions.d.cts.map +1 -1
- package/dist/workspace-config-policy.d.ts.map +1 -1
- package/dist/workspace-config-policy.js +17 -22
- package/dist/workspace-manifest.js +3 -3
- package/executors.json +6 -5
- package/managed/raw/patches/nx@23.2.1.patch +118 -24
- package/managed/raw/patches/ttsc@0.34.1.patch +64 -0
- package/managed/raw/tooling/direnv/developer-links.ts +121 -51
- package/managed/raw/tooling/direnv/installed-bun-links.ts +7 -6
- package/managed/raw/tooling/direnv/setup-environment.ts +14 -4
- package/managed/raw/tooling/git-hooks/pinned-revisions-served.ts +252 -0
- package/managed/raw/tooling/git-hooks/pre-push.sh +34 -32
- package/package.json +57 -7
- package/runtime/nx-publish/.build-inputs.json +11 -0
- package/runtime-input.sh +50 -23
- package/src/bin/smoo-nx-go-test-build.ts +83 -0
- package/src/bin/smoo-nx-go-test-run.ts +140 -0
- package/src/bounded-test-policy.ts +9 -8
- package/src/cargo-workspace.ts +12 -24
- package/src/cross-check-policy.ts +2 -2
- package/src/deploy-policy.ts +11 -0
- package/src/executors/bounded-exec/executor.ts +61 -42
- package/src/executors/bounded-exec/mbx-pool.ts +97 -33
- package/src/executors/bounded-exec/progress.ts +5 -5
- package/src/executors/bounded-exec/runner-sizing.ts +73 -7
- package/src/executors/bounded-exec/runtime-pin.ts +1 -1
- package/src/executors/bounded-exec/verdict.ts +7 -0
- package/src/executors/wrangler-deploy/deploy-hash.ts +15 -0
- package/src/executors/wrangler-deploy/executor.ts +63 -0
- package/src/executors/wrangler-deploy/hasher.ts +111 -0
- package/src/executors/wrangler-deploy/schema.json +16 -0
- package/src/executors/wrangler-deploy/schema.ts +4 -0
- package/src/go-tests.ts +67 -0
- package/src/index.ts +294 -253
- package/src/managed-files/files.ts +5 -0
- package/src/process-group.ts +2 -2
- package/src/runtime-input-policy.ts +3 -3
- package/src/test-timings.ts +72 -14
- package/src/version-actions.cts +10 -11
- package/src/workspace-config-policy.ts +20 -29
- package/src/workspace-manifest.ts +3 -3
- package/test-timings.json +131 -130
- package/dist/executors/clean-outputs/executor.d.ts +0 -26
- package/dist/executors/clean-outputs/executor.d.ts.map +0 -1
- package/dist/executors/clean-outputs/executor.js +0 -83
- package/dist/executors/clean-outputs/schema.d.ts +0 -4
- package/dist/executors/clean-outputs/schema.d.ts.map +0 -1
- package/src/executors/clean-outputs/executor.ts +0 -131
- package/src/executors/clean-outputs/schema.json +0 -15
- package/src/executors/clean-outputs/schema.ts +0 -3
- /package/dist/executors/{clean-outputs → wrangler-deploy}/schema.js +0 -0
|
@@ -400,7 +400,7 @@ index 9bd7b61bf9ad94c72a198dfe6f15fbcb68dfaac3..6b982fae848cc82a310eee9a1036be1a
|
|
|
400
400
|
flushSyncGeneratorChangesToDisk(generators: string[]): Promise<FlushSyncGeneratorChangesResult>;
|
|
401
401
|
getRegisteredSyncGenerators(): Promise<{
|
|
402
402
|
diff --git a/dist/src/daemon/client/client.js b/dist/src/daemon/client/client.js
|
|
403
|
-
index cebfd6d1f8ddb2c5b93dcb847904aa9ab0553de6..
|
|
403
|
+
index cebfd6d1f8ddb2c5b93dcb847904aa9ab0553de6..54af453aee4d3aaa56d6fe19c328c814e471c659 100644
|
|
404
404
|
--- a/dist/src/daemon/client/client.js
|
|
405
405
|
+++ b/dist/src/daemon/client/client.js
|
|
406
406
|
@@ -40,7 +40,6 @@ const nx_console_1 = require("../message-types/nx-console");
|
|
@@ -744,7 +744,7 @@ index cebfd6d1f8ddb2c5b93dcb847904aa9ab0553de6..8f26121c957183135bc75ad428fb7ef8
|
|
|
744
744
|
}
|
|
745
745
|
}
|
|
746
746
|
establishConnection() {
|
|
747
|
-
@@ -998,
|
|
747
|
+
@@ -998,14 +1124,31 @@ class DaemonClient {
|
|
748
748
|
return { available: false, refusal };
|
|
749
749
|
}
|
|
750
750
|
async sendMessageToDaemon(message, force) {
|
|
@@ -754,9 +754,15 @@ index cebfd6d1f8ddb2c5b93dcb847904aa9ab0553de6..8f26121c957183135bc75ad428fb7ef8
|
|
|
754
754
|
// the first message sent to the daemon includes an env prop
|
|
755
755
|
// that updates the process.env values on the daemon.
|
|
756
756
|
if (!this.envReflectionSent && !global.NX_PLUGIN_WORKER) {
|
|
757
|
-
|
|
757
|
+
message.env = (0, daemon_environment_1.getDaemonEnv)();
|
|
758
758
|
this.envReflectionSent = true;
|
|
759
759
|
}
|
|
760
|
+
+ // A plugin worker is no command: its request nests in a daemon operation
|
|
761
|
+
+ // already current, so the daemon serves it without a probe of its own
|
|
762
|
+
+ // (server.js, handleMessage).
|
|
763
|
+
+ if (global.NX_PLUGIN_WORKER) {
|
|
764
|
+
+ message.fromPluginWorker = true;
|
|
765
|
+
+ }
|
|
760
766
|
await this.startDaemonIfNecessary();
|
|
761
767
|
+ // The request waits on the daemon its record names. Its socket can outlive it: a
|
|
762
768
|
+ // listener a surviving child inherited accepts the request and never answers, and the
|
|
@@ -770,7 +776,7 @@ index cebfd6d1f8ddb2c5b93dcb847904aa9ab0553de6..8f26121c957183135bc75ad428fb7ef8
|
|
|
770
776
|
return new Promise((resolve, reject) => {
|
|
771
777
|
perf_hooks_1.performance.mark('sendMessageToDaemon-start');
|
|
772
778
|
// An open promise isn't enough to keep the event loop
|
|
773
|
-
@@ -1016,12 +
|
|
779
|
+
@@ -1016,12 +1159,25 @@ class DaemonClient {
|
|
774
780
|
keepAlive = setTimeout(() => {
|
|
775
781
|
reject(new Error('The daemon timed out while processing ' + message.type));
|
|
776
782
|
}, 20 * 60 * 1000);
|
|
@@ -796,7 +802,7 @@ index cebfd6d1f8ddb2c5b93dcb847904aa9ab0553de6..8f26121c957183135bc75ad428fb7ef8
|
|
|
796
802
|
});
|
|
797
803
|
}
|
|
798
804
|
async registerDaemonProcessWithMetricsService(daemonPid) {
|
|
799
|
-
@@ -1055,7 +
|
|
805
|
+
@@ -1055,7 +1211,13 @@ class DaemonClient {
|
|
800
806
|
console[parsedResult.level](parsedResult.message);
|
|
801
807
|
return;
|
|
802
808
|
}
|
|
@@ -811,7 +817,7 @@ index cebfd6d1f8ddb2c5b93dcb847904aa9ab0553de6..8f26121c957183135bc75ad428fb7ef8
|
|
|
811
817
|
this.currentReject(parsedResult.error);
|
|
812
818
|
}
|
|
813
819
|
else {
|
|
814
|
-
@@ -1132,8 +
|
|
820
|
+
@@ -1132,8 +1294,11 @@ class DaemonClient {
|
|
815
821
|
*/
|
|
816
822
|
const { available, refusal: polled } = await this.waitForServerToBeAvailable({ ignoreVersionMismatch: true });
|
|
817
823
|
if (available) {
|
|
@@ -825,7 +831,7 @@ index cebfd6d1f8ddb2c5b93dcb847904aa9ab0553de6..8f26121c957183135bc75ad428fb7ef8
|
|
|
825
831
|
}
|
|
826
832
|
else {
|
|
827
833
|
// A permission refusal from either source wins, then the poll's errno,
|
|
828
|
-
@@ -1161,19 +
|
|
834
|
+
@@ -1161,19 +1326,31 @@ class DaemonClient {
|
|
829
835
|
].join('\n'));
|
|
830
836
|
}
|
|
831
837
|
}
|
|
@@ -867,7 +873,7 @@ index cebfd6d1f8ddb2c5b93dcb847904aa9ab0553de6..8f26121c957183135bc75ad428fb7ef8
|
|
|
867
873
|
}
|
|
868
874
|
}
|
|
869
875
|
(0, tmp_dir_1.removeSocketDir)();
|
|
870
|
-
@@ -1200,6 +
|
|
876
|
+
@@ -1200,6 +1377,44 @@ function isDocker() {
|
|
871
877
|
function nxJsonIsNotPresent() {
|
|
872
878
|
return !(0, nx_json_1.hasNxJson)(workspace_root_1.workspaceRoot);
|
|
873
879
|
}
|
|
@@ -912,7 +918,7 @@ index cebfd6d1f8ddb2c5b93dcb847904aa9ab0553de6..8f26121c957183135bc75ad428fb7ef8
|
|
|
912
918
|
/**
|
|
913
919
|
* The operating system refused the connection. Most often the socket belongs to
|
|
914
920
|
* another user, which is the guarantee the owner-only socket directory buys —
|
|
915
|
-
@@ -1226,6 +
|
|
921
|
+
@@ -1226,6 +1441,21 @@ function daemonPermissionException(socketPath, cause) {
|
|
916
922
|
error.daemonPermissionError = true;
|
|
917
923
|
return error;
|
|
918
924
|
}
|
|
@@ -1218,10 +1224,23 @@ index 427ced7822fb05ba966d0543c224c5760b016572..303548db369472e0f99f31c3bc66ae9b
|
|
|
1218
1224
|
}
|
|
1219
1225
|
function getChangedEnvKeys(before, after) {
|
|
1220
1226
|
diff --git a/dist/src/daemon/message-types/daemon-message.d.ts b/dist/src/daemon/message-types/daemon-message.d.ts
|
|
1221
|
-
index 9dd6123ad6d9adb20a07f7db56fc476be78cbcca..
|
|
1227
|
+
index 9dd6123ad6d9adb20a07f7db56fc476be78cbcca..6ea90cf3fea484641b20aa11fd6a07d5a71c65fc 100644
|
|
1222
1228
|
--- a/dist/src/daemon/message-types/daemon-message.d.ts
|
|
1223
1229
|
+++ b/dist/src/daemon/message-types/daemon-message.d.ts
|
|
1224
|
-
@@ -
|
|
1230
|
+
@@ -1,6 +1,12 @@
|
|
1231
|
+
export type DaemonMessage = {
|
|
1232
|
+
type: string;
|
|
1233
|
+
env?: Record<string, string>;
|
|
1234
|
+
+ /**
|
|
1235
|
+
+ * Set by a plugin worker's daemon client. The daemon serves such a request
|
|
1236
|
+
+ * without proving its watcher current: it nests in an operation already
|
|
1237
|
+
+ * current.
|
|
1238
|
+
+ */
|
|
1239
|
+
+ fromPluginWorker?: boolean;
|
|
1240
|
+
/**
|
|
1241
|
+
* Stamped centrally by `DaemonSocketMessenger.sendMessage`, not by the ~30
|
|
1242
|
+
* sites that construct messages — hence optional. It can also be absent on a
|
|
1243
|
+
@@ -11,6 +17,8 @@ export type DaemonMessage = {
|
|
1225
1244
|
data?: any;
|
|
1226
1245
|
};
|
|
1227
1246
|
export declare function isDaemonMessage(msg: unknown): msg is DaemonMessage;
|
|
@@ -1230,7 +1249,7 @@ index 9dd6123ad6d9adb20a07f7db56fc476be78cbcca..0b1ee217729d63a29806cf6c38d0fc5d
|
|
|
1230
1249
|
/**
|
|
1231
1250
|
* Any message carrying the sender's workspace root. Structural so the checks
|
|
1232
1251
|
* below serve the daemon and the plugin worker without either importing the
|
|
1233
|
-
@@ -24,7 +
|
|
1252
|
+
@@ -24,7 +32,7 @@ type WorkspaceScopedMessage = {
|
|
1234
1253
|
/**
|
|
1235
1254
|
* A message from a different workspace — two sharing an NX_SOCKET_DIR — must not
|
|
1236
1255
|
* be processed. Roots are normalized first so that a workspace does not look
|
|
@@ -1900,7 +1919,7 @@ index 0000000000000000000000000000000000000000..0c065105dff1ed0847e28672661b1792
|
|
|
1900
1919
|
+ (0, shutdown_utils_1.handleServerProcessTerminationWithRestart)({ server: daemon.server, reason, sockets: daemon.sockets, notice });
|
|
1901
1920
|
+}
|
|
1902
1921
|
diff --git a/dist/src/daemon/server/server.js b/dist/src/daemon/server/server.js
|
|
1903
|
-
index b1c143e244efd435b28642ed86e999d6c86f7d94..
|
|
1922
|
+
index b1c143e244efd435b28642ed86e999d6c86f7d94..0fa42a0dd66fc6706fa36db9ed608486978a384d 100644
|
|
1904
1923
|
--- a/dist/src/daemon/server/server.js
|
|
1905
1924
|
+++ b/dist/src/daemon/server/server.js
|
|
1906
1925
|
@@ -7,17 +7,13 @@ const fs_1 = require("fs");
|
|
@@ -1962,7 +1981,7 @@ index b1c143e244efd435b28642ed86e999d6c86f7d94..cd24ff30639e538422cf813679e80966
|
|
|
1962
1981
|
async function handleMessage(socket, data) {
|
|
1963
1982
|
if (workspaceWatcherError) {
|
|
1964
1983
|
await (0, shutdown_utils_1.respondWithErrorAndExit)(socket, `File watcher error in the workspace '${workspace_root_1.workspaceRoot}'.`, workspaceWatcherError);
|
|
1965
|
-
@@ -134,9 +134,
|
|
1984
|
+
@@ -134,9 +134,39 @@ async function handleMessage(socket, data) {
|
|
1966
1985
|
return;
|
|
1967
1986
|
}
|
|
1968
1987
|
}
|
|
@@ -1981,8 +2000,11 @@ index b1c143e244efd435b28642ed86e999d6c86f7d94..cd24ff30639e538422cf813679e80966
|
|
|
1981
2000
|
+ // always did, so a write another process makes while the command runs is
|
|
1982
2001
|
+ // as visible as it was. A watcher that stopped delivering stops the daemon
|
|
1983
2002
|
+ // instead; the client is told so first, and continues without a daemon at
|
|
1984
|
-
+ // once.
|
|
1985
|
-
+
|
|
2003
|
+
+ // once. A plugin worker's request (`fromPluginWorker`) is no command and
|
|
2004
|
+
+ // makes no probe: it nests in a daemon operation already current, the
|
|
2005
|
+
+ // watcher's own recompute, which must read that recompute's files, or a
|
|
2006
|
+
+ // command whose connection made its probe.
|
|
2007
|
+
+ if (answersFromFiles(payload) && !payload.fromPluginWorker && !provenConnections.has(socket)) {
|
|
1986
2008
|
+ const stopped = await (0, watcher_1.proveWatcherCurrent)();
|
|
1987
2009
|
+ if (stopped !== undefined) {
|
|
1988
2010
|
+ const error = new Error(`The Nx daemon stopped: ${stopped}. This command continues without it.`);
|
|
@@ -1999,7 +2021,7 @@ index b1c143e244efd435b28642ed86e999d6c86f7d94..cd24ff30639e538422cf813679e80966
|
|
|
1999
2021
|
if (payload.type === 'PING') {
|
|
2000
2022
|
await handleResult(socket, 'PING', () => Promise.resolve({ response: true, description: 'ping' }), mode);
|
|
2001
2023
|
}
|
|
2002
|
-
@@ -185,15 +
|
|
2024
|
+
@@ -185,15 +215,6 @@ async function handleMessage(socket, data) {
|
|
2003
2025
|
else if ((0, hash_glob_1.isHandleHashMultiGlobMessage)(payload)) {
|
|
2004
2026
|
await handleResult(socket, hash_glob_1.HASH_GLOB, () => (0, handle_hash_glob_1.handleHashMultiGlob)(payload.globGroups), mode);
|
|
2005
2027
|
}
|
|
@@ -2015,7 +2037,7 @@ index b1c143e244efd435b28642ed86e999d6c86f7d94..cd24ff30639e538422cf813679e80966
|
|
|
2015
2037
|
else if ((0, force_shutdown_1.isHandleForceShutdownMessage)(payload)) {
|
|
2016
2038
|
await handleResult(socket, 'FORCE_SHUTDOWN', () => (0, handle_force_shutdown_1.handleForceShutdown)(server), mode);
|
|
2017
2039
|
}
|
|
2018
|
-
@@ -231,6 +
|
|
2040
|
+
@@ -231,6 +252,22 @@ async function handleMessage(socket, data) {
|
|
2019
2041
|
await (0, shutdown_utils_1.respondWithErrorAndExit)(socket, `Invalid payload from the client`, new Error(`Unsupported payload sent to daemon server: ${(0, consume_messages_from_socket_1.describeMessage)(unparsedPayload, { maxBytes: 200 })}`));
|
|
2020
2042
|
}
|
|
2021
2043
|
}
|
|
@@ -2038,7 +2060,7 @@ index b1c143e244efd435b28642ed86e999d6c86f7d94..cd24ff30639e538422cf813679e80966
|
|
|
2038
2060
|
async function handleResult(socket, type, hrFn, mode) {
|
|
2039
2061
|
let hr;
|
|
2040
2062
|
const startMark = new Date();
|
|
2041
|
-
@@ -242,7 +
|
|
2063
|
+
@@ -242,7 +279,12 @@ async function handleResult(socket, type, hrFn, mode) {
|
|
2042
2064
|
}
|
|
2043
2065
|
const doneHandlingMark = new Date();
|
|
2044
2066
|
if (hr.error) {
|
|
@@ -2052,7 +2074,7 @@ index b1c143e244efd435b28642ed86e999d6c86f7d94..cd24ff30639e538422cf813679e80966
|
|
|
2052
2074
|
}
|
|
2053
2075
|
else {
|
|
2054
2076
|
logger_1.serverLogger.log(`Serializing response for ${type} message in ${mode} mode`);
|
|
2055
|
-
@@ -256,9 +
|
|
2077
|
+
@@ -256,9 +298,10 @@ async function handleResult(socket, type, hrFn, mode) {
|
|
2056
2078
|
logger_1.serverLogger.log(`Handled ${mode} message ${type}. Handling time: ${doneHandlingMark.getTime() - startMark.getTime()}. Response time: ${endMark.getTime() - doneHandlingMark.getTime()}.`);
|
|
2057
2079
|
}
|
|
2058
2080
|
function handleInactivityTimeout() {
|
|
@@ -2065,7 +2087,7 @@ index b1c143e244efd435b28642ed86e999d6c86f7d94..cd24ff30639e538422cf813679e80966
|
|
|
2065
2087
|
(0, shutdown_utils_1.resetInactivityTimeout)(handleInactivityTimeout);
|
|
2066
2088
|
}
|
|
2067
2089
|
else {
|
|
2068
|
-
@@ -287,37 +
|
|
2090
|
+
@@ -287,37 +330,6 @@ function registerProcessTerminationListeners() {
|
|
2069
2091
|
sockets: exports.openSockets,
|
|
2070
2092
|
}));
|
|
2071
2093
|
}
|
|
@@ -2103,7 +2125,7 @@ index b1c143e244efd435b28642ed86e999d6c86f7d94..cd24ff30639e538422cf813679e80966
|
|
|
2103
2125
|
/**
|
|
2104
2126
|
* When applicable files in the workspaces are changed (created, updated, deleted),
|
|
2105
2127
|
* we need to recompute the cached serialized project graph so that it is readily
|
|
2106
|
-
@@ -339,6 +
|
|
2128
|
+
@@ -339,6 +351,11 @@ const handleWorkspaceChanges = async (err, changeEvents) => {
|
|
2107
2129
|
return;
|
|
2108
2130
|
}
|
|
2109
2131
|
logger_1.serverLogger.watcherLog((0, watcher_1.convertChangeEventsToLogMessage)(changeEvents));
|
|
@@ -2115,7 +2137,7 @@ index b1c143e244efd435b28642ed86e999d6c86f7d94..cd24ff30639e538422cf813679e80966
|
|
|
2115
2137
|
(0, route_workspace_changes_1.routeWorkspaceChanges)(changeEvents);
|
|
2116
2138
|
}
|
|
2117
2139
|
catch (err) {
|
|
2118
|
-
@@ -348,65 +
|
|
2140
|
+
@@ -348,65 +365,68 @@ const handleWorkspaceChanges = async (err, changeEvents) => {
|
|
2119
2141
|
(0, file_watcher_sockets_1.notifyFileWatcherSocketsOfError)(err);
|
|
2120
2142
|
}
|
|
2121
2143
|
};
|
|
@@ -2223,7 +2245,7 @@ index b1c143e244efd435b28642ed86e999d6c86f7d94..cd24ff30639e538422cf813679e80966
|
|
|
2223
2245
|
return new Promise(async (resolve, reject) => {
|
|
2224
2246
|
// `listen` reports a failed bind asynchronously on the server, which the
|
|
2225
2247
|
// try below cannot catch — without this an EACCES became an uncaught
|
|
2226
|
-
@@ -432,25 +
|
|
2248
|
+
@@ -432,25 +452,19 @@ async function startServer() {
|
|
2227
2249
|
// Best effort; the 0700 socket directory is the primary control.
|
|
2228
2250
|
}
|
|
2229
2251
|
}
|
|
@@ -3149,6 +3171,78 @@ index 332accab74919348073538f4198693328bf68193..a56864600a5e7a9f9e40adea9a7bfc9e
|
|
|
3149
3171
|
const plansReference = this.planner.getPlansReference(taskIds, taskGraph);
|
|
3150
3172
|
return this.inspector.inspectInputs(plansReference);
|
|
3151
3173
|
}
|
|
3174
|
+
diff --git a/dist/src/hasher/native-task-hasher-impl.js b/dist/src/hasher/native-task-hasher-impl.js
|
|
3175
|
+
index 61b015b9a1b4665c1f0a236d9ef41858dd925163..ea7e1b792faded260e13f101e637d2fedb36cfcf 100644
|
|
3176
|
+
--- a/dist/src/hasher/native-task-hasher-impl.js
|
|
3177
|
+
+++ b/dist/src/hasher/native-task-hasher-impl.js
|
|
3178
|
+
@@ -29,10 +29,65 @@ class NativeTaskHasherImpl {
|
|
3179
|
+
return hashes[0];
|
|
3180
|
+
}
|
|
3181
|
+
async hashTasks(tasks, taskGraph, perTaskEnvs, cwd, collectInputs) {
|
|
3182
|
+
- const plans = this.planner.getPlansReference(tasks.map((t) => t.id), taskGraph);
|
|
3183
|
+
+ const taskIds = tasks.map((t) => t.id);
|
|
3184
|
+
+ const plans = this.planner.getPlansReference(taskIds, taskGraph);
|
|
3185
|
+
const shouldCollectInputs = collectInputs ?? (0, task_io_service_1.getTaskIOService)().hasTaskInputSubscribers();
|
|
3186
|
+
- const hashes = this.hasher.hashPlans(plans, perTaskEnvs, cwd ?? process.cwd(), shouldCollectInputs);
|
|
3187
|
+
+ let hashes;
|
|
3188
|
+
+ try {
|
|
3189
|
+
+ hashes = this.hasher.hashPlans(plans, perTaskEnvs, cwd ?? process.cwd(), shouldCollectInputs);
|
|
3190
|
+
+ }
|
|
3191
|
+
+ catch (error) {
|
|
3192
|
+
+ throw hashPlansError(error, taskIds, this.planner, taskGraph);
|
|
3193
|
+
+ }
|
|
3194
|
+
return tasks.map((t) => hashes[t.id]);
|
|
3195
|
+
}
|
|
3196
|
+
}
|
|
3197
|
+
exports.NativeTaskHasherImpl = NativeTaskHasherImpl;
|
|
3198
|
+
+/** A refusal names this many task ids and counts the rest, as cowshed's refusals do. */
|
|
3199
|
+
+const NAMED_TASKS = 10;
|
|
3200
|
+
+function namedTasks(ids) {
|
|
3201
|
+
+ const named = ids.slice(0, NAMED_TASKS);
|
|
3202
|
+
+ if (ids.length > NAMED_TASKS) {
|
|
3203
|
+
+ named.push(`and ${ids.length - NAMED_TASKS} more`);
|
|
3204
|
+
+ }
|
|
3205
|
+
+ return named.join(', ');
|
|
3206
|
+
+}
|
|
3207
|
+
+/**
|
|
3208
|
+
+ * The native hasher's error names neither the task nor the input it failed on:
|
|
3209
|
+
+ * a runtime input whose output is not UTF-8 fails as `invalid utf-8 sequence of
|
|
3210
|
+
+ * 1 bytes from index 0`, which any runtime input of any task in the batch could
|
|
3211
|
+
+ * have raised. Name the tasks and the runtime inputs their plans hold, read from
|
|
3212
|
+
+ * the planner, so the error says where to look; nothing runs again. The native
|
|
3213
|
+
+ * message always leads and the native error is the cause: a planner that cannot
|
|
3214
|
+
+ * answer costs the listing, never the error it was asked to explain.
|
|
3215
|
+
+ */
|
|
3216
|
+
+function hashPlansError(error, taskIds, planner, taskGraph) {
|
|
3217
|
+
+ const native = error instanceof Error ? error.message : String(error);
|
|
3218
|
+
+ const lines = [`Could not hash ${namedTasks([...taskIds].sort())}: ${native}`];
|
|
3219
|
+
+ let plans;
|
|
3220
|
+
+ try {
|
|
3221
|
+
+ plans = planner.getPlans(taskIds, taskGraph);
|
|
3222
|
+
+ }
|
|
3223
|
+
+ catch (listing) {
|
|
3224
|
+
+ const reason = listing instanceof Error ? listing.message : String(listing);
|
|
3225
|
+
+ lines.push(`The runtime inputs of those tasks could not be listed: ${reason}`);
|
|
3226
|
+
+ return new Error(lines.join('\n'), { cause: error });
|
|
3227
|
+
+ }
|
|
3228
|
+
+ const tasksByRuntime = new Map();
|
|
3229
|
+
+ for (const taskId of Object.keys(plans).sort()) {
|
|
3230
|
+
+ for (const instruction of plans[taskId]) {
|
|
3231
|
+
+ if (instruction.startsWith('runtime:')) {
|
|
3232
|
+
+ const command = instruction.slice('runtime:'.length);
|
|
3233
|
+
+ const tasks = tasksByRuntime.get(command) ?? new Set();
|
|
3234
|
+
+ tasksByRuntime.set(command, tasks.add(taskId));
|
|
3235
|
+
+ }
|
|
3236
|
+
+ }
|
|
3237
|
+
+ }
|
|
3238
|
+
+ if (tasksByRuntime.size > 0) {
|
|
3239
|
+
+ lines.push('Runtime inputs of those tasks:');
|
|
3240
|
+
+ for (const command of [...tasksByRuntime.keys()].sort()) {
|
|
3241
|
+
+ lines.push(` ${command} (${namedTasks([...tasksByRuntime.get(command)])})`);
|
|
3242
|
+
+ }
|
|
3243
|
+
+ }
|
|
3244
|
+
+ return new Error(lines.join('\n'), { cause: error });
|
|
3245
|
+
+}
|
|
3152
3246
|
diff --git a/dist/src/hasher/task-hasher.d.ts b/dist/src/hasher/task-hasher.d.ts
|
|
3153
3247
|
index cf08aa6c0fb9bcbb2fbf10e554f2e0397b1b13d7..f67c434e41a776343e11225bdd12f02cd7570d0c 100644
|
|
3154
3248
|
--- a/dist/src/hasher/task-hasher.d.ts
|
|
@@ -113,6 +113,26 @@ diff --git a/lib/internal/javascriptRuntimeCapabilities.js b/lib/internal/javasc
|
|
|
113
113
|
// Inside a ttsx run this is the user's NODE_OPTIONS, not ttsx's preloads,
|
|
114
114
|
// which would refuse the cache and run in the probe (#1740).
|
|
115
115
|
const effectiveEnv = TtsxNodeOptions_1.TtsxNodeOptions.forHelpers(SidecarEnvironment_1.SidecarEnvironment.merge(process.env, env));
|
|
116
|
+
diff --git a/lib/plugin/internal/source/GoSourceInputs.js b/lib/plugin/internal/source/GoSourceInputs.js
|
|
117
|
+
--- a/lib/plugin/internal/source/GoSourceInputs.js
|
|
118
|
+
+++ b/lib/plugin/internal/source/GoSourceInputs.js
|
|
119
|
+
@@ -73,6 +73,16 @@
|
|
120
|
+
function goBuildEnv(goBinary, goBuildCacheRoot, effectiveEnv = process.env) {
|
|
121
|
+
const env = { ...effectiveEnv };
|
|
122
|
+
env.GOWORK = "auto";
|
|
123
|
+
+ // GOWORK=auto puts go in workspace mode wherever a go.work lies (typia's
|
|
124
|
+
+ // native plugin ships one), where go accepts only -mod=readonly or
|
|
125
|
+
+ // -mod=vendor. A caller's GOFLAGS -mod=mod, a host shell's say, failed
|
|
126
|
+
+ // every invocation; ttsc owns the workspace, so it drops that flag and
|
|
127
|
+
+ // keeps the caller's others.
|
|
128
|
+
+ if (env.GOFLAGS) {
|
|
129
|
+
+ env.GOFLAGS = env.GOFLAGS.split(/\s+/)
|
|
130
|
+
+ .filter((flag) => flag !== "" && !/^--?mod=/.test(flag))
|
|
131
|
+
+ .join(" ");
|
|
132
|
+
+ }
|
|
133
|
+
// Only the actual `go build` needs ttsc's GOCACHE; read-only metadata spawns
|
|
134
|
+
// (`go mod edit`, `go env`, `go version`) call goBuildEnv with no cache root
|
|
135
|
+
// and inherit ambient GOCACHE rather than receiving the managed build
|
|
116
136
|
diff --git a/lib/plugin/internal/source/PluginBuildEnvironmentReadings.js b/lib/plugin/internal/source/PluginBuildEnvironmentReadings.js
|
|
117
137
|
--- a/lib/plugin/internal/source/PluginBuildEnvironmentReadings.js
|
|
118
138
|
+++ b/lib/plugin/internal/source/PluginBuildEnvironmentReadings.js
|
|
@@ -140,6 +160,50 @@ diff --git a/lib/plugin/internal/source/PluginBuildEnvironmentReadings.js b/lib/
|
|
|
140
160
|
worker = created;
|
|
141
161
|
const retire = () => {
|
|
142
162
|
if (worker === created)
|
|
163
|
+
diff --git a/lib/plugin/internal/source/inspectPluginBuildLock.js b/lib/plugin/internal/source/inspectPluginBuildLock.js
|
|
164
|
+
--- a/lib/plugin/internal/source/inspectPluginBuildLock.js
|
|
165
|
+
+++ b/lib/plugin/internal/source/inspectPluginBuildLock.js
|
|
166
|
+
@@ -65,9 +65,16 @@
|
|
167
|
+
const PLUGIN_BUILD_LOCK_OBSERVER = node_crypto_1.default.randomBytes(16).toString("hex");
|
|
168
|
+
function inspectV3PluginBuildLock(lockDir) {
|
|
169
|
+
const generationDir = node_path_1.default.join(lockDir, PluginBuildLockProtocol_1.PluginBuildLockProtocol.PLUGIN_BUILD_LOCK_CURRENT_DIR);
|
|
170
|
+
+ // `current` changes only by whole-directory renames: a holder retires it
|
|
171
|
+
+ // onto its tombstone, and the next holder publishes a directory that
|
|
172
|
+
+ // already holds its generation. A read that finds no valid generation
|
|
173
|
+
+ // proves the lock malformed only when the same directory was `current`
|
|
174
|
+
+ // before and after it. Otherwise the read straddled a handoff of the key,
|
|
175
|
+
+ // and a handoff is a release: the caller observes the key again.
|
|
176
|
+
+ const observed = pluginBuildLockDirectoryIdentity(generationDir);
|
|
177
|
+
const generation = readPluginBuildLockGeneration(generationDir);
|
|
178
|
+
if (generation === null) {
|
|
179
|
+
- if (pluginBuildLockPathMissing(generationDir)) {
|
|
180
|
+
+ if (observed === null || observed !== pluginBuildLockDirectoryIdentity(generationDir)) {
|
|
181
|
+
return { state: "released" };
|
|
182
|
+
}
|
|
183
|
+
throw new Error(`ttsc plugin build lock has no valid ${PluginBuildLockProtocol_1.PluginBuildLockProtocol.PLUGIN_BUILD_LOCK_GENERATION_FILE}: ${generationDir}`);
|
|
184
|
+
@@ -269,6 +276,22 @@
|
|
185
|
+
return null;
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
+/**
|
|
189
|
+
+ * The device and inode of a lock directory, or null when a lookup proves it
|
|
190
|
+
+ * absent. A permission or sharing failure proves nothing and propagates.
|
|
191
|
+
+ */
|
|
192
|
+
+function pluginBuildLockDirectoryIdentity(directory) {
|
|
193
|
+
+ try {
|
|
194
|
+
+ const stat = node_fs_1.default.statSync(directory, { bigint: true });
|
|
195
|
+
+ return `${stat.dev}:${stat.ino}`;
|
|
196
|
+
+ }
|
|
197
|
+
+ catch (error) {
|
|
198
|
+
+ if (PluginBuildLockProtocol_1.PluginBuildLockProtocol.isMissingPathError(error)) {
|
|
199
|
+
+ return null;
|
|
200
|
+
+ }
|
|
201
|
+
+ throw error;
|
|
202
|
+
+ }
|
|
203
|
+
+}
|
|
204
|
+
/**
|
|
205
|
+
* Whether a path lookup proves absence. Permission and sharing failures are
|
|
206
|
+
* inconclusive, never evidence of a released or old abandoned generation.
|
|
143
207
|
diff --git a/lib/plugin/internal/source/waitForPluginBinary.js b/lib/plugin/internal/source/waitForPluginBinary.js
|
|
144
208
|
--- a/lib/plugin/internal/source/waitForPluginBinary.js
|
|
145
209
|
+++ b/lib/plugin/internal/source/waitForPluginBinary.js
|
|
@@ -24,6 +24,14 @@
|
|
|
24
24
|
* `globalStore`, each .bun entry is itself a link into the shared install
|
|
25
25
|
* cache, outside every checkout.
|
|
26
26
|
*
|
|
27
|
+
* A link brings its package's bins. Bun links each installed package's
|
|
28
|
+
* declared bins into its tree's node_modules/.bin through the alias, and a
|
|
29
|
+
* link leaves the .bin the install made: the installed version's bin set.
|
|
30
|
+
* After links apply and after every install, each live link's declared bins
|
|
31
|
+
* point through its alias as an install of the linked version would, and the
|
|
32
|
+
* entries into that alias for bins it no longer declares are removed
|
|
33
|
+
* (refreshDeveloperBins).
|
|
34
|
+
*
|
|
27
35
|
* Unlinking a package means removing its link, and the next install puts the
|
|
28
36
|
* lockfile's version there. A dangling link is removed before the install,
|
|
29
37
|
* with a warning. A link whose target this process may not read (EPERM in a
|
|
@@ -231,6 +239,7 @@ export async function keepDeveloperLinks<T>(
|
|
|
231
239
|
if (succeeded && recorded.size > 0 && process.env.GITHUB_ACTIONS !== 'true') {
|
|
232
240
|
applyDeclaredLinks(root, await planDeclaredLinks(root));
|
|
233
241
|
}
|
|
242
|
+
refreshDeveloperBins(root);
|
|
234
243
|
if (options !== undefined || (succeeded && undeclared.size > 0)) {
|
|
235
244
|
reportDeveloperLinks(root);
|
|
236
245
|
} else {
|
|
@@ -274,6 +283,81 @@ function packageName(link: { readonly path: string }): string {
|
|
|
274
283
|
return link.path.slice(link.path.lastIndexOf('node_modules/') + 'node_modules/'.length);
|
|
275
284
|
}
|
|
276
285
|
|
|
286
|
+
/** The node_modules tree a link sits directly in, relative to the root: its path up to its last node_modules. */
|
|
287
|
+
function linkTree(link: { readonly path: string }): string {
|
|
288
|
+
return link.path.slice(0, link.path.lastIndexOf('node_modules/') + 'node_modules'.length);
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
/**
|
|
292
|
+
* The bins a manifest declares, by name to the package-relative file: `bin` as an object, or as one string named
|
|
293
|
+
* for the package without its scope, as an install reads it. A name that would leave .bin is not a bin.
|
|
294
|
+
*/
|
|
295
|
+
function declaredBins(manifest: unknown, name: string): Map<string, string> {
|
|
296
|
+
const bin = typeof manifest === 'object' && manifest !== null ? Reflect.get(manifest, 'bin') : undefined;
|
|
297
|
+
const entries: [string, unknown][] =
|
|
298
|
+
typeof bin === 'string'
|
|
299
|
+
? [[name.slice(name.lastIndexOf('/') + 1), bin]]
|
|
300
|
+
: typeof bin === 'object' && bin !== null
|
|
301
|
+
? Object.entries(bin)
|
|
302
|
+
: [];
|
|
303
|
+
const bins = new Map<string, string>();
|
|
304
|
+
for (const [binName, file] of entries) {
|
|
305
|
+
if (typeof file !== 'string' || binName === '' || binName.includes('/') || binName.startsWith('.')) continue;
|
|
306
|
+
bins.set(binName, path.posix.normalize(file));
|
|
307
|
+
}
|
|
308
|
+
return bins;
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
/**
|
|
312
|
+
* Puts each readable live developer link's bins in its tree's .bin. bun links every installed package's declared
|
|
313
|
+
* bins there, through the package's own alias, and a link that replaces the package leaves the .bin that install
|
|
314
|
+
* made: the installed version's bin set, missing what the linked version added and dangling what it dropped. Each
|
|
315
|
+
* link's declared bins are linked as an install of the linked version would link them, and the entries that point into
|
|
316
|
+
* its alias for bins it no longer declares are removed; another package's entries are never touched. A link this
|
|
317
|
+
* process may not read keeps the bins it has.
|
|
318
|
+
*/
|
|
319
|
+
function refreshDeveloperBins(root: string): void {
|
|
320
|
+
const { live, unreadable } = findDeveloperLinks(root);
|
|
321
|
+
const blocked = new Set(unreadable.map((link) => link.path));
|
|
322
|
+
const changed: string[] = [];
|
|
323
|
+
for (const link of live) {
|
|
324
|
+
if (blocked.has(link.path)) continue;
|
|
325
|
+
let manifest: unknown;
|
|
326
|
+
try {
|
|
327
|
+
manifest = JSON.parse(readFileSync(path.join(root, link.path, 'package.json'), 'utf8'));
|
|
328
|
+
} catch (error) {
|
|
329
|
+
if (error instanceof Error && 'code' in error && error.code === 'ENOENT') continue;
|
|
330
|
+
throw error;
|
|
331
|
+
}
|
|
332
|
+
const binDirectory = path.join(root, linkTree(link), '.bin');
|
|
333
|
+
const alias = path.relative(binDirectory, path.join(root, link.path)).split(path.sep).join('/');
|
|
334
|
+
const wanted = new Map(
|
|
335
|
+
[...declaredBins(manifest, packageName(link))].map(([name, file]) => [name, path.posix.join(alias, file)]),
|
|
336
|
+
);
|
|
337
|
+
for (const entry of directoryEntries(binDirectory)) {
|
|
338
|
+
if (!entry.isSymbolicLink()) continue;
|
|
339
|
+
const at = path.join(binDirectory, entry.name);
|
|
340
|
+
const target = readlinkSync(at);
|
|
341
|
+
if (target.startsWith(`${alias}/`) && wanted.get(entry.name) !== target) {
|
|
342
|
+
rmSync(at, { force: true });
|
|
343
|
+
if (!wanted.has(entry.name)) changed.push(`-${entry.name}`);
|
|
344
|
+
}
|
|
345
|
+
}
|
|
346
|
+
for (const [name, target] of wanted) {
|
|
347
|
+
const at = path.join(binDirectory, name);
|
|
348
|
+
if (lstatSync(at, { throwIfNoEntry: false })?.isSymbolicLink() && readlinkSync(at) === target) continue;
|
|
349
|
+
mkdirSync(binDirectory, { recursive: true });
|
|
350
|
+
// Rename replaces whatever the install left at the name in one step.
|
|
351
|
+
const staged = path.join(binDirectory, `.${name}.developer-link-${process.pid}`);
|
|
352
|
+
rmSync(staged, { force: true });
|
|
353
|
+
symlinkSync(target, staged);
|
|
354
|
+
renameSync(staged, at);
|
|
355
|
+
changed.push(name);
|
|
356
|
+
}
|
|
357
|
+
}
|
|
358
|
+
if (changed.length > 0) console.error(`linked developer-link bins: ${[...new Set(changed)].join(', ')}`);
|
|
359
|
+
}
|
|
360
|
+
|
|
277
361
|
/** A package linked from many members is named once, with its count; each unreadable link is named on its own. */
|
|
278
362
|
function describeDeveloperLinks(root: string, { live, unreadable }: Omit<DeveloperLinks, 'dangling'>): void {
|
|
279
363
|
for (const link of unreadable) {
|
|
@@ -662,7 +746,10 @@ export function applyDeclaredLinks(root: string, plan: DeclaredLinksPlan): void
|
|
|
662
746
|
break;
|
|
663
747
|
}
|
|
664
748
|
}
|
|
665
|
-
if (plan.changes.length === 0)
|
|
749
|
+
if (plan.changes.length === 0) {
|
|
750
|
+
refreshDeveloperBins(root);
|
|
751
|
+
return;
|
|
752
|
+
}
|
|
666
753
|
const declared = new Map(readDeclaredLinks(root).map((link) => [link.name, link.directory]));
|
|
667
754
|
const recorded = readDeclaredRecord(root);
|
|
668
755
|
const counts = new Map<string, number>();
|
|
@@ -684,6 +771,7 @@ export function applyDeclaredLinks(root: string, plan: DeclaredLinksPlan): void
|
|
|
684
771
|
const entries = [...counts].map(([named, count]) => (count === 1 ? named : `${named} (${count} links)`));
|
|
685
772
|
console.error(`linked declared packages to local checkouts: ${entries.join(', ')}`);
|
|
686
773
|
}
|
|
774
|
+
refreshDeveloperBins(root);
|
|
687
775
|
}
|
|
688
776
|
|
|
689
777
|
/**
|
|
@@ -771,10 +859,11 @@ function unavailableReason(target: string): string | null {
|
|
|
771
859
|
}
|
|
772
860
|
|
|
773
861
|
/**
|
|
774
|
-
* A build unit of a linked package that does not describe its current sources
|
|
775
|
-
* would actually run. A unit with an input record is judged by content: one of its inputs has
|
|
776
|
-
* build read, was removed, or was added since. A unit
|
|
777
|
-
*
|
|
862
|
+
* A build unit of a linked package that does not describe its current sources, or cannot be shown to: what an alias
|
|
863
|
+
* to the live checkout would actually run. A unit with an input record is judged by content: one of its inputs has
|
|
864
|
+
* other bytes than the build read, was removed, or was added since. A unit with outputs but no record is
|
|
865
|
+
* `unrecorded`: nothing says which bytes built it, and modification times cannot tell a rewrite with the same bytes (a
|
|
866
|
+
* rebase, a branch switch, a stash) from a change. A published unit with no outputs was never built.
|
|
778
867
|
*/
|
|
779
868
|
export type StaleBuild = {
|
|
780
869
|
readonly packageName: string;
|
|
@@ -785,11 +874,8 @@ export type StaleBuild = {
|
|
|
785
874
|
readonly workspaceRoot: string;
|
|
786
875
|
} & (
|
|
787
876
|
| { readonly basis: 'recorded'; readonly input: string; readonly change: 'changed' | 'removed' | 'added' }
|
|
788
|
-
| {
|
|
789
|
-
|
|
790
|
-
readonly builtAt: { readonly path: string; readonly time: Date } | null;
|
|
791
|
-
readonly newestInput: { readonly path: string; readonly time: Date };
|
|
792
|
-
}
|
|
877
|
+
| { readonly basis: 'unrecorded'; readonly output: string }
|
|
878
|
+
| { readonly basis: 'unbuilt' }
|
|
793
879
|
);
|
|
794
880
|
|
|
795
881
|
/**
|
|
@@ -943,25 +1029,24 @@ function cachedBuildInputRecords(directory: string): string[] {
|
|
|
943
1029
|
* TypeScript emit's `outDir` is an independent boundary and accepts a standalone bootstrap's record without a producer,
|
|
944
1030
|
* so an enclosing old layout cannot hide it. Shell entry starts no Nx graph and normalizes no output declarations.
|
|
945
1031
|
*
|
|
946
|
-
* Outputs no record covers
|
|
947
|
-
* TypeScript build stale:
|
|
1032
|
+
* Outputs no record covers are grouped into units, so the refusal names what builds them:
|
|
948
1033
|
*
|
|
949
1034
|
* - the TypeScript project `tsconfig.lib.json` builds: the published, untracked files under its `outDir` less build
|
|
950
|
-
* info
|
|
951
|
-
* - each target the package manifest's `nx.targets` declares with outputs among those files
|
|
952
|
-
*
|
|
953
|
-
* - every other published, untracked file, read from the package's tracked files less documentation and tests.
|
|
1035
|
+
* info;
|
|
1036
|
+
* - each target the package manifest's `nx.targets` declares with outputs among those files;
|
|
1037
|
+
* - every other published, untracked file.
|
|
954
1038
|
*
|
|
955
|
-
*
|
|
956
|
-
*
|
|
957
|
-
*
|
|
958
|
-
*
|
|
1039
|
+
* Such a unit is refused as unrecorded, whatever the times of its files: it cannot be judged by content, and a
|
|
1040
|
+
* modification time cannot tell a rewrite with the same bytes from a change, while a cached rebuild that finds its
|
|
1041
|
+
* outputs current leaves their times as they were. Its producer has to write a record. A unit with no tracked input
|
|
1042
|
+
* is not judged, and the TypeScript emit's unit, which the package publishes, is refused as never built when it has no
|
|
1043
|
+
* outputs. A `.tsbuildinfo` belongs to no unit: the build emits with `incremental: false`, so one under `outDir` is a
|
|
1044
|
+
* leftover no build rewrites.
|
|
959
1045
|
*
|
|
960
1046
|
* Output directories built for another host (`darwin-x64` on an arm64 Mac) are skipped: nothing here runs them.
|
|
961
1047
|
* The remedy names the receipt's exact producer target and configuration; `build` need not reach a native producer.
|
|
962
|
-
*
|
|
963
|
-
*
|
|
964
|
-
* to skip the cache.
|
|
1048
|
+
* A cached build that leaves a recorded unit stale is a cache-key defect (its inputs miss something its outputs
|
|
1049
|
+
* depend on), never a reason to skip the cache.
|
|
965
1050
|
*/
|
|
966
1051
|
export function staleBuilds(packageName: string, directory: string): StaleBuild[] {
|
|
967
1052
|
const manifest: unknown = JSON.parse(readFileSync(path.join(directory, 'package.json'), 'utf8'));
|
|
@@ -1115,7 +1200,10 @@ export function staleBuilds(packageName: string, directory: string): StaleBuild[
|
|
|
1115
1200
|
const value = Reflect.get(definition, key);
|
|
1116
1201
|
return Array.isArray(value) ? value.filter((entry): entry is string => typeof entry === 'string') : [];
|
|
1117
1202
|
};
|
|
1118
|
-
|
|
1203
|
+
// A declared output names a directory with or without its trailing slash; the files under it are the same.
|
|
1204
|
+
const outputs = claim(
|
|
1205
|
+
strings('outputs').flatMap((output) => under(path.normalize(resolve(output)).replace(/\/+$/, ''))),
|
|
1206
|
+
);
|
|
1119
1207
|
if (outputs.length === 0) continue;
|
|
1120
1208
|
const fileInputs = strings('inputs').filter(
|
|
1121
1209
|
(input) => input.includes('{projectRoot}') || input.includes('{workspaceRoot}'),
|
|
@@ -1146,32 +1234,15 @@ export function staleBuilds(packageName: string, directory: string): StaleBuild[
|
|
|
1146
1234
|
expected: false,
|
|
1147
1235
|
});
|
|
1148
1236
|
|
|
1149
|
-
// A tracked input deleted in the working tree has no time; the files that remain decide.
|
|
1150
|
-
const modified = (file: string) => statSync(path.join(workspaceRoot, file), { throwIfNoEntry: false })?.mtime;
|
|
1151
1237
|
for (const unit of units) {
|
|
1152
1238
|
if (unit.inputs.length === 0) continue;
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
let builtAt: { readonly path: string; readonly time: Date } | null = null;
|
|
1159
|
-
for (const output of unit.outputs) {
|
|
1160
|
-
const time = modified(output);
|
|
1161
|
-
if (time !== undefined && (builtAt === null || time > builtAt.time)) builtAt = { path: output, time };
|
|
1239
|
+
const output = unit.outputs[0];
|
|
1240
|
+
if (output === undefined) {
|
|
1241
|
+
if (unit.expected)
|
|
1242
|
+
stale.push({ basis: 'unbuilt', packageName, directory, unit: unit.label, rebuild, workspaceRoot });
|
|
1243
|
+
continue;
|
|
1162
1244
|
}
|
|
1163
|
-
|
|
1164
|
-
if (builtAt !== null && newestInput.time <= builtAt.time) continue;
|
|
1165
|
-
stale.push({
|
|
1166
|
-
basis: 'modification-time',
|
|
1167
|
-
packageName,
|
|
1168
|
-
directory,
|
|
1169
|
-
unit: unit.label,
|
|
1170
|
-
builtAt,
|
|
1171
|
-
newestInput,
|
|
1172
|
-
rebuild,
|
|
1173
|
-
workspaceRoot,
|
|
1174
|
-
});
|
|
1245
|
+
stale.push({ basis: 'unrecorded', packageName, directory, unit: unit.label, output, rebuild, workspaceRoot });
|
|
1175
1246
|
}
|
|
1176
1247
|
return stale;
|
|
1177
1248
|
}
|
|
@@ -1188,10 +1259,9 @@ export function staleBuildsRefusal(stale: readonly StaleBuild[]): string {
|
|
|
1188
1259
|
: 'was added since the build';
|
|
1189
1260
|
return ` - ${build.packageName}: ${build.unit} is stale: input ${build.input} ${how} (its ${BUILD_INPUTS_FILE})`;
|
|
1190
1261
|
}
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
: ` - ${build.packageName}: ${build.unit} was built at ${build.builtAt.time.toISOString()} (${build.builtAt.path}), but ${build.newestInput.path} changed at ${build.newestInput.time.toISOString()} (${fallback})`;
|
|
1262
|
+
return build.basis === 'unbuilt'
|
|
1263
|
+
? ` - ${build.packageName}: ${build.unit} was never built`
|
|
1264
|
+
: ` - ${build.packageName}: ${build.unit} records no inputs (no ${BUILD_INPUTS_FILE} covers ${build.output}), so whether it describes its sources cannot be told: modification times would also count a file rewritten with its own bytes; its producer must write ${BUILD_INPUTS_FILE} beside its outputs`;
|
|
1195
1265
|
});
|
|
1196
1266
|
const commands = [...new Set(stale.map((build) => `cd ${JSON.stringify(build.workspaceRoot)} && ${build.rebuild}`))];
|
|
1197
1267
|
return `refusing developer link(s) to a live checkout whose build does not describe its sources; the link would run the old build:\n${lines.join('\n')}\nRebuild: ${commands.join('; ')}`;
|