mirror of
https://github.com/clusterio/clusterio.git
synced 2026-11-22 08:13:12 +09:00
Documented more things with JSDOC
This commit is contained in:
1 parent
96d60e5428
commit
02dc688161
4 files changed
+56
-3
No files matched your search
@@ -33,6 +33,7 @@ Factorio*
|
|||||||
/database
|
/database
|
||||||
database/items.db
|
database/items.db
|
||||||
config.json
|
config.json
|
||||||
|
package-lock.json
|
||||||
|
|
||||||
# weird pattern to ignore sharedPlugins except not ignore some core modules
|
# weird pattern to ignore sharedPlugins except not ignore some core modules
|
||||||
!sharedPlugins/
|
!sharedPlugins/
|
||||||
|
|||||||
@@ -1,6 +1,21 @@
|
|||||||
|
/**
|
||||||
|
Module for grabbing factorio locale from a local factorio install
|
||||||
|
@module getFactorioLocale
|
||||||
|
*/
|
||||||
|
|
||||||
const fs = require("fs");
|
const fs = require("fs");
|
||||||
const ini = require("ini");
|
const ini = require("ini");
|
||||||
|
|
||||||
|
/**
|
||||||
|
Gets raw factorio locale from the .ini file.
|
||||||
|
Not available outside of module through exports.
|
||||||
|
|
||||||
|
@memberof getFactorioLocale
|
||||||
|
@inner
|
||||||
|
@param {string} factorioDirectory
|
||||||
|
@param {string} languageCode
|
||||||
|
@param {function} callback
|
||||||
|
*/
|
||||||
function getLocale(factorioDirectory, languageCode, callback){
|
function getLocale(factorioDirectory, languageCode, callback){
|
||||||
var localeFile = factorioDirectory + '/data/base/locale/' + languageCode + '/base.cfg';
|
var localeFile = factorioDirectory + '/data/base/locale/' + languageCode + '/base.cfg';
|
||||||
fs.readFile(localeFile, "utf8", (err, rawLocale) => {
|
fs.readFile(localeFile, "utf8", (err, rawLocale) => {
|
||||||
@@ -8,7 +23,14 @@ function getLocale(factorioDirectory, languageCode, callback){
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function getLocaleAsObject(factorioDirectory, languageCode, callback){
|
/**
|
||||||
|
Gets factorios locale as an object, does not respect mods.
|
||||||
|
|
||||||
|
@param {string} factorioDirectory
|
||||||
|
@param {string} languageCode
|
||||||
|
@param {function} callback
|
||||||
|
*/
|
||||||
|
module.exports.asObject = function getLocaleAsObject(factorioDirectory, languageCode, callback){
|
||||||
if(typeof factorioDirectory != "string" || typeof languageCode != "string" || typeof callback != "function"){
|
if(typeof factorioDirectory != "string" || typeof languageCode != "string" || typeof callback != "function"){
|
||||||
throw "Error: wrong parameters provided";
|
throw "Error: wrong parameters provided";
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,8 +13,15 @@ const config = require("./../../config");
|
|||||||
|
|
||||||
const instances = fileOps.getDirectoriesSync("./instances/");
|
const instances = fileOps.getDirectoriesSync("./instances/");
|
||||||
/**
|
/**
|
||||||
Lists mods for an instance
|
Lists mods for an instance as a table. Warning, handles printing internally.
|
||||||
@param {string} instance - Name of the instance or "shared"
|
@param {string} instance - Name of the instance or "shared"
|
||||||
|
@async
|
||||||
|
@example
|
||||||
|
var modManager = require("modManager");
|
||||||
|
modManager.listMods("testInstance");
|
||||||
|
// console.logs table of mods installed on instance
|
||||||
|
modManager.listMods("shared");
|
||||||
|
// console.logs mods located in /sharedMods as a nice table
|
||||||
*/
|
*/
|
||||||
module.exports.listMods = function(instance){
|
module.exports.listMods = function(instance){
|
||||||
if(instance && instances.includes(instance)){
|
if(instance && instances.includes(instance)){
|
||||||
@@ -67,6 +74,12 @@ module.exports.listMods = function(instance){
|
|||||||
console.log(JSON.parse(res.getBody()))
|
console.log(JSON.parse(res.getBody()))
|
||||||
*/
|
*/
|
||||||
}
|
}
|
||||||
|
/**
|
||||||
|
Searches mods.factorio.com for mods matching a search term and prints
|
||||||
|
the results to console as a neat looking table
|
||||||
|
|
||||||
|
@param {string} searchTerm What to search for
|
||||||
|
*/
|
||||||
module.exports.findMods = function(searchTerm){
|
module.exports.findMods = function(searchTerm){
|
||||||
factorioAPI.init(false);
|
factorioAPI.init(false);
|
||||||
console.log("Authenticating to factorio.com...")
|
console.log("Authenticating to factorio.com...")
|
||||||
@@ -94,6 +107,12 @@ module.exports.findMods = function(searchTerm){
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 'https://api.github.com/repos/Danielv123/factorioClusterioMod/releases'
|
// 'https://api.github.com/repos/Danielv123/factorioClusterioMod/releases'
|
||||||
|
/**
|
||||||
|
Download mod from github repo by looking for the first binary download in
|
||||||
|
the latest release, saving it to /sharedMods
|
||||||
|
|
||||||
|
@param {string} url a github repo URL, for example https://api.github.com/repos/Danielv123/factorioClusterioMod/releases. Must link to /releases
|
||||||
|
*/
|
||||||
module.exports.downloadFromGitURL = function(url){
|
module.exports.downloadFromGitURL = function(url){
|
||||||
console.log("Downloading mod from "+url);
|
console.log("Downloading mod from "+url);
|
||||||
// get JSON data about releases
|
// get JSON data about releases
|
||||||
|
|||||||
@@ -5,6 +5,9 @@ combinator signals.
|
|||||||
|
|
||||||
@module clusterioMaster
|
@module clusterioMaster
|
||||||
@author Danielv123
|
@author Danielv123
|
||||||
|
|
||||||
|
@example
|
||||||
|
node master.js
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// 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
|
||||||
@@ -360,11 +363,13 @@ app.post("/api/readSignal", function(req,res) {
|
|||||||
/**
|
/**
|
||||||
GET endpoint to read the masters current inventory of items.
|
GET endpoint to read the masters current inventory of items.
|
||||||
|
|
||||||
|
@memberof clusterioMaster
|
||||||
|
@instance
|
||||||
@alias api/inventory
|
@alias api/inventory
|
||||||
@returns {object[]} JSON [{name:"iron-plate", count:100},{name:"copper-plate",count:5}]
|
@returns {object[]} JSON [{name:"iron-plate", count:100},{name:"copper-plate",count:5}]
|
||||||
*/
|
*/
|
||||||
// endpoint for getting an inventory of what we got
|
// endpoint for getting an inventory of what we got
|
||||||
app.get("/api/inventory", function(req, res) {
|
var apiinventory = app.get("/api/inventory", function(req, res) {
|
||||||
res.header("Access-Control-Allow-Origin", "*");
|
res.header("Access-Control-Allow-Origin", "*");
|
||||||
res.header("Access-Control-Allow-Headers", "Origin, X-Requested-With, Content-Type, Accept");
|
res.header("Access-Control-Allow-Headers", "Origin, X-Requested-With, Content-Type, Accept");
|
||||||
// Check it and send it
|
// Check it and send it
|
||||||
@@ -390,6 +395,8 @@ POST endpoint to log production graph statistics. Should contain a timestamp
|
|||||||
gathered from Date.now(), a slaveID (also reffered to as "unique") and of
|
gathered from Date.now(), a slaveID (also reffered to as "unique") and of
|
||||||
course the timeSeries data.
|
course the timeSeries data.
|
||||||
|
|
||||||
|
@memberof clusterioMaster
|
||||||
|
@instance
|
||||||
@alias api/logStats
|
@alias api/logStats
|
||||||
@param {object} JSON {timestamp: Date.now(), slaveID: "string", data: {"item": number}}
|
@param {object} JSON {timestamp: Date.now(), slaveID: "string", data: {"item": number}}
|
||||||
@returns {string} failure
|
@returns {string} failure
|
||||||
@@ -417,6 +424,8 @@ app.post("/api/logStats", function(req,res) {
|
|||||||
POST endpoint to get timeSeries statistics stored on the master. Can give production
|
POST endpoint to get timeSeries statistics stored on the master. Can give production
|
||||||
graphs and other IO statistics.
|
graphs and other IO statistics.
|
||||||
|
|
||||||
|
@memberof clusterioMaster
|
||||||
|
@instance
|
||||||
@alias api/getStats
|
@alias api/getStats
|
||||||
@param {object} JSON
|
@param {object} JSON
|
||||||
@returns {object} - with statistics
|
@returns {object} - with statistics
|
||||||
@@ -488,6 +497,8 @@ at /nodes. It is like getStats but it does not report items which were not
|
|||||||
produced at the moment of recording. (This is to save space, the 0-items were
|
produced at the moment of recording. (This is to save space, the 0-items were
|
||||||
making up about 92% of the response body weight.)
|
making up about 92% of the response body weight.)
|
||||||
|
|
||||||
|
@memberof clusterioMaster
|
||||||
|
@instance
|
||||||
@alias api/getTimelineStats
|
@alias api/getTimelineStats
|
||||||
@param {object} JSON {slaveID:1941029, fromTime: ???, toTime: ???}
|
@param {object} JSON {slaveID:1941029, fromTime: ???, toTime: ???}
|
||||||
@returns {object[]} timeseries where each entry is a set point in time.
|
@returns {object[]} timeseries where each entry is a set point in time.
|
||||||
|
|||||||
Reference in new issue
Block a user