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

rdev 1.8.6 #174

Merged
merged 6 commits into from
Nov 28, 2023
Merged
Show file tree
Hide file tree
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
3 changes: 2 additions & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: rdev
Title: R Development Tools
Version: 1.8.5
Version: 1.8.6
Authors@R:
person("John", "Benninghoff", , "[email protected]", role = c("aut", "cre"),
comment = c(ORCID = "0000-0002-6230-4742"))
Expand All @@ -11,6 +11,7 @@ URL: https://jabenninghoff.github.io/rdev/,
https://github.com/jabenninghoff/rdev
BugReports: https://github.com/jabenninghoff/rdev/issues
Imports:
checkmate,
cli,
curl,
desc,
Expand Down
4 changes: 4 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# rdev 1.8.6

* Check function arguments with [checkmate](https://mllg.github.io/checkmate/index.html)

# rdev 1.8.5

* Changed `use_analysis_package()` to store `_freeze` directory in git per Quarto [guide](https://quarto.org/docs/projects/code-execution.html#using-freeze)
Expand Down
1 change: 1 addition & 0 deletions R/build.R
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ unfreeze <- function() {
#'
#' @export
build_quarto_site <- function(input = NULL, as_job = FALSE, unfreeze = FALSE, ...) {
checkmate::assert_flag(unfreeze)
if (!fs::file_exists("README.Rmd")) {
stop("README.Rmd does not exist")
}
Expand Down
13 changes: 13 additions & 0 deletions R/ci.R
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
#' }
#' @export
check_renv <- function(update = rlang::is_interactive()) {
checkmate::assert_flag(update)

writeLines("renv::status(dev = TRUE)")
renv::status(dev = TRUE)

Expand Down Expand Up @@ -117,6 +119,17 @@ ci <- function(renv = TRUE, # nolint: cyclocomp_linter.
extra = TRUE,
urls = TRUE,
rcmdcheck = TRUE) {
checkmate::assert_flag(renv)
checkmate::assert_flag(missing)
checkmate::assert_flag(pkgdown)
checkmate::assert_flag(styler, null.ok = TRUE)
checkmate::assert_flag(lintr)
checkmate::assert_flag(document)
checkmate::assert_flag(normalize)
checkmate::assert_flag(extra)
checkmate::assert_flag(urls)
checkmate::assert_flag(rcmdcheck)

if (renv) {
writeLines("renv::status(dev = TRUE)")
status <- renv::status(dev = TRUE)
Expand Down
6 changes: 3 additions & 3 deletions R/helpers.R
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@
#' }
#' @export
local_temppkg <- function(dir = fs::file_temp(), type = "usethis", env = parent.frame()) {
if (!(type %in% c("usethis", "rdev", "analysis", "quarto"))) {
stop("unrecognized package type, '", type, "'")
}
checkmate::assert_string(dir)
checkmate::assert_choice(type, c("usethis", "rdev", "analysis", "quarto"))
checkmate::assert_environment(env)

# capture the current project - use try() since proj_get() will error within rcmdcheck()
old_project <- NULL
Expand Down
9 changes: 9 additions & 0 deletions R/release.R
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@
#'
#' @export
new_branch <- function(name, bump_ver = TRUE, current = FALSE) {
checkmate::assert_string(name)
checkmate::assert_flag(bump_ver)
checkmate::assert_flag(current)

if (gert::git_branch_exists(name, local = TRUE)) {
stop("local branch exists")
}
Expand Down Expand Up @@ -66,6 +70,7 @@ get_release <- function(pkg = ".", filename = "NEWS.md") {
if (pkg != ".") {
stop('currently only get_release(pkg = ".") is supported')
}
checkmate::assert_string(filename)

pkg_obj <- devtools::as.package(pkg)
header_regex <- paste0(
Expand Down Expand Up @@ -134,6 +139,8 @@ stage_release <- function(pkg = ".", filename = "NEWS.md", host = getOption("rde
if (pkg != ".") {
stop('currently only stage_release(pkg = ".") is supported')
}
checkmate::assert_string(filename)
checkmate::assert_string(host, null.ok = TRUE)

rel <- get_release(pkg = pkg, filename = filename)

Expand Down Expand Up @@ -236,6 +243,8 @@ merge_release <- function(pkg = ".", filename = "NEWS.md", host = getOption("rde
if (pkg != ".") {
stop('currently only merge_release(pkg = ".") is supported')
}
checkmate::assert_string(filename)
checkmate::assert_string(host, null.ok = TRUE)

rel <- get_release(pkg = pkg, filename = filename)
pr_title <- paste0(rel$package, " ", rel$version)
Expand Down
11 changes: 11 additions & 0 deletions R/setup.R
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,8 @@ get_github_repo <- function() {
#' @keywords internal
#' @noRd
fix_gitignore <- function(path = ".") {
checkmate::assert_string(path)

giti_path <- fs::path(path, ".gitignore")
gitignore <- readLines(giti_path)
gitignore <- gitignore[!grepl("^\\.Rproj\\.user$", gitignore)]
Expand Down Expand Up @@ -203,6 +205,11 @@ fix_gitignore <- function(path = ".") {
#' @export
create_github_repo <- function(repo_name, repo_desc = "", org = NULL,
host = getOption("rdev.host")) {
checkmate::assert_string(repo_name)
checkmate::assert_string(repo_desc)
checkmate::assert_string(org, null.ok = TRUE)
checkmate::assert_string(host, null.ok = TRUE)

conspicuous_place <- "usethis" %:::% "conspicuous_place"
user_path_prep <- "usethis" %:::% "user_path_prep"

Expand Down Expand Up @@ -343,6 +350,8 @@ get_server_url <- function() {
#'
#' @export
use_rdev_package <- function(quiet = TRUE) {
checkmate::assert_flag(quiet)

rlang::local_interactive(value = !quiet)

# add templates
Expand Down Expand Up @@ -475,6 +484,8 @@ use_analysis_package <- function(use_quarto = TRUE, prompt = FALSE) {
# workaround for lintr, R CMD check
create <- gitignore <- rbuildignore <- NULL

checkmate::assert_flag(use_quarto)

analysis_layout <- tibble::tribble(
~pattern, ~create, ~gitignore, ~rbuildignore,
"analysis", TRUE, FALSE, FALSE,
Expand Down
6 changes: 6 additions & 0 deletions R/to_document.R
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@
#' }
#' @export
to_document <- function(file_path, new_path, overwrite = FALSE) {
checkmate::assert_string(file_path)
checkmate::assert_string(new_path)
checkmate::assert_flag(overwrite)

if (!(fs::path_ext(file_path) %in% c("Rmd", "rmd"))) {
stop("'", file_path, "' is not an R Markdown (*.Rmd) file")
}
Expand Down Expand Up @@ -72,6 +76,8 @@ to_document <- function(file_path, new_path, overwrite = FALSE) {
#' @return Named list containing analysis notebook title, URL, date, and description
#' @export
rmd_metadata <- function(file_path) {
checkmate::assert_string(file_path)

if (!(fs::path_ext(file_path) %in% c("Rmd", "rmd"))) {
stop("'", file_path, "' is not an R Markdown (*.Rmd) file")
}
Expand Down
4 changes: 2 additions & 2 deletions R/urlchecker.R
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@ url_check <- urlchecker::url_check
# cli is not recorded in Imports. This function is a workaround to ensure use of cli is also
# detected by renv.
url_update_renv_workaround <- function(...) {
cli::cli_alert_success(...)
cli::cli_alert_success(...) # nocov
}

# NOTE: use of curl::new_pool() is considered a dependency by renv but not by R CMD check.
curl_new_pool_renv_workaround <- function(...) {
curl::new_pool(...)
curl::new_pool(...) # nocov
}

#' @rdname urlchecker-reexports
Expand Down
19 changes: 15 additions & 4 deletions R/utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
#' }
#' @export
sort_file <- function(filename) {
checkmate::assert_string(filename)

if (!fs::file_exists(filename)) stop("cannot sort file, '", filename, "': no such file")
writeLines(sort(readLines(filename)), filename)
}
Expand Down Expand Up @@ -47,6 +49,11 @@ sort_rbuildignore <- function() {
#' @export
spell_check_notebooks <- function(path = "analysis", glob = "*.Rmd", use_wordlist = TRUE,
lang = NULL) {
checkmate::assert_string(path)
checkmate::assert_string(glob)
checkmate::assert_flag(use_wordlist)
checkmate::assert_string(lang, null.ok = TRUE)

if (is.null(lang)) {
if (!fs::file_exists("DESCRIPTION")) {
stop("DESCRIPTION not found")
Expand Down Expand Up @@ -77,6 +84,7 @@ spell_check_notebooks <- function(path = "analysis", glob = "*.Rmd", use_wordlis
#' @export
update_wordlist_notebooks <- function(pkg = ".", vignettes = TRUE, path = "analysis",
glob = "*.Rmd", confirm = TRUE) {
# nocov start
as_package <- "spelling" %:::% "as_package"
get_wordfile <- "spelling" %:::% "get_wordfile"
get_wordlist <- spelling::get_wordlist
Expand All @@ -94,6 +102,7 @@ update_wordlist_notebooks <- function(pkg = ".", vignettes = TRUE, path = "analy
)),
method = "radix"
)
# end change
if (isTRUE(all.equal(old_words, new_words))) {
cat(sprintf("No changes required to %s\n", wordfile))
} else {
Expand Down Expand Up @@ -125,14 +134,14 @@ update_wordlist_notebooks <- function(pkg = ".", vignettes = TRUE, path = "analy
"Added %d and removed %d words in %s\n", length(words_added), length(words_removed), wordfile
))
}
# nocov end
}

deps_check <- function(type, exclude_base = TRUE) {
base_packages <- rownames(utils::installed.packages(priority = "base"))
checkmate::assert_choice(type, c("missing", "extra"))
checkmate::assert_flag(exclude_base)

if (!(type %in% c("missing", "extra"))) {
stop("invalid type '", type, "'")
}
base_packages <- rownames(utils::installed.packages(priority = "base"))
renv_deps <- renv::dependencies()
renv_deps <- renv_deps[!endsWith(renv_deps$Source, "/DESCRIPTION"), ]
renv_deps <- renv_deps[!renv_deps$Package == pkgload::pkg_name("."), ]
Expand Down Expand Up @@ -176,6 +185,8 @@ deps_check <- function(type, exclude_base = TRUE) {
#' @export
#' @rdname deps_check
missing_deps <- function(exclude_base = TRUE) {
checkmate::assert_flag(exclude_base)

deps_check("missing", exclude_base)
}

Expand Down
15 changes: 8 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -224,20 +224,20 @@ ci()
#> * creating vignettes ... OK
#> * checking for LF line-endings in source and make files and shell scripts
#> * checking for empty or unneeded directories
#> * building ‘rdev_1.8.5.tar.gz’
#> * building ‘rdev_1.8.6.tar.gz’
#>
#> ── R CMD check ─────────────────────────────────────────────────────────────────
#> * using log directory ‘/private/var/folders/vn/cw5f9gws42v9m8mdsds_zbl00000gp/T/RtmpM8E6ri/filea8035355982a/rdev.Rcheck’
#> * using log directory ‘/private/var/folders/vn/cw5f9gws42v9m8mdsds_zbl00000gp/T/RtmpC5kZVh/file180267d97952d/rdev.Rcheck’
#> * using R version 4.3.2 (2023-10-31)
#> * using platform: x86_64-apple-darwin20 (64-bit)
#> * using platform: aarch64-apple-darwin20 (64-bit)
#> * R was compiled by
#> Apple clang version 14.0.0 (clang-1400.0.29.202)
#> GNU Fortran (GCC) 12.2.0
#> * running under: macOS Monterey 12.7.1
#> * running under: macOS Ventura 13.6.2
#> * using session charset: UTF-8
#> * using option ‘--no-manual’
#> * checking for file ‘rdev/DESCRIPTION’ ... OK
#> * this is package ‘rdev’ version ‘1.8.5
#> * this is package ‘rdev’ version ‘1.8.6
#> * package encoding: UTF-8
#> * checking package namespace information ... OK
#> * checking package dependencies ... OK
Expand Down Expand Up @@ -295,9 +295,10 @@ ci()
#> NONE
#> * checking re-building of vignette outputs ... OK
#> * DONE
#>
#> Status: OK
#> ── R CMD check results ───────────────────────────────────────── rdev 1.8.5 ────
#> Duration: 1m 1.2s
#> ── R CMD check results ───────────────────────────────────────── rdev 1.8.6 ────
#> Duration: 31s
#>
#> 0 errors ✔ | 0 warnings ✔ | 0 notes ✔
```
4 changes: 4 additions & 0 deletions TODO.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
- [x] Add README.Rmd
- [x] Update `DESCRIPTION` and use description data in `README.Rmd`
- [x] Add ORCID
- [ ] Update my ORCID details

## Package

Expand Down Expand Up @@ -49,6 +50,9 @@
- [x] ~~Remove `pkgdown/extra.css` if <https://github.com/r-lib/pkgdown/issues/2377> is accepted~~
- [ ] Remove `preset: bootstrap` if <https://github.com/r-lib/pkgdown/issues/2376> is accepted
- [ ] Replace `dev = TRUE` logic if <https://github.com/rstudio/renv/issues/1695> is accepted
- [ ] Consider using RStudio [Extensions](https://rstudio.github.io/rstudio-extensions/index.html):
- [ ] Use Project [Templates](https://rstudio.github.io/rstudio-extensions/rstudio_project_templates.html) like [vertical](https://www.crumplab.com/vertical/) ?
- [ ] Add CSS to R Markdown [Template](https://rstudio.github.io/rstudio-extensions/rmarkdown_templates.html) instead of `assets/extra.css` ?
- [ ] Update errors and messages after reading Advanced R [Conditions](https://adv-r.hadley.nz/conditions.html) and re-reading the Tidyverse [Style Guide](https://style.tidyverse.org/index.html)
- [ ] Establish default [knitr options](https://yihui.org/knitr/options/), including `knitr::opts_chunk$set(fig.align = "center"")`, add to analysis template, also review [settings](https://github.com/hadley/adv-r/blob/master/common.R) for *Advanced R*
- [ ] Reduce the number of Imports, per R CMD check:
Expand Down
2 changes: 1 addition & 1 deletion docs/404.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion docs/LICENSE-text.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion docs/LICENSE.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 7 additions & 1 deletion docs/TODO.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion docs/articles/analysis-package-layout.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion docs/articles/index.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion docs/articles/rdev.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion docs/articles/style-guide.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading