CLI
I'm copying the original cli PR into a new one for a couple of reasons:
- The thread on the old one is VERY long and is getting hard to follow
- Whoever is using the account that opened that PR (if anyone) probably doesn't wanna receive notifications about it
Closes #133 Closes #54 Closes #408
Todo
- [x] Find a way to only run
ts-rstests through this CLI- Done by gating the generation of tests
- Added a feature flag called
exporttots-rsthat re-enables test generation. - This feature is always enabled when using this CLI
- Added a feature flag called
- Done by gating the generation of tests
- [x] Explore a way of generating an
index.tsfile to reexport all the generated types- During export, generate a metadata file to list all types and where they are exported to
- In the CLI, use the metadata file to create the index.ts file
- Gate the generation of this file behind a feature flag named
generate-metadata
- During export, generate a metadata file to list all types and where they are exported to
- [x] A configuration file so the user doesn't have to pass the flags every time
- [x] Add
configflag to pass the path to the file? - [x] Add
initsubcommand to help create the config file
- [x] Add
- [ ] Discuss other features of the CLI
- [ ] When we consider it ready, it would be interesting to also make it available through
cargo binstall
Feature wishlist
- [x] Customize representations (e.g
numbervsbigint) (@NyxCode) (being worked on in #334) - [x] Load configuration from configfile (@NyxCode) (being worked on in #334)
- [x] (maybe) Combine multiple types in one file? (@NyxCode) (#316)
- [x] (maybe) generate
index.tsfile, re-exporting types (@NyxCode) (See explanation above)
Checklist
- [x] I have followed the steps listed in the Contributing guide.
- [ ] If necessary, I have added documentation related to the changes made.
- [ ] I have added or updated the tests related to the changes made.
The implementation of the CLI is a breaking change for anyone who uses --no-default-features to disable serde-compat as that will also disable the new export feature, preventing the test functions that export the types from being generated
Hey @NyxCode, I merged #334 into the CLI and added a command to generate a default config file. I also removed the --merge flag, as I believe that #316 already does that well enough, especially when combined with #399.
What do you think of the current state of the CLI? Are there other features you want to include?
Hey @NyxCode! It looks llike I no longer have write access to ts-rs. Did something happen with you or is this because the repo is in the Aleph Alpha org?
@gustavo-shigueo Very weird - certainly nothing I did. I'll figure it out asap, sorry about that.
No problem. I imagine someone at the org level did some kind of security audit and went "who tf is this random dude with access to one of our repos" lol
Is there some work that I could contribute to this to help this PR get merged? I'm needing a way to generate barrel files (those index.ts files that reexport everything).
PS: NyxCode. Nice name. :3
Hello @CriusNyx , I'm not quite sure if/when this might be merged, as there are a few possible concerns about it:
- @NyxCode has raised some concerns in #382
- This PR is a breaking change for anyone using
--no-default-featuresto disableserde-compat - We are not yet sure if there are more features we want to add
- We haven't documented or tested the CLI very thoroughly yet - we did have someone use it and report good results in #408 though
All that being said, you can install it with the following command:
cargo install --git https://github.com/Aleph-Alpha/ts-rs --branch feat/cli ts-rs-cli and then use a ts-rs export --index to achieve the behavior you need