Skip to content

Commit

Permalink
feat: add new arguments to new_*() functions - fix #48
Browse files Browse the repository at this point in the history
  • Loading branch information
ahasverus committed Oct 24, 2023
1 parent 3797f27 commit 21aa416
Show file tree
Hide file tree
Showing 4 changed files with 177 additions and 18 deletions.
81 changes: 72 additions & 9 deletions R/new_compendium.R
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,14 @@
#'
#' This stage can be added/changed later by using [add_lifecycle_badge()].
#'
#' @param contributing A logical value. If `TRUE` (default) adds a
#' `CONTRIBUTING.md` file and `ISSUE_TEMPLATES`. See [add_contributing()] for
#' further information.
#'
#' @param code_of_conduct A logical value. If `TRUE` (default) adds a
#' `CODE_OF_CONDUCT.md` file. See [add_code_of_conduct()] for further
#' information.
#'
#' @param vignette A logical value. If `TRUE` creates a vignette in
#' `vignettes/`. Packages [`knitr`](https://yihui.org/knitr/) and
#' [`rmarkdown`](https://rmarkdown.rstudio.com/) are also added to the
Expand Down Expand Up @@ -110,6 +118,12 @@
#'
#' If `create_repo = FALSE` this argument is ignored. Default is `FALSE`.
#'
#' @param gh_citation A logical value. If `TRUE` configures GitHub
#' Actions to automatically update the `CITATION.cff` file.
#' See [add_github_actions_citation()] for further information.
#'
#' If `create_repo = FALSE` this argument is ignored. Default is `FALSE`.
#'
#' @param codecov A logical value. If `TRUE` configures GitHub Actions to
#' automatically report the code coverage of units tests after each push.
#' See [add_github_actions_codecov()] for further information.
Expand Down Expand Up @@ -187,12 +201,14 @@
#' }

