Skip to content

Commit 77c9011

Browse files
authored
Merge pull request #44 from node-red/rel400
Bump for 4.0 release
2 parents 99b6b0b + 832352f commit 77c9011

File tree

10 files changed

+159
-85
lines changed

10 files changed

+159
-85
lines changed

.github/workflows/tests.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ jobs:
1414
runs-on: ubuntu-latest
1515
strategy:
1616
matrix:
17-
node-version: [14, 16, 18, 20, 22]
17+
node-version: [18, 20, 22]
1818
steps:
1919
- uses: actions/checkout@v4
2020
- name: Use Node.js ${{ matrix.node-version }}
@@ -28,7 +28,7 @@ jobs:
2828
npm run test
2929
npm run coverage
3030
- name: Publish to coveralls.io
31-
if: ${{ matrix.node-version == 16 }}
31+
if: ${{ matrix.node-version == 20 }}
3232
uses: coverallsapp/github-action@v2
3333
with:
3434
github-token: ${{ github.token }}

CHANGELOG.md

+7
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
### 4.0.0
2+
3+
- Update template settings for 4.0
4+
- Update dependencies
5+
- Replace bcrypt with @node-rs/bcrypt
6+
- Set minimum node.js version to 18
7+
18
### 3.1.3
29

310
- Bump axios to 1.6.8 @knolleary

lib/commands/hash.js

+6-10
Original file line numberDiff line numberDiff line change
@@ -15,21 +15,17 @@
1515
**/
1616

1717
var prompt = require("../prompt");
18-
try { bcrypt = require('bcrypt'); }
18+
try { bcrypt = require('@node-rs/bcrypt'); }
1919
catch(e) { bcrypt = require('bcryptjs'); }
2020

