diff --git a/DESCRIPTION b/DESCRIPTION index 5d2e2486..afcbe3c6 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,8 +1,8 @@ Package: bio Type: Package Title: Resources Manager for R, RStudio and Related Software -Version: 0.2.5 -Date: 2024-05-27 +Version: 0.2.6 +Date: 2024-07-31 Authors@R: person("Vilmantas", "Gegzna", role = c("aut", "cre"), comment = c(ORCID = "0000-0002-9500-5167"), @@ -18,12 +18,13 @@ Language: en-US Encoding: UTF-8 LazyData: true Roxygen: list(markdown = TRUE) -RoxygenNote: 7.3.1 +RoxygenNote: 7.3.2 Additional_repositories: https://mokymai.github.io/download/ Imports: backup.tools (>= 0.0.3), checkmate, + cli, clipr, crayon, desc, diff --git a/R/packages--check.R b/R/packages--check.R index a3c1eb38..41bd257e 100644 --- a/R/packages--check.R +++ b/R/packages--check.R @@ -208,7 +208,8 @@ read_pkgs_list <- function(list_name, "It seems that there is no online version of list ", "{list_name_blue} or it cannot be accessed. ", "\nCheck if the list name is correct. ", - "Did you mean one of: \n{usethis::ui_value(bio::get_pkg_lists_local())}, ..." + "Did you mean one of: \n", + "{usethis::ui_value(bio::get_pkg_lists_local())}, ..." )) } else { usethis::ui_stop(w$message) @@ -239,7 +240,8 @@ get_path_pkgs_list <- function(list_name, local_list) { usethis::ui_stop(paste0( "List {list_name_blue} was not found on your computer. \n", "Check if the list name is correct. ", - "Did you mean one of: \n{usethis::ui_value(bio::get_pkg_lists_local())}, ..." + "Did you mean one of: \n", + "{usethis::ui_value(bio::get_pkg_lists_local())}, ..." )) } @@ -475,7 +477,8 @@ merge_pkgs_status_lists <- function(pkgs_list, pkgs_installed, #' head(get_pkgs_installation_status_raw("mini")) get_pkgs_installation_status_raw <- function(list_name = NULL, pkgs = NULL, local_list = getOption( - "bio.local_list", TRUE)) { + "bio.local_list", TRUE + )) { checkmate::assert_character(list_name, null.ok = TRUE) checkmate::assert_character(pkgs, null.ok = TRUE) if (is.null(list_name) && is.null(pkgs)) { @@ -508,7 +511,6 @@ get_pkgs_installation_status_raw <- function(list_name = NULL, pkgs = NULL, - # Installation status -------------------------------------------------------- # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # diff --git a/R/paths-and-files.R b/R/paths-and-files.R index 2381fa80..8b207f71 100644 --- a/R/paths-and-files.R +++ b/R/paths-and-files.R @@ -195,7 +195,7 @@ get_path_rstudio_internal_state_dir <- function(..., .check = FALSE) { # Linux/Mac: ~/.rstudio-desktop - if (rstudioapi::isAvailable() && rstudioapi::versionInfo()$version >= 1.4) { + if (rstudioapi::isAvailable() && rstudioapi::versionInfo()$version >= "1.4") { # RStudio 1.4 base <- switch(get_os_type(), diff --git a/R/programs.R b/R/programs.R index ce24625d..1244b085 100644 --- a/R/programs.R +++ b/R/programs.R @@ -41,7 +41,7 @@ check_user_info <- function() { #' @param skip_online_check (logical) If `TRUE`, the numbers of newest available #' stable programs are downloaded, when internet connection is connected. #' @param type (character) Which programs should be checked? Options: -#' `main`, `all`, `gmc-bs`, `gmc-r`. +#' `main`, `all`, `dev`, `gmc-bs`, `gmc-r`. #' #' @return #' Invisible `NULL`. @@ -64,7 +64,7 @@ check_installed_programs <- function(type = "main", skip_online_check = FALSE) { type_lwr <- tolower(type) - if (!type_lwr %in% c("main", "all", "gmc-bs", "gmc-r")) { + if (!type_lwr %in% c("main", "dev", "all", "gmc-bs", "gmc-r")) { ui_warn("Unknown value of type = '{type}'") } @@ -92,17 +92,17 @@ check_installed_programs <- function(type = "main", skip_online_check = FALSE) { "R Build Tools" } - check_tool_installed( - tool_name, - if (rstudioapi::isAvailable()) { - # Requires RStudio to be running - rstudioapi::buildToolsCheck() - } else { - pkgbuild::has_build_tools() - } - ) - - + if (type_lwr %in% c("all", "dev")) { + check_tool_installed( + tool_name, + if (rstudioapi::isAvailable()) { + # Requires RStudio to be running + rstudioapi::buildToolsCheck() + } else { + pkgbuild::has_build_tools() + } + ) + } # XQuartz (on Mac) if (type_lwr %in% c("all", "gmc-bs")) { @@ -177,14 +177,11 @@ get_available_r_version <- function(force = FALSE, skip = FALSE) { purrr::reduce(c) %>% stringr::str_extract("(?<=R-).\\d*[.].\\d*[.]\\d*(?=.tar.gz)") %>% .[!is.na(.)] %>% - numeric_version() %>% + as.numeric_version() %>% max() } else { - ui_warn(paste( - "To get the newest availableR version, network connection is required.", - "You are offline. " - )) + msg_offline(get_what = "R version") NULL } } @@ -202,28 +199,30 @@ get_available_rs_version <- function(force = FALSE, skip = FALSE) { readr::read_lines() %>% stringr::str_extract("(?<=RStudio-).*?(?=.exe)") %>% .[!is.na(.)] %>% - numeric_version() %>% + as.numeric_version() %>% max() } else { - ui_warn(paste( - "To get the newest available RStudio version,", - "network connection is required. You are offline. " - )) + msg_offline(get_what = "RStudio version") } } # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -check_internet_connection <- function() { +msg_offline <- function(get_what = "versions") { + cli::cli_warn(c( + "To get the newest available {get_what}, network connection is required.", + "x" = "This computer is offline. " + )) +} + +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +check_internet_connection <- function(get_what = "versions") { if (pingr::is_online()) { FALSE # Online } else { - ui_warn(paste0( - "To get the newest available versions, network connection is required. ", - "You are offline. " - )) + msg_offline(get_what = get_what) TRUE # Offline } } @@ -238,8 +237,8 @@ check_program_version <- function(name = "", v_installed = NULL, r_color <- red install_status <- "" - v_recommended <- numeric_version(v_recommended) - v_installed <- numeric_version(v_installed) + v_recommended <- as.numeric_version(v_recommended) + v_installed <- as.numeric_version(v_installed) if (!is.null(v_available)) { diff --git a/README.Rmd b/README.Rmd index c4776cc0..72a04599 100644 --- a/README.Rmd +++ b/README.Rmd @@ -39,8 +39,8 @@ Convenience functions to facilitate installation and management of required reso