-
Notifications
You must be signed in to change notification settings - Fork 23
/
nodejs-develop-plugins.md
17 lines (11 loc) · 1.93 KB
/
nodejs-develop-plugins.md
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
### About Flow's TypeScript/JavaScript plugins
Plugins written in TypeScript/JavaScript use the [JSON-RPC](https://flow-launcher.github.io/docs/#/json-rpc) protocol to communicate with Flow via JSON structured calls.
Although not a hard requirement, this guide will use Node.js to run the TypeScript/JavaScript. We will refer to TypeScript/JavaScript plugin as Node.js plugin from here on.
When building a Node.js plugins there are several things to be mindful of:
* The most important thing is we do not expect users to have to manually install the dependencies via npm because we aim to provide a seamless experience for them. This can be achieved by adding the following three things to your project:
1. Add a GitHub workflow- use a GitHub workflow that will install all your plugin's dependencies including the modules inside a folder called 'node_modules'.
2. Publish all as a zip- zip up your project including a lib directory that contains the modules and publish it to GitHub Releases page.
3. Point your module path to the node_modules directory- reference all the modules to that directory.
* Users can use their system-installed Node.js with Flow Launcher, but in most circumstances, they will most likely be using Flow Launcher's download of [Node.js](https://nodejs.org/dist/v16.18.0/node-v16.18.0-win-x64.zip)). This download of portable Node.js version is isolated from the user's system and can be simply removed.
### Simple Example
Have a look at this simple example plugin [here](https://github.com/Flow-Launcher/Flow.Launcher.Plugin.HelloWorldNodeJS), notice it has a folder called '.github/workflows' and a file called 'Publish Release.yml'. This is the workflow file that GitHub Workflow uses to run the CI/CD for the project. Moving out of that folder you can go into the [main.js](https://github.com/Flow-Launcher/Flow.Launcher.Plugin.HelloWorldNodeJS/blob/main/main.js) file, this is the entry file for your plugin.