21-
function command(argv,result) {
21+
async function command(argv,result) {
2222
if (argv.json) {
2323
console.warn("hash-pw command does not support json format output");
2424
}
25-
return new Promise(resolve => {
26-
prompt.read({prompt:"Password:",silent: true},function(err, password) {
27-
if (password) {
28-
result.log(bcrypt.hashSync(password, 8));
29-
}
30-
resolve();
31-
});
32-
});
25+
const password = await prompt.read({prompt:"Password:",silent: true})
26+
if (password) {
27+
result.log(bcrypt.hashSync(password, 8));
28+
}
3329
}
3430
command.alias = "hash-pw";
3531
command.usage = command.alias;

lib/commands/init/index.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ const fs = require("fs");
2222
const path = require("path");
2323

2424
let bcrypt;
25-
try { bcrypt = require('bcrypt'); }
25+
try { bcrypt = require('@node-rs/bcrypt'); }
2626
catch(e) { bcrypt = require('bcryptjs'); }
2727

2828
function prompt(opts) {

lib/commands/init/resources/settings.js.mustache

+101-18
Original file line numberDiff line numberDiff line change
@@ -136,11 +136,13 @@ module.exports = {
136136
* - httpServerOptions
137137
* - httpAdminRoot
138138
* - httpAdminMiddleware
139+
* - httpAdminCookieOptions
139140
* - httpNodeRoot
140141
* - httpNodeCors
141142
* - httpNodeMiddleware
142143
* - httpStatic
143-
* - httpStaticRoot
144+
* - httpStaticRoot
145+
* - httpStaticCors
144146
******************************************************************************/
145147

146148
/** the tcp port that the Node-RED web server is listening on */
@@ -181,10 +183,15 @@ module.exports = {
181183
// next();
182184
// },
183185

186+
/** The following property can be used to set addition options on the session
187+
* cookie used as part of adminAuth authentication system
188+
* Available options are documented here: https://www.npmjs.com/package/express-session#cookie
189+
*/
190+
// httpAdminCookieOptions: { },
184191

185192
/** Some nodes, such as HTTP In, can be used to listen for incoming http requests.
186193
* By default, these are served relative to '/'. The following property
187-
* can be used to specifiy a different root path. If set to false, this is
194+
* can be used to specify a different root path. If set to false, this is
188195
* disabled.
189196
*/
190197
//httpNodeRoot: '/red-nodes',
@@ -226,10 +233,18 @@ module.exports = {
226233
* to move httpAdminRoot
227234
*/
228235
//httpStatic: '/home/nol/node-red-static/', //single static source
229-
/* OR multiple static sources can be created using an array of objects... */
236+
/**
237+
* OR multiple static sources can be created using an array of objects...
238+
* Each object can also contain an options object for further configuration.
239+
* See https://expressjs.com/en/api.html#express.static for available options.
240+
* They can also contain an option `cors` object to set specific Cross-Origin
241+
* Resource Sharing rules for the source. `httpStaticCors` can be used to
242+
* set a default cors policy across all static routes.
243+
*/
230244
//httpStatic: [
231245
// {path: '/home/nol/pics/', root: "/img/"},
232246
// {path: '/home/nol/reports/', root: "/doc/"},
247+
// {path: '/home/nol/videos/', root: "/vid/", options: {maxAge: '1d'}}
233248
//],
234249

235250
/**
@@ -242,9 +257,26 @@ module.exports = {
242257
*/
243258
//httpStaticRoot: '/static/',
244259

260+
/** The following property can be used to configure cross-origin resource sharing
261+
* in the http static routes.
262+
* See https://github.com/troygoode/node-cors#configuration-options for
263+
* details on its contents. The following is a basic permissive set of options:
264+
*/
265+
//httpStaticCors: {
266+
// origin: "*",
267+
// methods: "GET,PUT,POST,DELETE"
268+
//},
269+
270+
/** The following property can be used to modify proxy options */
271+
// proxyOptions: {
272+
// mode: "legacy", // legacy mode is for non-strict previous proxy determination logic (node-red < v4 compatible)
273+
// },
274+
245275
/*******************************************************************************
246276
* Runtime Settings
247277
* - lang
278+
* - runtimeState
279+
* - diagnostics
248280
* - logging
249281
* - contextStorage
250282
* - exportGlobalContextKeys
@@ -257,6 +289,31 @@ module.exports = {
257289
*/
258290
// lang: "de",
259291

292+
/** Configure diagnostics options
293+
* - enabled: When `enabled` is `true` (or unset), diagnostics data will
294+
* be available at http://localhost:1880/diagnostics
295+
* - ui: When `ui` is `true` (or unset), the action `show-system-info` will
296+
* be available to logged in users of node-red editor
297+
*/
298+
diagnostics: {
299+
/** enable or disable diagnostics endpoint. Must be set to `false` to disable */
300+
enabled: true,
301+
/** enable or disable diagnostics display in the node-red editor. Must be set to `false` to disable */
302+
ui: true,
303+
},
304+
/** Configure runtimeState options
305+
* - enabled: When `enabled` is `true` flows runtime can be Started/Stopped
306+
* by POSTing to available at http://localhost:1880/flows/state
307+
* - ui: When `ui` is `true`, the action `core:start-flows` and
308+
* `core:stop-flows` will be available to logged in users of node-red editor
309+
* Also, the deploy menu (when set to default) will show a stop or start button
310+
*/
311+
runtimeState: {
312+
/** enable or disable flows/state endpoint. Must be set to `false` to disable */
313+
enabled: false,
314+
/** show or hide runtime stop/start options in the node-red editor. Must be set to `false` to hide */
315+
ui: false,
316+
},
260317
/** Configure the logging output */
261318
logging: {
262319
/** Only console logging is currently supported */
@@ -308,19 +365,22 @@ module.exports = {
308365
* will install/load. It can use '*' as a wildcard that matches anything.
309366
*/
310367
externalModules: {
311-
// autoInstall: false, /** Whether the runtime will attempt to automatically install missing modules */
312-
// autoInstallRetry: 30, /** Interval, in seconds, between reinstall attempts */
313-
// palette: { /** Configuration for the Palette Manager */
314-
// allowInstall: true, /** Enable the Palette Manager in the editor */
315-
// allowUpload: true, /** Allow module tgz files to be uploaded and installed */
316-
// allowList: [],
317-
// denyList: []
318-
// },
319-
// modules: { /** Configuration for node-specified modules */
320-
// allowInstall: true,
321-
// allowList: [],
322-
// denyList: []
323-
// }
368+
// autoInstall: false, /** Whether the runtime will attempt to automatically install missing modules */
369+
// autoInstallRetry: 30, /** Interval, in seconds, between reinstall attempts */
370+
// palette: { /** Configuration for the Palette Manager */
371+
// allowInstall: true, /** Enable the Palette Manager in the editor */
372+
// allowUpdate: true, /** Allow modules to be updated in the Palette Manager */
373+
// allowUpload: true, /** Allow module tgz files to be uploaded and installed */
374+
// allowList: ['*'],
375+
// denyList: [],
376+
// allowUpdateList: ['*'],
377+
// denyUpdateList: []
378+
// },
379+
// modules: { /** Configuration for node-specified modules */
380+
// allowInstall: true,
381+
// allowList: [],
382+
// denyList: []
383+
// }
324384
},
325385
326386
@@ -346,6 +406,12 @@ module.exports = {
346406
* a collection of themes to chose from.
347407
*/
348408
{{^editorTheme}}//{{/editorTheme}}theme: "{{editorTheme}}",
409+
410+
/** To disable the 'Welcome to Node-RED' tour that is displayed the first
411+
* time you access the editor for each release of Node-RED, set this to false
412+
*/
413+
//tours: false,
414+
349415
palette: {
350416
/** The following property can be used to order the categories in the editor
351417
* palette. If a node's category is not in the list, the category will get
@@ -367,6 +433,7 @@ module.exports = {
367433
mode: "{{projects.workflow}}"
368434
}
369435
},
436+
370437
codeEditor: {
371438
/** Select the text editor component used by the editor.
372439
* As of Node-RED V3, this defaults to "monaco", but can be set to "ace" if desired
@@ -387,7 +454,19 @@ module.exports = {
387454
//fontFamily: "Cascadia Code, Fira Code, Consolas, 'Courier New', monospace",
388455
//fontLigatures: true,
389456
}
390-
}
457+
},
458+
markdownEditor: {
459+
mermaid: {
460+
/** enable or disable mermaid diagram in markdown document
461+
*/
462+
enabled: true
463+
}
464+
},
465+
466+
multiplayer: {
467+
/** To enable the Multiplayer feature, set this value to true */
468+
enabled: false
469+
},
391470
},
392471

393472
/*******************************************************************************
@@ -400,6 +479,7 @@ module.exports = {
400479
* - ui (for use with Node-RED Dashboard)
401480
* - debugUseColors
402481
* - debugMaxLength
482+
* - debugStatusLength
403483
* - execMaxBufferSize
404484
* - httpRequestTimeout
405485
* - mqttReconnectTime
@@ -455,6 +535,9 @@ module.exports = {
455535
/** The maximum length, in characters, of any message sent to the debug sidebar tab */
456536
debugMaxLength: 1000,
457537

538+
/** The maximum length, in characters, of status messages under the debug node */
539+
//debugStatusLength: 32,
540+
458541
/** Maximum buffer size for the exec node. Defaults to 10Mb */
459542
//execMaxBufferSize: 10000000,
460543

@@ -488,7 +571,7 @@ module.exports = {
488571
*/
489572
//tlsConfigDisableLocalFiles: true,
490573

491-
/** The following property can be used to verify websocket connection attempts.
574+
/** The following property can be used to verify WebSocket connection attempts.
492575
* This allows, for example, the HTTP request headers to be checked to ensure
493576
* they include valid authentication information.
494577
*/

lib/commands/login.js

+23-32
Original file line numberDiff line numberDiff line change
@@ -18,40 +18,31 @@ var request = require("../request");
1818
var config = require("../config");
1919
var prompt = require("../prompt");
2020

21-
function command(argv,result) {
21+
async function command(argv,result) {
2222
config.tokens(null);
23-
return request.request('/auth/login',{}).then(function(resp) {
24-
return new Promise((resolve,reject) => {
25-
if (resp.type) {
26-
if (resp.type == "credentials") {
27-
prompt.read({prompt:"Username:"},function(err, username) {
28-
prompt.read({prompt:"Password:",silent: true},function(err, password) {
29-
request.request('/auth/token', {
30-
method: "POST",
31-
data: {
32-
client_id: 'node-red-admin',
33-
grant_type: 'password',
34-
scope: '*',
35-
username: username,
36-
password: password
37-
}
38-
}).then(function(resp) {
39-
config.tokens(resp);
40-
result.log("Logged in");
41-
resolve();
42-
}).catch(function(resp) {
43-
reject("Login failed");
44-
});
45-
});
46-
});
47-
} else {
48-
reject("Unsupported login type");
23+
const resp = await request.request('/auth/login',{})
24+
if (resp.type) {
25+
if (resp.type == "credentials") {
26+
const username = await prompt.read({prompt:"Username:"})
27+
const password = await prompt.read({prompt:"Password:",silent: true})
28+
const loginResp = await request.request('/auth/token', {
29+
method: "POST",
30+
data: {
31+
client_id: 'node-red-admin',
32+
grant_type: 'password',
33+
scope: '*',
34+
username: username,
35+
password: password
4936
}
50-
} else {
51-
resolve();
52-
}
53-
});
54-
});
37+
}).catch(resp => {
38+
throw new Error("Login failed");
39+
})
40+
config.tokens(loginResp);
41+
result.log("Logged in");
42+
} else {
43+
throw new Error("Unsupported login type");
44+
}
45+
}
5546
}
5647

5748
command.alias = "login";

lib/prompt.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
* limitations under the License.
1515
**/
1616

17-
var read = require("read");
17+
var { read } = require("read");
1818

1919
// This exists purely to provide a place to hook in a unit test mock of the
2020
// read module

0 commit comments

Comments
 (0)