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 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.

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().

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.