create-prisma 0.4.2-pr.53.201.1 → 0.4.2-pr.55.205.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/README.md CHANGED
@@ -13,7 +13,7 @@ yarn dlx create-prisma@next my-app
13
13
  bunx create-prisma@next my-app
14
14
  ```
15
15
 
16
- The CLI initializes Prisma 8 with the aligned `@prisma/cli` prerelease, installs dependencies, emits the contract, and generates a deployable Composer app. PostgreSQL projects use Composer's native Prisma Postgres provider, including migrations and a typed runtime client.
16
+ The CLI initializes Prisma 8 with `prisma@next`, installs dependencies, emits the contract, and generates a deployable Composer app. PostgreSQL projects use Composer's native Prisma Postgres provider, including migrations and a typed runtime client.
17
17
 
18
18
  The only Composer prompt is:
19
19
 
package/dist/cli.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import "./create-Bp1eBfXs.mjs";
2
+ import "./create-ek-5J5Ze.mjs";
3
3
  import { createCreatePrismaCli } from "./index.mjs";
4
4
 
5
5
  //#region src/cli.ts
@@ -40,7 +40,7 @@ async function getAnonymousId() {
40
40
  }
41
41
  function getCommonProperties() {
42
42
  return {
43
- "cli-version": "0.4.2-pr.53.201.1",
43
+ "cli-version": "0.4.2-pr.55.205.1",
44
44
  "node-version": process.version,
45
45
  platform: process.platform,
46
46
  arch: process.arch
@@ -429,10 +429,10 @@ const dependencyVersionMap = {
429
429
  "@astrojs/node": "^10.0.2",
430
430
  "@elysiajs/node": "^1.4.5",
431
431
  "@prisma/cli-engine": "0.2.0",
432
- "@prisma/composer": "0.9.0",
433
- "@prisma/composer-prisma-cloud": "0.9.0",
434
- "@prisma/orm-mongo": "8.0.0-rc.3",
435
- "@prisma/orm-postgres": "8.0.0-rc.3",
432
+ "@prisma/composer": "0.10.0",
433
+ "@prisma/composer-prisma-cloud": "0.10.0",
434
+ "@prisma/orm-mongo": "8.0.0-rc.4",
435
+ "@prisma/orm-postgres": "8.0.0-rc.4",
436
436
  "@sveltejs/adapter-node": "^5.3.2",
437
437
  "@types/node": "^25.6.2",
438
438
  alchemy: "2.0.0-beta.67",
@@ -613,31 +613,42 @@ function parsePrismaCliEnvelope(output) {
613
613
  } catch {}
614
614
  throw new Error("Prisma CLI returned output that is not a valid result envelope.");
615
615
  }
616
- function extractDeploymentUrl(output) {
617
- return output.match(/https:\/\/[a-z0-9.-]+\.prisma\.build\/?/gi)?.at(-1)?.replace(/\/$/, "");
618
- }
619
616
  function getPrismaCliArgs(packageManager, args) {
620
617
  return getPackageExecutionArgs(packageManager, [PRISMA_PLATFORM_CLI_PACKAGE, ...args]);
621
618
  }
622
- async function isAuthenticated(packageManager, projectDir) {
623
- const invocation = getPrismaCliArgs(packageManager, [
624
- "auth",
625
- "whoami",
619
+ async function runPrismaJsonCommand(options) {
620
+ const invocation = getPrismaCliArgs(options.packageManager, [
621
+ ...options.args,
626
622
  "--json",
627
623
  "--no-interactive"
628
624
  ]);
629
625
  const result = await execa(invocation.command, invocation.args, {
630
- cwd: projectDir,
626
+ cwd: options.projectDir,
631
627
  env: process.env,
632
628
  reject: false
633
629
  });
634
- const envelope = parsePrismaCliEnvelope(result.stdout);
635
- if (result.exitCode !== 0 || !envelope.ok) throw new Error(envelope.error?.summary ?? envelope.error?.message ?? "Prisma authentication check failed.");
636
- if (typeof envelope.result !== "object" || envelope.result === null) return false;
637
- return Reflect.get(envelope.result, "authenticated") === true;
630
+ if (options.forwardStderr && result.stderr) process.stderr.write(result.stderr.endsWith("\n") ? result.stderr : `${result.stderr}\n`);
631
+ let envelope;
632
+ try {
633
+ envelope = parsePrismaCliEnvelope(result.stdout);
634
+ } catch (error) {
635
+ if (result.exitCode !== 0 && result.stderr.trim()) throw new Error(result.stderr.trim());
636
+ throw error;
637
+ }
638
+ if (result.exitCode !== 0 || !envelope.ok || envelope.result === void 0) {
639
+ const summary = envelope.error?.summary ?? envelope.error?.message;
640
+ throw new Error([summary, envelope.error?.why].filter(Boolean).join(": ") || result.stderr.trim() || "Prisma CLI command failed.");
641
+ }
642
+ return envelope.result;
638
643
  }
639
644
  async function ensureAuthentication(packageManager, projectDir) {
640
- if (await isAuthenticated(packageManager, projectDir)) return;
645
+ const whoami = () => runPrismaJsonCommand({
646
+ packageManager,
647
+ projectDir,
648
+ args: ["auth", "whoami"]
649
+ });
650
+ const authState = await whoami();
651
+ if (authState.authenticated) return authState;
641
652
  const loginCommand = getPackageExecutionCommand(packageManager, [
642
653
  PRISMA_PLATFORM_CLI_PACKAGE,
643
654
  "auth",
@@ -651,30 +662,88 @@ async function ensureAuthentication(packageManager, projectDir) {
651
662
  env: process.env,
652
663
  stdio: "inherit"
653
664
  });
654
- if (!await isAuthenticated(packageManager, projectDir)) throw new Error("Prisma sign-in completed without an active workspace session.");
665
+ const authenticatedState = await whoami();
666
+ if (!authenticatedState.authenticated) throw new Error("Prisma sign-in completed without an active workspace session.");
667
+ return authenticatedState;
668
+ }
669
+ function parseComposerDeployResult(result) {
670
+ const summary = result.summary;
671
+ if (!summary) return;
672
+ const computeService = summary.nodes.flatMap((node) => node.entities).find((entity) => entity.kind === "compute-service");
673
+ return {
674
+ appName: summary.app,
675
+ ...computeService?.url ? { appUrl: computeService.url.replace(/\/$/, "") } : {}
676
+ };
677
+ }
678
+ async function getProjectDetails(options) {
679
+ try {
680
+ const result = await runPrismaJsonCommand({
681
+ packageManager: options.packageManager,
682
+ projectDir: options.projectDir,
683
+ args: [
684
+ "project",
685
+ "show",
686
+ "--project",
687
+ options.appName
688
+ ]
689
+ });
690
+ if (!result.project) return;
691
+ return {
692
+ workspace: result.workspace,
693
+ project: {
694
+ id: result.project.id,
695
+ name: result.project.name,
696
+ consoleUrl: `https://console.prisma.io/${encodeURIComponent(result.workspace.id)}/${encodeURIComponent(result.project.id)}`
697
+ }
698
+ };
699
+ } catch {
700
+ return;
701
+ }
655
702
  }
