spindb 0.6.0 → 0.7.0

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.
@@ -20,7 +20,7 @@ import { getMissingDependencies } from '../../core/dependency-manager'
20
20
  import { platformService } from '../../core/platform-service'
21
21
  import { startWithRetry } from '../../core/start-with-retry'
22
22
  import { TransactionManager } from '../../core/transaction-manager'
23
- import type { EngineName } from '../../types'
23
+ import { Engine } from '../../types'
24
24
 
25
25
  /**
26
26
  * Detect if a location string is a connection string or a file path
@@ -28,19 +28,19 @@ import type { EngineName } from '../../types'
28
28
  */
29
29
  function detectLocationType(location: string): {
30
30
  type: 'connection' | 'file' | 'not_found'
31
- inferredEngine?: EngineName
31
+ inferredEngine?: Engine
32
32
  } {
33
33
  // Check for PostgreSQL connection string
34
34
  if (
35
35
  location.startsWith('postgresql://') ||
36
36
  location.startsWith('postgres://')
37
37
  ) {
38
- return { type: 'connection', inferredEngine: 'postgresql' }
38
+ return { type: 'connection', inferredEngine: Engine.PostgreSQL }
39
39
  }
40
40
 
41
41
  // Check for MySQL connection string
42
42
  if (location.startsWith('mysql://')) {
43
- return { type: 'connection', inferredEngine: 'mysql' }
43
+ return { type: 'connection', inferredEngine: Engine.MySQL }
44
44
  }
45
45
 
46
46
  // Check if file exists
@@ -79,7 +79,7 @@ export const createCommand = new Command('create')
79
79
 
80
80
  try {
81
81
  let containerName = name
82
- let engine: EngineName = (options.engine as EngineName) || 'postgresql'
82
+ let engine: Engine = (options.engine as Engine) || Engine.PostgreSQL
83
83
  let version = options.version
84
84
  let database = options.database
85
85
 
@@ -136,7 +136,7 @@ export const createCommand = new Command('create')
136
136
  if (!containerName) {
137
137
  const answers = await promptCreateOptions()
138
138
  containerName = answers.name
139
- engine = answers.engine as EngineName
139
+ engine = answers.engine as Engine
140
140
  version = answers.version
141
141
  database = answers.database
142
142
  }
@@ -254,7 +254,7 @@ export const createCommand = new Command('create')
254
254
 
255
255
  try {
256
256
  await containerManager.create(containerName, {
257
- engine: dbEngine.name as EngineName,
257
+ engine: dbEngine.name as Engine,
258
258
  version,
259
259
  port,
260
260
  database,
@@ -35,7 +35,7 @@ import { platformService } from '../../core/platform-service'
35
35
  import { portManager } from '../../core/port-manager'
36
36
  import { defaults } from '../../config/defaults'
37
37
  import { getPostgresHomebrewPackage } from '../../config/engine-defaults'
38
- import type { EngineName } from '../../types'
38
+ import { Engine } from '../../types'
39
39
  import inquirer from 'inquirer'
40
40
  import {
41
41
  getMissingDependencies,
@@ -387,7 +387,7 @@ async function handleCreate(): Promise<void> {
387
387
  createSpinnerInstance.start()
388
388
 
389
389
  await containerManager.create(containerName, {
390
- engine: dbEngine.name as EngineName,
390
+ engine: dbEngine.name as Engine,
391
391
  version,
392
392
  port,
393
393
  database,
@@ -1156,7 +1156,7 @@ async function handleCreateForRestore(): Promise<{
1156
1156
  createSpinnerInstance.start()
1157
1157
 
1158
1158
  await containerManager.create(containerName, {
1159
- engine: dbEngine.name as EngineName,
1159
+ engine: dbEngine.name as Engine,
1160
1160
  version,
1161
1161
  port,
1162
1162
  database,
@@ -5,6 +5,7 @@ import {
5
5
  getSupportedEngines,
6
6
  type EngineDefaults,
7
7
  } from './engine-defaults'
8
+ import { Engine } from '../types'
8
9
 
9
10
  // Re-export engine-related functions and types
10
11
  export {
@@ -24,50 +25,25 @@ export type PortRange = {
24
25
  end: number
25
26
  }
26
27
 
27
- /**
28
- * Legacy Defaults type - kept for backward compatibility
29
- * New code should use getEngineDefaults(engine) instead
30
- */
31
28
  export type Defaults = {
32
- /** @deprecated Use getEngineDefaults(engine).defaultVersion instead */
33
- postgresVersion: string
34
29
  port: number
35
30
  portRange: PortRange
36
- engine: string
37
- /** @deprecated Use getEngineDefaults(engine).supportedVersions instead */
38
- supportedPostgresVersions: string[]
31
+ engine: Engine
39
32
  superuser: string
40
33
  platformMappings: PlatformMappings
41
34
  }
42
35
 
43
- // Get PostgreSQL defaults from engine-defaults
44
36
  const pgDefaults = engineDefaults.postgresql
45
37
 
46
38
  /**
47
- * Default configuration values
48
- * For backward compatibility, this defaults to PostgreSQL settings.
49
- * New code should use getEngineDefaults(engine) for engine-specific defaults.
39
+ * Default configuration values (PostgreSQL-based defaults)
40
+ * Use getEngineDefaults(engine) for engine-specific defaults.
50
41
  */
51
42
  export const defaults: Defaults = {
52
- // Default PostgreSQL version (from engine defaults)
53
- postgresVersion: pgDefaults.defaultVersion,
54
-
55
- // Default port (standard PostgreSQL port)
56
43
  port: pgDefaults.defaultPort,
57
-
58
- // Port range to scan if default is busy
59
44
  portRange: pgDefaults.portRange,
60
-
61
- // Default engine
62
- engine: 'postgresql',
63
-
64
- // Supported PostgreSQL versions (from engine defaults)
65
- supportedPostgresVersions: pgDefaults.supportedVersions,
66
-
67
- // Default superuser (from engine defaults)
45
+ engine: Engine.PostgreSQL,
68
46
  superuser: pgDefaults.superuser,
69
-
70
- // Platform mappings for zonky.io binaries (PostgreSQL specific)
71
47
  platformMappings: {
72
48
  'darwin-arm64': 'darwin-arm64v8',
73
49
  'darwin-x64': 'darwin-amd64',
@@ -6,7 +6,7 @@ import { exec } from 'child_process'
6
6
  import { promisify } from 'util'
7
7
  import { paths } from '../config/paths'
8
8
  import { defaults } from '../config/defaults'
9
- import type { ProgressCallback, InstalledBinary } from '../types'
9
+ import { Engine, type ProgressCallback, type InstalledBinary } from '../types'
10
10
 
11
11
  const execAsync = promisify(exec)
12
12
 
@@ -91,7 +91,7 @@ export class BinaryManager {
91
91
  const parts = entry.name.split('-')
92
92
  if (parts.length >= 4) {
93
93
  installed.push({
94
- engine: parts[0],
94
+ engine: parts[0] as Engine,
95
95
  version: parts[1],
96
96
  platform: parts[2],
97
97
  arch: parts[3],
@@ -5,10 +5,11 @@ import { processManager } from './process-manager'
5
5
  import { portManager } from './port-manager'
6
6
  import { getEngineDefaults, getSupportedEngines } from '../config/defaults'
7
7
  import { getEngine } from '../engines'
8
- import type { ContainerConfig, EngineName } from '../types'
8
+ import type { ContainerConfig } from '../types'
9
+ import { Engine } from '../types'
9
10
 
10
11
  export type CreateOptions = {
11
- engine: EngineName
12
+ engine: Engine
12
13
  version: string
13
14
  port: number
14
15
  database: string
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "spindb",
3
- "version": "0.6.0",
3
+ "version": "0.7.0",
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": {
package/types/index.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  export type ContainerConfig = {
2
2
  name: string
3
- engine: EngineName
3
+ engine: Engine
4
4
  version: string
5
5
  port: number
6
6
  database: string
@@ -14,7 +14,10 @@ export type ContainerConfig = {
14
14
  * Supported database engine names
15
15
  * Extendable for future engines (sqlite, etc.)
16
16
  */
17
- export type EngineName = 'postgresql' | 'mysql'
17
+ export enum Engine {
18
+ PostgreSQL = 'postgresql',
19
+ MySQL = 'mysql',
20
+ }
18
21
 
19
22
  export type ProgressCallback = (progress: {
20
23
  stage: string
@@ -22,7 +25,7 @@ export type ProgressCallback = (progress: {
22
25
  }) => void
23
26
 
24
27
  export type InstalledBinary = {
25
- engine: string
28
+ engine: Engine
26
29
  version: string
27
30
  platform: string
28
31
  arch: string
@@ -141,7 +144,7 @@ export type SpinDBConfig = {
141
144
  }
142
145
  // Default settings
143
146
  defaults?: {
144
- engine?: EngineName
147
+ engine?: Engine
145
148
  version?: string
146
149
  port?: number
147
150
  }