From 5cc791690baa5a4f12cbcb04eeab4f50f8695f9e Mon Sep 17 00:00:00 2001 From: Dave Conway-Jones Date: Fri, 23 Apr 2021 14:09:06 +0100 Subject: [PATCH] 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.