From 5cc791690baa5a4f12cbcb04eeab4f50f8695f9e Mon Sep 17 00:00:00 2001 From: Dave Conway-Jones Date: Fri, 23 Apr 2021 14:09:06 +0100 Subject: [PATCH 1/9] fix flowfile name to flows.json in settings and warn if not set (as if anyone reads warnings) Move setting to top of settings.js as it will be edited more often. Default behaviour will still work (needs translations) --- .../lib/storage/localfilesystem/projects/index.js | 6 +++++- .../@node-red/runtime/locales/en-US/runtime.json | 1 + packages/node_modules/node-red/settings.js | 14 +++++++------- 3 files changed, 13 insertions(+), 8 deletions(-) diff --git a/packages/node_modules/@node-red/runtime/lib/storage/localfilesystem/projects/index.js b/packages/node_modules/@node-red/runtime/lib/storage/localfilesystem/projects/index.js index 0533fe5e6..1734192bf 100644 --- a/packages/node_modules/@node-red/runtime/lib/storage/localfilesystem/projects/index.js +++ b/packages/node_modules/@node-red/runtime/lib/storage/localfilesystem/projects/index.js @@ -38,6 +38,8 @@ var activeProject; var globalGitUser = false; +var usingHostName = false; + function init(_settings, _runtime) { settings = _settings; runtime = _runtime; @@ -77,6 +79,7 @@ function init(_settings, _runtime) { } else { flowsFile = 'flows_'+require('os').hostname()+'.json'; flowsFullPath = fspath.join(settings.userDir,flowsFile); + usingHostName = true; } var ffExt = fspath.extname(flowsFullPath); var ffBase = fspath.basename(flowsFullPath,ffExt); @@ -526,7 +529,7 @@ async function getFlows() { if (projectsEnabled) { log.info(log._("storage.localfilesystem.projects.projects-directory", {projectsDirectory: projectsDir})); } - + if (activeProject) { // At this point activeProject will be a string, so go load it and // swap in an instance of Project @@ -541,6 +544,7 @@ async function getFlows() { } else { projectLogMessages.forEach(log.warn); } + if (usingHostName) { log.warn(log._("storage.localfilesystem.warn_name")) }; log.info(log._("storage.localfilesystem.flows-file",{path:flowsFullPath})); } } diff --git a/packages/node_modules/@node-red/runtime/locales/en-US/runtime.json b/packages/node_modules/@node-red/runtime/locales/en-US/runtime.json index 1a29f32b4..7d3293c13 100644 --- a/packages/node_modules/@node-red/runtime/locales/en-US/runtime.json +++ b/packages/node_modules/@node-red/runtime/locales/en-US/runtime.json @@ -159,6 +159,7 @@ "restore": "Restoring __type__ file backup : __path__", "restore-fail": "Restoring __type__ file backup failed : __message__", "fsync-fail": "Flushing file __path__ to disk failed : __message__", + "warn_name": "Flows file name not explicitly set. Using hostname.", "projects": { "changing-project": "Setting active project : __project__", "active-project": "Active project : __project__", diff --git a/packages/node_modules/node-red/settings.js b/packages/node_modules/node-red/settings.js index 331654ed8..ec9fe74a0 100644 --- a/packages/node_modules/node-red/settings.js +++ b/packages/node_modules/node-red/settings.js @@ -12,6 +12,13 @@ **/ module.exports = { + // The file containing the flows. If not set, it defaults to flows_.json + flowFile: 'flows.json', + + // To enabled pretty-printing of the flow within the flow file, set the following + // property to true: + //flowFilePretty: true, + // the tcp port that the Node-RED web server is listening on uiPort: process.env.PORT || 1880, @@ -61,13 +68,6 @@ module.exports = { // Colourise the console output of the debug node //debugUseColors: true, - // The file containing the flows. If not set, it defaults to flows_.json - //flowFile: 'flows.json', - - // To enabled pretty-printing of the flow within the flow file, set the following - // property to true: - //flowFilePretty: true, - // By default, credentials are encrypted in storage using a generated key. To // specify your own secret, set the following property. // If you want to disable encryption of credentials, set this property to false. From dd12572b1d21f594d64b3f1d62b3e9e69535a124 Mon Sep 17 00:00:00 2001 From: Nick O'Leary Date: Fri, 23 Apr 2021 14:30:50 +0100 Subject: [PATCH 2/9] Allow node16 build to fail for now --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index 4cffa0389..e99bc9270 100644 --- a/.travis.yml +++ b/.travis.yml @@ -13,6 +13,7 @@ matrix: - node_js: "12" script: - ./node_modules/.bin/grunt no-coverage + allow_failures: - node_js: "16" script: - ./node_modules/.bin/grunt no-coverage From fdd0a93bada06890c4c9e22c3b86007ec95449a2 Mon Sep 17 00:00:00 2001 From: Dave Conway-Jones Date: Fri, 23 Apr 2021 15:42:57 +0100 Subject: [PATCH 3/9] Deprecate use of httpRoot in settings and add warning (no change is actual behaviour yet - just warning) Should we remove option from settings ? or just label it ? --- packages/node_modules/@node-red/runtime/lib/index.js | 3 +++ .../@node-red/runtime/locales/en-US/runtime.json | 5 +++-- packages/node_modules/node-red/settings.js | 2 +- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/packages/node_modules/@node-red/runtime/lib/index.js b/packages/node_modules/@node-red/runtime/lib/index.js index 30481740f..d10ec18ea 100644 --- a/packages/node_modules/@node-red/runtime/lib/index.js +++ b/packages/node_modules/@node-red/runtime/lib/index.js @@ -181,6 +181,9 @@ function start() { if (settings.settingsFile) { log.info(log._("runtime.paths.settings",{path:settings.settingsFile})); } + if (settings.httpRoot !== undefined) { + log.warn(log._("server.httproot-deprecated")); + } if (settings.httpStatic) { log.info(log._("runtime.paths.httpStatic",{path:path.resolve(settings.httpStatic)})); } diff --git a/packages/node_modules/@node-red/runtime/locales/en-US/runtime.json b/packages/node_modules/@node-red/runtime/locales/en-US/runtime.json index 1a29f32b4..c51b463ed 100644 --- a/packages/node_modules/@node-red/runtime/locales/en-US/runtime.json +++ b/packages/node_modules/@node-red/runtime/locales/en-US/runtime.json @@ -42,7 +42,7 @@ "uninstall-failed-long": "Uninstall of module __name__ failed:", "uninstalled": "Uninstalled module: __name__" }, - "deprecatedOption": "Use of __old__ is deprecated. Use __new__ instead", + "deprecatedOption": "Use of __old__ is DEPRECATED. Use __new__ instead", "unable-to-listen": "Unable to listen on __listenpath__", "port-in-use": "Error: port in use", "uncaught-exception": "Uncaught Exception:", @@ -50,7 +50,8 @@ "now-running": "Server now running at __listenpath__", "failed-to-start": "Failed to start server:", "headless-mode": "Running in headless mode", - "httpadminauth-deprecated": "use of httpAdminAuth is deprecated. Use adminAuth instead", + "httpadminauth-deprecated": "Use of httpAdminAuth is DEPRECATED. Use adminAuth instead", + "httproot-deprecated": "Use of httpRoot is DEPRECATED. Use httpNodeRoot and httpAdminRoot instead", "https": { "refresh-interval": "Refreshing https settings every __interval__ hours", "settings-refreshed": "Server https settings have been refreshed", diff --git a/packages/node_modules/node-red/settings.js b/packages/node_modules/node-red/settings.js index 331654ed8..f68d502c0 100644 --- a/packages/node_modules/node-red/settings.js +++ b/packages/node_modules/node-red/settings.js @@ -96,7 +96,7 @@ module.exports = { // disabled. //httpNodeRoot: '/red-nodes', - // The following property can be used in place of 'httpAdminRoot' and 'httpNodeRoot', + // **DEPRECATED** The following property can be used in place of 'httpAdminRoot' and 'httpNodeRoot', // to apply the same root to both parts. //httpRoot: '/red', From 8732e89e55f987aabbde69d55a24efc3885bba94 Mon Sep 17 00:00:00 2001 From: Dave Conway-Jones Date: Fri, 23 Apr 2021 16:22:50 +0100 Subject: [PATCH 4/9] Update packages/node_modules/@node-red/runtime/locales/en-US/runtime.json Co-authored-by: Nick O'Leary --- .../node_modules/@node-red/runtime/locales/en-US/runtime.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/node_modules/@node-red/runtime/locales/en-US/runtime.json b/packages/node_modules/@node-red/runtime/locales/en-US/runtime.json index 7d3293c13..5e08dd55a 100644 --- a/packages/node_modules/@node-red/runtime/locales/en-US/runtime.json +++ b/packages/node_modules/@node-red/runtime/locales/en-US/runtime.json @@ -159,7 +159,7 @@ "restore": "Restoring __type__ file backup : __path__", "restore-fail": "Restoring __type__ file backup failed : __message__", "fsync-fail": "Flushing file __path__ to disk failed : __message__", - "warn_name": "Flows file name not explicitly set. Using hostname.", + "warn_name": "Flows file name not set. Generating name using hostname.", "projects": { "changing-project": "Setting active project : __project__", "active-project": "Active project : __project__", From 56fe2014e1ac3b213964475ddbd05902a10dd1d7 Mon Sep 17 00:00:00 2001 From: Dave Conway-Jones Date: Fri, 23 Apr 2021 16:36:15 +0100 Subject: [PATCH 5/9] Update packages/node_modules/@node-red/runtime/lib/index.js Co-authored-by: Nick O'Leary --- packages/node_modules/@node-red/runtime/lib/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/node_modules/@node-red/runtime/lib/index.js b/packages/node_modules/@node-red/runtime/lib/index.js index d10ec18ea..d95076e86 100644 --- a/packages/node_modules/@node-red/runtime/lib/index.js +++ b/packages/node_modules/@node-red/runtime/lib/index.js @@ -182,7 +182,7 @@ function start() { log.info(log._("runtime.paths.settings",{path:settings.settingsFile})); } if (settings.httpRoot !== undefined) { - log.warn(log._("server.httproot-deprecated")); + log.warn(log._("server.deprecatedOption",{old:"httpRoot", new: "httpNodeRoot/httpAdminRoot")); } if (settings.httpStatic) { log.info(log._("runtime.paths.httpStatic",{path:path.resolve(settings.httpStatic)})); From 37981679082f49ceac8bbdee95589e9057bbb6bd Mon Sep 17 00:00:00 2001 From: Dave Conway-Jones Date: Fri, 23 Apr 2021 16:36:22 +0100 Subject: [PATCH 6/9] Update packages/node_modules/@node-red/runtime/locales/en-US/runtime.json Co-authored-by: Nick O'Leary --- .../node_modules/@node-red/runtime/locales/en-US/runtime.json | 1 - 1 file changed, 1 deletion(-) diff --git a/packages/node_modules/@node-red/runtime/locales/en-US/runtime.json b/packages/node_modules/@node-red/runtime/locales/en-US/runtime.json index c51b463ed..0f87ad1fa 100644 --- a/packages/node_modules/@node-red/runtime/locales/en-US/runtime.json +++ b/packages/node_modules/@node-red/runtime/locales/en-US/runtime.json @@ -51,7 +51,6 @@ "failed-to-start": "Failed to start server:", "headless-mode": "Running in headless mode", "httpadminauth-deprecated": "Use of httpAdminAuth is DEPRECATED. Use adminAuth instead", - "httproot-deprecated": "Use of httpRoot is DEPRECATED. Use httpNodeRoot and httpAdminRoot instead", "https": { "refresh-interval": "Refreshing https settings every __interval__ hours", "settings-refreshed": "Server https settings have been refreshed", From b053e02174a8993c4c82de35ca2c98095de9e89c Mon Sep 17 00:00:00 2001 From: Dave Conway-Jones Date: Fri, 23 Apr 2021 16:38:45 +0100 Subject: [PATCH 7/9] remove httpRoot from setting.js entirely --- packages/node_modules/node-red/settings.js | 4 ---- 1 file changed, 4 deletions(-) diff --git a/packages/node_modules/node-red/settings.js b/packages/node_modules/node-red/settings.js index f68d502c0..a8f445c5b 100644 --- a/packages/node_modules/node-red/settings.js +++ b/packages/node_modules/node-red/settings.js @@ -96,10 +96,6 @@ module.exports = { // disabled. //httpNodeRoot: '/red-nodes', - // **DEPRECATED** The following property can be used in place of 'httpAdminRoot' and 'httpNodeRoot', - // to apply the same root to both parts. - //httpRoot: '/red', - // 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/. From b62e4f6662b02bbf47d4d70381e84410e38f341b Mon Sep 17 00:00:00 2001 From: Nick O'Leary Date: Mon, 26 Apr 2021 14:43:06 +0100 Subject: [PATCH 8/9] Fix deprecation of httpRoot --- packages/node_modules/@node-red/runtime/lib/index.js | 2 +- packages/node_modules/node-red/red.js | 1 - packages/node_modules/node-red/settings.js | 2 +- 3 files changed, 2 insertions(+), 3 deletions(-) diff --git a/packages/node_modules/@node-red/runtime/lib/index.js b/packages/node_modules/@node-red/runtime/lib/index.js index d95076e86..fd3fda721 100644 --- a/packages/node_modules/@node-red/runtime/lib/index.js +++ b/packages/node_modules/@node-red/runtime/lib/index.js @@ -182,7 +182,7 @@ function start() { log.info(log._("runtime.paths.settings",{path:settings.settingsFile})); } if (settings.httpRoot !== undefined) { - log.warn(log._("server.deprecatedOption",{old:"httpRoot", new: "httpNodeRoot/httpAdminRoot")); + log.warn(log._("server.deprecatedOption",{old:"httpRoot", new: "httpNodeRoot/httpAdminRoot"})); } if (settings.httpStatic) { log.info(log._("runtime.paths.httpStatic",{path:path.resolve(settings.httpStatic)})); diff --git a/packages/node_modules/node-red/red.js b/packages/node_modules/node-red/red.js index 55e355a7c..436537873 100755 --- a/packages/node_modules/node-red/red.js +++ b/packages/node_modules/node-red/red.js @@ -263,7 +263,6 @@ httpsPromise.then(function(startupHttps) { settings.httpAdminRoot = false; settings.httpNodeRoot = false; } else { - settings.httpRoot = settings.httpRoot||"/"; settings.disableEditor = settings.disableEditor||false; } diff --git a/packages/node_modules/node-red/settings.js b/packages/node_modules/node-red/settings.js index 9fb20f9ce..b0243180f 100644 --- a/packages/node_modules/node-red/settings.js +++ b/packages/node_modules/node-red/settings.js @@ -106,7 +106,7 @@ module.exports = { //apiMaxLength: '5mb', // If you installed the optional node-red-dashboard you can set it's path - // relative to httpRoot + // relative to httpNodeRoot // Other optional properties include // readOnly:{boolean}, // middleware:{function or array}, (req,res,next) - http middleware From ea50ba16f9e7230f2afcb36349ec7442d42b58cc Mon Sep 17 00:00:00 2001 From: Nick O'Leary Date: Mon, 26 Apr 2021 14:47:50 +0100 Subject: [PATCH 9/9] Move Inject node to CronosJS module --- package.json | 2 +- .../node_modules/@node-red/nodes/core/common/20-inject.js | 4 ++-- packages/node_modules/@node-red/nodes/package.json | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/package.json b/package.json index 9df66ddf4..573c76ee1 100644 --- a/package.json +++ b/package.json @@ -37,7 +37,7 @@ "cookie": "0.4.1", "cookie-parser": "1.4.5", "cors": "2.8.5", - "cron": "1.7.2", + "cronosjs": "1.7.1", "denque": "1.5.0", "express": "4.17.1", "express-session": "1.17.1", diff --git a/packages/node_modules/@node-red/nodes/core/common/20-inject.js b/packages/node_modules/@node-red/nodes/core/common/20-inject.js index b1db94ff5..772e238a3 100644 --- a/packages/node_modules/@node-red/nodes/core/common/20-inject.js +++ b/packages/node_modules/@node-red/nodes/core/common/20-inject.js @@ -16,7 +16,7 @@ module.exports = function(RED) { "use strict"; - var cron = require("cron"); + const {scheduleTask} = require("cronosjs"); function InjectNode(n) { RED.nodes.createNode(this,n); @@ -85,7 +85,7 @@ module.exports = function(RED) { if (RED.settings.verbose) { this.log(RED._("inject.crontab", this)); } - this.cronjob = new cron.CronJob(this.crontab, function() { node.emit("input", {}); }, null, true); + this.cronjob = scheduleTask(this.crontab,() => { node.emit("input", {})}); } }; diff --git a/packages/node_modules/@node-red/nodes/package.json b/packages/node_modules/@node-red/nodes/package.json index a1a8fc5ce..c46d4f975 100644 --- a/packages/node_modules/@node-red/nodes/package.json +++ b/packages/node_modules/@node-red/nodes/package.json @@ -22,7 +22,7 @@ "cookie-parser": "1.4.5", "cookie": "0.4.1", "cors": "2.8.5", - "cron": "1.7.2", + "cronosjs": "1.7.1", "denque": "1.5.0", "fs-extra": "9.1.0", "fs.notify": "0.0.4",