[mirror] Opinionated R package quickstart
0
fork

Configure Feed

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

Removed air/jarl separate config

VisruthSK 6dcf0359 84a0d5c4

+59 -90
+19 -35
R/bootstrapper.R
··· 8 8 #' @param private Whether to create the GitHub repository as private. Defaults to `TRUE`. 9 9 #' @param setup_gha Whether to configure GitHub Actions setup. 10 10 #' @param setup_dependabot Whether to write a Dependabot configuration. 11 - #' @param setup_air_jarl Whether to configure Air and Jarl defaults. 12 11 #' @param ... Additional arguments passed to [usethis::create_package()]. 13 12 #' 14 13 #' @return Invisibly returns `NULL`. ··· 19 18 private = TRUE, 20 19 setup_gha = TRUE, 21 20 setup_dependabot = TRUE, 22 - setup_air_jarl = TRUE, 23 21 ... 24 22 ) { 25 23 create_package(path, fields, private, ...) 26 24 pkg_setup( 27 25 setup_gha = setup_gha, 28 - setup_dependabot = setup_dependabot, 29 - setup_air_jarl = setup_air_jarl 26 + setup_dependabot = setup_dependabot 30 27 ) 31 28 invisible(NULL) 32 29 } ··· 87 84 #' 88 85 #' @param setup_gha Whether to configure GitHub Actions setup. 89 86 #' @param setup_dependabot Whether to write a Dependabot configuration. 90 - #' @param setup_air_jarl Whether to configure Air and Jarl defaults. 91 87 #' 92 88 #' @return Invisibly returns `NULL`. 93 89 #' @export 94 90 pkg_setup <- function( 95 91 setup_gha = TRUE, 96 - setup_dependabot = TRUE, 97 - setup_air_jarl = TRUE 92 + setup_dependabot = TRUE 98 93 ) { 99 94 tryCatch( 100 95 usethis::use_testthat(), ··· 118 113 } 119 114 if (setup_dependabot) { 120 115 configure_dependabot() 121 - } 122 - if (setup_air_jarl) { 123 - configure_air_jarl() 124 116 } 125 117 126 118 usethis::use_tidy_description() ··· 151 143 "JamesIves/github-pages-deploy-action@v4.5.0", 152 144 "JamesIves/github-pages-deploy-action@v4" 153 145 ) 146 + 147 + usethis::use_air() 148 + c( 149 + "{", 150 + ' "recommendations": [', 151 + ' "Posit.air-vscode",', 152 + ' "etiennebacher.jarl-vscode"', 153 + " ]", 154 + "}" 155 + ) |> 156 + write_to_path(fs::path(".vscode", "extensions.json")) 157 + c( 158 + "[lint]", 159 + "extend-select = [\"TESTTHAT\"]" 160 + ) |> 161 + write_to_path(fs::path("tests", "jarl.toml")) # TODO: need to make GHA jarl runs respect this 162 + 154 163 invisible(NULL) 155 164 } 156 165 ··· 174 183 invisible(NULL) 175 184 } 176 185 177 - #' Configure Air and Jarl Defaults 178 - #' 179 - #' Sets up Air, VS Code extension recommendations, and Jarl lint defaults. 180 - #' 181 - #' @return Invisibly returns `NULL`. 182 - #' @keywords internal 183 - #' @noRd 184 - configure_air_jarl <- function() { 185 - usethis::use_air() 186 - c( 187 - "{", 188 - ' "recommendations": [', 189 - ' "Posit.air-vscode",', 190 - ' "etiennebacher.jarl-vscode"', 191 - " ]", 192 - "}" 193 - ) |> 194 - write_to_path(fs::path(".vscode", "extensions.json")) 195 - c( 196 - "[lint]", 197 - "extend-select = [\"TESTTHAT\"]" 198 - ) |> 199 - write_to_path(fs::path("tests", "jarl.toml")) # TODO: need to make GHA jarl runs respect this 200 - invisible(NULL) 201 - } 202 186 203 187 #' Choose and Apply a License 204 188 #'
-3
man/bootstrapper.Rd
··· 10 10 private = TRUE, 11 11 setup_gha = TRUE, 12 12 setup_dependabot = TRUE, 13 - setup_air_jarl = TRUE, 14 13 ... 15 14 ) 16 15 } ··· 25 24 \item{setup_gha}{Whether to configure GitHub Actions setup.} 26 25 27 26 \item{setup_dependabot}{Whether to write a Dependabot configuration.} 28 - 29 - \item{setup_air_jarl}{Whether to configure Air and Jarl defaults.} 30 27 31 28 \item{...}{Additional arguments passed to \code{\link[usethis:create_package]{usethis::create_package()}}.} 32 29 }
+1 -3
man/pkg_setup.Rd
··· 4 4 \alias{pkg_setup} 5 5 \title{Apply Opinionated Package Setup} 6 6 \usage{ 7 - pkg_setup(setup_gha = TRUE, setup_dependabot = TRUE, setup_air_jarl = TRUE) 7 + pkg_setup(setup_gha = TRUE, setup_dependabot = TRUE) 8 8 } 9 9 \arguments{ 10 10 \item{setup_gha}{Whether to configure GitHub Actions setup.} 11 11 12 12 \item{setup_dependabot}{Whether to write a Dependabot configuration.} 13 - 14 - \item{setup_air_jarl}{Whether to configure Air and Jarl defaults.} 15 13 } 16 14 \value{ 17 15 Invisibly returns \code{NULL}.
+7 -3
tests/spelling.R
··· 1 - if(requireNamespace('spelling', quietly = TRUE)) 2 - spelling::spell_check_test(vignettes = TRUE, error = TRUE, 3 - skip_on_cran = TRUE) 1 + if (requireNamespace('spelling', quietly = TRUE)) { 2 + spelling::spell_check_test( 3 + vignettes = TRUE, 4 + error = TRUE, 5 + skip_on_cran = TRUE 6 + ) 7 + }
+32 -46
tests/testthat/test-bootstrapper.R
··· 10 10 expect_identical(list(...), list(open = FALSE)) 11 11 NULL 12 12 }, 13 - pkg_setup = function(setup_gha, setup_dependabot, setup_air_jarl) { 13 + pkg_setup = function(setup_gha, setup_dependabot) { 14 14 calls <<- c(calls, "pkg_setup") 15 15 expect_false(setup_gha) 16 16 expect_false(setup_dependabot) 17 - expect_true(setup_air_jarl) 18 17 NULL 19 18 }, 20 19 .package = "bootstrapper" ··· 27 26 private = FALSE, 28 27 setup_gha = FALSE, 29 28 setup_dependabot = FALSE, 30 - setup_air_jarl = TRUE, 31 29 open = FALSE 32 30 ) 33 31 ) ··· 115 113 calls$sections <<- c(calls$sections, "dependabot") 116 114 NULL 117 115 }, 118 - configure_air_jarl = function() { 119 - calls$sections <<- c(calls$sections, "air_jarl") 120 - NULL 121 - }, 122 116 find_replace_in_file = function(from, to, file, fixed = TRUE) { 123 117 calls$replaced <<- TRUE 124 118 expect_identical(from, "(development version)") ··· 136 130 expect_true("readme:FALSE" %in% calls$actions) 137 131 expect_true("news:FALSE" %in% calls$actions) 138 132 expect_true("tidy_description" %in% calls$actions) 139 - expect_identical(calls$sections, c("gha", "dependabot", "air_jarl")) 133 + expect_identical(calls$sections, c("gha", "dependabot")) 140 134 expect_true(calls$replaced) 141 135 }) 142 136 ··· 160 154 called <<- TRUE 161 155 NULL 162 156 }, 163 - configure_air_jarl = function() { 164 - called <<- TRUE 165 - NULL 166 - }, 167 157 find_replace_in_file = function(from, to, file, fixed = TRUE) NULL, 168 158 .package = "bootstrapper" 169 159 ) ··· 171 161 expect_null( 172 162 bootstrapper::pkg_setup( 173 163 setup_gha = FALSE, 174 - setup_dependabot = FALSE, 175 - setup_air_jarl = FALSE 164 + setup_dependabot = FALSE 176 165 ) 177 166 ) 178 167 expect_false(called) 179 168 }) 180 169 181 - test_that("configure_gha runs expected usethis and replacement calls", { 170 + test_that("configure_gha runs expected usethis, replacement, and air/jarl calls", { 182 171 configure_gha <- getFromNamespace("configure_gha", "bootstrapper") 183 - actions <- list(github_actions = list(), replacements = character(), spell = FALSE) 172 + actions <- list( 173 + github_actions = list(), 174 + replacements = character(), 175 + spell = FALSE, 176 + air = FALSE, 177 + writes = character() 178 + ) 184 179 185 180 testthat::local_mocked_bindings( 186 181 use_github_action = function(...) { ··· 192 187 actions$spell <<- error 193 188 NULL 194 189 }, 190 + use_air = function() { 191 + actions$air <<- TRUE 192 + NULL 193 + }, 195 194 .package = "usethis" 196 195 ) 197 196 198 197 testthat::local_mocked_bindings( 199 198 find_replace_in_gha = function(from, to) { 200 - actions$replacements <<- c(actions$replacements, paste(from, to, sep = " -> ")) 199 + actions$replacements <<- c( 200 + actions$replacements, 201 + paste(from, to, sep = " -> ") 202 + ) 203 + NULL 204 + }, 205 + write_to_path = function(text, filepath) { 206 + actions$writes <<- c(actions$writes, filepath) 201 207 NULL 202 208 }, 203 209 .package = "bootstrapper" ··· 220 226 "JamesIves/github-pages-deploy-action@v4.5.0 -> JamesIves/github-pages-deploy-action@v4" 221 227 ) 222 228 ) 229 + expect_true(actions$air) 230 + expect_setequal( 231 + basename(actions$writes), 232 + c("extensions.json", "jarl.toml") 233 + ) 223 234 }) 224 235 225 236 test_that("configure_dependabot writes dependabot config", { 226 - configure_dependabot <- getFromNamespace("configure_dependabot", "bootstrapper") 237 + configure_dependabot <- getFromNamespace( 238 + "configure_dependabot", 239 + "bootstrapper" 240 + ) 227 241 captured <- list(path = NULL, text = NULL) 228 242 229 243 testthat::local_mocked_bindings( ··· 238 252 expect_null(configure_dependabot()) 239 253 expect_identical(captured$path, fs::path(".github", "dependabot.yml")) 240 254 expect_true(any(grepl("^version: 2$", captured$text))) 241 - }) 242 - 243 - test_that("configure_air_jarl writes expected files", { 244 - configure_air_jarl <- getFromNamespace("configure_air_jarl", "bootstrapper") 245 - calls <- list(air = FALSE, writes = character()) 246 - 247 - testthat::local_mocked_bindings( 248 - use_air = function() { 249 - calls$air <<- TRUE 250 - NULL 251 - }, 252 - .package = "usethis" 253 - ) 254 - 255 - testthat::local_mocked_bindings( 256 - write_to_path = function(text, filepath) { 257 - calls$writes <<- c(calls$writes, filepath) 258 - NULL 259 - }, 260 - .package = "bootstrapper" 261 - ) 262 - 263 - expect_null(configure_air_jarl()) 264 - expect_true(calls$air) 265 - expect_setequal( 266 - basename(calls$writes), 267 - c("extensions.json", "jarl.toml") 268 - ) 269 255 }) 270 256 271 257 test_that("pkg_setup rethrows a generic message when test setup fails", {