@sidgaikwad/db-setup 1.0.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/LICENSE +21 -0
- package/README.md +169 -0
- package/bin/cli.js +5 -0
- package/dist/database.d.ts +2 -0
- package/dist/database.d.ts.map +1 -0
- package/dist/env.d.ts +30 -0
- package/dist/env.d.ts.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +28167 -0
- package/dist/providers/local-docker.d.ts +5 -0
- package/dist/providers/local-docker.d.ts.map +1 -0
- package/dist/providers/neon.d.ts +5 -0
- package/dist/providers/neon.d.ts.map +1 -0
- package/dist/providers/railway-pg.d.ts +2 -0
- package/dist/providers/railway-pg.d.ts.map +1 -0
- package/dist/providers/supabase.d.ts +5 -0
- package/dist/providers/supabase.d.ts.map +1 -0
- package/dist/utils/db-utils.d.ts +12 -0
- package/dist/utils/db-utils.d.ts.map +1 -0
- package/package.json +62 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024 siddharth
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
# 🗄️ Create DB Setup
|
|
2
|
+
|
|
3
|
+
> Interactive CLI for setting up PostgreSQL databases with multiple providers
|
|
4
|
+
|
|
5
|
+
[](https://www.npmjs.com/package/@sidgaikwad/create-db-setup)
|
|
6
|
+
[](https://opensource.org/licenses/MIT)
|
|
7
|
+
|
|
8
|
+
## ✨ Features
|
|
9
|
+
|
|
10
|
+
- 🎯 **Multiple Providers**: Neon, Supabase, Railway, Local Docker
|
|
11
|
+
- 🌍 **Region Selection**: Choose from 11+ global regions with emoji flags
|
|
12
|
+
- ⚙️ **Auto Configuration**: Automatically writes database URL to .env
|
|
13
|
+
- 📁 **Custom .env Paths**: Support for any .env file location (.env, .env.local, config/.env, etc.)
|
|
14
|
+
- 🏷️ **Custom Variable Names**: Use any variable name (DATABASE_URL, POSTGRES_URL, DB_URL, etc.)
|
|
15
|
+
- 💾 **Safe Updates**: Creates backups before modifying files
|
|
16
|
+
- 🔒 **Overwrite Protection**: Asks before overwriting existing variables
|
|
17
|
+
- 🎨 **Beautiful CLI**: Color-coded, interactive prompts
|
|
18
|
+
- 🛡️ **Type Safe**: Written in TypeScript
|
|
19
|
+
- 🚀 **Zero Config**: Works out of the box with Bun or Node.js
|
|
20
|
+
- ⚡ **Fast**: Optimized for Bun runtime
|
|
21
|
+
|
|
22
|
+
## 🚀 Quick Start
|
|
23
|
+
|
|
24
|
+
### Run with bunx (Recommended)
|
|
25
|
+
|
|
26
|
+
```bash
|
|
27
|
+
bunx @sidgaikwad/create-db-setup
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
### Or with npx
|
|
31
|
+
|
|
32
|
+
```bash
|
|
33
|
+
npx @sidgaikwad/create-db-setup
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
### Or Install Globally
|
|
37
|
+
|
|
38
|
+
```bash
|
|
39
|
+
# With Bun
|
|
40
|
+
bun install -g @sidgaikwad/create-db-setup
|
|
41
|
+
|
|
42
|
+
# With npm
|
|
43
|
+
npm install -g @sidgaikwad/create-db-setup
|
|
44
|
+
|
|
45
|
+
# Then run
|
|
46
|
+
create-db-setup
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
### Or use the shorter alias
|
|
50
|
+
|
|
51
|
+
```bash
|
|
52
|
+
bunx @sidgaikwad/create-db-setup
|
|
53
|
+
# or after global install
|
|
54
|
+
db-setup
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
## 📦 Supported Providers
|
|
58
|
+
|
|
59
|
+
### 🔷 Neon (Serverless PostgreSQL)
|
|
60
|
+
|
|
61
|
+
- Automatic CLI authentication
|
|
62
|
+
- 11 global regions (AWS + Azure)
|
|
63
|
+
- Pooled connections
|
|
64
|
+
- Free tier available
|
|
65
|
+
|
|
66
|
+
### 🟢 Supabase (Open Source Firebase Alternative)
|
|
67
|
+
|
|
68
|
+
- Project creation via CLI
|
|
69
|
+
- Global region selection
|
|
70
|
+
- Connection pooling
|
|
71
|
+
- Generous free tier
|
|
72
|
+
|
|
73
|
+
### 🚂 Railway (Platform as a Service)
|
|
74
|
+
|
|
75
|
+
- One-click PostgreSQL deployment
|
|
76
|
+
- Automatic environment variables
|
|
77
|
+
- Simple pricing
|
|
78
|
+
|
|
79
|
+
### 🐳 Local Docker
|
|
80
|
+
|
|
81
|
+
- Instant local PostgreSQL
|
|
82
|
+
- Pre-configured docker-compose
|
|
83
|
+
- Perfect for development
|
|
84
|
+
|
|
85
|
+
## 🎯 Usage
|
|
86
|
+
|
|
87
|
+
Simply run the CLI and follow the prompts:
|
|
88
|
+
|
|
89
|
+
```bash
|
|
90
|
+
$ bunx @sidgaikwad/create-db-setup
|
|
91
|
+
|
|
92
|
+
================ Database Setup ================
|
|
93
|
+
|
|
94
|
+
? Choose your PostgreSQL provider:
|
|
95
|
+
❯ Neon (Serverless)
|
|
96
|
+
Supabase (Cloud)
|
|
97
|
+
Railway
|
|
98
|
+
Local PostgreSQL (Docker)
|
|
99
|
+
I already have a DATABASE_URL
|
|
100
|
+
I'll configure later
|
|
101
|
+
|
|
102
|
+
[Select your provider and follow the interactive setup]
|
|
103
|
+
|
|
104
|
+
================ Environment Configuration ================
|
|
105
|
+
|
|
106
|
+
? Enter the path to your .env file: .env
|
|
107
|
+
? Enter the environment variable name for your database URL: DATABASE_URL
|
|
108
|
+
|
|
109
|
+
✅ DATABASE_URL has been added to your .env file!
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
### Flexible Configuration
|
|
113
|
+
|
|
114
|
+
The CLI now supports:
|
|
115
|
+
|
|
116
|
+
- **Custom .env file paths**: `.env`, `.env.local`, `config/.env`, etc.
|
|
117
|
+
- **Custom variable names**: `DATABASE_URL`, `POSTGRES_URL`, `DB_CONNECTION_STRING`, etc.
|
|
118
|
+
- **Automatic backup**: Creates `.env.backup` before making changes
|
|
119
|
+
- **Overwrite protection**: Asks before overwriting existing variables
|
|
120
|
+
|
|
121
|
+
## 🛠️ Requirements
|
|
122
|
+
|
|
123
|
+
- Node.js >= 18.0.0 OR Bun >= 1.0.0
|
|
124
|
+
- npm or yarn or pnpm or bun
|
|
125
|
+
|
|
126
|
+
## 📚 API
|
|
127
|
+
|
|
128
|
+
You can also use this as a library in your own Node.js projects:
|
|
129
|
+
|
|
130
|
+
```typescript
|
|
131
|
+
import { setupNeon, setupSupabase } from "@sidgaikwad/create-db-setup";
|
|
132
|
+
|
|
133
|
+
// Use individual provider setups
|
|
134
|
+
const databaseUrl = await setupNeon();
|
|
135
|
+
|
|
136
|
+
// Or use the interactive CLI
|
|
137
|
+
import { handleDatabaseSetup } from "@sidgaikwad/create-db-setup";
|
|
138
|
+
const databaseUrl = await handleDatabaseSetup();
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
## 🤝 Contributing
|
|
142
|
+
|
|
143
|
+
Contributions are welcome! Please feel free to submit a Pull Request.
|
|
144
|
+
|
|
145
|
+
1. Fork the repository
|
|
146
|
+
2. Create your feature branch (`git checkout -b feature/AmazingFeature`)
|
|
147
|
+
3. Commit your changes (`git commit -m 'Add some AmazingFeature'`)
|
|
148
|
+
4. Push to the branch (`git push origin feature/AmazingFeature`)
|
|
149
|
+
5. Open a Pull Request
|
|
150
|
+
|
|
151
|
+
## 📝 License
|
|
152
|
+
|
|
153
|
+
MIT © [siddharth]
|
|
154
|
+
|
|
155
|
+
## 🙏 Acknowledgments
|
|
156
|
+
|
|
157
|
+
- [@inquirer/prompts](https://github.com/SBoudrias/Inquirer.js) for interactive CLI
|
|
158
|
+
- [chalk](https://github.com/chalk/chalk) for terminal styling
|
|
159
|
+
- All the database providers for their excellent CLIs
|
|
160
|
+
|
|
161
|
+
## 🐛 Known Issues
|
|
162
|
+
|
|
163
|
+
See [GitHub Issues](https://github.com/sidgaikwad/create-db-setup/issues)
|
|
164
|
+
|
|
165
|
+
## 📮 Support
|
|
166
|
+
|
|
167
|
+
- 📧 Email: gaikwadsiddharth039@gmail.com
|
|
168
|
+
- 🐦 Twitter: [_sidd24_](https://twitter.com/_sidd24_)
|
|
169
|
+
- 💬 Discord: [Join our server](https://discord.gg/mJp3dckf)
|
package/bin/cli.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"database.d.ts","sourceRoot":"","sources":["../src/database.ts"],"names":[],"mappings":"AAQA,wBAAsB,mBAAmB,IAAI,OAAO,CAAC,MAAM,CAAC,CAmF3D"}
|
package/dist/env.d.ts
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
interface EnvConfig {
|
|
2
|
+
envPath: string;
|
|
3
|
+
variableName: string;
|
|
4
|
+
}
|
|
5
|
+
/**
|
|
6
|
+
* Initialize .env file from .env.example if it exists
|
|
7
|
+
*/
|
|
8
|
+
export declare function initializeEnvFile(): void;
|
|
9
|
+
/**
|
|
10
|
+
* Ask user for .env file location and variable name
|
|
11
|
+
*/
|
|
12
|
+
export declare function getEnvConfig(): Promise<EnvConfig>;
|
|
13
|
+
/**
|
|
14
|
+
* Write database URL to .env file
|
|
15
|
+
*/
|
|
16
|
+
export declare function writeDatabaseUrl(databaseUrl: string, config: EnvConfig): Promise<void>;
|
|
17
|
+
/**
|
|
18
|
+
* Show the configured database URL (masked for security)
|
|
19
|
+
*/
|
|
20
|
+
export declare function showDatabaseUrl(databaseUrl: string, variableName: string): void;
|
|
21
|
+
/**
|
|
22
|
+
* Validate if a string is a valid PostgreSQL connection string
|
|
23
|
+
*/
|
|
24
|
+
export declare function validateConnectionString(url: string): boolean;
|
|
25
|
+
/**
|
|
26
|
+
* Complete environment setup flow
|
|
27
|
+
*/
|
|
28
|
+
export declare function setupEnvironment(databaseUrl: string): Promise<void>;
|
|
29
|
+
export {};
|
|
30
|
+
//# sourceMappingURL=env.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"env.d.ts","sourceRoot":"","sources":["../src/env.ts"],"names":[],"mappings":"AAKA,UAAU,SAAS;IACjB,OAAO,EAAE,MAAM,CAAC;IAChB,YAAY,EAAE,MAAM,CAAC;CACtB;AAED;;GAEG;AACH,wBAAgB,iBAAiB,IAAI,IAAI,CASxC;AAED;;GAEG;AACH,wBAAsB,YAAY,IAAI,OAAO,CAAC,SAAS,CAAC,CAwHvD;AAED;;GAEG;AACH,wBAAsB,gBAAgB,CACpC,WAAW,EAAE,MAAM,EACnB,MAAM,EAAE,SAAS,GAChB,OAAO,CAAC,IAAI,CAAC,CAqDf;AAED;;GAEG;AACH,wBAAgB,eAAe,CAC7B,WAAW,EAAE,MAAM,EACnB,YAAY,EAAE,MAAM,GACnB,IAAI,CAMN;AAED;;GAEG;AACH,wBAAgB,wBAAwB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAG7D;AAED;;GAEG;AACH,wBAAsB,gBAAgB,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAiBzE"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":""}
|