@node-red/registry 3.1.0-beta.1 → 3.1.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.
@@ -242,63 +242,68 @@ async function ensureModuleDir() {
242
242
  }
243
243
  }
244
244
 
245
+ let installLock = Promise.resolve()
245
246
  async function installModule(moduleDetails) {
246
- let installSpec = moduleDetails.module;
247
- if (!registryUtil.checkModuleAllowed( moduleDetails.module, moduleDetails.version,installAllowList,installDenyList)) {
248
- const e = new Error("Install not allowed");
249
- e.code = "install_not_allowed";
250
- throw e;
251
- }
252
- if (moduleDetails.version) {
253
- installSpec = installSpec+"@"+moduleDetails.version;
254
- }
255
- log.info(log._("server.install.installing",{name: moduleDetails.module,version: moduleDetails.version||"latest"}));
256
- const installDir = getInstallDir();
247
+ const result = installLock.then(async () => {
248
+ let installSpec = moduleDetails.module;
249
+ if (!registryUtil.checkModuleAllowed( moduleDetails.module, moduleDetails.version,installAllowList,installDenyList)) {
250
+ const e = new Error("Install not allowed");
251
+ e.code = "install_not_allowed";
252
+ throw e;
253
+ }
254
+ if (moduleDetails.version) {
255
+ installSpec = installSpec+"@"+moduleDetails.version;
256
+ }
257
+ log.info(log._("server.install.installing",{name: moduleDetails.module,version: moduleDetails.version||"latest"}));
258
+ const installDir = getInstallDir();
257
259
 
258
- await ensureModuleDir();
260
+ await ensureModuleDir();
259
261
 
260
- let triggerPayload = {
261
- "module": moduleDetails.module,
262
- "version": moduleDetails.version,
263
- "dir": installDir,
264
- "args": ["--production","--engine-strict"]
265
- }
266
- return hooks.trigger("preInstall", triggerPayload).then((result) => {
267
- // preInstall passed
268
- // - run install
269
- if (result !== false) {
270
- let extraArgs = triggerPayload.args || [];
271
- let args = ['install', ...extraArgs, installSpec]
272
- log.trace(NPM_COMMAND + JSON.stringify(args));
273
- return exec.run(NPM_COMMAND, args, { cwd: installDir },true)
274
- } else {
275
- log.trace("skipping npm install");
276
- }
277
- }).then(() => {
278
- return hooks.trigger("postInstall", triggerPayload)
279
- }).then(() => {
280
- log.info(log._("server.install.installed", { name: installSpec }));
281
- const runtimeInstalledModules = settings.get("modules") || {};
282
- runtimeInstalledModules[moduleDetails.module] = moduleDetails;
283
- settings.set("modules",runtimeInstalledModules)
284
- }).catch(result => {
285
- var output = result.stderr || result.toString();
286
- var e;
287
- if (/E404/.test(output) || /ETARGET/.test(output)) {
288
- log.error(log._("server.install.install-failed-not-found",{name:installSpec}));
289
- e = new Error("Module not found");
290
- e.code = 404;
291
- throw e;
292
- } else {
293
- log.error(log._("server.install.install-failed-long",{name:installSpec}));
294
- log.error("------------------------------------------");
295
- log.error(output);
296
- log.error("------------------------------------------");
297
- e = new Error(log._("server.install.install-failed"));
298
- e.code = "unexpected_error";
299
- throw e;
262
+ let triggerPayload = {
263
+ "module": moduleDetails.module,
264
+ "version": moduleDetails.version,
265
+ "dir": installDir,
266
+ "args": ["--production","--engine-strict"]
300
267
  }
268
+ return hooks.trigger("preInstall", triggerPayload).then((result) => {
269
+ // preInstall passed
270
+ // - run install
271
+ if (result !== false) {
272
+ let extraArgs = triggerPayload.args || [];
273
+ let args = ['install', ...extraArgs, installSpec]
274
+ log.trace(NPM_COMMAND + JSON.stringify(args));
275
+ return exec.run(NPM_COMMAND, args, { cwd: installDir },true)
276
+ } else {
277
+ log.trace("skipping npm install");
278
+ }
279
+ }).then(() => {
280
+ return hooks.trigger("postInstall", triggerPayload)
281
+ }).then(() => {
282
+ log.info(log._("server.install.installed", { name: installSpec }));
283
+ const runtimeInstalledModules = settings.get("modules") || {};
284
+ runtimeInstalledModules[moduleDetails.module] = moduleDetails;
285
+ settings.set("modules",runtimeInstalledModules)
286
+ }).catch(result => {
287
+ var output = result.stderr || result.toString();
288
+ var e;
289
+ if (/E404/.test(output) || /ETARGET/.test(output)) {
290
+ log.error(log._("server.install.install-failed-not-found",{name:installSpec}));
291
+ e = new Error("Module not found");
292
+ e.code = 404;
293
+ throw e;
294
+ } else {
295
+ log.error(log._("server.install.install-failed-long",{name:installSpec}));
296
+ log.error("------------------------------------------");
297
+ log.error(output);
298
+ log.error("------------------------------------------");
299
+ e = new Error(log._("server.install.install-failed"));
300
+ e.code = "unexpected_error";
301
+ throw e;
302
+ }
303
+ })
301
304
  })
305
+ installLock = result.catch(() => {})
306
+ return result
302
307
  }
303
308
 
304
309
  module.exports = {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@node-red/registry",
3
- "version": "3.1.0-beta.1",
3
+ "version": "3.1.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": "3.1.0-beta.1",
19
+ "@node-red/util": "3.1.0-beta.3",
20
20
  "clone": "2.1.2",
21
- "fs-extra": "10.1.0",
22
- "semver": "7.3.8",
23
- "tar": "6.1.12",
21
+ "fs-extra": "11.1.1",
22
+ "semver": "7.5.0",
23
+ "tar": "6.1.13",
24
24
  "uglify-js": "3.17.4"
25
25
  }
26
26
  }