@node-red/registry 4.0.0-beta.2 → 4.0.0-beta.3

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.
@@ -28,11 +28,6 @@ let installEnabled = true;
28
28
  let installAllowList = ['*'];
29
29
  let installDenyList = [];
30
30
 
31
- let IMPORT_SUPPORTED = true;
32
- const nodeVersionParts = process.versions.node.split(".").map(v => parseInt(v));
33
- if (nodeVersionParts[0] < 12 || (nodeVersionParts[0] === 12 && nodeVersionParts[1] < 17)) {
34
- IMPORT_SUPPORTED = false;
35
- }
36
31
 
37
32
  function getInstallDir() {
38
33
  return path.resolve(settings.userDir || process.env.NODE_RED_HOME || ".");
@@ -110,18 +105,6 @@ function requireModule(module) {
110
105
  return require(moduleDir);
111
106
  }
112
107
  function importModule(module) {
113
- if (!IMPORT_SUPPORTED) {
114
- // On Node < 12.17 - fall back to try a require
115
- return new Promise((resolve, reject) => {
116
- try {
117
- const mod = requireModule(module);
118
- resolve(mod);
119
- } catch(err) {
120
- reject(err);
121
- }
122
- });
123
- }
124
-
125
108
  if (!registryUtil.checkModuleAllowed( module, null,installAllowList,installDenyList)) {
126
109
  const e = new Error("Module not allowed");
127
110
  e.code = "module_not_allowed";
@@ -273,7 +256,7 @@ async function installModule(moduleDetails) {
273
256
  let extraArgs = triggerPayload.args || [];
274
257
  let args = ['install', ...extraArgs, installSpec]
275
258
  log.trace(NPM_COMMAND + JSON.stringify(args));
276
- return exec.run(NPM_COMMAND, args, { cwd: installDir },true)
259
+ return exec.run(NPM_COMMAND, args, { cwd: installDir, shell: true },true)
277
260
  } else {
278
261
  log.trace("skipping npm install");
279
262
  }
package/lib/installer.js CHANGED
@@ -25,14 +25,17 @@ const registryUtil = require("./util");
25
25
  const library = require("./library");
26
26
  const {exec,log,events,hooks} = require("@node-red/util");
27
27
  const child_process = require('child_process');
28
- const npmCommand = process.platform === 'win32' ? 'npm.cmd' : 'npm';
29
- let installerEnabled = false;
30
28
 
31
29
  const plugins = require("./plugins");
32
30
 
31
+ const isWindows = process.platform === 'win32'
32
+ const npmCommand = isWindows ? 'npm.cmd' : 'npm';
33
+
34
+ let installerEnabled = false;
33
35
  let settings;
36
+
34
37
  const moduleRe = /^(@[^/@]+?[/])?[^/@]+?$/;
35
- const slashRe = process.platform === "win32" ? /\\|[/]/ : /[/]/;
38
+ const slashRe = isWindows ? /\\|[/]/ : /[/]/;
36
39
  const pkgurlRe = /^(https?|git(|\+https?|\+ssh|\+file)):\/\//;
37
40
  const localtgzRe = /^([a-zA-Z]:|\/).+tgz$/;
38
41
 
@@ -227,7 +230,7 @@ async function installModule(module,version,url) {
227
230
  let extraArgs = triggerPayload.args || [];
228
231
  let args = ['install', ...extraArgs, installName]
229
232
  log.trace(npmCommand + JSON.stringify(args));
230
- return exec.run(npmCommand,args,{ cwd: installDir}, true)
233
+ return exec.run(npmCommand,args,{ cwd: installDir, shell: true }, true)
231
234
  } else {
232
235
  log.trace("skipping npm install");
233
236
  }
@@ -262,7 +265,7 @@ async function installModule(module,version,url) {
262
265
  log.warn("------------------------------------------");
263
266
  e = new Error(log._("server.install.install-failed")+": "+err.toString());
264
267
  if (err.hook === "postInstall") {
265
- return exec.run(npmCommand,["remove",module],{ cwd: installDir}, false).finally(() => {
268
+ return exec.run(npmCommand,["remove",module],{ cwd: installDir, shell: true }, false).finally(() => {
266
269
  throw e;
267
270
  })
268
271
  }
@@ -366,7 +369,7 @@ async function getModuleVersionFromNPM(module, version) {
366
369
  }
367
370
 
368
371
  return new Promise((resolve, reject) => {
369
- child_process.execFile(npmCommand,['info','--json',installName],function(err,stdout,stderr) {
372
+ child_process.execFile(npmCommand,['info','--json',installName],{ shell: true },function(err,stdout,stderr) {
370
373
  try {
371
374
  if (!stdout) {
372
375
  log.warn(log._("server.install.install-failed-not-found",{name:module}));
@@ -525,7 +528,7 @@ function uninstallModule(module) {
525
528
  let extraArgs = triggerPayload.args || [];
526
529
  let args = ['remove', ...extraArgs, module]
527
530
  log.trace(npmCommand + JSON.stringify(args));
528
- return exec.run(npmCommand,args,{ cwd: installDir}, true)
531
+ return exec.run(npmCommand,args,{ cwd: installDir, shell: true }, true)
529
532
  } else {
530
533
  log.trace("skipping npm uninstall");
531
534
  }
@@ -592,7 +595,7 @@ async function checkPrereq() {
592
595
  installerEnabled = false;
593
596
  } else {
594
597
  return new Promise(resolve => {
595
- child_process.execFile(npmCommand,['-v'],function(err,stdout) {
598
+ child_process.execFile(npmCommand,['-v'],{ shell: true },function(err,stdout) {
596
599
  if (err) {
597
600
  log.info(log._("server.palette-editor.npm-not-found"));
598
601
  installerEnabled = false;
package/lib/subflow.js CHANGED
@@ -88,7 +88,7 @@ function generateSubflowConfig(subflow) {
88
88
  this.credentials['has_' + prop.name] = (this.credentials[prop.name] !== "");
89
89
  } else {
90
90
  switch(prop.type) {
91
- case "str": this[prop.name] = prop.value||""; break;
91
+ case "str": case "conf-type": this[prop.name] = prop.value||""; break;
92
92
  case "bool": this[prop.name] = (typeof prop.value === 'boolean')?prop.value:prop.value === "true" ; break;
93
93
  case "num": this[prop.name] = (typeof prop.value === 'number')?prop.value:Number(prop.value); break;
94
94
  default:
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@node-red/registry",
3
- "version": "4.0.0-beta.2",
3
+ "version": "4.0.0-beta.3",
4
4
  "license": "Apache-2.0",
5
5
  "main": "./lib/index.js",
6
6
  "repository": {
@@ -16,11 +16,11 @@
16
16
  }
17
17
  ],
18
18
  "dependencies": {
19
- "@node-red/util": "4.0.0-beta.2",
19
+ "@node-red/util": "4.0.0-beta.3",
20
20
  "clone": "2.1.2",
21
21
  "fs-extra": "11.1.1",
22
22
  "semver": "7.5.4",
23
- "tar": "6.1.13",
23
+ "tar": "6.2.1",
24
24
  "uglify-js": "3.17.4"
25
25
  }
26
26
  }