|
| 1 | +#' @export |
| 2 | +#' @rdname tidyverse |
| 3 | +#' @param year Approximate year when you last touched this package. If `NULL`, |
| 4 | +#' the default, will give you a full set of actions to perform. |
| 5 | +use_tidy_upkeep_issue <- function(year = NULL) { |
| 6 | + check_is_package("use_tidy_upkeep_issue()") |
| 7 | + |
| 8 | + tr <- target_repo(github_get = TRUE) |
| 9 | + if (!isTRUE(tr$can_push)) { |
| 10 | + ui_line(" |
| 11 | + It is very unusual to open an upkeep issue on a repo you can't push to: |
| 12 | + {ui_value(tr$repo_spec)}") |
| 13 | + if (ui_nope("Do you really want to do this?")) { |
| 14 | + ui_oops("Cancelling.") |
| 15 | + return(invisible()) |
| 16 | + } |
| 17 | + } |
| 18 | + |
| 19 | + checklist <- upkeep_checklist(year) |
| 20 | + |
| 21 | + gh <- gh_tr(tr) |
| 22 | + issue <- gh( |
| 23 | + "POST /repos/{owner}/{repo}/issues", |
| 24 | + title = glue("Upkeep for {project_name()}"), |
| 25 | + body = paste0(checklist, "\n", collapse = "") |
| 26 | + ) |
| 27 | + view_url(issue$html_url) |
| 28 | +} |
| 29 | + |
| 30 | +upkeep_checklist <- function(year = NULL) { |
| 31 | + year <- year %||% 2000 |
| 32 | + bullets <- c() |
| 33 | + |
| 34 | + if (year <= 2000) { |
| 35 | + bullets <- c(bullets, |
| 36 | + "Pre-history", |
| 37 | + "", |
| 38 | + todo("`usethis::use_readme_rmd()`"), |
| 39 | + todo("`usethis::use_roxygen_md()`"), |
| 40 | + todo(" |
| 41 | + `usethis::use_github_links()` |
| 42 | + It is advantageous if the link to your GitHub repo comes first, \\ |
| 43 | + before any other URLs, e.g. pkgdown site."), |
| 44 | + todo("`usethis::use_pkgdown_github_pages()`"), |
| 45 | + todo("`usethis::use_tidy_labels()`"), |
| 46 | + todo("`usethis::use_tidy_style()`"), |
| 47 | + todo("`usethis::use_tidy_description()`"), |
| 48 | + todo("`urlchecker::url_check()`"), |
| 49 | + "" |
| 50 | + ) |
| 51 | + } |
| 52 | + if (year <= 2020) { |
| 53 | + bullets <- c(bullets, |
| 54 | + "2020", |
| 55 | + "", |
| 56 | + todo(" |
| 57 | + `usethis::use_package_doc()` |
| 58 | + Consider letting usethis manage your `@importFrom` directives here. |
| 59 | + `usethis::use_import_from()` is handy for this."), |
| 60 | + todo(" |
| 61 | + `usethis::use_testthat(3)` and upgrade to 3e, \\ |
| 62 | + [testthat 3e vignette](https://testthat.r-lib.org/articles/third-edition.html)"), |
| 63 | + todo(" |
| 64 | + Align the names of `R/` files and `test/` files for workflow happiness. |
| 65 | + `usethis::rename_files()` can be helpful."), |
| 66 | + "" |
| 67 | + ) |
| 68 | + } |
| 69 | + if (year <= 2021) { |
| 70 | + bullets <- c(bullets, |
| 71 | + "2021", |
| 72 | + "", |
| 73 | + todo("`usethis::use_tidy_description()`", year > 2000), |
| 74 | + todo("`usethis::use_tidy_dependencies()`"), |
| 75 | + todo(" |
| 76 | + `usethis::use_tidy_github_actions()` and update artisanal actions to \\ |
| 77 | + use `setup-r-dependencies`"), |
| 78 | + todo("Remove check environments section from `cran-comments.md`"), |
| 79 | + todo("Bump required R version in DESCRIPTION to {tidy_minimum_r_version()}"), |
| 80 | + todo(" |
| 81 | + Use lifecycle instead of artisanal deprecation messages, as described \\ |
| 82 | + in [Communicate lifecycle changes in your functions](https://lifecycle.r-lib.org/articles/communicate.html)"), |
| 83 | + "" |
| 84 | + ) |
| 85 | + } |
| 86 | + |
| 87 | + bullets |
| 88 | +} |
| 89 | + |
| 90 | +# https://www.tidyverse.org/blog/2019/04/r-version-support/ |
| 91 | +tidy_minimum_r_version <- function() { |
| 92 | + con <- curl::curl("https://api.r-hub.io/rversions/r-oldrel/4") |
| 93 | + withr::defer(close(con)) |
| 94 | + # I do not want a failure here to make use_tidy_upkeep_issue() fail |
| 95 | + json <- tryCatch(readLines(con, warn = FALSE), error = function(e) NULL) |
| 96 | + if (is.null(json)) { |
| 97 | + oldrel_4 <- "3.4" |
| 98 | + } else { |
| 99 | + version <- jsonlite::fromJSON(json)$version |
| 100 | + oldrel_4 <- re_match(version, "[0-9]+[.][0-9]+")$.match |
| 101 | + } |
| 102 | + oldrel_4 |
| 103 | +} |
0 commit comments