spindb 0.1.0
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/.claude/settings.local.json +20 -0
- package/.env.example +1 -0
- package/.prettierignore +4 -0
- package/.prettierrc +6 -0
- package/CLAUDE.md +162 -0
- package/README.md +204 -0
- package/TODO.md +66 -0
- package/bin/cli.js +7 -0
- package/eslint.config.js +18 -0
- package/package.json +52 -0
- package/seeds/mysql/sample-db.sql +22 -0
- package/seeds/postgres/sample-db.sql +27 -0
- package/src/bin/cli.ts +8 -0
- package/src/cli/commands/clone.ts +101 -0
- package/src/cli/commands/config.ts +215 -0
- package/src/cli/commands/connect.ts +106 -0
- package/src/cli/commands/create.ts +148 -0
- package/src/cli/commands/delete.ts +94 -0
- package/src/cli/commands/list.ts +69 -0
- package/src/cli/commands/menu.ts +675 -0
- package/src/cli/commands/restore.ts +161 -0
- package/src/cli/commands/start.ts +95 -0
- package/src/cli/commands/stop.ts +91 -0
- package/src/cli/index.ts +38 -0
- package/src/cli/ui/prompts.ts +197 -0
- package/src/cli/ui/spinner.ts +94 -0
- package/src/cli/ui/theme.ts +113 -0
- package/src/config/defaults.ts +49 -0
- package/src/config/paths.ts +53 -0
- package/src/core/binary-manager.ts +239 -0
- package/src/core/config-manager.ts +259 -0
- package/src/core/container-manager.ts +234 -0
- package/src/core/port-manager.ts +84 -0
- package/src/core/process-manager.ts +353 -0
- package/src/engines/base-engine.ts +103 -0
- package/src/engines/index.ts +46 -0
- package/src/engines/postgresql/binary-urls.ts +52 -0
- package/src/engines/postgresql/index.ts +298 -0
- package/src/engines/postgresql/restore.ts +173 -0
- package/src/types/index.ts +97 -0
- package/tsconfig.json +24 -0
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
{
|
|
2
|
+
"permissions": {
|
|
3
|
+
"allow": [
|
|
4
|
+
"Bash(lsof:*)",
|
|
5
|
+
"Bash(npm view:*)",
|
|
6
|
+
"Bash(pnpm install:*)",
|
|
7
|
+
"Bash(pnpm run start --help:*)",
|
|
8
|
+
"Bash(pnpm run start:*)",
|
|
9
|
+
"Bash(curl:*)",
|
|
10
|
+
"Bash(psql:*)",
|
|
11
|
+
"Bash(chmod:*)",
|
|
12
|
+
"Bash(node bin/cli.js:*)",
|
|
13
|
+
"Bash(pnpm add:*)",
|
|
14
|
+
"Bash(pnpm run format:*)",
|
|
15
|
+
"Bash(pnpm run lint:*)"
|
|
16
|
+
],
|
|
17
|
+
"deny": [],
|
|
18
|
+
"ask": []
|
|
19
|
+
}
|
|
20
|
+
}
|
package/.env.example
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
# No environment variables needed for this project
|
package/.prettierignore
ADDED
package/.prettierrc
ADDED
package/CLAUDE.md
ADDED
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
# CLAUDE.md - Project Context for Claude Code
|
|
2
|
+
|
|
3
|
+
## Project Overview
|
|
4
|
+
|
|
5
|
+
SpinDB is a CLI tool for running local PostgreSQL databases without Docker. It's a lightweight alternative to DBngin, downloading and managing PostgreSQL binaries directly.
|
|
6
|
+
|
|
7
|
+
## Tech Stack
|
|
8
|
+
|
|
9
|
+
- **Runtime**: Node.js 18+ with TypeScript
|
|
10
|
+
- **Execution**: `tsx` for direct TypeScript execution (no build step for dev)
|
|
11
|
+
- **Package Manager**: pnpm (strictly - not npm/yarn)
|
|
12
|
+
- **CLI Framework**: Commander.js
|
|
13
|
+
- **Interactive UI**: Inquirer.js (prompts), Chalk (colors), Ora (spinners)
|
|
14
|
+
- **Module System**: ESM (`"type": "module"`)
|
|
15
|
+
- **Path Aliases**: `@/*` maps to `./src/*`
|
|
16
|
+
|
|
17
|
+
## Project Structure
|
|
18
|
+
|
|
19
|
+
```
|
|
20
|
+
src/
|
|
21
|
+
├── bin/cli.ts # Entry point (#!/usr/bin/env tsx)
|
|
22
|
+
├── cli/
|
|
23
|
+
│ ├── index.ts # Commander setup, routes to commands
|
|
24
|
+
│ ├── commands/ # CLI commands (create, start, stop, etc.)
|
|
25
|
+
│ │ ├── menu.ts # Interactive arrow-key menu (default when no args)
|
|
26
|
+
│ │ └── config.ts # Binary path configuration
|
|
27
|
+
│ └── ui/
|
|
28
|
+
│ ├── prompts.ts # Inquirer prompts
|
|
29
|
+
│ ├── spinner.ts # Ora spinner helpers
|
|
30
|
+
│ └── theme.ts # Chalk color theme
|
|
31
|
+
├── core/
|
|
32
|
+
│ ├── binary-manager.ts # Downloads PostgreSQL from zonky.io
|
|
33
|
+
│ ├── config-manager.ts # Manages ~/.spindb/config.json
|
|
34
|
+
│ ├── container-manager.ts # CRUD for containers
|
|
35
|
+
│ ├── port-manager.ts # Port availability checking
|
|
36
|
+
│ └── process-manager.ts # pg_ctl start/stop wrapper
|
|
37
|
+
├── config/
|
|
38
|
+
│ ├── paths.ts # ~/.spindb/ path definitions
|
|
39
|
+
│ └── defaults.ts # Default values, platform mappings
|
|
40
|
+
├── engines/
|
|
41
|
+
│ ├── base-engine.ts # Abstract base class
|
|
42
|
+
│ ├── index.ts # Engine registry
|
|
43
|
+
│ └── postgresql/
|
|
44
|
+
│ ├── index.ts # PostgreSQL engine implementation
|
|
45
|
+
│ ├── binary-urls.ts # Zonky.io URL builder
|
|
46
|
+
│ └── restore.ts # Backup detection and restore
|
|
47
|
+
└── types/index.ts # TypeScript interfaces
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
## Key Architecture Decisions
|
|
51
|
+
|
|
52
|
+
### Binary Source
|
|
53
|
+
PostgreSQL server binaries come from [zonky.io](https://github.com/zonkyio/embedded-postgres-binaries) (Maven Central). These only include server binaries (postgres, pg_ctl, initdb), NOT client tools (psql, pg_dump, pg_restore).
|
|
54
|
+
|
|
55
|
+
**Download flow:**
|
|
56
|
+
1. Download JAR from Maven Central
|
|
57
|
+
2. Unzip JAR (it's a ZIP file)
|
|
58
|
+
3. Extract `.txz` file inside
|
|
59
|
+
4. Extract tar.xz to `~/.spindb/bin/postgresql-{version}-{platform}-{arch}/`
|
|
60
|
+
|
|
61
|
+
### Client Tools
|
|
62
|
+
Client tools (psql, pg_restore) are detected from the system. The `config-manager.ts` handles:
|
|
63
|
+
- Auto-detection from PATH and common locations
|
|
64
|
+
- Caching paths in `~/.spindb/config.json`
|
|
65
|
+
- Manual override via `spindb config set`
|
|
66
|
+
|
|
67
|
+
### Data Storage
|
|
68
|
+
```
|
|
69
|
+
~/.spindb/
|
|
70
|
+
├── bin/ # Downloaded PostgreSQL binaries
|
|
71
|
+
├── containers/{name}/
|
|
72
|
+
│ ├── container.json # Container metadata
|
|
73
|
+
│ ├── data/ # PostgreSQL data directory
|
|
74
|
+
│ └── postgres.log # Server logs
|
|
75
|
+
└── config.json # Tool paths, settings
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
### Interactive Menu
|
|
79
|
+
When `spindb` is run with no arguments, it shows an interactive menu (`src/cli/commands/menu.ts`) using Inquirer's list prompt. Users navigate with arrow keys.
|
|
80
|
+
|
|
81
|
+
## Common Tasks
|
|
82
|
+
|
|
83
|
+
### Running the CLI
|
|
84
|
+
```bash
|
|
85
|
+
pnpm run start # Opens interactive menu
|
|
86
|
+
pnpm run start create mydb # Run specific command
|
|
87
|
+
pnpm run start --help # Show help
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
### Testing Changes
|
|
91
|
+
No test suite yet. Manual testing:
|
|
92
|
+
```bash
|
|
93
|
+
pnpm run start create testdb -p 5433
|
|
94
|
+
pnpm run start list
|
|
95
|
+
pnpm run start connect testdb
|
|
96
|
+
pnpm run start delete testdb --force --yes
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
### Adding a New Command
|
|
100
|
+
1. Create `src/cli/commands/{name}.ts`
|
|
101
|
+
2. Export a Commander `Command` instance
|
|
102
|
+
3. Import and add to `src/cli/index.ts`
|
|
103
|
+
4. Optionally add to interactive menu in `src/cli/commands/menu.ts`
|
|
104
|
+
|
|
105
|
+
## Important Implementation Details
|
|
106
|
+
|
|
107
|
+
### Platform Detection
|
|
108
|
+
```typescript
|
|
109
|
+
import { platform, arch } from 'os';
|
|
110
|
+
// platform() returns 'darwin' | 'linux'
|
|
111
|
+
// arch() returns 'arm64' | 'x64'
|
|
112
|
+
// Mapped to zonky.io names in defaults.ts platformMappings
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
### Version Mapping
|
|
116
|
+
Major versions (14, 15, 16, 17) map to full versions in `src/engines/postgresql/binary-urls.ts`:
|
|
117
|
+
```typescript
|
|
118
|
+
const VERSION_MAP = {
|
|
119
|
+
'14': '14.15.0',
|
|
120
|
+
'15': '15.10.0',
|
|
121
|
+
'16': '16.6.0',
|
|
122
|
+
'17': '17.2.0'
|
|
123
|
+
};
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
### Port Management
|
|
127
|
+
- Default port: 5432
|
|
128
|
+
- If busy, scans 5432-5500 for available port
|
|
129
|
+
- Uses `net.createServer()` to test availability
|
|
130
|
+
|
|
131
|
+
### Process Management
|
|
132
|
+
Uses `pg_ctl` for start/stop:
|
|
133
|
+
```bash
|
|
134
|
+
pg_ctl start -D {dataDir} -l {logFile} -w -o "-p {port}"
|
|
135
|
+
pg_ctl stop -D {dataDir} -m fast -w
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
PID file location: `~/.spindb/containers/{name}/data/postmaster.pid`
|
|
139
|
+
|
|
140
|
+
## Known Limitations
|
|
141
|
+
|
|
142
|
+
1. **No client tools bundled** - psql/pg_restore must be installed separately
|
|
143
|
+
2. **macOS/Linux only** - No Windows support (zonky.io doesn't provide Windows binaries)
|
|
144
|
+
3. **No backup command** - pg_dump must be run manually with system tools
|
|
145
|
+
4. **No automatic updates** - Binary versions are hardcoded in VERSION_MAP
|
|
146
|
+
|
|
147
|
+
## Future Improvements (Not Implemented)
|
|
148
|
+
|
|
149
|
+
- [ ] Add `spindb backup` command (wrapper around pg_dump)
|
|
150
|
+
- [ ] Support MySQL/SQLite engines (architecture supports it)
|
|
151
|
+
- [ ] Add `spindb logs` command to tail postgres.log
|
|
152
|
+
- [ ] Add `spindb exec` for running SQL files
|
|
153
|
+
- [ ] Automatic binary version updates
|
|
154
|
+
- [ ] Windows support (would need different binary source)
|
|
155
|
+
|
|
156
|
+
## Code Style Notes
|
|
157
|
+
|
|
158
|
+
- No `.js` extensions in imports
|
|
159
|
+
- Use `@/` path alias for all internal imports
|
|
160
|
+
- Prefer `async/await` over callbacks
|
|
161
|
+
- Use Ora spinners for long-running operations
|
|
162
|
+
- Error messages should include actionable fix suggestions
|
package/README.md
ADDED
|
@@ -0,0 +1,204 @@
|
|
|
1
|
+
# SpinDB
|
|
2
|
+
|
|
3
|
+
Spin up local PostgreSQL databases without Docker. A lightweight alternative to DBngin.
|
|
4
|
+
|
|
5
|
+
## Features
|
|
6
|
+
|
|
7
|
+
- **No Docker required** - Downloads and runs PostgreSQL binaries directly
|
|
8
|
+
- **Multiple containers** - Run multiple isolated PostgreSQL instances on different ports
|
|
9
|
+
- **Interactive menu** - Arrow-key navigation for all operations
|
|
10
|
+
- **Auto port management** - Automatically finds available ports
|
|
11
|
+
- **Clone containers** - Duplicate databases with all data
|
|
12
|
+
- **Backup restore** - Restore pg_dump backups (requires system PostgreSQL client tools)
|
|
13
|
+
|
|
14
|
+
## Installation
|
|
15
|
+
|
|
16
|
+
```bash
|
|
17
|
+
# Run directly with pnpx (no install needed)
|
|
18
|
+
pnpx spindb
|
|
19
|
+
|
|
20
|
+
# Or install globally
|
|
21
|
+
pnpm add -g spindb
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
## Quick Start
|
|
25
|
+
|
|
26
|
+
```bash
|
|
27
|
+
# Launch interactive menu
|
|
28
|
+
spindb
|
|
29
|
+
|
|
30
|
+
# Or use commands directly
|
|
31
|
+
spindb create mydb
|
|
32
|
+
spindb list
|
|
33
|
+
spindb connect mydb
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
## Commands
|
|
37
|
+
|
|
38
|
+
| Command | Description |
|
|
39
|
+
|---------|-------------|
|
|
40
|
+
| `spindb` | Open interactive menu |
|
|
41
|
+
| `spindb create [name]` | Create a new database container |
|
|
42
|
+
| `spindb list` | List all containers |
|
|
43
|
+
| `spindb start [name]` | Start a container |
|
|
44
|
+
| `spindb stop [name]` | Stop a container |
|
|
45
|
+
| `spindb connect [name]` | Connect with psql |
|
|
46
|
+
| `spindb restore [name] [backup]` | Restore a backup file |
|
|
47
|
+
| `spindb clone [source] [target]` | Clone a container |
|
|
48
|
+
| `spindb delete [name]` | Delete a container |
|
|
49
|
+
| `spindb config show` | Show configuration |
|
|
50
|
+
| `spindb config detect` | Auto-detect PostgreSQL tools |
|
|
51
|
+
|
|
52
|
+
## How It Works
|
|
53
|
+
|
|
54
|
+
SpinDB downloads pre-built PostgreSQL binaries from [zonky.io](https://github.com/zonkyio/embedded-postgres-binaries) on first use. These are the same binaries used by embedded-postgres for Java testing.
|
|
55
|
+
|
|
56
|
+
Data is stored in `~/.spindb/`:
|
|
57
|
+
```
|
|
58
|
+
~/.spindb/
|
|
59
|
+
├── bin/ # PostgreSQL server binaries
|
|
60
|
+
│ └── postgresql-16-darwin-arm64/
|
|
61
|
+
├── containers/ # Container data
|
|
62
|
+
│ └── mydb/
|
|
63
|
+
│ ├── container.json # Container config
|
|
64
|
+
│ ├── data/ # PostgreSQL data directory
|
|
65
|
+
│ └── postgres.log # Server logs
|
|
66
|
+
└── config.json # SpinDB configuration
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
## PostgreSQL Client Tools
|
|
70
|
+
|
|
71
|
+
SpinDB bundles the PostgreSQL **server** (postgres, pg_ctl, initdb) but not client tools (psql, pg_dump, pg_restore). For `connect` and `restore` commands, you need PostgreSQL client tools installed:
|
|
72
|
+
|
|
73
|
+
```bash
|
|
74
|
+
# macOS (Homebrew)
|
|
75
|
+
brew install libpq
|
|
76
|
+
brew link --force libpq
|
|
77
|
+
|
|
78
|
+
# Ubuntu/Debian
|
|
79
|
+
apt install postgresql-client
|
|
80
|
+
|
|
81
|
+
# Or use Postgres.app (macOS)
|
|
82
|
+
# Client tools are automatically detected
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
SpinDB auto-detects installed tools. Check what's configured:
|
|
86
|
+
|
|
87
|
+
```bash
|
|
88
|
+
spindb config show
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
Manually configure tool paths:
|
|
92
|
+
|
|
93
|
+
```bash
|
|
94
|
+
spindb config set psql /path/to/psql
|
|
95
|
+
spindb config set pg_restore /path/to/pg_restore
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
## Supported Platforms
|
|
99
|
+
|
|
100
|
+
- macOS (Apple Silicon & Intel)
|
|
101
|
+
- Linux (x64 & ARM64)
|
|
102
|
+
|
|
103
|
+
## Supported PostgreSQL Versions
|
|
104
|
+
|
|
105
|
+
- PostgreSQL 14
|
|
106
|
+
- PostgreSQL 15
|
|
107
|
+
- PostgreSQL 16
|
|
108
|
+
- PostgreSQL 17
|
|
109
|
+
|
|
110
|
+
## Examples
|
|
111
|
+
|
|
112
|
+
### Create a database with specific version
|
|
113
|
+
|
|
114
|
+
```bash
|
|
115
|
+
spindb create mydb --pg-version 15 --port 5433
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
### Restore a backup
|
|
119
|
+
|
|
120
|
+
```bash
|
|
121
|
+
# Start the container first
|
|
122
|
+
spindb start mydb
|
|
123
|
+
|
|
124
|
+
# Restore (supports .sql, custom format, and tar format)
|
|
125
|
+
spindb restore mydb ./backup.dump -d myapp
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
### Clone for testing
|
|
129
|
+
|
|
130
|
+
```bash
|
|
131
|
+
# Stop the source container
|
|
132
|
+
spindb stop production-copy
|
|
133
|
+
|
|
134
|
+
# Clone it
|
|
135
|
+
spindb clone production-copy test-branch
|
|
136
|
+
|
|
137
|
+
# Start the clone
|
|
138
|
+
spindb start test-branch
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
### Connect and run queries
|
|
142
|
+
|
|
143
|
+
```bash
|
|
144
|
+
# Interactive psql session
|
|
145
|
+
spindb connect mydb
|
|
146
|
+
|
|
147
|
+
# Or use the connection string directly
|
|
148
|
+
psql postgresql://postgres@localhost:5432/postgres
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
## Configuration
|
|
152
|
+
|
|
153
|
+
Configuration is stored in `~/.spindb/config.json`. You can edit it directly or use the `config` commands:
|
|
154
|
+
|
|
155
|
+
```bash
|
|
156
|
+
# Show all config
|
|
157
|
+
spindb config show
|
|
158
|
+
|
|
159
|
+
# Re-detect system tools
|
|
160
|
+
spindb config detect
|
|
161
|
+
|
|
162
|
+
# Set custom binary path
|
|
163
|
+
spindb config set psql /usr/local/bin/psql
|
|
164
|
+
|
|
165
|
+
# Get path for scripting
|
|
166
|
+
spindb config path psql
|
|
167
|
+
```
|
|
168
|
+
|
|
169
|
+
## Troubleshooting
|
|
170
|
+
|
|
171
|
+
### Port already in use
|
|
172
|
+
|
|
173
|
+
SpinDB automatically finds an available port if the default (5432) is in use. You can also specify a port:
|
|
174
|
+
|
|
175
|
+
```bash
|
|
176
|
+
spindb create mydb --port 5433
|
|
177
|
+
```
|
|
178
|
+
|
|
179
|
+
### psql not found
|
|
180
|
+
|
|
181
|
+
Install PostgreSQL client tools (see above) or configure the path manually:
|
|
182
|
+
|
|
183
|
+
```bash
|
|
184
|
+
spindb config set psql /path/to/psql
|
|
185
|
+
```
|
|
186
|
+
|
|
187
|
+
### Container won't start
|
|
188
|
+
|
|
189
|
+
Check the logs:
|
|
190
|
+
|
|
191
|
+
```bash
|
|
192
|
+
cat ~/.spindb/containers/mydb/postgres.log
|
|
193
|
+
```
|
|
194
|
+
|
|
195
|
+
### Reset everything
|
|
196
|
+
|
|
197
|
+
```bash
|
|
198
|
+
rm -rf ~/.spindb
|
|
199
|
+
```
|
|
200
|
+
|
|
201
|
+
## License
|
|
202
|
+
|
|
203
|
+
MIT
|
|
204
|
+
# spindb
|
package/TODO.md
ADDED
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
# SpinDB TODO
|
|
2
|
+
|
|
3
|
+
## Monetization Model
|
|
4
|
+
|
|
5
|
+
Similar to ngrok - free tier for individual developers with core functionality, paid tiers for power users and teams.
|
|
6
|
+
|
|
7
|
+
- **Free**: Full local dev experience, unlimited containers, basic backup/restore
|
|
8
|
+
- **Pro** ($X/month): Security features, multi-engine support, advanced features
|
|
9
|
+
- **Team** ($X/user/month): Shared configs, team collaboration, priority support
|
|
10
|
+
|
|
11
|
+
## Free Features
|
|
12
|
+
|
|
13
|
+
### High Priority
|
|
14
|
+
- [ ] **Run SQL file** - Add menu option to run a `.sql` file against a container (wrapper around `psql -f`)
|
|
15
|
+
- [ ] **Backup command** - Add `spindb backup` to create dumps using `pg_dump`
|
|
16
|
+
- [ ] **Logs command** - Add `spindb logs <container>` to tail `postgres.log`
|
|
17
|
+
- [ ] **Engine/binary management** - Menu to list installed PostgreSQL versions, install new versions, uninstall unused versions (free up disk space)
|
|
18
|
+
|
|
19
|
+
### Medium Priority
|
|
20
|
+
- [ ] **Container rename** - Rename a container without cloning/deleting
|
|
21
|
+
- [ ] **Export connection string** - Copy connection string to clipboard
|
|
22
|
+
- [ ] **Multiple databases per container** - List/create/delete databases within a container
|
|
23
|
+
|
|
24
|
+
### Low Priority
|
|
25
|
+
- [ ] **SQLite support** - Add SQLite engine
|
|
26
|
+
- [ ] **Health checks** - Periodic connection tests to verify containers are responsive
|
|
27
|
+
|
|
28
|
+
---
|
|
29
|
+
|
|
30
|
+
## Paid Features (Pro)
|
|
31
|
+
|
|
32
|
+
### Security
|
|
33
|
+
- [ ] **Password support** - Set password on container creation, modify `pg_hba.conf` for password auth
|
|
34
|
+
- [ ] **Encrypted backups** - Encrypt dumps with password using gpg/openssl
|
|
35
|
+
|
|
36
|
+
### Multi-Engine Support
|
|
37
|
+
- [ ] **MySQL support** - Add MySQL engine (needs binary source)
|
|
38
|
+
- [ ] **MongoDB support** - Add MongoDB engine
|
|
39
|
+
|
|
40
|
+
### Advanced Features
|
|
41
|
+
- [ ] **Container templates** - Save container configs as reusable templates
|
|
42
|
+
- [ ] **Import from Docker** - Import data from Docker PostgreSQL containers
|
|
43
|
+
- [ ] **Automatic binary updates** - Check for and download newer PostgreSQL versions
|
|
44
|
+
- [ ] **Custom superuser name** - Allow changing from default `postgres` user
|
|
45
|
+
- [ ] **Scheduled backups** - Cron-like backup scheduling
|
|
46
|
+
- [ ] **Cloud backup sync** - Sync backups to S3/GCS/Azure
|
|
47
|
+
|
|
48
|
+
### Team Features
|
|
49
|
+
- [ ] **Shared configs** - Export/import container configs for team sharing
|
|
50
|
+
- [ ] **Config profiles** - Dev/staging/test profiles with different settings
|
|
51
|
+
|
|
52
|
+
---
|
|
53
|
+
|
|
54
|
+
## Stretch Goals
|
|
55
|
+
|
|
56
|
+
- [ ] **Terminal-based IDE** - Full TUI (terminal UI) for browsing tables, running queries, viewing results, editing data inline (think `lazygit` but for databases)
|
|
57
|
+
- Potential libraries: [blessed](https://github.com/chjj/blessed), [ink](https://github.com/vadimdemedes/ink), [terminal-kit](https://github.com/cronvel/terminal-kit)
|
|
58
|
+
- Inspiration: `lazygit`, `k9s`, `pgcli`
|
|
59
|
+
|
|
60
|
+
---
|
|
61
|
+
|
|
62
|
+
## Known Limitations
|
|
63
|
+
|
|
64
|
+
- **No Windows support** - zonky.io doesn't provide Windows binaries
|
|
65
|
+
- **Client tools required** - psql/pg_dump/pg_restore must be installed separately (not bundled)
|
|
66
|
+
- **Local only** - No remote connection support (binds to 127.0.0.1)
|
package/bin/cli.js
ADDED
package/eslint.config.js
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import eslint from '@eslint/js'
|
|
2
|
+
import tseslint from 'typescript-eslint'
|
|
3
|
+
|
|
4
|
+
export default tseslint.config(
|
|
5
|
+
eslint.configs.recommended,
|
|
6
|
+
...tseslint.configs.recommended,
|
|
7
|
+
{
|
|
8
|
+
ignores: ['dist/', 'node_modules/', 'bin/'],
|
|
9
|
+
},
|
|
10
|
+
{
|
|
11
|
+
rules: {
|
|
12
|
+
'@typescript-eslint/no-unused-vars': [
|
|
13
|
+
'error',
|
|
14
|
+
{ argsIgnorePattern: '^_', varsIgnorePattern: '^_' },
|
|
15
|
+
],
|
|
16
|
+
},
|
|
17
|
+
},
|
|
18
|
+
)
|
package/package.json
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "spindb",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Spin up local database containers without Docker. A DBngin-like CLI for PostgreSQL.",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"bin": {
|
|
7
|
+
"spindb": "./bin/cli.js"
|
|
8
|
+
},
|
|
9
|
+
"scripts": {
|
|
10
|
+
"start": "tsx src/bin/cli.ts",
|
|
11
|
+
"dev": "tsx watch src/bin/cli.ts",
|
|
12
|
+
"build": "tsc",
|
|
13
|
+
"test": "tsx --test",
|
|
14
|
+
"format": "prettier --write .",
|
|
15
|
+
"lint": "eslint ."
|
|
16
|
+
},
|
|
17
|
+
"keywords": [
|
|
18
|
+
"postgres",
|
|
19
|
+
"postgresql",
|
|
20
|
+
"database",
|
|
21
|
+
"local",
|
|
22
|
+
"development",
|
|
23
|
+
"cli"
|
|
24
|
+
],
|
|
25
|
+
"author": "Bob Bass <bob@bbass.co>",
|
|
26
|
+
"license": "MIT",
|
|
27
|
+
"packageManager": "pnpm@9.14.2",
|
|
28
|
+
"engines": {
|
|
29
|
+
"node": ">=18"
|
|
30
|
+
},
|
|
31
|
+
"repository": {
|
|
32
|
+
"type": "git",
|
|
33
|
+
"url": "https://github.com/robertjbass/spindb.git"
|
|
34
|
+
},
|
|
35
|
+
"homepage": "https://github.com/robertjbass/spindb#readme",
|
|
36
|
+
"dependencies": {
|
|
37
|
+
"chalk": "^5.3.0",
|
|
38
|
+
"commander": "^12.1.0",
|
|
39
|
+
"inquirer": "^9.3.7",
|
|
40
|
+
"ora": "^8.1.1",
|
|
41
|
+
"tsx": "^4.7.0"
|
|
42
|
+
},
|
|
43
|
+
"devDependencies": {
|
|
44
|
+
"@eslint/js": "^9.39.1",
|
|
45
|
+
"@types/inquirer": "^9.0.7",
|
|
46
|
+
"@types/node": "^20.10.0",
|
|
47
|
+
"eslint": "^9.39.1",
|
|
48
|
+
"prettier": "^3.6.2",
|
|
49
|
+
"typescript": "^5.3.0",
|
|
50
|
+
"typescript-eslint": "^8.48.0"
|
|
51
|
+
}
|
|
52
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
-- Sample database schema for testing SpinDB
|
|
2
|
+
-- Creates a basic users table with common fields (MySQL syntax)
|
|
3
|
+
|
|
4
|
+
CREATE TABLE IF NOT EXISTS users (
|
|
5
|
+
id INT AUTO_INCREMENT PRIMARY KEY,
|
|
6
|
+
first_name VARCHAR(100) NOT NULL,
|
|
7
|
+
last_name VARCHAR(100) NOT NULL,
|
|
8
|
+
email VARCHAR(255) NOT NULL UNIQUE,
|
|
9
|
+
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
|
10
|
+
updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
|
|
11
|
+
deleted_at TIMESTAMP NULL,
|
|
12
|
+
INDEX idx_users_email (email),
|
|
13
|
+
INDEX idx_users_deleted_at (deleted_at)
|
|
14
|
+
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
|
15
|
+
|
|
16
|
+
-- Sample data
|
|
17
|
+
INSERT IGNORE INTO users (first_name, last_name, email) VALUES
|
|
18
|
+
('Alice', 'Johnson', 'alice@example.com'),
|
|
19
|
+
('Bob', 'Smith', 'bob@example.com'),
|
|
20
|
+
('Charlie', 'Williams', 'charlie@example.com'),
|
|
21
|
+
('Diana', 'Brown', 'diana@example.com'),
|
|
22
|
+
('Eve', 'Davis', 'eve@example.com');
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
-- Sample database schema for testing SpinDB
|
|
2
|
+
-- Creates a basic users table with common fields
|
|
3
|
+
|
|
4
|
+
CREATE TABLE IF NOT EXISTS users (
|
|
5
|
+
id SERIAL PRIMARY KEY,
|
|
6
|
+
first_name VARCHAR(100) NOT NULL,
|
|
7
|
+
last_name VARCHAR(100) NOT NULL,
|
|
8
|
+
email VARCHAR(255) NOT NULL UNIQUE,
|
|
9
|
+
created_at TIMESTAMP WITH TIME ZONE DEFAULT CURRENT_TIMESTAMP,
|
|
10
|
+
updated_at TIMESTAMP WITH TIME ZONE DEFAULT CURRENT_TIMESTAMP,
|
|
11
|
+
deleted_at TIMESTAMP WITH TIME ZONE
|
|
12
|
+
);
|
|
13
|
+
|
|
14
|
+
-- Create an index on email for faster lookups
|
|
15
|
+
CREATE INDEX IF NOT EXISTS idx_users_email ON users(email);
|
|
16
|
+
|
|
17
|
+
-- Create an index on deleted_at for soft delete queries
|
|
18
|
+
CREATE INDEX IF NOT EXISTS idx_users_deleted_at ON users(deleted_at);
|
|
19
|
+
|
|
20
|
+
-- Sample data
|
|
21
|
+
INSERT INTO users (first_name, last_name, email) VALUES
|
|
22
|
+
('Alice', 'Johnson', 'alice@example.com'),
|
|
23
|
+
('Bob', 'Smith', 'bob@example.com'),
|
|
24
|
+
('Charlie', 'Williams', 'charlie@example.com'),
|
|
25
|
+
('Diana', 'Brown', 'diana@example.com'),
|
|
26
|
+
('Eve', 'Davis', 'eve@example.com')
|
|
27
|
+
ON CONFLICT (email) DO NOTHING;
|