Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 14 additions & 14 deletions src/constants/dependencies.ts
Original file line number Diff line number Diff line change
@@ -1,33 +1,33 @@
import type { CreateTemplate, PackageManager } from "../types";

export const dependencyVersionMap = {
"@astrojs/node": "^11.1.7",
"@astrojs/node": "^11.1.9",
"@elysia/node": "^1.4.6",
"@prisma/composer": "0.28.0",
"@prisma/composer-prisma-cloud": "0.28.0",
"@prisma/composer": "0.34.0",
"@prisma/composer-prisma-cloud": "0.34.0",
"@prisma/dev": "0.25.2",
"@prisma/orm-mongo": "8.0.0-rc.16",
"@prisma/orm-mongo": "8.0.0-rc.20",
// Must match @prisma/composer-prisma-cloud's exact peerDependency, even when
// prisma bundles a newer @prisma/orm-toolchain, or npm install fails with
// ERESOLVE.
"@prisma/orm-postgres": "8.0.0-rc.16",
"@prisma/orm-postgres": "8.0.0-rc.20",
"@sveltejs/adapter-node": "^6.0.0",
"@types/node": "^26.6.4",
"@types/node": "^26.6.5",
"@vitejs/devtools": "0.7.6",
alchemy: "2.0.0-beta.78",
arktype: "^2.2.7",
dotenv: "^18.0.6",
effect: "4.0.0-rc.115",
alchemy: "2.0.0-beta.83",
arktype: "^2.2.9",
dotenv: "^18.0.9",
effect: "4.0.3",
mongodb: "^7.7.0",
"mongodb-memory-server": "^11.3.0",
nitro: "^3.0.260903-beta",
// Must match the @prisma/composer-cli version this prisma release depends on.
// `bun run check:pins` verifies that against the Composer pins above.
prisma: "8.0.0-rc.21",
prisma: "8.0.0-rc.27",
// Node 22 needs a global Temporal for the ORM runtime's timestamp columns.
"temporal-polyfill": "^1.0.5",
tsdown: "^0.23.0",
turbo: "2.11.7",
"temporal-polyfill": "^1.0.6",
tsdown: "^0.23.1",
turbo: "2.11.10",
tsx: "^4.23.15",
typescript: "^6.0.3",
} as const;
Expand Down
14 changes: 7 additions & 7 deletions templates/create/_package-manager/pnpm-workspace.yaml.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@ allowBuilds:
minimumReleaseAgeExclude:
- "@prisma/*"
overrides:
effect: "4.0.0-rc.115"
"@effect/platform-bun": "4.0.0-rc.115"
"@effect/platform-node": "4.0.0-rc.115"
"@effect/platform-node-shared": "4.0.0-rc.115"
"@effect/sql-d1": "4.0.0-rc.115"
"@effect/sql-sqlite-do": "4.0.0-rc.115"
"@effect/vitest": "4.0.0-rc.115"
effect: "4.0.3"
"@effect/platform-bun": "4.0.3"
"@effect/platform-node": "4.0.3"
"@effect/platform-node-shared": "4.0.3"
"@effect/sql-d1": "4.0.3"
"@effect/sql-sqlite-do": "4.0.3"
"@effect/vitest": "4.0.3"
{{#if (eq provider "mongo")}}
peerDependencyRules:
allowedVersions:
Expand Down
18 changes: 12 additions & 6 deletions templates/create/_shared/src/prisma/db.ts.hbs
Original file line number Diff line number Diff line change
@@ -1,23 +1,28 @@
{{#if (eq provider "postgres")}}
import postgres from "@prisma/orm-postgres/runtime";
import { contractFromJson } from "@prisma/orm-postgres/static";

{{#if (eq packageManager "deno")}}
import type { Contract } from "./{{#if (eq authoring "typescript")}}generated/{{/if}}contract.d.ts";
import contractJson from "./{{#if (eq authoring "typescript")}}generated/{{/if}}contract.json" with { type: "json" };

export const contract = contractFromJson<Contract>(contractJson);

const databaseUrl = Deno.env.get("DATABASE_URL");
if (!databaseUrl) {
throw new Error("DATABASE_URL is not set. Add it to .env before starting the app.");
}

export const db = postgres<Contract>({ contractJson, url: databaseUrl });
export const db = postgres({ contract, url: databaseUrl });
{{else}}
import "temporal-polyfill/global";

import service from "{{#if (eq template "turborepo")}}../../../service.ts{{else}}../../service.ts{{/if}}";
import type { Contract } from "./{{#if (eq authoring "typescript")}}generated/{{/if}}contract.d.ts";
import contractJson from "./{{#if (eq authoring "typescript")}}generated/{{/if}}contract.json" with { type: "json" };

export const contract = contractFromJson<Contract>(contractJson);

function loadComposerDatabase() {
try {
return service.load().database.client;
Expand All @@ -29,16 +34,19 @@ function loadComposerDatabase() {
export const db =
loadComposerDatabase() ??
(process.env.DATABASE_URL
? postgres<Contract>({ contractJson, url: process.env.DATABASE_URL })
: postgres<Contract>({ contractJson }));
? postgres({ contract, url: process.env.DATABASE_URL })
: postgres({ contract }));
{{/if}}
{{else}}
import mongo from "@prisma/orm-mongo/runtime";
import { contractFromJson } from "@prisma/orm-mongo/static";

import service from "{{#if (eq template "turborepo")}}../../../service.ts{{else}}../../service.ts{{/if}}";
import type { Contract } from "./{{#if (eq authoring "typescript")}}generated/{{/if}}contract.d.ts";
import contractJson from "./{{#if (eq authoring "typescript")}}generated/{{/if}}contract.json" with { type: "json" };

export const contract = contractFromJson<Contract>(contractJson);

function getDatabaseUrl(): string | undefined {
try {
return service.input().databaseUrl.expose();
Expand All @@ -49,9 +57,7 @@ function getDatabaseUrl(): string | undefined {

const databaseUrl = getDatabaseUrl();

export const db = databaseUrl
? mongo<Contract>({ contractJson, url: databaseUrl })
: mongo<Contract>({ contractJson });
export const db = databaseUrl ? mongo({ contract, url: databaseUrl }) : mongo({ contract });
{{/if}}

let connection: Promise<void> | undefined;
Expand Down
4 changes: 2 additions & 2 deletions templates/create/_shared/src/prisma/users.ts.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ export async function listUsers(limit = 10) {
{{#if (eq provider "mongo")}}
const users = [];

for await (const user of db.orm.users.select("_id", "email", "username", "name").limit(limit).all()) {
for await (const user of db.orm.users.select("id", "email", "username", "name").limit(limit).all()) {
users.push({
id: String(user._id),
id: String(user.id),
email: user.email,
username: user.username ?? null,
name: user.name ?? null,
Expand Down
6 changes: 3 additions & 3 deletions templates/create/astro/package.json.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@
"astro": "astro"
},
"dependencies": {
"astro": "^7.3.6"
"astro": "^7.4.2"
},
"devDependencies": {
"@types/node": "^26.6.4",
"@types/node": "^26.6.5",
"tsx": "^4.23.15",
"typescript": "^6.0.3",
"vite": "^8.3.3"
"vite": "^8.3.5"
}
}
4 changes: 2 additions & 2 deletions templates/create/hono/package.json.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@
"start": "node dist/server.mjs"
},
"dependencies": {
"@hono/node-server": "^2.1.3",
"@hono/node-server": "^2.1.5",
"hono": "^4.13.13"
},
"devDependencies": {
"@types/node": "^26.6.4",
"@types/node": "^26.6.5",
"typescript": "^6.0.3"
}
}
8 changes: 4 additions & 4 deletions templates/create/nest/package.json.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@
"start": "node dist/server.mjs"
},
"dependencies": {
"@nestjs/common": "^12.1.2",
"@nestjs/core": "^12.1.2",
"@nestjs/platform-express": "^12.1.2",
"@nestjs/common": "^12.2.0",
"@nestjs/core": "^12.2.0",
"@nestjs/platform-express": "^12.2.0",
"reflect-metadata": "^0.2.2",
"rxjs": "^7.8.2"
},
"devDependencies": {
"@types/node": "^26.6.4",
"@types/node": "^26.6.5",
"typescript": "^6.0.3"
}
}
12 changes: 6 additions & 6 deletions templates/create/next/package.json.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,16 @@
"lint": "eslint"
},
"dependencies": {
"next": "16.4.0",
"react": "19.3.0",
"react-dom": "19.3.0"
"next": "16.4.2",
"react": "19.3.1",
"react-dom": "19.3.1"
},
"devDependencies": {
"@types/node": "^26.6.4",
"@types/node": "^26.6.5",
"@types/react": "^19.3.0",
"@types/react-dom": "^19.3.0",
"eslint": "^10.12.0",
"eslint-config-next": "16.4.0",
"eslint": "^10.13.0",
"eslint-config-next": "16.4.2",
"tsx": "^4.23.15",
"typescript": "^6.0.3"
}
Expand Down
12 changes: 6 additions & 6 deletions templates/create/nuxt/package.json.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,15 @@
"typecheck": "nuxt typecheck"
},
"dependencies": {
"nuxt": "^4.6.0",
"vue": "^3.5.43",
"vue-router": "^5.3.1"
"nuxt": "^4.6.2",
"vue": "^3.5.44",
"vue-router": "^5.4.0"
},
"devDependencies": {
"@types/node": "^26.6.4",
"@types/node": "^26.6.5",
"tsx": "^4.23.15",
"typescript": "^6.0.3",
"vite": "^8.3.3",
"vue-tsc": "^3.3.12"
"vite": "^8.3.5",
"vue-tsc": "^3.3.13"
}
}
8 changes: 4 additions & 4 deletions templates/create/svelte/package.json.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,13 @@
"check:watch": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json --watch"
},
"devDependencies": {
"@sveltejs/kit": "^3.0.1",
"@sveltejs/kit": "^3.1.0",
"@sveltejs/vite-plugin-svelte": "^7.3.1",
"@types/node": "^26.6.4",
"@types/node": "^26.6.5",
"svelte": "^5.57.2",
"svelte-check": "^4.7.6",
"svelte-check": "^4.7.7",
"tsx": "^4.23.15",
"typescript": "^6.0.3",
"vite": "^8.3.3"
"vite": "^8.3.5"
}
}
12 changes: 6 additions & 6 deletions templates/create/tanstack-start/package.json.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,18 @@
"typecheck": "tsc --noEmit"
},
"dependencies": {
"@tanstack/react-router": "^1.170.41",
"@tanstack/react-start": "^1.168.60",
"react": "^19.3.0",
"react-dom": "^19.3.0"
"@tanstack/react-router": "^1.170.46",
"@tanstack/react-start": "^1.169.4",
"react": "^19.3.1",
"react-dom": "^19.3.1"
},
"devDependencies": {
"@types/node": "^26.6.4",
"@types/node": "^26.6.5",
"@types/react": "^19.3.0",
"@types/react-dom": "^19.3.0",
"@vitejs/plugin-react": "^6.1.2",
"tsx": "^4.23.15",
"typescript": "^6.0.3",
"vite": "^8.3.3"
"vite": "^8.3.5"
}
}
16 changes: 8 additions & 8 deletions tests/dependencies.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@ import { dependencyVersionMap, getDependencyVersion } from "../src/constants/dep

describe("Prisma 8 dependency versions", () => {
test("uses the selected Prisma 8 and Composer releases", () => {
expect(getDependencyVersion("@prisma/orm-postgres")).toBe("8.0.0-rc.16");
expect(getDependencyVersion("@prisma/orm-mongo")).toBe("8.0.0-rc.16");
expect(getDependencyVersion("@prisma/composer")).toBe("0.28.0");
expect(getDependencyVersion("@prisma/composer-prisma-cloud")).toBe("0.28.0");
expect(getDependencyVersion("prisma")).toBe("8.0.0-rc.21");
expect(getDependencyVersion("alchemy")).toBe("2.0.0-beta.78");
expect(getDependencyVersion("effect")).toBe("4.0.0-rc.115");
expect(getDependencyVersion("turbo")).toBe("2.11.7");
expect(getDependencyVersion("@prisma/orm-postgres")).toBe("8.0.0-rc.20");
expect(getDependencyVersion("@prisma/orm-mongo")).toBe("8.0.0-rc.20");
expect(getDependencyVersion("@prisma/composer")).toBe("0.34.0");
expect(getDependencyVersion("@prisma/composer-prisma-cloud")).toBe("0.34.0");
expect(getDependencyVersion("prisma")).toBe("8.0.0-rc.27");
expect(getDependencyVersion("alchemy")).toBe("2.0.0-beta.83");
expect(getDependencyVersion("effect")).toBe("4.0.3");
expect(getDependencyVersion("turbo")).toBe("2.11.10");
expect(getDependencyVersion("typescript")).toBe("^6.0.3");
});

Expand Down
5 changes: 3 additions & 2 deletions tests/e2e/create-prisma.e2e.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,8 @@ async function verifyBuiltServer(

async function verifyComposerDev(projectDir: string, usersPath = "") {
const process = Bun.spawn({
cmd: ["bun", "run", "dev:composer"],
// A piped prisma command prints plain text; --json asks for the endpoint frames read below.
cmd: ["bun", "run", "dev:composer", "--", "--json"],
cwd: projectDir,
env: { ...Bun.env, CI: "1" },
stdout: "pipe",
Expand Down Expand Up @@ -527,7 +528,7 @@ describe("create-prisma e2e", () => {
expect(packageJson.devDependencies.prisma).toBe(dependencyVersionMap.prisma);
expect(packageJson.scripts.postinstall).toBe("prisma skills sync || exit 0");
expect(packageJson.scripts.deploy).toContain("bun run composer:deploy");
expect(packageJson.overrides.effect).toBe("4.0.0-rc.115");
expect(packageJson.overrides.effect).toBe("4.0.3");
expect(moduleSource).toContain("postgres({");
expect(dbSource).toContain("service.load().database.client");

Expand Down
6 changes: 5 additions & 1 deletion tests/install.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -590,8 +590,12 @@ describe("generated templates", () => {
} else {
expect(prismaConfig).not.toContain("output:");
expect(dbSource).toContain('import type { Contract } from "./contract.d.ts";');
expect(dbSource).toContain("contractJson,");
}
expect(dbSource).toContain(
"export const contract = contractFromJson<Contract>(contractJson);",
);
expect(dbSource).toMatch(/(?:postgres|mongo)\(\{ contract[,\s}]/);
expect(dbSource).not.toContain("contractJson,");
expect(await pathExists(path.join(projectDir, "prisma-next.config.ts"))).toBe(false);
expect(await pathExists(path.join(projectDir, "deno.json"))).toBe(false);
if (template === "nuxt" || template === "svelte" || template === "tanstack-start") {
Expand Down
Loading