From 10395ef254c37e3dd312b6e3ae8bfbad19334b33 Mon Sep 17 00:00:00 2001 From: Edward Vielmetti Date: Thu, 24 May 2018 04:48:05 -0400 Subject: [PATCH 01/10] typo fix *hierarchy (#1735) --- nodes/core/io/10-mqtt.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nodes/core/io/10-mqtt.html b/nodes/core/io/10-mqtt.html index 722a7a7ae..afe710472 100644 --- a/nodes/core/io/10-mqtt.html +++ b/nodes/core/io/10-mqtt.html @@ -41,7 +41,7 @@
payload string | buffer
a string unless detected as a binary buffer.
topic string
-
the MQTT topic, uses / as a heirarchy separator.
+
the MQTT topic, uses / as a hierarchy separator.
qos number
0, fire and forget - 1, at least once - 2, once and once only.
retain boolean
From 0ef16989cddbe5858ebbf2e89a6a492fc714fbfb Mon Sep 17 00:00:00 2001 From: Nick O'Leary Date: Thu, 24 May 2018 20:25:26 +0100 Subject: [PATCH 02/10] Do not trim wires if node declares outputs in defaults but misses value Fixes #1737 --- editor/js/nodes.js | 28 ++++++++++++++++++++++------ 1 file changed, 22 insertions(+), 6 deletions(-) diff --git a/editor/js/nodes.js b/editor/js/nodes.js index 0a2fe7268..433e400a2 100644 --- a/editor/js/nodes.js +++ b/editor/js/nodes.js @@ -1033,15 +1033,31 @@ RED.nodes = (function() { node.type = "unknown"; } if (node._def.category != "config") { - node.inputs = n.inputs||node._def.inputs; - node.outputs = n.outputs||node._def.outputs; - // If 'wires' is longer than outputs, clip wires + if (n.hasOwnProperty('inputs')) { + node.inputs = n.inputs; + node._config.inputs = JSON.stringify(n.inputs); + } else { + node.inputs = node._def.inputs; + } + if (n.hasOwnProperty('outputs')) { + node.outputs = n.outputs; + node._config.outputs = JSON.stringify(n.outputs); + } else { + node.outputs = node._def.outputs; + } if (node.hasOwnProperty('wires') && node.wires.length > node.outputs) { - console.log("Warning: node.wires longer than node.outputs - trimming wires:",node.id," wires:",node.wires.length," outputs:",node.outputs); - node.wires = node.wires.slice(0,node.outputs); + if (!node._def.defaults.hasOwnProperty("outputs") || !isNaN(parseInt(n.outputs))) { + // If 'wires' is longer than outputs, clip wires + console.log("Warning: node.wires longer than node.outputs - trimming wires:",node.id," wires:",node.wires.length," outputs:",node.outputs); + node.wires = node.wires.slice(0,node.outputs); + } else { + // The node declares outputs in its defaults, but has not got a valid value + // Defer to the length of the wires array + node.outputs = node.wires.length; + } } for (d in node._def.defaults) { - if (node._def.defaults.hasOwnProperty(d)) { + if (node._def.defaults.hasOwnProperty(d) && d !== 'inputs' && d !== 'outputs') { node[d] = n[d]; node._config[d] = JSON.stringify(n[d]); } From 40f41678944912145f5d32e0f214b8398ee9d48b Mon Sep 17 00:00:00 2001 From: Dave Conway-Jones Date: Thu, 24 May 2018 21:39:46 +0100 Subject: [PATCH 03/10] let TCP in node report remote ip and port when in single packet mode --- nodes/core/io/31-tcpin.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/nodes/core/io/31-tcpin.js b/nodes/core/io/31-tcpin.js index 5853d4f42..c3bc2ab8c 100644 --- a/nodes/core/io/31-tcpin.js +++ b/nodes/core/io/31-tcpin.js @@ -130,6 +130,8 @@ module.exports = function(RED) { socket.setKeepAlive(true,120000); if (socketTimeout !== null) { socket.setTimeout(socketTimeout); } var id = (1+Math.random()*4294967295).toString(16); + var fromi; + var fromp; connectionPool[id] = socket; count++; node.status({text:RED._("tcpin.status.connections",{count:count})}); @@ -155,18 +157,21 @@ module.exports = function(RED) { msg._session = {type:"tcp",id:id}; node.send(msg); } - } else { + } + else { if ((typeof data) === "string") { buffer = buffer+data; } else { buffer = Buffer.concat([buffer,data],buffer.length+data.length); } + fromi = socket.remoteAddress; + fromp = socket.remotePort; } }); socket.on('end', function() { if (!node.stream || (node.datatype === "utf8" && node.newline !== "")) { if (buffer.length > 0) { - var msg = {topic:node.topic, payload:buffer, ip:socket.remoteAddress, port:socket.remotePort}; + var msg = {topic:node.topic, payload:buffer, ip:fromi, port:fromp}; msg._session = {type:"tcp",id:id}; node.send(msg); } From 7f89a4a26f2079fe771ecc28587187f93c0f078d Mon Sep 17 00:00:00 2001 From: KatsuyaHoshii Date: Fri, 25 May 2018 11:48:33 +0900 Subject: [PATCH 04/10] Update .travis.yml --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 328a85ef7..05edbdbb3 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,7 +4,7 @@ matrix: include: - node_js: "10" script: - - istanbul cover ./node_modules/.bin/grunt --report lcovonly && istanbul report text && ( cat coverage/lcov.info | $(npm get prefix)/bin/coveralls || true ) && rm -rf coverage + - ./node_modules/.bin/grunt coverage && istanbul report text && ( cat coverage/lcov.info | $(npm get prefix)/bin/coveralls || true ) && rm -rf coverage before_script: - npm install -g istanbul coveralls - node_js: "8" From 252df81f5963a76ea11619496a9aa38a1ebb0978 Mon Sep 17 00:00:00 2001 From: Nick O'Leary Date: Fri, 25 May 2018 10:50:58 +0100 Subject: [PATCH 05/10] Pass Date into the Function node sandbox to fix instanceof tests --- nodes/core/core/80-function.js | 1 + test/nodes/core/core/80-function_spec.js | 16 ++++++++++++++++ 2 files changed, 17 insertions(+) diff --git a/nodes/core/core/80-function.js b/nodes/core/core/80-function.js index 8aa95e4fc..0a7448ccd 100644 --- a/nodes/core/core/80-function.js +++ b/nodes/core/core/80-function.js @@ -80,6 +80,7 @@ module.exports = function(RED) { console:console, util:util, Buffer:Buffer, + Date: Date, RED: { util: RED.util }, diff --git a/test/nodes/core/core/80-function_spec.js b/test/nodes/core/core/80-function_spec.js index b96588b5b..f19e933dc 100644 --- a/test/nodes/core/core/80-function_spec.js +++ b/test/nodes/core/core/80-function_spec.js @@ -508,6 +508,22 @@ describe('function node', function() { }); }); + + it('should use the same Date object from outside the sandbox', function(done) { + var flow = [{id:"n1",type:"function",wires:[["n2"]],func:"msg.payload=global.get('typeTest')(new Date());return msg;"}, + {id:"n2", type:"helper"}]; + helper.load(functionNode, flow, function() { + var n1 = helper.getNode("n1"); + var n2 = helper.getNode("n2"); + n1.context().global.set("typeTest",function(d) { return d instanceof Date }); + n2.on("input", function(msg) { + msg.should.have.property('payload', true); + done(); + }); + n1.receive({payload:"foo",topic: "bar"}); + }); + }); + describe('Logger', function () { it('should log an Info Message', function (done) { var flow = [{id: "n1", type: "function", wires: [["n2"]], func: "node.log('test');"}]; From 5069f2844c86ff5061f6fde20b82455801cdeaee Mon Sep 17 00:00:00 2001 From: Nick O'Leary Date: Fri, 25 May 2018 10:51:29 +0100 Subject: [PATCH 06/10] Bump jsonata version --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index f90789e43..0f8b7fbd3 100644 --- a/package.json +++ b/package.json @@ -52,7 +52,7 @@ "is-utf8": "0.2.1", "js-yaml": "3.11.0", "json-stringify-safe": "5.0.1", - "jsonata": "1.5.3", + "jsonata": "1.5.4", "media-typer": "0.3.0", "memorystore": "1.6.0", "mqtt": "2.18.0", From bca020bc4dbf357614c2f59e1c6752b1cd435982 Mon Sep 17 00:00:00 2001 From: Nick O'Leary Date: Fri, 25 May 2018 11:36:17 +0100 Subject: [PATCH 07/10] Tidy up default grunt task and fixup test break due to reorder Fixes #1738 --- .travis.yml | 2 +- Gruntfile.js | 4 ++-- red/api/auth/users.js | 4 ++++ test/red/api/auth/users_spec.js | 8 +++++--- 4 files changed, 12 insertions(+), 6 deletions(-) diff --git a/.travis.yml b/.travis.yml index 05edbdbb3..054edefba 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,7 +4,7 @@ matrix: include: - node_js: "10" script: - - ./node_modules/.bin/grunt coverage && istanbul report text && ( cat coverage/lcov.info | $(npm get prefix)/bin/coveralls || true ) && rm -rf coverage + - ./node_modules/.bin/grunt && istanbul report text && ( cat coverage/lcov.info | $(npm get prefix)/bin/coveralls || true ) && rm -rf coverage before_script: - npm install -g istanbul coveralls - node_js: "8" diff --git a/Gruntfile.js b/Gruntfile.js index 2be2d23c0..3738e60b4 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -55,7 +55,7 @@ module.exports = function(grunt) { reportFormats: ['lcov','html'], print: 'both' }, - all: { src: ['test/**/*_spec.js'] }, + all: { src: ["test/_spec.js","test/red/**/*_spec.js","test/nodes/**/*_spec.js"] }, core: { src: ["test/_spec.js","test/red/**/*_spec.js"]}, nodes: { src: ["test/nodes/**/*_spec.js"]} }, @@ -474,7 +474,7 @@ module.exports = function(grunt) { grunt.registerTask('default', 'Builds editor content then runs code style checks and unit tests on all components', - ['build','test-core','test-editor','test-nodes']); + ['build','jshint:editor','mocha_istanbul:all']); grunt.registerTask('test-core', 'Runs code style check and unit tests on core runtime code', diff --git a/red/api/auth/users.js b/red/api/auth/users.js index 92c4c9ce9..24a762958 100644 --- a/red/api/auth/users.js +++ b/red/api/auth/users.js @@ -86,6 +86,10 @@ function init(config) { } else { api.authenticate = authenticate; } + } else { + api.get = get; + api.authenticate = authenticate; + api.default = api.default; } if (config.default) { if (typeof config.default === "function") { diff --git a/test/red/api/auth/users_spec.js b/test/red/api/auth/users_spec.js index 23c34001d..e7b70f7b1 100644 --- a/test/red/api/auth/users_spec.js +++ b/test/red/api/auth/users_spec.js @@ -194,8 +194,7 @@ describe("api/auth/users", function() { it('should fail to return user fred',function(done) { Users.get("fred").then(function(userf) { try { - userf.should.not.have.a.property("username","fred"); - userf.should.not.have.a.property("permissions","*"); + should.not.exist(userf); done(); } catch(err) { done(err); @@ -212,9 +211,12 @@ describe("api/auth/users", function() { default: function() { return("Done"); } }); }); + after(function() { + Users.init({}); + }); describe('#default',function() { it('handles api.default being a function',function(done) { - Users.should.have.property('default').which.is.a.Function; + Users.should.have.property('default').which.is.a.Function(); (Users.default()).should.equal("Done"); done(); }); From 8cb2e5140762c1a53abc946f326670867c7a24ca Mon Sep 17 00:00:00 2001 From: Nick O'Leary Date: Fri, 25 May 2018 11:40:14 +0100 Subject: [PATCH 08/10] Relax twitter node version ready for major version bump --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 0f8b7fbd3..820f6e426 100644 --- a/package.json +++ b/package.json @@ -61,7 +61,7 @@ "node-red-node-email": "0.1.*", "node-red-node-feedparser": "0.1.*", "node-red-node-rbe": "0.2.*", - "node-red-node-twitter": "0.1.*", + "node-red-node-twitter": "*", "nopt": "4.0.1", "oauth2orize": "1.11.0", "on-headers": "1.0.1", From 787709371361f3055aac1a7d3b11ca9aad58dcc2 Mon Sep 17 00:00:00 2001 From: Nick O'Leary Date: Fri, 25 May 2018 13:23:18 +0100 Subject: [PATCH 09/10] Bump 0.18.7 --- CHANGELOG.md | 18 ++++++++++++++++++ package.json | 2 +- 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1d6cccb65..749226d20 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,21 @@ +#### 0.18.7: Maintenance Release + + +Editor Fixes + + - - Do not trim wires if node declares outputs in defaults but misses value Fixes #1737 + +Node Fixes + + - Relax twitter node version ready for major version bump + - Pass Date into the Function node sandbox to fix instanceof tests + - let TCP in node report remote ip and port when in single packet mode + - typo fix in node help (#1735) + +Other Fixes + - Tidy up default grunt task and fixup test break due to reorder Fixes #1738 + - Bump jsonata version + #### 0.18.6: Maintenance Release Editor Fixes diff --git a/package.json b/package.json index 820f6e426..ec0f63a34 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "node-red", - "version": "0.18.6", + "version": "0.18.7", "description": "A visual tool for wiring the Internet of Things", "homepage": "http://nodered.org", "license": "Apache-2.0", From 472bbdb59f59108b7fa8624f1a8a2110d213530c Mon Sep 17 00:00:00 2001 From: Nick O'Leary Date: Fri, 25 May 2018 13:27:58 +0100 Subject: [PATCH 10/10] Fix typo in CHANGELOG --- CHANGELOG.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 749226d20..2a73106c4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,9 +1,8 @@ #### 0.18.7: Maintenance Release - Editor Fixes - - - Do not trim wires if node declares outputs in defaults but misses value Fixes #1737 + - Do not trim wires if node declares outputs in defaults but misses value Fixes #1737 Node Fixes