create-pg 1.1.1-pr67-overhaul-20177069937.0 → 1.1.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 +32 -192
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -1,239 +1,79 @@
|
|
|
1
|
-
# create-
|
|
1
|
+
# create-pg
|
|
2
2
|
|
|
3
|
-
`create-
|
|
3
|
+
`create-pg` is an alias for [`create-db`](https://www.npmjs.com/package/create-db) - an open-source CLI tool and library that provisions [**temporary Prisma Postgres databases**](https://www.prisma.io/postgres?utm_source=create_db_npm_docs) with a single command.
|
|
4
4
|
|
|
5
5
|
Each database is available for **24 hours** by default. To keep the database permanently, you can **claim it for free** using the URL displayed in the output.
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
## Installation and Usage
|
|
10
|
-
|
|
11
|
-
No installation required. Simply run:
|
|
12
|
-
|
|
13
|
-
```bash
|
|
14
|
-
npx create-db@latest
|
|
15
|
-
```
|
|
16
|
-
|
|
17
|
-
You can also use these aliases:
|
|
7
|
+
## Quick Start
|
|
18
8
|
|
|
19
9
|
```bash
|
|
20
10
|
npx create-pg@latest
|
|
21
|
-
npx create-postgres@latest
|
|
22
11
|
```
|
|
23
12
|
|
|
24
13
|
## CLI Usage
|
|
25
14
|
|
|
26
|
-
### Commands
|
|
27
|
-
|
|
28
|
-
```bash
|
|
29
|
-
npx create-db [create] # Create a new database (default command)
|
|
30
|
-
npx create-db regions # List available regions
|
|
31
|
-
```
|
|
32
|
-
|
|
33
|
-
### Options
|
|
34
|
-
|
|
35
|
-
| Flag | Alias | Description |
|
|
36
|
-
|------|-------|-------------|
|
|
37
|
-
| `--region <region>` | `-r` | AWS region for the database |
|
|
38
|
-
| `--interactive` | `-i` | Interactive mode to select a region |
|
|
39
|
-
| `--json` | `-j` | Output machine-readable JSON |
|
|
40
|
-
| `--env <path>` | `-e` | Write DATABASE_URL and CLAIM_URL to specified .env file |
|
|
41
|
-
| `--help` | `-h` | Show help message |
|
|
42
|
-
| `--version` | | Show version |
|
|
43
|
-
|
|
44
|
-
### Available Regions
|
|
45
|
-
|
|
46
|
-
- `ap-southeast-1` - Asia Pacific (Singapore)
|
|
47
|
-
- `ap-northeast-1` - Asia Pacific (Tokyo)
|
|
48
|
-
- `eu-central-1` - Europe (Frankfurt)
|
|
49
|
-
- `eu-west-3` - Europe (Paris)
|
|
50
|
-
- `us-east-1` - US East (N. Virginia)
|
|
51
|
-
- `us-west-1` - US West (N. California)
|
|
52
|
-
|
|
53
|
-
### Examples
|
|
54
|
-
|
|
55
15
|
```bash
|
|
56
16
|
# Create database in auto-detected nearest region
|
|
57
|
-
npx create-
|
|
17
|
+
npx create-pg
|
|
58
18
|
|
|
59
19
|
# Create database in a specific region
|
|
60
|
-
npx create-
|
|
61
|
-
npx create-
|
|
20
|
+
npx create-pg --region eu-west-3
|
|
21
|
+
npx create-pg -r us-east-1
|
|
62
22
|
|
|
63
23
|
# Interactive region selection
|
|
64
|
-
npx create-
|
|
65
|
-
npx create-
|
|
24
|
+
npx create-pg --interactive
|
|
25
|
+
npx create-pg -i
|
|
66
26
|
|
|
67
|
-
# Output as JSON
|
|
68
|
-
npx create-
|
|
69
|
-
npx create-
|
|
27
|
+
# Output as JSON
|
|
28
|
+
npx create-pg --json
|
|
29
|
+
npx create-pg -j
|
|
70
30
|
|
|
71
31
|
# Write connection string to .env file
|
|
72
|
-
npx create-
|
|
73
|
-
npx create-
|
|
74
|
-
|
|
75
|
-
# Combine flags
|
|
76
|
-
npx create-db -r eu-central-1 -j
|
|
77
|
-
npx create-db -i -e .env
|
|
32
|
+
npx create-pg --env .env
|
|
33
|
+
npx create-pg -e .env.local
|
|
78
34
|
|
|
79
35
|
# List available regions
|
|
80
|
-
npx create-
|
|
81
|
-
```
|
|
82
|
-
|
|
83
|
-
### JSON Output
|
|
84
|
-
|
|
85
|
-
When using `--json`, the output includes:
|
|
86
|
-
|
|
87
|
-
```json
|
|
88
|
-
{
|
|
89
|
-
"success": true,
|
|
90
|
-
"connectionString": "postgresql://user:pass@host:5432/postgres?sslmode=require",
|
|
91
|
-
"claimUrl": "https://create-db.prisma.io/claim?projectID=...",
|
|
92
|
-
"deletionDate": "2025-12-13T12:00:00.000Z",
|
|
93
|
-
"region": "us-east-1",
|
|
94
|
-
"name": "2025-12-12T12:00:00.000Z",
|
|
95
|
-
"projectId": "proj_..."
|
|
96
|
-
}
|
|
36
|
+
npx create-pg regions
|
|
97
37
|
```
|
|
98
38
|
|
|
99
|
-
###
|
|
100
|
-
|
|
101
|
-
When using `--env`, the following variables are appended to the specified file:
|
|
39
|
+
### Options
|
|
102
40
|
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
41
|
+
| Flag | Alias | Description |
|
|
42
|
+
|------|-------|-------------|
|
|
43
|
+
| `--region <region>` | `-r` | AWS region for the database |
|
|
44
|
+
| `--interactive` | `-i` | Interactive mode to select a region |
|
|
45
|
+
| `--json` | `-j` | Output machine-readable JSON |
|
|
46
|
+
| `--env <path>` | `-e` | Write DATABASE_URL and CLAIM_URL to specified .env file |
|
|
47
|
+
| `--help` | `-h` | Show help message |
|
|
107
48
|
|
|
108
49
|
## Programmatic API
|
|
109
50
|
|
|
110
|
-
You can also use `create-db` as a library in your Node.js applications:
|
|
111
|
-
|
|
112
|
-
```bash
|
|
113
|
-
npm install create-db
|
|
114
|
-
# or
|
|
115
|
-
bun add create-db
|
|
116
|
-
```
|
|
117
|
-
|
|
118
|
-
### `create(options?)`
|
|
119
|
-
|
|
120
|
-
Create a new Prisma Postgres database programmatically.
|
|
121
|
-
|
|
122
51
|
```typescript
|
|
123
|
-
import { create } from "create-
|
|
52
|
+
import { create, regions } from "create-pg";
|
|
124
53
|
|
|
54
|
+
// Create a database
|
|
125
55
|
const result = await create({ region: "us-east-1" });
|
|
126
56
|
|
|
127
57
|
if (result.success) {
|
|
128
58
|
console.log(`Connection string: ${result.connectionString}`);
|
|
129
59
|
console.log(`Claim URL: ${result.claimUrl}`);
|
|
130
|
-
console.log(`Expires: ${result.deletionDate}`);
|
|
131
60
|
} else {
|
|
132
61
|
console.error(`Error: ${result.message}`);
|
|
133
62
|
}
|
|
134
|
-
```
|
|
135
|
-
|
|
136
|
-
#### Options
|
|
137
|
-
|
|
138
|
-
| Option | Type | Description |
|
|
139
|
-
|--------|------|-------------|
|
|
140
|
-
| `region` | `RegionId` | AWS region for the database (optional, defaults to `us-east-1`) |
|
|
141
|
-
| `userAgent` | `string` | Custom user agent string for tracking (optional) |
|
|
142
|
-
|
|
143
|
-
### `regions()`
|
|
144
|
-
|
|
145
|
-
List available Prisma Postgres regions.
|
|
146
|
-
|
|
147
|
-
```typescript
|
|
148
|
-
import { regions } from "create-db";
|
|
149
63
|
|
|
64
|
+
// List available regions
|
|
150
65
|
const availableRegions = await regions();
|
|
151
|
-
console.log(availableRegions);
|
|
152
|
-
// [{ id: "us-east-1", name: "US East (N. Virginia)", status: "available" }, ...]
|
|
153
66
|
```
|
|
154
67
|
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
```typescript
|
|
158
|
-
import { create, isDatabaseSuccess, isDatabaseError } from "create-db";
|
|
159
|
-
|
|
160
|
-
const result = await create();
|
|
161
|
-
|
|
162
|
-
if (isDatabaseSuccess(result)) {
|
|
163
|
-
// result is DatabaseResult
|
|
164
|
-
console.log(result.connectionString);
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
if (isDatabaseError(result)) {
|
|
168
|
-
// result is DatabaseError
|
|
169
|
-
console.error(result.message);
|
|
170
|
-
}
|
|
171
|
-
```
|
|
68
|
+
## Aliases
|
|
172
69
|
|
|
173
|
-
|
|
70
|
+
You can also use:
|
|
174
71
|
|
|
175
|
-
```
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
RegionId,
|
|
179
|
-
CreateDatabaseResult,
|
|
180
|
-
DatabaseResult,
|
|
181
|
-
DatabaseError,
|
|
182
|
-
ProgrammaticCreateOptions,
|
|
183
|
-
} from "create-db";
|
|
184
|
-
|
|
185
|
-
// RegionId is a union type of available regions
|
|
186
|
-
type RegionId = "ap-southeast-1" | "ap-northeast-1" | "eu-central-1" | "eu-west-3" | "us-east-1" | "us-west-1";
|
|
187
|
-
|
|
188
|
-
// DatabaseResult (success)
|
|
189
|
-
interface DatabaseResult {
|
|
190
|
-
success: true;
|
|
191
|
-
connectionString: string | null;
|
|
192
|
-
claimUrl: string;
|
|
193
|
-
deletionDate: string;
|
|
194
|
-
region: string;
|
|
195
|
-
name: string;
|
|
196
|
-
projectId: string;
|
|
197
|
-
userAgent?: string;
|
|
198
|
-
}
|
|
199
|
-
|
|
200
|
-
// DatabaseError (failure)
|
|
201
|
-
interface DatabaseError {
|
|
202
|
-
success: false;
|
|
203
|
-
error: string;
|
|
204
|
-
message: string;
|
|
205
|
-
raw?: string;
|
|
206
|
-
details?: unknown;
|
|
207
|
-
status?: number;
|
|
208
|
-
}
|
|
209
|
-
|
|
210
|
-
// CreateDatabaseResult is DatabaseResult | DatabaseError
|
|
211
|
-
```
|
|
212
|
-
|
|
213
|
-
### Region Validation with Zod
|
|
214
|
-
|
|
215
|
-
```typescript
|
|
216
|
-
import { RegionSchema } from "create-db";
|
|
217
|
-
|
|
218
|
-
// Validate region input
|
|
219
|
-
const result = RegionSchema.safeParse("us-east-1");
|
|
220
|
-
if (result.success) {
|
|
221
|
-
console.log("Valid region:", result.data);
|
|
222
|
-
}
|
|
72
|
+
```bash
|
|
73
|
+
npx create-db@latest
|
|
74
|
+
npx create-postgres@latest
|
|
223
75
|
```
|
|
224
76
|
|
|
225
|
-
##
|
|
226
|
-
|
|
227
|
-
When you create a database, it is temporary and will be deleted after **24 hours**.
|
|
228
|
-
|
|
229
|
-
The output includes a **claim URL** that allows you to keep the database permanently for free.
|
|
230
|
-
|
|
231
|
-
**What claiming does:**
|
|
232
|
-
|
|
233
|
-
- Moves the database into your Prisma Data Platform account
|
|
234
|
-
- Prevents it from being auto-deleted
|
|
235
|
-
- Lets you continue using the database as a long-term instance
|
|
236
|
-
|
|
237
|
-
## Next Steps
|
|
77
|
+
## Documentation
|
|
238
78
|
|
|
239
|
-
|
|
79
|
+
For full documentation, see the [create-db README](https://github.com/prisma/create-db/tree/main/create-db#readme).
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "create-pg",
|
|
3
|
-
"version": "1.1.1
|
|
3
|
+
"version": "1.1.1",
|
|
4
4
|
"description": "Instantly create a temporary Prisma Postgres database with one command, then claim and persist it in your Prisma Data Platform project when ready.",
|
|
5
5
|
"author": "prisma",
|
|
6
6
|
"repository": {
|
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
"create-pg": "./cli.js"
|
|
37
37
|
},
|
|
38
38
|
"dependencies": {
|
|
39
|
-
"create-db": "1.1.1
|
|
39
|
+
"create-db": "1.1.1"
|
|
40
40
|
},
|
|
41
41
|
"publishConfig": {
|
|
42
42
|
"access": "public"
|