https://pantsbuild.org/ logo
#general
Title
# general
b

bitter-ability-32190

10/27/2021, 8:02 PM
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

happy-kitchen-89482

10/27/2021, 8:14 PM
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

bitter-ability-32190

10/27/2021, 8:15 PM
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

happy-kitchen-89482

10/27/2021, 8:16 PM
So you may need to duct tape codegen onto the
fmt
goal, since that naturally modifies files in the workspace
b

bitter-ability-32190

10/27/2021, 8:19 PM
Perhaps the answer then is that I should implementing a new formatter (and linter by inheritence)
h

happy-kitchen-89482

10/27/2021, 8:44 PM
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

curved-television-6568

10/27/2021, 9:13 PM
You could perhaps use the shell command target to generate the file, would still need to figure out how to lint it..
3 Views