Created
June 12, 2023 03:41
-
-
Save nanxstats/a8d386c019bfa6e7eab671c090bca8ce to your computer and use it in GitHub Desktop.
Create R package release checklists without requiring project or version control context
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#' Create a release checklist without requiring context | |
#' | |
#' @param package Package name. | |
#' @param version Release version number. | |
#' @param on_cran Is the package already on CRAN? Default is `TRUE`. | |
#' @param has_news Does the package use `NEWS.md`? Default is `TRUE`. | |
#' @param has_readme Does the package use `README.Rmd`? Default is `FALSE`. | |
#' @param has_lifecycle Does the package use lifecycle? Default is `FALSE`. | |
#' | |
#' @return Release checklist in Markdown format (invisibly). | |
#' | |
#' @examples | |
#' use_release_checklist("pkgname", version = "0.2.0") | |
#' use_release_checklist("pkgname", version = "0.1.0", on_cran = FALSE) | |
use_release_checklist <- function( | |
package, | |
version, | |
on_cran = TRUE, | |
has_news = TRUE, | |
has_readme = FALSE, | |
has_lifecycle = FALSE) { | |
checklist <- getFromNamespace("release_checklist", "usethis") | |
dir <- tempfile() | |
dir.create(dir) | |
on.exit(unlink(dir, recursive = TRUE), add = TRUE) | |
withr::with_dir(dir, { | |
write(paste("Package:", package), "DESCRIPTION") | |
if (has_news) file.create("NEWS.md") | |
if (has_lifecycle) write("Imports: lifecycle", "DESCRIPTION", append = TRUE) | |
if (has_readme) file.create("README.Rmd") | |
}) | |
mkd <- usethis::with_project( | |
dir, checklist(version = version, on_cran = on_cran), | |
quiet = TRUE | |
) | |
cat(mkd, sep = "\n") | |
invisible(mkd) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment