diff --git a/Cargo.toml b/Cargo.toml index ca44075..2f43ab3 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -5,6 +5,7 @@ version = "0.10.3" authors = ["Ashley Williams ", "Jesper HÃ¥kansson "] repository = "https://github.com/rustwasm/wasm-pack.git" license = "MIT OR Apache-2.0" +edition = "2021" readme = "README.md" categories = ["wasm"] documentation = "https://rustwasm.github.io/wasm-pack/" diff --git a/src/bindgen.rs b/src/bindgen.rs index db0342f..441ae25 100644 --- a/src/bindgen.rs +++ b/src/bindgen.rs @@ -1,10 +1,10 @@ //! Functionality related to running `wasm-bindgen`. +use crate::child; +use crate::command::build::{BuildProfile, Target}; +use crate::install::{self, Tool}; +use crate::manifest::CrateData; use anyhow::{bail, Context, Result}; -use child; -use command::build::{BuildProfile, Target}; -use install::{self, Tool}; -use manifest::CrateData; use semver; use std::path::Path; use std::process::Command; diff --git a/src/build/mod.rs b/src/build/mod.rs index a49432e..691ec49 100644 --- a/src/build/mod.rs +++ b/src/build/mod.rs @@ -1,14 +1,14 @@ //! Building a Rust crate into a `.wasm` binary. +use crate::child; +use crate::command::build::BuildProfile; +use crate::emoji; +use crate::manifest::Crate; +use crate::PBAR; use anyhow::{bail, Context, Result}; -use child; -use command::build::BuildProfile; -use emoji; -use manifest::Crate; use std::path::Path; use std::process::Command; use std::str; -use PBAR; pub mod wasm_target; diff --git a/src/build/wasm_target.rs b/src/build/wasm_target.rs index 6105470..8631086 100644 --- a/src/build/wasm_target.rs +++ b/src/build/wasm_target.rs @@ -1,13 +1,13 @@ //! Checking for the wasm32 target +use crate::child; +use crate::emoji; +use crate::PBAR; use anyhow::{anyhow, bail, Context, Result}; -use child; -use emoji; use log::info; use std::fmt; use std::path::{Path, PathBuf}; use std::process::Command; -use PBAR; struct Wasm32Check { rustc_path: PathBuf, diff --git a/src/child.rs b/src/child.rs index 742a186..7b8a58c 100644 --- a/src/child.rs +++ b/src/child.rs @@ -3,8 +3,8 @@ //! This module helps us ensure that all child processes that we spawn get //! properly logged and their output is logged as well. +use crate::install::Tool; use anyhow::{bail, Result}; -use install::Tool; use log::info; use std::process::{Command, Stdio}; diff --git a/src/command/build.rs b/src/command/build.rs index c1b63c4..4447e34 100644 --- a/src/command/build.rs +++ b/src/command/build.rs @@ -1,25 +1,25 @@ //! Implementation of the `wasm-pack build` command. +use crate::bindgen; +use crate::build; +use crate::cache; +use crate::command::utils::{create_pkg_dir, get_crate_path}; +use crate::emoji; +use crate::install::{self, InstallMode, Tool}; +use crate::license; +use crate::lockfile::Lockfile; +use crate::manifest; +use crate::readme; use crate::wasm_opt; +use crate::PBAR; use anyhow::{anyhow, bail, Error, Result}; use binary_install::Cache; -use bindgen; -use build; -use cache; -use command::utils::{create_pkg_dir, get_crate_path}; -use emoji; -use install::{self, InstallMode, Tool}; -use license; -use lockfile::Lockfile; use log::info; -use manifest; -use readme; use std::fmt; use std::path::PathBuf; use std::str::FromStr; use std::time::Instant; use structopt::clap::AppSettings; -use PBAR; /// Everything required to configure and run the `wasm-pack build` command. #[allow(missing_docs)] diff --git a/src/command/generate.rs b/src/command/generate.rs index 2f72186..609a0b5 100644 --- a/src/command/generate.rs +++ b/src/command/generate.rs @@ -1,9 +1,9 @@ +use crate::cache; +use crate::generate; +use crate::install::{self, Tool}; +use crate::PBAR; use anyhow::Result; -use cache; -use generate; -use install::{self, Tool}; use log::info; -use PBAR; /// Executes the 'cargo-generate' command in the current directory /// which generates a new rustwasm project from a template. diff --git a/src/command/login.rs b/src/command/login.rs index f24156d..817ae16 100644 --- a/src/command/login.rs +++ b/src/command/login.rs @@ -1,7 +1,7 @@ +use crate::npm; +use crate::PBAR; use anyhow::Result; use log::info; -use npm; -use PBAR; pub fn login( registry: Option, diff --git a/src/command/pack.rs b/src/command/pack.rs index 6b3da04..2c89108 100644 --- a/src/command/pack.rs +++ b/src/command/pack.rs @@ -1,9 +1,9 @@ +use crate::command::utils::{find_pkg_directory, get_crate_path}; +use crate::npm; +use crate::PBAR; use anyhow::{anyhow, Result}; -use command::utils::{find_pkg_directory, get_crate_path}; use log::info; -use npm; use std::path::PathBuf; -use PBAR; /// Executes the 'npm pack' command on the 'pkg' directory /// which creates a tarball that can be published to the NPM registry diff --git a/src/command/publish/mod.rs b/src/command/publish/mod.rs index 8d0374a..92c6f3f 100644 --- a/src/command/publish/mod.rs +++ b/src/command/publish/mod.rs @@ -2,15 +2,15 @@ pub mod access; use self::access::Access; +use crate::command::build::{Build, BuildOptions, Target}; +use crate::command::utils::{find_pkg_directory, get_crate_path}; +use crate::npm; +use crate::PBAR; use anyhow::{anyhow, bail, Result}; -use command::build::{Build, BuildOptions, Target}; -use command::utils::{find_pkg_directory, get_crate_path}; use dialoguer::{Confirm, Input, Select}; use log::info; -use npm; use std::path::PathBuf; use std::str::FromStr; -use PBAR; /// Creates a tarball from a 'pkg' directory /// and publishes it to the NPM registry diff --git a/src/command/test.rs b/src/command/test.rs index 8fc0a85..eed92eb 100644 --- a/src/command/test.rs +++ b/src/command/test.rs @@ -1,20 +1,20 @@ //! Implementation of the `wasm-pack test` command. +use crate::build; +use crate::cache; +use crate::command::utils::get_crate_path; +use crate::install::{self, InstallMode, Tool}; +use crate::lockfile::Lockfile; +use crate::manifest; +use crate::test::{self, webdriver}; use anyhow::{bail, Result}; use binary_install::Cache; -use build; -use cache; -use command::utils::get_crate_path; use console::style; -use install::{self, InstallMode, Tool}; -use lockfile::Lockfile; use log::info; -use manifest; use std::path::PathBuf; use std::str::FromStr; use std::time::Instant; use structopt::clap::AppSettings; -use test::{self, webdriver}; #[derive(Debug, Default, StructOpt)] #[structopt( diff --git a/src/generate.rs b/src/generate.rs index 552618f..660f123 100644 --- a/src/generate.rs +++ b/src/generate.rs @@ -1,9 +1,9 @@ //! Functionality related to running `cargo-generate`. +use crate::child; +use crate::emoji; +use crate::install::{self, Tool}; use anyhow::{Context, Result}; -use child; -use emoji; -use install::{self, Tool}; use std::process::Command; /// Run `cargo generate` in the current directory to create a new diff --git a/src/install/krate.rs b/src/install/krate.rs index 321b74b..4ac2fac 100644 --- a/src/install/krate.rs +++ b/src/install/krate.rs @@ -1,5 +1,5 @@ +use crate::install::Tool; use anyhow::Result; -use install::Tool; use serde::Deserialize; #[derive(Debug, Deserialize)] diff --git a/src/install/mod.rs b/src/install/mod.rs index c54f392..6debacc 100644 --- a/src/install/mod.rs +++ b/src/install/mod.rs @@ -1,11 +1,12 @@ //! Functionality related to installing prebuilt binaries and/or running cargo install. use self::krate::Krate; +use crate::child; +use crate::emoji; +use crate::install; +use crate::PBAR; use anyhow::{anyhow, bail, Context, Result}; use binary_install::{Cache, Download}; -use child; -use emoji; -use install; use log::debug; use log::{info, warn}; use std::env; @@ -13,7 +14,6 @@ use std::fs; use std::path::Path; use std::process::Command; use which::which; -use PBAR; mod arch; mod krate; diff --git a/src/lib.rs b/src/lib.rs index db0ecf8..8410b48 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -44,7 +44,7 @@ pub mod target; pub mod test; pub mod wasm_opt; -use progressbar::{LogLevel, ProgressOutput}; +use crate::progressbar::{LogLevel, ProgressOutput}; /// The global progress bar and user-facing message output. pub static PBAR: ProgressOutput = ProgressOutput::new(); diff --git a/src/license.rs b/src/license.rs index c804853..5305e41 100644 --- a/src/license.rs +++ b/src/license.rs @@ -4,9 +4,9 @@ use anyhow::{anyhow, Result}; use std::fs; use std::path::Path; +use crate::manifest::CrateData; +use crate::PBAR; use glob::glob; -use manifest::CrateData; -use PBAR; fn glob_license_files(path: &Path) -> Result> { let mut license_files: Vec = Vec::new(); diff --git a/src/lockfile.rs b/src/lockfile.rs index 18ab37e..44cb103 100644 --- a/src/lockfile.rs +++ b/src/lockfile.rs @@ -5,9 +5,9 @@ use std::fs; use std::path::PathBuf; +use crate::manifest::CrateData; use anyhow::{anyhow, bail, Context, Result}; use console::style; -use manifest::CrateData; use toml; /// This struct represents the contents of `Cargo.lock`. diff --git a/src/manifest/mod.rs b/src/manifest/mod.rs index 7614c90..e94fc80 100644 --- a/src/manifest/mod.rs +++ b/src/manifest/mod.rs @@ -15,10 +15,11 @@ use std::{collections::HashMap, fs}; use self::npm::{ repository::Repository, CommonJSPackage, ESModulesPackage, NoModulesPackage, NpmPackage, }; +use crate::command::build::{BuildProfile, Target}; +use crate::PBAR; use cargo_metadata::Metadata; use chrono::offset; use chrono::DateTime; -use command::build::{BuildProfile, Target}; use curl::easy; use serde::{self, Deserialize}; use serde_json; @@ -27,7 +28,6 @@ use std::env; use std::io::Write; use strsim::levenshtein; use toml; -use PBAR; const WASM_PACK_METADATA_KEY: &str = "package.metadata.wasm-pack"; const WASM_PACK_VERSION: Option<&'static str> = option_env!("CARGO_PKG_VERSION"); diff --git a/src/manifest/npm/commonjs.rs b/src/manifest/npm/commonjs.rs index eaf681d..29433ad 100644 --- a/src/manifest/npm/commonjs.rs +++ b/src/manifest/npm/commonjs.rs @@ -1,6 +1,6 @@ use std::collections::HashMap; -use manifest::npm::repository::Repository; +use crate::manifest::npm::repository::Repository; #[derive(Serialize)] pub struct CommonJSPackage { diff --git a/src/manifest/npm/esmodules.rs b/src/manifest/npm/esmodules.rs index b3b541b..2501a6c 100644 --- a/src/manifest/npm/esmodules.rs +++ b/src/manifest/npm/esmodules.rs @@ -1,6 +1,6 @@ use std::collections::HashMap; -use manifest::npm::repository::Repository; +use crate::manifest::npm::repository::Repository; #[derive(Serialize)] pub struct ESModulesPackage { diff --git a/src/manifest/npm/nomodules.rs b/src/manifest/npm/nomodules.rs index 20567cc..ed2e016 100644 --- a/src/manifest/npm/nomodules.rs +++ b/src/manifest/npm/nomodules.rs @@ -1,6 +1,6 @@ use std::collections::HashMap; -use manifest::npm::repository::Repository; +use crate::manifest::npm::repository::Repository; #[derive(Serialize)] pub struct NoModulesPackage { diff --git a/src/npm.rs b/src/npm.rs index 48a768f..7c4f08b 100644 --- a/src/npm.rs +++ b/src/npm.rs @@ -1,8 +1,8 @@ //! Functionality related to publishing to npm. +use crate::child; +use crate::command::publish::access::Access; use anyhow::{bail, Context, Result}; -use child; -use command::publish::access::Access; use log::info; /// The default npm registry used when we aren't working with a custom registry. diff --git a/src/progressbar.rs b/src/progressbar.rs index c4a96e4..330b7f9 100644 --- a/src/progressbar.rs +++ b/src/progressbar.rs @@ -1,8 +1,8 @@ //! Fancy progress bar functionality. +use crate::emoji; use anyhow::{bail, Error, Result}; use console::style; -use emoji; use std::sync::atomic::{AtomicBool, AtomicU8, Ordering}; #[repr(u8)] diff --git a/src/readme.rs b/src/readme.rs index b8d5e8e..c98cdc0 100644 --- a/src/readme.rs +++ b/src/readme.rs @@ -4,7 +4,7 @@ use anyhow::{Context, Result}; use std::fs; use std::path::Path; -use PBAR; +use crate::PBAR; /// Copy the crate's README into the `pkg` directory. pub fn copy_from_crate(path: &Path, out_dir: &Path) -> Result<()> { diff --git a/src/test/mod.rs b/src/test/mod.rs index 05ba4fc..1fbe920 100644 --- a/src/test/mod.rs +++ b/src/test/mod.rs @@ -2,9 +2,9 @@ pub mod webdriver; +use crate::child; use crate::PBAR; use anyhow::{Context, Result}; -use child; use std::ffi::OsStr; use std::path::Path; use std::process::Command; diff --git a/src/test/webdriver.rs b/src/test/webdriver.rs index 3b9ece9..fe77bfd 100644 --- a/src/test/webdriver.rs +++ b/src/test/webdriver.rs @@ -4,10 +4,10 @@ mod chromedriver; mod geckodriver; mod safaridriver; +use crate::PBAR; use anyhow::Result; use binary_install::Cache; use std::path::PathBuf; -use PBAR; pub use self::{ chromedriver::{get_or_install_chromedriver, install_chromedriver}, diff --git a/src/test/webdriver/chromedriver.rs b/src/test/webdriver/chromedriver.rs index 67e1928..c1d6397 100644 --- a/src/test/webdriver/chromedriver.rs +++ b/src/test/webdriver/chromedriver.rs @@ -1,11 +1,11 @@ use super::{get_and_notify, Collector}; +use crate::install::InstallMode; +use crate::stamps; +use crate::target; use anyhow::{bail, Context, Result}; use binary_install::Cache; use chrono::DateTime; -use install::InstallMode; -use stamps; use std::path::PathBuf; -use target; // Keep it up to date with each `wasm-pack` release. // https://chromedriver.storage.googleapis.com/LATEST_RELEASE diff --git a/src/test/webdriver/geckodriver.rs b/src/test/webdriver/geckodriver.rs index 1a8ee80..fc51b81 100644 --- a/src/test/webdriver/geckodriver.rs +++ b/src/test/webdriver/geckodriver.rs @@ -1,11 +1,11 @@ use super::{get_and_notify, Collector}; +use crate::install::InstallMode; +use crate::stamps; +use crate::target; use anyhow::{anyhow, bail, Context, Result}; use binary_install::Cache; use chrono::DateTime; -use install::InstallMode; -use stamps; use std::path::PathBuf; -use target; // Keep it up to date with each `wasm-pack` release. // https://github.com/mozilla/geckodriver/releases/latest diff --git a/tests/all/build.rs b/tests/all/build.rs index 4524498..6c42b48 100644 --- a/tests/all/build.rs +++ b/tests/all/build.rs @@ -1,7 +1,7 @@ +use crate::utils; use assert_cmd::prelude::*; use std::fs; use std::path::Path; -use utils; #[test] fn build_in_non_crate_directory_doesnt_panic() { diff --git a/tests/all/generate.rs b/tests/all/generate.rs index 4194942..b2f695e 100644 --- a/tests/all/generate.rs +++ b/tests/all/generate.rs @@ -1,5 +1,5 @@ +use crate::utils; use assert_cmd::prelude::*; -use utils; #[test] fn new_with_no_name_errors() { diff --git a/tests/all/license.rs b/tests/all/license.rs index 8869db8..ae0a6a7 100644 --- a/tests/all/license.rs +++ b/tests/all/license.rs @@ -3,7 +3,7 @@ extern crate wasm_pack; use std::fs; -use utils::{self, fixture}; +use crate::utils::{self, fixture}; use wasm_pack::license; use wasm_pack::manifest::CrateData; diff --git a/tests/all/lockfile.rs b/tests/all/lockfile.rs index f7a8784..94b938b 100644 --- a/tests/all/lockfile.rs +++ b/tests/all/lockfile.rs @@ -1,4 +1,4 @@ -use utils::fixture; +use crate::utils::fixture; use wasm_pack::lockfile::Lockfile; use wasm_pack::manifest::CrateData; diff --git a/tests/all/log_level.rs b/tests/all/log_level.rs index 95a08ca..65f4634 100644 --- a/tests/all/log_level.rs +++ b/tests/all/log_level.rs @@ -1,9 +1,9 @@ +use crate::utils; use assert_cmd::prelude::*; use predicates::boolean::PredicateBooleanExt; use predicates::prelude::predicate::str::contains; use predicates::reflection::PredicateReflection; use predicates::Predicate; -use utils; fn matches_info() -> impl Predicate + PredicateReflection { contains("[INFO]: Checking for the Wasm target...") diff --git a/tests/all/manifest.rs b/tests/all/manifest.rs index c5f0fbf..a828bd1 100644 --- a/tests/all/manifest.rs +++ b/tests/all/manifest.rs @@ -1,8 +1,8 @@ +use crate::utils::{self, fixture}; use assert_cmd::prelude::*; use std::collections::{HashMap, HashSet}; use std::fs; use std::path::PathBuf; -use utils::{self, fixture}; use wasm_pack::command::build::Target; use wasm_pack::command::utils::get_crate_path; use wasm_pack::{self, license, manifest}; diff --git a/tests/all/readme.rs b/tests/all/readme.rs index a621631..cefb01f 100644 --- a/tests/all/readme.rs +++ b/tests/all/readme.rs @@ -3,7 +3,7 @@ extern crate wasm_pack; use std::fs; -use utils::{self, fixture}; +use crate::utils::{self, fixture}; use wasm_pack::readme; #[test] diff --git a/tests/all/test.rs b/tests/all/test.rs index 0113f76..c5bba4e 100644 --- a/tests/all/test.rs +++ b/tests/all/test.rs @@ -1,7 +1,7 @@ +use crate::utils::fixture; use assert_cmd::prelude::*; use predicates::prelude::*; use std::env; -use utils::fixture; #[test] fn it_can_run_node_tests() { diff --git a/tests/all/wasm_opt.rs b/tests/all/wasm_opt.rs index 142d587..68c0dc9 100644 --- a/tests/all/wasm_opt.rs +++ b/tests/all/wasm_opt.rs @@ -1,6 +1,6 @@ +use crate::utils; use assert_cmd::prelude::*; use predicates::prelude::*; -use utils; #[test] fn off_in_dev() { diff --git a/tests/all/webdriver.rs b/tests/all/webdriver.rs index cf081e7..3cd93c9 100644 --- a/tests/all/webdriver.rs +++ b/tests/all/webdriver.rs @@ -1,5 +1,5 @@ +use crate::utils::fixture; use binary_install::Cache; -use utils::fixture; use wasm_pack::test::webdriver; #[test]