node-pluginsmanager 2.3.6 → 2.3.7
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.
- package/lib/cmd/git/install.js +1 -1
- package/lib/initSortedPlugins.js +16 -30
- package/lib/loadSortedPlugins.js +16 -34
- package/package.json +10 -10
package/lib/cmd/git/install.js
CHANGED
package/lib/initSortedPlugins.js
CHANGED
|
@@ -1,9 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
// consts
|
|
4
|
-
|
|
5
|
-
const MAX_PARALLEL = 5;
|
|
6
|
-
|
|
7
3
|
// private
|
|
8
4
|
|
|
9
5
|
// methods
|
|
@@ -37,7 +33,7 @@
|
|
|
37
33
|
* @param {number} i : stepper
|
|
38
34
|
* @return {Promise} : result operation
|
|
39
35
|
*/
|
|
40
|
-
function
|
|
36
|
+
function _initPlugins (pluginsToInit, emit, data, i = 0) {
|
|
41
37
|
|
|
42
38
|
return i < pluginsToInit.length ? Promise.resolve().then(() => {
|
|
43
39
|
|
|
@@ -46,29 +42,7 @@
|
|
|
46
42
|
// loop
|
|
47
43
|
}).then(() => {
|
|
48
44
|
|
|
49
|
-
return
|
|
50
|
-
|
|
51
|
-
}) : Promise.resolve();
|
|
52
|
-
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
/**
|
|
56
|
-
* Load plugins without sort conditions
|
|
57
|
-
* @param {object} pluginsToInit : plugins to init
|
|
58
|
-
* @param {function} emit : emit data function
|
|
59
|
-
* @param {object} data : data to send
|
|
60
|
-
* @return {Promise} : result operation
|
|
61
|
-
*/
|
|
62
|
-
function _initUnSortedPlugins (pluginsToInit, emit, data) {
|
|
63
|
-
|
|
64
|
-
return pluginsToInit.length ? Promise.all(pluginsToInit.splice(0, MAX_PARALLEL).map((p) => {
|
|
65
|
-
|
|
66
|
-
return _initPlugin(p, emit, data);
|
|
67
|
-
|
|
68
|
-
// loop
|
|
69
|
-
})).then(() => {
|
|
70
|
-
|
|
71
|
-
return _initUnSortedPlugins(pluginsToInit, emit, data);
|
|
45
|
+
return _initPlugins(pluginsToInit, emit, data, i + 1);
|
|
72
46
|
|
|
73
47
|
}) : Promise.resolve();
|
|
74
48
|
|
|
@@ -89,7 +63,7 @@ module.exports = function initSortedPlugins (plugins, orderedPluginsNames, emit,
|
|
|
89
63
|
|
|
90
64
|
// first, sorted plugins
|
|
91
65
|
return sortedPlugins.length ?
|
|
92
|
-
|
|
66
|
+
_initPlugins(sortedPlugins, emit, data) :
|
|
93
67
|
Promise.resolve();
|
|
94
68
|
|
|
95
69
|
}).then(() => {
|
|
@@ -97,12 +71,24 @@ module.exports = function initSortedPlugins (plugins, orderedPluginsNames, emit,
|
|
|
97
71
|
const unsortedPlugin = [
|
|
98
72
|
...plugins.filter((plugin) => {
|
|
99
73
|
return !orderedPluginsNames.includes(plugin.name);
|
|
74
|
+
}).sort((a, b) => {
|
|
75
|
+
|
|
76
|
+
if (a < b) {
|
|
77
|
+
return -1;
|
|
78
|
+
}
|
|
79
|
+
else if (a > b) {
|
|
80
|
+
return 1;
|
|
81
|
+
}
|
|
82
|
+
else {
|
|
83
|
+
return 0;
|
|
84
|
+
}
|
|
85
|
+
|
|
100
86
|
})
|
|
101
87
|
];
|
|
102
88
|
|
|
103
89
|
// then, all other plugins, asynchronously
|
|
104
90
|
return unsortedPlugin.length ?
|
|
105
|
-
|
|
91
|
+
_initPlugins(unsortedPlugin, emit, data) :
|
|
106
92
|
Promise.resolve();
|
|
107
93
|
|
|
108
94
|
});
|
package/lib/loadSortedPlugins.js
CHANGED
|
@@ -12,10 +12,6 @@
|
|
|
12
12
|
// locals
|
|
13
13
|
const createPluginByDirectory = require(join(__dirname, "createPluginByDirectory.js"));
|
|
14
14
|
|
|
15
|
-
// consts
|
|
16
|
-
|
|
17
|
-
const MAX_PARALLEL = 5;
|
|
18
|
-
|
|
19
15
|
// private
|
|
20
16
|
|
|
21
17
|
// methods
|
|
@@ -71,7 +67,7 @@
|
|
|
71
67
|
* @param {number} i : stepper
|
|
72
68
|
* @return {Promise} : result operation
|
|
73
69
|
*/
|
|
74
|
-
function
|
|
70
|
+
function _loadPlugins (globalDirectory, externalRessourcesDirectory, pluginsToLoad, loadedPlugins, emit, logger, data, i = 0) {
|
|
75
71
|
|
|
76
72
|
return i < pluginsToLoad.length ? Promise.resolve().then(() => {
|
|
77
73
|
|
|
@@ -80,33 +76,7 @@
|
|
|
80
76
|
// loop
|
|
81
77
|
}).then(() => {
|
|
82
78
|
|
|
83
|
-
return
|
|
84
|
-
|
|
85
|
-
}) : Promise.resolve();
|
|
86
|
-
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
/**
|
|
90
|
-
* Load plugins without sort conditions
|
|
91
|
-
* @param {string} globalDirectory : get plugins directory
|
|
92
|
-
* @param {string} externalRessourcesDirectory : get ressources directory
|
|
93
|
-
* @param {Array} pluginsToLoad : plugins to load
|
|
94
|
-
* @param {object} loadedPlugins : already loaded plugins
|
|
95
|
-
* @param {function} emit : emit data function
|
|
96
|
-
* @param {function|null} logger : if logger, send it to plugin
|
|
97
|
-
* @param {object} data : data to send
|
|
98
|
-
* @return {Promise} : result operation
|
|
99
|
-
*/
|
|
100
|
-
function _loadUnSortedPlugins (globalDirectory, externalRessourcesDirectory, pluginsToLoad, loadedPlugins, emit, logger, data) {
|
|
101
|
-
|
|
102
|
-
return pluginsToLoad.length ? Promise.all(pluginsToLoad.splice(0, MAX_PARALLEL).map((p) => {
|
|
103
|
-
|
|
104
|
-
return _loadPlugin(globalDirectory, externalRessourcesDirectory, p, loadedPlugins, emit, logger, data);
|
|
105
|
-
|
|
106
|
-
// loop
|
|
107
|
-
})).then(() => {
|
|
108
|
-
|
|
109
|
-
return _loadUnSortedPlugins(globalDirectory, externalRessourcesDirectory, pluginsToLoad, loadedPlugins, emit, logger, data);
|
|
79
|
+
return _loadPlugins(globalDirectory, externalRessourcesDirectory, pluginsToLoad, loadedPlugins, emit, logger, data, i + 1);
|
|
110
80
|
|
|
111
81
|
}) : Promise.resolve();
|
|
112
82
|
|
|
@@ -129,7 +99,7 @@ module.exports = function loadSortedPlugins (
|
|
|
129
99
|
|
|
130
100
|
// first, sorted plugins
|
|
131
101
|
return sortedPluginsNames.length ?
|
|
132
|
-
|
|
102
|
+
_loadPlugins(globalDirectory, externalRessourcesDirectory, sortedPluginsNames, loadedPlugins, emit, logger, data) :
|
|
133
103
|
Promise.resolve();
|
|
134
104
|
|
|
135
105
|
}).then(() => {
|
|
@@ -137,12 +107,24 @@ module.exports = function loadSortedPlugins (
|
|
|
137
107
|
const unsortedPluginsNames = [
|
|
138
108
|
...files.filter((pluginName) => {
|
|
139
109
|
return !orderedPluginsNames.includes(pluginName);
|
|
110
|
+
}).sort((a, b) => {
|
|
111
|
+
|
|
112
|
+
if (a < b) {
|
|
113
|
+
return -1;
|
|
114
|
+
}
|
|
115
|
+
else if (a > b) {
|
|
116
|
+
return 1;
|
|
117
|
+
}
|
|
118
|
+
else {
|
|
119
|
+
return 0;
|
|
120
|
+
}
|
|
121
|
+
|
|
140
122
|
})
|
|
141
123
|
];
|
|
142
124
|
|
|
143
125
|
// then, all other plugins, asynchronously
|
|
144
126
|
return unsortedPluginsNames.length ?
|
|
145
|
-
|
|
127
|
+
_loadPlugins(globalDirectory, externalRessourcesDirectory, unsortedPluginsNames, loadedPlugins, emit, logger, data) :
|
|
146
128
|
Promise.resolve();
|
|
147
129
|
|
|
148
130
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "node-pluginsmanager",
|
|
3
|
-
"version": "2.3.
|
|
3
|
+
"version": "2.3.7",
|
|
4
4
|
"description": "A plugins manager",
|
|
5
5
|
"main": "lib/main.js",
|
|
6
6
|
"typings": "lib/index.d.ts",
|
|
@@ -39,18 +39,18 @@
|
|
|
39
39
|
"node-promfs": "3.7.0"
|
|
40
40
|
},
|
|
41
41
|
"devDependencies": {
|
|
42
|
-
"@types/node": "
|
|
42
|
+
"@types/node": "17.0.31",
|
|
43
43
|
"@types/socket.io": "3.0.2",
|
|
44
|
-
"@types/ws": "8.
|
|
44
|
+
"@types/ws": "8.5.3",
|
|
45
45
|
"coveralls": "3.1.1",
|
|
46
|
-
"eslint": "8.
|
|
47
|
-
"express": "4.
|
|
48
|
-
"husky": "
|
|
49
|
-
"mocha": "
|
|
50
|
-
"node-pluginsmanager-plugin": "4.
|
|
46
|
+
"eslint": "8.15.0",
|
|
47
|
+
"express": "4.18.1",
|
|
48
|
+
"husky": "8.0.1",
|
|
49
|
+
"mocha": "10.0.0",
|
|
50
|
+
"node-pluginsmanager-plugin": "4.8.4",
|
|
51
51
|
"nyc": "15.1.0",
|
|
52
|
-
"typescript": "4.
|
|
53
|
-
"ws": "8.
|
|
52
|
+
"typescript": "4.6.4",
|
|
53
|
+
"ws": "8.6.0"
|
|
54
54
|
},
|
|
55
55
|
"homepage": "https://github.com/Psychopoulet/node-pluginsmanager#readme",
|
|
56
56
|
"engines": {
|