spindb 0.4.1 → 0.5.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.
@@ -54,7 +54,12 @@ export class PostgreSQLEngine extends BaseEngine {
54
54
  */
55
55
  getBinaryPath(version: string): string {
56
56
  const { platform: p, arch: a } = this.getPlatformInfo()
57
- return paths.getBinaryPath('postgresql', version, p, a)
57
+ return paths.getBinaryPath({
58
+ engine: 'postgresql',
59
+ version,
60
+ platform: p,
61
+ arch: a,
62
+ })
58
63
  }
59
64
 
60
65
  /**
@@ -104,7 +109,9 @@ export class PostgreSQLEngine extends BaseEngine {
104
109
  ): Promise<string> {
105
110
  const binPath = this.getBinaryPath(version)
106
111
  const initdbPath = join(binPath, 'bin', 'initdb')
107
- const dataDir = paths.getContainerDataPath(containerName)
112
+ const dataDir = paths.getContainerDataPath(containerName, {
113
+ engine: this.name,
114
+ })
108
115
 
109
116
  await processManager.initdb(initdbPath, dataDir, {
110
117
  superuser: (options.superuser as string) || defaults.superuser,
@@ -123,8 +130,8 @@ export class PostgreSQLEngine extends BaseEngine {
123
130
  const { name, version, port } = container
124
131
  const binPath = this.getBinaryPath(version)
125
132
  const pgCtlPath = join(binPath, 'bin', 'pg_ctl')
126
- const dataDir = paths.getContainerDataPath(name)
127
- const logFile = paths.getContainerLogPath(name)
133
+ const dataDir = paths.getContainerDataPath(name, { engine: this.name })
134
+ const logFile = paths.getContainerLogPath(name, { engine: this.name })
128
135
 
129
136
  onProgress?.({ stage: 'starting', message: 'Starting PostgreSQL...' })
130
137
 
@@ -146,7 +153,7 @@ export class PostgreSQLEngine extends BaseEngine {
146
153
  const { name, version } = container
147
154
  const binPath = this.getBinaryPath(version)
148
155
  const pgCtlPath = join(binPath, 'bin', 'pg_ctl')
149
- const dataDir = paths.getContainerDataPath(name)
156
+ const dataDir = paths.getContainerDataPath(name, { engine: this.name })
150
157
 
151
158
  await processManager.stop(pgCtlPath, dataDir)
152
159
  }
@@ -158,7 +165,7 @@ export class PostgreSQLEngine extends BaseEngine {
158
165
  const { name, version } = container
159
166
  const binPath = this.getBinaryPath(version)
160
167
  const pgCtlPath = join(binPath, 'bin', 'pg_ctl')
161
- const dataDir = paths.getContainerDataPath(name)
168
+ const dataDir = paths.getContainerDataPath(name, { engine: this.name })
162
169
 
163
170
  return processManager.status(pgCtlPath, dataDir)
164
171
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "spindb",
3
- "version": "0.4.1",
3
+ "version": "0.5.2",
4
4
  "description": "Spin up local database containers without Docker. A DBngin-like CLI for PostgreSQL.",
5
5
  "type": "module",
6
6
  "bin": {
@@ -9,7 +9,9 @@
9
9
  "scripts": {
10
10
  "start": "tsx cli/bin.ts",
11
11
  "dev": "tsx watch cli/bin.ts",
12
- "test": "tsx --test",
12
+ "test": "pnpm test:pg && pnpm test:mysql",
13
+ "test:pg": "node --import tsx --test tests/integration/postgresql.test.ts",
14
+ "test:mysql": "node --import tsx --test tests/integration/mysql.test.ts",
13
15
  "format": "prettier --write .",
14
16
  "lint": "tsc --noEmit && eslint ."
15
17
  },
package/types/index.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  export type ContainerConfig = {
2
2
  name: string
3
- engine: string
3
+ engine: EngineName
4
4
  version: string
5
5
  port: number
6
6
  database: string
@@ -9,6 +9,12 @@ export type ContainerConfig = {
9
9
  clonedFrom?: string
10
10
  }
11
11
 
12
+ /**
13
+ * Supported database engine names
14
+ * Extendable for future engines (sqlite, etc.)
15
+ */
16
+ export type EngineName = 'postgresql' | 'mysql'
17
+
12
18
  export type ProgressCallback = (progress: {
13
19
  stage: string
14
20
  message: string
@@ -65,9 +71,20 @@ export type EngineInfo = {
65
71
  }
66
72
 
67
73
  /**
68
- * Binary tool types
74
+ * Binary tool types for all supported engines
69
75
  */
70
- export type BinaryTool = 'psql' | 'pg_dump' | 'pg_restore' | 'pg_basebackup'
76
+ export type BinaryTool =
77
+ // PostgreSQL tools
78
+ | 'psql'
79
+ | 'pg_dump'
80
+ | 'pg_restore'
81
+ | 'pg_basebackup'
82
+ // MySQL tools
83
+ | 'mysql'
84
+ | 'mysqldump'
85
+ | 'mysqlpump'
86
+ | 'mysqld'
87
+ | 'mysqladmin'
71
88
 
72
89
  /**
73
90
  * Source of a binary - bundled (downloaded by spindb) or system (found on PATH)
@@ -88,16 +105,23 @@ export type BinaryConfig = {
88
105
  * Global spindb configuration stored in ~/.spindb/config.json
89
106
  */
90
107
  export type SpinDBConfig = {
91
- // Binary paths for client tools
108
+ // Binary paths for client tools (all engines)
92
109
  binaries: {
110
+ // PostgreSQL tools
93
111
  psql?: BinaryConfig
94
112
  pg_dump?: BinaryConfig
95
113
  pg_restore?: BinaryConfig
96
114
  pg_basebackup?: BinaryConfig
115
+ // MySQL tools
116
+ mysql?: BinaryConfig
117
+ mysqldump?: BinaryConfig
118
+ mysqlpump?: BinaryConfig
119
+ mysqld?: BinaryConfig
120
+ mysqladmin?: BinaryConfig
97
121
  }
98
122
  // Default settings
99
123
  defaults?: {
100
- engine?: string
124
+ engine?: EngineName
101
125
  version?: string
102
126
  port?: number
103
127
  }