From ff271efcbd37de68da36d6e9acca228988774033 Mon Sep 17 00:00:00 2001 From: Yihui Xie Date: Tue, 25 Nov 2025 22:20:58 -0600 Subject: [PATCH] close #1507: make publish_book() publish to connect.posit.cloud by default --- DESCRIPTION | 4 +-- NEWS.md | 2 ++ R/publish.R | 69 +++++++++++++++++++++------------------------ man/publish_book.Rd | 33 ++++++++-------------- 4 files changed, 47 insertions(+), 61 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index 51775bcdf..1f4d70844 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,7 +1,7 @@ Package: bookdown Type: Package Title: Authoring Books and Technical Documents with R Markdown -Version: 0.45.2 +Version: 0.45.3 Authors@R: c( person("Yihui", "Xie", role = c("aut", "cre"), email = "xie@yihui.name", comment = c(ORCID = "0000-0003-0645-5666")), person("Christophe", "Dervieux", , "cderv@posit.co", role = c("ctb"), @@ -89,7 +89,7 @@ Suggests: URL: https://github.com/rstudio/bookdown, https://pkgs.rstudio.com/bookdown/ BugReports: https://github.com/rstudio/bookdown/issues SystemRequirements: Pandoc (>= 1.17.2) -RoxygenNote: 7.3.2 +RoxygenNote: 7.3.3 Encoding: UTF-8 Config/Needs/book: remotes, webshot, svglite Config/Needs/website: pkgdown, tidyverse/tidytemplate, rstudio/quillt diff --git a/NEWS.md b/NEWS.md index 951853beb..d51038a0a 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,5 +1,7 @@ # CHANGES IN bookdown VERSION 0.46 +- `publish_book()` publishes the book to connect.posit.cloud by default now, instead of bookdown.org. The latter will be sunset soon in early 2026. + - Removed tests for `xfun::with_ext()` that don't belong to this package. # CHANGES IN bookdown VERSION 0.45 diff --git a/R/publish.R b/R/publish.R index 878fbf72a..82257044c 100644 --- a/R/publish.R +++ b/R/publish.R @@ -1,49 +1,44 @@ -#' Publish a book to the web -#' -#' Publish a book to the web. Note that you should be sure to render all -#' versions of the book before publishing, unless you have specified -#' \code{render = TRUE}. -#' -#' @inheritParams rsconnect::deploySite +#' Publish a book to a Posit Connect server #' +#' Publish a book to a Connect Server. By default, you should render the book +#' locally before publishing. #' @param name Name of the book (this will be used in the URL path of the #' published book). Defaults to the \code{book_filename} in #' \code{_bookdown.yml} if not specified. #' @param account Account name to publish to. Will default to any previously #' published to account or any single account already associated with #' \code{server}. -#' @param server Server to publish to (by default beta.rstudioconnect.com but -#' any RStudio Connect server can be published to). -#' +#' @param server Server to publish to (by default connect.posit.cloud, but any +#' Posit Connect server can be published to). +#' @param ... Other arguments to be passed to [rsconnect::deploySite()]. +#' @note Previously the default server was bookdown.org, which will be sunset. +#' You are no longer recommended to publish to bookdown.org. #' @export -publish_book = function( - name = NULL, account = NULL, server = NULL, render = c("none", "local", "server") -) { - - # if there are no RS Connect accounts setup on this machine - # then offer to add one for bookdown.org - accounts <- rsconnect::accounts() - accounts <- subset(accounts, server != "shinyapps.io") - if (is.null(accounts) || nrow(accounts) == 0) { - - # add the server if we need to - servers = rsconnect::servers() - if (nrow(subset(servers, name == 'bookdown.org')) == 0) - rsconnect::addServer("https://bookdown.org/__api__", 'bookdown.org') - - # see if they want to configure an account (bail if they don't) - message('You do not currently have a bookdown.org publishing account ', - 'configured on this system.') - result = readline('Would you like to configure one now? [Y/n]: ') - if (tolower(result) == 'n') return(invisible()) - - # configure the account - rsconnect::connectUser(server = 'bookdown.org') +publish_book = function(name = NULL, account = NULL, server = "connect.posit.cloud", ...) { + # delete local records of bookdown.org + accounts = rsconnect::accounts() + x1 = 'bookdown.org' %in% accounts$server + x2 = 'bookdown.org' %in% rsconnect::servers()$name + if (x1 || x2) { + warning( + 'bookdown.org will be sunset on January 31, 2026. Please consider ', + 'publishing to https://connect.posit.cloud instead.' + ) + if (readline('Do you want to remove the bookdown.org server now? Your book will _not_ be removed. (y/n) ') == 'y') { + if (x1) rsconnect::removeAccount(server = 'bookdown.org') + if (x2) rsconnect::removeServer('bookdown.org') + } + if (readline('Do you want to delete local records of the Connect deployment? Your book will _not_ be deleted (y/n) ') == 'y') { + rsconnect::forgetDeployment() + } + } + # if there are no Connect accounts setup on this machine, offer to add one + # for connect.posit.cloud + if (!'connect.posit.cloud' %in% accounts$server) { + if (readline('Do you want to connect to connect.posit.cloud? (y/n)') == 'y') + rsconnect::connectCloudUser() } # deploy the book - rsconnect::deploySite( - siteDir = getwd(), siteName = name, account = account, server = server, - render = render, logLevel = 'normal' - ) + rsconnect::deploySite(siteDir = getwd(), siteName = name, account = account, server = server, ...) } diff --git a/man/publish_book.Rd b/man/publish_book.Rd index 856ae16a1..3339ff75c 100644 --- a/man/publish_book.Rd +++ b/man/publish_book.Rd @@ -2,14 +2,9 @@ % Please edit documentation in R/publish.R \name{publish_book} \alias{publish_book} -\title{Publish a book to the web} +\title{Publish a book to a Posit Connect server} \usage{ -publish_book( - name = NULL, - account = NULL, - server = NULL, - render = c("none", "local", "server") -) +publish_book(name = NULL, account = NULL, server = "connect.posit.cloud", ...) } \arguments{ \item{name}{Name of the book (this will be used in the URL path of the @@ -20,22 +15,16 @@ published book). Defaults to the \code{book_filename} in published to account or any single account already associated with \code{server}.} -\item{server}{Server to publish to (by default beta.rstudioconnect.com but -any RStudio Connect server can be published to).} +\item{server}{Server to publish to (by default connect.posit.cloud, but any +Posit Connect server can be published to).} -\item{render}{Rendering behavior for site: -\itemize{ -\item \code{"none"} uploads a static version of the current contents of -the site directory. -\item \code{"local"} renders the site locally then uploads it. -\item \code{"server"} uploads the source of the site to render on the server. -} - -Note that for \code{"none"} and \code{"local"} source files (e.g. \code{.R}, \code{.Rmd} and -\code{.md}) will not be uploaded to the server.} +\item{...}{Other arguments to be passed to [rsconnect::deploySite()].} } \description{ -Publish a book to the web. Note that you should be sure to render all -versions of the book before publishing, unless you have specified -\code{render = TRUE}. +Publish a book to a Connect Server. By default, you should render the book +locally before publishing. +} +\note{ +Previously the default server was bookdown.org, which will be sunset. + You are no longer recommended to publish to bookdown.org. }