devstuffs.R 8.98 KB
Newer Older
kapsner's avatar
kapsner committed
1
2
3
4
5
6
7
8
9
10
packagename <- "DQAgui"

# remove existing description object
unlink("DESCRIPTION")
# Create a new description object
my_desc <- desc::description$new("!new")
# Set your package name
my_desc$set("Package", packagename)
# Set author names
my_desc$set_authors(c(
11
12
13
14
  person(
    "Lorenz A.",
    "Kapsner",
    email = "lorenz.kapsner@uk-erlangen.de",
15
    role = c("cre", "aut"),
16
17
18
19
20
    comment = c(ORCID = "0000-0003-1866-860X")
  ),
  person(
    "Jonathan M.",
    "Mang",
21
    role = "aut",
22
    comment = c(ORCID = "0000-0003-0518-4710")
23
  ),
24
  person("MIRACUM - Medical Informatics in Research and Care in University Medicine", role = "fnd"),
Lorenz Kapsner's avatar
Lorenz Kapsner committed
25
  person("Universitätsklinikum Erlangen", role = "cph")
26
))
kapsner's avatar
kapsner committed
27
28
29
30
#  person("Name2", "Surname2", email = "mail@2", role = 'aut')))
# Remove some author fields
my_desc$del("Maintainer")
# Set the version
31
my_desc$set_version("0.2.0.9005")
kapsner's avatar
kapsner committed
32
# The title of your package
33
my_desc$set(Title = "Graphical User Interface for Data Quality Assessment")
kapsner's avatar
kapsner committed
34
35
36
# The description of your package
my_desc$set(Description = "A graphical user interface (GUI) to the functions implemented in the R package 'DQAstats'.")
# The description of your package
37
my_desc$set("Date" = as.character(Sys.Date()))
kapsner's avatar
kapsner committed
38
# The urls
39
my_desc$set("URL", "https://github.com/miracum/dqa-dqagui")
kapsner's avatar
kapsner committed
40
my_desc$set("BugReports",
41
            "https://github.com/miracum/dqa-dqagui/issues")
kapsner's avatar
kapsner committed
42
43
44
45
46
47
# License
my_desc$set("License", "GPL-3")
# Save everyting
my_desc$write(file = "DESCRIPTION")

# License
Jonathan Mang's avatar
Jonathan Mang committed
48
#usethis::use_gpl3_license(name="Universitätsklinikum Erlangen")
kapsner's avatar
kapsner committed
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65


# add Imports and Depends
# Listing a package in either Depends or Imports ensures that it’s installed when needed
# Imports just loads the package, Depends attaches it
# Loading will load code, data and any DLLs; register S3 and S4 methods; and run the .onLoad() function.
##      After loading, the package is available in memory, but because it’s not in the search path,
##      you won’t be able to access its components without using ::.
##      Confusingly, :: will also load a package automatically if it isn’t already loaded.
##      It’s rare to load a package explicitly, but you can do so with requireNamespace() or loadNamespace().
# Attaching puts the package in the search path. You can’t attach a package without first loading it,
##      so both library() or require() load then attach the package.
##      You can see the currently attached packages with search().

# Depends

# Imports
66
67
usethis::use_package("data.table", type = "Imports")
usethis::use_package("magrittr", type = "Imports")
68
69
# For date-restriction:
usethis::use_package("daterangepicker", type = "Imports")
70
usethis::use_package("DT", type = "Imports")
Jonathan Mang's avatar
Jonathan Mang committed
71
72
usethis::use_package("lubridate", type = "Imports")
usethis::use_package("parsedate", type = "Imports")
73
usethis::use_package("shiny", type = "Imports")
74
usethis::use_package("shinyalert", type = "Imports")
75
76
77
usethis::use_package("shinydashboard", type = "Imports")
usethis::use_package("shinyFiles", type = "Imports")
usethis::use_package("shinyjs", type = "Imports")
78
usethis::use_package("shinyWidgets", type = "Imports")
79
80
usethis::use_package("knitr", type = "Imports")
usethis::use_package("jsonlite", type = "Imports")
81
82
83
usethis::use_package("DIZutils", type = "Imports", min_version = "0.1.0")
usethis::use_package("DIZtools", type = "Imports", min_version = "0.0.5")
usethis::use_package("DQAstats", type = "Imports", min_version = "0.3.0")
84
85
# For loading-animations:
usethis::use_package("waiter", type = "Imports")
86

