spindb 0.9.0 → 0.9.2

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.
Files changed (49) hide show
  1. package/README.md +7 -0
  2. package/cli/commands/backup.ts +13 -11
  3. package/cli/commands/clone.ts +18 -8
  4. package/cli/commands/config.ts +29 -29
  5. package/cli/commands/connect.ts +51 -39
  6. package/cli/commands/create.ts +120 -43
  7. package/cli/commands/delete.ts +8 -8
  8. package/cli/commands/deps.ts +17 -15
  9. package/cli/commands/doctor.ts +16 -15
  10. package/cli/commands/edit.ts +115 -60
  11. package/cli/commands/engines.ts +50 -17
  12. package/cli/commands/info.ts +12 -8
  13. package/cli/commands/list.ts +34 -19
  14. package/cli/commands/logs.ts +24 -14
  15. package/cli/commands/menu/backup-handlers.ts +72 -49
  16. package/cli/commands/menu/container-handlers.ts +140 -80
  17. package/cli/commands/menu/engine-handlers.ts +145 -11
  18. package/cli/commands/menu/index.ts +4 -4
  19. package/cli/commands/menu/shell-handlers.ts +34 -31
  20. package/cli/commands/menu/sql-handlers.ts +22 -16
  21. package/cli/commands/menu/update-handlers.ts +19 -17
  22. package/cli/commands/restore.ts +105 -43
  23. package/cli/commands/run.ts +20 -18
  24. package/cli/commands/self-update.ts +5 -5
  25. package/cli/commands/start.ts +11 -9
  26. package/cli/commands/stop.ts +9 -9
  27. package/cli/commands/url.ts +12 -9
  28. package/cli/helpers.ts +49 -4
  29. package/cli/ui/prompts.ts +21 -8
  30. package/cli/ui/spinner.ts +4 -4
  31. package/cli/ui/theme.ts +4 -4
  32. package/core/binary-manager.ts +5 -1
  33. package/core/container-manager.ts +81 -30
  34. package/core/error-handler.ts +31 -0
  35. package/core/platform-service.ts +3 -3
  36. package/core/port-manager.ts +2 -0
  37. package/core/process-manager.ts +25 -3
  38. package/core/start-with-retry.ts +6 -6
  39. package/core/transaction-manager.ts +6 -6
  40. package/engines/mysql/backup.ts +53 -36
  41. package/engines/mysql/index.ts +59 -16
  42. package/engines/mysql/restore.ts +4 -4
  43. package/engines/mysql/version-validator.ts +2 -2
  44. package/engines/postgresql/binary-manager.ts +17 -17
  45. package/engines/postgresql/index.ts +13 -2
  46. package/engines/postgresql/restore.ts +2 -2
  47. package/engines/postgresql/version-validator.ts +2 -2
  48. package/engines/sqlite/index.ts +31 -9
  49. package/package.json +1 -1
@@ -98,6 +98,7 @@ export class SQLiteEngine extends BaseEngine {
98
98
 
99
99
  // Check system PATH
100
100
  try {
101
+ // TODO - update when windows support is added
101
102
  const { stdout } = await execFileAsync('which', ['sqlite3'])
102
103
  const path = stdout.trim()
103
104
  return path || null
@@ -184,7 +185,9 @@ export class SQLiteEngine extends BaseEngine {
184
185
  ): Promise<{ port: number; connectionString: string }> {
185
186
  const entry = await sqliteRegistry.get(container.name)
186
187
  if (!entry) {
187
- throw new Error(`SQLite container "${container.name}" not found in registry`)
188
+ throw new Error(
189
+ `SQLite container "${container.name}" not found in registry`,
190
+ )
188
191
  }
189
192
  if (!existsSync(entry.filePath)) {
190
193
  throw new Error(`SQLite database file not found: ${entry.filePath}`)
@@ -243,7 +246,9 @@ export class SQLiteEngine extends BaseEngine {
243
246
  async connect(container: ContainerConfig, _database?: string): Promise<void> {
244
247
  const entry = await sqliteRegistry.get(container.name)
245
248
  if (!entry) {
246
- throw new Error(`SQLite container "${container.name}" not found in registry`)
249
+ throw new Error(
250
+ `SQLite container "${container.name}" not found in registry`,
251
+ )
247
252
  }
248
253
  if (!existsSync(entry.filePath)) {
249
254
  throw new Error(`SQLite database file not found: ${entry.filePath}`)
@@ -521,7 +526,9 @@ export class SQLiteEngine extends BaseEngine {
521
526
  if (code === 0) {
522
527
  resolve()
523
528
  } else {
524
- reject(new Error(`sqlite3 script execution failed with exit code ${code}`))
529
+ reject(
530
+ new Error(`sqlite3 script execution failed with exit code ${code}`),
531
+ )
525
532
  }
526
533
  })
527
534
  })
@@ -531,13 +538,28 @@ export class SQLiteEngine extends BaseEngine {
531
538
  * Download a file from HTTP/HTTPS URL
532
539
  */
533
540
  private async downloadFile(url: string, destPath: string): Promise<void> {
534
- const response = await fetch(url)
535
- if (!response.ok) {
536
- throw new Error(`Failed to download: ${response.status} ${response.statusText}`)
537
- }
541
+ const controller = new AbortController()
542
+ const timeoutMs = 5 * 60 * 1000 // 5 minutes
543
+ const timeout = setTimeout(() => controller.abort(), timeoutMs)
538
544
 
539
- const buffer = await response.arrayBuffer()
540
- await writeFile(destPath, Buffer.from(buffer))
545
+ try {
546
+ const response = await fetch(url, { signal: controller.signal })
547
+ if (!response.ok) {
548
+ throw new Error(
549
+ `Failed to download: ${response.status} ${response.statusText}`,
550
+ )
551
+ }
552
+
553
+ const buffer = await response.arrayBuffer()
554
+ await writeFile(destPath, Buffer.from(buffer))
555
+ } catch (error) {
556
+ if (error instanceof Error && error.name === 'AbortError') {
557
+ throw new Error('Download timed out after 5 minutes')
558
+ }
559
+ throw error
560
+ } finally {
561
+ clearTimeout(timeout)
562
+ }
541
563
  }
542
564
 
543
565
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "spindb",
3
- "version": "0.9.0",
3
+ "version": "0.9.2",
4
4
  "description": "Spin up local database containers without Docker. A DBngin-like CLI for PostgreSQL and MySQL.",
5
5
  "type": "module",
6
6
  "bin": {