Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: Move binary installation to it's own crate #415

Merged
merged 24 commits into from
Dec 28, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
a4b29a9
refactor: Move binary installation to it's own crate
drager Oct 15, 2018
ac70220
Remove authors from binary-install Cargo.toml
drager Oct 15, 2018
16a169b
fix: Exclude target so tests works
drager Oct 29, 2018
23e902b
Merge branch 'master' into refactor-binary-installation
drager Oct 29, 2018
65d060c
chore: Run latest rustfmt
drager Oct 29, 2018
69ee13b
test: Add tests for path functions
drager Oct 29, 2018
57e00f8
Merge branch 'master' into refactor-binary-installation
drager Oct 30, 2018
8150ba3
chore: Run cargo update
drager Oct 30, 2018
70df15f
test: Rework and rename path tests
drager Oct 30, 2018
37dac09
test: More tests for path functions as well as minor fixes
drager Oct 31, 2018
10080c2
fix: not(target_os = "windows")
drager Oct 31, 2018
d5faedd
test: Add initial tests for exposed functions in lib
drager Nov 1, 2018
98b405c
refactor: Use env::temp_dir() instead of current_dir() for tests
drager Nov 3, 2018
fa68a0d
test: Create and return tarball in tests, add more test cases
drager Nov 5, 2018
b15f062
Merge branch 'master' into refactor-binary-installation
drager Nov 6, 2018
714a8a1
refactor: Remove unneeded code, since master has changed a lot
drager Nov 6, 2018
50e472d
chore: Remove unused crates and error variants
drager Nov 6, 2018
489d3e8
refactor: Rename binary-install to wasm-pack-binary-install
drager Nov 6, 2018
a558ea5
Merge branch 'master' into refactor-binary-installation
drager Nov 6, 2018
b47dfa3
chore: Run latest rustfmt
drager Nov 7, 2018
99b9602
chore: Run latest rustfmt
drager Nov 7, 2018
7f38ccf
Merge branch 'master' into refactor-binary-installation
drager Nov 15, 2018
a2235e5
Merge branch 'master' into refactor-binary-installation
drager Dec 28, 2018
28f67e7
Merge branch 'master' into refactor-binary-installation
drager Dec 28, 2018
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 14 additions & 6 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 1 addition & 7 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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"
Expand Down
13 changes: 13 additions & 0 deletions binary-install/Cargo.toml
Original file line number Diff line number Diff line change
@@ -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"
19 changes: 11 additions & 8 deletions src/binaries.rs → binary-install/src/lib.rs
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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.
Expand All @@ -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))
}

Expand Down
2 changes: 1 addition & 1 deletion src/bindgen.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
//! Functionality related to installing and running `wasm-bindgen`.

use binaries::{Cache, Download};
use child;
use command::build::BuildProfile;
use emoji;
Expand All @@ -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;

Expand Down
2 changes: 1 addition & 1 deletion src/command/build.rs
Original file line number Diff line number Diff line change
@@ -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};
Expand All @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion src/command/test.rs
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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)]
Expand Down
13 changes: 3 additions & 10 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/test/webdriver.rs
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
2 changes: 1 addition & 1 deletion tests/all/bindgen.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use tempfile;
use wasm_pack::binaries::Cache;
use wasm_pack::bindgen;
use wasm_pack_binary_install::Cache;

#[test]
#[cfg(any(
Expand Down
1 change: 1 addition & 0 deletions tests/all/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion tests/all/utils/fixture.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion tests/all/webdriver.rs
Original file line number Diff line number Diff line change
@@ -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(
Expand Down