create-prisma 0.9.2-pr.62.229.1 → 0.9.2-pr.63.231.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,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import "./create-V-NkNn-8.mjs";
2
+ import "./create-B4dcx9oX.mjs";
3
3
  import { createCreatePrismaCli } from "./index.mjs";
4
4
 
5
5
  //#region src/cli.ts
@@ -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.62.229.1",
44
+ "cli-version": "0.9.2-pr.63.231.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 result = await execa(invocation.command, invocation.args, {
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
- if (options.forwardStderr && result.stderr) process.stderr.write(result.stderr.endsWith("\n") ? result.stderr : `${result.stderr}\n`);
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,
@@ -836,6 +854,7 @@ async function getProjectDetails(options) {
836
854
  }
837
855
  async function deployWithComposer(options) {
838
856
  const progress = options.verbose ? void 0 : spinner();
857
+ let deploymentLog;
839
858
  let progressRunning = false;
840
859
  const showProgress = (message) => {
841
860
  if (!progress) return;
@@ -866,6 +885,14 @@ async function deployWithComposer(options) {
866
885
  ...options.workspace ? { workspace: options.workspace } : {}
867
886
  });
868
887
  if (!selectedWorkspace) return;
888
+ showProgress("Checking Prisma project name...");
889
+ if (options.verbose) log.step("Checking Prisma project name.");
890
+ await ensureProjectNameAvailable({
891
+ appName: options.appName,
892
+ packageManager: options.packageManager,
893
+ projectDir: options.projectDir,
894
+ workspace: selectedWorkspace
895
+ });
869
896
  showProgress("Building for deployment...");
870
897
  if (options.verbose) log.step("Building for deployment.");
871
898
  const build = getRunScriptArgs(options.packageManager, "build");
@@ -874,22 +901,40 @@ async function deployWithComposer(options) {
874
901
  env: process.env,
875
902
  stdio: options.verbose ? "inherit" : "pipe"
876
903
  });
877
- showProgress("Deploying to Prisma...");
878
- if (options.verbose) log.step("Deploying to Prisma.");
904
+ clearProgress();
905
+ const deployCommand = getPackageExecutionCommand(options.packageManager, [
906
+ PRISMA_PLATFORM_CLI_PACKAGE,
907
+ "deploy",
908
+ "module.ts"
909
+ ]);
910
+ if (options.verbose) log.step(`Deploying to Prisma with ${deployCommand}.`);
911
+ else {
912
+ deploymentLog = taskLog({
913
+ title: "Deploying to Prisma...",
914
+ limit: 10
915
+ });
916
+ deploymentLog.message(`$ ${deployCommand}`);
917
+ }
879
918
  const deployment = parseComposerDeployResult(await runPrismaJsonCommand({
880
919
  packageManager: options.packageManager,
881
920
  projectDir: options.projectDir,
882
921
  args: ["deploy", "module.ts"],
883
- forwardStderr: options.verbose
922
+ onStderrLine: (line) => {
923
+ const redactedLine = redactSecrets(line);
924
+ if (options.verbose) process.stderr.write(`${redactedLine}\n`);
925
+ else deploymentLog?.message(redactedLine);
926
+ }
884
927
  }));
885
928
  const appName = deployment?.appName ?? options.appName;
886
- showProgress("Loading deployment details...");
929
+ if (options.verbose) log.step("Loading deployment details.");
930
+ else deploymentLog?.message("Loading deployment details...");
887
931
  const details = await getProjectDetails({
888
932
  packageManager: options.packageManager,
889
933
  projectDir: options.projectDir,
890
934
  appName
891
935
  });
892
- progress?.stop("Deployed to Prisma.");
936
+ deploymentLog?.success("Deployed to Prisma.");
937
+ deploymentLog = void 0;
893
938
  progressRunning = false;
894
939
  if (options.verbose) log.success("Deployed to Prisma.");
895
940
  const workspace = details?.workspace ?? selectedWorkspace;
@@ -900,7 +945,10 @@ async function deployWithComposer(options) {
900
945
  project: details?.project ?? { name: appName }
901
946
  };
902
947
  } catch (error) {
903
- progress?.error("Deployment failed.");
948
+ if (deploymentLog) {
949
+ deploymentLog.error("Deployment failed.");
950
+ deploymentLog = void 0;
951
+ } else progress?.error("Deployment failed.");
904
952
  progressRunning = false;
905
953
  log.error(`Deploy failed: ${getErrorMessage(error)}`);
906
954
  return;
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-V-NkNn-8.mjs";
2
+ import { a as DatabaseProviderSchema, i as CreateTemplateSchema, n as AuthoringStyleSchema, o as PackageManagerSchema, r as CreateCommandInputSchema, t as runCreateCommand } from "./create-B4dcx9oX.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.62.229.1";
8
+ const CLI_VERSION = "0.9.2-pr.63.231.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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-prisma",
3
- "version": "0.9.2-pr.62.229.1",
3
+ "version": "0.9.2-pr.63.231.1",
4
4
  "private": false,
5
5
  "description": "Create Prisma 8 projects with first-party templates and great DX.",
6
6
  "homepage": "https://github.com/prisma/create-prisma",