jormungandr-bite/packages/client/src/scripts/is-update-available.ts
2023-11-29 17:59:47 +01:00

16 lines
503 B
TypeScript

import { version } from "@/config.js";
import * as os from "@/os.js";
type LatestVersionResponse = {
tag_name?: string;
};
export async function isUpdateAvailable(): Promise<boolean> {
if (version.includes('-dev-')) return false;
return os.api("latest-version").then((res: LatestVersionResponse) => {
if (!res?.tag_name) return false;
const tag = res.tag_name as string;
return (version.includes('-pre') && !tag.includes('-pre')) || tag > `v${version}`;
});
}