Skip to content

Commit

Permalink
renaming var to GHQC_CONFIG_REPO and updating terminology
Browse files Browse the repository at this point in the history
  • Loading branch information
wes-a2ai committed Nov 19, 2024
1 parent 65a6207 commit 3286518
Show file tree
Hide file tree
Showing 21 changed files with 81 additions and 85 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: ghqc
Title: Manage QC via GitHub Issues using Shiny Apps
Version: 0.1.8
Version: 0.2.0
Authors@R: c(
person("Anne", "Zheng", email = "[email protected]", role = c("aut")),
person("Jenna", "Johnson", email = "[email protected]", role = c("aut")),
Expand Down
2 changes: 1 addition & 1 deletion NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ export(check_ghqc_configuration)
export(check_ghqcapp_dependencies)
export(download_ghqc_configuration)
export(ghqc_assign_app)
export(ghqc_infopath)
export(ghqc_config_path)
export(ghqc_libpath)
export(ghqc_record_app)
export(ghqc_resolve_app)
Expand Down
6 changes: 6 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
# ghqc 0.2.0

- Updated the custom configuration options repository (now `GHQC_OPTIONS_REPO`) check to reflect the following changes:
- The "note" file within the custom configuration repository is now `prepended_checklist_note` within "custom_options.yaml"
- `checklist_display_name_var` in "custom_options.yaml" provides option to change the name in which the QC checklists are referred to as.

# ghqc 0.1.8

- The logic for rejecting `gert` install as part of `setup_ghqc` was incorrect. Updating to allow for rejection
Expand Down
4 changes: 2 additions & 2 deletions R/checklist_validation.R
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#' @importFrom fs dir_ls
validate_checklists <- function(info_path = ghqc_infopath()) {
validate_checklists <- function(info_path = ghqc_config_path()) {
if (!fs::dir_exists(file.path(info_path, "checklists"))) return(invisible())
checklist_ls <- fs::dir_ls(file.path(info_path, "checklists"), regexp = "(.*?).yaml")
lapply(checklist_ls, function(x) val_checklist(x))
Expand All @@ -21,7 +21,7 @@ val_checklist <- function(checklist) {
list(valid = TRUE, reason = NA)
}

invalidate_checklists <- function(info_path = ghqc_infopath()) {
invalidate_checklists <- function(info_path = ghqc_config_path()) {
check_structure <- validate_checklists(info_path)
sapply(names(check_structure), function(x) invalid_checklist_rename(x, check_structure[[x]]$valid))
}
Expand Down
46 changes: 18 additions & 28 deletions R/info_repo.R
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
#' Check the content of the downloaded ghqc configuration information repository and download any updates needed
#'
#' @param info_path *(optional)* path in which the repository, set in environmental variable `GHQC_INFO_REPO`, is, or should be, downloaded to. Defaults to `~/.local/share/ghqc/{repo_name}`
#' @param info_path *(optional)* path in which the repository, set in environmental variable `GHQC_CONFIG_REPO`, is, or should be, downloaded to. Defaults to `~/.local/share/ghqc/{repo_name}`
#'
#' @importFrom cli cli_abort
#' @export
check_ghqc_configuration <- function(info_path = ghqc_infopath()) {
check_ghqc_configuration <- function(info_path = ghqc_config_path()) {
if (!interactive()) cli::cli_abort("Attempting to run in non-interactive function. Use {.code download_ghqc_configuration()} in non-interactive sections")
check_ghqc_info_repo_exists()
switch(info_repo_status(info_path),
Expand All @@ -15,12 +15,12 @@ check_ghqc_configuration <- function(info_path = ghqc_infopath()) {
)
}

#' Download the customizing information repository as set in environmental variable `GHQC_INFO_REPO`
#' Download the customizing information repository as set in environmental variable `GHQC_CONFIG_REPO`
#'
#' @param info_path *(optional)* path in which the repository, set in environmental variable `GHQC_INFO_REPO`, is, or should be, downloaded to. Defaults to `~/.local/share/ghqc/{repo_name}`
#' @param info_path *(optional)* path in which the repository, set in environmental variable `GHQC_CONFIG_REPO`, is, or should be, downloaded to. Defaults to `~/.local/share/ghqc/{repo_name}`
#' @param .force *(optional)* option to force a new download of the ghqc configuration information repository
#' @export
download_ghqc_configuration <- function(info_path = ghqc_infopath(), .force = FALSE) {
download_ghqc_configuration <- function(info_path = ghqc_config_path(), .force = FALSE) {
check_ghqc_info_repo_exists()
switch(info_repo_status(info_path, .force),
"clone" = repo_clone(info_path),
Expand All @@ -30,7 +30,7 @@ download_ghqc_configuration <- function(info_path = ghqc_infopath(), .force = FA
)
}
#' Remove the downloaded customizing information repository from `info_path`
#' @param info_path *(optional)* path in which the repository, set in environmental variable `GHQC_INFO_REPO`, is, or should be, downloaded to. Defaults to `~/.local/share/ghqc/{repo_name}`
#' @param info_path *(optional)* path in which the repository, set in environmental variable `GHQC_CONFIG_REPO`, is, or should be, downloaded to. Defaults to `~/.local/share/ghqc/{repo_name}`
#'
#' @return this function is used for its effects, but will return the removed `info_path`
#'
Expand All @@ -41,7 +41,7 @@ download_ghqc_configuration <- function(info_path = ghqc_infopath(), .force = FA
#' @importFrom fs dir_delete
#'
#' @export
remove_ghqc_configuration <- function(info_path = ghqc_infopath()) {
remove_ghqc_configuration <- function(info_path = ghqc_config_path()) {
cli::cli_inform("Removing downloaded custom configuration in {info_path}...")
tryCatch({
if (fs::dir_exists(info_path)) fs::dir_delete(info_path)
Expand Down Expand Up @@ -71,7 +71,7 @@ remote_repo_updates <- function(info_path) {

#' @importFrom cli cli_alert_danger
prompt_repo_clone <- function(info_path) {
cli::cli_alert_danger(sprintf("Info repository %s is not found locally", basename(info_path)))
cli::cli_alert_danger(sprintf("Custom configuration repository %s is not found locally", basename(info_path)))
yN <- readline(prompt = "Would you like to download the repository (y/N)? ")
if (yN == "y") {
repo_clone(info_path)
Expand All @@ -84,7 +84,7 @@ prompt_repo_clone <- function(info_path) {
#' @importFrom cli cli_alert_warning
#' @importFrom cli cli_alert_danger
prompt_repo_update <- function(info_path) {
cli::cli_alert_warning(sprintf("Info repository %s was found locally, but is not the most recent version", basename(info_path)))
cli::cli_alert_warning(sprintf("Custom configuration repository %s was found locally, but is not the most recent version", basename(info_path)))
yN <- readline(prompt = glue::glue("Would you like to update the repository. This will delete all local changes to {info_path} (y/N)? "))
if (yN == "y") {
repo_clone(info_path)
Expand Down Expand Up @@ -123,7 +123,7 @@ repo_clone <- function(info_path) {
#' @importFrom cli cli_inform
no_updates <- function(info_path) {
invalidate_checklists(info_path)
cli::cli_inform("Configuration Information Repository found up to date at {info_path}")
cli::cli_inform("Custom Configuration Repository found up to date at {info_path}")
info_files_desc(info_path)
}

Expand All @@ -132,13 +132,13 @@ no_updates <- function(info_path) {
#' @importFrom cli cli_inform
#' @importFrom cli cli_alert_warning
no_gert_found <- function(info_path) {
cli::cli_inform("Configuration Information Repository at {info_path}")
cli::cli_inform("Custom configuration Repository at {info_path}")
info_files_desc(info_path)
cli::cli_inform("")
cli::cli_alert_warning("Package 'gert' (>= 1.5.0) was not installed to check if information repository is up to date")
cli::cli_alert_warning("Package 'gert' (>= 1.5.0) was not installed to check if custom configuration repository is up to date")
}

# info repo description #
# Custom configuration repo description #
#' @importFrom fs file_exists
#' @importFrom cli cli_alert_success
#' @importFrom cli cli_alert_danger
Expand All @@ -156,7 +156,7 @@ info_files_desc <- function(info_path) {
if (fs::file_exists(repo_files[2])) {
custom_options_found(repo_files[2])
} else {
cli::cli_alert_info(paste0(cli::col_blue("custom_options.yaml"), " not found"))
cli::cli_alert_info(paste0(cli::col_blue("custom_options.yaml"), " not found. This file is not required."))
cli::cli_inform("")
}

Expand Down Expand Up @@ -234,10 +234,10 @@ checklists_found <- function(info_path) {
check_ghqc_info_repo_exists <- function() {
if (!fs::file_exists("~/.Renviron")) info_repo_not_found()
readRenviron("~/.Renviron")
info_repo <- Sys.getenv("GHQC_INFO_REPO")
info_repo <- Sys.getenv("GHQC_CONFIG_REPO")
if (info_repo == "") info_repo_not_found()
if (substr(info_repo, 1, 8) != "https://") {
cli::cli_abort("GHQC_INFO_REPO ({info_repo}) does not start with 'https://'")
cli::cli_abort("GHQC_CONFIG_REPO ({info_repo}) does not start with 'https://'")
}
}

Expand All @@ -247,20 +247,10 @@ info_repo_name <- function() {

info_repo_url <- function() {
check_ghqc_info_repo_exists()
Sys.getenv("GHQC_INFO_REPO")
Sys.getenv("GHQC_CONFIG_REPO")
}

#' @importFrom cli cli_abort
info_repo_not_found <- function() {
cli::cli_abort(message = "GHQC_INFO_REPO not found. Please set in ~/.Renviron")
}

f <- function() {
cli::cli_div(theme = list(ul = list(`margin-left` = 2, before = "")))
cli::cli_alert_success("logo.png successfully found")
ul <- cli::cli_ul()
cli::cli_alert_success("a")
cli::cli_blockquote("asdfasdfasdf")
cli::cli_alert_success("b")
cli::cli_end(ul)
cli::cli_abort(message = "GHQC_CONFIG_REPO not found. Please set in ~/.Renviron")
}
22 changes: 11 additions & 11 deletions R/interactive_setup.R
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,13 @@ interactive_renviron <- function() {
#' @importFrom cli cli_inform
#' @importFrom glue glue
interactive_info <- function(renv_text) {
info <- parse_renviron("GHQC_INFO_REPO", renv_text)
info <- parse_renviron("GHQC_CONFIG_REPO", renv_text)
if (info$val == "") {
cli::cli_inform(c(" ", "GHQC_INFO_REPO is not set in your ~/.Renviron"))
info_read <- readline("Provide the URL to the configuring information repository: ")
cli::cli_inform(c(" ", "GHQC_CONFIG_REPO is not set in your ~/.Renviron"))
info_read <- readline("Provide the URL to the custom configuration repository: ")
} else {
cli::cli_inform(c(" ", "GHQC_INFO_REPO is set to {info$val} in your ~/.Renviron"))
info_read <- readline(glue::glue("Customizing Information Repository ({info$val}) "))
cli::cli_inform(c(" ", "GHQC_CONFIG_REPO is set to {info$val} in your ~/.Renviron"))
info_read <- readline(glue::glue("Custom Configuration Repository ({info$val}) "))
if (info_read == "") info_read <- info$val
}
repeat {
Expand All @@ -42,9 +42,9 @@ interactive_info <- function(renv_text) {
info$val <- info_read
break
}
info_read <- readline(glue::glue("GHQC_INFO_REPO does not start with 'https:'. Please provide a valid URL: "))
info_read <- readline(glue::glue("GHQC_CONFIG_REPO does not start with 'https:'. Please provide a valid URL: "))
}
renviron_edit("GHQC_INFO_REPO", info$val, renv_text)
renviron_edit("GHQC_CONFIG_REPO", info$val, renv_text)
}

write_renv_text <- function(renv_text, val, var_name) {
Expand All @@ -58,10 +58,10 @@ write_renv_text <- function(renv_text, val, var_name) {
#' @importFrom cli cli_alert_danger
#' @importFrom glue glue
interactive_info_download <- function() {
cli::cli_h1("CONFIGURING INFORMATION REPOSITORY")
cli::cli_h1("CUSTOM CONFIGURATION REPOSITORY")
if (!rlang::is_installed("gert")) {
cli::cli_inform(c("!" = "Package {.code gert} is not found in your project package library",
" " = "The configuration information repository cannot be downloaded unless this package is present"))
" " = "The custom configuration repository cannot be downloaded unless this package is present"))
yN <- gsub('\"', "", readline("Would you like to install `gert` to continue? (y/N) "))
if (yN != "y" || yN == "") {
cli::cli_alert_danger("`gert` is not installed. Configuring information repository cannot be checked or downloaded using this package")
Expand All @@ -71,8 +71,8 @@ interactive_info_download <- function() {
}

cli::cli_inform(" ")
info_path <- gsub('\"', "", readline(glue::glue("Path to download the configuration information repository ({ghqc_infopath()}) ")))
if (info_path == "") info_path <- ghqc_infopath()
info_path <- gsub('\"', "", readline(glue::glue("Path to download the custom configuration repository ({ghqc_config_path()}) ")))
if (info_path == "") info_path <- ghqc_config_path()

cli::cli_inform(" ")
check_ghqc_configuration(info_path = info_path)
Expand Down
6 changes: 3 additions & 3 deletions R/setup_renviron.R
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
#' helper function to setup/write Renviron file for ghqc
#'
#' @param GHQC_INFO_REPO Repository URL to the customizing information repository
#' @param GHQC_CONFIG_REPO Repository URL to the customizing information repository
#'
#' @return This function is used primarly to write to the ~/.Renviron file. It will return the text contained in ~/.Renviron
#' @export
setup_ghqc_renviron <- function(GHQC_INFO_REPO) {
setup_ghqc_renviron <- function(GHQC_CONFIG_REPO) {
renv_text <- renviron_text()

renv_text <- renviron_edit("GHQC_INFO_REPO", GHQC_INFO_REPO, renv_text)
renv_text <- renviron_edit("GHQC_CONFIG_REPO", GHQC_CONFIG_REPO, renv_text)
writeLines(renv_text, "~/.Renviron")
invisible(renv_text)
}
Expand Down
10 changes: 5 additions & 5 deletions R/sitrep.R
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
#' @export
ghqc_sitrep <- function(...,
lib_path = ghqc_libpath(),
info_path = ghqc_infopath()){
info_path = ghqc_config_path()){
inputs <- c(...)

cli::cli_h1("Package Dependencies")
Expand All @@ -31,7 +31,7 @@ ghqc_sitrep <- function(...,
info_repo_section = TRUE
}, error = function(e) {
info_repo_section = FALSE
}) # if info_path not self set AND GHQC_INFO_REPO not set, section will be ommitted
}) # if info_path not self set AND GHQC_CONFIG_REPO not set, section will be ommitted
if (info_repo_section){
cli::cli_h1("Information Repository")
sitrep_info_check(info_path)
Expand Down Expand Up @@ -105,16 +105,16 @@ ghqcapp_pkg_status <- function(lib_path) {
sitrep_renviron_check <- function() {
sysenv <- sitrep_read_renviron()
ifelse(sysenv == "",
cli::cli_alert_danger("GHQC_INFO_REPO is not set in ~/.Renviron"),
cli::cli_alert_success("GHQC_INFO_REPO is set to {sysenv}"))
cli::cli_alert_danger("GHQC_CONFIG_REPO is not set in ~/.Renviron"),
cli::cli_alert_success("GHQC_CONFIG_REPO is set to {sysenv}"))
invisible(NA)
}

#' @importFrom fs file_exists
sitrep_read_renviron <- function() {
if (fs::file_exists("~/.Renviron")) {
readRenviron("~/.Renviron")
Sys.getenv("GHQC_INFO_REPO")
Sys.getenv("GHQC_CONFIG_REPO")
} else {
""
}
Expand Down
6 changes: 3 additions & 3 deletions R/utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ ghqc_libpath <- function() {
lib_path
}

#' The default install location for the ghqc customizing information repository
#' The default install location for the ghqc custom configuration repository
#'
#' @return string containing the default path to the ghqc information repository (~/.local/share/ghqc/&lt;info repo name here&gt;
#' @return string containing the default path to the ghqc custom configuration repository (~/.local/share/ghqc/&lt;config repo name here&gt;
#' @export
ghqc_infopath <- function() {
ghqc_config_path <- function() {
file.path("~/.local/share/ghqc", info_repo_name())
}
6 changes: 3 additions & 3 deletions R/wrappers.R
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
ghqc_assign_app <- function(app_name = "ghqc_assign_app",
qc_dir = getwd(),
lib_path = ghqc_libpath(),
info_path = ghqc_infopath()) {
info_path = ghqc_config_path()) {
run_app(app_name = app_name,
qc_dir = qc_dir,
lib_path = lib_path,
Expand Down Expand Up @@ -74,7 +74,7 @@ ghqc_assign_app <- function(app_name = "ghqc_assign_app",
ghqc_resolve_app <- function(app_name = "ghqc_resolve_app",
qc_dir = getwd(),
lib_path = ghqc_libpath(),
info_path = ghqc_infopath()) {
info_path = ghqc_config_path()) {
run_app(app_name = app_name,
qc_dir = qc_dir,
lib_path = lib_path,
Expand Down Expand Up @@ -117,7 +117,7 @@ ghqc_resolve_app <- function(app_name = "ghqc_resolve_app",
ghqc_record_app <- function(app_name = "ghqc_record_app",
qc_dir = getwd(),
lib_path = ghqc_libpath(),
info_path = ghqc_infopath()) {
info_path = ghqc_config_path()) {
run_app(app_name = app_name,
qc_dir = qc_dir,
lib_path = lib_path,
Expand Down
Binary file added avail_pkgs_wes.RDS
Binary file not shown.
4 changes: 2 additions & 2 deletions man/check_ghqc_configuration.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions man/download_ghqc_configuration.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion man/ghqc_assign_app.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 14 additions & 0 deletions man/ghqc_config_path.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 3286518

Please sign in to comment.