satoridb 1.1.3 → 1.1.5
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/add-to-path.ps1 +11 -0
- package/add-to-path.sh +25 -0
- package/cli.js +1 -1
- package/package.json +2 -2
- package/postinstall.js +25 -20
package/add-to-path.ps1
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
$SatoriPath = "$env:USERPROFILE\.satori\bin"
|
|
2
|
+
$CurrentPath = [Environment]::GetEnvironmentVariable("Path", "User")
|
|
3
|
+
|
|
4
|
+
if ($CurrentPath -notlike "*$SatoriPath*") {
|
|
5
|
+
$NewPath = "$CurrentPath;$SatoriPath"
|
|
6
|
+
[Environment]::SetEnvironmentVariable("Path", $NewPath, "User")
|
|
7
|
+
Write-Output "✅ Añadido '$SatoriPath' al PATH del usuario."
|
|
8
|
+
Write-Output "🔄 Reinicia tu terminal para aplicar los cambios."
|
|
9
|
+
} else {
|
|
10
|
+
Write-Output "ℹ️ '$SatoriPath' ya está en el PATH."
|
|
11
|
+
}
|
package/add-to-path.sh
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
|
|
3
|
+
SATORI_PATH="$HOME/.satori/bin"
|
|
4
|
+
PROFILE_FILES=("$HOME/.bashrc" "$HOME/.zshrc" "$HOME/.profile")
|
|
5
|
+
|
|
6
|
+
# Línea que añadiremos si no está
|
|
7
|
+
EXPORT_LINE='export PATH="$HOME/.satori/bin:$PATH"'
|
|
8
|
+
|
|
9
|
+
already_exists=false
|
|
10
|
+
|
|
11
|
+
for profile in "${PROFILE_FILES[@]}"; do
|
|
12
|
+
if [[ -f "$profile" ]] && grep -qF "$EXPORT_LINE" "$profile"; then
|
|
13
|
+
echo "ℹ️ Ya existe PATH en $profile"
|
|
14
|
+
already_exists=true
|
|
15
|
+
break
|
|
16
|
+
fi
|
|
17
|
+
done
|
|
18
|
+
|
|
19
|
+
if ! $already_exists; then
|
|
20
|
+
echo "✅ Añadiendo al PATH en ${PROFILE_FILES[0]}"
|
|
21
|
+
echo -e "\n# Añadido por Satori\n$EXPORT_LINE" >> "${PROFILE_FILES[0]}"
|
|
22
|
+
echo "🔄 Ejecuta: source ${PROFILE_FILES[0]}"
|
|
23
|
+
else
|
|
24
|
+
echo "✅ PATH ya contiene ~/.satori/bin"
|
|
25
|
+
fi
|
package/cli.js
CHANGED
package/package.json
CHANGED
package/postinstall.js
CHANGED
|
@@ -4,6 +4,7 @@ const fs = require("fs");
|
|
|
4
4
|
const https = require("https");
|
|
5
5
|
const AdmZip = require("adm-zip");
|
|
6
6
|
const { chmodSync } = require("fs");
|
|
7
|
+
const child_process = require("child_process");
|
|
7
8
|
|
|
8
9
|
const platform = os.platform();
|
|
9
10
|
const arch = os.arch();
|
|
@@ -25,20 +26,15 @@ const installDir = path.join(os.homedir(), ".satori", "bin");
|
|
|
25
26
|
const binName = platform === "win32" ? "satori.exe" : "satori";
|
|
26
27
|
const binFullPath = path.join(installDir, binName);
|
|
27
28
|
|
|
28
|
-
console.log(`📁 Temp directory: ${tmpDir}`);
|
|
29
|
-
console.log(`📁 Install directory: ${installDir}`);
|
|
30
|
-
console.log(`📁 Zip path: ${zipPath}`);
|
|
31
29
|
|
|
32
30
|
// Crear directorio temporal y subdirectorios con mejor manejo de errores
|
|
33
31
|
try {
|
|
34
32
|
fs.mkdirSync(tmpDir, { recursive: true });
|
|
35
|
-
console.log(`✅ Temp directory created/verified`);
|
|
36
33
|
|
|
37
34
|
// Crear el subdirectorio específico de la plataforma si es necesario
|
|
38
35
|
const platformSubDir = path.dirname(zipPath);
|
|
39
36
|
if (platformSubDir !== tmpDir) {
|
|
40
37
|
fs.mkdirSync(platformSubDir, { recursive: true });
|
|
41
|
-
console.log(`✅ Platform subdirectory created: ${platformSubDir}`);
|
|
42
38
|
}
|
|
43
39
|
} catch (err) {
|
|
44
40
|
console.error("❌ Error creating directories:", err.message);
|
|
@@ -47,12 +43,12 @@ try {
|
|
|
47
43
|
|
|
48
44
|
// Descargar ZIP con mejor manejo de errores
|
|
49
45
|
function downloadZip(url, dest, cb) {
|
|
50
|
-
console.
|
|
46
|
+
console.error(`🔽 Downloading from: ${url}`);
|
|
51
47
|
|
|
52
48
|
const file = fs.createWriteStream(dest);
|
|
53
49
|
|
|
54
50
|
const request = https.get(url, response => {
|
|
55
|
-
console.
|
|
51
|
+
console.error(`📡 Response status: ${response.statusCode}`);
|
|
56
52
|
|
|
57
53
|
if (response.statusCode !== 200) {
|
|
58
54
|
console.error("❌ Download failed:", response.statusCode);
|
|
@@ -65,11 +61,10 @@ function downloadZip(url, dest, cb) {
|
|
|
65
61
|
|
|
66
62
|
file.on("finish", () => {
|
|
67
63
|
file.close(() => {
|
|
68
|
-
console.
|
|
64
|
+
console.error(`✅ Download completed: ${dest}`);
|
|
69
65
|
// Verificar que el archivo existe y tiene contenido
|
|
70
66
|
try {
|
|
71
67
|
const stats = fs.statSync(dest);
|
|
72
|
-
console.log(`📊 File size: ${stats.size} bytes`);
|
|
73
68
|
if (stats.size === 0) {
|
|
74
69
|
console.error("❌ Downloaded file is empty");
|
|
75
70
|
fs.unlink(dest, () => {});
|
|
@@ -108,8 +103,7 @@ function downloadZip(url, dest, cb) {
|
|
|
108
103
|
|
|
109
104
|
// Extraer ZIP con mejor manejo de errores
|
|
110
105
|
function extractZip(src, dest) {
|
|
111
|
-
|
|
112
|
-
console.log(`📦 Extracting to: ${dest}`);
|
|
106
|
+
|
|
113
107
|
|
|
114
108
|
try {
|
|
115
109
|
// Verificar que el archivo ZIP existe
|
|
@@ -130,10 +124,10 @@ function extractZip(src, dest) {
|
|
|
130
124
|
|
|
131
125
|
if (platform !== "win32") {
|
|
132
126
|
chmodSync(binPath, 0o755);
|
|
133
|
-
console.
|
|
127
|
+
console.error(`✅ Set executable permissions on: ${binPath}`);
|
|
134
128
|
}
|
|
135
129
|
|
|
136
|
-
console.
|
|
130
|
+
console.error(`✅ Extraction completed`);
|
|
137
131
|
} catch (err) {
|
|
138
132
|
console.error("❌ Error extracting zip:", err.message);
|
|
139
133
|
process.exit(1);
|
|
@@ -141,24 +135,23 @@ function extractZip(src, dest) {
|
|
|
141
135
|
}
|
|
142
136
|
|
|
143
137
|
// Ejecutar
|
|
144
|
-
console.
|
|
138
|
+
console.error(`🔽 Downloading Satori ${platform}/${arch}...`);
|
|
145
139
|
|
|
146
140
|
downloadZip(`${baseURL}/${fileName}`, zipPath, () => {
|
|
147
141
|
try {
|
|
148
142
|
fs.mkdirSync(installDir, { recursive: true });
|
|
149
|
-
console.
|
|
143
|
+
console.error(`✅ Install directory created/verified`);
|
|
150
144
|
} catch (err) {
|
|
151
145
|
console.error("❌ Error creating install directory:", err.message);
|
|
152
146
|
process.exit(1);
|
|
153
147
|
}
|
|
154
148
|
|
|
155
149
|
extractZip(zipPath, installDir);
|
|
156
|
-
console.
|
|
150
|
+
console.error(`✅ Binary installed in: ${binFullPath}\n`);
|
|
157
151
|
|
|
158
152
|
// Limpiar archivo temporal
|
|
159
153
|
try {
|
|
160
154
|
fs.unlinkSync(zipPath);
|
|
161
|
-
console.log(`🧹 Cleaned up temporary file: ${zipPath}`);
|
|
162
155
|
} catch (err) {
|
|
163
156
|
console.warn(`⚠️ Could not clean up temporary file: ${err.message}`);
|
|
164
157
|
}
|
|
@@ -167,8 +160,20 @@ downloadZip(`${baseURL}/${fileName}`, zipPath, () => {
|
|
|
167
160
|
const profileFile = shell.includes("zsh") ? ".zshrc" : ".bashrc";
|
|
168
161
|
|
|
169
162
|
const exportLine = `export PATH="$HOME/.satori/bin:$PATH"`;
|
|
163
|
+
|
|
164
|
+
if (platform === "win32") {
|
|
165
|
+
child_process.spawn("powershell.exe", [
|
|
166
|
+
"-ExecutionPolicy", "Bypass",
|
|
167
|
+
"-File", path.join(__dirname, "add-to-path.ps1")
|
|
168
|
+
], { stdio: "inherit" });
|
|
169
|
+
|
|
170
|
+
} else {
|
|
171
|
+
child_process.spawn("bash", [
|
|
172
|
+
path.join(__dirname, "add-to-path.sh")
|
|
173
|
+
], { stdio: "inherit" });
|
|
174
|
+
}
|
|
170
175
|
|
|
171
|
-
|
|
172
|
-
console.
|
|
173
|
-
console.
|
|
176
|
+
/* console.error(`💡 Add this to your ~/${profileFile}:\n`);
|
|
177
|
+
console.error(` ${exportLine}\n`);
|
|
178
|
+
console.error(`Then run: source ~/${profileFile}\n`);*/
|
|
174
179
|
});
|