diff --git a/README.md b/README.md index af99b32..de2b055 100644 --- a/README.md +++ b/README.md @@ -93,12 +93,12 @@ You may need to run this with `sudo`, or from within an Administrator command sh ## Documentation -- [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)) -- [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)) -- [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)) -- [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)) -- [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)) -- [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)) -- [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)) +- [Use cases](https://github.com/node-red/node-red-nodegen/blob/0.2.3/docs/index.md#use-cases) ([Japanese](https://github.com/node-red/node-red-nodegen/blob/0.2.3/docs/index_ja.md#use-cases)) +- [How to use Node generator](https://github.com/node-red/node-red-nodegen/blob/0.2.3/docs/index.md#how-to-use-node-generator) ([Japanese](https://github.com/node-red/node-red-nodegen/blob/0.2.3/docs/index_ja.md#how-to-use-node-generator)) +- [Generated files which node package contains](https://github.com/node-red/node-red-nodegen/blob/0.2.3/docs/index.md#generated-files-which-node-package-contains) ([Japanese](https://github.com/node-red/node-red-nodegen/blob/0.2.3/docs/index_ja.md#generated-files-which-node-package-contains)) +- [How to create a node from OpenAPI document](https://github.com/node-red/node-red-nodegen/blob/0.2.3/docs/index.md#how-to-create-a-node-from-openapi-document) ([Japanese](https://github.com/node-red/node-red-nodegen/blob/0.2.3/docs/index_ja.md#how-to-create-a-node-from-openapi-document)) +- [How to create a node from function node](https://github.com/node-red/node-red-nodegen/blob/0.2.3/docs/index.md#how-to-create-a-node-from-function-node) ([Japanese](https://github.com/node-red/node-red-nodegen/blob/0.2.3/docs/index_ja.md#how-to-create-a-node-from-function-node)) +- [How to create a node from subflow](https://github.com/node-red/node-red-nodegen/blob/0.2.3/docs/index.md#how-to-create-a-node-from-subflow) ([Japanese](https://github.com/node-red/node-red-nodegen/blob/0.2.3/docs/index_ja.md#how-to-create-a-node-from-subflow)) +- [How to create a node from WoT Thing Description](https://github.com/node-red/node-red-nodegen/blob/0.2.3/docs/index.md#how-to-create-a-node-from-wot-thing-description) ([Japanese](https://github.com/node-red/node-red-nodegen/blob/0.2.3/docs/index_ja.md#how-to-create-a-node-from-wot-thing-description)) Note: Currently node generator supports GET and POST methods using JSON format without authentication. diff --git a/lib/subflow/index.js b/lib/subflow/index.js index 8a3d0a4..bd9e7c5 100644 --- a/lib/subflow/index.js +++ b/lib/subflow/index.js @@ -54,7 +54,7 @@ function createJSON(dstPath, flow, encoding, key) { else { sf.flow = newFlow; } - const data = JSON.stringify(sf, null, "\t"); + const data = JSON.stringify(sf, null, 4); fs.writeFileSync(dstPath, data); } @@ -79,6 +79,7 @@ module.exports = async function(data, options) { if (!data.license || (data.license === "")) { data.license = "unknown"; } + data.keywords = data.keywords || meta.keywords; data.info = meta.info; var params = { diff --git a/lib/swagger/index.js b/lib/swagger/index.js index 2c6d0f5..360802f 100644 --- a/lib/swagger/index.js +++ b/lib/swagger/index.js @@ -24,7 +24,7 @@ async function getSpec(src, data) { let response = await axios.get(src, requestOptions); spec = response.data; } else if (/\.yaml$/.test(src)) { - spec = yamljs.load(util.skipBom(await fs.promises.readFile(src))); + spec = yamljs.load(src); } else if (/\.json/.test(src)) { spec = JSON.parse(util.skipBom(await fs.promises.readFile(src))); } else { diff --git a/package.json b/package.json index 18b4bd3..2bf801e 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "node-red-nodegen", - "version": "0.2.2", + "version": "0.2.3", "description": "Node generator for Node-RED", "homepage": "http://nodered.org", "main": "./lib/nodegen.js", diff --git a/templates/function/package.json.mustache b/templates/function/package.json.mustache index 095a498..bf1f3cb 100644 --- a/templates/function/package.json.mustache +++ b/templates/function/package.json.mustache @@ -6,7 +6,11 @@ "scripts": { "test": "mocha \"test/**/*_spec.js\" --timeout 3000" }, + "engines": { + "node": ">=12.0.0" + }, "node-red": { + "version": ">=1.3.7", "nodes": { "{{&nodeName}}": "node.js" } diff --git a/templates/subflow/README.md.mustache b/templates/subflow/README.md.mustache index cae8709..a3b2239 100644 --- a/templates/subflow/README.md.mustache +++ b/templates/subflow/README.md.mustache @@ -9,6 +9,8 @@ Run the following command in your Node-RED user directory - typically `~/.node-r npm install {{&projectName}} +{{#nodeRead}} ## Information {{&nodeRead}} +{{/nodeRead}} diff --git a/templates/subflow/package.json.mustache b/templates/subflow/package.json.mustache index 9902cc9..a492866 100644 --- a/templates/subflow/package.json.mustache +++ b/templates/subflow/package.json.mustache @@ -7,7 +7,11 @@ "{{name}}"{{^last}}, {{/last}} {{/keywords}} ], + "engines": { + "node": ">=12.0.0" + }, "node-red": { + "version": ">=1.3.7", "nodes": { "{{&nodeName}}": "subflow.js" } diff --git a/templates/swagger/package.json.mustache b/templates/swagger/package.json.mustache index 67049b0..5d7b4f3 100644 --- a/templates/swagger/package.json.mustache +++ b/templates/swagger/package.json.mustache @@ -6,7 +6,11 @@ "scripts": { "test": "mocha \"test/**/*_spec.js\" --timeout 3000" }, + "engines": { + "node": ">=12.0.0" + }, "node-red": { + "version": ">=1.3.7", "nodes": { "{{&nodeName}}": "node.js" } @@ -19,7 +23,7 @@ "dependencies": { "q": "1.5.1", "request": "2.88.2", - "file-type": "17.1.1" + "file-type": "16.5.3" }, "devDependencies": { "mocha": "9.2.1", diff --git a/templates/webofthings/package.json.mustache b/templates/webofthings/package.json.mustache index a134e96..4b18e4b 100644 --- a/templates/webofthings/package.json.mustache +++ b/templates/webofthings/package.json.mustache @@ -1,37 +1,41 @@ { - "name": "{{&projectName}}", - "version": "{{&projectVersion}}", - "description": "Node-RED node for {{&nodeName}}", - "main": "node.js", - "scripts": { - "test": "mocha \"test/**/*_spec.js\"" - }, - "node-red": { - "nodes": { - "{{&nodeName}}": "node.js" - } - }, - "keywords": [ - {{#keywords}} - "{{name}}"{{^last}}, {{/last}} - {{/keywords}} - ], - "dependencies": { - "https-proxy-agent": "5.0.0", - "request": "2.88.2", - "ws": "8.5.0", - "url-template": "2.0.8", - "ajv": "8.10.0", - "coap": "1.0.3" - }, - "devDependencies": { - "node-red": "2.2.2", - "node-red-node-test-helper": "0.2.7" - }, - "license": "{{&licenseName}}", - "wot": { - {{#wotmeta}} - "{{name}}": "{{value}}"{{^last}}, {{/last}} - {{/wotmeta}} + "name": "{{&projectName}}", + "version": "{{&projectVersion}}", + "description": "Node-RED node for {{&nodeName}}", + "main": "node.js", + "scripts": { + "test": "mocha \"test/**/*_spec.js\"" + }, + "engines": { + "node": ">=12.0.0" + }, + "node-red": { + "version": ">=1.3.7", + "nodes": { + "{{&nodeName}}": "node.js" } + }, + "keywords": [ + {{#keywords}} + "{{name}}"{{^last}}, {{/last}} + {{/keywords}} + ], + "dependencies": { + "https-proxy-agent": "5.0.0", + "request": "2.88.2", + "ws": "8.5.0", + "url-template": "2.0.8", + "ajv": "8.10.0", + "coap": "1.0.3" + }, + "devDependencies": { + "node-red": "2.2.2", + "node-red-node-test-helper": "0.2.7" + }, + "license": "{{&licenseName}}", + "wot": { + {{#wotmeta}} + "{{name}}": "{{value}}"{{^last}}, {{/last}} + {{/wotmeta}} + } }