From 612c3a74f091e86ea663a2cd852a1a314f65a4ca Mon Sep 17 00:00:00 2001 From: Colin Gillespie Date: Sat, 23 Sep 2023 08:55:52 -0500 Subject: [PATCH] 14 trailing slash with the server (#24) * feat: Be less picky with server URLs * Include missing files in deploy * feat: Add in All checks complete --- DESCRIPTION | 2 +- NEWS.md | 5 +++++ R/check.R | 1 + R/deploy_quarto.R | 5 ++--- R/summarise_setup.R | 15 +++++++++------ 5 files changed, 18 insertions(+), 10 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index 142f431..b1a8c7b 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,7 +1,7 @@ Type: Package Package: audit.connect Title: Posit Connect Health Check -Version: 0.6.1 +Version: 0.6.3 Authors@R: person("Jumping", "Rivers", , "info@jumpingrivers.com", role = c("aut", "cre")) Description: Posit Connect Health Check. Deploys various content types to diff --git a/NEWS.md b/NEWS.md index fd394d3..290e4f5 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,3 +1,8 @@ +# audit.connect 0.6.3 _2023-09-23_ +- feat: Be less picky with server URLs +- fix: Deploy multiple files +- feat: Improve cli output - "All checks complete" + # audit.connect 0.6.2 _2023-09-23_ - fix: Checking system libs diff --git a/R/check.R b/R/check.R index afb832b..40aa381 100644 --- a/R/check.R +++ b/R/check.R @@ -35,6 +35,7 @@ check = function(server = NULL, token = NULL, register_uat_user(get_server(), get_token(), account = get_account()) check_list$results = check_deployments(dir, debug_level) + cli::cli_h1("All checks complete") invisible(check_list) } diff --git a/R/deploy_quarto.R b/R/deploy_quarto.R index ec2d5f1..c1414fd 100644 --- a/R/deploy_quarto.R +++ b/R/deploy_quarto.R @@ -1,11 +1,10 @@ deploy_quarto = function(quarto_dir, account = NULL, debug_level = debug_level) { suppress = get_suppress(debug_level) - tmp_dir = file.path(tempdir(), "quarto") + tmp_dir = file.path(tempdir(), "quarto", basename(quarto_dir)) on.exit(cleanup_quarto(tmp_dir, debug_level)) dir.create(tmp_dir, showWarnings = FALSE) - - file.copy(file.path(quarto_dir, "index.qmd"), tmp_dir) + fs::dir_copy(quarto_dir, tmp_dir, overwrite = TRUE) title = paste("UAT: Quarto", Sys.Date()) # quarto uses rsconnect::accounts. So, looks up the server in list of accounts if (is.null(account)) account = get_account() diff --git a/R/summarise_setup.R b/R/summarise_setup.R index 392c686..d68233d 100644 --- a/R/summarise_setup.R +++ b/R/summarise_setup.R @@ -10,8 +10,9 @@ summarise_setup = function(server, token) { } check_server = function(server) { + server = get_value("CONNECT_SERVER", server) + server = standardise_server_url(server) server = set_key("connect_server", get_value("CONNECT_SERVER", server)) - check_server_url_structure(server) check_server_accessibility(server) return(invisible(server)) } @@ -20,21 +21,23 @@ check_server = function(server) { # Solution: enforce one URL structure # This pkg likely won't work if the url is https://example.com/myrsc/ # But I don't have that structure to test, so ... -check_server_url_structure = function(server) { +standardise_server_url = function(server) { if (is.na(server)) { - cli::cli_abort("CONNECT_SERVER is missing") + cli::cli_abort("Can't find server. \\ + Either add CONNECT_SERVER to your .Renviron or + pass `server` as an argument") } end_slash = stringr::str_ends(server, pattern = "/") if (isFALSE(end_slash)) { - cli::cli_abort("The server URL should end with a `/`: {server}") + server = paste0(server, "/") } start_address = stringr::str_starts(server, pattern = "http") if (isFALSE(start_address)) { - cli::cli_abort("The server URL should start with 'http': {server}") + server = paste0("http://", server) } cli::cli_alert_info("Server: {cli::col_green(server)}") - return(invisible(NULL)) + return(invisible(server)) } check_server_accessibility = function(server) {