So I have some (non-python) files in my monorepo t...
# general
b
So I have some (non-python) files in my monorepo that are generated from other files. An easy example is we generate GitHub's CODEOWNERS from a yml file (for ease). Ideally, this functionality would sit in my build tool (E.g. it knows that script X generates CODEOWNERS from CODEOWNERS.yml). That way: ā€¢ If CODEOWNERS.yml gets touched it could re-generate (given the right command, like
fmt
) ā€¢ If CODEOWNERS isn't what we expect due to changes in CODEOWNERS.yml, we error on the right command (like
lint
?) ā€¢ If someone touches CODEOWNERS but not the yml, also error in a command (like
lint
) Any thoughts on this inside of Pants (I presume as a plugin)
h
Sounds like a codegen plugin. See https://www.pantsbuild.org/docs/plugins-codegen for details on how to write one of those.
šŸ™Œ 1
Although typically the results of codegen don't get checked in to the repo (since they are build byproducts) but it sounds like you want it in the repo?
b
Yup!
The CODEOWNERS example is a good one of a sane use case (my company has also some insane use-cases. Let's ignore those šŸ˜…)
Is back-into-the-repo a deal-breaker?
h
So you may need to duct tape codegen onto the
fmt
goal, since that naturally modifies files in the workspace
b
Perhaps the answer then is that I should implementing a new formatter (and linter by inheritence)
h
if it makes sense to have this be a formatter then yep! But the codegen example may still be useful in cobbling that together
šŸ™Œ 1
c
You could perhaps use the shell command target to generate the file, would still need to figure out how to lint it..