Skip to content
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
2 changes: 2 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# quarto (development version)

- `quarto_create_project()` offers better user experience now (thanks, @jennybc, #206, #153).

- `quarto_preview()` gains a `quiet` argument to suppress any output from R or Quarto CLI (thanks, @cwickham, #232.)

- Add some helpers function `theme_brand_*` and `theme_colors_*` to help theme with dark and light brand using some common graph and table packages (thanks, @gordonwoodhull, [#234](https://github.com/quarto-dev/quarto-r/issues/234)).
Expand Down
27 changes: 18 additions & 9 deletions R/create.R
Original file line number Diff line number Diff line change
@@ -1,23 +1,31 @@
#' Create a quarto project
#'
#' This function calls `quarto create project <type> <name>`. It will create a
#' new directory with the project name and add some skeletons files for the
#' project type chosen.
#' This function calls `quarto create project <type> <name>`. It creates a new
#' directory with the project name, inside the requested parent directory, and
#' adds some starter files that are appropriate to the project type.
#'
#' # Quarto version required
#'
#' This function require Quarto 1.4 or higher. Use [`quarto_version()`]to check
#' the version of Quarto detected.
#' This function requires Quarto 1.4 or higher. Use [quarto_version()] to see
#' your current Quarto version.
#'
#' @param type The type of project to create. As of 1.4, it can be one of
#' @param type The type of project to create. As of Quarto 1.4, it can be one of
#' `r paste0("\\code{", paste(quarto_project_type, collapse = "}, \\code{"),"}")`.
#' @param name The name of the project and the directory that will be created.
#' @param dir The directory where to create the new Quarto project.
#' @param dir The directory in which to create the new Quarto project, i.e. the
#' parent directory.
#'
#' @seealso Quarto documentation on [Quarto projects](https://quarto.org/docs/projects/quarto-projects.html)
#'
#' @inheritParams quarto_render
#' @inheritParams quarto_add_extension
#' @param no_prompt Do not prompt to approve the creation of the new project
#' folder.
#'
#' @examples
#' \dontrun{
#' quarto_create_project("my-first-quarto-project", dir = "~/tmp")
#' }
#'
#'
#' @export
quarto_create_project <- function(
Expand All @@ -43,7 +51,7 @@
"This will create a new Quarto {.emph {type}} project as a folder named {.strong {name}} in {.path {xfun::normalize_path(dir)}}."
))
prompt_value <- tolower(readline(sprintf("Do you want to proceed (Y/n)? ")))
if (!prompt_value %in% "y") {
if (!prompt_value %in% c("", "y")) {

Check warning on line 54 in R/create.R

View check run for this annotation

Codecov / codecov/patch

R/create.R#L54

Added line #L54 was not covered by tests
cli::cli_abort("Operation aborted.")
}
}
Expand All @@ -54,6 +62,7 @@
"project",
type,
name,
name,
"--no-prompt",
"--no-open",
if (is_quiet(quiet)) cli_arg_quiet(),
Expand Down
25 changes: 17 additions & 8 deletions man/quarto_create_project.Rd

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

8 changes: 0 additions & 8 deletions tests/testthat/test-create.R
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
test_that("Create a quarto project", {
skip_if_no_quarto("1.4")
# TODO: Fix the test once issue solve upstream
# - https://github.com/quarto-dev/quarto-cli/issues/8809
# - https://github.com/quarto-dev/quarto-r/issues/153
skip_if_quarto("1.5")
expect_snapshot(
error = TRUE,
quarto_create_project()
Expand All @@ -16,10 +12,6 @@ test_that("Create a quarto project", {

test_that("Create a quarto project in another directory", {
skip_if_no_quarto("1.4")
# TODO: Fix the test once issue solve upstream
# - https://github.com/quarto-dev/quarto-cli/issues/8809
# - https://github.com/quarto-dev/quarto-r/issues/153
skip_if_quarto("1.5")
tempdir <- withr::local_tempdir()
curr_wd <- getwd()
expect_no_error(quarto_create_project(
Expand Down