|
|
|
@ -11,15 +11,26 @@ use std::io::prelude::*; |
|
|
|
|
/// 📦 ✨ pack and publish your wasm!
|
|
|
|
|
#[derive(Debug, StructOpt)] |
|
|
|
|
struct Cli { |
|
|
|
|
/// ☔ init and pack, but don't publish
|
|
|
|
|
#[structopt(long = "dry-run", short = "d")] |
|
|
|
|
dry_run: bool, |
|
|
|
|
|
|
|
|
|
#[structopt(subcommand)] // Note that we mark a field as a subcommand
|
|
|
|
|
cmd: Command, |
|
|
|
|
/// 📝 log all the things!
|
|
|
|
|
#[structopt(long = "verbose", short = "v", parse(from_occurrences))] |
|
|
|
|
verbosity: u8, |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
#[derive(Debug, StructOpt)] |
|
|
|
|
enum Command { |
|
|
|
|
#[structopt(name = "init")] |
|
|
|
|
/// 🐣 initialize a package.json based on your compiled wasm
|
|
|
|
|
Init {}, |
|
|
|
|
#[structopt(name = "pack")] |
|
|
|
|
/// 🍱 create a tar of your npm package but don't publish!
|
|
|
|
|
Pack {}, |
|
|
|
|
#[structopt(name = "publish")] |
|
|
|
|
/// 🎆 pack up your npm package and publish!
|
|
|
|
|
Publish {}, |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
#[derive(Deserialize)] |
|
|
|
|
pub struct CargoManifest { |
|
|
|
|
package: CargoPackage, |
|
|
|
@ -66,10 +77,15 @@ fn write_package_json() -> Result<()> { |
|
|
|
|
Ok(()) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
main!(|args: Cli, log_level: verbosity| { |
|
|
|
|
write_package_json()?; |
|
|
|
|
println!("✍️ wrote package.json"); |
|
|
|
|
if !args.dry_run { |
|
|
|
|
println!("⬆️ published pkg to npm"); |
|
|
|
|
main!(|args: Cli, log_level: verbosity| match args.cmd { |
|
|
|
|
Command::Init { .. } => { |
|
|
|
|
write_package_json()?; |
|
|
|
|
println!("✍️ wrote a package.json!"); |
|
|
|
|
} |
|
|
|
|
Command::Pack { .. } => { |
|
|
|
|
println!("🎒 packed up your pacakge!"); |
|
|
|
|
} |
|
|
|
|
Command::Publish { .. } => { |
|
|
|
|
println!("💥 published your package!"); |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|