-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbuildPkg.R
75 lines (58 loc) · 2.35 KB
/
buildPkg.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
##======================================================================
## Script to check and build the `legtheme` package
##======================================================================
##----------------------------------------------------------------------
## Set working directory
if (!basename(getwd()) == "legtheme") {
stop("The working directory isn't /leg-theme")
}
##----------------------------------------------------------------------
## Packages
library(devtools)
library(knitr)
library(rmarkdown)
##----------------------------------------------------------------------
## Run checks
## Load the package (to make functions available)
load_all()
## Create/update NAMESPACE, *.Rd files.
document()
## Check documentation.
check_man()
## Check functions, datasets, run examples, etc. Using cleanup = FALSE
## and check_dir = "../" will create a directory named legtheme.Rcheck
## with all the logs, manuals, figures from examples, etc.
check(manual = TRUE, vignettes = FALSE, check_dir = "../")
## Examples
# Run examples from all functions of the package
# run_examples()
# Run examples from a specific function
# dev_example("yscale.components.right")
## Show all exported objects.
ls("package:legtheme")
packageVersion("legtheme")
## Build the package (it will be one directory up)
build(manual = TRUE, vignettes = FALSE)
# build the binary version for windows (not used)
# build_win() # not used here. see below
##----------------------------------------------------------------------
## Test installation.
## Test install with install.packages()
pkg <- paste0("../legtheme_", packageVersion("legtheme"), ".tar.gz")
install.packages(pkg, repos = NULL)
##----------------------------------------------------------------------
## Generate README.md
knit(input = "README.Rmd")
##----------------------------------------------------------------------
## Sending package tarballs and manual to remote server to be
## downloadable
## Create Windows version
pkg.win <- paste0("../legtheme_", packageVersion("legtheme"), ".zip")
cmd.win <- paste("cd ../legtheme.Rcheck && zip -r", pkg.win, "legtheme")
system(cmd.win)
## Link to manual
man <- "../legtheme.Rcheck/legtheme-manual.pdf"
## Send to downloads/ folder
dest <- "downloads/"
file.copy(c(pkg, pkg.win, man), dest, overwrite = TRUE)
##----------------------------------------------------------------------