diff --git a/Cargo.lock b/Cargo.lock index dfaf50e..eb3fba5 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1242,13 +1242,9 @@ dependencies = [ "atty 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", "cargo_metadata 0.6.4 (registry+https://github.com/rust-lang/crates.io-index)", "console 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)", - "curl 0.4.19 (registry+https://github.com/rust-lang/crates.io-index)", "dialoguer 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", - "dirs 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", "failure 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", - "flate2 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", "glob 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", - "hex 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", "human-panic 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)", "indicatif 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1258,17 +1254,29 @@ dependencies = [ "serde_derive 1.0.83 (registry+https://github.com/rust-lang/crates.io-index)", "serde_ignored 0.0.4 (registry+https://github.com/rust-lang/crates.io-index)", "serde_json 1.0.33 (registry+https://github.com/rust-lang/crates.io-index)", - "siphasher 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", "slog 2.4.1 (registry+https://github.com/rust-lang/crates.io-index)", "slog-async 2.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "slog-term 2.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "strsim 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", "structopt 0.2.14 (registry+https://github.com/rust-lang/crates.io-index)", - "tar 0.4.20 (registry+https://github.com/rust-lang/crates.io-index)", "tempfile 3.0.5 (registry+https://github.com/rust-lang/crates.io-index)", "toml 0.4.10 (registry+https://github.com/rust-lang/crates.io-index)", "walkdir 2.2.7 (registry+https://github.com/rust-lang/crates.io-index)", + "wasm-pack-binary-install 0.1.0", "which 2.0.1 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "wasm-pack-binary-install" +version = "0.1.0" +dependencies = [ + "curl 0.4.19 (registry+https://github.com/rust-lang/crates.io-index)", + "dirs 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", + "failure 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", + "flate2 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", + "hex 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", + "siphasher 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", + "tar 0.4.20 (registry+https://github.com/rust-lang/crates.io-index)", "zip 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", ] diff --git a/Cargo.toml b/Cargo.toml index 34e1727..dcf45e9 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -13,12 +13,8 @@ documentation = "https://rustwasm.github.io/wasm-pack/" atty = "0.2.11" cargo_metadata = "0.6.0" console = "0.6.1" -curl = "0.4.13" dialoguer = "0.3.0" -dirs = "1.0.4" failure = "0.1.2" -flate2 = "1.0.2" -hex = "0.3" human-panic = "1.0.1" glob = "0.2" indicatif = "0.9.0" @@ -29,17 +25,15 @@ serde = "1.0.74" serde_derive = "1.0.74" serde_ignored = "0.0.4" serde_json = "1.0.26" -siphasher = "0.2.3" slog = "2.3" slog-term = "2.4" slog-async = "2.3" strsim = "0.8.0" structopt = "0.2" -tar = "0.4.16" toml = "0.4" which = "2.0.0" +wasm-pack-binary-install = { version = "0.1.0", path = "./binary-install" } walkdir = "2" -zip = "0.5.0" [dev-dependencies] tempfile = "3" diff --git a/binary-install/Cargo.toml b/binary-install/Cargo.toml new file mode 100644 index 0000000..76d71b1 --- /dev/null +++ b/binary-install/Cargo.toml @@ -0,0 +1,13 @@ +[package] +name = "wasm-pack-binary-install" +version = "0.1.0" + +[dependencies] +curl = "0.4.13" +dirs = "1.0.4" +failure = "0.1.2" +flate2 = "1.0.2" +hex = "0.3" +siphasher = "0.2.3" +tar = "0.4.16" +zip = "0.5.0" diff --git a/src/binaries.rs b/binary-install/src/lib.rs similarity index 96% rename from src/binaries.rs rename to binary-install/src/lib.rs index a34c872..dcef39f 100644 --- a/src/binaries.rs +++ b/binary-install/src/lib.rs @@ -1,10 +1,16 @@ //! Utilities for finding and installing binaries that we depend on. -use curl; -use dirs; +extern crate curl; +#[macro_use] +extern crate failure; +extern crate dirs; +extern crate flate2; +extern crate hex; +extern crate siphasher; +extern crate tar; +extern crate zip; + use failure::{Error, ResultExt}; -use flate2; -use hex; use siphasher::sip::SipHasher13; use std::collections::HashSet; use std::env; @@ -13,8 +19,6 @@ use std::fs; use std::hash::{Hash, Hasher}; use std::io; use std::path::{Path, PathBuf}; -use tar; -use zip; /// Global cache for wasm-pack, currently containing binaries downloaded from /// urls like wasm-bindgen and such. @@ -38,8 +42,7 @@ impl Cache { .or_else(|| { let home = dirs::home_dir()?; Some(home.join(".wasm-pack")) - }) - .ok_or_else(|| format_err!("couldn't find your home directory, is $HOME not set?"))?; + }).ok_or_else(|| format_err!("couldn't find your home directory, is $HOME not set?"))?; Ok(Cache::at(&destination)) } diff --git a/src/bindgen.rs b/src/bindgen.rs index 8282f6b..0a84950 100644 --- a/src/bindgen.rs +++ b/src/bindgen.rs @@ -1,6 +1,5 @@ //! Functionality related to installing and running `wasm-bindgen`. -use binaries::{Cache, Download}; use child; use command::build::BuildProfile; use emoji; @@ -12,6 +11,7 @@ use std::fs; use std::path::{Path, PathBuf}; use std::process::Command; use target; +use wasm_pack_binary_install::{Cache, Download}; use which::which; use PBAR; diff --git a/src/command/build.rs b/src/command/build.rs index 4b00cca..0fbbff3 100644 --- a/src/command/build.rs +++ b/src/command/build.rs @@ -1,6 +1,5 @@ //! Implementation of the `wasm-pack build` command. -use binaries::{Cache, Download}; use bindgen; use build; use command::utils::{create_pkg_dir, set_crate_path}; @@ -16,6 +15,7 @@ use slog::Logger; use std::path::PathBuf; use std::str::FromStr; use std::time::Instant; +use wasm_pack_binary_install::{Cache, Download}; use PBAR; /// Everything required to configure and run the `wasm-pack init` command. diff --git a/src/command/test.rs b/src/command/test.rs index 92633dd..81e5c2b 100644 --- a/src/command/test.rs +++ b/src/command/test.rs @@ -1,7 +1,6 @@ //! Implementation of the `wasm-pack test` command. use super::build::BuildMode; -use binaries::Cache; use bindgen; use build; use command::utils::set_crate_path; @@ -16,6 +15,7 @@ use slog::Logger; use std::path::PathBuf; use std::time::Instant; use test::{self, webdriver}; +use wasm_pack_binary_install::Cache; use PBAR; #[derive(Debug, Default, StructOpt)] diff --git a/src/lib.rs b/src/lib.rs index e336d0f..901e1a3 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -4,16 +4,12 @@ extern crate cargo_metadata; extern crate console; -extern crate curl; -extern crate dialoguer; -extern crate dirs; extern crate strsim; #[macro_use] extern crate failure; -extern crate flate2; extern crate glob; -extern crate hex; extern crate indicatif; +extern crate which; #[macro_use] extern crate lazy_static; extern crate parking_lot; @@ -22,20 +18,17 @@ extern crate serde; extern crate serde_derive; extern crate serde_ignored; extern crate serde_json; -extern crate siphasher; #[macro_use] extern crate structopt; #[macro_use] extern crate slog; +extern crate dialoguer; extern crate slog_async; extern crate slog_term; -extern crate tar; extern crate toml; extern crate walkdir; -extern crate which; -extern crate zip; +extern crate wasm_pack_binary_install; -pub mod binaries; pub mod bindgen; pub mod build; pub mod child; diff --git a/src/test/webdriver.rs b/src/test/webdriver.rs index 4b06314..9709c40 100644 --- a/src/test/webdriver.rs +++ b/src/test/webdriver.rs @@ -1,10 +1,10 @@ //! Getting WebDriver client binaries. -use binaries::Cache; use command::build::BuildMode; use failure; use std::path::PathBuf; use target; +use wasm_pack_binary_install::Cache; /// Get the path to an existing `chromedriver`, or install it if no existing /// binary is found. diff --git a/tests/all/bindgen.rs b/tests/all/bindgen.rs index 985a4d0..e1077c5 100644 --- a/tests/all/bindgen.rs +++ b/tests/all/bindgen.rs @@ -1,6 +1,6 @@ use tempfile; -use wasm_pack::binaries::Cache; use wasm_pack::bindgen; +use wasm_pack_binary_install::Cache; #[test] #[cfg(any( diff --git a/tests/all/main.rs b/tests/all/main.rs index 563424d..572d655 100644 --- a/tests/all/main.rs +++ b/tests/all/main.rs @@ -9,6 +9,7 @@ extern crate slog; extern crate structopt; extern crate tempfile; extern crate wasm_pack; +extern crate wasm_pack_binary_install; mod bindgen; mod build; diff --git a/tests/all/utils/fixture.rs b/tests/all/utils/fixture.rs index 51331b6..0596873 100644 --- a/tests/all/utils/fixture.rs +++ b/tests/all/utils/fixture.rs @@ -8,7 +8,7 @@ use std::sync::{MutexGuard, Once, ONCE_INIT}; use std::thread; use tempfile::TempDir; use wasm_pack; -use wasm_pack::binaries::Cache; +use wasm_pack_binary_install::Cache; /// A test fixture in a temporary directory. pub struct Fixture { diff --git a/tests/all/webdriver.rs b/tests/all/webdriver.rs index f57c275..c0bbaa5 100644 --- a/tests/all/webdriver.rs +++ b/tests/all/webdriver.rs @@ -1,6 +1,6 @@ use utils::fixture; -use wasm_pack::binaries::Cache; use wasm_pack::test::webdriver; +use wasm_pack_binary_install::Cache; #[test] #[cfg(any(