diff --git a/DESCRIPTION b/DESCRIPTION
index 14a78d2..e6d3bde 100644
--- a/DESCRIPTION
+++ b/DESCRIPTION
@@ -1,6 +1,6 @@
Package: kwb.pkgbuild
Title: R package for standardised development at KWB
-Version: 0.1.1
+Version: 0.1.2
Authors@R:
c(person(given = "Michael",
family = "Rustler",
diff --git a/LICENSE b/LICENSE
index 225cf96..97d4ca6 100644
--- a/LICENSE
+++ b/LICENSE
@@ -1,21 +1,2 @@
-# MIT License
-
-Copyright (c) 2018 Kompetenzzentrum Wasser Berlin gGmbH (KWB)
-
-Permission is hereby granted, free of charge, to any person obtaining a copy
-of this software and associated documentation files (the "Software"), to deal
-in the Software without restriction, including without limitation the rights
-to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-copies of the Software, and to permit persons to whom the Software is
-furnished to do so, subject to the following conditions:
-
-The above copyright notice and this permission notice shall be included in all
-copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
-SOFTWARE.
+YEAR: 2018-2019
+COPYRIGHT HOLDER: Kompetenzzentrum Wasser Berlin gGmbH (KWB)
diff --git a/LICENSE.md b/LICENSE.md
index 225cf96..9d82b63 100644
--- a/LICENSE.md
+++ b/LICENSE.md
@@ -1,6 +1,6 @@
# MIT License
-Copyright (c) 2018 Kompetenzzentrum Wasser Berlin gGmbH (KWB)
+Copyright (c) 2018-2019 Kompetenzzentrum Wasser Berlin gGmbH (KWB)
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
diff --git a/NEWS.md b/NEWS.md
index 6b6e6f9..034eb7d 100644
--- a/NEWS.md
+++ b/NEWS.md
@@ -1,25 +1,27 @@
-* current development version
+# [kwb.pkgbuild 0.1.2](https://github.com/KWB-R/kwb.pkgbuild/releases/tag/v0.1.2) 2019-09-17
+
+* Fixed MIT LICENSE creation for CRAN (#60)
# [kwb.pkgbuild 0.1.1](https://github.com/KWB-R/kwb.pkgbuild/releases/tag/v0.1.1) 2019-09-06
-* use .md instead of .Rmd due to changed workflow in pkgdown v1.4 (see: [r-lib/pkgdown#1136](https://github.com/r-lib/pkgdown/issues/1136))
+* Use .md instead of .Rmd due to changed workflow in pkgdown v1.4 (see: [r-lib/pkgdown#1136](https://github.com/r-lib/pkgdown/issues/1136))
# [kwb.pkgbuild 0.1.0](https://github.com/KWB-R/kwb.pkgbuild/releases/tag/v0.1.0) 2019-09-04
-* improved use in case of an existing R package (by reading information from
+* Improved use in case of an existing R package (by reading information from
DESCRIPTION file with function `kwb.pkgbuild::read_description`)
-* improved documentation generation (closes #6)
+* Improved documentation generation (closes #6)
- + changed `README.Rmd` to `index.Rmd` (used by `pkgdown::build_home`) and added
+ + Changed `README.Rmd` to `index.Rmd` (used by `pkgdown::build_home`) and added
"Installation" chapter
- + added "Installation" chapter in `README.md` for Github repo site
+ + Added "Installation" chapter in `README.md` for Github repo site
-* automatically convert package title to Title Case with `tools::toTitleCase()`
+* Automatically convert package title to Title Case with `tools::toTitleCase()`
-* added a `NEWS.md` file to track changes to the package.
+* Added a `NEWS.md` file to track changes to the package.
-* see http://style.tidyverse.org/news.html for writing a good `NEWS.md`
+* See http://style.tidyverse.org/news.html for writing a good `NEWS.md`
diff --git a/R/use_mit_license.R b/R/use_mit_license.R
index ae3b05e..994306d 100644
--- a/R/use_mit_license.R
+++ b/R/use_mit_license.R
@@ -8,29 +8,46 @@
#' @importFrom usethis use_mit_license
#' @importFrom stringr str_detect
#' @importFrom fs file_copy
+#' @importFrom kwb.utils catAndRun
#' @export
use_mit_license <- function(
copyright_holder = list(name = kwb_string(), start_year = NULL)
)
{
- cat("Creating KWB MIT LICENSE file....\n")
- usethis::use_mit_license(name = copyright_holder$name)
+ kwb.utils::catAndRun("Creating KWB MIT LICENSE/LICENSE.md files",
+ expr = {
+ usethis::use_mit_license(name = copyright_holder$name)})
+
+
+ copyright_years <- ifelse(!is.null(copyright_holder$start_year),
+ sprintf("%s-%s", as.character(copyright_holder$start_year),
+ format(Sys.Date(), format = "%Y")),
+ format(Sys.Date(), format = "%Y"))
if (! is.null(copyright_holder$start_year)) {
+ kwb.utils::catAndRun("Modifying start year in MIT LICENSE (CRAN version)",
+ expr = {
+ writeLines(text = sprintf("YEAR: %s\nCOPYRIGHT HOLDER: %s",
+ copyright_years,
+ copyright_holder$name),
+ con = "LICENSE")
+ })
+
+ kwb.utils::catAndRun("Modifying start year in MIT LICENSE.md",
+ expr = {
lic_txt <- readLines("LICENSE.md")
index <- stringr::str_detect(lic_txt,pattern = "^Copyright\\s+\\(c\\)")
lic_txt[index] <- sprintf(
- "Copyright (c) %s-%s %s",
- as.character(copyright_holder$start_year),
- format(Sys.Date(), format = "%Y"),
+ "Copyright (c) %s %s",
+ copyright_years,
copyright_holder$name
)
- writeLines(lic_txt, "LICENSE.md")
+ writeLines(lic_txt, "LICENSE.md")})
+
+
}
- fs::file_copy("LICENSE.md", "LICENSE", overwrite = TRUE)
- cat("Creating MIT LICENSE file....done.\n")
}
diff --git a/tests/testthat/test-function-use_mit_license.R b/tests/testthat/test-function-use_mit_license.R
index b0dfe0d..c912596 100644
--- a/tests/testthat/test-function-use_mit_license.R
+++ b/tests/testthat/test-function-use_mit_license.R
@@ -2,10 +2,19 @@
# This test file has been generated by kwb.test::create_test_files()
#
-test_that("use_mit_license() works", {
+test_that("use_mit_license() works with defaults", {
+ withr::with_dir(create_pkg_temp(), {
+ usethis::proj_set(getwd())
+ kwb.pkgbuild::use_description()
+ kwb.pkgbuild:::use_mit_license()})
+})
+
+
+test_that("use_mit_license() works with defined start_year", {
withr::with_dir(create_pkg_temp(), {
usethis::proj_set(getwd())
kwb.pkgbuild::use_description()
cph <- list(name = kwb.pkgbuild:::kwb_string(), start_year = 2018)
kwb.pkgbuild:::use_mit_license(copyright_holder = cph)})
})
+