Merge branch 'dev' into master

This commit is contained in:
Stephen McLaughlin
2022-05-03 09:35:32 +01:00
committed by GitHub
267 changed files with 29180 additions and 21709 deletions

View File

@@ -229,5 +229,12 @@ module.exports = {
* @see @node-red/editor-api_auth
* @memberof node-red
*/
auth: api.auth
auth: api.auth,
/**
* The editor authentication api.
* @see @node-red/editor-api_auth
* @memberof node-red
*/
get diagnostics() { return api.diagnostics }
};

View File

@@ -1,6 +1,6 @@
{
"name": "node-red",
"version": "2.2.2",
"version": "3.0.0-beta.1",
"description": "Low-code programming for event-driven applications",
"homepage": "http://nodered.org",
"license": "Apache-2.0",
@@ -31,17 +31,17 @@
"flow"
],
"dependencies": {
"@node-red/editor-api": "2.2.2",
"@node-red/runtime": "2.2.2",
"@node-red/util": "2.2.2",
"@node-red/nodes": "2.2.2",
"@node-red/editor-api": "3.0.0-beta.1",
"@node-red/runtime": "3.0.0-beta.1",
"@node-red/util": "3.0.0-beta.1",
"@node-red/nodes": "3.0.0-beta.1",
"basic-auth": "2.0.1",
"bcryptjs": "2.4.3",
"express": "4.17.2",
"fs-extra": "10.0.0",
"node-red-admin": "^2.2.3",
"express": "4.18.0",
"fs-extra": "10.1.0",
"node-red-admin": "^3.0.0",
"nopt": "5.0.0",
"semver": "7.3.5"
"semver": "7.3.7"
},
"optionalDependencies": {
"bcrypt": "5.0.1"

View File

@@ -302,6 +302,26 @@ httpsPromise.then(function(startupHttps) {
settings.httpNodeAuth = settings.httpNodeAuth || settings.httpAuth;
}
if(settings.httpStatic) {
settings.httpStaticRoot = formatRoot(settings.httpStaticRoot || "/");
const statics = Array.isArray(settings.httpStatic) ? settings.httpStatic : [settings.httpStatic];
const sanitised = [];
for (let si = 0; si < statics.length; si++) {
let sp = statics[si];
if(typeof sp === "string") {
sp = { path: sp, root: "" }
sanitised.push(sp);
} else if (typeof sp === "object" && sp.path ) {
sanitised.push(sp);
} else {
continue;
}
sp.subRoot = formatRoot(sp.root);
sp.root = formatRoot(path.posix.join(settings.httpStaticRoot,sp.subRoot));
}
settings.httpStatic = sanitised.length ? sanitised : false;
}
// if we got a port from command line, use it (even if 0)
// replicate (settings.uiPort = parsedArgs.port||settings.uiPort||1880;) but allow zero
if (parsedArgs.port !== undefined){
@@ -394,12 +414,28 @@ httpsPromise.then(function(startupHttps) {
if (settings.httpNodeRoot !== false) {
app.use(settings.httpNodeRoot,RED.httpNode);
}
// if (settings.httpStatic) {
// settings.httpStaticAuth = settings.httpStaticAuth || settings.httpAuth;
// if (settings.httpStaticAuth) {
// app.use("/",basicAuthMiddleware(settings.httpStaticAuth.user,settings.httpStaticAuth.pass));
// }
// app.use("/",express.static(settings.httpStatic));
// }
if (settings.httpStatic) {
settings.httpStaticAuth = settings.httpStaticAuth || settings.httpAuth;
if (settings.httpStaticAuth) {
app.use("/",basicAuthMiddleware(settings.httpStaticAuth.user,settings.httpStaticAuth.pass));
let appUseMem = {};
for (let si = 0; si < settings.httpStatic.length; si++) {
const sp = settings.httpStatic[si];
const filePath = sp.path;
const thisRoot = sp.root || "/";
if(appUseMem[filePath + "::" + thisRoot]) {
continue;// this path and root already registered!
}
appUseMem[filePath + "::" + thisRoot] = true;
if (settings.httpStaticAuth) {
app.use(thisRoot, basicAuthMiddleware(settings.httpStaticAuth.user, settings.httpStaticAuth.pass));
}
app.use(thisRoot, express.static(filePath));
}
app.use("/",express.static(settings.httpStatic));
}
function getListenPath() {

View File

@@ -137,6 +137,7 @@ module.exports = {
* - httpNodeCors
* - httpNodeMiddleware
* - httpStatic
* - httpStaticRoot
******************************************************************************/
/** the tcp port that the Node-RED web server is listening on */
@@ -218,12 +219,30 @@ module.exports = {
/** When httpAdminRoot is used to move the UI to a different root path, the
* following property can be used to identify a directory of static content
* that should be served at http://localhost:1880/.
* When httpStaticRoot is set differently to httpAdminRoot, there is no need
* to move httpAdminRoot
*/
//httpStatic: '/home/nol/node-red-static/',
//httpStatic: '/home/nol/node-red-static/', //single static source
/* OR multiple static sources can be created using an array of objects... */
//httpStatic: [
// {path: '/home/nol/pics/', root: "/img/"},
// {path: '/home/nol/reports/', root: "/doc/"},
//],
/**
* All static routes will be appended to httpStaticRoot
* e.g. if httpStatic = "/home/nol/docs" and httpStaticRoot = "/static/"
* then "/home/nol/docs" will be served at "/static/"
* e.g. if httpStatic = [{path: '/home/nol/pics/', root: "/img/"}]
* and httpStaticRoot = "/static/"
* then "/home/nol/pics/" will be served at "/static/img/"
*/
//httpStaticRoot: '/static/',
/*******************************************************************************
* Runtime Settings
* - lang
* - diagnostics
* - logging
* - contextStorage
* - exportGlobalContextKeys
@@ -236,6 +255,19 @@ module.exports = {
*/
// lang: "de",
/** Configure diagnostics options
* - enabled: When `enabled` is `true` (or unset), diagnostics data will
* be available at http://localhost:1880/diagnostics
* - ui: When `ui` is `true` (or unset), the action `show-system-info` will
* be available to logged in users of node-red editor
*/
diagnostics: {
/** enable or disable diagnostics endpoint. Must be set to `false` to disable */
enabled: true,
/** enable or disable diagnostics display in the node-red editor. Must be set to `false` to disable */
ui: true,
},
/** Configure the logging output */
logging: {
/** Only console logging is currently supported */
@@ -359,9 +391,9 @@ module.exports = {
codeEditor: {
/** Select the text editor component used by the editor.
* Defaults to "ace", but can be set to "ace" or "monaco"
* As of Node-RED V3, this defaults to "monaco", but can be set to "ace" if desired
*/
lib: "ace",
lib: "monaco",
options: {
/** The follow options only apply if the editor is set to "monaco"
*
@@ -371,7 +403,7 @@ module.exports = {
*/
theme: "vs",
/** other overrides can be set e.g. fontSize, fontFamily, fontLigatures etc.
* for the full list, see https://microsoft.github.io/monaco-editor/api/interfaces/monaco.editor.istandaloneeditorconstructionoptions.html
* for the full list, see https://microsoft.github.io/monaco-editor/api/interfaces/monaco.editor.IStandaloneEditorConstructionOptions.html
*/
//fontSize: 14,
//fontFamily: "Cascadia Code, Fira Code, Consolas, 'Courier New', monospace",