Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions .github/workflows/prevent-generated-docs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: Prevent generated docs in source branches

on:
pull_request:
branches-ignore:
- gh-pages

jobs:
prevent-generated-docs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Reject generated docs changes
env:
BASE_REF: ${{ github.base_ref }}
run: |
git diff --name-status "origin/${BASE_REF}"...HEAD > changed-files.txt
if awk '$1 !~ /^D/ && $2 ~ /^docs\// { found = 1 } END { exit !found }' changed-files.txt; then
echo "Generated docs/ files belong on gh-pages, not source branches."
exit 1
fi
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
.Ruserdata
.positai
.DS_Store
docs
# Generated pkgdown site. The published copy is maintained on the gh-pages branch.
docs/
README.html
SRS.*
extras/SRS.qmd
Expand Down
26 changes: 18 additions & 8 deletions R/getPkgZips.R
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#' Download zip-compressed Windows binaries from a renv.lock file
#'
#'A function that locates and downloads Windows binaries (.zip) from CRAN based on packages specified in a renv.lock file.
#' A function that locates and downloads Windows binaries (.zip) from CRAN based on packages specified in a renv.lock file.
#' @param lockfile_path Path to renv.lock file, if empty will search for renv.lock in project directory
#' @param supplement Nested list of packages to supplement or use in place of a renv.lock file
#'
Expand Down Expand Up @@ -29,7 +29,14 @@
#' @importFrom here here
#' @importFrom stats setNames
#' @importFrom utils download.file
getPkgZips <- function(lockfile_path = NULL, supplement = NULL, override_lock = FALSE, r_rels_vect = c("4.0", "4.1", "4.2", "4.3", "4.4", "4.5", "4.6"), backupRrel = "4.4", outDir = NULL) {
getPkgZips <- function(
lockfile_path = NULL,
supplement = NULL,
override_lock = FALSE,
r_rels_vect = c("4.0", "4.1", "4.2", "4.3", "4.4", "4.5", "4.6"),
backupRrel = "4.4",
outDir = NULL
) {

# If specific lockfile path wasn't provided
if (is.null(lockfile_path)) {
Expand Down Expand Up @@ -127,14 +134,14 @@ getPkgZips <- function(lockfile_path = NULL, supplement = NULL, override_lock =
pkg_results <- list() # initiate list to store package information (version, URL, R-version, etc.)

pkg_vector <- names(pkgsVers_list$Packages) # pull vector of all packages from pkgsVers_list, overrides the previous versio used before searching for requirements

# Searching URLs and downloading ----
for (pkg in pkg_vector) {
version <- pkgsVers_list$Packages[[pkg]]$Version # pull package version from pkgsVers_list

found <- FALSE # initialize as FALSE
if (!(is.null(version))) { # if a version is specified, then search!
for (r_rel in sort(r_rels_vect, decreasing = TRUE)) { # try newest R version first
found <- FALSE # initalize as FALSE
# found <- FALSE # initialize as FALSE! Don't declare here, leads to errors saying package is found but giving the URL and name of the last found package
test_url <- paste0("https://cran.r-project.org/bin/windows/contrib/", r_rel, "/", pkg, "_", version , ".zip")

if (httr::HEAD(test_url)$status_code == 200) { # status_code = 200 checks for existence of the URL
Expand Down Expand Up @@ -168,7 +175,7 @@ getPkgZips <- function(lockfile_path = NULL, supplement = NULL, override_lock =
url <- test_url

if (is.null(version)) {
version <- "UNSPECIFIED" # override for print message, only used there within this statement
version <- "UNSPECIFIED" # override for print message
}

cli::cli_alert_warning(paste0("ALTERNATE: Found ", pkg, " v", alt_version, " under R v", backupRrel, " as an alternate to ", pkg, " v", version))
Expand All @@ -187,7 +194,10 @@ getPkgZips <- function(lockfile_path = NULL, supplement = NULL, override_lock =
}

if (!found) { # if the package isn't found under the alternate version of R
cli::cli_alert_danger(cat(paste0("PACKAGE NOT FOUND: Unable to find ", pkg, " v", version, " or a suitable alternate version under R v", backupRrel)), "\n")
if (is.null(version)) {
version <- "UNSPECIFIED" # override for print message
}
cli::cli_alert_danger(paste0("PACKAGE NOT FOUND: Unable to find ", pkg, " v", version, " or a suitable alternate version under R v", backupRrel), "\n") # got rid of cat() for testing pr
pkg_list <- list(Package = pkg,
Version = version,
R_release = NULL,
Expand Down Expand Up @@ -221,9 +231,9 @@ getPkgZips <- function(lockfile_path = NULL, supplement = NULL, override_lock =
cli::cli_alert_danger(paste0("Unable to find ", length(unique(not_found)), " package(s)"))
}

cat("Check the returned list for more details!")
# cli::cli_alert_info("Check the returned list for more details!")

return(pkg_results)
return(invisible())

}

74 changes: 0 additions & 74 deletions docs/404.html

This file was deleted.

3 changes: 0 additions & 3 deletions docs/404.md

This file was deleted.

Loading
Loading