Skip to content

Commit

Permalink
Merge pull request #88 from olivroy/crayon
Browse files Browse the repository at this point in the history
Remove crayon and clisymbols dep
  • Loading branch information
gaborcsardi authored Aug 28, 2024
2 parents 079e49d + a5bcf1b commit f645fed
Show file tree
Hide file tree
Showing 22 changed files with 99 additions and 115 deletions.
27 changes: 14 additions & 13 deletions .github/workflows/R-CMD-check.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@ on:
pull_request:
branches: [main, master]

name: R-CMD-check
name: R-CMD-check.yaml

permissions: read-all

jobs:
R-CMD-check:
Expand All @@ -25,24 +27,22 @@ jobs:
- {os: macos-latest, r: 'release'}

- {os: windows-latest, r: 'release'}
# Use 3.6 to trigger usage of RTools35
- {os: windows-latest, r: '3.6'}
# use 4.1 to check with rtools40's older compiler
- {os: windows-latest, r: '4.1'}

- {os: ubuntu-latest, r: 'devel', http-user-agent: 'release'}
- {os: ubuntu-latest, r: 'release'}
- {os: ubuntu-latest, r: 'oldrel-1'}
- {os: ubuntu-latest, r: 'oldrel-2'}
- {os: ubuntu-latest, r: 'oldrel-3'}
- {os: ubuntu-latest, r: 'oldrel-4'}
# use 4.0 or 4.1 to check with rtools40's older compiler
- {os: windows-latest, r: 'oldrel-4'}

- {os: ubuntu-latest, r: 'devel', http-user-agent: 'release'}
- {os: ubuntu-latest, r: 'release'}
- {os: ubuntu-latest, r: 'oldrel-1'}
- {os: ubuntu-latest, r: 'oldrel-2'}
- {os: ubuntu-latest, r: 'oldrel-3'}
- {os: ubuntu-latest, r: 'oldrel-4'}

env:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
R_KEEP_PKG_SOURCE: yes

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- uses: r-lib/actions/setup-pandoc@v2

Expand All @@ -60,3 +60,4 @@ jobs:
- uses: r-lib/actions/check-r-package@v2
with:
upload-snapshots: true
build_args: 'c("--no-manual","--compact-vignettes=gs+qpdf")'
8 changes: 5 additions & 3 deletions .github/workflows/pkgdown.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@ on:
types: [published]
workflow_dispatch:

name: pkgdown
name: pkgdown.yaml

permissions: read-all

jobs:
pkgdown:
Expand All @@ -22,7 +24,7 @@ jobs:
permissions:
contents: write
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- uses: r-lib/actions/setup-pandoc@v2

Expand All @@ -41,7 +43,7 @@ jobs:

- name: Deploy to GitHub pages 🚀
if: github.event_name != 'pull_request'
uses: JamesIves/github-pages-deploy-action@v4.4.1
uses: JamesIves/github-pages-deploy-action@v4.5.0
with:
clean: false
branch: gh-pages
Expand Down
12 changes: 9 additions & 3 deletions .github/workflows/pr-commands.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@ on:
issue_comment:
types: [created]

name: Commands
name: pr-commands.yaml

permissions: read-all

jobs:
document:
Expand All @@ -13,8 +15,10 @@ jobs:
runs-on: ubuntu-latest
env:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
permissions:
contents: write
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- uses: r-lib/actions/pr-fetch@v2
with:
Expand Down Expand Up @@ -50,8 +54,10 @@ jobs:
runs-on: ubuntu-latest
env:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
permissions:
contents: write
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- uses: r-lib/actions/pr-fetch@v2
with:
Expand Down
23 changes: 17 additions & 6 deletions .github/workflows/test-coverage.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@ on:
pull_request:
branches: [main, master]

name: test-coverage
name: test-coverage.yaml

permissions: read-all

jobs:
test-coverage:
Expand All @@ -15,36 +17,45 @@ jobs:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- uses: r-lib/actions/setup-r@v2
with:
use-public-rspm: true

- uses: r-lib/actions/setup-r-dependencies@v2
with:
extra-packages: any::covr
extra-packages: any::covr, any::xml2
needs: coverage

