Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Disallow deploying .qmd files with rmd-* app modes #595

Merged
merged 9 commits into from
Jun 29, 2022
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
5 changes: 4 additions & 1 deletion NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@

## 0.8.27 (in development)

- fix typo for `.rscignore` (#599)
* Quarto content will no longer silently deploy as R Markdown content when
Quarto metadata is missing or cannot be gathered. Functions will error,
requesting the path to a Quarto binary in the `quarto` argument. (#594)
* fix typo for `.rscignore` (#599)

## 0.8.26

Expand Down
48 changes: 36 additions & 12 deletions R/bundle.R
Original file line number Diff line number Diff line change
Expand Up @@ -406,16 +406,39 @@ inferAppMode <- function(appDir, appPrimaryDoc, files, quartoInfo) {
return("shiny")
}

# Determine if we have Rmd and if they are (optionally) need the Shiny runtime.
rmdFiles <- grep("^[^/\\\\]+\\.[rq]md$", files, ignore.case = TRUE, perl = TRUE, value = TRUE)
# Determine if we have Rmd files, and if they use the Shiny runtime.
rmdFiles <- grep("^[^/\\\\]+\\.rmd$", files, ignore.case = TRUE, perl = TRUE, value = TRUE)
shinyRmdFiles <- sapply(file.path(appDir, rmdFiles), isShinyRmd)

# An Rmd file with a Shiny runtime uses rmarkdown::run.
if (any(shinyRmdFiles)) {
if (is.null(quartoInfo)) {
return("rmd-shiny")
} else {
# Determine if we have qmd files, and if they use the Shiny runtime
qmdFiles <- grep("^[^/\\\\]+\\.qmd$", files, ignore.case = TRUE, perl = TRUE, value = TRUE)
shinyQmdFiles <- sapply(file.path(appDir, qmdFiles), isShinyRmd)

# We make Quarto requirement conditional on the presence of files that Quarto
# can render and _quarto.yml, because keying off the presence of qmds
# *or* _quarto.yml was causing deployment failures in static content.
# https://github.com/rstudio/rstudio/issues/11444
hasQuartoYaml <- any(grepl("^_quarto.y(a)?ml$", x = files, ignore.case = TRUE, perl = TRUE))
hasQuartoSupportedFiles <- any(length(qmdFiles) > 0, length(rmdFiles > 0))
requiresQuarto <- (hasQuartoSupportedFiles && hasQuartoYaml) || length(qmdFiles) > 0

# We gate the deployment of content that appears to be Quarto behind the
# presence of Quarto metadata. Rmd files can still be deployed as Quarto
# content.
if (requiresQuarto && is.null(quartoInfo)) {
stop(paste(
"Attempting to deploy Quarto content without Quarto metadata.",
"Please provide the path to a quarto binary to the 'quarto' argument."
))
}

# Shiny or Quarto documents with "server: shiny" in their YAML front matter
# are rmd-shiny or quarto-shiny.
if (any(shinyRmdFiles) || any(shinyQmdFiles)) {
if (!is.null(quartoInfo)) {
return("quarto-shiny")
} else {
return("rmd-shiny")
}
}

Expand All @@ -427,12 +450,13 @@ inferAppMode <- function(appDir, appPrimaryDoc, files, quartoInfo) {
return("shiny")
}

# Any non-Shiny R Markdown documents are rendered content (rmd-static).
if (length(rmdFiles) > 0) {
if (is.null(quartoInfo)) {
return("rmd-static")
} else {
# Any non-Shiny R Markdown or Quarto documents are rendered content and get
# rmd-static or quarto-static.
if (length(rmdFiles) > 0 || length(qmdFiles) > 0) {
if (!is.null(quartoInfo)) {
return("quarto-static")
} else {
return("rmd-static")
}
}

Expand Down
1 change: 0 additions & 1 deletion rsconnect.Rproj
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ StripTrailingWhitespace: Yes

BuildType: Package
PackageUseDevtools: Yes
PackageCleanBeforeInstall: Yes
PackageInstallArgs: --no-multiarch --with-keep.source
PackageCheckArgs: --as-cran
PackageRoxygenize: rd,collate,namespace
2 changes: 2 additions & 0 deletions tests/testthat/static-with-quarto-yaml/_quarto.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
project:
title: "slideshow"
Loading