From db87b0dfa551fb7658dc3a39a89fa3a8e2929d3b Mon Sep 17 00:00:00 2001
From: Dave Conway-Jones <conway@uk.ibm.com>
Date: Tue, 15 May 2018 22:10:14 +0100
Subject: [PATCH 1/7] Add missing ACE snippet files

to stop 404 in console
---
 editor/vendor/ace/snippets/json.js  | 1 +
 editor/vendor/ace/snippets/sql.js   | 1 +
 editor/vendor/ace/snippets/swift.js | 1 +
 3 files changed, 3 insertions(+)
 create mode 100644 editor/vendor/ace/snippets/json.js
 create mode 100644 editor/vendor/ace/snippets/sql.js
 create mode 100644 editor/vendor/ace/snippets/swift.js

diff --git a/editor/vendor/ace/snippets/json.js b/editor/vendor/ace/snippets/json.js
new file mode 100644
index 000000000..5e0e0ea2e
--- /dev/null
+++ b/editor/vendor/ace/snippets/json.js
@@ -0,0 +1 @@
+ace.define("ace/snippets/json",["require","exports","module"],function(e,t,n){"use strict";t.snippetText=undefined,t.scope="json"})
\ No newline at end of file
diff --git a/editor/vendor/ace/snippets/sql.js b/editor/vendor/ace/snippets/sql.js
new file mode 100644
index 000000000..1bacce06d
--- /dev/null
+++ b/editor/vendor/ace/snippets/sql.js
@@ -0,0 +1 @@
+ace.define("ace/snippets/sql",["require","exports","module"],function(e,t,n){"use strict";t.snippetText="snippet tbl\n	create table ${1:table} (\n		${2:columns}\n	);\nsnippet col\n	${1:name}	${2:type}	${3:default ''}	${4:not null}\nsnippet ccol\n	${1:name}	varchar2(${2:size})	${3:default ''}	${4:not null}\nsnippet ncol\n	${1:name}	number	${3:default 0}	${4:not null}\nsnippet dcol\n	${1:name}	date	${3:default sysdate}	${4:not null}\nsnippet ind\n	create index ${3:$1_$2} on ${1:table}(${2:column});\nsnippet uind\n	create unique index ${1:name} on ${2:table}(${3:column});\nsnippet tblcom\n	comment on table ${1:table} is '${2:comment}';\nsnippet colcom\n	comment on column ${1:table}.${2:column} is '${3:comment}';\nsnippet addcol\n	alter table ${1:table} add (${2:column} ${3:type});\nsnippet seq\n	create sequence ${1:name} start with ${2:1} increment by ${3:1} minvalue ${4:1};\nsnippet s*\n	select * from ${1:table}\n",t.scope="sql"})
\ No newline at end of file
diff --git a/editor/vendor/ace/snippets/swift.js b/editor/vendor/ace/snippets/swift.js
new file mode 100644
index 000000000..307d39f7c
--- /dev/null
+++ b/editor/vendor/ace/snippets/swift.js
@@ -0,0 +1 @@
+ace.define("ace/snippets/swift",["require","exports","module"],function(e,t,n){"use strict";t.snippetText=undefined,t.scope="swift"})
\ No newline at end of file

From 0a82459233e50eb976a13831ed5bb13e479bd3ea Mon Sep 17 00:00:00 2001
From: Nick O'Leary <nick.oleary@gmail.com>
Date: Thu, 17 May 2018 11:27:28 +0100
Subject: [PATCH 2/7] Handle a node having wires in the editor on ports it no
 longer has Fixes #1724

---
 editor/js/nodes.js | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/editor/js/nodes.js b/editor/js/nodes.js
