@autoship/react 0.5.1 → 0.6.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/README.md +5 -4
- package/dist/cli/init.d.ts.map +1 -1
- package/dist/cli/init.js +39 -43
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -35,13 +35,14 @@ The CLI will prompt you for credentials. You can provide them in two ways:
|
|
|
35
35
|
|
|
36
36
|
```bash
|
|
37
37
|
# Find this in Supabase Dashboard > Project Settings > Database > Connection string > URI
|
|
38
|
-
npx @autoship/react init --database-url "postgresql://postgres
|
|
38
|
+
npx @autoship/react init --database-url "postgresql://postgres:password@db.xxxx.supabase.co:5432/postgres"
|
|
39
39
|
```
|
|
40
40
|
|
|
41
|
-
**Option B:
|
|
41
|
+
**Option B: Project Ref + Database Password**
|
|
42
42
|
|
|
43
43
|
```bash
|
|
44
|
-
|
|
44
|
+
# Find project ref in Supabase Dashboard > Project Settings > General > Reference ID
|
|
45
|
+
npx @autoship/react init --project-ref abcdefghijklmnop --db-password yourpassword
|
|
45
46
|
```
|
|
46
47
|
|
|
47
48
|
**Using environment variables:**
|
|
@@ -51,7 +52,7 @@ npx @autoship/react init --supabase-url https://xxx.supabase.co --db-password yo
|
|
|
51
52
|
DATABASE_URL="postgresql://..." npx @autoship/react init
|
|
52
53
|
|
|
53
54
|
# Option B
|
|
54
|
-
|
|
55
|
+
SUPABASE_PROJECT_REF="abcdefghijklmnop" DB_PASSWORD="yourpassword" npx @autoship/react init
|
|
55
56
|
```
|
|
56
57
|
|
|
57
58
|
### 3. Expose the Autoship Schema in Supabase
|
package/dist/cli/init.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"init.d.ts","sourceRoot":"","sources":["../../src/cli/init.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"init.d.ts","sourceRoot":"","sources":["../../src/cli/init.ts"],"names":[],"mappings":"AA4WA,wBAAsB,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAcvD"}
|
package/dist/cli/init.js
CHANGED
|
@@ -35,8 +35,8 @@ function parseArgs(args) {
|
|
|
35
35
|
if (arg === "--database-url" && args[i + 1]) {
|
|
36
36
|
options.databaseUrl = args[++i];
|
|
37
37
|
}
|
|
38
|
-
else if (arg === "--
|
|
39
|
-
options.
|
|
38
|
+
else if (arg === "--project-ref" && args[i + 1]) {
|
|
39
|
+
options.projectRef = args[++i];
|
|
40
40
|
}
|
|
41
41
|
else if (arg === "--db-password" && args[i + 1]) {
|
|
42
42
|
options.dbPassword = args[++i];
|
|
@@ -59,36 +59,38 @@ Usage:
|
|
|
59
59
|
npx @autoship/react init [options]
|
|
60
60
|
|
|
61
61
|
Options:
|
|
62
|
-
--database-url <url>
|
|
63
|
-
--
|
|
64
|
-
--db-password <pwd>
|
|
65
|
-
-y, --non-interactive
|
|
66
|
-
-h, --help
|
|
62
|
+
--database-url <url> Full PostgreSQL connection URL (includes password)
|
|
63
|
+
--project-ref <ref> Supabase project ref (used to construct DATABASE_URL)
|
|
64
|
+
--db-password <pwd> Database password (used with --project-ref)
|
|
65
|
+
-y, --non-interactive Skip confirmation prompts
|
|
66
|
+
-h, --help Show this help message
|
|
67
67
|
|
|
68
68
|
Environment Variables:
|
|
69
|
-
DATABASE_URL
|
|
70
|
-
|
|
71
|
-
DB_PASSWORD
|
|
69
|
+
DATABASE_URL Full PostgreSQL connection URL (preferred)
|
|
70
|
+
SUPABASE_PROJECT_REF Supabase project ref (fallback, requires DB_PASSWORD)
|
|
71
|
+
DB_PASSWORD Database password (used with SUPABASE_PROJECT_REF)
|
|
72
72
|
|
|
73
73
|
Connection Methods:
|
|
74
|
-
1. Provide DATABASE_URL directly
|
|
75
|
-
|
|
74
|
+
1. Provide DATABASE_URL directly:
|
|
75
|
+
Find in Supabase Dashboard > Project Settings > Database > Connection string > URI
|
|
76
76
|
|
|
77
|
-
2. Provide
|
|
78
|
-
|
|
77
|
+
2. Provide SUPABASE_PROJECT_REF + DB_PASSWORD:
|
|
78
|
+
Find project ref in Supabase Dashboard > Project Settings > General > Reference ID
|
|
79
|
+
Find password in Supabase Dashboard > Project Settings > Database > Database password
|
|
79
80
|
|
|
80
81
|
Examples:
|
|
81
82
|
# Interactive mode (prompts for credentials)
|
|
82
83
|
npx @autoship/react init
|
|
83
84
|
|
|
84
85
|
# With full database URL
|
|
85
|
-
npx @autoship/react init --database-url "postgresql://postgres
|
|
86
|
+
npx @autoship/react init --database-url "postgresql://postgres:password@db.xxxx.supabase.co:5432/postgres"
|
|
86
87
|
|
|
87
|
-
# With
|
|
88
|
-
npx @autoship/react init --
|
|
88
|
+
# With project ref + password
|
|
89
|
+
npx @autoship/react init --project-ref abcdefghijklmnop --db-password mypassword
|
|
89
90
|
|
|
90
91
|
# Using environment variables
|
|
91
92
|
DATABASE_URL="postgresql://..." npx @autoship/react init
|
|
93
|
+
SUPABASE_PROJECT_REF="abcdefghijklmnop" DB_PASSWORD="mypassword" npx @autoship/react init
|
|
92
94
|
`);
|
|
93
95
|
}
|
|
94
96
|
function createReadlineInterface() {
|
|
@@ -143,28 +145,20 @@ async function promptSecret(rl, question) {
|
|
|
143
145
|
});
|
|
144
146
|
}
|
|
145
147
|
/**
|
|
146
|
-
* Constructs a DATABASE_URL from a Supabase project
|
|
148
|
+
* Constructs a DATABASE_URL from a Supabase project ref and password.
|
|
147
149
|
*
|
|
148
|
-
*
|
|
149
|
-
* Database URL format: postgresql://postgres
|
|
150
|
+
* Project ref: The unique identifier for your Supabase project (e.g., "abcdefghijklmnop")
|
|
151
|
+
* Database URL format: postgresql://postgres:[password]@db.[project-ref].supabase.co:5432/postgres
|
|
150
152
|
*
|
|
151
|
-
* Note: We use the
|
|
152
|
-
*
|
|
153
|
+
* Note: We use the direct connection (port 5432) instead of the pooler
|
|
154
|
+
* because the pooler requires region-specific endpoints.
|
|
153
155
|
*/
|
|
154
|
-
function constructDatabaseUrl(
|
|
155
|
-
const url = new URL(supabaseUrl);
|
|
156
|
-
const hostname = url.hostname; // e.g., "xxx.supabase.co"
|
|
157
|
-
const projectRef = hostname.split(".")[0];
|
|
156
|
+
function constructDatabaseUrl(projectRef, password) {
|
|
158
157
|
if (!projectRef) {
|
|
159
|
-
throw new Error("
|
|
158
|
+
throw new Error("Project ref is required");
|
|
160
159
|
}
|
|
161
|
-
// Supabase uses different regional pooler endpoints
|
|
162
|
-
// Default to us-east-1, but this can be adjusted
|
|
163
|
-
// The actual region is embedded in the project, but we can't easily detect it
|
|
164
|
-
// Users can provide DATABASE_URL directly if they need a specific region
|
|
165
|
-
const region = "us-east-1";
|
|
166
160
|
const encodedPassword = encodeURIComponent(password);
|
|
167
|
-
return `postgresql://postgres
|
|
161
|
+
return `postgresql://postgres:${encodedPassword}@db.${projectRef}.supabase.co:5432/postgres`;
|
|
168
162
|
}
|
|
169
163
|
async function getConnectionUrl(options) {
|
|
170
164
|
// Priority: CLI args > env vars > interactive prompt
|
|
@@ -173,11 +167,11 @@ async function getConnectionUrl(options) {
|
|
|
173
167
|
if (databaseUrl) {
|
|
174
168
|
return databaseUrl;
|
|
175
169
|
}
|
|
176
|
-
// Check for
|
|
177
|
-
let
|
|
170
|
+
// Check for PROJECT_REF + DB_PASSWORD combination
|
|
171
|
+
let projectRef = options.projectRef || process.env.SUPABASE_PROJECT_REF;
|
|
178
172
|
let dbPassword = options.dbPassword || process.env.DB_PASSWORD;
|
|
179
|
-
if (
|
|
180
|
-
return constructDatabaseUrl(
|
|
173
|
+
if (projectRef && dbPassword) {
|
|
174
|
+
return constructDatabaseUrl(projectRef, dbPassword);
|
|
181
175
|
}
|
|
182
176
|
// Interactive mode
|
|
183
177
|
const rl = createReadlineInterface();
|
|
@@ -186,8 +180,8 @@ async function getConnectionUrl(options) {
|
|
|
186
180
|
console.log(" This will create the required tables in your Supabase database.\n");
|
|
187
181
|
console.log(" You can provide credentials in two ways:");
|
|
188
182
|
console.log(" 1. Full DATABASE_URL (includes password)");
|
|
189
|
-
console.log(" 2. Supabase
|
|
190
|
-
const choice = await prompt(rl, " Enter (1) for DATABASE_URL or (2) for
|
|
183
|
+
console.log(" 2. Supabase project ref + database password\n");
|
|
184
|
+
const choice = await prompt(rl, " Enter (1) for DATABASE_URL or (2) for project ref + password: ");
|
|
191
185
|
if (choice === "1") {
|
|
192
186
|
console.log("\n Find your DATABASE_URL in Supabase Dashboard:");
|
|
193
187
|
console.log(" Project Settings > Database > Connection string > URI\n");
|
|
@@ -195,18 +189,20 @@ async function getConnectionUrl(options) {
|
|
|
195
189
|
return databaseUrl;
|
|
196
190
|
}
|
|
197
191
|
else {
|
|
198
|
-
if (!
|
|
199
|
-
|
|
192
|
+
if (!projectRef) {
|
|
193
|
+
console.log("\n Find your project ref in Supabase Dashboard:");
|
|
194
|
+
console.log(" Project Settings > General > Reference ID\n");
|
|
195
|
+
projectRef = await prompt(rl, " Project ref: ");
|
|
200
196
|
}
|
|
201
197
|
else {
|
|
202
|
-
console.log(`\n
|
|
198
|
+
console.log(`\n Project ref: ${projectRef}`);
|
|
203
199
|
}
|
|
204
200
|
if (!dbPassword) {
|
|
205
201
|
console.log("\n Find your database password in Supabase Dashboard:");
|
|
206
202
|
console.log(" Project Settings > Database > Database password\n");
|
|
207
203
|
dbPassword = await promptSecret(rl, " Database password: ");
|
|
208
204
|
}
|
|
209
|
-
return constructDatabaseUrl(
|
|
205
|
+
return constructDatabaseUrl(projectRef, dbPassword);
|
|
210
206
|
}
|
|
211
207
|
}
|
|
212
208
|
finally {
|