From a37fa35a8aed6b533f3fb0796fa18d5d57f2549d Mon Sep 17 00:00:00 2001 From: Nick O'Leary Date: Mon, 6 Apr 2020 21:42:44 +0100 Subject: [PATCH] [groups] Add node-red-node-group node --- utility/group/LICENSE | 14 ++++++++++++++ utility/group/README.md | 25 ++++++++++++++++++++++++ utility/group/group.html | 39 ++++++++++++++++++++++++++++++++++++++ utility/group/group.js | 16 ++++++++++++++++ utility/group/package.json | 20 +++++++++++++++++++ 5 files changed, 114 insertions(+) create mode 100644 utility/group/LICENSE create mode 100644 utility/group/README.md create mode 100644 utility/group/group.html create mode 100644 utility/group/group.js create mode 100644 utility/group/package.json diff --git a/utility/group/LICENSE b/utility/group/LICENSE new file mode 100644 index 00000000..f5b60114 --- /dev/null +++ b/utility/group/LICENSE @@ -0,0 +1,14 @@ +Copyright 2016 JS Foundation and other contributors, https://js.foundation/ +Copyright 2013-2016 IBM Corp. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + +http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. diff --git a/utility/group/README.md b/utility/group/README.md new file mode 100644 index 00000000..4c6f56e2 --- /dev/null +++ b/utility/group/README.md @@ -0,0 +1,25 @@ +node-red-node-group +=================== + +A Node-RED node to allow flows containing groups to be imported into older versions +of Node-RED. + +The ability to create groups was introduced in Node-RED 1.1.0, adding a new core +node type called `group`. + +This module provides its own `group` node type that can be installed into older +versions of Node-RED to allow them to run flows containing that type. + +It does *not* provide any group-like functionality - it *only* registers a +placeholder `group` node type. + +The module will only register the type if it detects it is being loaded into +Node-RED 1.0.x or older, otherwise it does nothing. + + +Install +------- + +Run the following command in your Node-RED user directory - typically `~/.node-red` + + npm i node-red-node-group diff --git a/utility/group/group.html b/utility/group/group.html new file mode 100644 index 00000000..d002ba40 --- /dev/null +++ b/utility/group/group.html @@ -0,0 +1,39 @@ + + + + + diff --git a/utility/group/group.js b/utility/group/group.js new file mode 100644 index 00000000..f976d2f4 --- /dev/null +++ b/utility/group/group.js @@ -0,0 +1,16 @@ + +module.exports = function(RED) { + var version = RED.version(); + var parts = /^(\d)+\.(\d)+\.(\d)+/.exec(version); + if (parts) { + var major = parseInt(parts[1]); + var minor = parseInt(parts[2]); + if (major > 1 || (major === 1 && minor > 0)) { + throw new Error("This module is not required for Node-RED 1.1.0 or later") + } + } + function GroupPolyfillNode(n) { + RED.nodes.createNode(this,n); + } + RED.nodes.registerType("group",GroupPolyfillNode); +} diff --git a/utility/group/package.json b/utility/group/package.json new file mode 100644 index 00000000..fb88571e --- /dev/null +++ b/utility/group/package.json @@ -0,0 +1,20 @@ +{ + "name": "node-red-node-group", + "version": "1.0.0", + "description": "A Node-RED node to allow flows containing groups to be imported into Node-RED 1.0.x or earlier.", + "dependencies": {}, + "repository": { + "type": "git", + "url": "https://github.com/node-red/node-red-nodes/tree/master/utility/group" + }, + "license": "Apache-2.0", + "keywords": [ + "node-red" + ], + "node-red": { + "nodes": { + "group": "group.js" + } + }, + "author": "Nick O'Leary " +}