@gregoriusrippenstein/node-red-contrib-nodedev 0.2.1 → 0.2.2

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
@@ -42,6 +42,23 @@ This [animation](https://cdn.openmindmap.org/content/1697013164685_out-fps15.gif
42
42
  ![img](https://cdn.openmindmap.org/content/1697013164685_out-fps15.gif)
43
43
 
44
44
 
45
+ ### Importing existing packages
46
+
47
+ Using the `Package Import` sidebar, it is also possible to install existing packages to find out how others have built their nodes.
48
+
49
+ The gif shows some of the features:
50
+
51
+ - import existing package,
52
+ - view the source files in Node-RED,
53
+ - preview of file content is shown in the info box,
54
+ - installing package locally is possible using the NodeDevOps node.
55
+
56
+ This [animation](https://cdn.openmindmap.org/content/1701013172299_nodedevinstall.gif) shows those features:
57
+
58
+ ![img](https://cdn.openmindmap.org/content/1701013172299_nodedevinstall.gif)
59
+
60
+ Of course making changes to the PkgFile nodes and then reinstalling the package will reflect those changes. This makes it simple to take an existing package, make modifications to suit oneself and then push those changes upstream to the original developer(s).
61
+
45
62
  ### Tips
46
63
 
47
64
  *How to avoid restarting Node-RED?*
@@ -25,6 +25,7 @@
25
25
  <option value="python">Python</option>
26
26
  <option value="sql">SQL</option>
27
27
  <option value="yaml">YAML</option>
28
+ <option value="xml">XML</option>
28
29
  <option value="base64">Base64</option>
29
30
  <option value="text">Text</option>
30
31
  </select>
@@ -63,6 +64,8 @@
63
64
  }[tag] || tag)
64
65
  );
65
66
 
67
+ let mth;
68
+
66
69
  switch(that.format) {
67
70
  case 'markdown':
68
71
  case 'text':
@@ -80,11 +83,19 @@
80
83
  case "html":
81
84
  return ["```" + that.format, escapeHTML(that.template), "```"].join("\n")
82
85
 
86
+ case "xml":
87
+ mth = (that.filename || "").match(/[.](svg)$/i)
88
+ if ( mth ) {
89
+ return "<img src=\"data:image/svg+xml;base64," + btoa(that.template) + "\"/>"
90
+ }
91
+ break;
92
+
83
93
  case "base64":
84
- let mth = (that.filename || "").match(/[.](png|jpg|jpeg|tiff|tif|gif|ico)$/i)
94
+ mth = (that.filename || "").match(/[.](png|jpg|jpeg|tiff|tif|gif|ico)$/i)
85
95
  if ( mth ) {
86
96
  return "<img src=\"data:image/" + mth[1].toLowerCase() + ";base64," + that.template + "\"/>"
87
97
  }
98
+ break;
88
99
  }
89
100
 
90
101
  return ""
@@ -3,6 +3,7 @@ module.exports = (function () {
3
3
  var tarStream = require('tar-stream');
4
4
  var streamx = require('streamx');
5
5
  var pakoGzip = require('pako');
6
+ var buffer = require('buffer');
6
7
 
7
8
  /*
8
9
  * there is no indication in a tar file of whether a file is binary or textual.
@@ -20,6 +21,8 @@ module.exports = (function () {
20
21
  "css": "css",
21
22
  "yaml": "yaml",
22
23
  "yml": "yaml",
24
+ "svg": "xml",
25
+ "xml": "xml",
23
26
 
24
27
  /* binary formats are encoded in base64 */
25
28
  "png": "base64",
@@ -63,8 +66,7 @@ module.exports = (function () {
63
66
  type: "PkgFile",
64
67
  name: header.name.split("/").at(-1),
65
68
  filename: header.name.replace(/^package\//, ''),
66
- // @ts-ignore
67
- template: Buffer.concat(buffer).toString(frmt == "base64" ? 'base64' : 'utf8'),
69
+ template: buffer.Buffer.concat(buffer).toString(frmt == "base64" ? 'base64' : 'utf8'),
68
70
  syntax: "plain", // not mustache templates, these are files.
69
71
  format: frmt,
70
72
  output: "str",
@@ -91,8 +93,7 @@ module.exports = (function () {
91
93
  })
92
94
 
93
95
  extract.on('error', onError );
94
-
95
- var stream = streamx.Readable.from(Buffer.from(pakoGzip.inflate(new Uint8Array(tgzData))))
96
+ var stream = streamx.Readable.from(buffer.Buffer.from(pakoGzip.inflate(new Uint8Array(tgzData))))
96
97
  stream.pipe(extract);
97
98
  }
98
99
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name" : "@gregoriusrippenstein/node-red-contrib-nodedev",
3
- "version": "0.2.1",
3
+ "version": "0.2.2",
4
4
  "dependencies": {
5
5
  "pako": "latest",
6
6
  "tar-stream": "latest",