keystonejs / keystone

The superpowered headless CMS for Node.js — built with GraphQL and React
https://keystonejs.com
MIT License
9.26k stars 1.16k forks source link

keystone prisma generate hangs with 2+ generators #8586

Closed Thinkscape closed 1 year ago

Thinkscape commented 1 year ago

Steps:

  1. Add a generator to prisma schema, i.e the erd one.

    npm i -D prisma-erd-generator @mermaid-js/mermaid-cli
    // keystone.ts
    export default config({
    db: {
    provider: "postgresql",
    url: env.DATABASE_URL,
    
    extendPrismaSchema: (schema: string) =>
      schema
        .replace(
          /(generator client {[^}]+})/,
          '$1\n\ngenerator erd {\nprovider = "prisma-erd-generator"\noutput   = "./erd.md"\n}\n'
        ),
  2. Run keystone prisma generate
  3. ✔ Replace the Prisma schema? … yes

Expected

Schema is generated and command finishes with exit code 0

Actual

Script hangs (never exits), with no cpu usage, at:

Your Prisma schema is not up to date
✔ Replace the Prisma schema? … yes
Prisma schema loaded from schema.prisma

✔ Generated Prisma Client (4.13.0 | library) to ./node_modules/.pnpm/@prisma+client@4.13.0_prisma@4.13.0/node_modules/@prisma/client in 80ms

✔ Generated Entity-relationship-diagram (1.7.0) to ./erd.md in 36ms
You can now start using Prisma Client in your code. Reference: https://pris.ly/d/client

import { PrismaClient } from '@prisma/client'
const prisma = new PrismaClient()

Background

Running the plain prisma generate on a prisma schema with the same 2 generators works correctly and exits with 0 (after generating erd.md file)

Thinkscape commented 1 year ago

Legend @acburdine ! Thanks for that ...