Skip to content
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

feat(outdated): interactive update #27812

Merged
merged 9 commits into from
Feb 4, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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