create-db 1.0.10-pr62-posthog-and-minor-fixes-18784790117.0 → 1.0.10-pr63-tolt-18787736233.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 +20 -19
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -10,8 +10,6 @@ import chalk from "chalk";
|
|
|
10
10
|
|
|
11
11
|
dotenv.config();
|
|
12
12
|
|
|
13
|
-
const CLI_RUN_ID = randomUUID();
|
|
14
|
-
|
|
15
13
|
const CREATE_DB_WORKER_URL =
|
|
16
14
|
process.env.CREATE_DB_WORKER_URL || "https://create-db-temp.prisma.io";
|
|
17
15
|
const CLAIM_DB_WORKER_URL =
|
|
@@ -20,7 +18,7 @@ const CLAIM_DB_WORKER_URL =
|
|
|
20
18
|
// Track pending analytics promises to ensure they complete before exit
|
|
21
19
|
const pendingAnalytics = [];
|
|
22
20
|
|
|
23
|
-
async function sendAnalyticsToWorker(eventName, properties) {
|
|
21
|
+
async function sendAnalyticsToWorker(eventName, properties, cliRunId) {
|
|
24
22
|
const controller = new AbortController();
|
|
25
23
|
const timer = setTimeout(() => controller.abort(), 5000);
|
|
26
24
|
|
|
@@ -28,7 +26,7 @@ async function sendAnalyticsToWorker(eventName, properties) {
|
|
|
28
26
|
try {
|
|
29
27
|
const payload = {
|
|
30
28
|
eventName,
|
|
31
|
-
properties: { distinct_id:
|
|
29
|
+
properties: { distinct_id: cliRunId, ...(properties || {}) },
|
|
32
30
|
};
|
|
33
31
|
await fetch(`${CREATE_DB_WORKER_URL}/analytics`, {
|
|
34
32
|
method: "POST",
|
|
@@ -406,7 +404,7 @@ function handleError(message, extra = "") {
|
|
|
406
404
|
process.exit(1);
|
|
407
405
|
}
|
|
408
406
|
|
|
409
|
-
async function promptForRegion(defaultRegion, userAgent) {
|
|
407
|
+
async function promptForRegion(defaultRegion, userAgent, cliRunId) {
|
|
410
408
|
let regions;
|
|
411
409
|
try {
|
|
412
410
|
regions = await getRegions();
|
|
@@ -436,12 +434,12 @@ async function promptForRegion(defaultRegion, userAgent) {
|
|
|
436
434
|
region: region,
|
|
437
435
|
"selection-method": "interactive",
|
|
438
436
|
"user-agent": userAgent,
|
|
439
|
-
});
|
|
437
|
+
}, cliRunId);
|
|
440
438
|
|
|
441
439
|
return region;
|
|
442
440
|
}
|
|
443
441
|
|
|
444
|
-
async function createDatabase(name, region, userAgent, silent = false) {
|
|
442
|
+
async function createDatabase(name, region, userAgent, cliRunId, silent = false) {
|
|
445
443
|
let s;
|
|
446
444
|
if (!silent) {
|
|
447
445
|
s = spinner();
|
|
@@ -481,7 +479,7 @@ async function createDatabase(name, region, userAgent, silent = false) {
|
|
|
481
479
|
"error-type": "rate_limit",
|
|
482
480
|
"status-code": 429,
|
|
483
481
|
"user-agent": userAgent,
|
|
484
|
-
});
|
|
482
|
+
}, cliRunId);
|
|
485
483
|
|
|
486
484
|
await flushAnalytics();
|
|
487
485
|
process.exit(1);
|
|
@@ -511,7 +509,7 @@ async function createDatabase(name, region, userAgent, silent = false) {
|
|
|
511
509
|
"error-type": "invalid_json",
|
|
512
510
|
"status-code": resp.status,
|
|
513
511
|
"user-agent": userAgent,
|
|
514
|
-
});
|
|
512
|
+
}, cliRunId);
|
|
515
513
|
|
|
516
514
|
await flushAnalytics();
|
|
517
515
|
process.exit(1);
|
|
@@ -583,7 +581,7 @@ async function createDatabase(name, region, userAgent, silent = false) {
|
|
|
583
581
|
"error-type": "api_error",
|
|
584
582
|
"error-message": result.error.message,
|
|
585
583
|
"user-agent": userAgent,
|
|
586
|
-
});
|
|
584
|
+
}, cliRunId);
|
|
587
585
|
|
|
588
586
|
await flushAnalytics();
|
|
589
587
|
process.exit(1);
|
|
@@ -641,11 +639,14 @@ async function createDatabase(name, region, userAgent, silent = false) {
|
|
|
641
639
|
command: CLI_NAME,
|
|
642
640
|
region,
|
|
643
641
|
utm_source: CLI_NAME,
|
|
644
|
-
});
|
|
642
|
+
}, cliRunId);
|
|
645
643
|
}
|
|
646
644
|
|
|
647
645
|
export async function main() {
|
|
648
646
|
try {
|
|
647
|
+
// Generate unique ID for this CLI run
|
|
648
|
+
const cliRunId = randomUUID();
|
|
649
|
+
|
|
649
650
|
const rawArgs = process.argv.slice(2);
|
|
650
651
|
|
|
651
652
|
const { flags } = await parseArgs();
|
|
@@ -673,7 +674,7 @@ export async function main() {
|
|
|
673
674
|
platform: process.platform,
|
|
674
675
|
arch: process.arch,
|
|
675
676
|
"user-agent": userAgent,
|
|
676
|
-
});
|
|
677
|
+
}, cliRunId);
|
|
677
678
|
|
|
678
679
|
if (!flags.help && !flags.json) {
|
|
679
680
|
await isOffline();
|
|
@@ -705,7 +706,7 @@ export async function main() {
|
|
|
705
706
|
region: region,
|
|
706
707
|
"selection-method": "flag",
|
|
707
708
|
"user-agent": userAgent,
|
|
708
|
-
});
|
|
709
|
+
}, cliRunId);
|
|
709
710
|
}
|
|
710
711
|
|
|
711
712
|
if (flags.interactive) {
|
|
@@ -715,11 +716,11 @@ export async function main() {
|
|
|
715
716
|
if (flags.json) {
|
|
716
717
|
try {
|
|
717
718
|
if (chooseRegionPrompt) {
|
|
718
|
-
region = await promptForRegion(region, userAgent);
|
|
719
|
+
region = await promptForRegion(region, userAgent, cliRunId);
|
|
719
720
|
} else {
|
|
720
721
|
await validateRegion(region, true);
|
|
721
722
|
}
|
|
722
|
-
const result = await createDatabase(name, region, userAgent, true);
|
|
723
|
+
const result = await createDatabase(name, region, userAgent, cliRunId, true);
|
|
723
724
|
console.log(JSON.stringify(result, null, 2));
|
|
724
725
|
await flushAnalytics();
|
|
725
726
|
process.exit(0);
|
|
@@ -739,11 +740,11 @@ export async function main() {
|
|
|
739
740
|
if (flags.env) {
|
|
740
741
|
try {
|
|
741
742
|
if (chooseRegionPrompt) {
|
|
742
|
-
region = await promptForRegion(region, userAgent);
|
|
743
|
+
region = await promptForRegion(region, userAgent, cliRunId);
|
|
743
744
|
} else {
|
|
744
745
|
await validateRegion(region, true);
|
|
745
746
|
}
|
|
746
|
-
const result = await createDatabase(name, region, userAgent, true);
|
|
747
|
+
const result = await createDatabase(name, region, userAgent, cliRunId, true);
|
|
747
748
|
if (result.error) {
|
|
748
749
|
console.error(result.message || "Unknown error");
|
|
749
750
|
await flushAnalytics();
|
|
@@ -770,12 +771,12 @@ export async function main() {
|
|
|
770
771
|
)
|
|
771
772
|
);
|
|
772
773
|
if (chooseRegionPrompt) {
|
|
773
|
-
region = await promptForRegion(region, userAgent);
|
|
774
|
+
region = await promptForRegion(region, userAgent, cliRunId);
|
|
774
775
|
}
|
|
775
776
|
|
|
776
777
|
region = await validateRegion(region);
|
|
777
778
|
|
|
778
|
-
await createDatabase(name, region, userAgent);
|
|
779
|
+
await createDatabase(name, region, userAgent, cliRunId);
|
|
779
780
|
|
|
780
781
|
outro("");
|
|
781
782
|
await flushAnalytics();
|
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-pr63-tolt-18787736233.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",
|