mirror of
https://github.com/node-red/node-red.git
synced 2023-10-10 13:36:53 +02:00
Merge branch 'master' into dev
This commit is contained in:
commit
2d066307f4
4
.github/workflows/tests.yml
vendored
4
.github/workflows/tests.yml
vendored
@ -19,9 +19,9 @@ jobs:
|
|||||||
matrix:
|
matrix:
|
||||||
node-version: [16, 18]
|
node-version: [16, 18]
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v3
|
||||||
- name: Use Node.js ${{ matrix.node-version }}
|
- name: Use Node.js ${{ matrix.node-version }}
|
||||||
uses: actions/setup-node@v2
|
uses: actions/setup-node@v3
|
||||||
with:
|
with:
|
||||||
node-version: ${{ matrix.node-version }}
|
node-version: ${{ matrix.node-version }}
|
||||||
- name: Install Dependencies
|
- name: Install Dependencies
|
||||||
|
@ -747,14 +747,14 @@ RED.projects = (function() {
|
|||||||
var row = $('<div class="form-row"></div>').appendTo(body);
|
var row = $('<div class="form-row"></div>').appendTo(body);
|
||||||
$('<label for="red-ui-projects-dialog-screen-create-project-file">'+RED._("projects.default-files.flow-file")+'</label>').appendTo(row);
|
$('<label for="red-ui-projects-dialog-screen-create-project-file">'+RED._("projects.default-files.flow-file")+'</label>').appendTo(row);
|
||||||
var subrow = $('<div style="position:relative;"></div>').appendTo(row);
|
var subrow = $('<div style="position:relative;"></div>').appendTo(row);
|
||||||
var defaultFlowFile = (createProjectOptions.files &&createProjectOptions.files.flow) || (RED.settings.files && RED.settings.files.flow)||"flow.json";
|
var defaultFlowFile = (createProjectOptions.files &&createProjectOptions.files.flow) || (RED.settings.files && RED.settings.files.flow) || "flows.json";
|
||||||
projectFlowFileInput = $('<input id="red-ui-projects-dialog-screen-create-project-file" type="text">').val(defaultFlowFile)
|
projectFlowFileInput = $('<input id="red-ui-projects-dialog-screen-create-project-file" type="text">').val(defaultFlowFile)
|
||||||
.on("change keyup paste",validateForm)
|
.on("change keyup paste",validateForm)
|
||||||
.appendTo(subrow);
|
.appendTo(subrow);
|
||||||
$('<div class="red-ui-projects-dialog-screen-input-status"></div>').appendTo(subrow);
|
$('<div class="red-ui-projects-dialog-screen-input-status"></div>').appendTo(subrow);
|
||||||
$('<label class="red-ui-projects-edit-form-sublabel"><small>*.json</small></label>').appendTo(row);
|
$('<label class="red-ui-projects-edit-form-sublabel"><small>*.json</small></label>').appendTo(row);
|
||||||
|
|
||||||
var defaultCredentialsFile = (createProjectOptions.files &&createProjectOptions.files.credentials) || (RED.settings.files && RED.settings.files.credentials)||"flow_cred.json";
|
var defaultCredentialsFile = (createProjectOptions.files &&createProjectOptions.files.credentials) || (RED.settings.files && RED.settings.files.credentials) || "flows_cred.json";
|
||||||
row = $('<div class="form-row"></div>').appendTo(body);
|
row = $('<div class="form-row"></div>').appendTo(body);
|
||||||
$('<label for="red-ui-projects-dialog-screen-create-project-credfile">'+RED._("projects.default-files.credentials-file")+'</label>').appendTo(row);
|
$('<label for="red-ui-projects-dialog-screen-create-project-credfile">'+RED._("projects.default-files.credentials-file")+'</label>').appendTo(row);
|
||||||
subrow = $('<div style="position:relative;"></div>').appendTo(row);
|
subrow = $('<div style="position:relative;"></div>').appendTo(row);
|
||||||
@ -1257,7 +1257,7 @@ RED.projects = (function() {
|
|||||||
row = $('<div class="form-row red-ui-projects-dialog-screen-create-row red-ui-projects-dialog-screen-create-row-empty"></div>').appendTo(container);
|
row = $('<div class="form-row red-ui-projects-dialog-screen-create-row red-ui-projects-dialog-screen-create-row-empty"></div>').appendTo(container);
|
||||||
$('<label for="red-ui-projects-dialog-screen-create-project-file">'+RED._("projects.create.flow-file")+'</label>').appendTo(row);
|
$('<label for="red-ui-projects-dialog-screen-create-project-file">'+RED._("projects.create.flow-file")+'</label>').appendTo(row);
|
||||||
subrow = $('<div style="position:relative;"></div>').appendTo(row);
|
subrow = $('<div style="position:relative;"></div>').appendTo(row);
|
||||||
projectFlowFileInput = $('<input id="red-ui-projects-dialog-screen-create-project-file" type="text">').val("flow.json")
|
projectFlowFileInput = $('<input id="red-ui-projects-dialog-screen-create-project-file" type="text">').val("flows.json")
|
||||||
.on("change keyup paste",validateForm)
|
.on("change keyup paste",validateForm)
|
||||||
.appendTo(subrow);
|
.appendTo(subrow);
|
||||||
$('<div class="red-ui-projects-dialog-screen-input-status"></div>').appendTo(subrow);
|
$('<div class="red-ui-projects-dialog-screen-input-status"></div>').appendTo(subrow);
|
||||||
|
@ -117,7 +117,9 @@ module.exports = function(RED) {
|
|||||||
}
|
}
|
||||||
if (typeof data === "boolean") { data = data.toString(); }
|
if (typeof data === "boolean") { data = data.toString(); }
|
||||||
if (typeof data === "number") { data = data.toString(); }
|
if (typeof data === "number") { data = data.toString(); }
|
||||||
if ((node.appendNewline) && (!Buffer.isBuffer(data))) { data += os.EOL; }
|
var aflg = true;
|
||||||
|
if (msg.hasOwnProperty("parts") && msg.parts.type === "string" && (msg.parts.count === msg.parts.index + 1)) { aflg = false; }
|
||||||
|
if ((node.appendNewline) && (!Buffer.isBuffer(data)) && aflg) { data += os.EOL; }
|
||||||
var buf;
|
var buf;
|
||||||
if (node.encoding === "setbymsg") {
|
if (node.encoding === "setbymsg") {
|
||||||
buf = encode(data, msg.encoding || "none");
|
buf = encode(data, msg.encoding || "none");
|
||||||
@ -314,7 +316,6 @@ module.exports = function(RED) {
|
|||||||
});
|
});
|
||||||
filename = filename || "";
|
filename = filename || "";
|
||||||
var fullFilename = filename;
|
var fullFilename = filename;
|
||||||
var filePath = "";
|
|
||||||
if (filename && RED.settings.fileWorkingDirectory && !path.isAbsolute(filename)) {
|
if (filename && RED.settings.fileWorkingDirectory && !path.isAbsolute(filename)) {
|
||||||
fullFilename = path.resolve(path.join(RED.settings.fileWorkingDirectory,filename));
|
fullFilename = path.resolve(path.join(RED.settings.fileWorkingDirectory,filename));
|
||||||
}
|
}
|
||||||
|
@ -818,6 +818,16 @@ function handlePreRoute(flow, sendEvent, reportError) {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function deliverMessageToDestination(sendEvent) {
|
||||||
|
if (sendEvent?.destination?.node) {
|
||||||
|
try {
|
||||||
|
sendEvent.destination.node.receive(sendEvent.msg);
|
||||||
|
} catch(err) {
|
||||||
|
Log.error(`Error delivering message to node:${sendEvent.destination.node._path} [${sendEvent.destination.node.type}]`)
|
||||||
|
Log.error(err.stack)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
function handlePreDeliver(flow,sendEvent, reportError) {
|
function handlePreDeliver(flow,sendEvent, reportError) {
|
||||||
// preDeliver - the local router has identified the node it is going to send to. At this point, the message has been cloned if needed.
|
// preDeliver - the local router has identified the node it is going to send to. At this point, the message has been cloned if needed.
|
||||||
hooks.trigger("preDeliver",sendEvent,(err) => {
|
hooks.trigger("preDeliver",sendEvent,(err) => {
|
||||||
@ -827,15 +837,10 @@ function handlePreDeliver(flow,sendEvent, reportError) {
|
|||||||
} else if (err !== false) {
|
} else if (err !== false) {
|
||||||
if (asyncMessageDelivery) {
|
if (asyncMessageDelivery) {
|
||||||
setImmediate(function() {
|
setImmediate(function() {
|
||||||
if (sendEvent.destination.node) {
|
deliverMessageToDestination(sendEvent)
|
||||||
sendEvent.destination.node.receive(sendEvent.msg);
|
|
||||||
}
|
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
if (sendEvent.destination.node) {
|
deliverMessageToDestination(sendEvent)
|
||||||
sendEvent.destination.node.receive(sendEvent.msg);
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
// postDeliver - the message has been dispatched to be delivered asynchronously (unless the sync delivery flag is set, in which case it would be continue as synchronous delivery)
|
// postDeliver - the message has been dispatched to be delivered asynchronously (unless the sync delivery flag is set, in which case it would be continue as synchronous delivery)
|
||||||
hooks.trigger("postDeliver", sendEvent, function(err) {
|
hooks.trigger("postDeliver", sendEvent, function(err) {
|
||||||
|
2
packages/node_modules/node-red/red.js
vendored
2
packages/node_modules/node-red/red.js
vendored
@ -458,7 +458,7 @@ httpsPromise.then(function(startupHttps) {
|
|||||||
RED.start().then(function() {
|
RED.start().then(function() {
|
||||||
if (settings.httpAdminRoot !== false || settings.httpNodeRoot !== false || settings.httpStatic) {
|
if (settings.httpAdminRoot !== false || settings.httpNodeRoot !== false || settings.httpStatic) {
|
||||||
server.on('error', function(err) {
|
server.on('error', function(err) {
|
||||||
if (err.errno === "EADDRINUSE") {
|
if (err.code === "EADDRINUSE") {
|
||||||
RED.log.error(RED.log._("server.unable-to-listen", {listenpath:getListenPath()}));
|
RED.log.error(RED.log._("server.unable-to-listen", {listenpath:getListenPath()}));
|
||||||
RED.log.error(RED.log._("server.port-in-use"));
|
RED.log.error(RED.log._("server.port-in-use"));
|
||||||
} else {
|
} else {
|
||||||
|
2
packages/node_modules/node-red/settings.js
vendored
2
packages/node_modules/node-red/settings.js
vendored
@ -416,7 +416,7 @@ module.exports = {
|
|||||||
*/
|
*/
|
||||||
// theme: "vs",
|
// theme: "vs",
|
||||||
/** other overrides can be set e.g. fontSize, fontFamily, fontLigatures etc.
|
/** 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/docs.html#interfaces/editor.IStandaloneEditorConstructionOptions.html
|
||||||
*/
|
*/
|
||||||
//fontSize: 14,
|
//fontSize: 14,
|
||||||
//fontFamily: "Cascadia Code, Fira Code, Consolas, 'Courier New', monospace",
|
//fontFamily: "Cascadia Code, Fira Code, Consolas, 'Courier New', monospace",
|
||||||
|
@ -194,6 +194,55 @@ describe('file Nodes', function() {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should append to a file and add newline, except last line of multipart input', function(done) {
|
||||||
|
var flow = [{id:"fileNode1", type:"file", name: "fileNode", "filename":fileToTest, "appendNewline":true, "overwriteFile":false, wires: [["helperNode1"]]},
|
||||||
|
{id:"helperNode1", type:"helper"}];
|
||||||
|
try {
|
||||||
|
fs.unlinkSync(fileToTest);
|
||||||
|
} catch(err) {
|
||||||
|
}
|
||||||
|
helper.load(fileNode, flow, function() {
|
||||||
|
var n1 = helper.getNode("fileNode1");
|
||||||
|
var n2 = helper.getNode("helperNode1");
|
||||||
|
var count = 0;
|
||||||
|
//var data = ["Line1", "Line2"];
|
||||||
|
|
||||||
|
n2.on("input", function (msg) {
|
||||||
|
try {
|
||||||
|
msg.should.have.property("payload");
|
||||||
|
//data.should.containDeep([msg.payload]);
|
||||||
|
if (count === 3) {
|
||||||
|
var f = fs.readFileSync(fileToTest).toString();
|
||||||
|
if (os.type() !== "Windows_NT") {
|
||||||
|
f.should.have.length(23);
|
||||||
|
f.should.equal("Line1\nLine2\nLine3\nLine4");
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
f.should.have.length(23);
|
||||||
|
f.should.equal("Line1\r\nLine2\r\nLine3\r\nLine4");
|
||||||
|
}
|
||||||
|
done();
|
||||||
|
}
|
||||||
|
count++;
|
||||||
|
}
|
||||||
|
catch (e) {
|
||||||
|
done(e);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
n1.receive({payload:"Line1",parts:{index:0,type:"string"}}); // string
|
||||||
|
setTimeout(function() {
|
||||||
|
n1.receive({payload:"Line2",parts:{index:1,type:"string"}}); // string
|
||||||
|
},30);
|
||||||
|
setTimeout(function() {
|
||||||
|
n1.receive({payload:"Line3",parts:{index:2,type:"string"}}); // string
|
||||||
|
},60);
|
||||||
|
setTimeout(function() {
|
||||||
|
n1.receive({payload:"Line4",parts:{index:3,type:"string",count:4}}); // string
|
||||||
|
},90);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
it('should append to a file after it has been deleted ', function(done) {
|
it('should append to a file after it has been deleted ', function(done) {
|
||||||
var flow = [{id:"fileNode1", type:"file", name: "fileNode", "filename":fileToTest, "appendNewline":false, "overwriteFile":false, wires: [["helperNode1"]]},
|
var flow = [{id:"fileNode1", type:"file", name: "fileNode", "filename":fileToTest, "appendNewline":false, "overwriteFile":false, wires: [["helperNode1"]]},
|
||||||
{id:"helperNode1", type:"helper"}];
|
{id:"helperNode1", type:"helper"}];
|
||||||
|
Loading…
Reference in New Issue
Block a user