Conversation
|
Awesome! For I've got a lot of open questions and ideas, but let me start with these two:
|
That'd certainly work. Alternatively, the tests could just output the typescript (or/and metadata) to stdout, and the CLI could maybe combine them, or write the files (and an |
This comment was marked as resolved.
This comment was marked as resolved.
We'd have to find a way to separate what we want from
This would need to be behind a new cargo feature otherwise the lib would not be usable without the CLI |
I like that!
Agreed! I'm not sure yet if we need that at all yet, so maybe we should continue to think about features & do that once there's a need for that. |
This comment was marked as off-topic.
This comment was marked as off-topic.
Oh, I'm terrible with names. But |
This comment was marked as resolved.
This comment was marked as resolved.
I considered both, but I think making |
|
Makes sense! I added an extra check with the |
…t value, this way, it'll obey the user's environment variable if it isn't passed into the CLI
Maybe we should revisit #94 to have a better idea of how to handle this |
|
Getting #49359 would be pretty cool - we could parse the JSON output, and do interesting stuff with it. $ cargo +nightly t --features ts-rs/export -- -Z unstable-options --format json 2>/dev/null
{ "type": "suite", "event": "started", "test_count": 10 }
{ "type": "test", "event": "started", "name": "export_bindings_complexenum" }
{ "type": "test", "event": "started", "name": "export_bindings_complexstruct" }
{ "type": "test", "event": "started", "name": "export_bindings_gender" }
{ "type": "test", "event": "started", "name": "export_bindings_inlinecomplexenum" }
{ "type": "test", "event": "started", "name": "export_bindings_point" }
{ "type": "test", "event": "started", "name": "export_bindings_role" }
{ "type": "test", "event": "started", "name": "export_bindings_series" }
{ "type": "test", "event": "started", "name": "export_bindings_simpleenum" }
{ "type": "test", "event": "started", "name": "export_bindings_user" }
{ "type": "test", "event": "started", "name": "export_bindings_vehicle" }
{ "type": "test", "name": "export_bindings_complexstruct", "event": "ok" }
{ "type": "test", "name": "export_bindings_gender", "event": "ok" }
{ "type": "test", "name": "export_bindings_point", "event": "ok" }
{ "type": "test", "name": "export_bindings_role", "event": "ok" }
{ "type": "test", "name": "export_bindings_simpleenum", "event": "ok" }
{ "type": "test", "name": "export_bindings_vehicle", "event": "ok" }
{ "type": "test", "name": "export_bindings_series", "event": "ok" }
{ "type": "test", "name": "export_bindings_user", "event": "ok" }
{ "type": "test", "name": "export_bindings_complexenum", "event": "ok" }
{ "type": "test", "name": "export_bindings_inlinecomplexenum", "event": "ok" }
{ "type": "suite", "event": "ok", "passed": 10, "failed": 0, "ignored": 0, "measured": 0, "filtered_out": 0, "exec_time": 0.031168 }
{ "type": "suite", "event": "started", "test_count": 0 }
{ "type": "suite", "event": "ok", "passed": 0, "failed": 0, "ignored": 0, "measured": 0, "filtered_out": 0, "exec_time": 0.0001069 } |
|
#49359 seems kinda close. #50297, on the other hand, seems far off. That's unfortunate, since we could probably do really cool stuff with it, without being too hacky. |
|
{ "type": "test", "name": "some_test", "event": "ok", "stdout": "hey\n" } |
Now that would make it easier lol |
|
With the "generate an
|
I think this might be the best way to go. Use the mutex file lock to append to a metadata file all the types' names anc paths, then parse the metadata file to generate the index.ts file |
I suspect that it might be simpler to write one metadata file per test, but i'd be happy to be convinced otherwise. |
I agree that this would probably be simpler, but we'd have to walk the output searching for these metadata files, so we could just walk the diretory reading the ts files instead |
| use clap::Parser; | ||
| use color_eyre::Result; | ||
|
|
||
| mod path; |
There was a problem hiding this comment.
Had to duplicate ts-rs/src/export/path.rs to make absolute paths
There was a problem hiding this comment.
Should we make a ts-rs-core crate to share these types of functions?
| /// Generates only a single index.ts file in your --output-directory that | ||
| /// contains all exported types | ||
| #[arg(long = "merge")] | ||
| pub merge_files: bool, |
Hey @NyxCode! This is a very rough first draft for the CLI tool we've been thinking about. It already handles all of our feature flags and the
TS_RS_EXPORT_DIRenvironment variableCloses #133
Todo
ts-rstests through this CLIexporttots-rsthat re-enables test generation.index.tsfile to reexport all the generated typesgenerate-metadataindex.ts, then deleting the originalinitsubcommand to help the user create said config file?cargo binstallFeature wishlist
numbervsbigint) (@NyxCode) (being worked on in proof-of-concept of type overrides using the CLI #334)#[ts(export_to = "...")]to the same file #316)index.tsfile, re-exporting types (@NyxCode) (See explanation above)Checklist