spindb 0.1.0 → 0.2.1

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 CHANGED
@@ -10,6 +10,9 @@ Spin up local PostgreSQL databases without Docker. A lightweight alternative to
10
10
  - **Auto port management** - Automatically finds available ports
11
11
  - **Clone containers** - Duplicate databases with all data
12
12
  - **Backup restore** - Restore pg_dump backups (requires system PostgreSQL client tools)
13
+ - **Custom database names** - Specify database name separate from container name
14
+ - **Engine management** - View installed PostgreSQL versions and free up disk space
15
+ - **Dynamic version selection** - Fetches all available versions from Maven Central
13
16
 
14
17
  ## Installation
15
18
 
@@ -109,10 +112,15 @@ spindb config set pg_restore /path/to/pg_restore
109
112
 
110
113
  ## Examples
111
114
 
112
- ### Create a database with specific version
115
+ ### Create a database with specific version and name
113
116
 
114
117
  ```bash
118
+ # Specify PostgreSQL version and port
115
119
  spindb create mydb --pg-version 15 --port 5433
120
+
121
+ # Specify a custom database name (different from container name)
122
+ spindb create mydb --database my_app_db
123
+ # Connection string: postgresql://postgres@localhost:5432/my_app_db
116
124
  ```
117
125
 
118
126
  ### Restore a backup
@@ -145,7 +153,21 @@ spindb start test-branch
145
153
  spindb connect mydb
146
154
 
147
155
  # Or use the connection string directly
148
- psql postgresql://postgres@localhost:5432/postgres
156
+ psql postgresql://postgres@localhost:5432/mydb
157
+ ```
158
+
159
+ ### Manage installed engines
160
+
161
+ The Engines menu (accessible from the main menu) shows all installed PostgreSQL versions with their disk usage. You can delete unused versions to free up space.
162
+
163
+ ```
164
+ ENGINE VERSION PLATFORM SIZE
165
+ ────────────────────────────────────────────────────────
166
+ postgresql 17 darwin-arm64 45.2 MB
167
+ postgresql 16.9.0 darwin-arm64 44.8 MB
168
+ postgresql 16 darwin-arm64 44.8 MB
169
+ ────────────────────────────────────────────────────────
170
+ 3 version(s) 134.8 MB
149
171
  ```
150
172
 
151
173
  ## Configuration
@@ -201,4 +223,3 @@ rm -rf ~/.spindb
201
223
  ## License
202
224
 
203
225
  MIT
204
- # spindb
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "spindb",
3
- "version": "0.1.0",
3
+ "version": "0.2.01",
4
4
  "description": "Spin up local database containers without Docker. A DBngin-like CLI for PostgreSQL.",
5
5
  "type": "module",
6
6
  "bin": {
@@ -48,5 +48,13 @@
48
48
  "prettier": "^3.6.2",
49
49
  "typescript": "^5.3.0",
50
50
  "typescript-eslint": "^8.48.0"
51
- }
51
+ },
52
+ "tsx": {
53
+ "tsconfig": "./tsconfig.json"
54
+ },
55
+ "files": [
56
+ "bin/**/*",
57
+ "src/**/*",
58
+ "tsconfig.json"
59
+ ]
52
60
  }
@@ -17,6 +17,7 @@ export const createCommand = new Command('create')
17
17
  'PostgreSQL version',
18
18
  defaults.postgresVersion,
19
19
  )
20
+ .option('-d, --database <database>', 'Database name')
20
21
  .option('-p, --port <port>', 'Port number')
21
22
  .option('--no-start', 'Do not start the container after creation')
22
23
  .action(
@@ -25,6 +26,7 @@ export const createCommand = new Command('create')
25
26
  options: {
26
27
  engine: string
27
28
  pgVersion: string
29
+ database?: string
28
30
  port?: string
29
31
  start: boolean
30
32
  },
@@ -33,6 +35,7 @@ export const createCommand = new Command('create')
33
35
  let containerName = name
34
36
  let engine = options.engine
35
37
  let version = options.pgVersion
38
+ let database = options.database
36
39
 
37
40
  // Interactive mode if no name provided
38
41
  if (!containerName) {
@@ -40,8 +43,12 @@ export const createCommand = new Command('create')
40
43
  containerName = answers.name
41
44
  engine = answers.engine
42
45
  version = answers.version
46
+ database = answers.database
43
47
  }
44
48
 
49
+ // Default database name to container name if not specified
50
+ database = database ?? containerName
51
+
45
52
  console.log(header('Creating Database Container'))
46
53
  console.log()
47
54
 
@@ -97,19 +104,20 @@ export const createCommand = new Command('create')
97
104
  engine: dbEngine.name,
98
105
  version,
99
106
  port,
107
+ database,
100
108
  })
101
109
 
102
110
  createSpinnerInstance.succeed('Container created')
103
111
 
104
- // Initialize database
105
- const initSpinner = createSpinner('Initializing database...')
112
+ // Initialize database cluster
113
+ const initSpinner = createSpinner('Initializing database cluster...')
106
114
  initSpinner.start()
107
115
 
108
116
  await dbEngine.initDataDir(containerName, version, {
109
117
  superuser: defaults.superuser,
110
118
  })
111
119
 
112
- initSpinner.succeed('Database initialized')
120
+ initSpinner.succeed('Database cluster initialized')
113
121
 
114
122
  // Start container if requested
115
123
  if (options.start !== false) {
@@ -125,6 +133,18 @@ export const createCommand = new Command('create')
125
133
  }
126
134
 
127
135
  startSpinner.succeed('PostgreSQL started')
136
+
137
+ // Create the user's database (if different from 'postgres')
138
+ if (config && database !== 'postgres') {
139
+ const dbSpinner = createSpinner(
140
+ `Creating database "${database}"...`,
141
+ )
142
+ dbSpinner.start()
143
+
144
+ await dbEngine.createDatabase(config, database)
145
+
146
+ dbSpinner.succeed(`Database "${database}" created`)
147
+ }
128
148
  }
129
149
 
130
150
  // Show success message