spindb 0.5.2 → 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.
Files changed (36) hide show
  1. package/README.md +137 -8
  2. package/cli/commands/connect.ts +8 -4
  3. package/cli/commands/create.ts +106 -67
  4. package/cli/commands/deps.ts +19 -4
  5. package/cli/commands/edit.ts +245 -0
  6. package/cli/commands/engines.ts +434 -0
  7. package/cli/commands/info.ts +279 -0
  8. package/cli/commands/menu.ts +408 -153
  9. package/cli/commands/restore.ts +10 -24
  10. package/cli/commands/start.ts +25 -20
  11. package/cli/commands/url.ts +79 -0
  12. package/cli/index.ts +9 -3
  13. package/cli/ui/prompts.ts +8 -6
  14. package/config/engine-defaults.ts +24 -1
  15. package/config/os-dependencies.ts +59 -113
  16. package/config/paths.ts +7 -36
  17. package/core/binary-manager.ts +19 -6
  18. package/core/config-manager.ts +17 -5
  19. package/core/dependency-manager.ts +9 -15
  20. package/core/error-handler.ts +336 -0
  21. package/core/platform-service.ts +634 -0
  22. package/core/port-manager.ts +11 -3
  23. package/core/process-manager.ts +12 -2
  24. package/core/start-with-retry.ts +167 -0
  25. package/core/transaction-manager.ts +170 -0
  26. package/engines/mysql/binary-detection.ts +177 -100
  27. package/engines/mysql/index.ts +240 -131
  28. package/engines/mysql/restore.ts +257 -0
  29. package/engines/mysql/version-validator.ts +373 -0
  30. package/{core/postgres-binary-manager.ts → engines/postgresql/binary-manager.ts} +63 -23
  31. package/engines/postgresql/binary-urls.ts +5 -3
  32. package/engines/postgresql/index.ts +4 -3
  33. package/engines/postgresql/restore.ts +54 -5
  34. package/engines/postgresql/version-validator.ts +262 -0
  35. package/package.json +6 -2
  36. package/cli/commands/postgres-tools.ts +0 -216
@@ -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
- })