[mirror] Opinionated R package quickstart
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

Rearranging

VisruthSK 26d5f9e9 34e3708f

+54 -46
+54 -46
R/bootstrapper.R
··· 1 - bootrapper <- function( 1 + bootstrapper <- function( 2 2 path = ".", 3 - author = person( 4 - "Visruth", 5 - "Srimath Kandali", 6 - , 7 - "public@visruth.com", 8 - role = c("aut", "cre", "cph"), 9 - comment = c(ORCID = "0009-0005-9097-0688") 10 - ), 11 - private = TRUE 3 + fields, 4 + private = TRUE, 5 + ... 12 6 ) { 13 - create_package(path, author, private) 7 + create_package(path, fields, private, ...) 14 8 pkg_setup() 15 9 invisible(NULL) 16 10 } 17 11 12 + create_package <- function( 13 + path = ".", 14 + fields = getOption( 15 + "usethis.description", 16 + list( 17 + "Authors@R" = person( 18 + "Visruth", 19 + "Srimath Kandali", 20 + , 21 + "public@visruth.com", 22 + role = c("aut", "cre", "cph"), 23 + comment = c(ORCID = "0009-0005-9097-0688") 24 + ) 25 + ) 26 + ), 27 + private = TRUE, 28 + ... 29 + ) { 30 + usethis::create_package(path = path, fields = fields, ...) 31 + unlink("*.Rproj") 32 + find_replace_in_file( 33 + "^\\^.*\\\\\\.Rproj\\$$", 34 + "", 35 + ".Rbuildignore", 36 + fixed = FALSE 37 + ) 38 + find_replace_in_file( 39 + "^\\^\\\\\\.Rproj\\\\\\.user\\$$", 40 + "", 41 + ".Rbuildignore", 42 + fixed = FALSE 43 + ) 44 + readLines(".Rbuildignore", warn = FALSE) |> 45 + Filter(nzchar, x = _) |> 46 + writeLines(".Rbuildignore") 47 + use_license(author) 48 + usethis::use_github(private = private) 49 + invisible(NULL) 50 + } 51 + 18 52 pkg_setup <- function() { 19 - # TODO: check if this is R package 53 + tryCatch( 54 + usethis::use_testthat(), 55 + error = function(...) { 56 + usethis::ui_stop( 57 + "This doesn't appear to be a package. Ensure you are in the right directory, or run {usethis::ui_code('create_package()')}." 58 + ) 59 + } 60 + ) 20 61 usethis::use_readme_md(open = FALSE) 21 - usethis::use_testthat() 22 62 usethis::use_news_md(open = FALSE) 23 63 24 64 # GitHub Actions setup ··· 68 108 invisible(NULL) 69 109 } 70 110 71 - create_package <- function( 72 - path = ".", 73 - author = person( 74 - "Visruth", 75 - "Srimath Kandali", 76 - , 77 - "public@visruth.com", 78 - role = c("aut", "cre", "cph"), 79 - comment = c(ORCID = "0009-0005-9097-0688") 80 - ), 81 - private = TRUE 82 - ) { 83 - usethis::create_package(path = path, fields = list("Authors@R" = author)) 84 - unlink("*.Rproj") 85 - find_replace_in_file( 86 - "^\\^.*\\\\\\.Rproj\\$$", 87 - "", 88 - ".Rbuildignore", 89 - fixed = FALSE 90 - ) 91 - find_replace_in_file( 92 - "^\\^\\\\\\.Rproj\\\\\\.user\\$$", 93 - "", 94 - ".Rbuildignore", 95 - fixed = FALSE 96 - ) 97 - readLines(".Rbuildignore", warn = FALSE) |> 98 - Filter(nzchar, x = _) |> 99 - writeLines(".Rbuildignore") 100 - use_license(author) 101 - usethis::use_github(private = private) 102 - invisible(NULL) 103 - } 111 + # Helpers --------------------------------------------------------------------- 104 112 105 113 use_license <- function(author) { 106 114 license_choices <- c(