@@ -105,16 +105,23 @@ upstream_repo_url_is_outdated <- function() {
105105# ' @param snippet Name of the snippet.
106106# ' @inheritParams fallback_doc
107107# ' @export
108- snippet_generate <- function (snippet = " " , root = here :: here()) {
108+ snippet_generate <- function (snippet = " " ,
109+ open = interactive(),
110+ root = here :: here()) {
109111 rlang :: arg_match(snippet , c(" additional-deps-roxygenize" ))
110112 if (snippet == " additional-deps-roxygenize" ) {
111- rlang :: inform(
112- " Generating snippet using installed versions of all dependencies.\n "
113- )
113+ rlang :: inform(paste(
114+ " Generating snippet using CRAN versions. If you need another source," ,
115+ " specify with syntax that `renv::install()` understands (see examples in" ,
116+ " help file)." ,
117+ " \n "
118+ ))
114119 deps <- desc :: desc_get_deps()
115120 deps <- deps [order(deps $ package ), ]
116121 snippet_generate_impl_additional_deps_roxygenize(deps $ package ) %> %
117122 cat(sep = " " )
123+ cat(" \n " )
124+ cli :: cli_ul(" Copy the above into `.pre-commit-config.yaml`." )
118125 remote_deps <- rlang :: with_handlers(
119126 desc :: desc_get_field(" Remotes" ),
120127 error = function (e ) character ()
@@ -134,16 +141,20 @@ You need in your `.pre-commit-config.yaml`
134141
135142 additional_dependencies:
136143 - tidyverse/tidyr@2fd80d5
137- "
144+
145+ "
138146 ))
139147 }
140148 }
149+ if (open ) {
150+ precommit :: open_config(root )
151+ }
141152}
142153
143- snippet_generate_impl_additional_deps_roxygenize <- function (packages ) {
154+ snippet_generate_impl_additional_deps_roxygenize <- function (packages , with_version = FALSE ) {
144155 out <- paste0(
145- " - " , packages , " @" ,
146- purrr :: map_chr(packages , ~ as.character(packageVersion(.x ))), " \n " ,
156+ " - " , packages , if ( with_version ) " @" ,
157+ if ( with_version ) purrr :: map_chr(packages , ~ as.character(packageVersion(.x ))), " \n " ,
147158 collapse = " "
148159 ) %> %
149160 sort()
0 commit comments