- name: Test coverage
run: |
covr::codecov(
cov <- covr::package_coverage(
quiet = FALSE,
clean = FALSE,
install_path = file.path(normalizePath(Sys.getenv("RUNNER_TEMP"), winslash = "/"), "package")
)
covr::to_cobertura(cov)
shell: Rscript {0}

- uses: codecov/codecov-action@v4
with:
fail_ci_if_error: ${{ github.event_name != 'pull_request' && true || false }}
file: ./cobertura.xml
plugin: noop
disable_search: true
token: ${{ secrets.CODECOV_TOKEN }}

- name: Show testthat output
if: always()
run: |
## --------------------------------------------------------------------
find ${{ runner.temp }}/package -name 'testthat.Rout*' -exec cat '{}' \; || true
find '${{ runner.temp }}/package' -name 'testthat.Rout*' -exec cat '{}' \; || true
shell: bash

- name: Upload test results
if: failure()
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: coverage-test-failures
path: ${{ runner.temp }}/package
10 changes: 3 additions & 7 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -22,24 +22,20 @@ Depends:
R (>= 3.6)
Imports:
cli,
clisymbols,
crayon,
desc,
glue,
jsonlite,
memoise,
rlang,
SnowballC,
stringdist,
tibble,
tidytext,
yesno
tidytext
Suggests:
BiocManager,
covr,
testthat (>= 3.0.0),
usethis
Config/Needs/website: tidyverse/tidytemplate
Config/testthat/edition: 3
Encoding: UTF-8
Roxygen: list(markdown = TRUE)
RoxygenNote: 7.2.3
RoxygenNote: 7.3.2
2 changes: 2 additions & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ S3method(format,available_sentiment)
S3method(format,available_valid_name)
S3method(format,available_wikipedia)
S3method(format,available_wiktionary)
S3method(print,available_abbreviation)
S3method(print,available_bad_words)
S3method(print,available_bioc)
S3method(print,available_cran)
Expand All @@ -17,6 +18,7 @@ S3method(print,available_sentiment)
S3method(print,available_valid_name)
S3method(print,available_wikipedia)
S3method(print,available_wiktionary)
S3method(testthat::compare,glue)
export(available)
export(available_on_bioc)
export(available_on_cran)
Expand Down
3 changes: 2 additions & 1 deletion R/available-package.R
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
#' @aliases available-package NULL
#' @keywords internal
"_PACKAGE"

## usethis namespace: start
#' @importFrom utils browseURL
#' @importFrom stats na.omit
## usethis namespace: end
NULL
13 changes: 7 additions & 6 deletions R/available.R
Original file line number Diff line number Diff line change
Expand Up @@ -73,11 +73,12 @@ print.available_query <- function(x, ...) {
create <- function(name, ...) {
print(available(name))

ans <- yesno::yesno(glue::glue("Create package `{name}`?"))
if (isTRUE(ans)) {
if (!requireNamespace("usethis")) {
stop("`usethis` must be installed to create a package", call. = FALSE)
}
ans <- utils::menu(
choices = c("Yes", "No"),
title = cli::format_inline("Create package {.pkg {name}}?")
)
if (ans == 1) {
rlang::check_installed("usethis", "to create a package.")
usethis::create_package(name, ...)
}
}
Expand Down Expand Up @@ -117,7 +118,7 @@ suggest <- function(path = ".", field = c("Title", "Description"), text = NULL)
text <- path
}
if (is.na(text)) {
stop("No text found, please specify one with `text`.", call. = FALSE)
cli::cli_abort("No text found, please specify one with `text`.", call = NULL)
}
}

Expand Down
15 changes: 7 additions & 8 deletions R/bad_words.R
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,15 @@ get_bad_words <- function(name) {
#' @export

format.available_bad_words <- function(x, ...) {
good <- crayon::green
bad <- crayon::combine_styles(crayon::bgRed, crayon::white)
paste0(
crayon::bold("Bad Words: "),
good <- cli::col_green
bad <- cli::combine_ansi_styles(cli::bg_red, cli::col_white)
cli::cat_line(
cli::style_bold("Bad Words: "),
if (length(x) == 0) {
good(clisymbols::symbol$tick)
good(cli::symbol$tick)
} else {
bad(glue_collapse(x, sep = ", ", last = " and "))
bad(cli::ansi_collapse(x))
},
"\n"
)
}

Expand All @@ -47,7 +46,7 @@ print.available_bad_words <- function(x, ...) {

mark_bad_words <- function(text, marker = NULL) {
if (is.null(marker)) {
marker <- crayon::combine_styles(crayon::white, crayon::bgRed)
marker <- cli::combine_ansi_styles(cli::col_white, cli::bg_red)
}

vapply(
Expand Down
2 changes: 1 addition & 1 deletion R/bioc.R
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ available_on_bioc <- function(name, repos = NULL, ...) {
#' @export

format.available_bioc <- function(x, ...) {
paste0(crayon::bold("Available on Bioconductor: "), yes_no(x[[1]]), "\n")
paste0(cli::style_bold("Available on Bioconductor: "), yes_no(x[[1]]), "\n")
}

#' @export
Expand Down
6 changes: 2 additions & 4 deletions R/cran.R
Original file line number Diff line number Diff line change
Expand Up @@ -31,19 +31,17 @@ archive_packages <- memoise::memoise(function() {
available_packages <- memoise::memoise(available.packages)

#' @export

format.available_cran <- function(x, ...) {
cat(crayon::bold("Available on CRAN:"), yes_no(x[[1]]), "\n")
cat(cli::style_bold("Available on CRAN: "), yes_no(x[[1]]), "\n")
}

#' @export

print.available_cran <- function(x, ...) {
cat(format(x, ...))
invisible(x)
}

default_cran_repos <- c(
CRAN = "https://cloud.r-project.org",
CRANextra = "http://www.stats.ox.ac.uk/pub/RWin"
CRANextra = "https://www.stats.ox.ac.uk/pub/RWin"
)
5 changes: 3 additions & 2 deletions R/dist.R
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,10 @@ pkg_name_dist <- function(name, pkgs) {
} else {
distances <- stringdist::stringdist(name, pkgs)

tibble::tibble(
data.frame(
pkgs = utils::head(pkgs[order(distances)]),
distance = utils::head(distances[order(distances)])
distance = utils::head(distances[order(distances)]),
stringsAsFactors = FALSE
)
}
}
2 changes: 1 addition & 1 deletion R/github.R
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ gh_pkg <- memoise::memoise(function(pkg) {
#' @export

format.available_github <- function(x, ...) {
paste0(crayon::bold("Available on GitHub: ", yes_no(x[[1]]), "\n"))
paste0(cli::style_bold("Available on GitHub: ", yes_no(x[[1]]), "\n"))
}

#' @export
Expand Down
7 changes: 5 additions & 2 deletions R/namr.R
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,10 @@ pick_word_from_title <- function(title, verb = FALSE) {

# make sure
if (length(package_name) == 0) {
stop("Sorry, we couldn't make a good name from your tile. Try using more specific words in your description.")
cli::cli_abort(c(
x = "Sorry, we couldn't make a good name from your tile.",
i = "Try using more specific words in your description."
))
}

package_name
Expand Down Expand Up @@ -170,7 +173,7 @@ find_acronym <- function(title) {

# make sure we don't have a name with reduplication
if (word %in% tolower(acronyms)) {
stop("Title is already acronym.")
cli::cli_abort("Title is already acronym.")
}

# return the first acronym from the title
Expand Down
3 changes: 0 additions & 3 deletions R/package.R

This file was deleted.

6 changes: 3 additions & 3 deletions R/sentiment.R
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,13 @@ get_sentiment <- function(name) {

format.available_sentiment <- function(x, ...) {
paste0(
crayon::bold("Sentiment:"),
cli::style_bold("Sentiment: "),
if (is.na(x[[1]])) {
"???"
} else if (isTRUE(x[[1]])) {
crayon::green("+++")
cli::col_green("+++")
} else {
crayon::red("---")
cli::col_red("---")
},
"\n"
)
Expand Down
Loading

0 comments on commit f645fed

Please sign in to comment.