edgedb / edgedb-cli

The EdgeDB CLI
https://www.edgedb.com/docs/cli/index
Apache License 2.0
166 stars 23 forks source link

Allow users to run arbitrary script(s) after `watch` applies schema updates #1099

Open raddevon opened 1 year ago

raddevon commented 1 year ago

Users would like to be able to rerun their generators or rerun tests whenever a schema updates. @elprans suggested we might allow users to point to a script directory to enable this: "Providing a path to a directory with shell scripts (a-la run-parts) is probably most flexible."

ssendev commented 11 months ago

having to create a directory doesn't sound "most flexible" just having a --exec <command> a la find seems more flexible since it doesn't require a dedicated directory/script.

for impatient people on linux with inotify-tools installed it's possible to use:

inotifywait -mqe close_write dbschema/default.esdl | while read f;do echo; edgedb migrate --dev-mode && npm run -s build:edgeql; done

or like this if it should also run immediately

(echo; inotifywait -mqe close_write dbschema/default.esdl) | while read f;do echo;  edgedb migrate --dev-mode && npm run -s build:edgeql; done
MrFoxPro commented 7 months ago

I think this is not required for edgedb-cli. That's what I'm doing

"edgedb:migrate:dev".exec = ''
  edgedb:dev migration apply --schema-dir=api/dbschema --dev-mode
'';

"edgedb:generate".exec = ''
  ${root}/api/node_modules/.bin/generate interfaces --file=${root}/lib/entities.d.ts --force-overwrite ${edb.args}
'';

<...>
watchexec -p -w api -e esdl,edgeql -- 'edgedb:migrate:dev && edgedb:generate