spindb 0.4.1 → 0.5.3
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/README.md +207 -101
- package/cli/commands/clone.ts +3 -1
- package/cli/commands/connect.ts +54 -24
- package/cli/commands/create.ts +309 -189
- package/cli/commands/delete.ts +3 -1
- package/cli/commands/deps.ts +19 -4
- package/cli/commands/edit.ts +245 -0
- package/cli/commands/engines.ts +434 -0
- package/cli/commands/info.ts +279 -0
- package/cli/commands/list.ts +14 -3
- package/cli/commands/menu.ts +510 -198
- package/cli/commands/restore.ts +66 -43
- package/cli/commands/start.ts +50 -19
- package/cli/commands/stop.ts +3 -1
- package/cli/commands/url.ts +79 -0
- package/cli/index.ts +9 -3
- package/cli/ui/prompts.ts +99 -34
- package/config/defaults.ts +40 -15
- package/config/engine-defaults.ts +107 -0
- package/config/os-dependencies.ts +119 -124
- package/config/paths.ts +82 -56
- package/core/binary-manager.ts +44 -6
- package/core/config-manager.ts +17 -5
- package/core/container-manager.ts +124 -60
- package/core/dependency-manager.ts +9 -15
- package/core/error-handler.ts +336 -0
- package/core/platform-service.ts +634 -0
- package/core/port-manager.ts +51 -32
- package/core/process-manager.ts +26 -8
- package/core/start-with-retry.ts +167 -0
- package/core/transaction-manager.ts +170 -0
- package/engines/index.ts +7 -2
- package/engines/mysql/binary-detection.ts +325 -0
- package/engines/mysql/index.ts +808 -0
- package/engines/mysql/restore.ts +257 -0
- package/engines/mysql/version-validator.ts +373 -0
- package/{core/postgres-binary-manager.ts → engines/postgresql/binary-manager.ts} +63 -23
- package/engines/postgresql/binary-urls.ts +5 -3
- package/engines/postgresql/index.ts +17 -9
- package/engines/postgresql/restore.ts +54 -5
- package/engines/postgresql/version-validator.ts +262 -0
- package/package.json +9 -3
- package/types/index.ts +29 -5
- package/cli/commands/postgres-tools.ts +0 -216
package/types/index.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export type ContainerConfig = {
|
|
2
2
|
name: string
|
|
3
|
-
engine:
|
|
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 =
|
|
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?:
|
|
124
|
+
engine?: EngineName
|
|
101
125
|
version?: string
|
|
102
126
|
port?: number
|
|
103
127
|
}
|
|
@@ -1,216 +0,0 @@
|
|
|
1
|
-
import { Command } from 'commander'
|
|
2
|
-
import chalk from 'chalk'
|
|
3
|
-
import { header, success, warning, error } from '../ui/theme'
|
|
4
|
-
import {
|
|
5
|
-
detectPackageManager,
|
|
6
|
-
getBinaryInfo,
|
|
7
|
-
installPostgresBinaries,
|
|
8
|
-
updatePostgresBinaries,
|
|
9
|
-
ensurePostgresBinary,
|
|
10
|
-
getPostgresVersion,
|
|
11
|
-
} from '../../core/postgres-binary-manager'
|
|
12
|
-
|
|
13
|
-
export const postgresToolsCommand = new Command('postgres-tools').description(
|
|
14
|
-
'Manage PostgreSQL client tools (psql, pg_restore, etc.)',
|
|
15
|
-
)
|
|
16
|
-
|
|
17
|
-
postgresToolsCommand
|
|
18
|
-
.command('check')
|
|
19
|
-
.description('Check PostgreSQL client tools status')
|
|
20
|
-
.option('--dump <path>', 'Check compatibility with a specific dump file')
|
|
21
|
-
.action(async (options: { dump?: string }) => {
|
|
22
|
-
console.log(header('PostgreSQL Tools Status'))
|
|
23
|
-
console.log()
|
|
24
|
-
|
|
25
|
-
// Check package manager
|
|
26
|
-
const packageManager = await detectPackageManager()
|
|
27
|
-
if (packageManager) {
|
|
28
|
-
console.log(success(`Package Manager: ${packageManager.name}`))
|
|
29
|
-
} else {
|
|
30
|
-
console.log(warning('Package Manager: Not found'))
|
|
31
|
-
}
|
|
32
|
-
console.log()
|
|
33
|
-
|
|
34
|
-
// Check binaries
|
|
35
|
-
const binaries = ['pg_restore', 'psql'] as const
|
|
36
|
-
|
|
37
|
-
for (const binary of binaries) {
|
|
38
|
-
const info = await getBinaryInfo(binary, options.dump)
|
|
39
|
-
|
|
40
|
-
if (!info) {
|
|
41
|
-
console.log(error(`${binary}: Not found`))
|
|
42
|
-
} else {
|
|
43
|
-
console.log(`${chalk.cyan(binary)}:`)
|
|
44
|
-
console.log(` Version: ${info.version}`)
|
|
45
|
-
console.log(` Path: ${info.path}`)
|
|
46
|
-
console.log(` Package Manager: ${info.packageManager || 'Unknown'}`)
|
|
47
|
-
|
|
48
|
-
if (options.dump) {
|
|
49
|
-
console.log(
|
|
50
|
-
` Compatible: ${info.isCompatible ? chalk.green('Yes') : chalk.red('No')}`,
|
|
51
|
-
)
|
|
52
|
-
if (info.requiredVersion) {
|
|
53
|
-
console.log(` Required Version: ${info.requiredVersion}+`)
|
|
54
|
-
}
|
|
55
|
-
} else {
|
|
56
|
-
console.log(` Status: ${chalk.green('Available')}`)
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
console.log()
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
if (options.dump) {
|
|
63
|
-
const binaryCheck = await ensurePostgresBinary(
|
|
64
|
-
'pg_restore',
|
|
65
|
-
options.dump,
|
|
66
|
-
{
|
|
67
|
-
autoInstall: false,
|
|
68
|
-
autoUpdate: false,
|
|
69
|
-
},
|
|
70
|
-
)
|
|
71
|
-
|
|
72
|
-
if (!binaryCheck.success) {
|
|
73
|
-
console.log(warning('Compatibility Issues Detected:'))
|
|
74
|
-
if (binaryCheck.action === 'install_required') {
|
|
75
|
-
console.log(error(' pg_restore is not installed'))
|
|
76
|
-
} else if (binaryCheck.action === 'update_required') {
|
|
77
|
-
console.log(
|
|
78
|
-
error(' pg_restore version is incompatible with the dump file'),
|
|
79
|
-
)
|
|
80
|
-
}
|
|
81
|
-
console.log()
|
|
82
|
-
console.log(chalk.gray('Run: spindb postgres-tools install --auto-fix'))
|
|
83
|
-
console.log(chalk.gray('Or: spindb postgres-tools update --auto-fix'))
|
|
84
|
-
} else {
|
|
85
|
-
console.log(success('All tools are compatible with the dump file'))
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
})
|
|
89
|
-
|
|
90
|
-
postgresToolsCommand
|
|
91
|
-
.command('install')
|
|
92
|
-
.description('Install PostgreSQL client tools')
|
|
93
|
-
.option('--auto-fix', 'Install and automatically fix compatibility issues')
|
|
94
|
-
.action(async (options: { autoFix?: boolean }) => {
|
|
95
|
-
console.log(header('Installing PostgreSQL Client Tools'))
|
|
96
|
-
console.log()
|
|
97
|
-
|
|
98
|
-
const installSuccess = await installPostgresBinaries()
|
|
99
|
-
|
|
100
|
-
if (installSuccess) {
|
|
101
|
-
console.log()
|
|
102
|
-
console.log(success('Installation completed successfully'))
|
|
103
|
-
|
|
104
|
-
if (options.autoFix) {
|
|
105
|
-
console.log()
|
|
106
|
-
console.log(chalk.gray('Verifying installation...'))
|
|
107
|
-
|
|
108
|
-
const pgRestoreCheck = await ensurePostgresBinary('pg_restore')
|
|
109
|
-
const psqlCheck = await ensurePostgresBinary('psql')
|
|
110
|
-
|
|
111
|
-
if (pgRestoreCheck.success && psqlCheck.success) {
|
|
112
|
-
console.log(success('All tools are working correctly'))
|
|
113
|
-
} else {
|
|
114
|
-
console.log(warning('Some tools may need additional configuration'))
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
})
|
|
119
|
-
|
|
120
|
-
postgresToolsCommand
|
|
121
|
-
.command('update')
|
|
122
|
-
.description('Update PostgreSQL client tools')
|
|
123
|
-
.option('--auto-fix', 'Update and automatically fix compatibility issues')
|
|
124
|
-
.action(async (options: { autoFix?: boolean }) => {
|
|
125
|
-
console.log(header('Updating PostgreSQL Client Tools'))
|
|
126
|
-
console.log()
|
|
127
|
-
|
|
128
|
-
const updateSuccess = await updatePostgresBinaries()
|
|
129
|
-
|
|
130
|
-
if (updateSuccess) {
|
|
131
|
-
console.log()
|
|
132
|
-
console.log(success('Update completed successfully'))
|
|
133
|
-
|
|
134
|
-
if (options.autoFix) {
|
|
135
|
-
console.log()
|
|
136
|
-
console.log(chalk.gray('Verifying update...'))
|
|
137
|
-
|
|
138
|
-
const pgRestoreVersion = await getPostgresVersion('pg_restore')
|
|
139
|
-
const psqlVersion = await getPostgresVersion('psql')
|
|
140
|
-
|
|
141
|
-
if (pgRestoreVersion && psqlVersion) {
|
|
142
|
-
console.log(success(`pg_restore: ${pgRestoreVersion}`))
|
|
143
|
-
console.log(success(`psql: ${psqlVersion}`))
|
|
144
|
-
} else {
|
|
145
|
-
console.log(warning('Could not verify versions'))
|
|
146
|
-
}
|
|
147
|
-
}
|
|
148
|
-
}
|
|
149
|
-
})
|
|
150
|
-
|
|
151
|
-
postgresToolsCommand
|
|
152
|
-
.command('fix')
|
|
153
|
-
.description('Fix compatibility issues with a dump file')
|
|
154
|
-
.argument('<dump-path>', 'Path to the dump file')
|
|
155
|
-
.action(async (dumpPath: string) => {
|
|
156
|
-
console.log(header('Fixing Compatibility Issues'))
|
|
157
|
-
console.log()
|
|
158
|
-
console.log(chalk.gray(`Dump file: ${dumpPath}`))
|
|
159
|
-
console.log()
|
|
160
|
-
|
|
161
|
-
const binaryCheck = await ensurePostgresBinary('pg_restore', dumpPath, {
|
|
162
|
-
autoInstall: true,
|
|
163
|
-
autoUpdate: true,
|
|
164
|
-
})
|
|
165
|
-
|
|
166
|
-
if (!binaryCheck.success) {
|
|
167
|
-
console.log(error('Failed to fix compatibility issues automatically'))
|
|
168
|
-
console.log()
|
|
169
|
-
|
|
170
|
-
if (
|
|
171
|
-
binaryCheck.action === 'install_required' ||
|
|
172
|
-
binaryCheck.action === 'install_failed'
|
|
173
|
-
) {
|
|
174
|
-
console.log(warning('Manual installation required:'))
|
|
175
|
-
console.log(
|
|
176
|
-
chalk.gray(' macOS: brew install libpq && brew link --force libpq'),
|
|
177
|
-
)
|
|
178
|
-
console.log(
|
|
179
|
-
chalk.gray(' Ubuntu/Debian: sudo apt install postgresql-client'),
|
|
180
|
-
)
|
|
181
|
-
console.log(
|
|
182
|
-
chalk.gray(' CentOS/RHEL/Fedora: sudo yum install postgresql'),
|
|
183
|
-
)
|
|
184
|
-
} else if (
|
|
185
|
-
binaryCheck.action === 'update_required' ||
|
|
186
|
-
binaryCheck.action === 'update_failed'
|
|
187
|
-
) {
|
|
188
|
-
console.log(warning('Manual update required:'))
|
|
189
|
-
console.log(
|
|
190
|
-
chalk.gray(' macOS: brew upgrade libpq && brew link --force libpq'),
|
|
191
|
-
)
|
|
192
|
-
console.log(
|
|
193
|
-
chalk.gray(
|
|
194
|
-
' Ubuntu/Debian: sudo apt update && sudo apt upgrade postgresql-client',
|
|
195
|
-
),
|
|
196
|
-
)
|
|
197
|
-
console.log(
|
|
198
|
-
chalk.gray(' CentOS/RHEL/Fedora: sudo yum update postgresql'),
|
|
199
|
-
)
|
|
200
|
-
}
|
|
201
|
-
|
|
202
|
-
process.exit(1)
|
|
203
|
-
}
|
|
204
|
-
|
|
205
|
-
console.log(success('Compatibility issues fixed successfully'))
|
|
206
|
-
|
|
207
|
-
if (binaryCheck.info) {
|
|
208
|
-
console.log()
|
|
209
|
-
console.log(chalk.gray('Current status:'))
|
|
210
|
-
console.log(` pg_restore version: ${binaryCheck.info.version}`)
|
|
211
|
-
console.log(` Path: ${binaryCheck.info.path}`)
|
|
212
|
-
if (binaryCheck.info.requiredVersion) {
|
|
213
|
-
console.log(` Required version: ${binaryCheck.info.requiredVersion}+`)
|
|
214
|
-
}
|
|
215
|
-
}
|
|
216
|
-
})
|