Skip to content

Commit

Permalink
feat: make github optional
Browse files Browse the repository at this point in the history
  • Loading branch information
mistydemeo committed Jan 23, 2024
1 parent d671f02 commit 4819fdb
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
4 changes: 3 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,18 @@ name = "axoupdater"
path = "src/lib.rs"

[features]
default = ["axo_releases", "github_releases"]
standalone = ["axocli"]
axo_releases = ["gazenot", "tokio"]
github_releases = ["reqwest"]

[dependencies]
axoasset = { version = "0.6.1", default-features = false, features = ["json-serde"]}
axocli = { version = "0.1.1", optional = true }
axoprocess = "0.1.0"
camino = { version = "1.1.6", features = ["serde1"] }
homedir = "0.2.1"
reqwest = { version = "0.11", default-features = false, features = ["blocking", "default-tls", "json"] }
reqwest = { version = "0.11", default-features = false, features = ["blocking", "default-tls", "json"], optional = true }
serde = "1.0.195"
temp-dir = "0.1.12"

Expand Down
9 changes: 9 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ use camino::Utf8PathBuf;
#[cfg(feature = "gazenot")]
use gazenot::{error::GazenotError, Gazenot};
use miette::Diagnostic;
#[cfg(feature = "github_releases")]
use reqwest::{
self,
header::{ACCEPT, USER_AGENT},
Expand Down Expand Up @@ -321,6 +322,7 @@ pub struct InstallReceipt {
pub version: String,
}

#[cfg(feature = "github_releases")]
pub fn get_github_releases(name: &String, owner: &String) -> AxoupdateResult<Vec<Release>> {
let client = reqwest::blocking::Client::new();
let resp: Vec<Release> = client
Expand Down Expand Up @@ -365,7 +367,14 @@ pub fn get_latest_stable_release(
release_type: &ReleaseSourceType,
) -> AxoupdateResult<Option<Release>> {
let releases = match release_type {
#[cfg(feature = "github_releases")]
ReleaseSourceType::GitHub => get_github_releases(name, owner)?,
#[cfg(not(feature = "github_releases"))]
ReleaseSourceType::GitHub => {
return Err(AxoupdateError::BackendDisabled {
backend: "github".to_owned(),
})
}
#[cfg(feature = "gazenot")]
ReleaseSourceType::Axo => get_axo_releases(name, owner)?,
#[cfg(not(feature = "gazenot"))]
Expand Down

0 comments on commit 4819fdb

Please sign in to comment.