Skip to content

Commit e09d9e7

Browse files
authored
Merge pull request #279 from datacarpentry/update/packages
Update 12 packages
2 parents 626ca5d + 46218d5 commit e09d9e7

File tree

2 files changed

+113
-27
lines changed

2 files changed

+113
-27
lines changed

renv/activate.R

Lines changed: 96 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
local({
33

44
# the requested version of renv
5-
version <- "1.0.7"
5+
version <- "1.0.9"
66
attr(version, "sha") <- NULL
77

88
# the project directory
@@ -98,6 +98,66 @@ local({
9898
unloadNamespace("renv")
9999

100100
# load bootstrap tools
101+
ansify <- function(text) {
102+
if (renv_ansify_enabled())
103+
renv_ansify_enhanced(text)
104+
else
105+
renv_ansify_default(text)
106+
}
107+
108+
renv_ansify_enabled <- function() {
109+
110+
override <- Sys.getenv("RENV_ANSIFY_ENABLED", unset = NA)
111+
if (!is.na(override))
112+
return(as.logical(override))
113+
114+
pane <- Sys.getenv("RSTUDIO_CHILD_PROCESS_PANE", unset = NA)
115+
if (identical(pane, "build"))
116+
return(FALSE)
117+
118+
testthat <- Sys.getenv("TESTTHAT", unset = "false")
119+
if (tolower(testthat) %in% "true")
120+
return(FALSE)
121+
122+
iderun <- Sys.getenv("R_CLI_HAS_HYPERLINK_IDE_RUN", unset = "false")
123+
if (tolower(iderun) %in% "false")
124+
return(FALSE)
125+
126+
TRUE
127+
128+
}
129+
130+
renv_ansify_default <- function(text) {
131+
text
132+
}
133+
134+
renv_ansify_enhanced <- function(text) {
135+
136+
# R help links
137+
pattern <- "`\\?(renv::(?:[^`])+)`"
138+
replacement <- "`\033]8;;ide:help:\\1\a?\\1\033]8;;\a`"
139+
text <- gsub(pattern, replacement, text, perl = TRUE)
140+
141+
# runnable code
142+
pattern <- "`(renv::(?:[^`])+)`"
143+
replacement <- "`\033]8;;ide:run:\\1\a\\1\033]8;;\a`"
144+
text <- gsub(pattern, replacement, text, perl = TRUE)
145+
146+
# return ansified text
147+
text
148+
149+
}
150+
151+
renv_ansify_init <- function() {
152+
153+
envir <- renv_envir_self()
154+
if (renv_ansify_enabled())
155+
assign("ansify", renv_ansify_enhanced, envir = envir)
156+
else
157+
assign("ansify", renv_ansify_default, envir = envir)
158+
159+
}
160+
101161
`%||%` <- function(x, y) {
102162
if (is.null(x)) y else x
103163
}
@@ -142,7 +202,10 @@ local({
142202
# compute common indent
143203
indent <- regexpr("[^[:space:]]", lines)
144204
common <- min(setdiff(indent, -1L)) - leave
145-
paste(substring(lines, common), collapse = "\n")
205+
text <- paste(substring(lines, common), collapse = "\n")
206+
207+
# substitute in ANSI links for executable renv code
208+
ansify(text)
146209

147210
}
148211

@@ -306,7 +369,11 @@ local({
306369
)
307370

308371
if ("headers" %in% names(formals(utils::download.file)))
309-
args$headers <- renv_bootstrap_download_custom_headers(url)
372+
{
373+
headers <- renv_bootstrap_download_custom_headers(url)
374+
if (length(headers) && is.character(headers))
375+
args$headers <- headers
376+
}
310377

311378
do.call(utils::download.file, args)
312379

@@ -385,10 +452,22 @@ local({
385452
for (type in types) {
386453
for (repos in renv_bootstrap_repos()) {
387454

455+
# build arguments for utils::available.packages() call
456+
args <- list(type = type, repos = repos)
457+
458+
# add custom headers if available -- note that
459+
# utils::available.packages() will pass this to download.file()
460+
if ("headers" %in% names(formals(utils::download.file)))
461+
{
462+
headers <- renv_bootstrap_download_custom_headers(url)
463+
if (length(headers) && is.character(headers))
464+
args$headers <- headers
465+
}
466+
388467
# retrieve package database
389468
db <- tryCatch(
390469
as.data.frame(
391-
utils::available.packages(type = type, repos = repos),
470+
do.call(utils::available.packages, args),
392471
stringsAsFactors = FALSE
393472
),
394473
error = identity
@@ -470,23 +549,31 @@ local({
470549

471550
}
472551

552+
renv_bootstrap_github_token <- function() {
553+
for (envvar in c("GITHUB_TOKEN", "GITHUB_PAT", "GH_TOKEN")) {
554+
envval <- Sys.getenv(envvar, unset = NA)
555+
if (!is.na(envval))
556+
return(envval)
557+
}
558+
}
559+
473560
renv_bootstrap_download_github <- function(version) {
474561

475562
enabled <- Sys.getenv("RENV_BOOTSTRAP_FROM_GITHUB", unset = "TRUE")
476563
if (!identical(enabled, "TRUE"))
477564
return(FALSE)
478565

479566
# prepare download options
480-
pat <- Sys.getenv("GITHUB_PAT")
481-
if (nzchar(Sys.which("curl")) && nzchar(pat)) {
567+
token <- renv_bootstrap_github_token()
568+
if (nzchar(Sys.which("curl")) && nzchar(token)) {
482569
fmt <- "--location --fail --header \"Authorization: token %s\""
483-
extra <- sprintf(fmt, pat)
570+
extra <- sprintf(fmt, token)
484571
saved <- options("download.file.method", "download.file.extra")
485572
options(download.file.method = "curl", download.file.extra = extra)
486573
on.exit(do.call(base::options, saved), add = TRUE)
487-
} else if (nzchar(Sys.which("wget")) && nzchar(pat)) {
574+
} else if (nzchar(Sys.which("wget")) && nzchar(token)) {
488575
fmt <- "--header=\"Authorization: token %s\""
489-
extra <- sprintf(fmt, pat)
576+
extra <- sprintf(fmt, token)
490577
saved <- options("download.file.method", "download.file.extra")
491578
options(download.file.method = "wget", download.file.extra = extra)
492579
on.exit(do.call(base::options, saved), add = TRUE)

renv/profiles/lesson-requirements/renv.lock

Lines changed: 17 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
"Package": "Matrix",
3737
"Version": "1.7-0",
3838
"Source": "Repository",
39-
"Repository": "CRAN",
39+
"Repository": "RSPM",
4040
"Requirements": [
4141
"R",
4242
"grDevices",
@@ -81,17 +81,17 @@
8181
},
8282
"bit": {
8383
"Package": "bit",
84-
"Version": "4.0.5",
84+
"Version": "4.5.0",
8585
"Source": "Repository",
8686
"Repository": "CRAN",
8787
"Requirements": [
8888
"R"
8989
],
90-
"Hash": "d242abec29412ce988848d0294b208fd"
90+
"Hash": "5dc7b2677d65d0e874fc4aaf0e879987"
9191
},
9292
"bit64": {
9393
"Package": "bit64",
94-
"Version": "4.0.5",
94+
"Version": "4.5.2",
9595
"Source": "Repository",
9696
"Repository": "CRAN",
9797
"Requirements": [
@@ -101,7 +101,7 @@
101101
"stats",
102102
"utils"
103103
],
104-
"Hash": "9fe98599ca456d6552421db0d6772d8f"
104+
"Hash": "e84984bf5f12a18628d9a02322128dfd"
105105
},
106106
"bslib": {
107107
"Package": "bslib",
@@ -241,14 +241,13 @@
241241
},
242242
"evaluate": {
243243
"Package": "evaluate",
244-
"Version": "0.24.0",
244+
"Version": "1.0.0",
245245
"Source": "Repository",
246246
"Repository": "CRAN",
247247
"Requirements": [
248-
"R",
249-
"methods"
248+
"R"
250249
],
251-
"Hash": "a1066cbc05caee9a4bf6d90f194ff4da"
250+
"Hash": "6b567375113ceb7d9f800de4dd42218e"
252251
},
253252
"fansi": {
254253
"Package": "fansi",
@@ -337,14 +336,14 @@
337336
},
338337
"glue": {
339338
"Package": "glue",
340-
"Version": "1.7.0",
339+
"Version": "1.8.0",
341340
"Source": "Repository",
342341
"Repository": "CRAN",
343342
"Requirements": [
344343
"R",
345344
"methods"
346345
],
347-
"Hash": "e0b3a53876554bd45879e596cdb10a52"
346+
"Hash": "5899f1eaa825580172bb56c08266f37c"
348347
},
349348
"gtable": {
350349
"Package": "gtable",
@@ -425,13 +424,13 @@
425424
},
426425
"jsonlite": {
427426
"Package": "jsonlite",
428-
"Version": "1.8.8",
427+
"Version": "1.8.9",
429428
"Source": "Repository",
430429
"Repository": "CRAN",
431430
"Requirements": [
432431
"methods"
433432
],
434-
"Hash": "e1b9c55281c5adc4dd113652d9e26768"
433+
"Hash": "4e993b65c2c3ffbffce7bb3e2c6f832b"
435434
},
436435
"knitr": {
437436
"Package": "knitr",
@@ -551,7 +550,7 @@
551550
"Package": "nlme",
552551
"Version": "3.1-166",
553552
"Source": "Repository",
554-
"Repository": "CRAN",
553+
"Repository": "RSPM",
555554
"Requirements": [
556555
"R",
557556
"graphics",
@@ -694,13 +693,13 @@
694693
},
695694
"renv": {
696695
"Package": "renv",
697-
"Version": "1.0.7",
696+
"Version": "1.0.9",
698697
"Source": "Repository",
699698
"Repository": "CRAN",
700699
"Requirements": [
701700
"utils"
702701
],
703-
"Hash": "397b7b2a265bc5a7a06852524dabae20"
702+
"Hash": "ef233f0e9064fc88c898b340c9add5c2"
704703
},
705704
"rlang": {
706705
"Package": "rlang",
@@ -860,13 +859,13 @@
860859
},
861860
"tinytex": {
862861
"Package": "tinytex",
863-
"Version": "0.52",
862+
"Version": "0.53",
864863
"Source": "Repository",
865864
"Repository": "CRAN",
866865
"Requirements": [
867866
"xfun"
868867
],
869-
"Hash": "cfbad971a71f0e27cec22e544a08bc3b"
868+
"Hash": "9db859e8aabbb474293dde3097839420"
870869
},
871870
"tzdb": {
872871
"Package": "tzdb",

0 commit comments

Comments
 (0)