Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

find github packages now also available on cran #536

Merged
merged 1 commit into from
Oct 28, 2024
Merged
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
107 changes: 51 additions & 56 deletions scripts/check-if-elevated-to-cran.R
Original file line number Diff line number Diff line change
@@ -1,62 +1,57 @@
# See https://github.com/cran-task-views/WebTechnologies/issues/505

# Copy from the bottom of https://cran.r-project.org/web/views/WebTechnologies.html:
packages <- c(
"dashR",
"discgolf",
"feedeR",
"formr",
"gdns",
"ipapi",
"meetupr",
"mockaRoo",
"nominatim",
"PostcodesioR",
"randNames",
"rcloud",
"RDoubleClick",
"rydn",
"securitytxt",
"stackr",
"twitter_ideology",
"twitterreport",
"urlshorteneR",
"useRsnap"
)

packages |>
rlang::set_names() |>
purrr::map_lgl(available::available_on_cran) |>
library(stringr)
library(available)
library(purrr)
library(rvest)

file_content <- readLines("WebTechnologies.md")

github_packages <- unlist(str_extract_all(file_content, "r github\\(\"([^\"]+)\"\\)"))
github_packages <- str_match(github_packages, "r github\\(\"([^\"]+)\"\\)")[, 2]
github_packages <- str_replace(github_packages, ".*/", "")

packages <- list()

# Check each package and print results
for (pkg in github_packages) {
packages[[pkg]] <- available_on_cran(pkg)
}

on_cran <- map_lgl(packages, function(x) isFALSE(as.logical(x)))
on_cran <- github_packages[on_cran]

on_cran %>%
rlang::set_names() %>%
purrr::map_lgl(available::available_on_cran) %>%
tibble::enframe(
value = "available_on_cran"
)

# # A tibble: 20 × 2
# name available_on_cran
# dashR TRUE
# discgolf FALSE # Archived on 2022-11-06 at the maintainer's request.
# feedeR FALSE # Archived on 2021-10-05 as check problems were not corrected in time.
# formr TRUE
# gdns FALSE # Archived on 2022-05-07 as calls defunct default.stringsAsFactors()
# ipapi TRUE
# meetupr TRUE
# mockaRoo TRUE
# nominatim TRUE
# PostcodesioR FALSE # now on cran
# randNames FALSE # Archived on 2022-08-22 at the maintainer's request.
# rcloud TRUE
# RDoubleClick TRUE
# rydn TRUE
# securitytxt FALSE # Archived on 2021-05-14 as check problems were not corrected in time.
# stackr TRUE
# twitter_ideology TRUE
# twitterreport TRUE
# urlshorteneR FALSE # now on cran
# useRsnap TRUE

# p <- packages[1]
# p <- "analogsea"
# address <- sprintf("https://CRAN.R-project.org/package=%s", p)
#
# url(address)
# available::available_on_cran(p)
urls <- sprintf("https://CRAN.R-project.org/package=%s", on_cran)

# read the urls

cran_status <- map(urls, ~{
tryCatch({
url <- .x
read_html(url)
}, error = function(e) {
e
})
})

cran_status <- map(cran_status, ~{
if (inherits(.x, "error")) {
NA
} else {
y <- .x %>%
html_nodes("p") %>%
html_text() %>%
str_detect("removed") %>%
any()
y <- ifelse(y, "removed", "available")
}
})

on_cran[!grep("removed", unlist(cran_status))]