create-prisma 0.4.2-pr.55.205.1 → 0.4.2-pr.55.207.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
@@ -15,7 +15,7 @@ bunx create-prisma@next my-app
15
15
 
16
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
- The only Composer prompt is:
18
+ The deployment prompt is:
19
19
 
20
20
  ```text
21
21
  Deploy to Prisma now?
@@ -23,6 +23,10 @@ Deploy to Prisma now?
23
23
 
24
24
  Choose no to deploy later with the generated `deploy` script.
25
25
 
26
+ When multiple Prisma workspace sessions are available, the CLI asks which workspace should receive
27
+ the deployment. For unattended usage, pass `--workspace <id-or-name>` or omit it to use the active
28
+ workspace. Choosing another workspace also updates the Prisma CLI's active workspace session.
29
+
26
30
  ## Templates
27
31
 
28
32
  - `minimal`
@@ -45,6 +49,7 @@ PostgreSQL and MongoDB are supported with PSL or TypeScript contract authoring.
45
49
  - `--authoring psl|typescript`
46
50
  - `--package-manager npm|pnpm|yarn|bun`
47
51
  - `--deploy` / `--no-deploy`
52
+ - `--workspace <id-or-name>`
48
53
  - `--yes`
49
54
  - `--force`
50
55
  - `--verbose`
package/dist/cli.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import "./create-ek-5J5Ze.mjs";
2
+ import "./create-DWIaBT8s.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.55.205.1",
43
+ "cli-version": "0.4.2-pr.55.207.1",
44
44
  "node-version": process.version,
45
45
  platform: process.platform,
46
46
  arch: process.arch
@@ -169,7 +169,8 @@ const PrismaSetupOptionsSchema = z.object({
169
169
  provider: DatabaseProviderSchema.optional().describe("Prisma 8 database target: PostgreSQL relational models or MongoDB document models"),
170
170
  authoring: AuthoringStyleSchema.optional().describe("Contract authoring style"),
171
171
  packageManager: PackageManagerSchema.optional().describe("Package manager used for dependency installation"),
172
- deploy: z.boolean().optional().describe("Deploy the generated app to Prisma immediately")
172
+ deploy: z.boolean().optional().describe("Deploy the generated app to Prisma immediately"),
173
+ workspace: z.string().trim().min(1, "Please enter a valid workspace id or name").optional().describe("Prisma workspace id or name to deploy into")
173
174
  });
174
175
  const PrismaSetupCommandInputSchema = CommonCommandOptionsSchema.extend(PrismaSetupOptionsSchema.shape);
175
176
  const CreateScaffoldOptionsSchema = z.object({
@@ -666,6 +667,70 @@ async function ensureAuthentication(packageManager, projectDir) {
666
667
  if (!authenticatedState.authenticated) throw new Error("Prisma sign-in completed without an active workspace session.");
667
668
  return authenticatedState;
668
669
  }
670
+ function workspaceLabel(workspace) {
671
+ return workspace.name ?? workspace.id;
672
+ }
673
+ async function useWorkspace(options) {
674
+ const result = await runPrismaJsonCommand({
675
+ packageManager: options.packageManager,
676
+ projectDir: options.projectDir,
677
+ args: [
678
+ "auth",
679
+ "workspace",
680
+ "use",
681
+ options.workspace
682
+ ]
683
+ });
684
+ if (result.workspace.id !== options.activeWorkspace.id) log.info(`Prisma CLI workspace switched to ${workspaceLabel(result.workspace)}.`);
685
+ return result.workspace;
686
+ }
687
+ async function selectDeploymentWorkspace(options) {
688
+ const activeWorkspace = options.authState.workspace;
689
+ if (!activeWorkspace) throw new Error("The active Prisma credential does not specify a workspace.");
690
+ if (options.workspace) {
691
+ if (options.authState.source === "environment") {
692
+ if (options.workspace === activeWorkspace.id || options.workspace === activeWorkspace.name) return activeWorkspace;
693
+ throw new Error(`The environment credential is fixed to workspace ${workspaceLabel(activeWorkspace)}. Unset it before using --workspace ${options.workspace}.`);
694
+ }
695
+ return useWorkspace({
696
+ packageManager: options.packageManager,
697
+ projectDir: options.projectDir,
698
+ workspace: options.workspace,
699
+ activeWorkspace
700
+ });
701
+ }
702
+ if (!options.shouldPrompt || process.stdin.isTTY !== true) return activeWorkspace;
703
+ const available = await runPrismaJsonCommand({
704
+ packageManager: options.packageManager,
705
+ projectDir: options.projectDir,
706
+ args: [
707
+ "auth",
708
+ "workspace",
709
+ "list"
710
+ ]
711
+ });
712
+ if (available.items.length <= 1) return activeWorkspace;
713
+ const selectedWorkspaceId = await select({
714
+ message: "Select Prisma workspace for deployment",
715
+ initialValue: activeWorkspace.id,
716
+ options: available.items.map((workspace) => ({
717
+ value: workspace.workspaceId,
718
+ label: workspace.workspaceName ?? workspace.workspaceId,
719
+ hint: workspace.current ? `${workspace.workspaceId}, current` : workspace.workspaceId
720
+ }))
721
+ });
722
+ if (isCancel(selectedWorkspaceId)) {
723
+ cancel("Operation cancelled.");
724
+ return;
725
+ }
726
+ if (selectedWorkspaceId === activeWorkspace.id) return activeWorkspace;
727
+ return useWorkspace({
728
+ packageManager: options.packageManager,
729
+ projectDir: options.projectDir,
730
+ workspace: selectedWorkspaceId,
731
+ activeWorkspace
732
+ });
733
+ }
669
734
  function parseComposerDeployResult(result) {
670
735
  const summary = result.summary;
671
736
  if (!summary) return;
@@ -704,6 +769,14 @@ async function deployWithComposer(options) {
704
769
  const progress = options.verbose ? void 0 : spinner();
705
770
  try {
706
771
  const authState = await ensureAuthentication(options.packageManager, options.projectDir);
772
+ const selectedWorkspace = await selectDeploymentWorkspace({
773
+ packageManager: options.packageManager,
774
+ projectDir: options.projectDir,
775
+ shouldPrompt: options.shouldPromptForWorkspace,
776
+ authState,
777
+ ...options.workspace ? { workspace: options.workspace } : {}
778
+ });
779
+ if (!selectedWorkspace) return;
707
780
  progress?.start("Building for deployment...");
708
781
  if (options.verbose) log.step("Building for deployment.");
709
782
  const build = getRunScriptArgs(options.packageManager, "build");
@@ -733,7 +806,7 @@ async function deployWithComposer(options) {
733
806
  });
734
807
  progress?.stop("Deployed to Prisma.");
735
808
  if (options.verbose) log.success("Deployed to Prisma.");
736
- const workspace = details?.workspace ?? authState.workspace ?? void 0;
809
+ const workspace = details?.workspace ?? selectedWorkspace;
737
810
  return {
738
811
  appName,
739
812
  ...deployment?.appUrl ? { appUrl: deployment.appUrl } : {},
@@ -850,7 +923,9 @@ async function collectPrismaSetupContext(input, options = {}) {
850
923
  databaseProvider,
851
924
  authoring,
852
925
  packageManager,
853
- shouldDeploy
926
+ shouldDeploy,
927
+ shouldPromptForWorkspace: !useDefaults,
928
+ ...input.workspace ? { workspace: input.workspace } : {}
854
929
  };
855
930
  }
856
931
  function getCommandErrorMessage(error) {
@@ -996,7 +1071,9 @@ async function executePrismaSetupContext(context, options = {}) {
996
1071
  appName: projectName,
997
1072
  packageManager: context.packageManager,
998
1073
  projectDir,
999
- verbose: context.verbose
1074
+ shouldPromptForWorkspace: context.shouldPromptForWorkspace,
1075
+ verbose: context.verbose,
1076
+ ...context.workspace ? { workspace: context.workspace } : {}
1000
1077
  });
1001
1078
  if (!deployment) return false;
1002
1079
  }
package/dist/index.d.mts CHANGED
@@ -222,6 +222,7 @@ declare const CreateCommandInputSchema: z.ZodObject<{
222
222
  bun: "bun";
223
223
  }>>;
224
224
  deploy: z.ZodOptional<z.ZodBoolean>;
225
+ workspace: z.ZodOptional<z.ZodString>;
225
226
  name: z.ZodOptional<z.ZodString>;
226
227
  template: z.ZodOptional<z.ZodEnum<{
227
228
  minimal: "minimal";
@@ -260,6 +261,7 @@ declare const router: {
260
261
  bun: "bun";
261
262
  }>>;
262
263
  deploy: z.ZodOptional<z.ZodBoolean>;
264
+ workspace: z.ZodOptional<z.ZodString>;
263
265
  name: z.ZodOptional<z.ZodString>;
264
266
  template: z.ZodOptional<z.ZodEnum<{
265
267
  minimal: "minimal";
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-ek-5J5Ze.mjs";
2
+ import { a as DatabaseProviderSchema, i as CreateTemplateSchema, n as AuthoringStyleSchema, o as PackageManagerSchema, r as CreateCommandInputSchema, t as runCreateCommand } from "./create-DWIaBT8s.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.55.205.1";
8
+ const CLI_VERSION = "0.4.2-pr.55.207.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.55.205.1",
3
+ "version": "0.4.2-pr.55.207.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",
@@ -1,3 +1,5 @@
1
+ import { env } from "node:process";
2
+
1
3
  import { definePrismaConfig } from "@prisma/cli-engine";
2
4
  import { defineConfig as ormConfig } from "@prisma/orm-{{#if (eq provider "postgres")}}postgres{{else}}mongo{{/if}}/config";
3
5
 
@@ -8,7 +10,7 @@ export default definePrismaConfig({
8
10
  output: "./src/prisma/generated",
9
11
  {{/if}}
10
12
  db: {
11
- connection: process.env.{{#if (eq provider "postgres")}}DATABASE_URL{{else}}MONGODB_URL{{/if}}!,
13
+ connection: env.{{#if (eq provider "postgres")}}DATABASE_URL{{else}}MONGODB_URL{{/if}}!,
12
14
  },
13
15
  }),
14
16
  composer: {