From 26f4c41d73d48641255a85507e494ce425b79628 Mon Sep 17 00:00:00 2001 From: pat-s Date: Thu, 27 Aug 2020 14:18:43 +0200 Subject: [PATCH 1/3] move from ui_* to {cli} --- NAMESPACE | 1 + R/bump-version.R | 7 ++++--- R/commit-version.R | 4 ++-- R/finalize-version.R | 6 +++--- R/import.R | 2 ++ R/package.R | 2 -- R/tag-version.R | 9 ++++++--- R/unbump-version.R | 12 ++++++------ R/update-news.R | 7 ++++--- R/update-version.R | 6 ++++-- 10 files changed, 32 insertions(+), 24 deletions(-) delete mode 100644 R/package.R diff --git a/NAMESPACE b/NAMESPACE index 95c8eb2dc..b5ed7fadd 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -9,6 +9,7 @@ export(tag_version) export(unbump_version) export(update_news) export(update_version) +import(cli) import(rlang) import(usethis) importFrom(purrr,discard) diff --git a/R/bump-version.R b/R/bump-version.R index 7e91ddcea..b68c4a1de 100644 --- a/R/bump-version.R +++ b/R/bump-version.R @@ -13,9 +13,10 @@ bump_version_impl <- function(which) { } else { #' - Otherwise, [commit_version()]. commit_version() - ui_info("Preparing package for release (CRAN or otherwise)") + cli_alert_info("Preparing package for release (CRAN or otherwise).") edit_news() - ui_todo("Convert the change log in {ui_path(news_path)} to release notes") - ui_todo("After CRAN release, call {ui_code('fledge::tag_version()')} and {ui_code('fledge::bump_version()')} to re-enter development mode") + cli_alert_warning("Convert the change log in {.file {news_path}} to release notes.") + cli_alert_warning("After CRAN release, call {.fun fledge::tag_version} and + {.fun fledge::bump_version} to re-enter development mode") } } diff --git a/R/commit-version.R b/R/commit-version.R index 35dad15be..56514fa07 100644 --- a/R/commit-version.R +++ b/R/commit-version.R @@ -2,7 +2,7 @@ commit_version_impl <- function() { check_only_staged(c("DESCRIPTION", news_path)) if (is_last_commit_bump()) { - ui_done("Resetting to previous commit") + cli_alert("Resetting to previous commit.") git2r::reset(git2r::revparse_single(revision = "HEAD^")) amending <- TRUE } else { @@ -11,7 +11,7 @@ commit_version_impl <- function() { git2r::add(".", c("DESCRIPTION", news_path)) if (length(git2r::status(".", unstaged = FALSE, untracked = FALSE)$staged) > 0) { - ui_done("Committing changes") + cli_alert("Committing changes.") git2r::commit(".", get_commit_message()) } diff --git a/R/finalize-version.R b/R/finalize-version.R index 887ce7259..a96e97502 100644 --- a/R/finalize-version.R +++ b/R/finalize-version.R @@ -15,7 +15,7 @@ finalize_version_impl <- function(push) { push_head(head) } else { edit_news() - ui_todo("Call {ui_code('fledge::finalize_version(push = TRUE)')}") + cli_alert_warning("Call {.code fledge::finalize_version(push = TRUE)}.") send_to_console("fledge::finalize_version(push = TRUE)") } } @@ -27,12 +27,12 @@ get_head_branch <- function() { } push_tag <- function(tag) { - ui_done("Force-pushing tag {ui_value(tag)}") + cli_alert("Force-pushing tag {.emph {tag}}.") git2r::push(name = "origin", refspec = paste0("refs/tags/", tag), force = TRUE) } push_head <- function(head) { - ui_done('Pushing {ui_value(head$name)}') + cli_alert('Pushing {.emph {head$name}}.') git2r::push(head) } diff --git a/R/import.R b/R/import.R index 3d20c78e3..2fb8426a5 100644 --- a/R/import.R +++ b/R/import.R @@ -1,4 +1,6 @@ #' @import rlang +#' @import cli +#' @import usethis #' @importFrom purrr map map_chr map_int discard keep some #' @importFrom tibble add_column NULL diff --git a/R/package.R b/R/package.R deleted file mode 100644 index 5f7a50ca8..000000000 --- a/R/package.R +++ /dev/null @@ -1,2 +0,0 @@ -#' @import usethis -NULL diff --git a/R/tag-version.R b/R/tag-version.R index 713ed3187..9779a935e 100644 --- a/R/tag-version.R +++ b/R/tag-version.R @@ -5,21 +5,24 @@ tag_version_impl <- function(force) { desc <- desc::desc(file = "DESCRIPTION") version <- desc$get_version() + cli_h2("Tagging version") + tag <- paste0("v", version) if (tag %in% names(git2r::tags())) { if (!force) { if (git2r::sha(get_repo_head(tag)) == git2r::sha(get_repo_head())) { - ui_info("Tag {ui_value(tag)} exists and points to the current commit.") + cli_alert_info("Tag {.field {tag}} exists and points to the current commit.") } else { abort(paste0("Tag ", tag, " exists, use `force = TRUE` to overwrite.")) } } else { - ui_done("Deleting tag {ui_value(tag)}") + cli_alert("Deleting tag {.field {tag}}.") git2r::tag_delete(".", tag) } } - ui_done("Creating tag {ui_value(tag)} with tag message derived from {ui_path('NEWS.md')}") + cli_alert("Creating tag {.emph {tag}} with tag message derived from + {.file NEWS.md}.", wrap = TRUE) msg_header <- paste0(desc$get("Package"), " ", version) git2r::tag(".", tag, message = paste0(msg_header, "\n\n", current_news)) diff --git a/R/unbump-version.R b/R/unbump-version.R index e84f2eebd..54269a5c2 100644 --- a/R/unbump-version.R +++ b/R/unbump-version.R @@ -4,19 +4,19 @@ unbump_version_impl <- function() { tag <- get_last_tag() last_commit <- git2r::last_commit() - ui_info("Checking if working copy is clean") + cli_alert_info("Checking if working copy is clean.") stopifnot(sum(map_int(git2r::status(), length)) == 0) - ui_info("Checking if last tag points to last commit") + cli_alert_info("Checking if last tag points to last commit.") stopifnot(tag$target == last_commit$sha) - ui_info("Checking if commit messages match") + cli_alert_info("Checking if commit messages match.") stopifnot(is_last_commit_bump()) - ui_done("Safety checks complete") + cli_alert_success("Safety checks complete.") - ui_done("Deleting tag {ui_value(tag$name)}") + cli_alert("Deleting tag {.emph {tag$name}}.") git2r::tag_delete(tag) parent_commit <- git2r::parents(last_commit)[[1]] - ui_done("Resetting to parent commit {ui_value(parent_commit$sha)}") + cli_alert_success("Resetting to parent commit {.emph {parent_commit$sha}}.") git2r::reset(parent_commit, "hard") } diff --git a/R/update-news.R b/R/update-news.R index c462ec332..26c0a2984 100644 --- a/R/update-news.R +++ b/R/update-news.R @@ -1,12 +1,13 @@ update_news_impl <- function(range) { news <- collect_news(range) - ui_done("Adding new entries to {ui_path(news_path)}") + cli_h2("Updating NEWS") + cli_alert("Adding new entries to {.file {news_path}}.") add_to_news(news) } collect_news <- function(range) { - ui_done("Scraping {ui_value(length(range))} commit messages") + cli_alert("Scraping {.field {length(range)}} commit messages.") messages <- gsub("\r\n", "\n", map_chr(range, "message")) messages_before_triple_dash <- map_chr(strsplit(messages, "\n---", fixed = TRUE), 1) @@ -22,7 +23,7 @@ collect_news <- function(range) { } } - ui_done("Found {ui_value(length(message_items))} NEWS-worthy entries.") + cli_alert_success("Found {.field {length(message_items)}} NEWS-worthy entries.") paste0(paste(message_items, collapse = "\n"), "\n\n") } diff --git a/R/update-version.R b/R/update-version.R index d355209de..f95439406 100644 --- a/R/update-version.R +++ b/R/update-version.R @@ -10,9 +10,11 @@ update_version_impl <- function(which) { new_version <- desc$get_version() - ui_done("Package version bumped to {ui_value(new_version)}") + cli_h2("Update Version") - ui_done("Adding header to {ui_path(news_path)}") + cli_alert_success("Package version bumped to {.emph {new_version}}.") + + cli_alert("Adding header to {.file {news_path}}.") header <- paste0( "# ", desc$get("Package"), " ", new_version, From b840b310a5d931ba59074d577f770a76c3faa5f1 Mon Sep 17 00:00:00 2001 From: pat-s Date: Thu, 27 Aug 2020 16:39:37 +0200 Subject: [PATCH 2/3] .emph -> .field --- R/finalize-version.R | 4 ++-- R/tag-version.R | 4 ++-- R/unbump-version.R | 4 ++-- R/update-version.R | 2 +- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/R/finalize-version.R b/R/finalize-version.R index a96e97502..2ec5cc878 100644 --- a/R/finalize-version.R +++ b/R/finalize-version.R @@ -27,12 +27,12 @@ get_head_branch <- function() { } push_tag <- function(tag) { - cli_alert("Force-pushing tag {.emph {tag}}.") + cli_alert("Force-pushing tag {.field {tag}}.") git2r::push(name = "origin", refspec = paste0("refs/tags/", tag), force = TRUE) } push_head <- function(head) { - cli_alert('Pushing {.emph {head$name}}.') + cli_alert('Pushing {.field {head$name}}.') git2r::push(head) } diff --git a/R/tag-version.R b/R/tag-version.R index 9779a935e..c1c0f340c 100644 --- a/R/tag-version.R +++ b/R/tag-version.R @@ -5,7 +5,7 @@ tag_version_impl <- function(force) { desc <- desc::desc(file = "DESCRIPTION") version <- desc$get_version() - cli_h2("Tagging version") + cli_h2("Tagging Version") tag <- paste0("v", version) if (tag %in% names(git2r::tags())) { @@ -21,7 +21,7 @@ tag_version_impl <- function(force) { } } - cli_alert("Creating tag {.emph {tag}} with tag message derived from + cli_alert("Creating tag {.field {tag}} with tag message derived from {.file NEWS.md}.", wrap = TRUE) msg_header <- paste0(desc$get("Package"), " ", version) git2r::tag(".", tag, message = paste0(msg_header, "\n\n", current_news)) diff --git a/R/unbump-version.R b/R/unbump-version.R index 54269a5c2..d1f9d6d4d 100644 --- a/R/unbump-version.R +++ b/R/unbump-version.R @@ -13,10 +13,10 @@ unbump_version_impl <- function() { cli_alert_success("Safety checks complete.") - cli_alert("Deleting tag {.emph {tag$name}}.") + cli_alert("Deleting tag {.field {tag$name}}.") git2r::tag_delete(tag) parent_commit <- git2r::parents(last_commit)[[1]] - cli_alert_success("Resetting to parent commit {.emph {parent_commit$sha}}.") + cli_alert_success("Resetting to parent commit {.field {parent_commit$sha}}.") git2r::reset(parent_commit, "hard") } diff --git a/R/update-version.R b/R/update-version.R index f95439406..3d6260a8a 100644 --- a/R/update-version.R +++ b/R/update-version.R @@ -12,7 +12,7 @@ update_version_impl <- function(which) { cli_h2("Update Version") - cli_alert_success("Package version bumped to {.emph {new_version}}.") + cli_alert_success("Package version bumped to {.field {new_version}}.") cli_alert("Adding header to {.file {news_path}}.") From e1bd26f36b42f5c8e6fbeebbee99c96f71caa406 Mon Sep 17 00:00:00 2001 From: pat-s Date: Thu, 27 Aug 2020 16:46:08 +0200 Subject: [PATCH 3/3] import cli --- DESCRIPTION | 1 + 1 file changed, 1 insertion(+) diff --git a/DESCRIPTION b/DESCRIPTION index 653405744..6a852b2df 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -20,6 +20,7 @@ URL: http://krlmlr.github.io/fledge, https://github.com/krlmlr/fledge BugReports: https://github.com/krlmlr/fledge/issues Imports: + cli, desc (>= 1.2.0), enc, git2r (>= 0.26.0),