spindb 0.6.0 → 0.7.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 (38) hide show
  1. package/README.md +421 -294
  2. package/cli/commands/config.ts +7 -1
  3. package/cli/commands/connect.ts +1 -0
  4. package/cli/commands/create.ts +7 -7
  5. package/cli/commands/edit.ts +10 -0
  6. package/cli/commands/engines.ts +10 -188
  7. package/cli/commands/info.ts +7 -14
  8. package/cli/commands/list.ts +2 -9
  9. package/cli/commands/logs.ts +130 -0
  10. package/cli/commands/menu/backup-handlers.ts +798 -0
  11. package/cli/commands/menu/container-handlers.ts +832 -0
  12. package/cli/commands/menu/engine-handlers.ts +382 -0
  13. package/cli/commands/menu/index.ts +184 -0
  14. package/cli/commands/menu/shared.ts +26 -0
  15. package/cli/commands/menu/shell-handlers.ts +331 -0
  16. package/cli/commands/menu/sql-handlers.ts +197 -0
  17. package/cli/commands/menu/update-handlers.ts +94 -0
  18. package/cli/commands/run.ts +150 -0
  19. package/cli/commands/url.ts +19 -5
  20. package/cli/constants.ts +10 -0
  21. package/cli/helpers.ts +152 -0
  22. package/cli/index.ts +5 -2
  23. package/cli/ui/prompts.ts +3 -11
  24. package/config/defaults.ts +5 -29
  25. package/core/binary-manager.ts +2 -2
  26. package/core/container-manager.ts +3 -2
  27. package/core/dependency-manager.ts +0 -163
  28. package/core/error-handler.ts +0 -26
  29. package/core/platform-service.ts +60 -40
  30. package/core/start-with-retry.ts +3 -28
  31. package/core/transaction-manager.ts +0 -8
  32. package/engines/base-engine.ts +10 -0
  33. package/engines/mysql/binary-detection.ts +1 -1
  34. package/engines/mysql/index.ts +78 -2
  35. package/engines/postgresql/index.ts +49 -0
  36. package/package.json +1 -1
  37. package/types/index.ts +7 -4
  38. package/cli/commands/menu.ts +0 -2670
package/README.md CHANGED
@@ -1,33 +1,103 @@
1
1
  # SpinDB
2
2
 
