yougile-cli 0.8.4 → 0.8.6
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/package.json +1 -1
- package/scripts/postinstall.js +20 -8
package/package.json
CHANGED
package/scripts/postinstall.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import { platform, arch } from "node:process";
|
|
3
3
|
import https from "node:https";
|
|
4
4
|
import http from "node:http";
|
|
5
|
-
import { chmodSync, mkdirSync } from "node:fs";
|
|
5
|
+
import { chmodSync, mkdirSync, renameSync, existsSync } from "node:fs";
|
|
6
6
|
import { join, dirname } from "node:path";
|
|
7
7
|
import { createGunzip } from "node:zlib";
|
|
8
8
|
import { fileURLToPath } from "node:url";
|
|
@@ -13,12 +13,13 @@ const __dirname = dirname(__filename);
|
|
|
13
13
|
|
|
14
14
|
const MANIFEST = {
|
|
15
15
|
"assets": {
|
|
16
|
-
"linux-x64": "https://gitverse.ru/sc/sbt/api/v1/attachments/
|
|
17
|
-
"darwin-arm64": "https://gitverse.ru/sc/sbt/api/v1/attachments/
|
|
18
|
-
"win32-x64": "https://gitverse.ru/sc/sbt/api/v1/attachments/
|
|
16
|
+
"linux-x64": "https://gitverse.ru/sc/sbt/api/v1/attachments/db316c6b-98dc-4716-92dd-04f9400ee1d2",
|
|
17
|
+
"darwin-arm64": "https://gitverse.ru/sc/sbt/api/v1/attachments/b7f21b00-e9cc-4f3c-9771-9158f0d2e09b",
|
|
18
|
+
"win32-x64": "https://gitverse.ru/sc/sbt/api/v1/attachments/a1b0f349-fdcc-477d-a44b-1239537cff43"
|
|
19
19
|
},
|
|
20
20
|
"binName": "yougile",
|
|
21
|
-
"version": "0.8.
|
|
21
|
+
"version": "0.8.6",
|
|
22
|
+
"sourceBinName": "cli"
|
|
22
23
|
};
|
|
23
24
|
|
|
24
25
|
const platformKey = `${platform}-${arch}`;
|
|
@@ -61,9 +62,10 @@ function download(url, redirectCount = 0) {
|
|
|
61
62
|
return;
|
|
62
63
|
}
|
|
63
64
|
|
|
65
|
+
// Extract with strip: 1 to remove the first directory level (e.g., linux-x64/)
|
|
64
66
|
res
|
|
65
67
|
.pipe(createGunzip())
|
|
66
|
-
.pipe(tar.extract({ cwd: binDir }))
|
|
68
|
+
.pipe(tar.extract({ cwd: binDir, strip: 1 }))
|
|
67
69
|
.on("finish", resolve)
|
|
68
70
|
.on("error", reject);
|
|
69
71
|
});
|
|
@@ -80,10 +82,20 @@ console.log(`📦 Installing ${MANIFEST.binName} for ${platformKey}...`);
|
|
|
80
82
|
|
|
81
83
|
download(downloadUrl)
|
|
82
84
|
.then(() => {
|
|
83
|
-
const
|
|
85
|
+
const sourceName = MANIFEST.sourceBinName || MANIFEST.binName;
|
|
86
|
+
const ext = platform === "win32" ? ".exe" : "";
|
|
87
|
+
const sourcePath = join(binDir, sourceName + ext);
|
|
88
|
+
const targetPath = join(binDir, MANIFEST.binName + ext);
|
|
89
|
+
|
|
90
|
+
// Rename binary if sourceBinName differs from binName
|
|
91
|
+
if (sourceName !== MANIFEST.binName && existsSync(sourcePath)) {
|
|
92
|
+
renameSync(sourcePath, targetPath);
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
// Make binary executable on Unix
|
|
84
96
|
if (platform !== "win32") {
|
|
85
97
|
try {
|
|
86
|
-
chmodSync(
|
|
98
|
+
chmodSync(targetPath, 0o755);
|
|
87
99
|
} catch (e) {
|
|
88
100
|
// Ignore chmod errors on some platforms
|
|
89
101
|
}
|