diff --git a/core/logger.js b/core/logger.js index 5c61c08..b20ddbe 100644 --- a/core/logger.js +++ b/core/logger.js @@ -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) { diff --git a/package.json b/package.json index b72d2a3..62ce28d 100644 --- a/package.json +++ b/package.json @@ -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 ", "license": "BSL-1.0", diff --git a/squad-server/factory.js b/squad-server/factory.js index 607b57a..55ec8e5 100644 --- a/squad-server/factory.js +++ b/squad-server/factory.js @@ -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 diff --git a/squad-server/plugins/auto-kick-unassigned.js b/squad-server/plugins/auto-kick-unassigned.js index b59d45f..74e25a5 100644 --- a/squad-server/plugins/auto-kick-unassigned.js +++ b/squad-server/plugins/auto-kick-unassigned.js @@ -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 ( diff --git a/squad-server/plugins/base-plugin.js b/squad-server/plugins/base-plugin.js index 42fc526..4a8e58c 100644 --- a/squad-server/plugins/base-plugin.js +++ b/squad-server/plugins/base-plugin.js @@ -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; } } } diff --git a/squad-server/utils/print-logo.js b/squad-server/utils/print-logo.js index a6c447a..731e338 100644 --- a/squad-server/utils/print-logo.js +++ b/squad-server/utils/print-logo.js @@ -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.' }