Skip to content

Commit

Permalink
Merge pull request #150 from jimhester/devtools-2.1.0
Browse files Browse the repository at this point in the history
Use usethis rather than devtools to create packages and use GitHub
  • Loading branch information
MarkEdmondson1234 authored Jul 1, 2019
2 parents 6b948b0 + 44bca60 commit 15a5dc4
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 9 deletions.
3 changes: 2 additions & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ Suggests:
rmarkdown,
roxygen2 (>= 5.0.0),
shiny (>= 0.13.2),
testthat
testthat,
usethis,
License: MIT + file LICENSE
LazyData: true
VignetteBuilder: knitr
Expand Down
3 changes: 3 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

* ...

* Depend on usethis for `create_package()` and `use_github()` as they are
removed in devtools 2.1.0 (@jimhester, #150).

# googleAuthR v0.8.0

* Change behaviour on API parse errors to write a diagnostic object to the working directory
Expand Down
15 changes: 9 additions & 6 deletions R/discovery.R
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,17 @@
#'
#' @param api_json json from \link{gar_discovery_api}
#' @param directory Where to build the package
#' @param rstudio Passed to \link[devtools]{create}, creates RStudio project file
#' @param check Perform a \link[devtools]{check} on the package once done
#' @param rstudio Passed to \link[usethis]{create}, creates RStudio project file
#' @param check Perform a \link[usethis]{check} on the package once done
#' @param github If TRUE will upload package to your github
#' @param format If TRUE will use \link[formatR]{tidy_eval} on content
#' @param overwrite Whether to overwrite an existing directory if it exists
#'
#' @details
#'
#' For github upload to work you need to have your github PAT setup. See \link[devtools]{use_github}.
#' For github upload to work you need to have your github PAT setup. See \link[usethis]{use_github}.
#'
#' Uses devtools' \link[devtools]{create} to create a package structure then
#' Uses usethis' \link[usethis]{usethis} to create a package structure then
#' \link{gar_create_api_skeleton} and \link{gar_create_api_objects} to create
#' starting files for a Google API package.
#'
Expand All @@ -32,6 +32,7 @@ gar_create_package <- function(api_json,
format = TRUE,
overwrite = TRUE){
check_package_loaded("devtools")
check_package_loaded("usethis")
package_name <- paste0("google",
gsub("\\.","", make.names(api_json$id, allow_ = FALSE)),
".auto")
Expand All @@ -46,7 +47,7 @@ gar_create_package <- function(api_json,
o_files <- file.path(package_dir, "R", paste0(api_json$name,"_objects.R"))

if(!file.exists(f_files)){
devtools::create(file.path(directory, package_name),
usethis::create_package(file.path(directory, package_name),
list(
Package = package_name,
Version = "0.0.0.9000",
Expand Down Expand Up @@ -77,7 +78,9 @@ gar_create_package <- function(api_json,

if(github){
## if fail, use git add
devtools::use_github(pkg = package_dir, protocol = "https")
usethis::with_project(package_dir,
usethis::use_github(protocol = "https")
)
} ## git2r::push

result
Expand Down
4 changes: 2 additions & 2 deletions R/discovery_build.R
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ make_readme <- function(directory, api_json){
"## Features \n",
" * Auto generated R functions for every method and object in the API\n",
" * Passes CRAN checks in skeleton form\n",
" * Auto-creates R package files via `devtools`\n",
" * Auto-creates R package files via `usethis`\n",
" * Auto-documentation of function arguments\n",
" * Type-checking of passed objects\n",
" * Ability to quickly add new features of the API as they are published.\n",
Expand All @@ -246,4 +246,4 @@ make_readme <- function(directory, api_json){

add_line(readme, filename)

}
}

0 comments on commit 15a5dc4

Please sign in to comment.