Skip to content

Commit c134a10

Browse files
v5 changes - see changelog
1 parent f6ad987 commit c134a10

14 files changed

Lines changed: 1897 additions & 642 deletions

CHANGELOG.md

Lines changed: 25 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,32 @@
11
# Change Log
22

3-
All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
3+
## 5.0.0
44

5-
alternate-node-red-installer adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
5+
[Code commits since last release](https://github.com/TotallyInformation/alternate-node-red-installer/compare/v3.0.2...v5.0.0).
66

7-
## [Unreleased](https://github.com/TotallyInformation/alternate-node-red-installer/compare/v2.0.2...master)
7+
### Breaking changes
88

9-
None
9+
Node.js v20 is now the minimum supported version.
1010

11-
## [3.0.2](https://github.com/TotallyInformation/alternate-node-red-installer/compare/v3.0.0...v4.0.0)
11+
The npm package name has changed from alternate-node-red-installer to @totallyinformation/nrinstall to allow easier running from `npx`. The old published package has now be deprecated.
12+
13+
### Other changes
14+
15+
* **MAJOR**: You can now run the installer directly with npx without installing globally: `npx @totallyinformation/nrinstall -f <root folder name>`.
16+
* **MAJOR**: The command line command is now `nrinstall` (if you install globally) or `npx @totallyinformation/nrinstall` (if you don't install globally).
17+
* Dependencies updated.
18+
* **MAJOR**: Changed name from alternate-node-red-installer to @totallyinformation/nrinstall to allow easier running from `npx`.
19+
* **MAJOR**: Updated the template example-settings.js file to be current with at least v4.1.8 of Node-RED.
20+
* Changed to ESM modules.
21+
* Updated the dependencies to the latest versions.
22+
23+
## [4.0.0](https://github.com/TotallyInformation/alternate-node-red-installer/compare/v3.0.2...v4.0.0)
24+
25+
**Node.js v18** is now the minimum version supported.
26+
27+
Dependencies updated as far as possible. Some dependencies are ESM only in their latest versions which will require significant rework.
28+
29+
## [3.0.2](https://github.com/TotallyInformation/alternate-node-red-installer/compare/v3.0.0...v3.0.2)
1230

1331
**WARNING**: Although this has the same major version number as the previous release, it is a breaking release. This is to allow the major versions to be aligned to Node-RED itself.
1432

@@ -17,12 +35,12 @@ None
1735
* Minimum version of Node.js supported is now v14 in alignment with Node-RED v3.
1836
* Update to node-red v3.0.2 as minimum - the latest version of node-red will always be installed when `nrinstall` is run.
1937

20-
## Fixed
38+
### Fixed
2139

2240
* Changes to the systemd service file - removing spurious quote characters.
2341
* Changes to the `data/envfile.ini` file - removing spurious quote characters.
2442

25-
## Changed
43+
### Changed
2644

2745
* Update `example-settings.js` to a newer version - aligned to node-red v3.0.2 with enhancements & additional help
2846
* Removed `.eslintrc.js`/`.eslintrc.json` - not required

README.md

Lines changed: 71 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,40 @@
1-
# alternate-node-red-installer
2-
An alternative installer for Node-RED. Avoids global installs, no admin rights required for new Node-RED instances.
1+
# @totallyinformation/nrinstall
2+
3+
An alternative installer for Node-RED. Avoids global installs, no admin rights required for new Node-RED instances. Local install allows full control and even multiple different versions of Node-RED running in parallel. Works on any platform supported by Node.JS. It also includes an enhanced settings.js example file and some additional utility scripts.
34

45
> This solution is particularly suited for development environments and anywhere that you don't want to install global NodeJS scripts. Also when you need to have different versions of Node-RED running in parallel.
56
7+
> [!NOTE]
8+
> That the npm package name for this repository has changed from [`alternate-node-red-installer`](https://www.npmjs.com/package/alternate-node-red-installer) to [`@totallyinformation/nrinstall`](https://www.npmjs.com/package/@totallyinformation/nrinstall) to allow easier running from `npx`. The old published package has now be deprecated.
9+
610
## Getting Started
711

812
1. Make sure that you have Node.JS correctly installed. Check that you can run it manually from the command line with `node --version && npm --version`.
9-
2. Make sure that Node.js is at least at version 8.16.0 (LTS) or above.
10-
3. For ease of use, install this package globally with `npm install -g alternate-node-red-installer`. You may need to use a command line with elevated rights (`sudo` on Linux).
11-
12-
Now, from any command line, you should be able to run the following:
13-
14-
```
15-
alternate-node-red-installer -f <root folder name>
16-
```
13+
2. Make sure that Node.js is at least at version 20 (LTS) or above.
14+
3. Run the installer directly with npx:
15+
16+
```
17+
npx @totallyinformation/nrinstall -f <root folder name>
18+
```
19+
20+
Where <root folder name>` is a relative or absolute folder path that you want to be the root of your new Node-RED installation.
1721

18-
Where <root folder name>` is a relative or absolute folder path that you want to be the root of your new Node-RED installation.
22+
4. Optional: install globally with `npm install -g @totallyinformation/nrinstall`. You may need to use a command line with elevated rights (`sudo` on Linux). Then run as:
1923

20-
Instead of the long-winded executable name, you can also use `nrinstall`
24+
```
25+
nrinstall -f <root folder name>
26+
```
2127

2228
Example (for Mac, Linux or Windows PowerShell):
2329

2430
```
31+
mkdir ~/nrtest
2532
nrinstall -f ~/nrtest
2633
```
2734

2835
Once the install has completed (it may take some time), you can navigate to the data sub-folder and work with Node-RED as normal (e.g. `cd ~/nrtest/data`).
2936

30-
You may wish to adjust the `settings.js` file and install any required Nodes at this point.
37+
You may wish to adjust the `./data/settings.js` file. See the `./data/example-settings.js` file for an example enhanced settings file.
3138

3239
Run `npm run` to see the run commands available for your convenience. They are detailed in the README.md file installed in the data subfolder.
3340

@@ -37,18 +44,20 @@ These instructions should work on any platform supported by Node.JS.
3744

3845
<!-- TOC -->
3946

40-
* [alternate-node-red-installer](#alternate-node-red-installer)
41-
* [Getting Started](#getting-started)
42-
* [Table of Contents](#table-of-contents)
43-
* [Introduction](#introduction)
44-
* [The issue](#the-issue)
45-
* [The solution](#the-solution)
46-
* [The advamtages](#the-advamtages)
47-
* [Starting Node-RED](#starting-node-red)
48-
* [Updating Node-RED and installed nodes](#updating-node-red-and-installed-nodes)
49-
* [Changes](#changes)
50-
* [To Do](#to-do)
51-
* [Prerequisites](#prerequisites)
47+
- [@totallyinformation/nrinstall](#totallyinformationnrinstall)
48+
- [Getting Started](#getting-started)
49+
- [Table of Contents](#table-of-contents)
50+
- [Introduction](#introduction)
51+
- [The issue](#the-issue)
52+
- [The solution](#the-solution)
53+
- [The advamtages](#the-advamtages)
54+
- [Starting Node-RED](#starting-node-red)
55+
- [Updating Node-RED and installed nodes](#updating-node-red-and-installed-nodes)
56+
- [Changes](#changes)
57+
- [To Do](#to-do)
58+
- [Prerequisites](#prerequisites)
59+
- [Sponsorship](#sponsorship)
60+
- [Other links](#other-links)
5261

5362
<!-- /TOC -->
5463

@@ -142,4 +151,40 @@ Please see the [TODO](./TODO.md) file.
142151

143152
## Prerequisites
144153

145-
* NodeJS. v10 is the minimum supported version.
154+
* NodeJS. v20 is the minimum supported version.
155+
156+
## Sponsorship
157+
158+
If you find value in my work, please consider a small sponsorship or other contribution to help me continue to provide free, open source software.
159+
160+
[![ko-fi](https://ko-fi.com/img/githubbutton_sm.svg)](https://ko-fi.com/A0A3PPMRJ)
161+
162+
[GitHub Sponsorship](https://github.com/sponsors/TotallyInformation),
163+
[PayPal Sponsorship](https://paypal.me/TotallyInformation),
164+
[Patreon Sponsorship](https://patreon.com/TotallyInformation?utm_medium=github&utm_source=join_link&utm_campaign=creatorshare_creator&utm_content=copyLink)
165+
166+
## Other links
167+
168+
Here are some other links to my work that you may find interesting:
169+
170+
- ![uib](https://github.com/TotallyInformation/node-red-contrib-uibuilder/raw/main/front-end/images/node-blue.ico) [UIBUILDER for Node-RED](https://github.com/TotallyInformation/node-red-contrib-uibuilder)
171+
-[Ideas, questions & general help](https://discourse.nodered.org/tag/node-red-contrib-uibuilder) - Ask your question on the Node-RED forum using the node-red-contrib-uibuilder tag.
172+
- 📁 [Documentation](https://totallyinformation.github.io/node-red-contrib-uibuilder) - Go to the latest documentation.
173+
- 🧑‍💻 [Flows](https://flows.nodered.org/search?term=uibuilder) - Example flows, nodes and collections related to UIBUILDER.
174+
- ℹ️ [WIKI](https://github.com/TotallyInformation/node-red-contrib-uibuilder/wiki) - More documentation and examples.
175+
- 📂 [Example Svelte External Template](https://github.com/TotallyInformation/uib-template-svelte-simple) - In case you want to build your own svelte app.
176+
- 📂 [Example Simple External Template](https://github.com/TotallyInformation/uib-template-test) - In case you want to build your own external template.
177+
- 📊 [uPlot UIBUILDER extension](https://github.com/TotallyInformation/nr-uibuilder-uplot) - Useful charts but also demonstrates how to build your own extension.
178+
179+
- 🧪 [Web Components Library](https://github.com/TotallyInformation/web-components) - A growing library of useful HTML Web Components. Useable with or without Node-RED & UIBUILDER. Some having specific enhancements for Node-RED but will still work well stand-alone. These now have their own dedicated documentation, demo and test website at https://wc.totallyinformation.net. Please check them out there.
180+
181+
- 🔨 [ui library module used by UIBUILDER](https://github.com/TotallyInformation/ui.js) - Can be used stand-alone for turning UI standard config JSON into HTML.
182+
183+
- 🕜 [node-red-contrib-moment](https://github.com/TotallyInformation/node-red-contrib-moment) - Nodes to make use of the MomentJS date/time handling library in Node-RED.
184+
185+
- 🧪 [Testbed for Node-RED custom nodes](https://github.com/TotallyInformation/Node-RED-Testbed) - Embodying more up-to-date thinking than the test nodes, a blank playground.
186+
- 🧪 [Test Nodes for Node-RED](https://github.com/TotallyInformation/uib-template-test) - Some test nodes for Node-RED that help you understand how everything works.
187+
188+
- 🚤 [HotNipi Gauge Web Component](https://github.com/TotallyInformation/gauge-hotnipi) - A really nice looking gauge component. Works with Node-RED, UIBUILDER, or stand-alone.
189+
190+
- 🧪 [Array Grouper](https://github.com/TotallyInformation/groupit) - Stand-alone function to reshape an array of objects.

TODO.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Alternate Node-RED Installer: To Do
1+
# Alternate Node-RED Installer: To Do (Maybe)
22

33
https://discourse.nodered.org/t/advice-setting-up-node-red-for-a-class/16650
44

Lines changed: 41 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/usr/bin/env node
2-
'use strict'
32
// @ts-nocheck
43

4+
55
/**
66
* Install the Node-RED alternate installation template
77
*
@@ -22,32 +22,38 @@
2222
* -- Job Done! --
2323
*/
2424

25-
const chalk = require('chalk')
26-
const boxen = require('boxen')
27-
const yargs = require('yargs')
28-
const fs = require('fs-extra')
29-
const path = require('path')
30-
//const exec = require('child_process').exec
31-
const util = require('util');
32-
const exec = util.promisify(require('child_process').exec)
33-
const tilib = require('../tilib')
34-
const ora = require('ora') // console spinner
35-
const replace = require('replace-in-file')
25+
import chalk from 'chalk'
26+
import chalkTemplate from 'chalk-template'
27+
import boxen from 'boxen'
28+
import yargs from 'yargs/yargs'
29+
import { hideBin } from 'yargs/helpers'
30+
import fs from 'fs-extra'
31+
import path from 'node:path'
32+
import util from 'node:util'
33+
import { exec as execCb } from 'node:child_process'
34+
import { fileURLToPath } from 'node:url'
35+
import tilib from '../tilib.js'
36+
import ora from 'ora' // console spinner
37+
import { replaceInFile } from 'replace-in-file'
3638

3739
/** Parameters from command line
3840
* @type {Object} options
3941
* @property {string} [folder] - Root folder that will contain the Node-RED installation.
4042
* @property {boolean} [no-color] - Turn off ANSI color output.
4143
*/
42-
const options = yargs
43-
.usage('Usage: -f <root-folder-name>')
44+
const options = yargs(hideBin(process.argv))
45+
.usage('Usage: npx @totallyinformation/nrinstall -f <root-folder-name>\n or if installed globally: nrinstall -f <root-folder-name>')
4446
.option('f', {
4547
alias: 'folder', describe: 'Root folder, Node-RED will be installed here', type: 'string', demandOption: true
4648
})
4749
.option('no-color', {
4850
describe: 'Turn off ANSI color output', type: 'boolean', demandOption: false
4951
})
50-
.argv
52+
.parse()
53+
54+
const exec = util.promisify(execCb)
55+
const __filename = fileURLToPath(import.meta.url)
56+
const __dirname = path.dirname(__filename)
5157

5258
const boxenOptions = {
5359
padding: 1,
@@ -69,7 +75,7 @@ spinner.color = 'yellow'
6975
const folder = path.resolve(options.folder)
7076
const templatesFolder = path.join(__dirname, '..', 'templates')
7177

72-
var msg = chalk`{cyan.bold.underline Alternate Installer for Node-RED}
78+
var msg = chalkTemplate`{cyan.bold.underline Alternate Installer for Node-RED}
7379
7480
{white Root Folder . . :} {green.bold.underline ${folder}}
7581
{white Templates Folder:} {green.bold.underline ${templatesFolder}}
@@ -84,11 +90,11 @@ async function installer(pkgFolder, folder='') {
8490
/** npm commands behave dreadfully. Many will error out even though they actually succeed. */
8591
console.log({folder})
8692
try{
87-
const { stdout, stderr } = await exec('npm install --production --unsafe-perm', {'cwd': folder})
93+
const { stdout, stderr } = await exec('npm install --omit=dev', {'cwd': folder})
8894
out.stdout = stdout
8995
out.stderr = stderr
9096
} catch(err) {
91-
//msg += chalk`\n{red CMD ERROR}\n`
97+
//msg += chalkTemplate`\n{red CMD ERROR}\n`
9298
//console.log(err)
9399
out.stdout = err.stdout
94100
out.stderr = err.stderr
@@ -97,9 +103,9 @@ async function installer(pkgFolder, folder='') {
97103
pkgFolder = tilib.findPackage('node-red', folder)
98104
if ( pkgFolder !== null ) {
99105
const nrPkg = tilib.readPackageJson(pkgFolder) || {'version':'N/A'}
100-
msg += chalk`{green Node-RED v{bold ${nrPkg.version}} successfully installed}\n`
106+
msg += chalkTemplate`{green Node-RED v{bold ${nrPkg.version}} successfully installed}\n`
101107
} else {
102-
msg += chalk`{red.bold Node-RED failed to install}\n`
108+
msg += chalkTemplate`{red.bold Node-RED failed to install}\n`
103109
}
104110
}
105111
}
@@ -119,9 +125,9 @@ async function copyDataTemplate(pkgFolder, folder) {
119125
'errorOnExist': true,
120126
}
121127
)
122-
msg += chalk`{green Copied template data (userDir) folder to ${fldrData}}\n`
128+
msg += chalkTemplate`{green Copied template data (userDir) folder to ${fldrData}}\n`
123129
} catch(err) {
124-
msg += chalk`{red.bold Data (userDir) folder already exists or cannot be created - NOT COPIED - Please use a folder name that does not exist. ${fldrData}}\n`
130+
msg += chalkTemplate`{red.bold Data (userDir) folder already exists or cannot be created - NOT COPIED - Please use a folder name that does not exist. ${fldrData}}\n`
125131
return
126132
}
127133

@@ -131,10 +137,10 @@ async function copyDataTemplate(pkgFolder, folder) {
131137
to: folder,
132138
}
133139
try {
134-
const results = await replace(fileReplaceOpts)
140+
const results = await replaceInFile(fileReplaceOpts)
135141
console.log(`Replaced "<root-folder-name>" with ${folder}`, results)
136142
} catch (error) {
137-
console.error(`FAILED to Replace "<root-folder-name>" with ${folder} - change manually before use`, error)
143+
console.error(`FAILED to Replace "<root-folder-name>" with ${folder} - change manually before use. `, error)
138144
}
139145
}
140146

@@ -149,9 +155,9 @@ async function copyMasterTemplate(pkgFolder, folder) {
149155
'errorOnExist': true,
150156
}
151157
)
152-
msg += chalk`{green Copied template master folder from templates to root folder: ${folder}}\n`
158+
msg += chalkTemplate`{green Copied template master folder from templates to root folder: ${folder}}\n`
153159
} catch(err) {
154-
msg += chalk`{red.bold Root folder already exists or cannot be created - NOT COPIED - Please use a folder name that does not exist. ${folder}}\n`
160+
msg += chalkTemplate`{red.bold Root folder already exists or cannot be created - NOT COPIED - Please use a folder name that does not exist. ${folder}}\n`
155161
return
156162
}
157163

@@ -161,10 +167,10 @@ async function copyMasterTemplate(pkgFolder, folder) {
161167
to: folder,
162168
}
163169
try {
164-
const results = await replace(fileReplaceOpts)
170+
const results = await replaceInFile(fileReplaceOpts)
165171
console.log(`Replaced "<root-folder-name>" with ${folder}`, results)
166172
} catch (error) {
167-
console.error(`FAILED to Replace "<root-folder-name>" with ${folder} - change manually before use`, error)
173+
console.error(`FAILED to Replace "<root-folder-name>" with ${folder} - change manually before use. `, error)
168174
}
169175
}
170176

@@ -178,7 +184,7 @@ async function copySettings(pkgFolder, folder) {
178184

179185
if (pkgFolder === null) pkgFolder = tilib.findPackage('node-red', folder)
180186
if ( pkgFolder !== null ) {
181-
//msg += chalk`{blue \nNode-RED package folder found: ${pkgFolder}\n}`
187+
//msg += chalkTemplate`{blue \nNode-RED package folder found: ${pkgFolder}\n}`
182188

183189
try {
184190
await fs.copy(
@@ -189,13 +195,13 @@ async function copySettings(pkgFolder, folder) {
189195
'errorOnExist': true,
190196
}
191197
)
192-
msg += chalk`{green Copied master settings.js}\n`
193-
msg += 'Check `example-settings.js` if you want an enhanced settings file.\n'
198+
msg += chalkTemplate`{green Copied template settings.js to data folder: ${userDirSettings}}\n`
199+
msg += 'Check `data/example-settings.js` if you want an enhanced settings file.\n'
194200
} catch(err) {
195-
msg += chalk`{red.bold Master settings.js already exists - NOT COPIED}\n`
201+
msg += chalkTemplate`{red.bold Master \`data/settings.js\` already exists - template NOT COPIED}\n`
196202
}
197203
} else {
198-
msg += chalk`\n{bgRed.bold.yellow Node-RED package folder not found }\n`
204+
msg += chalkTemplate`\n{bgRed.bold.yellow Node-RED package folder not found }\n`
199205
}
200206

201207
}
@@ -228,9 +234,9 @@ main(pkgFolder, folder)
228234
.then( () => {
229235
spinner.stop()
230236

231-
console.log(chalk`{cyan.bold NPM COMMAND OUTPUT}`)
237+
console.log(chalkTemplate`{cyan.bold NPM COMMAND OUTPUT}`)
232238
console.log(out.stdout)
233-
console.log(chalk`{magenta.bold NPM COMMAND ERROR OUTPUT}`)
239+
console.log(chalkTemplate`{magenta.bold NPM COMMAND ERROR OUTPUT}`)
234240
console.log(out.stderr)
235241
})
236242
.catch( (err) => { // belt & braces

0 commit comments

Comments
 (0)