656
703
  async function deployWithComposer(options) {
657
704
  const progress = options.verbose ? void 0 : spinner();
658
705
  try {
659
- await ensureAuthentication(options.packageManager, options.projectDir);
660
- progress?.start("Deploying to Prisma...");
661
- const command = getRunScriptArgs(options.packageManager, "deploy");
662
- const result = await execa(command.command, command.args, {
706
+ const authState = await ensureAuthentication(options.packageManager, options.projectDir);
707
+ progress?.start("Building for deployment...");
708
+ if (options.verbose) log.step("Building for deployment.");
709
+ const build = getRunScriptArgs(options.packageManager, "build");
710
+ await execa(build.command, build.args, {
663
711
  cwd: options.projectDir,
664
712
  env: process.env,
665
713
  stdio: options.verbose ? "inherit" : "pipe"
666
714
  });
715
+ progress?.message("Deploying to Prisma...");
716
+ if (options.verbose) log.step("Deploying to Prisma.");
717
+ const deployment = parseComposerDeployResult(await runPrismaJsonCommand({
718
+ packageManager: options.packageManager,
719
+ projectDir: options.projectDir,
720
+ args: [
721
+ "composer",
722
+ "deploy",
723
+ "module.ts"
724
+ ],
725
+ forwardStderr: options.verbose
726
+ }));
727
+ const appName = deployment?.appName ?? options.appName;
728
+ progress?.message("Loading deployment details...");
729
+ const details = await getProjectDetails({
730
+ packageManager: options.packageManager,
731
+ projectDir: options.projectDir,
732
+ appName
733
+ });
667
734
  progress?.stop("Deployed to Prisma.");
668
735
  if (options.verbose) log.success("Deployed to Prisma.");
669
- else {
670
- const deploymentUrl = extractDeploymentUrl([result.stdout, result.stderr].filter((value) => typeof value === "string").join("\n"));
671
- if (deploymentUrl) log.info(`App: ${deploymentUrl}`);
672
- }
673
- return true;
736
+ const workspace = details?.workspace ?? authState.workspace ?? void 0;
737
+ return {
738
+ appName,
739
+ ...deployment?.appUrl ? { appUrl: deployment.appUrl } : {},
740
+ ...workspace ? { workspace } : {},
741
+ project: details?.project ?? { name: appName }
742
+ };
674
743
  } catch (error) {
675
- progress?.stop("Deployment failed.");
744
+ progress?.error("Deployment failed.");
676
745
  log.error(`Deploy failed: ${getErrorMessage(error)}`);
677
- return false;
746
+ return;
678
747
  }
679
748
  }
680
749
 
@@ -861,6 +930,20 @@ async function emitContract(context, projectDir) {
861
930
  function formatNextSteps(steps) {
862
931
  return steps.map((step) => `${step.command}\n ${step.description}`).join("\n\n");
863
932
  }
933
+ function formatPlatformTarget(name, id) {
934
+ return name ? `${name} (${id})` : id;
935
+ }
936
+ function formatProjectSummary(options) {
937
+ const lines = [];
938
+ if (options.createdProjectPath) lines.push(`Path: ${path.resolve(options.createdProjectPath)}`);
939
+ if (options.deployment?.workspace) lines.push(`Workspace: ${formatPlatformTarget(options.deployment.workspace.name, options.deployment.workspace.id)}`);
940
+ if (options.deployment) {
941
+ lines.push(`Project: ${options.deployment.project.id ? formatPlatformTarget(options.deployment.project.name, options.deployment.project.id) : options.deployment.project.name}`);
942
+ lines.push(`App: ${options.deployment.appUrl ?? options.deployment.appName}`);
943
+ if (options.deployment.project.consoleUrl) lines.push(`Console: ${options.deployment.project.consoleUrl}`);
944
+ }
945
+ return lines.join("\n");
946
+ }
864
947
  function buildNextSteps(context, options) {
865
948
  const nextSteps = [...options.prependNextSteps ?? []];
866
949
  if (context.databaseProvider === "mongo") nextSteps.push({
@@ -903,20 +986,27 @@ async function executePrismaSetupContext(context, options = {}) {
903
986
  await emitContract(context, projectDir);
904
987
  progress?.stop("Prisma 8 project ready.");
905
988
  } catch (error) {
906
- progress?.stop("Could not create Prisma 8 project.");
989
+ progress?.error("Could not create Prisma 8 project.");
907
990
  cancel(getCommandErrorMessage(error));
908
991
  return false;
909
992
  }
993
+ let deployment;
910
994
  if (context.shouldDeploy) {
911
- if (!await deployWithComposer({
995
+ deployment = await deployWithComposer({
996
+ appName: projectName,
912
997
  packageManager: context.packageManager,
913
998
  projectDir,
914
999
  verbose: context.verbose
915
- })) return false;
1000
+ });
1001
+ if (!deployment) return false;
916
1002
  }
917
- if (options.createdProjectPath) note(path.resolve(options.createdProjectPath), "Project path");
1003
+ const projectSummary = formatProjectSummary({
1004
+ createdProjectPath: options.createdProjectPath,
1005
+ deployment
1006
+ });
1007
+ if (projectSummary) note(projectSummary, context.shouldDeploy ? "Deployment" : "Project");
918
1008
  note(formatNextSteps(buildNextSteps(context, options)), "Next steps");
919
- outro(context.shouldDeploy ? "Prisma 8 app deployed." : "Prisma 8 setup complete.");
1009
+ outro(context.shouldDeploy ? "Prisma 8 app deployed." : "Prisma 8 project ready.");
920
1010
  return true;
921
1011
  }
922
1012
 
@@ -1158,7 +1248,7 @@ async function executeCreateContext(context) {
1158
1248
  });
1159
1249
  if (context.prismaSetupContext.verbose) log.success("Starter files scaffolded.");
1160
1250
  } catch (error) {
1161
- createSpinner?.stop("Could not create Prisma 8 project.");
1251
+ createSpinner?.error("Could not create Prisma 8 project.");
1162
1252
  return {
1163
1253
  ok: false,
1164
1254
  stage: "scaffold_template",
@@ -1172,7 +1262,7 @@ async function executeCreateContext(context) {
1172
1262
  projectDir: context.targetDirectory
1173
1263
  });
1174
1264
  } catch (error) {
1175
- createSpinner?.stop("Could not create Prisma 8 project.");
1265
+ createSpinner?.error("Could not create Prisma 8 project.");
1176
1266
  return {
1177
1267
  ok: false,
1178
1268
  stage: "scaffold_template",
@@ -1198,7 +1288,7 @@ async function executeCreateContext(context) {
1198
1288
  stage: "prisma_setup"
1199
1289
  };
1200
1290
  } catch (error) {
1201
- createSpinner?.stop("Could not create Prisma 8 project.");
1291
+ createSpinner?.error("Could not create Prisma 8 project.");
1202
1292
  return {
1203
1293
  ok: false,
1204
1294
  stage: "prisma_setup",
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-Bp1eBfXs.mjs";
2
+ import { a as DatabaseProviderSchema, i as CreateTemplateSchema, n as AuthoringStyleSchema, o as PackageManagerSchema, r as CreateCommandInputSchema, t as runCreateCommand } from "./create-ek-5J5Ze.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.4.2-pr.53.201.1";
8
+ const CLI_VERSION = "0.4.2-pr.55.205.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.4.2-pr.53.201.1",
3
+ "version": "0.4.2-pr.55.205.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",
@@ -50,7 +50,7 @@
50
50
  "release-notes": "bunx changelogithub"
51
51
  },
52
52
  "dependencies": {
53
- "@clack/prompts": "^1.0.1",
53
+ "@clack/prompts": "^1.7.0",
54
54
  "@orpc/server": "^1.13.5",
55
55
  "execa": "^9.6.1",
56
56
  "fs-extra": "^11.3.3",
@@ -27,8 +27,7 @@ MongoDB is not provisioned by Composer. Set `MONGODB_URL` before running Compose
27
27
  ## Prisma
28
28
 
29
29
  - Contract: `src/prisma/contract{{#if (eq authoring "typescript")}}.ts{{else}}.prisma{{/if}}`
30
- - Prisma 8 config: `prisma-next.config.ts`
31
- - Universal CLI config: `prisma.config.ts`
30
+ - Prisma and Composer config: `prisma.config.ts`
32
31
  - Composer app: `module.ts` and `service.ts`
33
32
 
34
33
  After changing the contract, run:
@@ -14,7 +14,7 @@ export default module("{{projectName}}", ({ provision }) => {
14
14
  pnPostgres({
15
15
  name: "database",
16
16
  contract: appContract,
17
- config: "./prisma-next.config.ts",
17
+ config: "./prisma.config.ts",
18
18
  }),
19
19
  { id: "database" },
20
20
  );
@@ -1,9 +1,16 @@
1
1
  import { definePrismaConfig } from "@prisma/cli-engine";
2
-
3
- import orm from "./prisma-next.config.ts";
2
+ import { defineConfig as ormConfig } from "@prisma/orm-{{#if (eq provider "postgres")}}postgres{{else}}mongo{{/if}}/config";
4
3
 
5
4
  export default definePrismaConfig({
6
- orm,
5
+ orm: ormConfig({
6
+ contract: "./src/prisma/contract{{#if (eq authoring "typescript")}}.ts{{else}}.prisma{{/if}}",
7
+ {{#if (eq authoring "typescript")}}
8
+ output: "./src/prisma/generated",
9
+ {{/if}}
10
+ db: {
11
+ connection: process.env.{{#if (eq provider "postgres")}}DATABASE_URL{{else}}MONGODB_URL{{/if}}!,
12
+ },
13
+ }),
7
14
  composer: {
8
15
  configPath: "./prisma-composer.config.ts",
9
16
  },
@@ -1,11 +0,0 @@
1
- import { defineConfig } from "@prisma/orm-{{#if (eq provider "postgres")}}postgres{{else}}mongo{{/if}}/config";
2
-
3
- export default defineConfig({
4
- contract: "./src/prisma/contract{{#if (eq authoring "typescript")}}.ts{{else}}.prisma{{/if}}",
5
- {{#if (eq authoring "typescript")}}
6
- output: "./src/prisma/generated",
7
- {{/if}}
8
- db: {
9
- connection: process.env.DATABASE_URL!,
10
- },
11
- });