Skip to content

Commit b440d2d

Browse files
authored
feat(outdated): interactive update (#27812)
interactively select which packages to upgrade. a future improvement could be to add a way to select the version as well, though not sure how valuable that would be.
1 parent 28834a8 commit b440d2d

File tree

7 files changed

+596
-27
lines changed

7 files changed

+596
-27
lines changed

Cargo.lock

+68-8
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ cbc = { version = "=0.1.2", features = ["alloc"] }
123123
# Instead use util::time::utc_now()
124124
chrono = { version = "0.4", default-features = false, features = ["std", "serde"] }
125125
color-print = "0.3.5"
126-
console_static_text = "=0.8.1"
126+
console_static_text = "=0.8.3"
127127
ctr = { version = "0.9.2", features = ["alloc"] }
128128
dashmap = "5.5.3"
129129
data-encoding = "2.3.3"

cli/Cargo.toml

+2
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,7 @@ clap_complete = "=4.5.24"
105105
clap_complete_fig = "=4.5.2"
106106
color-print.workspace = true
107107
console_static_text.workspace = true
108+
crossterm = "0.28.1"
108109
dashmap.workspace = true
109110
data-encoding.workspace = true
110111
dhat = { version = "0.3.3", optional = true }
@@ -169,6 +170,7 @@ tower-lsp.workspace = true
169170
tracing = { version = "0.1", features = ["log", "default"] }
170171
twox-hash.workspace = true
171172
typed-arena = "=2.0.2"
173+
unicode-width = "0.1.3"
172174
uuid = { workspace = true, features = ["serde"] }
173175
walkdir.workspace = true
174176
which.workspace = true

cli/args/flags.rs

+43-10
Original file line numberDiff line numberDiff line change
@@ -475,7 +475,7 @@ pub enum DenoSubcommand {
475475

476476
#[derive(Clone, Debug, PartialEq, Eq)]
477477
pub enum OutdatedKind {
478-
Update { latest: bool },
478+
Update { latest: bool, interactive: bool },
479479
PrintOutdated { compatible: bool },
480480
}
481481

@@ -2660,7 +2660,7 @@ Specific version requirements to update to can be specified:
26602660
.long("latest")
26612661
.action(ArgAction::SetTrue)
26622662
.help(
2663-
"Update to the latest version, regardless of semver constraints",
2663+
"Consider the latest version, regardless of semver constraints",
26642664
)
26652665
.conflicts_with("compatible"),
26662666
)
@@ -2669,15 +2669,21 @@ Specific version requirements to update to can be specified:
26692669
.long("update")
26702670
.short('u')
26712671
.action(ArgAction::SetTrue)
2672-
.conflicts_with("compatible")
26732672
.help("Update dependency versions"),
26742673
)
2674+
.arg(
2675+
Arg::new("interactive")
2676+
.long("interactive")
2677+
.short('i')
2678+
.action(ArgAction::SetTrue)
2679+
.requires("update")
2680+
.help("Interactively select which dependencies to update")
2681+
)
26752682
.arg(
26762683
Arg::new("compatible")
26772684
.long("compatible")
26782685
.action(ArgAction::SetTrue)
2679-
.help("Only output versions that satisfy semver requirements")
2680-
.conflicts_with("update"),
2686+
.help("Only consider versions that satisfy semver requirements")
26812687
)
26822688
.arg(
26832689
Arg::new("recursive")
@@ -4462,7 +4468,11 @@ fn outdated_parse(
44624468
let update = matches.get_flag("update");
44634469
let kind = if update {
44644470
let latest = matches.get_flag("latest");
4465-
OutdatedKind::Update { latest }
4471+
let interactive = matches.get_flag("interactive");
4472+
OutdatedKind::Update {
4473+
latest,
4474+
interactive,
4475+
}
44664476
} else {
44674477
let compatible = matches.get_flag("compatible");
44684478
OutdatedKind::PrintOutdated { compatible }
@@ -11646,31 +11656,43 @@ Usage: deno repl [OPTIONS] [-- [ARGS]...]\n"
1164611656
svec!["--update"],
1164711657
OutdatedFlags {
1164811658
filters: vec![],
11649-
kind: OutdatedKind::Update { latest: false },
11659+
kind: OutdatedKind::Update {
11660+
latest: false,
11661+
interactive: false,
11662+
},
1165011663
recursive: false,
1165111664
},
1165211665
),
1165311666
(
1165411667
svec!["--update", "--latest"],
1165511668
OutdatedFlags {
1165611669
filters: vec![],
11657-
kind: OutdatedKind::Update { latest: true },
11670+
kind: OutdatedKind::Update {
11671+
latest: true,
11672+
interactive: false,
11673+
},
1165811674
recursive: false,
1165911675
},
1166011676
),
1166111677
(
1166211678
svec!["--update", "--recursive"],
1166311679
OutdatedFlags {
1166411680
filters: vec![],
11665-
kind: OutdatedKind::Update { latest: false },
11681+
kind: OutdatedKind::Update {
11682+
latest: false,
11683+
interactive: false,
11684+
},
1166611685
recursive: true,
1166711686
},
1166811687
),
1166911688
(
1167011689
svec!["--update", "@foo/bar"],
1167111690
OutdatedFlags {
1167211691
filters: svec!["@foo/bar"],
11673-
kind: OutdatedKind::Update { latest: false },
11692+
kind: OutdatedKind::Update {
11693+
latest: false,
11694+
interactive: false,
11695+
},
1167411696
recursive: false,
1167511697
},
1167611698
),
@@ -11682,6 +11704,17 @@ Usage: deno repl [OPTIONS] [-- [ARGS]...]\n"
1168211704
recursive: false,
1168311705
},
1168411706
),
11707+
(
11708+
svec!["--update", "--latest", "--interactive"],
11709+
OutdatedFlags {
11710+
filters: svec![],
11711+
kind: OutdatedKind::Update {
11712+
latest: true,
11713+
interactive: true,
11714+
},
11715+
recursive: false,
11716+
},
11717+
),
1168511718
];
1168611719
for (input, expected) in cases {
1168711720
let mut args = svec!["deno", "outdated"];

cli/tools/registry/pm/deps.rs

+6
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,12 @@ pub struct Dep {
194194
pub alias: Option<String>,
195195
}
196196

197+
impl Dep {
198+
pub fn alias_or_name(&self) -> &str {
199+
self.alias.as_deref().unwrap_or_else(|| &self.req.name)
200+
}
201+
}
202+
197203
fn import_map_entries(
198204
import_map: &ImportMap,
199205
) -> impl Iterator<Item = (KeyPath, SpecifierMapEntry<'_>)> {

0 commit comments

Comments
 (0)