-
Notifications
You must be signed in to change notification settings - Fork 0
/
devstuffs.R
159 lines (141 loc) · 4.41 KB
/
devstuffs.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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
# nolint start
packagename <- "rpkgTemplate"
# 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 your name
my_desc$set_authors(c(
person(
given = "John",
family = "Doe",
email = "john.doe@johnmail.com",
role = c('cre', 'aut', 'cph')
)))
# Remove some author fields
my_desc$del("Maintainer")
# Set the version
my_desc$set_version("0.0.0.9001")
# The title of your package
my_desc$set(Title = "Template for Creating R Packages")
# The description of your package
my_desc$set(Description = paste0(
"A template repository for creating R packages."
))
# The description of your package
my_desc$set("Date/Publication" = paste(as.character(Sys.time()), "UTC"))
# The urls
my_desc$set("URL", "https://github.com/kapsner/rpkgTemplate")
my_desc$set("BugReports",
"https://github.com/kapsner/rpkgTemplate/issues")
# Vignette Builder
my_desc$set("VignetteBuilder" = "quarto")
# Quarto
# my_desc$set("SystemRequirements" = paste0(
# "Quarto command line tools ",
# "(https://github.com/quarto-dev/quarto-cli).")
# )
# Testthat stuff
my_desc$set("Config/testthat/parallel" = "false")
my_desc$set("Config/testthat/edition" = "3")
# Roxygen
my_desc$set("Roxygen" = "list(markdown = TRUE)")
# Save everyting
my_desc$write(file = "DESCRIPTION")
# License
usethis::use_gpl3_license()
# Depends
usethis::use_package("R", min_version = "3.6", type = "Depends")
# Imports
# https://cran.r-project.org/web/packages/data.table/vignettes/datatable-importing.html
usethis::use_package("data.table", type = "Imports")
usethis::use_package("magrittr", type = "Imports")
# Suggests
usethis::use_package("testthat", type = "Suggests", min_version = "3.0.1")
usethis::use_package("lintr", type = "Suggests")
usethis::use_package("knitr", type = "Suggests")
# define remotes
# remotes_append_vector <- NULL
#
# # Development package 1
# tag1 <- "master" # e.g. "v0.1.7", "development" or "cran"
# if (tag1 == "cran") {
# install.packages("data.table")
# } else{
# remotes::install_github(
# repo = "Rdatatable/data.table",
# ref = tag1
# )
# # add_remotes <- paste0(
# # "url::https://gitlab.miracum.org/miracum/misc/diztools/-/archive/", tools_tag, "/diztools-", tools_tag, ".zip"
# # )
# add_remotes <- paste0(
# "github::Rdatatable/data.table@", tag1
# )
#
# if (is.null(remotes_append_vector)) {
# remotes_append_vector <- add_remotes
# } else {
# remotes_append_vector <- c(remotes_append_vector, add_remotes)
# }
# }
#
# tag2 <- "main" # e.g. "v0.1.7", "development" or "cran"
# if (tag2 == "cran") {
# install.packages("magrittr")
# } else{
# remotes::install_github(
# repo = "tidyverse/magrittr",
# ref = tag2
# )
# # add_remotes <- paste0(
# # "url::https://gitlab.miracum.org/miracum/misc/dizutils/-/archive/", utils_tag, "/dizutils-", utils_tag, ".zip"
# # )
# add_remotes <- paste0(
# "github::tidyverse/magrittr@", tag2
# )
#
# 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()
# )
# }
usethis::use_build_ignore("cran-comments.md")
usethis::use_build_ignore(".lintr")
usethis::use_build_ignore("tic.R")
usethis::use_build_ignore(".github")
usethis::use_build_ignore("NEWS.md")
usethis::use_build_ignore("README.md")
usethis::use_build_ignore("docs")
usethis::use_build_ignore("Meta")
usethis::use_git_ignore("!NEWS.md")
usethis::use_git_ignore("!README.md")
usethis::use_git_ignore("docs")
usethis::use_git_ignore("Meta")
usethis::use_tidy_description()
quarto::quarto_render(input = "README.qmd")
# https://github.com/gitpython-developers/GitPython/issues/1016#issuecomment-1104114129
# system(
# command = paste0("git config --global --add safe.directory ", getwd())
# )
# 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
# system(
# command = 'auto-changelog -u -t "sjtable2df NEWS" --tag-prefix "v" -o "NEWS.md"'
# )
an <- autonewsmd::autonewsmd$new(repo_name = packagename)
an$generate()
an$write(force = TRUE)
# nolint end