Replace dep crates_io_api with in-house solution (#846)

It also uses `max_stable_version` in the json downloaded from https://crates.io/api/v1/crates/$name if possible, which is equivalent to the version shown on https://crates.io/crates/$name .

 - Add new feat `json` to `binstalk-downloader`
 - Impl new async fn `Response::json`
 - use `Response::json` in `GhApiClient` impl
 - Mark all err types in binstalk-downloader as `non_exhaustive`
 - Ret `remote::Error` in `remote::Certificate::{from_pem, from_der}` instead of `ReqwestError`.
 - Refactor `BinstallError`: Merge variant `Unzip`, `Reqwest` & `Http`
    into one variant `Download`.
 - Manually download and parse json from httos://crates.io/api/v1
 - Remove unused deps `crates_io_api`

Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
This commit is contained in:
Jiahao XU 2023-03-02 18:25:34 +11:00 committed by GitHub
parent c00d648dac
commit 8eee318ccd
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
17 changed files with 120 additions and 244 deletions

View file

@ -26,7 +26,6 @@ binstalk = { path = "../binstalk", version = "0.8.0", default-features = false }
binstalk-manifests = { path = "../binstalk-manifests", version = "0.3.0" }
clap = { version = "4.1.8", features = ["derive", "env"] }
compact_str = "0.7.0"
crates_io_api = { version = "0.8.1", default-features = false }
dirs = "4.0.0"
file-format = { version = "0.14.0", default-features = false }
fs-lock = { version = "0.1.0", path = "../fs-lock" }

View file

@ -22,7 +22,6 @@ use binstalk::{
},
};
use binstalk_manifests::cargo_toml_binstall::PkgOverride;
use crates_io_api::AsyncClient as CratesIoApiClient;
use file_format::FileFormat;
use log::LevelFilter;
use miette::{miette, Result, WrapErr};
@ -90,10 +89,6 @@ pub async fn install_crates(args: Args, jobserver_client: LazyJobserverClient) -
let gh_api_client = GhApiClient::new(client.clone(), args.github_token);
// Build crates.io api client
let crates_io_api_client =
CratesIoApiClient::with_http_client(client.get_inner().clone(), Duration::from_millis(100));
// Create binstall_opts
let binstall_opts = Arc::new(ops::Options {
no_symlinks: args.no_symlinks,
@ -113,7 +108,6 @@ pub async fn install_crates(args: Args, jobserver_client: LazyJobserverClient) -
temp_dir: temp_dir.path().to_owned(),
install_path,
client,
crates_io_api_client,
gh_api_client,
jobserver_client,
});