-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
add version check
command
#14880
add version check
command
#14880
Conversation
@cptpiepmatz Any idea what these wasm failures are all about? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think maybe it could return something like:
╭────────────┬─────────╮
│ latest │ 0.101.0 │
│ up_to_date │ false │
│ channel │ stable │
╰────────────┴─────────╯
Cargo.toml
Outdated
@@ -136,7 +136,7 @@ quickcheck = "1.0" | |||
quickcheck_macros = "1.0" | |||
quote = "1.0" | |||
rand = "0.8" | |||
getrandom = "0.2" # pick same version that rand requires | |||
getrandom = "0.2" # pick same version that rand requires |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
..what happened here? 🤣
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lol, that's weird. I guess dependi extension tries to format it. i'll save without formatting and see what happens.
@@ -264,6 +264,7 @@ pub fn add_shell_command_context(mut engine_state: EngineState) -> EngineState { | |||
Term, | |||
TermSize, | |||
TermQuery, | |||
VersionCheck, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this should probably be gated behind the network
feature rather than the os
feature
looks like the diff --git a/crates/nu-command/Cargo.toml b/crates/nu-command/Cargo.toml
index 6eb92d2d4..667353f85 100644
--- a/crates/nu-command/Cargo.toml
+++ b/crates/nu-command/Cargo.toml
@@ -91,7 +91,7 @@ tabled = { workspace = true, features = ["ansi"], default-features = false }
titlecase = { workspace = true }
toml = { workspace = true, features = ["preserve_order"] }
unicode-segmentation = { workspace = true }
-update-informer = { workspace = true }
+update-informer = { workspace = true, optional = true }
ureq = { workspace = true, default-features = false, features = ["charset", "gzip", "json"] }
url = { workspace = true }
uu_cp = { workspace = true, optional = true }
@@ -177,6 +177,7 @@ js = [
network = [
"multipart-rs",
"native-tls",
+ "update-informer",
"ureq/native-tls",
"uuid",
] |
Thanks for the feedback @132ikl. I think followed all of your advice. |
That seems to be the right way to do it 👍🏻 |
@mgrachev would you mind taking a look at this please? I can't seem to get the nightly check working. The cargo pkg version seems right but it's saying .10 is current/latest version even though there is tag with 0.101.1-nightly.12 in the nightly repo
Note: I've changed every instance of version "0.101.1" to "0.101.1-nightly.10" including the root cargo.toml package.version as well and rebuilt. I've done this to simulate a nightly build and checking with an old version. However, when I run the command, I get this output.
channel is right, current should be false, latest should be 0.101.1-nightly.12. I'm sure it's something stupid I'm doing somewhere. |
It doesn't work because
A workaround:
ureq = { version = "2.12", default-features = false, features = ["native-tls"] }
network = [
"update-informer/native-tls",
]
struct NativeTlsHttpClient;
impl HttpClient for NativeTlsHttpClient {
fn get<T: serde::de::DeserializeOwned>(
url: &str,
timeout: std::time::Duration,
headers: update_informer::http_client::HeaderMap,
) -> update_informer::Result<T> {
let agent = ureq::AgentBuilder::new()
.tls_connector(std::sync::Arc::new(native_tls::TlsConnector::new()?))
.build();
let mut req = agent.get(url).timeout(timeout);
for (header, value) in headers {
req = req.set(header, value);
}
let json = req.call()?.into_json()?;
Ok(json)
}
}
pub fn check_for_latest_nushell_version() -> Value {
// skipped
let informer =
update_informer::new(NuShellNightly, nightly_pkg_name, current_version.clone())
.http_client(NativeTlsHttpClient)
.interval(std::time::Duration::ZERO);
// skipped
} In the future, I will try to fix this issue in the new version of |
That did it! Thanks so much @mgrachev. You've been a wonderful help during the process of integrating your crate. Sincerely appreciate all your help and your cool crate. |
ugh, wasm build/clippy again. |
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me, let's try it how it plays with the nightly
To be clear, for anyone testing this. It will probably only work on nightlies >= 0.101.1-nightly.14. @hustcer made some changes on how the nightlies are compiled related to versioning which are required for |
Description
This PR supersedes #14813 by making it a built-in command instead of checking for the latest version at some interval when nushell starts.
This is what it looks like.
This example shows the output when the running version was 0.101.1-nightly.10
Description from old PR.
One key functionality that I thought was interesting with this and that I worked with @hustcer on was to try and make sure it works with nightlies. So, it should tell you when there's a new nightly version that is available to download. This way, you can know about it without checking.
What's key from a nightly perspective is (1) the tags are now semver compliant and (2) hustcer now updates the Cargo.toml package.version version number prior to compilation so you can know you're running a nightly version, and this PR uses that information to know whether to check the nightly repo or the nushell repo for updates.
This uses the update-informer crate. NOTE that this informs you of updates but does not automatically update. I kind of see this as the first step to eventually having an auto updater.
There was caching of the version in the old PR since it ran on every nushell startup. Since this PR makes it a command and therefore always runs on-demand, I've removed the caching so that it always checks when you run it.
User-Facing Changes
Tests + Formatting
After Submitting