diff --git a/DESCRIPTION b/DESCRIPTION index 533bb07b..d7949318 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -10,9 +10,11 @@ Encoding: UTF-8 Imports: R6, httr, - rlang + rlang, + fs RoxygenNote: 6.0.1 -Suggests: rmarkdown, +Suggests: + rmarkdown, htmltools, flexdashboard, webshot, diff --git a/NAMESPACE b/NAMESPACE index bc4be41a..47895d7f 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -6,5 +6,8 @@ export(audit_r_versions) export(audit_runas) export(audit_vanity_urls) export(cache_apps) +export(deploy_bundle) +export(dir_bundle) +export(poll_task) export(promote) export(tag_page) diff --git a/R/promote.R b/R/promote.R index e2190935..b1e542df 100644 --- a/R/promote.R +++ b/R/promote.R @@ -51,23 +51,43 @@ promote <- function(from, warning(sprintf('Updating EXISTING app %d with name %s on %s', to_app$id, app_name, to)) } - to_app_url <- deploy_bundle( + task_id <- deploy_bundle( connect = to_client, bundle = bundle, - app = to_app + app_id = to_app$id ) + poll_task(connect = to_client, task_id = task_id) + + to_app_url <- app$url + return(to_app_url) } -deploy_bundle <- function(connect, bundle, app){ +#' @export +dir_bundle <- function(path = ".") { + before_wd <- getwd() + setwd(path) + on.exit(expr = setwd(before_wd), add = TRUE) + + utils::tar(tarfile = "bundle.tar.gz", files = ".", compression = "gzip", tar = "internal") + + return(fs::path_abs("bundle.tar.gz")) +} + +#' @export +deploy_bundle <- function(connect, bundle, app_id){ #upload bundle - new_bundle_id <- connect$upload_bundle(bundle, app$id) + new_bundle_id <- connect$upload_bundle(bundle, app_id) #activate bundle - task_id <- connect$activate_bundle(app$id, new_bundle_id) + task_id <- connect$activate_bundle(app_id, new_bundle_id) - #poll task + return(task_id) +} + +#' @export +poll_task <- function(connect, task_id) { start <- 0 while (task_id > 0) { Sys.sleep(2) @@ -80,5 +100,5 @@ deploy_bundle <- function(connect, bundle, app){ task_id = 0 } } - return(app$url) + invisible() }