This repository has been archived by the owner on Sep 21, 2023. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 37
/
basic-use.Rmd
89 lines (52 loc) · 3.23 KB
/
basic-use.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
---
title: "General Overview"
output: rmarkdown::html_vignette
vignette: >
%\VignetteIndexEntry{Basic Use}
%\VignetteEngine{knitr::rmarkdown}
%\VignetteEncoding{UTF-8}
---
```{r, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
eval = FALSE
)
```
### Introduction
The easiest way to get started building your app is with the `electrify()` function. This is a "metafunction" that calls the other functions of electricShine in the order that the package was intended to build apps.
If you want more control (e.g. icons haven't yet been implemented)...until a more thorough vignette is written, you can use source code of `electrify()` as a guide to step through the build process.
### Getting Started
#### The metafunction
Unless you are customizing the nodejs code, you should only ever have to interact with one function:
`electricShine::electrify()`
### The `run_app()`
Your package must have a function that starts your Shiny app.
- The name of this function is specified through the `functionName` argumnet of `electrify()`:
- e.g. `electricShine::electrify(functionName='run_app')`
The function must have an `options` argument to pass to to `shiny::shinyApp()` (example below).
To modify the example: Replace the `app_ui` with your package's `app_ui` function name. Replace the `app_server` with your package's `app_server` function name.
```{r}
run_app <- function(options = list()) {
shinyApp(ui = app_ui,
server = app_server,
options = options)
}
```
#### The build
By running the `electricShine::electrify()` function your R session will start doing the following things:
- Install nodejs into your electricShine package folder.
- Download R from the MRAN date you provided
- Download the js dependencies (electron, etc) from npm (npm is like CRAN) if they aren't already installed/found.
- Begin the build of your app
This will take some time depending on your internet speed, and computer. The build step is the longest and can take minutes (seems to be IO-limited so a fast hard drive will work best). An internet connection is required.
### The results
In the directory your specified in `buildPath`, you will find a new folder named what you chose for `appName`. Directly inside you will find the raw electron build. Your new electron `.exe` can be found in `buildPath/appName/dist`, where `appName` is what you assigned `electrify(appName = )`.
Advanced: If you want to test the electron app without installing. You can open cmd.exe and `cd` to `buildPath/appName` and if you have nodejs installed and in your `PATH`, use the command `npm start` to initiate the app.
Advanced: If you want to make changes before creating the exe- run the `electricShine::electrify()` with `build = FALSE` and make your changes within `buildPath/appName`. When you're ready to build the installer run the following, using the same `buildPath` and `appName` as in `electricShine::electrify()`.
```{r}
electricShine::run_build_release(nodejs_path = file.path(system.file(package = "electricShine"), "nodejs"),
app_path = file.path(buildPath, appName),
nodejs_version = "12.13.0")
```
You can also run `npm release` from the app's directory.