The overall flow can be thought of as follows:
- Build/test the package localy
- Run alternitive tests
- Submit it CRAN
The detailes steps are found below:
- Clone the repo
- Open RStudio and run the below.
- Load packages
pkgs <- installed.packages()
pkg_name <- 'xxx'
pkg_path <- 'd:/repos/yyy/xxx'
pkg_pkg <- paste0('package:', pkg_name)
if (!('devtools' %in% pkgs)) { install.packages('devtools') }
if (!('roxygen2' %in% pkgs)) { install.packages('roxygen2') }
if (!('pkgdown' %in% pkgs)) { install.packages('pkgdown') }
if (pkg_name %in% pkgs) { remove.packages(pkg_name) }
- Set working directory and clean files that will be regenerated. This folder will vary based on where the repo was cloned.
setwd(pkg_path)
unlink(c('./man', './inst/doc', './NAMESPACE'), recursive = T)
- Run the pre-build checks
devtools::check(manual = T, vignettes = T)
detach(pos = which(search() == pkg_pkg), unload = T)
unlink(c('./man', './NAMESPACE'), recursive = T)
- Make docs
devtools::document()
devtools::build_vignettes()
dir.create('./inst/doc', showWarnings = F, recursive = T)
files <- list.files('./doc', pattern = 'html')
lapply(files, function(x) { file.rename(paste0('./doc/', x), paste0('./inst/doc/', x)) } )
unlink(c('./doc', './Meta'), recursive = T)
detach(pos = which(search() == pkg_pkg), unload = T)
- Test the install-ability
devtools::install_local(upgrade = 'never')
remove.packages(pkg_name)
- Run the tests
devtools::test()
- Test using CRAN like resources
rhub::check_for_cran()
devtools::check_win_release()