Skip to content
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

No output generated #36

Closed
jasonmacdonald opened this issue Dec 3, 2021 · 8 comments · Fixed by #39
Closed

No output generated #36

jasonmacdonald opened this issue Dec 3, 2021 · 8 comments · Fixed by #39

Comments

@jasonmacdonald
Copy link

I've looked through all the other topical issues and it seems even with the latest version I still cannot get it to produce any output, despite saying it completed just fine :(

OS: MacOS 12.0.1
package version: 0.6.1

Schema


generator client {
  provider = "prisma-client-js"
}

generator erd {
  provider = "prisma-erd-generator"
  output   = "ERD.png"
}

generator nestgraphql {
  provider               = "node ../../../node_modules/prisma-nestjs-graphql"
  output                 = "../src/@generated/"
  reExport               = Single
  fields_Validator_from  = "class-validator"
  fields_Validator_input = true
}

datasource db {
  provider = "postgresql"
  url   = env("DATABASE_URL")
}

model User {
  /// @validator.IsUUID(all)
  id        String   @id @default(uuid()) @db.Uuid
  /// @Validator.IsEmail()
  email     String   @unique
  /// @Validator.Length(8, 64)
  password  String
  /// @Validator.IsJSON()
  roles     Json[]
  profile   Profile?
  /// @HideField({ output: false, input: true })
  createdAt DateTime @default(now())
  /// @HideField({ output: false, input: true })
  updatedAt DateTime @default(now())
}

model Profile {
  id        String @id @default(uuid()) @db.Uuid
  user      User   @relation(fields: [userId], references: [id])
  userId    String @unique @db.Uuid
  firstName String
  lastName  String
}

Console log says everything is fine

✔ Generated Entity-relationship-diagram to ./prisma/ERD.png in 621ms

But no diagram is produced.

@jasonmacdonald
Copy link
Author

It appears it's looking for the mmdc file in the wrong place.

_NOTE: I removed some of the path and replaced them with ${PROJECT_ROOT}. This is just the path to my project root.

'Command failed: /Users/${PROJECT_ROOT}/libs/api/model/node_modules/.bin/mmdc -i /var/folders/t6/4vwlff9j6r5frxsm0s5sdjmh0000gq/T/prisma-erd-4wfTkY/prisma.mmd -o /Users/${PROJECT_ROOT}/libs/api/model/prisma/ERD.png -t forest -c /var/folders/t6/4vwlff9j6r5frxsm0s5sdjmh0000gq/T/prisma-erd-4wfTkY/config.json'

It should be looking here

/Users/${PROJECT_ROOT}/node_modules/.bin/mmdc -i 

but instead it's trying to find it inside my NX/libs folder

@keonik
Copy link
Owner

keonik commented Dec 6, 2021

Hey Jason! I'm out on some paternity leave so I will get to this when I have some more time. I'm seeing a lot of others running into similar problems and I think its a project setup issue. I started this off of the base case of

project/
   prisma/
      schema.prisma

and running the project from the project dir.

It works for that but there are some use cases I'm not thinking of. Is your situation any different from this?

For the time being I'm adding your schema to the test list to see if its an actual issue with the schema parsing or path or whatever else it could be.

36

@kefniark
Copy link

kefniark commented Dec 7, 2021

Same issue there

✔ Generated Entity-relationship-diagram to .\prisma\prisma-schema.svg in 106ms

But no file to be found anywhere

  • Node 16
  • Windows 10
  • prisma@3.6.x
  • prisma-erd-generator@0.6.1

And similar kind of issue, a node_modules path issue, because I'm using workspaces in this project (but I guess any DnD or modern npm replacement could cause similar issues)

Dirty workaround

Change the path to match the current project folder structure

const mermaidCliNodePath = path.resolve(path.join('node_modules', '.bin', 'mmdc')); // cant find the library
const mermaidCliNodePath = path.resolve(path.join('..', '..', 'node_modules', '.bin', 'mmdc')); // this works in my case

Better workaround

Also install the mermaid-cli as a dev dependency, to make sure it's available in the local ./node_modules/.bin/

yarn add -D prisma-erd-generator # install this library
yarn add -D @mermaid-js/mermaid-cli # Workaround: install mermaid-cli locally

@keonik
Copy link
Owner

keonik commented Dec 17, 2021

I'm gonna add mermaid cli as a peer dependency that way it at least warns to install it as a dev dependency. It should already be included though as its a dependency for the package.

@keonik keonik mentioned this issue Dec 17, 2021
Merged
@keonik
Copy link
Owner

keonik commented Dec 18, 2021

0.7.0 is going to hopefully throw some errors if the mmdc library is missing or if the file isn't generated. It won't fix the no output generated but it hopefully will throw errors and get people to share whether they're getting the mmdc path correct or the cli command is failing.

@keonik keonik reopened this Dec 18, 2021
@keonik
Copy link
Owner

keonik commented Dec 18, 2021

@jasonmacdonald @kefniark Could one of you try out the next version and see if it at least throws errors for you?

@kefniark
Copy link

kefniark commented Dec 22, 2021

I confirm, now it throw an error if mermaid-cli is not available locally 👍

Error: 
✔ Generated Prisma Client (3.6.0 | library) to .\node_modules\@prisma\client in 348ms

Error: Expected mermaid CLI at C:\Users\{PROJECT_PATH}\node_modules\.bin\mmdc but this package was not found.

Now I get new trouble in docker deployment, if I try to run prisma generate it explode because the path to the documentation does not exist 😄
But that's another issue

Prisma schema loaded from prisma/schema.prisma

Output directory "/app/docs/pages/" doesn't exist

Error: Command failed: /app/apps/api/node_modules/.bin/mmdc -i /tmp/prisma-erd-DufAnG/prisma.mmd -o /app/docs/pages/database.svg -t default -c /tmp/prisma-erd-DufAnG/config.json

Sadly I don't see any argument in prisma generate, to run only certain generators

@keonik
Copy link
Owner

keonik commented Dec 26, 2021

Yeah easiest way forward there is to make the directory you want to output to. I'm closing now that this will give better insight into where the issues are coming up.

@keonik keonik closed this as completed Dec 26, 2021
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 a pull request may close this issue.

3 participants