satoridb 1.1.2 β 1.1.3
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 +106 -9
package/package.json
CHANGED
package/postinstall.js
CHANGED
|
@@ -20,38 +20,120 @@ else {
|
|
|
20
20
|
}
|
|
21
21
|
|
|
22
22
|
const tmpDir = path.join(os.tmpdir(), "satori-temp");
|
|
23
|
-
fs.mkdirSync(tmpDir, { recursive: true });
|
|
24
|
-
|
|
25
23
|
const zipPath = path.join(tmpDir, fileName);
|
|
26
24
|
const installDir = path.join(os.homedir(), ".satori", "bin");
|
|
27
25
|
const binName = platform === "win32" ? "satori.exe" : "satori";
|
|
28
26
|
const binFullPath = path.join(installDir, binName);
|
|
29
27
|
|
|
30
|
-
|
|
28
|
+
console.log(`π Temp directory: ${tmpDir}`);
|
|
29
|
+
console.log(`π Install directory: ${installDir}`);
|
|
30
|
+
console.log(`π Zip path: ${zipPath}`);
|
|
31
|
+
|
|
32
|
+
// Crear directorio temporal y subdirectorios con mejor manejo de errores
|
|
33
|
+
try {
|
|
34
|
+
fs.mkdirSync(tmpDir, { recursive: true });
|
|
35
|
+
console.log(`β
Temp directory created/verified`);
|
|
36
|
+
|
|
37
|
+
// Crear el subdirectorio especΓfico de la plataforma si es necesario
|
|
38
|
+
const platformSubDir = path.dirname(zipPath);
|
|
39
|
+
if (platformSubDir !== tmpDir) {
|
|
40
|
+
fs.mkdirSync(platformSubDir, { recursive: true });
|
|
41
|
+
console.log(`β
Platform subdirectory created: ${platformSubDir}`);
|
|
42
|
+
}
|
|
43
|
+
} catch (err) {
|
|
44
|
+
console.error("β Error creating directories:", err.message);
|
|
45
|
+
process.exit(1);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
// Descargar ZIP con mejor manejo de errores
|
|
31
49
|
function downloadZip(url, dest, cb) {
|
|
50
|
+
console.log(`π½ Downloading from: ${url}`);
|
|
51
|
+
|
|
32
52
|
const file = fs.createWriteStream(dest);
|
|
33
|
-
|
|
53
|
+
|
|
54
|
+
const request = https.get(url, response => {
|
|
55
|
+
console.log(`π‘ Response status: ${response.statusCode}`);
|
|
56
|
+
|
|
34
57
|
if (response.statusCode !== 200) {
|
|
35
58
|
console.error("β Download failed:", response.statusCode);
|
|
59
|
+
file.close();
|
|
60
|
+
fs.unlink(dest, () => {}); // Limpiar archivo parcial
|
|
36
61
|
process.exit(1);
|
|
37
62
|
}
|
|
38
63
|
|
|
39
64
|
response.pipe(file);
|
|
65
|
+
|
|
40
66
|
file.on("finish", () => {
|
|
41
|
-
file.close(
|
|
67
|
+
file.close(() => {
|
|
68
|
+
console.log(`β
Download completed: ${dest}`);
|
|
69
|
+
// Verificar que el archivo existe y tiene contenido
|
|
70
|
+
try {
|
|
71
|
+
const stats = fs.statSync(dest);
|
|
72
|
+
console.log(`π File size: ${stats.size} bytes`);
|
|
73
|
+
if (stats.size === 0) {
|
|
74
|
+
console.error("β Downloaded file is empty");
|
|
75
|
+
fs.unlink(dest, () => {});
|
|
76
|
+
process.exit(1);
|
|
77
|
+
}
|
|
78
|
+
cb();
|
|
79
|
+
} catch (err) {
|
|
80
|
+
console.error("β Error verifying downloaded file:", err.message);
|
|
81
|
+
process.exit(1);
|
|
82
|
+
}
|
|
83
|
+
});
|
|
42
84
|
});
|
|
43
|
-
|
|
85
|
+
|
|
86
|
+
file.on("error", err => {
|
|
87
|
+
console.error("β Error writing file:", err.message);
|
|
88
|
+
fs.unlink(dest, () => {});
|
|
89
|
+
process.exit(1);
|
|
90
|
+
});
|
|
91
|
+
});
|
|
92
|
+
|
|
93
|
+
request.on('error', err => {
|
|
44
94
|
console.error("β Network error:", err.message);
|
|
95
|
+
file.close();
|
|
96
|
+
fs.unlink(dest, () => {});
|
|
97
|
+
process.exit(1);
|
|
98
|
+
});
|
|
99
|
+
|
|
100
|
+
request.setTimeout(30000, () => {
|
|
101
|
+
console.error("β Download timeout");
|
|
102
|
+
request.destroy();
|
|
103
|
+
file.close();
|
|
104
|
+
fs.unlink(dest, () => {});
|
|
45
105
|
process.exit(1);
|
|
46
106
|
});
|
|
47
107
|
}
|
|
48
108
|
|
|
49
|
-
// Extraer ZIP
|
|
109
|
+
// Extraer ZIP con mejor manejo de errores
|
|
50
110
|
function extractZip(src, dest) {
|
|
111
|
+
console.log(`π¦ Extracting from: ${src}`);
|
|
112
|
+
console.log(`π¦ Extracting to: ${dest}`);
|
|
113
|
+
|
|
51
114
|
try {
|
|
115
|
+
// Verificar que el archivo ZIP existe
|
|
116
|
+
if (!fs.existsSync(src)) {
|
|
117
|
+
console.error(`β ZIP file not found: ${src}`);
|
|
118
|
+
process.exit(1);
|
|
119
|
+
}
|
|
120
|
+
|
|
52
121
|
const zip = new AdmZip(src);
|
|
53
122
|
zip.extractAllTo(dest, true);
|
|
54
|
-
|
|
123
|
+
|
|
124
|
+
// Verificar que el binario fue extraΓdo
|
|
125
|
+
const binPath = path.join(dest, binName);
|
|
126
|
+
if (!fs.existsSync(binPath)) {
|
|
127
|
+
console.error(`β Binary not found after extraction: ${binPath}`);
|
|
128
|
+
process.exit(1);
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
if (platform !== "win32") {
|
|
132
|
+
chmodSync(binPath, 0o755);
|
|
133
|
+
console.log(`β
Set executable permissions on: ${binPath}`);
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
console.log(`β
Extraction completed`);
|
|
55
137
|
} catch (err) {
|
|
56
138
|
console.error("β Error extracting zip:", err.message);
|
|
57
139
|
process.exit(1);
|
|
@@ -62,10 +144,25 @@ function extractZip(src, dest) {
|
|
|
62
144
|
console.log(`π½ Downloading Satori ${platform}/${arch}...`);
|
|
63
145
|
|
|
64
146
|
downloadZip(`${baseURL}/${fileName}`, zipPath, () => {
|
|
65
|
-
|
|
147
|
+
try {
|
|
148
|
+
fs.mkdirSync(installDir, { recursive: true });
|
|
149
|
+
console.log(`β
Install directory created/verified`);
|
|
150
|
+
} catch (err) {
|
|
151
|
+
console.error("β Error creating install directory:", err.message);
|
|
152
|
+
process.exit(1);
|
|
153
|
+
}
|
|
154
|
+
|
|
66
155
|
extractZip(zipPath, installDir);
|
|
67
156
|
console.log(`β
Binary installed in: ${binFullPath}\n`);
|
|
68
157
|
|
|
158
|
+
// Limpiar archivo temporal
|
|
159
|
+
try {
|
|
160
|
+
fs.unlinkSync(zipPath);
|
|
161
|
+
console.log(`π§Ή Cleaned up temporary file: ${zipPath}`);
|
|
162
|
+
} catch (err) {
|
|
163
|
+
console.warn(`β οΈ Could not clean up temporary file: ${err.message}`);
|
|
164
|
+
}
|
|
165
|
+
|
|
69
166
|
const shell = process.env.SHELL || "";
|
|
70
167
|
const profileFile = shell.includes("zsh") ? ".zshrc" : ".bashrc";
|
|
71
168
|
|