|
| 1 | +#' Update a Quarto extensions |
| 2 | +#' |
| 3 | +#' Update an extension to this folder or project by running `quarto update` |
| 4 | +#' |
| 5 | +#' # Extension Trust |
| 6 | +#' |
| 7 | +#' Quarto extensions may execute code when documents are rendered. Therefore, if |
| 8 | +#' you do not trust the author of an extension, we recommend that you do not |
| 9 | +#' install or use the extension. |
| 10 | +#' By default `no_prompt = FALSE` which means that |
| 11 | +#' the function will ask for explicit approval when used interactively, or |
| 12 | +#' disallow installation. |
| 13 | +#' |
| 14 | +#' @inheritParams quarto_render |
| 15 | +#' |
| 16 | +#' @param extension The extension to install, either an archive or a GitHub |
| 17 | +#' repository as described in the documentation |
| 18 | +#' <https://quarto.org/docs/extensions/managing.html>. |
| 19 | +#' |
| 20 | +#' @param no_prompt Do not prompt to confirm approval to download external extension. |
| 21 | +#' |
| 22 | +#' @examples |
| 23 | +#' \dontrun{ |
| 24 | +#' # Update a template and set up a draft document from a GitHub repository |
| 25 | +#' quarto_update_extension("quarto-ext/fontawesome") |
| 26 | +#' |
| 27 | +#' # Update a template and set up a draft document from a ZIP archive |
| 28 | +#' quarto_update_extension("https://github.com/quarto-ext/fontawesome/archive/refs/heads/main.zip") |
| 29 | +#' } |
| 30 | +#' |
| 31 | +#' @importFrom rlang is_interactive |
| 32 | +#' @importFrom cli cli_abort |
| 33 | +#' @export |
| 34 | +quarto_update_extension <- function(extension = NULL, no_prompt = FALSE, quiet = FALSE, quarto_args = NULL) { |
| 35 | + rlang::check_required(extension) |
| 36 | + |
| 37 | + quarto_bin <- find_quarto() |
| 38 | + |
| 39 | + # This will ask for approval or stop installation |
| 40 | + approval <- check_extension_approval(no_prompt, "Quarto extensions", "https://quarto.org/docs/extensions/managing.html") |
| 41 | + |
| 42 | + if (approval) { |
| 43 | + args <- c(extension, "--no-prompt", if (quiet) cli_arg_quiet(), quarto_args) |
| 44 | + quarto_update(args, quarto_bin = quarto_bin, echo = TRUE) |
| 45 | + } |
| 46 | + |
| 47 | + invisible() |
| 48 | +} |
| 49 | + |
| 50 | +quarto_update <- function(args = character(), ...) { |
| 51 | + quarto_run_what("update", args = args, ...) |
| 52 | +} |
0 commit comments