More work on listing mods nicely with node client.js manager

This commit is contained in:
Danielv123 committed 2017-11-05 17:50:14 +01:00
1 parent c901275f38
commit 0735aa2db4
4 files changed
+33 -19

No files matched your search

+8 -4
View File
@@ -123,10 +123,14 @@ if (!command || command == "help" || command == "--help") {
displayLines.forEach(line => console.log(line));
process.exit(1);
} else if (command == "manage"){
console.log("Launching mod manager");
modManager.listMods(instance);
// console.log("Launching mod manager");
const action = process.argv[4];
if(instance && action && action == "list"){
modManager.listMods(instance);
} else {
console.log('Usage:');
console.log('node client.js manage [instance, "shared"] ["list"]');
}
// process.exit(1);
} else if (command == "delete") {
if (!process.argv[3]) {
+11 -15
View File
@@ -1,4 +1,5 @@
const rightpad = require("right-pad");
const asTable = require("as-table").configure({delimiter: ' | '});
const factorioAPI = require("node-factorio-api");
const fileOps = require("./../fileOps.js");
@@ -15,8 +16,15 @@ module.exports.listMods = function(instance){
require_ownership: false
}).then(token => {
console.log("authed")
factorioAPI.getModsFromSaves().then(list => {
console.log(list)
/**/
factorioAPI.getInstalledMods().then(mods => {
console.log("Currently installed:");
console.log(asTable(mods));
factorioAPI.getModsFromSaves().then(list => {
console.log("Mods used in save:");
console.log(JSON.stringify(list))
console.log(asTable(list[0].mods))
});
});
});
} else {
@@ -29,19 +37,7 @@ module.exports.listMods = function(instance){
require_ownership: false
}).then(() => {
factorioAPI.getInstalledMods().then(mods => {
let modNames = ["Name:"];
let modVersions = ["Version:"];
mods.forEach(mod=>{
modNames.push(mod.name);
modVersions.push(mod.version);
});
let longestName = modNames.reduce(function (a, b) { return a.length > b.length ? a : b; });
let longestVersion = modVersions.reduce(function (a, b) { return a.length > b.length ? a : b; });
console.log("| "+rightpad("Name:", longestName.length, " ")+" | "+rightpad("Version:", longestVersion.length, " ")+" |");
mods.forEach(mod => {
console.log("| "+rightpad(mod.name, longestName.length, " ")+" | "+rightpad(mod.version, longestVersion.length, " ")+" |");
});
console.log(asTable(mods));
});
});
}
+13
View File
@@ -177,6 +177,14 @@
"resolved": "https://registry.npmjs.org/array-flatten/-/array-flatten-1.1.1.tgz",
"integrity": "sha1-ml9pkFGx5wczKPKgCJaLZOopVdI="
},
"as-table": {
"version": "1.0.31",
"resolved": "https://registry.npmjs.org/as-table/-/as-table-1.0.31.tgz",
"integrity": "sha1-0AGAAk7LttGnRxUN91HTcWrqgWY=",
"requires": {
"printable-characters": "1.0.38"
}
},
"asap": {
"version": "2.0.5",
"resolved": "https://registry.npmjs.org/asap/-/asap-2.0.5.tgz",
@@ -3206,6 +3214,11 @@
}
}
},
"printable-characters": {
"version": "1.0.38",
"resolved": "https://registry.npmjs.org/printable-characters/-/printable-characters-1.0.38.tgz",
"integrity": "sha1-du+ErM/X+DZvtxOPuSRmqRbVmbw="
},
"private": {
"version": "0.1.7",
"resolved": "https://registry.npmjs.org/private/-/private-0.1.7.tgz",
+1
View File
@@ -15,6 +15,7 @@
"author": "Danielv123",
"license": "ISC",
"dependencies": {
"as-table": "^1.0.31",
"averaged-timeseries": "^1.4.0",
"body-parser": "^1.18.2",
"canvasjs": "^1.8.1",