3
- Spin up local PostgreSQL and MySQL databases without Docker. A lightweight alternative to DBngin and Postgres.app.
3
+ [![npm version](https://img.shields.io/npm/v/spindb.svg)](https://www.npmjs.com/package/spindb)
4
+ [![License: PolyForm Noncommercial](https://img.shields.io/badge/License-PolyForm%20Noncommercial-blue.svg)](LICENSE)
5
+ [![Platform: macOS | Linux](https://img.shields.io/badge/Platform-macOS%20%7C%20Linux-lightgrey.svg)](#supported-platforms)
4
6
 
5
- ## Features
7
+ **Local databases without the Docker baggage.**
6
8
 
7
- - **No Docker required** - Downloads PostgreSQL binaries directly, uses system MySQL
8
- - **Multiple engines** - PostgreSQL and MySQL support
9
- - **Multiple containers** - Run multiple isolated database instances on different ports
10
- - **Interactive menu** - Arrow-key navigation for all operations
11
- - **Auto port management** - Automatically finds available ports
12
- - **Clone containers** - Duplicate databases with all data
13
- - **Backup & restore** - Create and restore pg_dump/mysqldump backups
14
- - **Custom database names** - Specify database name separate from container name
15
- - **Engine management** - View installed PostgreSQL versions and free up disk space
16
- - **Dynamic version selection** - Fetches available PostgreSQL versions from Maven Central
9
+ Spin up PostgreSQL and MySQL instances for local development. No Docker daemon, no container networking, no volume mounts. Just databases running on localhost, ready in seconds.
10
+
11
+ ---
12
+
13
+ ## Why SpinDB?
14
+
15
+ Docker is great for production parity and complex multi-service setups. But for local development databases, it's often overkill:
16
+
17
+ - **Resource overhead** - Docker Desktop runs a Linux VM on macOS/Windows
18
+ - **Complexity** - Volumes, networks, compose files for a single database
19
+ - **Startup time** - Container initialization vs native process launch
20
+ - **Licensing** - Docker Desktop requires a paid subscription for larger organizations
21
+
22
+ Sometimes you just want PostgreSQL on `localhost:5432` without the ceremony.
23
+
24
+ SpinDB runs databases as native processes with isolated data directories. No VM, no daemon, no container networking. Just databases.
25
+
26
+ ### SpinDB vs Alternatives
27
+
28
+ | Feature | SpinDB | Docker | DBngin | Postgres.app |
29
+ |---------|--------|--------|--------|--------------|
30
+ | No Docker required | ✅ | ❌ | ✅ | ✅ |
31
+ | Multiple DB engines | ✅ | ✅ | ✅ | ❌ |
32
+ | CLI-first | ✅ | ✅ | ❌ | ❌ |
33
+ | Multiple versions | ✅ | ✅ | ✅ | ✅ |
34
+ | Clone databases | ✅ | Manual | ✅ | ❌ |
35
+ | Low resource usage | ✅ | ❌ | ✅ | ✅ |
36
+ | Linux support | ✅ | ✅ | ❌ | ❌ |
37
+ | Free | ✅ | ⚠️ | ✅ | ✅ |
38
+
39
+ ### How It Works
40
+
41
+ SpinDB uses the term "container" loosely—there's no Docker involved. When you create a container, SpinDB:
42
+
43
+ 1. Downloads the database server binary (or uses your system's installation)
44
+ 2. Creates an isolated data directory at `~/.spindb/containers/{engine}/{name}/`
45
+ 3. Runs the database as a native process on your machine
46
+
47
+ Each "container" is just:
48
+ - A configuration file (`container.json`)
49
+ - A data directory (`data/`)
50
+ - A log file (`postgres.log` or `mysql.log`)
51
+
52
+ Native processes mean instant startup and no virtualization overhead.
53
+
54
+ ---
55
+
56
+ ## The Interactive Menu
57
+
58
+ Most of the time, you don't need to remember commands. Just run:
59
+
60
+ ```bash
61
+ spindb
62
+ ```
63
+
64
+ You'll get an interactive menu with arrow-key navigation:
65
+
66
+ ```
67
+ ? What would you like to do?
68
+ ❯ Create a new container
69
+ Manage containers
70
+ View installed engines
71
+ Check dependencies
72
+ Settings
73
+ Exit
74
+ ```
75
+
76
+ **Everything in the menu is also available as a CLI command.** The menu is just a friendlier interface for the same operations. If you prefer typing commands or scripting, SpinDB has full CLI support.
77
+
78
+ ---
17
79
 
18
80
  ## Installation
19
81
 
82
+ SpinDB is distributed via npm. A global install is recommended so you can run `spindb` from anywhere.
83
+
84
+ We recommend [pnpm](https://pnpm.io/) as a faster, more disk-efficient alternative to npm.
85
+
20
86
  ```bash
21
- # Install globally (recommended)
87
+ # Using pnpm (recommended)
88
+ pnpm add -g spindb
89
+
90
+ # Using npm
22
91
  npm install -g spindb
23
92
 
24
- # Or run directly with pnpx (no install needed)
93
+ # Or run directly without installing
25
94
  pnpx spindb
95
+ npx spindb
26
96
  ```
27
97
 
28
98
  ### Updating
29
99
 
30
- SpinDB checks for updates automatically and will notify you when a new version is available:
100
+ SpinDB checks for updates automatically and notifies you when a new version is available.
31
101
 
32
102
  ```bash
33
103
  # Update to latest version
@@ -35,256 +105,261 @@ spindb self-update
35
105
 
36
106
  # Or check manually
37
107
  spindb version --check
108
+
109
+ # Disable automatic update checks
110
+ spindb config update-check off
38
111
  ```
39
112
 
113
+ ---
114
+
40
115
  ## Quick Start
41
116
 
42
117
  ```bash
43
- # Launch interactive menu
44
- spindb
118
+ # Create and start a PostgreSQL database
119
+ spindb create myapp
45
120
 
46
- # Or use commands directly
47
- spindb create mydb # PostgreSQL (default)
48
- spindb create mydb --engine mysql # MySQL
49
- spindb list
50
- spindb connect mydb
121
+ # Connect to it
122
+ spindb connect myapp
123
+
124
+ # You're in! Run some SQL:
125
+ # postgres=# CREATE TABLE users (id SERIAL PRIMARY KEY, name TEXT);
51
126
  ```
52
127
 
53
- ## Commands
128
+ That's it. Your database is running on `localhost:5432`, and your data persists in `~/.spindb/containers/postgresql/myapp/`.
54
129
 
55
- | Command | Description |
56
- |---------|-------------|
57
- | `spindb` | Open interactive menu |
58
- | `spindb create [name]` | Create a new database container |
59
- | `spindb list` | List all containers |
60
- | `spindb info [name]` | Show container details (or all containers) |
61
- | `spindb start [name]` | Start a container |
62
- | `spindb stop [name]` | Stop a container |
63
- | `spindb connect [name]` | Connect with psql/mysql shell (`--pgcli`/`--mycli` for enhanced) |
64
- | `spindb url [name]` | Output connection string |
65
- | `spindb edit [name]` | Edit container properties (rename, port) |
66
- | `spindb backup [name]` | Create a database backup |
67
- | `spindb restore [name] [backup]` | Restore a backup file |
68
- | `spindb clone [source] [target]` | Clone a container |
69
- | `spindb delete [name]` | Delete a container |
70
- | `spindb engines` | List installed database engines |
71
- | `spindb engines delete` | Delete an installed engine version |
72
- | `spindb config show` | Show configuration |
73
- | `spindb config detect` | Auto-detect database tools |
74
- | `spindb deps check` | Check status of client tools |
75
- | `spindb deps install` | Install missing client tools |
76
- | `spindb version` | Show current version |
77
- | `spindb version --check` | Check for available updates |
78
- | `spindb self-update` | Update to latest version |
79
- | `spindb config update-check [on\|off]` | Enable/disable update notifications |
80
-
81
- ## Supported Engines
82
-
83
- ### PostgreSQL 🐘
84
-
85
- - Downloads server binaries from [zonky.io embedded-postgres-binaries](https://github.com/zonkyio/embedded-postgres-binaries)
86
- - Versions: 14, 15, 16, 17
87
- - Requires system client tools (psql, pg_dump, pg_restore) for some operations
88
-
89
- **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.
90
-
91
- ### MySQL 🐬
92
-
93
- - Uses system-installed MySQL (via Homebrew, apt, etc.)
94
- - Version determined by system installation
95
- - Requires: mysqld, mysql, mysqldump, mysqladmin
96
-
97
- **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:
98
- ```bash
99
- # Ubuntu/Debian
100
- sudo apt install mariadb-server
130
+ ---
101
131
 
102
- # Arch
103
- sudo pacman -S mariadb
104
- ```
132
+ ## Database Engines
105
133
 
106
- ## How It Works
134
+ ### Supported Engines
107
135
 
108
- Data is stored in `~/.spindb/`:
109
- ```
110
- ~/.spindb/
111
- ├── bin/ # PostgreSQL server binaries
112
- │ └── postgresql-17-darwin-arm64/
113
- ├── containers/
114
- │ ├── postgresql/ # PostgreSQL containers
115
- │ │ └── mydb/
116
- │ │ ├── container.json
117
- │ │ ├── data/
118
- │ │ └── postgres.log
119
- │ └── mysql/ # MySQL containers
120
- │ └── mydb/
121
- │ ├── container.json
122
- │ ├── data/
123
- │ └── mysql.log
124
- └── config.json
125
- ```
136
+ #### PostgreSQL
126
137
 
127
- ## How Data Persists
138
+ | | |
139
+ |---|---|
140
+ | Versions | 14, 15, 16, 17 |
141
+ | Default port | 5432 |
142
+ | Default user | `postgres` |
143
+ | Binary source | [zonky.io](https://github.com/zonkyio/embedded-postgres-binaries) |
128
144
 
129
- 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.
145
+ SpinDB downloads PostgreSQL server binaries automatically. These are pre-compiled binaries from the zonky.io project, hosted on Maven Central. They're extracted from official PostgreSQL distributions and work on macOS and Linux (x64 and ARM64).
130
146
 
131
- ### What happens when you start a container
147
+ **Why download binaries instead of using system PostgreSQL?** You might want PostgreSQL 14 for one project and 17 for another. SpinDB lets you run different versions side-by-side without conflicts.
132
148
 
133
- 1. SpinDB runs the database server binary (e.g., `pg_ctl start`)
134
- 2. The server binds to `127.0.0.1` on your configured port
135
- 3. A **PID file** is created to track the running process
136
- 4. Logs are written to the container's log file
149
+ **Client tools required:** You still need `psql`, `pg_dump`, and `pg_restore` installed on your system for some operations (connecting, backups, restores). SpinDB can install these for you:
137
150
 
138
- ### What happens when you stop a container
151
+ ```bash
152
+ spindb deps install --engine postgresql
153
+ ```
139
154
 
140
- 1. SpinDB sends a shutdown signal to the database process
141
- 2. The server flushes any pending writes to disk
142
- 3. The **PID file is removed**
143
- 4. Your data remains safely in the data directory
155
+ #### MySQL
144
156
 
145
- ### Where your data lives
157
+ | | |
158
+ |---|---|
159
+ | Versions | Depends on system installation |
160
+ | Default port | 3306 |
161
+ | Default user | `root` |
162
+ | Binary source | System installation |
146
163
 
147
- All database files persist in the container's `data/` directory:
164
+ Unlike PostgreSQL, SpinDB uses your system's MySQL installation. This is because MySQL doesn't have a nice cross-platform binary distribution like zonky.io provides for PostgreSQL.
148
165
 
149
- ```
150
- ~/.spindb/containers/postgresql/mydb/
151
- ├── container.json # Container configuration (port, version, etc.)
152
- ├── postgres.log # Server logs
153
- └── data/ # ← Your actual database files live here
154
- ├── base/ # Table data
155
- ├── pg_wal/ # Transaction logs
156
- └── ...
166
+ ```bash
167
+ # macOS
168
+ brew install mysql
169
+
170
+ # Ubuntu/Debian
171
+ sudo apt install mysql-server
172
+
173
+ # Check if SpinDB can find MySQL
174
+ spindb deps check --engine mysql
157
175
  ```
158
176
 
159
- 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.
177
+ **Linux users:** MariaDB works as a drop-in replacement for MySQL. If you have MariaDB installed, SpinDB will detect and use it automatically. In a future release, MariaDB will be available as its own engine with support for MariaDB-specific features.
160
178
 
161
- ### How SpinDB knows if a container is running
179
+ ### Planned Engines
162
180
 
163
- SpinDB checks for the PID file and verifies the process is still alive. No PID file (or dead process) = stopped container.
181
+ | Engine | Type | Status |
182
+ |--------|------|--------|
183
+ | SQLite | File-based | Planned for v1.2 |
184
+ | Redis | In-memory key-value | Planned for v1.2 |
185
+ | MongoDB | Document database | Planned for v1.2 |
164
186
 
165
- ## Client Tools
187
+ ---
166
188
 
167
- SpinDB bundles the PostgreSQL **server** but not client tools. For `connect` and `restore` commands, you need client tools installed.
189
+ ## Commands
190
+
191
+ ### Container Lifecycle
168
192
 
169
- ### Automatic Installation
193
+ #### `create` - Create a new container
170
194
 
171
195
  ```bash
172
- # Check status of all client tools
173
- spindb deps check
196
+ spindb create mydb # PostgreSQL (default)
197
+ spindb create mydb --engine mysql # MySQL
198
+ spindb create mydb --version 16 # Specific PostgreSQL version
199
+ spindb create mydb --port 5433 # Custom port
200
+ spindb create mydb --database my_app # Custom database name
201
+ spindb create mydb --no-start # Create without starting
202
+ ```
174
203
 
175
- # Install missing tools
176
- spindb deps install
204
+ Create and restore in one command:
177
205
 
178
- # Install for a specific engine
179
- spindb deps install --engine postgresql
180
- spindb deps install --engine mysql
206
+ ```bash
207
+ spindb create mydb --from ./backup.dump
208
+ spindb create mydb --from "postgresql://user:pass@host:5432/production"
181
209
  ```
182
210
 
183
- **Note:** On Linux, package managers (apt, pacman, dnf) require `sudo` privileges. You may be prompted for your password when installing dependencies.
211
+ <details>
212
+ <summary>All options</summary>
184
213
 
185
- ### Manual Installation
214
+ | Option | Description |
215
+ |--------|-------------|
216
+ | `--engine`, `-e` | Database engine (`postgresql`, `mysql`) |
217
+ | `--version`, `-v` | Engine version |
218
+ | `--port`, `-p` | Port number |
219
+ | `--database`, `-d` | Primary database name |
220
+ | `--from` | Restore from backup file or connection string |
221
+ | `--no-start` | Create without starting |
186
222
 
187
- #### PostgreSQL
223
+ </details>
224
+
225
+ #### `start` - Start a container
188
226
 
189
227
  ```bash
190
- # macOS (Homebrew) - use the latest PostgreSQL version (currently 17)
191
- brew install postgresql@17
192
- brew link --overwrite postgresql@17
228
+ spindb start mydb
229
+ ```
193
230
 
194
- # Ubuntu/Debian
195
- sudo apt install postgresql-client
231
+ #### `stop` - Stop a container
196
232
 
197
- # Arch
198
- sudo pacman -S postgresql-libs
233
+ ```bash
234
+ spindb stop mydb
199
235
  ```
200
236
 
201
- #### MySQL
237
+ #### `delete` - Delete a container
202
238
 
203
239
  ```bash
204
- # macOS (Homebrew)
205
- brew install mysql
240
+ spindb delete mydb
241
+ spindb delete mydb --force # Skip confirmation
242
+ ```
206
243
 
207
- # Ubuntu/Debian
208
- sudo apt install mysql-server
244
+ ### Data Operations
245
+
246
+ #### `connect` - Open database shell
209
247
 
210
- # Arch
211
- sudo pacman -S mysql
248
+ ```bash
249
+ spindb connect mydb # Standard shell (psql/mysql)
250
+ spindb connect mydb --pgcli # Enhanced PostgreSQL shell
251
+ spindb connect mydb --mycli # Enhanced MySQL shell
252
+ spindb connect mydb --tui # Universal SQL client (usql)
212
253
  ```
213
254
 
214
- ## Supported Platforms
255
+ Install enhanced shells on-the-fly:
215
256
 
216
- - macOS (Apple Silicon & Intel)
217
- - Linux (x64 & ARM64)
257
+ ```bash
258
+ spindb connect mydb --install-pgcli
259
+ spindb connect mydb --install-mycli
260
+ spindb connect mydb --install-tui
261
+ ```
218
262
 
219
- ## Examples
263
+ #### `run` - Execute SQL
220
264
 
221
- ### Create databases
265
+ ```bash
266
+ spindb run mydb script.sql # Run a SQL file
267
+ spindb run mydb --sql "SELECT * FROM users" # Run inline SQL
268
+ spindb run mydb seed.sql --database my_app # Target specific database
269
+ ```
270
+
271
+ #### `url` - Get connection string
222
272
 
223
273
  ```bash
224
- # PostgreSQL with specific version and port
225
- spindb create mydb --engine postgresql --version 16 --port 5433
274
+ spindb url mydb # postgresql://postgres@localhost:5432/mydb
275
+ spindb url mydb --copy # Copy to clipboard
276
+ spindb url mydb --json # JSON output with details
277
+
278
+ # Use in scripts
279
+ export DATABASE_URL=$(spindb url mydb)
280
+ psql $(spindb url mydb)
281
+ ```
226
282
 
227
- # MySQL
228
- spindb create mydb --engine mysql --port 3307
283
+ #### `backup` - Create a backup
229
284
 
230
- # With custom database name
231
- spindb create mydb --database my_app_db
285
+ ```bash
286
+ spindb backup mydb # Auto-generated filename
287
+ spindb backup mydb --name my-backup # Custom name
288
+ spindb backup mydb --output ./backups/ # Custom directory
289
+ spindb backup mydb --database my_app # Backup specific database
232
290
  ```
233
291
 
234
- ### Create and restore in one command
292
+ Backup formats:
235
293
 
236
294
  ```bash
237
- # Create and restore from a dump file
238
- spindb create mydb --from ./backup.dump
295
+ spindb backup mydb --format sql # Plain SQL (.sql)
296
+ spindb backup mydb --format dump # Compressed (.dump for PG, .sql.gz for MySQL)
239
297
 
240
- # Create and pull from a remote database
241
- spindb create mydb --from "postgresql://user:pass@remote-host:5432/production_db"
298
+ # Shorthand
299
+ spindb backup mydb --sql
300
+ spindb backup mydb --dump
242
301
  ```
243
302
 
244
- ### Clone for testing
303
+ #### `restore` - Restore from backup
245
304
 
246
305
  ```bash
247
- # Stop the source container
248
- spindb stop production-copy
306
+ spindb restore mydb backup.dump
307
+ spindb restore mydb backup.sql --database my_app
308
+ ```
249
309
 
250
- # Clone it
251
- spindb clone production-copy test-branch
310
+ ### Container Management
252
311
 
253
- # Start the clone
254
- spindb start test-branch
312
+ #### `list` - List all containers
313
+
314
+ ```bash
315
+ spindb list
316
+ spindb list --json
255
317
  ```
256
318
 
257
- ### Connect to databases
319
+ #### `info` - Show container details
258
320
 
259
321
  ```bash
260
- # Interactive shell (auto-detects engine)
261
- spindb connect mydb
322
+ spindb info # All containers
323
+ spindb info mydb # Specific container
324
+ spindb info mydb --json
325
+ ```
262
326
 
263
- # Use pgcli/mycli for enhanced shell (dropdown auto-completion)
264
- spindb connect mydb --pgcli # PostgreSQL
265
- spindb connect mydb --mycli # MySQL
327
+ #### `clone` - Clone a container
266
328
 
267
- # Install pgcli/mycli and connect in one command
268
- spindb connect mydb --install-pgcli
269
- spindb connect mydb --install-mycli
329
+ ```bash
330
+ spindb stop source-db # Source must be stopped
331
+ spindb clone source-db new-db
332
+ spindb start new-db
333
+ ```
270
334
 
271
- # Use usql for universal SQL client (works with both engines)
272
- spindb connect mydb --tui
273
- spindb connect mydb --install-tui
335
+ #### `edit` - Rename or change port
336
+
337
+ ```bash
338
+ spindb edit mydb --name newname # Must be stopped
339
+ spindb edit mydb --port 5433
340
+ spindb edit mydb # Interactive mode
341
+ ```
274
342
 
275
- # Or use connection string directly
276
- psql postgresql://postgres@localhost:5432/mydb
277
- mysql -u root -h 127.0.0.1 -P 3306 mydb
343
+ #### `logs` - View container logs
344
+
345
+ ```bash
346
+ spindb logs mydb
347
+ spindb logs mydb --follow # Follow mode (like tail -f)
348
+ spindb logs mydb -n 50 # Last 50 lines
349
+ spindb logs mydb --editor # Open in $EDITOR
278
350
  ```
279
351
 
280
- ### Manage installed engines
352
+ ### Engine & System
281
353
 
282
- View installed engines with disk usage (PostgreSQL) and system detection (MySQL):
354
+ #### `engines` - Manage installed engines
283
355
 
284
356
  ```bash
285
- spindb engines
357
+ spindb engines # List installed engines
358
+ spindb engines delete postgresql 16 # Delete a version (frees ~45MB)
286
359
  ```
287
360
 
361
+ Example output:
362
+
288
363
  ```
289
364
  ENGINE VERSION SOURCE SIZE
290
365
  ────────────────────────────────────────────────────────
@@ -297,84 +372,170 @@ PostgreSQL: 2 version(s), 90.0 MB
297
372
  MySQL: system-installed at /opt/homebrew/bin/mysqld
298
373
  ```
299
374
 
300
- Delete unused PostgreSQL versions to free disk space:
375
+ #### `deps` - Manage client tools
301
376
 
302
377
  ```bash
303
- spindb engines delete postgresql 16
378
+ spindb deps check # Check all dependencies
379
+ spindb deps check --engine postgresql # Check specific engine
380
+ spindb deps install # Install missing tools
381
+ spindb deps install --engine mysql # Install for specific engine
304
382
  ```
305
383
 
306
- ### Container info and connection strings
384
+ #### `config` - Configuration
307
385
 
308
386
  ```bash
309
- # View all container details
310
- spindb info
387
+ spindb config show # Show current configuration
388
+ spindb config detect # Re-detect tool paths
389
+ spindb config update-check on # Enable update notifications
390
+ spindb config update-check off # Disable update notifications
391
+ ```
311
392
 
312
- # View specific container
313
- spindb info mydb
393
+ #### `version` - Version info
314
394
 
315
- # Get connection string for scripting
316
- spindb url mydb
317
- export DATABASE_URL=$(spindb url mydb)
318
- psql $(spindb url mydb)
319
-
320
- # Copy connection string to clipboard
321
- spindb url mydb --copy
395
+ ```bash
396
+ spindb version
397
+ spindb version --check # Check for updates
322
398
  ```
323
399
 
324
- ### Backup databases
400
+ #### `self-update` - Update SpinDB
325
401
 
326
402
  ```bash
327
- # Backup with default settings (SQL format, auto-generated filename)
328
- spindb backup mydb
403
+ spindb self-update
404
+ ```
329
405
 
330
- # Backup specific database in container
331
- spindb backup mydb --database my_app_db
406
+ ---
332
407
 
333
- # Custom filename and output directory
334
- spindb backup mydb --name my-backup --output ./backups/
408
+ ## Enhanced CLI Tools
335
409
 
336
- # Choose format: sql (plain text) or dump (compressed/binary)
337
- spindb backup mydb --format sql # Plain SQL (.sql)
338
- spindb backup mydb --format dump # PostgreSQL custom format (.dump) / MySQL gzipped (.sql.gz)
410
+ SpinDB supports enhanced database shells that provide features like auto-completion, syntax highlighting, and better output formatting.
339
411
 
340
- # Shorthand flags
341
- spindb backup mydb --sql # Same as --format sql
342
- spindb backup mydb --dump # Same as --format dump
343
- ```
412
+ | Engine | Standard | Enhanced | Universal |
413
+ |--------|----------|----------|-----------|
414
+ | PostgreSQL | `psql` | `pgcli` | `usql` |
415
+ | MySQL | `mysql` | `mycli` | `usql` |
416
+ | SQLite (planned) | `sqlite3` | `litecli` | `usql` |
417
+ | Redis (planned) | `redis-cli` | `iredis` | - |
418
+ | MongoDB (planned) | `mongosh` | - | - |
419
+
420
+ **pgcli / mycli** provide:
421
+ - Intelligent auto-completion (tables, columns, keywords)
422
+ - Syntax highlighting
423
+ - Multi-line editing
424
+ - Query history with search
344
425
 
345
- **Backup formats:**
346
- - **SQL format** (`.sql`) - Plain text, universal, can be read/edited
347
- - **Dump format** - PostgreSQL uses custom format (`.dump`), MySQL uses gzipped SQL (`.sql.gz`)
426
+ **usql** is a universal SQL client that works with any database. Great if you work with multiple engines.
348
427
 
349
- ### Edit containers
428
+ Install and connect in one command:
350
429
 
351
430
  ```bash
352
- # Rename a container (must be stopped)
353
- spindb edit mydb --name newname
431
+ spindb connect mydb --install-pgcli
432
+ spindb connect mydb --install-mycli
433
+ spindb connect mydb --install-tui # usql
434
+ ```
354
435
 
355
- # Change port
356
- spindb edit mydb --port 5433
436
+ ---
437
+
438
+ ## Architecture
439
+
440
+ ### Storage Layout
357
441
 
358
- # Interactive mode
359
- spindb edit mydb
442
+ ```
443
+ ~/.spindb/
444
+ ├── bin/ # Downloaded server binaries
445
+ │ └── postgresql-17.7.0-darwin-arm64/ # ~45 MB per version
446
+ ├── containers/
447
+ │ ├── postgresql/
448
+ │ │ └── mydb/
449
+ │ │ ├── container.json # Configuration
450
+ │ │ ├── data/ # Database files
451
+ │ │ └── postgres.log # Server logs
452
+ │ └── mysql/
453
+ │ └── mydb/
454
+ │ ├── container.json
455
+ │ ├── data/
456
+ │ └── mysql.log
457
+ ├── logs/ # Error logs
458
+ └── config.json # Tool paths cache
360
459
  ```
361
460
 
362
- ## Running Tests
461
+ ### How Data Persists
363
462
 
364
- ```bash
365
- # Run all tests (PostgreSQL + MySQL)
366
- pnpm test
463
+ SpinDB runs databases as **native processes** on your machine. When you start a container:
367
464
 
368
- # Run individual test suites
369
- pnpm test:pg
370
- pnpm test:mysql
371
- ```
465
+ 1. SpinDB launches the database server binary (`pg_ctl start` or `mysqld`)
466
+ 2. The server binds to `127.0.0.1` on your configured port
467
+ 3. A PID file tracks the running process
468
+ 4. Logs are written to the container's log file
469
+
470
+ When you stop a container:
471
+
472
+ 1. SpinDB sends a graceful shutdown signal
473
+ 2. The database flushes pending writes to disk
474
+ 3. The PID file is removed
475
+ 4. Your data remains in the `data/` directory
476
+
477
+ **Your data is never deleted unless you explicitly delete the container.**
478
+
479
+ ### Binary Sources
480
+
481
+ **PostgreSQL:** Server binaries are downloaded from [zonky.io/embedded-postgres-binaries](https://github.com/zonkyio/embedded-postgres-binaries), a project that packages official PostgreSQL releases for embedding in applications. The binaries are hosted on Maven Central and support:
482
+ - macOS (Apple Silicon and Intel)
483
+ - Linux (x64 and ARM64)
484
+
485
+ **MySQL:** Uses your system's MySQL installation. SpinDB detects binaries from Homebrew, apt, pacman, or custom paths.
486
+
487
+ ---
488
+
489
+ ## Supported Platforms
490
+
491
+ | Platform | Architecture | Status |
492
+ |----------|-------------|--------|
493
+ | macOS | Apple Silicon (ARM64) | ✅ Supported |
494
+ | macOS | Intel (x64) | ✅ Supported |
495
+ | Linux | x64 | ✅ Supported |
496
+ | Linux | ARM64 | ✅ Supported |
497
+ | Windows | Any | ❌ Not supported |
498
+
499
+ **Why no Windows?** The zonky.io project doesn't provide Windows binaries for PostgreSQL. Windows support would require a different binary source and significant testing.
500
+
501
+ ---
502
+
503
+ ## Limitations
504
+
505
+ - **No Windows support** - zonky.io doesn't provide Windows PostgreSQL binaries
506
+ - **Client tools required** - `psql` and `mysql` must be installed separately for some operations
507
+ - **Local only** - Databases bind to `127.0.0.1`; remote connections planned for v1.1
508
+ - **MySQL requires system install** - Unlike PostgreSQL, we don't download MySQL binaries
509
+
510
+ ---
511
+
512
+ ## Roadmap
513
+
514
+ See [TODO.md](TODO.md) for the full roadmap.
515
+
516
+ ### v1.1 - Remote Connections & Secrets
517
+ - Connect to remote databases
518
+ - Environment variable support in connection strings
519
+ - Secrets management (macOS Keychain)
520
+
521
+ ### v1.2 - Additional Engines
522
+ - SQLite (file-based, no server)
523
+ - Redis (in-memory key-value)
524
+ - MongoDB (document database)
525
+ - MariaDB as standalone engine
526
+
527
+ ### v1.3 - Advanced Features
528
+ - Container templates
529
+ - Scheduled backups
530
+ - Import from Docker
531
+
532
+ ---
372
533
 
373
534
  ## Troubleshooting
374
535
 
375
536
  ### Port already in use
376
537
 
377
- SpinDB automatically finds an available port. You can also specify one:
538
+ SpinDB automatically finds an available port. To specify one:
378
539
 
379
540
  ```bash
380
541
  spindb create mydb --port 5433
@@ -382,7 +543,7 @@ spindb create mydb --port 5433
382
543
 
383
544
  ### Client tool not found
384
545
 
385
- Install client tools or configure the path:
546
+ Install client tools or configure manually:
386
547
 
387
548
  ```bash
388
549
  spindb deps install
@@ -395,8 +556,9 @@ spindb config set psql /path/to/psql
395
556
  Check the logs:
396
557
 
397
558
  ```bash
559
+ spindb logs mydb
560
+ # or read directly
398
561
  cat ~/.spindb/containers/postgresql/mydb/postgres.log
399
- cat ~/.spindb/containers/mysql/mydb/mysql.log
400
562
  ```
401
563
 
402
564
  ### Reset everything
@@ -405,73 +567,38 @@ cat ~/.spindb/containers/mysql/mydb/mysql.log
405
567
  rm -rf ~/.spindb
406
568
  ```
407
569
 
408
- ## Project Structure
409
-
410
- ```
411
- spindb/
412
- ├── bin.ts # Entry point (#!/usr/bin/env tsx)
413
- ├── cli/
414
- │ ├── index.ts # Commander setup, routes to commands
415
- │ ├── commands/ # CLI commands
416
- │ │ ├── menu.ts # Interactive arrow-key menu
417
- │ │ ├── create.ts # Create container command
418
- │ │ ├── delete.ts # Delete container command
419
- │ │ └── ... # Other commands
420
- │ └── ui/
421
- │ ├── prompts.ts # Inquirer prompts
422
- │ ├── spinner.ts # Ora spinner helpers
423
- │ └── theme.ts # Chalk color theme
424
- ├── core/
425
- │ ├── binary-manager.ts # Downloads PostgreSQL from zonky.io
426
- │ ├── config-manager.ts # Manages ~/.spindb/config.json
427
- │ ├── container-manager.ts # CRUD for containers
428
- │ ├── port-manager.ts # Port availability checking
429
- │ ├── process-manager.ts # Process start/stop wrapper
430
- │ ├── dependency-manager.ts # Client tool detection
431
- │ ├── error-handler.ts # Centralized error handling
432
- │ └── transaction-manager.ts # Rollback support for operations
433
- ├── config/
434
- │ ├── paths.ts # ~/.spindb/ path definitions
435
- │ ├── defaults.ts # Default values, platform mappings
436
- │ └── os-dependencies.ts # OS-specific dependency definitions
437
- ├── engines/
438
- │ ├── base-engine.ts # Abstract base class
439
- │ ├── index.ts # Engine registry
440
- │ ├── postgresql/
441
- │ │ ├── index.ts # PostgreSQL engine implementation
442
- │ │ ├── binary-urls.ts # Zonky.io URL builder
443
- │ │ ├── restore.ts # Backup detection and restore
444
- │ │ └── version-validator.ts # Version compatibility checks
445
- │ └── mysql/
446
- │ ├── index.ts # MySQL engine implementation
447
- │ ├── binary-detection.ts # MySQL binary path detection
448
- │ ├── restore.ts # Backup detection and restore
449
- │ └── version-validator.ts # Version compatibility checks
450
- ├── types/
451
- │ └── index.ts # TypeScript interfaces
452
- └── tests/
453
- ├── unit/ # Unit tests
454
- ├── integration/ # Integration tests
455
- └── fixtures/ # Test data
456
- ├── postgresql/
457
- │ └── seeds/
458
- └── mysql/
459
- └── seeds/
460
- ```
570
+ ---
461
571
 
462
572
  ## Contributing
463
573
 
464
- ### Version Updates
574
+ See [CLAUDE.md](CLAUDE.md) for development setup and architecture documentation.
575
+
576
+ ### Running Tests
577
+
578
+ ```bash
579
+ pnpm test # All tests
580
+ pnpm test:unit # Unit tests only
581
+ pnpm test:pg # PostgreSQL integration
582
+ pnpm test:mysql # MySQL integration
583
+ ```
584
+
585
+ ---
586
+
587
+ ## Acknowledgments
465
588
 
466
- SpinDB uses versioned PostgreSQL packages from Homebrew (e.g., `postgresql@17`). When new major versions are released:
589
+ SpinDB wouldn't be possible without:
467
590
 
468
- 1. Check [PostgreSQL releases](https://www.postgresql.org/docs/release/) and [Homebrew formulae](https://formulae.brew.sh/formula/postgresql)
469
- 2. Update `config/engine-defaults.ts`:
470
- - Change `latestVersion` to the new version
471
- - Add the new version to `supportedVersions`
591
+ - **[zonky.io/embedded-postgres-binaries](https://github.com/zonkyio/embedded-postgres-binaries)** - Pre-compiled PostgreSQL binaries that make Docker-free PostgreSQL possible. These binaries are extracted from official PostgreSQL distributions and hosted on Maven Central.
472
592
 
473
- See `CLAUDE.md` for detailed maintenance instructions.
593
+ ---
474
594
 
475
595
  ## License
476
596
 
477
- MIT
597
+ [PolyForm Noncommercial 1.0.0](LICENSE)
598
+
599
+ SpinDB is free for:
600
+ - Personal use and hobby projects
601
+ - Educational and research purposes
602
+ - Nonprofit organizations, educational institutions, and government
603
+
604
+ **SpinDB may not be used for commercial purposes.**