From 8652be8b87d64526ba44c99c90173a970e29cb8e Mon Sep 17 00:00:00 2001 From: oiupoyt Date: Sat, 10 Oct 2026 18:11:33 +0530 Subject: [PATCH] feat(updater): switch auto-updater and documentation to Forgejo releases API --- Cargo.toml | 4 ++-- README.md | 2 +- packages/oneclient_app/src/constants.rs | 8 +++---- packages/oneclient_app/src/updater.rs | 30 ++++++++++++++----------- 4 files changed, 24 insertions(+), 20 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index b2d91b3c..853b8e2f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -9,12 +9,12 @@ authors = [ "Polyfrost", "Polyfrost Contributors", ] -documentation = "https://github.com/oiupoyt/OneLauncher-Cracked" +documentation = "https://git.oiupoyt.space/oiupoyt/OneLauncher-Cracked" edition = "2024" homepage = "https://polyfrost.org/projects/oneclient" license = "GPL-3.0-only" readme = "README.md" -repository = "https://github.com/oiupoyt/OneLauncher-Cracked" +repository = "https://git.oiupoyt.space/oiupoyt/OneLauncher-Cracked" rust-version = "1.97" version = "2.5.1-c3" diff --git a/README.md b/README.md index ed764dc0..bb95cec8 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ forked from [OneLauncher](https://github.com/Polyfrost/OneLauncher) allowing for -## download from [**Releases Page**](https://github.com/oiupoyt/OneLauncher-Cracked/releases). +## download from [**Releases Page**](https://git.oiupoyt.space/oiupoyt/OneLauncher-Cracked/releases). yes the actual client performs normally aswell > [!WARNING] diff --git a/packages/oneclient_app/src/constants.rs b/packages/oneclient_app/src/constants.rs index 6fa12a2a..5d1ef894 100644 --- a/packages/oneclient_app/src/constants.rs +++ b/packages/oneclient_app/src/constants.rs @@ -1,7 +1,7 @@ pub const WINDOW_APP_ID: &str = "oneclient_app"; pub const WINDOW_TITLE: &str = "OneClient"; -pub const GITHUB_REPO: &str = "oiupoyt/OneLauncher-Cracked"; -pub const GITHUB_API_LATEST_RELEASE: &str = - "https://api.github.com/repos/oiupoyt/OneLauncher-Cracked/releases/latest"; -pub const RELEASES_URL: &str = "https://github.com/oiupoyt/OneLauncher-Cracked/releases/latest"; \ No newline at end of file +pub const FORGEJO_REPO: &str = "oiupoyt/OneLauncher-Cracked"; +pub const FORGEJO_API_LATEST_RELEASE: &str = + "https://git.oiupoyt.space/api/v1/repos/oiupoyt/OneLauncher-Cracked/releases/latest"; +pub const RELEASES_URL: &str = "https://git.oiupoyt.space/oiupoyt/OneLauncher-Cracked/releases"; \ No newline at end of file diff --git a/packages/oneclient_app/src/updater.rs b/packages/oneclient_app/src/updater.rs index 1e16a71a..46d8bc5b 100644 --- a/packages/oneclient_app/src/updater.rs +++ b/packages/oneclient_app/src/updater.rs @@ -3,7 +3,7 @@ use std::path::PathBuf; use oneclient_events::{Choice, EventBus, Prompt}; use uuid::Uuid; -use crate::constants::GITHUB_API_LATEST_RELEASE; +use crate::constants::FORGEJO_API_LATEST_RELEASE; pub const UPDATE_CHOICE_INSTALL: &str = "update.install"; @@ -66,24 +66,28 @@ impl CrackedVersion { } #[derive(Debug, Clone, serde::Deserialize)] -pub struct GithubRelease { +pub struct ForgejoRelease { pub tag_name: String, pub name: Option, pub body: Option, pub html_url: String, #[serde(default)] - pub assets: Vec, + pub assets: Vec, } +pub type GithubRelease = ForgejoRelease; + #[derive(Debug, Clone, serde::Deserialize)] -pub struct GithubReleaseAsset { +pub struct ForgejoReleaseAsset { pub name: String, pub size: u64, pub browser_download_url: String, } -impl GithubRelease { - pub fn find_installer_asset(&self) -> Option<&GithubReleaseAsset> { +pub type GithubReleaseAsset = ForgejoReleaseAsset; + +impl ForgejoRelease { + pub fn find_installer_asset(&self) -> Option<&ForgejoReleaseAsset> { #[cfg(target_os = "windows")] { self.assets.iter().find(|a| a.name.ends_with("_x64-setup.exe") || a.name.ends_with("-setup.exe") || a.name.ends_with(".exe")) @@ -163,7 +167,7 @@ async fn run_simulated_update() -> anyhow::Result<()> { } async fn run_check(auto_install: bool, events: EventBus) -> anyhow::Result<()> { - let Some(release) = check_for_github_update().await? else { + let Some(release) = check_for_forgejo_update().await? else { tracing::info!("no update available"); return Ok(()); }; @@ -187,7 +191,7 @@ async fn run_check(auto_install: bool, events: EventBus) -> anyhow::Result<()> { return Ok(()); } - download_and_install_github(release, events).await + download_and_install_forgejo(release, events).await } fn can_self_update() -> bool { @@ -215,23 +219,23 @@ fn can_self_update() -> bool { } } -async fn check_for_github_update() -> anyhow::Result> { +async fn check_for_forgejo_update() -> anyhow::Result> { let client = reqwest::Client::builder() .user_agent("OneLauncher-Cracked-Updater") .timeout(std::time::Duration::from_secs(10)) .build()?; let resp = client - .get(GITHUB_API_LATEST_RELEASE) + .get(FORGEJO_API_LATEST_RELEASE) .send() .await?; if !resp.status().is_success() { - tracing::debug!("GitHub releases API returned status: {}", resp.status()); + tracing::debug!("Forgejo releases API returned status: {}", resp.status()); return Ok(None); } - let release: GithubRelease = resp.json().await?; + let release: ForgejoRelease = resp.json().await?; let current_str = env!("CARGO_PKG_VERSION"); let current_ver = CrackedVersion::parse(current_str).unwrap_or(CrackedVersion { @@ -253,7 +257,7 @@ async fn check_for_github_update() -> anyhow::Result> { } } -async fn download_and_install_github(release: GithubRelease, events: EventBus) -> anyhow::Result<()> { +async fn download_and_install_forgejo(release: ForgejoRelease, events: EventBus) -> anyhow::Result<()> { let Some(asset) = release.find_installer_asset() else { events .notify("Update available")