-
-
Notifications
You must be signed in to change notification settings - Fork 780
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! |
…or direct dependencies ✨
…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
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.
@@ -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.
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"); |
/** | ||
* Used to compare 2 versions of a package. | ||
*/ | ||
pub type PackageVersionDiffs = HashMap<String, (Version, Version)>; |
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 either use this always or remove it
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 either use this always or remove it
I'm not sure what you mean. PackageVersionDiffs
are used only for the major versions check currently. I don't see any other place making comparisons between 2 versions (except probably within pubgrub which makes comparisons betweens many versions probably).
Is you suggestion to remove the type and use HashMap<String, (Version, Version)>
everywhere?
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: ...)
.
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.