Skip to content
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
2 changes: 2 additions & 0 deletions .Rbuildignore
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,5 @@
^\.lintr\.R$
^notes$
^CRAN-SUBMISSION$
^[.]?air[.]toml$
^\.vscode$
5 changes: 5 additions & 0 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"recommendations": [
"Posit.air-vscode"
]
}
10 changes: 10 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"[r]": {
"editor.formatOnSave": true,
"editor.defaultFormatter": "Posit.air-vscode"
},
"[quarto]": {
"editor.formatOnSave": true,
"editor.defaultFormatter": "quarto.quarto"
}
}
12 changes: 10 additions & 2 deletions R/active.R
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
find_active_file <- function(arg = "file", call = parent.frame()) {
if (!is_rstudio_running()) {
cli::cli_abort("Argument {.arg {arg}} is missing, with no default", call = call)
cli::cli_abort(
"Argument {.arg {arg}} is missing, with no default",
call = call
)
}
normalizePath(rstudioapi::getSourceEditorContext()$path)
}
Expand All @@ -18,7 +21,12 @@ find_test_file <- function(path, call = parent.frame()) {
pkg <- as.package(dirname(path))

is_test <- type == "test"
path[!is_test] <- paste0(pkg$path, "/tests/testthat/test-", name_source(path[!is_test]), ".R")
path[!is_test] <- paste0(
pkg$path,
"/tests/testthat/test-",
name_source(path[!is_test]),
".R"
)
path <- unique(path[file_exists(path)])

if (length(path) == 0) {
Expand Down
26 changes: 17 additions & 9 deletions R/build-manual.R
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,23 @@ build_manual <- function(pkg = ".", path = NULL) {
pkg <- as.package(pkg)
path <- path %||% path_dir(pkg$path)
name <- paste0(pkg$package, "_", pkg$version, ".pdf", collapse = " ")
tryCatch(msg <- callr::rcmd("Rd2pdf", cmdargs = c(
"--force",
paste0("--output=", path, "/", name),
pkg$path
), fail_on_status = TRUE, stderr = "2>&1", spinner = FALSE),
error = function(e) {
cat(e$stdout)
cli::cli_abort("Failed to build manual")
})
tryCatch(
msg <- callr::rcmd(
"Rd2pdf",
cmdargs = c(
"--force",
paste0("--output=", path, "/", name),
pkg$path
),
fail_on_status = TRUE,
stderr = "2>&1",
spinner = FALSE
),
error = function(e) {
cat(e$stdout)
cli::cli_abort("Failed to build manual")
}
)

cat(msg$stdout)
invisible(msg)
Expand Down
28 changes: 23 additions & 5 deletions R/build-readme.R
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,13 @@
#' @inheritParams install
#' @inheritParams rmarkdown::render
#' @export
build_rmd <- function(files, path = ".", output_options = list(), ..., quiet = TRUE) {
build_rmd <- function(
files,
path = ".",
output_options = list(),
...,
quiet = TRUE
) {
check_dots_used(action = getOption("devtools.ellipsis_action", rlang::warn))

pkg <- as.package(path)
Expand All @@ -33,12 +39,16 @@ build_rmd <- function(files, path = ".", output_options = list(), ..., quiet = T
# Ensure rendering github_document() doesn't generate HTML file
output_options$html_preview <- FALSE


for (path in paths) {
cli::cli_inform(c(i = "Building {.path {path}}"))
callr::r_safe(
function(...) rmarkdown::render(...),
args = list(input = path, ..., output_options = output_options, quiet = quiet),
args = list(
input = path,
...,
output_options = output_options,
quiet = quiet
),
show = TRUE,
spinner = FALSE,
stderr = "2>&1"
Expand All @@ -54,13 +64,21 @@ build_readme <- function(path = ".", quiet = TRUE, ...) {
pkg <- as.package(path)

regexp <- paste0(path_file(pkg$path), "/(inst/)?readme[.]rmd")
readme_path <- path_abs(dir_ls(pkg$path, ignore.case = TRUE, regexp = regexp, recurse = 1, type = "file"))
readme_path <- path_abs(dir_ls(
pkg$path,
ignore.case = TRUE,
regexp = regexp,
recurse = 1,
type = "file"
))

if (length(readme_path) == 0) {
cli::cli_abort("Can't find {.file README.Rmd} or {.file inst/README.Rmd}.")
}
if (length(readme_path) > 1) {
cli::cli_abort("Can't have both {.file README.Rmd} and {.file inst/README.Rmd}.")
cli::cli_abort(
"Can't have both {.file README.Rmd} and {.file inst/README.Rmd}."
)
}

build_rmd(readme_path, path = path, quiet = quiet, ...)
Expand Down
4 changes: 3 additions & 1 deletion R/check-devtools.R
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,9 @@ check_version <- function(pkg = ".") {
check_vignette_titles <- function(pkg = ".") {
pkg <- as.package(pkg)
vigns <- tools::pkgVignettes(dir = pkg$path)
if (length(vigns$docs) == 0) return()
if (length(vigns$docs) == 0) {
return()
}

has_vignette_title <- function(v, n) {
h <- readLines(v, n = n)
Expand Down
28 changes: 22 additions & 6 deletions R/check-mac.R
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,14 @@
#' @family build functions
#' @return The url with the check results (invisibly)
#' @export
check_mac_release <- function(pkg = ".", dep_pkgs = character(), args = NULL, manual = TRUE, quiet = FALSE, ...) {
check_mac_release <- function(
pkg = ".",
dep_pkgs = character(),
args = NULL,
manual = TRUE,
quiet = FALSE,
...
) {
check_dots_used(action = getOption("devtools.ellipsis_action", rlang::warn))

pkg <- as.package(pkg)
Expand All @@ -23,17 +30,25 @@ check_mac_release <- function(pkg = ".", dep_pkgs = character(), args = NULL, ma
))
}

built_path <- pkgbuild::build(pkg$path, tempdir(),
built_path <- pkgbuild::build(
pkg$path,
tempdir(),
args = args,
manual = manual, quiet = quiet, ...
manual = manual,
quiet = quiet,
...
)

dep_built_paths <- character()
for (i in seq_along(dep_pkgs)) {
dep_pkg <- as.package(dep_pkgs[[i]])$path
dep_built_paths[[i]] <- pkgbuild::build(dep_pkg, tempdir(),
dep_built_paths[[i]] <- pkgbuild::build(
dep_pkg,
tempdir(),
args = args,
manual = manual, quiet = quiet, ...
manual = manual,
quiet = quiet,
...
)
}
on.exit(file_delete(c(built_path, dep_built_paths)), add = TRUE)
Expand All @@ -49,7 +64,8 @@ check_mac_release <- function(pkg = ".", dep_pkgs = character(), args = NULL, ma
body <- append(body, uploads)
}

res <- httr::POST(url,
res <- httr::POST(
url,
body = body,
headers = list(
"Content-Type" = "multipart/form-data"
Expand Down
87 changes: 70 additions & 17 deletions R/check-win.R
Original file line number Diff line number Diff line change
Expand Up @@ -20,39 +20,82 @@ NULL

#' @describeIn check_win Check package on the development version of R.
#' @export
check_win_devel <- function(pkg = ".", args = NULL, manual = TRUE, email = NULL, quiet = FALSE, ...) {
check_win_devel <- function(
pkg = ".",
args = NULL,
manual = TRUE,
email = NULL,
quiet = FALSE,
...
) {
check_dots_used(action = getOption("devtools.ellipsis_action", rlang::warn))

check_win(
pkg = pkg, version = "R-devel", args = args, manual = manual,
email = email, quiet = quiet, ...
pkg = pkg,
version = "R-devel",
args = args,
manual = manual,
email = email,
quiet = quiet,
...
)
}

#' @describeIn check_win Check package on the released version of R.
#' @export
check_win_release <- function(pkg = ".", args = NULL, manual = TRUE, email = NULL, quiet = FALSE, ...) {
check_win_release <- function(
pkg = ".",
args = NULL,
manual = TRUE,
email = NULL,
quiet = FALSE,
...
) {
check_dots_used(action = getOption("devtools.ellipsis_action", rlang::warn))

check_win(
pkg = pkg, version = "R-release", args = args, manual = manual,
email = email, quiet = quiet, ...
pkg = pkg,
version = "R-release",
args = args,
manual = manual,
email = email,
quiet = quiet,
...
)
}

#' @describeIn check_win Check package on the previous major release version of R.
#' @export
check_win_oldrelease <- function(pkg = ".", args = NULL, manual = TRUE, email = NULL, quiet = FALSE, ...) {
check_win_oldrelease <- function(
pkg = ".",
args = NULL,
manual = TRUE,
email = NULL,
quiet = FALSE,
...
) {
check_dots_used(action = getOption("devtools.ellipsis_action", rlang::warn))

check_win(
pkg = pkg, version = "R-oldrelease", args = args, manual = manual,
email = email, quiet = quiet, ...
pkg = pkg,
version = "R-oldrelease",
args = args,
manual = manual,
email = email,
quiet = quiet,
...
)
}

check_win <- function(pkg = ".", version = c("R-devel", "R-release", "R-oldrelease"),
args = NULL, manual = TRUE, email = NULL, quiet = FALSE, ...) {
check_win <- function(
pkg = ".",
version = c("R-devel", "R-release", "R-oldrelease"),
args = NULL,
manual = TRUE,
email = NULL,
quiet = FALSE,
...
) {
pkg <- as.package(pkg)

if (!is.null(email)) {
Expand Down Expand Up @@ -80,14 +123,20 @@ check_win <- function(pkg = ".", version = c("R-devel", "R-release", "R-oldrelea
}
}

built_path <- pkgbuild::build(pkg$path, tempdir(),
built_path <- pkgbuild::build(
pkg$path,
tempdir(),
args = args,
manual = manual, quiet = quiet, ...
manual = manual,
quiet = quiet,
...
)
on.exit(file_delete(built_path), add = TRUE)

url <- paste0(
"ftp://win-builder.r-project.org/", version, "/",
"ftp://win-builder.r-project.org/",
version,
"/",
path_file(built_path)
)
lapply(url, upload_ftp, file = built_path)
Expand Down Expand Up @@ -142,8 +191,12 @@ upload_ftp <- function(file, url, verbose = FALSE) {
con <- file(file, open = "rb")
on.exit(close(con), add = TRUE)
h <- curl::new_handle(upload = TRUE, filetime = FALSE)
curl::handle_setopt(h, readfunction = function(n) {
readBin(con, raw(), n = n)
}, verbose = verbose)
curl::handle_setopt(
h,
readfunction = function(n) {
readBin(con, raw(), n = n)
},
verbose = verbose
)
curl::curl_fetch_memory(url, handle = h)
}
Loading