Commit graph

496 commits

Author SHA1 Message Date
Jiahao XU
3b1a7f2c78
Optimize extract_zip: Use async_zip::read::stream::ZipFileReader to avoid temporary file (#590)
* Add new dep async_zip v0.0.9 to binstalk-downloader
   with features "gzip", "zstd", "xz", "bzip2", "tokio".
* Refactor: Simplify `async_extracter::extract_*` API
* Refactor: Create newtype wrapper of `ZipError`
   so that the zip can be upgraded without affecting API of this crate.
* Enable feature fs of dep tokio in binstalk-downloader
* Rewrite `extract_zip` to use `async_zip::read::stream::ZipFileReader`
   which avoids writing the zip file to a temporary file and then read it
   back into memory.
* Refactor: Impl new fn `await_on_option` and use it
* Optimize `tokio::select!`: Make them biased and check for cancellation first
  to make cancellation takes effect ASAP.
* Rm unused dep zip from binstalk-downloader

Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
2022-12-12 00:44:34 +00:00
dependabot[bot]
e6f969245a
Bump zstd from 0.12.0+zstd.1.5.2 to 0.12.1+zstd.1.5.2 (#595)
Bumps [zstd](https://github.com/gyscos/zstd-rs) from 0.12.0+zstd.1.5.2 to 0.12.1+zstd.1.5.2.
- [Release notes](https://github.com/gyscos/zstd-rs/releases)
- [Commits](https://github.com/gyscos/zstd-rs/compare/v0.12.0...v0.12.1)

---
updated-dependencies:
- dependency-name: zstd
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-12-11 14:47:23 +00:00
Jiahao XU
ec026c1711
Optimize CratesToml::collect_into_crates_versions (#589)
Avoid calling `CrateVersionSource::from_str` which parses the source and
allocates `Url`.

Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
2022-12-04 01:46:30 +00:00
Jiahao XU
23a5937aff
Optimization: Rewrite Download::and_visit_tar to use tokio-tar (#587)
* Add new dep tokio-tar v0.3.0 to binstalk-downloader
* Add new dep tokio-util v0.7.4 with feat io to binstalk-downloader
* Add dep async-trait v0.1.59 to binstalk-downloader
* Add new dep async-compression v0.3.15 to binstalk-downloader
   with features "gzip", "zstd", "xz", "bzip2", "tokio".
* Rewrite `Download::and_visit_tar` to use `tokio-tar`
   to avoid the cumbersome `block_in_place`.
* Apply temporary workaround: Rm use of let-else in mod visitor

Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
2022-12-04 14:31:34 +13:00
Jiahao XU
39f175be04
Feature: Check for installed crates in cargo_install_v1_manifest (#582)
* Add & Impl new fn `CratesToml::collect_into_crates_versions`
   to iterate over crates listed in cargo_crates_v1, accessing their names
   and versions.
* Re-export `CompactString`, `Version` & `Url` in binstalk-manifests
   for convenience
* Fix `CratesToml::load_from_path`: Wrap `File` in `FileLock::new_shared`
   to avoid concurrent write while reading the file.
* Filter out installed crates in cargo_install_v1_metadata
* Make match in `filter_out_installed_crates` more explicit
* Add new test `cargo_crates_v1::test::test_loading`
* Optimize `CratesToml`: Use `Vec` instead of `BTreeMap`
  since we cannot simply call `BTreeMap::get` to find an entry for a crate
  anyway.
  This also accidentally fixed the CI.
* Impl new API `CratesToml::remove`
* Fix`CratesToml::append_to_path` by removing previous records of
   the crates that are just updated.

Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
2022-12-03 15:25:41 +00:00
Jiahao XU
887ebb6f6f
Fix BinstallError::CrateContext: Forward diagnostics of field CrateContextError::err (#586)
Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
2022-12-03 12:12:04 +00:00
Jiahao XU
a69db83aa6
Fix error reporting in main and move all arg validation into fn args::parse (#585)
* Fix reporting parsing error from `args::parse`
   Report it in `args::parse` by using `Args::command().error(...).exit()`
   instead of returning `BinstallError`.
* Rm unused variant `BinstallError::OverrideOptionUsedWithMultiInstall`
* Refactor: Move `strategies` validation into `args::parse`
* Rm unused variant `BinstallError::InvalidStrategies`
* Add new unit test `args::test::verify_cli`

Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
2022-12-03 11:57:50 +00:00
Jiahao XU
b564b8ac4e
Fix logging: Print error and continue on failure to flush logs (#584)
instead of exiting the entire process.

Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
2022-12-04 00:15:15 +13:00
Jiahao XU
8a5577297e
Optimize BinstallError: Reduce size from 40B to 32B (#581)
* Optimize `BinstallError::CratesIoApi`: Extract new type `errors::CratesIoApiError` and box it
   Also improve `<CratesIoApiError as Display>::fmt` impl.
* Optimize `BinstallError::SubProcess`: Use `Box<str>` instead of `String`
* Optimize `BinstallError::CargoManifest`: Box `CargoTomlError`
* Optimize `BinstallError::VersionParse`: Extract `VersionParseError` and box it
   Also improve `<VersionParseError as Display>::fmt` impl.
* Optimize `BinstallError::CrateContext`: Extract `CrateContextError` and box it in
* Optimize `install_from_source`: Only format `cmd` on err

Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
2022-12-01 20:05:00 +13:00
Jiahao XU
ab3e47c42b
Optimize Fetcher::find and fix quickinstall reporting (#579)
* Optimize `Fetcher::find`: Make it non-async to avoid boxing
   and return `AutoAbortJoinHandle<...>` instead.
   
   Since spawning a new task in tokio box the future anyway, boxing the
   returned future again in `Fetcher::find` merely adds unnecessary
   overheads.
* Optimize `QuickInstall::report`: Make it async fn instead of ret `JoinHandle`
   
   This provides several benefits:
    - On debug build, no task will be spawned
    - The calls to `self.stats_url()` can be evaluated in parallel.
    - The task now returns `()` so that the task spawned is smaller.
* Fix `QuickInstall::find`: `warn!` if quickinstall report fails

Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
2022-11-30 16:15:22 +13:00
Jiahao XU
ff737730f4
Optimize use of tokio::select!: Use biased selection (#580)
as there is no need to randomize the first one to be polled.

For `cancel_on_user_sig_term` and `StreamReadable::fill_buf`, the
cancellation future should always to be polled first so that user would
feel responsive.

Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
2022-11-30 16:05:52 +13:00
dependabot[bot]
af82f1021c
Bump async-trait from 0.1.58 to 0.1.59 (#578)
Bumps [async-trait](https://github.com/dtolnay/async-trait) from 0.1.58 to 0.1.59.
- [Release notes](https://github.com/dtolnay/async-trait/releases)
- [Commits](https://github.com/dtolnay/async-trait/compare/0.1.58...0.1.59)

---
updated-dependencies:
- dependency-name: async-trait
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-11-30 01:50:00 +00:00
dependabot[bot]
99548b1e50
Bump clap from 4.0.27 to 4.0.29 (#577)
Bumps [clap](https://github.com/clap-rs/clap) from 4.0.27 to 4.0.29.
- [Release notes](https://github.com/clap-rs/clap/releases)
- [Changelog](https://github.com/clap-rs/clap/blob/master/CHANGELOG.md)
- [Commits](https://github.com/clap-rs/clap/compare/v4.0.27...v4.0.29)

---
updated-dependencies:
- dependency-name: clap
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-11-30 01:35:11 +00:00
Jiahao XU
d63e001d6f
Fix panic in ui::confirm on I/O error (#576)
Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
2022-11-29 05:53:45 +00:00
Jiahao XU
d64710d3a6
Fix crates/bin/build.rs: Rerun build.rs if manifest.rc and windows.manifest changed (#575)
Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
2022-11-29 18:31:59 +13:00
Jiahao XU
6785d3ef82
Fix msrv: Bump to v1.65.0 (#574)
- bin and binstalk uses new let-else lang feature
 - dep zstd of binstalk-downloader just bumped its msrv to v1.64.0

Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
2022-11-29 17:18:28 +13:00
Jiahao XU
b5002de9c4
Return Future + 'static in GhCrateMeta::launch_baseline_find_tasks (#573)
So that the borrow checker know that `FuturesUnordered<F>` holds no
reference to any data and thus it can further optimize future returned
by `GhCrateMeta::find`.

Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
2022-11-29 16:26:54 +13:00
dependabot[bot]
30cc94b5bc
Bump serde from 1.0.147 to 1.0.148 (#572)
Bumps [serde](https://github.com/serde-rs/serde) from 1.0.147 to 1.0.148.
- [Release notes](https://github.com/serde-rs/serde/releases)
- [Commits](https://github.com/serde-rs/serde/compare/v1.0.147...v1.0.148)

---
updated-dependencies:
- dependency-name: serde
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-11-29 13:39:33 +11:00
dependabot[bot]
4b018cf90a
Bump clap from 4.0.26 to 4.0.27 (#571)
Bumps [clap](https://github.com/clap-rs/clap) from 4.0.26 to 4.0.27.
- [Release notes](https://github.com/clap-rs/clap/releases)
- [Changelog](https://github.com/clap-rs/clap/blob/master/CHANGELOG.md)
- [Commits](https://github.com/clap-rs/clap/compare/v4.0.26...v4.0.27)

---
updated-dependencies:
- dependency-name: clap
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-11-25 01:39:18 +00:00
dependabot[bot]
6c9d932b81
Bump flate2 from 1.0.24 to 1.0.25 (#570)
Bumps [flate2](https://github.com/rust-lang/flate2-rs) from 1.0.24 to 1.0.25.
- [Release notes](https://github.com/rust-lang/flate2-rs/releases)
- [Commits](https://github.com/rust-lang/flate2-rs/commits/1.0.25)

---
updated-dependencies:
- dependency-name: flate2
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-11-25 01:24:37 +00:00
dependabot[bot]
81bd1483a9
Bump zstd from 0.11.2+zstd.1.5.2 to 0.12.0+zstd.1.5.2 (#563)
* Bump zstd from 0.11.2+zstd.1.5.2 to 0.12.0+zstd.1.5.2

Bumps [zstd](https://github.com/gyscos/zstd-rs) from 0.11.2+zstd.1.5.2 to 0.12.0+zstd.1.5.2.
- [Release notes](https://github.com/gyscos/zstd-rs/releases)
- [Commits](https://github.com/gyscos/zstd-rs/commits)

---
updated-dependencies:
- dependency-name: zstd
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

* Update comment in `binstalk-downloader/Cargo.toml`

Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>

Signed-off-by: dependabot[bot] <support@github.com>
Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Jiahao XU <Jiahao_XU@outlook.com>
2022-11-24 13:22:27 +00:00
dependabot[bot]
0f21db4c49
Bump jobslot from 0.2.6 to 0.2.8 (#564)
Bumps [jobslot](https://github.com/cargo-bins/jobslot) from 0.2.6 to 0.2.8.
- [Release notes](https://github.com/cargo-bins/jobslot/releases)
- [Commits](https://github.com/cargo-bins/jobslot/compare/v0.2.6...v0.2.8)

---
updated-dependencies:
- dependency-name: jobslot
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-11-24 13:03:41 +00:00
dependabot[bot]
f71c3606f8
Bump miette from 5.4.1 to 5.5.0 (#565)
Bumps [miette](https://github.com/zkat/miette) from 5.4.1 to 5.5.0.
- [Release notes](https://github.com/zkat/miette/releases)
- [Changelog](https://github.com/zkat/miette/blob/main/CHANGELOG.md)
- [Commits](https://github.com/zkat/miette/compare/miette-derive-v5.4.1...miette-derive-v5.5.0)

---
updated-dependencies:
- dependency-name: miette
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-11-24 12:46:34 +00:00
github-actions[bot]
7544fde813
release: cargo-binstall v0.17.0 (#562)
chore: Release

Co-authored-by: github-actions <github-actions@github.com>
2022-11-23 01:18:44 +11:00
github-actions[bot]
5172bd46a0
release: binstalk v0.5.0 (#561)
chore: Release

Co-authored-by: github-actions <github-actions@github.com>
Co-authored-by: Jiahao XU <Jiahao_XU@outlook.com>
2022-11-22 11:24:54 +00:00
github-actions[bot]
d1b490468b
release: binstalk-downloader v0.1.0 (#559)
chore: Release

Co-authored-by: github-actions <github-actions@github.com>
Co-authored-by: Jiahao XU <Jiahao_XU@outlook.com>
2022-11-22 10:53:50 +00:00
github-actions[bot]
0084254c8c
release: binstalk-manifests v0.1.0 (#558)
chore: Release

Co-authored-by: github-actions <github-actions@github.com>
2022-11-22 10:36:10 +00:00
github-actions[bot]
6fd3044c12
release: binstalk-types v0.1.0 (#557)
chore: Release

Co-authored-by: github-actions <github-actions@github.com>
2022-11-22 09:21:27 +00:00
Jiahao XU
73751c4437
Set version of newly created crates to v0.0.0 (#556)
so that release-pr can operate on them and increase minor version for a
new release.

Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
2022-11-22 08:52:27 +00:00
github-actions[bot]
e5cd7d7ca1
release: detect-targets v0.1.3 (#555)
chore: Release

Co-authored-by: github-actions <github-actions@github.com>
2022-11-22 08:31:43 +00:00
Jiahao XU
822e7094e5
Upgrade dependencies (#554)
- bytes v1.2.1 => v1.3.0
 - serde_json v1.0.88 => v1.0.89
 - compact_str v0.6.0 => v0.6.1

Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
2022-11-22 07:39:58 +00:00
Jiahao XU
bd3f1d598c
Enable feature thin of dep zstd for any target built natively (#480)
* Add new feature `binstalk-downloader/zstd-thin`
* Add new feature `binstalk/zstd-thin`
* Add new feature `binstalk/zstd-thin`
* Enable feature zstd-thin for targets built natively

Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
2022-11-22 06:52:41 +00:00
Jiahao XU
66abf1b8c1
More mionr optimizations (#553)
* Optimize `BinFile::preview_bin`: Use `Path::display` instead of `to_string_lossy` to avoid allocation.
* Refactor: Rm useless `AsRef::as_ref` call
* Optimize `GhCrateMeta::find`: Reduce fut size by converting `Url` to `String`
   `Url` is much larger than `String`.
* Refactor `PackageInfo::resolve`: Destruct `Meta::binstall`
* Optimize `resolve::load_manifest_path`: Avoid allocation

Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
2022-11-22 19:35:16 +13:00
Jiahao XU
62e350eba9
detect-targets: Add support of MacOS universal binary (#552)
* Add support for MacOS universal bin
* Refactor: Extract new fn `macos::detect_alternative_targets`

Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
2022-11-21 22:16:28 +13:00
dependabot[bot]
7706aa14cf
Bump serde_json from 1.0.87 to 1.0.88 (#547)
Bumps [serde_json](https://github.com/serde-rs/json) from 1.0.87 to 1.0.88.
- [Release notes](https://github.com/serde-rs/json/releases)
- [Commits](https://github.com/serde-rs/json/compare/v1.0.87...v1.0.88)

---
updated-dependencies:
- dependency-name: serde_json
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-11-21 02:37:50 +00:00
dependabot[bot]
1821469342
Bump tokio from 1.21.2 to 1.22.0 (#548)
Bumps [tokio](https://github.com/tokio-rs/tokio) from 1.21.2 to 1.22.0.
- [Release notes](https://github.com/tokio-rs/tokio/releases)
- [Commits](https://github.com/tokio-rs/tokio/compare/tokio-1.21.2...tokio-1.22.0)

---
updated-dependencies:
- dependency-name: tokio
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-11-21 02:19:14 +00:00
Jiahao XU
83b2de3ea2
Enforce strict strategies parsing rule: Reject duplicate strategy in --strategies (#545)
`cargo-binstall` should reject duplicate strategy in `--strategies` as it is illegal input and it cannot be interpreted reasonably.

* Reject duplicate strategy in `--strategies`
* Optimize `compute_resolvers`: Use `Vec::retain`
   instead of `Iterator::filter` plus collecting into `Vec`.
* Optimize `compute_resolvers`: Reject `strategies.len() > Strategy::COUNT`
* Improve err msg for cases where user disabled all strategies
* Simplify `BinstallError::InvalidStrategies`: Takes `&'static str`
   instead of `&'static &'static str` since other variants are larger than 8B.

Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
2022-11-21 12:02:58 +11:00
Jiahao XU
bdb4b2070d
Minor optimization (#544)
* Optimization: Rm `debug!` in `find_version`
   printing all version iterated obviously doesn't help much in debugging
   in the problem but rather just confusing.
   
   Also this makes it hard for the compiler to optimize the iterators.
* Use let-else in `ManifestVisitor`
* Optimize `BinFile::preview_{bin, link}` for zero-copy
   Return `impl Display` that lazily format instead of allocating a `String`
* Optimize `infer_bin_dir_template`: Generate dir lazily
* Optimize `find_version`: Lazily clone `version_req` only on err
* Refactor `find_version`: Use `bool::then_some`
* Add dep either v1.8.0 to binstalk
* Optimize `GhCrateMeta::find`: Avoid cloning and `Vec` creation
   by using `Either`
* Optimize `ops::install::install_from_package`: Make it a regular fn
   instead of async fn since it does not `.await` on any async fn.
* Optimize `QuickInstall`: Rm field `target`
   since `Arc<Data>` already contains that field.
* Optimize `Fetcher`s: Extract new struct `TargetData`
   so that `Data` can be shared by all fetchers, regardless of the target.
* Optimize `QuickInstall`: Rm unused field `data`
* Optimize `Resolution::print`: Replace branching with conditional move

Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
2022-11-21 10:32:46 +13:00
dependabot[bot]
696d8c2a82
Bump reqwest from 0.11.12 to 0.11.13 (#538)
* Bump reqwest from 0.11.12 to 0.11.13

Bumps [reqwest](https://github.com/seanmonstar/reqwest) from 0.11.12 to 0.11.13.
- [Release notes](https://github.com/seanmonstar/reqwest/releases)
- [Changelog](https://github.com/seanmonstar/reqwest/blob/master/CHANGELOG.md)
- [Commits](https://github.com/seanmonstar/reqwest/compare/v0.11.12...v0.11.13)

---
updated-dependencies:
- dependency-name: reqwest
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>

* Bump trust-dns-resolver to v0.22.0
* Enable feature dns-over-quic if rustls & trust-dns-resolver are enabled

Signed-off-by: dependabot[bot] <support@github.com>
Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Jiahao XU <Jiahao_XU@outlook.com>
2022-11-20 00:21:50 +11:00
Jiahao XU
50b6e62164
Minor refactor and optimization (#543)
* Avoid potential panicking in `args::parse` by using `Vec::get` instead of indexing
* Refactor: Simplify `opts::{resolve, install}` API
   Many parameters can be shared and put into `opts::Options` intead and
   that would also avoid a few `Arc<Path>`.
* Optimize `get_install_path`: Avoid cloning `install_path`
* Optimize `LazyJobserverClient`: Un`Arc` & remove `Clone` impl
   to avoid additional boxing
* Optimize `find_version`: Avoid cloning `semver::Version`
* Optimize `GhCrateMeta::launch_baseline_find_tasks`
   return `impl Iterator<Item = impl Future<Output = ...>>`
   instead of `impl Iterator<Item = AutoAbortJoinHandle<...>>`
   to avoid unnecessary spawning.
   
   Each task spawned has to be boxed and then polled by tokio runtime.
   They might also be moved.
   
   While they increase parallelism, spawning these futures does not justify
   the costs because:
    - Each `Future` only calls `remote_exists`
    - Each `remote_exists` call send requests to the same domain, which is
      likely to share the same http2 connection.
      Since the conn is shared anyway, spawning does not speedup anything
      but merely add communication overhead.
    - Plus the tokio runtime spawning cost
* Optimize `install_crates`: Destruct `Args` before any `.await` point
   to reduce size of the future
* Refactor `logging`: Replace param `arg` with `log_level` & `json_output`
   to avoid dep on `Args`
* Add dep strum & strum_macros to crates/bin
* Derive `strum_macros::EnumCount` for `Strategy`
* Optimize strategies parsing in `install_crates`
* Fix panic in `install_crates` when `Compile` is not the last strategy specified
* Optimize: Take `Vec<Self>` instead of slice in `CrateName::dedup`
* Refactor: Extract new fn `compute_resolvers`
* Refactor: Extract new fn `compute_paths_and_load_manifests`
* Refactor: Extract new fn `filter_out_installed_crates`
* Reorder `install_crates`: Only run target detection if args are valid
   and there are some crates to be installed.
* Optimize `filter_out_installed_crates`: Avoid allocation
   by returning an `Iterator`
* Fix user_agent of `remote::Client`: Let user specify it
* Refactor: Replace `UIThread` with `ui::confirm`
   which is much simpler.

Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
2022-11-19 20:00:27 +13:00
Jiahao XU
325cb5cc19
Optimizations plus bug fix (#541)
* Optimize `Download::and_extract`: Avoid dup monomorphization
* Increase buffer size for binstall_crates_v1 to `4096 * 5`
* Optimize `opts::resolve`: Avoid unnecessary `clone`s
* Fix reserve in `opts::resolve`: Do not over-reserve
* Rename field `opts::Options::resolver` => `resolvers`
* Refactor: Extract new type `resolve::PackageInfo`
    - which makes `opts::resolve_inner` easier to understand
    - reduce number of parameters required for `download_extract_and_verify` and
      `collect_bin_files`
    - reducing size of future returned by `opts::resolve_inner` by dropping
      `cargo_toml::{Manifest, Package}` as early as possible since
      `Manifest` is 3000 Bytes large while `Package` is 600 Bytes large.
* Optimize `fetchers::Data`: Use `CompactString` for field name & version
   since they are usually small enough to fit in inlined version of
   `CompactString`.
* Optimize `gh_crate_meta`: Avoid unnecessary allocation
   in `RepositoryHost::get_default_pkg_url_template`.
* Refacator: Use `Itertools::cartesian_product` in `apply_filenames_to_paths`
* Optimize `ops::resolve`: Avoid unnecessary `clone` & reduce future size
   by calling `fetcher.target_meta()` to obtain final metadata after
   downloaded and extracted the binaries.
* Optimize `ops::resolve`: Avoid unnecessary allocation
   in `download_extract_and_verify`: Replace `Itertools::join` with
   `Itertools::format` to avoid allocating the string.
* Fix disabling cargo-install fallback
* Simplify `BinFile::from_product`: Takes `&str` instead of `&Product`
   since we only need `product.name`
* Rename `BinFile::from_product` => `BinFile::new`
* Refactor: Create newtype `ops::resolve::Bin`
   so that we don't need to `unwrap()` on `Product::name`
   and reduce memory usage.

Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
2022-11-17 23:59:35 +00:00
Alessandro Candido
bb1f51a739
Short option for no-confirm flag (#540)
Add short name for no-confirm flag

Closes #536

The -y short name is a convention, often used by package managers (apt, yum, ...) and it is associated with a request of no interaction (thus often used in scripts, to automate workflows)
2022-11-17 18:54:10 +11:00
dependabot[bot]
69ed65dbba
Bump digest from 0.10.5 to 0.10.6 (#539)
Bumps [digest](https://github.com/RustCrypto/traits) from 0.10.5 to 0.10.6.
- [Release notes](https://github.com/RustCrypto/traits/releases)
- [Commits](https://github.com/RustCrypto/traits/compare/digest-v0.10.5...digest-v0.10.6)

---
updated-dependencies:
- dependency-name: digest
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-11-17 01:30:32 +00:00
dependabot[bot]
451c69b37e
Bump clap from 4.0.25 to 4.0.26 (#537)
Bumps [clap](https://github.com/clap-rs/clap) from 4.0.25 to 4.0.26.
- [Release notes](https://github.com/clap-rs/clap/releases)
- [Changelog](https://github.com/clap-rs/clap/blob/master/CHANGELOG.md)
- [Commits](https://github.com/clap-rs/clap/compare/v4.0.25...v4.0.26)

---
updated-dependencies:
- dependency-name: clap
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-11-17 12:07:49 +11:00
Jiahao XU
d9cc3ce219
Refactor: Extract new crate binstalk-types plus other misc refactor and optimization (#535)
* Refactor: Extract new crate binstalk-types
* Optimize: Rm field `CrateInfo::other`
   which also removes dep serde-tuple-vec-map and serde-json from
   binstalk-types.
   
   This also makes `CrateInfo` easier to use, more generic and can be used
   over any `Serializer`, not just `serde_json::Value`.
* Mark all errors in `binstalk-manifests` as non_exhaustive
* Reduce size of `CvsParseError` by using `Box<str>`
   instead of `String` for variant `UnknownSourceType`.
* Reduce size of `CratesTomlParseError` to 16 bytes on 64bit platform
   by boxing variants `TomlWrite` and `CvsParse` as these two fields are
   significantly larger than other variants.
* Unify import style in mod `binstall_crates_v1`
* Replace dep binstalk-manifests with binstalk-types in binstalk-downloader
   to reduce its transitive dependencies and enables binstalk-downloader to
   be built in parallel to binstak-manifests.
* Replace dep binstalk-manifests with binstalk-types in binstalk
   to reduce transitive dependencies and enables binstalk to be built in
   parallel to binstalk-manifests.
   
   This is benefitial because binstalk-manifests pulls in toml_edit, which
   could takes up to 15s to be built on M1 (7-9s for codegen).
* Add dep binstalk-manifests to crates/bin
* Update dependabot and GHA release-pr

Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
2022-11-17 13:46:27 +13:00
dependabot[bot]
58326a6085
Bump mimalloc from 0.1.31 to 0.1.32 (#533)
Bumps [mimalloc](https://github.com/purpleprotocol/mimalloc_rust) from 0.1.31 to 0.1.32.
- [Release notes](https://github.com/purpleprotocol/mimalloc_rust/releases)
- [Commits](https://github.com/purpleprotocol/mimalloc_rust/compare/v0.1.31...v0.1.32)

---
updated-dependencies:
- dependency-name: mimalloc
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-11-16 02:18:59 +00:00
dependabot[bot]
66eb4d2d54
Bump clap from 4.0.24 to 4.0.25 (#534)
Bumps [clap](https://github.com/clap-rs/clap) from 4.0.24 to 4.0.25.
- [Release notes](https://github.com/clap-rs/clap/releases)
- [Changelog](https://github.com/clap-rs/clap/blob/master/CHANGELOG.md)
- [Commits](https://github.com/clap-rs/clap/compare/v4.0.24...v4.0.25)

---
updated-dependencies:
- dependency-name: clap
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-11-16 01:27:53 +00:00
Jiahao XU
b6f223d925
Switch binstalk-manifests LICENSE to "Apache-2.0 OR MIT" (#513)
Signed-off-by: Félix Saparelli <felix@passcod.name>
Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
Signed-off-by: pinage404
Signed-off-by: Ryo Yamashita <qryxip@gmail.com>
Signed-off-by: azzamsa

and https://github.com/cargo-bins/cargo-binstall/pull/513#issuecomment-1315898664 for Ryan Kurte
2022-11-15 22:51:11 +00:00
dependabot[bot]
7f4d023914
Bump clap from 4.0.23 to 4.0.24 (#532)
Bumps [clap](https://github.com/clap-rs/clap) from 4.0.23 to 4.0.24.
- [Release notes](https://github.com/clap-rs/clap/releases)
- [Changelog](https://github.com/clap-rs/clap/blob/master/CHANGELOG.md)
- [Commits](https://github.com/clap-rs/clap/compare/v4.0.23...v4.0.24)

---
updated-dependencies:
- dependency-name: clap
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-11-15 01:53:55 +00:00
Jiahao XU
c34a2850b3
Optimization: Box variants in Error to reduce size and remove unused variants in BinstallError (#530)
* Box `HttpError` in `binsalk_downloader::remote::Error::Http`
   as `HttpError` contains `Url` which are too big.
* Box `HttpError` in `BinstallError::Http` same as the previous commit.
* Box `TinyTemplateError` in `BinstallError::Template`
  since `TinyTemplateError` is 56 bytes large where most of the other variants are below 40 bytes large.
* Rm unsed variant `BinstallError::VersionUnavailable`
* Box `CratesIoApiError` in `BinstallError::CratesIoApi`
   It is 32 bytes large while other variants are below 40 bytes large.
* Improve err msg for `BinstallError::CrateContext`
* Rm unused variant `BinstallError::VersionReq`

Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
2022-11-15 02:46:32 +13:00