Skip to content
This repository has been archived by the owner on Aug 3, 2023. It is now read-only.

Commit

Permalink
feat #450: support negate flags for publish
Browse files Browse the repository at this point in the history
  • Loading branch information
ashleymichal committed Sep 18, 2019
1 parent 286f3cb commit c049f7e
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 10 deletions.
18 changes: 14 additions & 4 deletions src/commands/publish/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,23 @@ use crate::settings::global_user::GlobalUser;
use crate::settings::target::Target;
use crate::terminal::{emoji, message};

pub fn publish(user: &GlobalUser, target: &Target) -> Result<(), failure::Error> {
pub fn publish(
user: &GlobalUser,
target: &Target,
no_worker: bool,
no_bucket: bool,
) -> Result<(), failure::Error> {
info!("workers_dev = {}", target.workers_dev);

validate_target(target)?;
upload_buckets(target, user)?;
commands::build(&target)?;
publish_script(&user, &target)?;
if !no_bucket {
upload_buckets(target, user)?;
}
if !no_worker {
commands::build(&target)?;
publish_script(&user, &target)?;
}

Ok(())
}

Expand Down
26 changes: 20 additions & 6 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -377,6 +377,18 @@ fn run() -> Result<(), failure::Error> {
.short("e")
.long("env")
.takes_value(true)
)
.arg(
Arg::with_name("no_worker")
.help("run publish without uploading your worker. used if you want to publish a bucket on its own")
.long("no-worker")
.takes_value(false)
)
.arg(
Arg::with_name("no_bucket")
.help("run publish without uploading your bucket to kv. used to update worker logic alone")
.long("no-bucket")
.takes_value(false)
),
)
.subcommand(
Expand Down Expand Up @@ -482,16 +494,18 @@ fn run() -> Result<(), failure::Error> {
failure::bail!("You can only pass --env or --release, not both")
}
let manifest = settings::target::Manifest::new(config_path)?;
let target;
if matches.is_present("env") {
let target = manifest.get_target(matches.value_of("env"), false)?;
commands::publish(&user, &target)?;
target = manifest.get_target(matches.value_of("env"), false)?;
} else if matches.is_present("release") {
let target = manifest.get_target(None, true)?;
commands::publish(&user, &target)?;
target = manifest.get_target(None, true)?;
} else {
let target = manifest.get_target(None, false)?;
commands::publish(&user, &target)?;
target = manifest.get_target(None, false)?;
}

let no_worker = matches.is_present("no_worker");
let no_bucket = matches.is_present("no_bucket");
commands::publish(&user, &target, no_worker, no_bucket)?;
} else if let Some(matches) = matches.subcommand_matches("subdomain") {
info!("Getting project settings");
let manifest = settings::target::Manifest::new(config_path)?;
Expand Down

0 comments on commit c049f7e

Please sign in to comment.