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