Conversation
The update check contacts crates.io on every run and pulls in an HTTP and TLS stack. Move it from the cli feature into a new update-check feature, enabled by default, so distributions can build the CLI without it via --no-default-features --features cli. The --skip-update-check option is kept, so existing scripts that pass it keep working when the feature is disabled. Signed-off-by: Victor Irzak <victor@irzak.com>
|
|
||
| [features] | ||
| default = ["cli"] | ||
| default = ["cli", "update-check"] |
There was a problem hiding this comment.
I like the change, but, in theory, it would require a major version bump. Although I don't think any library user would be affected by this change.
A minor-compatible alternative: keep pub mod update gated on cli, and gate only the dependency and the function body on update-check:
/// Check for updates
#[cfg(feature = "cli")]
pub mod update {
/// Check for updates to the espflash crate.
///
/// Does nothing unless the `update-check` feature is enabled.
pub fn check_for_update(name: &str, version: &str) {
#[cfg(feature = "update-check")]
{
use std::time::Duration;
use log::info;
use update_informer::{Check, registry::Crates};
let informer =
update_informer::new(Crates, name, version).interval(Duration::from_secs(0));
if let Some(version) = informer.check_version().ok().flatten() {
info!("🚀 A new version of {name} is available: {version}");
}
}
#[cfg(not(feature = "update-check"))]
let _ = (name, version);
}
}This would still drop the HTTP and TSL stack on OpenWrt build.
We still have to decide if the next espflash version would be 5.0.0 or a minor version. We will have a plan for this at the end of the mont
There was a problem hiding this comment.
Good point, done in 247ef74: update and check_for_update() stay under cli, only the update-informer call is gated on update-check, and the binary change is reverted. Built with --no-default-features --features cli the binary still has no HTTP/TLS code.
Removing espflash::update when only cli is enabled would be a breaking change for library users. Keep the module and check_for_update() under cli, and gate only the update-informer call on update-check, so the function does nothing when the feature is disabled. Signed-off-by: Victor Irzak <victor@irzak.com>
SergioGasquez
left a comment
There was a problem hiding this comment.
Currently we dont test this config, we should add
- run: RUSTFLAGS="-D warnings" cargo check -p espflash --no-default-features --features cliTo https://github.com/esp-rs/espflash/blob/main/.github/workflows/ci.yml#L89-L90
| ] | ||
|
|
||
| # Checks crates.io for a newer release on every run of the CLI | ||
| update-check = ["dep:update-informer"] |
There was a problem hiding this comment.
| update-check = ["dep:update-informer"] | |
| update-check = ["cli", "dep:update-informer"] |
Otherwise update-check doesn't turn on cli and with --no-default-features --features update-check, the dependency gets pulled in but the update module isn't compiled.
There was a problem hiding this comment.
Applied in 267d78b, together with the CI step for --no-default-features --features cli.
Without cli, update-check pulled in update-informer but did not compile the update module. Also add a CI step for --no-default-features --features cli, which builds the CLI without the update check. Signed-off-by: Victor Irzak <victor@irzak.com>
The update check contacts crates.io on every run and pulls in
update-informerwith an HTTP and TLS stack. This moves it out of theclifeature into a newupdate-checkfeature, which is enabled by default, so nothing changes forcargo install espflash.Distributions can now build the CLI without it via
--no-default-features --features cli. OpenWrt asked for exactly that when packaging espflash (openwrt/packages#30659). There it also takes about 1 MB off the binary.--skip-update-checkis kept, so scripts that pass it keep working when the feature is off.