Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update 15 packages #118

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
95 changes: 58 additions & 37 deletions renv/activate.R
Original file line number Diff line number Diff line change
Expand Up @@ -695,11 +695,19 @@ local({

}

renv_bootstrap_platform_prefix <- function() {
renv_bootstrap_platform_prefix_default <- function() {

# construct version prefix
version <- paste(R.version$major, R.version$minor, sep = ".")
prefix <- paste("R", numeric_version(version)[1, 1:2], sep = "-")
# read version component
version <- Sys.getenv("RENV_PATHS_VERSION", unset = "R-%v")

# expand placeholders
placeholders <- list(
list("%v", format(getRversion()[1, 1:2])),
list("%V", format(getRversion()[1, 1:3]))
)

for (placeholder in placeholders)
version <- gsub(placeholder[[1L]], placeholder[[2L]], version, fixed = TRUE)

# include SVN revision for development versions of R
# (to avoid sharing platform-specific artefacts with released versions of R)
Expand All @@ -708,10 +716,19 @@ local({
identical(R.version[["nickname"]], "Unsuffered Consequences")

if (devel)
prefix <- paste(prefix, R.version[["svn rev"]], sep = "-r")
version <- paste(version, R.version[["svn rev"]], sep = "-r")

version

}

renv_bootstrap_platform_prefix <- function() {

# construct version prefix
version <- renv_bootstrap_platform_prefix_default()

# build list of path components
components <- c(prefix, R.version$platform)
components <- c(version, R.version$platform)

# include prefix if provided by user
prefix <- renv_bootstrap_platform_prefix_impl()
Expand Down Expand Up @@ -950,14 +967,14 @@ local({
}

renv_bootstrap_validate_version_dev <- function(version, description) {

expected <- description[["RemoteSha"]]
if (!is.character(expected))
return(FALSE)

pattern <- sprintf("^\\Q%s\\E", version)
grepl(pattern, expected, perl = TRUE)

}

renv_bootstrap_validate_version_release <- function(version, description) {
Expand Down Expand Up @@ -1198,86 +1215,89 @@ local({
}

renv_json_read_patterns <- function() {

list(

# objects
list("{", "\t\n\tobject(\t\n\t"),
list("}", "\t\n\t)\t\n\t"),
list("{", "\t\n\tobject(\t\n\t", TRUE),
list("}", "\t\n\t)\t\n\t", TRUE),

# arrays
list("[", "\t\n\tarray(\t\n\t"),
list("]", "\n\t\n)\n\t\n"),
list("[", "\t\n\tarray(\t\n\t", TRUE),
list("]", "\n\t\n)\n\t\n", TRUE),

# maps
list(":", "\t\n\t=\t\n\t")

list(":", "\t\n\t=\t\n\t", TRUE),

# newlines
list("\\u000a", "\n", FALSE)

)

}

renv_json_read_envir <- function() {

envir <- new.env(parent = emptyenv())

envir[["+"]] <- `+`
envir[["-"]] <- `-`

envir[["object"]] <- function(...) {
result <- list(...)
names(result) <- as.character(names(result))
result
}

envir[["array"]] <- list

envir[["true"]] <- TRUE
envir[["false"]] <- FALSE
envir[["null"]] <- NULL

envir

}

renv_json_read_remap <- function(object, patterns) {

# repair names if necessary
if (!is.null(names(object))) {

nms <- names(object)
for (pattern in patterns)
nms <- gsub(pattern[[2L]], pattern[[1L]], nms, fixed = TRUE)
names(object) <- nms

}

# repair strings if necessary
if (is.character(object)) {
for (pattern in patterns)
object <- gsub(pattern[[2L]], pattern[[1L]], object, fixed = TRUE)
}

# recurse for other objects
if (is.recursive(object))
for (i in seq_along(object))
object[i] <- list(renv_json_read_remap(object[[i]], patterns))

# return remapped object
object

}

renv_json_read_default <- function(file = NULL, text = NULL) {

# read json text
text <- paste(text %||% readLines(file, warn = FALSE), collapse = "\n")

# convert into something the R parser will understand
patterns <- renv_json_read_patterns()
transformed <- text
for (pattern in patterns)
transformed <- gsub(pattern[[1L]], pattern[[2L]], transformed, fixed = TRUE)

# parse it
rfile <- tempfile("renv-json-", fileext = ".R")
on.exit(unlink(rfile), add = TRUE)
Expand All @@ -1287,9 +1307,10 @@ local({
# evaluate in safe environment
result <- eval(json, envir = renv_json_read_envir())

# fix up strings if necessary
# fix up strings if necessary -- do so only with reversible patterns
patterns <- Filter(function(pattern) pattern[[3L]], patterns)
renv_json_read_remap(result, patterns)

}


Expand Down
Loading
Loading