Add CLI option to skip generating types
dethell opened this issue · 5 comments
Every time Counterfact is launched it generates all the various .types
files and paths based on the OpenApi doc. It would be nice if there were an option for the command line to skip generating the files (and basically just tell CF to assume all the types and components are already generated). I realize we need CF to generate the types and such, but lately we have seen that when a version bump happens for CF with a new feature it updates all the generated types. Our users are often caught off guard by this and don't know if they should commit these types or not when they aren't really intending to change anything with our mocks.
Our plan is to explicitly generate the types and components only when we know the OpenApi spec has been updated. We do realize this means a new feature to CF that might need a re-gen of the types and models would be skipped, but it would allow us to have more control over when those types get updated and committed.
Good feedback. In addition to that, I think it would be good to track which version created the types and warn the user that their types are about to change due to a version update.
You are running Counterfact version 1.1.0. Your types were generated using version 1.0.0.
To see what changed, visit: https://github.com/pmcelhaney/counterfact/blob/main/CHANGELOG.md
If you proceed, the type definitions under path-types and components may be
automatically updated to reflect new features. We recommend that you let that
update happen and commit the changes. If you would rather not upgrade
your types now, you can exit and run the old version of Counterfact.
npx counterfact@1.0.0
Would you like to proceed? (yes)/no:
I'm now thinking about creating flags to turn on individual features.
--generate generate all code for both types and routes
--watch --generate, plus watch for changes and update the code on the fly
--serve run the server
--repl start the REPL
--open open the GUI
The following flags are the same as above with narrower scopes. (--generate
is equivalent to --generate-types --generate-routes
--generate-types
--watch-types
--generate-routes
--watch-routes
If none of these flags is passed, it's the same as running the CLI with "everything on it" (--watch --serve --repl --open
).
@pmcelhaney should the path-types
be considered part of the types or part of the routes?
Similarly, what about the root _.context.ts
file? If we omit routes, should we be generating the base context file?
The path-types are part of types. The _.context.ts file is part of routes.