@@ -85,62 +85,62 @@ create_template <- function(path, name, common_objects, modules, author,
8585 # Check inputs ====
8686
8787 if (! is.character(path )){
88- logger % > % writeLog(type = " error" , " path must be a character string" )
88+ logger | > writeLog(type = " error" , " path must be a character string" )
8989 return ()
9090 }
9191
9292 if (! dir.exists(path )){
93- logger % > % writeLog(type = " error" , " The specified path does not exist" )
93+ logger | > writeLog(type = " error" , " The specified path does not exist" )
9494 return ()
9595 }
9696
9797 if (! is.character(name )){
98- logger % > % writeLog(type = " error" , " name must be a character string" )
98+ logger | > writeLog(type = " error" , " name must be a character string" )
9999 return ()
100100 }
101101
102102 if (grepl(" ^[A-Za-z0-9]+$" , name , perl = TRUE ) == FALSE ){
103- logger % > % writeLog(type = " error" , " Package names can only contain letters and numbers" )
103+ logger | > writeLog(type = " error" , " Package names can only contain letters and numbers" )
104104 return ()
105105 }
106106
107107 if (grepl(" ^[0-9]+$" , substr(name , 1 , 1 ), perl = TRUE ) == TRUE ){
108- logger % > % writeLog(type = " error" , " Package names cannot start with numbers" )
108+ logger | > writeLog(type = " error" , " Package names cannot start with numbers" )
109109 return ()
110110 }
111111
112112 online <- curl :: has_internet()
113113
114114 if (online ) {
115115 if (name %in% tools :: CRAN_package_db()[, c(" Package" )]) {
116- logger % > % writeLog(type = " error" , " A package on CRAN already uses that name" )
116+ logger | > writeLog(type = " error" , " A package on CRAN already uses that name" )
117117 return ()
118118 }
119119 } else {
120- logger % > % writeLog(type = " warning" , " You are not online so your package name could
120+ logger | > writeLog(type = " warning" , " You are not online so your package name could
121121 not be checked against existing CRAN packages" )
122122 }
123123
124124 if (dir.exists(file.path(path , name ))){
125- logger % > % writeLog(type = " error" , " The specified app directory already exists" )
125+ logger | > writeLog(type = " error" , " The specified app directory already exists" )
126126 return ()
127127 }
128128
129129 if (! is.vector(common_objects ) || ! is.character(common_objects )){
130- logger % > % writeLog(type = " error" , " common_objects must be a vector of character strings" )
130+ logger | > writeLog(type = " error" , " common_objects must be a vector of character strings" )
131131 return ()
132132 }
133133
134134 if (any(common_objects %in% c(" meta" , " logger" , " state" , " poly" , " tasks" ))){
135135 conflicts <- common_objects [common_objects %in% c(" meta" , " logger" , " state" , " poly" , " tasks" , " reset" )]
136136 conflicts <- paste(conflicts , collapse = " ," )
137- logger % > % writeLog(type = " error" , glue :: glue(" common_objects contains {conflicts} which are included
137+ logger | > writeLog(type = " error" , glue :: glue(" common_objects contains {conflicts} which are included
138138 in common by default. Please choose a different name." ))
139139 return ()
140140 }
141141
142142 if (! is.data.frame(modules )){
143- logger % > % writeLog(type = " error" , " modules must be a dataframe" )
143+ logger | > writeLog(type = " error" , " modules must be a dataframe" )
144144 return ()
145145 }
146146
@@ -150,33 +150,33 @@ create_template <- function(path, name, common_objects, modules, author,
150150 missing_column <- module_columns [! (module_columns %in% colnames(modules ))]
151151 missing_column <- paste(missing_column , collapse = " ," )
152152 if (missing_column == " async" ){
153- logger % > % writeLog(type = " warning" , glue :: glue(" As of v0.2.0 the modules dataframe should also contain an async column" ))
153+ logger | > writeLog(type = " warning" , glue :: glue(" As of v0.2.0 the modules dataframe should also contain an async column" ))
154154 modules <- cbind(modules , data.frame (" async" = rep(FALSE , nrow(modules ))))
155155 } else {
156- logger % > % writeLog(type = " error" , glue :: glue(" The modules dataframe must contain the column(s): {missing_column}" ))
156+ logger | > writeLog(type = " error" , glue :: glue(" The modules dataframe must contain the column(s): {missing_column}" ))
157157 return ()
158158 }
159159 }
160160
161161 if (! all(colnames(modules ) %in% module_columns )){
162162 invalid_column <- colnames(modules )[! colnames(modules ) %in% module_columns ]
163163 invalid_column <- paste(invalid_column , collapse = " ," )
164- logger % > % writeLog(type = " error" , glue :: glue(" The modules dataframe contains {invalid_column} which is/are not valid column names" ))
164+ logger | > writeLog(type = " error" , glue :: glue(" The modules dataframe contains {invalid_column} which is/are not valid column names" ))
165165 return ()
166166 }
167167
168168 if (any(modules $ map ) == TRUE && include_map == FALSE ){
169- logger % > % writeLog(type = " info" , " Your modules use a map but you had not included it so changing include_map to TRUE" )
169+ logger | > writeLog(type = " info" , " Your modules use a map but you had not included it so changing include_map to TRUE" )
170170 include_map <- TRUE
171171 }
172172
173173 if (any(modules $ map ) == FALSE && include_map == TRUE ){
174- logger % > % writeLog(type = " error" , " You have included a map but none of your modules use it" )
174+ logger | > writeLog(type = " error" , " You have included a map but none of your modules use it" )
175175 return ()
176176 }
177177
178178 if (any(modules $ result ) == FALSE ){
179- logger % > % writeLog(type = " error" , " At least one module must return results" )
179+ logger | > writeLog(type = " error" , " At least one module must return results" )
180180 return ()
181181 }
182182
@@ -187,12 +187,12 @@ create_template <- function(path, name, common_objects, modules, author,
187187 }
188188
189189 if (! is.character(author )){
190- logger % > % writeLog(type = " error" , " author must be a character string" )
190+ logger | > writeLog(type = " error" , " author must be a character string" )
191191 return ()
192192 }
193193
194194 if (! is.logical(c(include_map , include_table , include_code , install ))){
195- logger % > % writeLog(type = " error" , " include_map, include_table,
195+ logger | > writeLog(type = " error" , " include_map, include_table,
196196 include_code & install must be TRUE or FALSE" )
197197 return ()
198198 }
@@ -216,8 +216,7 @@ create_template <- function(path, name, common_objects, modules, author,
216216
217217 if (async ){
218218 import_line <- grep(" *Imports*" , description_lines )
219- description_lines <- append(description_lines , " bslib," , import_line )
220- description_lines <- append(description_lines , " mirai," , import_line + 7 )
219+ description_lines <- append(description_lines , " mirai," , import_line + 6 )
221220 }
222221
223222 if (include_map ){
@@ -509,7 +508,9 @@ create_template <- function(path, name, common_objects, modules, author,
509508
510509 helper_function_params <- c(
511510 file = system.file(" app_skeleton" , " helper_functions.Rmd" , package = " shinyscholar" ),
512- list (include_map = include_map )
511+ list (include_code = include_code ,
512+ include_map = include_map ,
513+ async = async )
513514 )
514515 helper_function_lines <- tidy_purl(helper_function_params )
515516 writeLines(helper_function_lines , file.path(path , " R" , " helper_functions.R" ))
@@ -527,7 +528,8 @@ create_template <- function(path, name, common_objects, modules, author,
527528
528529 # Install package ====
529530 if (install ){
530- devtools :: install_local(path = path , force = TRUE )
531+ devtools :: document(path )
532+ devtools :: install(path , force = TRUE )
531533 }
532534
533535 invisible ()
0 commit comments