hofstadter-io / hof

Framework that joins data models, schemas, code generation, and a task engine. Language and technology agnostic.
https://docs.hofstadter.io
Apache License 2.0
523 stars 37 forks source link

Support for code gen hooks #102

Open verdverm opened 2 years ago

verdverm commented 2 years ago

The original idea came from wanting to run another tool after code gen, on the output. Generally, providing hooks into the code gen lifecycle seems interesting.

from slack:


the process I want is:


https://github.com/hofstadter-io/demos/tree/main/adhoc-to-module/05#using-hofflow-to-watch-code-gen-and-perform-post-actions

Code gen post actions seems like an almost guaranteed scenario

Though you might just put hof into your current source -> prod pipeline,, I might put configurable fields into generators. So at least the top-level generator (the one run by the users) will have them run. Not sure about subgenerators, defaults, or running something you didn't directly import...

It ought to be easy enough to import the flow when telling the user to write down these 20 lines to use your generator...

verdverm commented 2 years ago

It might be nice to call out code formatters the same way, such that the user might be able to run different formatters on different languages or sets of files in a generator.

support flows too?

#cmd: { ... like flow/task/exec schema }
gen: {
  // lang or name : command to run
  formatters: [name=string]: #cmd

  commands: [name=string]: #cmd
  // might be useful for installing the tools needed for the formatter
}
verdverm commented 2 years ago

how might we support running prettier in background mode during code gen, sending data over an API? or through os.Pipe? Run a container? (and provide a nice default with lots of languages supported)

What we really want is a Go package that does what pretty does... so we do everything in memory, and don't incur a full program startup / shutdown per file