counterfact icon indicating copy to clipboard operation
counterfact copied to clipboard

Better explanation of why generated code should be committed to version control

Open pmcelhaney opened this issue 1 year ago • 2 comments

Is there any good reason to commit generated code for types to version control? In the documentation I wrote that those files should be committed, but now I can't remember what my reasoning was.

If the types code isn't committed, I think that would alleviate confusion when a new version of Counterfact generates types differently from the previous version.

Counterfact creates a .gitignore file for the .cache directory and that seems to work fine. I can't think of a reason we shouldn't add the types directories to that file.

pmcelhaney avatar Apr 16 '24 00:04 pmcelhaney

I would think just committing the components and paths would be enough. Types are ephemeral since they are regenerated anyway.

dethell avatar Apr 16 '24 11:04 dethell

Components are also types.

Okay, I remember the problem with not committing types. The moment you pull down the repo it's "broken" because there are references to type files that aren't there. In theory, you could run Counterfact and regenerate them in seconds. But the OpenAPI file might be outside of the repo, so there's no guarantee that running Counterfact again will produce exactly the same code.

I've changed the title of this issue to add more clarity in the documentation rather than change the code.

pmcelhaney avatar Apr 16 '24 20:04 pmcelhaney

It's explained in https://github.com/pmcelhaney/counterfact/blob/main/docs/faq-generated-code.md

pmcelhaney avatar Oct 02 '24 23:10 pmcelhaney