index 5e2c7ca1d..0a2fe7268 100644
--- a/editor/js/nodes.js
+++ b/editor/js/nodes.js
@@ -491,7 +491,9 @@ RED.nodes = (function() {
             for (var j=0;j<wires.length;j++) {
                 var w = wires[j];
                 if (w.target.type != "subflow") {
-                    node.wires[w.sourcePort].push(w.target.id);
+                    if (w.sourcePort < node.wires.length) {
+                        node.wires[w.sourcePort].push(w.target.id);
+                    }
                 }
             }
 

From 4edb1f80b05bb8ecfb7318c4a93ef2c8c0191dc2 Mon Sep 17 00:00:00 2001
From: Nick O'Leary <nick.oleary@gmail.com>
Date: Thu, 17 May 2018 12:17:55 +0100
Subject: [PATCH 3/7] Update mailing list references to new forum

---
 .github/ISSUE_TEMPLATE.md        | 4 +++-
 .github/PULL_REQUEST_TEMPLATE.md | 2 +-
 CONTRIBUTING.md                  | 4 ++--
 README.md                        | 3 +--
 4 files changed, 7 insertions(+), 6 deletions(-)

diff --git a/.github/ISSUE_TEMPLATE.md b/.github/ISSUE_TEMPLATE.md
index b50449579..5d4d87bb7 100644
--- a/.github/ISSUE_TEMPLATE.md
+++ b/.github/ISSUE_TEMPLATE.md
@@ -8,7 +8,9 @@ If your issue is:
   - a feature request or suggestion for a change,
   - or problems with 3rd party (`node-red-contrib-`) nodes
 
-please use the [mailing list](https://groups.google.com/forum/#!forum/node-red), [slack team](https://nodered.org/slack) or ask a question on [Stack Overflow](https://stackoverflow.com/questions/tagged/node-red) and tag it `node-red`.
+please use the [Node-RED Forum](https://discourse.nodered.org) or [slack team](https://nodered.org/slack).
+
+You could also consider asking a question on [Stack Overflow](https://stackoverflow.com/questions/tagged/node-red) and tag it `node-red`.
 
 That way the whole Node-RED user community can help, rather than rely on the core development team.
 
diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md
index 10185376d..05fdacd51 100644
--- a/.github/PULL_REQUEST_TEMPLATE.md
+++ b/.github/PULL_REQUEST_TEMPLATE.md
@@ -16,7 +16,7 @@ Put an `x` in the boxes that apply
 <!--
 If you want to raise a pull-request with a new feature, or a refactoring
 of existing code, it **may well get rejected** if it hasn't been discussed on
-the [mailing list](https://groups.google.com/forum/#!forum/node-red) or
+the [forum](https://discourse.nodered.org) or
 [slack team](https://nodered.org/slack) first.
 
 -->
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
index 64008278c..33a2f582f 100644
--- a/CONTRIBUTING.md
+++ b/CONTRIBUTING.md
@@ -30,13 +30,13 @@ At a minimum, please include:
 
 ## Feature requests
 
-For feature requests, please raise them on the [mailing list](https://groups.google.com/forum/#!forum/node-red).
+For feature requests, please raise them on the [forum](https://discourse.nodered.org).
 
 ## Pull-Requests
 
 If you want to raise a pull-request with a new feature, or a refactoring
 of existing code, it may well get rejected if you haven't discussed it on
-the [mailing list](https://groups.google.com/forum/#!forum/node-red) first.
+the [forum](https://discourse.nodered.org) first.
 
 All contributors need to sign the JS Foundation's Contributor License Agreement.
 It is an online process and quick to do. You can read the details of the agreement
diff --git a/README.md b/README.md
index e762f8faa..c1306a796 100644
--- a/README.md
+++ b/README.md
@@ -22,8 +22,7 @@ started.
 
 More documentation can be found [here](http://nodered.org/docs).
 
-For further help, or general discussion, please use the
-[mailing list](https://groups.google.com/forum/#!forum/node-red).
+For further help, or general discussion, please use the [Node-RED Forum](https://discourse.nodered.org) or [slack team](https://nodered.org/slack).
 
 ## Developers
 

From 30c2aa96d616bbdac683227b4ae7caf95a5ba765 Mon Sep 17 00:00:00 2001
From: Nick O'Leary <nick.oleary@gmail.com>
Date: Thu, 17 May 2018 12:21:06 +0100
Subject: [PATCH 4/7] Update changelog

---
 CHANGELOG.md | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/CHANGELOG.md b/CHANGELOG.md
index 916a47ebe..dcfbd6a5b 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,3 +1,13 @@
+#### 0.18.6: Maintenance Release
+
+Editor Fixes
+
+ - Handle a node having wires in the editor on ports it no longer has Fixes #1724
+ - Add missing ACE snippet files
+ - Fix wireClippedNodes is not defined Fixes #1726
+ - Split node html to isolate bad nodes when loading
+ - Avoid unnecessary use of .html() where .text() will do
+
 #### 0.18.5: Maintenance Release
 
 Projects

From 4d3d1a02a8ee7b74cc2ae4c1503a5f5e11c845f6 Mon Sep 17 00:00:00 2001
From: Nick O'Leary <nick.oleary@gmail.com>
Date: Fri, 18 May 2018 11:03:00 +0100
Subject: [PATCH 5/7] Add editorTheme.projects.enabled to default settings.js

---
 settings.js | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/settings.js b/settings.js
index 0438dc5ea..dc79223fe 100644
--- a/settings.js
+++ b/settings.js
@@ -233,5 +233,13 @@ module.exports = {
             // Whether or not to include audit events in the log output
             audit: false
         }
+    },
+
+    // Customising the editor
+    editorTheme: {
+        projects: {
+            // To enable the Projects feature, set this value to true
+            enabled: false
+        }
     }
 }

From d4d9190919c697efe200b89a3eadf2c7c101d596 Mon Sep 17 00:00:00 2001
From: Nick O'Leary <nick.oleary@gmail.com>
Date: Fri, 18 May 2018 11:03:49 +0100
Subject: [PATCH 6/7] Bump version

---
 CHANGELOG.md | 2 ++
 package.json | 8 ++++----
 2 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/CHANGELOG.md b/CHANGELOG.md
index dcfbd6a5b..1d6cccb65 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -8,6 +8,8 @@ Editor Fixes
  - Split node html to isolate bad nodes when loading
  - Avoid unnecessary use of .html() where .text() will do
 
+ - Add editorTheme.projects.enabled to default settings.js"
+
 #### 0.18.5: Maintenance Release
 
 Projects
diff --git a/package.json b/package.json
index fad92be48..f90789e43 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
 {
   "name": "node-red",
-  "version": "0.18.5",
+  "version": "0.18.6",
   "description": "A visual tool for wiring the Internet of Things",
   "homepage": "http://nodered.org",
   "license": "Apache-2.0",
@@ -35,7 +35,7 @@
   "dependencies": {
     "basic-auth": "2.0.0",
     "bcryptjs": "2.4.3",
-    "body-parser": "1.18.2",
+    "body-parser": "1.18.3",
     "cheerio": "0.22.0",
     "clone": "2.1.1",
     "cookie": "0.3.1",
@@ -55,7 +55,7 @@
     "jsonata": "1.5.3",
     "media-typer": "0.3.0",
     "memorystore": "1.6.0",
-    "mqtt": "2.17.0",
+    "mqtt": "2.18.0",
     "multer": "1.3.0",
     "mustache": "2.3.0",
     "node-red-node-email": "0.1.*",
@@ -71,7 +71,7 @@
     "raw-body": "2.3.3",
     "semver": "5.5.0",
     "sentiment": "2.1.0",
-    "uglify-js": "3.3.24",
+    "uglify-js": "3.3.25",
     "when": "3.7.8",
     "ws": "1.1.5",
     "xml2js": "0.4.19"

From af1ea610ea4eafb825d2521b1270aefa264843a5 Mon Sep 17 00:00:00 2001
From: Hiroyasu Nishiyama <hiroyasu.nishiyama.uq@hitachi.com>
Date: Mon, 21 May 2018 19:34:56 +0900
Subject: [PATCH 7/7] allow id and name reference in function node code (#1731)

---
 nodes/core/core/80-function.html         |  6 +++++
 nodes/core/core/80-function.js           |  4 ++++
 test/nodes/core/core/80-function_spec.js | 28 ++++++++++++++++++++++++
 3 files changed, 38 insertions(+)

diff --git a/nodes/core/core/80-function.html b/nodes/core/core/80-function.html
index 4d5131df8..61af46d36 100644
--- a/nodes/core/core/80-function.html
+++ b/nodes/core/core/80-function.html
@@ -52,6 +52,12 @@
     <p>The Catch node can also be used to handle errors. To invoke a Catch node,
     pass <code>msg</code> as a second argument to <code>node.error</code>:</p>
     <pre>node.error("Error",msg);</pre>
+    <h4>Referring Node Information</h4>
+    <p>In the function block, id and name of the node can be referenced using the following properties:</p>
+    <ul>
+        <li><code>node.id</code> - id of the node</li>
+        <li><code>node.name</code> - name of the node</li>
+    </ul>
 </script>
 
 <script type="text/javascript">
diff --git a/nodes/core/core/80-function.js b/nodes/core/core/80-function.js
index 8aa95e4fc..a76e1eead 100644
--- a/nodes/core/core/80-function.js
+++ b/nodes/core/core/80-function.js
@@ -62,6 +62,8 @@ module.exports = function(RED) {
                            "results = (function(msg){ "+
                               "var __msgid__ = msg._msgid;"+
                               "var node = {"+
+                                 "id:__node__.id,"+
+                                 "name:__node__.name,"+
                                  "log:__node__.log,"+
                                  "error:__node__.error,"+
                                  "warn:__node__.warn,"+
@@ -84,6 +86,8 @@ module.exports = function(RED) {
                 util: RED.util
             },
             __node__: {
+                id: node.id,
+                name: node.name,
                 log: function() {
                     node.log.apply(node, arguments);
                 },
diff --git a/test/nodes/core/core/80-function_spec.js b/test/nodes/core/core/80-function_spec.js
index b96588b5b..0e94f97af 100644
--- a/test/nodes/core/core/80-function_spec.js
+++ b/test/nodes/core/core/80-function_spec.js
@@ -508,6 +508,34 @@ describe('function node', function() {
         });
     });
 
+    it('should allow accessing node.id', function(done) {
+        var flow = [{id:"n1",type:"function",wires:[["n2"]],func:"msg.payload = node.id; return msg;"},
+                    {id:"n2", type:"helper"}];
+        helper.load(functionNode, flow, function() {
+            var n1 = helper.getNode("n1");
+            var n2 = helper.getNode("n2");
+            n2.on("input", function(msg) {
+                msg.should.have.property('payload', n1.id);
+                done();
+            });
+            n1.receive({payload:"foo",topicb: "bar"});
+        });
+    });
+
+    it('should allow accessing node.name', function(done) {
+        var flow = [{id:"n1",type:"function",wires:[["n2"]],func:"msg.payload = node.name; return msg;", "name":"name of node"},
+                    {id:"n2", type:"helper"}];
+        helper.load(functionNode, flow, function() {
+            var n1 = helper.getNode("n1");
+            var n2 = helper.getNode("n2");
+            n2.on("input", function(msg) {
+                msg.should.have.property('payload', n1.name);
+                done();
+            });
+            n1.receive({payload:"foo",topicb: "bar"});
+        });
+    });
+
     describe('Logger', function () {
         it('should log an Info Message', function (done) {
             var flow = [{id: "n1", type: "function", wires: [["n2"]], func: "node.log('test');"}];