spindb 0.5.2 β 0.5.4
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 +188 -9
- package/cli/commands/connect.ts +334 -105
- package/cli/commands/create.ts +106 -67
- 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 +1 -1
- package/cli/commands/menu.ts +664 -167
- package/cli/commands/restore.ts +11 -25
- package/cli/commands/start.ts +25 -20
- package/cli/commands/url.ts +79 -0
- package/cli/index.ts +9 -3
- package/cli/ui/prompts.ts +20 -12
- package/cli/ui/theme.ts +1 -1
- package/config/engine-defaults.ts +24 -1
- package/config/os-dependencies.ts +151 -113
- package/config/paths.ts +7 -36
- package/core/binary-manager.ts +12 -6
- package/core/config-manager.ts +17 -5
- package/core/dependency-manager.ts +144 -15
- package/core/error-handler.ts +336 -0
- package/core/platform-service.ts +634 -0
- package/core/port-manager.ts +11 -3
- package/core/process-manager.ts +12 -2
- package/core/start-with-retry.ts +167 -0
- package/core/transaction-manager.ts +170 -0
- package/engines/mysql/binary-detection.ts +177 -100
- package/engines/mysql/index.ts +240 -131
- 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 +35 -4
- package/engines/postgresql/restore.ts +54 -5
- package/engines/postgresql/version-validator.ts +262 -0
- package/package.json +6 -2
- package/cli/commands/postgres-tools.ts +0 -216
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# SpinDB
|
|
2
2
|
|
|
3
|
-
Spin up local PostgreSQL and MySQL databases without Docker. A lightweight alternative to DBngin.
|
|
3
|
+
Spin up local PostgreSQL and MySQL databases without Docker. A lightweight alternative to DBngin and Postgres.app.
|
|
4
4
|
|
|
5
5
|
## Features
|
|
6
6
|
|
|
@@ -45,12 +45,17 @@ spindb connect mydb
|
|
|
45
45
|
| `spindb` | Open interactive menu |
|
|
46
46
|
| `spindb create [name]` | Create a new database container |
|
|
47
47
|
| `spindb list` | List all containers |
|
|
48
|
+
| `spindb info [name]` | Show container details (or all containers) |
|
|
48
49
|
| `spindb start [name]` | Start a container |
|
|
49
50
|
| `spindb stop [name]` | Stop a container |
|
|
50
|
-
| `spindb connect [name]` | Connect with psql/mysql shell |
|
|
51
|
+
| `spindb connect [name]` | Connect with psql/mysql shell (`--pgcli`/`--mycli` for enhanced) |
|
|
52
|
+
| `spindb url [name]` | Output connection string |
|
|
53
|
+
| `spindb edit [name]` | Edit container properties (rename, port) |
|
|
51
54
|
| `spindb restore [name] [backup]` | Restore a backup file |
|
|
52
55
|
| `spindb clone [source] [target]` | Clone a container |
|
|
53
56
|
| `spindb delete [name]` | Delete a container |
|
|
57
|
+
| `spindb engines` | List installed database engines |
|
|
58
|
+
| `spindb engines delete` | Delete an installed engine version |
|
|
54
59
|
| `spindb config show` | Show configuration |
|
|
55
60
|
| `spindb config detect` | Auto-detect database tools |
|
|
56
61
|
| `spindb deps check` | Check status of client tools |
|
|
@@ -60,16 +65,27 @@ spindb connect mydb
|
|
|
60
65
|
|
|
61
66
|
### PostgreSQL π
|
|
62
67
|
|
|
63
|
-
- Downloads binaries from [zonky.io](https://github.com/zonkyio/embedded-postgres-binaries)
|
|
68
|
+
- Downloads server binaries from [zonky.io embedded-postgres-binaries](https://github.com/zonkyio/embedded-postgres-binaries)
|
|
64
69
|
- Versions: 14, 15, 16, 17
|
|
65
70
|
- Requires system client tools (psql, pg_dump, pg_restore) for some operations
|
|
66
71
|
|
|
72
|
+
**Why zonky.io?** Zonky.io provides pre-compiled PostgreSQL server binaries for multiple platforms (macOS, Linux) and architectures (x64, ARM64) hosted on Maven Central. This allows SpinDB to download and run PostgreSQL without requiring a full system installation. The binaries are extracted from official PostgreSQL distributions and repackaged for easy embedding in applications.
|
|
73
|
+
|
|
67
74
|
### MySQL π¬
|
|
68
75
|
|
|
69
76
|
- Uses system-installed MySQL (via Homebrew, apt, etc.)
|
|
70
77
|
- Version determined by system installation
|
|
71
78
|
- Requires: mysqld, mysql, mysqldump, mysqladmin
|
|
72
79
|
|
|
80
|
+
**Linux Note:** On Linux systems, MariaDB is commonly used as a drop-in replacement for MySQL. SpinDB fully supports MariaDB and will automatically detect it. When MariaDB is installed, the `mysql`, `mysqld`, and `mysqldump` commands work the same way. Install with:
|
|
81
|
+
```bash
|
|
82
|
+
# Ubuntu/Debian
|
|
83
|
+
sudo apt install mariadb-server
|
|
84
|
+
|
|
85
|
+
# Arch
|
|
86
|
+
sudo pacman -S mariadb
|
|
87
|
+
```
|
|
88
|
+
|
|
73
89
|
## How It Works
|
|
74
90
|
|
|
75
91
|
Data is stored in `~/.spindb/`:
|
|
@@ -91,6 +107,44 @@ Data is stored in `~/.spindb/`:
|
|
|
91
107
|
βββ config.json
|
|
92
108
|
```
|
|
93
109
|
|
|
110
|
+
## How Data Persists
|
|
111
|
+
|
|
112
|
+
SpinDB runs database servers as **native processes** on your machineβno Docker or virtualization involved. When you start a container, SpinDB launches the actual `postgres` or `mysqld` binary, which listens on localhost at your configured port.
|
|
113
|
+
|
|
114
|
+
### What happens when you start a container
|
|
115
|
+
|
|
116
|
+
1. SpinDB runs the database server binary (e.g., `pg_ctl start`)
|
|
117
|
+
2. The server binds to `127.0.0.1` on your configured port
|
|
118
|
+
3. A **PID file** is created to track the running process
|
|
119
|
+
4. Logs are written to the container's log file
|
|
120
|
+
|
|
121
|
+
### What happens when you stop a container
|
|
122
|
+
|
|
123
|
+
1. SpinDB sends a shutdown signal to the database process
|
|
124
|
+
2. The server flushes any pending writes to disk
|
|
125
|
+
3. The **PID file is removed**
|
|
126
|
+
4. Your data remains safely in the data directory
|
|
127
|
+
|
|
128
|
+
### Where your data lives
|
|
129
|
+
|
|
130
|
+
All database files persist in the container's `data/` directory:
|
|
131
|
+
|
|
132
|
+
```
|
|
133
|
+
~/.spindb/containers/postgresql/mydb/
|
|
134
|
+
βββ container.json # Container configuration (port, version, etc.)
|
|
135
|
+
βββ postgres.log # Server logs
|
|
136
|
+
βββ data/ # β Your actual database files live here
|
|
137
|
+
βββ base/ # Table data
|
|
138
|
+
βββ pg_wal/ # Transaction logs
|
|
139
|
+
βββ ...
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
The `data/` directory is a standard PostgreSQL/MySQL data directory. Stopping and starting a container doesn't affect your dataβonly the PID file changes.
|
|
143
|
+
|
|
144
|
+
### How SpinDB knows if a container is running
|
|
145
|
+
|
|
146
|
+
SpinDB checks for the PID file and verifies the process is still alive. No PID file (or dead process) = stopped container.
|
|
147
|
+
|
|
94
148
|
## Client Tools
|
|
95
149
|
|
|
96
150
|
SpinDB bundles the PostgreSQL **server** but not client tools. For `connect` and `restore` commands, you need client tools installed.
|
|
@@ -109,12 +163,14 @@ spindb deps install --engine postgresql
|
|
|
109
163
|
spindb deps install --engine mysql
|
|
110
164
|
```
|
|
111
165
|
|
|
166
|
+
**Note:** On Linux, package managers (apt, pacman, dnf) require `sudo` privileges. You may be prompted for your password when installing dependencies.
|
|
167
|
+
|
|
112
168
|
### Manual Installation
|
|
113
169
|
|
|
114
170
|
#### PostgreSQL
|
|
115
171
|
|
|
116
172
|
```bash
|
|
117
|
-
# macOS (Homebrew)
|
|
173
|
+
# macOS (Homebrew) - use the latest PostgreSQL version (currently 17)
|
|
118
174
|
brew install postgresql@17
|
|
119
175
|
brew link --overwrite postgresql@17
|
|
120
176
|
|
|
@@ -187,6 +243,18 @@ spindb start test-branch
|
|
|
187
243
|
# Interactive shell (auto-detects engine)
|
|
188
244
|
spindb connect mydb
|
|
189
245
|
|
|
246
|
+
# Use pgcli/mycli for enhanced shell (dropdown auto-completion)
|
|
247
|
+
spindb connect mydb --pgcli # PostgreSQL
|
|
248
|
+
spindb connect mydb --mycli # MySQL
|
|
249
|
+
|
|
250
|
+
# Install pgcli/mycli and connect in one command
|
|
251
|
+
spindb connect mydb --install-pgcli
|
|
252
|
+
spindb connect mydb --install-mycli
|
|
253
|
+
|
|
254
|
+
# Use usql for universal SQL client (works with both engines)
|
|
255
|
+
spindb connect mydb --tui
|
|
256
|
+
spindb connect mydb --install-tui
|
|
257
|
+
|
|
190
258
|
# Or use connection string directly
|
|
191
259
|
psql postgresql://postgres@localhost:5432/mydb
|
|
192
260
|
mysql -u root -h 127.0.0.1 -P 3306 mydb
|
|
@@ -194,15 +262,59 @@ mysql -u root -h 127.0.0.1 -P 3306 mydb
|
|
|
194
262
|
|
|
195
263
|
### Manage installed engines
|
|
196
264
|
|
|
197
|
-
|
|
265
|
+
View installed engines with disk usage (PostgreSQL) and system detection (MySQL):
|
|
266
|
+
|
|
267
|
+
```bash
|
|
268
|
+
spindb engines
|
|
269
|
+
```
|
|
198
270
|
|
|
199
271
|
```
|
|
200
|
-
ENGINE
|
|
272
|
+
ENGINE VERSION SOURCE SIZE
|
|
201
273
|
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
|
202
|
-
postgresql
|
|
203
|
-
postgresql
|
|
274
|
+
π postgresql 17.7 darwin-arm64 45.2 MB
|
|
275
|
+
π postgresql 16.8 darwin-arm64 44.8 MB
|
|
276
|
+
π¬ mysql 8.0.35 system (system-installed)
|
|
204
277
|
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
|
205
|
-
|
|
278
|
+
|
|
279
|
+
PostgreSQL: 2 version(s), 90.0 MB
|
|
280
|
+
MySQL: system-installed at /opt/homebrew/bin/mysqld
|
|
281
|
+
```
|
|
282
|
+
|
|
283
|
+
Delete unused PostgreSQL versions to free disk space:
|
|
284
|
+
|
|
285
|
+
```bash
|
|
286
|
+
spindb engines delete postgresql 16
|
|
287
|
+
```
|
|
288
|
+
|
|
289
|
+
### Container info and connection strings
|
|
290
|
+
|
|
291
|
+
```bash
|
|
292
|
+
# View all container details
|
|
293
|
+
spindb info
|
|
294
|
+
|
|
295
|
+
# View specific container
|
|
296
|
+
spindb info mydb
|
|
297
|
+
|
|
298
|
+
# Get connection string for scripting
|
|
299
|
+
spindb url mydb
|
|
300
|
+
export DATABASE_URL=$(spindb url mydb)
|
|
301
|
+
psql $(spindb url mydb)
|
|
302
|
+
|
|
303
|
+
# Copy connection string to clipboard
|
|
304
|
+
spindb url mydb --copy
|
|
305
|
+
```
|
|
306
|
+
|
|
307
|
+
### Edit containers
|
|
308
|
+
|
|
309
|
+
```bash
|
|
310
|
+
# Rename a container (must be stopped)
|
|
311
|
+
spindb edit mydb --name newname
|
|
312
|
+
|
|
313
|
+
# Change port
|
|
314
|
+
spindb edit mydb --port 5433
|
|
315
|
+
|
|
316
|
+
# Interactive mode
|
|
317
|
+
spindb edit mydb
|
|
206
318
|
```
|
|
207
319
|
|
|
208
320
|
## Running Tests
|
|
@@ -251,6 +363,73 @@ cat ~/.spindb/containers/mysql/mydb/mysql.log
|
|
|
251
363
|
rm -rf ~/.spindb
|
|
252
364
|
```
|
|
253
365
|
|
|
366
|
+
## Project Structure
|
|
367
|
+
|
|
368
|
+
```
|
|
369
|
+
spindb/
|
|
370
|
+
βββ bin.ts # Entry point (#!/usr/bin/env tsx)
|
|
371
|
+
βββ cli/
|
|
372
|
+
β βββ index.ts # Commander setup, routes to commands
|
|
373
|
+
β βββ commands/ # CLI commands
|
|
374
|
+
β β βββ menu.ts # Interactive arrow-key menu
|
|
375
|
+
β β βββ create.ts # Create container command
|
|
376
|
+
β β βββ delete.ts # Delete container command
|
|
377
|
+
β β βββ ... # Other commands
|
|
378
|
+
β βββ ui/
|
|
379
|
+
β βββ prompts.ts # Inquirer prompts
|
|
380
|
+
β βββ spinner.ts # Ora spinner helpers
|
|
381
|
+
β βββ theme.ts # Chalk color theme
|
|
382
|
+
βββ core/
|
|
383
|
+
β βββ binary-manager.ts # Downloads PostgreSQL from zonky.io
|
|
384
|
+
β βββ config-manager.ts # Manages ~/.spindb/config.json
|
|
385
|
+
β βββ container-manager.ts # CRUD for containers
|
|
386
|
+
β βββ port-manager.ts # Port availability checking
|
|
387
|
+
β βββ process-manager.ts # Process start/stop wrapper
|
|
388
|
+
β βββ dependency-manager.ts # Client tool detection
|
|
389
|
+
β βββ error-handler.ts # Centralized error handling
|
|
390
|
+
β βββ transaction-manager.ts # Rollback support for operations
|
|
391
|
+
βββ config/
|
|
392
|
+
β βββ paths.ts # ~/.spindb/ path definitions
|
|
393
|
+
β βββ defaults.ts # Default values, platform mappings
|
|
394
|
+
β βββ os-dependencies.ts # OS-specific dependency definitions
|
|
395
|
+
βββ engines/
|
|
396
|
+
β βββ base-engine.ts # Abstract base class
|
|
397
|
+
β βββ index.ts # Engine registry
|
|
398
|
+
β βββ postgresql/
|
|
399
|
+
β β βββ index.ts # PostgreSQL engine implementation
|
|
400
|
+
β β βββ binary-urls.ts # Zonky.io URL builder
|
|
401
|
+
β β βββ restore.ts # Backup detection and restore
|
|
402
|
+
β β βββ version-validator.ts # Version compatibility checks
|
|
403
|
+
β βββ mysql/
|
|
404
|
+
β βββ index.ts # MySQL engine implementation
|
|
405
|
+
β βββ binary-detection.ts # MySQL binary path detection
|
|
406
|
+
β βββ restore.ts # Backup detection and restore
|
|
407
|
+
β βββ version-validator.ts # Version compatibility checks
|
|
408
|
+
βββ types/
|
|
409
|
+
β βββ index.ts # TypeScript interfaces
|
|
410
|
+
βββ tests/
|
|
411
|
+
βββ unit/ # Unit tests
|
|
412
|
+
βββ integration/ # Integration tests
|
|
413
|
+
βββ fixtures/ # Test data
|
|
414
|
+
βββ postgresql/
|
|
415
|
+
β βββ seeds/
|
|
416
|
+
βββ mysql/
|
|
417
|
+
βββ seeds/
|
|
418
|
+
```
|
|
419
|
+
|
|
420
|
+
## Contributing
|
|
421
|
+
|
|
422
|
+
### Version Updates
|
|
423
|
+
|
|
424
|
+
SpinDB uses versioned PostgreSQL packages from Homebrew (e.g., `postgresql@17`). When new major versions are released:
|
|
425
|
+
|
|
426
|
+
1. Check [PostgreSQL releases](https://www.postgresql.org/docs/release/) and [Homebrew formulae](https://formulae.brew.sh/formula/postgresql)
|
|
427
|
+
2. Update `config/engine-defaults.ts`:
|
|
428
|
+
- Change `latestVersion` to the new version
|
|
429
|
+
- Add the new version to `supportedVersions`
|
|
430
|
+
|
|
431
|
+
See `CLAUDE.md` for detailed maintenance instructions.
|
|
432
|
+
|
|
254
433
|
## License
|
|
255
434
|
|
|
256
435
|
MIT
|