electron-node-red/README.md

87 wiersze
3.5 KiB
Markdown
Czysty Zwykły widok Historia

2019-10-27 21:58:54 +00:00
# Electron Node-RED
[![GitHub version](https://badge.fury.io/gh/dceejay%2Felectron-node-red.svg)](https://badge.fury.io/gh/dceejay%2Felectron-node-red)
2019-11-03 23:34:46 +00:00
[![GitHub license](https://img.shields.io/github/license/dceejay/electron-node-red.svg)](https://github.com/dceejay/electron-node-red/blob/master/LICENSE)
2016-03-09 21:49:41 +00:00
2019-10-23 22:46:16 +00:00
This is an Electron template to embed [Node-RED](https://nodered.org) with a Dashboard generated by node-red-dashboard to create a native application.
2019-10-23 22:46:16 +00:00
This is not intended to be a useful tool as-is, but as a base for you to create your own versions. You will need to edit the `main.js` to suit your application and update the `package.json` file to include your own required nodes and dependencies.
2019-10-23 22:46:16 +00:00
At the top of `main.js` are a couple of flags you can switch to turn off editing, allow loading of a different flow file (and save as), and add the worldmap to the menu. Again these are only there to show you possibilities. Have fun.
2016-03-09 21:49:41 +00:00
2019-10-24 13:30:24 +00:00
## Configuring the project for building
2016-03-09 21:49:41 +00:00
2019-10-23 22:46:16 +00:00
This project uses the **electron-builder** project to help build native versions
2019-11-03 22:12:35 +00:00
of Node-RED applications, so please read and become familiar with their
[documentation](https://www.electron.build/) as some basic knowledge is assumed.
2019-10-23 22:46:16 +00:00
2019-11-03 22:12:35 +00:00
As a pre-req, as well as a recent version of node.js, you will need the **yarn** install tool.
2016-03-09 21:49:41 +00:00
```bash
# Clone this repository
2016-10-29 13:43:32 +00:00
git clone https://github.com/dceejay/electron-node-red.git
2016-03-09 21:49:41 +00:00
# Go into the repository
2016-03-09 21:59:34 +00:00
cd electron-node-red
2019-10-23 22:46:16 +00:00
# Install the yarn install tool globally
sudo npm i -g yarn
# Install project dependencies
yarn
2016-03-09 21:49:41 +00:00
```
2019-10-23 22:46:16 +00:00
## Building local runtime
2019-10-23 22:46:16 +00:00
You should then be able to run
2019-11-03 22:12:35 +00:00
```bash
2019-10-23 22:46:16 +00:00
yarn && yarn dist
```
2019-10-23 22:46:16 +00:00
to create a runtime for your local platform.
2019-11-03 22:12:35 +00:00
However - there may be some errors. If so they are usually fairly self explanatory,
and may just require installation of another npm or brew or apt package,
2019-10-24 08:38:26 +00:00
then retry the command.
2016-05-06 12:18:15 +00:00
2019-10-24 08:38:26 +00:00
Runtimes are created in the `dist` directory under the `electron-node-red` project.
2016-10-29 13:43:32 +00:00
2019-10-23 22:46:16 +00:00
### Building for other platforms
2016-05-06 12:18:15 +00:00
2019-10-23 22:46:16 +00:00
Generally you can just add the required parameter to the command
2019-11-03 22:12:35 +00:00
```bash
2019-10-23 22:46:16 +00:00
yarn && yarn dist -w // for windows
yarn && yarn dist -l // for linux
yarn && yarn dist -m // for mac
```
2016-05-10 11:39:24 +00:00
2019-10-23 22:46:16 +00:00
These will generally fail the first time through and you will need to install some extra library in order to make it
complete successfully.
2016-10-30 22:06:48 +00:00
2019-10-26 17:30:16 +00:00
The defaults are to build a `.msi` for Windows, a `.dmg` for Mac, and both a `.deb` and `.rpm` for Linux.
2019-10-23 22:46:16 +00:00
These can be changed by editing the build section of the `package.json` file, see the
[electron-builder config docs](https://www.electron.build/configuration/configuration) for more info.
2016-10-30 22:06:48 +00:00
2019-10-24 13:30:24 +00:00
## Building multi platform using Docker
2019-10-24 13:30:24 +00:00
Electron-builder has a pre-configured Docker image that can help you build cross platform
images if you like Docker - again read [their docs](https://www.electron.build/multi-platform-build#build-electron-app-using-docker-on-a-local-machine).
2019-10-27 21:58:54 +00:00
This is very useful if you need to build for Windows on a Mac as the electron-builder invokes wine which is only 32-bit and so can't be run under Catalina.
2019-10-24 13:30:24 +00:00
## Developing and Testing - Running locally
While developing and testing you can just run your app locally by running
2019-11-03 22:12:35 +00:00
```bash
2019-10-23 22:46:16 +00:00
npm start
```
2019-11-03 22:12:35 +00:00
2019-10-23 22:46:16 +00:00
from within the project folder.
2016-05-20 10:20:54 +00:00
2019-10-24 08:38:26 +00:00
The initial flow file is named `electronflow.json` along with it's credentials file
`electronflow_cred.json`. Just copy your existing flow in instead.
2019-10-24 13:30:24 +00:00
The default is to start on the dashboard page - as this is intended to be just an application - without the Node-RED editor exposed to the end user, but there are some simple flags to
to configure this at the top of `main.js`.
2019-10-24 08:38:26 +00:00
2019-11-03 22:12:35 +00:00
---