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

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.
@@ -56,6 +56,8 @@
56
56
  noderedinstall: { value: false },
57
57
  randompackagename: { value: false },
58
58
 
59
+ nodered_uninstall: { value: false },
60
+
59
61
  ignore_package_check: { value: false },
60
62
 
61
63
  gitcommit: { value: false },
@@ -90,9 +92,15 @@
90
92
  },
91
93
 
92
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
+ })
93
100
 
94
101
  $('#node-input-noderedinstall').on('change', () => {
95
102
  if ( $('#node-input-noderedinstall').is(":checked") ) {
103
+ $('#node-input-nodered_uninstall').prop('checked',false).trigger('change')
96
104
  $("#noderedinstall-options").animate({opacity: 'show', height: 'show'}, 450);
97
105
  } else {
98
106
  $("#noderedinstall-options").animate({opacity: 'hide', height: 'hide'}, 450);
@@ -266,6 +274,13 @@
266
274
  </div>
267
275
  </div>
268
276
 
277
+ <div class="form-row">
278
+ <label for="node-input-nodered_uninstall" style="min-width: 120px;">
279
+ <span>Uninstall package?</span>
280
+ </label>
281
+ <input type="checkbox" id="node-input-nodered_uninstall" style="display:inline-block; width:15px; vertical-align:baseline;">
282
+ </div>
283
+
269
284
  <hr/>
270
285
  <div class="form-row">
271
286
  <label for="node-input-npmpublish" style="min-width: 120px;">
@@ -67,17 +67,24 @@
67
67
  </div>
68
68
  </div>
69
69
 
70
+ <div class="form-row">
71
+ <label for="node-input-isrealplugin" style="min-width: 250px;">
72
+ <span>Plugin?</span>
73
+ </label>
74
+ <input type="checkbox" id="node-input-isrealplugin" style="display:inline-block; width:15px; vertical-align:baseline;">
75
+ </div>
76
+
70
77
  <div class="form-row">
71
78
  <label for="node-input-isplugin" style="min-width: 250px;">
72
- <span>Plugin: Sidebar + Config?</span>
73
- </label>
79
+ <span>Sidebar + Config?</span>
80
+ </label>
74
81
  <input type="checkbox" id="node-input-isplugin" style="display:inline-block; width:15px; vertical-align:baseline;">
75
82
  </div>
76
83
 
77
84
  <div class="form-row">
78
85
  <label for="node-input-frt2bakcomm" style="min-width: 250px;">
79
- <span>Frontend to Backend communication?</span>
80
- </label>
86
+ <span>Frontend to Backend communication?</span>
87
+ </label>
81
88
  <input type="checkbox" id="node-input-frt2bakcomm" style="display:inline-block; width:15px; vertical-align:baseline;">
82
89
  </div>
83
90
 
@@ -198,7 +205,15 @@
198
205
  data["bak2frtcomm"] = $('#node-input-bak2frtcomm').is(":checked");
199
206
  data["frt2bakcomm"] = $('#node-input-frt2bakcomm').is(":checked");
200
207
  data["createmanifest"] = $('#node-input-createmanifest').is(":checked");
208
+
209
+ /*
210
+ Argh! This is a mess but I can't change it because isplugin is used
211
+ in the wild. isplugin is actually a sidebar + config node, while
212
+ isrealplugin is a plugin in the true sense of Node-RED. This was
213
+ done due to lack-of-knowledge on the part of the author.
214
+ */
201
215
  data["isplugin"] = $('#node-input-isplugin').is(":checked");
216
+ data["isrealplugin"] = $('#node-input-isrealplugin').is(":checked");
202
217
 
203
218
  data["__task"] = "generate_from_templates";
204
219
 
@@ -239,6 +254,7 @@
239
254
  bak2frtcomm: { value: false },
240
255
  createmanifest: { value: false },
241
256
  isplugin: { value: false },
257
+ isrealplugin: { value: false },
242
258
  },
243
259
  inputs: 1,
244
260
  outputs: 1,
@@ -292,6 +308,20 @@
292
308
  sortPalette: function (a, b) { return a.l - b.l; }
293
309
  }).appendTo("#node-input-row-style-colour");
294
310
 
311
+ $("#node-input-isrealplugin").on('change', function(ev) {
312
+ if ( $('#node-input-isrealplugin').is(":checked") ) {
313
+ $('#node-input-isplugin').prop('checked',false).trigger('change')
314
+ $('#node-input-frt2bakcomm').prop('checked',false).trigger('change')
315
+ $('#node-input-bak2frtcomm').prop('checked',false).trigger('change')
316
+ }
317
+ })
318
+
319
+ $("#node-input-isplugin").on('change', function(ev) {
320
+ if ( $('#node-input-isplugin').is(":checked") ) {
321
+ $('#node-input-isrealplugin').prop('checked',false).trigger('change')
322
+ }
323
+ })
324
+
295
325
  $("#node-input-colour").on('change', function(ev) {
296
326
  var colour = $(this).val();
297
327
  var nodeDiv = $('.red-ui-search-result-node')
@@ -223,6 +223,31 @@ module.exports = function (RED) {
223
223
  })
224
224
  }
225
225
 
