Skip to content
Open
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
4 changes: 2 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -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"),
Expand Down Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
69 changes: 32 additions & 37 deletions R/publish.R
Original file line number Diff line number Diff line change
@@ -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, ...)
}
33 changes: 11 additions & 22 deletions man/publish_book.Rd

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