-
-
Notifications
You must be signed in to change notification settings - Fork 218
feat(cli): Add prisma 7 support and improve alchemy support #692
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 6 commits
d5befba
46ebcfb
de47b88
20ad0ad
92aa7cc
2077910
281ca96
895a2a9
39ce131
be56cf5
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -53,6 +53,7 @@ export const dependencyVersionMap = { | |
| "@planetscale/database": "^1.19.0", | ||
|
|
||
| "@libsql/client": "^0.14.0", | ||
| libsql: "^0.5.22", | ||
|
|
||
| "@neondatabase/serverless": "^1.0.1", | ||
| pg: "^8.14.1", | ||
|
|
@@ -62,12 +63,15 @@ export const dependencyVersionMap = { | |
|
|
||
| mysql2: "^3.14.0", | ||
|
|
||
| "@prisma/client": "^6.15.0", | ||
| prisma: "^6.15.0", | ||
| "@prisma/adapter-d1": "^6.15.0", | ||
| "@prisma/adapter-libsql": "^6.15.0", | ||
|
|
||
| "@prisma/adapter-planetscale": "^6.15.0", | ||
| "@prisma/client": "dev", | ||
| prisma: "dev", | ||
| "@prisma/adapter-d1": "dev", | ||
| "@prisma/adapter-neon": "dev", | ||
| "@prisma/adapter-mariadb": "dev", | ||
| "@prisma/adapter-libsql": "dev", | ||
| "@prisma/adapter-better-sqlite3": "dev", | ||
| "@prisma/adapter-pg": "dev", | ||
| "@prisma/adapter-planetscale": "dev", | ||
|
|
||
| mongoose: "^8.14.0", | ||
|
|
||
|
|
@@ -157,7 +161,7 @@ export const dependencyVersionMap = { | |
| alchemy: "^0.77.0", | ||
|
|
||
| dotenv: "^17.2.2", | ||
| tsdown: "^0.15.5", | ||
| tsdown: "^0.16.5", | ||
| zod: "^4.1.11", | ||
|
Comment on lines
161
to
165
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧩 Analysis chaintsdown bump to ^0.16.5 – ensure all configs and templates are aligned Bumping
🏁 Script executed: #!/bin/bash
# Audit tsdown usage and versions across the repo
rg -n 'tsdown' -C3 .Length of output: 5011 Update apps/cli/package.json to match the tsdown bump The CLI app's own Update 🤖 Prompt for AI Agents |
||
| srvx: "0.8.15", | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -3,6 +3,7 @@ import { spinner } from "@clack/prompts"; | |
| import consola from "consola"; | ||
| import fs from "fs-extra"; | ||
| import pc from "picocolors"; | ||
| import type { AvailableDependencies } from "../../constants"; | ||
| import type { ProjectConfig } from "../../types"; | ||
| import { addPackageDependency } from "../../utils/add-package-deps"; | ||
| import { setupCloudflareD1 } from "../database-providers/d1-setup"; | ||
|
|
@@ -33,51 +34,80 @@ export async function setupDatabase( | |
|
|
||
| const s = spinner(); | ||
| const dbPackageDir = path.join(projectDir, "packages/db"); | ||
| const webDir = path.join(projectDir, "apps/web"); | ||
|
|
||
| if (!(await fs.pathExists(dbPackageDir))) { | ||
| return; | ||
| } | ||
|
|
||
| try { | ||
| if (orm === "prisma") { | ||
| if (database === "mysql" && dbSetup === "planetscale") { | ||
| if (database === "mongodb") { | ||
| await addPackageDependency({ | ||
| dependencies: [ | ||
| "@prisma/client", | ||
| "@prisma/adapter-planetscale", | ||
| "@planetscale/database", | ||
| ], | ||
| devDependencies: ["prisma"], | ||
| projectDir: dbPackageDir, | ||
| }); | ||
| } else if (database === "sqlite" && dbSetup === "turso") { | ||
| await addPackageDependency({ | ||
| dependencies: ["@prisma/client", "@prisma/adapter-libsql"], | ||
| devDependencies: ["prisma"], | ||
| customDependencies: { | ||
| "@prisma/client": "6.19.0", | ||
| }, | ||
| customDevDependencies: { | ||
| prisma: "6.19.0", | ||
| }, | ||
| projectDir: dbPackageDir, | ||
| }); | ||
| } else { | ||
| const prismaDependencies: AvailableDependencies[] = ["@prisma/client"]; | ||
| const prismaDevDependencies: AvailableDependencies[] = ["prisma"]; | ||
|
|
||
| if (database === "mysql" && dbSetup === "planetscale") { | ||
| prismaDependencies.push( | ||
| "@prisma/adapter-planetscale", | ||
| "@planetscale/database", | ||
| ); | ||
| } else if (database === "mysql") { | ||
| prismaDependencies.push("@prisma/adapter-mariadb"); | ||
| } else if (database === "sqlite") { | ||
| prismaDependencies.push("@prisma/adapter-libsql"); | ||
| } else if (database === "postgres") { | ||
| if (dbSetup === "neon") { | ||
| prismaDependencies.push("@prisma/adapter-neon"); | ||
| } else { | ||
| prismaDependencies.push("@prisma/adapter-pg"); | ||
| prismaDependencies.push("pg"); | ||
| prismaDevDependencies.push("@types/pg"); | ||
| } | ||
| } | ||
|
|
||
| await addPackageDependency({ | ||
| dependencies: ["@prisma/client"], | ||
| devDependencies: ["prisma"], | ||
| dependencies: prismaDependencies, | ||
| devDependencies: prismaDevDependencies, | ||
| projectDir: dbPackageDir, | ||
| }); | ||
| } | ||
|
|
||
| const webDir = path.join(projectDir, "apps/web"); | ||
| if (await fs.pathExists(webDir)) { | ||
| await addPackageDependency({ | ||
| dependencies: ["@prisma/client"], | ||
| projectDir: webDir, | ||
| }); | ||
| if (database === "mongodb") { | ||
| await addPackageDependency({ | ||
| customDependencies: { | ||
| "@prisma/client": "6.19.0", | ||
| }, | ||
| projectDir: webDir, | ||
| }); | ||
| } else { | ||
| await addPackageDependency({ | ||
| dependencies: ["@prisma/client"], | ||
| projectDir: webDir, | ||
| }); | ||
| } | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Bug: Prisma MongoDB hardcoded to v6.19.0 instead of v7.0.0The code hardcodes Prisma and |
||
| } | ||
| } else if (orm === "drizzle") { | ||
| if (database === "sqlite") { | ||
| await addPackageDependency({ | ||
| dependencies: ["drizzle-orm", "@libsql/client"], | ||
| dependencies: ["drizzle-orm", "@libsql/client", "libsql"], | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧩 Analysis chainVerify that both The dependency array now includes both 🌐 Web query: 💡 Result: Short answer: No — Drizzle projects using the libSQL driver only require the @libsql/client package (plus drizzle-orm/drizzle-kit as usual). The separate libsql npm package is a different libSQL JS binding and is not required by Drizzle. [1][2][3] Sources:
Remove the Drizzle's libSQL driver only requires 🤖 Prompt for AI Agents |
||
| devDependencies: ["drizzle-kit"], | ||
| projectDir: dbPackageDir, | ||
| }); | ||
| await addPackageDependency({ | ||
| dependencies: ["@libsql/client", "libsql"], | ||
| projectDir: webDir, | ||
| }); | ||
coderabbitai[bot] marked this conversation as resolved.
Show resolved
Hide resolved
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Bug: Drizzle: Inconsistent Directory ChecksFor Drizzle with SQLite, |
||
| } else if (database === "postgres") { | ||
| if (dbSetup === "neon") { | ||
| await addPackageDependency({ | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -77,12 +77,6 @@ export async function displayPostInstallInstructions( | |
| config.payments === "polar" && config.auth === "better-auth" | ||
| ? getPolarInstructions(backend) | ||
| : ""; | ||
| const wranglerDeployInstructions = getWranglerDeployInstructions( | ||
| runCmd, | ||
| webDeploy, | ||
| serverDeploy, | ||
| backend, | ||
| ); | ||
| const alchemyDeployInstructions = getAlchemyDeployInstructions( | ||
| runCmd, | ||
| webDeploy, | ||
|
|
@@ -127,10 +121,7 @@ export async function displayPostInstallInstructions( | |
| if ( | ||
| database === "sqlite" && | ||
| dbSetup === "none" && | ||
| (serverDeploy === "wrangler" || | ||
| serverDeploy === "alchemy" || | ||
| webDeploy === "wrangler" || | ||
| webDeploy === "alchemy") | ||
| (serverDeploy === "alchemy" || webDeploy === "alchemy") | ||
| ) { | ||
| output += `${pc.cyan(`${stepCounter++}.`)} ${runCmd} db:local\n${pc.dim( | ||
| " (starts local SQLite server for Workers compatibility)", | ||
|
|
@@ -162,9 +153,6 @@ export async function displayPostInstallInstructions( | |
| )} Complete D1 database setup first\n (see Database commands below)\n`; | ||
| } | ||
| output += `${pc.cyan(`${stepCounter++}.`)} ${runCmd} dev\n`; | ||
| if (serverDeploy === "wrangler") { | ||
| output += `${pc.cyan(`${stepCounter++}.`)} cd apps/server && ${runCmd} cf-typegen\n`; | ||
| } | ||
| } | ||
| } | ||
|
|
||
|
|
@@ -203,8 +191,6 @@ export async function displayPostInstallInstructions( | |
| if (tauriInstructions) output += `\n${tauriInstructions.trim()}\n`; | ||
| if (lintingInstructions) output += `\n${lintingInstructions.trim()}\n`; | ||
| if (pwaInstructions) output += `\n${pwaInstructions.trim()}\n`; | ||
| if (wranglerDeployInstructions) | ||
| output += `\n${wranglerDeployInstructions.trim()}\n`; | ||
| if (alchemyDeployInstructions) | ||
| output += `\n${alchemyDeployInstructions.trim()}\n`; | ||
| if (starlightInstructions) output += `\n${starlightInstructions.trim()}\n`; | ||
|
|
@@ -261,10 +247,10 @@ async function getDatabaseInstructions( | |
| database: Database, | ||
| orm?: ORM, | ||
| runCmd?: string, | ||
| runtime?: Runtime, | ||
| _runtime?: Runtime, | ||
| dbSetup?: DatabaseSetup, | ||
| serverDeploy?: string, | ||
| backend?: string, | ||
| _backend?: string, | ||
| ) { | ||
| const instructions: string[] = []; | ||
|
|
||
|
|
@@ -277,49 +263,6 @@ async function getDatabaseInstructions( | |
| } | ||
| } | ||
|
|
||
| if (serverDeploy === "wrangler" && dbSetup === "d1") { | ||
| if (orm === "prisma" && runtime === "workers") { | ||
| instructions.push( | ||
| `\n${pc.yellow( | ||
| "WARNING:", | ||
| )} Prisma + D1 on Workers with Wrangler has migration issues.\n Consider using Alchemy deploy instead of Wrangler for D1 projects.\n`, | ||
| ); | ||
| } | ||
| const packageManager = runCmd === "npm run" ? "npm" : runCmd || "npm"; | ||
|
|
||
| instructions.push( | ||
| `${pc.cyan("1.")} Login to Cloudflare: ${pc.white( | ||
| `${packageManager} wrangler login`, | ||
| )}`, | ||
| ); | ||
| instructions.push( | ||
| `${pc.cyan("2.")} Create D1 database: ${pc.white( | ||
| `${packageManager} wrangler d1 create your-database-name`, | ||
| )}`, | ||
| ); | ||
| const wranglerPath = backend === "self" ? "apps/web" : "apps/server"; | ||
| instructions.push( | ||
| `${pc.cyan( | ||
| "3.", | ||
| )} Update ${wranglerPath}/wrangler.jsonc with database_id and database_name`, | ||
| ); | ||
| instructions.push( | ||
| `${pc.cyan("4.")} Generate migrations: ${pc.white( | ||
| `cd ${wranglerPath} && ${runCmd} db:generate`, | ||
| )}`, | ||
| ); | ||
| instructions.push( | ||
| `${pc.cyan("5.")} Apply migrations locally: ${pc.white( | ||
| `${packageManager} wrangler d1 migrations apply YOUR_DB_NAME --local`, | ||
| )}`, | ||
| ); | ||
| instructions.push( | ||
| `${pc.cyan("6.")} Apply migrations to production: ${pc.white( | ||
| `${packageManager} wrangler d1 migrations apply YOUR_DB_NAME`, | ||
| )}`, | ||
| ); | ||
| } | ||
|
|
||
| if (dbSetup === "d1" && serverDeploy === "alchemy") { | ||
| if (orm === "drizzle") { | ||
| instructions.push( | ||
|
|
@@ -368,6 +311,9 @@ async function getDatabaseInstructions( | |
| ); | ||
| } | ||
| if (!(dbSetup === "d1" && serverDeploy === "alchemy")) { | ||
| instructions.push( | ||
| `${pc.cyan("•")} Generate Prisma Client: ${`${runCmd} db:generate`}`, | ||
| ); | ||
| instructions.push(`${pc.cyan("•")} Apply schema: ${`${runCmd} db:push`}`); | ||
| } | ||
| if (!(dbSetup === "d1" && serverDeploy === "alchemy")) { | ||
|
|
@@ -442,29 +388,6 @@ function getBunWebNativeWarning() { | |
| )} 'bun' might cause issues with web + native apps in a monorepo.\n Use 'pnpm' if problems arise.`; | ||
| } | ||
|
|
||
| function getWranglerDeployInstructions( | ||
| runCmd?: string, | ||
| webDeploy?: string, | ||
| serverDeploy?: string, | ||
| backend?: string, | ||
| ) { | ||
| const instructions: string[] = []; | ||
|
|
||
| if (webDeploy === "wrangler") { | ||
| const deployPath = backend === "self" ? "apps/web" : "apps/web"; | ||
| instructions.push( | ||
| `${pc.bold("Deploy web to Cloudflare Workers:")}\n${pc.cyan("•")} Deploy: ${`cd ${deployPath} && ${runCmd} deploy`}`, | ||
| ); | ||
| } | ||
| if (serverDeploy === "wrangler" && backend !== "self") { | ||
| instructions.push( | ||
| `${pc.bold("Deploy server to Cloudflare Workers:")}\n${pc.cyan("•")} Deploy: ${`cd apps/server && ${runCmd} deploy`}`, | ||
| ); | ||
| } | ||
|
|
||
| return instructions.length ? `\n${instructions.join("\n")}` : ""; | ||
| } | ||
|
|
||
| function getClerkInstructions() { | ||
| return `${pc.bold("Clerk Authentication Setup:")}\n${pc.cyan("•")} Follow the guide: ${pc.underline("https://docs.convex.dev/auth/clerk")}\n${pc.cyan("•")} Set CLERK_JWT_ISSUER_DOMAIN in Convex Dashboard\n${pc.cyan("•")} Set CLERK_PUBLISHABLE_KEY in apps/*/.env`; | ||
| } | ||
|
|
@@ -485,7 +408,7 @@ function getAlchemyDeployInstructions( | |
|
|
||
| if (webDeploy === "alchemy" && serverDeploy !== "alchemy") { | ||
| instructions.push( | ||
| `${pc.bold("Deploy web with Alchemy:")}\n${pc.cyan("•")} Dev: ${`cd apps/web && ${runCmd} dev`}\n${pc.cyan("•")} Deploy: ${`cd apps/web && ${runCmd} deploy`}\n${pc.cyan("•")} Destroy: ${`cd apps/web && ${runCmd} destroy`}`, | ||
| `${pc.bold("Deploy web with Alchemy:")}\n${pc.cyan("•")} Dev: ${`cd apps/web && ${runCmd} alchemy dev`}\n${pc.cyan("•")} Deploy: ${`cd apps/web && ${runCmd} deploy`}\n${pc.cyan("•")} Destroy: ${`cd apps/web && ${runCmd} destroy`}`, | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Bug: Inconsistent Alchemy Command PrefixesInconsistent There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Bug: Alchemy Web Deployment: Command Prefix ErrorThe web Alchemy deployment instructions include an incorrect |
||
| ); | ||
| } else if ( | ||
| serverDeploy === "alchemy" && | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.