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.
@@ -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
@@ -23,7 +23,7 @@ function run(args) {
23
23
 
24
24
  const args = process.argv.slice(2);
25
25
  if (args[0] === "update") {
26
- console.log("🔄 Ejecutando actualización...");
26
+ console.error("🔄 Ejecutando actualización...");
27
27
  require("./postinstall");
28
28
  } else {
29
29
  run(args);
package/package.json CHANGED
@@ -1,9 +1,9 @@
1
1
  {
2
2
  "name": "satoridb",
3
- "version": "1.1.4",
3
+ "version": "1.1.5",
4
4
  "description": "Install satori",
5
5
  "bin" : {
6
- "satori" : "cli.js"
6
+ "satori" : "./cli.js"
7
7
  },
8
8
  "scripts": {
9
9
  "postinstall" : "node postinstall.js"
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.log(`🔽 Downloading from: ${url}`);
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.log(`📡 Response status: ${response.statusCode}`);
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.log(`✅ Download completed: ${dest}`);
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.log(`✅ Set executable permissions on: ${binPath}`);
127
+ console.error(`✅ Set executable permissions on: ${binPath}`);
127
128
  }
128
129
 
129
- console.log(`✅ Extraction completed`);
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.log(`🔽 Downloading Satori ${platform}/${arch}...`);
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.log(`✅ Install directory created/verified`);
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.log(`✅ Binary installed in: ${binFullPath}\n`);
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.log(`💡 Add this to your ~/${profileFile}:\n`);
164
- console.log(` ${exportLine}\n`);
165
- console.log(`Then run: source ~/${profileFile}\n`);*/
176
+ /* console.error(`💡 Add this to your ~/${profileFile}:\n`);
177
+ console.error(` ${exportLine}\n`);
178
+ console.error(`Then run: source ~/${profileFile}\n`);*/
166
179
  });