EZPPLauncher/electron/updateCheck.js

26 lines
659 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-01-22 11:37:29 +00:00
const latestRelease = await fetch(repoApiUrl);
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
};