• Checks for updates by comparing the current version with the latest GitHub release. Fetches release information from GitHub API and compares version numbers to determine availability.

    Returns Promise<UpdateInfo>

    A promise resolving to an UpdateInfo object.

    export async function checkForUpdates(): Promise<UpdateInfo> {
    console.debug("[AppVersion] Checking for app updates...");

    try {
    const response = await fetch(
    "https://api.github.com/repos/RLAlpha49/KenmeiToAnilist/releases/latest",
    );

    if (!response.ok) {
    console.warn(
    `[AppVersion] ⚠️ Failed to fetch latest release: HTTP ${response.status}`,
    );
    return {
    hasUpdate: false,
    latestVersion: "",
    releaseUrl: "",
    };
    }

    const data = await response.json();
    const latestVersion = data.tag_name?.replace(/^v/, "") || "";
    const currentVersion = getAppVersion();

    // Compare semantic versions: returns > 0 if latest is newer
    const hasUpdate =
    latestVersion &&
    currentVersion &&
    compareVersions(latestVersion, currentVersion) > 0;

    if (hasUpdate) {
    console.info(
    `[AppVersion] 🆕 Update available: ${currentVersion}${latestVersion}`,
    );
    } else {
    console.debug(
    `[AppVersion] ✅ App is up to date (current: ${currentVersion}, latest: ${latestVersion})`,
    );
    }

    return {
    hasUpdate,
    latestVersion,
    releaseUrl: data.html_url || "",
    };
    } catch (error) {
    console.error("[AppVersion] ❌ Error checking for updates:", error);
    return {
    hasUpdate: false,
    latestVersion: "",
    releaseUrl: "",
    };
    }
    }