mirror of
https://github.com/clusterio/clusterio.git
synced 2026-11-30 16:57:13 +09:00
Remove unused config parameter to pluginManager
Remove the unused library initialization parameter config to pluginManager and reorganize pluginManager to no longer be defined by a function.
This commit is contained in:
1 parent
35546b4b18
commit
a31778c7ff
4 files changed
+30
-22
No files matched your search
@@ -18,6 +18,7 @@ const objectOps = require("lib/objectOps.js");
|
||||
const fileOps = require("lib/fileOps");
|
||||
const stringUtils = require("lib/stringUtils.js");
|
||||
const configManager = require("lib/manager/configManager.js");
|
||||
const pluginManager = require("lib/manager/pluginManager");
|
||||
const hashFile = require('lib/hash').hashFile;
|
||||
|
||||
console.warn(`
|
||||
@@ -235,7 +236,6 @@ if (!command || command == "help" || command == "--help") {
|
||||
}
|
||||
} else if(tool == "plugins"){
|
||||
(async function(){try{
|
||||
const pluginManager = require("lib/manager/pluginManager.js")(config);
|
||||
if(action == "list"){
|
||||
await pluginManager.listPlugins();
|
||||
} else if(action == "add" || action == "install" || action == "download"){
|
||||
@@ -587,7 +587,6 @@ async function instanceManagement(instanceconfig) {
|
||||
setInterval(B=> socket.emit("heartbeat"), 10000);
|
||||
|
||||
// load plugins and execute onLoad event
|
||||
const pluginManager = require("lib/manager/pluginManager.js")(config);
|
||||
let pluginsToLoad = await pluginManager.getPlugins();
|
||||
let plugins = [];
|
||||
|
||||
|
||||
@@ -3,17 +3,14 @@ const path = require("path");
|
||||
const git = require("simple-git")("./sharedPlugins");
|
||||
|
||||
|
||||
module.exports = function(config){
|
||||
if(!config) config = require("./../../config");
|
||||
|
||||
return {
|
||||
listPlugins: async function(){
|
||||
async function listPlugins() {
|
||||
let plugins = await this.getPlugins();
|
||||
plugins.forEach(plug => {
|
||||
console.log(`${plug.name}`.padEnd(22).substr(0,22)+` - ${plug.description}`.substr(0,80-22));
|
||||
});
|
||||
},
|
||||
getPlugins: async function(){
|
||||
}
|
||||
|
||||
async function getPlugins() {
|
||||
let directories = await fs.readdir("./sharedPlugins");
|
||||
let returnArray = [];
|
||||
for(let i in directories){
|
||||
@@ -39,15 +36,17 @@ module.exports = function(config){
|
||||
}
|
||||
}
|
||||
return returnArray;
|
||||
},
|
||||
addPlugin: function(path){
|
||||
}
|
||||
|
||||
function addPlugin(path) {
|
||||
return new Promise((resolve, reject) => {
|
||||
if(path.includes("git")){ // we are decently sure this is a git repo
|
||||
git.clone(path, data => resolve(data))
|
||||
}
|
||||
});
|
||||
},
|
||||
removePlugin: async function(name){
|
||||
}
|
||||
|
||||
async function removePlugin(name) {
|
||||
let plugins = await this.getPlugins();
|
||||
for(let i in plugins){
|
||||
let plug = plugins[i];
|
||||
@@ -64,8 +63,9 @@ module.exports = function(config){
|
||||
ok:false,
|
||||
msg:`Plugin matching "${name}" not found`,
|
||||
}
|
||||
},
|
||||
enablePlugin: async function(name, instance){
|
||||
}
|
||||
|
||||
async function enablePlugin(name, instance) {
|
||||
let plugins = await this.getPlugins();
|
||||
let plugin = plugins[findInArray("name", name, plugins)[0]];
|
||||
if(plugin){
|
||||
@@ -88,8 +88,9 @@ module.exports = function(config){
|
||||
msg:`Found no excact match for plugin ${name}`,
|
||||
}
|
||||
}
|
||||
},
|
||||
disablePlugin: async function(name, instance){
|
||||
}
|
||||
|
||||
async function disablePlugin(name, instance) {
|
||||
let plugins = await this.getPlugins();
|
||||
let plugin = plugins[findInArray("name", name, plugins)[0]];
|
||||
if(plugin){
|
||||
@@ -104,13 +105,21 @@ module.exports = function(config){
|
||||
msg:`Found no excact match for plugin ${name}`,
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
function findInArray(key, value, array){
|
||||
|
||||
function findInArray(key, value, array) {
|
||||
let indexes = [];
|
||||
for(let i in array){
|
||||
if(array[i][key] && array[i][key] === value) indexes.push(i);
|
||||
}
|
||||
return indexes;
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
listPlugins,
|
||||
getPlugins,
|
||||
addPlugin,
|
||||
removePlugin,
|
||||
enablePlugin,
|
||||
disablePlugin,
|
||||
};
|
||||
@@ -33,6 +33,7 @@ let config = {};
|
||||
// homebrew modules
|
||||
const generateSSLcert = require("lib/generateSSLcert");
|
||||
const getFactorioLocale = require("lib/getFactorioLocale");
|
||||
const pluginManager = require("lib/manager/pluginManager.js");
|
||||
const database = require("lib/database");
|
||||
|
||||
// homemade express middleware for token auth
|
||||
@@ -800,7 +801,6 @@ async function pluginManagement(){
|
||||
}
|
||||
|
||||
async function getPlugins(){
|
||||
const pluginManager = require("lib/manager/pluginManager.js")(config);
|
||||
let plugins = [];
|
||||
let pluginsToLoad = await pluginManager.getPlugins();
|
||||
for(let i = 0; i < pluginsToLoad.length; i++){
|
||||
|
||||
@@ -9,7 +9,7 @@ module.exports = class remoteCommands {
|
||||
this.messageInterface = messageInterface;
|
||||
this.config = mergedConfig;
|
||||
this.socket = extras.socket;
|
||||
const pluginManager = require("lib/manager/pluginManager.js")(this.config);
|
||||
const pluginManager = require("lib/manager/pluginManager.js");
|
||||
const configManager = require("lib/manager/configManager.js");
|
||||
// const modManager = require("lib/manager/modManager.js")(this.config);
|
||||
this.socket.on("hello", () => {
|
||||
|
||||
Reference in new issue
Block a user