Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
There was a problem hiding this comment.
Pull Request Overview
This PR represents a major v2 refactor of the nuxt-prisma module, transitioning from a plugin-based architecture to a server-utility approach with integrated database provisioning and enhanced configuration options.
Key Changes:
- Removed the plugin-based Prisma client injection system and composables
- Introduced automatic database provisioning via
create-dbwith prompt support - Restructured module configuration with nested
init,devtools, andsetupsections - Added package manager detection and unified command execution
- Removed extensive documentation and examples directories
Reviewed Changes
Copilot reviewed 35 out of 44 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
| src/runtime/server/utils/prisma.ts | Removed singleton pattern file (to be regenerated by module) |
| src/runtime/plugin.ts | Removed Nuxt plugin for Prisma client injection |
| src/runtime/composables/usePrismaClient.ts | Removed composable (replaced by server utility) |
| src/package-utils/setup-helpers.ts | Refactored to use package manager detection, added database provisioning, simplified helper functions |
| src/package-utils/prompts.ts | Simplified to individual prompt functions with memoization |
| src/package-utils/log-helpers.ts | Added logging messages for database setup workflow |
| src/module.ts | Major restructure with new configuration schema and database provisioning workflow |
| playground/* | Updated playground to v2 structure and removed layer-based architecture |
| package.json | Updated dependencies to Nuxt 4 and Prisma 6.18 |
| docs/* | Removed entire documentation directory |
| README.md | Completely rewritten with new module capabilities and configuration |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
src/package-utils/setup-helpers.ts
Outdated
| async function detectPackageManager(rootDir: string): Promise<'bun' | 'pnpm' | 'yarn' | 'npm'> { | ||
| const { existsSync } = fs; |
There was a problem hiding this comment.
Destructuring existsSync from fs is redundant since fs is already imported at the top level. Use fs.existsSync directly or remove the top-level import.
src/package-utils/setup-helpers.ts
Outdated
| const importPath = `${clientImportPath}/client` | ||
| const fileContent = `import { PrismaClient } from '../${importPath}' |
There was a problem hiding this comment.
The import path construction is incorrect. If clientImportPath is '../generated', the result will be import { PrismaClient } from '../undefined/client' since the parameter is optional and defaults to undefined. This will cause import errors. Should use clientImportPath || '../generated' or provide a default value in the function signature.
src/module.ts
Outdated
| await writeClientInLib(LAYER_PATH); | ||
|
|
||
| if (options.generateClient) { | ||
| await writeClientInLib(PROJECT_PATH, options.init?.output); |
There was a problem hiding this comment.
Passing options.init?.output as-is to writeClientInLib will cause issues when it's undefined or when it contains '../generated'. The function expects a clean path but will construct '../undefined/client' or '../undefined/client' when no output is provided. This needs a default value or proper path resolution.
| await writeClientInLib(PROJECT_PATH, options.init?.output); | |
| // Ensure output path is valid and resolved | |
| const outputPath = | |
| options.init?.output && options.init.output !== "../generated" | |
| ? pathe.resolve(PROJECT_PATH, options.init.output) | |
| : pathe.resolve(PROJECT_PATH, "prisma/client"); | |
| await writeClientInLib(PROJECT_PATH, outputPath); |
playground/app.vue
Outdated
| const prisma = usePrisma() | ||
| const posts = await prisma.post.findMany() | ||
|
|
There was a problem hiding this comment.
Using usePrisma() in a client-side component (app.vue) will throw an error based on the implementation in playground/server/utils/prisma.ts which checks import.meta.client. This code should be moved to a server component or API route.
| const prisma = usePrisma() | |
| const posts = await prisma.post.findMany() | |
| const { data: posts } = await useFetch('/api/posts') |
| prisma: { | ||
| database: { |
There was a problem hiding this comment.
The configuration example in the README shows a database property, but the actual module configuration in src/module.ts uses init, devtools, and setup properties. The README configuration does not match the implemented interface.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
No description provided.