UNPKG

vanzy-protect

Version:

Epic Obfuscator Yeahhh

41 lines (40 loc) 1.76 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.checkVersion = exports.printVersionInfo = void 0; const NpmApi = require("npm-api"); const kolorist = require("kolorist"); const Cache = require("node-cache"); const fill_1 = require("../util/fill"); const calcLength_1 = require("../util/calcLength"); const constants_1 = require("./constants"); function printVersionInfo(version) { const string = `There is an ${kolorist.red('update')} avalible Version ${kolorist.yellow(version[0])} --> ${kolorist.bold(kolorist.green(version[1]))} ${kolorist.magenta(kolorist.bold('How to install:'))} Simply run ${kolorist.inverse('npm install -g ' + kolorist.lightBlue('vanzy-protect'))}`; var maxL = 0; string.split('\n').forEach((i) => { if (i.length > maxL) maxL = i.length; }); maxL += 4; const top = `┏${(0, fill_1.fill)(maxL, '━')}┓`; const bottom = `┗${(0, fill_1.fill)(maxL, '━')}┛`; console.log(top); string.split('\n').forEach((i) => { console.log('┃', i + (0, fill_1.fill)(maxL - (0, calcLength_1.calcLength)(i) - 2, ' '), '┃'); }); console.log(bottom); } exports.printVersionInfo = printVersionInfo; async function checkVersion() { const cache = new Cache(); const lc = cache.get('checked_for_update'); if (lc) { return { currentVersion: constants_1.VERSION, latestVersion: constants_1.VERSION }; } const currentVersion = constants_1.VERSION; const npm = new NpmApi(); const repo = npm.repo('vanzy-protect'); const _package = await repo.package(); const latestVersion = _package.version; cache.set('checked_for_update', true, 1800); return { currentVersion, latestVersion }; } exports.checkVersion = checkVersion;