Cauen / prisma-generator-pothos-codegen

The fastest way to create a fully customizable CRUD Graphql API from Prisma Schema.
https://www.npmjs.com/package/prisma-generator-pothos-codegen
100 stars 19 forks source link

Example generates empty folders #8

Closed snake575 closed 2 years ago

snake575 commented 2 years ago

HI!, I was getting all empty folders on my project, so went to try the inputs-simple-sqlite example (deleting all the generated files) but got the same issue 🫤

Repro: https://github.com/snake575/prisma-generator-pothos-example

snake575 commented 2 years ago

Did a little testing, the generator works on windows, but not on macOS (genererates only empty folders)

Cauen commented 2 years ago

@snake575 I've tried with Ubuntu 20 and it works

Could you help me to find the cause on macOS? Does the input file generate normally?

I suspect it might be some limitation for bulk generation on macOS, and maybe using an await to generate the files will solve it.

Could you do these tests? Thanks for your contribution

snake575 commented 2 years ago

Hi @Cauen I tried on ubuntu and you're right, must be an issue with macOS 🤔

Cauen commented 2 years ago

Can you point me where to use an await?

Trying to run the test example making some changes to the source code to wait for a file to be generated before trying to generate another

https://github.com/Cauen/prisma-generator-pothos-codegen/blob/master/src/crudGenerator/index.ts


If you can do some testing and find the cause, I would be happy to accept a PR from you.

Otherwise, sometime soon I create a VM here to do some testing

snake575 commented 2 years ago

@Cauen solved the issue on #10 using fs/promises. It was the only way I could find to reliably have the generator working on macOS, however it may not be as performant.

This line never gets executed on macOS (have no idea why 🤷🏻‍♂️): https://github.com/Cauen/prisma-generator-pothos-codegen/blob/137bd72e19b089d79946bc62fb800ac261baa007/src/utils/filesystem.ts#L38