node-pluginsmanager 3.6.1 → 3.6.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.
|
@@ -25,7 +25,6 @@ const isFile_1 = __importDefault(require("./utils/isFile"));
|
|
|
25
25
|
const createPluginByDirectory_1 = __importDefault(require("./createPluginByDirectory"));
|
|
26
26
|
const loadSortedPlugins_1 = __importDefault(require("./loadSortedPlugins"));
|
|
27
27
|
const initSortedPlugins_1 = __importDefault(require("./initSortedPlugins"));
|
|
28
|
-
const extractGithub_1 = __importDefault(require("./utils/extractGithub"));
|
|
29
28
|
const getLatestGithubTag_1 = __importDefault(require("./utils/getLatestGithubTag"));
|
|
30
29
|
const parseGithubUserRepo_1 = __importDefault(require("./utils/parseGithubUserRepo"));
|
|
31
30
|
// git
|
|
@@ -223,7 +222,7 @@ class PluginsManager extends node_events_1.default {
|
|
|
223
222
|
// after releasing, destroy packages data & free "plugins" list, using "data" in arguments for "destroy" plugin's Orchestrator method
|
|
224
223
|
destroyAll(...data) {
|
|
225
224
|
return Promise.all(this.plugins.map((plugin) => {
|
|
226
|
-
return plugin.destroy().then(() => {
|
|
225
|
+
return plugin.destroy(...data).then(() => {
|
|
227
226
|
this.emit("destroyed", plugin.name, ...data);
|
|
228
227
|
});
|
|
229
228
|
})).then(() => {
|
|
@@ -272,7 +271,7 @@ class PluginsManager extends node_events_1.default {
|
|
|
272
271
|
}
|
|
273
272
|
getLatestGithubTag(plugin) {
|
|
274
273
|
return (0, checkOrchestrator_1.default)("getLatestGithubTag/plugin", plugin).then(() => {
|
|
275
|
-
const githubUserRepo = (0, parseGithubUserRepo_1.default)(
|
|
274
|
+
const githubUserRepo = (0, parseGithubUserRepo_1.default)(plugin.repository);
|
|
276
275
|
if (!githubUserRepo) {
|
|
277
276
|
throw new Error("Plugin \"" + plugin.name + "\" has an invalid github project link");
|
|
278
277
|
}
|
|
@@ -414,45 +413,46 @@ class PluginsManager extends node_events_1.default {
|
|
|
414
413
|
updateViaGithub(plugin, ...data) {
|
|
415
414
|
let directory = "";
|
|
416
415
|
let key = -1;
|
|
416
|
+
let pluginName = "";
|
|
417
417
|
// check plugin
|
|
418
418
|
return (0, checkOrchestrator_1.default)("updateViaGithub/plugin", plugin).then(() => {
|
|
419
|
-
|
|
420
|
-
|
|
419
|
+
pluginName = plugin.name;
|
|
420
|
+
key = this.getPluginsNames().findIndex((pn) => {
|
|
421
|
+
return pluginName === pn;
|
|
421
422
|
});
|
|
422
423
|
if (-1 >= key) {
|
|
423
|
-
throw new Error("Plugin \"" +
|
|
424
|
+
throw new Error("Plugin \"" + pluginName + "\" is not registered");
|
|
424
425
|
}
|
|
425
426
|
// check plugin directory
|
|
426
427
|
}).then(() => {
|
|
427
428
|
return (0, checkAbsoluteDirectory_1.default)("updateViaGithub/directory", this.directory).then(() => {
|
|
428
|
-
directory = (0, node_path_1.join)(this.directory,
|
|
429
|
+
directory = (0, node_path_1.join)(this.directory, pluginName);
|
|
429
430
|
return (0, checkAbsoluteDirectory_1.default)("updateViaGithub/plugindirectory", directory);
|
|
430
431
|
});
|
|
431
432
|
// check remote version
|
|
432
433
|
}).then(() => {
|
|
433
434
|
const currentVersion = semver_1.default.coerce(plugin.version);
|
|
434
435
|
if (!currentVersion) {
|
|
435
|
-
throw new Error("Plugin \"" +
|
|
436
|
+
throw new Error("Plugin \"" + pluginName + "\" has no valid version (\"" + plugin.version + "\")");
|
|
436
437
|
}
|
|
437
|
-
this._logger?.("debug", "Get github latest tag", false,
|
|
438
|
+
this._logger?.("debug", "Get github latest tag", false, pluginName);
|
|
438
439
|
return this.getLatestGithubTag(plugin).then((tag) => {
|
|
439
440
|
const latestVersion = semver_1.default.coerce(tag);
|
|
440
441
|
if (!latestVersion) {
|
|
441
|
-
throw new Error("No valid version found for plugin \"" +
|
|
442
|
+
throw new Error("No valid version found for plugin \"" + pluginName + "\" on github");
|
|
442
443
|
}
|
|
443
|
-
this._logger?.("debug", "Compare local version with github
|
|
444
|
+
this._logger?.("debug", "Compare local version with github latest tag", false, pluginName);
|
|
444
445
|
if (!semver_1.default.gt(latestVersion, currentVersion)) {
|
|
445
|
-
throw new Error("Plugin \"" +
|
|
446
|
+
throw new Error("Plugin \"" + pluginName + "\" is already up to date (v" + plugin.version + ")");
|
|
446
447
|
}
|
|
447
|
-
this._logger?.("success", "New version available", false,
|
|
448
|
+
this._logger?.("success", "New version available", false, pluginName);
|
|
448
449
|
return tag;
|
|
449
450
|
});
|
|
450
451
|
// release plugin
|
|
451
452
|
}).then((latestTag) => {
|
|
452
|
-
const pluginName = plugin.name;
|
|
453
453
|
return plugin.release(...data).then(() => {
|
|
454
454
|
this.emit("released", plugin, ...data);
|
|
455
|
-
return plugin.destroy();
|
|
455
|
+
return plugin.destroy(...data);
|
|
456
456
|
}).then(() => {
|
|
457
457
|
this.emit("destroyed", pluginName, ...data);
|
|
458
458
|
this.plugins.splice(key, 1);
|
|
@@ -460,13 +460,13 @@ class PluginsManager extends node_events_1.default {
|
|
|
460
460
|
});
|
|
461
461
|
// update plugin
|
|
462
462
|
}).then((latestTag) => {
|
|
463
|
-
this._logger?.("debug", "Update with new plugin version", false,
|
|
463
|
+
this._logger?.("debug", "Update with new plugin version", false, pluginName);
|
|
464
464
|
return (0, gitUpdate_1.default)(directory, latestTag).then(() => {
|
|
465
465
|
return (0, createPluginByDirectory_1.default)(directory, this.externalResourcesDirectory, this._logger, ...data);
|
|
466
466
|
});
|
|
467
467
|
// check plugin modules versions
|
|
468
468
|
}).then((_plugin) => {
|
|
469
|
-
this._logger?.("debug", "Check modules", false,
|
|
469
|
+
this._logger?.("debug", "Check modules", false, pluginName);
|
|
470
470
|
return this.checkModules(_plugin).then(() => {
|
|
471
471
|
return _plugin;
|
|
472
472
|
});
|
|
@@ -490,25 +490,26 @@ class PluginsManager extends node_events_1.default {
|
|
|
490
490
|
// uninstall a plugin, using "data" in arguments for "release" and "uninstall" plugin's methods
|
|
491
491
|
uninstall(plugin, ...data) {
|
|
492
492
|
let directory = "";
|
|
493
|
-
let key = -1;
|
|
494
493
|
let pluginName = "";
|
|
495
494
|
// check plugin
|
|
496
495
|
return Promise.resolve().then(() => {
|
|
497
496
|
return (0, checkOrchestrator_1.default)("uninstall/plugin", plugin).then(() => {
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
497
|
+
pluginName = plugin.name;
|
|
498
|
+
if (!this.getPluginsNames().includes(pluginName)) {
|
|
499
|
+
throw new Error("Plugin \"" + pluginName + "\" is not registered");
|
|
500
|
+
}
|
|
502
501
|
});
|
|
503
502
|
// check plugin directory
|
|
504
503
|
}).then(() => {
|
|
505
504
|
return (0, checkAbsoluteDirectory_1.default)("uninstall/directory", this.directory).then(() => {
|
|
506
|
-
pluginName = plugin.name;
|
|
507
505
|
directory = (0, node_path_1.join)(this.directory, pluginName);
|
|
508
506
|
return (0, checkAbsoluteDirectory_1.default)("uninstall/plugindirectory", directory);
|
|
509
507
|
});
|
|
510
508
|
// release plugin
|
|
511
509
|
}).then(() => {
|
|
510
|
+
const key = this.getPluginsNames().findIndex((name) => {
|
|
511
|
+
return name === pluginName;
|
|
512
|
+
});
|
|
512
513
|
return plugin.release(...data).then(() => {
|
|
513
514
|
return (0, rmdirp_1.default)((0, node_path_1.join)(this.externalResourcesDirectory, pluginName));
|
|
514
515
|
}).then(() => {
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
|
|
3
3
|
"name": "node-pluginsmanager",
|
|
4
|
-
"version": "3.6.
|
|
4
|
+
"version": "3.6.2",
|
|
5
5
|
"description": "A plugins manager.",
|
|
6
6
|
|
|
7
7
|
"type": "commonjs",
|
|
@@ -53,7 +53,7 @@
|
|
|
53
53
|
},
|
|
54
54
|
"devDependencies": {
|
|
55
55
|
"@types/express": "5.0.6",
|
|
56
|
-
"@types/node": "26.0
|
|
56
|
+
"@types/node": "26.1.0",
|
|
57
57
|
"@types/semver": "7.7.1",
|
|
58
58
|
"@types/socket.io": "3.0.2",
|
|
59
59
|
"@types/ws": "8.18.1",
|
|
@@ -61,7 +61,7 @@
|
|
|
61
61
|
"express": "5.2.1",
|
|
62
62
|
"husky": "9.1.7",
|
|
63
63
|
"mocha": "11.7.6",
|
|
64
|
-
"node-pluginsmanager-plugin": "7.4.
|
|
64
|
+
"node-pluginsmanager-plugin": "7.4.2",
|
|
65
65
|
"nyc": "18.0.0",
|
|
66
66
|
"proxyquire": "2.1.3",
|
|
67
67
|
"rimraf": "6.1.3",
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import type { Orchestrator } from "node-pluginsmanager-plugin";
|
|
2
|
-
interface OrchestratorExtended extends Orchestrator {
|
|
3
|
-
"github"?: string;
|
|
4
|
-
"repository"?: string | Record<string, string>;
|
|
5
|
-
}
|
|
6
|
-
export default function extractGithub(plugin: OrchestratorExtended): string | null;
|
|
7
|
-
export {};
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
// types & interfaces
|
|
3
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
-
exports.default = extractGithub;
|
|
5
|
-
// module
|
|
6
|
-
function extractGithub(plugin) {
|
|
7
|
-
let github = null;
|
|
8
|
-
if ("object" === typeof plugin) {
|
|
9
|
-
if ("string" === typeof plugin.github) {
|
|
10
|
-
github = plugin.github;
|
|
11
|
-
}
|
|
12
|
-
else if ("string" === typeof plugin.repository) {
|
|
13
|
-
github = plugin.repository;
|
|
14
|
-
}
|
|
15
|
-
else if ("object" === typeof plugin.repository && "string" === typeof plugin.repository.url) {
|
|
16
|
-
github = plugin.repository.url;
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
return github ?? null;
|
|
20
|
-
}
|