diff --git a/DESCRIPTION b/DESCRIPTION index 35efac7..5655eb6 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,7 +1,7 @@ Package: r.releases.utils Title: Utilities for An R Universe of Package Releases Description: Utilities for an R universe of package releases. -Version: 0.0.5 +Version: 0.0.6 License: MIT + file LICENSE URL: https://r-releases.github.io/r.releases.utils/, diff --git a/NAMESPACE b/NAMESPACE index 6bd490d..24a3379 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -9,6 +9,8 @@ export(try_message) importFrom(gh,gh) importFrom(jsonlite,parse_json) importFrom(jsonlite,read_json) +importFrom(nanonext,ncurl) importFrom(nanonext,parse_url) +importFrom(nanonext,status_code) importFrom(pkgsearch,cran_package) importFrom(vctrs,vec_rbind) diff --git a/NEWS.md b/NEWS.md index f3f949c..8447807 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,3 +1,7 @@ +# r.releases.utils 0.0.6 + +* Check URL exists as part of package verification. + # r.releases.utils 0.0.5 * Write pretty JSON to `packages.json` (@llrs, https://github.com/r-releases/help/issues/4). diff --git a/R/assert_package.R b/R/assert_package.R index 228f668..d8b08c7 100644 --- a/R/assert_package.R +++ b/R/assert_package.R @@ -47,6 +47,17 @@ assert_package <- function(name, url) { if (identical(owner, "cran")) { return(paste("URL", shQuote(url), "appears to use a CRAN mirror.")) } + status <- nanonext::ncurl(url)[["status"]] + if (status != 200L) { + return( + paste( + "URL", + shQuote(url), + "returned HTTP error", + nanonext::status_code(status) + ) + ) + } assert_cran_url(name = name, url = url) } diff --git a/R/package.R b/R/package.R index 704c66f..f73f627 100644 --- a/R/package.R +++ b/R/package.R @@ -4,7 +4,7 @@ #' @family help #' @importFrom gh gh #' @importFrom jsonlite parse_json read_json -#' @importFrom nanonext parse_url +#' @importFrom nanonext ncurl parse_url status_code #' @importFrom pkgsearch cran_package #' @importFrom vctrs vec_rbind NULL diff --git a/tests/test-assert_package.R b/tests/test-assert_package.R index 8eafc58..5bef07d 100644 --- a/tests/test-assert_package.R +++ b/tests/test-assert_package.R @@ -140,6 +140,17 @@ stopifnot( ) ) +stopifnot( + grepl( + "returned HTTP error", + r.releases.utils::assert_package( + name = "afantasticallylongandimpossiblepackage", + url = "https://github.com/r-lib/afantasticallylongandimpossiblepackage" + ), + fixed = TRUE + ) +) + stopifnot( is.null( r.releases.utils::assert_package(