-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #67 from Appsilon/develop
Release v0.3.0
- Loading branch information
Showing
38 changed files
with
5,822 additions
and
122 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
Package: rhino | ||
Title: A framework for enterprise Shiny applications | ||
Version: 0.2.0 | ||
Version: 0.3.0 | ||
Authors@R: | ||
c( | ||
person(given = "Kamil", family = "Zyla", role = "aut", email = "[email protected]"), | ||
|
@@ -18,12 +18,15 @@ Encoding: UTF-8 | |
Roxygen: list(markdown = TRUE) | ||
RoxygenNote: 7.1.2 | ||
Imports: | ||
fs, | ||
cli, | ||
renv, | ||
withr | ||
Suggests: | ||
lintr (>= 2.0.0), | ||
testthat (>= 3.0.0) | ||
cli, | ||
glue, | ||
fs, | ||
lintr (>= 2.0.0), | ||
renv, | ||
sass, | ||
styler, | ||
testthat (>= 3.0.0), | ||
withr, | ||
yaml | ||
Config/testthat/edition: 3 | ||
Config/testthat/parallel: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,13 @@ | ||
# Generated by roxygen2: do not edit by hand | ||
|
||
export(build_js) | ||
export(build_sass) | ||
export(format_r) | ||
export(init) | ||
importFrom(cli,cli_alert_success) | ||
importFrom(fs,dir_copy) | ||
export(lint_js) | ||
export(lint_r) | ||
export(lint_sass) | ||
export(test_e2e) | ||
export(test_r) | ||
importFrom(fs,dir_create) | ||
importFrom(fs,file_copy) | ||
importFrom(fs,path) | ||
importFrom(fs,path_package) | ||
importFrom(renv,init) | ||
importFrom(withr,with_dir) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
system_yarn <- function(...) { | ||
status <- system2( | ||
command = "yarn", | ||
args = c("--cwd", shQuote(node_path()), ...) | ||
) | ||
if (status != 0) { | ||
stop(glue::glue("yarn failed with exit status {status}"), call. = FALSE) | ||
} | ||
} | ||
|
||
add_node <- function() { | ||
copy_template("node", node_path()) | ||
fs::link_create( | ||
path = fs::path("..", ".."), | ||
new_path = fs::path(node_path(), "root") | ||
) | ||
} | ||
|
||
yarn <- function(...) { | ||
if (!fs::dir_exists(node_path())) { | ||
add_node() | ||
system_yarn("install") | ||
} | ||
system_yarn(...) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
read_config <- function() { | ||
yaml::read_yaml("rhino.yml") | ||
} | ||
|
||
template_path <- function(...) { | ||
fs::path_package("rhino", "templates", ...) | ||
} | ||
|
||
node_path <- function(...) { | ||
fs::path(".rhino", "node", ...) | ||
} | ||
|
||
rename_template_path <- function(path) { | ||
path <- fs::path_split(path)[[1]] | ||
path <- sub("^dot\\.", ".", path) | ||
path <- sub("\\.template$", "", path) | ||
fs::path_join(path) | ||
} | ||
|
||
# Copy template from source path (relative to `inst/templates`) to destination | ||
# with some renaming applied to the names of files and directories: | ||
# 1. Leading `dot.` is replaced with `.`. | ||
# 2. Trailing `.template` is removed. | ||
copy_template <- function(src, dst) { | ||
src <- template_path(src) | ||
target <- function(path) { | ||
path <- fs::path_rel(path, start = src) | ||
path <- rename_template_path(path) | ||
fs::path(dst, path) | ||
} | ||
|
||
fs::dir_create(dst) | ||
fs::dir_walk( | ||
path = src, | ||
recurse = TRUE, | ||
type = "directory", | ||
fun = function(dir) fs::dir_create(target(dir)) | ||
) | ||
fs::dir_walk( | ||
path = src, | ||
recurse = TRUE, | ||
type = "file", | ||
fun = function(file) fs::file_copy(file, target(file)) | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,131 @@ | ||
#' Run R unit tests | ||
#' | ||
#' @importFrom fs path | ||
#' @export | ||
test_r <- function() { | ||
testthat::test_dir(path("tests", "testthat")) | ||
} | ||
|
||
#' Lint R | ||
#' | ||
#' @param accepted_errors Number of accepted style errors. | ||
#' | ||
#' @export | ||
lint_r <- function(accepted_errors = 0) { | ||
lints <- c( | ||
lintr::lint("app.R"), | ||
lintr::lint_dir("app"), | ||
lintr::lint_dir(path("tests", "testthat")) | ||
) | ||
|
||
style_errors <- length(lints) | ||
|
||
if (style_errors > accepted_errors) { | ||
print(lints) | ||
stop(sprintf("Number of style errors: %s", style_errors)) | ||
} | ||
} | ||
|
||
#' Format R | ||
#' | ||
#' @param path File or directory to format | ||
#' | ||
#' @export | ||
format_r <- function(path) { | ||
if (fs::is_dir(path)) { | ||
styler::style_dir(path) | ||
} else { | ||
styler::style_file(path) | ||
} | ||
} | ||
|
||
#' Build JavaScript | ||
#' | ||
#' Builds the `app/js/index.js` file into `app/static/js/app.min.js`. | ||
#' The code is transformed and bundled | ||
#' using [Babel](https://babeljs.io) and [Webpack](https://webpack.js.org), | ||
#' so the latest JavaScript features can be used | ||
#' (including ECMAScript 2015 aka ES6 and newer standards). | ||
#' | ||
#' Functions/objects defined in the global scope do not automatically become `window` properties, | ||
#' so the following JS code: | ||
#' ```js | ||
#' function sayHello() { alert('Hello!'); } | ||
#' ``` | ||
#' won't work as expected if used in R like this: | ||
#' ```R | ||
#' tags$button("Hello!", onclick = 'sayHello()'); | ||
#' ``` | ||
#' | ||
#' Instead you should explicitly export functions: | ||
#' ```js | ||
#' export function sayHello() { alert('Hello!'); } | ||
#' ``` | ||
#' and access them via the global `App` object: | ||
#' ```R | ||
#' tags$button("Hello!", onclick = "App.sayHello()") | ||
#' ``` | ||
#' | ||
#' @export | ||
build_js <- function() { | ||
yarn("build-js") | ||
} | ||
|
||
# nolint start | ||
#' Lint JavaScript | ||
#' | ||
#' Runs [ESLint](https://eslint.org) on the JavaScript sources in the `app/js` directory. | ||
#' | ||
#' If your code uses global objects defined by other JS libraries or R packages, | ||
#' you'll need to let the linter know or it will complain about undefined objects. | ||
#' For example, the `{leaflet}` package defines a global object `L`. | ||
#' To access it without raising linter errors, add `/* global L */` comment in your JS code. | ||
#' | ||
#' You don't need to define `Shiny` and `$` as these globals are defined by default. | ||
#' | ||
#' If you find a particular ESLint error unapplicable to your code, | ||
#' you can disable a specific rule for the next line of code with a comment like: | ||
#' ```js | ||
#' // eslint-disable-next-line no-restricted-syntax | ||
#' ``` | ||
#' See the [ESLint documentation](https://eslint.org/docs/user-guide/configuring/rules#using-configuration-comments-1) | ||
#' for full details. | ||
#' | ||
#' @export | ||
# nolint end | ||
lint_js <- function() { | ||
yarn("lint-js") | ||
} | ||
|
||
#' Build Sass | ||
#' | ||
#' @importFrom fs dir_create path | ||
#' @export | ||
build_sass <- function() { | ||
config <- read_config()$sass | ||
if (config == "node") { | ||
yarn("build-sass") | ||
} else if (config == "r") { | ||
output_dir <- path("app", "static", "css") | ||
dir_create(output_dir) | ||
sass::sass( | ||
input = sass::sass_file(path("app", "styles", "main.scss")), | ||
output = path(output_dir, "app.min.css"), | ||
cache = FALSE | ||
) | ||
} | ||
} | ||
|
||
#' Lint Sass | ||
#' | ||
#' @export | ||
lint_sass <- function() { | ||
yarn("lint-sass") | ||
} | ||
|
||
#' Run Cypress end-to-end tests | ||
#' | ||
#' @export | ||
test_e2e <- function() { | ||
yarn("test-e2e") | ||
} |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
linters: | ||
with_defaults( | ||
line_length_linter = line_length_linter(100), | ||
infix_spaces_linter = NULL, | ||
object_usage_linter = NULL | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
sass: node |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"baseUrl": "http://localhost:3333", | ||
"pluginsFile": false, | ||
"supportFile": false | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
/screenshots/ | ||
/videos/ |
Oops, something went wrong.