@gregoriusrippenstein/node-red-contrib-nodedev 0.4.5 → 0.4.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.
@@ -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>
@@ -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.6",
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>