diff --git a/NAMESPACE b/NAMESPACE index c0da22ca..1f59daf5 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -98,16 +98,6 @@ importFrom(cli,cli_alert_info) importFrom(config,get) importFrom(desc,desc_get_deps) importFrom(desc,description) -importFrom(fs,dir_copy) -importFrom(fs,dir_create) -importFrom(fs,dir_exists) -importFrom(fs,file_copy) -importFrom(fs,file_create) -importFrom(fs,file_delete) -importFrom(fs,file_exists) -importFrom(fs,path) -importFrom(fs,path_abs) -importFrom(fs,path_file) importFrom(htmltools,htmlDependency) importFrom(rstudioapi,documentSaveAll) importFrom(rstudioapi,getSourceEditorContext) diff --git a/R/add_dockerfiles.R b/R/add_dockerfiles.R index b3857371..563d6059 100644 --- a/R/add_dockerfiles.R +++ b/R/add_dockerfiles.R @@ -58,7 +58,6 @@ talk_once <- function(.f, msg = "") { #' @importFrom usethis use_build_ignore #' @importFrom desc desc_get_deps #' @importFrom rstudioapi navigateToFile isAvailable hasFun -#' @importFrom fs path path_file #' #' @examples #' \donttest{ @@ -179,9 +178,9 @@ add_dockerfile_ <- talk_once( reason = "to build a Dockerfile." ) - where <- path(pkg, output) + where <- fs_path(pkg, output) - usethis::use_build_ignore(path_file(where)) + usethis::use_build_ignore(basename(where)) dock <- dockerfiler::dock_from_desc( path = path, @@ -228,7 +227,6 @@ add_dockerfile_ <- talk_once( #' @export #' @rdname dockerfiles -#' @importFrom fs path path_file add_dockerfile_shinyproxy <- function( path = "DESCRIPTION", output = "Dockerfile", @@ -289,7 +287,7 @@ add_dockerfile_shinyproxy_ <- talk_once( version = "0.2.0", reason = "to build a Dockerfile." ) - where <- path(pkg, output) + where <- fs_path(pkg, output) usethis::use_build_ignore(output) @@ -332,7 +330,6 @@ add_dockerfile_shinyproxy_ <- talk_once( #' @export #' @rdname dockerfiles -#' @importFrom fs path path_file add_dockerfile_heroku <- function( path = "DESCRIPTION", output = "Dockerfile", @@ -393,7 +390,7 @@ add_dockerfile_heroku_ <- talk_once( version = "0.2.0", reason = "to build a Dockerfile." ) - where <- path(pkg, output) + where <- fs_path(pkg, output) usethis::use_build_ignore(output) diff --git a/R/add_dockerfiles_renv.R b/R/add_dockerfiles_renv.R index f6639bdf..b9c59503 100644 --- a/R/add_dockerfiles_renv.R +++ b/R/add_dockerfiles_renv.R @@ -41,10 +41,17 @@ add_dockerfile_with_renv_ <- function( } if (is.null(lockfile)) { - lockfile <- attachment::create_renv_for_prod(path = source_folder, output = file.path(output_dir, "renv.lock.prod")) + lockfile <- attachment::create_renv_for_prod( + path = source_folder, + output = file.path(output_dir, "renv.lock.prod") + ) } - file.copy(from = lockfile, to = output_dir) + fs_file_copy( + path = lockfile, + new_path = output_dir, + overwrite = TRUE + ) socle <- dockerfiler::dock_from_renv( lockfile = lockfile, @@ -289,7 +296,10 @@ add_dockerfile_with_renv_heroku <- function( ) ) - readme_output <- file.path(output_dir, "README") + readme_output <- fs_path( + output_dir, + "README" + ) write_there <- function(...) { write(..., file = readme_output, append = TRUE) diff --git a/R/add_files.R b/R/add_files.R index df6a9e60..08a420ea 100644 --- a/R/add_files.R +++ b/R/add_files.R @@ -1,14 +1,3 @@ -check_name_length <- function(name) { - stop_if( - name, - ~ length(.x) > 1, - sprintf( - "`name` should be of length 1. Got %d.", - length(name) - ) - ) -} - #' Create Files #' #' These functions create files inside the `inst/app` folder. @@ -35,7 +24,6 @@ check_name_length <- function(name) { #' @importFrom attempt stop_if #' @importFrom cli cat_bullet #' @importFrom utils file.edit -#' @importFrom fs path_abs path file_create file_exists #' #' @note `add_ui_server_files` will be deprecated in future version of `{golem}` #' @@ -61,7 +49,7 @@ add_js_file <- function( name <- file_path_sans_ext(name) - old <- setwd(path_abs(pkg)) + old <- setwd(fs_path_abs(pkg)) on.exit(setwd(old)) dir_created <- create_if_needed( @@ -74,16 +62,15 @@ add_js_file <- function( return(invisible(FALSE)) } - dir <- path_abs(dir) + dir <- fs_path_abs(dir) - where <- path( + where <- fs_path( dir, sprintf("%s.js", name) ) - if (!file.exists(where)) { - file_create(where) - + if (!fs_file_exists(where)) { + fs_file_create(where) if (with_doc_ready) { write_there <- function(...) { write(..., file = where, append = TRUE) @@ -112,8 +99,6 @@ add_js_file <- function( #' @export #' @rdname add_files -#' -#' @importFrom fs path_abs path file_create file_exists add_js_handler <- function( name, pkg = get_golem_wd(), @@ -132,7 +117,7 @@ add_js_handler <- function( name <- file_path_sans_ext(name) - old <- setwd(path_abs(pkg)) + old <- setwd(fs_path_abs(pkg)) on.exit(setwd(old)) dir_created <- create_if_needed( @@ -145,15 +130,15 @@ add_js_handler <- function( return(invisible(FALSE)) } - dir <- path_abs(dir) + dir <- fs_path_abs(dir) - where <- file.path( + where <- fs_path( dir, sprintf("%s.js", name) ) - if (!file.exists(where)) { - file_create(where) + if (!fs_file_exists(where)) { + fs_file_create(where) template(path = where, ...) @@ -175,7 +160,6 @@ add_js_handler <- function( #' @export #' @rdname add_files -#' @importFrom fs path_abs path file_create file_exists add_js_input_binding <- function( name, pkg = get_golem_wd(), @@ -212,7 +196,7 @@ add_js_input_binding <- function( sprintf("input-%s", name) ) - old <- setwd(path_abs(pkg)) + old <- setwd(fs_path_abs(pkg)) on.exit(setwd(old)) dir_created <- create_if_needed( @@ -225,15 +209,15 @@ add_js_input_binding <- function( return(invisible(FALSE)) } - dir <- path_abs(dir) + dir <- fs_path_abs(dir) - where <- file.path( + where <- fs_path( dir, sprintf("%s.js", name) ) - if (!file.exists(where)) { - file_create(where) + if (!fs_file_exists(where)) { + fs_file_create(where) write_there <- function(...) { write(..., file = where, append = TRUE) @@ -324,7 +308,6 @@ add_js_input_binding <- function( #' @export #' @rdname add_files -#' @importFrom fs path_abs path file_create file_exists add_js_output_binding <- function( name, pkg = get_golem_wd(), @@ -345,7 +328,7 @@ add_js_output_binding <- function( sprintf("output-%s", name) ) - old <- setwd(path_abs(pkg)) + old <- setwd(fs_path_abs(pkg)) on.exit(setwd(old)) dir_created <- create_if_needed( @@ -358,15 +341,15 @@ add_js_output_binding <- function( return(invisible(FALSE)) } - dir <- path_abs(dir) + dir <- fs_path_abs(dir) - where <- file.path( + where <- fs_path( dir, sprintf("%s.js", name) ) - if (!file.exists(where)) { - file_create(where) + if (!fs_file_exists(where)) { + fs_file_create(where) write_there <- function(...) { write(..., file = where, append = TRUE) @@ -407,7 +390,6 @@ add_js_output_binding <- function( #' @export #' @rdname add_files -#' @importFrom fs path_abs path file_create file_exists add_css_file <- function( name, pkg = get_golem_wd(), @@ -426,7 +408,7 @@ add_css_file <- function( name <- file_path_sans_ext(name) - old <- setwd(path_abs(pkg)) + old <- setwd(fs_path_abs(pkg)) on.exit(setwd(old)) dir_created <- create_if_needed( @@ -439,9 +421,9 @@ add_css_file <- function( return(invisible(FALSE)) } - dir <- path_abs(dir) + dir <- fs_path_abs(dir) - where <- path( + where <- fs_path( dir, sprintf( "%s.css", @@ -449,8 +431,8 @@ add_css_file <- function( ) ) - if (!file_exists(where)) { - file_create(where) + if (!fs_file_exists(where)) { + fs_file_create(where) template(path = where, ...) file_created_dance( where, @@ -470,7 +452,6 @@ add_css_file <- function( #' @export #' @rdname add_files -#' @importFrom fs path_abs path file_create file_exists #' @importFrom cli cli_alert_info add_sass_file <- function( name, @@ -490,7 +471,7 @@ add_sass_file <- function( name <- file_path_sans_ext(name) - old <- setwd(path_abs(pkg)) + old <- setwd(fs_path_abs(pkg)) on.exit(setwd(old)) dir_created <- create_if_needed( @@ -503,9 +484,9 @@ add_sass_file <- function( return(invisible(FALSE)) } - dir_abs <- path_abs(dir) + dir_abs <- fs_path_abs(dir) - where <- path( + where <- fs_path( dir_abs, sprintf( "%s.sass", @@ -513,8 +494,8 @@ add_sass_file <- function( ) ) - if (!file_exists(where)) { - file_create(where) + if (!fs_file_exists(where)) { + fs_file_create(where) template(path = where, ...) file_created_dance( where, @@ -544,7 +525,6 @@ add_sass_file <- function( #' @export #' @rdname add_files -#' @importFrom fs path_abs path file_create file_exists add_html_template <- function( name = "template.html", pkg = get_golem_wd(), @@ -556,7 +536,7 @@ add_html_template <- function( check_name_length(name) - old <- setwd(path_abs(pkg)) + old <- setwd(fs_path_abs(pkg)) on.exit(setwd(old)) dir_created <- create_if_needed( @@ -569,9 +549,9 @@ add_html_template <- function( return(invisible(FALSE)) } - dir <- path_abs(dir) + dir <- fs_path_abs(dir) - where <- path( + where <- fs_path( dir, sprintf( "%s.html", @@ -579,8 +559,8 @@ add_html_template <- function( ) ) - if (!file_exists(where)) { - file_create(where) + if (!fs_file_exists(where)) { + fs_file_create(where) write_there <- function(...) write(..., file = where, append = TRUE) write_there("") write_there("") @@ -615,7 +595,6 @@ add_html_template <- function( #' @export #' @rdname add_files -#' @importFrom fs path_abs path file_create file_exists add_partial_html_template <- function( name = "partial_template.html", pkg = get_golem_wd(), @@ -626,7 +605,7 @@ add_partial_html_template <- function( name <- file_path_sans_ext(name) check_name_length(name) - old <- setwd(path_abs(pkg)) + old <- setwd(fs_path_abs(pkg)) on.exit(setwd(old)) dir_created <- create_if_needed( @@ -639,9 +618,9 @@ add_partial_html_template <- function( return(invisible(FALSE)) } - dir <- path_abs(dir) + dir <- fs_path_abs(dir) - where <- path( + where <- fs_path( dir, sprintf( "%s.html", @@ -649,8 +628,8 @@ add_partial_html_template <- function( ) ) - if (!file_exists(where)) { - file_create(where) + if (!fs_file_exists(where)) { + fs_file_create(where) write_there <- function(...) write(..., file = where, append = TRUE) write_there("
") write_there(" {{ content }}") @@ -674,7 +653,6 @@ add_partial_html_template <- function( #' @export #' @rdname add_files -#' @importFrom fs path_abs file_create add_ui_server_files <- function( pkg = get_golem_wd(), dir = "inst/app", @@ -682,7 +660,7 @@ add_ui_server_files <- function( ) { .Deprecated(msg = "This function will be deprecated in a future version of {golem}.\nPlease comment on https://github.com/ThinkR-open/golem/issues/445 if you want it to stay.") - old <- setwd(path_abs(pkg)) + old <- setwd(fs_path_abs(pkg)) on.exit(setwd(old)) dir_created <- create_if_needed( @@ -695,13 +673,13 @@ add_ui_server_files <- function( return(invisible(FALSE)) } - dir <- path_abs(dir) + dir <- fs_path_abs(dir) # UI - where <- path(dir, "ui.R") + where <- fs_path(dir, "ui.R") - if (!file_exists(where)) { - file_create(where) + if (!fs_file_exists(where)) { + fs_file_create(where) write_there <- function(...) write(..., file = where, append = TRUE) @@ -722,8 +700,8 @@ add_ui_server_files <- function( "server.R" ) - if (!file_exists(where)) { - file_create(where) + if (!fs_file_exists(where)) { + fs_file_create(where) write_there <- function(...) write(..., file = where, append = TRUE) diff --git a/R/add_r_files.R b/R/add_r_files.R index 4013f6c7..7624ba10 100644 --- a/R/add_r_files.R +++ b/R/add_r_files.R @@ -1,4 +1,3 @@ -#' @importFrom fs path_abs path file_create add_r_files <- function( name, ext = c("fct", "utils"), @@ -12,7 +11,7 @@ add_r_files <- function( check_name_length(name) - old <- setwd(path_abs(pkg)) + old <- setwd(fs_path_abs(pkg)) on.exit(setwd(old)) dir_created <- create_if_needed( @@ -43,15 +42,15 @@ add_r_files <- function( module <- paste0("mod_", module, "_") } - where <- path( + where <- fs_path( "R", paste0(module, ext, "_", name, ".R") ) - if (!file_exists(where)) { - file_create(where) + if (!fs_file_exists(where)) { + fs_file_create(where) - if (file_exists(where) & is.null(module)) { + if (fs_file_exists(where) & is.null(module)) { # Must be a function or utility file being created append_roxygen_comment( name = name, diff --git a/R/add_rstudio_files.R b/R/add_rstudio_files.R index 41966f4e..f756e1e1 100644 --- a/R/add_rstudio_files.R +++ b/R/add_rstudio_files.R @@ -1,7 +1,6 @@ #' @importFrom utils capture.output #' @importFrom cli cat_bullet #' @importFrom usethis use_build_ignore use_package -#' @importFrom fs path file_create path_file add_rstudio_files <- function( pkg, open, @@ -12,7 +11,7 @@ add_rstudio_files <- function( ) ) { service <- match.arg(service) - where <- path(pkg, "app.R") + where <- fs_path(pkg, "app.R") rlang::check_installed( "pkgload", @@ -25,14 +24,14 @@ add_rstudio_files <- function( pkg = pkg ) - if (!file_exists(where)) { - file_create(where) + if (!fs_file_exists(where)) { + fs_file_create(where) write_there <- function(..., here = where) { write(..., here, append = TRUE) } - use_build_ignore(path_file(where)) + use_build_ignore(basename(where)) use_build_ignore("rsconnect") write_there("# Launch the ShinyApp (Do not remove this comment)") write_there("# To deploy, run: rsconnect::deployApp()") diff --git a/R/addins.R b/R/addins.R index b998a669..50502b9d 100644 --- a/R/addins.R +++ b/R/addins.R @@ -37,16 +37,15 @@ insert_ns <- function() { rstudioapi::modifyRange(sel_rng, mod_text, id = id) } -#' @importFrom fs path file_exists go_to <- function( file, wd = golem::get_golem_wd() ) { - file <- path( + file <- fs_path( wd, file ) - if (!file_exists(file)) { + if (!fs_file_exists(file)) { message(file, "not found.") } diff --git a/R/config.R b/R/config.R index 4f2ac5cc..37df7748 100644 --- a/R/config.R +++ b/R/config.R @@ -8,9 +8,8 @@ # work #' @importFrom attempt attempt is_try_error -#' @importFrom fs path path_abs guess_where_config <- function( - path = ".", + path = golem::pkg_path(), file = "inst/golem-config.yml" ) { # We'll try to guess where the path @@ -19,23 +18,23 @@ guess_where_config <- function( # This one should be correct in 99% of the case # If we don't change the default values of the params. # => current directory /inst/golem-config.yml - ret_path <- path( + ret_path <- fs_path( path, file ) - if (file_exists(ret_path)) { - return(path_abs(ret_path)) + if (fs_file_exists(ret_path)) { + return(fs_path_abs(ret_path)) } # Maybe for some reason we are in inst/ ret_path <- "golem-config.yml" - if (file_exists(ret_path)) { - return(path_abs(ret_path)) + if (fs_file_exists(ret_path)) { + return(fs_path_abs(ret_path)) } # Trying with pkg_path ret_path <- attempt({ - path( + fs_path( golem::pkg_path(), "inst/golem-config.yml" ) @@ -43,10 +42,10 @@ guess_where_config <- function( if ( !is_try_error(ret_path) & - file_exists(ret_path) + fs_file_exists(ret_path) ) { return( - path_abs(ret_path) + fs_path_abs(ret_path) ) } return(NULL) @@ -58,25 +57,23 @@ guess_where_config <- function( #' If it can't find it, this function asks the #' user if they want to set the golem skeleton. #' -#' @importFrom fs file_copy path -#' #' @param path Path to start looking for the config #' #' @export -get_current_config <- function(path = ".") { +get_current_config <- function(path = getwd()) { # We check wether we can guess where the config file is path_conf <- guess_where_config(path) # We default to inst/ if this doesn't exist if (is.null(path_conf)) { - path_conf <- path( + path_conf <- fs_path( path, "inst/golem-config.yml" ) } - if (!file_exists(path_conf)) { + if (!fs_file_exists(path_conf)) { if (interactive()) { ask <- yesno( sprintf( @@ -89,22 +86,22 @@ get_current_config <- function(path = ".") { return(NULL) } - file_copy( + fs_file_copy( path = golem_sys("shinyexample/inst/golem-config.yml"), - new_path = path( + new_path = fs_path( path, "inst/golem-config.yml" ) ) - file_copy( + fs_file_copy( path = golem_sys("shinyexample/R/app_config.R"), - new_path = file.path( + new_path = fs_path( path, "R/app_config.R" ) ) replace_word( - path( + fs_path( path, "R/app_config.R" ), @@ -134,7 +131,7 @@ change_app_config_name <- function( name, path = get_golem_wd() ) { - pth <- fs::path(path, "R", "app_config.R") + pth <- fs_path(path, "R", "app_config.R") app_config <- readLines(pth) where_system.file <- grep("system.file", app_config) diff --git a/R/create_golem.R b/R/create_golem.R index 566ede49..5f4b5651 100644 --- a/R/create_golem.R +++ b/R/create_golem.R @@ -58,7 +58,6 @@ replace_package_name <- function( #' @importFrom utils getFromNamespace #' @importFrom rstudioapi isAvailable openProject hasFun #' @importFrom usethis use_latest_dependencies create_project -#' @importFrom fs dir_copy #' @importFrom yaml write_yaml #' #' @export @@ -75,7 +74,10 @@ create_golem <- function( with_git = FALSE, ... ) { - path_to_golem <- normalizePath(path, mustWork = FALSE) + path_to_golem <- normalizePath( + path, + mustWork = FALSE + ) if (check_name) { cat_rule("Checking package name") @@ -84,7 +86,7 @@ create_golem <- function( } - if (dir.exists(path_to_golem)) { + if (fs_dir_exists(path_to_golem)) { if (!isTRUE(overwrite)) { stop( paste( @@ -104,6 +106,7 @@ create_golem <- function( path = path_to_golem, open = FALSE, ) + here::set_here(path_to_golem) cat_green_tick("Created package directory") } @@ -112,7 +115,7 @@ create_golem <- function( from <- golem_sys("shinyexample") # Copy over whole directory - dir_copy( + fs_dir_copy( path = from, new_path = path_to_golem, overwrite = TRUE diff --git a/R/desc.R b/R/desc.R index b26da92d..45bb25fd 100644 --- a/R/desc.R +++ b/R/desc.R @@ -12,7 +12,6 @@ #' #' @importFrom desc description #' @importFrom cli cat_bullet -#' @importFrom fs path path_abs #' #' @export #' @@ -28,10 +27,10 @@ fill_desc <- function( repo_url = NULL, pkg = get_golem_wd() ) { - path <- path_abs(pkg) + path <- fs_path_abs(pkg) desc <- desc::description$new( - file = path(path, "DESCRIPTION") + file = fs_path(path, "DESCRIPTION") ) if (!is.null(author_orcid) & !is.character(author_orcid)) { diff --git a/R/disable_autoload.R b/R/disable_autoload.R index 0e8f7993..64215656 100644 --- a/R/disable_autoload.R +++ b/R/disable_autoload.R @@ -10,12 +10,12 @@ #' } #' @return The path to the file, invisibly. disable_autoload <- function(pkg = get_golem_wd()) { - fls <- fs::path( + fls <- fs_path( pkg, "R", "_disable_autoload.R" ) - if (fs::file_exists(fls)) { + if (fs_file_exists(fls)) { cat_red_bullet( "_disable_autoload.R already exists, skipping its creation." ) diff --git a/R/fs_boostrap.R b/R/fs_boostrap.R new file mode 100644 index 00000000..55ab5b83 --- /dev/null +++ b/R/fs_boostrap.R @@ -0,0 +1,82 @@ +# All the fns here check that {fs} is installed +# before doing anything. +check_fs_installed <- function() { + rlang::check_installed( + "fs", + reason = "for file & directory manipulation.\nYou can install all {golem} dev dependencies with `golem::install_dev_deps()`." + ) +} + +fs_dir_exists <- function(path) { + check_fs_installed() + fs::dir_exists(path) +} + +fs_dir_create <- function( + path, + ..., + mode = "u=rwx,go=rx", + recurse = TRUE, + recursive +) { + check_fs_installed() + fs::dir_create( + path, + ..., + mode = mode, + recurse = recurse, + recursive = recursive + ) +} + + +fs_file_create <- function(where) { + check_fs_installed() + fs::file_create(where) +} + +fs_file_delete <- function(path) { + check_fs_installed() + fs::file_delete(path) +} + +fs_file_exists <- function(path) { + check_fs_installed() + fs::file_exists(path) +} + +fs_path_abs <- function(path) { + check_fs_installed() + fs::path_abs(path) +} + +fs_path <- function(..., ext = "") { + check_fs_installed() + fs::path(..., ext = ext) +} + +fs_file_copy <- function( + path, + new_path, + overwrite = FALSE +) { + check_fs_installed() + fs::file_copy( + path = path, + new_path = new_path, + overwrite + ) +} + +fs_dir_copy <- function( + path, + new_path, + overwrite = FALSE +) { + check_fs_installed() + fs::dir_copy( + path, + new_path, + overwrite + ) +} diff --git a/R/golem-yaml-get.R b/R/golem-yaml-get.R index 5eaa7781..613e720f 100644 --- a/R/golem-yaml-get.R +++ b/R/golem-yaml-get.R @@ -29,13 +29,12 @@ get_golem_things <- function( } #' @export -#' @importFrom fs path_abs #' @rdname golem_opts get_golem_wd <- function( use_parent = TRUE, pkg = golem::pkg_path() ) { - path <- path_abs(pkg) + path <- fs_path_abs(pkg) pth <- get_golem_things( value = "golem_wd", @@ -50,7 +49,6 @@ get_golem_wd <- function( } #' @export -#' @importFrom fs path_abs #' @rdname golem_opts get_golem_name <- function( config = Sys.getenv( @@ -63,7 +61,7 @@ get_golem_name <- function( use_parent = TRUE, pkg = golem::pkg_path() ) { - path <- path_abs(pkg) + path <- fs_path_abs(pkg) nm <- get_golem_things( value = "golem_name", config = config, @@ -77,7 +75,6 @@ get_golem_name <- function( } #' @export -#' @importFrom fs path_abs #' @rdname golem_opts get_golem_version <- function( config = Sys.getenv( @@ -90,7 +87,7 @@ get_golem_version <- function( use_parent = TRUE, pkg = golem::pkg_path() ) { - path <- path_abs(pkg) + path <- fs_path_abs(pkg) vers <- get_golem_things( value = "golem_version", config = config, diff --git a/R/golem-yaml-set.R b/R/golem-yaml-set.R index b1807c32..4e5c26c3 100644 --- a/R/golem-yaml-set.R +++ b/R/golem-yaml-set.R @@ -1,5 +1,4 @@ #' @export -#' @importFrom fs path_abs #' @rdname golem_opts set_golem_wd <- function( golem_wd = golem::pkg_path(), @@ -13,7 +12,7 @@ set_golem_wd <- function( golem_yaml_path <- "golem::pkg_path()" attr(golem_yaml_path, "tag") <- "!expr" } else { - golem_yaml_path <- path_abs(golem_wd) + golem_yaml_path <- fs_path_abs(golem_wd) } amend_golem_config( @@ -24,18 +23,17 @@ set_golem_wd <- function( talkative = talkative ) - invisible(path) + invisible(golem_yaml_path) } #' @export #' @rdname golem_opts -#' @importFrom fs path_abs set_golem_name <- function( name = golem::pkg_name(), pkg = golem::pkg_path(), talkative = TRUE ) { - path <- path_abs(pkg) + path <- fs_path_abs(pkg) # Changing in YAML amend_golem_config( @@ -53,7 +51,7 @@ set_golem_name <- function( # Changing in DESCRIPTION desc <- desc::description$new( - file = fs::path( + file = fs_path( path, "DESCRIPTION" ) @@ -70,13 +68,12 @@ set_golem_name <- function( #' @export #' @rdname golem_opts -#' @importFrom fs path_abs set_golem_version <- function( version = golem::pkg_version(), pkg = golem::pkg_path(), talkative = TRUE ) { - path <- path_abs(pkg) + path <- fs_path_abs(pkg) # Changing in YAML amend_golem_config( @@ -88,7 +85,7 @@ set_golem_version <- function( ) desc <- desc::description$new( - file = fs::path( + file = fs_path( path, "DESCRIPTION" ) diff --git a/R/modules_fn.R b/R/modules_fn.R index 6ae04aa7..c55d0cac 100644 --- a/R/modules_fn.R +++ b/R/modules_fn.R @@ -21,7 +21,6 @@ #' @export #' @importFrom cli cat_bullet #' @importFrom utils file.edit -#' @importFrom fs path_abs path file_create #' #' @seealso [module_template()] #' @@ -43,11 +42,11 @@ add_module <- function( check_name_length(name) name <- file_path_sans_ext(name) - old <- setwd(path_abs(pkg)) + old <- setwd(fs_path_abs(pkg)) on.exit(setwd(old)) dir_created <- create_if_needed( - path(pkg, "R"), + fs_path(pkg, "R"), type = "directory" ) @@ -56,13 +55,13 @@ add_module <- function( return(invisible(FALSE)) } - where <- path( + where <- fs_path( "R", paste0("mod_", name, ".R") ) - if (!file_exists(where)) { - file_create(where) + if (!fs_file_exists(where)) { + fs_file_create(where) module_template(name = name, path = where, export = export, ...) @@ -269,17 +268,17 @@ use_module_test <- function( "fs" ) - old <- setwd(fs::path_abs(pkg)) + old <- setwd(fs_path_abs(pkg)) on.exit(setwd(old)) - if (!dir.exists( - path(pkg, "tests", "testthat") + if (!fs_dir_exists( + fs_path(pkg, "tests", "testthat") )) { usethis::use_testthat() } - path <- fs::path( + path <- fs_path( pkg, "tests", "testthat", @@ -290,8 +289,8 @@ use_module_test <- function( ext = "R" ) - if (!fs::file_exists(path)) { - fs::file_create(path) + if (!fs_file_exists(path)) { + fs_file_create(path) write_there <- function(...) { write(..., file = path, append = TRUE) diff --git a/R/pkg_tools.R b/R/pkg_tools.R index 6e743294..ab3aa4b4 100644 --- a/R/pkg_tools.R +++ b/R/pkg_tools.R @@ -9,7 +9,7 @@ daf_desc <- function( as.data.frame( read.dcf( normalizePath( - file.path(path, "DESCRIPTION") + fs_path(path, "DESCRIPTION") ) ) )[entry] @@ -37,7 +37,8 @@ pkg_version <- function(path = ".") { } #' @export #' @rdname pkg_tools -pkg_path <- function(path = ".") { - rlang::check_installed("here") - here::here() +pkg_path <- function() { + # rlang::check_installed("here") + # here::here() + getwd() } diff --git a/R/reload.R b/R/reload.R index 95e062aa..b124da96 100644 --- a/R/reload.R +++ b/R/reload.R @@ -35,7 +35,7 @@ check_name_consistency <- function(pkg) { old_dir <- setwd(pkg) package_name <- desc::desc_get("Package") - pth <- fs::path( + pth <- fs_path( pkg, "R", "app_config.R" diff --git a/R/use_favicon.R b/R/use_favicon.R index 65953ccc..6ad5a7e7 100644 --- a/R/use_favicon.R +++ b/R/use_favicon.R @@ -7,7 +7,6 @@ #' @export #' #' @importFrom attempt stop_if_not -#' @importFrom fs path_abs path file_copy #' #' @return Used for side-effects. #' @@ -34,7 +33,7 @@ use_favicon <- function( ) - local <- fs::file_exists(path) + local <- fs_file_exists(path) if (!local) { if (getRversion() >= "3.5") { @@ -65,15 +64,15 @@ use_favicon <- function( destfile, method = method ) - path <- path_abs(destfile) + path <- fs_path_abs(destfile) } - old <- setwd(path_abs(pkg)) + old <- setwd(fs_path_abs(pkg)) on.exit(setwd(old)) - to <- path( - path_abs(pkg), + to <- fs_path( + fs_path_abs(pkg), "inst/app/www", sprintf( "favicon.%s", @@ -82,7 +81,7 @@ use_favicon <- function( ) if (!(path == to)) { - file_copy( + fs_file_copy( path, to, overwrite = TRUE @@ -109,16 +108,15 @@ use_favicon <- function( #' @rdname favicon #' @export -#' @importFrom fs file_delete file_exists remove_favicon <- function(path = "inst/app/www/favicon.ico") { - if (file_exists(path)) { + if (fs_file_exists(path)) { cat_green_tick( sprintf( "Removing favicon at %s", path ) ) - file_delete(path) + fs_file_delete(path) } else { cat_red_bullet( sprintf( @@ -148,7 +146,7 @@ favicon <- function( resources_path = "www", ext = "ico" ) { - ico <- fs::path( + ico <- fs_path( resources_path, ico, ext = ext diff --git a/R/use_files.R b/R/use_files.R index f23f4b8c..f1d479a0 100644 --- a/R/use_files.R +++ b/R/use_files.R @@ -15,7 +15,6 @@ #' @export #' @rdname use_files #' @importFrom cli cat_bullet -#' @importFrom fs path_abs path file_exists #' #' @return The path to the file, invisibly. use_external_js_file <- function( @@ -26,7 +25,7 @@ use_external_js_file <- function( open = FALSE, dir_create = TRUE ) { - old <- setwd(path_abs(pkg)) + old <- setwd(fs_path_abs(pkg)) on.exit(setwd(old)) if (missing(name)) { @@ -48,14 +47,14 @@ use_external_js_file <- function( return(invisible(FALSE)) } - dir <- path_abs(dir) + dir <- fs_path_abs(dir) - where <- path( + where <- fs_path( dir, new_file ) - if (file_exists(where)) { + if (fs_file_exists(where)) { cat_exists(where) return(invisible(FALSE)) } @@ -85,7 +84,6 @@ use_external_js_file <- function( #' @export #' @rdname use_files -#' @importFrom fs path_abs file_exists use_external_css_file <- function( url, name, @@ -94,7 +92,7 @@ use_external_css_file <- function( open = FALSE, dir_create = TRUE ) { - old <- setwd(path_abs(pkg)) + old <- setwd(fs_path_abs(pkg)) on.exit(setwd(old)) if (missing(name)) { @@ -116,14 +114,14 @@ use_external_css_file <- function( return(invisible(FALSE)) } - dir <- path_abs(dir) + dir <- fs_path_abs(dir) - where <- path( + where <- fs_path( dir, new_file ) - if (file_exists(where)) { + if (fs_file_exists(where)) { cat_exists(where) return(invisible(FALSE)) } @@ -153,7 +151,6 @@ use_external_css_file <- function( #' @export #' @rdname use_files -#' @importFrom fs path_abs file_exists use_external_html_template <- function( url, name = "template.html", @@ -162,7 +159,7 @@ use_external_html_template <- function( open = FALSE, dir_create = TRUE ) { - old <- setwd(path_abs(pkg)) + old <- setwd(fs_path_abs(pkg)) on.exit(setwd(old)) new_file <- sprintf( @@ -182,14 +179,14 @@ use_external_html_template <- function( return(invisible(FALSE)) } - dir <- path_abs(dir) + dir <- fs_path_abs(dir) - where <- path( + where <- fs_path( dir, new_file ) - if (file_exists(where)) { + if (fs_file_exists(where)) { cat_exists(where) return(invisible(FALSE)) } @@ -213,7 +210,6 @@ use_external_html_template <- function( #' @export #' @rdname use_files -#' @importFrom fs path_abs file_exists use_external_file <- function( url, name, @@ -229,7 +225,7 @@ use_external_file <- function( } - old <- setwd(path_abs(pkg)) + old <- setwd(fs_path_abs(pkg)) on.exit(setwd(old)) dir_created <- create_if_needed( @@ -242,14 +238,14 @@ use_external_file <- function( return(invisible(FALSE)) } - dir <- path_abs(dir) + dir <- fs_path_abs(dir) - where <- path( + where <- fs_path( dir, name ) - if (file_exists(where)) { + if (fs_file_exists(where)) { cat_exists(where) return(invisible(FALSE)) } @@ -263,7 +259,6 @@ use_external_file <- function( #' @export #' @rdname use_files -#' @importFrom fs path_abs file_exists use_internal_js_file <- function( path, name, @@ -273,7 +268,7 @@ use_internal_js_file <- function( dir_create = TRUE ) { check_name_length(name) - old <- setwd(path_abs(pkg)) + old <- setwd(fs_path_abs(pkg)) on.exit(setwd(old)) if (missing(name)) { @@ -293,14 +288,14 @@ use_internal_js_file <- function( return(invisible(FALSE)) } - dir <- path_abs(dir) + dir <- fs_path_abs(dir) - where <- path( + where <- fs_path( dir, new_file ) - if (file_exists(where)) { + if (fs_file_exists(where)) { cat_exists(where) return(invisible(FALSE)) } @@ -314,7 +309,7 @@ use_internal_js_file <- function( cat_start_copy() - file.copy(path, where) + fs_file_copy(path, where) file_created_dance( where, @@ -329,7 +324,6 @@ use_internal_js_file <- function( #' @export #' @rdname use_files -#' @importFrom fs path_abs file_exists use_internal_css_file <- function( path, name, @@ -340,7 +334,7 @@ use_internal_css_file <- function( ) { check_name_length(name) - old <- setwd(path_abs(pkg)) + old <- setwd(fs_path_abs(pkg)) on.exit(setwd(old)) if (missing(name)) { @@ -360,14 +354,14 @@ use_internal_css_file <- function( return(invisible(FALSE)) } - dir <- path_abs(dir) + dir <- fs_path_abs(dir) - where <- path( + where <- fs_path( dir, new_file ) - if (file_exists(where)) { + if (fs_file_exists(where)) { cat_exists(where) return(invisible(FALSE)) } @@ -381,7 +375,7 @@ use_internal_css_file <- function( cat_start_copy() - file.copy(path, where) + fs_file_copy(path, where) file_created_dance( where, @@ -396,7 +390,6 @@ use_internal_css_file <- function( #' @export #' @rdname use_files -#' @importFrom fs path_abs file_exists use_internal_html_template <- function( path, name = "template.html", @@ -405,7 +398,7 @@ use_internal_html_template <- function( open = FALSE, dir_create = TRUE ) { - old <- setwd(path_abs(pkg)) + old <- setwd(fs_path_abs(pkg)) on.exit(setwd(old)) check_name_length(name) @@ -425,21 +418,21 @@ use_internal_html_template <- function( return(invisible(FALSE)) } - dir <- path_abs(dir) + dir <- fs_path_abs(dir) - where <- path( + where <- fs_path( dir, new_file ) - if (file_exists(where)) { + if (fs_file_exists(where)) { cat_exists(where) return(invisible(FALSE)) } cat_start_copy() - file.copy(path, where) + fs_file_copy(path, where) cat_copied(where) @@ -455,7 +448,6 @@ use_internal_html_template <- function( #' @export #' @rdname use_files -#' @importFrom fs path_abs file_exists use_internal_file <- function( path, name, @@ -470,7 +462,7 @@ use_internal_file <- function( check_name_length(name) - old <- setwd(path_abs(pkg)) + old <- setwd(fs_path_abs(pkg)) on.exit(setwd(old)) dir_created <- create_if_needed( @@ -483,21 +475,21 @@ use_internal_file <- function( return(invisible(FALSE)) } - dir <- path_abs(dir) + dir <- fs_path_abs(dir) - where <- path( + where <- fs_path( dir, name ) - if (file_exists(where)) { + if (fs_file_exists(where)) { cat_exists(where) return(invisible(FALSE)) } cat_start_copy() - file.copy(path, where) + fs_file_copy(path, where) cat_copied(where) } diff --git a/R/use_recommended.R b/R/use_recommended.R index 3321721e..c72d85a7 100644 --- a/R/use_recommended.R +++ b/R/use_recommended.R @@ -11,7 +11,6 @@ #' @param spellcheck Whether or not to use a spellcheck test. #' #' @importFrom usethis use_testthat use_package -#' @importFrom fs path_abs #' @rdname use_recommended #' #' @export @@ -26,7 +25,7 @@ use_recommended_deps <- function( msg = "use_recommended_deps() is soft deprecated and will be removed in future versions of {golem}." ) - old <- setwd(path_abs(pkg)) + old <- setwd(fs_path_abs(pkg)) on.exit(setwd(old)) for (i in sort(recommended)) { @@ -42,7 +41,6 @@ use_recommended_deps <- function( #' @importFrom usethis use_testthat use_package use_spell_check #' @importFrom utils capture.output #' @importFrom attempt without_warning stop_if -#' @importFrom fs path_abs path file_exists use_recommended_tests <- function( pkg = get_golem_wd(), spellcheck = TRUE, @@ -50,12 +48,17 @@ use_recommended_tests <- function( lang = "en-US", error = FALSE ) { - old <- setwd(path_abs(pkg)) + old <- setwd(fs_path_abs(pkg)) + + rlang::check_installed( + "fs", + reason = "for file & directory manipulation." + ) on.exit(setwd(old)) - if (!dir.exists( - path(path_abs(pkg), "tests") + if (!fs_dir_exists( + fs_path(fs_path_abs(pkg), "tests") )) { without_warning(use_testthat)() } @@ -64,14 +67,14 @@ use_recommended_tests <- function( } stop_if( - path(old, "tests", "testthat", "test-golem-recommended.R"), - file_exists, + fs_path(old, "tests", "testthat", "test-golem-recommended.R"), + fs_file_exists, "test-golem-recommended.R already exists. \nPlease remove it first if you need to reinsert it." ) - file_copy( + fs_file_copy( golem_sys("utils", "test-golem-recommended.R"), - path(old, "tests", "testthat"), + fs_path(old, "tests", "testthat"), overwrite = TRUE ) diff --git a/R/use_utils.R b/R/use_utils.R index 23bcd166..e9de1af3 100644 --- a/R/use_utils.R +++ b/R/use_utils.R @@ -29,10 +29,10 @@ use_utils_ui <- function( cat_green_tick("Utils UI added") if (with_test) { - if (!isTRUE(dir.exists("tests"))) { + if (!isTRUE(fs_dir_exists("tests"))) { use_testthat() } - pth <- path( + pth <- fs_path( pkg, "tests", "testthat", @@ -81,10 +81,10 @@ use_utils_server <- function( cat_green_tick("Utils server added") if (with_test) { - if (!isTRUE(dir.exists("tests"))) { + if (!isTRUE(fs_dir_exists("tests"))) { use_testthat() } - pth <- path( + pth <- fs_path( pkg, "tests", "testthat", @@ -131,23 +131,32 @@ use_utils_test_server <- function(pkg = get_golem_wd()) { use_utils_test_(pkg, "server") } - -#' @importFrom fs file_copy path_abs path_file use_utils <- function( file_name, folder_name, pkg = get_golem_wd() ) { + rlang::check_installed( + "fs", + reason = "for file manipulation." + ) + old <- setwd( - path_abs(pkg) + fs_path_abs(pkg) ) on.exit(setwd(old)) - where <- path(path_abs(pkg), folder_name, file_name) - if (file_exists(where)) { + + where <- fs_path( + fs_path_abs(pkg), + folder_name, + file_name + ) + + if (fs_file_exists(where)) { cat_exists(where) return(FALSE) } else { - file_copy( + fs_file_copy( path = golem_sys("utils", file_name), new_path = where ) diff --git a/R/utils.R b/R/utils.R index ad70b6e3..2246d5ea 100644 --- a/R/utils.R +++ b/R/utils.R @@ -16,22 +16,18 @@ darkgrey <- function(x) { x <- crayon::make_style("darkgrey")(x) } -#' @importFrom fs dir_exists file_exists -dir_not_exist <- Negate(fs::dir_exists) -file_not_exist <- Negate(fs::file_exists) - -#' @importFrom fs dir_create file_create create_if_needed <- function( path, type = c("file", "directory"), content = NULL ) { type <- match.arg(type) + # Check if file or dir already exist if (type == "file") { - dont_exist <- file_not_exist(path) + dont_exist <- Negate(fs_file_exists)(path) } else if (type == "directory") { - dont_exist <- dir_not_exist(path) + dont_exist <- Negate(fs_dir_exists)(path) } # If it doesn't exist, ask if we are allowed # to create it @@ -50,10 +46,10 @@ create_if_needed <- function( } else { # Create the file if (type == "file") { - file_create(path) + fs_file_create(path) write(content, path, append = TRUE) } else if (type == "directory") { - dir_create(path, recurse = TRUE) + fs_dir_create(path, recurse = TRUE) } } } else { @@ -72,10 +68,9 @@ create_if_needed <- function( return(TRUE) } -#' @importFrom fs file_exists check_file_exist <- function(file) { res <- TRUE - if (file_exists(file)) { + if (fs_file_exists(file)) { if (interactive()) { res <- yesno("This file already exists, override?") } else { @@ -85,20 +80,6 @@ check_file_exist <- function(file) { return(res) } -# TODO Remove from codebase -#' @importFrom fs dir_exists -check_dir_exist <- function(dir) { - res <- TRUE - if (!dir_exists(dir)) { - if (interactive()) { - res <- yesno(sprintf("The %s does not exists, create?", dir)) - } else { - res <- FALSE - } - } - return(res) -} - # internal replace_word <- function( file, @@ -161,13 +142,13 @@ cat_exists <- function(where) { cat_red_bullet( sprintf( "[Skipped] %s already exists.", - path_file(where) + basename(where) ) ) cat_info( sprintf( "If you want replace it, remove the %s file first.", - path_file(where) + basename(where) ) ) } @@ -257,7 +238,7 @@ open_or_go_to <- function( } desc_exist <- function(pkg) { - file_exists( + fs_file_exists( paste0(pkg, "/DESCRIPTION") ) } @@ -271,7 +252,7 @@ after_creation_message_js <- function( desc_exist(pkg) ) { if ( - fs::path_abs(dir) != fs::path_abs("inst/app/www") & + fs_path_abs(dir) != fs_path_abs("inst/app/www") & utils::packageVersion("golem") < "0.2.0" ) { cat_red_bullet( @@ -293,7 +274,7 @@ after_creation_message_css <- function( if ( desc_exist(pkg) ) { - if (fs::path_abs(dir) != fs::path_abs("inst/app/www") & + if (fs_path_abs(dir) != fs_path_abs("inst/app/www") & utils::packageVersion("golem") < "0.2.0" ) { cat_red_bullet( @@ -316,7 +297,7 @@ after_creation_message_sass <- function( if ( desc_exist(pkg) ) { - if (fs::path_abs(dir) != fs::path_abs("inst/app/www") & + if (fs_path_abs(dir) != fs_path_abs("inst/app/www") & utils::packageVersion("golem") < "0.2.0" ) { cat_red_bullet( @@ -405,10 +386,9 @@ yesno <- function(...) { menu(c("Yes", "No")) == 1 } -#' @importFrom fs file_exists add_sass_code <- function(where, dir, name) { - if (file_exists(where)) { - if (file_exists("dev/run_dev.R")) { + if (fs_file_exists(where)) { + if (fs_file_exists("dev/run_dev.R")) { lines <- readLines("dev/run_dev.R") new_lines <- append( x = lines, @@ -453,3 +433,17 @@ is_existing_module <- function(module) { ) module %in% existing_module_names } + +# This function is used for checking +# that the name argument of the function +# creating files is not of length() > 1 +check_name_length <- function(name) { + stop_if( + name, + ~ length(.x) > 1, + sprintf( + "`name` should be of length 1. Got %d.", + length(name) + ) + ) +} diff --git a/inst/mantests/build.R b/inst/mantests/build.R index e90cca0e..1f7cde70 100644 --- a/inst/mantests/build.R +++ b/inst/mantests/build.R @@ -76,22 +76,13 @@ golem::install_dev_deps( withr::with_tempdir({ cli::cat_rule("Install crystalmountains") - # tmp_cm <- tempfile(fileext = ".zip") - - # download.file( - # "https://github.com/ThinkR-open/crystalmountains/archive/refs/heads/main.zip", - # "main.zip" - # ) - - # unzip(tmp_cm) - remotes::install_github( "thinkr-open/crystalmountains", lib.loc = temp_lib, update = "never" ) - # unlink("crystalmountains-main", TRUE, TRUE) + here::set_here(getwd()) # Going to the temp dir and create a new golem cli::cat_rule("Creating a golem based app") library(golem) diff --git a/man/get_current_config.Rd b/man/get_current_config.Rd index e2ed0da8..b795d92b 100644 --- a/man/get_current_config.Rd +++ b/man/get_current_config.Rd @@ -4,7 +4,7 @@ \alias{get_current_config} \title{Get the path to the current config File} \usage{ -get_current_config(path = ".") +get_current_config(path = getwd()) } \arguments{ \item{path}{Path to start looking for the config} diff --git a/man/pkg_tools.Rd b/man/pkg_tools.Rd index 6103d946..a2c40e54 100644 --- a/man/pkg_tools.Rd +++ b/man/pkg_tools.Rd @@ -10,7 +10,7 @@ pkg_name(path = ".") pkg_version(path = ".") -pkg_path(path = ".") +pkg_path() } \arguments{ \item{path}{Path to use to read the DESCRIPTION} diff --git a/vignettes/c_deploy.Rmd b/vignettes/c_deploy.Rmd index 5ff5b4c7..b8d60c07 100644 --- a/vignettes/c_deploy.Rmd +++ b/vignettes/c_deploy.Rmd @@ -18,7 +18,7 @@ $(document).ready(function () { ```{r setup, include = FALSE} knitr::opts_chunk$set( collapse = TRUE, - comment = "#>", + comment = "#>", eval = FALSE ) ``` @@ -28,18 +28,15 @@ knitr::opts_chunk$set( When launching the app, you might have noticed that the `dev/run_dev.R` function calls `run_app()`, which has the following structure: ```{r} -run_app <- function( - ... -) { +run_app <- function(...) { with_golem_options( app = shinyApp( - ui = app_ui, + ui = app_ui, server = app_server - ), + ), golem_opts = list(...) ) } - ``` This function might looks a little bit weird, but there's a long story behind it, and you can read more about it [there](https://rtask.thinkr.fr/shinyapp-runapp-shinyappdir-difference/). @@ -48,7 +45,7 @@ But long story short, this combination of `with_golem_options` & `golem_opts = l ```{r} run_app(this = "that") -# And in the app +# And in the app this <- get_golem_options("this") ``` @@ -92,7 +89,7 @@ golem::add_dockerfile_heroku() > this functions will create a "deploy" folder containing : -```{txt} +``` deploy/ +-- Dockerfile +-- Dockerfile_base @@ -110,15 +107,25 @@ golem::add_dockerfile_with_renv(output_dir = "deploy") # If you want to deploy to ShinyProxy golem::add_dockerfile_with_renv_shinyproxy(output_dir = "deploy") - ``` If you would like to use {renv} during developpement, you can init a renv.lock file with ```{r} -attachment::create_renv_for_dev(dev_pkg = c("renv", "devtools", "roxygen2", - "usethis", "pkgload", "testthat", "remotes", "covr", "attachment", - "pak", "dockerfiler","golem")) +attachment::create_renv_for_dev(dev_pkg = c( + "renv", + "devtools", + "roxygen2", + "usethis", + "pkgload", + "testthat", + "remotes", + "covr", + "attachment", + "pak", + "dockerfiler", + "golem" +)) ``` an activate {renv} with @@ -136,17 +143,15 @@ renv::activate() ```{r} # If you want to deploy via a generic Dockerfile -golem::add_dockerfile_with_renv(output_dir = "deploy",lockfile = "renv.lock") +golem::add_dockerfile_with_renv(output_dir = "deploy", lockfile = "renv.lock") # If you want to deploy to ShinyProxy -golem::add_dockerfile_with_renv_shinyproxy(output_dir = "deploy",lockfile = "renv.lock") - - +golem::add_dockerfile_with_renv_shinyproxy(output_dir = "deploy", lockfile = "renv.lock") ``` > this functions will create a "deploy" folder containing : -```{txt} +``` deploy/ +-- Dockerfile +-- Dockerfile_base diff --git a/vignettes/e_config.Rmd b/vignettes/e_config.Rmd index 5b583ea4..4ad83d4d 100644 --- a/vignettes/e_config.Rmd +++ b/vignettes/e_config.Rmd @@ -19,7 +19,8 @@ x <- file.path( ) unlink(x, TRUE, TRUE) -create_golem(x, package_name = "golex", open = FALSE) +x <- golem::create_golem(x, package_name = "golex", open = FALSE) +old <- setwd(x) knitr::opts_knit$set(root.dir = x) ``` @@ -43,13 +44,17 @@ This config file is based on the [`{config}`](https://github.com/rstudio/config) Here is what the default config file looks like: -```{r echo = FALSE, comment= "", } -cat( - sep = "\n", - readLines( - "inst/golem-config.yml" - ) -) +``` +default: + golem_name: golex + golem_version: 0.0.0.9000 + app_prod: no + +production: + app_prod: yes + +dev: + golem_wd: !expr golem::pkg_path() ``` + default/golem_name, default/golem_version, default/app_prod are usable across the whole life of your golem app: while developing, and also when in production.