SquadJS/squad-server/utils/print-logo.js

68 lines
2.2 KiB
JavaScript
Raw Normal View History

2020-10-22 17:30:43 -05:00
import axios from 'axios';
2020-10-05 12:52:01 -05:00
import { SQUADJS_VERSION, COPYRIGHT_MESSAGE } from './constants.js';
2020-05-15 12:42:39 -05:00
2020-12-08 11:16:32 -06:00
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]*))?/);
2020-10-22 17:30:43 -05:00
2020-12-08 11:16:32 -06:00
cMatch.shift();
lMatch.shift();
2020-10-22 17:30:43 -05:00
2020-12-08 11:16:32 -06:00
const [cMajor, cMinor, cPatch, cBetaVersion] = cMatch;
const [lMajor, lMinor, lPatch, lBetaVersion] = lMatch;
2020-10-22 17:30:43 -05:00
2020-12-08 11:16:32 -06:00
return (
2020-10-22 17:30:43 -05:00
cMajor < lMajor ||
(cMajor === lMajor && cMinor < lMinor) ||
2020-12-08 11:16:32 -06:00
(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)));
2020-10-22 17:30:43 -05:00
console.log(
`
2020-08-26 11:24:07 -05:00
_____ ____ _ _ _____ \x1b[33m_\x1b[0m
/ ____|/ __ \\| | | | /\\ | __ \\ \x1b[33m(_)\x1b[0m
| (___ | | | | | | | / \\ | | | | \x1b[33m_ ___\x1b[0m
\\___ \\| | | | | | |/ /\\ \\ | | | |\x1b[33m| / __|\x1b[0m
____) | |__| | |__| / ____ \\| |__| |\x1b[33m| \\__ \\\x1b[0m
|_____/ \\___\\_\\\\____/_/ \\_\\_____\x1b[33m(_) |___/\x1b[0m
\x1b[33m_/ |\x1b[0m
\x1b[33m|__/\x1b[0m
2020-05-15 12:42:39 -05:00
${COPYRIGHT_MESSAGE}
GitHub: https://github.com/Thomas-Smyth/SquadJS
2020-12-08 11:16:32 -06:00
Latest Version: ${
branch === 'master' ? masterData.version : betaData.version
}, Installed Version: ${SQUADJS_VERSION},
2020-10-22 17:30:43 -05:00
${
2020-12-08 11:16:32 -06:00
outdated
2020-10-22 17:30:43 -05:00
? 'Your SquadJS version is outdated, please consider updating.'
: 'Your SquadJS version is up to date.'
}
`
);
2020-05-15 12:42:39 -05:00
}