add target arg to publish

master
csmoe 6 years ago
parent ddd93481c3
commit 95268cdaf4
  1. 541
      Cargo.lock
  2. 10
      src/command/build.rs
  3. 12
      src/command/mod.rs
  4. 3
      src/command/publish/mod.rs
  5. 6
      src/logger.rs

541
Cargo.lock generated

File diff suppressed because it is too large Load Diff

@ -111,11 +111,11 @@ pub struct BuildOptions {
#[structopt(long = "release")]
/// Create a release build. Enable optimizations and disable debug info.
release: bool,
pub release: bool,
#[structopt(long = "profiling")]
/// Create a profiling build. Enable optimizations and debug info.
profiling: bool,
pub profiling: bool,
#[structopt(long = "out-dir", short = "d", default_value = "pkg")]
/// Sets the output directory with a relative path.
@ -129,10 +129,12 @@ impl Default for BuildOptions {
scope: None,
mode: BuildMode::Normal,
disable_dts: false,
target: String::from("browser"),
target: String::new(),
debug: false,
dev: false,
out_dir: String::from("pkg"),
release: false,
profiling: false,
out_dir: String::new(),
}
}
}

@ -36,6 +36,10 @@ pub enum Command {
#[structopt(name = "publish")]
/// 🎆 pack up your npm package and publish!
Publish {
#[structopt(long = "target", short = "t", default_value = "browser")]
/// Sets the target environment. [possible values: browser, nodejs, no-modules]
target: String,
/// The access level for the package to be published
#[structopt(long = "access", short = "a")]
access: Option<Access>,
@ -96,10 +100,14 @@ pub fn run_wasm_pack(command: Command, log: &Logger) -> result::Result<(), Error
info!(&log, "Path: {:?}", &path);
pack(path, &log)
}
Command::Publish { path, access } => {
Command::Publish {
target,
path,
access,
} => {
info!(&log, "Running publish command...");
info!(&log, "Path: {:?}", &path);
publish(path, access, &log)
publish(target, path, access, &log)
}
Command::Login {
registry,

@ -15,6 +15,7 @@ use PBAR;
/// Creates a tarball from a 'pkg' directory
/// and publishes it to the NPM registry
pub fn publish(
target: String,
path: Option<PathBuf>,
access: Option<Access>,
log: &Logger,
@ -40,7 +41,7 @@ pub fn publish(
.interact()?;
let target = Input::new()
.with_prompt("target")
.default("browser".to_string())
.default(target)
.show_default(true)
.interact()?
.to_string();

@ -38,7 +38,11 @@ fn log_file_path(cmd: &Command) -> PathBuf {
let path = match cmd {
Command::Build(build_opts) => &build_opts.path,
Command::Pack { path } => path,
Command::Publish { path, access: _ } => path,
Command::Publish {
target: _,
path,
access: _,
} => path,
Command::Test(test_opts) => &test_opts.path,
Command::Login { .. } => &None,
};

Loading…
Cancel
Save