satoridb 1.1.16 → 1.1.18

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 CHANGED
@@ -1,11 +1,40 @@
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."
1
+ try {
2
+ $SatoriPath = "$env:USERPROFILE\.satori\bin"
3
+ $BinPath = Join-Path $SatoriPath "satori.exe"
4
+
5
+ # Asegurarse de que el directorio existe
6
+ if (-not (Test-Path $SatoriPath)) {
7
+ Write-Host " Directory $SatoriPath does not exist. Installation may have failed."
8
+ exit 1
9
+ }
10
+
11
+ # Obtener PATH actual del usuario
12
+ $CurrentPath = [Environment]::GetEnvironmentVariable("Path", "User") ?? ""
13
+
14
+ # Verificar si ya está en PATH
15
+ if ($CurrentPath -notlike "*$SatoriPath*") {
16
+ $NewPath = if ($CurrentPath.Trim() -eq "") {
17
+ "$SatoriPath"
18
+ } else {
19
+ "$CurrentPath;$SatoriPath"
20
+ }
21
+
22
+ [Environment]::SetEnvironmentVariable("Path", $NewPath, "User")
23
+ Write-Host "✅ Added '$SatoriPath' to user PATH."
24
+ Write-Host "🔄 Please restart your terminal to apply changes."
25
+ } else {
26
+ Write-Host "ℹ️ '$SatoriPath' is already in PATH."
27
+ }
28
+
29
+ # Verificar si el binario existe
30
+ if (Test-Path $BinPath) {
31
+ Write-Host "✅ Binary found at: $BinPath"
32
+ } else {
33
+ Write-Host "⚠️ Binary not found at: $BinPath"
34
+ }
35
+
36
+ } catch {
37
+ Write-Host "❌ Error configuring PATH: $($_.Exception.Message)"
38
+ Write-Host "💡 You can manually add: $SatoriPath to your system PATH."
39
+ exit 1
11
40
  }
package/add-to-path.sh CHANGED
@@ -1,8 +1,23 @@
1
1
  #!/bin/bash
2
2
 
3
+ set -e # Salir en caso de error
4
+
3
5
  SATORI_PATH="$HOME/.satori/bin"
4
6
  EXPORT_LINE='export PATH="$HOME/.satori/bin:$PATH"'
5
7
 
8
+ # Check if directory exists
9
+ if [ ! -d "$SATORI_PATH" ]; then
10
+ echo "❌ Directory $SATORI_PATH does not exist. Installation may have failed."
11
+ exit 1
12
+ fi
13
+
14
+ # Check if binary exists
15
+ if [ -f "$SATORI_PATH/satori" ]; then
16
+ echo "✅ Binary found at: $SATORI_PATH/satori"
17
+ else
18
+ echo "⚠️ Binary not found at: $SATORI_PATH/satori"
19
+ fi
20
+
6
21
  # Detectar shell y archivo de configuración
