Skip to content

Commit

Permalink
cmd(build/init): deprecate init
Browse files Browse the repository at this point in the history
  • Loading branch information
csmoe committed Jul 27, 2018
1 parent 02e539d commit b8ce2b4
Show file tree
Hide file tree
Showing 7 changed files with 14 additions and 157 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ visiting that repo!

## 🎙️ Commands

- [`init`](docs/init.md): Initialize an npm wasm pkg from a rustwasm crate
- [`init`](docs/init.md): [**Deprecated**] Initialize an npm wasm pkg from a rustwasm crate
- [`build`](docs/build.md): Generate an npm wasm pkg from a rustwasm crate
- [`pack`](docs/pack.md): Create a tarball of your rustwasm pkg
- [`publish`](docs/publish.md): Publish your rustwasm pkg to a registry
Expand Down
2 changes: 1 addition & 1 deletion docs/init.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# wasm-pack init
# wasm-pack init(Deprecated)

The `wasm-pack init` command creates the files neccessary for JavaScript
interoperability and for publishing a package to npm. This involves
Expand Down
138 changes: 0 additions & 138 deletions src/command/init.rs

This file was deleted.

12 changes: 1 addition & 11 deletions src/command/mod.rs
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
//! CLI command structures, parsing, and execution.

mod build;
pub mod init;
mod login;
mod pack;
mod publish;
pub mod utils;

use self::build::{Build, BuildMode, BuildOptions};
use self::init::{Init, InitOptions};
use self::login::login;
use self::pack::pack;
use self::publish::publish;
Expand All @@ -21,12 +19,8 @@ use PBAR;
/// The various kinds of commands that `wasm-pack` can execute.
#[derive(Debug, StructOpt)]
pub enum Command {
#[structopt(name = "init")]
/// 🐣 initialize a package.json based on your compiled wasm!
Init(InitOptions),

/// 🏗️ build your npm package!
#[structopt(name = "build")]
#[structopt(name = "build", alias = "init")]
Build(BuildOptions),

#[structopt(name = "pack")]
Expand Down Expand Up @@ -83,10 +77,6 @@ pub fn run_wasm_pack(command: Command, log: &Logger) -> result::Result<(), Error
// Run the correct command based off input and store the result of it so that we can clear
// the progress bar then return it
let status = match command {
Command::Init(init_opts) => {
info!(&log, "Running init command...");
Init::from(init_opts).run(&log)
}
Command::Build(build_opts) => {
info!(&log, "Running build command...");
let build_mode = match build_opts.mode.as_str() {
Expand Down
1 change: 0 additions & 1 deletion src/logger.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ pub fn new(cmd: &Command, verbosity: u8) -> Result<Logger, Error> {
/// Figure out where to stick the log based off the command arguments given
fn log_file_path(cmd: &Command) -> PathBuf {
let path = match cmd {
Command::Init(init_opts) => &init_opts.path,
Command::Build(build_opts) => &build_opts.path,
Command::Pack { path } => path,
Command::Publish { path } => path,
Expand Down
6 changes: 6 additions & 0 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ extern crate structopt;
extern crate wasm_pack;

use failure::Fail;
use std::env;
use structopt::StructOpt;
use wasm_pack::{command::run_wasm_pack, error::Error, logger, Cli};

Expand All @@ -20,6 +21,11 @@ fn main() {
}

fn run() -> Result<(), Error> {
// Deprecate `init`
if let Some("init") = env::args().nth(1).as_ref().map(|arg| arg.as_str()) {
println!("wasm-pack init is deprecated, consider using wasm-pack build");
}

let args = Cli::from_args();
let log = logger::new(&args.cmd, args.verbosity)?;
run_wasm_pack(args.cmd, &log)?;
Expand Down
10 changes: 5 additions & 5 deletions tests/all/manifest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ fn it_recognizes_a_map_during_depcheck() {
fn it_creates_a_package_json_default_path() {
let fixture = utils::fixture(".");
let step = wasm_pack::progressbar::Step::new(1);
wasm_pack::command::init::create_pkg_dir(&fixture.path, &step).unwrap();
wasm_pack::command::utils::create_pkg_dir(&fixture.path, &step).unwrap();
assert!(manifest::write_package_json(&fixture.path, &None, false, "", &step).is_ok());
let package_json_path = &fixture.path.join("pkg").join("package.json");
assert!(fs::metadata(package_json_path).is_ok());
Expand Down Expand Up @@ -83,7 +83,7 @@ fn it_creates_a_package_json_default_path() {
fn it_creates_a_package_json_provided_path() {
let fixture = utils::fixture("tests/fixtures/js-hello-world");
let step = wasm_pack::progressbar::Step::new(1);
wasm_pack::command::init::create_pkg_dir(&fixture.path, &step).unwrap();
wasm_pack::command::utils::create_pkg_dir(&fixture.path, &step).unwrap();
assert!(manifest::write_package_json(&fixture.path, &None, false, "", &step).is_ok());
let package_json_path = &fixture.path.join("pkg").join("package.json");
assert!(fs::metadata(package_json_path).is_ok());
Expand All @@ -104,7 +104,7 @@ fn it_creates_a_package_json_provided_path() {
fn it_creates_a_package_json_provided_path_with_scope() {
let fixture = utils::fixture("tests/fixtures/scopes");
let step = wasm_pack::progressbar::Step::new(1);
wasm_pack::command::init::create_pkg_dir(&fixture.path, &step).unwrap();
wasm_pack::command::utils::create_pkg_dir(&fixture.path, &step).unwrap();
assert!(
manifest::write_package_json(&fixture.path, &Some("test".to_string()), false, "", &step)
.is_ok()
Expand All @@ -128,7 +128,7 @@ fn it_creates_a_package_json_provided_path_with_scope() {
fn it_creates_a_pkg_json_with_correct_files_on_node() {
let fixture = utils::fixture(".");
let step = wasm_pack::progressbar::Step::new(1);
wasm_pack::command::init::create_pkg_dir(&fixture.path, &step).unwrap();
wasm_pack::command::utils::create_pkg_dir(&fixture.path, &step).unwrap();
assert!(manifest::write_package_json(&fixture.path, &None, false, "nodejs", &step).is_ok());
let package_json_path = &fixture.path.join("pkg").join("package.json");
assert!(fs::metadata(package_json_path).is_ok());
Expand Down Expand Up @@ -157,7 +157,7 @@ fn it_creates_a_pkg_json_with_correct_files_on_node() {
fn it_creates_a_package_json_with_correct_keys_when_types_are_skipped() {
let fixture = utils::fixture(".");
let step = wasm_pack::progressbar::Step::new(1);
wasm_pack::command::init::create_pkg_dir(&fixture.path, &step).unwrap();
wasm_pack::command::utils::create_pkg_dir(&fixture.path, &step).unwrap();
assert!(manifest::write_package_json(&fixture.path, &None, true, "", &step).is_ok());
let package_json_path = &fixture.path.join("pkg").join("package.json");
assert!(fs::metadata(package_json_path).is_ok());
Expand Down

0 comments on commit b8ce2b4

Please sign in to comment.