Skip to content

Commit

Permalink
14 trailing slash with the server (#24)
Browse files Browse the repository at this point in the history
* feat: Be less picky with server URLs

* Include missing files in deploy

* feat: Add in All checks complete
  • Loading branch information
csgillespie authored Sep 23, 2023
1 parent 27db724 commit 612c3a7
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 10 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -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", , "[email protected]", role = c("aut", "cre"))
Description: Posit Connect Health Check. Deploys various content types to
Expand Down
5 changes: 5 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -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

Expand Down
1 change: 1 addition & 0 deletions R/check.R
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

Expand Down
5 changes: 2 additions & 3 deletions R/deploy_quarto.R
Original file line number Diff line number Diff line change
@@ -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()
Expand Down
15 changes: 9 additions & 6 deletions R/summarise_setup.R
Original file line number Diff line number Diff line change
Expand Up @@ -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))
}
Expand All @@ -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) {
Expand Down

0 comments on commit 612c3a7

Please sign in to comment.