Skip to content

feat: nuxt-prisma module v2#106

Closed
AmanVarshney01 wants to merge 15 commits intomainfrom
v2
Closed

feat: nuxt-prisma module v2#106
AmanVarshney01 wants to merge 15 commits intomainfrom
v2

Conversation

@AmanVarshney01
Copy link
Member

No description provided.

@vercel
Copy link

vercel bot commented Oct 28, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Preview Comments Updated (UTC)
nuxt-prisma Error Error Dec 2, 2025 5:12pm

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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-db with prompt support
  • Restructured module configuration with nested init, devtools, and setup sections
  • 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.

Comment on lines +9 to +10
async function detectPackageManager(rootDir: string): Promise<'bun' | 'pnpm' | 'yarn' | 'npm'> {
const { existsSync } = fs;
Copy link

Copilot AI Oct 28, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copilot uses AI. Check for mistakes.
Comment on lines +230 to +231
const importPath = `${clientImportPath}/client`
const fileContent = `import { PrismaClient } from '../${importPath}'
Copy link

Copilot AI Oct 28, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copilot uses AI. Check for mistakes.
src/module.ts Outdated
await writeClientInLib(LAYER_PATH);

if (options.generateClient) {
await writeClientInLib(PROJECT_PATH, options.init?.output);
Copy link

Copilot AI Oct 28, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Suggested change
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);

Copilot uses AI. Check for mistakes.
Comment on lines +8 to +10
const prisma = usePrisma()
const posts = await prisma.post.findMany()

Copy link

Copilot AI Oct 28, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Suggested change
const prisma = usePrisma()
const posts = await prisma.post.findMany()
const { data: posts } = await useFetch('/api/posts')

Copilot uses AI. Check for mistakes.
Comment on lines +44 to +45
prisma: {
database: {
Copy link

Copilot AI Oct 28, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copilot uses AI. Check for mistakes.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants