forked from wadpac/GGIR
-
Notifications
You must be signed in to change notification settings - Fork 0
/
prepareNewRelease.R
93 lines (92 loc) · 3.28 KB
/
prepareNewRelease.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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
prepareNewRelease = function(version = c()) {
# In preparation of a new package release this function helps
# to check that version number and release date are correct
# in the DESCRIPTION file, GGIR-package.Rd, and NEWS.Rd
# The function does not fix any errors, it only warns the user about
# mistakes via messages in the console.
# The function is not part of the package on CRAN, because it's name is
# listed in the .RBuildignore file.
# Argument version: a character specifying the expected version number, e.g. "1.8-1"
date = unlist(strsplit(as.character(Sys.time())," "))[1]
dateReversed = unlist(strsplit(date,"-"))
dateReversed = paste0(dateReversed[3],"-",dateReversed[2],"-",dateReversed[1])
# Check DESCRIPTION file
D = read.csv(file = "./DESCRIPTION", sep = "\n")
errorfound = FALSE
i = 1
while (i <= nrow(D)) {
tmp = as.character(unlist(strsplit(as.character(D[i,]),": ")))
if (tmp[1] == "Version") {
if (tmp[2] != version) {
cat("\nError: Version number is not correct in DESCRIPTION file")
errorfound = TRUE
}
}
if (tmp[1] == "Date") {
if (tmp[2] != date) {
cat("\nError: Date is not correct in DESCRIPTION file")
errorfound = TRUE
}
}
i = i + 1
}
# Check GGIR-package.Rd file
P = read.csv(file = "./man/GGIR-package.Rd", sep = "\n")
i = 1
while (i <= nrow(P)) {
tmp = as.character(unlist(strsplit(as.character(P[i,]),"[: \\]")))
if (tmp[1] == "Version") {
if (tmp[5] != version) {
cat("\nError: Version number is not correct in GGIR-package.Rd file")
errorfound = TRUE
}
}
if (tmp[1] == "Date") {
if (tmp[5] != date) {
cat("\nError: Date is not correct in GGIR-package.Rd file")
errorfound = TRUE
}
}
i = i + 1
}
# Check NEWs.rd file
NE = read.table(file = "./inst/NEWS.Rd", sep = "\n", quote = "")
i = 1
versioninfile = dateinfile = c()
while (i <= nrow(NE)) {
tmp = as.character(unlist(strsplit(as.character(NE[3,]),"version ")))
if (length(tmp) > 1) {
tmp2 = as.character(unlist(strsplit(as.character(tmp[2])," ")))
versioninfile = tmp2[1]
if (length(tmp2) > 2) {
tmp3 = as.character(unlist(strsplit(as.character(tmp2[3]),":"))[2])
dateinfile = as.character(unlist(strsplit(as.character(tmp3),"[)]"))[1])
}
}
if (length(versioninfile) > 0 & length(dateinfile) > 0) {
if (versioninfile != version) {
cat("\nError: Version number is not correct in NEWS.Rd file")
errorfound = TRUE
}
if (dateinfile != dateReversed) {
cat("\nError: Date is not correct in NEWS.Rd file")
errorfound = TRUE
}
break() # only check first date and version number
}
i = i + 1
}
if (errorfound == FALSE) cat(paste0("\nNo problem found. Package consistently uses version ",version," and release date ", dateReversed))
Q1 = menu(c("Yes", "No"), title = paste0("\nDo you want to check the package with manual, remote and incoming?"))
if (Q1 == 1) {
devtools::check(
manual = TRUE,
remote = TRUE,
incoming = TRUE
)
}
Q2 = menu(c("Yes", "No"), title = paste0("\nDo you want to build the package for CRAN including manual?"))
if (Q2 == 1) {
devtools::build(manual = TRUE)
}
}