| 1 |
|
| 2 |
renv_cellar_roots <- function(project = NULL) { |
| 3 |
c( |
| 4 |
renv_paths_renv("cellar", project = project), |
| 5 |
renv_paths_renv("local", project = project), |
| 6 |
renv_paths_cellar(), |
| 7 |
renv_paths_local() |
| 8 |
) |
| 9 |
} |
| 10 |
|
| 11 |
renv_cellar_database <- function(project = NULL) { |
| 12 |
|
| 13 |
# find cellar root directories |
| 14 |
project <- renv_project_resolve(project) |
| 15 |
roots <- renv_cellar_roots(project) |
| 16 |
|
| 17 |
# list files both at top-level + one nested level |
| 18 |
paths <- list.files(roots, full.names = TRUE) |
| 19 |
paths <- c(paths, list.files(paths, full.names = TRUE)) |
| 20 |
|
| 21 |
# grab files that look like packages |
| 22 |
extpat <- "(?:\\.tar\\.gz|\\.tgz|\\.zip)$" |
| 23 |
paths <- grep(extpat, paths, value = TRUE) |
| 24 |
|
| 25 |
# parse into data.frame |
| 26 |
base <- basename(paths) |
| 27 |
parts <- strsplit(base, "_", fixed = TRUE) |
| 28 |
package <- map_chr(parts, `[[`, 1L) |
| 29 |
rest <- map_chr(parts, `[[`, 2L) |
| 30 |
version <- sub(extpat, "", rest) |
| 31 |
|
| 32 |
data_frame( |
| 33 |
Package = package, |
| 34 |
Version = version, |
| 35 |
Path = paths |
| 36 |
) |
| 37 |
|
| 38 |
} |