satoridb 1.1.0 → 1.1.2
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/postinstall.js +29 -14
package/package.json
CHANGED
package/postinstall.js
CHANGED
|
@@ -8,19 +8,22 @@ const { chmodSync } = require("fs");
|
|
|
8
8
|
const platform = os.platform();
|
|
9
9
|
const arch = os.arch();
|
|
10
10
|
|
|
11
|
-
const baseURL = "https://www.satoridb.com
|
|
11
|
+
const baseURL = "https://www.satoridb.com";
|
|
12
12
|
let fileName;
|
|
13
13
|
|
|
14
14
|
if (platform === "linux") fileName = "lin/satori-linux.zip";
|
|
15
15
|
else if (platform === "darwin") fileName = "mac/satori-mac.zip";
|
|
16
16
|
else if (platform === "win32") fileName = "win/satori-win.zip";
|
|
17
17
|
else {
|
|
18
|
-
console.error("❌
|
|
18
|
+
console.error("❌ Not supported platform:", platform);
|
|
19
19
|
process.exit(1);
|
|
20
20
|
}
|
|
21
21
|
|
|
22
|
+
const tmpDir = path.join(os.tmpdir(), "satori-temp");
|
|
23
|
+
fs.mkdirSync(tmpDir, { recursive: true });
|
|
24
|
+
|
|
25
|
+
const zipPath = path.join(tmpDir, fileName);
|
|
22
26
|
const installDir = path.join(os.homedir(), ".satori", "bin");
|
|
23
|
-
const zipPath = path.join(os.tmpdir(), fileName);
|
|
24
27
|
const binName = platform === "win32" ? "satori.exe" : "satori";
|
|
25
28
|
const binFullPath = path.join(installDir, binName);
|
|
26
29
|
|
|
@@ -29,34 +32,46 @@ function downloadZip(url, dest, cb) {
|
|
|
29
32
|
const file = fs.createWriteStream(dest);
|
|
30
33
|
https.get(url, response => {
|
|
31
34
|
if (response.statusCode !== 200) {
|
|
32
|
-
console.error("❌
|
|
35
|
+
console.error("❌ Download failed:", response.statusCode);
|
|
33
36
|
process.exit(1);
|
|
34
37
|
}
|
|
38
|
+
|
|
35
39
|
response.pipe(file);
|
|
36
40
|
file.on("finish", () => {
|
|
37
41
|
file.close(cb);
|
|
38
42
|
});
|
|
43
|
+
}).on('error', err => {
|
|
44
|
+
console.error("❌ Network error:", err.message);
|
|
45
|
+
process.exit(1);
|
|
39
46
|
});
|
|
40
47
|
}
|
|
41
48
|
|
|
42
49
|
// Extraer ZIP
|
|
43
50
|
function extractZip(src, dest) {
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
51
|
+
try {
|
|
52
|
+
const zip = new AdmZip(src);
|
|
53
|
+
zip.extractAllTo(dest, true);
|
|
54
|
+
if (platform !== "win32") chmodSync(path.join(dest, binName), 0o755);
|
|
55
|
+
} catch (err) {
|
|
56
|
+
console.error("❌ Error extracting zip:", err.message);
|
|
57
|
+
process.exit(1);
|
|
58
|
+
}
|
|
47
59
|
}
|
|
48
60
|
|
|
49
|
-
//
|
|
50
|
-
console.log(
|
|
61
|
+
// Ejecutar
|
|
62
|
+
console.log(`🔽 Downloading Satori ${platform}/${arch}...`);
|
|
63
|
+
|
|
51
64
|
downloadZip(`${baseURL}/${fileName}`, zipPath, () => {
|
|
52
65
|
fs.mkdirSync(installDir, { recursive: true });
|
|
53
66
|
extractZip(zipPath, installDir);
|
|
54
|
-
console.log(`✅
|
|
67
|
+
console.log(`✅ Binary installed in: ${binFullPath}\n`);
|
|
55
68
|
|
|
56
69
|
const shell = process.env.SHELL || "";
|
|
57
70
|
const profileFile = shell.includes("zsh") ? ".zshrc" : ".bashrc";
|
|
58
71
|
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
console.log(
|
|
62
|
-
});
|
|
72
|
+
const exportLine = `export PATH="$HOME/.satori/bin:$PATH"`;
|
|
73
|
+
|
|
74
|
+
console.log(`💡 Add this to your ~/${profileFile}:\n`);
|
|
75
|
+
console.log(` ${exportLine}\n`);
|
|
76
|
+
console.log(`Then run: source ~/${profileFile}\n`);
|
|
77
|
+
});
|