226
+ function createRealPluginNodeDefintions(msg,node) {
227
+ var pluginJsPath = path.join(__dirname, 'templates', 'tmplplugin.js');
228
+ var content = {};
229
+
230
+ var promises = [
231
+ handleTemplate(msg, node, fs.readFileSync(pluginJsPath, 'utf8')).then((c) => { content["jsac"] = c }),
232
+ ];
233
+
234
+ return Promise.all(promises).then(() => {
235
+ return [{
236
+ id: RED.util.generateId(),
237
+ type: "PkgFile",
238
+ name: msg.node.name + "Plugin.js",
239
+ filename: "plugins/" + msg.node.namelwr + ".js",
240
+ template: content["jsac"],
241
+ syntax: "mustache",
242
+ format: "javascript",
243
+ output: "str",
244
+ x: 100,
245
+ y: 50,
246
+ wires: [[]]
247
+ }]
248
+ })
249
+ }
250
+
226
251
  function createSimpleNodeDefintions(msg,node) {
227
252
  var htmlPath = path.join(__dirname, 'templates', 'tmpl.html');
228
253
  var htmlJsPath = path.join(__dirname, 'templates', 'tmpl.html.js');
@@ -322,6 +347,8 @@ module.exports = function (RED) {
322
347
  function createNodeDefintions(msg, node) {
323
348
  if ( msg.node.isplugin ) {
324
349
  return createPluginNodeDefintions(msg, node)
350
+ } else if (msg.node.isrealplugin ) {
351
+ return createRealPluginNodeDefintions(msg, node)
325
352
  } else {
326
353
  return createSimpleNodeDefintions(msg, node)
327
354
  }
@@ -339,6 +366,9 @@ module.exports = function (RED) {
339
366
  if ( msg.node.isplugin ) {
340
367
  spcRepDict["pluginstanza"] = " \"sidebar-plugin\": \"" + nodeDefinitions[1].filename + "\""
341
368
  }
369
+ if (msg.node.isrealplugin) {
370
+ spcRepDict["pluginstanza"] = " \"" + msg.node.namelwr + "\": \"" + nodeDefinitions[0].filename + "\""
371
+ }
342
372
 
343
373
  var content = {};
344
374
 
@@ -1,4 +1,17 @@
1
- # LICENSE
1
+ ## LICENSE - DON'T DO EVIL
2
2
 
3
- License texts comes here.
3
+ **The do not do evil license**
4
4
 
5
+ Adapted from JSON.org, http://www.json.org/license.html
6
+
7
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
8
+
9
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
10
+
11
+ The Software shall be used for Good, not Evil.
12
+
13
+ Remember the curse of the evil-doer upon whose blood the devil does drink and upon whose flesh the devil does feast. For eternity will the evil-doer bear this Sisyphean burden, only to be relieved of their suffering upon the apocalyptic end of it all including the foundations of the internet, computers, technology and mice. Only after the last AI enters the blue-screen-of-death modus, only then will the evil-doer be freed of their rightful and justified punishment for doing evil.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
16
+
17
+ THE CURSE IS PROVIDED "AS IS" OR "WORSE", NO SOFTENING OF ANY KIND IS HEREBY EXPRESSED, IMPLIED OR OFFERED. MAY ALL EVIL-DOERS SUFFER IN ETERNITY.
@@ -21,11 +21,25 @@
21
21
  {{#node.isplugin}}
22
22
  "plugins": {
23
23
  {{{__.pluginstanza}}}
24
- },
24
+ },
25
+ "nodes": {
26
+ {{{__.nodestanza}}}
27
+ }
25
28
  {{/node.isplugin}}
29
+
30
+ {{#node.isrealplugin}}
31
+ "plugins": {
32
+ {{{__.pluginstanza}}}
33
+ }
34
+ {{/node.isrealplugin}}
35
+
36
+ {{^node.isplugin}}
37
+ {{^node.isrealplugin}}
26
38
  "nodes": {
27
39
  {{{__.nodestanza}}}
28
40
  }
41
+ {{/node.isrealplugin}}
42
+ {{/node.isplugin}}
29
43
  },
30
44
 
31
45
  "repository": {
@@ -0,0 +1,29 @@
1
+ module.exports = function (RED) {
2
+ const OnReceiveHookName = "onReceive.{{ node.name }}"
3
+ const OnPreuninstallHookName = "preUninstall.{{ node.name }}"
4
+
5
+ function {{ node.name }}OnReceiveHook(evnt) {
6
+ try {
7
+ let nde = RED.nodes.getNode(evnt.destination.id)
8
+ nde.status({ fill: "green", shape: "ring", text: "msg received" })
9
+ setTimeout(() => { nde.status({}) }, 1000)
10
+ } catch (ex) {
11
+ console.error(ex)
12
+ }
13
+ }
14
+
15
+ RED.plugins.registerPlugin("msg-tracer-plugin", {
16
+ onadd: () => {
17
+ RED.hooks.add(OnReceiveHookName, {{ node.name }}OnReceiveHook)
18
+
19
+ // add hook to uninstall package so that the hook for this
20
+ // plugin are removed.
21
+ RED.hooks.add(OnPreuninstallHookName, (evnt) => {
22
+ if (evnt.module == "{{__.ocb3}} pname {{__.ccb3}}") {
23
+ RED.hooks.remove(OnReceiveHookName)
24
+ RED.hooks.remove(OnPreuninstallHookName)
25
+ }
26
+ })
27
+ }
28
+ })
29
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name" : "@gregoriusrippenstein/node-red-contrib-nodedev",
3
- "version": "0.4.4",
3
+ "version": "0.4.5",
4
4
  "dependencies": {
5
5
  "pako": "^2.1.0",
6
6
  "tar-stream": "^3.1.6",