edgedb-js icon indicating copy to clipboard operation
edgedb-js copied to clipboard

[generate] issues with prompting about .gitignore

Open spalger opened this issue 1 year ago • 1 comments

Describe the bug

Just wanted to log some issues I experienced wrt. setting up the .gitignore file while trying to setup edgedb code generation in a monorepo where the "edgeql-js" output is written to a non-standard location within a package.

  • assumes that the .gitignore files will be in the cwd where the generate script is run
    • would probably make sense to check parents of the outdir until you found the root of the repo or something
  • does not match /out/directory syntax in the gitignore file (only match this specific instance, not any instance in any parent directory)
  • blocks forever when stdin is not a tty (like on CI)
  • can only be disabled by creating the outdir before running the command

Needed to read a bunch of code in this repo to figure out how to work around these issues, so I think it probably makes sense to add a CLI flag to disable the gitignore validation logic. The option is already available in the code there just isn't any way to customize it from the CLI it seems.

Reproduction

With a basic monorepo, or even this one, modify the .gitignore file at the root to exclude the generated output and run this script within some package (not at the root of the repo).

Additionally, try using the /packages/{package}/src/edgeql-js syntax.

pnpx @edgedb/generate edgeql-js --target ts --out ./src/edgeql-js/

Then you can delete the generated output and run echo "$(pnpm run codegen)" the command will hang forever because the code is waiting for the user to confirm updating/creating the .gitignore file even through there is no way for the user to see or respond to the request.

Expected behavior All .gitignore files which could ignore the output should be checked, process.stding.isTTY should be checked before doing anything interactive, and there should be a documented way to bypass these checks in the case that the logic just isn't compatible with a given repo.

Versions (please complete the following information):

  • OS: macOS Sonoma 14.4.1
  • EdgeDB version (e.g. 2.0): 5.2+1e07d04
  • EdgeDB CLI version (e.g. 2.0): 5.0.0+c9dfeec
  • edgedb-js version (e.g. 0.20.10;): 1.5.4
  • Node/Deno version: v20.12.2

spalger avatar Apr 28 '24 01:04 spalger

Okay, I thought I fixed this but generate broke again this morning. I have a db package in my trubo-mono-repo and the codegen command is within that package, which I run as part of building the package, so it runs within the context of that package.

Yesterday that required that I have a .gitignore file within the db package that listed the exact string src/edgeql-js in it.

It seems that after upgrading from turborepo 1.10 to 1.13 the command now requires putting packages/db/src/edgeql-js to the .gitignore file at the root of the repo.

I feel like I have spent way too much time fiddling with this 😅

spalger avatar Apr 28 '24 18:04 spalger

@spalger

Sorry for the fiddly-ness here! I agree we should have some way to silence this interaction. I'll add it to the TODO list.

scotttrinh avatar May 06 '24 14:05 scotttrinh