## ----setup, include = FALSE---------------------------------------------------
knitr::opts_chunk$set(collapse = TRUE, comment = "#>", eval = FALSE)

## -----------------------------------------------------------------------------
# remotes::install_github("lennon-li/courieR")

## -----------------------------------------------------------------------------
# library(courieR)
# 
# routes <- find_routes()
# routes[, c("version", "rscript_path", "is_current")]
# #>   version                                           rscript_path is_current
# #> 1   4.6.0         C:/Program Files/R/R-4.6.0/bin/x64/Rscript.exe       TRUE
# #> 2   4.5.2         C:/Program Files/R/R-4.5.2/bin/x64/Rscript.exe      FALSE
# #> 3   4.5.2  C:/Users/you/AppData/Local/Programs/R/R-4.5.2/bin/...      FALSE
# #> 4   4.5.1  C:/Users/you/AppData/Local/Programs/R/R-4.5.1/bin/...      FALSE
# #> 5   4.1.1              C:/Users/you/Documents/R/R-4.1.1/bin/...      FALSE

## -----------------------------------------------------------------------------
# routes <- find_routes(search_paths = "/opt/custom-r/bin/Rscript")

## -----------------------------------------------------------------------------
# open_hub()

## -----------------------------------------------------------------------------
# # always do a dry run first
# result <- ship(
#   source_path = routes$rscript_path[2],   # old R
#   target_path = routes$rscript_path[1],   # new R (current)
#   dry_run = TRUE
# )
# print(result$plan)

## -----------------------------------------------------------------------------
# result <- ship(
#   source_path = routes$rscript_path[2],
#   target_path = routes$rscript_path[1],
#   upgrade = TRUE
# )
# 
# # check for any errors
# result$results[result$results$status == "error", ]

## -----------------------------------------------------------------------------
# a_pkgs <- manifest(rscript_path = routes$rscript_path[1])
# b_pkgs <- manifest(rscript_path = routes$rscript_path[2])
# 
# comp <- inventory(a_pkgs, b_pkgs)
# nrow(comp$missing)    # packages in A but not in B
# nrow(comp$outdated)   # packages where A has a newer version than B