7
22
  detect_profile() {
8
23
  if [ -n "$ZSH_VERSION" ]; then
@@ -23,12 +38,14 @@ detect_profile() {
23
38
 
24
39
  PROFILE_FILE=$(detect_profile)
25
40
 
26
- # Verificar si ya existe la línea
41
+ # Check if line already exists
27
42
  if [[ -f "$PROFILE_FILE" ]] && grep -qF "$EXPORT_LINE" "$PROFILE_FILE"; then
28
- echo "ℹ️ Ya existe PATH en $PROFILE_FILE"
29
- echo "✅ PATH ya contiene ~/.satori/bin"
43
+ echo "ℹ️ PATH already exists in $PROFILE_FILE"
44
+ echo "✅ PATH already contains ~/.satori/bin"
30
45
  else
31
- echo "✅ Añadiendo al PATH en $PROFILE_FILE"
32
- echo -e "\n# Añadido por Satori\n$EXPORT_LINE" >> "$PROFILE_FILE"
33
- echo "🔄 Ejecuta: source $PROFILE_FILE"
46
+ echo "✅ Adding to PATH in $PROFILE_FILE"
47
+ echo -e "\n# Added by Satori\n$EXPORT_LINE" >> "$PROFILE_FILE"
48
+ echo "🔄 Run: source $PROFILE_FILE"
34
49
  fi
50
+
51
+ echo "✅ Configuration completed"
package/cli.js CHANGED
@@ -41,8 +41,8 @@ function parseData(data) {
41
41
  }
42
42
  return JSON.parse(cleanData);
43
43
  } catch (e) {
44
- // Si no se puede parsear como JSON, mantener como string
45
- console.log("⚠️ No se pudo parsear como JSON, manteniendo como string");
44
+ // If cannot parse as JSON, keep as string
45
+ console.log("⚠️ Could not parse as JSON, keeping as string");
46
46
  console.log("Error:", e.message);
47
47
  return data;
48
48
  }
@@ -53,26 +53,26 @@ function parseData(data) {
53
53
 
54
54
  function run(args) {
55
55
  if (!fs.existsSync(binPath)) {
56
- console.log("❌ Satori no está instalado. Intenta reinstalar el paquete.");
56
+ console.log("❌ Satori is not installed. Try reinstalling the package.");
57
57
  process.exit(1);
58
58
  }
59
59
 
60
60
  let result = spawnSync(binPath, args, { stdio: "inherit" });
61
61
  if (result.error) {
62
- console.log("❌ Error ejecutando:", result.error.message);
62
+ console.log("❌ Error executing:", result.error.message);
63
63
  process.exit(1);
64
64
  }
65
65
  }
66
66
 
67
67
  async function connectToSatori(host, user = null, password = null) {
68
68
  try {
69
- console.log(`🔗 Conectando a ${host}...`);
69
+ console.log(`🔗 Connecting to ${host}...`);
70
70
  satoriInstance = new Satori({host, user, password});
71
71
  await satoriInstance.connect();
72
- console.log("✅ Conexión exitosa a SatoriDB");
72
+ console.log("✅ Successfully connected to SatoriDB");
73
73
  return true;
74
74
  } catch (error) {
75
- console.log("❌ Error al conectar:", error.message);
75
+ console.log("❌ Error connecting:", error.message);
76
76
  return false;
77
77
  }
78
78
  }
@@ -95,9 +95,9 @@ async function executeCommand(command, args) {
95
95
  return;
96
96
  }
97
97
 
98
- // Comandos que requieren conexión
98
+ // Commands that require connection
99
99
  if (!satoriInstance) {
100
- console.log("❌ No hay conexión activa. Usa 'connect <host> [user] [password]' primero.");
100
+ console.log("❌ No active connection. Use 'connect <host> [user] [password]' first.");
101
101
  return;
102
102
  }
103
103
 
@@ -115,7 +115,7 @@ async function executeCommand(command, args) {
115
115
  data = parseData(data);
116
116
 
117
117
  await satoriInstance.set({key, data});
118
- console.log(`✅ Datos guardados en clave: ${key}`);
118
+ console.log(`✅ Data saved in key: ${key}`);
119
119
  break;
120
120
 
121
121
  case "put":
@@ -127,7 +127,7 @@ async function executeCommand(command, args) {
127
127
  // Parsear JSON en el valor si es necesario
128
128
  replaceValue = parseData(replaceValue);
129
129
  await satoriInstance.put({key: putKey, replace_field: replaceField, replace_value: replaceValue, encryption_key: encryption_key_put});
130
- console.log(`✅ Campo actualizado: ${putKey}.${replaceField} = ${replaceValue}`);
130
+ console.log(`✅ Field updated: ${putKey}.${replaceField} = ${replaceValue}`);
131
131
  break;
132
132
 
133
133
  case "get":
@@ -135,11 +135,11 @@ async function executeCommand(command, args) {
135
135
  let getKey = args[0];
136
136
  let encryption_key_get = args[1] || null;
137
137
  let result = await satoriInstance.get({key: getKey, encryption_key: encryption_key_get});
138
- console.log(`📄 Datos de ${getKey}:`, JSON.stringify(result, null, 2));
138
+ console.log(`📄 Data from ${getKey}:`, JSON.stringify(result, null, 2));
139
139
  break;
140
140
  }else{
141
141
  let result = await satoriInstance.get();
142
- console.log(`📄 Datos de get:`, JSON.stringify(result, null, 2));
142
+ console.log(`📄 Data from get:`, JSON.stringify(result, null, 2));
143
143
  break;
144
144
  }
145
145
 
@@ -151,7 +151,7 @@ async function executeCommand(command, args) {
151
151
  }
152
152
  let deleteKey = args[0];
153
153
  await satoriInstance.delete({key: deleteKey});
154
- console.log(`🗑️ Clave eliminada: ${deleteKey}`);
154
+ console.log(`🗑️ Key deleted: ${deleteKey}`);
155
155
  break;
156
156
 
157
157
  case "ask":
@@ -162,7 +162,7 @@ async function executeCommand(command, args) {
162
162
  let question = args[0];
163
163
  let backend = args[1] || null;
164
164
  let result = await satoriInstance.ask({question, backend});
165
- console.log("🔍 Resultados de búsqueda:", JSON.stringify(result, null, 2));
165
+ console.log("🔍 Search results:", JSON.stringify(result, null, 2));
166
166
  break;
167
167
 
168
168
  case "query":
@@ -173,7 +173,7 @@ async function executeCommand(command, args) {
173
173
  let query = args[0];
174
174
  let backend_q = args[1] || null;
175
175
  let result_q = await satoriInstance.query({query, backend: backend_q});
176
- console.log("🔍 Resultados de búsqueda:", JSON.stringify(result_q, null, 2));
176
+ console.log("🔍 Search results:", JSON.stringify(result_q, null, 2));
177
177
  break;
178
178
 
179
179
  case "dfs":
@@ -185,7 +185,7 @@ async function executeCommand(command, args) {
185
185
  let relation = args[1] || null;
186
186
  let encryption_key = args[2] || null;
187
187
  let result_dfs = await satoriInstance.dfs({node, relation, encryption_key});
188
- console.log("🔍 Resultados de búsqueda:", JSON.stringify(result_dfs, null, 2));
188
+ console.log("🔍 Search results:", JSON.stringify(result_dfs, null, 2));
189
189
  break;
190
190
 
191
191
  case "encrypt":
@@ -196,7 +196,7 @@ async function executeCommand(command, args) {
196
196
  let key_encrypt = args[0];
197
197
  let encryption_key_encrypt = args[1] || null;
198
198
  let result_encrypt = await satoriInstance.encrypt({key: key_encrypt, encryption_key: encryption_key_encrypt});
199
- console.log("🔍 Resultados de encriptación:", JSON.stringify(result_encrypt, null, 2));
199
+ console.log("🔍 Encryption results:", JSON.stringify(result_encrypt, null, 2));
200
200
  break;
201
201
 
202
202
  case "decrypt":
@@ -207,7 +207,7 @@ async function executeCommand(command, args) {
207
207
  let key_decrypt = args[0];
208
208
  let encryption_key_decrypt = args[1] || null;
209
209
  let result_decrypt = await satoriInstance.decrypt({key: key_decrypt, encryption_key: encryption_key_decrypt});
210
- console.log("🔍 Resultados de desencriptación:", JSON.stringify(result_decrypt, null, 2));
210
+ console.log("🔍 Decryption results:", JSON.stringify(result_decrypt, null, 2));
211
211
  break;
212
212
 
213
213
  case "push":
@@ -222,7 +222,7 @@ async function executeCommand(command, args) {
222
222
  // Parsear JSON en el valor si es necesario
223
223
  value_push = parseData(value_push);
224
224
  let result_push = await satoriInstance.push({key: key_push, array: array_push, value: value_push, encryption_key: encryption_key_push});
225
- console.log("🔍 Resultados de inserción:", JSON.stringify(result_push, null, 2));
225
+ console.log("🔍 Insertion results:", JSON.stringify(result_push, null, 2));
226
226
  break;
227
227
 
228
228
  case "pop":
@@ -234,7 +234,7 @@ async function executeCommand(command, args) {
234
234
  let array_pop = args[1];
235
235
  let encryption_key_pop = args[2] || null;
236
236
  let result_pop = await satoriInstance.pop({key: key_pop, array: array_pop, encryption_key: encryption_key_pop});
237
- console.log("🔍 Resultados de eliminación:", JSON.stringify(result_pop, null, 2));
237
+ console.log("🔍 Removal results:", JSON.stringify(result_pop, null, 2));
238
238
  break;
239
239
 
240
240
  case "splice":
@@ -246,7 +246,7 @@ async function executeCommand(command, args) {
246
246
  let array_splice = args[1];
247
247
  let encryption_key_splice = args[2] || null;
248
248
  let result_splice = await satoriInstance.splice({key: key_splice, array: array_splice, encryption_key: encryption_key_splice});
249
- console.log("🔍 Resultados de inserción:", JSON.stringify(result_splice, null, 2));
249
+ console.log("🔍 Insertion results:", JSON.stringify(result_splice, null, 2));
250
250
  break;
251
251
 
252
252
  case "remove":
@@ -261,7 +261,7 @@ async function executeCommand(command, args) {
261
261
  // Parsear JSON en el valor si es necesario
262
262
  value_remove = parseData(value_remove);
263
263
  let result_remove = await satoriInstance.remove({key: key_remove, array: array_remove, value: value_remove, encryption_key: encryption_key_remove});
264
- console.log("🔍 Resultados de eliminación:", JSON.stringify(result_remove, null, 2));
264
+ console.log("🔍 Removal results:", JSON.stringify(result_remove, null, 2));
265
265
  break;
266
266
 
267
267
  case "set_vertex":
@@ -275,7 +275,7 @@ async function executeCommand(command, args) {
275
275
  // Parsear JSON en el vertex si es necesario
276
276
  vertex_set_vertex = parseData(vertex_set_vertex);
277
277
  let result_set_vertex = await satoriInstance.set_vertex({key: key_set_vertex, vertex: vertex_set_vertex, encryption_key: encryption_key_set_vertex});
278
- console.log("🔍 Resultados de inserción:", JSON.stringify(result_set_vertex, null, 2));
278
+ console.log("🔍 Insertion results:", JSON.stringify(result_set_vertex, null, 2));
279
279
  break;
280
280
 
281
281
  case "get_vertex":
@@ -286,7 +286,7 @@ async function executeCommand(command, args) {
286
286
  let key_get_vertex = args[0];
287
287
  let encryption_key_get_vertex = args[1] || null;
288
288
  let result_get_vertex = await satoriInstance.get_vertex({key: key_get_vertex, encryption_key: encryption_key_get_vertex});
289
- console.log("🔍 Resultados de inserción:", JSON.stringify(result_get_vertex, null, 2));
289
+ console.log("🔍 Insertion results:", JSON.stringify(result_get_vertex, null, 2));
290
290
  break;
291
291
 
292
292
  case "delete_vertex":
@@ -300,38 +300,38 @@ async function executeCommand(command, args) {
300
300
  // Parsear JSON en el vertex si es necesario
301
301
  vertex_delete_vertex = parseData(vertex_delete_vertex);
302
302
  let result_delete_vertex = await satoriInstance.delete_vertex({key: key_delete_vertex, vertex: vertex_delete_vertex, encryption_key: encryption_key_delete_vertex});
303
- console.log("🔍 Resultados de eliminación:", JSON.stringify(result_delete_vertex, null, 2));
303
+ console.log("🔍 Removal results:", JSON.stringify(result_delete_vertex, null, 2));
304
304
  break;
305
305
 
306
306
  default:
307
- console.log("❌ Comando no reconocido. Usa 'help' para ver comandos disponibles.");
307
+ console.log("❌ Command not recognized. Use 'help' to see available commands.");
308
308
  }
309
309
  } catch (error) {
310
- console.log("❌ Error ejecutando comando:", error.message);
310
+ console.log("❌ Error executing command:", error.message);
311
311
  }
312
312
  }
313
313
 
314
314
  function showHelp() {
315
315
  console.log(`
316
- 📚 Comandos disponibles:
316
+ 📚 Available commands:
317
317
 
318
- 🔗 Conexión:
319
- connect <host> [user] [password] - Conectar a SatoriDB
318
+ 🔗 Connection:
319
+ connect <host> [user] [password] - Connect to SatoriDB
320
320
 
321
- 📝 Operaciones de datos:
322
- set <key> <data> - Guardar datos en una clave
323
- put <key> <field> <value> - Actualizar un campo específico
324
- get <key> - Obtener datos de una clave
325
- delete <key> - Eliminar una clave
326
- ask <question> [backend] - Hacer una pregunta
327
- query <query> [backend] - Hacer una consulta
321
+ 📝 Data operations:
322
+ set <key> <data> - Save data to a key
323
+ put <key> <field> <value> - Update a specific field
324
+ get <key> - Get data from a key
325
+ delete <key> - Delete a key
326
+ ask <question> [backend] - Ask a question
327
+ query <query> [backend] - Make a query
328
328
 
329
- 🛠️ Otros:
330
- help - Mostrar esta ayuda
331
- exit / quit - Salir de la CLI
332
- clear - Limpiar pantalla
329
+ 🛠️ Others:
330
+ help - Show this help
331
+ exit / quit - Exit the CLI
332
+ clear - Clear screen
333
333
 
334
- 💡 Ejemplo: set user:123 '{"name": "Juan", "age": 25}'
334
+ 💡 Example: set user:123 '{"name": "John", "age": 25}'
335
335
  `);
336
336
  }
337
337
 
@@ -346,9 +346,9 @@ async function startInteractiveCLI() {
346
346
  prompt: 'satori> '
347
347
  });
348
348
 
349
- console.log("🚀 SatoriDB CLI Interactiva");
350
- console.log("📝 Escribe 'help' para ver comandos disponibles");
351
- console.log("💡 Usa 'connect <host> [user] [password]' para comenzar\n");
349
+ console.log("🚀 SatoriDB Interactive CLI");
350
+ console.log("📝 Type 'help' to see available commands");
351
+ console.log("💡 Use 'connect <host> [user] [password]' to start\n");
352
352
 
353
353
  rl.prompt();
354
354
 
@@ -377,7 +377,7 @@ async function startInteractiveCLI() {
377
377
  let password = args[2] || null;
378
378
  let success = await connectToSatori(host, user, password);
379
379
  if (success) {
380
- console.log("✅ Ahora puedes usar comandos como 'set', 'get', 'put', etc.");
380
+ console.log("✅ Now you can use commands like 'set', 'get', 'put', etc.");
381
381
  }
382
382
  } else {
383
383
  await executeCommand(command, args);
@@ -387,7 +387,7 @@ async function startInteractiveCLI() {
387
387
  });
388
388
 
389
389
  rl.on('close', () => {
390
- console.log('\n👋 ¡Hasta luego!');
390
+ console.log('\n👋 Goodbye!');
391
391
  process.exit(0);
392
392
  });
393
393
  }
@@ -414,7 +414,10 @@ if (args[0] === "update") {
414
414
  process.exit(1);
415
415
  }
416
416
  });
417
+ } else if (args[0] === "verify") {
418
+ console.log("🔍 Verifying installation...");
419
+ require("./verify-install");
417
420
  } else {
418
- // Si no hay argumentos o argumentos no reconocidos, iniciar CLI interactiva
421
+ // If no arguments or unrecognized arguments, start interactive CLI
419
422
  startInteractiveCLI();
420
423
  }
package/package.json CHANGED
@@ -1,17 +1,23 @@
1
1
  {
2
2
  "name": "satoridb",
3
- "version": "1.1.16",
3
+ "version": "1.1.18",
4
4
  "description": "Install satori",
5
5
  "bin": {
6
6
  "satoridb": "./cli.js"
7
7
  },
8
8
  "scripts": {
9
- "postinstall": "node postinstall.js"
9
+ "postinstall": "node postinstall.js",
10
+ "verify": "node verify-install.js"
10
11
  },
11
12
  "author": "",
12
13
  "license": "ISC",
13
14
  "dependencies": {
14
15
  "adm-zip": "^0.5.16",
15
16
  "satori-node": "^1.0.51"
16
- }
17
+ },
18
+ "files": [
19
+ "postinstall.js",
20
+ "add-to-path.ps1",
21
+ "add-to-path.sh"
22
+ ]
17
23
  }
package/postinstall.js CHANGED
@@ -15,7 +15,7 @@ let fileName;
15
15
  if (platform === "linux") fileName = "lin/satori-linux.zip";
16
16
  else if (platform === "win32") fileName = "win/satori-win.zip";
17
17
  else {
18
- console.log("❌ Not supported platform:", platform);
18
+ console.log("❌ Platform not supported:", platform);
19
19
  process.exit(1);
20
20
  }
21
21
 
@@ -53,7 +53,7 @@ function downloadZip(url, dest, cb) {
53
53
  if (response.statusCode !== 200) {
54
54
  console.log("❌ Download failed:", response.statusCode);
55
55
  file.close();
56
- fs.unlink(dest, () => {}); // Limpiar archivo parcial
56
+ fs.unlink(dest, () => {}); // Clean partial file
57
57
  process.exit(1);
58
58
  }
59
59
 
@@ -149,31 +149,46 @@ downloadZip(`${baseURL}/${fileName}`, zipPath, () => {
149
149
  extractZip(zipPath, installDir);
150
150
  console.log(`✅ Binary installed in: ${binFullPath}\n`);
151
151
 
152
- // Limpiar archivo temporal
152
+ // Clean temporary file
153
153
  try {
154
154
  fs.unlinkSync(zipPath);
155
155
  } catch (err) {
156
156
  console.warn(`⚠️ Could not clean up temporary file: ${err.message}`);
157
157
  }
158
158
 
159
- let shell = process.env.SHELL || "";
160
- let profileFile = shell.includes("zsh") ? ".zshrc" : ".bashrc";
161
-
162
- let exportLine = `export PATH="$HOME/.satori/bin:$PATH"`;
159
+ console.log(`\n🔧 Configuring PATH...`);
163
160
 
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
- }
175
-
176
- /* console.log(`💡 Add this to your ~/${profileFile}:\n`);
177
- console.log(` ${exportLine}\n`);
178
- console.log(`Then run: source ~/${profileFile}\n`);*/
161
+ if (process.platform === "win32") {
162
+ spawnSync("powershell.exe", [
163
+ "-ExecutionPolicy",
164
+ "Bypass",
165
+ "-File",
166
+ "./add-to-path.ps1" // Ajusta la ruta si está en otro lugar
167
+ ], { stdio: "inherit" });
168
+ } else {
169
+ console.log(`🐧 Running bash script for Linux/macOS...`);
170
+ try {
171
+ let result = child_process.spawnSync("bash", [
172
+ path.join(__dirname, "add-to-path.sh")
173
+ ], {
174
+ stdio: "inherit",
175
+ timeout: 10000
176
+ });
177
+
178
+ if (result.status === 0) {
179
+ console.log(`✅ PATH configured successfully on Linux/macOS`);
180
+ } else {
181
+ console.log(`⚠️ Error configuring PATH on Linux/macOS. Code: ${result.status}`);
182
+ console.log(`💡 You can manually add: export PATH="$HOME/.satori/bin:$PATH" to your shell profile`);
183
+ }
184
+ } catch (error) {
185
+ console.log(`❌ Error running bash script: ${error.message}`);
186
+ console.log(`💡 You can manually add: export PATH="$HOME/.satori/bin:$PATH" to your shell profile`);
187
+ }
188
+ }
189
+
190
+ console.log(`\n🎉 Installation completed!`);
191
+ console.log(`📁 Binary installed at: ${binFullPath}`);
192
+ console.log(`🔄 Restart your terminal to use the 'satori' command directly`);
193
+ console.log(`💡 Or use: ${binFullPath} to run directly`);
179
194
  });