2
2
local({
3
3
4
4
# the requested version of renv
5
- version <- " 1.1.0 "
5
+ version <- " 1.1.4 "
6
6
attr(version , " sha" ) <- NULL
7
7
8
8
# the project directory
@@ -135,12 +135,12 @@ local({
135
135
136
136
# R help links
137
137
pattern <- " `\\ ?(renv::(?:[^`])+)`"
138
- replacement <- " `\0 33]8;;ide: help:\\ 1\a ?\\ 1\0 33]8;;\a `"
138
+ replacement <- " `\0 33]8;;x-r- help:\\ 1\a ?\\ 1\0 33]8;;\a `"
139
139
text <- gsub(pattern , replacement , text , perl = TRUE )
140
140
141
141
# runnable code
142
142
pattern <- " `(renv::(?:[^`])+)`"
143
- replacement <- " `\0 33]8;;ide: run:\\ 1\a\\ 1\0 33]8;;\a `"
143
+ replacement <- " `\0 33]8;;x-r- run:\\ 1\a\\ 1\0 33]8;;\a `"
144
144
text <- gsub(pattern , replacement , text , perl = TRUE )
145
145
146
146
# return ansified text
@@ -695,11 +695,19 @@ local({
695
695
696
696
}
697
697
698
- renv_bootstrap_platform_prefix <- function () {
698
+ renv_bootstrap_platform_prefix_default <- function () {
699
699
700
- # construct version prefix
701
- version <- paste(R.version $ major , R.version $ minor , sep = " ." )
702
- prefix <- paste(" R" , numeric_version(version )[1 , 1 : 2 ], sep = " -" )
700
+ # read version component
701
+ version <- Sys.getenv(" RENV_PATHS_VERSION" , unset = " R-%v" )
702
+
703
+ # expand placeholders
704
+ placeholders <- list (
705
+ list (" %v" , format(getRversion()[1 , 1 : 2 ])),
706
+ list (" %V" , format(getRversion()[1 , 1 : 3 ]))
707
+ )
708
+
709
+ for (placeholder in placeholders )
710
+ version <- gsub(placeholder [[1L ]], placeholder [[2L ]], version , fixed = TRUE )
703
711
704
712
# include SVN revision for development versions of R
705
713
# (to avoid sharing platform-specific artefacts with released versions of R)
@@ -708,10 +716,19 @@ local({
708
716
identical(R.version [[" nickname" ]], " Unsuffered Consequences" )
709
717
710
718
if (devel )
711
- prefix <- paste(prefix , R.version [[" svn rev" ]], sep = " -r" )
719
+ version <- paste(version , R.version [[" svn rev" ]], sep = " -r" )
720
+
721
+ version
722
+
723
+ }
724
+
725
+ renv_bootstrap_platform_prefix <- function () {
726
+
727
+ # construct version prefix
728
+ version <- renv_bootstrap_platform_prefix_default()
712
729
713
730
# build list of path components
714
- components <- c(prefix , R.version $ platform )
731
+ components <- c(version , R.version $ platform )
715
732
716
733
# include prefix if provided by user
717
734
prefix <- renv_bootstrap_platform_prefix_impl()
@@ -950,14 +967,14 @@ local({
950
967
}
951
968
952
969
renv_bootstrap_validate_version_dev <- function (version , description ) {
953
-
970
+
954
971
expected <- description [[" RemoteSha" ]]
955
972
if (! is.character(expected ))
956
973
return (FALSE )
957
-
974
+
958
975
pattern <- sprintf(" ^\\ Q%s\\ E" , version )
959
976
grepl(pattern , expected , perl = TRUE )
960
-
977
+
961
978
}
962
979
963
980
renv_bootstrap_validate_version_release <- function (version , description ) {
@@ -1198,86 +1215,89 @@ local({
1198
1215
}
1199
1216
1200
1217
renv_json_read_patterns <- function () {
1201
-
1218
+
1202
1219
list (
1203
-
1220
+
1204
1221
# objects
1205
- list (" {" , " \t\n\t object(\t\n\t " ),
1206
- list (" }" , " \t\n\t )\t\n\t " ),
1207
-
1222
+ list (" {" , " \t\n\t object(\t\n\t " , TRUE ),
1223
+ list (" }" , " \t\n\t )\t\n\t " , TRUE ),
1224
+
1208
1225
# arrays
1209
- list (" [" , " \t\n\t array(\t\n\t " ),
1210
- list (" ]" , " \n\t\n )\n\t\n " ),
1211
-
1226
+ list (" [" , " \t\n\t array(\t\n\t " , TRUE ),
1227
+ list (" ]" , " \n\t\n )\n\t\n " , TRUE ),
1228
+
1212
1229
# maps
1213
- list (" :" , " \t\n\t =\t\n\t " )
1214
-
1230
+ list (" :" , " \t\n\t =\t\n\t " , TRUE ),
1231
+
1232
+ # newlines
1233
+ list (" \\ u000a" , " \n " , FALSE )
1234
+
1215
1235
)
1216
-
1236
+
1217
1237
}
1218
1238
1219
1239
renv_json_read_envir <- function () {
1220
1240
1221
1241
envir <- new.env(parent = emptyenv())
1222
-
1242
+
1223
1243
envir [[" +" ]] <- `+`
1224
1244
envir [[" -" ]] <- `-`
1225
-
1245
+
1226
1246
envir [[" object" ]] <- function (... ) {
1227
1247
result <- list (... )
1228
1248
names(result ) <- as.character(names(result ))
1229
1249
result
1230
1250
}
1231
-
1251
+
1232
1252
envir [[" array" ]] <- list
1233
-
1253
+
1234
1254
envir [[" true" ]] <- TRUE
1235
1255
envir [[" false" ]] <- FALSE
1236
1256
envir [[" null" ]] <- NULL
1237
-
1257
+
1238
1258
envir
1239
-
1259
+
1240
1260
}
1241
1261
1242
1262
renv_json_read_remap <- function (object , patterns ) {
1243
-
1263
+
1244
1264
# repair names if necessary
1245
1265
if (! is.null(names(object ))) {
1246
-
1266
+
1247
1267
nms <- names(object )
1248
1268
for (pattern in patterns )
1249
1269
nms <- gsub(pattern [[2L ]], pattern [[1L ]], nms , fixed = TRUE )
1250
1270
names(object ) <- nms
1251
-
1271
+
1252
1272
}
1253
-
1273
+
1254
1274
# repair strings if necessary
1255
1275
if (is.character(object )) {
1256
1276
for (pattern in patterns )
1257
1277
object <- gsub(pattern [[2L ]], pattern [[1L ]], object , fixed = TRUE )
1258
1278
}
1259
-
1279
+
1260
1280
# recurse for other objects
1261
1281
if (is.recursive(object ))
1262
1282
for (i in seq_along(object ))
1263
1283
object [i ] <- list (renv_json_read_remap(object [[i ]], patterns ))
1264
-
1284
+
1265
1285
# return remapped object
1266
1286
object
1267
-
1287
+
1268
1288
}
1269
1289
1270
1290
renv_json_read_default <- function (file = NULL , text = NULL ) {
1271
1291
1272
1292
# read json text
1273
1293
text <- paste(text %|| % readLines(file , warn = FALSE ), collapse = " \n " )
1274
-
1294
+
1275
1295
# convert into something the R parser will understand
1276
1296
patterns <- renv_json_read_patterns()
1277
1297
transformed <- text
1278
1298
for (pattern in patterns )
1279
1299
transformed <- gsub(pattern [[1L ]], pattern [[2L ]], transformed , fixed = TRUE )
1280
-
1300
+
1281
1301
# parse it
1282
1302
rfile <- tempfile(" renv-json-" , fileext = " .R" )
1283
1303
on.exit(unlink(rfile ), add = TRUE )
@@ -1287,9 +1307,10 @@ local({
1287
1307
# evaluate in safe environment
1288
1308
result <- eval(json , envir = renv_json_read_envir())
1289
1309
1290
- # fix up strings if necessary
1310
+ # fix up strings if necessary -- do so only with reversible patterns
1311
+ patterns <- Filter(function (pattern ) pattern [[3L ]], patterns )
1291
1312
renv_json_read_remap(result , patterns )
1292
-
1313
+
1293
1314
}
1294
1315
1295
1316
0 commit comments