@gregoriusrippenstein/node-red-contrib-nodedev 0.4.5 → 0.4.7

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.
@@ -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 {
@@ -29,6 +29,98 @@
29
29
  <option value="base64">Base64</option>
30
30
  <option value="text">Text</option>
31
31
  <option value="typescript">TypeScript</option>
32
+ <option value="python">Python</option>
33
+ <option value="go">Go</option>
34
+ <option value="postiats">ATS</option>
35
+ <option value="apex">Apex</option>
36
+ <option value="azcli">Azure CLI</option>
37
+ <option value="bat">Batch</option>
38
+ <option value="bicep">Bicep</option>
39
+ <option value="c">C</option>
40
+ <option value="csharp">C#</option>
41
+ <option value="cpp">C++</option>
42
+ <option value="csp">CSP</option>
43
+ <option value="css">CSS</option>
44
+ <option value="cameligo">Cameligo</option>
45
+ <option value="coffeescript">CoffeeScript</option>
46
+ <option value="cypher">Cypher</option>
47
+ <option value="msdax">DAX</option>
48
+ <option value="dart">Dart</option>
49
+ <option value="dockerfile">Dockerfile</option>
50
+ <option value="ecl">ECL</option>
51
+ <option value="elixir">Elixir</option>
52
+ <option value="fsharp">F#</option>
53
+ <option value="flow9">Flow9</option>
54
+ <option value="freemarker2">FreeMarker2</option>
55
+ <option value="freemarker2.tag-angle.interpolation-bracket">FreeMarker2 (Angle&#x2F;Bracket)</option>
56
+ <option value="freemarker2.tag-angle.interpolation-dollar">FreeMarker2 (Angle&#x2F;Dollar)</option>
57
+ <option value="freemarker2.tag-auto.interpolation-bracket">FreeMarker2 (Auto&#x2F;Bracket)</option>
58
+ <option value="freemarker2.tag-auto.interpolation-dollar">FreeMarker2 (Auto&#x2F;Dollar)</option>
59
+ <option value="freemarker2.tag-bracket.interpolation-bracket">FreeMarker2 (Bracket&#x2F;Bracket)</option>
60
+ <option value="freemarker2.tag-bracket.interpolation-dollar">FreeMarker2 (Bracket&#x2F;Dollar)</option>
61
+ <option value="go">Go</option>
62
+ <option value="graphql">GraphQL</option>
63
+ <option value="html">HTML</option>
64
+ <option value="handlebars">Handlebars</option>
65
+ <option value="ini">Ini</option>
66
+ <option value="json">JSON</option>
67
+ <option value="java">Java</option>
68
+ <option value="javascript">JavaScript</option>
69
+ <option value="kotlin">Kotlin</option>
70
+ <option value="less">Less</option>
71
+ <option value="lexon">Lexon</option>
72
+ <option value="liquid">Liquid</option>
73
+ <option value="lua">Lua</option>
74
+ <option value="mips">MIPS</option>
75
+ <option value="markdown">Markdown</option>
76
+ <option value="m3">Modula-3</option>
77
+ <option value="mysql">MySQL</option>
78
+ <option value="objective-c">Objective-C</option>
79
+ <option value="php">PHP</option>
80
+ <option value="powerquery">PQ</option>
81
+ <option value="pascal">Pascal</option>
82
+ <option value="pascaligo">Pascaligo</option>
83
+ <option value="perl">Perl</option>
84
+ <option value="plaintext">Plain Text</option>
85
+ <option value="pgsql">PostgreSQL</option>
86
+ <option value="powershell">PowerShell</option>
87
+ <option value="pug">Pug</option>
88
+ <option value="python">Python</option>
89
+ <option value="qsharp">Q#</option>
90
+ <option value="r">R</option>
91
+ <option value="razor">Razor</option>
92
+ <option value="redshift">Redshift</option>
93
+ <option value="ruby">Ruby</option>
94
+ <option value="rust">Rust</option>
95
+ <option value="sql">SQL</option>
96
+ <option value="systemverilog">SV</option>
97
+ <option value="scss">Sass</option>
98
+ <option value="scala">Scala</option>
99
+ <option value="shell">Shell</option>
100
+ <option value="sb">Small Basic</option>
101
+ <option value="st">StructuredText</option>
102
+ <option value="swift">Swift</option>
103
+ <option value="hcl">Terraform</option>
104
+ <option value="twig">Twig</option>
105
+ <option value="typescript">TypeScript</option>
106
+ <option value="verilog">V</option>
107
+ <option value="vb">Visual Basic</option>
108
+ <option value="wgsl">WebGPU Shading Language</option>
109
+ <option value="xml">XML</option>
110
+ <option value="yaml">YAML</option>
111
+ <option value="abap">abap</option>
112
+ <option value="aes">aes</option>
113
+ <option value="clojure">clojure</option>
114
+ <option value="jsonata">jsonata</option>
115
+ <option value="julia">julia</option>
116
+ <option value="pla">pla</option>
117
+ <option value="proto">protobuf</option>
118
+ <option value="restructuredtext">reStructuredText</option>
119
+ <option value="redis">redis</option>
120
+ <option value="scheme">scheme</option>
121
+ <option value="sol">sol</option>
122
+ <option value="sparql">sparql</option>
123
+ <option value="tcl">tcl</option>
32
124
  </select>
33
125
  <button type="button" id="node-pkgfile-expand-editor" class="red-ui-button red-ui-button-small"><i class="fa fa-expand"></i></button>
34
126
  </div>
@@ -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,
@@ -6,6 +6,238 @@ module.exports = (function () {
6
6
  let pathUtil = require('path')
7
7
  const buffer = require('buffer')
8
8
 
9
+ const monacoExtMap = {
10
+ "dats": "postiats",
11
+ "sats": "postiats",
12
+ "hats": "postiats",
13
+ "cls": "apex",
14
+ "azcli": "azcli",
15
+ "bat": "bat",
16
+ "cmd": "bat",
17
+ "bicep": "bicep",
18
+ "c": "c",
19
+ "h": "c",
20
+ "cs": "csharp",
21
+ "csx": "csharp",
22
+ "cake": "csharp",
23
+ "cpp": "cpp",
24
+ "cc": "cpp",
25
+ "cxx": "cpp",
26
+ "hpp": "cpp",
27
+ "hh": "cpp",
28
+ "hxx": "cpp",
29
+ "css": "css",
30
+ "mligo": "cameligo",
31
+ "coffee": "coffeescript",
32
+ "cypher": "cypher",
33
+ "cyp": "cypher",
34
+ "dax": "msdax",
35
+ "msdax": "msdax",
36
+ "dart": "dart",
37
+ "dockerfile": "dockerfile",
38
+ "ecl": "ecl",
39
+ "ex": "elixir",
40
+ "exs": "elixir",
41
+ "fs": "fsharp",
42
+ "fsi": "fsharp",
43
+ "ml": "fsharp",
44
+ "mli": "fsharp",
45
+ "fsx": "fsharp",
46
+ "fsscript": "fsharp",
47
+ "flow": "flow9",
48
+ "ftl": "freemarker2",
49
+ "ftlh": "freemarker2",
50
+ "ftlx": "freemarker2",
51
+ "go": "go",
52
+ "graphql": "graphql",
53
+ "gql": "graphql",
54
+ "html": "html",
55
+ "htm": "html",
56
+ "shtml": "html",
57
+ "xhtml": "html",
58
+ "mdoc": "html",
59
+ "jsp": "html",
60
+ "asp": "html",
61
+ "aspx": "html",
62
+ "jshtm": "html",
63
+ "handlebars": "handlebars",
64
+ "hbs": "handlebars",
65
+ "ini": "ini",
66
+ "properties": "ini",
67
+ "gitconfig": "ini",
68
+ "json": "json",
69
+ "bowerrc": "json",
70
+ "jshintrc": "json",
71
+ "jscsrc": "json",
72
+ "eslintrc": "json",
73
+ "babelrc": "json",
74
+ "har": "json",
75
+ "java": "java",
76
+ "jav": "java",
77
+ "js": "javascript",
78
+ "es6": "javascript",
79
+ "jsx": "javascript",
80
+ "mjs": "javascript",
81
+ "cjs": "javascript",
82
+ "kt": "kotlin",
83
+ "kts": "kotlin",
84
+ "less": "less",
85
+ "lex": "lexon",
86
+ "liquid": "liquid",
87
+ "html.liquid": "liquid",
88
+ "lua": "lua",
89
+ "s": "mips",
90
+ "md": "markdown",
91
+ "markdown": "markdown",
92
+ "mdown": "markdown",
93
+ "mkdn": "markdown",
94
+ "mkd": "markdown",
95
+ "mdwn": "markdown",
96
+ "mdtxt": "markdown",
97
+ "mdtext": "markdown",
98
+ "m3": "m3",
99
+ "i3": "m3",
100
+ "mg": "m3",
101
+ "ig": "m3",
102
+ "m": "objective-c",
103
+ "php": "php",
104
+ "php4": "php",
105
+ "php5": "php",
106
+ "phtml": "php",
107
+ "ctp": "php",
108
+ "pq": "powerquery",
109
+ "pqm": "powerquery",
110
+ "pas": "pascal",
111
+ "p": "pascal",
112
+ "pp": "pascal",
113
+ "ligo": "pascaligo",
114
+ "pl": "perl",
115
+ "pm": "perl",
116
+ "txt": "plaintext",
117
+ "ps1": "powershell",
118
+ "psm1": "powershell",
119
+ "psd1": "powershell",
120
+ "jade": "pug",
121
+ "pug": "pug",
122
+ "py": "python",
123
+ "rpy": "python",
124
+ "pyw": "python",
125
+ "cpy": "python",
126
+ "gyp": "python",
127
+ "gypi": "python",
128
+ "qs": "qsharp",
129
+ "r": "r",
130
+ "rhistory": "r",
131
+ "rmd": "r",
132
+ "rprofile": "r",
133
+ "rt": "r",
134
+ "cshtml": "razor",
135
+ "rb": "ruby",
136
+ "rbx": "ruby",
137
+ "rjs": "ruby",
138
+ "gemspec": "ruby",
139
+ "pp": "ruby",
140
+ "rs": "rust",
141
+ "rlib": "rust",
142
+ "sql": "sql",
143
+ "sv": "systemverilog",
144
+ "svh": "systemverilog",
145
+ "scss": "scss",
146
+ "scala": "scala",
147
+ "sc": "scala",
148
+ "sbt": "scala",
149
+ "sh": "shell",
150
+ "bash": "shell",
151
+ "sb": "sb",
152
+ "st": "st",
153
+ "iecst": "st",
154
+ "iecplc": "st",
155
+ "lc3lib": "st",
156
+ "swift": "swift",
157
+ "tf": "hcl",
158
+ "tfvars": "hcl",
159
+ "hcl": "hcl",
160
+ "twig": "twig",
161
+ "ts": "typescript",
162
+ "tsx": "typescript",
163
+ "cts": "typescript",
164
+ "mts": "typescript",
165
+ "v": "verilog",
166
+ "vh": "verilog",
167
+ "vb": "vb",
168
+ "wgsl": "wgsl",
169
+ "xml": "xml",
170
+ "xsd": "xml",
171
+ "dtd": "xml",
172
+ "ascx": "xml",
173
+ "csproj": "xml",
174
+ "config": "xml",
175
+ "props": "xml",
176
+ "targets": "xml",
177
+ "wxi": "xml",
178
+ "wxl": "xml",
179
+ "wxs": "xml",
180
+ "xaml": "xml",
181
+ "svg": "xml",
182
+ "svgz": "xml",
183
+ "opf": "xml",
184
+ "xslt": "xml",
185
+ "xsl": "xml",
186
+ "yaml": "yaml",
187
+ "yml": "yaml",
188
+ "abap": "abap",
189
+ "aes": "aes",
190
+ "clj": "clojure",
191
+ "cljs": "clojure",
192
+ "cljc": "clojure",
193
+ "edn": "clojure",
194
+ "jl": "julia",
195
+ "pla": "pla",
196
+ "proto": "proto",
197
+ "rst": "restructuredtext",
198
+ "redis": "redis",
199
+ "scm": "scheme",
200
+ "ss": "scheme",
201
+ "sch": "scheme",
202
+ "rkt": "scheme",
203
+ "sol": "sol",
204
+ "rq": "sparql",
205
+ "tcl": "tcl",
206
+
207
+ /* handmade software is the best */
208
+ "html": "html",
209
+ "js": "javascript",
210
+ "cjs": "javascript",
211
+ "mjs": "javascript",
212
+ "md": "markdown",
213
+ "json": "json",
214
+ "txt": "text",
215
+ "css": "css",
216
+ "yaml": "yaml",
217
+ "yml": "yaml",
218
+ "svg": "xml",
219
+ "xml": "xml",
220
+ "ts": "typescript",
221
+ "sql": "sql",
222
+
223
+
224
+ /* binary formats are encoded in base64 */
225
+ "png": "base64",
226
+ "tiff": "base64",
227
+ "tif": "base64",
228
+ "jpg": "base64",
229
+ "jpeg": "base64",
230
+ "bin": "base64",
231
+ "bmp": "base64",
232
+ "gif": "base64",
233
+ "woff2": "base64",
234
+ "woff": "base64",
235
+ "ttf": "base64",
236
+ "mov": "base64",
237
+ "ico": "base64",
238
+ "eot": "base64",
239
+ }
240
+
9
241
  /*
10
242
  * there is no indication in a tar file of whether a file is binary or textual.
11
243
  * we can only make a guess by the extension of the filename.
@@ -13,35 +245,7 @@ module.exports = (function () {
13
245
  var computeFormat = (filename) => {
14
246
  let ext = pathUtil.extname(filename).substr(1).toLowerCase()
15
247
 
16
- return {
17
- "html": "html",
18
- "js": "javascript",
19
- "md": "markdown",
20
- "json": "json",
21
- "txt": "text",
22
- "css": "css",
23
- "yaml": "yaml",
24
- "yml": "yaml",
25
- "svg": "xml",
26
- "xml": "xml",
27
- "ts": "typescript",
28
-
29
- /* binary formats are encoded in base64 */
30
- "png": "base64",
31
- "tiff": "base64",
32
- "tif": "base64",
33
- "jpg": "base64",
34
- "jpeg": "base64",
35
- "bin": "base64",
36
- "bmp": "base64",
37
- "gif": "base64",
38
- "woff2": "base64",
39
- "woff": "base64",
40
- "ttf": "base64",
41
- "mov": "base64",
42
- "ico": "base64",
43
- "eot": "base64",
44
- }[ext] || "text";
248
+ return monacoExtMap[ext] || "text";
45
249
  }
46
250
 
47
251
  var convertTarFile = (RED, tgzData, onFinish, onError) => {
@@ -104,24 +308,36 @@ module.exports = (function () {
104
308
  if (buffer.Buffer.isBuffer(tgzData)) {
105
309
  import('file-type').then(module => {
106
310
  module.fileTypeFromBuffer(tgzData).then(filetype => {
107
- if ( filetype && filetype.ext == "tar") {
108
- var stream = streamx.Readable.from(tgzData)
109
- stream.pipe(extract);
110
- } else {
111
- var stream = streamx.Readable.from(Buffer.from(pakoGzip.inflate(new Uint8Array(tgzData))))
112
- stream.pipe(extract);
311
+
312
+ try {
313
+ if (filetype && filetype.ext == "tar") {
314
+ var stream = streamx.Readable.from(tgzData)
315
+ stream.pipe(extract)
316
+ } else {
317
+ var stream = streamx.Readable.from(Buffer.from(pakoGzip.inflate(new Uint8Array(tgzData))))
318
+ stream.pipe(extract)
319
+ }
320
+ } catch (ex) {
321
+ onError(ex)
113
322
  }
323
+
114
324
  }).catch(err => {
115
- var stream = streamx.Readable.from(Buffer.from(pakoGzip.inflate(new Uint8Array(tgzData))))
116
- stream.pipe(extract);
325
+ try {
326
+ var stream = streamx.Readable.from(Buffer.from(pakoGzip.inflate(new Uint8Array(tgzData))))
327
+ stream.pipe(extract).catch(onError);
328
+ } catch (ex) { onError(ex) }
117
329
  })
118
- }).catch( e => {
119
- var stream = streamx.Readable.from(Buffer.from(pakoGzip.inflate(new Uint8Array(tgzData))))
120
- stream.pipe(extract);
330
+ }).catch(e => {
331
+ try {
332
+ var stream = streamx.Readable.from(Buffer.from(pakoGzip.inflate(new Uint8Array(tgzData))))
333
+ stream.pipe(extract).catch(onError);
334
+ } catch (ex) { onError(ex) }
121
335
  })
122
336
  } else {
123
- var stream = streamx.Readable.from(Buffer.from(pakoGzip.inflate(new Uint8Array(tgzData))))
124
- stream.pipe(extract);
337
+ try {
338
+ var stream = streamx.Readable.from(Buffer.from(pakoGzip.inflate(new Uint8Array(tgzData))))
339
+ stream.pipe(extract).catch(onError);
340
+ } catch (ex) { onError(ex) }
125
341
  }
126
342
  } catch (ex) {
127
343
  onError(ex)
@@ -271,22 +271,23 @@ module.exports = function (RED) {
271
271
  })
272
272
  );
273
273
  }
274
-
275
- pacote.manifest(
276
- msg.pkgname + "@" + msg.pkgversion,
277
- { registry: msg.pkgregistry || 'https://registry.npmjs.org' }
278
- ).then(manifest => {
274
+
275
+ if (msg.pkgname.match(/^git@github.com:.+[.]git/i) || msg.pkgname.match(/https?:\/\/github.com\//i) ) {
276
+ let mth = msg.pkgname.match(/^git@github.com:(.+)\/(.+)[.]git/i) || msg.pkgname.match(/https?:\/\/github.com\/([^\/]+)\/([^\/]+)\/?/i)
277
+
278
+ let tarballUrl = "https://github.com/" + mth[1] + "/" + mth[2] + "/tarball/" + msg.pkgversion
279
+
279
280
  RED.comms.publish(
280
281
  "nodedev:perform-autoimport-nodes",
281
282
  RED.util.encodeObject({
282
283
  msg: "notify",
283
- text: "Found url for " + msg.pkgname + "@" + msg.pkgversion,
284
+ text: "Importing GitHub repo: <b>" + msg.pkgname + "</b> @ <b>" + msg.pkgversion + "</b>",
284
285
  type: "warning",
285
286
  })
286
287
  );
287
288
 
288
289
  import('got').then((module) => {
289
- module.got.get(manifest._resolved,
290
+ module.got.get(tarballUrl,
290
291
  {
291
292
  timeout: {
292
293
  request: 25000,
@@ -305,18 +306,53 @@ module.exports = function (RED) {
305
306
  }).catch(err => {
306
307
  onError(err)
307
308
  });
309
+ } else {
310
+ pacote.manifest(
311
+ msg.pkgname + "@" + msg.pkgversion,
312
+ { registry: msg.pkgregistry || 'https://registry.npmjs.org' }
313
+ ).then(manifest => {
314
+ RED.comms.publish(
315
+ "nodedev:perform-autoimport-nodes",
316
+ RED.util.encodeObject({
317
+ msg: "notify",
318
+ text: "Found url for <b>" + msg.pkgname + "</b> @ <b>" + msg.pkgversion + "</b>",
319
+ type: "warning",
320
+ })
321
+ );
308
322
 
309
- }).catch(err => {
310
- RED.comms.publish(
311
- "nodedev:perform-autoimport-nodes",
312
- RED.util.encodeObject({
313
- msg: "notify",
314
- text: "Failed to retrieve tgz file for " + msg.pkgname + "@" + msg.pkgversion + ": " + err,
315
- type: "error",
316
- })
317
- );
318
- })
323
+ import('got').then((module) => {
324
+ module.got.get(manifest._resolved,
325
+ {
326
+ timeout: {
327
+ request: 25000,
328
+ response: 25000
329
+ },
330
+ responseType: 'buffer'
331
+ }).then(resp => {
332
+ try {
333
+ tarHelpers.convertTarFile(RED, resp.body, onFinish, onError);
334
+ } catch (err) {
335
+ onError(err)
336
+ }
337
+ }).catch(err => {
338
+ onError(err)
339
+ });
340
+ }).catch(err => {
341
+ onError(err)
342
+ });
319
343
 
344
+ }).catch(err => {
345
+ RED.comms.publish(
346
+ "nodedev:perform-autoimport-nodes",
347
+ RED.util.encodeObject({
348
+ msg: "notify",
349
+ text: "Failed to retrieve tgz file for " + msg.pkgname + "@" + msg.pkgversion + ": " + err,
350
+ type: "error",
351
+ })
352
+ );
353
+ })
354
+ }
355
+
320
356
  res.sendStatus(200);
321
357
 
322
358
  RED.comms.publish(
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name" : "@gregoriusrippenstein/node-red-contrib-nodedev",
3
- "version": "0.4.5",
3
+ "version": "0.4.7",
4
4
  "dependencies": {
5
5
  "pako": "^2.1.0",
6
6
  "tar-stream": "^3.1.6",
@@ -362,6 +362,10 @@
362
362
  </div>
363
363
 
364
364
  <div class="form-row" style="margin-left: 10px;">
365
+ Importing GitHub repos is also supported. For this, the package name should be either <code>https://github.com/&lt;user&gt;/&lt;repo&gt;</code> or <code>git@github.com:&lt;user&gt;/&lt;repo&gt;</code>, the version is assumed to be branch or tag name and the Registry option is ignored.
366
+ </div>
367
+
368
+ <div class="form-row" style="margin-left: 10px; margin-top: 30px;">
365
369
  Enter package details here:
366
370
  </div>
367
371
 
@@ -385,9 +389,9 @@
385
389
 
386
390
  <div class="form-row" style="margin-left: 10px;">
387
391
  <label for="node-input-nodefactorysidebar-package-registry">
388
- <i class="fa fa-tag"></i>
389
- Registry
390
- </label>
392
+ <i class="fa fa-tag"></i>
393
+ Registry
394
+ </label>
391
395
  <input type="text" id="node-input-nodefactorysidebar-package-registry"
392
396
  placeholder="https://registry.npmjs.org">
393
397
  </div>