From 7d3493ff0c8f202949a1a05e4b178da40122121a Mon Sep 17 00:00:00 2001 From: Hirzi Date: Fri, 1 Nov 2024 12:39:42 +0700 Subject: [PATCH] feat: update checker --- index.js | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/index.js b/index.js index c55b81f..615f8a3 100644 --- a/index.js +++ b/index.js @@ -26,6 +26,16 @@ console.log( ` \n \n${package.description}\n ` ); +axios.get("https://raw.githubusercontent.com/HirziDevs/PteroStats/refs/heads/main/package.json").then(response => { + if (response.data && response.data.version !== package.version) console.log( + cliColor.yellowBright(`+============================================================+\n`) + + ` Update available: ${package.version} → ${cliColor.green(response.data.version)}\n` + + ` Download at ${cliColor.blueBright("https://ps.znproject.my.id/download")} to update.\n` + + cliColor.redBright(` Make sure to backup ${cliColor.blueBright("config.yml")} and ${cliColor.blueBright(".env")} before updating.\n`) + + cliColor.yellowBright(`+============================================================+`) + ) +}).catch(error => console.log(`${cliColor.cyanBright("[PteroStats]")} ${cliColor.redBright("Failed to check for updates.")}`)); + if (!fs.existsSync(".env") || !fs.existsSync(".setup-complete")) return require("./handlers/setup.js")(); process.on('uncaughtException', (error) => errorLogging(error))