diff --git a/Cargo.lock b/Cargo.lock index 6222abf..e28d9b8 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -80,6 +80,17 @@ dependencies = [ "vec_map 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "clicolors-control" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", + "lazy_static 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.36 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "coco" version = "0.1.1" @@ -89,6 +100,21 @@ dependencies = [ "scopeguard 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "console" +version = "0.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "clicolors-control 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", + "lazy_static 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.36 (registry+https://github.com/rust-lang/crates.io-index)", + "parking_lot 0.5.4 (registry+https://github.com/rust-lang/crates.io-index)", + "regex 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)", + "termios 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", + "unicode-width 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "dtoa" version = "0.4.2" @@ -149,11 +175,31 @@ name = "glob" version = "0.2.11" source = "registry+https://github.com/rust-lang/crates.io-index" +[[package]] +name = "indicatif" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "console 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)", + "lazy_static 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", + "parking_lot 0.5.4 (registry+https://github.com/rust-lang/crates.io-index)", + "regex 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "itoa" version = "0.3.4" source = "registry+https://github.com/rust-lang/crates.io-index" +[[package]] +name = "kernel32-sys" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi-build 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "lazy_static" version = "0.2.11" @@ -233,6 +279,34 @@ dependencies = [ "libc 0.2.36 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "owning_ref" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "stable_deref_trait 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "parking_lot" +version = "0.5.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "owning_ref 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", + "parking_lot_core 0.2.13 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "parking_lot_core" +version = "0.2.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "libc 0.2.36 (registry+https://github.com/rust-lang/crates.io-index)", + "rand 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", + "smallvec 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "proc-macro2" version = "0.2.2" @@ -387,6 +461,16 @@ dependencies = [ "serde 1.0.27 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "smallvec" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "stable_deref_trait" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" + [[package]] name = "strsim" version = "0.7.0" @@ -466,6 +550,14 @@ dependencies = [ "redox_termios 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "termios" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "libc 0.2.36 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "textwrap" version = "0.9.0" @@ -543,7 +635,9 @@ source = "registry+https://github.com/rust-lang/crates.io-index" name = "wasm-pack" version = "0.1.0" dependencies = [ + "console 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)", "failure 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", + "indicatif 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", "quicli 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.27 (registry+https://github.com/rust-lang/crates.io-index)", "serde_derive 1.0.27 (registry+https://github.com/rust-lang/crates.io-index)", @@ -551,6 +645,11 @@ dependencies = [ "toml 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "winapi" +version = "0.2.8" +source = "registry+https://github.com/rust-lang/crates.io-index" + [[package]] name = "winapi" version = "0.3.4" @@ -560,6 +659,11 @@ dependencies = [ "winapi-x86_64-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "winapi-build" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" + [[package]] name = "winapi-i686-pc-windows-gnu" version = "0.4.0" @@ -589,7 +693,9 @@ dependencies = [ "checksum cfg-if 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "d4c819a1287eb618df47cc647173c5c4c66ba19d888a6e50d605672aed3140de" "checksum chrono 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "7c20ebe0b2b08b0aeddba49c609fe7957ba2e33449882cb186a180bc60682fa9" "checksum clap 2.29.4 (registry+https://github.com/rust-lang/crates.io-index)" = "7b8f59bcebcfe4269b09f71dab0da15b355c75916a8f975d3876ce81561893ee" +"checksum clicolors-control 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1f84dec9bc083ce2503908cd305af98bd363da6f54bf8d4bf0ac14ee749ad5d1" "checksum coco 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "c06169f5beb7e31c7c67ebf5540b8b472d23e3eade3b2ec7d1f5b504a85f91bd" +"checksum console 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)" = "7649ca90478264b9686aac8d269fcb014f14c2bed7c79a7e51b9f6afd4d783eb" "checksum dtoa 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "09c3753c3db574d215cba4ea76018483895d7bff25a31b49ba45db21c48e50ab" "checksum either 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "740178ddf48b1a9e878e6d6509a1442a2d42fd2928aae8e7a6f8a36fb01981b3" "checksum env_logger 0.5.3 (registry+https://github.com/rust-lang/crates.io-index)" = "f15f0b172cb4f52ed5dbf47f774a387cd2315d1bf7894ab5af9b083ae27efa5a" @@ -598,7 +704,9 @@ dependencies = [ "checksum fuchsia-zircon 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "2e9763c69ebaae630ba35f74888db465e49e259ba1bc0eda7d06f4a067615d82" "checksum fuchsia-zircon-sys 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "3dcaa9ae7725d12cdb85b3ad99a434db70b468c09ded17e012d86b5c1010f7a7" "checksum glob 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)" = "8be18de09a56b60ed0edf84bc9df007e30040691af7acd1c41874faac5895bfb" +"checksum indicatif 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "a29b2fa6f00010c268bface64c18bb0310aaa70d46a195d5382d288c477fb016" "checksum itoa 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)" = "8324a32baf01e2ae060e9de58ed0bc2320c9a2833491ee36cd3b4c414de4db8c" +"checksum kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7507624b29483431c0ba2d82aece8ca6cdba9382bff4ddd0f7490560c056098d" "checksum lazy_static 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)" = "76f033c7ad61445c5b347c7382dd1237847eb1bce590fe50365dcb33d546be73" "checksum lazy_static 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "c8f31047daa365f19be14b47c29df4f7c3b581832407daabe6ae77397619237d" "checksum libc 0.2.36 (registry+https://github.com/rust-lang/crates.io-index)" = "1e5d97d6708edaa407429faa671b942dc0f2727222fb6b6539bf1db936e4b121" @@ -610,6 +718,9 @@ dependencies = [ "checksum num-traits 0.1.43 (registry+https://github.com/rust-lang/crates.io-index)" = "92e5113e9fd4cc14ded8e499429f396a20f98c772a47cc8622a736e1ec843c31" "checksum num-traits 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "e7de20f146db9d920c45ee8ed8f71681fd9ade71909b48c3acbd766aa504cf10" "checksum num_cpus 1.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "c51a3322e4bca9d212ad9a158a02abc6934d005490c054a2778df73a70aa0a30" +"checksum owning_ref 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "cdf84f41639e037b484f93433aa3897863b561ed65c6e59c7073d7c561710f37" +"checksum parking_lot 0.5.4 (registry+https://github.com/rust-lang/crates.io-index)" = "9fd9d732f2de194336fb02fe11f9eed13d9e76f13f4315b4d88a14ca411750cd" +"checksum parking_lot_core 0.2.13 (registry+https://github.com/rust-lang/crates.io-index)" = "538ef00b7317875071d5e00f603f24d16f0b474c1a5fc0ccb8b454ca72eafa79" "checksum proc-macro2 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "d1cb7aaaa4bf022ec2b14ff2f2ba1643a22f3cee88df014a85e14b392282c61d" "checksum quicli 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "8b39e72e41703f8a10d864b6ab4c74f9568acca64142cd45bdbd0e755bef6522" "checksum quote 0.3.15 (registry+https://github.com/rust-lang/crates.io-index)" = "7a6e920b65c65f10b2ae65c831a81a073a89edd28c7cce89475bff467ab4167a" @@ -628,6 +739,8 @@ dependencies = [ "checksum serde_derive 1.0.27 (registry+https://github.com/rust-lang/crates.io-index)" = "f4ba7591cfe93755e89eeecdbcc668885624829b020050e6aec99c2a03bd3fd0" "checksum serde_derive_internals 0.19.0 (registry+https://github.com/rust-lang/crates.io-index)" = "6e03f1c9530c3fb0a0a5c9b826bdd9246a5921ae995d75f512ac917fc4dd55b5" "checksum serde_json 1.0.9 (registry+https://github.com/rust-lang/crates.io-index)" = "c9db7266c7d63a4c4b7fe8719656ccdd51acf1bed6124b174f933b009fb10bcb" +"checksum smallvec 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "44db0ecb22921ef790d17ae13a3f6d15784183ff5f2a01aa32098c7498d2b4b9" +"checksum stable_deref_trait 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "15132e0e364248108c5e2c02e3ab539be8d6f5d52a01ca9bbf27ed657316f02b" "checksum strsim 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "bb4f380125926a99e52bc279241539c018323fab05ad6368b56f93d9369ff550" "checksum structopt 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "327335c760260b46ea41fb857565b27ecbf9acfd16a37498ea599b14aa71d814" "checksum structopt-derive 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "a43218e713ea7004f0b7855556f5dec3a92d8f405502ff37c1f34ac4e125719f" @@ -637,6 +750,7 @@ dependencies = [ "checksum synstructure 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)" = "3a761d12e6d8dcb4dcf952a7a89b475e3a9d69e4a69307e01a470977642914bd" "checksum termcolor 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)" = "73e83896da740a4541a6f21606b35f2aa4bada5b65d89dc61114bf9d6ff2dc7e" "checksum termion 1.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "689a3bdfaab439fd92bc87df5c4c78417d3cbe537487274e9b0b2dce76e92096" +"checksum termios 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "d5d9cf598a6d7ce700a4e6a9199da127e6819a61e64b68609683cc9a01b5683a" "checksum textwrap 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "c0b59b6b4b44d867f1370ef1bd91bfb262bf07bf0ae65c202ea2fbc16153b693" "checksum thread_local 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)" = "279ef31c19ededf577bfd12dfae728040a21f635b06a24cd670ff510edd38963" "checksum time 0.1.39 (registry+https://github.com/rust-lang/crates.io-index)" = "a15375f1df02096fb3317256ce2cee6a1f42fc84ea5ad5fc8c421cfe40c73098" @@ -648,7 +762,9 @@ dependencies = [ "checksum utf8-ranges 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "662fab6525a98beff2921d7f61a39e7d59e0b425ebc7d0d9e66d316e55124122" "checksum vec_map 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "887b5b631c2ad01628bbbaa7dd4c869f80d3186688f8d0b6f58774fbe324988c" "checksum void 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "6a02e4885ed3bc0f2de90ea6dd45ebcbb66dacffe03547fadbb0eeae2770887d" +"checksum winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)" = "167dc9d6949a9b857f3451275e911c3f44255842c1f7a76f33c55103a909087a" "checksum winapi 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)" = "04e3bd221fcbe8a271359c04f21a76db7d0c6028862d1bb5512d85e1e2eb5bb3" +"checksum winapi-build 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "2d315eee3b34aca4797b2da6b13ed88266e6d612562a0c46390af8299fc699bc" "checksum winapi-i686-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" "checksum winapi-x86_64-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" "checksum wincolor 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "eeb06499a3a4d44302791052df005d5232b927ed1a9658146d842165c4de7767" diff --git a/Cargo.toml b/Cargo.toml index 5fb8342..ae25ad5 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -8,7 +8,9 @@ license = "MIT/Apache-2.0" readme = "README.md" [dependencies] +console = "0.6.1" failure = "0.1.1" +indicatif = "0.9.0" quicli = "0.2" serde = "1.0" serde_derive = "1.0" diff --git a/src/bindgen.rs b/src/bindgen.rs index 368fdf3..89ecc41 100644 --- a/src/bindgen.rs +++ b/src/bindgen.rs @@ -8,21 +8,14 @@ pub fn cargo_install_wasm_bindgen() { .output() .unwrap_or_else(|e| panic!("failed to execute process: {}", e)); - if output.status.success() { - let s = String::from_utf8_lossy(&output.stdout); - - println!( - "✅ cargo_install_wasm_bindgen succeeded and stdout was:\n{}", - s - ); - } else { - let s = String::from_utf8_lossy(&output.stderr); - - print!( - "⛔ cargo_install_wasm_bindgen failed and stderr was:\n{}", - s - ); - } + //if !output.status.success() { + // let s = String::from_utf8_lossy(&output.stderr); + + // print!( + // "⛔ cargo_install_wasm_bindgen failed and stderr was:\n{}", + // s + // ); + // } } pub fn wasm_bindgen_build(path: &str, name: &str) { @@ -36,12 +29,7 @@ pub fn wasm_bindgen_build(path: &str, name: &str) { .output() .unwrap_or_else(|e| panic!("failed to execute process: {}", e)); - if output.status.success() { - let s = String::from_utf8_lossy(&output.stdout); - - println!("✅ wasm_bindgen_build succeeded and stdout was:\n{}", s); - println!("🏄<200d>♀️ ready to go!"); - } else { + if !output.status.success() { let s = String::from_utf8_lossy(&output.stderr); print!("⛔ wasm_bindgen_build failed and stderr was:\n{}", s); diff --git a/src/build.rs b/src/build.rs index 361ecb1..23faeb4 100644 --- a/src/build.rs +++ b/src/build.rs @@ -8,14 +8,7 @@ pub fn rustup_add_wasm_target() { .output() .unwrap_or_else(|e| panic!("failed to execute process: {}", e)); - if output.status.success() { - let s = String::from_utf8_lossy(&output.stdout); - - println!( - "✅ rustup_add_wasm_target succeeded and stdout was:\n{}", - s - ); - } else { + if !output.status.success() { let s = String::from_utf8_lossy(&output.stderr); print!("⛔ rustup_add_wasm_target failed and stderr was:\n{}", s); @@ -32,12 +25,7 @@ pub fn cargo_build_wasm(path: &str) { .output() .unwrap_or_else(|e| panic!("failed to execute process: {}", e)); - if output.status.success() { - let s = String::from_utf8_lossy(&output.stdout); - - println!("✅ cargo_build_wasm succeeded and stdout was:\n{}", s); - println!("🏎️ 💨 compiled to wasm!"); - } else { + if !output.status.success() { let s = String::from_utf8_lossy(&output.stderr); print!("⛔ cargo_build_wasm failed and stderr was:\n{}", s); diff --git a/src/lib.rs b/src/lib.rs index d25a3a7..b9552d8 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,4 +1,5 @@ extern crate failure; +extern crate indicatif; #[macro_use] extern crate serde_derive; extern crate serde_json; diff --git a/src/main.rs b/src/main.rs index b430250..121f838 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,11 +1,28 @@ +extern crate console; extern crate failure; +extern crate indicatif; #[macro_use] extern crate quicli; extern crate wasm_pack; -use wasm_pack::{bindgen, build, manifest, readme}; +mod progressbar; + +use std::time::Instant; +use console::{style, Emoji}; +use indicatif::HumanDuration; use quicli::prelude::*; +use wasm_pack::{bindgen, build, manifest, readme}; + +static TARGET: Emoji = Emoji("🎯 ", ""); +static CYCLONE: Emoji = Emoji("🌀 ", ""); +static FOLDER: Emoji = Emoji("📂 ", ""); +static MEMO: Emoji = Emoji("📝 ", ""); +static DANCERS: Emoji = Emoji("👯 ", ""); +static DOWN_ARROW: Emoji = Emoji("⬇️ ", ""); +static RUNNER: Emoji = Emoji("🏃‍♀️ ", ""); +static SPARKLE: Emoji = Emoji("✨ ", ":-)"); +static PACKAGE: Emoji = Emoji("📦 ", ":-)"); /// 📦 ✨ pack and publish your wasm! #[derive(Debug, StructOpt)] @@ -32,18 +49,82 @@ enum Command { main!(|args: Cli, log_level: verbosity| match args.cmd { Command::Init { path } => { + let started = Instant::now(); + let crate_path = match path { Some(p) => p, None => ".".to_string(), }; + + let step1 = format!( + "{} {}Adding WASM target...", + style("[1/7]").bold().dim(), + TARGET + ); + let pb1 = progressbar::new(); + pb1.set_message(&step1); build::rustup_add_wasm_target(); + pb1.finish(); + let step2 = format!( + "{} {}Compiling to WASM...", + style("[2/7]").bold().dim(), + CYCLONE + ); + let pb2 = progressbar::new(); + pb2.set_message(&step2); build::cargo_build_wasm(&crate_path); + pb2.finish(); + let step3 = format!( + "{} {}Creating a pkg directory...", + style("[3/7]").bold().dim(), + FOLDER + ); + let pb3 = progressbar::new(); + pb3.set_message(&step3); wasm_pack::create_pkg_dir(&crate_path)?; + pb3.finish(); + let step4 = format!( + "{} {}Writing a package.json...", + style("[4/7]").bold().dim(), + MEMO + ); + let pb4 = progressbar::new(); + pb4.set_message(&step4); manifest::write_package_json(&crate_path)?; + pb4.finish(); + let step5 = format!( + "{} {}Copying over your README...", + style("[5/7]").bold().dim(), + DANCERS + ); + let pb5 = progressbar::new(); + pb5.set_message(&step5); readme::copy_from_crate(&crate_path)?; + pb5.finish(); + let step6 = format!( + "{} {}Installing WASM-bindgen...", + style("[6/7]").bold().dim(), + DOWN_ARROW + ); + let pb6 = progressbar::new(); + pb6.set_message(&step6); bindgen::cargo_install_wasm_bindgen(); + pb6.finish(); let name = manifest::get_crate_name(&crate_path)?; + let step7 = format!( + "{} {}Running WASM-bindgen...", + style("[7/7]").bold().dim(), + RUNNER + ); + let pb7 = progressbar::new(); + pb7.set_message(&step7); bindgen::wasm_bindgen_build(&crate_path, &name); + pb7.finish(); + println!("{} Done in {}", SPARKLE, HumanDuration(started.elapsed())); + println!( + "{} Your WASM pkg is ready to publish at {}/pkg", + PACKAGE, &crate_path + ) } Command::Pack { .. } => { println!("🙅‍♀️ whoops! this is not implemented yet! sorry!"); diff --git a/src/manifest.rs b/src/manifest.rs index 7c5356f..a61928c 100644 --- a/src/manifest.rs +++ b/src/manifest.rs @@ -38,7 +38,6 @@ struct Repository { fn read_cargo_toml(path: &str) -> Result { let manifest_path = format!("{}/Cargo.toml", path); - println!("👩<200d>🍳 reading {}", manifest_path); let mut cargo_file = File::open(manifest_path)?; let mut cargo_contents = String::new(); cargo_file.read_to_string(&mut cargo_contents)?; @@ -73,7 +72,6 @@ pub fn write_package_json(path: &str) -> Result<(), Error> { let npm_data = crate_data.into_npm(); let npm_json = serde_json::to_string(&npm_data)?; pkg_file.write_all(npm_json.as_bytes())?; - println!("✍️ wrote a package.json!"); Ok(()) } diff --git a/src/progressbar.rs b/src/progressbar.rs new file mode 100644 index 0000000..7c8b447 --- /dev/null +++ b/src/progressbar.rs @@ -0,0 +1,12 @@ +use indicatif::{ProgressBar, ProgressStyle}; + +pub fn new() -> ProgressBar { + let pb = ProgressBar::new_spinner(); + pb.enable_steady_tick(200); + pb.set_style( + ProgressStyle::default_spinner() + .tick_chars("/|\\- ") + .template("{spinner:.dim.bold} {wide_msg}"), + ); + pb +}