TEXT   28
updateDistribution
Guest on 3rd February 2023 01:32:54 AM


  1. updateDistribution <- function() {
  2.  
  3.   if (utils::packageVersion("iNZight") < 3) {
  4.       conf <-
  5.           tcltk::tk_messageBox(message = paste("iNZight 3 is now available for download from our website.",
  6.                                                "\n\nThere have been a lot of big changes, so you'll need",
  7.                                                "to install iNZight again to get them.",
  8.                                                "\n\nDo you want to go to the website now?"),
  9.                                title = "iNZight 3.0 Released!", icon = "info", type = "okcancel")
  10.       if (conf == "ok")
  11.           utils::browseURL("https://www.stat.auckland.ac.nz/~wild/iNZight/getinzight.php")
  12.       q("no")
  13.       return(invisible(NULL))
  14.   }
  15.  
  16.   if (!exists("OS")) OS <- ifelse(.Platform$OS == "windows", "windows", "osx")
  17.  
  18.   ## UPDATE VERSION NUMBERS AS REQUIRED
  19.   LATEST <- switch(OS,
  20.                    "windows" = 1.0,
  21.                    "osx" = 1.0)
  22.  
  23.   if (!exists("VERSION")) VERSION <- 0
  24.   if (VERSION < LATEST) {
  25.       utils::download.file(
  26.         sprintf("https://raw.githubusercontent.com/iNZightVIT/dev/master/updateProfile-%s.R", OS),
  27.         ".Rprofile"
  28.       )
  29.  
  30.       tcltk::tkmessageBox(title = "Rerun Updater", message = "Update script updated - please run the Updater again.",
  31.                           type = "ok", icon = "info")
  32.       return(invisible(NULL))
  33.   }
  34.  
  35.   cat("==========================================================\n")
  36.   cat("               Checking for updates ...\n")
  37.   cat("==========================================================\n\n")
  38.  
  39.   ## List any packages added to iNZight after the release
  40.   pkgs <- c("")
  41.  
  42.   ## --- Update iNZight packages:
  43.   utils::update.packages(repos = "http://r.docker.stat.auckland.ac.nz/R", ask = FALSE)
  44.  
  45.   ## A list of packages we NEED to have installed (since older versions anyway...)
  46.   pkgs <- pkgs[!pkgs %in% rownames(utils::installed.packages())]
  47.   if (length(pkgs) > 0)
  48.       utils::install.packages(pkgs, repos = "http://cran.stat.auckland.ac.nz")
  49.  
  50.   ## success message
  51.   cat("==========================================================\n")
  52.   cat("               Updating complete!!\n")
  53.   cat("==========================================================\n\n")
  54.  
  55.   tcltk::tkmessageBox(title = "Update Complete", message = "iNZight is now up to date!",
  56.                       icon = "info", type = "ok")
  57.  
  58.   q("no")
  59.  
  60.   return(invisible(NULL))
  61. }
  62.  
  63.  
  64.  
  65. updateDistribution()

Raw Paste

Login or Register to edit or fork this paste. It's free.