#' Get system requirements by R package
#'
#' @param packages character vector of packages names
#' @param quiet boolean if TRUE the function is quiet
#' @param batch_n number of simultaneous packages to ask
#'
#' @return character vector of sysreqs
#' @export
#'
#' @importFrom remotes package_deps
get_sysreqs <- function(packages, quiet = TRUE, batch_n = 30) {
all_deps <- sort(unique(c(packages, unlist(remotes::package_deps(packages)$package))))
sp <- split(all_deps, ceiling(seq_along(all_deps)/batch_n))
hold <- lapply(sp, function(.x) {
get_batch_sysreqs(.x, quiet = quiet)
}) %>%
unlist() %>%
unname() %>%
unique() %>%
sort()
setdiff(hold, sysreqs_in_base)
}
#' @keywords internal
#' @noRd
#' @importFrom fs file_temp file_delete
#' @importFrom jsonlite fromJSON
#' @importFrom utils download.file
get_batch_sysreqs <- function(all_deps, quiet = TRUE) {
url <- sprintf("https://sysreqs.r-hub.io/pkg/%s/linux-x86_64-debian-gcc",
paste(all_deps, collapse = ","))
path <- fs::file_temp()
utils::download.file(url, path, mode = "wb", quiet = quiet)
out <- jsonlite::fromJSON(path)
fs::file_delete(path)
unique(out[!is.na(out)])
}
sysreqs_in_base <- c("gdebi-core",
"git-core",
"libcurl4-gnutls-dev",
"wget")
# get_sysreqs("inst/testapp")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.