From bec3821b96b23df10a7f7e8601337551d9a86202 Mon Sep 17 00:00:00 2001 From: Pawel Rucki <12943682+pawelru@users.noreply.github.com> Date: Fri, 19 Apr 2024 13:35:04 +0200 Subject: [PATCH 1/7] rvest published date if empty --- DESCRIPTION | 2 ++ R/deps_installation_proposal.R | 2 +- R/get_ref.R | 19 +++++++++++++++++++ tests/testthat/{setup.R => setup-envvar.R} | 0 4 files changed, 22 insertions(+), 1 deletion(-) rename tests/testthat/{setup.R => setup-envvar.R} (100%) diff --git a/DESCRIPTION b/DESCRIPTION index 28bd76d3..d716f82a 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -22,6 +22,7 @@ Imports: pkgdepends (>= 0.5.0), rcmdcheck, remotes (>= 2.2.0), + rvest, stats, utils, withr (>= 2.4.3) @@ -36,6 +37,7 @@ Config/Needs/verdepcheck: r-lib/pkgdepends, r-lib/rcmdcheck, r-lib/remotes, + tidyverse/rvest, r-lib/withr, yihui/knitr, r-lib/pingr, diff --git a/R/deps_installation_proposal.R b/R/deps_installation_proposal.R index 8947d038..838a985c 100644 --- a/R/deps_installation_proposal.R +++ b/R/deps_installation_proposal.R @@ -202,7 +202,7 @@ new_min_cohort_deps_installation_proposal <- function(path, # nolint origin = "1970-01-01" ) - ppm_repo <- get_ppm_snapshot_by_date(max_release_date) + ppm_repo <- get_ppm_snapshot_by_date(max_release_date + 1) config <- append_config(config, list("cran_mirror" = ppm_repo)) diff --git a/R/get_ref.R b/R/get_ref.R index 1a793ca2..56f13872 100644 --- a/R/get_ref.R +++ b/R/get_ref.R @@ -438,6 +438,25 @@ get_cran_data <- function(package) { cran_current <- pkgcache::meta_cache_list(packages = package)[, c( "type", "package", "version", "published" )] + if (all(is.na(cran_current$published))) { + # workaround of https://github.com/r-lib/pkgcache/issues/109 + # if fixed - please investigate removing `rvest` dependency + scrapped_table <- head( + rvest::html_table( + rvest::html_element( + rvest::read_html(sprintf("https://CRAN.R-project.org/package=%s", package)), + "table" + ) + ), + 5 + ) + cran_current <- data.frame( + type = "cran", + package = package, + version = scrapped_table[scrapped_table$X1 == "Version:", "X2"][[1]], + published = scrapped_table[scrapped_table$X1 == "Published:", "X2"][[1]] + ) + } # Bioc custom logic as packages in Bioconductor do not return a published date # this will be immediately obsolete if {pkgcache} starts to return a non-NA value diff --git a/tests/testthat/setup.R b/tests/testthat/setup-envvar.R similarity index 100% rename from tests/testthat/setup.R rename to tests/testthat/setup-envvar.R From 36f6351b6c39c71a4c5b431bd54242695a06b387 Mon Sep 17 00:00:00 2001 From: github-actions <41898282+github-actions[bot]@users.noreply.github.com> Date: Fri, 19 Apr 2024 11:42:23 +0000 Subject: [PATCH 2/7] [skip roxygen] [skip vbump] Roxygen Man Pages Auto Update --- DESCRIPTION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DESCRIPTION b/DESCRIPTION index d716f82a..e85ba0a8 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -48,5 +48,5 @@ Encoding: UTF-8 Language: en-US LazyData: true Roxygen: list(markdown = TRUE) -RoxygenNote: 7.2.3 +RoxygenNote: 7.3.1 Config/testthat/edition: 3 From 044f064dd9ee8185aa80ec138b71164cd45823e7 Mon Sep 17 00:00:00 2001 From: Pawel Rucki <12943682+pawelru@users.noreply.github.com> Date: Fri, 19 Apr 2024 13:49:20 +0200 Subject: [PATCH 3/7] lint --- R/deps_installation_proposal.R | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/R/deps_installation_proposal.R b/R/deps_installation_proposal.R index 838a985c..b0fceb5b 100644 --- a/R/deps_installation_proposal.R +++ b/R/deps_installation_proposal.R @@ -130,9 +130,11 @@ new_min_cohort_deps_installation_proposal <- function(path, # nolint refs, function(x) { version <- version_from_desc(d, x$package) - if (inherits(x, "remote_ref_github") && + if ( + inherits(x, "remote_ref_github") && check_if_on_cran(x, version$op, version$op_ver) && - x$commitish == "") { + x$commitish == "" + ) { pkgdepends::parse_pkg_ref(x$package) } else { x From 925077e0d6fff1c22715394606af372d03a9eaae Mon Sep 17 00:00:00 2001 From: github-actions <41898282+github-actions[bot]@users.noreply.github.com> Date: Fri, 19 Apr 2024 11:51:17 +0000 Subject: [PATCH 4/7] [skip style] [skip vbump] Restyle files --- R/deps_installation_proposal.R | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/R/deps_installation_proposal.R b/R/deps_installation_proposal.R index b0fceb5b..3cde74a6 100644 --- a/R/deps_installation_proposal.R +++ b/R/deps_installation_proposal.R @@ -132,8 +132,8 @@ new_min_cohort_deps_installation_proposal <- function(path, # nolint version <- version_from_desc(d, x$package) if ( inherits(x, "remote_ref_github") && - check_if_on_cran(x, version$op, version$op_ver) && - x$commitish == "" + check_if_on_cran(x, version$op, version$op_ver) && + x$commitish == "" ) { pkgdepends::parse_pkg_ref(x$package) } else { From ef008e5edb5785cf4be862d428b61a3e0240eaf9 Mon Sep 17 00:00:00 2001 From: Pawel Rucki <12943682+pawelru@users.noreply.github.com> Date: Fri, 19 Apr 2024 13:57:37 +0200 Subject: [PATCH 5/7] empty commit From 4c313d00c0248f728271792374ceeb6d87857449 Mon Sep 17 00:00:00 2001 From: Pawel Rucki <12943682+pawelru@users.noreply.github.com> Date: Fri, 19 Apr 2024 15:00:51 +0200 Subject: [PATCH 6/7] use tools instead --- DESCRIPTION | 3 +-- R/get_ref.R | 15 +++------------ 2 files changed, 4 insertions(+), 14 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index e85ba0a8..3c5574e8 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -22,8 +22,8 @@ Imports: pkgdepends (>= 0.5.0), rcmdcheck, remotes (>= 2.2.0), - rvest, stats, + tools, utils, withr (>= 2.4.3) Suggests: @@ -37,7 +37,6 @@ Config/Needs/verdepcheck: r-lib/pkgdepends, r-lib/rcmdcheck, r-lib/remotes, - tidyverse/rvest, r-lib/withr, yihui/knitr, r-lib/pingr, diff --git a/R/get_ref.R b/R/get_ref.R index 56f13872..d1d880a3 100644 --- a/R/get_ref.R +++ b/R/get_ref.R @@ -440,21 +440,12 @@ get_cran_data <- function(package) { )] if (all(is.na(cran_current$published))) { # workaround of https://github.com/r-lib/pkgcache/issues/109 - # if fixed - please investigate removing `rvest` dependency - scrapped_table <- head( - rvest::html_table( - rvest::html_element( - rvest::read_html(sprintf("https://CRAN.R-project.org/package=%s", package)), - "table" - ) - ), - 5 - ) + db <- subset(tools::CRAN_package_db(), Package == package) cran_current <- data.frame( type = "cran", package = package, - version = scrapped_table[scrapped_table$X1 == "Version:", "X2"][[1]], - published = scrapped_table[scrapped_table$X1 == "Published:", "X2"][[1]] + version = db$Version, + published = as.POSIXct(db$`Date/Publication`) ) } From 07c97c0802c9473a0e7ed34a1b0e2aa0a69355bd Mon Sep 17 00:00:00 2001 From: Pawel Rucki <12943682+pawelru@users.noreply.github.com> Date: Fri, 19 Apr 2024 17:19:29 +0200 Subject: [PATCH 7/7] use pkgenv --- R/get_ref.R | 5 ++++- R/utils.R | 2 ++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/R/get_ref.R b/R/get_ref.R index d1d880a3..9171cf9a 100644 --- a/R/get_ref.R +++ b/R/get_ref.R @@ -440,7 +440,10 @@ get_cran_data <- function(package) { )] if (all(is.na(cran_current$published))) { # workaround of https://github.com/r-lib/pkgcache/issues/109 - db <- subset(tools::CRAN_package_db(), Package == package) + if (is.null(pkgenv$cache_db)) { + pkgenv$cache_db <- tools::CRAN_package_db() + } + db <- subset(pkgenv$cache_db, Package == package) cran_current <- data.frame( type = "cran", package = package, diff --git a/R/utils.R b/R/utils.R index 8b72a9da..94d79282 100644 --- a/R/utils.R +++ b/R/utils.R @@ -4,6 +4,8 @@ .desc_field <- "Config/Needs/verdepcheck" +pkgenv <- new.env(parent = emptyenv()) + #' @importFrom pkgdepends as_pkg_dependencies default_config <- function() { list(