Skip to content
Closed
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 DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,10 @@ Imports:
desc (>= 1.4.1),
ellipsis (>= 0.3.2),
fs (>= 1.5.2),
httr2 (>= 1.1.2),
lifecycle (>= 1.0.1),
memoise (>= 2.0.1),
mime (>= 0.13),
miniUI (>= 0.1.1.1),
pkgbuild (>= 1.3.1),
pkgdown (>= 2.0.6),
Expand Down
11 changes: 11 additions & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,17 @@ import(fs)
importFrom(cli,cat_bullet)
importFrom(cli,cat_rule)
importFrom(ellipsis,check_dots_used)
importFrom(fs,file_delete)
importFrom(fs,file_temp)
importFrom(httr2,req_body_multipart)
importFrom(httr2,req_perform)
importFrom(httr2,request)
importFrom(httr2,resp_body_raw)
importFrom(httr2,resp_body_string)
importFrom(httr2,resp_check_status)
importFrom(lifecycle,deprecated)
importFrom(memoise,memoise)
importFrom(mime,guess_type)
importFrom(pkgbuild,clean_dll)
importFrom(pkgbuild,find_rtools)
importFrom(pkgbuild,has_devel)
Expand All @@ -107,6 +116,8 @@ importFrom(remotes,install_svn)
importFrom(remotes,install_url)
importFrom(remotes,install_version)
importFrom(remotes,update_packages)
importFrom(rlang,check_installed)
importFrom(rlang,warn)
importFrom(sessioninfo,package_info)
importFrom(sessioninfo,session_info)
importFrom(stats,update)
Expand Down
26 changes: 14 additions & 12 deletions R/check-mac.R
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#' @inheritParams check_win
#' @param dep_pkgs Additional custom dependencies to install prior to checking
#' the package.
#' @importFrom httr2 request req_body_multipart req_perform resp_check_status resp_body_string
#' @family build functions
#' @return The url with the check results (invisibly)
#' @export
Expand Down Expand Up @@ -40,26 +41,25 @@ check_mac_release <- function(pkg = ".", dep_pkgs = character(), args = NULL, ma

url <- "https://mac.r-project.org/macbuilder/v1/submit"

rlang::check_installed("httr")
body <- list(pkgfile = httr::upload_file(built_path))
rlang::check_installed("httr2")
body <- list(pkgfile = upload_file(built_path))

# upload_file function implemented in utils.R

if (length(dep_built_paths) > 0) {
uploads <- lapply(dep_built_paths, httr::upload_file)
uploads <- lapply(dep_built_paths, upload_file)
names(uploads) <- rep("depfiles", length(uploads))
body <- append(body, uploads)
}

res <- httr::POST(url,
body = body,
headers = list(
"Content-Type" = "multipart/form-data"
),
encode = "multipart"
)
req <- httr2::request(url)
req <- httr2::req_body_multipart(req, !!!body)
res <- httr2::req_perform(req)

httr::stop_for_status(res, task = "Uploading package")
httr2::resp_check_status(res, info = "Uploading package")

response_url <- httr::content(res)$url
res_body <- httr2::resp_body_string(res)
response_url <- regmatches(res_body, regexpr("https://mac\\.R-project\\.org/macbuilder/results/[0-9a-zA-Z\\-]+/", res_body))

if (!quiet) {
time <- strftime(Sys.time() + 10 * 60, "%I:%M %p")
Expand All @@ -72,3 +72,5 @@ check_mac_release <- function(pkg = ".", dep_pkgs = character(), args = NULL, ma

invisible(response_url)
}


2 changes: 1 addition & 1 deletion R/check.R
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
#' CRAN, and hence can take a reasonable amount of time.
#'
#' * Debugging flags for the compiler, set by
#' [`compiler_flags(FALSE)`][compiler_flags()].
#' [`compiler_flags(FALSE)`][pkgbuild::compiler_flags()].
#'
#' * If `aspell` is found, `_R_CHECK_CRAN_INCOMING_USE_ASPELL_`
#' is set to `TRUE`. If no spell checker is installed, a warning is issued.
Expand Down
33 changes: 21 additions & 12 deletions R/release.R
Original file line number Diff line number Diff line change
Expand Up @@ -277,23 +277,27 @@ upload_cran <- function(pkg, built_path, call = parent.frame()) {

# Initial upload ---------
cli::cli_inform(c(i = "Uploading package & comments"))
rlang::check_installed("httr")
rlang::check_installed("httr2")
body <- list(
pkg_id = "",
name = maint$name,
email = maint$email,
uploaded_file = httr::upload_file(built_path, "application/x-gzip"),
uploaded_file = upload_file(built_path, "application/x-gzip"),
comment = comments,
upload = "Upload package"
)
r <- httr::POST(cran_submission_url, body = body)

req <- httr2::request(cran_submission_url)
req <- httr2::req_body_multipart(req, !!!body)
r <- httr2::req_perform(req)

# If a 404 likely CRAN is closed for maintenance, try to get the message
if (httr::status_code(r) == 404) {
if (httr2::resp_status(r) == 404) {
msg <- ""
try({
r2 <- httr::GET(sub("index2", "index", cran_submission_url))
msg <- extract_cran_msg(httr::content(r2, "text"))
try({
req2 <- httr2::request(sub("index2", "index", cran_submission_url))
r2 <- httr2::req_perform(req2)
msg <- extract_cran_msg(httr2::resp_body_string(r2))
})
cli::cli_abort(
c(
Expand All @@ -304,8 +308,8 @@ upload_cran <- function(pkg, built_path, call = parent.frame()) {
)
}

httr::stop_for_status(r)
new_url <- httr::parse_url(r$url)
httr2::resp_check_status(r)
new_url <- httr2::url_parse(r$url)

# Confirmation -----------
cli::cli_inform(c(i = "Confirming submission"))
Expand All @@ -316,9 +320,14 @@ upload_cran <- function(pkg, built_path, call = parent.frame()) {
policy_check = "1/",
submit = "Submit package"
)
r <- httr::POST(cran_submission_url, body = body)
httr::stop_for_status(r)
new_url <- httr::parse_url(r$url)

req <- httr2::request(cran_submission_url)
req <- httr2::req_body_multipart(req, !!!body)
r <- httr2::req_perform(req)

httr2::resp_check_status(r)

new_url <- httr2::url_parse(r$url)
if (new_url$query$submit == "1") {
cli::cli_inform(c(
"v" = "Package submission successful",
Expand Down
2 changes: 1 addition & 1 deletion R/remotes.R
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ with_pkgbuild_build_tools <- function(fun) {
#'

#' These functions are re-exported from the remotes package. They differ only
#' that the ones in devtools use the [ellipsis] package to ensure all dotted
#' that the ones in devtools use the [ellipsis::check_dots_used] feature to ensure all dotted
#' arguments are used.
#'
#' Follow the links below to see the documentation.
Expand Down
20 changes: 13 additions & 7 deletions R/run-source.R
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@
#' @param url url
#' @param ... other options passed to [source()]
#' @param sha1 The (prefix of the) SHA-1 hash of the file at the remote URL.
#' @importFrom fs file_temp file_delete
#' @importFrom rlang check_installed warn
#' @importFrom httr2 request req_perform resp_check_status resp_body_raw
#' @importFrom ellipsis check_dots_used
#' @export
#' @seealso [source_gist()]
#' @examples
Expand All @@ -31,18 +35,20 @@
source_url <- function(url, ..., sha1 = NULL) {
stopifnot(is.character(url), length(url) == 1)
rlang::check_installed("digest")
rlang::check_installed("httr")
rlang::check_installed("httr2")

temp_file <- file_temp()
on.exit(file_delete(temp_file), add = TRUE)
temp_file <- fs::file_temp()
on.exit(fs::file_delete(temp_file), add = TRUE)

request <- httr::GET(url)
httr::stop_for_status(request)
writeBin(httr::content(request, type = "raw"), temp_file)
resp <- httr2::req_perform(httr2::request(url))

httr2::resp_check_status(resp)

writeBin(httr2::resp_body_raw(resp), temp_file)

check_sha1(temp_file, sha1)

check_dots_used(action = getOption("devtools.ellipsis_action", rlang::warn))
ellipsis::check_dots_used(action = getOption("devtools.ellipsis_action", rlang::warn))
source(temp_file, ...)
}

Expand Down
9 changes: 9 additions & 0 deletions R/utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -45,3 +45,12 @@ is_testing <- function() {
is_rstudio_running <- function() {
!is_testing() && rstudioapi::isAvailable()
}

#' @importFrom mime guess_type
upload_file <- function(path, type = NULL) {
stopifnot(is.character(path), length(path) == 1, file.exists(path))
if (is.null(type)) {
type <- mime::guess_type(path)
}
curl::form_file(path, type)
}
2 changes: 1 addition & 1 deletion man/check.Rd

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

13 changes: 5 additions & 8 deletions man/load_all.Rd

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

7 changes: 5 additions & 2 deletions man/reexports.Rd

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

2 changes: 1 addition & 1 deletion man/remote-reexports.Rd

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