Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use CC licenses, all of them (follow up to #1855) #1919

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 1 addition & 2 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,7 @@ export(use_bioc_badge)
export(use_blank_slate)
export(use_build_ignore)
export(use_c)
export(use_cc0_license)
export(use_ccby_license)
export(use_cc_license)
export(use_circleci)
export(use_circleci_badge)
export(use_citation)
Expand Down
6 changes: 5 additions & 1 deletion NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@
if your package includes an `upkeep_bullets()` function that returns a
character vector (#1794).

## Licensing improvements

New `use_cc_license()` makes it easier to pick specific versions of the CC licenses. Defaults to CC0 1.0 Universal (CC0 1.0) (@pachadotdev, #1845).

## Package development

* Although nested projects are discouraged, they can be useful in development
Expand Down Expand Up @@ -621,7 +625,7 @@ Patch release to align some path handling internals with an update coming in the

* New `ui_silence()` makes it easier to selectively silence some UI output.

* New `use_agpl3_license()` (@pachamaltese, #870).
* New `use_agpl3_license()` (@pachadotdev, #870).

* New `use_data_table()` to set up a package for Import-ing `data.table`
(@michaelchirico, #897).
Expand Down
69 changes: 66 additions & 3 deletions R/license.R
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,26 @@
#' * [LGPL v3](https://choosealicense.com/licenses/lgpl-3.0/): requires sharing
#' of improvements.
#'
#' Creative commons licenses appropriate for data packages:
#' Creative commons licenses appropriate for data packages and other non-code (i.e.,
#' books):
#' * [CC0](https://creativecommons.org/publicdomain/zero/1.0/): dedicated
#' to public domain.
#' * [CC-BY](https://creativecommons.org/licenses/by/4.0/): Free to share and
#' adapt, must give appropriate credit. Derived works must be shared under the same
#' license.
#' * [CC-BY-SA](https://creativecommons.org/licenses/by-sa/4.0/): Free to share and
#' adapt, must give appropriate credit.
#' * [CC-BY-NC](https://creativecommons.org/licenses/by-nc/4.0/): Free to share and
#' adapt, must give appropriate credit. Commercial purposes are out of scope.
#' * [CC-BY-NC-SA](https://creativecommons.org/licenses/by-nc-sa/4.0/): Free to share and
#' adapt, must give appropriate credit. Commercial purposes are out of scope.
#' Derived works must be shared under the same license.
#' * [CC-BY-ND](https://creativecommons.org/licenses/by-nd/4.0/): Free to share and
#' adapt, must give appropriate credit. Derived works must be shared under the same
#' license.
#' * [CC-BY-NC-ND](https://creativecommons.org/licenses/by-nc-nd/4.0/): Free to
#' share, must give appropriate credit. Commercial purposes and adaptations are
#' out of scope.
#'
#' See <https://choosealicense.com> for more details and other options.
#'
Expand Down Expand Up @@ -117,22 +132,70 @@ use_apache_license <- function(version = 2, include_future = TRUE) {

#' @rdname licenses
#' @export
use_cc_license <- function(version = 0) {
version <- ifelse(version == 0, "0", "version")
switch(
version,
`0` = use_cc0_license(),
`by` = use_ccby_license(),
`by-sa` = use_ccbysa_license(),
`by-nc` = use_ccbync_license(),
`by-nc-sa` = use_ccbyncsa_license(),
`by-nd` = use_ccbynd_license(),
`by-nc-nd` = use_ccbyncnd_license(),
stop("`version` must be one of 0, 'by', 'by-sa', 'by-nc', 'by-nc-sa', 'by-nd', or 'by-nc-nd'")
)
}

use_cc0_license <- function() {
if (is_package()) {
proj_desc_field_update("License", "CC0", overwrite = TRUE)
}
use_license_template("cc0")
}

#' @rdname licenses
#' @export
use_ccby_license <- function() {
if (is_package()) {
proj_desc_field_update("License", "CC BY 4.0", overwrite = TRUE)
}
use_license_template("ccby-4")
}

use_ccbysa_license <- function() {
if (is_package()) {
proj_desc_field_update("License", "CC BY-SA 4.0", overwrite = TRUE)
}
use_license_template("ccbysa-4")
}

use_ccbync_license <- function() {
if (is_package()) {
proj_desc_field_update("License", "CC BY-NC 4.0", overwrite = TRUE)
}
use_license_template("ccbync-4")
}

use_ccbyncsa_license <- function() {
if (is_package()) {
proj_desc_field_update("License", "CC BY-NC-SA 4.0", overwrite = TRUE)
}
use_license_template("ccbyncsa-4")
}

use_ccbynd_license <- function() {
if (is_package()) {
proj_desc_field_update("License", "CC BY-ND 4.0", overwrite = TRUE)
}
use_license_template("ccbynd-4")
}

use_ccbyncnd_license <- function() {
if (is_package()) {
proj_desc_field_update("License", "CC BY-NC-ND 4.0", overwrite = TRUE)
}
use_license_template("ccbyncnd-4")
}

#' @rdname licenses
#' @export
use_proprietary_license <- function(copyright_holder) {
Expand Down