diff --git a/Cargo.toml b/Cargo.toml index 7e8a24b..2ca448e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -14,7 +14,7 @@ license = "MIT OR Apache-2.0" name = "libmake" repository = "https://github.com/sebastienrousseau/libmake.git" rust-version = "1.69.0" -version = "0.1.7" +version = "0.1.8" include = [ "/CONTRIBUTING.md", "/LICENSE-APACHE", @@ -45,6 +45,7 @@ assert_cmd = "2.0.11" clap = "4.2.7" csv = "1.2.1" figlet-rs = "0.1.5" +reqwest = { version = "0.11.17", features = ["blocking"] } serde = { version = "1.0.162", features = ["derive"] } serde_json = "1.0.96" serde_yaml = "0.9.21" diff --git a/README.md b/README.md index cdb9360..47b8050 100644 --- a/README.md +++ b/README.md @@ -332,6 +332,6 @@ this project. [codecov-badge]: https://img.shields.io/codecov/c/github/sebastienrousseau/libmake?style=for-the-badge&token=Q9KJ6XXL67 'Codecov' [crates-badge]: https://img.shields.io/crates/v/libmake.svg?style=for-the-badge 'Crates.io Badge' [docs-badge]: https://img.shields.io/docsrs/libmake.svg?style=for-the-badge 'Docs.rs Badge' -[libs-badge]: https://img.shields.io/badge/lib.rs-v0.1.7-orange.svg?style=for-the-badge 'Lib.rs Badge' +[libs-badge]: https://img.shields.io/badge/lib.rs-v0.1.8-orange.svg?style=for-the-badge 'Lib.rs Badge' [license-badge]: https://img.shields.io/crates/l/libmake.svg?style=for-the-badge 'License Badge' [made-with-rust-badge]: https://img.shields.io/badge/rust-f04041?style=for-the-badge&labelColor=c0282d&logo=rust 'Made With Rust Badge' diff --git a/TEMPLATE.md b/TEMPLATE.md index 65a386f..5884bd8 100644 --- a/TEMPLATE.md +++ b/TEMPLATE.md @@ -51,10 +51,10 @@ The library is designed to be used as a command-line tool. It is available on [C [9]: https://lib.rs/crates/libmake [14]: https://codecov.io/github/sebastienrousseau/libmake?branch=main -[banner]: https://raw.githubusercontent.com/sebastienrousseau/vault/main/assets/libmake/logo/logo-libmake.svg "libmake Banner" +[banner]: https://kura.pro/libmake/images/banners/banner-libmake.svg "LibMake Banner" [codecov-badge]: https://img.shields.io/codecov/c/github/sebastienrousseau/libmake?style=for-the-badge&token=Q9KJ6XXL67 'Codecov' [crates-badge]: https://img.shields.io/crates/v/libmake.svg?style=for-the-badge 'Crates.io Badge' [docs-badge]: https://img.shields.io/docsrs/libmake.svg?style=for-the-badge 'Docs.rs Badge' -[libs-badge]: https://img.shields.io/badge/lib.rs-v0.1.7-orange.svg?style=for-the-badge 'Lib.rs Badge' +[libs-badge]: https://img.shields.io/badge/lib.rs-v0.1.8-orange.svg?style=for-the-badge 'Lib.rs Badge' [license-badge]: https://img.shields.io/crates/l/libmake.svg?style=for-the-badge 'License Badge' [made-with-rust-badge]: https://img.shields.io/badge/rust-f04041?style=for-the-badge&labelColor=c0282d&logo=rust 'Made With Rust Badge' diff --git a/src/cli.rs b/src/cli.rs index bbb5039..38e5ff9 100644 --- a/src/cli.rs +++ b/src/cli.rs @@ -147,7 +147,7 @@ pub fn build_cli() -> Result { ) .arg( Arg::new("version") - .default_value("0.1.7") + .default_value("0.1.8") .help("Sets the version of the library") .long("version") .short('v') diff --git a/src/generator.rs b/src/generator.rs index b1c47ad..18d6330 100644 --- a/src/generator.rs +++ b/src/generator.rs @@ -1,5 +1,6 @@ use crate::interface::replace_placeholders; -use assert_cmd::Command; +use reqwest::blocking::get; +// use assert_cmd::Command; use serde::{Deserialize, Serialize}; use serde_json; use serde_yaml; @@ -217,22 +218,24 @@ pub fn create_template_folder() -> io::Result<()> { for file in &files { let file_url = format!("{}{}", url, file); let file_path = template_dir_path.join(file); - let output = Command::new("curl") - .arg("-s") - .arg("-L") - .arg("-o") - .arg(file_path.as_os_str()) - .arg(file_url) - .output()?; - if !output.status.success() { - return Err(io::Error::new( + let response = get(&file_url).map_err(|e| { + io::Error::new( io::ErrorKind::Other, - format!( - "Failed to download template file: {}", - String::from_utf8_lossy(&output.stderr) - ), - )); - } + format!("Failed to download template file: {}", e), + ) + })?; + let file_contents = response.text().map_err(|e| { + io::Error::new( + io::ErrorKind::Other, + format!("Failed to read response body: {}", e), + ) + })?; + std::fs::write( + &file_path, + file_contents + .trim_start_matches('\n') + .trim_end_matches('\n'), + )?; } Ok(()) } diff --git a/src/lib.rs b/src/lib.rs index a3c2a43..2ac9c5d 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -13,7 +13,7 @@ //! //! [![Rust](https://img.shields.io/badge/rust-f04041?style=for-the-badge&labelColor=c0282d&logo=rust)](https://www.rust-lang.org) //! [![Crates.io](https://img.shields.io/crates/v/libmake.svg?style=for-the-badge&color=success&labelColor=27A006)](https://crates.io/crates/libmake) -//! [![Lib.rs](https://img.shields.io/badge/lib.rs-v0.1.7-success.svg?style=for-the-badge&color=8A48FF&labelColor=6F36E4)](https://lib.rs/crates/libmake) +//! [![Lib.rs](https://img.shields.io/badge/lib.rs-v0.1.8-success.svg?style=for-the-badge&color=8A48FF&labelColor=6F36E4)](https://lib.rs/crates/libmake) //! [![GitHub](https://img.shields.io/badge/github-555555?style=for-the-badge&labelColor=000000&logo=github)](https://github.com/sebastienrousseau/libmake) //! [![License](https://img.shields.io/crates/l/libmake.svg?style=for-the-badge&color=007EC6&labelColor=03589B)](http://opensource.org/licenses/MIT) //! diff --git a/template/README.tpl b/template/README.tpl index b7c1a9a..76065e7 100644 --- a/template/README.tpl +++ b/template/README.tpl @@ -194,4 +194,4 @@ providing a lot of useful suggestions on how to improve this project. [docs-badge]: https://img.shields.io/docsrs/{name}.svg?style=for-the-badge 'Docs.rs badge' [libs-badge]: https://img.shields.io/badge/lib.rs-v{version}-orange.svg?style=for-the-badge 'Lib.rs badge' [license-badge]: https://img.shields.io/crates/l/{name}.svg?style=for-the-badge 'License badge' -[made-with-rust-badge]: https://img.shields.io/badge/rust-f04041?style=for-the-badge&labelColor=c0282d&logo=rust 'Made With Rust badge' +[made-with-rust-badge]: https://img.shields.io/badge/rust-f04041?style=for-the-badge&labelColor=c0282d&logo=rust 'Made With Rust badge' \ No newline at end of file diff --git a/template/TEMPLATE.tpl b/template/TEMPLATE.tpl index 617d95d..d6c1a77 100644 --- a/template/TEMPLATE.tpl +++ b/template/TEMPLATE.tpl @@ -64,4 +64,4 @@ align="right" [docs-badge]: https://img.shields.io/docsrs/{name}.svg?style=for-the-badge 'Docs.rs badge' [libs-badge]: https://img.shields.io/badge/lib.rs-v{version}-orange.svg?style=for-the-badge 'Lib.rs badge' [license-badge]: https://img.shields.io/crates/l/{name}.svg?style=for-the-badge 'License badge' -[made-with-rust-badge]: https://img.shields.io/badge/rust-f04041?style=for-the-badge&labelColor=c0282d&logo=rust 'Made With Rust badge' +[made-with-rust-badge]: https://img.shields.io/badge/rust-f04041?style=for-the-badge&labelColor=c0282d&logo=rust 'Made With Rust badge' \ No newline at end of file diff --git a/template/criterion.tpl b/template/criterion.tpl index ee9aefc..5e40200 100644 --- a/template/criterion.tpl +++ b/template/criterion.tpl @@ -47,4 +47,4 @@ criterion_group!( {name}_join_benchmark, {name}_benchmark ); -criterion_main!({name}_macros_benchmark); +criterion_main!({name}_macros_benchmark); \ No newline at end of file diff --git a/template/macros.tpl b/template/macros.tpl index fb0b9d0..26c9fb3 100644 --- a/template/macros.tpl +++ b/template/macros.tpl @@ -117,4 +117,4 @@ macro_rules! {name}_print_vec { println!("{}", v); } }}; -} +} \ No newline at end of file diff --git a/template/main.tpl b/template/main.tpl index 156479e..3b2987d 100644 --- a/template/main.tpl +++ b/template/main.tpl @@ -8,4 +8,4 @@ fn main() { eprintln!("Error running {name}: {}", err); std::process::exit(1); } -} +} \ No newline at end of file diff --git a/template/test.tpl b/template/test.tpl index 4e9f3e3..bc6d940 100644 --- a/template/test.tpl +++ b/template/test.tpl @@ -8,4 +8,4 @@ mod tests { let {name} = {name}::new(); assert_eq!({name}, {name}::default()); } -} +} \ No newline at end of file diff --git a/tests/data/mylibrary.csv b/tests/data/mylibrary.csv index 996fc94..8bfd0c8 100644 --- a/tests/data/mylibrary.csv +++ b/tests/data/mylibrary.csv @@ -1,2 +1,2 @@ author,build,categories,description,documentation,edition,email,homepage,keywords,license,name,output,readme,repository,rustversion,version,website -Me,build.rs,"['category 1', 'category 2']",A library for doing things,https://lib.rs/crates/my_library,2021,test@test.com,https://test.com,"['keyword1', 'keyword2']",MIT OR Apache-2.0,my_library,my_library,README.md,https://github.com/test/test,1.69.0,0.1.7,https://test.com \ No newline at end of file +Me,build.rs,"['category 1', 'category 2']",A library for doing things,https://lib.rs/crates/my_library,2021,test@test.com,https://test.com,"['keyword1', 'keyword2']",MIT OR Apache-2.0,my_library,my_library,README.md,https://github.com/test/test,1.69.0,0.1.8,https://test.com \ No newline at end of file diff --git a/tests/data/mylibrary.json b/tests/data/mylibrary.json index ab7636e..33c2b13 100644 --- a/tests/data/mylibrary.json +++ b/tests/data/mylibrary.json @@ -14,6 +14,6 @@ "readme": "README.md", "repository": "https://github.com/test/test", "rustversion": "1.69.0", - "version": "0.1.7", + "version": "0.1.8", "website": "https://test.com" } \ No newline at end of file diff --git a/tests/data/mylibrary.toml b/tests/data/mylibrary.toml index 2077c27..0120056 100644 --- a/tests/data/mylibrary.toml +++ b/tests/data/mylibrary.toml @@ -13,5 +13,5 @@ output = "my_library" readme = "README.md" repository = "https://github.com/test/test" rustversion = "1.69.0" -version = "0.1.7" +version = "0.1.8" website = "https://test.com" diff --git a/tests/data/mylibrary.yaml b/tests/data/mylibrary.yaml index 920d714..7c4d2ee 100644 --- a/tests/data/mylibrary.yaml +++ b/tests/data/mylibrary.yaml @@ -13,5 +13,5 @@ output: my_library readme: README.md repository: https://github.com/test/test rustversion: '1.69.0' -version: '0.1.7' +version: '0.1.8' website: https://test.com diff --git a/tests/test_cli.rs b/tests/test_cli.rs index a9a34bb..44a4f68 100644 --- a/tests/test_cli.rs +++ b/tests/test_cli.rs @@ -22,7 +22,7 @@ mod tests { ("readme", "README.md"), ("repository", "https://github.com/test/test"), ("rustversion", "1.69.0"), - ("version", "0.1.7"), + ("version", "0.1.8"), ("website", "https://test.com"), ]; diff --git a/tests/test_utils.rs b/tests/test_utils.rs index 0190976..e2db58b 100644 --- a/tests/test_utils.rs +++ b/tests/test_utils.rs @@ -105,7 +105,7 @@ mod tests { ); assert_eq!( get_csv_field(Some(file_path), 15), - Some(vec!["0.1.7".to_string()]) + Some(vec!["0.1.8".to_string()]) ); assert_eq!( get_csv_field(Some(file_path), 16),