@prisma/cli-init 0.0.3 → 0.0.4
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.
|
@@ -5,11 +5,11 @@ var __export = (target, all) => {
|
|
|
5
5
|
};
|
|
6
6
|
|
|
7
7
|
// src/platform/_lib/utils.ts
|
|
8
|
-
import
|
|
8
|
+
import internals2 from "@prisma/internals";
|
|
9
9
|
import { bold, green } from "kleur/colors";
|
|
10
10
|
|
|
11
11
|
// src/platform/_lib/cli/parameters.ts
|
|
12
|
-
import
|
|
12
|
+
import internals from "@prisma/internals";
|
|
13
13
|
var getRequiredParameter = (args, names, environmentVariable) => {
|
|
14
14
|
const value = getOptionalParameter(args, names, environmentVariable);
|
|
15
15
|
if (value === void 0)
|
|
@@ -17,8 +17,8 @@ var getRequiredParameter = (args, names, environmentVariable) => {
|
|
|
17
17
|
return value;
|
|
18
18
|
};
|
|
19
19
|
function argOrThrow(argv, spec) {
|
|
20
|
-
const args = arg(argv, spec);
|
|
21
|
-
if (isError(args))
|
|
20
|
+
const args = internals.arg(argv, spec);
|
|
21
|
+
if (internals.isError(args))
|
|
22
22
|
throw args;
|
|
23
23
|
return args;
|
|
24
24
|
}
|
|
@@ -129,7 +129,7 @@ var platformParameters = {
|
|
|
129
129
|
}
|
|
130
130
|
};
|
|
131
131
|
var ErrorPlatformUnauthorized = new Error(
|
|
132
|
-
`No platform credentials found. Run ${green(getCommandWithExecutor("prisma platform auth login --early-access"))} first. Alternatively you can provide a token via the \`--token\` or \`-t\` parameters, or set the 'PRISMA_TOKEN' environment variable with a token.`
|
|
132
|
+
`No platform credentials found. Run ${green(internals2.getCommandWithExecutor("prisma platform auth login --early-access"))} first. Alternatively you can provide a token via the \`--token\` or \`-t\` parameters, or set the 'PRISMA_TOKEN' environment variable with a token.`
|
|
133
133
|
// prettier-ignore
|
|
134
134
|
);
|
|
135
135
|
var getTokenOrThrow = async (args) => {
|
|
@@ -137,7 +137,7 @@ var getTokenOrThrow = async (args) => {
|
|
|
137
137
|
if (token)
|
|
138
138
|
return token;
|
|
139
139
|
const credentials = await credentialsFile.load();
|
|
140
|
-
if (
|
|
140
|
+
if (internals2.isError(credentials))
|
|
141
141
|
throw credentials;
|
|
142
142
|
if (!credentials)
|
|
143
143
|
throw ErrorPlatformUnauthorized;
|
|
@@ -164,7 +164,7 @@ var poll = async (fn, until, waitMs, timeoutMs, message) => {
|
|
|
164
164
|
console.log(message);
|
|
165
165
|
result = await wait().then(fn);
|
|
166
166
|
}
|
|
167
|
-
if (
|
|
167
|
+
if (internals2.isError(result))
|
|
168
168
|
throw result;
|
|
169
169
|
return result;
|
|
170
170
|
};
|
|
@@ -182,10 +182,10 @@ We created an initial ${green("schema.prisma")} file and a ${green(".env")} file
|
|
|
182
182
|
|
|
183
183
|
${bold("--- Next steps ---")}
|
|
184
184
|
|
|
185
|
-
Go to ${link("https://pris.ly/ppg-init")} for detailed instructions.
|
|
185
|
+
Go to ${internals2.link("https://pris.ly/ppg-init")} for detailed instructions.
|
|
186
186
|
|
|
187
187
|
${bold("1. Define your database schema")}
|
|
188
|
-
Open the ${green("schema.prisma")} file and define your first models. Check the docs if you need inspiration: ${link(
|
|
188
|
+
Open the ${green("schema.prisma")} file and define your first models. Check the docs if you need inspiration: ${internals2.link(
|
|
189
189
|
"https://pris.ly/ppg-init"
|
|
190
190
|
)}.
|
|
191
191
|
|
|
@@ -198,10 +198,10 @@ View and edit your data locally by running this command:
|
|
|
198
198
|
${green("npx prisma studio")}
|
|
199
199
|
|
|
200
200
|
...or online in Console:
|
|
201
|
-
${link(`https://console.prisma.io/${workspaceId}/${projectId}/${environmentId}/studio`)}
|
|
201
|
+
${internals2.link(`https://console.prisma.io/${workspaceId}/${projectId}/${environmentId}/studio`)}
|
|
202
202
|
|
|
203
203
|
${bold(`4. Send queries from your app`)}
|
|
204
|
-
To access your database from a JavaScript/TypeScript app, you need to use Prisma ORM. Go here for step-by-step instructions: ${link(
|
|
204
|
+
To access your database from a JavaScript/TypeScript app, you need to use Prisma ORM. Go here for step-by-step instructions: ${internals2.link(
|
|
205
205
|
"https://pris.ly/ppg-init"
|
|
206
206
|
)}
|
|
207
207
|
`;
|
|
@@ -216,7 +216,7 @@ ${green(databaseUrl)}
|
|
|
216
216
|
|
|
217
217
|
${bold("--- Next steps ---")}
|
|
218
218
|
|
|
219
|
-
Go to ${link("https://pris.ly/ppg-init")} for detailed instructions.
|
|
219
|
+
Go to ${internals2.link("https://pris.ly/ppg-init")} for detailed instructions.
|
|
220
220
|
|
|
221
221
|
${bold("1. Install and use the Prisma Accelerate extension")}
|
|
222
222
|
Prisma Postgres requires the Prisma Accelerate extension for querying. If you haven't already installed it, install it in your project:
|
|
@@ -236,13 +236,13 @@ View and edit your data locally by running this command:
|
|
|
236
236
|
${green("npx prisma studio")}
|
|
237
237
|
|
|
238
238
|
...or online in Console:
|
|
239
|
-
${link(`https://console.prisma.io/${workspaceId}/${projectId}/${environmentId}/studio`)}
|
|
239
|
+
${internals2.link(`https://console.prisma.io/${workspaceId}/${projectId}/${environmentId}/studio`)}
|
|
240
240
|
|
|
241
241
|
${bold(`4. Send queries from your app`)}
|
|
242
242
|
If you already have an existing app with Prisma ORM, you can now run it and it will send queries against your newly created Prisma Postgres instance.
|
|
243
243
|
|
|
244
244
|
${bold(`5. Learn more`)}
|
|
245
|
-
For more info, visit the Prisma Postgres docs: ${link("https://pris.ly/ppg-docs")}
|
|
245
|
+
For more info, visit the Prisma Postgres docs: ${internals2.link("https://pris.ly/ppg-docs")}
|
|
246
246
|
`;
|
|
247
247
|
return isExistingPrismaProject ? existingPrismaProjectOutput : newPrismaProjectOutput;
|
|
248
248
|
};
|
|
@@ -256,7 +256,8 @@ __export(__exports, {
|
|
|
256
256
|
});
|
|
257
257
|
|
|
258
258
|
// src/platform/_lib/cli/dispatchToSubCommand.ts
|
|
259
|
-
import
|
|
259
|
+
import internals3 from "@prisma/internals";
|
|
260
|
+
var { HelpError, link } = internals3;
|
|
260
261
|
var dispatchToSubCommand = async (commands, argv, config) => {
|
|
261
262
|
const commandName = argv[0];
|
|
262
263
|
if (!commandName)
|
|
@@ -266,7 +267,7 @@ var dispatchToSubCommand = async (commands, argv, config) => {
|
|
|
266
267
|
return new HelpError(`Unknown command or parameter "${commandName}"`);
|
|
267
268
|
const hasHelpFlag = Boolean(argv.find((it) => ["-h", "--help"].includes(it)));
|
|
268
269
|
if (hasHelpFlag)
|
|
269
|
-
return `Help output for this command will be available soon. In the meantime, visit ${
|
|
270
|
+
return `Help output for this command will be available soon. In the meantime, visit ${link("https://pris.ly/cli/platform-docs")} for more information.`;
|
|
270
271
|
const result = await command.parse(argv.slice(1), config);
|
|
271
272
|
return result;
|
|
272
273
|
};
|
|
@@ -290,15 +291,18 @@ var createNamespace = () => {
|
|
|
290
291
|
var $ = createNamespace();
|
|
291
292
|
|
|
292
293
|
// src/platform/_lib/messages.ts
|
|
293
|
-
import
|
|
294
|
+
import internals4 from "@prisma/internals";
|
|
294
295
|
import { bold as bold2, dim, green as green2, white } from "kleur/colors";
|
|
295
296
|
var table = (object, renderersInput) => {
|
|
296
297
|
const renderers = {
|
|
297
298
|
key: renderersInput.key ?? dim,
|
|
298
299
|
// eslint-disable-next-line
|
|
299
|
-
values: mapObjectValues(
|
|
300
|
+
values: internals4.mapObjectValues(
|
|
301
|
+
renderersInput.values ?? {},
|
|
302
|
+
(_) => _ === true ? id : _
|
|
303
|
+
)
|
|
300
304
|
};
|
|
301
|
-
return formatTable(
|
|
305
|
+
return internals4.formatTable(
|
|
302
306
|
Object.entries(renderers.values).map(([propertyName, renderer]) => {
|
|
303
307
|
const valueRendered = renderer(object[propertyName]);
|
|
304
308
|
if (valueRendered === null)
|
|
@@ -337,19 +341,19 @@ import fetch, { Headers } from "node-fetch";
|
|
|
337
341
|
|
|
338
342
|
// src/platform/_lib/userAgent.ts
|
|
339
343
|
import Debug from "@prisma/debug";
|
|
340
|
-
import
|
|
344
|
+
import internals5 from "@prisma/internals";
|
|
341
345
|
import * as Checkpoint from "checkpoint-client";
|
|
342
346
|
|
|
343
347
|
// package.json
|
|
344
|
-
var version = "0.0.
|
|
348
|
+
var version = "0.0.4";
|
|
345
349
|
|
|
346
350
|
// src/platform/_lib/userAgent.ts
|
|
347
351
|
var debug = Debug("prisma:cli:platform:_lib:userAgent");
|
|
348
352
|
var getUserAgent = async () => {
|
|
349
353
|
const signature = await Checkpoint.getSignature().catch(unknownToError);
|
|
350
|
-
if (
|
|
354
|
+
if (internals5.isError(signature))
|
|
351
355
|
debug(`await checkpoint.getSignature() failed silently with ${signature.message}`);
|
|
352
|
-
const signatureString =
|
|
356
|
+
const signatureString = internals5.isError(signature) ? "unknown" : signature;
|
|
353
357
|
return `prisma-cli-init/${version} (Signature: ${signatureString})`;
|
|
354
358
|
};
|
|
355
359
|
|
|
@@ -423,20 +427,20 @@ var Disable = class _Disable {
|
|
|
423
427
|
};
|
|
424
428
|
|
|
425
429
|
// src/platform/accelerate/enable.ts
|
|
426
|
-
import
|
|
430
|
+
import internals6 from "@prisma/internals";
|
|
427
431
|
var Enable = class _Enable {
|
|
428
432
|
static new() {
|
|
429
433
|
return new _Enable();
|
|
430
434
|
}
|
|
431
435
|
async parse(argv, _config) {
|
|
432
|
-
const args =
|
|
436
|
+
const args = internals6.arg(argv, {
|
|
433
437
|
...platformParameters.environment,
|
|
434
438
|
"--url": String,
|
|
435
439
|
// TODO rename to "serviceToken" in a future release.
|
|
436
440
|
"--apikey": Boolean,
|
|
437
441
|
"--region": String
|
|
438
442
|
});
|
|
439
|
-
if (
|
|
443
|
+
if (internals6.isError(args))
|
|
440
444
|
return args;
|
|
441
445
|
const token = await getTokenOrThrow(args);
|
|
442
446
|
const environmentId = getRequiredParameterOrThrow(args, ["--environment", "-e"]);
|
|
@@ -507,7 +511,7 @@ var Enable = class _Enable {
|
|
|
507
511
|
}
|
|
508
512
|
}
|
|
509
513
|
});
|
|
510
|
-
const gettingStartedUrl =
|
|
514
|
+
const gettingStartedUrl = internals6.link("https://pris.ly/d/accelerate-getting-started");
|
|
511
515
|
if (serviceTokenCreate) {
|
|
512
516
|
return messages.success(
|
|
513
517
|
`Accelerate enabled. Use this Accelerate connection string to authenticate requests:
|
|
@@ -542,7 +546,7 @@ var $2 = createNamespace();
|
|
|
542
546
|
// src/platform/auth/login.ts
|
|
543
547
|
import { select } from "@inquirer/prompts";
|
|
544
548
|
import Debug2 from "@prisma/debug";
|
|
545
|
-
import
|
|
549
|
+
import internals7 from "@prisma/internals";
|
|
546
550
|
import listen from "async-listen";
|
|
547
551
|
import http from "http";
|
|
548
552
|
import { green as green3 } from "kleur/colors";
|
|
@@ -553,27 +557,27 @@ var Login = class _Login {
|
|
|
553
557
|
return new _Login();
|
|
554
558
|
}
|
|
555
559
|
async parse(argv, _config) {
|
|
556
|
-
const args =
|
|
560
|
+
const args = internals7.arg(argv, {
|
|
557
561
|
// internal optimize flag to track signup attribution
|
|
558
562
|
"--optimize": Boolean
|
|
559
563
|
});
|
|
560
|
-
if (
|
|
564
|
+
if (internals7.isError(args))
|
|
561
565
|
return args;
|
|
562
566
|
if (args["--optimize"]) {
|
|
563
567
|
console.warn("The '--optimize' flag is deprecated. Use API keys instead.");
|
|
564
568
|
}
|
|
565
569
|
const credentials = await credentialsFile.load();
|
|
566
|
-
if (
|
|
570
|
+
if (internals7.isError(credentials))
|
|
567
571
|
throw credentials;
|
|
568
572
|
if (credentials)
|
|
569
|
-
return `Already authenticated. Run ${green3(
|
|
573
|
+
return `Already authenticated. Run ${green3(internals7.getCommandWithExecutor("prisma platform auth show --early-access"))} to see the current user.`;
|
|
570
574
|
console.info("Authenticating to Prisma Platform CLI via browser.\n");
|
|
571
575
|
const server = http.createServer();
|
|
572
576
|
const randomPort = 0;
|
|
573
577
|
const redirectUrl = await listen(server, randomPort, "127.0.0.1");
|
|
574
578
|
const loginUrl = await createLoginUrl({ connection: "github", redirectTo: redirectUrl.href });
|
|
575
579
|
console.info("Visit the following URL in your browser to authenticate:");
|
|
576
|
-
console.info(
|
|
580
|
+
console.info(internals7.link(loginUrl.href));
|
|
577
581
|
const callbackResult = await Promise.all([
|
|
578
582
|
new Promise((resolve, reject) => {
|
|
579
583
|
server.once("request", (req, res) => {
|
|
@@ -613,11 +617,11 @@ var Login = class _Login {
|
|
|
613
617
|
}),
|
|
614
618
|
open(loginUrl.href)
|
|
615
619
|
]).then((results) => results[0]).catch(unknownToError);
|
|
616
|
-
if (
|
|
620
|
+
if (internals7.isError(callbackResult))
|
|
617
621
|
throw new Error(`Authentication failed: ${callbackResult.message}`);
|
|
618
622
|
{
|
|
619
623
|
const writeResult = await credentialsFile.save({ token: callbackResult.token });
|
|
620
|
-
if (
|
|
624
|
+
if (internals7.isError(writeResult))
|
|
621
625
|
throw new Error("Writing credentials to disk failed", { cause: writeResult });
|
|
622
626
|
}
|
|
623
627
|
return successMessage(`Authentication successful for ${callbackResult.user.email}`);
|
|
@@ -663,7 +667,7 @@ var loginOrSignup = async () => {
|
|
|
663
667
|
const redirectUrl = await listen(server, randomPort, "127.0.0.1");
|
|
664
668
|
const loginUrl = await createLoginUrl({ connection: providerAnswer, redirectTo: redirectUrl.href });
|
|
665
669
|
console.info("Visit the following URL in your browser to authenticate:");
|
|
666
|
-
console.info(
|
|
670
|
+
console.info(internals7.link(loginUrl.href));
|
|
667
671
|
const callbackResult = await Promise.all([
|
|
668
672
|
new Promise((resolve, reject) => {
|
|
669
673
|
server.once("request", (req, res) => {
|
|
@@ -703,11 +707,11 @@ var loginOrSignup = async () => {
|
|
|
703
707
|
}),
|
|
704
708
|
open(loginUrl.href)
|
|
705
709
|
]).then((results) => results[0]).catch(unknownToError);
|
|
706
|
-
if (
|
|
710
|
+
if (internals7.isError(callbackResult))
|
|
707
711
|
throw new Error(`Authentication failed: ${callbackResult.message}`);
|
|
708
712
|
{
|
|
709
713
|
const writeResult = await credentialsFile.save({ token: callbackResult.token });
|
|
710
|
-
if (
|
|
714
|
+
if (internals7.isError(writeResult))
|
|
711
715
|
throw new Error("Writing credentials to disk failed", { cause: writeResult });
|
|
712
716
|
}
|
|
713
717
|
return {
|
|
@@ -718,11 +722,11 @@ var loginOrSignup = async () => {
|
|
|
718
722
|
};
|
|
719
723
|
|
|
720
724
|
// src/platform/auth/logout.ts
|
|
721
|
-
import
|
|
725
|
+
import internals9 from "@prisma/internals";
|
|
722
726
|
import { green as green4 } from "kleur/colors";
|
|
723
727
|
|
|
724
728
|
// src/platform/_lib/jwt.ts
|
|
725
|
-
import
|
|
729
|
+
import internals8 from "@prisma/internals";
|
|
726
730
|
var decodeJwt = (jwt) => {
|
|
727
731
|
if (typeof jwt !== "string")
|
|
728
732
|
throw new Error("JWTs must use Compact JWS serialization, JWT must be a string");
|
|
@@ -737,13 +741,13 @@ var decodeJwt = (jwt) => {
|
|
|
737
741
|
() => atob(payload),
|
|
738
742
|
() => new Error("Failed to base64 decode the payload.")
|
|
739
743
|
);
|
|
740
|
-
if (
|
|
744
|
+
if (internals8.isError(decoded))
|
|
741
745
|
return decoded;
|
|
742
746
|
const result = tryCatch(
|
|
743
747
|
() => JSON.parse(decoded),
|
|
744
748
|
() => new Error("Failed to parse the decoded payload as JSON.")
|
|
745
749
|
);
|
|
746
|
-
if (
|
|
750
|
+
if (internals8.isError(result))
|
|
747
751
|
return result;
|
|
748
752
|
if (!isObject(result))
|
|
749
753
|
throw new Error("Invalid JWT Claims Set.");
|
|
@@ -757,13 +761,13 @@ var Logout = class _Logout {
|
|
|
757
761
|
}
|
|
758
762
|
async parse() {
|
|
759
763
|
const credentials = await credentialsFile.load();
|
|
760
|
-
if (
|
|
764
|
+
if (internals9.isError(credentials))
|
|
761
765
|
throw credentials;
|
|
762
766
|
if (!credentials)
|
|
763
|
-
return `You are not currently logged in. Run ${green4(
|
|
767
|
+
return `You are not currently logged in. Run ${green4(internals9.getCommandWithExecutor("prisma platform auth login --early-access"))} to log in.`;
|
|
764
768
|
if (credentials.token) {
|
|
765
769
|
const jwt = decodeJwt(credentials.token);
|
|
766
|
-
if (!
|
|
770
|
+
if (!internals9.isError(jwt) && jwt.jti) {
|
|
767
771
|
await requestOrThrow({
|
|
768
772
|
token: credentials.token,
|
|
769
773
|
body: {
|
|
@@ -902,16 +906,16 @@ var Create = class _Create {
|
|
|
902
906
|
};
|
|
903
907
|
|
|
904
908
|
// src/platform/environment/delete.ts
|
|
905
|
-
import
|
|
909
|
+
import internals10 from "@prisma/internals";
|
|
906
910
|
var Delete = class _Delete {
|
|
907
911
|
static new() {
|
|
908
912
|
return new _Delete();
|
|
909
913
|
}
|
|
910
914
|
async parse(argv, _config) {
|
|
911
|
-
const args =
|
|
915
|
+
const args = internals10.arg(argv, {
|
|
912
916
|
...platformParameters.environment
|
|
913
917
|
});
|
|
914
|
-
if (
|
|
918
|
+
if (internals10.isError(args))
|
|
915
919
|
return args;
|
|
916
920
|
const token = await getTokenOrThrow(args);
|
|
917
921
|
const environmentId = getRequiredParameterOrThrow(args, ["--environment", "-e"]);
|
|
@@ -948,16 +952,16 @@ var Delete = class _Delete {
|
|
|
948
952
|
};
|
|
949
953
|
|
|
950
954
|
// src/platform/environment/show.ts
|
|
951
|
-
import
|
|
955
|
+
import internals11 from "@prisma/internals";
|
|
952
956
|
var Show2 = class _Show {
|
|
953
957
|
static new() {
|
|
954
958
|
return new _Show();
|
|
955
959
|
}
|
|
956
960
|
async parse(argv, _config) {
|
|
957
|
-
const args =
|
|
961
|
+
const args = internals11.arg(argv, {
|
|
958
962
|
...platformParameters.project
|
|
959
963
|
});
|
|
960
|
-
if (
|
|
964
|
+
if (internals11.isError(args))
|
|
961
965
|
return args;
|
|
962
966
|
const token = await getTokenOrThrow(args);
|
|
963
967
|
const projectId = getRequiredParameterOrThrow(args, ["--project", "-p"]);
|
|
@@ -1113,16 +1117,16 @@ var createProjectOrThrow = async (input) => {
|
|
|
1113
1117
|
};
|
|
1114
1118
|
|
|
1115
1119
|
// src/platform/project/delete.ts
|
|
1116
|
-
import
|
|
1120
|
+
import internals12 from "@prisma/internals";
|
|
1117
1121
|
var Delete2 = class _Delete {
|
|
1118
1122
|
static new() {
|
|
1119
1123
|
return new _Delete();
|
|
1120
1124
|
}
|
|
1121
1125
|
async parse(argv, _config) {
|
|
1122
|
-
const args =
|
|
1126
|
+
const args = internals12.arg(argv, {
|
|
1123
1127
|
...platformParameters.project
|
|
1124
1128
|
});
|
|
1125
|
-
if (
|
|
1129
|
+
if (internals12.isError(args))
|
|
1126
1130
|
return args;
|
|
1127
1131
|
const token = await getTokenOrThrow(args);
|
|
1128
1132
|
const projectId = getRequiredParameterOrThrow(args, ["--project", "-p"]);
|
|
@@ -1159,16 +1163,16 @@ var Delete2 = class _Delete {
|
|
|
1159
1163
|
};
|
|
1160
1164
|
|
|
1161
1165
|
// src/platform/project/show.ts
|
|
1162
|
-
import
|
|
1166
|
+
import internals13 from "@prisma/internals";
|
|
1163
1167
|
var Show3 = class _Show {
|
|
1164
1168
|
static new() {
|
|
1165
1169
|
return new _Show();
|
|
1166
1170
|
}
|
|
1167
1171
|
async parse(argv, _config) {
|
|
1168
|
-
const args =
|
|
1172
|
+
const args = internals13.arg(argv, {
|
|
1169
1173
|
...platformParameters.workspace
|
|
1170
1174
|
});
|
|
1171
|
-
if (
|
|
1175
|
+
if (internals13.isError(args))
|
|
1172
1176
|
return args;
|
|
1173
1177
|
const token = await getTokenOrThrow(args);
|
|
1174
1178
|
const workspaceId = getRequiredParameterOrThrow(args, ["--workspace", "-w"]);
|
|
@@ -1329,7 +1333,7 @@ var Delete3 = class _Delete {
|
|
|
1329
1333
|
};
|
|
1330
1334
|
|
|
1331
1335
|
// src/platform/serviceToken/show.ts
|
|
1332
|
-
import
|
|
1336
|
+
import internals14 from "@prisma/internals";
|
|
1333
1337
|
var Show4 = class _Show {
|
|
1334
1338
|
constructor(legacy = false) {
|
|
1335
1339
|
this.legacy = legacy;
|
|
@@ -1338,10 +1342,10 @@ var Show4 = class _Show {
|
|
|
1338
1342
|
return new _Show(legacy);
|
|
1339
1343
|
}
|
|
1340
1344
|
async parse(argv, _config) {
|
|
1341
|
-
const args =
|
|
1345
|
+
const args = internals14.arg(argv, {
|
|
1342
1346
|
...platformParameters.environment
|
|
1343
1347
|
});
|
|
1344
|
-
if (
|
|
1348
|
+
if (internals14.isError(args))
|
|
1345
1349
|
return args;
|
|
1346
1350
|
const token = await getTokenOrThrow(args);
|
|
1347
1351
|
const environmentId = getRequiredParameterOrThrow(args, ["--environment", "-e"]);
|
package/dist/index.js
CHANGED
|
@@ -4,24 +4,11 @@ import {
|
|
|
4
4
|
printPpgInitOutput,
|
|
5
5
|
requestOrThrow,
|
|
6
6
|
successMessage
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-PNUQLAGM.js";
|
|
8
8
|
|
|
9
9
|
// src/Init.ts
|
|
10
10
|
import { confirm, input, select } from "@inquirer/prompts";
|
|
11
|
-
import
|
|
12
|
-
arg,
|
|
13
|
-
canConnectToDatabase,
|
|
14
|
-
checkUnsupportedDataProxy,
|
|
15
|
-
format,
|
|
16
|
-
getCommandWithExecutor,
|
|
17
|
-
HelpError,
|
|
18
|
-
isError,
|
|
19
|
-
link,
|
|
20
|
-
logger,
|
|
21
|
-
PRISMA_POSTGRES_PROTOCOL,
|
|
22
|
-
PRISMA_POSTGRES_PROVIDER,
|
|
23
|
-
protocolToConnectorType
|
|
24
|
-
} from "@prisma/internals";
|
|
11
|
+
import internals from "@prisma/internals";
|
|
25
12
|
import dotenv from "dotenv";
|
|
26
13
|
import { Schema as Shape } from "effect";
|
|
27
14
|
import fs2 from "fs";
|
|
@@ -183,7 +170,7 @@ var defaultPort = (datasourceProvider) => {
|
|
|
183
170
|
return 5432;
|
|
184
171
|
case "cockroachdb":
|
|
185
172
|
return 26257;
|
|
186
|
-
case PRISMA_POSTGRES_PROVIDER:
|
|
173
|
+
case internals.PRISMA_POSTGRES_PROVIDER:
|
|
187
174
|
return null;
|
|
188
175
|
}
|
|
189
176
|
return void 0;
|
|
@@ -218,7 +205,7 @@ var Init = class _Init {
|
|
|
218
205
|
static new() {
|
|
219
206
|
return new _Init();
|
|
220
207
|
}
|
|
221
|
-
static help = format(`
|
|
208
|
+
static help = internals.format(`
|
|
222
209
|
Set up a new Prisma project
|
|
223
210
|
|
|
224
211
|
${bold2("Usage")}
|
|
@@ -263,7 +250,7 @@ var Init = class _Init {
|
|
|
263
250
|
${dim("$")} prisma init --with-model
|
|
264
251
|
`);
|
|
265
252
|
async parse(argv, _config) {
|
|
266
|
-
const args = arg(argv, {
|
|
253
|
+
const args = internals.arg(argv, {
|
|
267
254
|
"--help": Boolean,
|
|
268
255
|
"-h": "--help",
|
|
269
256
|
"--url": String,
|
|
@@ -279,10 +266,10 @@ var Init = class _Init {
|
|
|
279
266
|
"--prompt": String,
|
|
280
267
|
"--vibe": String
|
|
281
268
|
});
|
|
282
|
-
if (isError(args) || args["--help"]) {
|
|
269
|
+
if (internals.isError(args) || args["--help"]) {
|
|
283
270
|
return this.help();
|
|
284
271
|
}
|
|
285
|
-
checkUnsupportedDataProxy({ cmd: "init", urls: [args["--url"]] });
|
|
272
|
+
internals.checkUnsupportedDataProxy({ cmd: "init", urls: [args["--url"]] });
|
|
286
273
|
const outputDirName = args._[0];
|
|
287
274
|
if (outputDirName) {
|
|
288
275
|
throw Error("The init command does not take any argument.");
|
|
@@ -322,7 +309,7 @@ var Init = class _Init {
|
|
|
322
309
|
},
|
|
323
310
|
async (input2) => {
|
|
324
311
|
const url2 = input2["--url"];
|
|
325
|
-
const canConnect = await canConnectToDatabase(url2);
|
|
312
|
+
const canConnect = await internals.canConnectToDatabase(url2);
|
|
326
313
|
if (canConnect !== true) {
|
|
327
314
|
const { code, message } = canConnect;
|
|
328
315
|
if (code !== "P1003") {
|
|
@@ -333,7 +320,7 @@ var Init = class _Init {
|
|
|
333
320
|
}
|
|
334
321
|
}
|
|
335
322
|
}
|
|
336
|
-
const datasourceProvider2 = protocolToConnectorType(`${url2.split(":")[0]}:`);
|
|
323
|
+
const datasourceProvider2 = internals.protocolToConnectorType(`${url2.split(":")[0]}:`);
|
|
337
324
|
return { datasourceProvider: datasourceProvider2, url: url2 };
|
|
338
325
|
}
|
|
339
326
|
).otherwise(() => {
|
|
@@ -345,7 +332,7 @@ var Init = class _Init {
|
|
|
345
332
|
const generatorProvider = args["--generator-provider"];
|
|
346
333
|
const previewFeatures = args["--preview-feature"];
|
|
347
334
|
const output = args["--output"];
|
|
348
|
-
const isPpgCommand = args["--db"] || datasourceProvider === PRISMA_POSTGRES_PROVIDER || args["--prompt"] || args["--vibe"];
|
|
335
|
+
const isPpgCommand = args["--db"] || datasourceProvider === internals.PRISMA_POSTGRES_PROVIDER || args["--prompt"] || args["--vibe"];
|
|
349
336
|
let prismaPostgresDatabaseUrl;
|
|
350
337
|
let workspaceId = ``;
|
|
351
338
|
let projectId = ``;
|
|
@@ -355,9 +342,9 @@ var Init = class _Init {
|
|
|
355
342
|
let generatedSchema;
|
|
356
343
|
let generatedName;
|
|
357
344
|
if (isPpgCommand) {
|
|
358
|
-
const PlatformCommands = await import("./_-
|
|
345
|
+
const PlatformCommands = await import("./_-L7JAXIED.js");
|
|
359
346
|
const credentials = await credentialsFile.load();
|
|
360
|
-
if (isError(credentials))
|
|
347
|
+
if (internals.isError(credentials))
|
|
361
348
|
throw credentials;
|
|
362
349
|
if (!credentials) {
|
|
363
350
|
if (args["--non-interactive"]) {
|
|
@@ -447,7 +434,7 @@ var Init = class _Init {
|
|
|
447
434
|
environmentId: project.defaultEnvironment.id,
|
|
448
435
|
displayName: `database-setup-prismaPostgres-api-key`
|
|
449
436
|
});
|
|
450
|
-
prismaPostgresDatabaseUrl = `${PRISMA_POSTGRES_PROTOCOL}//accelerate.prisma-data.net/?api_key=${serviceToken.value}`;
|
|
437
|
+
prismaPostgresDatabaseUrl = `${internals.PRISMA_POSTGRES_PROTOCOL}//accelerate.prisma-data.net/?api_key=${serviceToken.value}`;
|
|
451
438
|
spinner.succeed(successMessage("Your Prisma Postgres database is ready \u2705"));
|
|
452
439
|
} catch (error) {
|
|
453
440
|
spinner.fail(error instanceof Error ? error.message : "Something went wrong");
|
|
@@ -546,12 +533,12 @@ var Init = class _Init {
|
|
|
546
533
|
steps.push(`Define models in the schema.prisma file.`);
|
|
547
534
|
} else {
|
|
548
535
|
steps.push(
|
|
549
|
-
`Run ${green(getCommandWithExecutor("prisma db pull"))} to turn your database schema into a Prisma schema.`
|
|
536
|
+
`Run ${green(internals.getCommandWithExecutor("prisma db pull"))} to turn your database schema into a Prisma schema.`
|
|
550
537
|
);
|
|
551
538
|
}
|
|
552
539
|
steps.push(
|
|
553
540
|
`Run ${green(
|
|
554
|
-
getCommandWithExecutor("prisma generate")
|
|
541
|
+
internals.getCommandWithExecutor("prisma generate")
|
|
555
542
|
)} to generate the Prisma Client. You can then start querying your database.`
|
|
556
543
|
);
|
|
557
544
|
steps.push(
|
|
@@ -578,21 +565,21 @@ var Init = class _Init {
|
|
|
578
565
|
const defaultOutput = `
|
|
579
566
|
\u2714 Your Prisma schema was created at ${green("prisma/schema.prisma")}
|
|
580
567
|
You can now open it in your favorite editor.
|
|
581
|
-
${warnings.length > 0 && logger.should.warn() ? `
|
|
568
|
+
${warnings.length > 0 && internals.logger.should.warn() ? `
|
|
582
569
|
${warnings.join("\n")}
|
|
583
570
|
` : ""}
|
|
584
571
|
Next steps:
|
|
585
572
|
${steps.map((s, i) => `${i + 1}. ${s}`).join("\n")}
|
|
586
573
|
|
|
587
574
|
More information in our documentation:
|
|
588
|
-
${link("https://pris.ly/d/getting-started")}
|
|
575
|
+
${internals.link("https://pris.ly/d/getting-started")}
|
|
589
576
|
`;
|
|
590
577
|
return isPpgCommand ? printPpgInitOutput({ databaseUrl: prismaPostgresDatabaseUrl, workspaceId, projectId, environmentId }) : defaultOutput;
|
|
591
578
|
}
|
|
592
579
|
// help message
|
|
593
580
|
help(error) {
|
|
594
581
|
if (error) {
|
|
595
|
-
return new HelpError(`
|
|
582
|
+
return new internals.HelpError(`
|
|
596
583
|
${bold2(red2(`!`))} ${error}
|
|
597
584
|
${_Init.help}`);
|
|
598
585
|
}
|