Closed Ty-WDFW closed 2 days ago
I like it! How would you feel about including at optional pull of .qmd template and associated style.css from snippets? I usually end up needing to track down those two snippets and add them when I'm working on proejcts. The following two lines would do that, saving the files into the scripts
folder.
usethis::use_github_file("https://github.com/FRAMverse/snippets/blob/main/R/markdown-and-quarto/custom-yaml-header.Rmd", save_as = "scripts/quarto-template-header.qmd") usethis::use_github_file("https://github.com/FRAMverse/snippets/blob/main/R/markdown-and-quarto/style.css", save_as = "scripts/styl.css")
We'd need to add usethis
as a dependency, and it would arguably make the function a little more fragile or add complexity I think we'd want something to handle the case when users define custom folder name vector that doesn't include scripts
-- probably an if statement checking the existence of scripts
folder before downloading. I'm going to see if I can mock that up.
#'
r lifecycle::badge("experimental")`
snippets
repoinitialize_project <- function(folders = c('scripts', 'original_data', 'cleaned_data', 'figures', 'results'), templates = FALSE, renv = FALSE){
purrr::walk( folders, (folder) dir.create(here::here(glue::glue("{folder}"))) ) cli::cli_alert_success('Successfully initialized FRAM project')
if (renv){ cli::cli_alert_info( "Initializing {.pkg renv}, don't forget to run {.fn renv::snapshot} before saving project" ) invisible(readline('Press [Enter] to conitue...')) renv::init() }
if (templates){
cli::cli_alert_info(
"Copying quarto templates from the snippets
repo..."
)
file.exists("scripts/"){
prefix = "scripts/"
} else {
prefix = ""
}
usethis::use_github_file("https://github.com/FRAMverse/snippets/blob/main/R/markdown-and-quarto/custom-yaml-header.Rmd",
save_as = paste0(prefix, "quarto-template-header.qmd"))
usethis::use_github_file("https://github.com/FRAMverse/snippets/blob/main/R/markdown-and-quarto/style.css",
save_as = paste0(prefix, "style.css"))
}
}`
@cbedwards-dfw, thoughts?