mirror of
https://github.com/Drop-OSS/drop.git
synced 2026-07-25 01:13:39 +10:00
fix: check update not using drop's correct version
This commit is contained in:
@@ -23,11 +23,28 @@ export default defineTask<TaskReturn>({
|
|||||||
async run() {
|
async run() {
|
||||||
if (systemConfig.shouldCheckForUpdates()) {
|
if (systemConfig.shouldCheckForUpdates()) {
|
||||||
console.log("[Task check:update]: Checking for update");
|
console.log("[Task check:update]: Checking for update");
|
||||||
|
|
||||||
|
const currVerStr = systemConfig.getDropVersion();
|
||||||
|
const currVer = semver.coerce(currVerStr);
|
||||||
|
if (currVer === null) {
|
||||||
|
const msg = "Drop provided a invalid semver tag";
|
||||||
|
console.log("[Task check:update]:", msg);
|
||||||
|
return {
|
||||||
|
result: {
|
||||||
|
success: false,
|
||||||
|
error: {
|
||||||
|
message: msg,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const response = await fetch(
|
const response = await fetch(
|
||||||
"https://api.github.com/repos/Drop-OSS/drop/releases/latest",
|
"https://api.github.com/repos/Drop-OSS/drop/releases/latest",
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// if response failed somehow
|
||||||
if (!response.ok) {
|
if (!response.ok) {
|
||||||
console.log("[Task check:update]: Failed to check for update", {
|
console.log("[Task check:update]: Failed to check for update", {
|
||||||
status: response.status,
|
status: response.status,
|
||||||
@@ -44,6 +61,7 @@ export default defineTask<TaskReturn>({
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// parse and validate response
|
||||||
const resJson = await response.json();
|
const resJson = await response.json();
|
||||||
const body = latestRelease(resJson);
|
const body = latestRelease(resJson);
|
||||||
if (body instanceof type.errors) {
|
if (body instanceof type.errors) {
|
||||||
@@ -59,11 +77,8 @@ export default defineTask<TaskReturn>({
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
// const currVerStr = systemConfig.getDropVersion()
|
// parse remote version
|
||||||
const currVerStr = "v0.1";
|
|
||||||
|
|
||||||
const latestVer = semver.coerce(body.tag_name);
|
const latestVer = semver.coerce(body.tag_name);
|
||||||
const currVer = semver.coerce(currVerStr);
|
|
||||||
if (latestVer === null) {
|
if (latestVer === null) {
|
||||||
const msg = "Github Api returned invalid semver tag";
|
const msg = "Github Api returned invalid semver tag";
|
||||||
console.log("[Task check:update]:", msg);
|
console.log("[Task check:update]:", msg);
|
||||||
@@ -75,19 +90,9 @@ export default defineTask<TaskReturn>({
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
} else if (currVer === null) {
|
|
||||||
const msg = "Drop provided a invalid semver tag";
|
|
||||||
console.log("[Task check:update]:", msg);
|
|
||||||
return {
|
|
||||||
result: {
|
|
||||||
success: false,
|
|
||||||
error: {
|
|
||||||
message: msg,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// check if is newer version
|
||||||
if (semver.gt(latestVer, currVer)) {
|
if (semver.gt(latestVer, currVer)) {
|
||||||
console.log("[Task check:update]: Update available");
|
console.log("[Task check:update]: Update available");
|
||||||
notificationSystem.pushAllAdmins({
|
notificationSystem.pushAllAdmins({
|
||||||
|
|||||||
Reference in New Issue
Block a user