create-db 1.0.10-pr64-update-posthog-18919179297.0 → 1.0.10-pr65-DC-6214-accelerate-removed-19338564383.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 +121 -88
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -429,17 +429,27 @@ async function promptForRegion(defaultRegion, userAgent, cliRunId) {
|
|
|
429
429
|
process.exit(0);
|
|
430
430
|
}
|
|
431
431
|
|
|
432
|
-
void sendAnalyticsToWorker(
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
432
|
+
void sendAnalyticsToWorker(
|
|
433
|
+
"create_db:region_selected",
|
|
434
|
+
{
|
|
435
|
+
command: CLI_NAME,
|
|
436
|
+
region: region,
|
|
437
|
+
"selection-method": "interactive",
|
|
438
|
+
"user-agent": userAgent,
|
|
439
|
+
},
|
|
440
|
+
cliRunId
|
|
441
|
+
);
|
|
438
442
|
|
|
439
443
|
return region;
|
|
440
444
|
}
|
|
441
445
|
|
|
442
|
-
async function createDatabase(
|
|
446
|
+
async function createDatabase(
|
|
447
|
+
name,
|
|
448
|
+
region,
|
|
449
|
+
userAgent,
|
|
450
|
+
cliRunId,
|
|
451
|
+
silent = false
|
|
452
|
+
) {
|
|
443
453
|
let s;
|
|
444
454
|
if (!silent) {
|
|
445
455
|
s = spinner();
|
|
@@ -473,13 +483,17 @@ async function createDatabase(name, region, userAgent, cliRunId, silent = false)
|
|
|
473
483
|
);
|
|
474
484
|
}
|
|
475
485
|
|
|
476
|
-
void sendAnalyticsToWorker(
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
486
|
+
void sendAnalyticsToWorker(
|
|
487
|
+
"create_db:database_creation_failed",
|
|
488
|
+
{
|
|
489
|
+
command: CLI_NAME,
|
|
490
|
+
region: region,
|
|
491
|
+
"error-type": "rate_limit",
|
|
492
|
+
"status-code": 429,
|
|
493
|
+
"user-agent": userAgent,
|
|
494
|
+
},
|
|
495
|
+
cliRunId
|
|
496
|
+
);
|
|
483
497
|
|
|
484
498
|
await flushAnalytics();
|
|
485
499
|
process.exit(1);
|
|
@@ -503,13 +517,17 @@ async function createDatabase(name, region, userAgent, cliRunId, silent = false)
|
|
|
503
517
|
s.stop("Unexpected response from create service.");
|
|
504
518
|
}
|
|
505
519
|
|
|
506
|
-
void sendAnalyticsToWorker(
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
520
|
+
void sendAnalyticsToWorker(
|
|
521
|
+
"create_db:database_creation_failed",
|
|
522
|
+
{
|
|
523
|
+
command: CLI_NAME,
|
|
524
|
+
region,
|
|
525
|
+
"error-type": "invalid_json",
|
|
526
|
+
"status-code": resp.status,
|
|
527
|
+
"user-agent": userAgent,
|
|
528
|
+
},
|
|
529
|
+
cliRunId
|
|
530
|
+
);
|
|
513
531
|
|
|
514
532
|
await flushAnalytics();
|
|
515
533
|
process.exit(1);
|
|
@@ -543,8 +561,7 @@ async function createDatabase(name, region, userAgent, cliRunId, silent = false)
|
|
|
543
561
|
|
|
544
562
|
if (silent && !result.error) {
|
|
545
563
|
const jsonResponse = {
|
|
546
|
-
connectionString:
|
|
547
|
-
directConnectionString: directConn,
|
|
564
|
+
connectionString: directConn,
|
|
548
565
|
claimUrl: claimUrl,
|
|
549
566
|
deletionDate: expiryDate.toISOString(),
|
|
550
567
|
region: database?.region?.id || region,
|
|
@@ -575,13 +592,17 @@ async function createDatabase(name, region, userAgent, cliRunId, silent = false)
|
|
|
575
592
|
);
|
|
576
593
|
}
|
|
577
594
|
|
|
578
|
-
void sendAnalyticsToWorker(
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
595
|
+
void sendAnalyticsToWorker(
|
|
596
|
+
"create_db:database_creation_failed",
|
|
597
|
+
{
|
|
598
|
+
command: CLI_NAME,
|
|
599
|
+
region: region,
|
|
600
|
+
"error-type": "api_error",
|
|
601
|
+
"error-message": result.error.message,
|
|
602
|
+
"user-agent": userAgent,
|
|
603
|
+
},
|
|
604
|
+
cliRunId
|
|
605
|
+
);
|
|
585
606
|
|
|
586
607
|
await flushAnalytics();
|
|
587
608
|
process.exit(1);
|
|
@@ -593,53 +614,44 @@ async function createDatabase(name, region, userAgent, cliRunId, silent = false)
|
|
|
593
614
|
|
|
594
615
|
const expiryFormatted = expiryDate.toLocaleString();
|
|
595
616
|
|
|
617
|
+
log.message("");
|
|
618
|
+
log.info(chalk.bold("Database Connection"));
|
|
596
619
|
log.message("");
|
|
597
620
|
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
if (prismaConn) {
|
|
601
|
-
log.message(
|
|
602
|
-
chalk.magenta(" Use this connection string optimized for Prisma ORM:")
|
|
603
|
-
);
|
|
604
|
-
log.message(" " + chalk.yellow(prismaConn));
|
|
605
|
-
log.message("");
|
|
606
|
-
}
|
|
607
|
-
|
|
621
|
+
// Direct connection (only output this one)
|
|
608
622
|
if (directConn) {
|
|
609
|
-
log.message(
|
|
610
|
-
chalk.cyan(" Use this connection string for everything else:")
|
|
611
|
-
);
|
|
623
|
+
log.message(chalk.cyan(" Connection String:"));
|
|
612
624
|
log.message(" " + chalk.yellow(directConn));
|
|
613
625
|
log.message("");
|
|
614
626
|
} else {
|
|
615
|
-
log.warning(
|
|
616
|
-
|
|
617
|
-
"Direct connection details are not available in the API response."
|
|
618
|
-
)
|
|
619
|
-
);
|
|
627
|
+
log.warning(chalk.yellow(" Connection details are not available."));
|
|
628
|
+
log.message("");
|
|
620
629
|
}
|
|
621
630
|
|
|
631
|
+
// prismaConn is still available as a variable but not displayed
|
|
632
|
+
|
|
633
|
+
// Claim database section
|
|
622
634
|
const clickableUrl = terminalLink(claimUrl, claimUrl, { fallback: false });
|
|
623
|
-
log.success(
|
|
624
|
-
log.message(
|
|
625
|
-
chalk.cyan(" Want to keep your database? Claim for free via this link:")
|
|
626
|
-
);
|
|
635
|
+
log.success(chalk.bold("Claim Your Database"));
|
|
636
|
+
log.message(chalk.cyan(" Keep your database for free:"));
|
|
627
637
|
log.message(" " + chalk.yellow(clickableUrl));
|
|
628
638
|
log.message(
|
|
629
639
|
chalk.italic(
|
|
630
640
|
chalk.gray(
|
|
631
|
-
|
|
632
|
-
expiryFormatted +
|
|
633
|
-
" if not claimed."
|
|
641
|
+
` Database will be deleted on ${expiryFormatted} if not claimed.`
|
|
634
642
|
)
|
|
635
643
|
)
|
|
636
644
|
);
|
|
637
645
|
|
|
638
|
-
void sendAnalyticsToWorker(
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
646
|
+
void sendAnalyticsToWorker(
|
|
647
|
+
"create_db:database_created",
|
|
648
|
+
{
|
|
649
|
+
command: CLI_NAME,
|
|
650
|
+
region,
|
|
651
|
+
utm_source: CLI_NAME,
|
|
652
|
+
},
|
|
653
|
+
cliRunId
|
|
654
|
+
);
|
|
643
655
|
}
|
|
644
656
|
|
|
645
657
|
export async function main() {
|
|
@@ -659,22 +671,27 @@ export async function main() {
|
|
|
659
671
|
userAgent = `${userEnvVars.PRISMA_ACTOR_NAME}/${userEnvVars.PRISMA_ACTOR_PROJECT}`;
|
|
660
672
|
}
|
|
661
673
|
|
|
662
|
-
void sendAnalyticsToWorker(
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
674
|
+
void sendAnalyticsToWorker(
|
|
675
|
+
"create_db:cli_command_ran",
|
|
676
|
+
{
|
|
677
|
+
command: CLI_NAME,
|
|
678
|
+
"full-command": `${CLI_NAME} ${rawArgs.join(" ")}`.trim(),
|
|
679
|
+
"has-region-flag":
|
|
680
|
+
rawArgs.includes("--region") || rawArgs.includes("-r"),
|
|
681
|
+
"has-interactive-flag":
|
|
682
|
+
rawArgs.includes("--interactive") || rawArgs.includes("-i"),
|
|
683
|
+
"has-help-flag": rawArgs.includes("--help") || rawArgs.includes("-h"),
|
|
684
|
+
"has-list-regions-flag": rawArgs.includes("--list-regions"),
|
|
685
|
+
"has-json-flag": rawArgs.includes("--json") || rawArgs.includes("-j"),
|
|
686
|
+
"has-env-flag": rawArgs.includes("--env") || rawArgs.includes("-e"),
|
|
687
|
+
"has-user-agent-from-env": !!userAgent,
|
|
688
|
+
"node-version": process.version,
|
|
689
|
+
platform: process.platform,
|
|
690
|
+
arch: process.arch,
|
|
691
|
+
"user-agent": userAgent,
|
|
692
|
+
},
|
|
693
|
+
cliRunId
|
|
694
|
+
);
|
|
678
695
|
|
|
679
696
|
if (!flags.help && !flags.json) {
|
|
680
697
|
await isOffline();
|
|
@@ -701,12 +718,16 @@ export async function main() {
|
|
|
701
718
|
if (flags.region) {
|
|
702
719
|
region = flags.region;
|
|
703
720
|
|
|
704
|
-
void sendAnalyticsToWorker(
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
721
|
+
void sendAnalyticsToWorker(
|
|
722
|
+
"create_db:region_selected",
|
|
723
|
+
{
|
|
724
|
+
command: CLI_NAME,
|
|
725
|
+
region: region,
|
|
726
|
+
"selection-method": "flag",
|
|
727
|
+
"user-agent": userAgent,
|
|
728
|
+
},
|
|
729
|
+
cliRunId
|
|
730
|
+
);
|
|
710
731
|
}
|
|
711
732
|
|
|
712
733
|
if (flags.interactive) {
|
|
@@ -720,7 +741,13 @@ export async function main() {
|
|
|
720
741
|
} else {
|
|
721
742
|
await validateRegion(region, true);
|
|
722
743
|
}
|
|
723
|
-
const result = await createDatabase(
|
|
744
|
+
const result = await createDatabase(
|
|
745
|
+
name,
|
|
746
|
+
region,
|
|
747
|
+
userAgent,
|
|
748
|
+
cliRunId,
|
|
749
|
+
true
|
|
750
|
+
);
|
|
724
751
|
console.log(JSON.stringify(result, null, 2));
|
|
725
752
|
await flushAnalytics();
|
|
726
753
|
process.exit(0);
|
|
@@ -744,13 +771,19 @@ export async function main() {
|
|
|
744
771
|
} else {
|
|
745
772
|
await validateRegion(region, true);
|
|
746
773
|
}
|
|
747
|
-
const result = await createDatabase(
|
|
774
|
+
const result = await createDatabase(
|
|
775
|
+
name,
|
|
776
|
+
region,
|
|
777
|
+
userAgent,
|
|
778
|
+
cliRunId,
|
|
779
|
+
true
|
|
780
|
+
);
|
|
748
781
|
if (result.error) {
|
|
749
782
|
console.error(result.message || "Unknown error");
|
|
750
783
|
await flushAnalytics();
|
|
751
784
|
process.exit(1);
|
|
752
785
|
}
|
|
753
|
-
console.log(`DATABASE_URL="${result.
|
|
786
|
+
console.log(`DATABASE_URL="${result.connectionString}"`);
|
|
754
787
|
console.error("\n# Claim your database at: " + result.claimUrl);
|
|
755
788
|
await flushAnalytics();
|
|
756
789
|
process.exit(0);
|
|
@@ -787,7 +820,7 @@ export async function main() {
|
|
|
787
820
|
}
|
|
788
821
|
}
|
|
789
822
|
|
|
790
|
-
//
|
|
791
|
-
if (import.meta.url
|
|
792
|
-
main();
|
|
823
|
+
// Run main() if this file is being executed directly
|
|
824
|
+
if (import.meta.url.endsWith('/index.js') || process.argv[1] === import.meta.url.replace('file://', '')) {
|
|
825
|
+
main().catch(console.error);
|
|
793
826
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "create-db",
|
|
3
|
-
"version": "1.0.10-
|
|
3
|
+
"version": "1.0.10-pr65-DC-6214-accelerate-removed-19338564383.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": "prisma",
|