@gregoriusrippenstein/node-red-contrib-nodedev 0.0.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,97 @@
1
+ <script type="text/javascript">
2
+ RED.nodes.registerType('NpmPublish',{
3
+ color: '#e5e4ef',
4
+ icon: "font-awesome/fa-money",
5
+ category: 'nodedev',
6
+ defaults: {
7
+ name: {
8
+ value:"",
9
+ },
10
+ otp: {
11
+ value: "",
12
+ },
13
+ action: {
14
+ value: "publish"
15
+ },
16
+ authToken: {
17
+ value: "NPM_AUTH_TOKEN",
18
+ },
19
+ authTokenType: {
20
+ value: "env",
21
+ },
22
+ },
23
+
24
+ inputs: 1,
25
+ outputs: 1,
26
+
27
+ label: function() {
28
+ return (this.name || this._def.paletteLabel);
29
+ },
30
+
31
+ labelStyle: function() {
32
+ return this.name?"node_label_italic":"";
33
+ },
34
+
35
+ onpaletteadd: function() {
36
+ },
37
+
38
+ oneditprepare: function() {
39
+ var sltObj = $('#node-input-action');
40
+ sltObj.html("");
41
+
42
+ ["publish","unpublish"].forEach( function(v) {
43
+ sltObj.append($('<option></option>').val(v).html(v));
44
+ });
45
+
46
+ sltObj.val(this.action || "publish");
47
+
48
+ $("#node-input-authToken").typedInput({
49
+ types:["env", "msg", "flow","global", "cred"],
50
+ typeField: "#node-input-authTokenType"
51
+ });
52
+ },
53
+
54
+ oneditcancel: function() {
55
+ },
56
+
57
+ oneditsave: function() {
58
+ },
59
+
60
+
61
+ });
62
+ </script>
63
+
64
+ <script type="text/html" data-template-name="NpmPublish">
65
+ <div class="form-row">
66
+ <label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
67
+ <input type="text" id="node-input-name" placeholder="Name">
68
+ </div>
69
+
70
+ <div class="form-row">
71
+ <label for="node-input-authToken">
72
+ <i class="fa fa-tag"></i>
73
+ NPM Auth Token
74
+ </label>
75
+ <input type="text" id="node-input-authToken">
76
+ <input type="hidden" id="node-input-authTokenType">
77
+ </div>
78
+
79
+ <div class="form-row">
80
+ <label for="node-input-otp"><i class="fa fa-tag"></i> OTP</label>
81
+ <input type="text" id="node-input-otp" placeholder="One Time Password">
82
+ </div>
83
+
84
+ <div class="form-row">
85
+ <label for="node-input-action">
86
+ <i class="fa fa-tag"></i> Action
87
+ </label>
88
+ <select id="node-input-action"></select>
89
+ </div>
90
+ </script>
91
+
92
+ <script type="text/html" data-help-name="NpmPublish">
93
+ <p>Publish tarball to NpmJS registry.</p>
94
+ This publishes or unpublishes a tarball generated by the NpmTarball node.
95
+
96
+ The package name is taken from the package.json if not supplied.
97
+ </script>
@@ -0,0 +1,76 @@
1
+ module.exports = function (RED) {
2
+ function NpmPublishFunctionality(config) {
3
+ RED.nodes.createNode(this, config);
4
+
5
+ var node = this;
6
+ var cfg = config;
7
+
8
+ const libpub = require('libnpmpublish');
9
+
10
+ node.on('close', function () {
11
+ node.status({});
12
+ });
13
+
14
+ node.on("input", function (msg, send, done) {
15
+ RED.util.evaluateNodeProperty(cfg.authToken, cfg.authTokenType, node, msg, (err, result) => {
16
+ if (err || result.trim() == "") {
17
+ node.status({
18
+ fill: "red",
19
+ shape: "dot",
20
+ text: "Failed, no AUTH TOKEN provided."
21
+ });
22
+
23
+ msg.error = err;
24
+ done("failed to get auth token", msg)
25
+ return;
26
+ }
27
+
28
+ var auth_token = result;
29
+ var tarball = Buffer.from(msg.payload)
30
+
31
+ var manifest = JSON.parse(msg.contents.filter((d) => {
32
+ return d.name == "package.json"
33
+ })[0].contents);
34
+
35
+ var opts = {
36
+ userAgent: "node-red-contrib-nodedev@1.1.1",
37
+ access: "public",
38
+ otp: msg.npmotp || cfg.otp,
39
+ authToken: auth_token,
40
+ '//registry.npmjs.org/:_authToken': auth_token,
41
+ };
42
+
43
+ var userscope = manifest.name.split("/")[0];
44
+ opts[userscope + ":registry"] = "https://registry.npmjs.org"
45
+
46
+ if (cfg.action == "publish") {
47
+ libpub.publish(
48
+ manifest, tarball, opts
49
+ ).then((data) => {
50
+ msg.payload = JSON.stringify(data);
51
+ send(msg)
52
+ done()
53
+ }).catch((exp) => {
54
+ msg.error = exp;
55
+ done("publish failed", msg)
56
+ })
57
+ }
58
+
59
+ if (cfg.action == "unpublish") {
60
+ libpub.unpublish(
61
+ manifest.name, opts
62
+ ).then((data) => {
63
+ msg.payload = JSON.stringify(data);
64
+ send(msg)
65
+ done()
66
+ }).catch((exp) => {
67
+ msg.error = exp;
68
+ done("publish failed", msg)
69
+ })
70
+ }
71
+ })
72
+ });
73
+ }
74
+
75
+ RED.nodes.registerType("NpmPublish", NpmPublishFunctionality);
76
+ }
@@ -0,0 +1,70 @@
1
+ <script type="text/javascript">
2
+ RED.nodes.registerType('{{ node.name }}',{
3
+ color: '{{ node.color }}',
4
+ icon: "{{{ node.icon }}}",
5
+ category: '{{ node.category }}',
6
+ defaults: {
7
+ name: {
8
+ value:"",
9
+ },
10
+ },
11
+
12
+ {{#node.hasinput}}
13
+ inputs: 1,
14
+ {{/node.hasinput}}
15
+ {{^node.hasinput}}
16
+ inputs: 0,
17
+ {{/node.hasinput}}
18
+
19
+ outputs: {{ node.outputcount }},
20
+
21
+ label: function() {
22
+ return (this.name || this._def.paletteLabel);
23
+ },
24
+
25
+ labelStyle: function() {
26
+ return this.name?"node_label_italic":"";
27
+ },
28
+
29
+ onpaletteadd: function() {
30
+ },
31
+
32
+ oneditprepare: function() {
33
+ },
34
+
35
+ oneditcancel: function() {
36
+ },
37
+
38
+ oneditsave: function() {
39
+ },
40
+
41
+ {{#node.hasbutton}}
42
+ button: {
43
+ enabled: function() {
44
+ return !this.changed
45
+ },
46
+
47
+ onclick: function () {
48
+ if (this.changed) {
49
+ return RED.notify(RED._("notification.warning", {
50
+ message: RED._("notification.warnings.undeployedChanges")
51
+ }), "warning");
52
+ }
53
+ }
54
+ },
55
+ {{/node.hasbutton}}
56
+
57
+ });
58
+ </script>
59
+
60
+ <script type="text/html" data-template-name="{{ node.name }}">
61
+ <div class="form-row">
62
+ <label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
63
+ <input type="text" id="node-input-name" placeholder="Name">
64
+ </div>
65
+ </script>
66
+
67
+ <script type="text/html" data-help-name="{{ node.name }}">
68
+ <p>{{ node.summary }}</p>
69
+ {{ node.description }}
70
+ </script>
@@ -0,0 +1,18 @@
1
+ module.exports = function(RED) {
2
+ function {{ node.name }}Functionality(config) {
3
+ RED.nodes.createNode(this,config);
4
+
5
+ var node = this;
6
+ var cfg = config;
7
+
8
+ node.on('close', function() {
9
+ node.status({});
10
+ });
11
+
12
+ node.on("input", function(msg, send, done) {
13
+ send(msg);
14
+ done();
15
+ });
16
+ }
17
+ RED.nodes.registerType("{{ node.name }}", {{ node.name }}Functionality);
18
+ }
package/package.json ADDED
@@ -0,0 +1,42 @@
1
+ {
2
+ "name" : "@gregoriusrippenstein/node-red-contrib-nodedev",
3
+ "version": "0.0.6",
4
+ "dependencies": {
5
+ "pako": "latest",
6
+ "tar-stream": "latest",
7
+ "mustache": "latest",
8
+ "libnpmpublish": "latest",
9
+ "streamx": "latest"
10
+ },
11
+
12
+ "keywords": [
13
+ "node-red", "node development", "introspection", "bootstrapping", "recursion"
14
+ ],
15
+
16
+ "homepage": "https://github.com/gorenje/node-red-contrib-nodedev",
17
+ "license": "Don't do evil.",
18
+ "author": "Gerrit Riessen <does.anyone@spread-the.love> (https://spread-the.love)",
19
+ "engines": {
20
+ "node": ">=16"
21
+ },
22
+
23
+ "node-red" : {
24
+ "version": ">=3.0.0",
25
+ "nodes": {
26
+ "nodefactory": "nodes/10-node-factory.js",
27
+ "pkgfile": "nodes/20-pkg-file.js",
28
+ "npmtarball": "nodes/30-npm-tarball.js",
29
+ "noderedinstall": "nodes/40-node-red-install.js",
30
+ "npmpublish": "nodes/50-npm-publish.js"
31
+ }
32
+ },
33
+
34
+ "description": "Support the development of Node-RED nodes within Node-RED.",
35
+ "repository": {
36
+ "type": "github",
37
+ "url": "git+https://github.com/gorenje/node-red-contrib-nodedev.git"
38
+ },
39
+ "bugs": {
40
+ "url": "https://github.com/gorenje/node-red-contrib-nodedev"
41
+ }
42
+ }