mainplane 0.5.8 → 0.5.10
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/SHA256SUMS +16 -16
- package/mainplane.js +16 -6
- package/package.json +1 -1
package/SHA256SUMS
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
1
|
+
c602cf40f04fb578e148373c0f20fd2bdc649679dbbbeaadde1957b3b6a2cf86 CHANGELOG.md
|
|
2
|
+
1d175cae9f8552ff51711d3151fcc0c891c4f781ad8e1a200b5e9f56cfaec453 THIRD_PARTY_NOTICES
|
|
3
|
+
f303b9a1e3a1362baa38127d92869d19a7e928f1a3184c8378e055a3281fa766 install.ps1
|
|
4
|
+
7851d86d3cec6b5acf6cc8c108f4ee864cc6522b28675e780068573439117dc2 install.sh
|
|
5
|
+
296c88d2abdf9562bd8020687b83b35bb424e7e862013e2c003cd866c84bd800 mainplane-darwin-amd64
|
|
6
|
+
c89cc62a13dbc004a52fc3f64ed81ef6d1ca7320873471736cd5a1322d840745 mainplane-darwin-arm64
|
|
7
|
+
59ac34cb4d7515faa18465ee28541aa84044521f223fa74d01084fe4456a6ea7 mainplane-linux-amd64
|
|
8
|
+
0ab763fd57f73c908c23caf796b84546bb3fb03d9cde1d841f1081e6c42a8a7e mainplane-linux-arm64
|
|
9
|
+
5022fab5b59254660cb5be8df50be9a0ee769306521d4cfd8e87b63ad46b2031 mainplane-server-darwin-amd64
|
|
10
|
+
12186e5cdaaa70ab278137eb412d53b93293956be1fb0adfb741d559a58ae2a5 mainplane-server-darwin-arm64
|
|
11
|
+
337e467edd4967e106b5e10034389b41f0fe84f90af49d2cdf261332e2f41cc2 mainplane-server-linux-amd64
|
|
12
|
+
1eea47d94bb6511e63ffa842e9e9b03089c6caac5f49163f74ee77e44b9d7e51 mainplane-server-linux-arm64
|
|
13
|
+
cb33d87414d95ddbad5b0cc70290d8071f1c7ecdc1902ac653bfb781a9a597a0 mainplane-server-windows-amd64.exe
|
|
14
|
+
05dfc22979109eec3a738e28b8456a8f27307dbf4bc9bfdbdc7a90e19881a3f9 mainplane-server-windows-arm64.exe
|
|
15
|
+
4fb337cc1f12f78b13dddca353f277ebabedd6a8d381146170ed4319864a2228 mainplane-windows-amd64.exe
|
|
16
|
+
84c166b9018dc3012f0c2dea13dd0c87fbc24fabd5784c6628bc42b38105de0e mainplane-windows-arm64.exe
|
package/mainplane.js
CHANGED
|
@@ -19,16 +19,26 @@ async function main() {
|
|
|
19
19
|
goos === "windows" ? process.env.LOCALAPPDATA
|
|
20
20
|
: goos === "darwin" ? path.join(os.homedir(), "Library", "Caches")
|
|
21
21
|
: process.env.XDG_CACHE_HOME || path.join(os.homedir(), ".cache");
|
|
22
|
-
const bin = path.join(cache, "mainplane", v, goos === "windows" ? "mainplane.exe" : "mainplane");
|
|
23
|
-
|
|
22
|
+
const bin = path.join(cache, "mainplane", v, `${goos}-${arch}`, goos === "windows" ? "mainplane.exe" : "mainplane");
|
|
23
|
+
const sum = line.split(" ")[0];
|
|
24
|
+
const hash = (b) => createHash("sha256").update(b).digest("hex");
|
|
25
|
+
if (!fs.existsSync(bin) || hash(fs.readFileSync(bin)) !== sum) {
|
|
24
26
|
const url = `https://dl.mainplane.ai/${v}/${name}`;
|
|
25
|
-
const res = await fetch(url);
|
|
27
|
+
const res = await fetch(url, { signal: AbortSignal.timeout(300000) });
|
|
26
28
|
if (!res.ok) throw new Error(`${url}: ${res.status}`);
|
|
27
29
|
const b = Buffer.from(await res.arrayBuffer());
|
|
28
|
-
if (
|
|
30
|
+
if (hash(b) !== sum) throw new Error(`${url} does not match SHA256SUMS`);
|
|
29
31
|
fs.mkdirSync(path.dirname(bin), { recursive: true });
|
|
30
|
-
|
|
31
|
-
|
|
32
|
+
// A temporary file per process, since first runs may race; the loser keeps the winner's identical file.
|
|
33
|
+
const tmp = `${bin}.${process.pid}`;
|
|
34
|
+
fs.writeFileSync(tmp, b);
|
|
35
|
+
fs.chmodSync(tmp, 0o755);
|
|
36
|
+
try {
|
|
37
|
+
fs.renameSync(tmp, bin);
|
|
38
|
+
} catch (e) {
|
|
39
|
+
fs.rmSync(tmp);
|
|
40
|
+
if (!fs.existsSync(bin) || hash(fs.readFileSync(bin)) !== sum) throw e;
|
|
41
|
+
}
|
|
32
42
|
}
|
|
33
43
|
const r = spawnSync(bin, process.argv.slice(2), { stdio: "inherit" });
|
|
34
44
|
if (r.error) throw r.error;
|
package/package.json
CHANGED