create-prisma 0.4.2-next.37.82.1 → 0.4.2-next.37.84.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
@@ -14,7 +14,7 @@ Scaffold a new app with Prisma Next already wired up.
14
14
  - adds `contract:emit`, `db:init`, `db:update`, `db:verify`, `db:seed`, `migration:plan`, `migration:apply`, `migration:status`, and `migration:show` scripts
15
15
  - adds `db:up` / `db:down` and `docker-compose.yml` for default MongoDB projects
16
16
  - creates or updates `.env` with `DATABASE_URL`
17
- - writes `.env.example`, `prisma-next.md`, and `.agents/skills/prisma-next/SKILL.md`
17
+ - writes `.env.example`, appends a Prisma Next reference to `README.md`, and scaffolds `.agents/skills/prisma-next/SKILL.md`
18
18
  - can install dependencies and run `prisma-next contract emit`
19
19
 
20
20
  `db:init`, migrations, and seeding are never run automatically. PostgreSQL projects show
package/dist/cli.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import "./create-BpEvye82.mjs";
2
+ import "./create-Bn4nsBxN.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-next.37.82.1",
43
+ "cli-version": "0.4.2-next.37.84.1",
44
44
  "node-version": process.version,
45
45
  platform: process.platform,
46
46
  arch: process.arch
@@ -867,6 +867,7 @@ const minimumServerVersion = {
867
867
  postgres: "14",
868
868
  mongo: "6.0"
869
869
  };
