Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
jhk0530 committed Jan 18, 2024
2 parents 9f0272b + 46dcd30 commit c591344
Showing 1 changed file with 18 additions and 17 deletions.
35 changes: 18 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@
<a href='https://www.r-bloggers.com/2023/03/creating-standalone-apps-from-shiny-with-electron-2023-macos-m1/' target ='_blank'>Creating Standalone Apps from Shiny with Electron [2023, macOS M1]</a>

## Versions info
![NodeJS](https://img.shields.io/badge/node.js-18.17.1-6DA55F?style=for-the-badge&logo=node.js&logoColor=white)
![NodeJS](https://img.shields.io/badge/node.js-20.11.0-6DA55F?style=for-the-badge&logo=node.js&logoColor=white)
![NPM](https://img.shields.io/badge/NPM-10.3.0-%23CB3837.svg?style=for-the-badge&logo=npm&logoColor=white)
![RStudio](https://img.shields.io/badge/RStudio-2023.12.0-4285F4?style=for-the-badge&logo=rstudio&logoColor=white)
![R](https://img.shields.io/badge/r-4.3.2-%23276DC3.svg?style=for-the-badge&logo=r&logoColor=white)
![R](https://img.shields.io/badge/r-4.3.1-%23276DC3.svg?style=for-the-badge&logo=r&logoColor=white)
![Electron.js](https://img.shields.io/badge/Electron-7.2.0-191970?style=for-the-badge&logo=Electron&logoColor=white)
![windowOS](https://img.shields.io/badge/windows-10-AAA?style=for-the-badge&logo=microsoft)

Expand All @@ -43,23 +43,24 @@
2. Install **Node.js**: from <a href = "https://nodejs.org/en/" target = "_blank"> offical page </a>
3. Install **Electron Forge** using `npm` (`npm` is installed with `Node.js`)
4. In the **Terminal**, run `sudo npm i -g @electron-forge/cli`, (`sudo` requires password)
5. Install **Innoextract** from <a href='https://constexpr.org/innoextract/' target ='_blank'>this link</a> (Windows Only) and move it to program files and add Environment variable PATH (See [this](https://stackoverflow.com/questions/53193489/path-variable-in-environmental-variable-accepts-only-one-path)

> [!NOTE]
> Check your versions of `node` and `npm` in **Terminal** with `node -v`, `npm -v`.
5. Give **Star** ⭐, **Fork** this repository to your own account. Then **clone** it to your local PC
6. Give **Star** ⭐, **Fork** this repository to your own account. Then **clone** it to your local PC

### B. Elecron project

6. Open an R project with cloned repository's `.Rproj` file.
7. In your project directory (may `Github/shiny-electron-template-m1`), install **Electron** locally by running `npx create-electron-app <APPNAME>`.
7. Open an R project with cloned repository's `.Rproj` file.
8. In your project directory (may `Github/shiny-electron-template-m1`), install **Electron** locally by running `npx create-electron-app <APPNAME>`.

> [!WARNING]
> You can not use `app` as `<APPNAME>` <br>
> Assume using `myapp` in this tutorial
8. In your `myapp` folder, **delete** `src` directory
9. Copy (or move) below files to your `myapp` folder:
9. In your `myapp` folder, **delete** `src` directory
10. Copy (or move) below files to your `myapp` folder:

- `get-r-win.sh`: For install local R for electron app.
- `add-cran-binary-pkgs.R`: For install R packages into your project locally
Expand All @@ -76,48 +77,48 @@
- src/loading.html
- `src/main.js`: configure shiny electron app (like `width`, `height`)

10. Change your directory to new app folder `cd myapp` with **Terminal**
11. Change your directory to new app folder `cd myapp` with **Terminal**

### C. Setup R

11. Install local R with `sh ./get-r-win.sh`
12. Install local R with `sh ./get-r-win.sh`
- First, check the version of R on your machine. In the R **Console**, run `version`.

> [!WARNING]
> **Your PC's R version** and **electron's R version** must same
12. Build `app.R` as your application's code.
13. Build `app.R` as your application's code.

> [!NOTE]
> not only `app.R` also other required files for shiny application (like `/www`)
13. If you don't have the `automagic` package installed, run `install.packages("automagic")` in the **console**.
14. If you don't have the `automagic` package installed, run `install.packages("automagic")` in the **console**.

14. In the Rstudio **terminal**, run `Rscript add-cran-binary-pkgs.R` to get packages for R.
15. In the Rstudio **terminal**, run `Rscript add-cran-binary-pkgs.R` to get packages for R.

> [!NOTE]
> If your shiny application uses not-CRAN packages (like `github` / `bioconductor`), See **Add not-CRAN packages** below.
>
### D. Setup electron

15. Change `package.json` as <a target = "_blank" href='%5Bfix%5D%20package-json'>`[fix] packages-json`</a>'s content. And modify **author** information.
16. Change `package.json` as <a target = "_blank" href='%5Bfix%5D%20package-json'>`[fix] packages-json`</a>'s content. And modify **author** information.

> [!NOTE]
> Node package's version confirmed in 2024.01
16. Change `forge.config.js` as <a target = "_blank" href = '/%5Bfix%5D%20forge-config-js'>`[fix] forge.config.js`</a>'s content.
17. Change `forge.config.js` as <a target = "_blank" href = '/%5Bfix%5D%20forge-config-js'>`[fix] forge.config.js`</a>'s content.

17. Run `npm install` in **Terminal** to add new dependencies you listed in `package.json` to the **node_modules** folder.
18. Run `npm install` in **Terminal** to add new dependencies you listed in `package.json` to the **node_modules** folder.

### E. Build shiny.exe

> [!NOTE]
> You need to run step after this, **whenever** you want to update shiny application.
18. Test your shiny application work by `electron-forge start` in **Terminal**.
19. Test your shiny application work by `electron-forge start` in **Terminal**.

19. If the app runs successfully, congratulations! Create the `.exe`(as ZIP) on the `electron-forge make` in **Terminal**. Your app can be found in the **/out** folder. (Strongly recommend to **open with Administrator**)
20. If the app runs successfully, congratulations! Create the `.exe`(as ZIP) on the `electron-forge make` in **Terminal**. Your app can be found in the **/out** folder. (Strongly recommend to **open with Administrator**)

------------------------------------------------------------------------

Expand Down

0 comments on commit c591344

Please sign in to comment.