ThinkR-open / attachment

Tools to deal with dependencies in scripts, Rmd and packages
https://thinkr-open.github.io/attachment/
Other
108 stars 13 forks source link

Get remotes in desc for github packages #20

Closed Cervangirard closed 2 years ago

Cervangirard commented 4 years ago

We could use something like this to get remotes for DESCRIPTION files

pkg <- attachment::att_from_description()
test <- lapply(pkg, function(x){
  packageDescription(x)
  }) %>%
  setNames(pkg)
cran_or_not <- lapply(test, function(x){
  print(x)
  x[["Repository"]]
  }) %>%
  sapply(., is.null)

github_pkg <- names(cran_or_not[cran_or_not])
cran_pkg <- names(cran_or_not[!cran_or_not])
github_repo <- lapply(github_pkg,function(x) {
  desc <- test[[x]]
  tolower(paste(desc$RemoteUsername, desc$RemoteRepo, sep = "/"))
  }) %>%
  setNames(github_pkg)
lapply(cran_pkg, install.packages)
lapply(github_repo, remotes::install_github)
statnmap commented 3 years ago

Please verify that the proposition works and adds the correct field in DESCRIPTION