···66#' @param fields Named list of `DESCRIPTION` fields passed to
77#' [usethis::create_package()]. See [usethis::use_description()]
88#' @param private Whether to create the GitHub repository as private. Defaults to `TRUE`.
99+#' @param setup_gha Whether to configure GitHub Actions setup.
1010+#' @param setup_dependabot Whether to write a Dependabot configuration.
1111+#' @param setup_air_jarl Whether to configure Air and Jarl defaults.
912#' @param ... Additional arguments passed to [usethis::create_package()].
1013#'
1114#' @return Invisibly returns `NULL`.
···1417 path = ".",
1518 fields,
1619 private = TRUE,
2020+ setup_gha = TRUE,
2121+ setup_dependabot = TRUE,
2222+ setup_air_jarl = TRUE,
1723 ...
1824) {
1925 create_package(path, fields, private, ...)
2020- pkg_setup()
2626+ pkg_setup(
2727+ setup_gha = setup_gha,
2828+ setup_dependabot = setup_dependabot,
2929+ setup_air_jarl = setup_air_jarl
3030+ )
2131 invisible(NULL)
2232}
2333···7383#'
7484#' Run the package setup steps used by `bootstrapper`, including test
7585#' infrastructure, README/NEWS creation, GitHub Actions, and linting defaults.
8686+#' Run this in the root directory of your package.
8787+#'
8888+#' @param setup_gha Whether to configure GitHub Actions setup.
8989+#' @param setup_dependabot Whether to write a Dependabot configuration.
9090+#' @param setup_air_jarl Whether to configure Air and Jarl defaults.
7691#'
7792#' @return Invisibly returns `NULL`.
7893#' @export
7979-pkg_setup <- function() {
9494+pkg_setup <- function(
9595+ setup_gha = TRUE,
9696+ setup_dependabot = TRUE,
9797+ setup_air_jarl = TRUE
9898+) {
8099 tryCatch(
81100 usethis::use_testthat(),
82101 error = function(...) {
83102 usethis::ui_stop(
8484- "This doesn't appear to be a package. Ensure you are in the right directory, or run {usethis::ui_code('create_package()')}."
103103+ "This doesn't appear to be a package. Ensure you are in the right directory, or run {usethis::ui_code('create_package()')} in this directory to start a R package."
85104 )
86105 }
87106 )
···94113 fs::path("NEWS.md")
95114 )
961159797- # GitHub Actions setup
116116+ if (setup_gha) {
117117+ configure_gha()
118118+ }
119119+ if (setup_dependabot) {
120120+ configure_dependabot()
121121+ }
122122+ if (setup_air_jarl) {
123123+ configure_air_jarl()
124124+ }
125125+126126+ usethis::use_tidy_description()
127127+ invisible(NULL)
128128+}
129129+130130+# Helpers ---------------------------------------------------------------------
131131+132132+#' Configure GitHub Actions Defaults
133133+#'
134134+#' Sets up standard GitHub Actions used by this package template and updates
135135+#' workflow references.
136136+#'
137137+#' @return Invisibly returns `NULL`.
138138+#' @keywords internal
139139+#' @noRd
140140+configure_gha <- function() {
98141 usethis::use_github_action("check-standard", badge = TRUE)
99142 usethis::use_github_action("test-coverage", badge = TRUE)
100143 usethis::use_github_action(
···103146 usethis::use_pkgdown_github_pages()
104147 usethis::use_spell_check(error = TRUE)
105148106106- # Dependabot
149149+ find_replace_in_gha("actions/checkout@v4", "actions/checkout@v6")
150150+ find_replace_in_gha(
151151+ "JamesIves/github-pages-deploy-action@v4.5.0",
152152+ "JamesIves/github-pages-deploy-action@v4"
153153+ )
154154+ invisible(NULL)
155155+}
156156+157157+#' Configure Dependabot Defaults
158158+#'
159159+#' Writes a default Dependabot configuration for GitHub Actions.
160160+#'
161161+#' @return Invisibly returns `NULL`.
162162+#' @keywords internal
163163+#' @noRd
164164+configure_dependabot <- function() {
107165 c(
108166 "version: 2",
109167 "updates:",
···113171 " interval: \"weekly\""
114172 ) |> # TODO: move file to inst?
115173 write_to_path(fs::path(".github", "dependabot.yml"))
174174+ invisible(NULL)
175175+}
116176117117- # Air and Jarl configs
177177+#' Configure Air and Jarl Defaults
178178+#'
179179+#' Sets up Air, VS Code extension recommendations, and Jarl lint defaults.
180180+#'
181181+#' @return Invisibly returns `NULL`.
182182+#' @keywords internal
183183+#' @noRd
184184+configure_air_jarl <- function() {
118185 usethis::use_air()
119186 c(
120187 "{",
···130197 "extend-select = [\"TESTTHAT\"]"
131198 ) |>
132199 write_to_path(fs::path("tests", "jarl.toml")) # TODO: need to make GHA jarl runs respect this
133133-134134- # Cleanup
135135- find_replace_in_gha("actions/checkout@v4", "actions/checkout@v6")
136136- find_replace_in_gha(
137137- "JamesIves/github-pages-deploy-action@v4.5.0",
138138- "JamesIves/github-pages-deploy-action@v4"
139139- )
140140- usethis::use_tidy_description()
141200 invisible(NULL)
142201}
143143-144144-# Helpers ---------------------------------------------------------------------
145202146203#' Choose and Apply a License
147204#'
···166223 "Skip for now" = FALSE
167224 )
168225 usethis::ui_info("Select a license for this package.")
169169- selected_fn <- if (interactive()) {
226226+ selected_fn <- if (is_interactive()) {
170227 unname(
171228 license_choices[[utils::menu(
172229 choices = names(license_choices),
+11
R/utils.R
···7979 pattern = "\\.ya?ml$"
8080 )
8181}
8282+8383+#' Determine Interactive Mode
8484+#'
8585+#' Wrapper around [base::interactive()] to make interactive branches testable.
8686+#'
8787+#' @return A single logical value.
8888+#' @keywords internal
8989+#' @noRd
9090+is_interactive <- function() {
9191+ interactive()
9292+}
+15-1
man/bootstrapper.Rd
···44\alias{bootstrapper}
55\title{Bootstrap a New R Package}
66\usage{
77-bootstrapper(path = ".", fields, private = TRUE, ...)
77+bootstrapper(
88+ path = ".",
99+ fields,
1010+ private = TRUE,
1111+ setup_gha = TRUE,
1212+ setup_dependabot = TRUE,
1313+ setup_air_jarl = TRUE,
1414+ ...
1515+)
816}
917\arguments{
1018\item{path}{Path where the package should be created. Defaults to \code{"."}}
···1321\code{\link[usethis:create_package]{usethis::create_package()}}. See \code{\link[usethis:use_description]{usethis::use_description()}}}
14221523\item{private}{Whether to create the GitHub repository as private. Defaults to \code{TRUE}.}
2424+2525+\item{setup_gha}{Whether to configure GitHub Actions setup.}
2626+2727+\item{setup_dependabot}{Whether to write a Dependabot configuration.}
2828+2929+\item{setup_air_jarl}{Whether to configure Air and Jarl defaults.}
16301731\item{...}{Additional arguments passed to \code{\link[usethis:create_package]{usethis::create_package()}}.}
1832}
+9-1
man/pkg_setup.Rd
···44\alias{pkg_setup}
55\title{Apply Opinionated Package Setup}
66\usage{
77-pkg_setup()
77+pkg_setup(setup_gha = TRUE, setup_dependabot = TRUE, setup_air_jarl = TRUE)
88+}
99+\arguments{
1010+\item{setup_gha}{Whether to configure GitHub Actions setup.}
1111+1212+\item{setup_dependabot}{Whether to write a Dependabot configuration.}
1313+1414+\item{setup_air_jarl}{Whether to configure Air and Jarl defaults.}
815}
916\value{
1017Invisibly returns \code{NULL}.
···1219\description{
1320Run the package setup steps used by \code{bootstrapper}, including test
1421infrastructure, README/NEWS creation, GitHub Actions, and linting defaults.
2222+Run this in the root directory of your package.
1523}