inst/deploy_scripts/deploy.R

default_warn <- getOption("warn")
options(warn = -1)

azure_scripts <-
  c(
    "ASF_timeslider",
    "CWD_surveillance_tables",
    "CWD_table",
    "CWD_table_with_details",
    "trichinella"
  )

internal_scripts <- c("ASF_internal",
                      "influenza",
                      "influenza_timeseries",
                      "kvarka_timeseries")

umbraco_scripts <-
  c(
    "CWD_timeslider",
    "influenza_timeslider",
    "kvarka_map",
    "Salmonella_cat_timeslider",
    "tularemia_map"
  )

cat("Updating umbraco maps\n")

sapply(umbraco_scripts,
       function(file) {
         tryCatch({
           source(paste0(file, ".R"))
           file <- basename(file)
           ## variable 'response' should be defined as the return value of
           ## publish_umbraco() function to live server inside each script
           response_code <- response$status_code
           cat(sprintf(
             "POST of %s to Umbraco live server gave respone code %d\n\n",
             file,
             response_code
           ))
         },
         error = function(e) {
           cat(sprintf("%s failed with the following error message:\n%s\n\n", file, e))
         })
       })

cat("Updating azure and internal maps and tables\n")

sapply(c(azure_scripts,
         internal_scripts),
       function(file) {
         tryCatch({
           source(paste0(file, ".R"))
           cat(sprintf("%s sucessfully updated\n", file))
         },
         error = function(e) {
           file <- basename(file)
           cat(sprintf("%s failed with the following error message:\n%s\n", file, e))
         })
       })

file.copy("deploy_pages",
          "../..",
          recursive = TRUE,
          overwrite = TRUE)

unlink("deploy_pages",
       recursive = TRUE,
       force = TRUE)


options(warn = default_warn)
SVA-SE/svamap documentation built on Sept. 25, 2020, 3:53 p.m.