Skip to content

Commit

Permalink
Merge branch 'r-lib:main' into challenge-uncommited-tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
olivroy authored Nov 26, 2024
2 parents 0e95811 + 20e7eb2 commit f20c5f4
Show file tree
Hide file tree
Showing 34 changed files with 412 additions and 283 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: usethis
Title: Automate Package and Project Setup
Version: 3.0.0.9000
Version: 3.1.0
Authors@R: c(
person("Hadley", "Wickham", , "[email protected]", role = "aut",
comment = c(ORCID = "0000-0003-4757-117X")),
Expand Down
24 changes: 15 additions & 9 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,21 @@
# usethis (development version)
# usethis 3.1.0

## Bug fixes and minor improvements
* `use_vignette()` and `use_article()` support Quarto. The `name` of the new
vignette or article can optionally include a file extension to signal whether
`.Rmd` or `.qmd` is desired, with `.Rmd` remaining the default for now. Thanks
to @olivroy for getting the ball rolling (#1997).

* `use_data()` defaults to serialization version 3 (@laurabrianna, #2044).

* `use_package()` can lower a minimum version requirement
(@jplecavalier, #1957).

* `use_package()` now decreases a package minimum version required when
`min_version` is lower than what is currently specified in the DESCRIPTION
file (@jplecavalier, #1957).

* `use_data()` now uses serialization version 3 by default. (@laurabrianna, #2044)
* `use_release_issue()` only suggests doing reverse dependency checks if there
are, in fact, reverse dependencies (#1817, @seankross).

* Reverse dependency checks are only suggested if they exist
(#1817, @seankross).
* `use_tidy_upkeep_issue()` records the year it is being run in the
`Config/usethis/upkeep` field in DESCRIPTION. If this value exists, it is
used to filter the checklist when making the issue.

# usethis 3.0.0

Expand Down
3 changes: 1 addition & 2 deletions R/author.R
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,7 @@
#' DESCRIPTION file and the user hasn't given any author information via the
#' `fields` argument or the global option `"usethis.description"`. The
#' placeholder looks something like `First Last <[email protected]> [aut,
#' cre] (YOUR-ORCID-ID)` and `use_author()` offers to remove it in interactive
#' sessions.
#' cre]` and `use_author()` offers to remove it in interactive sessions.
#'
#' @inheritParams utils::person
#' @inheritDotParams utils::person
Expand Down
10 changes: 6 additions & 4 deletions R/data.R
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,13 @@ use_data <- function(...,

objs <- get_objs_from_dots(dots(...))

if (version < 3) {
use_dependency("R", "depends", "2.10")
} else {
use_dependency("R", "depends", "3.5")
original_minimum_r_version <- pkg_minimum_r_version()
serialization_minimum_r_version <- if (version < 3) "2.10" else "3.5"
if (is.na(original_minimum_r_version) ||
original_minimum_r_version < serialization_minimum_r_version) {
use_dependency("R", "depends", serialization_minimum_r_version)
}

if (internal) {
use_directory("R")
paths <- path("R", "sysdata.rda")
Expand Down
2 changes: 1 addition & 1 deletion R/description.R
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ usethis_description_defaults <- function(package = NULL) {
Version = "0.0.0.9000",
Title = "What the Package Does (One Line, Title Case)",
Description = "What the package does (one paragraph).",
"Authors@R" = 'person("First", "Last", email = "[email protected]", role = c("aut", "cre"), comment = c(ORCID = "YOUR-ORCID-ID"))',
"Authors@R" = 'person("First", "Last", email = "[email protected]", role = c("aut", "cre"))',
License = "`use_mit_license()`, `use_gpl3_license()` or friends to pick a license",
Encoding = "UTF-8"
)
Expand Down
7 changes: 4 additions & 3 deletions R/release.R
Original file line number Diff line number Diff line change
Expand Up @@ -534,10 +534,11 @@ author_has_rstudio_email <- function() {
pkg_minimum_r_version <- function() {
deps <- proj_desc()$get_deps()
r_dep <- deps[deps$package == "R" & deps$type == "Depends", "version"]
if (length(r_dep) == 0) {
return(numeric_version("0"))
if (length(r_dep) > 0) {
numeric_version(gsub("[^0-9.]", "", r_dep))
} else {
NA_character_
}
numeric_version(gsub("[^0-9.]", "", r_dep))
}

# Borrowed from pak, but modified also retain user's non-cran repos:
Expand Down
5 changes: 2 additions & 3 deletions R/roxygen.R
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ use_roxygen_md <- function(overwrite = FALSE) {
}

# FALSE: no Roxygen field
# TRUE: plain old "list(markdown = TRUE)"
# TRUE: matches regex targetting 'markdown = TRUE', with some whitespace slop
# NA: everything else
uses_roxygen_md <- function() {
desc <- proj_desc()
Expand All @@ -66,8 +66,7 @@ uses_roxygen_md <- function() {
}

roxygen <- desc$get_field("Roxygen", "")
if (identical(roxygen, "list(markdown = TRUE)") ||
identical(roxygen, "list(markdown = TRUE, r6 = FALSE)")) {
if (grepl("markdown\\s*=\\s*TRUE", roxygen)) {
TRUE
} else {
NA
Expand Down
4 changes: 3 additions & 1 deletion R/tidyverse.R
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,9 @@
#' tidyverse conventions around GitHub issue label names and colours.
#'
#' * `use_tidy_upkeep_issue()` creates an issue containing a checklist of
#' actions to bring your package up to current tidyverse standards.
#' actions to bring your package up to current tidyverse standards. Also
#' records the current date in the `Config/usethis/last-upkeep` field in
#' `DESCRIPTION`.
#'
#' * `use_tidy_logo()` calls `use_logo()` on the appropriate hex sticker PNG
#' file at <https://github.com/rstudio/hex-stickers>.
Expand Down
53 changes: 35 additions & 18 deletions R/upkeep.R
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@
#' @export
#' @examples
#' \dontrun{
#' use_upkeep_issue(2023)
#' use_upkeep_issue()
#' }
use_upkeep_issue <- function(year = NULL) {
make_upkeep_issue(year = year, tidy = FALSE)
}

make_upkeep_issue <- function(year, tidy) {
make_upkeep_issue <- function(year, last_upkeep, tidy) {
who <- if (tidy) "use_tidy_upkeep_issue()" else "use_upkeep_issue()"
check_is_package(who)

Expand All @@ -41,7 +41,7 @@ make_upkeep_issue <- function(year, tidy) {

gh <- gh_tr(tr)
if (tidy) {
checklist <- tidy_upkeep_checklist(year, repo_spec = tr$repo_spec)
checklist <- tidy_upkeep_checklist(last_upkeep, repo_spec = tr$repo_spec)
} else {
checklist <- upkeep_checklist(tr)
}
Expand Down Expand Up @@ -118,30 +118,33 @@ upkeep_checklist <- function(target_repo = NULL) {

#' @export
#' @rdname tidyverse
#' @param year Approximate year when you last touched this package. If `NULL`,
#' the default, will give you a full set of actions to perform.
use_tidy_upkeep_issue <- function(year = NULL) {
make_upkeep_issue(year = year, tidy = TRUE)
#' @param last_upkeep Year of last upkeep. By default, the
#' `Config/usethis/last-upkeep` field in `DESCRIPTION` is consulted for this, if
#' it's defined. If there's no information on the last upkeep, the issue will
#' contain the full checklist.
use_tidy_upkeep_issue <- function(last_upkeep = last_upkeep_year()) {
make_upkeep_issue(year = NULL, last_upkeep = last_upkeep, tidy = TRUE)
record_upkeep_date(Sys.Date())
}

# for mocking
Sys.Date <- NULL

tidy_upkeep_checklist <- function(year = NULL, repo_spec = "OWNER/REPO") {
tidy_upkeep_checklist <- function(last_upkeep = last_upkeep_year(),
repo_spec = "OWNER/REPO") {
desc <- proj_desc()

posit_pkg <- is_posit_pkg()
posit_person_ok <- is_posit_person_canonical()

year <- year %||% 2000

bullets <- c(
"### To begin",
"",
todo('`pr_init("upkeep-{format(Sys.Date(), "%Y-%m")}")`'),
""
)

if (year <= 2000) {
if (last_upkeep <= 2000) {
bullets <- c(
bullets,
"### Pre-history",
Expand All @@ -156,7 +159,7 @@ tidy_upkeep_checklist <- function(year = NULL, repo_spec = "OWNER/REPO") {
""
)
}
if (year <= 2020) {
if (last_upkeep <= 2020) {
bullets <- c(
bullets,
"### 2020",
Expand All @@ -167,7 +170,7 @@ tidy_upkeep_checklist <- function(year = NULL, repo_spec = "OWNER/REPO") {
""
)
}
if (year <= 2021) {
if (last_upkeep <= 2021) {
bullets <- c(
bullets,
"### 2021",
Expand All @@ -177,7 +180,7 @@ tidy_upkeep_checklist <- function(year = NULL, repo_spec = "OWNER/REPO") {
""
)
}
if (year <= 2022) {
if (last_upkeep <= 2022) {
bullets <- c(
bullets,
"### 2022",
Expand All @@ -190,9 +193,7 @@ tidy_upkeep_checklist <- function(year = NULL, repo_spec = "OWNER/REPO") {
)
}

if (year <= 2023) {
desc <- proj_desc()

if (last_upkeep <= 2023) {
bullets <- c(
bullets,
"### 2023",
Expand Down Expand Up @@ -242,14 +243,15 @@ tidy_upkeep_checklist <- function(year = NULL, repo_spec = "OWNER/REPO") {
)
}

minimum_r_version <- pkg_minimum_r_version()
bullets <- c(
bullets,
"### To finish",
"",
todo("`usethis::use_mit_license()`", grepl("MIT", desc$get_field("License"))),
todo(
'`usethis::use_package("R", "Depends", "{tidy_minimum_r_version()}")`',
tidy_minimum_r_version() > pkg_minimum_r_version()
is.na(minimum_r_version) || tidy_minimum_r_version() > minimum_r_version
),
todo("`usethis::use_tidy_description()`"),
todo("`usethis::use_tidy_github_actions()`"),
Expand Down Expand Up @@ -327,3 +329,18 @@ has_old_cran_comments <- function() {
file_exists(cc) &&
any(grepl("# test environment", readLines(cc), ignore.case = TRUE))
}

last_upkeep_date <- function() {
as.Date(
proj_desc()$get_field("Config/usethis/last-upkeep", "2000-01-01"),
format = "%Y-%m-%d"
)
}

last_upkeep_year <- function() {
as.integer(format(last_upkeep_date(), "%Y"))
}

record_upkeep_date <- function(date) {
proj_desc_field_update("Config/usethis/last-upkeep", format(date, "%Y-%m-%d"))
}
Loading

0 comments on commit f20c5f4

Please sign in to comment.