From 29e903e1c8067fc10ddb9a11cf08194bcb3fe779 Mon Sep 17 00:00:00 2001 From: Nick O'Leary Date: Thu, 30 Sep 2021 15:28:09 +0100 Subject: [PATCH] Improve error reporting when installing bad nodes --- .../editor-client/locales/en-US/editor.json | 3 ++- .../@node-red/editor-client/src/js/nodes.js | 13 ++++++--- .../@node-red/registry/lib/installer.js | 27 ++++++++++++++----- 3 files changed, 32 insertions(+), 11 deletions(-) diff --git a/packages/node_modules/@node-red/editor-client/locales/en-US/editor.json b/packages/node_modules/@node-red/editor-client/locales/en-US/editor.json index 95c803216..e6f927ca1 100755 --- a/packages/node_modules/@node-red/editor-client/locales/en-US/editor.json +++ b/packages/node_modules/@node-red/editor-client/locales/en-US/editor.json @@ -544,7 +544,8 @@ "nodeEnabled_plural": "Nodes enabled:", "nodeDisabled": "Node disabled:", "nodeDisabled_plural": "Nodes disabled:", - "nodeUpgraded": "Node module __module__ upgraded to version __version__" + "nodeUpgraded": "Node module __module__ upgraded to version __version__", + "unknownNodeRegistered": "Unrecognised node type registered: " }, "editor": { "title": "Manage palette", diff --git a/packages/node_modules/@node-red/editor-client/src/js/nodes.js b/packages/node_modules/@node-red/editor-client/src/js/nodes.js index da3bdb729..3c95239a1 100644 --- a/packages/node_modules/@node-red/editor-client/src/js/nodes.js +++ b/packages/node_modules/@node-red/editor-client/src/js/nodes.js @@ -142,9 +142,12 @@ RED.nodes = (function() { RED.events.emit("registry:node-set-disabled",ns); }, registerNodeType: function(nt,def) { - nodeDefinitions[nt] = def; - def.type = nt; if (nt.substring(0,8) != "subflow:") { + if (!nodeSets[typeToId[nt]]) { + var fullType = (RED._loadingModule?("["+RED._loadingModule+"] "):"")+nt + RED.notify(RED._("palette.event.unknownNodeRegistered",{type:fullType}), "error"); + return; + } def.set = nodeSets[typeToId[nt]]; nodeSets[typeToId[nt]].added = true; nodeSets[typeToId[nt]].enabled = true; @@ -167,9 +170,13 @@ RED.nodes = (function() { } return result; } - // TODO: too tightly coupled into palette UI } + + def.type = nt; + nodeDefinitions[nt] = def; + + if (def.defaults) { for (var d in def.defaults) { if (def.defaults.hasOwnProperty(d)) { diff --git a/packages/node_modules/@node-red/registry/lib/installer.js b/packages/node_modules/@node-red/registry/lib/installer.js index 88846bac4..95022fbb1 100644 --- a/packages/node_modules/@node-red/registry/lib/installer.js +++ b/packages/node_modules/@node-red/registry/lib/installer.js @@ -299,16 +299,29 @@ async function installModule(module,version,url) { function reportAddedModules(info) { if (info.nodes.length > 0) { - log.info(log._("server.added-types")); + const installedTypes = []; + const errorSets = []; for (var i=0;i 0) { + for (var j=0;j 0) { + errorSets.forEach(l => log.warn(l)) + } + if (installedTypes.length > 0) { + log.info(log._("server.added-types")); + installedTypes.forEach(l => log.info(l)) + } } return info; }