mirror of
https://github.com/AsgardEternal/SquadJS.git
synced 2024-09-28 14:04:25 -05:00
Fix out of date version system
This commit is contained in:
parent
fb7ba533a9
commit
8a29ad043f
@ -10,7 +10,8 @@ class Logger {
|
||||
let colorFunc = chalk[this.colors[module] || 'white'];
|
||||
if (typeof colorFunc !== 'function') colorFunc = chalk.white;
|
||||
|
||||
if ((this.verboseness[module] || 1) >= verboseness) console.log(`[${colorFunc(module)}][${verboseness}] ${message}`, ...extras)
|
||||
if ((this.verboseness[module] || 1) >= verboseness)
|
||||
console.log(`[${colorFunc(module)}][${verboseness}] ${message}`, ...extras);
|
||||
}
|
||||
|
||||
setVerboseness(module, verboseness) {
|
||||
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "SquadJS",
|
||||
"version": "1.4.8",
|
||||
"version": "2.0.0-beta1",
|
||||
"repository": "https://github.com/Thomas-Smyth/SquadJS.git",
|
||||
"author": "Thomas Smyth <https://github.com/Thomas-Smyth>",
|
||||
"license": "BSL-1.0",
|
||||
|
@ -17,7 +17,7 @@ const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
||||
export default class SquadServerFactory {
|
||||
static async buildFromConfig(config) {
|
||||
for (const plugin of Object.keys(plugins)) {
|
||||
Logger.setColor(plugin, "magentaBright");
|
||||
Logger.setColor(plugin, 'magentaBright');
|
||||
}
|
||||
|
||||
// setup logging levels
|
||||
|
@ -130,7 +130,12 @@ export default class AutoKickUnassigned extends BasePlugin {
|
||||
async updateTrackingList(forceUpdate = false) {
|
||||
const run = !(this.betweenRounds || this.server.players.length < this.options.playerThreshold);
|
||||
|
||||
this.verbose(3, `Update Tracking List? ${run} (Between rounds: ${this.betweenRounds}, Below player threshold: ${this.server.players.length < this.options.playerThreshold})`)
|
||||
this.verbose(
|
||||
3,
|
||||
`Update Tracking List? ${run} (Between rounds: ${
|
||||
this.betweenRounds
|
||||
}, Below player threshold: ${this.server.players.length < this.options.playerThreshold})`
|
||||
);
|
||||
|
||||
if (!run) {
|
||||
for (const steamID of Object.keys(this.trackedPlayers)) this.untrackPlayer(steamID);
|
||||
@ -152,8 +157,7 @@ export default class AutoKickUnassigned extends BasePlugin {
|
||||
if (!isUnassigned) continue;
|
||||
|
||||
if (isAdmin) this.verbose(2, `Admin is Unassigned: ${player.name}`);
|
||||
if (isWhitelist)
|
||||
this.verbose(2, `Whitelist player is Unassigned: ${player.name}`);
|
||||
if (isWhitelist) this.verbose(2, `Whitelist player is Unassigned: ${player.name}`);
|
||||
|
||||
// start tracking player
|
||||
if (
|
||||
|
@ -19,7 +19,10 @@ export default class BasePlugin {
|
||||
);
|
||||
}
|
||||
|
||||
this.options[optionName] = typeof this.rawOptions[optionName] !== 'undefined' ? this.rawOptions[optionName] : option.default;
|
||||
this.options[optionName] =
|
||||
typeof this.rawOptions[optionName] !== 'undefined'
|
||||
? this.rawOptions[optionName]
|
||||
: option.default;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2,21 +2,44 @@ import axios from 'axios';
|
||||
|
||||
import { SQUADJS_VERSION, COPYRIGHT_MESSAGE } from './constants.js';
|
||||
|
||||
export default async function () {
|
||||
const { data } = await axios.get(
|
||||
'https://raw.githubusercontent.com/Thomas-Smyth/SquadJS/master/package.json'
|
||||
);
|
||||
function versionOutOfDate(current, latest) {
|
||||
const cMatch = current.match(/([0-9]+)\.([0-9]+)\.([0-9]+)(?:-beta([0-9]*))?/);
|
||||
const lMatch = latest.match(/([0-9]+)\.([0-9]+)\.([0-9]+)(?:-beta([0-9]*))?/);
|
||||
|
||||
const cMatch = SQUADJS_VERSION.match(/([0-9]+)\.([0-9]+)\.([0-9]+)/).shift();
|
||||
const lMatch = data.version.match(/([0-9]+)\.([0-9]+)\.([0-9]+)/).shift();
|
||||
cMatch.shift();
|
||||
lMatch.shift();
|
||||
|
||||
const [cMajor, cMinor, cPatch] = cMatch;
|
||||
const [lMajor, lMinor, lPatch] = lMatch;
|
||||
const [cMajor, cMinor, cPatch, cBetaVersion] = cMatch;
|
||||
const [lMajor, lMinor, lPatch, lBetaVersion] = lMatch;
|
||||
|
||||
const outdatedVersion =
|
||||
return (
|
||||
cMajor < lMajor ||
|
||||
(cMajor === lMajor && cMinor < lMinor) ||
|
||||
(cMajor === lMajor && cMinor === lMinor && cPatch < lPatch);
|
||||
(cMajor === lMajor && cMinor === lMinor && cPatch < lPatch) ||
|
||||
(cBetaVersion &&
|
||||
lBetaVersion &&
|
||||
cMajor === lMajor &&
|
||||
cMinor === lMinor &&
|
||||
cPatch === lPatch &&
|
||||
cBetaVersion < lBetaVersion)
|
||||
);
|
||||
}
|
||||
|
||||
export default async function () {
|
||||
const { data: masterData } = await axios.get(
|
||||
`https://raw.githubusercontent.com/Thomas-Smyth/SquadJS/master/package.json`
|
||||
);
|
||||
|
||||
const { data: betaData } = await axios.get(
|
||||
`https://raw.githubusercontent.com/Thomas-Smyth/SquadJS/beta/package.json`
|
||||
);
|
||||
|
||||
const branch = SQUADJS_VERSION.includes('beta') ? 'beta' : 'master';
|
||||
const outdated =
|
||||
(branch === 'master' && versionOutOfDate(SQUADJS_VERSION, masterData.version)) ||
|
||||
(branch === 'beta' &&
|
||||
(versionOutOfDate(SQUADJS_VERSION, masterData.version) ||
|
||||
versionOutOfDate(SQUADJS_VERSION, betaData.version)));
|
||||
|
||||
console.log(
|
||||
`
|
||||
@ -31,9 +54,11 @@ export default async function () {
|
||||
${COPYRIGHT_MESSAGE}
|
||||
GitHub: https://github.com/Thomas-Smyth/SquadJS
|
||||
|
||||
Latest Version: ${data.version}, Installed Version: ${SQUADJS_VERSION},
|
||||
Latest Version: ${
|
||||
branch === 'master' ? masterData.version : betaData.version
|
||||
}, Installed Version: ${SQUADJS_VERSION},
|
||||
${
|
||||
outdatedVersion
|
||||
outdated
|
||||
? 'Your SquadJS version is outdated, please consider updating.'
|
||||
: 'Your SquadJS version is up to date.'
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user