new_compendium <- function(compendium = NULL, license = "GPL (>= 2)",
status = NULL, lifecycle = NULL, vignette = FALSE,
status = NULL, lifecycle = NULL, contributing = TRUE,
code_of_conduct = TRUE, vignette = FALSE,
test = FALSE, create_repo = TRUE, private = FALSE,
gh_check = FALSE, codecov = FALSE, website = FALSE,
gh_render = FALSE, given = NULL, family = NULL,
email = NULL, orcid = NULL, organisation = NULL,
renv = FALSE, dockerfile = FALSE, overwrite = FALSE,
gh_render = FALSE, gh_citation = FALSE, given = NULL,
family = NULL, email = NULL, orcid = NULL,
organisation = NULL, renv = FALSE,
dockerfile = FALSE, overwrite = FALSE,
quiet = FALSE) {

## If not RStudio ----
Expand Down Expand Up @@ -302,10 +318,11 @@ new_compendium <- function(compendium = NULL, license = "GPL (>= 2)",

} else {

gh_check <- FALSE
codecov <- FALSE
website <- FALSE
gh_render <- FALSE
gh_check <- FALSE
codecov <- FALSE
website <- FALSE
gh_render <- FALSE
gh_citation <- FALSE
}


Expand Down Expand Up @@ -521,6 +538,36 @@ new_compendium <- function(compendium = NULL, license = "GPL (>= 2)",



##
## ADDING CONTRIBUTING ----
##


if (contributing) {

ui_title("Adding Contributing")

add_contributing(email = email, organisation = organisation, open = FALSE,
overwrite = overwrite, quiet = quiet)
}



##
## ADDING CODE OF CONDUCT ----
##


if (code_of_conduct) {

ui_title("Adding Code of conduct")

add_code_of_conduct(email = email, open = FALSE, overwrite = overwrite,
quiet = quiet)
}



##
## ADDING README ----
##
Expand Down Expand Up @@ -668,13 +715,29 @@ new_compendium <- function(compendium = NULL, license = "GPL (>= 2)",



##
## GHA CITATION ----
##



if (gh_citation) {

ui_title("Configuring GH Actions - CITATION.cff")

add_github_actions_citation(quiet = quiet)
add_to_buildignore(".github", quiet = quiet)
}



##
## SECOND COMMIT ----
##



if (gh_check || codecov || website || gh_render) {
if (gh_check || codecov || website || gh_render || gh_citation) {

ui_title("Committing changes")

Expand Down
80 changes: 71 additions & 9 deletions R/new_package.R
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,14 @@
#'
#' This stage can be added/changed later by using [add_lifecycle_badge()].
#'
#' @param contributing A logical value. If `TRUE` (default) adds a
#' `CONTRIBUTING.md` file and `ISSUE_TEMPLATES`. See [add_contributing()] for
#' further information.
#'
#' @param code_of_conduct A logical value. If `TRUE` (default) adds a
#' `CODE_OF_CONDUCT.md` file. See [add_code_of_conduct()] for further
#' information.
#'
#' @param vignette A logical value. If `TRUE` (default) creates a vignette in
#' `vignettes/`. Packages [`knitr`](https://yihui.org/knitr/) and
#' [`rmarkdown`](https://rmarkdown.rstudio.com/) are also added to the
Expand Down Expand Up @@ -95,6 +103,12 @@
#' See [add_github_actions_render()] for further information.
#'
#' If `create_repo = FALSE` this argument is ignored.
#'
#' @param gh_citation A logical value. If `TRUE` (default) configures GitHub
#' Actions to automatically update the `CITATION.cff` file.
#' See [add_github_actions_citation()] for further information.
#'
#' If `create_repo = FALSE` this argument is ignored.
#'
#' @param codecov A logical value. If `TRUE` (default) configures GitHub
#' Actions to automatically report the code coverage of units tests after
Expand Down Expand Up @@ -281,12 +295,13 @@
#' }

new_package <- function(license = "GPL (>= 2)", status = NULL,
lifecycle = NULL, vignette = TRUE,
lifecycle = NULL, contributing = TRUE,
code_of_conduct = TRUE, vignette = TRUE,
test = TRUE, create_repo = TRUE, private = FALSE,
gh_check = TRUE, codecov = TRUE, website = TRUE,
gh_render = TRUE, given = NULL, family = NULL,
email = NULL, orcid = NULL, organisation = NULL,
overwrite = FALSE, quiet = FALSE) {
gh_render = TRUE, gh_citation = TRUE, given = NULL,
family = NULL, email = NULL, orcid = NULL,
organisation = NULL, overwrite = FALSE, quiet = FALSE) {


## If not RStudio ----
Expand Down Expand Up @@ -398,10 +413,11 @@ new_package <- function(license = "GPL (>= 2)", status = NULL,

} else {

gh_check <- FALSE
codecov <- FALSE
website <- FALSE
gh_render <- FALSE
gh_check <- FALSE
codecov <- FALSE
website <- FALSE
gh_render <- FALSE
gh_citation <- FALSE
}


Expand Down Expand Up @@ -567,6 +583,36 @@ new_package <- function(license = "GPL (>= 2)", status = NULL,

add_vignette(open = FALSE, overwrite = overwrite, quiet = quiet)
}



##
## ADDING CONTRIBUTING ----
##


if (contributing) {

ui_title("Adding Contributing")

add_contributing(email = email, organisation = organisation, open = FALSE,
overwrite = overwrite, quiet = quiet)
}



##
## ADDING CODE OF CONDUCT ----
##


if (code_of_conduct) {

ui_title("Adding Code of conduct")

add_code_of_conduct(email = email, open = FALSE, overwrite = overwrite,
quiet = quiet)
}



Expand Down Expand Up @@ -714,6 +760,22 @@ new_package <- function(license = "GPL (>= 2)", status = NULL,

usethis::use_github_pages(branch = "gh-pages")
}



##
## GHA CITATION ----
##



if (gh_citation) {

ui_title("Configuring GH Actions - CITATION.cff")

add_github_actions_citation(quiet = quiet)
add_to_buildignore(".github", quiet = quiet)
}



Expand All @@ -723,7 +785,7 @@ new_package <- function(license = "GPL (>= 2)", status = NULL,



if (gh_check || codecov || gh_render || website) {
if (gh_check || codecov || gh_render || website || gh_citation) {

ui_title("Committing changes")

Expand Down
17 changes: 17 additions & 0 deletions man/new_compendium.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 17 additions & 0 deletions man/new_package.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 21aa416

Please sign in to comment.