Merge branch 'master' into dev

This commit is contained in:
Nick O'Leary
2023-02-02 10:40:33 +00:00
135 changed files with 1055 additions and 357 deletions

View File

@@ -100,9 +100,13 @@ function buildDiagnosticReport(scope, callback) {
version: os.version(),
},
runtime: {
isStarted: runtime.isStarted(),
modules: modules,
version: runtime.settings.version,
isStarted: runtime.isStarted(),
flows: {
state: runtime.flows && runtime.flows.state(),
started: runtime.flows && runtime.flows.started,
},
modules: modules,
settings: {
available: runtime.settings.available(),
apiMaxLength: runtime.settings.apiMaxLength || "UNSET",
@@ -114,6 +118,11 @@ function buildDiagnosticReport(scope, callback) {
flowFile: runtime.settings.flowFile || "UNSET",
mqttReconnectTime: runtime.settings.mqttReconnectTime || "UNSET",
serialReconnectTime: runtime.settings.serialReconnectTime || "UNSET",
socketReconnectTime: runtime.settings.socketReconnectTime || "UNSET",
socketTimeout: runtime.settings.socketTimeout || "UNSET",
tcpMsgQueueSize: runtime.settings.tcpMsgQueueSize || "UNSET",
inboundWebSocketTimeout: runtime.settings.inboundWebSocketTimeout || "UNSET",
runtimeState: runtime.settings.runtimeState || "UNSET",
adminAuth: runtime.settings.adminAuth ? "SET" : "UNSET",
@@ -131,6 +140,7 @@ function buildDiagnosticReport(scope, callback) {
uiHost: runtime.settings.uiHost ? "SET" : "UNSET",
uiPort: runtime.settings.uiPort ? "SET" : "UNSET",
userDir: runtime.settings.userDir ? "SET" : "UNSET",
nodesDir: runtime.settings.nodesDir && runtime.settings.nodesDir.length ? "SET" : "UNSET",
}
}
}

View File

@@ -641,6 +641,7 @@ function getFlow(id) {
if (node.type === 'link out') {
delete node.wires;
}
delete node.credentials;
return node;
})
}
@@ -648,7 +649,10 @@ function getFlow(id) {
if (flow.configs) {
var configIds = Object.keys(flow.configs);
result.configs = configIds.map(function(configId) {
return clone(flow.configs[configId]);
const node = clone(flow.configs[configId]);
delete node.credentials;
return node
})
if (result.configs.length === 0) {
delete result.configs;
@@ -660,12 +664,16 @@ function getFlow(id) {
var subflow = clone(flow.subflows[subflowId]);
var nodeIds = Object.keys(subflow.nodes);
subflow.nodes = nodeIds.map(function(id) {
return subflow.nodes[id];
const node = clone(subflow.nodes[id])
delete node.credentials
return node
});
if (subflow.configs) {
var configIds = Object.keys(subflow.configs);
subflow.configs = configIds.map(function(id) {
return subflow.configs[id];
const node = clone(subflow.configs[id])
delete node.credentials
return node
})
}
delete subflow.instances;

View File

@@ -136,10 +136,12 @@ function createNode(flow,config) {
subflowInstanceConfig,
instanceConfig
);
// Register this subflow as an instance node of the parent flow.
// This allows nodes inside the subflow to get ahold of each other
// such as a node accessing its config node
flow.subflowInstanceNodes[config.id] = subflow
subflow.start();
return subflow.node;
Log.error(Log._("nodes.flow.unknown-type", {type:type}));
}
} catch(err) {
Log.error(err);

View File

@@ -161,6 +161,8 @@ function start() {
for (i=0;i<nodeErrors.length;i+=1) {
if (nodeErrors[i].err.code === "type_already_registered") {
log.warn("["+nodeErrors[i].id+"] "+log._("server.type-already-registered",{type:nodeErrors[i].err.details.type,module: nodeErrors[i].err.details.moduleA}));
} else if (nodeErrors[i].err.code === "set_has_no_types") {
log.warn("["+nodeErrors[i].id+"] "+log._("server.set-has-no-types", nodeErrors[i].err.details));
} else {
log.warn("["+nodeErrors[i].id+"] "+nodeErrors[i].err);
}

View File

@@ -373,6 +373,11 @@ Node.prototype.send = function(msg) {
if (msg === null || typeof msg === "undefined") {
return;
} else if (!util.isArray(msg)) {
// A single message has been passed in
if (typeof msg !== 'object') {
this.error(Log._("nodes.flow.non-message-returned", { type: typeof msg }));
return
}
if (this._wire) {
// A single message and a single wire on output 0
// TODO: pre-load flows.get calls - cannot do in constructor
@@ -425,27 +430,31 @@ Node.prototype.send = function(msg) {
for (k = 0; k < msgs.length; k++) {
var m = msgs[k];
if (m !== null && m !== undefined) {
if (!m._msgid) {
hasMissingIds = true;
if (typeof m !== 'object') {
this.error(Log._("nodes.flow.non-message-returned", { type: typeof m }));
} else {
if (!m._msgid) {
hasMissingIds = true;
}
/* istanbul ignore else */
if (!sentMessageId) {
sentMessageId = m._msgid;
}
sendEvents.push({
msg: m,
source: {
id: this.id,
node: this,
port: i
},
destination: {
id: wires[j],
node: undefined
},
cloneMessage: msgSent
});
msgSent = true;
}
/* istanbul ignore else */
if (!sentMessageId) {
sentMessageId = m._msgid;
}
sendEvents.push({
msg: m,
source: {
id: this.id,
node: this,
port: i
},
destination: {
id: wires[j],
node: undefined
},
cloneMessage: msgSent
});
msgSent = true;
}
}
}

View File

@@ -18,7 +18,7 @@ var i18n = require("@node-red/util").i18n;
module.exports = {
"package.json": function(project) {
var package = {
var packageDetails = {
"name": project.name,
"description": project.summary||i18n._("storage.localfilesystem.projects.summary"),
"version": "0.0.1",
@@ -30,11 +30,11 @@ module.exports = {
};
if (project.files) {
if (project.files.flow) {
package['node-red'].settings.flowFile = project.files.flow;
package['node-red'].settings.credentialsFile = project.files.credentials;
packageDetails['node-red'].settings.flowFile = project.files.flow;
packageDetails['node-red'].settings.credentialsFile = project.files.credentials;
}
}
return JSON.stringify(package,"",4);
return JSON.stringify(packageDetails,"",4);
},
"README.md": function(project) {
var content = project.name+"\n"+("=".repeat(project.name.length))+"\n\n";

View File

@@ -71,6 +71,8 @@ function runGitCommand(args,cwd,env,emit) {
err.code = "git_missing_user";
} else if (/name consists only of disallowed characters/i.test(stderr)) {
err.code = "git_missing_user";
} else if (/nothing (add )?to commit/i.test(stdout)) {
return stdout;
}
throw err;
})
@@ -106,7 +108,7 @@ function runGitCommandWithSSHCommand(args,cwd,auth,emit) {
commandEnv.GIT_SSH = path.join(__dirname,"node-red-ssh.sh");
commandEnv.NODE_RED_KEY_FILE=auth.key_path;
// GIT_SSH_COMMAND - added in git 2.3.0
commandEnv.GIT_SSH_COMMAND = "ssh -i " + auth.key_path + " -F /dev/null";
commandEnv.GIT_SSH_COMMAND = "ssh -i \"" + auth.key_path + "\" -F /dev/null";
// console.log('commandEnv:', commandEnv);
return runGitCommand(args,cwd,commandEnv,emit).then( result => {
rs.close();
@@ -419,7 +421,10 @@ module.exports = {
});
},
initRepo: function(cwd) {
return runGitCommand(["init"],cwd);
var args = ["init", "--initial-branch", "main"];
return runGitCommand(args, cwd).catch(function () {
return runGitCommand(["init"], cwd);
});
},
setUpstream: function(cwd,remoteBranch) {
var args = ["branch","--set-upstream-to",remoteBranch];