create-db 1.0.3-pr45-DC-4829-source-flag-17134940199.0 → 1.0.3-pr45-DC-4829-source-flag-17136895926.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.
Files changed (2) hide show
  1. package/index.js +7 -45
  2. 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
  }
@@ -431,6 +423,7 @@ async function createDatabase(name, region, source, returnJson = false ) {
431
423
  region: database?.region?.id || region,
432
424
  name: database?.name,
433
425
  projectId: projectId,
426
+ source: source || null,
434
427
  };
435
428
  }
436
429
 
@@ -521,22 +514,10 @@ async function main() {
521
514
 
522
515
  const { flags } = await parseArgs();
523
516
 
524
- let source;
525
- if (flags.source) {
526
- const userEnvVars = readUserEnvFile();
527
- const userCwd = process.cwd();
528
- const envPath = path.join(userCwd, '.env');
529
-
530
- if (fs.existsSync(envPath)) {
531
- const ctaVars = [];
532
- if (userEnvVars.CTA_VERSION) ctaVars.push(`v${userEnvVars.CTA_VERSION}`);
533
- if (userEnvVars.CTA_FRAMEWORK) ctaVars.push(userEnvVars.CTA_FRAMEWORK);
534
- if (userEnvVars.CTA_FRAMEWORK_VERSION) ctaVars.push(`fv${userEnvVars.CTA_FRAMEWORK_VERSION}`);
535
-
536
- if (ctaVars.length > 0) {
537
- source = ctaVars.join('-');
538
- }
539
- }
517
+ let source;
518
+ const userEnvVars = readUserEnvFile();
519
+ if (userEnvVars.PRISMA_ACTOR_NAME && userEnvVars.PRISMA_ACTOR_PROJECT) {
520
+ source = `${userEnvVars.PRISMA_ACTOR_NAME}/${userEnvVars.PRISMA_ACTOR_PROJECT}`;
540
521
  }
541
522
 
542
523
  try {
@@ -550,7 +531,7 @@ async function main() {
550
531
  "has-help-flag": rawArgs.includes("--help") || rawArgs.includes("-h"),
551
532
  "has-list-regions-flag": rawArgs.includes("--list-regions"),
552
533
  "has-json-flag": rawArgs.includes("--json") || rawArgs.includes("-j"),
553
- "has-source-flag": rawArgs.includes("--source") || rawArgs.includes("-s"),
534
+ "has-source-from-env": !!source,
554
535
  "node-version": process.version,
555
536
  platform: process.platform,
556
537
  arch: process.arch,
@@ -600,26 +581,7 @@ async function main() {
600
581
  } catch (error) {}
601
582
  }
602
583
 
603
- if (flags.source) {
604
- const userCwd = process.cwd();
605
- const envPath = path.join(userCwd, '.env');
606
-
607
- if (!fs.existsSync(envPath)) {
608
- console.error(chalk.red("Error: Source not configured correctly."));
609
- process.exit(1);
610
- }
611
-
612
- const userEnvVars = readUserEnvFile();
613
- const ctaVars = [];
614
- if (userEnvVars.CTA_VERSION) ctaVars.push(`v${userEnvVars.CTA_VERSION}`);
615
- if (userEnvVars.CTA_FRAMEWORK) ctaVars.push(userEnvVars.CTA_FRAMEWORK);
616
- if (userEnvVars.CTA_FRAMEWORK_VERSION) ctaVars.push(`fv${userEnvVars.CTA_FRAMEWORK_VERSION}`);
617
-
618
- if (ctaVars.length === 0) {
619
- console.error(chalk.red("Error: Source not configured correctly."));
620
- process.exit(1);
621
- }
622
- }
584
+
623
585
 
624
586
  if (flags.interactive) {
625
587
  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-17134940199.0",
3
+ "version": "1.0.3-pr45-DC-4829-source-flag-17136895926.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": "",