Skip to content

Commit

Permalink
Remove crayon and clisymbols in favour of cli.
Browse files Browse the repository at this point in the history
  • Loading branch information
olivroy committed Jun 11, 2024
1 parent 1969854 commit 3ba13bf
Show file tree
Hide file tree
Showing 7 changed files with 33 additions and 34 deletions.
3 changes: 1 addition & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,7 @@ Encoding: UTF-8
Depends: R (>= 2.10)
Imports:
cffr,
clisymbols,
crayon,
cli,
devtools,
gert,
gh,
Expand Down
2 changes: 1 addition & 1 deletion R/add_compendium.R
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ add_compendium <- function(compendium = NULL, quiet = FALSE) {

ui_done(paste0("Adding a {ui_value('README.md')} to ",
"{ui_value(paste0(compendium[i], '/'))} directory"))
ui_line()
cli::cat_line()
}
}
}
Expand Down
18 changes: 9 additions & 9 deletions R/add_dependencies.R
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ add_dependencies <- function(compendium = NULL) {
"{ui_value('NAMESPACE')}:"))
ui_line("{ui_code(duplicated_deps)}")
ui_todo("You can omit package name when calling these functions")
ui_line()
cli::cat_line()
}


Expand Down Expand Up @@ -192,11 +192,11 @@ add_dependencies <- function(compendium = NULL) {

if (!length(pkgs_in_depends)) {

ui_line(" {clisymbols::symbol$radio_on} No package found")
ui_line(" {cli::symbol$radio_on} No package found")

} else {

ui_line(paste0(" {clisymbols::symbol$radio_on} Found ",
ui_line(paste0(" {cli::symbol$radio_on} Found ",
"{ui_value(length(pkgs_in_depends))} package(s)"))
}

Expand Down Expand Up @@ -226,19 +226,19 @@ add_dependencies <- function(compendium = NULL) {

# Message

ui_line(paste0(" {clisymbols::symbol$radio_on} Found ",
ui_line(paste0(" {cli::symbol$radio_on} Found ",
"{ui_value(length(pkgs_in_imports))} package(s)"))

msg <- paste0("Imports: ", paste0(pkgs_in_imports, collapse = ", "))
ui_line(paste0(" {clisymbols::symbol$radio_on} Adding the following ",
ui_line(paste0(" {cli::symbol$radio_on} Adding the following ",
"line in {ui_value('DESCRIPTION')}: {ui_code(msg)}"))

pkgs_in_imports <- paste0(pkgs_in_imports, collapse = ",\n ")
descr$"Imports" <- paste0("\n ", pkgs_in_imports)

} else {

ui_line(" {clisymbols::symbol$radio_on} No package found")
ui_line(" {cli::symbol$radio_on} No package found")

pos <- which(colnames(descr) == "Imports")
if (length(pos)) descr <- descr[ , -pos]
Expand Down Expand Up @@ -271,11 +271,11 @@ add_dependencies <- function(compendium = NULL) {

# Message

ui_line(paste0(" {clisymbols::symbol$radio_on} Found ",
ui_line(paste0(" {cli::symbol$radio_on} Found ",
"{ui_value(length(pkgs_in_suggests))} package(s)"))

msg <- paste0("Suggests: ", paste0(pkgs_in_suggests, collapse = ", "))
ui_line(paste0(" {clisymbols::symbol$radio_on} Adding the following ",
ui_line(paste0(" {cli::symbol$radio_on} Adding the following ",
"line in {ui_value('DESCRIPTION')}: {ui_code(msg)}"))


Expand All @@ -284,7 +284,7 @@ add_dependencies <- function(compendium = NULL) {

} else {

ui_line(" {clisymbols::symbol$radio_on} No package found")
ui_line(" {cli::symbol$radio_on} No package found")

pos <- which(colnames(descr) %in% c("Suggests", "VignetteBuilder"))
if (length(pos)) descr <- descr[ , -pos]
Expand Down
2 changes: 1 addition & 1 deletion R/add_renv.R
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ add_renv <- function(quiet = FALSE) {
ui_done("Creating {ui_value('renv/')}")
ui_done("Writing {ui_value('.Rprofile')}")
ui_done("Writing {ui_value('renv.lock')}")
ui_line()
cli::cat_line()
ui_todo("Call {ui_code('renv::install()')} to install packages")
ui_todo("Call {ui_code('renv::snapshot()')} to update the lockfile")
}
Expand Down
18 changes: 9 additions & 9 deletions R/new_compendium.R
Original file line number Diff line number Diff line change
Expand Up @@ -409,22 +409,22 @@ new_compendium <- function(compendium = NULL, license = "GPL (>= 2)",
add_to_buildignore(".Rproj.user", quiet = quiet)
add_to_buildignore(".DS_Store", quiet = quiet)

if (!quiet) ui_line()
if (!quiet) cli::cat_line()


## Create DESCRIPTION ----

add_description(given, family, email, orcid, organisation, open = FALSE,
overwrite = overwrite, quiet = quiet)

if (!quiet) ui_line()
if (!quiet) cli::cat_line()


## Add LICENSE ----

add_license(license, given, family, quiet = quiet)

if (!quiet) ui_line()
if (!quiet) cli::cat_line()


## Create folders ----
Expand All @@ -438,7 +438,7 @@ new_compendium <- function(compendium = NULL, license = "GPL (>= 2)",

# if (!quiet) ui_done("Creating {ui_value('man/')} directory")

if (!quiet) ui_line()
if (!quiet) cli::cat_line()


## Package doc bonus ----
Expand All @@ -460,7 +460,7 @@ new_compendium <- function(compendium = NULL, license = "GPL (>= 2)",
overwrite = overwrite))
}

if (!quiet) ui_line()
if (!quiet) cli::cat_line()
if (!quiet) ui_done("Writing {ui_value('R/fun-demo.R')} file")

# suppressMessages(devtools::document(quiet = TRUE))
Expand All @@ -478,7 +478,7 @@ new_compendium <- function(compendium = NULL, license = "GPL (>= 2)",
ui_title("Creating Compendium Folders")

add_compendium(compendium, quiet = quiet)
ui_line()
cli::cat_line()

add_makefile(given, family, email, open = FALSE, overwrite = overwrite,
quiet = quiet)
Expand Down Expand Up @@ -704,7 +704,7 @@ new_compendium <- function(compendium = NULL, license = "GPL (>= 2)",

add_github_actions_pkgdown()

ui_line()
cli::cat_line()

usethis::use_github_pages(branch = "gh-pages")
}
Expand Down Expand Up @@ -858,7 +858,7 @@ new_compendium <- function(compendium = NULL, license = "GPL (>= 2)",

if (!is.null(compendium)) {

ui_line()
cli::cat_line()
ui_todo("Put your data in {ui_value('data/raw-data')} directory")
ui_todo("Write your R scripts in the {ui_value('analyses/')} directory")
ui_todo("Source your R scripts in the {ui_value('make.R')} file")
Expand All @@ -868,7 +868,7 @@ new_compendium <- function(compendium = NULL, license = "GPL (>= 2)",
ui_todo("Export your figures in the {ui_value('figures/')} directory")
}

ui_line()
cli::cat_line()

ui_todo("...and commit your changes!")

Expand Down
14 changes: 7 additions & 7 deletions R/new_package.R
Original file line number Diff line number Diff line change
Expand Up @@ -500,22 +500,22 @@ new_package <- function(license = "GPL (>= 2)", status = NULL,
add_to_buildignore(".Rproj.user", quiet = quiet)
add_to_buildignore(".DS_Store", quiet = quiet)

if (!quiet) ui_line()
if (!quiet) cli::cat_line()


## Create DESCRIPTION ----

add_description(given, family, email, orcid, organisation, open = FALSE,
overwrite = overwrite, quiet = quiet)

if (!quiet) ui_line()
if (!quiet) cli::cat_line()


## Add LICENSE ----

add_license(license, given, family, quiet = quiet)

if (!quiet) ui_line()
if (!quiet) cli::cat_line()


## Create folders ----
Expand All @@ -529,7 +529,7 @@ new_package <- function(license = "GPL (>= 2)", status = NULL,

if (!quiet) ui_done("Creating {ui_value('man/')} directory")

if (!quiet) ui_line()
if (!quiet) cli::cat_line()


## Package doc bonus ----
Expand All @@ -551,7 +551,7 @@ new_package <- function(license = "GPL (>= 2)", status = NULL,
overwrite = overwrite))
}

if (!quiet) ui_line()
if (!quiet) cli::cat_line()
if (!quiet) ui_done("Writing {ui_value('R/fun-demo.R')} file")

suppressMessages(devtools::document(quiet = TRUE))
Expand Down Expand Up @@ -752,7 +752,7 @@ new_package <- function(license = "GPL (>= 2)", status = NULL,

add_github_actions_pkgdown()

ui_line()
cli::cat_line()

usethis::use_github_pages(branch = "gh-pages")
}
Expand Down Expand Up @@ -890,7 +890,7 @@ new_package <- function(license = "GPL (>= 2)", status = NULL,
ui_todo(paste0("Write your units tests in the ",
"{ui_value('tests/testthat/')} directory"))

ui_line()
cli::cat_line()

ui_todo("...and commit your changes!")

Expand Down
10 changes: 5 additions & 5 deletions R/utils-sys.R
Original file line number Diff line number Diff line change
Expand Up @@ -147,11 +147,11 @@ proj_in_proj <- function() {
ui_title <- function(texte) {


ui_line()
cat(clisymbols::symbol$radio_on,
crayon::bold(crayon::underline(texte)))
ui_line()
ui_line()
cli::cat_line()
cat(cli::symbol$radio_on,
cli::style_bold(cli::style_underline(texte)))
cli::cat_line()
cli::cat_line()

invisible(NULL)
}
Expand Down

0 comments on commit 3ba13bf

Please sign in to comment.