mirror of
https://github.com/agdamsbo/FreesearchR.git
synced 2026-06-19 04:27:30 +02:00
new version and formatted code
This commit is contained in:
parent
7fdbd1f90e
commit
a7d8fd4b36
27 changed files with 3736 additions and 3189 deletions
101
renv/activate.R
101
renv/activate.R
|
|
@ -2,7 +2,8 @@
|
|||
local({
|
||||
|
||||
# the requested version of renv
|
||||
version <- "1.1.5"
|
||||
version <- "1.1.7"
|
||||
attr(version, "md5") <- "dd5d60f155dadff4c88c2fc6680504b4"
|
||||
attr(version, "sha") <- NULL
|
||||
|
||||
# the project directory
|
||||
|
|
@ -168,6 +169,16 @@ local({
|
|||
if (quiet)
|
||||
return(invisible())
|
||||
|
||||
# also check for config environment variables that should suppress messages
|
||||
# https://github.com/rstudio/renv/issues/2214
|
||||
enabled <- Sys.getenv("RENV_CONFIG_STARTUP_QUIET", unset = NA)
|
||||
if (!is.na(enabled) && tolower(enabled) %in% c("true", "1"))
|
||||
return(invisible())
|
||||
|
||||
enabled <- Sys.getenv("RENV_CONFIG_SYNCHRONIZED_CHECK", unset = NA)
|
||||
if (!is.na(enabled) && tolower(enabled) %in% c("false", "0"))
|
||||
return(invisible())
|
||||
|
||||
msg <- sprintf(fmt, ...)
|
||||
cat(msg, file = stdout(), sep = if (appendLF) "\n" else "")
|
||||
|
||||
|
|
@ -215,6 +226,16 @@ local({
|
|||
section <- header(sprintf("Bootstrapping renv %s", friendly))
|
||||
catf(section)
|
||||
|
||||
# try to install renv from cache
|
||||
md5 <- attr(version, "md5", exact = TRUE)
|
||||
if (length(md5)) {
|
||||
pkgpath <- renv_bootstrap_find(version)
|
||||
if (length(pkgpath) && file.exists(pkgpath)) {
|
||||
file.copy(pkgpath, library, recursive = TRUE)
|
||||
return(invisible())
|
||||
}
|
||||
}
|
||||
|
||||
# attempt to download renv
|
||||
catf("- Downloading renv ... ", appendLF = FALSE)
|
||||
withCallingHandlers(
|
||||
|
|
@ -240,7 +261,6 @@ local({
|
|||
|
||||
# add empty line to break up bootstrapping from normal output
|
||||
catf("")
|
||||
|
||||
return(invisible())
|
||||
}
|
||||
|
||||
|
|
@ -257,12 +277,20 @@ local({
|
|||
repos <- Sys.getenv("RENV_CONFIG_REPOS_OVERRIDE", unset = NA)
|
||||
if (!is.na(repos)) {
|
||||
|
||||
# check for RSPM; if set, use a fallback repository for renv
|
||||
rspm <- Sys.getenv("RSPM", unset = NA)
|
||||
if (identical(rspm, repos))
|
||||
repos <- c(RSPM = rspm, CRAN = cran)
|
||||
# split on ';' if present
|
||||
parts <- strsplit(repos, ";", fixed = TRUE)[[1L]]
|
||||
|
||||
return(repos)
|
||||
# split into named repositories if present
|
||||
idx <- regexpr("=", parts, fixed = TRUE)
|
||||
keys <- substring(parts, 1L, idx - 1L)
|
||||
vals <- substring(parts, idx + 1L)
|
||||
names(vals) <- keys
|
||||
|
||||
# if we have a single unnamed repository, call it CRAN
|
||||
if (length(vals) == 1L && identical(keys, ""))
|
||||
names(vals) <- "CRAN"
|
||||
|
||||
return(vals)
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -511,6 +539,51 @@ local({
|
|||
|
||||
}
|
||||
|
||||
renv_bootstrap_find <- function(version) {
|
||||
|
||||
path <- renv_bootstrap_find_cache(version)
|
||||
if (length(path) && file.exists(path)) {
|
||||
catf("- Using renv %s from global package cache", version)
|
||||
return(path)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
renv_bootstrap_find_cache <- function(version) {
|
||||
|
||||
md5 <- attr(version, "md5", exact = TRUE)
|
||||
if (is.null(md5))
|
||||
return()
|
||||
|
||||
# infer path to renv cache
|
||||
cache <- Sys.getenv("RENV_PATHS_CACHE", unset = "")
|
||||
if (!nzchar(cache)) {
|
||||
root <- Sys.getenv("RENV_PATHS_ROOT", unset = NA)
|
||||
if (!is.na(root))
|
||||
cache <- file.path(root, "cache")
|
||||
}
|
||||
|
||||
if (!nzchar(cache)) {
|
||||
tools <- asNamespace("tools")
|
||||
if (is.function(tools$R_user_dir)) {
|
||||
root <- tools$R_user_dir("renv", "cache")
|
||||
cache <- file.path(root, "cache")
|
||||
}
|
||||
}
|
||||
|
||||
# start completing path to cache
|
||||
file.path(
|
||||
cache,
|
||||
renv_bootstrap_cache_version(),
|
||||
renv_bootstrap_platform_prefix(),
|
||||
"renv",
|
||||
version,
|
||||
md5,
|
||||
"renv"
|
||||
)
|
||||
|
||||
}
|
||||
|
||||
renv_bootstrap_download_tarball <- function(version) {
|
||||
|
||||
# if the user has provided the path to a tarball via
|
||||
|
|
@ -979,7 +1052,7 @@ local({
|
|||
|
||||
renv_bootstrap_validate_version_release <- function(version, description) {
|
||||
expected <- description[["Version"]]
|
||||
is.character(expected) && identical(expected, version)
|
||||
is.character(expected) && identical(c(expected), c(version))
|
||||
}
|
||||
|
||||
renv_bootstrap_hash_text <- function(text) {
|
||||
|
|
@ -1181,6 +1254,18 @@ local({
|
|||
|
||||
}
|
||||
|
||||
renv_bootstrap_cache_version <- function() {
|
||||
# NOTE: users should normally not override the cache version;
|
||||
# this is provided just to make testing easier
|
||||
Sys.getenv("RENV_CACHE_VERSION", unset = "v5")
|
||||
}
|
||||
|
||||
renv_bootstrap_cache_version_previous <- function() {
|
||||
version <- renv_bootstrap_cache_version()
|
||||
number <- as.integer(substring(version, 2L))
|
||||
paste("v", number - 1L, sep = "")
|
||||
}
|
||||
|
||||
renv_json_read <- function(file = NULL, text = NULL) {
|
||||
|
||||
jlerr <- NULL
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue