satoridb 1.1.4 → 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 +24 -11
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();
|
|
@@ -42,12 +43,12 @@ try {
|
|
|
42
43
|
|
|
43
44
|
// Descargar ZIP con mejor manejo de errores
|
|
44
45
|
function downloadZip(url, dest, cb) {
|
|
45
|
-
console.
|
|
46
|
+
console.error(`🔽 Downloading from: ${url}`);
|
|
46
47
|
|
|
47
48
|
const file = fs.createWriteStream(dest);
|
|
48
49
|
|
|
49
50
|
const request = https.get(url, response => {
|
|
50
|
-
console.
|
|
51
|
+
console.error(`📡 Response status: ${response.statusCode}`);
|
|
51
52
|
|
|
52
53
|
if (response.statusCode !== 200) {
|
|
53
54
|
console.error("❌ Download failed:", response.statusCode);
|
|
@@ -60,7 +61,7 @@ function downloadZip(url, dest, cb) {
|
|
|
60
61
|
|
|
61
62
|
file.on("finish", () => {
|
|
62
63
|
file.close(() => {
|
|
63
|
-
console.
|
|
64
|
+
console.error(`✅ Download completed: ${dest}`);
|
|
64
65
|
// Verificar que el archivo existe y tiene contenido
|
|
65
66
|
try {
|
|
66
67
|
const stats = fs.statSync(dest);
|
|
@@ -123,10 +124,10 @@ function extractZip(src, dest) {
|
|
|
123
124
|
|
|
124
125
|
if (platform !== "win32") {
|
|
125
126
|
chmodSync(binPath, 0o755);
|
|
126
|
-
console.
|
|
127
|
+
console.error(`✅ Set executable permissions on: ${binPath}`);
|
|
127
128
|
}
|
|
128
129
|
|
|
129
|
-
console.
|
|
130
|
+
console.error(`✅ Extraction completed`);
|
|
130
131
|
} catch (err) {
|
|
131
132
|
console.error("❌ Error extracting zip:", err.message);
|
|
132
133
|
process.exit(1);
|
|
@@ -134,19 +135,19 @@ function extractZip(src, dest) {
|
|
|
134
135
|
}
|
|
135
136
|
|
|
136
137
|
// Ejecutar
|
|
137
|
-
console.
|
|
138
|
+
console.error(`🔽 Downloading Satori ${platform}/${arch}...`);
|
|
138
139
|
|
|
139
140
|
downloadZip(`${baseURL}/${fileName}`, zipPath, () => {
|
|
140
141
|
try {
|
|
141
142
|
fs.mkdirSync(installDir, { recursive: true });
|
|
142
|
-
console.
|
|
143
|
+
console.error(`✅ Install directory created/verified`);
|
|
143
144
|
} catch (err) {
|
|
144
145
|
console.error("❌ Error creating install directory:", err.message);
|
|
145
146
|
process.exit(1);
|
|
146
147
|
}
|
|
147
148
|
|
|
148
149
|
extractZip(zipPath, installDir);
|
|
149
|
-
console.
|
|
150
|
+
console.error(`✅ Binary installed in: ${binFullPath}\n`);
|
|
150
151
|
|
|
151
152
|
// Limpiar archivo temporal
|
|
152
153
|
try {
|
|
@@ -159,8 +160,20 @@ downloadZip(`${baseURL}/${fileName}`, zipPath, () => {
|
|
|
159
160
|
const profileFile = shell.includes("zsh") ? ".zshrc" : ".bashrc";
|
|
160
161
|
|
|
161
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
|
+
}
|
|
162
175
|
|
|
163
|
-
/* console.
|
|
164
|
-
console.
|
|
165
|
-
console.
|
|
176
|
+
/* console.error(`💡 Add this to your ~/${profileFile}:\n`);
|
|
177
|
+
console.error(` ${exportLine}\n`);
|
|
178
|
+
console.error(`Then run: source ~/${profileFile}\n`);*/
|
|
166
179
|
});
|