// Modules
const endpoint = require("@runkit/runkit/json-endpoint/1.0.0");
const fetch = require("node-fetch");
// Configurable variables
const appRepo = "SpacingBat3/electron-discord-webapp"
const badgeName = "Unofficial"
const debHost = "https://download.tuxfamily.org/"
const debRepo = "webcordapt"
// Other variable declarations
const debDataUrl = debHost+debRepo+"/debian/dists/buster/main/binary-amd64/Packages"
const debData = await (await fetch(debDataUrl)).text();
const debVer = 'v'+(debData.split(/\n/)[1].split(": ")[1]); // Line 2, value
const appTagURL = 'https://api.github.com/repos/'+appRepo+'/releases/latest'
const appTag = (await (await fetch(appTagURL)).json()).tag_name
const isSameVersion = (appTag === debVer);
let stateColor;
// Code + debug info
console.log("Debian: "+debVer,"Github: "+appTag);
console.log("Is same version? "+isSameVersion);
isSameVersion ? stateColor="purple" : stateColor="yellow";
const badge = {
"subject": badgeName,
"status": debVer,
"color": stateColor
}
console.log("Badge object:",badge)
endpoint(module.exports, () => {
return badge;
});