Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: update update-informer to 1.0 #4867

Merged
merged 2 commits into from May 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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