diff --git a/NAMESPACE b/NAMESPACE
index 1a95c0c02..a05818a37 100644
--- a/NAMESPACE
+++ b/NAMESPACE
@@ -97,10 +97,4 @@ importFrom(pkgload,unload)
importFrom(sessioninfo,package_info)
importFrom(sessioninfo,session_info)
importFrom(stats,update)
-importFrom(usethis,ui_code)
-importFrom(usethis,ui_done)
-importFrom(usethis,ui_field)
-importFrom(usethis,ui_path)
-importFrom(usethis,ui_todo)
-importFrom(usethis,ui_value)
importFrom(usethis,use_test)
diff --git a/NEWS.md b/NEWS.md
index d00b134b6..5cecf5fde 100644
--- a/NEWS.md
+++ b/NEWS.md
@@ -6,6 +6,7 @@
* `build_vignettes()` and `clean_vignettes()` are now deprecated. We no longer recommend building vignettes in this way; instead use `pkgdown::build_article()` to render articles locally (#2488).
* `build_site()` now just calls `pkgdown::build_site()`, meaning that you will get more (informative) output by default (#2578).
* New `check_mac_devel()` function to check a package using the macOS builder at https://mac.r-project.org/macbuilder/submit.html (@nfrerebeau, #2507)
+* `dev_sitrep()` now uses cli for user-facing messages instead of deprecated usethis UI functions.
* `dev_sitrep()` now works correctly in Positron (#2618).
* `is_loading()` is now re-exported from pkgload (#2556).
* Package installation functions are now deprecated: `install_bioc()`, `install_bitbucket()`, `install_cran()`, `install_deps()`, `install_dev()`, `install_dev_deps()`, `install_git()`, `install_github()`, `install_gitlab()`, `install_local()`, `install_svn()`, `install_url()`, `install_version()`, `update_packages()`, `dev_package_deps()`, `github_pull()`, and `github_release()`. We now recommend pak () for general package installation. See `?install-deprecated` for migration guidance.
diff --git a/R/sitrep.R b/R/sitrep.R
index 5a880b48b..c37adbaff 100644
--- a/R/sitrep.R
+++ b/R/sitrep.R
@@ -66,7 +66,7 @@ check_for_rstudio_updates <- function(
sprintf(
"%s.\nDownload at: %s",
result[["update-message"]],
- ui_field(result[["update-url"]])
+ result[["update-url"]]
)
)
}
@@ -93,7 +93,6 @@ r_release <- memoise::memoise(.r_release)
#' everything should be ready for package development.
#'
#' @return A named list, with S3 class `dev_sitrep` (for printing purposes).
-#' @importFrom usethis ui_code ui_field ui_todo ui_value ui_done ui_path
#' @export
#' @examples
#' \dontrun{
@@ -104,21 +103,52 @@ dev_sitrep <- function(pkg = ".", debug = FALSE) {
has_build_tools <- !is_windows || pkgbuild::has_build_tools(debug = debug)
+ new_dev_sitrep(
+ pkg = pkg,
+ r_version = getRversion(),
+ r_path = path_real(R.home()),
+ r_release_version = r_release(),
+ is_windows = is_windows,
+ has_build_tools = has_build_tools,
+ rtools_path = if (has_build_tools) pkgbuild::rtools_path(),
+ devtools_version = utils::packageVersion("devtools"),
+ devtools_deps = remotes::package_deps("devtools", dependencies = NA),
+ pkg_deps = if (!is.null(pkg)) {
+ remotes::dev_package_deps(pkg$path, dependencies = TRUE)
+ },
+ rstudio_version = if (is_rstudio_running()) rstudioapi::getVersion(),
+ rstudio_msg = if (!is_positron()) check_for_rstudio_updates()
+ )
+}
+
+new_dev_sitrep <- function(
+ pkg = NULL,
+ r_version = getRversion(),
+ r_path = path_real(R.home()),
+ r_release_version = r_version,
+ is_windows = FALSE,
+ has_build_tools = TRUE,
+ rtools_path = NULL,
+ devtools_version = utils::packageVersion("devtools"),
+ devtools_deps = data.frame(package = character(), diff = numeric()),
+ pkg_deps = NULL,
+ rstudio_version = NULL,
+ rstudio_msg = NULL
+) {
structure(
list(
pkg = pkg,
- r_version = getRversion(),
- r_path = path_real(R.home()),
- r_release_version = r_release(),
+ r_version = r_version,
+ r_path = r_path,
+ r_release_version = r_release_version,
+ is_windows = is_windows,
has_build_tools = has_build_tools,
- rtools_path = if (has_build_tools) pkgbuild::rtools_path(),
- devtools_version = utils::packageVersion("devtools"),
- devtools_deps = remotes::package_deps("devtools", dependencies = NA),
- pkg_deps = if (!is.null(pkg)) {
- remotes::dev_package_deps(pkg$path, dependencies = TRUE)
- },
- rstudio_version = if (is_rstudio_running()) rstudioapi::getVersion(),
- rstudio_msg = if (!is_positron()) check_for_rstudio_updates()
+ rtools_path = rtools_path,
+ devtools_version = devtools_version,
+ devtools_deps = devtools_deps,
+ pkg_deps = pkg_deps,
+ rstudio_version = rstudio_version,
+ rstudio_msg = rstudio_msg
),
class = "dev_sitrep"
)
@@ -128,80 +158,68 @@ dev_sitrep <- function(pkg = ".", debug = FALSE) {
print.dev_sitrep <- function(x, ...) {
all_ok <- TRUE
- hd_line("R")
+ cli::cli_rule("R")
kv_line("version", x$r_version)
kv_line("path", x$r_path, path = TRUE)
if (x$r_version < x$r_release_version) {
- ui_todo(
- '
- {ui_field("R")} is out of date ({ui_value(x$r_version)} vs {ui_value(x$r_release_version)})
- '
- )
+ cli::cli_bullets(c(
+ "!" = "{.field R} is out of date ({.val {x$r_version}} vs {.val {x$r_release_version}})"
+ ))
all_ok <- FALSE
}
- if (is_windows) {
- hd_line("Rtools")
+ if (x$is_windows) {
+ cli::cli_rule("Rtools")
if (x$has_build_tools) {
kv_line("path", x$rtools_path, path = TRUE)
} else {
- ui_todo(
- '
- {ui_field("RTools")} is not installed:
- Download and install it from: {ui_field("https://cloud.r-project.org/bin/windows/Rtools/")}
- '
- )
+ cli::cli_bullets(c(
+ "!" = "{.field Rtools} is not installed.",
+ " " = "Download and install it from: {.url https://cloud.r-project.org/bin/windows/Rtools/}"
+ ))
}
all_ok <- FALSE
}
if (!is.null(x$rstudio_version)) {
- hd_line(if (is_positron()) "Positron" else "RStudio")
+ cli::cli_rule(if (is_positron()) "Positron" else "RStudio")
kv_line("version", x$rstudio_version)
if (!is.null(x$rstudio_msg)) {
- ui_todo(x$rstudio_msg)
+ cli::cli_bullets(c("!" = "{x$rstudio_msg}"))
all_ok <- FALSE
}
}
- hd_line("devtools")
+ cli::cli_rule("devtools")
kv_line("version", x$devtools_version)
devtools_deps_old <- x$devtools_deps$diff < 0
if (any(devtools_deps_old)) {
- ui_todo(
- '
- {ui_field("devtools")} or its dependencies out of date:
- {paste(ui_value(x$devtools_deps$package[devtools_deps_old]), collapse = ", ")}
- Update them with {ui_code("devtools::update_packages(\\"devtools\\")")}
- '
- )
+ cli::cli_bullets(c(
+ "!" = "{.pkg devtools} or its dependencies out of date:",
+ " " = "{.val {x$devtools_deps$package[devtools_deps_old]}}",
+ " " = "Update them with {.code devtools::update_packages(\"devtools\")}"
+ ))
all_ok <- FALSE
}
- hd_line("dev package")
+ cli::cli_rule("dev package")
kv_line("package", x$pkg$package)
kv_line("path", x$pkg$path, path = TRUE)
pkg_deps_old <- x$pkg_deps$diff < 0
if (any(pkg_deps_old)) {
- ui_todo(
- '
- {ui_field(x$pkg$package)} dependencies out of date:
- {paste(ui_value(x$pkg_deps$package[pkg_deps_old]), collapse = ", ")}
- Update them with {ui_code("devtools::install_dev_deps()")}
- '
- )
+ cli::cli_bullets(c(
+ "!" = "{.field {x$pkg$package}} dependencies out of date:",
+ " " = "{.val {x$pkg_deps$package[pkg_deps_old]}}",
+ " " = "Update them with {.code devtools::install_dev_deps()}"
+ ))
all_ok <- FALSE
}
if (all_ok) {
- ui_done(
- "
- All checks passed
- "
- )
+ cli::cli_bullets(c("v" = "All checks passed"))
}
invisible(x)
@@ -210,19 +228,12 @@ print.dev_sitrep <- function(x, ...) {
# Helpers -----------------------------------------------------------------
-hd_line <- function(name) {
- cli::cat_rule(cli::style_bold(name))
-}
-
kv_line <- function(key, value, path = FALSE) {
if (is.null(value)) {
- value <- cli::col_silver("")
+ cli::cli_inform(c("*" = "{key}: {.silver }"))
+ } else if (path) {
+ cli::cli_inform(c("*" = "{key}: {.path {value}}"))
} else {
- if (path) {
- value <- ui_path(value, base = NA)
- } else {
- value <- ui_value(value)
- }
+ cli::cli_inform(c("*" = "{key}: {.val {value}}"))
}
- cli::cat_line(cli::symbol$bullet, " ", key, ": ", value)
}
diff --git a/R/test.R b/R/test.R
index 37d6a8caa..bd038ee53 100644
--- a/R/test.R
+++ b/R/test.R
@@ -31,7 +31,9 @@ test <- function(
if (!uses_testthat(pkg)) {
cli::cli_inform(c(i = "No testing infrastructure found."))
if (!interactive()) {
- ui_todo('Setup testing with {ui_code("usethis::use_testthat()")}.')
+ cli::cli_bullets(c(
+ "!" = 'Setup testing with {.code usethis::use_testthat()}.'
+ ))
return(invisible())
}
if (yesno("Create it?")) {
diff --git a/inst/WORDLIST b/inst/WORDLIST
index 91a0c756e..f36162419 100644
--- a/inst/WORDLIST
+++ b/inst/WORDLIST
@@ -53,6 +53,7 @@ SHA
Studer
Takahashi
Titov
+UI
UNC
VignetteBuilder
WARNINGs
diff --git a/tests/testthat/_snaps/sitrep.md b/tests/testthat/_snaps/sitrep.md
index 817b7b734..548c26c8e 100644
--- a/tests/testthat/_snaps/sitrep.md
+++ b/tests/testthat/_snaps/sitrep.md
@@ -1,3 +1,84 @@
+# print shows all checks passed
+
+ Code
+ print(x)
+ Message
+ -- R -------------------------------------------------------
+ * version: 4.4.0
+ * path: '/usr/lib/R'
+ -- devtools ------------------------------------------------
+ * version: 2.4.6
+ -- dev package ---------------------------------------------
+ * package:
+ * path:
+ v All checks passed
+
+# print warns when R is out of date
+
+ Code
+ print(x)
+ Message
+ -- R -------------------------------------------------------
+ * version: 4.3.0
+ * path: '/usr/lib/R'
+ ! R is out of date (4.3.0 vs 4.4.0)
+ -- devtools ------------------------------------------------
+ * version: 2.4.6
+ -- dev package ---------------------------------------------
+ * package:
+ * path:
+
+# print warns about outdated devtools deps
+
+ Code
+ print(x)
+ Message
+ -- R -------------------------------------------------------
+ * version: 4.4.0
+ * path: '/usr/lib/R'
+ -- devtools ------------------------------------------------
+ * version: 2.4.6
+ ! devtools or its dependencies out of date:
+ "cli"
+ Update them with `devtools::update_packages("devtools")`
+ -- dev package ---------------------------------------------
+ * package:
+ * path:
+
+# print warns about outdated package deps
+
+ Code
+ print(x)
+ Message
+ -- R -------------------------------------------------------
+ * version: 4.4.0
+ * path: '/usr/lib/R'
+ -- devtools ------------------------------------------------
+ * version: 2.4.6
+ -- dev package ---------------------------------------------
+ * package: "mypkg"
+ * path: '/tmp/mypkg'
+ ! mypkg dependencies out of date:
+ "dplyr" and "tidyr"
+ Update them with `devtools::install_dev_deps()`
+
+# print shows RStudio update message
+
+ Code
+ print(x)
+ Message
+ -- R -------------------------------------------------------
+ * version: 4.4.0
+ * path: '/usr/lib/R'
+ -- RStudio -------------------------------------------------
+ * version: "2024.04.0"
+ ! RStudio is out of date.
+ -- devtools ------------------------------------------------
+ * version: 2.4.6
+ -- dev package ---------------------------------------------
+ * package:
+ * path:
+
# check_for_rstudio_updates
Code
diff --git a/tests/testthat/test-sitrep.R b/tests/testthat/test-sitrep.R
index 3a11128cd..c2debee42 100644
--- a/tests/testthat/test-sitrep.R
+++ b/tests/testthat/test-sitrep.R
@@ -1,3 +1,60 @@
+test_that("print shows all checks passed", {
+ local_reproducible_output(width = 60)
+ x <- new_dev_sitrep(
+ r_version = R_system_version("4.4.0"),
+ r_path = "/usr/lib/R",
+ devtools_version = package_version("2.4.6")
+ )
+ expect_snapshot(print(x))
+})
+
+test_that("print warns when R is out of date", {
+ local_reproducible_output(width = 60)
+ x <- new_dev_sitrep(
+ r_version = R_system_version("4.3.0"),
+ r_path = "/usr/lib/R",
+ r_release_version = R_system_version("4.4.0"),
+ devtools_version = package_version("2.4.6")
+ )
+ expect_snapshot(print(x))
+})
+
+test_that("print warns about outdated devtools deps", {
+ local_reproducible_output(width = 60)
+ x <- new_dev_sitrep(
+ r_version = R_system_version("4.4.0"),
+ r_path = "/usr/lib/R",
+ devtools_version = package_version("2.4.6"),
+ devtools_deps = data.frame(package = c("rlang", "cli"), diff = c(0, -1))
+ )
+ expect_snapshot(print(x))
+})
+
+test_that("print warns about outdated package deps", {
+ local_reproducible_output(width = 60)
+ x <- new_dev_sitrep(
+ r_version = R_system_version("4.4.0"),
+ r_path = "/usr/lib/R",
+ devtools_version = package_version("2.4.6"),
+ pkg = list(package = "mypkg", path = "/tmp/mypkg"),
+ pkg_deps = data.frame(package = c("dplyr", "tidyr"), diff = c(-1, -1))
+ )
+ expect_snapshot(print(x))
+})
+
+test_that("print shows RStudio update message", {
+ local_reproducible_output(width = 60)
+ withr::local_envvar(POSITRON = "")
+ x <- new_dev_sitrep(
+ r_version = R_system_version("4.4.0"),
+ r_path = "/usr/lib/R",
+ devtools_version = package_version("2.4.6"),
+ rstudio_version = "2024.04.0",
+ rstudio_msg = "RStudio is out of date."
+ )
+ expect_snapshot(print(x))
+})
+
test_that("check_for_rstudio_updates", {
skip_if_offline()
skip_on_cran()