Skip to content

Commit c0aa191

Browse files
Merge pull request #130 from kazuhitoyokoi/master-updatesubflowtemplate
Output subflow information to README.md
2 parents 63b2417 + 0bcbfd8 commit c0aa191

File tree

7 files changed

+106
-29
lines changed

7 files changed

+106
-29
lines changed

README.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -93,12 +93,12 @@ You may need to run this with `sudo`, or from within an Administrator command sh
9393

9494
## Documentation
9595

96-
- [Use cases](https://github.com/node-red/node-red-nodegen/blob/0.2.1/docs/index.md#use-cases) ([Japanese](https://github.com/node-red/node-red-nodegen/blob/0.2.1/docs/index_ja.md#use-cases))
97-
- [How to use Node generator](https://github.com/node-red/node-red-nodegen/blob/0.2.1/docs/index.md#how-to-use-node-generator) ([Japanese](https://github.com/node-red/node-red-nodegen/blob/0.2.1/docs/index_ja.md#how-to-use-node-generator))
98-
- [Generated files which node package contains](https://github.com/node-red/node-red-nodegen/blob/0.2.1/docs/index.md#generated-files-which-node-package-contains) ([Japanese](https://github.com/node-red/node-red-nodegen/blob/0.2.1/docs/index_ja.md#generated-files-which-node-package-contains))
99-
- [How to create a node from OpenAPI document](https://github.com/node-red/node-red-nodegen/blob/0.2.1/docs/index.md#how-to-create-a-node-from-openapi-document) ([Japanese](https://github.com/node-red/node-red-nodegen/blob/0.2.1/docs/index_ja.md#how-to-create-a-node-from-openapi-document))
100-
- [How to create a node from function node](https://github.com/node-red/node-red-nodegen/blob/0.2.1/docs/index.md#how-to-create-a-node-from-function-node) ([Japanese](https://github.com/node-red/node-red-nodegen/blob/0.2.1/docs/index_ja.md#how-to-create-a-node-from-function-node))
101-
- [How to create a node from subflow](https://github.com/node-red/node-red-nodegen/blob/0.2.1/docs/index.md#how-to-create-a-node-from-subflow) ([Japanese](https://github.com/node-red/node-red-nodegen/blob/0.2.1/docs/index_ja.md#how-to-create-a-node-from-subflow))
102-
- [How to create a node from WoT Thing Description](https://github.com/node-red/node-red-nodegen/blob/0.2.1/docs/index.md#how-to-create-a-node-from-wot-thing-description) ([Japanese](https://github.com/node-red/node-red-nodegen/blob/0.2.1/docs/index_ja.md#how-to-create-a-node-from-wot-thing-description))
96+
- [Use cases](https://github.com/node-red/node-red-nodegen/blob/0.2.2/docs/index.md#use-cases) ([Japanese](https://github.com/node-red/node-red-nodegen/blob/0.2.2/docs/index_ja.md#use-cases))
97+
- [How to use Node generator](https://github.com/node-red/node-red-nodegen/blob/0.2.2/docs/index.md#how-to-use-node-generator) ([Japanese](https://github.com/node-red/node-red-nodegen/blob/0.2.2/docs/index_ja.md#how-to-use-node-generator))
98+
- [Generated files which node package contains](https://github.com/node-red/node-red-nodegen/blob/0.2.2/docs/index.md#generated-files-which-node-package-contains) ([Japanese](https://github.com/node-red/node-red-nodegen/blob/0.2.2/docs/index_ja.md#generated-files-which-node-package-contains))
99+
- [How to create a node from OpenAPI document](https://github.com/node-red/node-red-nodegen/blob/0.2.2/docs/index.md#how-to-create-a-node-from-openapi-document) ([Japanese](https://github.com/node-red/node-red-nodegen/blob/0.2.2/docs/index_ja.md#how-to-create-a-node-from-openapi-document))
100+
- [How to create a node from function node](https://github.com/node-red/node-red-nodegen/blob/0.2.2/docs/index.md#how-to-create-a-node-from-function-node) ([Japanese](https://github.com/node-red/node-red-nodegen/blob/0.2.2/docs/index_ja.md#how-to-create-a-node-from-function-node))
101+
- [How to create a node from subflow](https://github.com/node-red/node-red-nodegen/blob/0.2.2/docs/index.md#how-to-create-a-node-from-subflow) ([Japanese](https://github.com/node-red/node-red-nodegen/blob/0.2.2/docs/index_ja.md#how-to-create-a-node-from-subflow))
102+
- [How to create a node from WoT Thing Description](https://github.com/node-red/node-red-nodegen/blob/0.2.2/docs/index.md#how-to-create-a-node-from-wot-thing-description) ([Japanese](https://github.com/node-red/node-red-nodegen/blob/0.2.2/docs/index_ja.md#how-to-create-a-node-from-wot-thing-description))
103103

104104
Note: Currently node generator supports GET and POST methods using JSON format without authentication.

lib/subflow/index.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ module.exports = async function(data, options) {
7979
if (!data.license || (data.license === "")) {
8080
data.license = "unknown";
8181
}
82+
data.info = meta.info;
8283

8384
var params = {
8485
nodeName: data.name,
@@ -88,6 +89,8 @@ module.exports = async function(data, options) {
8889
category: data.category || "subflow",
8990
description: data.desc,
9091
licenseName: data.license,
92+
nodeRead: sf.info || "",
93+
encoding: options.encoding
9194
};
9295

9396
// Make directory

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "node-red-nodegen",
3-
"version": "0.2.1",
3+
"version": "0.2.2",
44
"description": "Node generator for Node-RED",
55
"homepage": "http://nodered.org",
66
"main": "./lib/nodegen.js",

samples/qrcode.json

Lines changed: 66 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,66 @@
1-
[{"id":"921a4b1d.07bb68","type":"subflow","name":"QRcode","info":"","category":"","in":[{"x":140,"y":120,"wires":[{"id":"e563f491.e443f8"}]}],"out":[{"x":380,"y":120,"wires":[{"id":"e563f491.e443f8","port":0}]}],"env":[],"meta":{"module":"node-red-contrib-qrcode","type":"qrcode","version":"0.1.0","author":"[email protected]","desc":"Node-RED node for converting string to QRcode","keywords":"Node-RED, subflow, QRcode","license":"Apache-2.0"},"color":"#87A980","icon":"font-awesome/fa-qrcode"},{"id":"e563f491.e443f8","type":"function","z":"921a4b1d.07bb68","name":"","func":"qrcode.toString(msg.payload, (err,str) => {\n if (err) {\n node.error(err);\n return;\n }\n node.send({payload: str});\n});","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[{"var":"qrcode","module":"qrcode"}],"x":260,"y":120,"wires":[[]]}]
1+
[
2+
{
3+
"id": "921a4b1d.07bb68",
4+
"type": "subflow",
5+
"name": "QRcode",
6+
"info": "This node generates a QR code from the text data in the `msg.payload`. The QR code in the outputted `msg.payload` is text data (not image data) described by text which consists of black rectangles and white spaces. Therefore, you can use the debug node to see the QR code.\n\n### Inputs\n- `payload` - _string_\n\n Text data which is converted to QR code\n\n### Outputs\n- `payload` - _string_\n\n Text data which contains QR code\n\n**Note**: This node uses the [node-qrcode](https://www.npmjs.com/package/qrcode) module to generate QR codes.",
7+
"category": "",
8+
"in": [
9+
{
10+
"x": 140,
11+
"y": 120,
12+
"wires": [
13+
{
14+
"id": "e563f491.e443f8"
15+
}
16+
]
17+
}
18+
],
19+
"out": [
20+
{
21+
"x": 380,
22+
"y": 120,
23+
"wires": [
24+
{
25+
"id": "e563f491.e443f8",
26+
"port": 0
27+
}
28+
]
29+
}
30+
],
31+
"env": [],
32+
"meta": {
33+
"module": "node-red-contrib-qrcode",
34+
"type": "qrcode",
35+
"version": "0.1.0",
36+
"author": "[email protected]",
37+
"desc": "Node-RED node for converting string to QRcode",
38+
"keywords": "Node-RED, subflow, QRcode",
39+
"license": "Apache-2.0"
40+
},
41+
"color": "#87A980",
42+
"icon": "font-awesome/fa-qrcode"
43+
},
44+
{
45+
"id": "e563f491.e443f8",
46+
"type": "function",
47+
"z": "921a4b1d.07bb68",
48+
"name": "",
49+
"func": "qrcode.toString(msg.payload, (err,str) => {\n if (err) {\n node.error(err);\n return;\n }\n node.send({payload: str});\n});",
50+
"outputs": 1,
51+
"noerr": 0,
52+
"initialize": "",
53+
"finalize": "",
54+
"libs": [
55+
{
56+
"var": "qrcode",
57+
"module": "qrcode"
58+
}
59+
],
60+
"x": 260,
61+
"y": 120,
62+
"wires": [
63+
[]
64+
]
65+
}
66+
]

templates/subflow/README.md.mustache

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,12 @@
33

44
{{&description}}
55

6-
Install
7-
-------
6+
## Install
87

98
Run the following command in your Node-RED user directory - typically `~/.node-red`
109

1110
npm install {{&projectName}}
1211

12+
## Information
13+
14+
{{&nodeRead}}
Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,21 @@
11
{
2-
"name": "{{&projectName}}",
3-
"version": "{{&projectVersion}}",
4-
"description": "Node-RED node for {{&nodeName}}",
5-
"node-red": {
6-
"nodes": {
7-
"{{&nodeName}}": "subflow.js"
8-
}
9-
},
10-
"keywords": [
11-
{{#keywords}}
12-
"{{name}}"{{^last}}, {{/last}}
13-
{{/keywords}}
14-
],
15-
"dependencies": {
16-
"crypto-js": "4.1.1"
2+
"name": "{{&projectName}}",
3+
"version": "{{&projectVersion}}",
4+
"description": "Node-RED node for {{&nodeName}}",
5+
"keywords": [
6+
{{#keywords}}
7+
"{{name}}"{{^last}}, {{/last}}
8+
{{/keywords}}
9+
],
10+
"node-red": {
11+
"nodes": {
12+
"{{&nodeName}}": "subflow.js"
1713
}
14+
},
15+
{{#encoding}}
16+
"dependencies": {
17+
"crypto-js": "4.1.1"
18+
},
19+
{{/encoding}}
20+
"license": "{{&licenseName}}"
1821
}

templates/subflow/subflow.js.mustache

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
module.exports = function(RED) {
1+
module.exports = function (RED) {
22
const fs = require('fs');
33
const path = require("path");
4-
const crypt = require("crypto-js");
5-
64
const file = path.join(__dirname, "subflow.json");
75
const text = fs.readFileSync(file);
86
const flow = JSON.parse(text);
7+
{{#encoding}}
8+
const crypt = require("crypto-js");
99

1010
function getDecoder(encoding) {
1111
var settings = RED.settings;
@@ -63,4 +63,8 @@ module.exports = function(RED) {
6363
}
6464

6565
RED.nodes.registerSubflow(convFlow(flow));
66+
{{/encoding}}
67+
{{^encoding}}
68+
RED.nodes.registerSubflow(flow);
69+
{{/encoding}}
6670
}

0 commit comments

Comments
 (0)