Skip to content

Commit b8ce2b4

Browse files
committed
cmd(build/init): deprecate init
1 parent 02e539d commit b8ce2b4

File tree

7 files changed

+14
-157
lines changed

7 files changed

+14
-157
lines changed

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ visiting that repo!
3030

3131
## 🎙️ Commands
3232

33-
- [`init`](docs/init.md): Initialize an npm wasm pkg from a rustwasm crate
33+
- [`init`](docs/init.md): [**Deprecated**] Initialize an npm wasm pkg from a rustwasm crate
3434
- [`build`](docs/build.md): Generate an npm wasm pkg from a rustwasm crate
3535
- [`pack`](docs/pack.md): Create a tarball of your rustwasm pkg
3636
- [`publish`](docs/publish.md): Publish your rustwasm pkg to a registry

docs/init.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# wasm-pack init
1+
# wasm-pack init(Deprecated)
22

33
The `wasm-pack init` command creates the files neccessary for JavaScript
44
interoperability and for publishing a package to npm. This involves

src/command/init.rs

-138
This file was deleted.

src/command/mod.rs

+1-11
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,12 @@
11
//! CLI command structures, parsing, and execution.
22
33
mod build;
4-
pub mod init;
54
mod login;
65
mod pack;
76
mod publish;
87
pub mod utils;
98

109
use self::build::{Build, BuildMode, BuildOptions};
11-
use self::init::{Init, InitOptions};
1210
use self::login::login;
1311
use self::pack::pack;
1412
use self::publish::publish;
@@ -21,12 +19,8 @@ use PBAR;
2119
/// The various kinds of commands that `wasm-pack` can execute.
2220
#[derive(Debug, StructOpt)]
2321
pub enum Command {
24-
#[structopt(name = "init")]
25-
/// 🐣 initialize a package.json based on your compiled wasm!
26-
Init(InitOptions),
27-
2822
/// 🏗️ build your npm package!
29-
#[structopt(name = "build")]
23+
#[structopt(name = "build", alias = "init")]
3024
Build(BuildOptions),
3125

3226
#[structopt(name = "pack")]
@@ -83,10 +77,6 @@ pub fn run_wasm_pack(command: Command, log: &Logger) -> result::Result<(), Error
8377
// Run the correct command based off input and store the result of it so that we can clear
8478
// the progress bar then return it
8579
let status = match command {
86-
Command::Init(init_opts) => {
87-
info!(&log, "Running init command...");
88-
Init::from(init_opts).run(&log)
89-
}
9080
Command::Build(build_opts) => {
9181
info!(&log, "Running build command...");
9282
let build_mode = match build_opts.mode.as_str() {

src/logger.rs

-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ pub fn new(cmd: &Command, verbosity: u8) -> Result<Logger, Error> {
3333
/// Figure out where to stick the log based off the command arguments given
3434
fn log_file_path(cmd: &Command) -> PathBuf {
3535
let path = match cmd {
36-
Command::Init(init_opts) => &init_opts.path,
3736
Command::Build(build_opts) => &build_opts.path,
3837
Command::Pack { path } => path,
3938
Command::Publish { path } => path,

src/main.rs

+6
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ extern crate structopt;
55
extern crate wasm_pack;
66

77
use failure::Fail;
8+
use std::env;
89
use structopt::StructOpt;
910
use wasm_pack::{command::run_wasm_pack, error::Error, logger, Cli};
1011

@@ -20,6 +21,11 @@ fn main() {
2021
}
2122

2223
fn run() -> Result<(), Error> {
24+
// Deprecate `init`
25+
if let Some("init") = env::args().nth(1).as_ref().map(|arg| arg.as_str()) {
26+
println!("wasm-pack init is deprecated, consider using wasm-pack build");
27+
}
28+
2329
let args = Cli::from_args();
2430
let log = logger::new(&args.cmd, args.verbosity)?;
2531
run_wasm_pack(args.cmd, &log)?;

tests/all/manifest.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ fn it_recognizes_a_map_during_depcheck() {
5555
fn it_creates_a_package_json_default_path() {
5656
let fixture = utils::fixture(".");
5757
let step = wasm_pack::progressbar::Step::new(1);
58-
wasm_pack::command::init::create_pkg_dir(&fixture.path, &step).unwrap();
58+
wasm_pack::command::utils::create_pkg_dir(&fixture.path, &step).unwrap();
5959
assert!(manifest::write_package_json(&fixture.path, &None, false, "", &step).is_ok());
6060
let package_json_path = &fixture.path.join("pkg").join("package.json");
6161
assert!(fs::metadata(package_json_path).is_ok());
@@ -83,7 +83,7 @@ fn it_creates_a_package_json_default_path() {
8383
fn it_creates_a_package_json_provided_path() {
8484
let fixture = utils::fixture("tests/fixtures/js-hello-world");
8585
let step = wasm_pack::progressbar::Step::new(1);
86-
wasm_pack::command::init::create_pkg_dir(&fixture.path, &step).unwrap();
86+
wasm_pack::command::utils::create_pkg_dir(&fixture.path, &step).unwrap();
8787
assert!(manifest::write_package_json(&fixture.path, &None, false, "", &step).is_ok());
8888
let package_json_path = &fixture.path.join("pkg").join("package.json");
8989
assert!(fs::metadata(package_json_path).is_ok());
@@ -104,7 +104,7 @@ fn it_creates_a_package_json_provided_path() {
104104
fn it_creates_a_package_json_provided_path_with_scope() {
105105
let fixture = utils::fixture("tests/fixtures/scopes");
106106
let step = wasm_pack::progressbar::Step::new(1);
107-
wasm_pack::command::init::create_pkg_dir(&fixture.path, &step).unwrap();
107+
wasm_pack::command::utils::create_pkg_dir(&fixture.path, &step).unwrap();
108108
assert!(
109109
manifest::write_package_json(&fixture.path, &Some("test".to_string()), false, "", &step)
110110
.is_ok()
@@ -128,7 +128,7 @@ fn it_creates_a_package_json_provided_path_with_scope() {
128128
fn it_creates_a_pkg_json_with_correct_files_on_node() {
129129
let fixture = utils::fixture(".");
130130
let step = wasm_pack::progressbar::Step::new(1);
131-
wasm_pack::command::init::create_pkg_dir(&fixture.path, &step).unwrap();
131+
wasm_pack::command::utils::create_pkg_dir(&fixture.path, &step).unwrap();
132132
assert!(manifest::write_package_json(&fixture.path, &None, false, "nodejs", &step).is_ok());
133133
let package_json_path = &fixture.path.join("pkg").join("package.json");
134134
assert!(fs::metadata(package_json_path).is_ok());
@@ -157,7 +157,7 @@ fn it_creates_a_pkg_json_with_correct_files_on_node() {
157157
fn it_creates_a_package_json_with_correct_keys_when_types_are_skipped() {
158158
let fixture = utils::fixture(".");
159159
let step = wasm_pack::progressbar::Step::new(1);
160-
wasm_pack::command::init::create_pkg_dir(&fixture.path, &step).unwrap();
160+
wasm_pack::command::utils::create_pkg_dir(&fixture.path, &step).unwrap();
161161
assert!(manifest::write_package_json(&fixture.path, &None, true, "", &step).is_ok());
162162
let package_json_path = &fixture.path.join("pkg").join("package.json");
163163
assert!(fs::metadata(package_json_path).is_ok());

0 commit comments

Comments
 (0)