-
-
Notifications
You must be signed in to change notification settings - Fork 794
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
show latest major version available in gleam deps update
#3876
base: main
Are you sure you want to change the base?
Conversation
Hello! Are you still working on this one? Thanks |
I was hoping to work on it this weekend but some things have come up. I can only get back to it next weekend. |
320e39f
to
fa633dc
Compare
300e9eb
to
2f1055d
Compare
Could a flag be provided that forces a non-zero exit-code if major deps updates are available? Would that make sense? The idea would be to have a CI check that goes red if deps are not up to date. |
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.
Very nice! I've left some small notes inline.
compiler-core/src/dependency.rs
Outdated
] | ||
.into_iter() | ||
.collect(), | ||
//requirements: HashMap::new(), |
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.
Unused code 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.
Haha, this is embarrassing.
PS. Fixed.
compiler-core/src/dependency.rs
Outdated
let Some(latest) = &hexpackage | ||
.releases | ||
.iter() | ||
.map(|release| release.version.clone()) |
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.
Can take a reference here and avoid cloning
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.
Fixed
compiler-core/src/dependency.rs
Outdated
.sorted_by(|a, b| b.cmp(a)) | ||
.next() |
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.
Using .max
will be faster than sorting and taking the first
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.
Fixed.
compiler-cli/src/dependencies.rs
Outdated
|
||
// lazily assuming the longest version could be 8 characters. eg: 1.1234.2 | ||
// excluding qualifiers other than x.y.z | ||
eprintln!("{name}:{padding} {v1:<8} -> {v2:<8}"); |
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.
Let's render this to a string and then snapshot test the function. This function can then just print the string and not be responsible for formatting and printing
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.
Done.
0781fc3
to
c2e7c65
Compare
@inoas I think the flag would make more sense in a |
100bf86
to
839318a
Compare
gleam deps update
gleam deps update
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.
Great, thank you.

I gave it a try and while the information is there and useful I don't think it fits in at all with any of the other information printed. How can we show this better?
Should it be shown for all resolution or only for gleam update
? If the latter it would be easier to make a good output format for it.
It makes sense to show for Although it was helpful when I recently did I'd say for an MVP show only in |
Sounds great! |
ad3d34d
to
22b1135
Compare
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 great!! Thank you. I've left a few tiny notes inline.
compiler-cli/src/dependencies.rs
Outdated
@@ -219,73 +221,75 @@ pub fn download<Telem: Telemetry>( | |||
// manifest which will result in the latest versions of the dependency | |||
// packages being resolved (not the locked ones). | |||
use_manifest: UseManifest, | |||
// If true we check for major version updates and print them to the console. | |||
check_major_versions: bool, |
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.
Create an enum instead of using bools please. true
and false
mean nothing without context so they are hard to understand. See the other arguments for examples.
compiler-cli/src/dependencies.rs
Outdated
tracing::debug!("writing_manifest_toml"); | ||
write_manifest_to_disc(paths, &manifest)?; | ||
output_string | ||
.push_str("\nHint: the following dependencies have new major versions available:\n\n"); |
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.
.push_str("\nHint: the following dependencies have new major versions available:\n\n"); | |
.push_str("\nThe following dependencies have new major versions available:\n\n"); |
compiler-cli/src/dependencies.rs
Outdated
fn should_use_manifest(mut self) -> Self { | ||
self.use_manifest = UseManifest::Yes; | ||
self | ||
} |
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 is cool!
Another option which can be convenient at times is to have a struct with public fields and have an into_dependency_manager()
method or something like that
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 looked into builder pattern and init pattern (misnamed but similar to what you're suggesting). But as the tokio runtime, Package Fetcher and Telemetry needs to be specified, I cannot implement Default. Which means I'll have to define all struct fields at callsite. Which means any addition or change to the struct will require changes at all callsites.
Alternatively I could go for a builder, but seems too small right now.
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.
Although...I could make it DependencyManagerConfig.into_dependecy_manager(runtime: ..., package_fetcher: ..., telemetry: ...)
.
Are you still planning to work on this? Thank you 🙏 |
Hey yeah, will be working on this 🙂. Was a bit busy over the last 2 weeks, will be resuming it this week 🤞 |
22b1135
to
4cf6967
Compare
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.
Thank you! A few small things
compiler-cli/src/build.rs
Outdated
telemetry, | ||
None, | ||
Vec::new(), | ||
dependencies::DependencyManagerConfig::default(), |
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 is much less clear than before- please explicitly state each item of config. The programmer should be able to tell what the desired behaviour is at each call-site. This will mean removing the default implementation.
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.
Done
compiler-cli/src/dependencies.rs
Outdated
pub mode: Mode, | ||
pub use_manifest: UseManifest, | ||
pub check_major_versions: CheckMajorVersions, |
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.
Document what each of these do please 🙏
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.
Done
compiler-cli/src/dependencies.rs
Outdated
} | ||
} | ||
|
||
pub struct DependencyManager<Telem: Telemetry, P: dependency::PackageFetcher> { |
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.
Remove these constraints please 🙏 Constraints are only needed on the functions.
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.
Done
8ba89b8
to
4a66951
Compare
…err instead of stdout ♻️
…cy resolution and major version resolution to reduce network calls to hexpm ♻️
Changed PackageFetcher to use impl or a generic. This will avoid dynamic dispatch and there is only one implementation for production so monomorphization will not increase the bin size.
… struct impl ♻️ The struct now holds the relevant dependencies that were being passed around with each function call.
…s to reduce API churn ♻️
Although Rc is used, it is still cloned in dependency::DependencyProvider as it needs to sort the releases
…ager with defaults ♻️
385bc90
to
c347c0a
Compare
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.
Beautiful work, thank you so much!
I've been manually testing this and it's really nice and useful, but it prints about dependencies being out of date before they are reported as having been added.
$ gleam add lustre@2 gleam_json@1
Resolving versions
Downloading packages
Downloaded 5 packages in 0.48s
Hint: the following dependencies have new major versions available:
gleam_json 1.0.1 -> 2.3.0
lustre 2.0.1 -> 4.6.3
Added lustre v2.0.1
Added gleam_json v1.0.1
I think it would make more sense the other way around
$ gleam add lustre@2 gleam_json@1
Resolving versions
Downloading packages
Downloaded 5 packages in 0.48s
Added lustre v2.0.1
Added gleam_json v1.0.1
The following dependencies have new major versions available:
gleam_json 1.0.1 -> 2.3.0
lustre 2.0.1 -> 4.6.3
What do you think?
Yeah the current output is confusing. But that's actually a bug. Major version availability should be shown only on PS. I'm traveling until 28th feb, so updates might be a bit slow. |
This PR aims to solve #3843.
The sample output from that issue:
% gleam deps update Resolving versions Downloading packages Downloaded 2 packages in 0.01s Hint: the following dependencies have new major versions available... - wibble@2 - wobble@3
Todos
Handle Async: fireoff the checks and show the results at the end.Didn't make sense to do this.Merge version check into a single callHexpm API doesn't have this. Went with cache instead.