mainplane 0.5.8 → 0.5.11
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
|
+
70a78da611805e2abc434021ae2e165640543281d8c8790d6e37fbeedf21a2cf CHANGELOG.md
|
|
2
|
+
1d175cae9f8552ff51711d3151fcc0c891c4f781ad8e1a200b5e9f56cfaec453 THIRD_PARTY_NOTICES
|
|
3
|
+
9dc6997b78f540ce215639206289ea190afd00d87caf698c20f139b1df357655 install.ps1
|
|
4
|
+
bd64ec1d4ec26bb941edffe460f752d1f473924d8633618396ec6e02f1798ee6 install.sh
|
|
5
|
+
5f1c630b4b011d64a0d13956c67b9e652629e752b24ead399715fa29d9b1b722 mainplane-darwin-amd64
|
|
6
|
+
879e36f7ed79f3ffb63de906ea74c44e076223699fbc4c8ac709f18ed700a276 mainplane-darwin-arm64
|
|
7
|
+
d2833f95c6df01258b3a0c8a8375b7d4688511d9d46705c54b9f9ab9f16419bc mainplane-linux-amd64
|
|
8
|
+
16bb848bbea76dfd7f2182228146b7f900b018c7a934f3932bfccdfc84ae602f mainplane-linux-arm64
|
|
9
|
+
f454dc9718bb064715048b64425b5dd723ce20ab7b0d475aad144e2e5bd8616b mainplane-server-darwin-amd64
|
|
10
|
+
92e2004c5afaeaa021326a1074e8011bf9d4799a5045bf48c0e655a32977cf0c mainplane-server-darwin-arm64
|
|
11
|
+
293c39899994b170211273ea210f6518248ee792260034b4810a4ae4d2f0bfa0 mainplane-server-linux-amd64
|
|
12
|
+
2afbbd92933b2734d9626d451df2b106a51a8b8950a2f3b7649be43740069f5a mainplane-server-linux-arm64
|
|
13
|
+
00c2ea69c2b41ee4a29c2a6106e40c3c6f57b02dedbb97f9bba22858d47b5444 mainplane-server-windows-amd64.exe
|
|
14
|
+
501d439d542df6a13dd57aa1b193f7cee066a581e26d5d965570d4487ccc978d mainplane-server-windows-arm64.exe
|
|
15
|
+
2039e00d8d077418a74183893c4adb12bae6e460a22bcd60ecbaba4475f6828a mainplane-windows-amd64.exe
|
|
16
|
+
120583605398071bd825d8169757aceb52a01a8c9d14f351a4b31fb77c3dd553 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