Skip to content

Commit 090a6fc

Browse files
committed
fix: keep the old params for backward compatibility
1 parent 5b9767c commit 090a6fc

File tree

2 files changed

+54
-11
lines changed

2 files changed

+54
-11
lines changed

R/desc.R

+53-10
Original file line numberDiff line numberDiff line change
@@ -17,20 +17,63 @@ fill_desc <- function(
1717
pkg_name,
1818
pkg_title,
1919
pkg_description,
20-
authors = c(person("Angelo",
21-
"Canty",
22-
role = "aut",
23-
comment = "S original, <http://statwww.epfl.ch/davison/BMA/library.html>"),
24-
person(c("Brian", "D."),
25-
"Ripley",
26-
role = c("aut", "trl", "cre"),
27-
comment = "R port",
28-
email = "[email protected]")),
20+
authors = person(
21+
given = NULL,
22+
family = NULL,
23+
email = NULL,
24+
role = NULL,
25+
comment = NULL
26+
),
2927
repo_url = NULL,
3028
pkg_version = "0.0.0.9000",
31-
pkg = get_golem_wd()
29+
pkg = get_golem_wd(),
30+
author_first_name = NULL,
31+
author_last_name = NULL,
32+
author_email = NULL,
33+
author_orcid = NULL
3234
) {
35+
3336
stopifnot(`'authors' must be of class 'person'` = inherits(authors, "person"))
37+
38+
# Handling retrocompatibility
39+
40+
# Case 1 : old author params are not null
41+
any_author_params_is_not_null <- all(
42+
vapply(
43+
list(
44+
author_first_name,
45+
author_last_name,
46+
author_email,
47+
author_orcid
48+
), is.null, logical(1)
49+
)
50+
)
51+
52+
if (!any_author_params_is_not_null) {
53+
warning("The `author_first_name`, `author_last_name`, `author_email` and `author_orcid` parameters will be deprecated from fill_desc() in the next version of {golem}. \nPlease use the `authors` parameter instead.\nSee ?person for more details on how to use it.")
54+
# Case 1.1 : old author params are null and authors is empty
55+
if (length(authors) == 0) {
56+
# We use the old author params to fill the DESCRIPTION file
57+
cli_cli_alert_info(
58+
"the `authors` argument is empty, using `author_first_name`, `author_last_name`, `author_email` and `author_orcid` to fill the DESCRIPTION file."
59+
)
60+
authors <- person(
61+
given = author_first_name,
62+
family = author_last_name,
63+
email = author_email,
64+
role = NULL,
65+
comment = c(ORCID = author_orcid)
66+
)
67+
} else {
68+
# Case 1.2, old author params are null and authors is not empty
69+
# We keep the authors as is
70+
cli_cli_alert_info(
71+
"the `authors` argument is not empty, using it to fill the DESCRIPTION file, the old author params are ignored."
72+
)
73+
}
74+
}
75+
# the else here is the case 2 : old author params are null and authors is set, we keep the authors as is
76+
3477
path <- fs_path_abs(pkg)
3578

3679
desc <- desc_description(

inst/shinyexample/dev/01_start.R

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ golem::fill_desc(
2626
given = "AUTHOR_FIRST", # Your First Name
2727
family = "AUTHOR_LAST", # Your Last Name
2828
email = "[email protected]" # Your email
29-
),
29+
),
3030
repo_url = NULL, # The URL of the GitHub repo (optional),
3131
pkg_version = "0.0.0.9000" # The version of the package containing the app
3232
)

0 commit comments

Comments
 (0)