Update index.js

This commit is contained in:
Troplo 2022-07-29 22:53:31 +10:00
parent 4936f0851f
commit 9f3ff615bf

View file

@ -12,26 +12,31 @@ const { execSync } = require('child_process');
console.log("Troplo/Colubrina CLI") console.log("Troplo/Colubrina CLI")
console.log("Colubrina version", require("../frontend/package.json").version) console.log("Colubrina version", require("../frontend/package.json").version)
async function checkForUpdates() { async function checkForUpdates() {
await axios if (!process.argv.includes("--skip-update")) {
.get("https://services.troplo.com/api/v1/state", { await axios
headers: { .get("https://services.troplo.com/api/v1/state", {
"X-Troplo-Project": "colubrina" headers: {
}, "X-Troplo-Project": "colubrina"
timeout: 800 },
}) timeout: 1000
.then((res) => { })
if (require("frontend/package.json").version !== res.data.latestVersion) { .then((res) => {
console.log("A new version of Colubrina is available!") if (require("../frontend/package.json").version !== res.data.latestVersion) {
console.log("Latest version:", res.data.latestVersion) console.log("A new version of Colubrina is available!")
} else { console.log("Latest version:", res.data.latestVersion)
console.log("Colubrina is up to date.") } else {
} console.log("Colubrina is up to date.")
}) }
.catch(() => { })
console.log( .catch((e) => {
"Failed to check for updates, ensure you are connected to the internet, and services.troplo.com is whitelisted behind any potential firewalls." console.log(e)
) console.log(
}) "Failed to check for updates, ensure you are connected to the internet, and services.troplo.com is whitelisted behind any potential firewalls."
)
})
} else {
console.log("Skipping update check")
}
} }
let state = { let state = {
db: { db: {