From e0bb7a1295cd2ee6e29995d599c4f1dd691f5bce Mon Sep 17 00:00:00 2001 From: Kath <55346310+Kathund@users.noreply.github.com> Date: Sun, 18 Feb 2024 19:18:24 +0800 Subject: [PATCH] Auto Update on by default --- src/Client.js | 8 ++++---- src/Private/updater.js | 18 ++---------------- src/Private/validate.js | 2 +- 3 files changed, 7 insertions(+), 21 deletions(-) diff --git a/src/Client.js b/src/Client.js index ab6d830c..6d699209 100644 --- a/src/Client.js +++ b/src/Client.js @@ -42,10 +42,10 @@ class Client extends EventEmitter { args ); }; + } - if (this.options.checkForUpdates) { - updater.checkForUpdates(); - } + if (this.options.checkForUpdates) { + updater.checkForUpdates(); } /** * All cache entries @@ -357,7 +357,7 @@ class Client extends EventEmitter { * @prop {number} [cacheSize=-1] The amount how many results will be cached. (`-1` for infinity) * @prop {boolean} [silent=false] Don't automatically put warnings into console. * @prop {object} [headers={}] Extra Headers ( like User-Agent ) to add to request. - * @prop {boolean} [checkForUpdates=false] Enable/Disable check for new version of hypixel-api-reborn. + * @prop {boolean} [checkForUpdates=true] Enable/Disable check for new version of hypixel-api-reborn. */ const defaultCache = require('./Private/defaultCache.js'); /** diff --git a/src/Private/updater.js b/src/Private/updater.js index 18e7bedf..dcfba673 100644 --- a/src/Private/updater.js +++ b/src/Private/updater.js @@ -1,5 +1,5 @@ -/* eslint-disable no-console */ /* eslint-disable require-jsdoc */ +/* eslint-disable no-console */ const fetch = require('node-fetch'); const Errors = require('../Errors'); class Updater { @@ -11,23 +11,9 @@ class Updater { const latestVersion = metadata['dist-tags'].latest; const compare = this.compare(currentVersion, latestVersion); if (compare === -1) { - this.notify(latestVersion); + console.log(`New version of hypixel-api-reborn is available! Current version: ${currentVersion}, Latest version: ${latestVersion}`); } } - notify(newVersion) { - console.log(` - - New version of hypixel-api-reborn is available! - - v${newVersion} - Changelog: https://github.com/Hypixel-API-Reborn/hypixel-api-reborn/releases/tag/${newVersion} - - \x1b[33mnpm i hypixel-api-reborn@${newVersion}\x1b[0m - or - \x1b[33myarn add hypixel-api-reborn@${newVersion}\x1b[0m - - `); - } compare(a, b) { const pa = a.split('.'); const pb = b.split('.'); diff --git a/src/Private/validate.js b/src/Private/validate.js index 71c25dca..cacd48d1 100644 --- a/src/Private/validate.js +++ b/src/Private/validate.js @@ -38,7 +38,7 @@ class Validation { syncWithHeaders: !!options.syncWithHeaders, headers: options.headers || {}, silent: !!options.silent, - checkForUpdates: options.checkForUpdates || false + checkForUpdates: options.checkForUpdates || true }; }