-
-
Notifications
You must be signed in to change notification settings - Fork 220
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 4 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 |
|---|---|---|
|
|
@@ -33,6 +33,7 @@ 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; | ||
|
|
@@ -64,7 +65,6 @@ export async function setupDatabase( | |
| }); | ||
| } | ||
|
|
||
| const webDir = path.join(projectDir, "apps/web"); | ||
| if (await fs.pathExists(webDir)) { | ||
| await addPackageDependency({ | ||
| dependencies: ["@prisma/client"], | ||
|
|
@@ -74,10 +74,14 @@ export async function setupDatabase( | |
| } else if (orm === "drizzle") { | ||
| if (database === "sqlite") { | ||
| await addPackageDependency({ | ||
| dependencies: ["drizzle-orm", "@libsql/client"], | ||
| dependencies: ["drizzle-orm", "@libsql/client", "libsql"], | ||
| 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( | ||
|
|
@@ -442,29 +385,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 +405,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" && | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -6,37 +6,7 @@ import { addEnvVariablesToFile, type EnvVariable } from "../core/env-setup"; | |
| export async function setupCloudflareD1(config: ProjectConfig) { | ||
| const { projectDir, serverDeploy, orm, backend } = config; | ||
|
|
||
| if (serverDeploy === "wrangler") { | ||
| const targetApp = backend === "self" ? "apps/web" : "apps/server"; | ||
| const envPath = path.join(projectDir, targetApp, ".env"); | ||
|
|
||
| const variables: EnvVariable[] = [ | ||
| { | ||
| key: "CLOUDFLARE_ACCOUNT_ID", | ||
| value: "", | ||
| condition: true, | ||
| }, | ||
| { | ||
| key: "CLOUDFLARE_DATABASE_ID", | ||
| value: "", | ||
| condition: true, | ||
| }, | ||
| { | ||
| key: "CLOUDFLARE_D1_TOKEN", | ||
| value: "", | ||
| condition: true, | ||
| }, | ||
| ]; | ||
|
|
||
| try { | ||
| await addEnvVariablesToFile(envPath, variables); | ||
| } catch (_err) {} | ||
| } | ||
|
|
||
| if ( | ||
| (serverDeploy === "wrangler" || serverDeploy === "alchemy") && | ||
| orm === "prisma" | ||
| ) { | ||
| if (serverDeploy === "alchemy" && orm === "prisma") { | ||
|
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: Hardcoded DB path breaks self backend.The |
||
| const targetApp2 = backend === "self" ? "apps/web" : "apps/server"; | ||
| const envPath = path.join(projectDir, targetApp2, ".env"); | ||
| const variables: EnvVariable[] = [ | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧩 Analysis chain
Verify that both
@libsql/clientandlibsqlpackages are required.The dependency array now includes both
@libsql/clientandlibsql. Please confirm whether both packages are necessary for libsql/Drizzle integration with SQLite, or if there's any redundancy.🌐 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
libsqlpackage from dependencies — only@libsql/clientis required.Drizzle's libSQL driver only requires
@libsql/client; the separatelibsqlpackage is an unrelated libSQL JS binding and should not be included in the dependencies array at line 77.🤖 Prompt for AI Agents