kapsner's avatar
kapsner committed
87
88

# Suggests
89
usethis::use_package("testthat", type = "Suggests", min_version = "3.0.0")
90
usethis::use_package("lintr", type = "Suggests")
kapsner's avatar
kapsner committed
91

92
93
# define remotes
remotes_append_vector <- NULL
94

95
# Development packages
96

97
tools_tag <- "dev" # e.g. "v0.1.7", "development" or "cran"
98
if (tools_tag == "cran") {
99
  install.packages("DIZtools")
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
} else{
  devtools::install_git(
    url = "https://gitlab.miracum.org/miracum/misc/diztools.git",
    ref = tools_tag,
    upgrade = "always",
    quiet = TRUE
  )
  add_remotes <- paste0(
    "url::https://gitlab.miracum.org/miracum/misc/diztools/-/archive/", tools_tag, "/diztools-", tools_tag, ".zip"
  )
  desc::desc_set_remotes(
    add_remotes,
    file = usethis::proj_get()
  )
}

116
utils_tag <- "development" # e.g. "v0.1.7", "development" or "cran"
117
if (utils_tag == "cran") {
118
  install.packages("DIZutils")
119
} else{
120
121
122
123
124
125
  devtools::install_git(
    url = "https://gitlab.miracum.org/miracum/misc/dizutils.git",
    ref = utils_tag,
    upgrade = "always",
    quiet = TRUE
  )
126
  add_remotes <- paste0(
127
    "url::https://gitlab.miracum.org/miracum/misc/dizutils/-/archive/", utils_tag, "/dizutils-", utils_tag, ".zip"
128
129
130
131
132
133
  )
  if (is.null(remotes_append_vector)) {
    remotes_append_vector <- add_remotes
  } else {
    remotes_append_vector <- c(remotes_append_vector, add_remotes)
  }
134
135
}

136
stats_tag <- "development" # e.g. "v0.1.7", "development" or "cran"
137
if (stats_tag == "cran") {
138
  install.packages("DQAstats")
139
140
141
142
143
144
145
} else{
  devtools::install_git(
    url = "https://gitlab.miracum.org/miracum/dqa/dqastats.git",
    ref = stats_tag,
    upgrade = "always",
    quiet = TRUE
  )
146
  add_remotes <- paste0(
147
    "url::https://gitlab.miracum.org/miracum/dqa/dqastats/-/archive/", stats_tag, "/dqastats-", stats_tag, ".zip"
148
149
150
151
152
153
154
155
156
157
158
159
160
161
  )
  if (is.null(remotes_append_vector)) {
    remotes_append_vector <- add_remotes
  } else {
    remotes_append_vector <- c(remotes_append_vector, add_remotes)
  }
}

# finally, add remotes (if required)
if (!is.null(remotes_append_vector)) {
  desc::desc_set_remotes(
    remotes_append_vector,
    file = usethis::proj_get()
  )
162
163
}

kapsner's avatar
kapsner committed
164

Jonathan Mang's avatar
Jonathan Mang committed
165
## .Rbuildignore: ##
166
167
168
169
170
fn <- ".Rbuildignore"
if (file.exists(fn)) {
  file.remove(fn)
}
usethis::use_build_ignore("docker")
Jonathan Mang's avatar
Jonathan Mang committed
171
172
173
usethis::use_build_ignore("data-raw")
usethis::use_build_ignore("LICENSE.md")
usethis::use_build_ignore(".gitlab-ci.yml")
174
usethis::use_build_ignore(".vscode")
Lorenz Kapsner's avatar
Lorenz Kapsner committed
175
usethis::use_build_ignore(".lintr")
Jonathan Mang's avatar
Jonathan Mang committed
176
usethis::use_build_ignore("ci/*")
177
usethis::use_build_ignore("NEWS.md")
178
usethis::use_build_ignore("logfile.md")
Lorenz Kapsner's avatar
Lorenz Kapsner committed
179
usethis::use_build_ignore("reconf.sh")
180
usethis::use_build_ignore("cran-comments.md")
181
182
183
184
185
186
usethis::use_build_ignore(".ccache")
usethis::use_build_ignore(".github")
usethis::use_build_ignore("tic.R")
usethis::use_build_ignore("CRAN-RELEASE")
usethis::use_build_ignore("CRAN-SUBMISSION")
usethis::use_build_ignore("dqagui.Rproj")
Lorenz Kapsner's avatar
Lorenz Kapsner committed
187
188
usethis::use_build_ignore("man/figures")
usethis::use_build_ignore("Rplots.pdf")
Jonathan Mang's avatar
Jonathan Mang committed
189
190

