create-prisma 0.9.2-pr.62.229.1 → 0.9.2-pr.63.232.1
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/dist/cli.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { z } from "zod";
|
|
3
|
-
import { cancel, confirm, intro, isCancel, log, note, outro, select, spinner, text } from "@clack/prompts";
|
|
3
|
+
import { cancel, confirm, intro, isCancel, log, note, outro, select, spinner, taskLog, text } from "@clack/prompts";
|
|
4
4
|
import fs from "fs-extra";
|
|
5
5
|
import path from "node:path";
|
|
6
6
|
import { randomUUID } from "node:crypto";
|
|
@@ -10,6 +10,7 @@ import Handlebars from "handlebars";
|
|
|
10
10
|
import { existsSync } from "node:fs";
|
|
11
11
|
import { fileURLToPath } from "node:url";
|
|
12
12
|
import { execa } from "execa";
|
|
13
|
+
import { createInterface } from "node:readline";
|
|
13
14
|
import { styleText } from "node:util";
|
|
14
15
|
|
|
15
16
|
//#region src/telemetry/client.ts
|
|
@@ -40,7 +41,7 @@ async function getAnonymousId() {
|
|
|
40
41
|
}
|
|
41
42
|
function getCommonProperties() {
|
|
42
43
|
return {
|
|
43
|
-
"cli-version": "0.9.2-pr.
|
|
44
|
+
"cli-version": "0.9.2-pr.63.232.1",
|
|
44
45
|
"node-version": process.version,
|
|
45
46
|
platform: process.platform,
|
|
46
47
|
arch: process.arch
|
|
@@ -694,12 +695,16 @@ async function runPrismaJsonCommand(options) {
|
|
|
694
695
|
"--json",
|
|
695
696
|
"--no-interactive"
|
|
696
697
|
]);
|
|
697
|
-
const
|
|
698
|
+
const subprocess = execa(invocation.command, invocation.args, {
|
|
698
699
|
cwd: options.projectDir,
|
|
699
700
|
env: process.env,
|
|
700
701
|
reject: false
|
|
701
702
|
});
|
|
702
|
-
|
|
703
|
+
const stderrLines = options.onStderrLine && subprocess.stderr ? (async () => {
|
|
704
|
+
const lines = createInterface({ input: subprocess.stderr });
|
|
705
|
+
for await (const line of lines) if (line.trim()) options.onStderrLine?.(line);
|
|
706
|
+
})() : Promise.resolve();
|
|
707
|
+
const [result] = await Promise.all([subprocess, stderrLines]);
|
|
703
708
|
let envelope;
|
|
704
709
|
try {
|
|
705
710
|
envelope = parsePrismaCliEnvelope(result.stdout);
|
|
@@ -713,6 +718,19 @@ async function runPrismaJsonCommand(options) {
|
|
|
713
718
|
}
|
|
714
719
|
return envelope.result;
|
|
715
720
|
}
|
|
721
|
+
function findProjectNameCollisions(projects, appName) {
|
|
722
|
+
return projects.filter((project) => project.name === appName);
|
|
723
|
+
}
|
|
724
|
+
async function ensureProjectNameAvailable(options) {
|
|
725
|
+
const collisions = findProjectNameCollisions((await runPrismaJsonCommand({
|
|
726
|
+
packageManager: options.packageManager,
|
|
727
|
+
projectDir: options.projectDir,
|
|
728
|
+
args: ["project", "list"]
|
|
729
|
+
})).items, options.appName);
|
|
730
|
+
if (collisions.length === 0) return;
|
|
731
|
+
const projectIds = collisions.map((project) => project.id).join(", ");
|
|
732
|
+
throw new Error(`A Prisma project named "${options.appName}" already exists in workspace ${workspaceLabel(options.workspace)} (${options.workspace.id}). Choose a different project name or delete the existing project (${projectIds}) in Prisma Console, then retry.`);
|
|
733
|
+
}
|
|
716
734
|
async function ensureAuthentication(packageManager, projectDir, beforeInteractiveLogin) {
|
|
717
735
|
const whoami = () => runPrismaJsonCommand({
|
|
718
736
|
packageManager,
|
|
@@ -834,8 +852,13 @@ async function getProjectDetails(options) {
|
|
|
834
852
|
return;
|
|
835
853
|
}
|
|
836
854
|
}
|
|
837
|
-
|
|
855
|
+
/**
|
|
856
|
+
* Performs the optional one-shot deployment at the end of a create-prisma scaffold.
|
|
857
|
+
* Generated projects use their own `deploy` script for every subsequent deployment.
|
|
858
|
+
*/
|
|
859
|
+
async function deployNewProjectWithComposer(options) {
|
|
838
860
|
const progress = options.verbose ? void 0 : spinner();
|
|
861
|
+
let deploymentLog;
|
|
839
862
|
let progressRunning = false;
|
|
840
863
|
const showProgress = (message) => {
|
|
841
864
|
if (!progress) return;
|
|
@@ -866,6 +889,14 @@ async function deployWithComposer(options) {
|
|
|
866
889
|
...options.workspace ? { workspace: options.workspace } : {}
|
|
867
890
|
});
|
|
868
891
|
if (!selectedWorkspace) return;
|
|
892
|
+
showProgress("Checking Prisma project name...");
|
|
893
|
+
if (options.verbose) log.step("Checking Prisma project name.");
|
|
894
|
+
await ensureProjectNameAvailable({
|
|
895
|
+
appName: options.appName,
|
|
896
|
+
packageManager: options.packageManager,
|
|
897
|
+
projectDir: options.projectDir,
|
|
898
|
+
workspace: selectedWorkspace
|
|
899
|
+
});
|
|
869
900
|
showProgress("Building for deployment...");
|
|
870
901
|
if (options.verbose) log.step("Building for deployment.");
|
|
871
902
|
const build = getRunScriptArgs(options.packageManager, "build");
|
|
@@ -874,22 +905,40 @@ async function deployWithComposer(options) {
|
|
|
874
905
|
env: process.env,
|
|
875
906
|
stdio: options.verbose ? "inherit" : "pipe"
|
|
876
907
|
});
|
|
877
|
-
|
|
878
|
-
|
|
908
|
+
clearProgress();
|
|
909
|
+
const deployCommand = getPackageExecutionCommand(options.packageManager, [
|
|
910
|
+
PRISMA_PLATFORM_CLI_PACKAGE,
|
|
911
|
+
"deploy",
|
|
912
|
+
"module.ts"
|
|
913
|
+
]);
|
|
914
|
+
if (options.verbose) log.step(`Deploying to Prisma with ${deployCommand}.`);
|
|
915
|
+
else {
|
|
916
|
+
deploymentLog = taskLog({
|
|
917
|
+
title: "Deploying to Prisma...",
|
|
918
|
+
limit: 10
|
|
919
|
+
});
|
|
920
|
+
deploymentLog.message(`$ ${deployCommand}`);
|
|
921
|
+
}
|
|
879
922
|
const deployment = parseComposerDeployResult(await runPrismaJsonCommand({
|
|
880
923
|
packageManager: options.packageManager,
|
|
881
924
|
projectDir: options.projectDir,
|
|
882
925
|
args: ["deploy", "module.ts"],
|
|
883
|
-
|
|
926
|
+
onStderrLine: (line) => {
|
|
927
|
+
const redactedLine = redactSecrets(line);
|
|
928
|
+
if (options.verbose) process.stderr.write(`${redactedLine}\n`);
|
|
929
|
+
else deploymentLog?.message(redactedLine);
|
|
930
|
+
}
|
|
884
931
|
}));
|
|
885
932
|
const appName = deployment?.appName ?? options.appName;
|
|
886
|
-
|
|
933
|
+
if (options.verbose) log.step("Loading deployment details.");
|
|
934
|
+
else deploymentLog?.message("Loading deployment details...");
|
|
887
935
|
const details = await getProjectDetails({
|
|
888
936
|
packageManager: options.packageManager,
|
|
889
937
|
projectDir: options.projectDir,
|
|
890
938
|
appName
|
|
891
939
|
});
|
|
892
|
-
|
|
940
|
+
deploymentLog?.success("Deployed to Prisma.");
|
|
941
|
+
deploymentLog = void 0;
|
|
893
942
|
progressRunning = false;
|
|
894
943
|
if (options.verbose) log.success("Deployed to Prisma.");
|
|
895
944
|
const workspace = details?.workspace ?? selectedWorkspace;
|
|
@@ -900,7 +949,10 @@ async function deployWithComposer(options) {
|
|
|
900
949
|
project: details?.project ?? { name: appName }
|
|
901
950
|
};
|
|
902
951
|
} catch (error) {
|
|
903
|
-
|
|
952
|
+
if (deploymentLog) {
|
|
953
|
+
deploymentLog.error("Deployment failed.");
|
|
954
|
+
deploymentLog = void 0;
|
|
955
|
+
} else progress?.error("Deployment failed.");
|
|
904
956
|
progressRunning = false;
|
|
905
957
|
log.error(`Deploy failed: ${getErrorMessage(error)}`);
|
|
906
958
|
return;
|
|
@@ -1186,7 +1238,7 @@ async function executePrismaSetupContext(context, options = {}) {
|
|
|
1186
1238
|
}
|
|
1187
1239
|
let deployment;
|
|
1188
1240
|
if (context.shouldDeploy) {
|
|
1189
|
-
deployment = await
|
|
1241
|
+
deployment = await deployNewProjectWithComposer({
|
|
1190
1242
|
appName: projectName,
|
|
1191
1243
|
packageManager: context.packageManager,
|
|
1192
1244
|
projectDir,
|
package/dist/index.mjs
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { a as DatabaseProviderSchema, i as CreateTemplateSchema, n as AuthoringStyleSchema, o as PackageManagerSchema, r as CreateCommandInputSchema, t as runCreateCommand } from "./create-
|
|
2
|
+
import { a as DatabaseProviderSchema, i as CreateTemplateSchema, n as AuthoringStyleSchema, o as PackageManagerSchema, r as CreateCommandInputSchema, t as runCreateCommand } from "./create-DLnU4PH_.mjs";
|
|
3
3
|
import { os } from "@orpc/server";
|
|
4
4
|
import { createCli } from "trpc-cli";
|
|
5
5
|
import { z } from "zod";
|
|
6
6
|
|
|
7
7
|
//#region src/index.ts
|
|
8
|
-
const CLI_VERSION = "0.9.2-pr.
|
|
8
|
+
const CLI_VERSION = "0.9.2-pr.63.232.1";
|
|
9
9
|
const CreateCliInputSchema = z.tuple([z.string().trim().min(1, "Please enter a valid project name").optional().describe("Project name / directory"), CreateCommandInputSchema]);
|
|
10
10
|
function normalizeCreateCliInput(input) {
|
|
11
11
|
const [projectName, options] = input;
|
package/package.json
CHANGED