create-db 1.0.3-pr45-DC-4829-source-flag-17135144702.0 → 1.0.3-pr45-DC-4829-source-flag-17136985429.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/index.js +13 -47
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -126,14 +126,12 @@ async function parseArgs() {
|
|
|
126
126
|
"list-regions",
|
|
127
127
|
"interactive",
|
|
128
128
|
"json",
|
|
129
|
-
"source",
|
|
130
129
|
];
|
|
131
130
|
const shorthandMap = {
|
|
132
131
|
r: "region",
|
|
133
132
|
i: "interactive",
|
|
134
133
|
h: "help",
|
|
135
134
|
j: "json",
|
|
136
|
-
s: "source",
|
|
137
135
|
};
|
|
138
136
|
|
|
139
137
|
const exitWithError = (message) => {
|
|
@@ -156,8 +154,6 @@ async function parseArgs() {
|
|
|
156
154
|
exitWithError("Missing value for --region flag.");
|
|
157
155
|
flags.region = region;
|
|
158
156
|
i++;
|
|
159
|
-
} else if (flag === "source") {
|
|
160
|
-
flags.source = true;
|
|
161
157
|
} else {
|
|
162
158
|
flags[flag] = true;
|
|
163
159
|
}
|
|
@@ -176,8 +172,6 @@ async function parseArgs() {
|
|
|
176
172
|
exitWithError("Missing value for -r flag.");
|
|
177
173
|
flags.region = region;
|
|
178
174
|
i++;
|
|
179
|
-
} else if (mappedFlag === "source") {
|
|
180
|
-
flags.source = true;
|
|
181
175
|
} else {
|
|
182
176
|
flags[mappedFlag] = true;
|
|
183
177
|
}
|
|
@@ -197,8 +191,6 @@ async function parseArgs() {
|
|
|
197
191
|
exitWithError("Missing value for -r flag.");
|
|
198
192
|
flags.region = region;
|
|
199
193
|
i++;
|
|
200
|
-
} else if (mappedFlag === "source") {
|
|
201
|
-
flags.source = true;
|
|
202
194
|
} else {
|
|
203
195
|
flags[mappedFlag] = true;
|
|
204
196
|
}
|
|
@@ -423,7 +415,7 @@ async function createDatabase(name, region, source, returnJson = false ) {
|
|
|
423
415
|
const expiryDate = new Date(Date.now() + 24 * 60 * 60 * 1000);
|
|
424
416
|
|
|
425
417
|
if (returnJson && !result.error) {
|
|
426
|
-
|
|
418
|
+
const jsonResponse = {
|
|
427
419
|
connectionString: prismaConn,
|
|
428
420
|
directConnectionString: directConn,
|
|
429
421
|
claimUrl: claimUrl,
|
|
@@ -431,8 +423,13 @@ async function createDatabase(name, region, source, returnJson = false ) {
|
|
|
431
423
|
region: database?.region?.id || region,
|
|
432
424
|
name: database?.name,
|
|
433
425
|
projectId: projectId,
|
|
434
|
-
source: source || null,
|
|
435
426
|
};
|
|
427
|
+
|
|
428
|
+
if (source) {
|
|
429
|
+
jsonResponse.source = source;
|
|
430
|
+
}
|
|
431
|
+
|
|
432
|
+
return jsonResponse;
|
|
436
433
|
}
|
|
437
434
|
|
|
438
435
|
if (result.error) {
|
|
@@ -522,22 +519,10 @@ async function main() {
|
|
|
522
519
|
|
|
523
520
|
const { flags } = await parseArgs();
|
|
524
521
|
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
const envPath = path.join(userCwd, '.env');
|
|
530
|
-
|
|
531
|
-
if (fs.existsSync(envPath)) {
|
|
532
|
-
const ctaVars = [];
|
|
533
|
-
if (userEnvVars.CTA_VERSION) ctaVars.push(`v${userEnvVars.CTA_VERSION}`);
|
|
534
|
-
if (userEnvVars.CTA_FRAMEWORK) ctaVars.push(userEnvVars.CTA_FRAMEWORK);
|
|
535
|
-
if (userEnvVars.CTA_FRAMEWORK_VERSION) ctaVars.push(`fv${userEnvVars.CTA_FRAMEWORK_VERSION}`);
|
|
536
|
-
|
|
537
|
-
if (ctaVars.length > 0) {
|
|
538
|
-
source = ctaVars.join('-');
|
|
539
|
-
}
|
|
540
|
-
}
|
|
522
|
+
let source;
|
|
523
|
+
const userEnvVars = readUserEnvFile();
|
|
524
|
+
if (userEnvVars.PRISMA_ACTOR_NAME && userEnvVars.PRISMA_ACTOR_PROJECT) {
|
|
525
|
+
source = `${userEnvVars.PRISMA_ACTOR_NAME}/${userEnvVars.PRISMA_ACTOR_PROJECT}`;
|
|
541
526
|
}
|
|
542
527
|
|
|
543
528
|
try {
|
|
@@ -551,7 +536,7 @@ async function main() {
|
|
|
551
536
|
"has-help-flag": rawArgs.includes("--help") || rawArgs.includes("-h"),
|
|
552
537
|
"has-list-regions-flag": rawArgs.includes("--list-regions"),
|
|
553
538
|
"has-json-flag": rawArgs.includes("--json") || rawArgs.includes("-j"),
|
|
554
|
-
"has-source-
|
|
539
|
+
"has-source-from-env": !!source,
|
|
555
540
|
"node-version": process.version,
|
|
556
541
|
platform: process.platform,
|
|
557
542
|
arch: process.arch,
|
|
@@ -601,26 +586,7 @@ async function main() {
|
|
|
601
586
|
} catch (error) {}
|
|
602
587
|
}
|
|
603
588
|
|
|
604
|
-
|
|
605
|
-
const userCwd = process.cwd();
|
|
606
|
-
const envPath = path.join(userCwd, '.env');
|
|
607
|
-
|
|
608
|
-
if (!fs.existsSync(envPath)) {
|
|
609
|
-
console.error(chalk.red("Error: Source not configured correctly."));
|
|
610
|
-
process.exit(1);
|
|
611
|
-
}
|
|
612
|
-
|
|
613
|
-
const userEnvVars = readUserEnvFile();
|
|
614
|
-
const ctaVars = [];
|
|
615
|
-
if (userEnvVars.CTA_VERSION) ctaVars.push(`v${userEnvVars.CTA_VERSION}`);
|
|
616
|
-
if (userEnvVars.CTA_FRAMEWORK) ctaVars.push(userEnvVars.CTA_FRAMEWORK);
|
|
617
|
-
if (userEnvVars.CTA_FRAMEWORK_VERSION) ctaVars.push(`fv${userEnvVars.CTA_FRAMEWORK_VERSION}`);
|
|
618
|
-
|
|
619
|
-
if (ctaVars.length === 0) {
|
|
620
|
-
console.error(chalk.red("Error: Source not configured correctly."));
|
|
621
|
-
process.exit(1);
|
|
622
|
-
}
|
|
623
|
-
}
|
|
589
|
+
|
|
624
590
|
|
|
625
591
|
if (flags.interactive) {
|
|
626
592
|
chooseRegionPrompt = true;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "create-db",
|
|
3
|
-
"version": "1.0.3-pr45-DC-4829-source-flag-
|
|
3
|
+
"version": "1.0.3-pr45-DC-4829-source-flag-17136985429.0",
|
|
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
|
"main": "index.js",
|
|
6
6
|
"author": "",
|