omar-dulaimi / prisma-zod-generator

Prisma 2+ generator to emit Zod schemas from your Prisma schema
MIT License
535 stars 45 forks source link

prisma-zod-generator deletes the entire output folder! #71

Open renanmt opened 1 year ago

renanmt commented 1 year ago

Bug description

I changed the output parameter to drop the files inside my src folder just to learn the generator deleted my entire day of work. Can you please review this behavior? If the output is different from the default, DO NOT WIPE THE OUTPUT FOLDER!

How to reproduce

Change the output option in the generator to:

generator zod {
  provider = "prisma-zod-generator"
  output = "../src"
} 

Expected behavior

Lose a full day of work if you did not commit anything yet.

Prisma information

generator zod { provider = "prisma-zod-generator" output = "../src" }

Environment & setup

Prisma Version

4.5.0
omar-dulaimi commented 1 year ago

There was definitely a reason why this happens, I don't remember exactly why. But if it doesn't cause any other issues, we may change it to overwrite instead.

Also, usually generators outputs go into a folder where the prisma schema resides. It's always a good idea to commit early and commit often. It's a bad practice doing it like you describe.

Anyway, I should work on this maybe this weekend. Feel free to work on it if you like.