R/create_package.R

Defines functions create_package

Documented in create_package

#' Create a package
#' @description Creates a new package at given path; the package is named as the
#'   last folder in the path.
#'
#' @param path A path. If it exists, it is used. If it does not exist, it is
#'   created, provided that the parent path exists.
#' @param ... Additional arguments passed to `usethis::create_package()`
#' @param use_git Initialise and make initial commits to a local git
#'   repository. By default is `TRUE`.
#' @param use_github Create and push to a GitHub repository. By default takes
#'   value of `use_git`. If set to `TRUE`, `use_git` must also be `TRUE`.
#' @param use_ci Set up a GitHub Action job to run R CMD CHECK. By default takes
#'   value of `use_github`. If set to `TRUE`, `use_github` must also be `TRUE`.
#' @param use_precommit Set up `precommit` to run checks before any commit. By
#'   default takes value of `use_ci`. If set to `TRUE`, `use_git` must also
#'   be `TRUE`.
#' @param use_coverage Set up `covr` and, if using GitHub, a GitHub Action to run
#'   code coverage and use the Codecov service. By default takes value of `use_ci`.
#' @param use_lintr Set up lintr. By default is `TRUE`.
#' @param use_tests Set up testthat. By default is `TRUE`.
#' @inheritParams usethis::create_package
#' @return The path to the created package, invisibly.
#'
#' @export
create_package <- function(path, use_git = TRUE, use_github = use_git,
                           use_ci = use_github, use_precommit = use_ci,
                           use_coverage = use_ci, use_lintr = TRUE,
                           use_tests = TRUE, ..., open = FALSE) {
  if (!check_create_package_args(as.list(environment())[2:5])) {
    return(invisible(FALSE))
  }

  create_package_(path, open, usethis::create_package, ...)

  post_creation_steps(
    path, use_git, use_github, use_ci, use_precommit, use_coverage, use_lintr, use_tests
  )

  invisible(path)
}
MarkMc1089/devpacker documentation built on April 19, 2022, 4:48 p.m.