@gregoriusrippenstein/node-red-contrib-nodedev 0.4.6 → 0.4.8

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.
package/README.md CHANGED
@@ -2,9 +2,11 @@
2
2
 
3
3
  *What?*
4
4
 
5
- The idea behind this collection of nodes to democratise the development of Node-RED nodes. Normally the development of your [own nodes](https://nodered.org/docs/creating-nodes/) will require the use of a third-party editor. Something like VSCode or Vim or Atom or god forbid, [Emacs](https://discourse.nodered.org/t/node-red-node-development-in-node-red/81525/2). This requirement makes creating nodes that much harder. So why not create nodes for Node-RED in Node-RED? After all, if you are using Node-RED, you probably understand how to use Node-RED.
5
+ The idea behind this collection of nodes to democratise the development of Node-RED nodes. Normally the development of your [own nodes](https://nodered.org/docs/creating-nodes/) will require the use of a third-party editor. Something like VSCode or Vim or Atom or [Emacs](https://discourse.nodered.org/t/node-red-node-development-in-node-red/81525/2). This requirement makes creating nodes that much harder. So why not create nodes for Node-RED in Node-RED? After all, if you are using Node-RED, you probably understand how to use Node-RED.
6
6
 
7
- So this package tries to provide some supporting nodes for making node development in Node-RED possible and simpler. I have created a set of nodes that fulfill my needs, everything else is bound my imagination.
7
+ So this package tries to provide some supporting nodes for making node development in Node-RED possible and simpler. I have created a set of nodes that fulfill my needs, everything else is bound my imagination.
8
+
9
+ Imagine a [continous integration](https://en.wikipedia.org/wiki/Continuous_integration) server combined with an editor. This can be done because Node-RED can both editor code (using something like a function node) and also perform actions such as posting data off to servers (http request node).
8
10
 
9
11
  *What do these nodes provide?*
10
12
 
@@ -14,14 +16,13 @@ So this package tries to provide some supporting nodes for making node developme
14
16
  - A `NodeFactory` node that can create templates for node development. It also converts existing `.tgz` packages to `PkgFile` nodes, meaning that existing packages can easily be ported to this style of development.
15
17
  - A `NpmPublish` allows node packages to be published to a node registry, for example [npmjs](https://www.npmjs.com/). The NpmPublish can also be used to publish to private registries, for example, those based on [Verdaccio](https://verdaccio.org/).
16
18
  - A `OTPGenerate` node can be used to generate an One Time Password (OTP) for publishing nodes to registries. For example the NPMjs.com registry.
19
+ - The `NodeDevOps` node controls what is done, i.e., install package locally, commit to GitHub or publish to Npm. For these operations to work, a support [flow](https://flowhub.org/f/d0506e991d512ace) needs to be installed in Node-RED. This can be done using the [FlowHub nodes](https://flows.nodered.org/node/@gregoriusrippenstein/node-red-contrib-flowhub).
17
20
 
18
21
  *This is all very confusing?*
19
22
 
20
- Of course, all this is very meta and it gets worse since these nodes are maintained by this [flow](https://flowhub.org/f/b92be5062203ff69). These nodes are creating in Node-RED in a kind of a bootstrapping for further node development in Node-RED.
21
-
22
- This is not an inbuilt extension of Node-RED and obviously a more integrated workflow would be simpler. This is a attempt to find a better solution to node development, one by which testing and fixing nodes becomes faster.
23
+ Of course, all this is very meta and it gets worse since these nodes are maintained by this [flow](https://flowhub.org/f/b92be5062203ff69). These nodes are bootstrapped in Node-RED to aid Node-RED node development within Node-RED. On the other hand, Node-RED node [development](https://nodered.org/docs/creating-nodes/) is initially also confusing (requiring at least three different files). That's why the NodeFactory provides templates for various types of nodes.
23
24
 
24
- It also gets more confusing since these nodes will open the Node-RED import dialog with pre-defined nodes. These are generally safe to import since that's how this package creates an initial set of nodes for representing a node package. Also importing nodes for an unknown node package is not recommended unless it happens to be your own package!
25
+ This is not an inbuilt extension of Node-RED and obviously a more integrated workflow would be simpler. This is a attempt to find a better solution to Node-RED node development (*not* NodeJS development), one by which testing and fixing nodes becomes faster because everything is done in Node-RED.
25
26
 
26
27
  ### Screencast
27
28
 
@@ -1,208 +1,224 @@
1
1
  <script type="text/javascript">
2
- (function(){
3
-
4
- function sendToBackend(node,data = {}) {
5
-
6
- $.ajax({
7
- url: "NodeDevOps/" + node.id,
8
- type: "POST",
9
- contentType: "application/json; charset=utf-8",
10
-
11
- data: JSON.stringify(data),
12
-
13
- success: function (resp) {
14
- RED.notify("Node Developer Operation trigger", {
15
- type: "success",
16
- id: "NodeDevOps",
17
- timeout: 2000
18
- });
19
- },
20
-
21
- error: function (jqXHR, textStatus, errorThrown) {
22
- if (jqXHR.status == 404) {
23
- RED.notify("Node has not yet been deployed, please deploy.", "error");
24
- } else if (jqXHR.status == 405) {
25
- RED.notify("Not Allowed.", "error");
26
- } else if (jqXHR.status == 500) {
27
- RED.notify(node._("common.notification.error", {
28
- message: node._("inject.errors.failed")
29
- }), "error");
30
- } else if (jqXHR.status == 0) {
31
- RED.notify(node._("common.notification.error", {
32
- message: node._("common.notification.errors.no-response")
33
- }), "error");
34
- } else {
35
- RED.notify(node._("common.notification.error", {
36
- message: node._("common.notification.errors.unexpected", {
37
- status: jqXHR.status, message: textStatus }) }), "error");
38
- }
39
- }
2
+ (function(){
3
+ function sendToBackend(node, data = {}) {
4
+ $.ajax({
5
+ url: "NodeDevOps/" + node.id,
6
+ type: "POST",
7
+ contentType: "application/json; charset=utf-8",
8
+
9
+ data: JSON.stringify(data),
10
+
11
+ success: function (resp) {
12
+ RED.notify("Node Developer Operation trigger", {
13
+ type: "success",
14
+ id: "NodeDevOps",
15
+ timeout: 2000
40
16
  });
41
- }
42
-
43
- RED.nodes.registerType('NodeDevOps',{
44
- color: '#e5e4ef',
45
- icon: "font-awesome/fa-terminal",
46
- category: 'nodedev',
47
- defaults: {
48
- name: { value:"" },
49
-
50
- pname: { value: "", required: true },
51
- pversion: { value: "", required: true },
52
- pauthorname: { value: "", required: true },
53
- pauthoremail: { value: "", required: true },
54
- pdescription: { value: "", required: true },
55
-
56
- noderedinstall: { value: false },
57
- randompackagename: { value: false },
58
-
59
- nodered_uninstall: { value: false },
60
-
61
- ignore_package_check: { value: false },
62
-
63
- gitcommit: { value: false },
64
- gitcheckforchange: { value: false },
65
- githubowner: { value: ""},
66
- githubrepo: { value: ""},
67
- githubbranch: { value: "main"},
68
- githubauthor: { value: ""},
69
- githubauthoremail: { value: "" },
70
- githubmessage: { value: "" },
71
- githubgettar: { value: false },
72
-
73
- npmpublish: { value: false },
74
- npmunpublish: { value: false },
75
- npmotp: { value: ""},
76
-
77
- writetgzfile: { value: false },
78
17
  },
79
18
 
80
- inputs: 0,
81
- outputs: 1,
19
+ error: function (jqXHR, textStatus, errorThrown) {
20
+ if (jqXHR.status == 404) {
21
+ RED.notify("Node has not yet been deployed, please deploy.", "error");
22
+ } else if (jqXHR.status == 405) {
23
+ RED.notify("Not Allowed.", "error");
24
+ } else if (jqXHR.status == 500) {
25
+ RED.notify(node._("common.notification.error", {
26
+ message: node._("inject.errors.failed")
27
+ }), "error");
28
+ } else if (jqXHR.status == 0) {
29
+ RED.notify(node._("common.notification.error", {
30
+ message: node._("common.notification.errors.no-response")
31
+ }), "error");
32
+ } else {
33
+ RED.notify(node._("common.notification.error", {
34
+ message: node._("common.notification.errors.unexpected", {
35
+ status: jqXHR.status, message: textStatus
36
+ })
37
+ }), "error");
38
+ }
39
+ }
40
+ });
41
+ }
42
+
43
+ RED.nodes.registerType('NodeDevOps', {
44
+ color: '#e5e4ef',
45
+ icon: "font-awesome/fa-terminal",
46
+ category: 'nodedev',
47
+ defaults: {
48
+ name: { value: "" },
49
+
50
+ pname: { value: "", required: true },
51
+ pversion: { value: "", required: true },
52
+ pauthorname: { value: "", required: true },
53
+ pauthoremail: { value: "", required: true },
54
+ pdescription: { value: "", required: true },
55
+
56
+ noderedinstall: { value: false },
57
+ randompackagename: { value: false },
58
+
59
+ nodered_uninstall: { value: false },
60
+
61
+ ignore_package_check: { value: false },
62
+
63
+ gitcommit: { value: false },
64
+ gitcheckforchange: { value: false },
65
+ githubowner: { value: "" },
66
+ githubrepo: { value: "" },
67
+ githubbranch: { value: "main" },
68
+ githubauthor: { value: "" },
69
+ githubauthoremail: { value: "" },
70
+ githubmessage: { value: "" },
71
+ githubgettar: { value: false },
72
+ githubtoken: { value: "GITHUB_TOKEN" },
73
+ githubtokenType: { value: "env" },
74
+
75
+ npmpublish: { value: false },
76
+ npmunpublish: { value: false },
77
+ npmotp: { value: "" },
78
+ npmtoken: { value: "NPM_AUTH_TOKEN" },
79
+ npmtokenType: { value: "env" },
80
+
81
+ writetgzfile: { value: false },
82
+
83
+ },
84
+
85
+ inputs: 0,
86
+ outputs: 1,
87
+
88
+ label: function () {
89
+ return (this.name || this._def.paletteLabel);
90
+ },
91
+
92
+ labelStyle: function () {
93
+ return this.name ? "node_label_italic" : "";
94
+ },
95
+
96
+ onpaletteadd: function () {
97
+ },
98
+
99
+ oneditprepare: function () {
100
+ $('#node-input-nodered_uninstall').on('change', () => {
101
+ if ($('#node-input-nodered_uninstall').is(":checked")) {
102
+ $('#node-input-noderedinstall').prop('checked', false).trigger('change')
103
+ }
104
+ })
105
+
106
+ $('#node-input-noderedinstall').on('change', () => {
107
+ if ($('#node-input-noderedinstall').is(":checked")) {
108
+ $('#node-input-nodered_uninstall').prop('checked', false).trigger('change')
109
+ $("#noderedinstall-options").animate({ opacity: 'show', height: 'show' }, 450);
110
+ } else {
111
+ $("#noderedinstall-options").animate({ opacity: 'hide', height: 'hide' }, 450);
112
+ }
113
+ });
114
+
115
+ $('#node-input-gitcommit').on('change', () => {
116
+ if ($('#node-input-gitcommit').is(":checked")) {
117
+ $("#github-options").animate({ opacity: 'show', height: 'show' }, 450);
118
+ $("#gitcommit-options").animate({ opacity: 'show', height: 'show' }, 450);
119
+ $('#node-input-gitcheckforchange').prop('checked', false)
120
+ } else {
121
+ $("#gitcommit-options").animate({ opacity: 'hide', height: 'hide' }, 450);
122
+ if (!$('#node-input-gitcheckforchange').is(":checked")) {
123
+ $("#github-options").animate({ opacity: 'hide', height: 'hide' }, 450);
124
+ }
125
+ }
126
+ });
127
+
128
+ $('#node-input-gitcheckforchange').on('change', () => {
129
+ if ($('#node-input-gitcheckforchange').is(":checked")) {
130
+ $("#github-options").animate({ opacity: 'show', height: 'show' }, 450);
131
+ $("#gitcommit-options").animate({ opacity: 'hide', height: 'hide' }, 450);
132
+ $('#node-input-gitcommit').prop('checked', false)
133
+ } else {
134
+ if (!$('#node-input-gitcommit').is(":checked")) {
135
+ $("#github-options").animate({ opacity: 'hide', height: 'hide' }, 450);
136
+ $("#gitcommit-options").animate({ opacity: 'hide', height: 'hide' }, 450);
137
+ }
138
+ }
139
+ });
140
+
141
+ $('#node-input-githubgettar').on('change', () => {
142
+ if ($('#node-input-githubgettar').is(":checked")) {
143
+ $("#github-options").animate({ opacity: 'show', height: 'show' }, 450);
144
+ $('#node-input-ignore_package_check').prop('checked', true)
145
+ } else {
146
+ if (!$('#node-input-gitcheckforchange').is(":checked") && !$('#node-input-gitcommit').is(":checked")) {
147
+ $("#github-options").animate({ opacity: 'hide', height: 'hide' }, 450);
148
+ }
149
+ }
150
+ });
151
+
152
+ $('#node-input-npmpublish').on('change', () => {
153
+ if ($('#node-input-npmpublish').is(":checked")) {
154
+ $("#npmpublish-options").animate({ opacity: 'show', height: 'show' }, 450);
155
+ $('#node-input-npmunpublish').prop('checked', false)
156
+ } else {
157
+ if (!$('#node-input-npmunpublish').is(":checked")) {
158
+ $("#npmpublish-options").animate({ opacity: 'hide', height: 'hide' }, 450);
159
+ }
160
+ }
161
+ });
162
+
163
+ $('#node-input-npmunpublish').on('change', () => {
164
+ if ($('#node-input-npmunpublish').is(":checked")) {
165
+ $("#npmpublish-options").animate({ opacity: 'show', height: 'show' }, 450);
166
+ $('#node-input-npmpublish').prop('checked', false)
167
+ } else {
168
+ if (!$('#node-input-npmpublish').is(":checked")) {
169
+ $("#npmpublish-options").animate({ opacity: 'hide', height: 'hide' }, 450);
170
+ }
171
+ }
172
+ });
82
173
 
83
- label: function() {
84
- return (this.name || this._def.paletteLabel);
85
- },
174
+ $("#node-input-npmtoken").typedInput({
175
+ types: ["env", "msg", "global", "cred"],
176
+ typeField: "#node-input-npmtokenType"
177
+ });
86
178
 
87
- labelStyle: function() {
88
- return this.name?"node_label_italic":"";
89
- },
179
+ $("#node-input-githubtoken").typedInput({
180
+ types: ["env", "msg", "global", "cred"],
181
+ typeField: "#node-input-githubtokenType"
182
+ });
90
183
 
91
- onpaletteadd: function() {
92
- },
184
+ },
93
185
 
94
- oneditprepare: function() {
95
- $('#node-input-nodered_uninstall').on('change', () => {
96
- if ( $('#node-input-nodered_uninstall').is(":checked") ) {
97
- $('#node-input-noderedinstall').prop('checked',false).trigger('change')
98
- }
99
- })
100
-
101
- $('#node-input-noderedinstall').on('change', () => {
102
- if ( $('#node-input-noderedinstall').is(":checked") ) {
103
- $('#node-input-nodered_uninstall').prop('checked',false).trigger('change')
104
- $("#noderedinstall-options").animate({opacity: 'show', height: 'show'}, 450);
105
- } else {
106
- $("#noderedinstall-options").animate({opacity: 'hide', height: 'hide'}, 450);
107
- }
108
- });
109
-
110
- $('#node-input-gitcommit').on('change', () => {
111
- if ( $('#node-input-gitcommit').is(":checked") ) {
112
- $("#github-options").animate({opacity: 'show', height: 'show'}, 450);
113
- $("#gitcommit-options").animate({opacity: 'show', height: 'show'}, 450);
114
- $('#node-input-gitcheckforchange').prop('checked',false)
115
- } else {
116
- $("#gitcommit-options").animate({opacity: 'hide', height: 'hide'}, 450);
117
- if ( !$('#node-input-gitcheckforchange').is(":checked") ) {
118
- $("#github-options").animate({opacity: 'hide', height: 'hide'}, 450);
119
- }
120
- }
121
- });
122
-
123
- $('#node-input-gitcheckforchange').on('change', () => {
124
- if ( $('#node-input-gitcheckforchange').is(":checked") ) {
125
- $("#github-options").animate({opacity: 'show', height: 'show'}, 450);
126
- $("#gitcommit-options").animate({opacity: 'hide', height: 'hide'}, 450);
127
- $('#node-input-gitcommit').prop('checked',false)
128
- } else {
129
- if ( !$('#node-input-gitcommit').is(":checked") ) {
130
- $("#github-options").animate({opacity: 'hide', height: 'hide'}, 450);
131
- $("#gitcommit-options").animate({opacity: 'hide', height: 'hide'}, 450);
132
- }
133
- }
134
- });
135
-
136
- $('#node-input-githubgettar').on('change', () => {
137
- if ( $('#node-input-githubgettar').is(":checked") ) {
138
- $("#github-options").animate({opacity: 'show', height: 'show'}, 450);
139
- $('#node-input-ignore_package_check').prop('checked',true)
140
- } else {
141
- if ( !$('#node-input-gitcheckforchange').is(":checked") && !$('#node-input-gitcommit').is(":checked") ) {
142
- $("#github-options").animate({opacity: 'hide', height: 'hide'}, 450);
143
- }
144
- }
145
- });
146
-
147
- $('#node-input-npmpublish').on('change', () => {
148
- if ( $('#node-input-npmpublish').is(":checked") ) {
149
- $("#npmpublish-options").animate({opacity: 'show', height: 'show'}, 450);
150
- $('#node-input-npmunpublish').prop('checked',false)
151
- } else {
152
- if ( !$('#node-input-npmunpublish').is(":checked") ) {
153
- $("#npmpublish-options").animate({opacity: 'hide', height: 'hide'}, 450);
154
- }
155
- }
156
- });
157
-
158
- $('#node-input-npmunpublish').on('change', () => {
159
- if ( $('#node-input-npmunpublish').is(":checked") ) {
160
- $("#npmpublish-options").animate({opacity: 'show', height: 'show'}, 450);
161
- $('#node-input-npmpublish').prop('checked',false)
162
- } else {
163
- if ( !$('#node-input-npmpublish').is(":checked") ) {
164
- $("#npmpublish-options").animate({opacity: 'hide', height: 'hide'}, 450);
165
- }
166
- }
167
- });
186
+ oneditcancel: function () {
187
+ },
168
188
 
169
- },
189
+ oneditsave: function () {
190
+ },
170
191
 
171
- oneditcancel: function() {
172
- },
192
+ onpaletteremove: function () {
193
+ },
173
194
 
174
- oneditsave: function() {
175
- },
176
195
 
177
- onpaletteremove: function() {
196
+ button: {
197
+ enabled: function () {
198
+ return !this.changed
178
199
  },
179
200
 
201
+ onclick: function () {
202
+ if (this.changed) {
203
+ return RED.notify(RED._("notification.warning", {
204
+ message: RED._("notification.warnings.undeployedChanges")
205
+ }), "warning");
206
+ }
180
207
 
181
- button: {
182
- enabled: function() {
183
- return !this.changed
184
- },
208
+ var that = this;
209
+ var data = {}
185
210
 
186
- onclick: function () {
187
- if (this.changed) {
188
- return RED.notify(RED._("notification.warning", {
189
- message: RED._("notification.warnings.undeployedChanges")
190
- }), "warning");
191
- }
211
+ Object.keys(that._def.defaults).forEach(kname => {
212
+ data[kname] = that[kname]
213
+ })
192
214
 
193
- var that = this;
194
- var data = {}
215
+ sendToBackend(that, data)
216
+ }
217
+ },
195
218
 
196
- Object.keys(that._def.defaults).forEach( kname => {
197
- data[kname] = that[kname]
198
- })
199
-
200
- sendToBackend(that, data)
201
- }
202
- },
219
+ });
203
220
 
204
- });
205
- })();
221
+ })();
206
222
  </script>
207
223
 
208
224
  <script type="text/html" data-template-name="NodeDevOps">
@@ -211,8 +227,8 @@
211
227
  <input type="text" id="node-input-name" placeholder="Name"/>
212
228
  </div>
213
229
 
214
- <hr/>
215
-
230
+ <hr />
231
+
216
232
  <div class="form-row">
217
233
  <label for="node-input-pname" style="min-width: 150px;">Package Details:</label>
218
234
  </div>
@@ -226,7 +242,7 @@
226
242
  <label for="node-input-pversion" style="min-width: 150px;"><i class="fa fa-tag"></i> Version</label>
227
243
  <input type="text" id="node-input-pversion" placeholder="0.0.1"/>
228
244
  </div>
229
-
245
+
230
246
  <div class="form-row">
231
247
  <label for="node-input-pauthorname" style="min-width: 150px;"><i class="fa fa-address-book-o"></i> Author Name</label>
232
248
  <input type="text" id="node-input-pauthorname" placeholder="Alfred E. Neumann"/>
@@ -256,15 +272,15 @@
256
272
  <input type="checkbox" id="node-input-writetgzfile" style="display:inline-block; width:15px; vertical-align:baseline;">
257
273
  </div>
258
274
 
259
- <hr/>
275
+ <hr />
260
276
 
261
277
  <div class="form-row">
262
- <label for="node-input-noderedinstall" style="min-width: 120px;">
278
+ <label for="node-input-noderedinstall" style="min-width: 180px;">
263
279
  <span>Install locally?</span>
264
280
  </label>
265
- <input type="checkbox" id="node-input-noderedinstall" style="display:inline-block; width:15px; vertical-align:baseline;">
281
+ <input type="checkbox" id="node-input-noderedinstall" style="margin-left: 10px; display:inline-block; width:15px; vertical-align:baseline;">
266
282
  </div>
267
-
283
+
268
284
  <div id="noderedinstall-options">
269
285
  <div class="form-row">
270
286
  <label for="node-input-randompackagename" style="min-width: 180px;">
@@ -275,13 +291,13 @@
275
291
  </div>
276
292
 
277
293
  <div class="form-row">
278
- <label for="node-input-nodered_uninstall" style="min-width: 120px;">
279
- <span>Uninstall package?</span>
294
+ <label for="node-input-nodered_uninstall" style="min-width: 180px;">
295
+ <span>Remove package locally?</span>
280
296
  </label>
281
- <input type="checkbox" id="node-input-nodered_uninstall" style="display:inline-block; width:15px; vertical-align:baseline;">
297
+ <input type="checkbox" id="node-input-nodered_uninstall" style="margin-left: 10px; display:inline-block; width:15px; vertical-align:baseline;">
282
298
  </div>
283
299
 
284
- <hr/>
300
+ <hr />
285
301
  <div class="form-row">
286
302
  <label for="node-input-npmpublish" style="min-width: 120px;">
287
303
  <span>NPMjs: Publish</span>
@@ -294,6 +310,14 @@
294
310
  </div>
295
311
 
296
312
  <div id="npmpublish-options">
313
+ <div class="form-row">
314
+ <label for="node-input-npmtoken" style="min-width: 150px;">
315
+ <i class="fa fa-key"></i>NPM Auth Token
316
+ </label>
317
+ <input type="text" id="node-input-npmtoken">
318
+ <input type="hidden" id="node-input-npmtokenType">
319
+ </div>
320
+
297
321
  <div class="form-row">
298
322
  <label for="node-input-npmotp" style="min-width: 150px;"><i class="fa fa-tag"></i> One Time Password</label>
299
323
  <input type="text" id="node-input-npmotp" placeholder="111999"/>
@@ -302,7 +326,7 @@
302
326
 
303
327
  <hr />
304
328
  <div class="form-row">
305
- <label for="node-input-gitcommit" style="min-width: 120px;">
329
+ <label for="node-input-gitcommit" style="min-width: 120px;">
306
330
  <span>GitHub: Commit?</span>
307
331
  </label>
308
332
  <input type="checkbox" id="node-input-gitcommit" style="display:inline-block; width:15px; vertical-align:baseline;">
@@ -310,26 +334,34 @@
310
334
  <label for="node-input-gitcheckforchange" style="margin-left: 30px; min-width: 100px;">
311
335
  <span>What changed?</span>
312
336
  </label>
313
- <input type="checkbox" id="node-input-gitcheckforchange" style="display:inline-block; width:15px; vertical-align:baseline;">
337
+ <input type="checkbox" id="node-input-gitcheckforchange" style="display:inline-block; width:15px; vertical-align:baseline;">
314
338
 
315
339
  <label for="node-input-githubgettar" style="margin-left: 15px; min-width: 100px;">
316
- <span>Get Repo?</span>
340
+ <span>Retrieve Repo?</span>
317
341
  </label>
318
- <input type="checkbox" id="node-input-githubgettar" style="display:inline-block; width:15px; vertical-align:baseline;">
342
+ <input type="checkbox" id="node-input-githubgettar" style="display:inline-block; width:15px; vertical-align:baseline;">
319
343
  </div>
320
344
 
321
345
  <div id="github-options">
346
+ <div class="form-row">
347
+ <label for="node-input-githubtoken" style="min-width: 150px;">
348
+ <i class="fa fa-key"></i>GitHub Auth Token
349
+ </label>
350
+ <input type="text" id="node-input-githubtoken">
351
+ <input type="hidden" id="node-input-githubtokenType">
352
+ </div>
353
+
322
354
  <div class="form-row">
323
355
  <label for="node-input-githubowner" style="min-width: 150px;"><i class="fa fa-user-o"></i> GitHub Username</label>
324
356
  <input type="text" id="node-input-githubowner" placeholder="username"/>
325
357
  </div>
326
358
  <div class="form-row">
327
- <label for="node-input-githubrepo" style="min-width: 150px;"><i class="fa fa-paw"></i> Repository</label>
328
- <input type="text" id="node-input-githubrepo" placeholder=""/>
359
+ <label for="node-input-githubrepo" style="min-width: 150px;"><i class="fa fa-paw"></i> Repository</label>
360
+ <input type="text" id="node-input-githubrepo" placeholder=""/>
329
361
  </div>
330
362
  <div class="form-row">
331
- <label for="node-input-githubbranch" style="min-width: 150px;"><i class="fa fa-tree"></i> Branch</label>
332
- <input type="text" id="node-input-githubbranch" placeholder="main"/>
363
+ <label for="node-input-githubbranch" style="min-width: 150px;"><i class="fa fa-tree"></i> Branch</label>
364
+ <input type="text" id="node-input-githubbranch" placeholder="main"/>
333
365
  </div>
334
366
  </div>
335
367
 
@@ -346,6 +378,7 @@
346
378
  <label for="node-input-githubauthoremail" style="min-width: 150px;"><i class="fa fa-envelope-o"></i> Author Email</label>
347
379
  <input type="text" id="node-input-githubauthoremail" placeholder="joe@spreads-the.love"/>
348
380
  </div>
381
+
349
382
  </div>
350
383
  </script>
351
384
 
@@ -11,21 +11,40 @@ module.exports = function (RED) {
11
11
 
12
12
  node.on("input", function (msg, send, done) {
13
13
  msg.commit_message = msg.githubmessage;
14
-
14
+
15
15
  if (msg.randompackagename) {
16
- msg.pversion = (
17
- Math.random().toString().substring(2).substring(2, 3) + "." +
18
- Math.random().toString().substring(2).substring(2, 3) + "." +
16
+ msg.pversion = (
17
+ Math.random().toString().substring(2).substring(2, 3) + "." +
18
+ Math.random().toString().substring(2).substring(2, 3) + "." +
19
19
  Math.random().toString().substring(2).substring(2, 5).replace(/^0/, '1')
20
20
  )
21
21
  }
22
22
 
23
- if (msg.randompackagename && (msg.gitcommit || msg.npmpublish || msg.npmunpublish) ) {
23
+ if (msg.randompackagename && (msg.gitcommit || msg.npmpublish || msg.npmunpublish)) {
24
24
  done("Cannot randomise package and perform GitHub or NPM operation", msg)
25
25
  return
26
26
  }
27
- send(msg);
28
- done();
27
+
28
+ RED.util.evaluateNodeProperty(cfg.npmtoken, cfg.npmtokenType, node, msg, (errNpm, resultNpm) => {
29
+ RED.util.evaluateNodeProperty(cfg.githubtoken, cfg.githubtokenType, node, msg, (errGitHub, resultGitHub) => {
30
+ if (errNpm || !resultNpm) {
31
+ if (msg.npmpublish || msg.npmunpublish) {
32
+ done("Cannot perform NPM operation without NPM auth token", msg)
33
+ return
34
+ }
35
+ } else { msg.npmauthtokenvalue = resultNpm }
36
+
37
+ if (errGitHub || !resultGitHub) {
38
+ if (msg.gitcommit) {
39
+ done("Cannot perform GitHub commit without GitHub auth token", msg)
40
+ return
41
+ }
42
+ } else { msg.githubauthtokenvalue = resultGitHub }
43
+
44
+ send(msg);
45
+ done();
46
+ })
47
+ })
29
48
  });
30
49
  }
31
50
 
@@ -37,7 +56,7 @@ module.exports = function (RED) {
37
56
  var node = RED.nodes.getNode(req.params.id);
38
57
  if (node != null) {
39
58
  try {
40
- if (req.body && node.type == "NodeDevOps") {
59
+ if (req.body && node.type == "NodeDevOps") {
41
60
  node.receive(req.body);
42
61
  res.status(200).send({ status: "ok" })
43
62
  } else {
@@ -3,19 +3,19 @@
3
3
  category: 'nodedev',
4
4
  color: '#e5e4ef',
5
5
  defaults: {
6
- name: {value:""},
7
-
8
- otptype: {value:"totp"},
9
- secret: { value: "OTP_SECRET"},
10
- secretType: { value: "env"},
11
- issuer: { value: "" },
12
- label: { value: "" },
13
- digits: { value: 6 },
14
- period: { value: 30 },
15
- algorithm: { value: "SHA1" },
16
- counter: { value: 0 },
17
-
18
- property: { value:"payload" },
6
+ name: { value:"" },
7
+
8
+ otptype: { value:"totp" },
9
+ secret: { value: "OTP_SECRET" },
10
+ secretType: { value: "env" },
11
+ issuer: { value: "" },
12
+ label: { value: "" },
13
+ digits: { value: 6 },
14
+ period: { value: 30 },
15
+ algorithm: { value: "SHA1" },
16
+ counter: { value: 0 },
17
+
18
+ property: { value:"payload" },
19
19
  propertyType: { value:"msg" }
20
20
  },
21
21
  inputs:1,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name" : "@gregoriusrippenstein/node-red-contrib-nodedev",
3
- "version": "0.4.6",
3
+ "version": "0.4.8",
4
4
  "dependencies": {
5
5
  "pako": "^2.1.0",
6
6
  "tar-stream": "^3.1.6",