satoridb 1.1.21 → 1.1.22
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 +10 -9
- package/cli.js +1 -1
- package/package.json +1 -1
- package/postinstall.js +37 -6
- package/verify-install.js +1 -1
package/add-to-path.ps1
CHANGED
|
@@ -1,15 +1,16 @@
|
|
|
1
1
|
try {
|
|
2
|
+
"Running add-to-path.ps1 at $(Get-Date)" | Out-File "$env:TEMP\satori-add-path.log" -Append
|
|
2
3
|
$SatoriPath = "$env:USERPROFILE\.satori\bin"
|
|
3
4
|
$BinPath = Join-Path $SatoriPath "satori.exe"
|
|
4
5
|
|
|
5
6
|
# Asegurarse de que el directorio existe
|
|
6
7
|
if (-not (Test-Path $SatoriPath)) {
|
|
7
|
-
|
|
8
|
+
"Directory $SatoriPath does not exist. Installation may have failed." | Out-File "$env:TEMP\satori-add-path.log" -Append
|
|
8
9
|
exit 1
|
|
9
10
|
}
|
|
10
11
|
|
|
11
12
|
# Obtener PATH actual del usuario
|
|
12
|
-
$CurrentPath = [Environment]::GetEnvironmentVariable("Path", "User")
|
|
13
|
+
$CurrentPath = [Environment]::GetEnvironmentVariable("Path", "User")
|
|
13
14
|
|
|
14
15
|
# Verificar si ya está en PATH
|
|
15
16
|
if ($CurrentPath -notlike "*$SatoriPath*") {
|
|
@@ -20,21 +21,21 @@ try {
|
|
|
20
21
|
}
|
|
21
22
|
|
|
22
23
|
[Environment]::SetEnvironmentVariable("Path", $NewPath, "User")
|
|
23
|
-
|
|
24
|
-
|
|
24
|
+
"Added '$SatoriPath' to user PATH." | Out-File "$env:TEMP\satori-add-path.log" -Append
|
|
25
|
+
"Please restart your terminal to apply changes." | Out-File "$env:TEMP\satori-add-path.log" -Append
|
|
25
26
|
} else {
|
|
26
|
-
|
|
27
|
+
"'$SatoriPath' is already in PATH." | Out-File "$env:TEMP\satori-add-path.log" -Append
|
|
27
28
|
}
|
|
28
29
|
|
|
29
30
|
# Verificar si el binario existe
|
|
30
31
|
if (Test-Path $BinPath) {
|
|
31
|
-
|
|
32
|
+
"Binary found at: $BinPath" | Out-File "$env:TEMP\satori-add-path.log" -Append
|
|
32
33
|
} else {
|
|
33
|
-
|
|
34
|
+
"Binary not found at: $BinPath" | Out-File "$env:TEMP\satori-add-path.log" -Append
|
|
34
35
|
}
|
|
35
36
|
|
|
36
37
|
} catch {
|
|
37
|
-
|
|
38
|
-
|
|
38
|
+
" Error configuring PATH: $($_.Exception.Message)" | Out-File "$env:TEMP\satori-add-path.log" -Append
|
|
39
|
+
" You can manually add: $SatoriPath to your system PATH." | Out-File "$env:TEMP\satori-add-path.log" -Append
|
|
39
40
|
exit 1
|
|
40
41
|
}
|
package/cli.js
CHANGED
package/package.json
CHANGED
package/postinstall.js
CHANGED
|
@@ -135,6 +135,34 @@ function extractZip(src, dest) {
|
|
|
135
135
|
}
|
|
136
136
|
}
|
|
137
137
|
|
|
138
|
+
|
|
139
|
+
function runPowerShellScript() {
|
|
140
|
+
return new Promise((resolve, reject) => {
|
|
141
|
+
const psScript = path.join(__dirname, "add-to-path.ps1");
|
|
142
|
+
const ps = child_process.spawn("powershell.exe", [
|
|
143
|
+
"-ExecutionPolicy",
|
|
144
|
+
"Bypass",
|
|
145
|
+
"-File",
|
|
146
|
+
psScript
|
|
147
|
+
]);
|
|
148
|
+
|
|
149
|
+
ps.stdout.on("data", (data) => {
|
|
150
|
+
process.stdout.write(data.toString());
|
|
151
|
+
});
|
|
152
|
+
|
|
153
|
+
ps.stderr.on("data", (data) => {
|
|
154
|
+
process.stderr.write(data.toString());
|
|
155
|
+
});
|
|
156
|
+
|
|
157
|
+
ps.on("close", (code) => {
|
|
158
|
+
if (code !== 0) {
|
|
159
|
+
reject(new Error(`PowerShell script exited with code ${code}`));
|
|
160
|
+
} else {
|
|
161
|
+
resolve();
|
|
162
|
+
}
|
|
163
|
+
});
|
|
164
|
+
});
|
|
165
|
+
}
|
|
138
166
|
// Ejecutar
|
|
139
167
|
console.log(`🔽 Downloading Satori ${platform}/${arch}...`);
|
|
140
168
|
|
|
@@ -160,12 +188,15 @@ downloadZip(`${baseURL}/${fileName}`, zipPath, () => {
|
|
|
160
188
|
console.log(`\n🔧 Configuring PATH...`);
|
|
161
189
|
|
|
162
190
|
if (process.platform === "win32") {
|
|
163
|
-
|
|
164
|
-
"
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
191
|
+
(async () => {
|
|
192
|
+
if (process.platform === "win32") {
|
|
193
|
+
try {
|
|
194
|
+
await runPowerShellScript();
|
|
195
|
+
} catch (err) {
|
|
196
|
+
console.error(err);
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
})();
|
|
169
200
|
} else {
|
|
170
201
|
console.log(`🐧 Running bash script for Linux/macOS...`);
|
|
171
202
|
try {
|
package/verify-install.js
CHANGED