-
Notifications
You must be signed in to change notification settings - Fork 0
Prisma Integration + Scaffolding Fixes #22
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
base: main
Are you sure you want to change the base?
Changes from all commits
112edf1
a38bd18
87c4421
f27e90b
cc8ffa0
59bf0b0
d262a2c
ec14a8e
88542a7
9fc2984
ea0449a
f630c4b
1f4942b
77d9c39
07340b1
8b22369
abc394c
624d6e6
bceecec
0551be1
8649a7c
564af5b
0b3abe4
2660054
8e62dc0
922b055
db2fb86
597ff4f
2b8dbb8
6ba1c72
b79480e
b658506
b69a71e
955e5a6
3644f96
66aa1ef
6ba9bc6
518804b
4c90a1f
cacdb53
f28a527
f7b97d3
974e691
fdd882d
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 | ||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -8,10 +8,13 @@ import { | |||||||||||||||||||||||||||||
| defaultDependencies, | ||||||||||||||||||||||||||||||
| defaultPlugins, | ||||||||||||||||||||||||||||||
| eslintAndPrettierDependencies, | ||||||||||||||||||||||||||||||
| eslintReactDependencies | ||||||||||||||||||||||||||||||
| eslintReactDependencies, | ||||||||||||||||||||||||||||||
| prismaDevDependencies, | ||||||||||||||||||||||||||||||
| prismaRuntimeDependencies | ||||||||||||||||||||||||||||||
| } from '../../data'; | ||||||||||||||||||||||||||||||
| import type { CreateConfiguration, PackageJson } from '../../types'; | ||||||||||||||||||||||||||||||
| import { getPackageVersions } from '../../utils/getPackageVersion'; | ||||||||||||||||||||||||||||||
| import { toDockerProjectName } from '../../utils/toDockerProjectName'; | ||||||||||||||||||||||||||||||
| import { versions } from '../../versions'; | ||||||||||||||||||||||||||||||
| import { computeFlags } from '../project/computeFlags'; | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
|
|
@@ -25,6 +28,7 @@ type CreatePackageJsonProps = Pick< | |||||||||||||||||||||||||||||
| | 'orm' | ||||||||||||||||||||||||||||||
| | 'frontendDirectories' | ||||||||||||||||||||||||||||||
| | 'codeQualityTool' | ||||||||||||||||||||||||||||||
| | 'databaseDirectory' | ||||||||||||||||||||||||||||||
| > & { | ||||||||||||||||||||||||||||||
| projectName: string; | ||||||||||||||||||||||||||||||
| latest: boolean; | ||||||||||||||||||||||||||||||
|
|
@@ -33,13 +37,13 @@ type CreatePackageJsonProps = Pick< | |||||||||||||||||||||||||||||
| const dbClientCommands = { | ||||||||||||||||||||||||||||||
| cockroachdb: 'cockroach sql --insecure --database=database', | ||||||||||||||||||||||||||||||
| gel: 'gel -H localhost -P 5656 -u admin --tls-security insecure -b main', | ||||||||||||||||||||||||||||||
| mariadb: 'MYSQL_PWD=userpassword mariadb -h127.0.0.1 -u user database', | ||||||||||||||||||||||||||||||
| mariadb: 'MYSQL_PWD=rootpassword mariadb -h127.0.0.1 -u root database', | ||||||||||||||||||||||||||||||
| mongodb: | ||||||||||||||||||||||||||||||
| 'mongosh -u user -p password --authenticationDatabase admin database', | ||||||||||||||||||||||||||||||
| 'mongosh -u root -p rootpassword --authenticationDatabase admin database', | ||||||||||||||||||||||||||||||
| mssql: '/opt/mssql-tools18/bin/sqlcmd -C -S localhost -U sa -P SApassword1', | ||||||||||||||||||||||||||||||
| mysql: 'MYSQL_PWD=userpassword mysql -h127.0.0.1 -u user database', | ||||||||||||||||||||||||||||||
| postgresql: 'psql -h localhost -U user -d database', | ||||||||||||||||||||||||||||||
| singlestore: 'singlestore -u root -ppassword -D database' | ||||||||||||||||||||||||||||||
| mysql: 'MYSQL_PWD=rootpassword mysql -h127.0.0.1 -u root database', | ||||||||||||||||||||||||||||||
| postgresql: 'psql -h localhost -U postgres -d database', | ||||||||||||||||||||||||||||||
| singlestore: 'singlestore -u root -prootpassword -D database' | ||||||||||||||||||||||||||||||
| } as const; | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| export const createPackageJson = async ({ | ||||||||||||||||||||||||||||||
|
|
@@ -52,7 +56,8 @@ export const createPackageJson = async ({ | |||||||||||||||||||||||||||||
| useTailwind, | ||||||||||||||||||||||||||||||
| latest, | ||||||||||||||||||||||||||||||
| frontendDirectories, | ||||||||||||||||||||||||||||||
| codeQualityTool | ||||||||||||||||||||||||||||||
| codeQualityTool, | ||||||||||||||||||||||||||||||
| databaseDirectory | ||||||||||||||||||||||||||||||
| }: CreatePackageJsonProps) => { | ||||||||||||||||||||||||||||||
| const flags = computeFlags(frontendDirectories); | ||||||||||||||||||||||||||||||
| const isLocal = !databaseHost || databaseHost === 'none'; | ||||||||||||||||||||||||||||||
|
|
@@ -248,33 +253,58 @@ export const createPackageJson = async ({ | |||||||||||||||||||||||||||||
| versions['elysia-scoped-state'] | ||||||||||||||||||||||||||||||
| ); | ||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| if (orm === 'drizzle') { | ||||||||||||||||||||||||||||||
| dependencies['drizzle-orm'] = resolveVersion( | ||||||||||||||||||||||||||||||
| 'drizzle-orm', | ||||||||||||||||||||||||||||||
| versions['drizzle-orm'] | ||||||||||||||||||||||||||||||
| ); | ||||||||||||||||||||||||||||||
| devDependencies['drizzle-kit'] = resolveVersion( | ||||||||||||||||||||||||||||||
| 'drizzle-kit', | ||||||||||||||||||||||||||||||
| versions['drizzle-kit'] | ||||||||||||||||||||||||||||||
| ); | ||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||
| const usesAccelerate = | ||||||||||||||||||||||||||||||
| orm === 'prisma' && | ||||||||||||||||||||||||||||||
| (databaseHost === 'neon' || databaseHost === 'planetscale'); | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| switch (databaseHost) { | ||||||||||||||||||||||||||||||
| case 'neon': | ||||||||||||||||||||||||||||||
| dependencies['@neondatabase/serverless'] = resolveVersion( | ||||||||||||||||||||||||||||||
| '@neondatabase/serverless', | ||||||||||||||||||||||||||||||
| versions['@neondatabase/serverless'] | ||||||||||||||||||||||||||||||
| ); | ||||||||||||||||||||||||||||||
| break; | ||||||||||||||||||||||||||||||
| case 'planetscale': | ||||||||||||||||||||||||||||||
| dependencies['@planetscale/database'] = resolveVersion( | ||||||||||||||||||||||||||||||
| '@planetscale/database', | ||||||||||||||||||||||||||||||
| versions['@planetscale/database'] | ||||||||||||||||||||||||||||||
| if (orm === 'prisma') { | ||||||||||||||||||||||||||||||
| prismaRuntimeDependencies.forEach((dep) => { | ||||||||||||||||||||||||||||||
| dependencies[dep.value] = resolveVersion( | ||||||||||||||||||||||||||||||
| dep.value, | ||||||||||||||||||||||||||||||
| dep.latestVersion | ||||||||||||||||||||||||||||||
| ); | ||||||||||||||||||||||||||||||
| break; | ||||||||||||||||||||||||||||||
| case 'turso': | ||||||||||||||||||||||||||||||
| dependencies['@libsql/client'] = resolveVersion( | ||||||||||||||||||||||||||||||
| '@libsql/client', | ||||||||||||||||||||||||||||||
| versions['@libsql/client'] | ||||||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| prismaDevDependencies.forEach((dep) => { | ||||||||||||||||||||||||||||||
| if (dep.value === '@prisma/extension-accelerate' && !usesAccelerate) | ||||||||||||||||||||||||||||||
| return; | ||||||||||||||||||||||||||||||
| devDependencies[dep.value] = resolveVersion( | ||||||||||||||||||||||||||||||
| dep.value, | ||||||||||||||||||||||||||||||
| dep.latestVersion | ||||||||||||||||||||||||||||||
| ); | ||||||||||||||||||||||||||||||
| break; | ||||||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||
| if (orm === 'drizzle') { | ||||||||||||||||||||||||||||||
| switch (databaseHost) { | ||||||||||||||||||||||||||||||
| case 'neon': | ||||||||||||||||||||||||||||||
| dependencies['@neondatabase/serverless'] = resolveVersion( | ||||||||||||||||||||||||||||||
| '@neondatabase/serverless', | ||||||||||||||||||||||||||||||
| versions['@neondatabase/serverless'] | ||||||||||||||||||||||||||||||
| ); | ||||||||||||||||||||||||||||||
| break; | ||||||||||||||||||||||||||||||
| case 'planetscale': | ||||||||||||||||||||||||||||||
| dependencies['@planetscale/database'] = resolveVersion( | ||||||||||||||||||||||||||||||
| '@planetscale/database', | ||||||||||||||||||||||||||||||
| versions['@planetscale/database'] | ||||||||||||||||||||||||||||||
| ); | ||||||||||||||||||||||||||||||
| break; | ||||||||||||||||||||||||||||||
| case 'turso': | ||||||||||||||||||||||||||||||
| dependencies['@libsql/client'] = resolveVersion( | ||||||||||||||||||||||||||||||
| '@libsql/client', | ||||||||||||||||||||||||||||||
| versions['@libsql/client'] | ||||||||||||||||||||||||||||||
| ); | ||||||||||||||||||||||||||||||
| break; | ||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| if (latest) s.stop(green('Package versions resolved')); | ||||||||||||||||||||||||||||||
|
|
@@ -296,7 +326,8 @@ export const createPackageJson = async ({ | |||||||||||||||||||||||||||||
| databaseEngine !== 'sqlite' | ||||||||||||||||||||||||||||||
| ) { | ||||||||||||||||||||||||||||||
| const clientCmd = dbClientCommands[databaseEngine]; | ||||||||||||||||||||||||||||||
| const dockerPrefix = `docker compose -p ${databaseEngine} -f db/docker-compose.db.yml`; | ||||||||||||||||||||||||||||||
| const composeFile = `${databaseDirectory ?? 'db'}/docker-compose.db.yml`; | ||||||||||||||||||||||||||||||
| const dockerPrefix = `docker compose -p ${toDockerProjectName(projectName)} -f ${composeFile}`; | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| scripts['db:up'] = `${dockerPrefix} up -d --wait db`; | ||||||||||||||||||||||||||||||
| scripts['db:down'] = `${dockerPrefix} down`; | ||||||||||||||||||||||||||||||
|
|
@@ -347,16 +378,33 @@ export const createPackageJson = async ({ | |||||||||||||||||||||||||||||
| ); | ||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| if (isLocalDb && databaseEngine === 'sqlite') { | ||||||||||||||||||||||||||||||
| scripts['db:sqlite'] = 'sqlite3 db/database.sqlite'; | ||||||||||||||||||||||||||||||
| scripts['db:init'] = 'sqlite3 db/database.sqlite < db/init.sql'; | ||||||||||||||||||||||||||||||
| if (isLocal && databaseEngine === 'sqlite') { | ||||||||||||||||||||||||||||||
| const dbDir = databaseDirectory ?? 'db'; | ||||||||||||||||||||||||||||||
| scripts['db:sqlite'] = `sqlite3 ${dbDir}/database.sqlite`; | ||||||||||||||||||||||||||||||
| scripts['db:init'] = | ||||||||||||||||||||||||||||||
| `sqlite3 ${dbDir}/database.sqlite < ${dbDir}/init.sql`; | ||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||
|
Comment on lines
381
to
386
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 chain🏁 Script executed: #!/bin/bash
# Search for both init.sql and schema.sql references in TypeScript files
rg -n "init\.sql|schema\.sql" --type=ts -C2Repository: absolutejs/create-absolutejs Length of output: 1132 🏁 Script executed: #!/bin/bash
# Search for all references to init.sql in the entire codebase
rg "init\.sql" -nRepository: absolutejs/create-absolutejs Length of output: 187 Change The generated Proposed fix scripts['db:init'] =
- `sqlite3 ${dbDir}/database.sqlite < ${dbDir}/init.sql`;
+ `sqlite3 ${dbDir}/database.sqlite < ${dbDir}/schema.sql`;📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| if (orm === 'drizzle') { | ||||||||||||||||||||||||||||||
| scripts['db:studio'] = 'drizzle-kit studio'; | ||||||||||||||||||||||||||||||
| scripts['db:push'] = 'drizzle-kit push'; | ||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| if (orm === 'prisma') { | ||||||||||||||||||||||||||||||
| const schemaPath = databaseDirectory | ||||||||||||||||||||||||||||||
| ? `${databaseDirectory}/schema.prisma` | ||||||||||||||||||||||||||||||
| : 'db/schema.prisma'; | ||||||||||||||||||||||||||||||
| scripts['postinstall'] = `prisma generate --schema ${schemaPath}`; | ||||||||||||||||||||||||||||||
| scripts['db:generate'] = `prisma generate --schema ${schemaPath}`; | ||||||||||||||||||||||||||||||
| scripts['db:push'] = `prisma db push --schema ${schemaPath}`; | ||||||||||||||||||||||||||||||
| scripts['db:studio'] = `prisma studio --schema ${schemaPath}`; | ||||||||||||||||||||||||||||||
| scripts['db:migrate'] = `prisma migrate dev --schema ${schemaPath}`; | ||||||||||||||||||||||||||||||
| scripts['db:migrate:deploy'] = | ||||||||||||||||||||||||||||||
| `prisma migrate deploy --schema ${schemaPath}`; | ||||||||||||||||||||||||||||||
| scripts['db:migrate:reset'] = | ||||||||||||||||||||||||||||||
| `prisma migrate reset --schema ${schemaPath}`; | ||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| const packageJson: PackageJson = { | ||||||||||||||||||||||||||||||
| dependencies, | ||||||||||||||||||||||||||||||
| devDependencies, | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
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
🌐 Web query:
@prisma/extension-accelerate runtime dependency vs dev dependency documentation💡 Result:
@prisma/extension-accelerateshould be a runtime dependency (put it independencies), because it’s imported and used by your application code at runtime (e.g.,import { withAccelerate } from "@prisma/extension-accelerate";). Prisma’s guides install it without--save-dev, while installing the Prisma CLI (prisma) with--save-dev. (prismagraphql.com)Citations:
🏁 Script executed:
Repository: absolutejs/create-absolutejs
Length of output: 85
🏁 Script executed:
Repository: absolutejs/create-absolutejs
Length of output: 383
🏁 Script executed:
Repository: absolutejs/create-absolutejs
Length of output: 645
🏁 Script executed:
Repository: absolutejs/create-absolutejs
Length of output: 425
@prisma/extension-acceleratemust be a runtime dependency, not a dev dependency.According to Prisma's official documentation,
@prisma/extension-accelerateis imported and used at runtime in the generated Prisma client code (seesrc/generators/configurations/generatePrismaClient.tsline 18). Placing it indevDependencies(currently insrc/data.tsline 186) means it will not be installed in production environments when usingnpm install --productionor equivalent flags, causing runtime failures when Accelerate is enabled.Move
@prisma/extension-acceleratefromprismaDevDependenciestoprismaRuntimeDependenciesinsrc/data.ts.🤖 Prompt for AI Agents