Skip to content

Commit e76562d

Browse files
andholpil
authored andcommitted
feat(dependencies): pretty print major version update hint into columns ✨
1 parent 0352a76 commit e76562d

File tree

1 file changed

+16
-6
lines changed

1 file changed

+16
-6
lines changed

compiler-cli/src/dependencies.rs

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -422,17 +422,27 @@ pub fn download<Telem: Telemetry>(
422422
let major_versions_available =
423423
dependency::check_for_major_version_updates(&manifest, package_fetcher);
424424
if !major_versions_available.is_empty() {
425-
// print to stderr instead of stdout because this is not part of the standard output of this
426-
// command
427-
eprintln!("\nHint: the following dependencies have new major versions available...\n");
428-
for (name, (v1, v2)) in major_versions_available {
429-
eprintln!("{}@{} -> {}@{}", name, v1, name, v2);
430-
}
425+
pretty_print_major_versions_available(major_versions_available);
431426
}
432427

433428
Ok(manifest)
434429
}
435430

431+
fn pretty_print_major_versions_available(versions: dependency::PackageVersionDiffs) {
432+
let longest_package_name_length = versions.keys().map(|name| name.len()).max().unwrap_or(10);
433+
434+
// print to stderr instead of stdout because this is not part of the standard output of this
435+
// command
436+
eprintln!("\nHint: the following dependencies have new major versions available...\n");
437+
for (name, (v1, v2)) in versions {
438+
let padding = " ".repeat(longest_package_name_length - name.len());
439+
440+
// lazily assuming the longest version could be 8 characters. eg: 1.1234.2
441+
// excluding qualifiers other than x.y.z
442+
eprintln!("{name}:{padding} {v1:<8} -> {v2:<8}");
443+
}
444+
}
445+
436446
async fn add_missing_packages<Telem: Telemetry>(
437447
paths: &ProjectPaths,
438448
fs: Box<ProjectIO>,

0 commit comments

Comments
 (0)