From b0ea1bab5fa0dfaa4985f2769d659874dca29a3a Mon Sep 17 00:00:00 2001 From: Jon Harmon Date: Thu, 28 Mar 2024 16:48:49 -0500 Subject: [PATCH] Overdo importFrom I'll probably want to back off from this, won't I? --- NAMESPACE | 3 +++ R/beekeeper-package.R | 3 +++ R/generate_pkg-paths.R | 4 ++-- R/generate_pkg-prepare.R | 10 +++++----- R/generate_pkg-template.R | 4 ++-- man/dot-is_pkg.Rd | 2 +- 6 files changed, 16 insertions(+), 10 deletions(-) diff --git a/NAMESPACE b/NAMESPACE index aaba9b3..701cb57 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -11,6 +11,8 @@ importFrom(cli,cli_abort) importFrom(cli,cli_warn) importFrom(desc,desc) importFrom(dplyr,filter) +importFrom(fs,file_delete) +importFrom(fs,file_exists) importFrom(fs,is_dir) importFrom(fs,path) importFrom(fs,path_dir) @@ -23,6 +25,7 @@ importFrom(lubridate,now) importFrom(lubridate,parse_date_time) importFrom(nectar,call_api) importFrom(nectar,stabilize_string) +importFrom(purrr,imap_chr) importFrom(purrr,list_rbind) importFrom(purrr,map) importFrom(purrr,map2) diff --git a/R/beekeeper-package.R b/R/beekeeper-package.R index b9af329..d870576 100644 --- a/R/beekeeper-package.R +++ b/R/beekeeper-package.R @@ -6,6 +6,8 @@ #' @importFrom cli cli_warn #' @importFrom desc desc #' @importFrom dplyr filter +#' @importFrom fs file_delete +#' @importFrom fs file_exists #' @importFrom fs is_dir #' @importFrom fs path #' @importFrom fs path_dir @@ -18,6 +20,7 @@ #' @importFrom lubridate parse_date_time #' @importFrom nectar call_api #' @importFrom nectar stabilize_string +#' @importFrom purrr imap_chr #' @importFrom purrr list_rbind #' @importFrom purrr map #' @importFrom purrr map_chr diff --git a/R/generate_pkg-paths.R b/R/generate_pkg-paths.R index dadbe2f..c058f9c 100644 --- a/R/generate_pkg-paths.R +++ b/R/generate_pkg-paths.R @@ -23,13 +23,13 @@ NULL } .generate_paths_files <- function(paths_by_tag, api_abbr, security_data) { - paths_file_paths <- purrr::imap_chr( + paths_file_paths <- imap_chr( paths_by_tag, function(path_tag, path_tag_name) { .generate_paths_file(path_tag, path_tag_name, api_abbr, security_data) } ) - paths_test_paths <- purrr::imap_chr( + paths_test_paths <- imap_chr( paths_by_tag, function(path_tag, path_tag_name) { .generate_paths_test_file(path_tag, path_tag_name, api_abbr) diff --git a/R/generate_pkg-prepare.R b/R/generate_pkg-prepare.R index 92c147d..21b22de 100644 --- a/R/generate_pkg-prepare.R +++ b/R/generate_pkg-prepare.R @@ -8,7 +8,7 @@ if (.is_pkg(base_path)) { return(invisible(NULL)) } - cli::cli_abort(c( + cli_abort(c( "Can't generate package files outside of a package.", x = "{.path {base_path}} is not inside a package." )) @@ -22,16 +22,16 @@ #' #' @return `TRUE` if the project is a package, `FALSE` if not. #' @keywords internal -.is_pkg <- function(base_path = usethis::proj_get()) { - root_file <- rlang::try_fetch( - rprojroot::find_package_root_file(path = base_path), +.is_pkg <- function(base_path = proj_get()) { + root_file <- try_fetch( + find_package_root_file(path = base_path), error = function(cnd) NULL ) !is.null(root_file) } .read_config <- function(config_file = "_beekeeper.yml") { - config <- yaml::read_yaml(config_file) + config <- read_yaml(config_file) config <- .stabilize_config(config) return(config) } diff --git a/R/generate_pkg-template.R b/R/generate_pkg-template.R index 81dcc48..8d4e2cf 100644 --- a/R/generate_pkg-template.R +++ b/R/generate_pkg-template.R @@ -23,9 +23,9 @@ .bk_use_template_impl <- function(template, data, target, dir) { target <- proj_path(dir, target) save_as <- path_rel(target, proj_path()) - if (fs::file_exists(target)) { + if (file_exists(target)) { # TODO: Intelligently prompt about this. - fs::file_delete(target) + file_delete(target) } use_template( template = template, diff --git a/man/dot-is_pkg.Rd b/man/dot-is_pkg.Rd index 04ff632..4ab171a 100644 --- a/man/dot-is_pkg.Rd +++ b/man/dot-is_pkg.Rd @@ -4,7 +4,7 @@ \alias{.is_pkg} \title{Check whether we're in a package} \usage{ -.is_pkg(base_path = usethis::proj_get()) +.is_pkg(base_path = proj_get()) } \arguments{ \item{base_path}{The root URL of the current project.}