-
Notifications
You must be signed in to change notification settings - Fork 761
/
Copy pathinfrastructure.R
660 lines (554 loc) · 20.7 KB
/
infrastructure.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
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
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
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
#' Add useful infrastructure to a package.
#'
#' @param pkg package description, can be path or package name. See
#' \code{\link{as.package}} for more information.
#' @name infrastructure
#' @family infrastructure
NULL
#' @section \code{use_testthat}:
#' Add testing infrastructure to a package that does not already have it.
#' This will create \file{tests/testthat.R}, \file{tests/testthat/} and
#' add \pkg{testthat} to the suggested packages. This is called
#' automatically from \code{\link{test}} if needed.
#' @rdname infrastructure
#' @aliases add_test_infrastructure
#' @export
use_testthat <- function(pkg = ".") {
pkg <- as.package(pkg)
check_suggested("testthat")
if (uses_testthat(pkg)) {
stop("Package already has testing infrastructure", call. = FALSE)
}
# Create tests/testthat and install file for R CMD CHECK
dir.create(file.path(pkg$path, "tests", "testthat"),
showWarnings = FALSE, recursive = TRUE)
writeLines(render_template("testthat.R", list(name = pkg$package)),
file.path(pkg$path, "tests", "testthat.R"))
add_desc_package(pkg, "Suggests", "testthat")
invisible(TRUE)
}
#' @export
add_test_infrastructure <- use_testthat
#' @section \code{use_test}:
#' Add a test file, also add testing infrastructure if necessary.
#' This will create \file{tests/testthat/test-<name>.R} with a user-specified
#' name for the test. Will fail if the file exists.
#' @rdname infrastructure
#' @aliases add_test_infrastructure
#' @export
use_test <- function(name, pkg = ".") {
pkg <- as.package(pkg)
check_suggested("testthat")
if (!uses_testthat(pkg)) {
use_testthat(pkg)
}
path <- sprintf("tests/testthat/test-%s.R", name)
if (file.exists(file.path(pkg$path, path))) {
stop("File ", path, " exists", call. = FALSE)
}
writeLines(
render_template("test-example.R", list(test_name = name)),
file.path(pkg$path, path))
message("Test file created in ", path)
}
#' @section \code{use_rstudio}:
#' Does not modify \code{.Rbuildignore} as RStudio will do that when
#' opened for the first time.
#' @export
#' @rdname infrastructure
#' @aliases add_rstudio_project
use_rstudio <- function(pkg = ".") {
pkg <- as.package(pkg)
path <- file.path(pkg$path, paste0(pkg$package, ".Rproj"))
if (file.exists(path)) {
stop(pkg$package, ".Rproj already exists", call. = FALSE)
}
message("Adding RStudio project file to ", pkg$package)
template_path <- system.file("templates/template.Rproj", package = "devtools")
file.copy(template_path, path)
add_git_ignore(pkg, c(".Rproj.user", ".Rhistory", ".RData"))
add_build_ignore(pkg, c("^.*\\.Rproj$", "^\\.Rproj\\.user$"), escape = FALSE)
invisible(TRUE)
}
#' @export
add_rstudio_project <- use_rstudio
#' @section \code{use_vignette}:
#' Adds needed packages to \code{DESCRIPTION}, and creates draft vignette
#' in \code{vignettes/}. It adds \code{inst/doc} to \code{.gitignore}
#' so you don't accidentally check in the built vignettes.
#' @param name File name to use for new vignette. Should consist only of
#' numbers, letters, _ and -. I recommend using lower case.
#' @export
#' @rdname infrastructure
use_vignette <- function(name, pkg = ".") {
pkg <- as.package(pkg)
check_suggested("rmarkdown")
add_desc_package(pkg, "Suggests", "knitr")
add_desc_package(pkg, "Suggests", "rmarkdown")
add_desc_package(pkg, "VignetteBuilder", "knitr")
dir.create(file.path(pkg$path, "vignettes"), showWarnings = FALSE)
add_git_ignore(pkg, "inst/doc")
path <- file.path(pkg$path, "vignettes", paste0(name, ".Rmd"))
rmarkdown::draft(path, "html_vignette", "rmarkdown",
create_dir = FALSE, edit = FALSE)
message("Draft vignette created in ", path)
}
#' @section \code{use_rcpp}:
#' Creates \code{src/} and adds needed packages to \code{DESCRIPTION}.
#' @export
#' @rdname infrastructure
use_rcpp <- function(pkg = ".") {
pkg <- as.package(pkg)
check_suggested("Rcpp")
message("Adding Rcpp to LinkingTo and Imports")
add_desc_package(pkg, "LinkingTo", "Rcpp")
add_desc_package(pkg, "Imports", "Rcpp")
message("Creating src/ and src/.gitignore")
dir.create(file.path(pkg$path, "src"), showWarnings = FALSE)
union_write(file.path(pkg$path, "src", ".gitignore"),
c("*.o", "*.so", "*.dll"))
message(
"Next, include the following roxygen tags somewhere in your package:\n",
"#' @useDynLib ", pkg$package, "\n",
"#' @importFrom Rcpp sourceCpp"
)
}
#' @rdname infrastructure
#' @section \code{use_travis}:
#' Add basic travis template to a package. Also adds \code{.travis.yml} to
#' \code{.Rbuildignore} so it isn't included in the built package.
#' @export
#' @aliases add_travis
use_travis <- function(pkg = ".") {
pkg <- as.package(pkg)
path <- file.path(pkg$path, ".travis.yml")
if (file.exists(path)) {
stop(".travis.yml already exists", call. = FALSE)
}
gh <- github_info(pkg$path)
message("Adding .travis.yml to ", pkg$package, ". Next: \n",
" * Turn on travis for this repo at https://travis-ci.org/profile\n",
" * Add a travis shield to your README.md:\n",
"[![Travis-CI Build Status]",
"(https://travis-ci.org/", gh$username, "/", gh$repo, ".svg?branch=master)]",
"(https://travis-ci.org/", gh$username, "/", gh$repo, ")"
)
template_path <- system.file("templates/travis.yml", package = "devtools")
file.copy(template_path, path)
add_build_ignore(pkg, ".travis.yml")
invisible(TRUE)
}
#' @rdname devtools-deprecated
#' @section \code{use_coveralls}:
#' Add coveralls to basic travis template to a package.
#' @export
use_coveralls <- function(pkg = ".") {
.Deprecated("use_coverage(type = \"coveralls\")", package = "devtools")
use_coverage(pkg, type = "coveralls")
}
#' @rdname infrastructure
#' @param type CI tool to use. Currently supports codecov and coverall.
#' @section \code{use_coverage}:
#' Add test code coverage to basic travis template to a package.
#' @export
use_coverage <- function(pkg = ".", type = c("codecov", "coveralls")) {
pkg <- as.package(pkg)
path <- file.path(pkg$path, ".travis.yml")
if (!file.exists(path)) {
stop(".travis.yml does not exist, please run `use_travis()` to create it", call. = FALSE)
}
travis_content <- readLines(file.path(pkg$path, ".travis.yml"))
type <- match.arg(type)
switch(type,
codecov = {
if (any(grepl("codecov", travis_content))) {
stop("codecov information already added to .travis.yml", call. = FALSE)
}
gh <- github_info(pkg$path)
message("Adding codecov information into .travis.yml for ", pkg$package, ". Next: \n",
"[![Coverage Status]",
"(https://img.shields.io/codecov/c/github/", gh$username, "/", gh$repo, "/master.svg)]",
"(https://codecov.io/github/", gh$username, "/", gh$repo, "?branch=master)\n",
" * Add the following to .travis.yml:\n",
"r_packages:\n",
" - covr\n",
"after_success:\n",
" - Rscript -e 'covr::codecov()'")
},
coveralls = {
if (any(grepl("coveralls", travis_content))) {
stop("coveralls information already added to .travis.yml", call. = FALSE)
}
gh <- github_info(pkg$path)
message("Adding coveralls information into .travis.yml for ", pkg$package, ". Next: \n",
" * Turn on coveralls for this repo at https://coveralls.io/repos/new\n",
" * Add a coveralls shield to your README.md:\n",
"[![Coverage Status]",
"(https://img.shields.io/coveralls/", gh$username, "/", gh$repo, ".svg)]",
"(https://coveralls.io/r/", gh$username, "/", gh$repo, "?branch=master)\n",
" * Add the following to .travis.yml:\n",
"r_github_packages:\n",
" - jimhester/covr\n",
"after_success:\n",
" - Rscript -e 'covr::coveralls()'")
})
invisible(TRUE)
}
#' @export
add_travis <- use_travis
#' @rdname infrastructure
#' @section \code{use_appveyor}:
#' Add basic AppVeyor template to a package. Also adds \code{appveyor.yml} to
#' \code{.Rbuildignore} so it isn't included in the built package.
#' @export
use_appveyor <- function(pkg = ".") {
pkg <- as.package(pkg)
path <- file.path(pkg$path, "appveyor.yml")
if (file.exists(path)) {
stop("appveyor.yml already exists", call. = FALSE)
}
gh <- github_info(pkg$path)
message("Adding appveyor.yml to ", pkg$package, ". Next: \n",
" * Turn on AppVeyor for this repo at https://ci.appveyor.com/projects\n",
" * Add an AppVeyor shield to your README.md:\n",
"[![AppVeyor Build Status]",
"(https://ci.appveyor.com/api/projects/status/github/", gh$username, "/", gh$repo, "?branch=master&svg=true)]",
"(https://ci.appveyor.com/project/", gh$username, "/", gh$repo, ")"
)
template_path <- system.file("templates/appveyor.yml", package = "devtools")
file.copy(template_path, path)
add_build_ignore(pkg, "appveyor.yml")
invisible(TRUE)
}
#' @rdname infrastructure
#' @section \code{use_package_doc}:
#' Adds a roxygen template for package documentation
#' @export
use_package_doc <- function(pkg = ".") {
pkg <- as.package(pkg)
path <- file.path("R", paste(pkg$package, "-package.r", sep = ""))
if (file.exists(file.path(pkg$path, path))) {
stop(path, " already exists", call. = FALSE)
}
message("Creating ", path)
out <- render_template("packagename-package.r", list(name = pkg$package))
writeLines(out, file.path(pkg$path, path))
}
#' Use specified package.
#'
#' This adds a dependency to DESCRIPTION and offers a little advice
#' about how to best use it.
#'
#' @param package Name of package to depend on.
#' @param type Type of dependency: must be one of "Imports", "Suggests",
#' "Depends", "Suggests", "Enhances", or "LinkingTo" (or unique abbreviation)
#' @param pkg package description, can be path or package name. See
#' \code{\link{as.package}} for more information.
#' @family infrastructure
#' @export
#' @examples
#' \dontrun{
#' use_package("ggplot2")
#' use_package("dplyr", "suggests")
#'
#' }
use_package <- function(package, type = "Imports", pkg = ".") {
stopifnot(is.character(package), length(package) == 1)
stopifnot(is.character(type), length(type) == 1)
if (!is_installed(package)) {
stop(package, " must be installed before you can take a dependency on it",
call. = FALSE)
}
types <- c("Imports", "Depends", "Suggests", "Enhances", "LinkingTo")
names(types) <- tolower(types)
type <- types[[match.arg(tolower(type), names(types))]]
message("Adding ", package, " to ", type)
add_desc_package(pkg, type, package)
msg <- switch(type,
Imports = paste0("Refer to functions with ", package, "::fun()"),
Depends = paste0("Are you sure you want Depends? Imports is almost always",
" the better choice."),
Suggests = paste0("Use requireNamespace(\"", package, "\", quietly = TRUE)",
" to test if package is installed,\n",
"then use ", package, "::fun() to refer to functions."),
Enhances = "",
LinkingTo = show_includes(package)
)
message(msg)
}
show_includes <- function(package) {
incl <- system.file("include", package = package)
h <- dir(incl, "\\.(h|hpp)$")
if (length(h) == 0) return()
message("Possible includes are:\n",
paste0("#include <", h, ">", collapse = "\n"))
}
add_desc_package <- function(pkg = ".", field, name) {
pkg <- as.package(pkg)
desc_path <- file.path(pkg$path, "DESCRIPTION")
desc <- read_dcf(desc_path)
old <- desc[[field]]
if (is.null(old)) {
new <- name
changed <- TRUE
} else {
if (!grepl(name, old)) {
new <- paste0(old, ",\n ", name)
changed <- TRUE
} else {
changed <- FALSE
}
}
if (changed) {
desc[[field]] <- new
write_dcf(desc_path, desc)
}
invisible(changed)
}
#' Use data in a package.
#'
#' This function makes it easy to save package data in the correct format.
#'
#' @param ... Unquoted names of existing objects to save.
#' @param pkg Package where to store data. Defaults to package in working
#' directory.
#' @param internal If \code{FALSE}, saves each object in individual
#' \code{.rda} files in the \code{data/} directory. These are available
#' whenever the package is loaded. If \code{TRUE}, stores all objects in
#' a single \code{R/sysdata.rda} file. These objects are only available
#' within the package.
#' @param overwrite By default, \code{use_data} will not overwrite existing
#' files. If you really want to do so, set this to \code{TRUE}.
#' @param compress Choose the type of compression used by \code{\link{save}}.
#' Should be one of "gzip", "bzip2" or "xz".
#' @export
#' @family infrastructure
#' @examples
#' \dontrun{
#' x <- 1:10
#' y <- 1:100
#'
#' use_data(x, y) # For external use
#' use_data(x, y, internal = TRUE) # For internal use
#' }
use_data <- function(..., pkg = ".", internal = FALSE, overwrite = FALSE,
compress = "bzip2") {
pkg <- as.package(pkg)
to_save <- dots(...)
is_name <- vapply(to_save, is.symbol, logical(1))
if (any(!is_name)) {
stop("Can only save existing named objects", call. = FALSE)
}
objs <- vapply(to_save, as.character, character(1))
if (internal) {
data_path <- file.path(pkg$path, "R", "sysdata.rda")
if (file.exists(data_path) && !overwrite) {
stop("R/sysdata.rda exists. Use overwrite = TRUE to overwrite",
call. = FALSE)
}
message("Saving ", paste(objs, collapse = ", "), " to R/sysdata.rda")
save(..., file = data_path, envir = parent.frame(), compress = compress)
} else {
data_path <- file.path(pkg$path, "data")
if (!file.exists(data_path)) dir.create(data_path)
paths <- file.path(pkg$path, "data", paste0(objs, ".rda"))
if (any(file.exists(paths)) && !overwrite) {
stop(paste(basename(paths), collapse = ", "), " already exist. ",
"Use overwrite = TRUE to overwrite", call. = FALSE)
}
message("Saving ", paste(objs, collapse = ", "), " to ",
paste0("data/", basename(paths), collapse = ", "))
envir <- parent.frame()
save_one <- function(name, path) {
save(list = name, file = path, envir = envir, compress = compress)
}
Map(save_one, objs, paths)
}
invisible()
}
#' Use \code{data-raw} to compute package datasets.
#'
#' @param pkg Package where to create \code{data-raw}. Defaults to package in
#' working directory.
#' @export
#' @family infrastructure
use_data_raw <- function(pkg = ".") {
pkg <- as.package(pkg)
path <- file.path(pkg$path, "data-raw")
if (file.exists(path)) {
stop("data-raw/ already exists", call. = FALSE)
}
message("Creating data-raw/")
dir.create(path)
add_build_ignore(pkg, "data-raw")
message("Next: \n",
"* Add data creation scripts in data-raw\n",
"* Use devtools::use_data() to add data to package")
}
#' Add a file to \code{.Rbuildignore}
#'
#' \code{.Rbuildignore} has a regular expression on each line, but it's
#' usually easier to work with specific file names. By default, will (crudely)
#' turn a filename into a regular expression that will only match that
#' path. Repeated entries will be silently removed.
#'
#' @param pkg package description, can be path or package name. See
#' \code{\link{as.package}} for more information
#' @param files Name of file.
#' @param escape If \code{TRUE}, the default, will escape \code{.} to
#' \code{\\.} and surround with \code{^} and \code{$}.
#' @return Nothing, called for its side effect.
#' @export
#' @aliases add_build_ignore
#' @family infrastructure
#' @keywords internal
use_build_ignore <- function(files, escape = TRUE, pkg = ".") {
pkg <- as.package(pkg)
if (escape) {
files <- paste0("^", gsub("\\.", "\\\\.", files), "$")
}
path <- file.path(pkg$path, ".Rbuildignore")
union_write(path, files)
invisible(TRUE)
}
#' Use README.Rmd
#'
#' This creates `README.Rmd` from template and adds to \code{.Rbuildignore}.
#'
#' @param hook Hook name. One of "pre-commit", "prepare-commit-msg",
#' "commit-msg", "post-commit", "applypatch-msg", "pre-applypatch",
#' "post-applypatch", "pre-rebase", "post-rewrite", "post-checkout",
#' "post-merge", "pre-push", "pre-auto-gc".
#' @param script Text of script to run
#' @param pkg package description, can be path or package name. See
#' \code{\link{as.package}} for more information
#' @export
#' @family infrastructure
#' @keywords internal
use_readme_rmd <- function(pkg = ".") {
pkg <- as.package(pkg)
readme_path <- file.path(pkg$path, "README.Rmd")
template <- render_template("README.Rmd")
if (!file.exists(readme_path)) {
message("Creating README.Rmd")
writeLines(template, readme_path)
} else {
rule("README.Rmd exists. Please check that it starts with:")
message(template)
rule()
}
use_build_ignore("README.Rmd", pkg = pkg)
use_build_ignore("^README-.*\\.png$", escape = FALSE, pkg = pkg)
if (uses_git(pkg$path) && file.exists(pkg$path, ".git", "hooks", "pre-commit")) {
message("Adding pre-commit hook")
use_git_hook("pre-commit", render_template("readme-rmd-pre-commit.sh"),
pkg = pkg)
}
invisible(TRUE)
}
#' @rdname infrastructure
#' @section \code{use_revdep}:
#' Add \code{revdep} directory and basic check template.
#' @export
#' @aliases add_travis
use_revdep <- function(pkg = ".") {
pkg <- as.package(pkg)
message("Creating revdep/ & adding to .Rbuildignore")
dir.create(file.path(pkg$path, "revdep"), showWarnings = FALSE)
use_build_ignore("revdep", pkg = pkg)
message("Add revdep subdirectories to .gitignore")
path <- file.path(pkg$path, "revdep", ".gitignore")
union_write(path, "**/")
if (!file.exists(file.path(pkg$path, "revdep/check.R"))) {
message("Adding revdep/check.R template")
writeLines(render_template("revdep.R", list(name = pkg$package)),
file.path(pkg$path, "revdep", "check.R"))
}
}
#' @rdname infrastructure
#' @section \code{use_cran_comments}:
#' Add \code{cran-comments.md} template.
#' @export
#' @aliases add_travis
use_cran_comments <- function(pkg = ".") {
pkg <- as.package(pkg)
use_build_ignore("cran-comments.md")
comments <- file.path(pkg$path, "cran-comments.md")
if (file.exists(comments))
stop("cran-comments.md already exists", call. = FALSE)
message("Adding cran-comments.md template")
writeLines(render_template("cran-comments.md", list()), comments)
invisible()
}
#' @rdname infrastructure
#' @section \code{use_code_of_conduct}:
#' Add a code of conduct to from \url{http://contributor-covenant.org}.
#'
#' @export
#' @aliases add_travis
use_code_of_conduct <- function(pkg = ".") {
pkg <- as.package(pkg)
comments <- file.path(pkg$path, "CONDUCT.md")
if (file.exists(comments))
stop("CONDUCT.md already exists", call. = FALSE)
message("* Creating CONDUCT.md")
writeLines(render_template("CONDUCT.md", list()), comments)
message("* Adding CONDUCT.md to .Rbuildignore")
use_build_ignore("CONDUCT.md")
message("* Don't forget to describe the code of conduct in your README.md:")
message("Please note that this project is released with a ",
"[Contributor Code of Conduct](CONDUCT.md). ", "By participating in this ",
"project you agree to abide by its terms.")
}
add_build_ignore <- function(pkg = ".", files, escape = TRUE) {
use_build_ignore(files, escape = escape, pkg = pkg)
}
union_write <- function(path, new_lines) {
if (file.exists(path)) {
lines <- readLines(path, warn = FALSE)
} else {
lines <- character()
}
all <- union(lines, new_lines)
writeLines(all, path)
}
#' @rdname infrastructure
#' @section \code{use_cran_badge}:
#' Add a badge to show CRAN status and version number on the README
#' @export
use_cran_badge <- function(pkg = ".") {
pkg <- as.package(pkg)
message(
" * Add a CRAN status shield by adding the following line to your README:\n",
"[](http://cran.r-project.org/package=", pkg$package, ")"
)
invisible(TRUE)
}
#' @rdname infrastructure
#' @section \code{use_mit_license}:
#' Adds the necessary infrastructure to declare your package as
#' distributed under the MIT license.
#' @param copyright_holder The copyright holder for this package. Defaults to
#' \code{getOption("devtools.name")}.
#' @export
use_mit_license <- function(pkg = ".", copyright_holder = getOption("devtools.name", "<Author>")) {
pkg <- as.package(pkg)
# Update the DESCRIPTION
descPath <- file.path(pkg$path, "DESCRIPTION")
DESCRIPTION <- read_dcf(descPath)
DESCRIPTION$License <- "MIT + file LICENSE"
write_dcf(descPath, DESCRIPTION)
# Update the license
licensePath <- file.path(pkg$path, "LICENSE")
if (file.exists(licensePath))
if (!file.remove(licensePath))
stop("Failed to remove license file '", licensePath, "'", call. = FALSE)
# Write the MIT template
template <- c(
paste("YEAR:", format(Sys.Date(), "%Y")),
paste("COPYRIGHT HOLDER:", copyright_holder)
)
writeLines(template, con = licensePath)
message("* Added infrastructure for MIT license")
licensePath
}