Skip to content

Commit 1c4e62f

Browse files
Merge pull request #15 from sebastienrousseau/feat/libmake
feat(libmake): replacing `curl` with `reqwest` to remove the HTTP headers in downloaded template files
2 parents 90b2a6c + b7d599e commit 1c4e62f

18 files changed

+38
-34
lines changed

Cargo.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ license = "MIT OR Apache-2.0"
1414
name = "libmake"
1515
repository = "https://github.com/sebastienrousseau/libmake.git"
1616
rust-version = "1.69.0"
17-
version = "0.1.7"
17+
version = "0.1.8"
1818
include = [
1919
"/CONTRIBUTING.md",
2020
"/LICENSE-APACHE",
@@ -45,6 +45,7 @@ assert_cmd = "2.0.11"
4545
clap = "4.2.7"
4646
csv = "1.2.1"
4747
figlet-rs = "0.1.5"
48+
reqwest = { version = "0.11.17", features = ["blocking"] }
4849
serde = { version = "1.0.162", features = ["derive"] }
4950
serde_json = "1.0.96"
5051
serde_yaml = "0.9.21"

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -332,6 +332,6 @@ this project.
332332
[codecov-badge]: https://img.shields.io/codecov/c/github/sebastienrousseau/libmake?style=for-the-badge&token=Q9KJ6XXL67 'Codecov'
333333
[crates-badge]: https://img.shields.io/crates/v/libmake.svg?style=for-the-badge 'Crates.io Badge'
334334
[docs-badge]: https://img.shields.io/docsrs/libmake.svg?style=for-the-badge 'Docs.rs Badge'
335-
[libs-badge]: https://img.shields.io/badge/lib.rs-v0.1.7-orange.svg?style=for-the-badge 'Lib.rs Badge'
335+
[libs-badge]: https://img.shields.io/badge/lib.rs-v0.1.8-orange.svg?style=for-the-badge 'Lib.rs Badge'
336336
[license-badge]: https://img.shields.io/crates/l/libmake.svg?style=for-the-badge 'License Badge'
337337
[made-with-rust-badge]: https://img.shields.io/badge/rust-f04041?style=for-the-badge&labelColor=c0282d&logo=rust 'Made With Rust Badge'

TEMPLATE.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,10 +51,10 @@ The library is designed to be used as a command-line tool. It is available on [C
5151
[9]: https://lib.rs/crates/libmake
5252
[14]: https://codecov.io/github/sebastienrousseau/libmake?branch=main
5353

54-
[banner]: https://raw.githubusercontent.com/sebastienrousseau/vault/main/assets/libmake/logo/logo-libmake.svg "libmake Banner"
54+
[banner]: https://kura.pro/libmake/images/banners/banner-libmake.svg "LibMake Banner"
5555
[codecov-badge]: https://img.shields.io/codecov/c/github/sebastienrousseau/libmake?style=for-the-badge&token=Q9KJ6XXL67 'Codecov'
5656
[crates-badge]: https://img.shields.io/crates/v/libmake.svg?style=for-the-badge 'Crates.io Badge'
5757
[docs-badge]: https://img.shields.io/docsrs/libmake.svg?style=for-the-badge 'Docs.rs Badge'
58-
[libs-badge]: https://img.shields.io/badge/lib.rs-v0.1.7-orange.svg?style=for-the-badge 'Lib.rs Badge'
58+
[libs-badge]: https://img.shields.io/badge/lib.rs-v0.1.8-orange.svg?style=for-the-badge 'Lib.rs Badge'
5959
[license-badge]: https://img.shields.io/crates/l/libmake.svg?style=for-the-badge 'License Badge'
6060
[made-with-rust-badge]: https://img.shields.io/badge/rust-f04041?style=for-the-badge&labelColor=c0282d&logo=rust 'Made With Rust Badge'

src/cli.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ pub fn build_cli() -> Result<ArgMatches, Error> {
147147
)
148148
.arg(
149149
Arg::new("version")
150-
.default_value("0.1.7")
150+
.default_value("0.1.8")
151151
.help("Sets the version of the library")
152152
.long("version")
153153
.short('v')

src/generator.rs

Lines changed: 19 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
use crate::interface::replace_placeholders;
2-
use assert_cmd::Command;
2+
use reqwest::blocking::get;
3+
// use assert_cmd::Command;
34
use serde::{Deserialize, Serialize};
45
use serde_json;
56
use serde_yaml;
@@ -217,22 +218,24 @@ pub fn create_template_folder() -> io::Result<()> {
217218
for file in &files {
218219
let file_url = format!("{}{}", url, file);
219220
let file_path = template_dir_path.join(file);
220-
let output = Command::new("curl")
221-
.arg("-s")
222-
.arg("-L")
223-
.arg("-o")
224-
.arg(file_path.as_os_str())
225-
.arg(file_url)
226-
.output()?;
227-
if !output.status.success() {
228-
return Err(io::Error::new(
221+
let response = get(&file_url).map_err(|e| {
222+
io::Error::new(
229223
io::ErrorKind::Other,
230-
format!(
231-
"Failed to download template file: {}",
232-
String::from_utf8_lossy(&output.stderr)
233-
),
234-
));
235-
}
224+
format!("Failed to download template file: {}", e),
225+
)
226+
})?;
227+
let file_contents = response.text().map_err(|e| {
228+
io::Error::new(
229+
io::ErrorKind::Other,
230+
format!("Failed to read response body: {}", e),
231+
)
232+
})?;
233+
std::fs::write(
234+
&file_path,
235+
file_contents
236+
.trim_start_matches('\n')
237+
.trim_end_matches('\n'),
238+
)?;
236239
}
237240
Ok(())
238241
}

src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
//!
1414
//! [![Rust](https://img.shields.io/badge/rust-f04041?style=for-the-badge&labelColor=c0282d&logo=rust)](https://www.rust-lang.org)
1515
//! [![Crates.io](https://img.shields.io/crates/v/libmake.svg?style=for-the-badge&color=success&labelColor=27A006)](https://crates.io/crates/libmake)
16-
//! [![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)
16+
//! [![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)
1717
//! [![GitHub](https://img.shields.io/badge/github-555555?style=for-the-badge&labelColor=000000&logo=github)](https://github.com/sebastienrousseau/libmake)
1818
//! [![License](https://img.shields.io/crates/l/libmake.svg?style=for-the-badge&color=007EC6&labelColor=03589B)](http://opensource.org/licenses/MIT)
1919
//!

template/README.tpl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,4 +194,4 @@ providing a lot of useful suggestions on how to improve this project.
194194
[docs-badge]: https://img.shields.io/docsrs/{name}.svg?style=for-the-badge 'Docs.rs badge'
195195
[libs-badge]: https://img.shields.io/badge/lib.rs-v{version}-orange.svg?style=for-the-badge 'Lib.rs badge'
196196
[license-badge]: https://img.shields.io/crates/l/{name}.svg?style=for-the-badge 'License badge'
197-
[made-with-rust-badge]: https://img.shields.io/badge/rust-f04041?style=for-the-badge&labelColor=c0282d&logo=rust 'Made With Rust badge'
197+
[made-with-rust-badge]: https://img.shields.io/badge/rust-f04041?style=for-the-badge&labelColor=c0282d&logo=rust 'Made With Rust badge'

template/TEMPLATE.tpl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,4 +64,4 @@ align="right"
6464
[docs-badge]: https://img.shields.io/docsrs/{name}.svg?style=for-the-badge 'Docs.rs badge'
6565
[libs-badge]: https://img.shields.io/badge/lib.rs-v{version}-orange.svg?style=for-the-badge 'Lib.rs badge'
6666
[license-badge]: https://img.shields.io/crates/l/{name}.svg?style=for-the-badge 'License badge'
67-
[made-with-rust-badge]: https://img.shields.io/badge/rust-f04041?style=for-the-badge&labelColor=c0282d&logo=rust 'Made With Rust badge'
67+
[made-with-rust-badge]: https://img.shields.io/badge/rust-f04041?style=for-the-badge&labelColor=c0282d&logo=rust 'Made With Rust badge'

template/criterion.tpl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,4 +47,4 @@ criterion_group!(
4747
{name}_join_benchmark,
4848
{name}_benchmark
4949
);
50-
criterion_main!({name}_macros_benchmark);
50+
criterion_main!({name}_macros_benchmark);

template/macros.tpl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,4 +117,4 @@ macro_rules! {name}_print_vec {
117117
println!("{}", v);
118118
}
119119
}};
120-
}
120+
}

0 commit comments

Comments
 (0)