EZPPLauncher/electron/updateCheck.js

31 lines
865 B
JavaScript
Raw Normal View History

2024-01-19 14:04:58 +00:00
const semver = require("semver");
const { appVersion } = require("./appInfo");
2024-01-22 11:37:29 +00:00
const repoApiUrl =
2024-01-19 14:04:58 +00:00
"https://git.ez-pp.farm/api/v1/repos/EZPPFarm/EZPPLauncher/releases?limit=1";
2024-01-22 11:37:29 +00:00
const releasesUrl =
"https://git.ez-pp.farm/EZPPFarm/EZPPLauncher/releases/latest";
2024-01-19 14:04:58 +00:00
module.exports = {
updateAvailable: async () => {
try {
2024-07-17 08:24:07 +00:00
const latestRelease = await fetch(repoApiUrl, {
headers: {
"User-Agent":
"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/128.0.0.0 Safari/537.36 Edg/128.0.0.0",
},
});
2024-01-19 14:04:58 +00:00
const json = await latestRelease.json();
if (json.length <= 0) return false;
2024-01-19 15:24:39 +00:00
return {
update: semver.lt(appVersion, json[0].tag_name),
release: json[0],
};
2024-01-19 14:04:58 +00:00
} catch (err) {
2024-01-19 15:24:39 +00:00
return { update: false };
2024-01-19 14:04:58 +00:00
}
},
2024-01-22 11:37:29 +00:00
releasesUrl,
2024-01-19 14:04:58 +00:00
};