870
+ const readmeSectionMarker = "<!-- prisma-next-reference -->";
870
871
  const requiredPrismaFileGroups = [
871
872
  [
872
873
  "prisma/contract.prisma",
@@ -910,6 +911,18 @@ async function writeFileIfMissing(filePath, content) {
910
911
  if (await fs.pathExists(filePath)) return;
911
912
  await fs.outputFile(filePath, content.endsWith("\n") ? content : `${content}\n`, "utf8");
912
913
  }
914
+ async function appendReadmeSectionIfMissing(projectDir, content) {
915
+ const readmePath = path.join(projectDir, "README.md");
916
+ const section = `${readmeSectionMarker}\n${content.trim()}\n`;
917
+ if (!await fs.pathExists(readmePath)) {
918
+ await fs.outputFile(readmePath, `# Prisma Next\n\n${section}`, "utf8");
919
+ return;
920
+ }
921
+ const existingContent = await fs.readFile(readmePath, "utf8");
922
+ if (existingContent.includes(readmeSectionMarker)) return;
923
+ const separator = existingContent.endsWith("\n") ? "\n" : "\n\n";
924
+ await fs.writeFile(readmePath, `${existingContent}${separator}${section}`, "utf8");
925
+ }
913
926
  function getEnvExampleContent(provider) {
914
927
  const label = getDatabaseLabel(provider);
915
928
  const minVersion = minimumServerVersion[provider];
@@ -924,7 +937,7 @@ function getEnvExampleContent(provider) {
924
937
  function formatCommandListItem(packageManager, scriptName, description) {
925
938
  return `- \`${getRunScriptCommand(packageManager, scriptName)}\` - ${description}`;
926
939
  }
927
- function getPrismaNextQuickReferenceContent(options) {
940
+ function getPrismaNextReadmeSectionContent(options) {
928
941
  const { provider, authoring, schemaPreset, packageManager, schemaPath, dbImportPath, scripts, rootScripts } = options;
929
942
  const label = getDatabaseLabel(provider);
930
943
  const minVersion = minimumServerVersion[provider];
@@ -947,12 +960,12 @@ function getPrismaNextQuickReferenceContent(options) {
947
960
  "2. Run `contract:emit` after editing the contract.",
948
961
  "3. Run `migration:plan` and review the generated migration.",
949
962
  "4. Run `migration:apply` to apply pending migrations.",
950
- "5. Run `db:seed` if you want the starter sample data."
963
+ ...schemaPreset === "basic" ? ["5. Run `db:seed` if you want the starter sample data."] : []
951
964
  ] : [
952
965
  "1. Run `contract:emit` after editing the contract.",
953
966
  "2. For first-time setup, run `db:init` to create and sign the database state.",
954
967
  "3. For later contract changes, run `migration:plan` and `migration:apply`.",
955
- "4. Run `db:seed` if you want the starter sample data."
968
+ ...schemaPreset === "basic" ? ["4. Run `db:seed` if you want the starter sample data."] : []
956
969
  ];
957
970
  const queryExample = provider === "mongo" ? [
958
971
  "```ts",
@@ -974,7 +987,7 @@ function getPrismaNextQuickReferenceContent(options) {
974
987
  "PostgreSQL models use their contract model names, so the starter `User` model is queried through `db.orm.User`. Prefer `db.orm` for application queries and use raw SQL only when the ORM does not cover the operation."
975
988
  ];
976
989
  return [
977
- "# Prisma Next",
990
+ "## Prisma Next Reference",
978
991
  "",
979
992
  `This project uses Prisma Next with ${label}. The contract is authored in ${authoring === "typescript" ? "TypeScript" : "PSL"} at \`${schemaPath}\`.`,
980
993
  "",
@@ -1010,6 +1023,8 @@ function getPrismaNextQuickReferenceContent(options) {
1010
1023
  function getPrismaNextAgentSkillContent(options) {
1011
1024
  const { provider, authoring, schemaPreset, packageManager, schemaPath, dbImportPath, scripts, rootScripts } = options;
1012
1025
  const label = getDatabaseLabel(provider);
1026
+ const runtimePackage = provider === "mongo" ? "@prisma-next/mongo" : "@prisma-next/postgres";
1027
+ const descriptionDetails = provider === "mongo" ? "MongoDB queries, DATABASE_URL, db init/update/verify, migrations, seeding, local MongoDB Docker setup, replica sets, typed aggregations, or mongoClient escape hatches." : "PostgreSQL queries, DATABASE_URL, db init/update/verify, migrations, seeding, PostgreSQL setup, or raw SQL escape hatches.";
1013
1028
  const hasWorkspaceRootDbUp = typeof scripts["db:up"] !== "string" && typeof rootScripts["db:up"] === "string";
1014
1029
  const hasDbUp = typeof scripts["db:up"] === "string" || hasWorkspaceRootDbUp;
1015
1030
  const commands = [
@@ -1025,40 +1040,87 @@ function getPrismaNextAgentSkillContent(options) {
1025
1040
  ...schemaPreset === "basic" ? [formatCommandListItem(packageManager, "db:seed", "insert starter sample data")] : []
1026
1041
  ];
1027
1042
  const queryGuidance = provider === "mongo" ? [
1028
- "- Use `db.orm.users` / `db.orm.posts`; Mongo accessors follow emitted collection names.",
1029
- "- `.all()` returns an async iterable result, so `for await` is always safe.",
1030
- "- Use `db.query` for typed aggregation pipelines.",
1031
- "- The Mongo client connects lazily; scripts should call `await db.close()` in `finally`.",
1032
- "- Local MongoDB should run as a replica set for migration workflows."
1043
+ "- Use `db.orm`. Mongo root accessors are lowercased plural collection names emitted by `contract:emit`, for example `db.orm.users` and `db.orm.posts`.",
1044
+ "- `.all()` returns an async iterable result. Consume it with `for await` or await it to materialize an array.",
1045
+ "- Use `db.query` for typed aggregation pipelines when the ORM cannot express a query.",
1046
+ "- For direct MongoDB driver control, construct your own `MongoClient` and pass it through the `mongoClient` binding; keep that raw client reference for sessions, transactions, and change streams.",
1047
+ "- Do not use `db.runtime()` as a raw driver escape hatch. It returns Prisma Next's internal executor, not a `mongodb` `MongoClient` or `Db`.",
1048
+ "- The Mongo client connects lazily on the first query. Short-lived scripts should call `await db.close()` in `finally`.",
1049
+ "- Multi-document transactions and change streams require MongoDB to run as a replica set. The generated local Docker setup does this."
1033
1050
  ] : [
1034
- "- Use `db.orm.User` / `db.orm.Post`; PostgreSQL accessors follow contract model names.",
1035
- "- Prefer `db.orm` for application queries.",
1036
- "- Use raw SQL only when the ORM cannot express the operation.",
1037
- "- Close script runtimes with `await db.runtime().close()` when needed."
1051
+ "- Use `db.orm`. PostgreSQL root accessors follow contract model names, for example `db.orm.User` and `db.orm.Post`.",
1052
+ "- Prefer `db.orm` for application queries. Use raw SQL only when the ORM cannot express the operation or the user explicitly asks for it.",
1053
+ "- `.where(...)`, `.select(...)`, `.orderBy(...)`, `.take(...)`, `.all()`, `.first()`, and `.include(...)` are the primary ORM query methods.",
1054
+ "- Short-lived scripts should close the runtime with `await db.runtime().close()` when needed."
1038
1055
  ];
1039
- return [
1040
- "# Prisma Next Project Skill",
1056
+ const queryExamples = provider === "mongo" ? [
1057
+ "```ts",
1058
+ `import { db } from "${dbImportPath}";`,
1041
1059
  "",
1042
- `This project uses Prisma Next with ${label}. The contract is \`${schemaPath}\` using ${authoring === "typescript" ? "TypeScript" : "PSL"} authoring.`,
1060
+ "const user = await db.orm.users.where({ email: \"alice@example.com\" }).first();",
1043
1061
  "",
1044
- "## Files",
1062
+ "for await (const user of db.orm.users.select(\"_id\", \"email\").take(10).all()) {",
1063
+ " console.log(user.email);",
1064
+ "}",
1045
1065
  "",
1046
- `- Contract: \`${schemaPath}\``,
1047
- "- Config: `prisma-next.config.ts`",
1048
- `- Database helper: import \`db\` from \`${dbImportPath}\``,
1049
- "- Generated files: `prisma/contract.json` and `prisma/contract.d.ts`",
1066
+ "const usersWithPosts = await db.orm.users",
1067
+ " .select(\"_id\", \"email\")",
1068
+ " .include(\"posts\")",
1069
+ " .take(10)",
1070
+ " .all();",
1071
+ "```"
1072
+ ] : [
1073
+ "```ts",
1074
+ `import { db } from "${dbImportPath}";`,
1050
1075
  "",
1051
- "## Rules",
1076
+ "const user = await db.orm.User",
1077
+ " .where((user) => user.email.eq(\"alice@example.com\"))",
1078
+ " .first();",
1052
1079
  "",
1053
- "- Never edit generated contract artifacts by hand.",
1054
- "- Run `contract:emit` after contract edits before relying on new types.",
1055
- "- Do not auto-run `db:init`, migrations, or seed commands.",
1056
- ...queryGuidance,
1080
+ "const users = await db.orm.User.select(\"id\", \"email\").take(10).all();",
1081
+ "",
1082
+ "const usersWithPosts = await db.orm.User",
1083
+ " .select(\"id\", \"email\")",
1084
+ " .include(\"posts\", (post) => post.select(\"id\", \"title\").take(5))",
1085
+ " .take(10)",
1086
+ " .all();",
1087
+ "```"
1088
+ ];
1089
+ return [
1090
+ "---",
1091
+ "name: prisma-next",
1092
+ "description: >-",
1093
+ ` Prisma Next project workflow for this generated ${label} app. Use whenever working in this repository on Prisma Next contracts, generated contract artifacts, database helpers, ${descriptionDetails}`,
1094
+ "---",
1095
+ "",
1096
+ "# Prisma Next - Project Skill",
1097
+ "",
1098
+ `This project uses **Prisma Next** with **${label}** via \`${runtimePackage}\`. The contract is \`${schemaPath}\` using ${authoring === "typescript" ? "TypeScript" : "PSL"} authoring.`,
1099
+ "",
1100
+ "## Files",
1101
+ "",
1102
+ `- **Contract**: \`${schemaPath}\` - edit this to add or change models.`,
1103
+ "- **Config**: `prisma-next.config.ts` - tells the CLI where the contract is and how to connect to the database.",
1104
+ `- **Database helper**: import \`db\` from \`${dbImportPath}\`. This is the entry point for queries.`,
1105
+ "- **Generated files**: `prisma/contract.json` and `prisma/contract.d.ts`. Do not edit these by hand.",
1057
1106
  "",
1058
1107
  "## Commands",
1059
1108
  "",
1060
1109
  ...commands,
1061
1110
  "",
1111
+ "## How To Write Queries",
1112
+ "",
1113
+ ...queryExamples,
1114
+ "",
1115
+ "## Rules",
1116
+ "",
1117
+ "- Never hand-edit `contract.json` or `contract.d.ts`. Regenerate them with `contract:emit`.",
1118
+ "- Always run `contract:emit` after changing the contract before writing code that depends on the changed models.",
1119
+ "- Do not auto-run `db:init`, migrations, or seed commands. These are manual project-owner actions.",
1120
+ "- Do not restructure the generated database helper unless the user explicitly asks.",
1121
+ "- `DATABASE_URL` lives in `.env`; `.env.example` documents the expected shape and minimum server version.",
1122
+ ...queryGuidance,
1123
+ "",
1062
1124
  "## Common Workflow",
1063
1125
  "",
1064
1126
  "- Edit the contract.",
@@ -1082,7 +1144,7 @@ async function writePrismaNextProjectDocs(options) {
1082
1144
  const scripts = await readPackageScripts(prismaProjectDir);
1083
1145
  const rootScripts = await readPackageScripts(options.projectDir);
1084
1146
  await writeFileIfMissing(path.join(prismaProjectDir, ".env.example"), getEnvExampleContent(options.provider));
1085
- await writeFileIfMissing(path.join(prismaProjectDir, "prisma-next.md"), getPrismaNextQuickReferenceContent({
1147
+ await appendReadmeSectionIfMissing(prismaProjectDir, getPrismaNextReadmeSectionContent({
1086
1148
  provider: options.provider,
1087
1149
  authoring: options.authoring,
1088
1150
  schemaPreset: options.schemaPreset,
package/dist/index.mjs CHANGED
@@ -1,10 +1,10 @@
1
1
  #!/usr/bin/env node
2
- import { a as DatabaseProviderSchema, c as SchemaPresetSchema, i as CreateTemplateSchema, n as AuthoringStyleSchema, o as DatabaseUrlSchema, r as CreateCommandInputSchema, s as PackageManagerSchema, t as runCreateCommand } from "./create-BpEvye82.mjs";
2
+ import { a as DatabaseProviderSchema, c as SchemaPresetSchema, i as CreateTemplateSchema, n as AuthoringStyleSchema, o as DatabaseUrlSchema, r as CreateCommandInputSchema, s as PackageManagerSchema, t as runCreateCommand } from "./create-Bn4nsBxN.mjs";
3
3
  import { os } from "@orpc/server";
4
4
  import { createCli } from "trpc-cli";
5
5
 
6
6
  //#region src/index.ts
7
- const CLI_VERSION = "0.4.2-next.37.82.1";
7
+ const CLI_VERSION = "0.4.2-next.37.84.1";
8
8
  const router = os.router({ create: os.meta({
9
9
  description: "Create a new project with Prisma setup",
10
10
  default: true,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-prisma",
3
- "version": "0.4.2-next.37.82.1",
3
+ "version": "0.4.2-next.37.84.1",
4
4
  "private": false,
5
5
  "description": "Create Prisma Next projects with first-party templates and great DX.",
6
6
  "homepage": "https://github.com/prisma/create-prisma",
@@ -36,7 +36,7 @@ Database helper scripts are added to `package.json`:
36
36
  - `{{runScriptCommand packageManager "db:seed"}}` - insert sample users manually
37
37
  {{/if}}
38
38
 
39
- See `prisma-next.md` and `.agents/skills/prisma-next/SKILL.md` for provider-specific Prisma Next workflow notes.
39
+ This README includes provider-specific Prisma Next reference notes below. Agent-specific project guidance is scaffolded in `.agents/skills/prisma-next/SKILL.md`.
40
40
 
41
41
  Node-based Prisma Next projects expect Node.js 24 LTS or newer.
42
42
  {{#if (eq schemaPreset "basic")}}
@@ -34,7 +34,7 @@ Database helper scripts are added to `package.json`:
34
34
  - `{{runScriptCommand packageManager "db:seed"}}` - insert sample users manually
35
35
  {{/if}}
36
36
 
37
- See `prisma-next.md` and `.agents/skills/prisma-next/SKILL.md` for provider-specific Prisma Next workflow notes.
37
+ This README includes provider-specific Prisma Next reference notes below. Agent-specific project guidance is scaffolded in `.agents/skills/prisma-next/SKILL.md`.
38
38
 
39
39
  Node-based Prisma Next projects expect Node.js 24 LTS or newer.
40
40
  {{#if (eq schemaPreset "basic")}}
@@ -34,7 +34,7 @@ Database helper scripts are added to `package.json`:
34
34
  - `{{runScriptCommand packageManager "db:seed"}}` - insert sample users manually
35
35
  {{/if}}
36
36
 
37
- See `prisma-next.md` and `.agents/skills/prisma-next/SKILL.md` for provider-specific Prisma Next workflow notes.
37
+ This README includes provider-specific Prisma Next reference notes below. Agent-specific project guidance is scaffolded in `.agents/skills/prisma-next/SKILL.md`.
38
38
 
39
39
  Node-based Prisma Next projects expect Node.js 24 LTS or newer.
40
40
  {{#if (eq schemaPreset "basic")}}
@@ -35,7 +35,7 @@ Database helper scripts are added to `package.json`:
35
35
  - `{{runScriptCommand packageManager "db:seed"}}` - insert sample users manually
36
36
  {{/if}}
37
37
 
38
- See `prisma-next.md` and `.agents/skills/prisma-next/SKILL.md` for provider-specific Prisma Next workflow notes.
38
+ This README includes provider-specific Prisma Next reference notes below. Agent-specific project guidance is scaffolded in `.agents/skills/prisma-next/SKILL.md`.
39
39
 
40
40
  Node-based Prisma Next projects expect Node.js 24 LTS or newer.
41
41
  {{#if (eq schemaPreset "basic")}}
@@ -34,7 +34,7 @@ Database helper scripts are added to `package.json`:
34
34
  - `{{runScriptCommand packageManager "db:seed"}}` - insert sample users manually
35
35
  {{/if}}
36
36
 
37
- See `prisma-next.md` and `.agents/skills/prisma-next/SKILL.md` for provider-specific Prisma Next workflow notes.
37
+ This README includes provider-specific Prisma Next reference notes below. Agent-specific project guidance is scaffolded in `.agents/skills/prisma-next/SKILL.md`.
38
38
 
39
39
  Node-based Prisma Next projects expect Node.js 24 LTS or newer.
40
40
  {{#if (eq schemaPreset "basic")}}
@@ -36,7 +36,7 @@ Database helper scripts are added to `package.json`:
36
36
  - `{{runScriptCommand packageManager "db:seed"}}` - insert sample users manually
37
37
  {{/if}}
38
38
 
39
- See `prisma-next.md` and `.agents/skills/prisma-next/SKILL.md` for provider-specific Prisma Next workflow notes.
39
+ This README includes provider-specific Prisma Next reference notes below. Agent-specific project guidance is scaffolded in `.agents/skills/prisma-next/SKILL.md`.
40
40
 
41
41
  Node-based Prisma Next projects expect Node.js 24 LTS or newer.
42
42
  {{#if (eq schemaPreset "basic")}}
@@ -35,7 +35,7 @@ Database helper scripts are added to `package.json`:
35
35
  - `{{runScriptCommand packageManager "db:seed"}}` - insert sample users manually
36
36
  {{/if}}
37
37
 
38
- See `prisma-next.md` and `.agents/skills/prisma-next/SKILL.md` for provider-specific Prisma Next workflow notes.
38
+ This README includes provider-specific Prisma Next reference notes below. Agent-specific project guidance is scaffolded in `.agents/skills/prisma-next/SKILL.md`.
39
39
 
40
40
  Node-based Prisma Next projects expect Node.js 24 LTS or newer.
41
41
  {{#if (eq schemaPreset "basic")}}
@@ -35,7 +35,7 @@ Database helper scripts are added to `package.json`:
35
35
  - `{{runScriptCommand packageManager "db:seed"}}` - insert sample users manually
36
36
  {{/if}}
37
37
 
38
- See `prisma-next.md` and `.agents/skills/prisma-next/SKILL.md` for provider-specific Prisma Next workflow notes.
38
+ This README includes provider-specific Prisma Next reference notes below. Agent-specific project guidance is scaffolded in `.agents/skills/prisma-next/SKILL.md`.
39
39
 
40
40
  Node-based Prisma Next projects expect Node.js 24 LTS or newer.
41
41
  {{#if (eq schemaPreset "basic")}}
@@ -27,7 +27,7 @@ Generated by `create-prisma` with the Turborepo template.
27
27
  - `{{runScriptCommand packageManager "db:seed"}}` - insert sample users manually in `packages/db`
28
28
  {{/if}}
29
29
 
30
- See `packages/db/prisma-next.md` and `packages/db/.agents/skills/prisma-next/SKILL.md` for provider-specific Prisma Next workflow notes.
30
+ See `packages/db/README.md` for provider-specific Prisma Next reference notes. Agent-specific project guidance is scaffolded in `packages/db/.agents/skills/prisma-next/SKILL.md`.
31
31
 
32
32
  ## Prisma Next
33
33