node-pluginsmanager 3.3.0 → 3.4.0
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.
|
@@ -19,6 +19,8 @@ const checkFunction_1 = __importDefault(require("./checkers/checkFunction"));
|
|
|
19
19
|
const checkNonEmptyArray_1 = __importDefault(require("./checkers/checkNonEmptyArray"));
|
|
20
20
|
const checkNonEmptyString_1 = __importDefault(require("./checkers/checkNonEmptyString"));
|
|
21
21
|
const checkOrchestrator_1 = __importDefault(require("./checkers/checkOrchestrator"));
|
|
22
|
+
const isDirectory_1 = __importDefault(require("./utils/isDirectory"));
|
|
23
|
+
const isFile_1 = __importDefault(require("./utils/isFile"));
|
|
22
24
|
const createPluginByDirectory_1 = __importDefault(require("./createPluginByDirectory"));
|
|
23
25
|
const loadSortedPlugins_1 = __importDefault(require("./loadSortedPlugins"));
|
|
24
26
|
const initSortedPlugins_1 = __importDefault(require("./initSortedPlugins"));
|
|
@@ -280,8 +282,30 @@ class PluginsManager extends node_events_1.default {
|
|
|
280
282
|
});
|
|
281
283
|
});
|
|
282
284
|
}).then((directory) => {
|
|
283
|
-
|
|
284
|
-
|
|
285
|
+
// download plugin
|
|
286
|
+
return Promise.resolve().then(() => {
|
|
287
|
+
return (0, gitInstall_1.default)(directory, user, repo);
|
|
288
|
+
// check if plugin directory is created
|
|
289
|
+
}).then(() => {
|
|
290
|
+
return (0, isDirectory_1.default)(directory).then((isPluginADirectory) => {
|
|
291
|
+
return !isPluginADirectory ? Promise.reject(new Error("\"" + repo + "\" plugin directory is not created")) : Promise.resolve();
|
|
292
|
+
});
|
|
293
|
+
// check if plugin has a valid package.json
|
|
294
|
+
}).then(() => {
|
|
295
|
+
return (0, isFile_1.default)((0, node_path_1.join)(directory, "package.json")).then((isPluginAPackageFile) => {
|
|
296
|
+
return !isPluginAPackageFile ? Promise.reject(new Error("\"" + repo + "\" plugin has no valid package.json")) : Promise.resolve();
|
|
297
|
+
});
|
|
298
|
+
// install dependencies if needed
|
|
299
|
+
}).then(() => {
|
|
300
|
+
return (0, promises_1.readFile)((0, node_path_1.join)(directory, "package.json"), "utf-8").then((content) => {
|
|
301
|
+
return JSON.parse(content);
|
|
302
|
+
}).then(({ dependencies }) => {
|
|
303
|
+
return "object" !== typeof dependencies || null === dependencies || 0 >= Object.keys(dependencies).length
|
|
304
|
+
? Promise.resolve()
|
|
305
|
+
: (0, npmInstall_1.default)(directory);
|
|
306
|
+
});
|
|
307
|
+
// create plugin
|
|
308
|
+
}).then(() => {
|
|
285
309
|
return (0, createPluginByDirectory_1.default)(directory, this.externalResourcesDirectory, this._logger, ...data);
|
|
286
310
|
// check plugin modules versions
|
|
287
311
|
}).then((plugin) => {
|
|
@@ -289,17 +313,19 @@ class PluginsManager extends node_events_1.default {
|
|
|
289
313
|
return Promise.resolve(plugin);
|
|
290
314
|
});
|
|
291
315
|
}).then((plugin) => {
|
|
316
|
+
// execute plugin install script
|
|
292
317
|
return Promise.resolve().then(() => {
|
|
293
|
-
return
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
// execute init script
|
|
318
|
+
return plugin.install(...data).then(() => {
|
|
319
|
+
this.emit("installed", plugin, ...data);
|
|
320
|
+
});
|
|
321
|
+
// execute init plugin script
|
|
297
322
|
}).then(() => {
|
|
298
|
-
|
|
299
|
-
|
|
323
|
+
return plugin.init(...data).then(() => {
|
|
324
|
+
this.emit("initialized", plugin, ...data);
|
|
325
|
+
this.plugins.push(plugin);
|
|
326
|
+
});
|
|
327
|
+
// return installed plugin
|
|
300
328
|
}).then(() => {
|
|
301
|
-
this.emit("initialized", plugin, ...data);
|
|
302
|
-
this.plugins.push(plugin);
|
|
303
329
|
return Promise.resolve(plugin);
|
|
304
330
|
}).catch((err) => {
|
|
305
331
|
return this.uninstall(plugin, ...data).then(() => {
|
|
@@ -5,18 +5,13 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
};
|
|
6
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
7
|
exports.default = checkDirectory;
|
|
8
|
-
// natives
|
|
9
|
-
const node_fs_1 = require("node:fs");
|
|
10
8
|
// locals
|
|
11
9
|
const checkNonEmptyString_1 = __importDefault(require("./checkNonEmptyString"));
|
|
10
|
+
const isDirectory_1 = __importDefault(require("../utils/isDirectory"));
|
|
12
11
|
// module
|
|
13
12
|
function checkDirectory(dataName, directory) {
|
|
14
13
|
return (0, checkNonEmptyString_1.default)(dataName, directory).then(() => {
|
|
15
|
-
return
|
|
16
|
-
(0, node_fs_1.lstat)(directory, (err, stats) => {
|
|
17
|
-
return resolve(Boolean(!err && stats.isDirectory()));
|
|
18
|
-
});
|
|
19
|
-
});
|
|
14
|
+
return (0, isDirectory_1.default)(directory);
|
|
20
15
|
}).then((exists) => {
|
|
21
16
|
return exists ? Promise.resolve() : Promise.reject(new Error("\"" + dataName + "\" (" + directory + ") is not a valid directory"));
|
|
22
17
|
});
|
|
@@ -14,7 +14,7 @@ function isDirectory(directory) {
|
|
|
14
14
|
reject(new TypeError("\"directory\" argument is not a string"));
|
|
15
15
|
}
|
|
16
16
|
else if ("" === directory.trim()) {
|
|
17
|
-
reject(new
|
|
17
|
+
reject(new RangeError("\"directory\" argument is empty"));
|
|
18
18
|
}
|
|
19
19
|
else {
|
|
20
20
|
(0, node_fs_1.lstat)(directory, (err, stats) => {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default function isFile(directory: string): Promise<boolean>;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// deps
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.default = isFile;
|
|
5
|
+
// natives
|
|
6
|
+
const node_fs_1 = require("node:fs");
|
|
7
|
+
// module
|
|
8
|
+
function isFile(directory) {
|
|
9
|
+
return new Promise((resolve, reject) => {
|
|
10
|
+
if ("undefined" === typeof directory) {
|
|
11
|
+
reject(new ReferenceError("missing \"directory\" argument"));
|
|
12
|
+
}
|
|
13
|
+
else if ("string" !== typeof directory) {
|
|
14
|
+
reject(new TypeError("\"directory\" argument is not a string"));
|
|
15
|
+
}
|
|
16
|
+
else if ("" === directory.trim()) {
|
|
17
|
+
reject(new RangeError("\"directory\" argument is empty"));
|
|
18
|
+
}
|
|
19
|
+
else {
|
|
20
|
+
(0, node_fs_1.lstat)(directory, (err, stats) => {
|
|
21
|
+
return resolve(Boolean(!err && stats.isFile()));
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
});
|
|
25
|
+
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
|
|
3
3
|
"name": "node-pluginsmanager",
|
|
4
|
-
"version": "3.
|
|
4
|
+
"version": "3.4.0",
|
|
5
5
|
"description": "A plugins manager.",
|
|
6
6
|
|
|
7
7
|
"type": "commonjs",
|
|
@@ -47,7 +47,7 @@
|
|
|
47
47
|
},
|
|
48
48
|
|
|
49
49
|
"dependencies": {
|
|
50
|
-
"check-node-engine": "1.
|
|
50
|
+
"check-node-engine": "1.1.0",
|
|
51
51
|
"check-version-modules": "2.5.0"
|
|
52
52
|
},
|
|
53
53
|
"devDependencies": {
|
|
@@ -59,13 +59,13 @@
|
|
|
59
59
|
"express": "5.2.1",
|
|
60
60
|
"husky": "9.1.7",
|
|
61
61
|
"mocha": "11.7.6",
|
|
62
|
-
"node-pluginsmanager-plugin": "7.
|
|
62
|
+
"node-pluginsmanager-plugin": "7.3.0",
|
|
63
63
|
"nyc": "18.0.0",
|
|
64
64
|
"proxyquire": "2.1.3",
|
|
65
65
|
"rimraf": "6.1.3",
|
|
66
66
|
"socket.io": "4.8.3",
|
|
67
67
|
"typescript": "5.9.3",
|
|
68
|
-
"used-deps-analyzer": "0.
|
|
68
|
+
"used-deps-analyzer": "0.4.0",
|
|
69
69
|
"ws": "8.21.0"
|
|
70
70
|
},
|
|
71
71
|
|