Skip to content

Commit

Permalink
feat(outdated): interactive update (#27812)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
nathanwhit authored Feb 4, 2025
1 parent 28834a8 commit b440d2d
Show file tree
Hide file tree
Showing 7 changed files with 596 additions and 27 deletions.
76 changes: 68 additions & 8 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ cbc = { version = "=0.1.2", features = ["alloc"] }
# Instead use util::time::utc_now()
chrono = { version = "0.4", default-features = false, features = ["std", "serde"] }
color-print = "0.3.5"
console_static_text = "=0.8.1"
console_static_text = "=0.8.3"
ctr = { version = "0.9.2", features = ["alloc"] }
dashmap = "5.5.3"
data-encoding = "2.3.3"
Expand Down
2 changes: 2 additions & 0 deletions cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ clap_complete = "=4.5.24"
clap_complete_fig = "=4.5.2"
color-print.workspace = true
console_static_text.workspace = true
crossterm = "0.28.1"
dashmap.workspace = true
data-encoding.workspace = true
dhat = { version = "0.3.3", optional = true }
Expand Down Expand Up @@ -169,6 +170,7 @@ tower-lsp.workspace = true
tracing = { version = "0.1", features = ["log", "default"] }
twox-hash.workspace = true
typed-arena = "=2.0.2"
unicode-width = "0.1.3"
uuid = { workspace = true, features = ["serde"] }
walkdir.workspace = true
which.workspace = true
Expand Down
53 changes: 43 additions & 10 deletions cli/args/flags.rs
Original file line number Diff line number Diff line change
Expand Up @@ -475,7 +475,7 @@ pub enum DenoSubcommand {

#[derive(Clone, Debug, PartialEq, Eq)]
pub enum OutdatedKind {
Update { latest: bool },
Update { latest: bool, interactive: bool },
PrintOutdated { compatible: bool },
}

Expand Down Expand Up @@ -2660,7 +2660,7 @@ Specific version requirements to update to can be specified:
.long("latest")
.action(ArgAction::SetTrue)
.help(
"Update to the latest version, regardless of semver constraints",
"Consider the latest version, regardless of semver constraints",
)
.conflicts_with("compatible"),
)
Expand All @@ -2669,15 +2669,21 @@ Specific version requirements to update to can be specified:
.long("update")
.short('u')
.action(ArgAction::SetTrue)
.conflicts_with("compatible")
.help("Update dependency versions"),
)
.arg(
Arg::new("interactive")
.long("interactive")
.short('i')
.action(ArgAction::SetTrue)
.requires("update")
.help("Interactively select which dependencies to update")
)
.arg(
Arg::new("compatible")
.long("compatible")
.action(ArgAction::SetTrue)
.help("Only output versions that satisfy semver requirements")
.conflicts_with("update"),
.help("Only consider versions that satisfy semver requirements")
)
.arg(
Arg::new("recursive")
Expand Down Expand Up @@ -4462,7 +4468,11 @@ fn outdated_parse(
let update = matches.get_flag("update");
let kind = if update {
let latest = matches.get_flag("latest");
OutdatedKind::Update { latest }
let interactive = matches.get_flag("interactive");
OutdatedKind::Update {
latest,
interactive,
}
} else {
let compatible = matches.get_flag("compatible");
OutdatedKind::PrintOutdated { compatible }
Expand Down Expand Up @@ -11646,31 +11656,43 @@ Usage: deno repl [OPTIONS] [-- [ARGS]...]\n"
svec!["--update"],
OutdatedFlags {
filters: vec![],
kind: OutdatedKind::Update { latest: false },
kind: OutdatedKind::Update {
latest: false,
interactive: false,
},
recursive: false,
},
),
(
svec!["--update", "--latest"],
OutdatedFlags {
filters: vec![],
kind: OutdatedKind::Update { latest: true },
kind: OutdatedKind::Update {
latest: true,
interactive: false,
},
recursive: false,
},
),
(
svec!["--update", "--recursive"],
OutdatedFlags {
filters: vec![],
kind: OutdatedKind::Update { latest: false },
kind: OutdatedKind::Update {
latest: false,
interactive: false,
},
recursive: true,
},
),
(
svec!["--update", "@foo/bar"],
OutdatedFlags {
filters: svec!["@foo/bar"],
kind: OutdatedKind::Update { latest: false },
kind: OutdatedKind::Update {
latest: false,
interactive: false,
},
recursive: false,
},
),
Expand All @@ -11682,6 +11704,17 @@ Usage: deno repl [OPTIONS] [-- [ARGS]...]\n"
recursive: false,
},
),
(
svec!["--update", "--latest", "--interactive"],
OutdatedFlags {
filters: svec![],
kind: OutdatedKind::Update {
latest: true,
interactive: true,
},
recursive: false,
},
),
];
for (input, expected) in cases {
let mut args = svec!["deno", "outdated"];
Expand Down
6 changes: 6 additions & 0 deletions cli/tools/registry/pm/deps.rs
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,12 @@ pub struct Dep {
pub alias: Option<String>,
}

impl Dep {
pub fn alias_or_name(&self) -> &str {
self.alias.as_deref().unwrap_or_else(|| &self.req.name)
}
}

fn import_map_entries(
import_map: &ImportMap,
) -> impl Iterator<Item = (KeyPath, SpecifierMapEntry<'_>)> {
Expand Down
Loading

0 comments on commit b440d2d

Please sign in to comment.