mirror of
https://github.com/clusterio/clusterio.git
synced 2026-11-24 00:23:12 +09:00
Merge branch '#85'
This commit is contained in:
commit
7d99162072
4 files changed
+17
-15
No files matched your search
@@ -25,8 +25,8 @@ const configManager = require("./lib/manager/configManager.js");
|
|||||||
var config = require('./config');
|
var config = require('./config');
|
||||||
var global = {};
|
var global = {};
|
||||||
|
|
||||||
if (!fs.existsSync("./instances/")) {
|
if (!fs.existsSync(config.instanceDirectory)) {
|
||||||
fs.mkdirSync("instances");
|
fs.mkdirSync(config.instanceDirectory);
|
||||||
}
|
}
|
||||||
if (!fs.existsSync("./sharedPlugins/")) {
|
if (!fs.existsSync("./sharedPlugins/")) {
|
||||||
fs.mkdirSync("sharedPlugins");
|
fs.mkdirSync("sharedPlugins");
|
||||||
@@ -35,7 +35,7 @@ if (!fs.existsSync("./sharedMods/")) {
|
|||||||
fs.mkdirSync("sharedMods");
|
fs.mkdirSync("sharedMods");
|
||||||
}
|
}
|
||||||
const instance = process.argv[3];
|
const instance = process.argv[3];
|
||||||
const instancedirectory = './instances/' + instance;
|
const instancedirectory = config.instanceDirectory + '/' + instance;
|
||||||
const command = process.argv[2];
|
const command = process.argv[2];
|
||||||
|
|
||||||
// Set the process title, shows up as the title of the CMD window on windows
|
// Set the process title, shows up as the title of the CMD window on windows
|
||||||
@@ -116,7 +116,7 @@ if (!command || command == "help" || command == "--help") {
|
|||||||
console.error("node client.js manage");
|
console.error("node client.js manage");
|
||||||
process.exit(1);
|
process.exit(1);
|
||||||
} else if (command == "list") {
|
} else if (command == "list") {
|
||||||
let instanceNames = fileOps.getDirectoriesSync("./instances/");
|
let instanceNames = fileOps.getDirectoriesSync(config.instanceDirectory);
|
||||||
instanceNames.unshift("Name:");
|
instanceNames.unshift("Name:");
|
||||||
let longestInstanceName = 0;
|
let longestInstanceName = 0;
|
||||||
// determine longest instance name
|
// determine longest instance name
|
||||||
@@ -139,7 +139,7 @@ if (!command || command == "help" || command == "--help") {
|
|||||||
if(instance.includes("Name:")){
|
if(instance.includes("Name:")){
|
||||||
factorioPort = "Port:"
|
factorioPort = "Port:"
|
||||||
} else {
|
} else {
|
||||||
factorioPort = require("./instances/"+instance+"/config").factorioPort;
|
factorioPort = require(config.instanceDirectory+"/"+instance+"/config").factorioPort;
|
||||||
}
|
}
|
||||||
factorioPorts.push(factorioPort);
|
factorioPorts.push(factorioPort);
|
||||||
});
|
});
|
||||||
@@ -224,8 +224,8 @@ if (!command || command == "help" || command == "--help") {
|
|||||||
if (!process.argv[3]) {
|
if (!process.argv[3]) {
|
||||||
console.error("Usage: node client.js delete [instance]");
|
console.error("Usage: node client.js delete [instance]");
|
||||||
process.exit(1);
|
process.exit(1);
|
||||||
} else if (typeof process.argv[3] == "string" && fs.existsSync("./instances/" + process.argv[3]) && process.argv[3] != "/" && process.argv[3] != "") {
|
} else if (typeof process.argv[3] == "string" && fs.existsSync(config.instanceDirectory+"/" + process.argv[3]) && process.argv[3] != "/" && process.argv[3] != "") {
|
||||||
fileOps.deleteFolderRecursiveSync("./instances/" + process.argv[3]);
|
fileOps.deleteFolderRecursiveSync(config.instanceDirectory+"/" + process.argv[3]);
|
||||||
console.log("Deleted instance " + process.argv[3]);
|
console.log("Deleted instance " + process.argv[3]);
|
||||||
process.exit(0);
|
process.exit(0);
|
||||||
} else {
|
} else {
|
||||||
@@ -265,7 +265,7 @@ if (!command || command == "help" || command == "--help") {
|
|||||||
// fs.symlinkSync('../../../sharedMods', instancedirectory + "/mods", 'junction') // This is broken because it can only take a file as first argument, not a folder
|
// fs.symlinkSync('../../../sharedMods', instancedirectory + "/mods", 'junction') // This is broken because it can only take a file as first argument, not a folder
|
||||||
fs.writeFileSync(instancedirectory + "/config.ini", "[path]\r\n\
|
fs.writeFileSync(instancedirectory + "/config.ini", "[path]\r\n\
|
||||||
read-data=__PATH__executable__/../../data\r\n\
|
read-data=__PATH__executable__/../../data\r\n\
|
||||||
write-data=__PATH__executable__/../../../instances/" + instance + "\r\n\
|
write-data=__PATH__executable__/../../../"+config.instanceDirectory+"/" + instance + "\r\n\
|
||||||
");
|
");
|
||||||
|
|
||||||
// this line is probably not needed anymore but Im not gonna remove it
|
// this line is probably not needed anymore but Im not gonna remove it
|
||||||
@@ -688,7 +688,7 @@ function instanceManagement() {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
var form = req.form();
|
var form = req.form();
|
||||||
form.append('file', fs.createReadStream("./instances/"+instance+"/mods/"+mod));
|
form.append('file', fs.createReadStream(config.instanceDirectory+"/"+instance+"/mods/"+mod));
|
||||||
} else {
|
} else {
|
||||||
console.log("Not sending mod: " + mod + " to master because config.uploadModsToMaster is not enabled")
|
console.log("Not sending mod: " + mod + " to master because config.uploadModsToMaster is not enabled")
|
||||||
}
|
}
|
||||||
@@ -973,7 +973,7 @@ function hashMods(instanceName, callback) {
|
|||||||
}
|
}
|
||||||
let hashedMods = [];
|
let hashedMods = [];
|
||||||
/*let mods = fs.readdirSync("./sharedMods/")*/
|
/*let mods = fs.readdirSync("./sharedMods/")*/
|
||||||
let instanceMods = fs.readdirSync("./instances/"+instanceName+"/mods/");
|
let instanceMods = fs.readdirSync(config.instanceDirectory+"/"+instanceName+"/mods/");
|
||||||
if(instanceMods.length == 0){
|
if(instanceMods.length == 0){
|
||||||
callback({}); // there are no mods installed, return an empty object
|
callback({}); // there are no mods installed, return an empty object
|
||||||
}
|
}
|
||||||
@@ -983,7 +983,7 @@ function hashMods(instanceName, callback) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
for(let i=0; i<instanceMods.length; i++){
|
for(let i=0; i<instanceMods.length; i++){
|
||||||
let path = "./instances/"+instanceName+"/mods/"+instanceMods[i];
|
let path = config.instanceDirectory+"/"+instanceName+"/mods/"+instanceMods[i];
|
||||||
let name = instanceMods[i];
|
let name = instanceMods[i];
|
||||||
let options = {
|
let options = {
|
||||||
files:path,
|
files:path,
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
{
|
{
|
||||||
"__comment": "Where factorio folder. Should be in the same folder as this config file.",
|
"__comment": "Where factorio folder. Should be in the same folder as this config file.",
|
||||||
"factorioDirectory": "factorio",
|
"factorioDirectory": "factorio",
|
||||||
|
"instanceDirectory": "instances",
|
||||||
|
|
||||||
"__comment1": "IP players should connect to to join your servers, should be portforwarded and stuff",
|
"__comment1": "IP players should connect to to join your servers, should be portforwarded and stuff",
|
||||||
"publicIP": "localhost",
|
"publicIP": "localhost",
|
||||||
|
|||||||
+2
-1
@@ -1,10 +1,11 @@
|
|||||||
const fileOps = require("_app/fileOps");
|
const fileOps = require("_app/fileOps");
|
||||||
|
const config = require("./../config");
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
sync: function(){
|
sync: function(){
|
||||||
let instances;
|
let instances;
|
||||||
try {
|
try {
|
||||||
instances = fileOps.getDirectoriesSync("./instances/");
|
instances = fileOps.getDirectoriesSync(config.instanceDirectory);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
// there are no instances created yet, probably missing the folder
|
// there are no instances created yet, probably missing the folder
|
||||||
instances = [];
|
instances = [];
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ modManager.listMods("shared");
|
|||||||
module.exports.listMods = function(instance){
|
module.exports.listMods = function(instance){
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
if(instance && instances.includes(instance)){
|
if(instance && instances.includes(instance)){
|
||||||
factorioAPI.init(false, 'instances/'+instance+'/instanceMods', 'instances/'+instance+'/saves', config.factorio_version);
|
factorioAPI.init(false, config.instanceDirectory+'/'+instance+'/instanceMods', config.instanceDirectory+'/'+instance+'/saves', config.factorio_version);
|
||||||
factorioAPI.authenticate({
|
factorioAPI.authenticate({
|
||||||
username: config.username,
|
username: config.username,
|
||||||
token: config.token,
|
token: config.token,
|
||||||
@@ -134,7 +134,7 @@ module.exports.addMod = function(term, instance){
|
|||||||
if(instance == "shared"){ // modDirectory has to end in /
|
if(instance == "shared"){ // modDirectory has to end in /
|
||||||
var modDirectory = "sharedMods/";
|
var modDirectory = "sharedMods/";
|
||||||
} else {
|
} else {
|
||||||
var modDirectory = "instances/"+instance+"/instanceMods/";
|
var modDirectory = config.instanceDirectory+"/"+instance+"/instanceMods/";
|
||||||
}
|
}
|
||||||
if(term && term.length > 0){
|
if(term && term.length > 0){
|
||||||
if(term.includes("mods.factorio.com/mods/")){ // https://mods.factorio.com/mods/Danielv123/ChooChoo
|
if(term.includes("mods.factorio.com/mods/")){ // https://mods.factorio.com/mods/Danielv123/ChooChoo
|
||||||
@@ -210,7 +210,7 @@ module.exports.removeMod = function removeMod(term, instance, force = false){
|
|||||||
if(instance == "shared"){ // modDirectory has to end in /
|
if(instance == "shared"){ // modDirectory has to end in /
|
||||||
var modDirectory = "sharedMods/";
|
var modDirectory = "sharedMods/";
|
||||||
} else {
|
} else {
|
||||||
var modDirectory = "instances/"+instance+"/instanceMods/";
|
var modDirectory = config.instanceDirectory+"/"+instance+"/instanceMods/";
|
||||||
}
|
}
|
||||||
if(term && typeof term == "string" && term.length > 0){
|
if(term && typeof term == "string" && term.length > 0){
|
||||||
let mods = fs.readdirSync(modDirectory);
|
let mods = fs.readdirSync(modDirectory);
|
||||||
|
|||||||
Reference in new issue
Block a user