node-pluginsmanager 3.6.0 → 3.6.1

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.
@@ -31,7 +31,7 @@ export default class PluginsManager extends EventEmitter {
31
31
  beforeInitAll(callback: tBeforeAllMethodCallback): Promise<void>;
32
32
  initAll(...data: unknown[]): Promise<void>;
33
33
  releaseAll(...data: unknown[]): Promise<void>;
34
- getLatestGithubTag(user: string, repo: string): Promise<string>;
34
+ getLatestGithubTag(plugin: Orchestrator): Promise<string>;
35
35
  installViaGithub(user: string, repo: string, ...data: unknown[]): Promise<Orchestrator>;
36
36
  updateViaGithub(plugin: Orchestrator, ...data: unknown[]): Promise<Orchestrator>;
37
37
  uninstall(plugin: Orchestrator, ...data: unknown[]): Promise<string>;
@@ -270,9 +270,15 @@ class PluginsManager extends node_events_1.default {
270
270
  this.emit("allreleased", ...data);
271
271
  });
272
272
  }
273
- getLatestGithubTag(user, repo) {
274
- return (0, getLatestGithubTag_1.default)(user, repo).then((tag) => {
275
- return tag.name;
273
+ getLatestGithubTag(plugin) {
274
+ return (0, checkOrchestrator_1.default)("getLatestGithubTag/plugin", plugin).then(() => {
275
+ const githubUserRepo = (0, parseGithubUserRepo_1.default)((0, extractGithub_1.default)(plugin));
276
+ if (!githubUserRepo) {
277
+ throw new Error("Plugin \"" + plugin.name + "\" has an invalid github project link");
278
+ }
279
+ return (0, getLatestGithubTag_1.default)(githubUserRepo.user, githubUserRepo.repo).then((tag) => {
280
+ return tag.name;
281
+ });
276
282
  });
277
283
  }
278
284
  // install a plugin via github repo, using "data" in arguments for "install" and "init" plugin's Orchestrator methods
@@ -408,17 +414,8 @@ class PluginsManager extends node_events_1.default {
408
414
  updateViaGithub(plugin, ...data) {
409
415
  let directory = "";
410
416
  let key = -1;
411
- let githubUrl = "";
412
- let latestTag = "";
413
417
  // check plugin
414
418
  return (0, checkOrchestrator_1.default)("updateViaGithub/plugin", plugin).then(() => {
415
- const github = (0, extractGithub_1.default)(plugin);
416
- return (0, checkNonEmptyString_1.default)("updateViaGithub/github", github).catch(() => {
417
- return Promise.reject(new ReferenceError("Plugin \"" + plugin.name + "\" must be linked in the package to a github project to be updated"));
418
- }).then(() => {
419
- githubUrl = github;
420
- });
421
- }).then(() => {
422
419
  key = this.getPluginsNames().findIndex((pluginName) => {
423
420
  return pluginName === plugin.name;
424
421
  });
@@ -433,17 +430,13 @@ class PluginsManager extends node_events_1.default {
433
430
  });
434
431
  // check remote version
435
432
  }).then(() => {
436
- const githubUserRepo = (0, parseGithubUserRepo_1.default)(githubUrl);
437
- if (!githubUserRepo) {
438
- throw new Error("Plugin \"" + plugin.name + "\" has an invalid github project link");
439
- }
440
433
  const currentVersion = semver_1.default.coerce(plugin.version);
441
434
  if (!currentVersion) {
442
435
  throw new Error("Plugin \"" + plugin.name + "\" has no valid version (\"" + plugin.version + "\")");
443
436
  }
444
437
  this._logger?.("debug", "Get github latest tag", false, plugin.name);
445
- return (0, getLatestGithubTag_1.default)(githubUserRepo.user, githubUserRepo.repo).then((tag) => {
446
- const latestVersion = semver_1.default.coerce(tag.name);
438
+ return this.getLatestGithubTag(plugin).then((tag) => {
439
+ const latestVersion = semver_1.default.coerce(tag);
447
440
  if (!latestVersion) {
448
441
  throw new Error("No valid version found for plugin \"" + plugin.name + "\" on github");
449
442
  }
@@ -451,11 +444,11 @@ class PluginsManager extends node_events_1.default {
451
444
  if (!semver_1.default.gt(latestVersion, currentVersion)) {
452
445
  throw new Error("Plugin \"" + plugin.name + "\" is already up to date (v" + plugin.version + ")");
453
446
  }
454
- latestTag = tag.name;
455
447
  this._logger?.("success", "New version available", false, plugin.name);
448
+ return tag;
456
449
  });
457
450
  // release plugin
458
- }).then(() => {
451
+ }).then((latestTag) => {
459
452
  const pluginName = plugin.name;
460
453
  return plugin.release(...data).then(() => {
461
454
  this.emit("released", plugin, ...data);
@@ -463,9 +456,10 @@ class PluginsManager extends node_events_1.default {
463
456
  }).then(() => {
464
457
  this.emit("destroyed", pluginName, ...data);
465
458
  this.plugins.splice(key, 1);
459
+ return latestTag;
466
460
  });
467
461
  // update plugin
468
- }).then(() => {
462
+ }).then((latestTag) => {
469
463
  this._logger?.("debug", "Update with new plugin version", false, plugin.name);
470
464
  return (0, gitUpdate_1.default)(directory, latestTag).then(() => {
471
465
  return (0, createPluginByDirectory_1.default)(directory, this.externalResourcesDirectory, this._logger, ...data);
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
 
3
3
  "name": "node-pluginsmanager",
4
- "version": "3.6.0",
4
+ "version": "3.6.1",
5
5
  "description": "A plugins manager.",
6
6
 
7
7
  "type": "commonjs",