@smoothbricks/nx-plugin 0.4.30 → 0.5.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 +36 -21
- package/dist/cargo-toolchain-policy.d.ts +6 -6
- package/dist/cargo-toolchain-policy.js +6 -6
- package/dist/cross-check-policy.d.ts +31 -14
- package/dist/cross-check-policy.d.ts.map +1 -1
- package/dist/cross-check-policy.js +43 -15
- package/dist/executors/bounded-exec/cpu-tokens.d.ts +22 -5
- package/dist/executors/bounded-exec/cpu-tokens.d.ts.map +1 -1
- package/dist/executors/bounded-exec/cpu-tokens.js +189 -18
- package/dist/executors/bounded-exec/executor.d.ts.map +1 -1
- package/dist/executors/bounded-exec/executor.js +3 -2
- package/dist/executors/bounded-exec/run-cpu-pool.d.ts +10 -0
- package/dist/executors/bounded-exec/run-cpu-pool.d.ts.map +1 -0
- package/dist/executors/bounded-exec/run-cpu-pool.js +63 -0
- package/dist/executors/cargo-zigbuild/executor.d.ts +60 -0
- package/dist/executors/cargo-zigbuild/executor.d.ts.map +1 -0
- package/dist/executors/cargo-zigbuild/executor.js +266 -0
- package/dist/executors/cargo-zigbuild/schema.d.ts +15 -0
- package/dist/executors/cargo-zigbuild/schema.d.ts.map +1 -0
- package/dist/index.d.ts +3 -16
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +69 -92
- package/dist/testing.d.ts.map +1 -1
- package/dist/testing.js +3 -2
- package/executors.json +4 -4
- package/managed/raw/patches/nx@23.2.1.patch +177 -9
- package/managed/raw/tooling/direnv/devenv.smoo.nix +46 -46
- package/managed/raw/tooling/direnv/setup-environment.ts +13 -0
- package/managed/raw/tooling/git-hooks/pre-push.sh +41 -23
- package/package.json +1 -1
- package/src/cargo-closure-key.test.ts +3 -2
- package/src/cargo-toolchain-policy.ts +6 -6
- package/src/cross-check-policy.test.ts +90 -11
- package/src/cross-check-policy.ts +47 -17
- package/src/executors/bounded-exec/cpu-tokens.test.ts +205 -0
- package/src/executors/bounded-exec/cpu-tokens.ts +229 -22
- package/src/executors/bounded-exec/executor.ts +3 -2
- package/src/executors/bounded-exec/run-cpu-pool.test.ts +76 -0
- package/src/executors/bounded-exec/run-cpu-pool.ts +75 -0
- package/src/executors/cargo-zigbuild/executor.test.ts +129 -0
- package/src/executors/cargo-zigbuild/executor.ts +176 -0
- package/src/executors/cargo-zigbuild/schema.json +35 -0
- package/src/executors/cargo-zigbuild/schema.ts +14 -0
- package/src/index.test.ts +41 -63
- package/src/index.ts +73 -101
- package/src/nx-daemon-validity.test.ts +65 -0
- package/src/testing.ts +3 -2
- package/test-timings.json +2 -1
- package/dist/executors/napi-cross-toolchain/executor.d.ts +0 -42
- package/dist/executors/napi-cross-toolchain/executor.d.ts.map +0 -1
- package/dist/executors/napi-cross-toolchain/executor.js +0 -126
- package/dist/executors/napi-cross-toolchain/schema.d.ts +0 -4
- package/dist/executors/napi-cross-toolchain/schema.d.ts.map +0 -1
- package/src/executors/napi-cross-toolchain/executor.test.ts +0 -112
- package/src/executors/napi-cross-toolchain/executor.ts +0 -165
- package/src/executors/napi-cross-toolchain/schema.json +0 -15
- package/src/executors/napi-cross-toolchain/schema.ts +0 -3
- /package/dist/executors/{napi-cross-toolchain → cargo-zigbuild}/schema.js +0 -0
package/dist/testing.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"testing.d.ts","sourceRoot":"","sources":["../src/testing.ts"],"names":[],"mappings":"AAsDA,oCAAoC;AACpC,MAAM,WAAW,YAAY;IAC3B,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,+DAA+D;IAC/D,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;CAC1B;AAED,4EAA4E;AAC5E,wBAAsB,YAAY,IAAI,OAAO,CAAC,YAAY,EAAE,CAAC,CAe5D;AAED;;;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MAAM,CAWjF;AAED;;;;;;GAMG;AACH,wBAAsB,oBAAoB,CAAC,MAAM,EAAE,MAAM,EAAE,iBAAiB,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAIrG;AAoBD;;;;;;;;;GASG;AACH,wBAAgB,sBAAsB,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,CAKhE;AAED;;;;;;;;GAQG;AACH,wBAAsB,6BAA6B,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CA8BtF;AAED;;;;;;GAMG;AACH,wBAAsB,6BAA6B,CAAC,SAAS,EAAE,MAAM,EAAE,IAAI,EAAE,GAAG,GAAG,GAAG,GAAG,OAAO,CAAC,MAAM,CAAC,CAMvG;AAED;;;;;GAKG;AACH,wBAAsB,4BAA4B,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CASnF;AA0DD;;;;;;;;;;;;;;;GAeG;AACH,wBAAsB,YAAY,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAqBxF"}
|
package/dist/testing.js
CHANGED
|
@@ -120,9 +120,10 @@ export function terminate(pid, signal = 'SIGTERM') {
|
|
|
120
120
|
* `timeoutMs` later is an error naming it and `owner`.
|
|
121
121
|
*/
|
|
122
122
|
export async function awaitExit(processes, owner, timeoutMs = EXIT_TIMEOUT_MS) {
|
|
123
|
-
|
|
123
|
+
// The monotonic clock: a wall-clock step (NTP, sleep and wake) must not move the deadline.
|
|
124
|
+
const deadline = performance.now() + timeoutMs;
|
|
124
125
|
for (let waiting = processes.filter((entry) => isRunning(entry.pid)); waiting.length > 0;) {
|
|
125
|
-
if (
|
|
126
|
+
if (performance.now() > deadline) {
|
|
126
127
|
// A signal probe also answers for a zombie, which has already exited.
|
|
127
128
|
const live = new Set((await processTable()).filter((entry) => !entry.stat.startsWith('Z')).map((entry) => entry.pid));
|
|
128
129
|
const survivors = waiting.filter((entry) => live.has(entry.pid));
|
package/executors.json
CHANGED
|
@@ -15,10 +15,10 @@
|
|
|
15
15
|
"schema": "./src/executors/clean-outputs/schema.json",
|
|
16
16
|
"description": "Remove declared build output directories unless they contain tracked files"
|
|
17
17
|
},
|
|
18
|
-
"
|
|
19
|
-
"implementation": "./dist/executors/
|
|
20
|
-
"schema": "./src/executors/
|
|
21
|
-
"description": "
|
|
18
|
+
"cargo-zigbuild": {
|
|
19
|
+
"implementation": "./dist/executors/cargo-zigbuild/executor.js",
|
|
20
|
+
"schema": "./src/executors/cargo-zigbuild/schema.json",
|
|
21
|
+
"description": "Build one Linux binary or cdylib with devenv's zig through cargo-zigbuild and copy it to its output file"
|
|
22
22
|
},
|
|
23
23
|
"shard-timings": {
|
|
24
24
|
"implementation": "./dist/executors/shard-timings/executor.js",
|
|
@@ -678,7 +678,7 @@ index c2a2f8f70fe71940e47c97931c5925bac1fbd480..39582a8fc342ae59decd3d4ca25179f2
|
|
|
678
678
|
// Bump generation synchronously so any in-flight compute fails its
|
|
679
679
|
diff --git a/dist/src/daemon/server/restart-checks.d.ts b/dist/src/daemon/server/restart-checks.d.ts
|
|
680
680
|
new file mode 100644
|
|
681
|
-
index 0000000000000000000000000000000000000000..
|
|
681
|
+
index 0000000000000000000000000000000000000000..28f263f82b7b698ec1bf88943924696b3d9a91e7
|
|
682
682
|
--- /dev/null
|
|
683
683
|
+++ b/dist/src/daemon/server/restart-checks.d.ts
|
|
684
684
|
@@ -0,0 +1,10 @@
|
|
@@ -687,22 +687,22 @@ index 0000000000000000000000000000000000000000..2a76dce933112854e34d61a44aa90b7c
|
|
|
687
687
|
+export declare const DAEMON_VALIDITY_SAFETY_INTERVAL_MS = 5000;
|
|
688
688
|
+export declare const relativeServerProcess: string;
|
|
689
689
|
+export declare function registerDaemonForRestartChecks(server: Server, sockets: Iterable<Socket>, socketPath: string): void;
|
|
690
|
-
+export declare function
|
|
690
|
+
+export declare function recordInstallationBaseline(): void;
|
|
691
691
|
+export declare function restartDaemonIfLockFilesChanged(paths: string[]): boolean;
|
|
692
692
|
+export declare function stopDaemonIfReplaced(events: WatchEvent[]): boolean;
|
|
693
693
|
+export declare function stopDaemonIfOutdated(): boolean;
|
|
694
694
|
+export declare function stopDaemonIfWorkspaceGone(): boolean;
|
|
695
695
|
diff --git a/dist/src/daemon/server/restart-checks.js b/dist/src/daemon/server/restart-checks.js
|
|
696
696
|
new file mode 100644
|
|
697
|
-
index 0000000000000000000000000000000000000000..
|
|
697
|
+
index 0000000000000000000000000000000000000000..5f7aa0aa874dfe389388169c8acb0c0ab45f5180
|
|
698
698
|
--- /dev/null
|
|
699
699
|
+++ b/dist/src/daemon/server/restart-checks.js
|
|
700
|
-
@@ -0,0 +1,
|
|
700
|
+
@@ -0,0 +1,295 @@
|
|
701
701
|
+"use strict";
|
|
702
702
|
+Object.defineProperty(exports, "__esModule", { value: true });
|
|
703
703
|
+exports.relativeServerProcess = exports.DAEMON_VALIDITY_SAFETY_INTERVAL_MS = void 0;
|
|
704
704
|
+exports.registerDaemonForRestartChecks = registerDaemonForRestartChecks;
|
|
705
|
-
+exports.
|
|
705
|
+
+exports.recordInstallationBaseline = recordInstallationBaseline;
|
|
706
706
|
+exports.restartDaemonIfLockFilesChanged = restartDaemonIfLockFilesChanged;
|
|
707
707
|
+exports.stopDaemonIfReplaced = stopDaemonIfReplaced;
|
|
708
708
|
+exports.stopDaemonIfOutdated = stopDaemonIfOutdated;
|
|
@@ -740,8 +740,14 @@ index 0000000000000000000000000000000000000000..6adb712340b154dcabb7570bc1b4c586
|
|
|
740
740
|
+ }
|
|
741
741
|
+ return (0, file_hasher_1.hashArray)(hashes);
|
|
742
742
|
+}
|
|
743
|
-
|
|
743
|
+
+// The startup baseline of everything a restart judges by bytes: the root
|
|
744
|
+
+// lockfiles and the linked plugins below.
|
|
745
|
+
+function recordInstallationBaseline() {
|
|
744
746
|
+ lockFileHash = hashLockFiles();
|
|
747
|
+
+ const roots = linkedPluginRoots() ?? [];
|
|
748
|
+
+ linkedPluginRootKey = JSON.stringify(roots);
|
|
749
|
+
+ linkedPluginFiles = hashCensus(linkedPluginCensus(roots), new Map());
|
|
750
|
+
+ linkedPluginCensusAt = Date.now();
|
|
745
751
|
+}
|
|
746
752
|
+function lockFileHashChanged() {
|
|
747
753
|
+ const newHash = hashLockFiles();
|
|
@@ -753,6 +759,164 @@ index 0000000000000000000000000000000000000000..6adb712340b154dcabb7570bc1b4c586
|
|
|
753
759
|
+ lockFileHash = newHash;
|
|
754
760
|
+ return false;
|
|
755
761
|
+}
|
|
762
|
+
+// A plugin nx.json names whose package resolves outside the workspace (a
|
|
763
|
+
+// developer link into another checkout) changes behind that link with no
|
|
764
|
+
+// lockfile change here. The daemon kept serving the graph the old plugin code
|
|
765
|
+
+// inferred, so every task hashed after the change was keyed on a configuration
|
|
766
|
+
+// no fresh process computes. Its published files and the lockfiles of the
|
|
767
|
+
+// checkout it lives in are judged like the root lockfiles: a file whose stat
|
|
768
|
+
+// moved is hashed again, and only changed bytes restart the daemon. Files are
|
|
769
|
+
+// keyed by plugin and package-relative path, so a link moved to a copy with the
|
|
770
|
+
+// same bytes keeps the daemon. A request resolves each link and stats the files
|
|
771
|
+
+// already known; a moved link, and at most once per safety interval anyway, takes
|
|
772
|
+
+// the full census, which finds a file added beside them. A package inside the
|
|
773
|
+
+// workspace changes only with its lockfile.
|
|
774
|
+
+let linkedPluginRootKey;
|
|
775
|
+
+let linkedPluginFiles;
|
|
776
|
+
+let linkedPluginCensusAt = 0;
|
|
777
|
+
+const PACKAGE_GLOB = /[*?[{]/;
|
|
778
|
+
+function pluginSpecifiers() {
|
|
779
|
+
+ let plugins;
|
|
780
|
+
+ try {
|
|
781
|
+
+ plugins = JSON.parse((0, fs_1.readFileSync)(nxJson, 'utf8')).plugins;
|
|
782
|
+
+ }
|
|
783
|
+
+ catch (error) {
|
|
784
|
+
+ logger_1.serverLogger.log(`[Server] linked plugins not judged: nx.json unreadable: ${error.message}`);
|
|
785
|
+
+ return null;
|
|
786
|
+
+ }
|
|
787
|
+
+ return (Array.isArray(plugins) ? plugins : [])
|
|
788
|
+
+ .map((entry) => (typeof entry === 'string' ? entry : entry?.plugin))
|
|
789
|
+
+ .filter((name) => typeof name === 'string' && !name.startsWith('.') && !(0, path_1.isAbsolute)(name));
|
|
790
|
+
+}
|
|
791
|
+
+// Each nx.json plugin whose package resolves outside the workspace, as
|
|
792
|
+
+// [specifier, real package root]; null when nx.json cannot say which plugins there are.
|
|
793
|
+
+function linkedPluginRoots() {
|
|
794
|
+
+ const specifiers = pluginSpecifiers();
|
|
795
|
+
+ if (specifiers === null) return null;
|
|
796
|
+
+ const workspace = (0, fs_1.realpathSync)(workspace_root_1.workspaceRoot);
|
|
797
|
+
+ const roots = [];
|
|
798
|
+
+ for (const name of specifiers) {
|
|
799
|
+
+ let root;
|
|
800
|
+
+ try {
|
|
801
|
+
+ root = (0, fs_1.realpathSync)((0, path_1.join)(workspace_root_1.workspaceRoot, 'node_modules', name));
|
|
802
|
+
+ }
|
|
803
|
+
+ catch (error) {
|
|
804
|
+
+ if (error.code === 'ENOENT') continue;
|
|
805
|
+
+ throw error;
|
|
806
|
+
+ }
|
|
807
|
+
+ if (root !== workspace && !root.startsWith(workspace + path_1.sep)) roots.push([name, root]);
|
|
808
|
+
+ }
|
|
809
|
+
+ return roots;
|
|
810
|
+
+}
|
|
811
|
+
+function statKey(stat) {
|
|
812
|
+
+ return `${stat.dev}:${stat.ino}:${stat.size}:${stat.mtimeNs}:${stat.ctimeNs}`;
|
|
813
|
+
+}
|
|
814
|
+
+// Adds every file under `path` (following links, each directory once) to
|
|
815
|
+
+// `census`, keyed by `prefix` and its path relative to `base`, with its stat.
|
|
816
|
+
+function addFiles(census, prefix, base, path, seen = new Set()) {
|
|
817
|
+
+ let stat;
|
|
818
|
+
+ try {
|
|
819
|
+
+ stat = (0, fs_1.statSync)(path, { bigint: true });
|
|
820
|
+
+ }
|
|
821
|
+
+ catch (error) {
|
|
822
|
+
+ if (error.code === 'ENOENT') return;
|
|
823
|
+
+ throw error;
|
|
824
|
+
+ }
|
|
825
|
+
+ if (stat.isDirectory()) {
|
|
826
|
+
+ const directory = `${stat.dev}:${stat.ino}`;
|
|
827
|
+
+ if (seen.has(directory)) return;
|
|
828
|
+
+ seen.add(directory);
|
|
829
|
+
+ for (const entry of (0, fs_1.readdirSync)(path)) {
|
|
830
|
+
+ if (entry !== 'node_modules') addFiles(census, prefix, base, (0, path_1.join)(path, entry), seen);
|
|
831
|
+
+ }
|
|
832
|
+
+ }
|
|
833
|
+
+ else if (stat.isFile()) {
|
|
834
|
+
+ census.set(`${prefix}${(0, path_1.relative)(base, path)}`, { path, stat: statKey(stat) });
|
|
835
|
+
+ }
|
|
836
|
+
+}
|
|
837
|
+
+// Every file each linked plugin publishes and its checkout's lockfiles.
|
|
838
|
+
+function linkedPluginCensus(roots) {
|
|
839
|
+
+ const census = new Map();
|
|
840
|
+
+ for (const [name, root] of roots) {
|
|
841
|
+
+ const manifest = (0, path_1.join)(root, 'package.json');
|
|
842
|
+
+ addFiles(census, `${name}\0`, root, manifest);
|
|
843
|
+
+ // A manifest with no plain `files` list (absent, a glob, or bytes that do
|
|
844
|
+
+ // not parse, which the census holds too) publishes the whole package.
|
|
845
|
+
+ let files;
|
|
846
|
+
+ try {
|
|
847
|
+
+ files = JSON.parse((0, fs_1.readFileSync)(manifest, 'utf8')).files;
|
|
848
|
+
+ }
|
|
849
|
+
+ catch {
|
|
850
|
+
+ files = undefined;
|
|
851
|
+
+ }
|
|
852
|
+
+ const listed = Array.isArray(files) ? files.filter((file) => typeof file !== 'string' || !file.startsWith('!')) : [];
|
|
853
|
+
+ const published = listed.length > 0 && listed.every((file) => typeof file === 'string' && !PACKAGE_GLOB.test(file));
|
|
854
|
+
+ for (const file of published ? listed : ['.']) addFiles(census, `${name}\0`, root, (0, path_1.join)(root, file));
|
|
855
|
+
+ for (let directory = root; ; directory = (0, path_1.dirname)(directory)) {
|
|
856
|
+
+ const locks = LOCK_FILE_NAMES.map((lock) => (0, path_1.join)(directory, lock)).filter((lock) => (0, fs_1.existsSync)(lock));
|
|
857
|
+
+ if (locks.length > 0 || (0, path_1.dirname)(directory) === directory) {
|
|
858
|
+
+ for (const lock of locks) addFiles(census, `${name}\0lock\0`, directory, lock);
|
|
859
|
+
+ break;
|
|
860
|
+
+ }
|
|
861
|
+
+ }
|
|
862
|
+
+ }
|
|
863
|
+
+ return census;
|
|
864
|
+
+}
|
|
865
|
+
+// The census with each file's hash, reusing `recorded`'s for a file whose path
|
|
866
|
+
+// and stat have not moved.
|
|
867
|
+
+function hashCensus(census, recorded) {
|
|
868
|
+
+ const files = new Map();
|
|
869
|
+
+ for (const [key, { path, stat }] of census) {
|
|
870
|
+
+ const previous = recorded.get(key);
|
|
871
|
+
+ files.set(key, previous !== undefined && previous.path === path && previous.stat === stat
|
|
872
|
+
+ ? previous
|
|
873
|
+
+ : { path, stat, hash: (0, native_1.hashFile)(path) });
|
|
874
|
+
+ }
|
|
875
|
+
+ return files;
|
|
876
|
+
+}
|
|
877
|
+
+// The known files' stats, a vanished one left out.
|
|
878
|
+
+function knownFileStats() {
|
|
879
|
+
+ const census = new Map();
|
|
880
|
+
+ for (const [key, { path }] of linkedPluginFiles) {
|
|
881
|
+
+ let stat;
|
|
882
|
+
+ try {
|
|
883
|
+
+ stat = (0, fs_1.statSync)(path, { bigint: true });
|
|
884
|
+
+ }
|
|
885
|
+
+ catch (error) {
|
|
886
|
+
+ if (error.code === 'ENOENT') continue;
|
|
887
|
+
+ throw error;
|
|
888
|
+
+ }
|
|
889
|
+
+ census.set(key, { path, stat: statKey(stat) });
|
|
890
|
+
+ }
|
|
891
|
+
+ return census;
|
|
892
|
+
+}
|
|
893
|
+
+function linkedPluginsChanged() {
|
|
894
|
+
+ if (linkedPluginFiles === undefined) return false;
|
|
895
|
+
+ const roots = linkedPluginRoots();
|
|
896
|
+
+ if (roots === null) return false;
|
|
897
|
+
+ const rootKey = JSON.stringify(roots);
|
|
898
|
+
+ const now = Date.now();
|
|
899
|
+
+ const full = rootKey !== linkedPluginRootKey || now - linkedPluginCensusAt >= exports.DAEMON_VALIDITY_SAFETY_INTERVAL_MS;
|
|
900
|
+
+ const census = full ? linkedPluginCensus(roots) : knownFileStats();
|
|
901
|
+
+ if (full) {
|
|
902
|
+
+ linkedPluginRootKey = rootKey;
|
|
903
|
+
+ linkedPluginCensusAt = now;
|
|
904
|
+
+ }
|
|
905
|
+
+ const files = hashCensus(census, linkedPluginFiles);
|
|
906
|
+
+ let change = null;
|
|
907
|
+
+ for (const [key, { path, hash }] of files) {
|
|
908
|
+
+ const previous = linkedPluginFiles.get(key);
|
|
909
|
+
+ if (previous === undefined) change ??= `${path} appeared`;
|
|
910
|
+
+ else if (previous.hash !== hash) change ??= `${path} changed`;
|
|
911
|
+
+ }
|
|
912
|
+
+ for (const [key, { path }] of linkedPluginFiles) {
|
|
913
|
+
+ if (!files.has(key)) change ??= `${path} disappeared`;
|
|
914
|
+
+ }
|
|
915
|
+
+ linkedPluginFiles = files;
|
|
916
|
+
+ if (change === null) return false;
|
|
917
|
+
+ logger_1.serverLogger.log(`[Server] linked plugin file ${change}`);
|
|
918
|
+
+ return true;
|
|
919
|
+
+}
|
|
756
920
|
+// Applied paths have been hashed by the native workspace context; same-byte
|
|
757
921
|
+// rewrites were dropped already. No lockfile is read on this watcher path.
|
|
758
922
|
+function restartDaemonIfLockFilesChanged(paths) {
|
|
@@ -806,6 +970,10 @@ index 0000000000000000000000000000000000000000..6adb712340b154dcabb7570bc1b4c586
|
|
|
806
970
|
+ restartDaemon('LOCK_FILES_CHANGED');
|
|
807
971
|
+ return true;
|
|
808
972
|
+ }
|
|
973
|
+
+ if (linkedPluginsChanged()) {
|
|
974
|
+
+ restartDaemon('LINKED_PLUGIN_CHANGED');
|
|
975
|
+
+ return true;
|
|
976
|
+
+ }
|
|
809
977
|
+ return false;
|
|
810
978
|
+}
|
|
811
979
|
+function isReplaced() {
|
|
@@ -826,7 +994,7 @@ index 0000000000000000000000000000000000000000..6adb712340b154dcabb7570bc1b4c586
|
|
|
826
994
|
+ (0, shutdown_utils_1.handleServerProcessTerminationWithRestart)({ server: daemon.server, reason, sockets: daemon.sockets });
|
|
827
995
|
+}
|
|
828
996
|
diff --git a/dist/src/daemon/server/server.js b/dist/src/daemon/server/server.js
|
|
829
|
-
index b1c143e244efd435b28642ed86e999d6c86f7d94..
|
|
997
|
+
index b1c143e244efd435b28642ed86e999d6c86f7d94..c68bcacb9bc46babaa86ea0ac212e79de1b47244 100644
|
|
830
998
|
--- a/dist/src/daemon/server/server.js
|
|
831
999
|
+++ b/dist/src/daemon/server/server.js
|
|
832
1000
|
@@ -7,17 +7,13 @@ const fs_1 = require("fs");
|
|
@@ -1011,8 +1179,8 @@ index b1c143e244efd435b28642ed86e999d6c86f7d94..5f1157fd3e37afc8ef739a8adce78a2b
|
|
|
1011
1179
|
+ process.exit(0);
|
|
1012
1180
|
+ }
|
|
1013
1181
|
+ (0, restart_checks_1.registerDaemonForRestartChecks)(server, exports.openSockets, socketPath);
|
|
1014
|
-
+ // Record before watch/scan so a lockfile changed during boot is not lost.
|
|
1015
|
-
+ (0, restart_checks_1.
|
|
1182
|
+
+ // Record before watch/scan so a lockfile or linked plugin changed during boot is not lost.
|
|
1183
|
+
+ (0, restart_checks_1.recordInstallationBaseline)();
|
|
1016
1184
|
// Watch before scan: a file written during boot must be visible to the
|
|
1017
1185
|
// watcher or the scan below. Scan-first left a blind window where such
|
|
1018
1186
|
// files stayed invisible to both until an unrelated change arrived.
|
|
@@ -98,6 +98,19 @@
|
|
|
98
98
|
mkdir -p "$out/bin"
|
|
99
99
|
ln -s ${pkgs.python3Packages.pyflakes}/bin/pyflakes "$out/bin/pyflakes"
|
|
100
100
|
'';
|
|
101
|
+
|
|
102
|
+
# Builds every Linux artifact and the cross clippy; see `profiles.linux-cross`
|
|
103
|
+
# below for where it applies and why. The rust-std set is every Linux triple
|
|
104
|
+
# an artifact ships for except x86_64-unknown-linux-gnu, which the base shell
|
|
105
|
+
# already carries.
|
|
106
|
+
linuxToolchain = {
|
|
107
|
+
packages = [pkgs.zig pkgs.cargo-zigbuild];
|
|
108
|
+
languages.rust.targets = [
|
|
109
|
+
"aarch64-unknown-linux-gnu"
|
|
110
|
+
"x86_64-unknown-linux-musl"
|
|
111
|
+
"aarch64-unknown-linux-musl"
|
|
112
|
+
];
|
|
113
|
+
};
|
|
101
114
|
in {
|
|
102
115
|
# nixpkgs carries actionlint, not the jdx fork. Supply the immutable upstream
|
|
103
116
|
# release as a normal package, with the same pin in developer shells and CI.
|
|
@@ -233,62 +246,49 @@ in {
|
|
|
233
246
|
# CI validates on Linux, so a macOS shell carries Linux's std and can
|
|
234
247
|
# type-check the arm CI compiles. rust-std alone reaches every crate whose
|
|
235
248
|
# dependency graph is pure Rust; a dependency that compiles C for the target
|
|
236
|
-
# — ring, openssl-sys, libgit2-sys, libz-sys — additionally needs a
|
|
237
|
-
# compiler, which is
|
|
238
|
-
# below
|
|
249
|
+
# — ring, openssl-sys, libgit2-sys, libz-sys — additionally needs a C
|
|
250
|
+
# compiler for the target, which is zig in the `linux-cross` toolchain
|
|
251
|
+
# below, kept off every macOS shell and macOS runner.
|
|
239
252
|
#
|
|
240
253
|
# The reverse direction is not available at any price: type-checking an Apple
|
|
241
254
|
# target from Linux needs an Apple SDK for those same C-building
|
|
242
255
|
# dependencies, which is a licensing boundary rather than a missing package.
|
|
243
|
-
targets =
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
256
|
+
targets =
|
|
257
|
+
[
|
|
258
|
+
"wasm32-unknown-unknown"
|
|
259
|
+
"x86_64-unknown-linux-gnu"
|
|
260
|
+
]
|
|
261
|
+
++ lib.optionals pkgs.stdenv.hostPlatform.isLinux linuxToolchain.languages.rust.targets;
|
|
247
262
|
};
|
|
248
263
|
|
|
249
|
-
#
|
|
250
|
-
#
|
|
251
|
-
#
|
|
252
|
-
#
|
|
253
|
-
#
|
|
254
|
-
#
|
|
255
|
-
#
|
|
256
|
-
#
|
|
257
|
-
# macOS laptop runs deliberately. Nothing on Darwin links a Linux object.
|
|
264
|
+
# The Linux toolchain: zig, driven through cargo-zigbuild, plus the Linux
|
|
265
|
+
# rust-std set. It builds every published Linux artifact — static musl CLIs,
|
|
266
|
+
# glibc 2.17 N-API addons — and `check:linux`'s cross clippy, with the same
|
|
267
|
+
# command on every host. zig carries glibc symbol-version stubs for every
|
|
268
|
+
# glibc and the musl sources inside its own store path, so nothing on the
|
|
269
|
+
# build machine reaches the artifact: no loader path, no RUNPATH, no build
|
|
270
|
+
# host's glibc floor. cargo-zigbuild supplies the `zig cc` shims and per-triple
|
|
271
|
+
# compiler variables itself, so this module sets no environment.
|
|
258
272
|
#
|
|
259
|
-
#
|
|
260
|
-
#
|
|
261
|
-
#
|
|
262
|
-
# `
|
|
263
|
-
#
|
|
264
|
-
#
|
|
273
|
+
# A Linux host carries it in the base shell, because its ordinary `build`
|
|
274
|
+
# includes its own platform's artifacts. A macOS host opts in through the
|
|
275
|
+
# `linux-cross` profile, activated by `devenv -P linux-cross` and driven by
|
|
276
|
+
# the root `check:linux` script: zig is a 380 MiB closure, about 0.9 GiB with
|
|
277
|
+
# the three rust-std targets, and nothing else on Darwin needs it. devenv 2.2.3
|
|
278
|
+
# has first-class profiles, so this is one gated module in the shared file
|
|
279
|
+
# rather than a second config directory that would re-import and re-pin
|
|
280
|
+
# everything here.
|
|
265
281
|
#
|
|
266
|
-
#
|
|
267
|
-
# being written out, so a nixpkgs bump that renames the prefix carries these
|
|
268
|
-
# with it rather than leaving four stale strings that fail at build-script time.
|
|
269
|
-
#
|
|
270
|
-
# This profile supplies the toolchain and nothing else. CARGO_BUILD_TARGET is
|
|
282
|
+
# The profile supplies the toolchain and nothing else. CARGO_BUILD_TARGET is
|
|
271
283
|
# deliberately NOT set: the triple belongs to the Nx target that asks for it
|
|
272
|
-
# (`cargo-lint-
|
|
284
|
+
# (`cargo-lint-cross` passes `--target` explicitly), not to the ambient
|
|
273
285
|
# environment. An ambient triple would make the check silently host-local
|
|
274
|
-
# whenever the profile was forgotten — reporting green having compiled macOS
|
|
275
|
-
# and that false green is the precise failure this whole profile exists to end.
|
|
286
|
+
# whenever the profile was forgotten — reporting green having compiled macOS.
|
|
276
287
|
# With the flag on the target instead, running it outside this profile fails
|
|
277
|
-
# loudly
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
tool = name: "${crossCC}/bin/${crossCC.targetPrefix}${name}";
|
|
282
|
-
in {
|
|
283
|
-
packages = [crossCC];
|
|
284
|
-
env = {
|
|
285
|
-
CC_x86_64_unknown_linux_gnu = tool "cc";
|
|
286
|
-
CXX_x86_64_unknown_linux_gnu = tool "c++";
|
|
287
|
-
AR_x86_64_unknown_linux_gnu = tool "ar";
|
|
288
|
-
CARGO_TARGET_X86_64_UNKNOWN_LINUX_GNU_LINKER = tool "cc";
|
|
289
|
-
# bindgen runs host libclang, which cannot infer the cross compiler's headers.
|
|
290
|
-
BINDGEN_EXTRA_CLANG_ARGS_x86_64_unknown_linux_gnu = "--target=x86_64-unknown-linux-gnu -isystem ${crossLibc}/include -isystem ${pkgs.pkgsCross.gnu64.linuxHeaders}/include";
|
|
291
|
-
};
|
|
288
|
+
# loudly on the missing cargo-zigbuild, and a host lint can never be mistaken
|
|
289
|
+
# for a cross one.
|
|
290
|
+
profiles.linux-cross.module = {
|
|
291
|
+
config = lib.mkIf (!pkgs.stdenv.hostPlatform.isLinux) linuxToolchain;
|
|
292
292
|
};
|
|
293
293
|
|
|
294
294
|
# linux-cross is the only profile here, and the shape of the publish job is
|
|
@@ -404,7 +404,7 @@ in {
|
|
|
404
404
|
# `cargo hakari verify` for a workspace that took that route.
|
|
405
405
|
pkgs.cargo-hakari
|
|
406
406
|
]
|
|
407
|
-
++ lib.optionals pkgs.stdenv.hostPlatform.isLinux [pkgs.chromium];
|
|
407
|
+
++ lib.optionals pkgs.stdenv.hostPlatform.isLinux ([pkgs.chromium] ++ linuxToolchain.packages);
|
|
408
408
|
|
|
409
409
|
# devenv wraps the Python interpreter to find native libraries in
|
|
410
410
|
# `languages.python.libraries`, whose default is this checkout's
|
|
@@ -253,6 +253,19 @@ try {
|
|
|
253
253
|
current && !hasStaleDeveloperLinks(projectRoot, ['nx']) && danglingStoreLinks(projectRoot).length === 0 ? 0 : 1,
|
|
254
254
|
);
|
|
255
255
|
}
|
|
256
|
+
// Planning reads, apart from a snapshot it may capture, which seals by an atomic rename (linked-snapshots.ts),
|
|
257
|
+
// and applying a plan with no changes only says what this machine cannot honour. So an entry with nothing to
|
|
258
|
+
// write never takes the install lock, and the entries of one checkout do not queue behind each other's probe of
|
|
259
|
+
// a provider checkout: a declaration whose snapshot the provider refuses fails the status on every entry.
|
|
260
|
+
const plan = await planDeclaredLinks(projectRoot);
|
|
261
|
+
if (
|
|
262
|
+
plan.changes.length === 0 &&
|
|
263
|
+
danglingStoreLinks(projectRoot).length === 0 &&
|
|
264
|
+
!hasStaleDeveloperLinks(projectRoot, ['nx'])
|
|
265
|
+
) {
|
|
266
|
+
applyDeclaredLinks(projectRoot, plan);
|
|
267
|
+
process.exit(0);
|
|
268
|
+
}
|
|
256
269
|
await withInstallLock(async () => {
|
|
257
270
|
// Recheck under the install lock: another shell may already have repaired
|
|
258
271
|
// the aliases. Use the same installer as smoo:install, never a second linker.
|
|
@@ -8,24 +8,27 @@
|
|
|
8
8
|
# repository so the guard never publishes what it guards; with none
|
|
9
9
|
# configured the check passes silently.
|
|
10
10
|
#
|
|
11
|
-
# 2. The macOS-only Linux cross-compile gate. It
|
|
12
|
-
#
|
|
13
|
-
#
|
|
14
|
-
#
|
|
15
|
-
#
|
|
11
|
+
# 2. The macOS-only Linux cross-compile gate. It asks Nx for cargo-lint-cross,
|
|
12
|
+
# whose hit means a real `cargo-zigbuild clippy --target x86_64-unknown-linux-gnu`
|
|
13
|
+
# already passed for exactly this tree, so the push is safe with no toolchain
|
|
14
|
+
# present. From a plain shell the cross target itself never compiles here: on
|
|
15
|
+
# a miss its guard refuses. Its dependencies are ordinary Nx tasks whose outputs
|
|
16
|
+
# the cross key reads, so Nx restores them from the cache or, for a tree no gate
|
|
17
|
+
# ran, builds them. A refusal names the one command that fixes it; any other Nx
|
|
18
|
+
# failure is said as that, never as a cache miss.
|
|
16
19
|
#
|
|
17
|
-
# Why
|
|
18
|
-
#
|
|
19
|
-
#
|
|
20
|
-
#
|
|
21
|
-
#
|
|
20
|
+
# Why the cross target never compiles here. The cross-clippy needs zig and
|
|
21
|
+
# cargo-zigbuild, which a macOS host carries only in the linux-cross devenv
|
|
22
|
+
# profile. A hook that entered that profile spent minutes compiling on a push
|
|
23
|
+
# the user expected to take a second, and it did so in an environment they
|
|
24
|
+
# never asked for. Pushing is not the place to discover that the tree has not
|
|
25
|
+
# been compiled for Linux: the land gate, or `bun run check:linux`, is.
|
|
22
26
|
#
|
|
23
|
-
#
|
|
24
|
-
#
|
|
25
|
-
#
|
|
26
|
-
#
|
|
27
|
-
#
|
|
28
|
-
# hits.
|
|
27
|
+
# The target's own guard refuses to start when cargo-zigbuild is not on PATH,
|
|
28
|
+
# which is what turns a miss into a refusal here. A push made from a shell that
|
|
29
|
+
# already carries cargo-zigbuild — an entered linux-cross shell — passes that
|
|
30
|
+
# guard, so there a miss runs the check itself: the same clippy `check:linux`
|
|
31
|
+
# runs, in the toolchain the user entered for it.
|
|
29
32
|
#
|
|
30
33
|
# Everything in tooling depends only on devenv.nix packages, so this hook also
|
|
31
34
|
# works with no devenv on PATH. It must never pretend a check ran that did not.
|
|
@@ -63,18 +66,33 @@ case "$(uname -s)" in
|
|
|
63
66
|
*) exit 0 ;;
|
|
64
67
|
esac
|
|
65
68
|
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
+
# The guard's refusal (nx-plugin cross-check-policy.ts CARGO_CROSS_LINT_REFUSAL)
|
|
70
|
+
# is the one line that means the key missed. Nx exits 1 for every task failure,
|
|
71
|
+
# so the hook reads the output for it rather than guessing from the status.
|
|
72
|
+
output=$(mktemp "${TMPDIR:-/tmp}/pre-push-cross.XXXXXX") || exit 1
|
|
73
|
+
trap 'rm -f "$output"' EXIT
|
|
74
|
+
set -o pipefail
|
|
75
|
+
nx run-many -t cargo-lint-cross --output-style=static 2>&1 | tee "$output"
|
|
76
|
+
status=$?
|
|
77
|
+
[ "$status" -eq 0 ] && exit 0
|
|
69
78
|
|
|
70
|
-
|
|
79
|
+
if grep -qF 'cargo-lint-cross needs cargo-zigbuild from the linux-cross toolchain; run: bun run check:linux' "$output"; then
|
|
80
|
+
cat >&2 <<'EOF'
|
|
71
81
|
|
|
72
82
|
pre-push: the Linux cross-compile check is NOT cached for this tree, so this
|
|
73
|
-
push would ship code that has never been compiled for Linux.
|
|
74
|
-
|
|
75
|
-
|
|
83
|
+
push would ship code that has never been compiled for Linux. The "needs
|
|
84
|
+
cargo-zigbuild" line above is the cross target refusing to compile here, not a
|
|
85
|
+
broken toolchain.
|
|
76
86
|
|
|
77
87
|
Run: bun run check:linux
|
|
78
88
|
Wait for it to pass, then push again.
|
|
79
89
|
EOF
|
|
90
|
+
else
|
|
91
|
+
cat >&2 <<EOF
|
|
92
|
+
|
|
93
|
+
pre-push: Nx failed (exit $status) before the Linux cross-compile check reached
|
|
94
|
+
a cache verdict; the output above names why. This is not a cache miss, and
|
|
95
|
+
bun run check:linux will not fix it.
|
|
96
|
+
EOF
|
|
97
|
+
fi
|
|
80
98
|
exit 1
|
package/package.json
CHANGED
|
@@ -223,8 +223,9 @@ it('the hook run reads the key the gate run wrote, after the gate rewrote compil
|
|
|
223
223
|
const gate = await nx(GATE_RECEIPT);
|
|
224
224
|
expect(gate.exitCode, gate.log).toBe(0);
|
|
225
225
|
expect(await readFile(join(workspace, '.runs'), 'utf8')).toBe('1\n');
|
|
226
|
-
// The gate's own execution left a compiled-in file its graph never saw.
|
|
227
|
-
|
|
226
|
+
// The gate's own execution left a compiled-in file its graph never saw. readdir's order is the filesystem's
|
|
227
|
+
// (hash order on Linux), so the listing is compared as a set.
|
|
228
|
+
expect((await readdir(join(workspace, GENERATED))).sort()).toEqual(['chunk-1.js', 'vocabulary.rs']);
|
|
228
229
|
|
|
229
230
|
const hook = await nx(HOOK_RECEIPT);
|
|
230
231
|
expect(hook.exitCode, hook.log).toBe(0);
|
|
@@ -20,12 +20,12 @@ import { runtimeInput, shellWord } from './runtime-input.js';
|
|
|
20
20
|
* two machines ever agree and no cargo target can share a cache entry with a
|
|
21
21
|
* peer or with CI — a remote cache for Rust was dead on arrival. And the dump
|
|
22
22
|
* differs between a bare shell and a devenv profile for the SAME sources: in
|
|
23
|
-
* the `linux-cross` profile `
|
|
24
|
-
* `
|
|
25
|
-
*
|
|
26
|
-
*
|
|
27
|
-
*
|
|
28
|
-
*
|
|
23
|
+
* the `linux-cross` profile `CARGO_INSTALL_ROOT` moves under
|
|
24
|
+
* `profiles/linux-cross/`, and every variable the profile's tools set appears,
|
|
25
|
+
* so the entry `check:linux` writes inside the profile could never be hit by
|
|
26
|
+
* the pre-push probe, which runs bare. Measured on one repository-root archive
|
|
27
|
+
* target with the dump still in place: bare 18197306115812424011, in-profile
|
|
28
|
+
* 12567954759860890767.
|
|
29
29
|
*
|
|
30
30
|
* A file input has neither defect. The lock's bytes are identical bare and
|
|
31
31
|
* in-profile and on every machine holding the checkout, while the toolchain
|