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

Add use_r_universe_badge() #1994

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open

Add use_r_universe_badge() #1994

wants to merge 7 commits into from

Conversation

olivroy
Copy link
Contributor

@olivroy olivroy commented May 18, 2024

FIx #1883

It has limitations, in the sense that it doesn't verify that the repo actually exists. It would also be great to add the r-universe installation options too.

I could add this to the badge with ui_code()

install.packages('{pkg}', repos = c('https://{org}.r-universe.dev', 'https://cloud.r-project.org'))

It worked out of the box with usethis
image

implementation considerations

  • marked it as experimental
  • requires a (github?) url in DESCRIPTION, or can probably manage with only git remote.
  • Assumes r-universe is set up (which is true for CRAN packages that have a repo link in DESCRIPTION), although it would probably be great to check if R-universe is set-up and nudge towards r-universe help, but that seems out of scope for this PR.
  • If the repo name is different than packages name, it doesn't affect the r-universe url. So rstudio/pins-r still has the
  • Doesn't currently care for a r-universe.dev link in description, (probably should though, but I didn't want the function to get too complicated)
  • Added an example for how to manually setup a r-universe badge in use_badge()

If you want, you can let me know what you think @jeroen. And you'd probably best to implement this function.

ideas

A browse_r_universe() similar to browse_github() would probably be useful and easy to implement + the badge could build on top of this.

man page preview

image

R/badge.R Outdated
Comment on lines 154 to 171
check_is_package("use_r_universe_badge()")
# The r-universe link needs the package name + organization.

pkg <- project_name()
url <- tryCatch(github_url(pkg), error = function(e) NULL)
# in order to get organization
desc <- proj_desc()
urls <- desc$get_urls()
dat <- parse_github_remotes(c(urls, url))
gh_org <- unique(dat$repo_owner[!is.na(dat$repo_owner)])
if (length(gh_org) == 0L) {
ui_abort(c(
"{.pkg {pkg}} must have a repo URL in DESCRITPION to create a badge.",
"Use {.fn usethis::use_badge} if you have a different configuration.",
"If {.pkg {pkg}} is on CRAN, you can also see {.url cran.dev/{pkg}}
for a redirect to the r-universe homepage."
))
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This feels like a lot a custom code for a task we do elsewhere, even in other badge functions. Seems like target_repo_spec() is relevant.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Badge for r-universe?
2 participants