Skip to content

Commit

Permalink
Merge pull request #131 from kazuhitoyokoi/master-updatenodetemplate
Browse files Browse the repository at this point in the history
Improve node templates
  • Loading branch information
kazuhitoyokoi authored Mar 30, 2022
2 parents c0aa191 + b77eca1 commit 4b2e94e
Show file tree
Hide file tree
Showing 7 changed files with 56 additions and 37 deletions.
3 changes: 2 additions & 1 deletion lib/subflow/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand All @@ -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 = {
Expand Down
2 changes: 1 addition & 1 deletion lib/swagger/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
4 changes: 4 additions & 0 deletions templates/function/package.json.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
Expand Down
2 changes: 2 additions & 0 deletions templates/subflow/README.md.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ Run the following command in your Node-RED user directory - typically `~/.node-r

npm install {{&projectName}}

{{#nodeRead}}
## Information

{{&nodeRead}}
{{/nodeRead}}
4 changes: 4 additions & 0 deletions templates/subflow/package.json.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,11 @@
"{{name}}"{{^last}}, {{/last}}
{{/keywords}}
],
"engines": {
"node": ">=12.0.0"
},
"node-red": {
"version": ">=1.3.7",
"nodes": {
"{{&nodeName}}": "subflow.js"
}
Expand Down
6 changes: 5 additions & 1 deletion templates/swagger/package.json.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
Expand All @@ -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",
Expand Down
72 changes: 38 additions & 34 deletions templates/webofthings/package.json.mustache
Original file line number Diff line number Diff line change
@@ -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}}
}
}

0 comments on commit 4b2e94e

Please sign in to comment.