## .gitignore:
191
192
193
194
195
196
197
198
fn <- ".gitignore"
if (file.exists(fn)) {
  file.remove(fn)
}
usethis::use_git_ignore("## --------------")
usethis::use_git_ignore("## This file is auto generated.")
usethis::use_git_ignore("## Please apply changes in `./data-raw/devstuffs.R`!")
usethis::use_git_ignore("## -------------")
Jonathan Mang's avatar
Jonathan Mang committed
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
usethis::use_git_ignore("/*")
usethis::use_git_ignore("/*/")
usethis::use_git_ignore("*.log")
usethis::use_git_ignore("!/.gitignore")
usethis::use_git_ignore("!/data-raw/")
usethis::use_git_ignore("!/DESCRIPTION")
usethis::use_git_ignore("!/inst/")
usethis::use_git_ignore("!/LICENSE.md")
usethis::use_git_ignore("!/man/")
usethis::use_git_ignore("!NAMESPACE")
usethis::use_git_ignore("!/R/")
usethis::use_git_ignore("!/README.md")
usethis::use_git_ignore("!/tests/")
usethis::use_git_ignore("/.Rhistory")
usethis::use_git_ignore("!/*.Rproj")
usethis::use_git_ignore("/.Rproj*")
usethis::use_git_ignore("/.RData")
216
usethis::use_git_ignore("/.vscode")
Lorenz Kapsner's avatar
Lorenz Kapsner committed
217
usethis::use_git_ignore("!/.lintr")
218
usethis::use_git_ignore("!/NEWS.md")
219
usethis::use_git_ignore("!/cran-comments.md")
Jonathan Mang's avatar
Jonathan Mang committed
220
221
#usethis::use_git_ignore("/inst/demo_data/utilities/MDR/.~lock.mdr_example_data.csv#")
usethis::use_git_ignore(".~lock.*.csv#")
222
223
224
225
226
227
228
229
230
231
232
usethis::use_git_ignore("!/docker/")
usethis::use_git_ignore("/docker/*")
usethis::use_git_ignore("!/docker/build_image.sh")
usethis::use_git_ignore("!/docker/docker-compose.yml")
usethis::use_git_ignore("!/docker/Dockerfile")
usethis::use_git_ignore("!/docker/README.md")
usethis::use_git_ignore("!/docker/.env")
usethis::use_git_ignore("!/docker/app.R")
usethis::use_git_ignore("!/docker/shiny-server.conf")
usethis::use_git_ignore("!/docker/show-log.sh")

kapsner's avatar
kapsner committed
233

234
235
236
# create NEWS.md using the python-package "auto-changelog" (must be installed)
# https://www.conventionalcommits.org/en/v1.0.0/
# build|ci|docs|feat|fix|perf|refactor|test
237
238
239

# https://github.com/gitpython-developers/GitPython/issues/1016#issuecomment-1104114129
system(
Lorenz Kapsner's avatar
Lorenz Kapsner committed
240
  command = paste0("git config --global --add safe.directory ", getwd())
241
242
)

243
244
245
system(
  command = 'auto-changelog -u -t "DQAgui NEWS" --tag-prefix "v" -o "NEWS.md"'
)
246

Lorenz Kapsner's avatar
Lorenz Kapsner committed
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
badger::badge_cran_download("DQAgui", "grand-total", "blue")
badger::badge_cran_download("DQAgui", "last-month", "blue")
badger::badge_dependencies("DQAgui")


# imgurl <- path.expand("~/development/Rpackages/bg4.jpeg")
# hexSticker::sticker(
#   subplot = imgurl,
#   package = "DQAgui",
#   s_width = 0.66,
#   s_height = 0.66,
#   s_x = 1,
#   s_y = 1,
#   p_size = 26,
#   p_x = 1,
#   p_y = 1,
#   filename = "man/figures/logo.png",
#   h_color = "#5c87ff", # "#b4f2e9",
#   p_color = "#5c87ff", # "#b4f2e9",
#   h_size = 0.8,
#   h_fill = "#fff184",#ffc2da
#   spotlight = TRUE,
#   #l_width = 6,
#   #l_height = 6,
#   white_around_sticker = FALSE,
#   asp = 1
# )