Skip to content

Commit fcbb1f0

Browse files
committed
cmd(init/build): deprecated init
1 parent 02e539d commit fcbb1f0

File tree

6 files changed

+9
-152
lines changed

6 files changed

+9
-152
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)?;

0 commit comments

Comments
 (0)