|
|
|
|
|
path <- "repos.json" |
|
|
|
if (!fs::file_exists(path)) { |
|
repos <- gh::gh( |
|
"GET https://api.github.com/orgs/CRAN/repos", |
|
.limit = Inf, |
|
.progress = TRUE |
|
) |
|
jsonlite::write_json(repos, path) |
|
} else { |
|
repos <- jsonlite::read_json(path) |
|
} |
|
|
|
|
|
fs::dir_create("CRAN") |
|
|
|
download_repo <- purrr::insistently(function(repo) { |
|
repo_name <- as.character(repo$name) |
|
|
|
dest <- glue::glue("CRAN/{repo_name}.zip") |
|
if (fs::file_exists(dest)) { |
|
return() |
|
} |
|
|
|
gh::gh( |
|
"GET /repos/cran/{repo_name}/zipball", |
|
repo_name = repo_name, |
|
.destfile = dest |
|
) |
|
}) |
|
|
|
library(future) |
|
plan(multisession, workers = 6) |
|
furrr::future_map( |
|
repos, |
|
download_repo, |
|
.progress = TRUE |
|
) |
|
|