rstudio / rsconnect

Publish Shiny Applications, RMarkdown Documents, Jupyter Notebooks, Plumber APIs, and more
http://rstudio.github.io/rsconnect/
129 stars 79 forks source link

quarto: more flexible discovery #1055

Closed aronatkins closed 3 months ago

aronatkins commented 3 months ago

A rendered script script.R might look like:

#' ---
#' title: cats are cats
#' ---

cat("i am a cat\n")

It may or may not have an accompanying _quarto.yml file. A simple version of the Quarto configuration might look like:

project:
    type: default

Other changes

This work also necessitated a change to how we bundle content. In particular, RStudio is able to run and deploy Shiny single-file applications which are contained in files not named app.R. For example, if we create a project containing the default Geyser app and save it to notapp.R rather than app.R, RStudio can deploy that file. It is able to deploy the Shiny application because notapp.R is renamed to app.R when the content is bundled.

The action taken by RStudio is effectively:

rsconnect::deployApp(appPrimaryDoc = "notapp.R")

This forces rsconnect to treat the content as a Shiny application and also forces the rename of notapp.R to app.R.

Prior to this change, rsconnect would rewrite any appPrimaryDoc=*.R to app.R regardless of content type. Unfortunately, appPrimaryDoc is computed internally and used by Quarto content. Because that primary asset was an R script, bundling renamed it. To avoid this, the rename is now specific to Shiny content.

Test that RStudio can deploy a Shiny application in a notapp.R file. Download that deployed bundle and see that the application has been renamed to app.R.

Other types of content (e.g., Plumber APIs, Quarto rendered scripts) do not have their R scripts renamed when deployed.

aronatkins commented 3 months ago

Out of curiosity: I have only been loosely following the Connect-side changes for Quarto R scripts. I know we have kicked around the idea of an "R script" content type; is this substantially different for how we think that'd function?

This uses Quarto to run the script because that gives us very opinionated ways of capturing output, attaching resources, etc. This may not be enough for some folks, but is much less invasive than rewriting an R script into an R Markdown document, for example.