@bloret-crew/blora-agent 0.1.0-beta.2 → 27.0.0-beta
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/bin/install.js +23 -9
- package/package.json +2 -1
package/bin/install.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
|
-
const { createWriteStream, existsSync, mkdirSync,
|
|
3
|
+
const { chmodSync, copyFileSync, createWriteStream, existsSync, mkdirSync, rmSync, unlinkSync } = require("node:fs");
|
|
4
4
|
const { tmpdir } = require("node:os");
|
|
5
5
|
const path = require("node:path");
|
|
6
6
|
const { execFile } = require("node:child_process");
|
|
@@ -18,11 +18,16 @@ const destination = path.join(installDir, executable);
|
|
|
18
18
|
const DOWNLOAD_TIMEOUT_MS = 120_000;
|
|
19
19
|
const MAX_ATTEMPTS = 4;
|
|
20
20
|
|
|
21
|
-
function platformAsset() {
|
|
22
|
-
const arch =
|
|
23
|
-
const
|
|
24
|
-
|
|
25
|
-
|
|
21
|
+
function platformAsset(platform = process.platform, architecture = process.arch) {
|
|
22
|
+
const arch = architecture === "x64" ? "x86_64" : architecture === "arm64" ? "aarch64" : architecture;
|
|
23
|
+
const platformName = {
|
|
24
|
+
linux: "linux",
|
|
25
|
+
darwin: "macos",
|
|
26
|
+
win32: "windows",
|
|
27
|
+
}[platform];
|
|
28
|
+
if (!platformName) throw new Error(`unsupported platform: ${platform}`);
|
|
29
|
+
const ext = platformName === "windows" ? "zip" : "tar.gz";
|
|
30
|
+
return `blora-${version}-${platformName}-${arch}.${ext}`;
|
|
26
31
|
}
|
|
27
32
|
|
|
28
33
|
function wait(ms) {
|
|
@@ -137,8 +142,13 @@ async function main() {
|
|
|
137
142
|
await extract(archive, target);
|
|
138
143
|
const extracted = path.join(target, executable);
|
|
139
144
|
if (!existsSync(extracted)) throw new Error(`release archive does not contain ${executable}`);
|
|
140
|
-
|
|
141
|
-
|
|
145
|
+
try {
|
|
146
|
+
copyFileSync(extracted, destination);
|
|
147
|
+
unlinkSync(extracted);
|
|
148
|
+
} catch (error) {
|
|
149
|
+
throw new Error(`could not install binary: ${error.message}`);
|
|
150
|
+
}
|
|
151
|
+
if (process.platform !== "win32") chmodSync(destination, 0o755);
|
|
142
152
|
console.log("Blora installed.");
|
|
143
153
|
} catch (error) {
|
|
144
154
|
console.error(`Blora binary download failed: ${error.message}`);
|
|
@@ -150,4 +160,8 @@ async function main() {
|
|
|
150
160
|
}
|
|
151
161
|
}
|
|
152
162
|
|
|
153
|
-
main
|
|
163
|
+
if (require.main === module) {
|
|
164
|
+
main();
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
module.exports = { platformAsset };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bloret-crew/blora-agent",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "27.0.0-beta",
|
|
4
4
|
"description": "Blora Agent CLI installer",
|
|
5
5
|
"license": "GPL-3.0-or-later",
|
|
6
6
|
"repository": {
|
|
@@ -21,6 +21,7 @@
|
|
|
21
21
|
"LICENSE"
|
|
22
22
|
],
|
|
23
23
|
"scripts": {
|
|
24
|
+
"test": "node --test test/*.test.js",
|
|
24
25
|
"postinstall": "node bin/install.js"
|
|
25
26
|
},
|
|
26
27
|
"engines": {
|