From 4fc25b508ef5a71163d0c4ed0cda37248f440e22 Mon Sep 17 00:00:00 2001 From: Moritz Bischof Date: Fri, 21 Jun 2024 04:28:52 +0200 Subject: [PATCH 1/5] proof-of-concept of type overrides using the CLI --- Cargo.lock | 54 +++++++++++++++++++++++ cli/Cargo.toml | 4 +- cli/src/args.rs | 48 -------------------- cli/src/cargo.rs | 18 +++++--- cli/src/config.rs | 104 ++++++++++++++++++++++++++++++++++++++++++++ cli/src/main.rs | 38 ++++++++-------- cli/src/metadata.rs | 2 +- example/ts-rs.toml | 5 +++ ts-rs/src/lib.rs | 21 ++++++++- 9 files changed, 218 insertions(+), 76 deletions(-) delete mode 100644 cli/src/args.rs create mode 100644 cli/src/config.rs create mode 100644 example/ts-rs.toml diff --git a/Cargo.lock b/Cargo.lock index 5310ff96e..258a99271 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -259,6 +259,8 @@ version = "0.1.0" dependencies = [ "clap", "color-eyre", + "serde", + "toml", ] [[package]] @@ -1052,6 +1054,15 @@ dependencies = [ "serde", ] +[[package]] +name = "serde_spanned" +version = "0.6.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "79e674e01f999af37c49f70a6ede167a8a60b2503e56c5599532a65baa5969a0" +dependencies = [ + "serde", +] + [[package]] name = "sharded-slab" version = "0.1.7" @@ -1378,6 +1389,40 @@ version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" +[[package]] +name = "toml" +version = "0.8.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6f49eb2ab21d2f26bd6db7bf383edc527a7ebaee412d17af4d40fdccd442f335" +dependencies = [ + "serde", + "serde_spanned", + "toml_datetime", + "toml_edit", +] + +[[package]] +name = "toml_datetime" +version = "0.6.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4badfd56924ae69bcc9039335b2e017639ce3f9b001c393c1b2d1ef846ce2cbf" +dependencies = [ + "serde", +] + +[[package]] +name = "toml_edit" +version = "0.22.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f21c7aaf97f1bd9ca9d4f9e73b0a6c74bd5afef56f2bc931943a6e1c37e04e38" +dependencies = [ + "indexmap", + "serde", + "serde_spanned", + "toml_datetime", + "winnow", +] + [[package]] name = "tracing" version = "0.1.40" @@ -1717,6 +1762,15 @@ version = "0.52.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dff9641d1cd4be8d1a070daf9e3773c5f67e78b4d9d42263020c057706765c04" +[[package]] +name = "winnow" +version = "0.6.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "59b5e5f6c299a3c7890b876a2a587f3115162487e704907d9b6cd29473052ba1" +dependencies = [ + "memchr", +] + [[package]] name = "wyz" version = "0.5.1" diff --git a/cli/Cargo.toml b/cli/Cargo.toml index 1236df2a7..94fb29e85 100644 --- a/cli/Cargo.toml +++ b/cli/Cargo.toml @@ -6,5 +6,7 @@ edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -clap = { version = "4", features = ["derive"]} +clap = { version = "4", features = ["derive"] } color-eyre = "0.6" +serde = { version = "1", features = ["derive"] } +toml = "0.8" \ No newline at end of file diff --git a/cli/src/args.rs b/cli/src/args.rs deleted file mode 100644 index 86cde5f8f..000000000 --- a/cli/src/args.rs +++ /dev/null @@ -1,48 +0,0 @@ -use std::path::PathBuf; - -use clap::Parser; - -use crate::metadata::FILE_NAME; - -#[derive(Parser, Debug)] -#[allow(clippy::struct_excessive_bools)] -pub struct Args { - /// Defines where your TS bindings will be saved by setting TS_RS_EXPORT_DIR - #[arg(long, short)] - pub output_directory: PathBuf, - - /// Disables warnings caused by using serde attributes that ts-rs cannot process - #[arg(long)] - pub no_warnings: bool, - - /// Adds the ".js" extension to import paths - #[arg(long)] - pub esm_imports: bool, - - /// Formats the generated TypeScript files - #[arg(long)] - pub format: bool, - - /// Generates an index.ts file in your --output-directory that re-exports all - /// types generated by ts-rs - #[arg(long = "index")] - pub generate_index_ts: bool, - - /// Generates only a single index.ts file in your --output-directory that - /// contains all exported types - #[arg(long = "merge")] - pub merge_files: bool, - - /// Do not capture `cargo test`'s output, and pass --nocapture to the test binary - #[arg(long = "nocapture")] - pub no_capture: bool, -} - -// Args is in scope for the entirety of the main function, so this will only -// be executed when the program is finished running. This helps prevent us -// from forgetting to do cleanup if some code branch early returns from main -impl Drop for Args { - fn drop(&mut self) { - _ = std::fs::remove_file(self.output_directory.join(FILE_NAME)); - } -} diff --git a/cli/src/cargo.rs b/cli/src/cargo.rs index a9695f247..4a9a2938d 100644 --- a/cli/src/cargo.rs +++ b/cli/src/cargo.rs @@ -2,7 +2,8 @@ use std::process::{Command, Stdio}; use color_eyre::Result; -use crate::{args::Args, path}; +use crate::config::Config; +use crate::path; macro_rules! feature { ($cargo_invocation: expr, $args: expr, { $($field: ident => $feature: literal),* $(,)? }) => { @@ -16,7 +17,7 @@ macro_rules! feature { }; } -pub fn invoke(args: &Args) -> Result<()> { +pub fn invoke(cfg: &Config) -> Result<()> { let mut cargo_invocation = Command::new("cargo"); cargo_invocation @@ -26,20 +27,25 @@ pub fn invoke(args: &Args) -> Result<()> { .arg("ts-rs/export") .arg("--features") .arg("ts-rs/generate-metadata") - .stdout(if args.no_capture { + .stdout(if cfg.no_capture { Stdio::inherit() } else { Stdio::piped() }) - .env("TS_RS_EXPORT_DIR", path::absolute(&args.output_directory)?); + .env("TS_RS_EXPORT_DIR", path::absolute(&cfg.output_directory)?); - feature!(cargo_invocation, args, { + for (rust, ts) in &cfg.overrides { + let env = format!("TS_RS_INTERNAL_OVERRIDE_{rust}"); + cargo_invocation.env(env, ts); + } + + feature!(cargo_invocation, cfg, { no_warnings => "no-serde-warnings", esm_imports => "import-esm", format => "format", }); - if args.no_capture { + if cfg.no_capture { cargo_invocation.arg("--").arg("--nocapture"); } else { cargo_invocation.arg("--quiet"); diff --git a/cli/src/config.rs b/cli/src/config.rs new file mode 100644 index 000000000..2c3c6c68e --- /dev/null +++ b/cli/src/config.rs @@ -0,0 +1,104 @@ +use clap::Parser; +use color_eyre::Result; +use serde::Deserialize; +use std::collections::HashMap; +use std::path::{Path, PathBuf}; +use color_eyre::eyre::bail; + +#[derive(Parser, Debug)] +#[allow(clippy::struct_excessive_bools)] +pub struct Args { + /// Defines where your TS bindings will be saved by setting TS_RS_EXPORT_DIR + #[arg(long, short)] + pub output_directory: PathBuf, + + /// Disables warnings caused by using serde attributes that ts-rs cannot process + #[arg(long)] + pub no_warnings: bool, + + /// Adds the ".js" extension to import paths + #[arg(long)] + pub esm_imports: bool, + + /// Formats the generated TypeScript files + #[arg(long)] + pub format: bool, + + /// Generates an index.ts file in your --output-directory that re-exports all + /// types generated by ts-rs + #[arg(long = "index")] + pub generate_index_ts: bool, + + /// Generates only a single index.ts file in your --output-directory that + /// contains all exported types + #[arg(long = "merge")] + pub merge_files: bool, + + /// Do not capture `cargo test`'s output, and pass --nocapture to the test binary + #[arg(long = "nocapture")] + pub no_capture: bool, +} + +// keeping this separate from `Args` for now :shrug: +#[derive(Default, Deserialize)] +#[serde(deny_unknown_fields, default)] +pub struct Config { + // type overrides for types implemented inside ts-rs. + pub overrides: HashMap, + pub output_directory: PathBuf, + pub no_warnings: bool, + pub esm_imports: bool, + pub format: bool, + pub generate_index_ts: bool, + pub merge_files: bool, + pub no_capture: bool, +} + +impl Config { + pub fn load() -> Result { + let mut cfg = Self::load_from_file()?; + cfg.merge(Args::parse()); + cfg.verify()?; + Ok(cfg) + } + + fn load_from_file() -> Result { + // TODO: from where do we actually load the config? + let path = Path::new("./ts-rs.toml"); + if !path.is_file() { + return Ok(Self::default()); + } + let content = std::fs::read_to_string(path)?; + Ok(toml::from_str::(&content)?) + } + + fn verify(&self) -> Result<()> { + if self.merge_files && self.generate_index_ts { + bail!("--index is not compatible with --merge"); + } + Ok(()) + } + + fn merge( + &mut self, + Args { + output_directory, + no_warnings, + esm_imports, + format, + generate_index_ts, + merge_files, + no_capture, + }: Args, + ) { + self.output_directory = output_directory; + self.no_warnings = no_warnings; + self.esm_imports = esm_imports; + self.format = format; + self.generate_index_ts = generate_index_ts; + self.merge_files = merge_files; + self.no_capture = no_capture; + } +} + + diff --git a/cli/src/main.rs b/cli/src/main.rs index 005684c57..8957519bc 100644 --- a/cli/src/main.rs +++ b/cli/src/main.rs @@ -5,45 +5,45 @@ use std::{ io::{Read, Write}, }; -use clap::Parser; use color_eyre::{owo_colors::OwoColorize, Result}; -mod args; mod cargo; mod metadata; mod path; +mod config; -use args::Args; use metadata::{Metadata, FILE_NAME}; +use crate::config::Config; const BLANK_LINE: [u8; 2] = [b'\n', b'\n']; const NOTE: &[u8; 109] = b"// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.\n"; +struct Cleanup<'a>(&'a Config); +impl<'a> Drop for Cleanup<'a> { + fn drop(&mut self) { + _ = fs::remove_file(self.0.output_directory.join(FILE_NAME)); + } +} + fn main() -> Result<()> { color_eyre::install()?; - let args = Args::parse(); + let cfg = Config::load()?; + let _cleanup = Cleanup(&cfg); - let metadata_path = args.output_directory.join(FILE_NAME); + let metadata_path = cfg.output_directory.join(FILE_NAME); if metadata_path.exists() { fs::remove_file(&metadata_path)?; } - if args.merge_files && args.generate_index_ts { - eprintln!( - "{} --index is not compatible with --merge", - "Error:".red().bold() - ); - return Ok(()); - } - cargo::invoke(&args)?; + cargo::invoke(&cfg)?; let metadata_content = fs::read_to_string(&metadata_path)?; let metadata = Metadata::try_from(&*metadata_content)?; - let demand_unique_names = args.merge_files || args.generate_index_ts; + let demand_unique_names = cfg.merge_files || cfg.generate_index_ts; if !demand_unique_names || metadata.is_empty() { return Ok(()); @@ -60,7 +60,7 @@ fn main() -> Result<()> { return Ok(()); } - let index_path = args.output_directory.join("index.ts"); + let index_path = cfg.output_directory.join("index.ts"); if index_path.exists() { fs::remove_file(&index_path)?; @@ -73,7 +73,7 @@ fn main() -> Result<()> { index.write_all(NOTE)?; - if args.generate_index_ts { + if cfg.generate_index_ts { for path in metadata.export_paths() { index.write_fmt(format_args!("\nexport * from {path:?};"))?; } @@ -81,9 +81,9 @@ fn main() -> Result<()> { return Ok(()); } - if args.merge_files { + if cfg.merge_files { for path in metadata.export_paths() { - let path = path::absolute(args.output_directory.join(path))?; + let path = path::absolute(cfg.output_directory.join(path))?; let mut file = OpenOptions::new().read(true).open(&path)?; let mut buf = Vec::with_capacity(file.metadata()?.len().try_into()?); @@ -98,7 +98,7 @@ fn main() -> Result<()> { fs::remove_file(path)?; } - path::remove_empty_subdirectories(&args.output_directory)?; + path::remove_empty_subdirectories(&cfg.output_directory)?; return Ok(()); } diff --git a/cli/src/metadata.rs b/cli/src/metadata.rs index e04cc2bf7..7aee2f7a4 100644 --- a/cli/src/metadata.rs +++ b/cli/src/metadata.rs @@ -12,7 +12,7 @@ use color_eyre::{ pub const FILE_NAME: &str = "ts_rs.meta"; pub struct Metadata<'a> { - entries: std::collections::HashMap<&'a str, HashSet>>, + entries: HashMap<&'a str, HashSet>>, } impl<'a> TryFrom<&'a str> for Metadata<'a> { diff --git a/example/ts-rs.toml b/example/ts-rs.toml new file mode 100644 index 000000000..08506ebd2 --- /dev/null +++ b/example/ts-rs.toml @@ -0,0 +1,5 @@ +[overrides] +u64 = "number" +i64 = "number" +u128 = "number" +i128 = "number" \ No newline at end of file diff --git a/ts-rs/src/lib.rs b/ts-rs/src/lib.rs index a422c5942..d8678a2c5 100644 --- a/ts-rs/src/lib.rs +++ b/ts-rs/src/lib.rs @@ -127,6 +127,7 @@ use std::{ ops::{Range, RangeInclusive}, path::{Path, PathBuf}, }; +use std::sync::OnceLock; pub use ts_rs_macros::TS; @@ -609,12 +610,30 @@ impl Dependency { } } +static OVERRIDES: OnceLock> = OnceLock::new(); + +fn get_override(rust_type: &str) -> Option<&'static str> { + let overrides = OVERRIDES.get_or_init(|| { + const PREFIX: &str = "TS_RS_INTERNAL_OVERRIDE_"; + std::env::vars_os() + .flat_map(|(key, value)| Some((key.into_string().ok()?, value.into_string().ok()?))) + .filter(|(key, _)| key.starts_with(PREFIX)) + .map(|(key, value)| (&key.leak()[PREFIX.len()..], &*value.leak())) + .collect() + }); + overrides.get(rust_type).copied() +} + // generate impls for primitive types macro_rules! impl_primitives { ($($($ty:ty),* => $l:literal),*) => { $($( impl TS for $ty { type WithoutGenerics = Self; - fn name() -> String { $l.to_owned() } + fn name() -> String { + $crate::get_override(stringify!($ty)) + .unwrap_or($l) + .to_owned() + } fn inline() -> String { ::name() } fn inline_flattened() -> String { panic!("{} cannot be flattened", ::name()) } fn decl() -> String { panic!("{} cannot be declared", ::name()) } From ff49be6c179dc66684b9606febf89af0a6abfc55 Mon Sep 17 00:00:00 2001 From: gustavo-shigueo Date: Tue, 25 Jun 2024 10:04:21 -0300 Subject: [PATCH 2/5] Fix clippy warnings --- Cargo.lock | 513 ++++++++++++++++++++++------------------------ README.md | 2 +- cli/src/config.rs | 9 +- cli/src/main.rs | 6 +- ts-rs/Cargo.toml | 2 +- ts-rs/src/lib.rs | 4 +- 6 files changed, 255 insertions(+), 281 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 258a99271..29b4ae831 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -29,9 +29,9 @@ checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" [[package]] name = "ahash" -version = "0.8.7" +version = "0.8.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "77c3a9648d43b9cd48db467b3f87fdd6e146bcc88ab0180006cef2179fe11d01" +checksum = "e89da841a80418a9b391ebaea17f5c112ffaaa96f621d2c285b5174da76b9011" dependencies = [ "cfg-if", "getrandom", @@ -42,18 +42,18 @@ dependencies = [ [[package]] name = "aho-corasick" -version = "1.1.2" +version = "1.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b2969dcb958b36655471fc61f7e416fa76033bdd4bfed0678d8fee1e2d07a1f0" +checksum = "8e60d3430d3a69478ad0993f19238d2df97c507009a52b3c10addcd7f6bcb916" dependencies = [ "memchr", ] [[package]] name = "allocator-api2" -version = "0.2.16" +version = "0.2.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0942ffc6dcaadf03badf6e6a2d0228460359d5e34b57ccdc720b7382dfbd5ec5" +checksum = "5c6cb57a04249c6480766f7f7cef5467412af1490f8d1e243141daddada3264f" [[package]] name = "android-tzdata" @@ -72,47 +72,48 @@ dependencies = [ [[package]] name = "anstream" -version = "0.6.13" +version = "0.6.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d96bd03f33fe50a863e394ee9718a706f988b9079b20c3784fb726e7678b62fb" +checksum = "418c75fa768af9c03be99d17643f93f79bbba589895012a80e3452a19ddda15b" dependencies = [ "anstyle", "anstyle-parse", "anstyle-query", "anstyle-wincon", "colorchoice", + "is_terminal_polyfill", "utf8parse", ] [[package]] name = "anstyle" -version = "1.0.6" +version = "1.0.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8901269c6307e8d93993578286ac0edf7f195079ffff5ebdeea6a59ffb7e36bc" +checksum = "038dfcf04a5feb68e9c60b21c9625a54c2c0616e79b72b0fd87075a056ae1d1b" [[package]] name = "anstyle-parse" -version = "0.2.3" +version = "0.2.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c75ac65da39e5fe5ab759307499ddad880d724eed2f6ce5b5e8a26f4f387928c" +checksum = "c03a11a9034d92058ceb6ee011ce58af4a9bf61491aa7e1e59ecd24bd40d22d4" dependencies = [ "utf8parse", ] [[package]] name = "anstyle-query" -version = "1.0.2" +version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e28923312444cdd728e4738b3f9c9cac739500909bb3d3c94b43551b16517648" +checksum = "ad186efb764318d35165f1758e7dcef3b10628e26d41a44bc5550652e6804391" dependencies = [ "windows-sys", ] [[package]] name = "anstyle-wincon" -version = "3.0.2" +version = "3.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1cd54b81ec8d6180e24654d0b371ad22fc3dd083b6ff8ba325b72e00c87660a7" +checksum = "61a38449feb7068f52bb06c12759005cf459ee52bb4adc1d5a7c4322d716fb19" dependencies = [ "anstyle", "windows-sys", @@ -120,36 +121,27 @@ dependencies = [ [[package]] name = "anyhow" -version = "1.0.79" +version = "1.0.86" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "080e9890a082662b09c1ad45f567faeeb47f22b5fb23895fbe1e651e718e25ca" +checksum = "b3d1d046238990b9cf5bcde22a3fb3584ee5cf65fb2765f454ed428c7a0063da" [[package]] name = "ast_node" -version = "0.9.6" +version = "0.9.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c3e3e06ec6ac7d893a0db7127d91063ad7d9da8988f8a1a256f03729e6eec026" +checksum = "2ab31376d309dd3bfc9cfb3c11c93ce0e0741bbe0354b20e7f8c60b044730b79" dependencies = [ "proc-macro2", "quote", "swc_macros_common", - "syn 2.0.48", -] - -[[package]] -name = "atomic-polyfill" -version = "1.0.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8cf2bce30dfe09ef0bfaef228b9d414faaf7e563035494d7fe092dba54b300f4" -dependencies = [ - "critical-section", + "syn 2.0.68", ] [[package]] name = "autocfg" -version = "1.1.0" +version = "1.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" +checksum = "0c4b4d0bd25bd0b74681c0ad21497610ce1b7c91b1022cd21c80c6fbdd9476b0" [[package]] name = "backtrace" @@ -183,10 +175,12 @@ dependencies = [ [[package]] name = "bigdecimal" -version = "0.3.1" +version = "0.4.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a6773ddc0eafc0e509fb60e48dff7f450f8e674a0686ae8605e8d9901bd5eefa" +checksum = "51d712318a27c7150326677b321a5fa91b55f6d9034ffd67f20319e147d40cee" dependencies = [ + "autocfg", + "libm", "num-bigint", "num-integer", "num-traits", @@ -195,9 +189,9 @@ dependencies = [ [[package]] name = "bitflags" -version = "2.5.0" +version = "2.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cf4b9d6a944f767f8e5e0db018570623c85f3d925ac718db4e06d0187adb21c1" +checksum = "b048fb63fd8b5923fc5aa7b340d8e156aec7ec02f0c78fa8a6ddc2613f6f71de" [[package]] name = "bitvec" @@ -213,9 +207,9 @@ dependencies = [ [[package]] name = "bson" -version = "2.9.0" +version = "2.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ce21468c1c9c154a85696bb25c20582511438edb6ad67f846ba1378ffdd80222" +checksum = "d8a88e82b9106923b5c4d6edfca9e7db958d4e98a478ec115022e81b9b38e2c8" dependencies = [ "ahash", "base64", @@ -234,9 +228,9 @@ dependencies = [ [[package]] name = "bumpalo" -version = "3.14.0" +version = "3.16.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f30e7476521f6f8af1a1c4c0b8cc94f0bee37d91763d0ca2665f299b6cd8aec" +checksum = "79296716171880943b8470b5f8d03aa55eb2e645a4874bdbb28adb49162e012c" dependencies = [ "allocator-api2", ] @@ -249,9 +243,9 @@ checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b" [[package]] name = "bytes" -version = "1.5.0" +version = "1.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a2bd12c1caf447e69cd4528f47f94d203fd2582878ecb9e9465484c4148a8223" +checksum = "514de17de45fdb8dc022b1a7975556c53c86f9f0aa5f534b98977b171857c2c9" [[package]] name = "cargo-ts" @@ -265,9 +259,9 @@ dependencies = [ [[package]] name = "cc" -version = "1.0.94" +version = "1.0.100" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "17f6e324229dc011159fcc089755d1e2e216a90d43a7dea6853ca740b84f35e7" +checksum = "c891175c3fb232128f48de6590095e59198bbeb8620c310be349bfc3afd12c7b" [[package]] name = "cfg-if" @@ -277,9 +271,9 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" [[package]] name = "chrono" -version = "0.4.33" +version = "0.4.38" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9f13690e35a5e4ace198e7beea2895d29f3a9cc55015fcebe6336bd2010af9eb" +checksum = "a21f936df1771bf62b77f047b726c4625ff2e8aa607c01ec06e5a05bd8463401" dependencies = [ "android-tzdata", "iana-time-zone", @@ -292,9 +286,9 @@ dependencies = [ [[package]] name = "clap" -version = "4.5.4" +version = "4.5.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "90bc066a67923782aa8515dbaea16946c5bcc5addbd668bb80af688e53e548a0" +checksum = "5db83dced34638ad474f39f250d7fea9598bdd239eaced1bdf45d597da0f433f" dependencies = [ "clap_builder", "clap_derive", @@ -302,9 +296,9 @@ dependencies = [ [[package]] name = "clap_builder" -version = "4.5.2" +version = "4.5.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ae129e2e766ae0ec03484e609954119f123cc1fe650337e155d03b022f24f7b4" +checksum = "f7e204572485eb3fbf28f871612191521df159bc3e15a9f5064c66dba3a8c05f" dependencies = [ "anstream", "anstyle", @@ -314,21 +308,21 @@ dependencies = [ [[package]] name = "clap_derive" -version = "4.5.4" +version = "4.5.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "528131438037fd55894f62d6e9f068b8f45ac57ffa77517819645d10aed04f64" +checksum = "c780290ccf4fb26629baa7a1081e68ced113f1d3ec302fa5948f1c381ebf06c6" dependencies = [ "heck", "proc-macro2", "quote", - "syn 2.0.48", + "syn 2.0.68", ] [[package]] name = "clap_lex" -version = "0.7.0" +version = "0.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "98cc8fbded0c607b7ba9dd60cd98df59af97e84d24e49c8557331cfc26d301ce" +checksum = "4b82cf0babdbd58558212896d1a4272303a57bdb245c2bf1147185fb45640e70" [[package]] name = "color-eyre" @@ -359,9 +353,9 @@ dependencies = [ [[package]] name = "colorchoice" -version = "1.0.0" +version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "acbf1af155f9b9ef647e42cdc158db4b64a1b61f743629225fde6f3e0be2a7c7" +checksum = "0b6a852b24ab71dffc585bcb46eaf7959d175cb865a7152e35b348d1b2960422" [[package]] name = "core-foundation-sys" @@ -369,12 +363,6 @@ version = "0.8.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "06ea2b9bc92be3c2baa9334a323ebca2d6f074ff852cd1d7b11064035cd3868f" -[[package]] -name = "critical-section" -version = "1.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7059fff8937831a9ae6f0fe4d658ffabf58f2ca96aa9dec1c889f936f705f216" - [[package]] name = "data-url" version = "0.3.1" @@ -383,9 +371,9 @@ checksum = "5c297a1c74b71ae29df00c3e22dd9534821d60eb9af5a0192823fa2acea70c2a" [[package]] name = "deno_ast" -version = "0.35.1" +version = "0.38.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c45813a2b6c658e5bc5a2f8336460f2b1c1c61a7adaf5e861df16ae3f3c76ca1" +checksum = "584547d27786a734536fde7088f8429d355569c39410427be44695c300618408" dependencies = [ "deno_media_type", "deno_terminal", @@ -399,15 +387,16 @@ dependencies = [ "swc_ecma_parser", "swc_eq_ignore_macros", "text_lines", + "thiserror", "unicode-width", "url", ] [[package]] name = "deno_media_type" -version = "0.1.2" +version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a798670c20308e5770cc0775de821424ff9e85665b602928509c8c70430b3ee0" +checksum = "a8978229b82552bf8457a0125aa20863f023619cfc21ebb007b1e571d68fd85b" dependencies = [ "data-url", "serde", @@ -435,9 +424,9 @@ dependencies = [ [[package]] name = "dprint-core" -version = "0.66.1" +version = "0.66.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "317f9cd1da390ab12e1858b3a71c7d6c8e8ad633454cb0b73ce5589964d9c177" +checksum = "f3ab0dd2bedc109d25f0d21afb09b7d329f6c6fa83b095daf31d2d967e091548" dependencies = [ "anyhow", "bumpalo", @@ -460,9 +449,9 @@ dependencies = [ [[package]] name = "dprint-plugin-typescript" -version = "0.90.0" +version = "0.90.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f180a70c7fae19cf6296a70d0850748e72d5162400491cde0aa424b22fd81212" +checksum = "d7c3c339020ebbbbbe5fc049350935ee2ea2ba5a3fc01f753588639a30404cda" dependencies = [ "anyhow", "deno_ast", @@ -475,9 +464,9 @@ dependencies = [ [[package]] name = "dprint-swc-ext" -version = "0.15.1" +version = "0.16.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5bad772f9e49af3a613fcddf1671d1e2e877e0a6d94f2b7162bfea4ac8140bee" +checksum = "019d17f2c2457c5a70a7cf4505b1a562ca8ab168c0ac0c005744efbd29fcb8fe" dependencies = [ "allocator-api2", "bumpalo", @@ -492,9 +481,9 @@ dependencies = [ [[package]] name = "either" -version = "1.10.0" +version = "1.12.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "11157ac094ffbdde99aa67b23417ebdd801842852b500e395a45a9c0aac03e4a" +checksum = "3dca9240753cf90908d7e4aac30f630662b02aebaa1b58a3cadabdb23385b58b" [[package]] name = "equivalent" @@ -533,13 +522,13 @@ dependencies = [ [[package]] name = "from_variant" -version = "0.1.7" +version = "0.1.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3a0b11eeb173ce52f84ebd943d42e58813a2ebb78a6a3ff0a243b71c5199cd7b" +checksum = "fdc9cc75639b041067353b9bce2450d6847e547276c6fbe4487d7407980e07db" dependencies = [ "proc-macro2", "swc_macros_common", - "syn 2.0.48", + "syn 2.0.68", ] [[package]] @@ -550,9 +539,9 @@ checksum = "e6d5a32815ae3f33302d95fdcb2ce17862f8c65363dcfd29360480ba1001fc9c" [[package]] name = "getrandom" -version = "0.2.12" +version = "0.2.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "190092ea657667030ac6a35e305e62fc4dd69fd98ac98631e5d3a2b1575a12b5" +checksum = "c4567c8db10ae91089c99af84c68c38da3ec2f087c3f82960bcdbf3656b6f4d7" dependencies = [ "cfg-if", "libc", @@ -567,18 +556,18 @@ checksum = "4271d37baee1b8c7e4b708028c57d816cf9d2434acb33a549475f78c181f6253" [[package]] name = "hash32" -version = "0.2.1" +version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b0c35f58762feb77d74ebe43bdbc3210f09be9fe6742234d573bacc26ed92b67" +checksum = "47d60b12902ba28e2730cd37e95b8c9223af2808df9e902d4df49588d1470606" dependencies = [ "byteorder", ] [[package]] name = "hashbrown" -version = "0.14.3" +version = "0.14.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "290f1a1d9242c78d09ce40a5e87e7554ee637af1351968159f4952f028f75604" +checksum = "e5274423e17b7c9fc20b6e7e208532f9b19825d82dfd615708b70edd83df41f1" dependencies = [ "ahash", "allocator-api2", @@ -586,14 +575,11 @@ dependencies = [ [[package]] name = "heapless" -version = "0.7.17" +version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cdc6457c0eb62c71aac4bc17216026d8410337c4126773b9c5daba343f17964f" +checksum = "0bfb9eb618601c89945a70e254898da93b13be0388091d42117462b265bb3fad" dependencies = [ - "atomic-polyfill", "hash32", - "rustc_version", - "spin", "stable_deref_trait", ] @@ -611,9 +597,9 @@ checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" [[package]] name = "hstr" -version = "0.2.8" +version = "0.2.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b0f5356d62012374578cd3a5c013d6586de3efbca3b53379fc1edfbb95c9db14" +checksum = "96274be293b8877e61974a607105d09c84caebe9620b47774aa8a6b942042dd4" dependencies = [ "hashbrown", "new_debug_unreachable", @@ -625,9 +611,9 @@ dependencies = [ [[package]] name = "iana-time-zone" -version = "0.1.59" +version = "0.1.60" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b6a67363e2aa4443928ce15e57ebae94fd8949958fd1223c4cfc0cd473ad7539" +checksum = "e7ffbb5a1b541ea2561f8c41c087286cc091e21e556a4f09a8f6cbf17b69b141" dependencies = [ "android_system_properties", "core-foundation-sys", @@ -664,9 +650,9 @@ checksum = "ce23b50ad8242c51a442f3ff322d56b02f08852c77e4c0b4d3fd684abc89c683" [[package]] name = "indexmap" -version = "2.2.2" +version = "2.2.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "824b2ae422412366ba479e8111fd301f7b5faece8149317bb81925979a53f520" +checksum = "168fb715dda47215e360912c096649d23d58bf392ac62f73919e831745e40f26" dependencies = [ "equivalent", "hashbrown", @@ -682,100 +668,106 @@ dependencies = [ "Inflector", "proc-macro2", "quote", - "syn 2.0.48", + "syn 2.0.68", ] +[[package]] +name = "is_terminal_polyfill" +version = "1.70.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f8478577c03552c21db0e2724ffb8986a5ce7af88107e6be5d2ee6e158c12800" + [[package]] name = "itoa" -version = "1.0.10" +version = "1.0.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b1a46d1a171d865aa5f83f92695765caa047a9b4cbae2cbf37dbd613a793fd4c" +checksum = "49f1f14873335454500d59611f1cf4a4b0f786f9ac11f4312a78e4cf2566695b" [[package]] name = "js-sys" -version = "0.3.67" +version = "0.3.69" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9a1d36f1235bc969acba30b7f5990b864423a6068a10f7c90ae8f0112e3a59d1" +checksum = "29c15563dc2726973df627357ce0c9ddddbea194836909d655df6a75d2cf296d" dependencies = [ "wasm-bindgen", ] [[package]] name = "lazy_static" -version = "1.4.0" +version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" +checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe" [[package]] name = "libc" -version = "0.2.153" +version = "0.2.155" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9c198f91728a82281a64e1f4f9eeb25d82cb32a5de251c6bd1b5154d63a8e7bd" +checksum = "97b3888a4aecf77e811145cadf6eef5901f4782c53886191b2f693f24761847c" [[package]] -name = "lock_api" -version = "0.4.11" +name = "libm" +version = "0.2.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3c168f8615b12bc01f9c17e2eb0cc07dcae1940121185446edc3744920e8ef45" -dependencies = [ - "autocfg", - "scopeguard", -] +checksum = "4ec2a862134d2a7d32d7983ddcdd1c4923530833c9f2ea1a44fc5fa473989058" [[package]] name = "log" -version = "0.4.20" +version = "0.4.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b5e6163cb8c49088c2c36f57875e58ccd8c87c7427f7fbd50ea6710b2f3f2e8f" +checksum = "90ed8c1e510134f979dbc4f070f87d4313098b704861a105fe34231c70a3901c" [[package]] name = "memchr" -version = "2.7.1" +version = "2.7.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "523dc4f511e55ab87b694dc30d0f820d60906ef06413f93d4d7a1385599cc149" +checksum = "78ca9ab1a0babb1e7d5695e3530886289c18cf2f87ec19a575a0abdce112e3a3" [[package]] name = "miniz_oxide" -version = "0.7.2" +version = "0.7.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9d811f3e15f28568be3407c8e7fdb6514c1cda3cb30683f15b6a1a1dc4ea14a7" +checksum = "b8a240ddb74feaf34a79a7add65a741f3167852fba007066dcac1ca548d89c08" dependencies = [ "adler", ] [[package]] name = "new_debug_unreachable" -version = "1.0.4" +version = "1.0.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e4a24736216ec316047a1fc4252e27dabb04218aa4a3f37c6e7ddbf1f9782b54" +checksum = "650eef8c711430f1a879fdd01d4745a7deea475becfb90269c06775983bbf086" [[package]] name = "num-bigint" -version = "0.4.4" +version = "0.4.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "608e7659b5c3d7cba262d894801b9ec9d00de989e8a82bd4bef91d08da45cdc0" +checksum = "c165a9ab64cf766f73521c0dd2cfdff64f488b8f0b3e621face3462d3db536d7" dependencies = [ - "autocfg", "num-integer", "num-traits", "serde", ] +[[package]] +name = "num-conv" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "51d515d32fb182ee37cda2ccdcb92950d6a3c2893aa280e540671c2cd0f3b1d9" + [[package]] name = "num-integer" -version = "0.1.45" +version = "0.1.46" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "225d3389fb3509a24c93f5c29eb6bde2586b98d9f016636dff58d7c6f7569cd9" +checksum = "7969661fd2958a5cb096e56c8e1ad0444ac2bbcd0061bd28660485a44879858f" dependencies = [ - "autocfg", "num-traits", ] [[package]] name = "num-traits" -version = "0.2.17" +version = "0.2.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "39e3200413f237f41ab11ad6d161bc7239c84dcb631773ccd7de3dfe4b5c267c" +checksum = "071dfc062690e90b734c0b2273ce72ad0ffa95f0c74596bc250dcfd960262841" dependencies = [ "autocfg", ] @@ -797,9 +789,9 @@ checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" [[package]] name = "ordered-float" -version = "3.9.2" +version = "4.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f1e1c390732d15f1d48471625cd92d154e66db2c56645e29a9cd26f4699f72dc" +checksum = "a76df7075c7d4d01fdcb46c912dd17fba5b60c78ea480b475f2b6ab6f666584e" dependencies = [ "num-traits", ] @@ -846,7 +838,7 @@ dependencies = [ "phf_shared", "proc-macro2", "quote", - "syn 2.0.48", + "syn 2.0.68", ] [[package]] @@ -860,9 +852,9 @@ dependencies = [ [[package]] name = "pin-project-lite" -version = "0.2.13" +version = "0.2.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8afb450f006bf6385ca15ef45d71d2288452bc3683ce2e2cacc0d18e4be60b58" +checksum = "bda66fc9667c18cb2758a2ac84d1167245054bcf85d5d1aaa6923f45801bdd02" [[package]] name = "powerfmt" @@ -878,9 +870,9 @@ checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de" [[package]] name = "proc-macro2" -version = "1.0.78" +version = "1.0.86" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e2422ad645d89c99f8f3e6b88a9fdeca7fabeac836b1002371c4367c8f984aae" +checksum = "5e719e8df665df0d1c8fbfd238015744736151d4445ec0836b8e628aae103b77" dependencies = [ "unicode-ident", ] @@ -896,9 +888,9 @@ dependencies = [ [[package]] name = "quote" -version = "1.0.35" +version = "1.0.36" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "291ec9ab5efd934aaf503a6466c5d5251535d108ee747472c3977cc5acc868ef" +checksum = "0fa76aaf39101c457836aec0ce2316dbdc3ab723cdda1c6bd4e6ad4208acaca7" dependencies = [ "proc-macro2", ] @@ -941,9 +933,9 @@ dependencies = [ [[package]] name = "regex" -version = "1.10.3" +version = "1.10.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b62dbe01f0b06f9d8dc7d49e05a0785f153b00b2c227856282f671e0318c9b15" +checksum = "b91213439dad192326a0d7c6ee3955910425f441d7038e0d6933b0aec5c4517f" dependencies = [ "aho-corasick", "memchr", @@ -953,9 +945,9 @@ dependencies = [ [[package]] name = "regex-automata" -version = "0.4.5" +version = "0.4.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5bb987efffd3c6d0d8f5f89510bb458559eab11e4f869acb20bf845e016259cd" +checksum = "38caf58cc5ef2fed281f89292ef23f6365465ed9a41b7a7754eb4e26496c92df" dependencies = [ "aho-corasick", "memchr", @@ -964,15 +956,15 @@ dependencies = [ [[package]] name = "regex-syntax" -version = "0.8.2" +version = "0.8.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c08c74e62047bb2de4ff487b251e4a92e24f48745648451635cec7d591162d9f" +checksum = "7a66a03ae7c801facd77a29370b4faec201768915ac14a721ba36f20bc9c209b" [[package]] name = "rustc-demangle" -version = "0.1.23" +version = "0.1.24" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d626bb9dae77e28219937af045c257c28bfd3f69333c512553507f5f9798cb76" +checksum = "719b953e2095829ee67db738b3bfa9fa368c94900df327b3f07fe6e794d2fe1f" [[package]] name = "rustc-hash" @@ -980,20 +972,11 @@ version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2" -[[package]] -name = "rustc_version" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bfa0f585226d2e68097d4f95d113b15b83a82e819ab25717ec0590d9584ef366" -dependencies = [ - "semver", -] - [[package]] name = "ryu" -version = "1.0.16" +version = "1.0.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f98d2aa92eebf49b69786be48e4477826b256916e84a57ff2a4f21923b48eb4c" +checksum = "f3cb5ba0dc43242ce17de99c180e96db90b235b8a9fdc9543c96d2209116bd9f" [[package]] name = "scoped-tls" @@ -1001,52 +984,46 @@ version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e1cf6437eb19a8f4a6cc0f7dca544973b0b78843adbfeb3683d1a94a0024a294" -[[package]] -name = "scopeguard" -version = "1.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" - [[package]] name = "semver" -version = "1.0.21" +version = "1.0.23" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b97ed7a9823b74f99c7742f5336af7be5ecd3eeafcb1507d1fa93347b1d589b0" +checksum = "61697e0a1c7e512e84a621326239844a24d8207b4669b41bc18b32ea5cbf988b" [[package]] name = "serde" -version = "1.0.197" +version = "1.0.203" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3fb1c873e1b9b056a4dc4c0c198b24c3ffa059243875552b2bd0933b1aee4ce2" +checksum = "7253ab4de971e72fb7be983802300c30b5a7f0c2e56fab8abfc6a214307c0094" dependencies = [ "serde_derive", ] [[package]] name = "serde_bytes" -version = "0.11.14" +version = "0.11.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8b8497c313fd43ab992087548117643f6fcd935cbf36f176ffda0aacf9591734" +checksum = "387cc504cb06bb40a96c8e04e951fe01854cf6bc921053c954e4a606d9675c6a" dependencies = [ "serde", ] [[package]] name = "serde_derive" -version = "1.0.197" +version = "1.0.203" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7eb0b34b42edc17f6b7cac84a52a1c5f0e1bb2227e997ca9011ea3dd34e8610b" +checksum = "500cbc0ebeb6f46627f50f3f5811ccf6bf00643be300b4c3eabc0ef55dc5b5ba" dependencies = [ "proc-macro2", "quote", - "syn 2.0.48", + "syn 2.0.68", ] [[package]] name = "serde_json" -version = "1.0.113" +version = "1.0.118" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "69801b70b1c3dac963ecb03a364ba0ceda9cf60c71cfe475e99864759c8b8a79" +checksum = "d947f6b3163d8857ea16c4fa0dd4840d52f3041039a85decd46867eb1abef2e4" dependencies = [ "indexmap", "itoa", @@ -1080,9 +1057,9 @@ checksum = "38b58827f4464d87d377d175e90bf58eb00fd8716ff0a62f80356b5e61555d0d" [[package]] name = "smallvec" -version = "1.13.1" +version = "1.13.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e6ecd384b10a64542d77071bd64bd7b231f4ed5940fba55e98c3de13824cf3d7" +checksum = "3c5e1a9a646d36c3599cd173a41282daf47c44583ad367b8e6837255952e5c67" [[package]] name = "smartstring" @@ -1095,15 +1072,6 @@ dependencies = [ "version_check", ] -[[package]] -name = "spin" -version = "0.9.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6980e8d7511241f8acf4aebddbb1ff938df5eebe98691418c4468d0b72a96a67" -dependencies = [ - "lock_api", -] - [[package]] name = "stable_deref_trait" version = "1.2.0" @@ -1131,14 +1099,14 @@ checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f" [[package]] name = "string_enum" -version = "0.4.2" +version = "0.4.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1b650ea2087d32854a0f20b837fc56ec987a1cb4f758c9757e1171ee9812da63" +checksum = "05e383308aebc257e7d7920224fa055c632478d92744eca77f99be8fa1545b90" dependencies = [ "proc-macro2", "quote", "swc_macros_common", - "syn 2.0.48", + "syn 2.0.68", ] [[package]] @@ -1149,9 +1117,9 @@ checksum = "7da8b5736845d9f2fcb837ea5d9e2628564b3b043a70948a3f0b778838c5fb4f" [[package]] name = "swc_atoms" -version = "0.6.6" +version = "0.6.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "04d9d1941a7d24fc503efa29c53f88dd61e6a15cc371947a75cca3b48d564b5b" +checksum = "bb6567e4e67485b3e7662b486f1565bdae54bd5b9d6b16b2ba1a9babb1e42125" dependencies = [ "hstr", "once_cell", @@ -1161,9 +1129,9 @@ dependencies = [ [[package]] name = "swc_common" -version = "0.33.22" +version = "0.33.26" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a8f91d53367db183e55ecaa090c9a2b6e62ddbd1258aa2ac6c6925772eec9e2b" +checksum = "a2f9706038906e66f3919028f9f7a37f3ed552f1b85578e93f4468742e2da438" dependencies = [ "ast_node", "better_scoped_tls", @@ -1186,9 +1154,9 @@ dependencies = [ [[package]] name = "swc_ecma_ast" -version = "0.112.7" +version = "0.113.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6bcd97ee367b48444f90416ea56e71d761600f816bcae9df4f99293d1fa36bd5" +checksum = "dc1690cc0c9ab60b44ac0225ba1e231ac532f7ba1d754df761c6ee607561afae" dependencies = [ "bitflags", "is-macro", @@ -1204,9 +1172,9 @@ dependencies = [ [[package]] name = "swc_ecma_parser" -version = "0.143.12" +version = "0.144.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b6fc7ab256f83a9491b37a510dd1cba9d81bb306faf3cff1dacdbc897fa4869f" +checksum = "0499e69683ae5d67a20ff0279b94bc90f29df7922a46331b54d5dd367bf89570" dependencies = [ "either", "new_debug_unreachable", @@ -1232,25 +1200,25 @@ checksum = "695a1d8b461033d32429b5befbf0ad4d7a2c4d6ba9cd5ba4e0645c615839e8e4" dependencies = [ "proc-macro2", "quote", - "syn 2.0.48", + "syn 2.0.68", ] [[package]] name = "swc_macros_common" -version = "0.3.9" +version = "0.3.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "50176cfc1cbc8bb22f41c6fe9d1ec53fbe057001219b5954961b8ad0f336fce9" +checksum = "91745f3561057493d2da768437c427c0e979dff7396507ae02f16c981c4a8466" dependencies = [ "proc-macro2", "quote", - "syn 2.0.48", + "syn 2.0.68", ] [[package]] name = "swc_visit" -version = "0.5.10" +version = "0.5.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3f5b3e8d1269a7cb95358fed3412645d9c15aa0eb1f4ca003a25a38ef2f30f1b" +checksum = "043d11fe683dcb934583ead49405c0896a5af5face522e4682c16971ef7871b9" dependencies = [ "either", "swc_visit_macros", @@ -1258,15 +1226,15 @@ dependencies = [ [[package]] name = "swc_visit_macros" -version = "0.5.11" +version = "0.5.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "33fc817055fe127b4285dc85058596768bfde7537ae37da82c67815557f03e33" +checksum = "4ae9ef18ff8daffa999f729db056d2821cd2f790f3a11e46422d19f46bb193e7" dependencies = [ "Inflector", "proc-macro2", "quote", "swc_macros_common", - "syn 2.0.48", + "syn 2.0.68", ] [[package]] @@ -1282,9 +1250,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.48" +version = "2.0.68" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0f3531638e407dfc0814761abb7c00a5b54992b849452a0646b7f65c9f770f3f" +checksum = "901fa70d88b9d6c98022e23b4136f9f3e54e4662c3bc1bd1d84a42a9a0f0c1e9" dependencies = [ "proc-macro2", "quote", @@ -1317,22 +1285,22 @@ dependencies = [ [[package]] name = "thiserror" -version = "1.0.56" +version = "1.0.61" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d54378c645627613241d077a3a79db965db602882668f9136ac42af9ecb730ad" +checksum = "c546c80d6be4bc6a00c0f01730c08df82eaa7a7a61f11d656526506112cc1709" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "1.0.56" +version = "1.0.61" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fa0faa943b50f3db30a20aa7e265dbc66076993efed8463e8de414e5d06d3471" +checksum = "46c3384250002a6d5af4d114f2845d37b57521033f30d5c3f46c4d70e1197533" dependencies = [ "proc-macro2", "quote", - "syn 2.0.48", + "syn 2.0.68", ] [[package]] @@ -1347,12 +1315,13 @@ dependencies = [ [[package]] name = "time" -version = "0.3.31" +version = "0.3.36" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f657ba42c3f86e7680e53c8cd3af8abbe56b5491790b46e22e19c0d57463583e" +checksum = "5dfd88e563464686c916c7e46e623e520ddc6d79fa6641390f2e3fa86e83e885" dependencies = [ "deranged", "itoa", + "num-conv", "powerfmt", "serde", "time-core", @@ -1367,18 +1336,19 @@ checksum = "ef927ca75afb808a4d64dd374f00a2adf8d0fcff8e7b184af886c3c87ec4a3f3" [[package]] name = "time-macros" -version = "0.2.16" +version = "0.2.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "26197e33420244aeb70c3e8c78376ca46571bc4e701e4791c2cd9f57dcb3a43f" +checksum = "3f252a68540fde3a3877aeea552b832b40ab9a69e318efd078774a01ddee1ccf" dependencies = [ + "num-conv", "time-core", ] [[package]] name = "tinyvec" -version = "1.6.0" +version = "1.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "87cc5ceb3875bb20c2890005a4e226a4651264a5c75edb2421b52861a0a0cb50" +checksum = "c55115c6fbe2d2bef26eb09ad74bde02d8255476fc0c7b515ef09fbb35742d82" dependencies = [ "tinyvec_macros", ] @@ -1442,7 +1412,7 @@ checksum = "34704c8d6ebcbc939824180af020566b01a7c01f80641264eba0999f6c2b6be7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.48", + "syn 2.0.68", ] [[package]] @@ -1478,9 +1448,9 @@ dependencies = [ [[package]] name = "triomphe" -version = "0.1.11" +version = "0.1.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "859eb650cfee7434994602c3a68b25d77ad9e68c8a6cd491616ef86661382eb3" +checksum = "e6631e42e10b40c0690bf92f404ebcfe6e1fdb480391d15f17cc8e96eeed5369" dependencies = [ "serde", "stable_deref_trait", @@ -1513,7 +1483,7 @@ version = "8.1.0" dependencies = [ "proc-macro2", "quote", - "syn 2.0.48", + "syn 2.0.68", "termcolor", ] @@ -1531,9 +1501,9 @@ checksum = "08f95100a766bf4f8f28f90d77e0a5461bbdb219042e7679bebe79004fed8d75" [[package]] name = "unicode-id-start" -version = "1.1.2" +version = "1.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b8f73150333cb58412db36f2aca8f2875b013049705cc77b94ded70a1ab1f5da" +checksum = "02aebfa694eccbbbffdd92922c7de136b9fe764396d2f10e21bce1681477cfc1" [[package]] name = "unicode-ident" @@ -1543,24 +1513,24 @@ checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" [[package]] name = "unicode-normalization" -version = "0.1.22" +version = "0.1.23" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5c5713f0fc4b5db668a2ac63cdb7bb4469d8c9fed047b1d0292cc7b0ce2ba921" +checksum = "a56d1686db2308d901306f92a263857ef59ea39678a5458e7cb17f01415101f5" dependencies = [ "tinyvec", ] [[package]] name = "unicode-width" -version = "0.1.11" +version = "0.1.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e51733f11c9c4f72aa0c160008246859e340b00807569a0da0e7a1079b27ba85" +checksum = "0336d538f7abc86d282a4189614dfaa90810dfc2c6f6427eaf88e16311dd225d" [[package]] name = "url" -version = "2.5.0" +version = "2.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "31e6302e3bb753d46e83516cae55ae196fc0c309407cf11ab35cc51a4c2a4633" +checksum = "22784dbdf76fdde8af1aeda5622b546b422b6fc585325248a2bf9f5e41e94d6c" dependencies = [ "form_urlencoded", "idna", @@ -1570,15 +1540,15 @@ dependencies = [ [[package]] name = "utf8parse" -version = "0.2.1" +version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "711b9620af191e0cdc7468a8d14e709c3dcdb115b36f838e601583af800a370a" +checksum = "06abde3611657adf66d383f00b093d7faecc7fa57071cce2578660c9f1010821" [[package]] name = "uuid" -version = "1.7.0" +version = "1.9.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f00cc9702ca12d3c81455259621e676d0f7251cec66a21e98fe2e9a37db93b2a" +checksum = "5de17fd2f7da591098415cff336e12965a28061ddace43b59cb3c430179c9439" dependencies = [ "getrandom", "serde", @@ -1604,9 +1574,9 @@ checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" [[package]] name = "wasm-bindgen" -version = "0.2.90" +version = "0.2.92" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b1223296a201415c7fad14792dbefaace9bd52b62d33453ade1c5b5f07555406" +checksum = "4be2531df63900aeb2bca0daaaddec08491ee64ceecbee5076636a3b026795a8" dependencies = [ "cfg-if", "wasm-bindgen-macro", @@ -1614,24 +1584,24 @@ dependencies = [ [[package]] name = "wasm-bindgen-backend" -version = "0.2.90" +version = "0.2.92" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fcdc935b63408d58a32f8cc9738a0bffd8f05cc7c002086c6ef20b7312ad9dcd" +checksum = "614d787b966d3989fa7bb98a654e369c762374fd3213d212cfc0251257e747da" dependencies = [ "bumpalo", "log", "once_cell", "proc-macro2", "quote", - "syn 2.0.48", + "syn 2.0.68", "wasm-bindgen-shared", ] [[package]] name = "wasm-bindgen-macro" -version = "0.2.90" +version = "0.2.92" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3e4c238561b2d428924c49815533a8b9121c664599558a5d9ec51f8a1740a999" +checksum = "a1f8823de937b71b9460c0c34e25f3da88250760bec0ebac694b49997550d726" dependencies = [ "quote", "wasm-bindgen-macro-support", @@ -1639,22 +1609,22 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro-support" -version = "0.2.90" +version = "0.2.92" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bae1abb6806dc1ad9e560ed242107c0f6c84335f1749dd4e8ddb012ebd5e25a7" +checksum = "e94f17b526d0a461a191c78ea52bbce64071ed5c04c9ffe424dcb38f74171bb7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.48", + "syn 2.0.68", "wasm-bindgen-backend", "wasm-bindgen-shared", ] [[package]] name = "wasm-bindgen-shared" -version = "0.2.90" +version = "0.2.92" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4d91413b1c31d7539ba5ef2451af3f0b833a005eb27a631cec32bc0635a8602b" +checksum = "af190c94f2773fdb3729c55b007a722abb5384da03bc0986df4c289bf5567e96" [[package]] name = "winapi" @@ -1674,11 +1644,11 @@ checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" [[package]] name = "winapi-util" -version = "0.1.6" +version = "0.1.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f29e6f9198ba0d26b4c9f07dbe6f9ed633e1f3d5b8b414090084349e46a52596" +checksum = "4d4cc384e1e73b93bafa6fb4f1df8c41695c8a91cf9c4c64358067d15a7b6c6b" dependencies = [ - "winapi", + "windows-sys", ] [[package]] @@ -1707,13 +1677,14 @@ dependencies = [ [[package]] name = "windows-targets" -version = "0.52.0" +version = "0.52.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8a18201040b24831fbb9e4eb208f8892e1f50a37feb53cc7ff887feb8f50e7cd" +checksum = "6f0713a46559409d202e70e28227288446bf7841d3211583a4b53e3f6d96e7eb" dependencies = [ "windows_aarch64_gnullvm", "windows_aarch64_msvc", "windows_i686_gnu", + "windows_i686_gnullvm", "windows_i686_msvc", "windows_x86_64_gnu", "windows_x86_64_gnullvm", @@ -1722,45 +1693,51 @@ dependencies = [ [[package]] name = "windows_aarch64_gnullvm" -version = "0.52.0" +version = "0.52.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cb7764e35d4db8a7921e09562a0304bf2f93e0a51bfccee0bd0bb0b666b015ea" +checksum = "7088eed71e8b8dda258ecc8bac5fb1153c5cffaf2578fc8ff5d61e23578d3263" [[package]] name = "windows_aarch64_msvc" -version = "0.52.0" +version = "0.52.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bbaa0368d4f1d2aaefc55b6fcfee13f41544ddf36801e793edbbfd7d7df075ef" +checksum = "9985fd1504e250c615ca5f281c3f7a6da76213ebd5ccc9561496568a2752afb6" [[package]] name = "windows_i686_gnu" -version = "0.52.0" +version = "0.52.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "88ba073cf16d5372720ec942a8ccbf61626074c6d4dd2e745299726ce8b89670" + +[[package]] +name = "windows_i686_gnullvm" +version = "0.52.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a28637cb1fa3560a16915793afb20081aba2c92ee8af57b4d5f28e4b3e7df313" +checksum = "87f4261229030a858f36b459e748ae97545d6f1ec60e5e0d6a3d32e0dc232ee9" [[package]] name = "windows_i686_msvc" -version = "0.52.0" +version = "0.52.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ffe5e8e31046ce6230cc7215707b816e339ff4d4d67c65dffa206fd0f7aa7b9a" +checksum = "db3c2bf3d13d5b658be73463284eaf12830ac9a26a90c717b7f771dfe97487bf" [[package]] name = "windows_x86_64_gnu" -version = "0.52.0" +version = "0.52.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3d6fa32db2bc4a2f5abeacf2b69f7992cd09dca97498da74a151a3132c26befd" +checksum = "4e4246f76bdeff09eb48875a0fd3e2af6aada79d409d33011886d3e1581517d9" [[package]] name = "windows_x86_64_gnullvm" -version = "0.52.0" +version = "0.52.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1a657e1e9d3f514745a572a6846d3c7aa7dbe1658c056ed9c3344c4109a6949e" +checksum = "852298e482cd67c356ddd9570386e2862b5673c85bd5f88df9ab6802b334c596" [[package]] name = "windows_x86_64_msvc" -version = "0.52.0" +version = "0.52.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dff9641d1cd4be8d1a070daf9e3773c5f67e78b4d9d42263020c057706765c04" +checksum = "bec47e5bfd1bff0eeaf6d8b485cc1074891a197ab4225d504cb7a1ab88b02bf0" [[package]] name = "winnow" @@ -1782,20 +1759,20 @@ dependencies = [ [[package]] name = "zerocopy" -version = "0.7.32" +version = "0.7.34" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "74d4d3961e53fa4c9a25a8637fc2bfaf2595b3d3ae34875568a5cf64787716be" +checksum = "ae87e3fcd617500e5d106f0380cf7b77f3c6092aae37191433159dda23cfb087" dependencies = [ "zerocopy-derive", ] [[package]] name = "zerocopy-derive" -version = "0.7.32" +version = "0.7.34" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9ce1b18ccd8e73a9321186f97e46f9f04b778851177567b1975109d26a08d2a6" +checksum = "15e934569e47891f7d9411f1a451d947a60e000ab3bd24fbb970f000387d1b3b" dependencies = [ "proc-macro2", "quote", - "syn 2.0.48", + "syn 2.0.68", ] diff --git a/README.md b/README.md index 6d019aee3..bdb51a6ab 100644 --- a/README.md +++ b/README.md @@ -116,6 +116,6 @@ Feel free to open an issue, discuss using GitHub discussions or open a PR. [See CONTRIBUTING.md](https://github.com/Aleph-Alpha/ts-rs/blob/main/CONTRIBUTING.md) ### MSRV -The Minimum Supported Rust Version for this crate is 1.63.0 +The Minimum Supported Rust Version for this crate is 1.72.0 License: MIT diff --git a/cli/src/config.rs b/cli/src/config.rs index 2c3c6c68e..05e7a29f6 100644 --- a/cli/src/config.rs +++ b/cli/src/config.rs @@ -1,14 +1,14 @@ use clap::Parser; +use color_eyre::eyre::bail; use color_eyre::Result; use serde::Deserialize; use std::collections::HashMap; use std::path::{Path, PathBuf}; -use color_eyre::eyre::bail; #[derive(Parser, Debug)] #[allow(clippy::struct_excessive_bools)] pub struct Args { - /// Defines where your TS bindings will be saved by setting TS_RS_EXPORT_DIR + /// Defines where your TS bindings will be saved by setting `TS_RS_EXPORT_DIR` #[arg(long, short)] pub output_directory: PathBuf, @@ -42,6 +42,7 @@ pub struct Args { // keeping this separate from `Args` for now :shrug: #[derive(Default, Deserialize)] #[serde(deny_unknown_fields, default)] +#[allow(clippy::struct_excessive_bools)] pub struct Config { // type overrides for types implemented inside ts-rs. pub overrides: HashMap, @@ -69,7 +70,7 @@ impl Config { return Ok(Self::default()); } let content = std::fs::read_to_string(path)?; - Ok(toml::from_str::(&content)?) + Ok(toml::from_str::(&content)?) } fn verify(&self) -> Result<()> { @@ -100,5 +101,3 @@ impl Config { self.no_capture = no_capture; } } - - diff --git a/cli/src/main.rs b/cli/src/main.rs index 8957519bc..1b05cc9f4 100644 --- a/cli/src/main.rs +++ b/cli/src/main.rs @@ -8,12 +8,12 @@ use std::{ use color_eyre::{owo_colors::OwoColorize, Result}; mod cargo; +mod config; mod metadata; mod path; -mod config; -use metadata::{Metadata, FILE_NAME}; use crate::config::Config; +use metadata::{Metadata, FILE_NAME}; const BLANK_LINE: [u8; 2] = [b'\n', b'\n']; const NOTE: &[u8; 109] = b"// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.\n"; @@ -36,8 +36,6 @@ fn main() -> Result<()> { fs::remove_file(&metadata_path)?; } - - cargo::invoke(&cfg)?; let metadata_content = fs::read_to_string(&metadata_path)?; diff --git a/ts-rs/Cargo.toml b/ts-rs/Cargo.toml index 47cb1c25a..351567d04 100644 --- a/ts-rs/Cargo.toml +++ b/ts-rs/Cargo.toml @@ -15,7 +15,7 @@ categories = [ "web-programming", ] readme = "../README.md" -rust-version = "1.63.0" +rust-version = "1.72.0" [features] chrono-impl = ["chrono"] diff --git a/ts-rs/src/lib.rs b/ts-rs/src/lib.rs index d8678a2c5..d0fea267a 100644 --- a/ts-rs/src/lib.rs +++ b/ts-rs/src/lib.rs @@ -114,8 +114,9 @@ //! [See CONTRIBUTING.md](https://github.com/Aleph-Alpha/ts-rs/blob/main/CONTRIBUTING.md) //! //! ## MSRV -//! The Minimum Supported Rust Version for this crate is 1.63.0 +//! The Minimum Supported Rust Version for this crate is 1.72.0 +use std::sync::OnceLock; use std::{ any::TypeId, collections::{BTreeMap, BTreeSet, HashMap, HashSet}, @@ -127,7 +128,6 @@ use std::{ ops::{Range, RangeInclusive}, path::{Path, PathBuf}, }; -use std::sync::OnceLock; pub use ts_rs_macros::TS; From 2faf4bedcfc312f3757f3cbca9d094ea151510f1 Mon Sep 17 00:00:00 2001 From: gustavo-shigueo Date: Tue, 25 Jun 2024 20:42:13 -0300 Subject: [PATCH 3/5] cargo fmt --- ts-rs/src/lib.rs | 2 +- ts-rs/tests/integration/issue_308.rs | 2 +- ts-rs/tests/integration/issue_317.rs | 2 +- ts-rs/tests/integration/main.rs | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/ts-rs/src/lib.rs b/ts-rs/src/lib.rs index d0fea267a..54774a925 100644 --- a/ts-rs/src/lib.rs +++ b/ts-rs/src/lib.rs @@ -116,7 +116,6 @@ //! ## MSRV //! The Minimum Supported Rust Version for this crate is 1.72.0 -use std::sync::OnceLock; use std::{ any::TypeId, collections::{BTreeMap, BTreeSet, HashMap, HashSet}, @@ -127,6 +126,7 @@ use std::{ }, ops::{Range, RangeInclusive}, path::{Path, PathBuf}, + sync::OnceLock, }; pub use ts_rs_macros::TS; diff --git a/ts-rs/tests/integration/issue_308.rs b/ts-rs/tests/integration/issue_308.rs index be402b20f..41fc5e790 100644 --- a/ts-rs/tests/integration/issue_308.rs +++ b/ts-rs/tests/integration/issue_308.rs @@ -1,6 +1,6 @@ use std::path::{Path, PathBuf}; -use ts_rs::{TypeVisitor, Dependency, ExportError, TS}; +use ts_rs::{Dependency, ExportError, TypeVisitor, TS}; #[rustfmt::skip] trait Malicious { diff --git a/ts-rs/tests/integration/issue_317.rs b/ts-rs/tests/integration/issue_317.rs index bc286baab..fed7f8869 100644 --- a/ts-rs/tests/integration/issue_317.rs +++ b/ts-rs/tests/integration/issue_317.rs @@ -8,7 +8,7 @@ struct VariantId(u32); #[ts(export_to = "issue_317/")] struct VariantOverview { id: u32, - name: String + name: String, } #[derive(TS)] diff --git a/ts-rs/tests/integration/main.rs b/ts-rs/tests/integration/main.rs index 6eeef9f8b..cb5ca38fe 100644 --- a/ts-rs/tests/integration/main.rs +++ b/ts-rs/tests/integration/main.rs @@ -23,6 +23,7 @@ mod infer_as; mod issue_168; mod issue_232; mod issue_308; +mod issue_317; mod issue_70; mod issue_80; mod leading_colon; @@ -59,4 +60,3 @@ mod union_with_data; mod union_with_internal_tag; mod unit; mod r#unsized; -mod issue_317; From 633a11e1b793015937b16273444406db6f6b5935 Mon Sep 17 00:00:00 2001 From: gustavo-shigueo Date: Tue, 25 Jun 2024 20:54:32 -0300 Subject: [PATCH 4/5] Allow user to provide custom path to config file --- cli/src/cargo.rs | 5 ++- cli/src/config.rs | 83 +++++++++++++++++++++++++++++++++++------------ cli/src/main.rs | 13 ++++---- 3 files changed, 71 insertions(+), 30 deletions(-) diff --git a/cli/src/cargo.rs b/cli/src/cargo.rs index 4a9a2938d..30a569126 100644 --- a/cli/src/cargo.rs +++ b/cli/src/cargo.rs @@ -2,8 +2,7 @@ use std::process::{Command, Stdio}; use color_eyre::Result; -use crate::config::Config; -use crate::path; +use crate::{config::Config, path}; macro_rules! feature { ($cargo_invocation: expr, $args: expr, { $($field: ident => $feature: literal),* $(,)? }) => { @@ -32,7 +31,7 @@ pub fn invoke(cfg: &Config) -> Result<()> { } else { Stdio::piped() }) - .env("TS_RS_EXPORT_DIR", path::absolute(&cfg.output_directory)?); + .env("TS_RS_EXPORT_DIR", path::absolute(&cfg.output_directory())?); for (rust, ts) in &cfg.overrides { let env = format!("TS_RS_INTERNAL_OVERRIDE_{rust}"); diff --git a/cli/src/config.rs b/cli/src/config.rs index 05e7a29f6..f7809545f 100644 --- a/cli/src/config.rs +++ b/cli/src/config.rs @@ -1,16 +1,22 @@ +use std::{ + collections::HashMap, + path::{Path, PathBuf}, +}; + use clap::Parser; -use color_eyre::eyre::bail; -use color_eyre::Result; +use color_eyre::{eyre::bail, owo_colors::OwoColorize, Result}; use serde::Deserialize; -use std::collections::HashMap; -use std::path::{Path, PathBuf}; #[derive(Parser, Debug)] #[allow(clippy::struct_excessive_bools)] pub struct Args { + /// Path to the `ts-rs` config file + #[arg(long)] + pub config: Option, + /// Defines where your TS bindings will be saved by setting `TS_RS_EXPORT_DIR` #[arg(long, short)] - pub output_directory: PathBuf, + pub output_directory: Option, /// Disables warnings caused by using serde attributes that ts-rs cannot process #[arg(long)] @@ -41,48 +47,79 @@ pub struct Args { // keeping this separate from `Args` for now :shrug: #[derive(Default, Deserialize)] -#[serde(deny_unknown_fields, default)] +#[serde(deny_unknown_fields, default, rename_all = "kebab-case")] #[allow(clippy::struct_excessive_bools)] pub struct Config { // type overrides for types implemented inside ts-rs. pub overrides: HashMap, - pub output_directory: PathBuf, + pub output_directory: Option, pub no_warnings: bool, pub esm_imports: bool, pub format: bool, + + #[serde(rename = "index")] pub generate_index_ts: bool, + + #[serde(rename = "merge")] pub merge_files: bool, + + #[serde(rename = "nocapture")] pub no_capture: bool, } impl Config { pub fn load() -> Result { - let mut cfg = Self::load_from_file()?; - cfg.merge(Args::parse()); + let args = Args::parse(); + + let cfg = Self::load_from_file(args.config.as_deref())?.merge(args); cfg.verify()?; Ok(cfg) } - fn load_from_file() -> Result { + pub fn output_directory(&self) -> &Path { + self.output_directory + .as_deref() + .expect("Output directory must not be `None`") + } + + fn load_from_file(path: Option<&Path>) -> Result { + if let Some(path) = path { + if !path.is_file() { + bail!("The provided path doesn't exist"); + } + + let content = std::fs::read_to_string(path)?; + return Ok(toml::from_str(&content)?); + } + // TODO: from where do we actually load the config? let path = Path::new("./ts-rs.toml"); if !path.is_file() { return Ok(Self::default()); } let content = std::fs::read_to_string(path)?; - Ok(toml::from_str::(&content)?) + Ok(toml::from_str(&content)?) } fn verify(&self) -> Result<()> { if self.merge_files && self.generate_index_ts { - bail!("--index is not compatible with --merge"); + bail!( + "{}: --index is not compatible with --merge", + "Error".bold().red() + ); } + + if self.output_directory.is_none() { + bail!("{}: You must provide the output diretory, either through the config file or the --output-directory flag", "Error".bold().red()) + } + Ok(()) } fn merge( - &mut self, + mut self, Args { + config: _, output_directory, no_warnings, esm_imports, @@ -91,13 +128,17 @@ impl Config { merge_files, no_capture, }: Args, - ) { - self.output_directory = output_directory; - self.no_warnings = no_warnings; - self.esm_imports = esm_imports; - self.format = format; - self.generate_index_ts = generate_index_ts; - self.merge_files = merge_files; - self.no_capture = no_capture; + ) -> Self { + // QUESTION: This gives the CLI flag priority over the config file's value, + // is this the correct order? + self.output_directory = output_directory.or(self.output_directory); + + self.no_warnings |= no_warnings; + self.esm_imports |= esm_imports; + self.format |= format; + self.generate_index_ts |= generate_index_ts; + self.merge_files |= merge_files; + self.no_capture |= no_capture; + self } } diff --git a/cli/src/main.rs b/cli/src/main.rs index 1b05cc9f4..f3e0c1fe8 100644 --- a/cli/src/main.rs +++ b/cli/src/main.rs @@ -12,16 +12,17 @@ mod config; mod metadata; mod path; -use crate::config::Config; use metadata::{Metadata, FILE_NAME}; +use crate::config::Config; + const BLANK_LINE: [u8; 2] = [b'\n', b'\n']; const NOTE: &[u8; 109] = b"// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.\n"; struct Cleanup<'a>(&'a Config); impl<'a> Drop for Cleanup<'a> { fn drop(&mut self) { - _ = fs::remove_file(self.0.output_directory.join(FILE_NAME)); + _ = fs::remove_file(self.0.output_directory().join(FILE_NAME)); } } @@ -31,7 +32,7 @@ fn main() -> Result<()> { let cfg = Config::load()?; let _cleanup = Cleanup(&cfg); - let metadata_path = cfg.output_directory.join(FILE_NAME); + let metadata_path = cfg.output_directory().join(FILE_NAME); if metadata_path.exists() { fs::remove_file(&metadata_path)?; } @@ -58,7 +59,7 @@ fn main() -> Result<()> { return Ok(()); } - let index_path = cfg.output_directory.join("index.ts"); + let index_path = cfg.output_directory().join("index.ts"); if index_path.exists() { fs::remove_file(&index_path)?; @@ -81,7 +82,7 @@ fn main() -> Result<()> { if cfg.merge_files { for path in metadata.export_paths() { - let path = path::absolute(cfg.output_directory.join(path))?; + let path = path::absolute(cfg.output_directory().join(path))?; let mut file = OpenOptions::new().read(true).open(&path)?; let mut buf = Vec::with_capacity(file.metadata()?.len().try_into()?); @@ -96,7 +97,7 @@ fn main() -> Result<()> { fs::remove_file(path)?; } - path::remove_empty_subdirectories(&cfg.output_directory)?; + path::remove_empty_subdirectories(&cfg.output_directory())?; return Ok(()); } From 2b88340244bccec2957dd1a35f07a677c8c5e7fd Mon Sep 17 00:00:00 2001 From: gustavo-shigueo Date: Wed, 26 Jun 2024 14:44:48 -0300 Subject: [PATCH 5/5] Move impl Drop back into args --- cli/src/cargo.rs | 6 +- cli/src/config.rs | 297 ++++++++++++++++++++++++---------------------- cli/src/main.rs | 26 ++-- 3 files changed, 168 insertions(+), 161 deletions(-) diff --git a/cli/src/cargo.rs b/cli/src/cargo.rs index 30a569126..27307821d 100644 --- a/cli/src/cargo.rs +++ b/cli/src/cargo.rs @@ -2,7 +2,7 @@ use std::process::{Command, Stdio}; use color_eyre::Result; -use crate::{config::Config, path}; +use crate::{config::Args, path}; macro_rules! feature { ($cargo_invocation: expr, $args: expr, { $($field: ident => $feature: literal),* $(,)? }) => { @@ -16,7 +16,7 @@ macro_rules! feature { }; } -pub fn invoke(cfg: &Config) -> Result<()> { +pub fn invoke(cfg: &Args) -> Result<()> { let mut cargo_invocation = Command::new("cargo"); cargo_invocation @@ -31,7 +31,7 @@ pub fn invoke(cfg: &Config) -> Result<()> { } else { Stdio::piped() }) - .env("TS_RS_EXPORT_DIR", path::absolute(&cfg.output_directory())?); + .env("TS_RS_EXPORT_DIR", path::absolute(cfg.output_directory())?); for (rust, ts) in &cfg.overrides { let env = format!("TS_RS_INTERNAL_OVERRIDE_{rust}"); diff --git a/cli/src/config.rs b/cli/src/config.rs index f7809545f..40e32514a 100644 --- a/cli/src/config.rs +++ b/cli/src/config.rs @@ -1,144 +1,153 @@ -use std::{ - collections::HashMap, - path::{Path, PathBuf}, -}; - -use clap::Parser; -use color_eyre::{eyre::bail, owo_colors::OwoColorize, Result}; -use serde::Deserialize; - -#[derive(Parser, Debug)] -#[allow(clippy::struct_excessive_bools)] -pub struct Args { - /// Path to the `ts-rs` config file - #[arg(long)] - pub config: Option, - - /// Defines where your TS bindings will be saved by setting `TS_RS_EXPORT_DIR` - #[arg(long, short)] - pub output_directory: Option, - - /// Disables warnings caused by using serde attributes that ts-rs cannot process - #[arg(long)] - pub no_warnings: bool, - - /// Adds the ".js" extension to import paths - #[arg(long)] - pub esm_imports: bool, - - /// Formats the generated TypeScript files - #[arg(long)] - pub format: bool, - - /// Generates an index.ts file in your --output-directory that re-exports all - /// types generated by ts-rs - #[arg(long = "index")] - pub generate_index_ts: bool, - - /// Generates only a single index.ts file in your --output-directory that - /// contains all exported types - #[arg(long = "merge")] - pub merge_files: bool, - - /// Do not capture `cargo test`'s output, and pass --nocapture to the test binary - #[arg(long = "nocapture")] - pub no_capture: bool, -} - -// keeping this separate from `Args` for now :shrug: -#[derive(Default, Deserialize)] -#[serde(deny_unknown_fields, default, rename_all = "kebab-case")] -#[allow(clippy::struct_excessive_bools)] -pub struct Config { - // type overrides for types implemented inside ts-rs. - pub overrides: HashMap, - pub output_directory: Option, - pub no_warnings: bool, - pub esm_imports: bool, - pub format: bool, - - #[serde(rename = "index")] - pub generate_index_ts: bool, - - #[serde(rename = "merge")] - pub merge_files: bool, - - #[serde(rename = "nocapture")] - pub no_capture: bool, -} - -impl Config { - pub fn load() -> Result { - let args = Args::parse(); - - let cfg = Self::load_from_file(args.config.as_deref())?.merge(args); - cfg.verify()?; - Ok(cfg) - } - - pub fn output_directory(&self) -> &Path { - self.output_directory - .as_deref() - .expect("Output directory must not be `None`") - } - - fn load_from_file(path: Option<&Path>) -> Result { - if let Some(path) = path { - if !path.is_file() { - bail!("The provided path doesn't exist"); - } - - let content = std::fs::read_to_string(path)?; - return Ok(toml::from_str(&content)?); - } - - // TODO: from where do we actually load the config? - let path = Path::new("./ts-rs.toml"); - if !path.is_file() { - return Ok(Self::default()); - } - let content = std::fs::read_to_string(path)?; - Ok(toml::from_str(&content)?) - } - - fn verify(&self) -> Result<()> { - if self.merge_files && self.generate_index_ts { - bail!( - "{}: --index is not compatible with --merge", - "Error".bold().red() - ); - } - - if self.output_directory.is_none() { - bail!("{}: You must provide the output diretory, either through the config file or the --output-directory flag", "Error".bold().red()) - } - - Ok(()) - } - - fn merge( - mut self, - Args { - config: _, - output_directory, - no_warnings, - esm_imports, - format, - generate_index_ts, - merge_files, - no_capture, - }: Args, - ) -> Self { - // QUESTION: This gives the CLI flag priority over the config file's value, - // is this the correct order? - self.output_directory = output_directory.or(self.output_directory); - - self.no_warnings |= no_warnings; - self.esm_imports |= esm_imports; - self.format |= format; - self.generate_index_ts |= generate_index_ts; - self.merge_files |= merge_files; - self.no_capture |= no_capture; - self - } -} +use std::{ + collections::HashMap, + path::{Path, PathBuf}, +}; + +use clap::Parser; +use color_eyre::{eyre::bail, owo_colors::OwoColorize, Result}; +use serde::Deserialize; + +#[derive(Parser, Debug)] +#[allow(clippy::struct_excessive_bools)] +pub struct Args { + #[clap(skip)] + pub overrides: HashMap, + + /// Path to the `ts-rs` config file + #[arg(long)] + pub config: Option, + + /// Defines where your TS bindings will be saved by setting `TS_RS_EXPORT_DIR` + #[arg(long, short)] + pub output_directory: Option, + + /// Disables warnings caused by using serde attributes that ts-rs cannot process + #[arg(long)] + pub no_warnings: bool, + + /// Adds the ".js" extension to import paths + #[arg(long)] + pub esm_imports: bool, + + /// Formats the generated TypeScript files + #[arg(long)] + pub format: bool, + + /// Generates an index.ts file in your --output-directory that re-exports all + /// types generated by ts-rs + #[arg(long = "index")] + pub generate_index_ts: bool, + + /// Generates only a single index.ts file in your --output-directory that + /// contains all exported types + #[arg(long = "merge")] + pub merge_files: bool, + + /// Do not capture `cargo test`'s output, and pass --nocapture to the test binary + #[arg(long = "nocapture")] + pub no_capture: bool, +} + +// keeping this separate from `Args` for now :shrug: +#[derive(Default, Deserialize)] +#[serde(deny_unknown_fields, default, rename_all = "kebab-case")] +#[allow(clippy::struct_excessive_bools)] +pub struct Config { + /// Type overrides for types implemented inside ts-rs. + pub overrides: HashMap, + pub output_directory: Option, + pub no_warnings: bool, + pub esm_imports: bool, + pub format: bool, + + #[serde(rename = "index")] + pub generate_index_ts: bool, + + #[serde(rename = "merge")] + pub merge_files: bool, + + #[serde(rename = "nocapture")] + pub no_capture: bool, +} + +impl Args { + pub fn load() -> Result { + let mut args = Self::parse(); + + let cfg = Config::load_from_file(args.config.as_deref())?; + + args.merge(cfg); + args.verify()?; + + Ok(args) + } + + pub fn output_directory(&self) -> &Path { + self.output_directory + .as_deref() + .expect("Output directory must not be `None`") + } + + fn verify(&self) -> Result<()> { + if self.merge_files && self.generate_index_ts { + bail!( + "{}: --index is not compatible with --merge", + "Error".bold().red() + ); + } + + if self.output_directory.is_none() { + bail!("{}: You must provide the output diretory, either through the config file or the --output-directory flag", "Error".bold().red()) + } + + Ok(()) + } + + fn merge( + &mut self, + Config { + overrides, + output_directory, + no_warnings, + esm_imports, + format, + generate_index_ts, + merge_files, + no_capture, + }: Config, + ) { + // QUESTION: This gives the CLI flag priority over the config file's value, + // is this the correct order? + self.output_directory = output_directory.or_else(|| self.output_directory.clone()); + + self.overrides = overrides; + self.no_warnings |= no_warnings; + self.esm_imports |= esm_imports; + self.format |= format; + self.generate_index_ts |= generate_index_ts; + self.merge_files |= merge_files; + self.no_capture |= no_capture; + } +} + +impl Config { + fn load_from_file(path: Option<&Path>) -> Result { + if let Some(path) = path { + if !path.is_file() { + bail!("The provided path doesn't exist"); + } + + let content = std::fs::read_to_string(path)?; + return Ok(toml::from_str(&content)?); + } + + // TODO: from where do we actually load the config? + let path = Path::new("./ts-rs.toml"); + if !path.is_file() { + return Ok(Self::default()); + } + + let content = std::fs::read_to_string(path)?; + Ok(toml::from_str(&content)?) + } +} diff --git a/cli/src/main.rs b/cli/src/main.rs index f3e0c1fe8..254637a1f 100644 --- a/cli/src/main.rs +++ b/cli/src/main.rs @@ -14,35 +14,33 @@ mod path; use metadata::{Metadata, FILE_NAME}; -use crate::config::Config; +use crate::config::Args; const BLANK_LINE: [u8; 2] = [b'\n', b'\n']; const NOTE: &[u8; 109] = b"// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.\n"; -struct Cleanup<'a>(&'a Config); -impl<'a> Drop for Cleanup<'a> { +impl Drop for Args { fn drop(&mut self) { - _ = fs::remove_file(self.0.output_directory().join(FILE_NAME)); + _ = fs::remove_file(self.output_directory().join(FILE_NAME)); } } fn main() -> Result<()> { color_eyre::install()?; - let cfg = Config::load()?; - let _cleanup = Cleanup(&cfg); + let args = Args::load()?; - let metadata_path = cfg.output_directory().join(FILE_NAME); + let metadata_path = args.output_directory().join(FILE_NAME); if metadata_path.exists() { fs::remove_file(&metadata_path)?; } - cargo::invoke(&cfg)?; + cargo::invoke(&args)?; let metadata_content = fs::read_to_string(&metadata_path)?; let metadata = Metadata::try_from(&*metadata_content)?; - let demand_unique_names = cfg.merge_files || cfg.generate_index_ts; + let demand_unique_names = args.merge_files || args.generate_index_ts; if !demand_unique_names || metadata.is_empty() { return Ok(()); @@ -59,7 +57,7 @@ fn main() -> Result<()> { return Ok(()); } - let index_path = cfg.output_directory().join("index.ts"); + let index_path = args.output_directory().join("index.ts"); if index_path.exists() { fs::remove_file(&index_path)?; @@ -72,7 +70,7 @@ fn main() -> Result<()> { index.write_all(NOTE)?; - if cfg.generate_index_ts { + if args.generate_index_ts { for path in metadata.export_paths() { index.write_fmt(format_args!("\nexport * from {path:?};"))?; } @@ -80,9 +78,9 @@ fn main() -> Result<()> { return Ok(()); } - if cfg.merge_files { + if args.merge_files { for path in metadata.export_paths() { - let path = path::absolute(cfg.output_directory().join(path))?; + let path = path::absolute(args.output_directory().join(path))?; let mut file = OpenOptions::new().read(true).open(&path)?; let mut buf = Vec::with_capacity(file.metadata()?.len().try_into()?); @@ -97,7 +95,7 @@ fn main() -> Result<()> { fs::remove_file(path)?; } - path::remove_empty_subdirectories(&cfg.output_directory())?; + path::remove_empty_subdirectories(args.output_directory())?; return Ok(()); }