@sidgaikwad/db-setup 1.1.0 → 1.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 +232 -62
- package/dist/index.js +2672 -24906
- package/dist/providers/railway-pg.d.ts.map +1 -1
- package/dist/providers/supabase.d.ts +0 -4
- package/dist/providers/supabase.d.ts.map +1 -1
- package/package.json +9 -5
- package/postinstall.js +57 -0
package/README.md
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
# 🗄️
|
|
1
|
+
# 🗄️ Database Setup CLI
|
|
2
2
|
|
|
3
|
-
> Interactive CLI for setting up PostgreSQL databases with multiple providers
|
|
3
|
+
> Interactive CLI for setting up PostgreSQL databases with multiple providers (Neon, Supabase, Railway, Local Docker)
|
|
4
4
|
|
|
5
|
-
[](https://www.npmjs.com/package/@sidgaikwad/db-setup)
|
|
6
6
|
[](https://opensource.org/licenses/MIT)
|
|
7
7
|
|
|
8
8
|
## ✨ Features
|
|
@@ -10,51 +10,147 @@
|
|
|
10
10
|
- 🎯 **Multiple Providers**: Neon, Supabase, Railway, Local Docker
|
|
11
11
|
- 🌍 **Region Selection**: Choose from 11+ global regions with emoji flags
|
|
12
12
|
- ⚙️ **Auto Configuration**: Automatically writes database URL to .env
|
|
13
|
-
- 📁 **Custom .env Paths**: Support for any .env file location
|
|
14
|
-
- 🏷️ **Custom Variable Names**: Use any variable name (DATABASE_URL, POSTGRES_URL,
|
|
13
|
+
- 📁 **Custom .env Paths**: Support for any .env file location
|
|
14
|
+
- 🏷️ **Custom Variable Names**: Use any variable name (DATABASE_URL, POSTGRES_URL, etc.)
|
|
15
15
|
- 💾 **Safe Updates**: Creates backups before modifying files
|
|
16
16
|
- 🔒 **Overwrite Protection**: Asks before overwriting existing variables
|
|
17
17
|
- 🎨 **Beautiful CLI**: Color-coded, interactive prompts
|
|
18
|
-
- 🛡️ **Type Safe**: Written in TypeScript
|
|
19
18
|
- 🚀 **Zero Config**: Works out of the box with Bun or Node.js
|
|
20
|
-
- ⚡ **Fast**: Optimized for Bun runtime
|
|
21
19
|
|
|
22
20
|
## 🚀 Quick Start
|
|
23
21
|
|
|
24
|
-
### Run
|
|
22
|
+
### Option 1: Run Without Installing (Recommended)
|
|
25
23
|
|
|
26
24
|
```bash
|
|
27
|
-
|
|
25
|
+
# With Bun
|
|
26
|
+
bunx @sidgaikwad/db-setup
|
|
27
|
+
|
|
28
|
+
# With npm
|
|
29
|
+
npx @sidgaikwad/db-setup
|
|
28
30
|
```
|
|
29
31
|
|
|
30
|
-
###
|
|
32
|
+
### Option 2: Install Locally
|
|
31
33
|
|
|
32
34
|
```bash
|
|
33
|
-
|
|
35
|
+
# With Bun
|
|
36
|
+
bun add @sidgaikwad/db-setup
|
|
37
|
+
|
|
38
|
+
# With npm
|
|
39
|
+
npm install @sidgaikwad/db-setup
|
|
40
|
+
|
|
41
|
+
# With pnpm
|
|
42
|
+
pnpm add @sidgaikwad/db-setup
|
|
43
|
+
|
|
44
|
+
# With yarn
|
|
45
|
+
yarn add @sidgaikwad/db-setup
|
|
34
46
|
```
|
|
35
47
|
|
|
36
|
-
|
|
48
|
+
**Then run:**
|
|
49
|
+
|
|
50
|
+
```bash
|
|
51
|
+
# Using package scripts
|
|
52
|
+
bun run create-db-setup
|
|
53
|
+
# or
|
|
54
|
+
npm run create-db-setup
|
|
55
|
+
|
|
56
|
+
# Using npx/bunx
|
|
57
|
+
bunx @sidgaikwad/db-setup
|
|
58
|
+
# or
|
|
59
|
+
npx @sidgaikwad/db-setup
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
### Option 3: Install Globally
|
|
37
63
|
|
|
38
64
|
```bash
|
|
39
65
|
# With Bun
|
|
40
|
-
bun install -g @sidgaikwad/
|
|
66
|
+
bun install -g @sidgaikwad/db-setup
|
|
41
67
|
|
|
42
68
|
# With npm
|
|
43
|
-
npm install -g @sidgaikwad/
|
|
69
|
+
npm install -g @sidgaikwad/db-setup
|
|
44
70
|
|
|
45
|
-
# Then run
|
|
71
|
+
# Then run anywhere
|
|
46
72
|
create-db-setup
|
|
73
|
+
# or
|
|
74
|
+
db-setup
|
|
47
75
|
```
|
|
48
76
|
|
|
49
|
-
|
|
77
|
+
## 📦 Adding to Your Project
|
|
78
|
+
|
|
79
|
+
### In Next.js, Remix, or any Node.js project:
|
|
50
80
|
|
|
51
81
|
```bash
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
82
|
+
# Install the package
|
|
83
|
+
bun add @sidgaikwad/db-setup
|
|
84
|
+
|
|
85
|
+
# Add to package.json scripts (optional)
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
**package.json:**
|
|
89
|
+
|
|
90
|
+
```json
|
|
91
|
+
{
|
|
92
|
+
"scripts": {
|
|
93
|
+
"db:setup": "create-db-setup",
|
|
94
|
+
"setup": "create-db-setup"
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
**Then run:**
|
|
100
|
+
|
|
101
|
+
```bash
|
|
102
|
+
bun run db:setup
|
|
103
|
+
# or
|
|
104
|
+
npm run db:setup
|
|
55
105
|
```
|
|
56
106
|
|
|
57
|
-
##
|
|
107
|
+
## 🎯 Usage
|
|
108
|
+
|
|
109
|
+
```bash
|
|
110
|
+
$ bunx @sidgaikwad/db-setup
|
|
111
|
+
|
|
112
|
+
🗄️ Database Setup CLI
|
|
113
|
+
|
|
114
|
+
Configure your PostgreSQL database with ease!
|
|
115
|
+
|
|
116
|
+
================ Database Setup ================
|
|
117
|
+
|
|
118
|
+
? Choose your PostgreSQL provider: (Use arrow keys)
|
|
119
|
+
❯ Neon (Serverless PostgreSQL)
|
|
120
|
+
Supabase (Open Source Firebase Alternative)
|
|
121
|
+
Railway (Platform as a Service)
|
|
122
|
+
Local PostgreSQL (Docker)
|
|
123
|
+
I already have a DATABASE_URL
|
|
124
|
+
I'll configure later
|
|
125
|
+
|
|
126
|
+
[Select your provider and follow the interactive setup]
|
|
127
|
+
|
|
128
|
+
================ Environment Configuration ================
|
|
129
|
+
|
|
130
|
+
? Select your .env file location: (Use arrow keys)
|
|
131
|
+
❯ .env (Root directory)
|
|
132
|
+
.env.local (Local environment)
|
|
133
|
+
.env.development (Development)
|
|
134
|
+
.env.production (Production)
|
|
135
|
+
config/.env (Config directory)
|
|
136
|
+
apps/backend/.env (Monorepo backend)
|
|
137
|
+
Custom path...
|
|
138
|
+
|
|
139
|
+
? Select the environment variable name: (Use arrow keys)
|
|
140
|
+
❯ DATABASE_URL (Standard)
|
|
141
|
+
POSTGRES_URL (Alternative)
|
|
142
|
+
DB_URL (Short form)
|
|
143
|
+
DB_CONNECTION_STRING (Descriptive)
|
|
144
|
+
DIRECT_URL (Prisma direct)
|
|
145
|
+
DATABASE_CONNECTION (Verbose)
|
|
146
|
+
Custom variable name...
|
|
147
|
+
|
|
148
|
+
✅ Database configured successfully!
|
|
149
|
+
|
|
150
|
+
🎉 Setup completed successfully!
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
## 📚 Supported Providers
|
|
58
154
|
|
|
59
155
|
### 🔷 Neon (Serverless PostgreSQL)
|
|
60
156
|
|
|
@@ -62,6 +158,7 @@ db-setup
|
|
|
62
158
|
- 11 global regions (AWS + Azure)
|
|
63
159
|
- Pooled connections
|
|
64
160
|
- Free tier available
|
|
161
|
+
- **Regions**: US East, US West, EU Central, EU West, Asia Pacific, South America
|
|
65
162
|
|
|
66
163
|
### 🟢 Supabase (Open Source Firebase Alternative)
|
|
67
164
|
|
|
@@ -69,73 +166,138 @@ db-setup
|
|
|
69
166
|
- Global region selection
|
|
70
167
|
- Connection pooling
|
|
71
168
|
- Generous free tier
|
|
169
|
+
- **Features**: Real-time, Auth, Storage, Edge Functions
|
|
72
170
|
|
|
73
171
|
### 🚂 Railway (Platform as a Service)
|
|
74
172
|
|
|
75
173
|
- One-click PostgreSQL deployment
|
|
76
174
|
- Automatic environment variables
|
|
77
175
|
- Simple pricing
|
|
176
|
+
- **Perfect for**: Quick deployments, side projects
|
|
78
177
|
|
|
79
178
|
### 🐳 Local Docker
|
|
80
179
|
|
|
81
180
|
- Instant local PostgreSQL
|
|
82
181
|
- Pre-configured docker-compose
|
|
83
182
|
- Perfect for development
|
|
183
|
+
- No cloud account needed
|
|
84
184
|
|
|
85
|
-
##
|
|
185
|
+
## 🛠️ Requirements
|
|
186
|
+
|
|
187
|
+
- Node.js >= 18.0.0 OR Bun >= 1.0.0
|
|
188
|
+
- npm, yarn, pnpm, or bun
|
|
86
189
|
|
|
87
|
-
|
|
190
|
+
## 💡 Examples
|
|
191
|
+
|
|
192
|
+
### Example 1: Standard Setup
|
|
88
193
|
|
|
89
194
|
```bash
|
|
90
|
-
|
|
195
|
+
bunx @sidgaikwad/db-setup
|
|
196
|
+
# Select: Neon
|
|
197
|
+
# Select: .env (Root directory)
|
|
198
|
+
# Select: DATABASE_URL (Standard)
|
|
199
|
+
```
|
|
91
200
|
|
|
92
|
-
|
|
201
|
+
### Example 2: Monorepo Setup
|
|
93
202
|
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
I'll configure later
|
|
203
|
+
```bash
|
|
204
|
+
bunx @sidgaikwad/db-setup
|
|
205
|
+
# Select: Neon
|
|
206
|
+
# Select: apps/backend/.env (Monorepo backend)
|
|
207
|
+
# Select: DATABASE_URL (Standard)
|
|
208
|
+
```
|
|
101
209
|
|
|
102
|
-
|
|
210
|
+
### Example 3: Custom Variable Name
|
|
103
211
|
|
|
104
|
-
|
|
212
|
+
```bash
|
|
213
|
+
bunx @sidgaikwad/db-setup
|
|
214
|
+
# Select: Supabase
|
|
215
|
+
# Select: .env.local (Local environment)
|
|
216
|
+
# Select: POSTGRES_URL (Alternative)
|
|
217
|
+
```
|
|
218
|
+
|
|
219
|
+
### Example 4: Multiple Databases
|
|
105
220
|
|
|
106
|
-
|
|
107
|
-
|
|
221
|
+
```bash
|
|
222
|
+
# Primary database
|
|
223
|
+
bunx @sidgaikwad/db-setup
|
|
224
|
+
# Variable: DATABASE_URL
|
|
108
225
|
|
|
109
|
-
|
|
226
|
+
# Analytics database
|
|
227
|
+
bunx @sidgaikwad/db-setup
|
|
228
|
+
# Variable: ANALYTICS_DATABASE_URL
|
|
110
229
|
```
|
|
111
230
|
|
|
112
|
-
|
|
231
|
+
## 🔧 Integration with Frameworks
|
|
113
232
|
|
|
114
|
-
|
|
233
|
+
### Next.js
|
|
115
234
|
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
-
|
|
119
|
-
|
|
235
|
+
```bash
|
|
236
|
+
bun add @sidgaikwad/db-setup
|
|
237
|
+
bunx @sidgaikwad/db-setup
|
|
238
|
+
# Select: .env.local
|
|
239
|
+
# Select: DATABASE_URL
|
|
240
|
+
```
|
|
120
241
|
|
|
121
|
-
|
|
242
|
+
### Remix
|
|
122
243
|
|
|
123
|
-
|
|
124
|
-
|
|
244
|
+
```bash
|
|
245
|
+
bun add @sidgaikwad/db-setup
|
|
246
|
+
bunx @sidgaikwad/db-setup
|
|
247
|
+
# Select: .env
|
|
248
|
+
# Select: DATABASE_URL
|
|
249
|
+
```
|
|
250
|
+
|
|
251
|
+
### SvelteKit
|
|
252
|
+
|
|
253
|
+
```bash
|
|
254
|
+
bun add @sidgaikwad/db-setup
|
|
255
|
+
bunx @sidgaikwad/db-setup
|
|
256
|
+
# Select: .env
|
|
257
|
+
# Select: DATABASE_URL
|
|
258
|
+
```
|
|
259
|
+
|
|
260
|
+
### Express/Fastify
|
|
261
|
+
|
|
262
|
+
```bash
|
|
263
|
+
npm install @sidgaikwad/db-setup
|
|
264
|
+
npx @sidgaikwad/db-setup
|
|
265
|
+
# Select: .env
|
|
266
|
+
# Select: POSTGRES_URL
|
|
267
|
+
```
|
|
268
|
+
|
|
269
|
+
## 📝 Best Practices
|
|
125
270
|
|
|
126
|
-
|
|
271
|
+
### ✅ DO:
|
|
127
272
|
|
|
128
|
-
|
|
273
|
+
- Use `.env.local` for local development (not committed to git)
|
|
274
|
+
- Use `.env.production` for production-specific variables
|
|
275
|
+
- Use `.env.test` for testing environments
|
|
276
|
+
- Keep backups of your `.env` files (CLI creates them automatically)
|
|
277
|
+
- Use descriptive variable names for multiple databases
|
|
129
278
|
|
|
130
|
-
|
|
131
|
-
import { setupNeon, setupSupabase } from "@sidgaikwad/create-db-setup";
|
|
279
|
+
### ❌ DON'T:
|
|
132
280
|
|
|
133
|
-
|
|
134
|
-
|
|
281
|
+
- Don't commit `.env` files with real credentials to git
|
|
282
|
+
- Don't use the same database for development and production
|
|
283
|
+
- Don't forget to add `.env*` to your `.gitignore`
|
|
135
284
|
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
285
|
+
### 🔒 Security
|
|
286
|
+
|
|
287
|
+
**.gitignore:**
|
|
288
|
+
|
|
289
|
+
```gitignore
|
|
290
|
+
.env
|
|
291
|
+
.env.local
|
|
292
|
+
.env.*.local
|
|
293
|
+
.env.backup
|
|
294
|
+
```
|
|
295
|
+
|
|
296
|
+
**.env.example** (commit this):
|
|
297
|
+
|
|
298
|
+
```env
|
|
299
|
+
# Database Configuration
|
|
300
|
+
DATABASE_URL=postgresql://user:password@localhost:5432/dbname
|
|
139
301
|
```
|
|
140
302
|
|
|
141
303
|
## 🤝 Contributing
|
|
@@ -150,20 +312,28 @@ Contributions are welcome! Please feel free to submit a Pull Request.
|
|
|
150
312
|
|
|
151
313
|
## 📝 License
|
|
152
314
|
|
|
153
|
-
MIT © [
|
|
315
|
+
MIT © [Siddharth Gaikwad](https://github.com/sidgaikwad)
|
|
154
316
|
|
|
155
317
|
## 🙏 Acknowledgments
|
|
156
318
|
|
|
157
319
|
- [@inquirer/prompts](https://github.com/SBoudrias/Inquirer.js) for interactive CLI
|
|
158
320
|
- [chalk](https://github.com/chalk/chalk) for terminal styling
|
|
159
|
-
-
|
|
321
|
+
- [Neon](https://neon.tech), [Supabase](https://supabase.com), [Railway](https://railway.app) for excellent database services
|
|
160
322
|
|
|
161
|
-
## 🐛
|
|
323
|
+
## 🐛 Issues & Support
|
|
162
324
|
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
## 📮 Support
|
|
325
|
+
Found a bug or need help?
|
|
166
326
|
|
|
327
|
+
- 🐛 [Report an issue](https://github.com/sidgaikwad/db-setup/issues)
|
|
328
|
+
- 💬 [Start a discussion](https://github.com/sidgaikwad/db-setup/discussions)
|
|
167
329
|
- 📧 Email: gaikwadsiddharth039@gmail.com
|
|
168
|
-
|
|
169
|
-
|
|
330
|
+
|
|
331
|
+
## 📮 Links
|
|
332
|
+
|
|
333
|
+
- 📦 [NPM Package](https://www.npmjs.com/package/@sidgaikwad/db-setup)
|
|
334
|
+
- 🐙 [GitHub Repository](https://github.com/sidgaikwad/db-setup)
|
|
335
|
+
- 📚 [Documentation](https://github.com/sidgaikwad/db-setup#readme)
|
|
336
|
+
|
|
337
|
+
---
|
|
338
|
+
|
|
339
|
+
Made with ❤️ by [Siddharth Gaikwad](https://github.com/sidgaikwad)
|