Skip to content

Commit

Permalink
chore: update update-informer to 1.0 (vercel#4867)
Browse files Browse the repository at this point in the history
  • Loading branch information
mgrachev authored and wolfworldwidedigital committed May 10, 2023
1 parent 422feeb commit a5ee709
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 15 deletions.
42 changes: 35 additions & 7 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion crates/turbo-updater/Cargo.toml
Expand Up @@ -19,4 +19,4 @@ reqwest = { workspace = true, features = ["json", "blocking"] }
semver = { workspace = true }
serde = { workspace = true, features = ["derive"] }
thiserror = { workspace = true }
update-informer = { git = "https://github.com/mgrachev/update-informer", rev = "b7a415ac2276e857167b9fe8282044f93155878a", default_features = false }
update-informer = { version = "1.0", default_features = false }
14 changes: 7 additions & 7 deletions crates/turbo-updater/src/lib.rs
Expand Up @@ -5,7 +5,7 @@ use semver::Version as SemVerVersion;
use serde::Deserialize;
use thiserror::Error as ThisError;
use update_informer::{
http_client::{HttpClient, SendRequest},
http_client::{GenericHttpClient, HeaderMap, HttpClient},
Check, Package, Registry, Result as UpdateResult,
};

Expand Down Expand Up @@ -51,8 +51,8 @@ struct NPMRegistry;

impl Registry for NPMRegistry {
const NAME: &'static str = "npm-registry";
fn get_latest_version<T: SendRequest>(
http: HttpClient<T>,
fn get_latest_version<T: HttpClient>(
http: GenericHttpClient<T>,
pkg: &Package,
) -> UpdateResult<Option<String>> {
// determine tag to request
Expand All @@ -76,19 +76,19 @@ impl Registry for NPMRegistry {
// Vendored here until update-informer allows us to control tls implementation
pub struct ReqwestHttpClient;

impl SendRequest for ReqwestHttpClient {
impl HttpClient for ReqwestHttpClient {
fn get<T: serde::de::DeserializeOwned>(
url: &str,
timeout: Duration,
headers: Option<(&str, &str)>,
headers: HeaderMap,
) -> Result<T, Box<dyn std::error::Error>> {
let mut req = reqwest::blocking::Client::builder()
.timeout(timeout)
.build()?
.get(url);

if let Some((key, val)) = headers {
req = req.header(key, val)
for (key, value) in headers {
req = req.header(key, value);
}

let json = req.send()?.json()?;
Expand Down

0 comments on commit a5ee709

Please sign in to comment.