-
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 #33 from Appsilon/develop
Release v0.2.0
- Loading branch information
Showing
18 changed files
with
289 additions
and
4 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 |
---|---|---|
@@ -0,0 +1,34 @@ | ||
# Workflow derived from https://github.com/r-lib/actions/tree/v2/examples | ||
# Need help debugging build failures? Start at https://github.com/r-lib/actions#where-to-find-help | ||
on: | ||
push: | ||
branches: | ||
- main | ||
workflow_dispatch: | ||
|
||
name: pkgdown | ||
|
||
jobs: | ||
pkgdown: | ||
runs-on: ubuntu-latest | ||
env: | ||
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} | ||
steps: | ||
- uses: actions/checkout@v2 | ||
|
||
- uses: r-lib/actions/setup-pandoc@v2 | ||
|
||
- uses: r-lib/actions/setup-r@v2 | ||
with: | ||
use-public-rspm: true | ||
|
||
- uses: r-lib/actions/setup-r-dependencies@v2 | ||
with: | ||
extra-packages: any::pkgdown, local::. | ||
needs: website | ||
|
||
- name: Deploy to gh-pages branch | ||
run: | | ||
git config --local user.name "$GITHUB_ACTOR" | ||
git config --local user.email "[email protected]" | ||
Rscript -e 'pkgdown::deploy_to_branch(new_process = 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 |
---|---|---|
@@ -1,3 +1,5 @@ | ||
linters: with_defaults( | ||
line_length_linter = line_length_linter(100) | ||
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 |
---|---|---|
@@ -1,6 +1,6 @@ | ||
Package: rhino | ||
Title: A framework for enterprise Shiny applications | ||
Version: 0.1.0 | ||
Version: 0.2.0 | ||
Authors@R: | ||
c( | ||
person(given = "Kamil", family = "Zyla", role = "aut", email = "[email protected]"), | ||
|
@@ -11,12 +11,17 @@ Authors@R: | |
person(family = "Appsilon Sp. z o.o.", role = "cph") | ||
) | ||
Description: A framework that supports creating and extending enterprise Shiny applications using best practices. | ||
URL: https://github.com/Appsilon/rhino | ||
URL: https://appsilon.github.io/rhino, https://github.com/Appsilon/rhino | ||
BugReports: https://github.com/Appsilon/rhino/issues | ||
License: MIT + file LICENSE | ||
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) | ||
|
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,2 +1,11 @@ | ||
# Generated by roxygen2: do not edit by hand | ||
|
||
export(init) | ||
importFrom(cli,cli_alert_success) | ||
importFrom(fs,dir_copy) | ||
importFrom(fs,dir_create) | ||
importFrom(fs,file_copy) | ||
importFrom(fs,path) | ||
importFrom(fs,path_package) | ||
importFrom(renv,init) | ||
importFrom(withr,with_dir) |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
#' Create Shiny application using `{rhino}` | ||
#' | ||
#' @param dir Name of the directory to create application in. | ||
#' @param github_actions_ci Should the Github Actions CI be added. | ||
#' | ||
#' @export | ||
init <- function(dir = ".", github_actions_ci = TRUE) { | ||
init_setup(dir) | ||
|
||
create_app_structure(dir) | ||
|
||
if (isTRUE(github_actions_ci)) add_github_actions_ci(dir) | ||
|
||
init_renv(dir) | ||
} | ||
|
||
#' @importFrom fs dir_create | ||
#' @importFrom cli cli_alert_success | ||
init_setup <- function(dir) { | ||
dir_create(dir) | ||
cli_alert_success("Application directory created") | ||
} | ||
|
||
#' @importFrom fs dir_copy file_copy path | ||
#' @importFrom cli cli_alert_success | ||
create_app_structure <- function(dir) { | ||
file_copy( | ||
path = path_rhino("app_structure", "app.R"), | ||
new_path = dir | ||
) | ||
|
||
file_copy( | ||
path = path_rhino("app_structure", "Rprofile"), | ||
new_path = path(dir, ".Rprofile") | ||
) | ||
|
||
file_copy( | ||
path = path_rhino("app_structure", "src.Rproj2"), | ||
new_path = path(dir, "src.Rproj") | ||
) | ||
|
||
dir_copy( | ||
path = path_rhino("app_structure", "app"), | ||
new_path = dir | ||
) | ||
|
||
cli_alert_success("Application structure created") | ||
} | ||
|
||
#' @importFrom fs dir_create dir_copy path | ||
#' @importFrom cli cli_alert_success | ||
add_github_actions_ci <- function(dir) { | ||
github_path <- path(dir, ".github") | ||
dir_create(github_path) | ||
dir_copy( | ||
path = path_rhino("github_ci", "workflows"), | ||
new_path = github_path | ||
) | ||
|
||
cli_alert_success("Github Actions CI added") | ||
} | ||
|
||
#' @importFrom fs file_copy | ||
#' @importFrom renv init | ||
#' @importFrom withr with_dir | ||
#' @importFrom cli cli_alert_success | ||
init_renv <- function(dir) { | ||
file_copy( | ||
path = path_rhino("renv", "renvignore"), | ||
new_path = path(dir, ".renvignore") | ||
) | ||
|
||
file_copy( | ||
path = path_rhino("renv", "dependencies.R"), | ||
new_path = path(dir) | ||
) | ||
|
||
with_dir( | ||
dir, | ||
renv::init(restart = FALSE) | ||
) | ||
|
||
cli_alert_success("renv initiated") | ||
} | ||
|
||
#' @importFrom fs path_package | ||
path_rhino <- function(...) { | ||
path_package( | ||
"rhino", | ||
"templates", | ||
... | ||
) | ||
} |
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,7 @@ | ||
Binding: init | ||
Title: Shiny Application using rhino | ||
|
||
Parameter: github_actions_ci | ||
Widget: CheckboxInput | ||
Label: Github Actions CI | ||
Default: On |
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 @@ | ||
# Allow absolute module imports (relative to the app root). | ||
options(box.path = file.path(getwd(), "app")) |
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,29 @@ | ||
# Purge the box module cache, so the app can be reloaded without restarting the R session. | ||
rm(list = ls(box:::loaded_mods), envir = box:::loaded_mods) | ||
|
||
box::use( | ||
logger[appender_file, log_appender, log_threshold], | ||
shiny[addResourcePath, shinyApp], | ||
) | ||
box::use( | ||
r/main, | ||
) | ||
|
||
# nolint start | ||
LOG_FILE <- Sys.getenv("LOG_FILE") | ||
LOG_LEVEL <- Sys.getenv("LOG_LEVEL", unset = "INFO") | ||
# nolint end | ||
|
||
addResourcePath("static", "app/static") | ||
|
||
log_threshold(LOG_LEVEL) | ||
if (nzchar(LOG_FILE)) { | ||
log_appender(appender_file(LOG_FILE)) | ||
} | ||
|
||
shinyApp( | ||
ui = main$ui("app"), | ||
server = function(input, output) { | ||
main$server("app") | ||
} | ||
) |
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,23 @@ | ||
box::use( | ||
shiny[bootstrapPage, moduleServer, NS, renderText, tags, textOutput], | ||
) | ||
|
||
#' @export | ||
ui <- function(id) { | ||
ns <- NS(id) | ||
bootstrapPage( | ||
tags$head( | ||
tags$link(rel = "icon", href = "static/favicon.ico", sizes = "any") | ||
), | ||
tags$h3( | ||
textOutput(ns("message")) | ||
) | ||
) | ||
} | ||
|
||
#' @export | ||
server <- function(id) { | ||
moduleServer(id, function(input, output, session) { | ||
output$message <- renderText("Hello!") | ||
}) | ||
} |
Binary file not shown.
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,13 @@ | ||
Version: 1.0 | ||
|
||
RestoreWorkspace: Default | ||
SaveWorkspace: Default | ||
AlwaysSaveHistory: Default | ||
|
||
EnableCodeIndexing: Yes | ||
UseSpacesForTab: Yes | ||
NumSpacesForTab: 2 | ||
Encoding: UTF-8 | ||
|
||
RnwWeave: Sweave | ||
LaTeX: pdfLaTeX |
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,33 @@ | ||
name: Linter | ||
on: push | ||
jobs: | ||
main: | ||
name: Run linter | ||
runs-on: ubuntu-20.04 | ||
steps: | ||
- name: Checkout repo | ||
uses: actions/checkout@v2 | ||
|
||
- name: Setup R | ||
uses: r-lib/actions/setup-r@v1 | ||
with: | ||
r-version: '4.1.0' | ||
|
||
- name: Restore renv from cache | ||
uses: actions/cache@v2 | ||
with: | ||
path: renv/library | ||
key: renv-${{ hashFiles('renv.lock') }} | ||
restore-keys: renv- | ||
|
||
- name: Sync renv with lockfile | ||
shell: Rscript {0} | ||
run: | | ||
options(renv.config.cache.symlinks = FALSE) | ||
renv::restore(clean = TRUE) | ||
- name: Lint R | ||
if: always() | ||
shell: Rscript {0} | ||
run: | | ||
rhino::lint_r() |
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,11 @@ | ||
# This file allows packrat (used by rsconnect during deployment) to pick up dependencies. | ||
|
||
# Development | ||
library(lintr) | ||
library(yaml) # Used to load config for lintr. | ||
|
||
# Production | ||
library(box) | ||
library(logger) | ||
library(shiny) | ||
library(rhino) |
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,3 @@ | ||
# Only use `dependencies.R` to infer project dependencies. | ||
* | ||
!dependencies.R |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.