0
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2025-03-03 17:34:47 -05:00

fix: add info suggestion for unsafely-ignore-certificate-errors and add --help=full (#28203)

For #27865
This commit is contained in:
Leo Kettmeir 2025-02-24 17:20:59 +01:00 committed by GitHub
parent bc71eb9541
commit 0fbab02d0f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 72 additions and 58 deletions

22
Cargo.lock generated
View file

@ -856,18 +856,18 @@ dependencies = [
[[package]]
name = "clap"
version = "4.5.16"
version = "4.5.30"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ed6719fffa43d0d87e5fd8caeab59be1554fb028cd30edc88fc4369b17971019"
checksum = "92b7b18d71fad5313a1e320fa9897994228ce274b60faa4d694fe0ea89cd9e6d"
dependencies = [
"clap_builder",
]
[[package]]
name = "clap_builder"
version = "4.5.15"
version = "4.5.30"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "216aec2b177652e3846684cbfe25c9964d18ec45234f0f5da5157b207ed1aab6"
checksum = "a35db2071778a7344791a4fb4f95308b5673d219dee3ae348b86642574ecc90c"
dependencies = [
"anstream",
"anstyle",
@ -878,9 +878,9 @@ dependencies = [
[[package]]
name = "clap_complete"
version = "4.5.24"
version = "4.5.45"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6d7db6eca8c205649e8d3ccd05aa5042b1800a784e56bc7c43524fde8abbfa9b"
checksum = "1e3040c8291884ddf39445dc033c70abc2bc44a42f0a3a00571a0f483a83f0cd"
dependencies = [
"clap",
]
@ -897,9 +897,9 @@ dependencies = [
[[package]]
name = "clap_lex"
version = "0.7.2"
version = "0.7.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1462739cb27611015575c0c11df5df7601141071f07518d56fcc1be504cbec97"
checksum = "f46ad14479a25103f283c0f10005961cf086d8dc42205bb44c46ac563475dca6"
[[package]]
name = "cli_tests"
@ -8268,12 +8268,12 @@ dependencies = [
[[package]]
name = "terminal_size"
version = "0.3.0"
version = "0.4.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "21bebf2b7c9e0a515f6e0f8c51dc0f8e4696391e6f1ff30379559f8365fb0df7"
checksum = "5352447f921fda68cf61b4101566c0bdb5104eff6804d0678e5227580ab6a4e9"
dependencies = [
"rustix",
"windows-sys 0.48.0",
"windows-sys 0.59.0",
]
[[package]]

View file

@ -100,8 +100,8 @@ boxed_error.workspace = true
bytes.workspace = true
capacity_builder.workspace = true
chrono = { workspace = true, features = ["now"] }
clap = { version = "=4.5.16", features = ["env", "string", "wrap_help", "error-context"] }
clap_complete = "=4.5.24"
clap = { version = "=4.5.30", features = ["env", "string", "wrap_help", "error-context"] }
clap_complete = "=4.5.45"
clap_complete_fig = "=4.5.2"
color-print.workspace = true
console_static_text.workspace = true

View file

@ -1257,7 +1257,9 @@ pub fn flags_from_vec(args: Vec<OsString>) -> clap::error::Result<Flags> {
app
};
if help_expansion == "unstable"
if help_expansion == "full" {
subcommand = enable_full(subcommand);
} else if help_expansion == "unstable"
&& subcommand
.get_arguments()
.any(|arg| arg.get_id().as_str() == "unstable")
@ -1423,6 +1425,17 @@ fn enable_unstable(command: Command) -> Command {
})
}
fn enable_full(command: Command) -> Command {
command.mut_args(|arg| {
let long_help = arg.get_long_help();
if !long_help.is_some_and(|s| s.to_string() == "false") {
arg.hide(false)
} else {
arg
}
})
}
macro_rules! heading {
($($name:ident = $title:expr),+; $total:literal) => {
$(const $name: &str = $title;)+
@ -1547,11 +1560,11 @@ pub fn clap_root() -> Command {
Arg::new("help")
.short('h')
.long("help")
.hide(true)
.action(ArgAction::Append)
.num_args(0..=1)
.require_equals(true)
.value_parser(["unstable"])
.value_name("CONTEXT")
.value_parser(["unstable", "full"])
.global(true),
)
.arg(
@ -3464,7 +3477,7 @@ fn permission_args(app: Command, requires: Option<&'static str>) -> Command {
.action(ArgAction::Append)
.require_equals(true)
.value_name("PATH")
.help("Allow file system read access. Optionally specify allowed paths")
.long_help("false")
.value_hint(ValueHint::AnyPath)
.hide(true);
if let Some(requires) = requires {
@ -3481,7 +3494,7 @@ fn permission_args(app: Command, requires: Option<&'static str>) -> Command {
.action(ArgAction::Append)
.require_equals(true)
.value_name("PATH")
.help("Deny file system read access. Optionally specify denied paths")
.long_help("false")
.value_hint(ValueHint::AnyPath)
.hide(true);
if let Some(requires) = requires {
@ -3499,7 +3512,7 @@ fn permission_args(app: Command, requires: Option<&'static str>) -> Command {
.action(ArgAction::Append)
.require_equals(true)
.value_name("PATH")
.help("Allow file system write access. Optionally specify allowed paths")
.long_help("false")
.value_hint(ValueHint::AnyPath)
.hide(true);
if let Some(requires) = requires {
@ -3516,7 +3529,7 @@ fn permission_args(app: Command, requires: Option<&'static str>) -> Command {
.action(ArgAction::Append)
.require_equals(true)
.value_name("PATH")
.help("Deny file system write access. Optionally specify denied paths")
.long_help("false")
.value_hint(ValueHint::AnyPath)
.hide(true);
if let Some(requires) = requires {
@ -3534,7 +3547,7 @@ fn permission_args(app: Command, requires: Option<&'static str>) -> Command {
.use_value_delimiter(true)
.require_equals(true)
.value_name("IP_OR_HOSTNAME")
.help("Allow network access. Optionally specify allowed IP addresses and host names, with ports as necessary")
.long_help("false")
.value_parser(flags_net::validator)
.hide(true);
if let Some(requires) = requires {
@ -3551,10 +3564,9 @@ fn permission_args(app: Command, requires: Option<&'static str>) -> Command {
.use_value_delimiter(true)
.require_equals(true)
.value_name("IP_OR_HOSTNAME")
.help("Deny network access. Optionally specify denied IP addresses and host names, with ports as necessary")
.long_help("false")
.value_parser(flags_net::validator)
.hide(true)
;
.hide(true);
if let Some(requires) = requires {
arg = arg.requires(requires)
}
@ -3570,7 +3582,7 @@ fn permission_args(app: Command, requires: Option<&'static str>) -> Command {
.use_value_delimiter(true)
.require_equals(true)
.value_name("VARIABLE_NAME")
.help("Allow access to system environment information. Optionally specify accessible environment variables")
.long_help("false")
.value_parser(|key: &str| {
if key.is_empty() || key.contains(&['=', '\0'] as &[char]) {
return Err(format!("invalid key \"{key}\""));
@ -3582,8 +3594,7 @@ fn permission_args(app: Command, requires: Option<&'static str>) -> Command {
key.to_string()
})
})
.hide(true)
;
.hide(true);
if let Some(requires) = requires {
arg = arg.requires(requires)
}
@ -3598,7 +3609,7 @@ fn permission_args(app: Command, requires: Option<&'static str>) -> Command {
.use_value_delimiter(true)
.require_equals(true)
.value_name("VARIABLE_NAME")
.help("Deny access to system environment information. Optionally specify accessible environment variables")
.long_help("false")
.value_parser(|key: &str| {
if key.is_empty() || key.contains(&['=', '\0'] as &[char]) {
return Err(format!("invalid key \"{key}\""));
@ -3610,8 +3621,7 @@ fn permission_args(app: Command, requires: Option<&'static str>) -> Command {
key.to_string()
})
})
.hide(true)
;
.hide(true);
if let Some(requires) = requires {
arg = arg.requires(requires)
}
@ -3627,10 +3637,9 @@ fn permission_args(app: Command, requires: Option<&'static str>) -> Command {
.use_value_delimiter(true)
.require_equals(true)
.value_name("API_NAME")
.help("Allow access to OS information. Optionally allow specific APIs by function name")
.long_help("false")
.value_parser(|key: &str| SysDescriptor::parse(key.to_string()).map(|s| s.into_string()))
.hide(true)
;
.hide(true);
if let Some(requires) = requires {
arg = arg.requires(requires)
}
@ -3645,10 +3654,9 @@ fn permission_args(app: Command, requires: Option<&'static str>) -> Command {
.use_value_delimiter(true)
.require_equals(true)
.value_name("API_NAME")
.help("Deny access to OS information. Optionally deny specific APIs by function name")
.long_help("false")
.value_parser(|key: &str| SysDescriptor::parse(key.to_string()).map(|s| s.into_string()))
.hide(true)
;
.hide(true);
if let Some(requires) = requires {
arg = arg.requires(requires)
}
@ -3663,9 +3671,8 @@ fn permission_args(app: Command, requires: Option<&'static str>) -> Command {
.use_value_delimiter(true)
.require_equals(true)
.value_name("PROGRAM_NAME")
.help("Allow running subprocesses. Optionally specify allowed runnable program names")
.hide(true)
;
.long_help("false")
.hide(true);
if let Some(requires) = requires {
arg = arg.requires(requires)
}
@ -3680,9 +3687,8 @@ fn permission_args(app: Command, requires: Option<&'static str>) -> Command {
.use_value_delimiter(true)
.require_equals(true)
.value_name("PROGRAM_NAME")
.help("Deny running subprocesses. Optionally specify denied runnable program names")
.hide(true)
;
.long_help("false")
.hide(true);
if let Some(requires) = requires {
arg = arg.requires(requires)
}
@ -3698,7 +3704,7 @@ fn permission_args(app: Command, requires: Option<&'static str>) -> Command {
.action(ArgAction::Append)
.require_equals(true)
.value_name("PATH")
.help("(Unstable) Allow loading dynamic libraries. Optionally specify allowed directories or files")
.long_help("false")
.value_hint(ValueHint::AnyPath)
.hide(true);
if let Some(requires) = requires {
@ -3715,7 +3721,7 @@ fn permission_args(app: Command, requires: Option<&'static str>) -> Command {
.action(ArgAction::Append)
.require_equals(true)
.value_name("PATH")
.help("(Unstable) Deny loading dynamic libraries. Optionally specify denied directories or files")
.long_help("false")
.value_hint(ValueHint::AnyPath)
.hide(true);
if let Some(requires) = requires {
@ -3729,7 +3735,7 @@ fn permission_args(app: Command, requires: Option<&'static str>) -> Command {
let mut arg = Arg::new("allow-hrtime")
.long("allow-hrtime")
.action(ArgAction::SetTrue)
.help("REMOVED in Deno 2.0")
.long_help("false")
.hide(true);
if let Some(requires) = requires {
arg = arg.requires(requires)
@ -3742,7 +3748,7 @@ fn permission_args(app: Command, requires: Option<&'static str>) -> Command {
let mut arg = Arg::new("deny-hrtime")
.long("deny-hrtime")
.action(ArgAction::SetTrue)
.help("REMOVED in Deno 2.0")
.long_help("false")
.hide(true);
if let Some(requires) = requires {
arg = arg.requires(requires)
@ -3756,7 +3762,7 @@ fn permission_args(app: Command, requires: Option<&'static str>) -> Command {
.long("no-prompt")
.action(ArgAction::SetTrue)
.hide(true)
.help("Always throw if required permission wasn't passed");
.long_help("false");
if let Some(requires) = requires {
arg = arg.requires(requires)
}
@ -4623,11 +4629,11 @@ fn completions_parse(
matches: &mut ArgMatches,
mut app: Command,
) {
use clap_complete::generate;
use clap_complete::shells::Bash;
use clap_complete::shells::Fish;
use clap_complete::shells::PowerShell;
use clap_complete::shells::Zsh;
use clap_complete::aot::generate;
use clap_complete::aot::Bash;
use clap_complete::aot::Fish;
use clap_complete::aot::PowerShell;
use clap_complete::aot::Zsh;
use clap_complete_fig::Fig;
let mut buf: Vec<u8> = vec![];

View file

@ -437,6 +437,12 @@ fn get_suggestions_for_terminal_errors(e: &JsError) -> Vec<FixSuggestion> {
"Run again with `--unstable-net` flag to enable this API.",
),
];
} else if msg.contains("client error (Connect): invalid peer certificate") {
return vec![
FixSuggestion::hint(
"Run again with the `--unsafely-ignore-certificate-errors` flag to bypass certificate errors.",
),
];
// Try to capture errors like:
// ```
// Uncaught Error: Cannot find module '../build/Release/canvas.node'

View file

@ -5,6 +5,7 @@ See the Deno 1.x to 2.x Migration Guide for migration instructions: https://docs
Usage: deno bundle [OPTIONS]
Options:
-q, --quiet Suppress diagnostic output
--unstable The `--unstable` flag has been deprecated. Use granular `--unstable-*` flags instead
To view the list of individual unstable feature flags, run this command again with --help=unstable
-h, --help[=<CONTEXT>] [possible values: unstable, full]
-q, --quiet Suppress diagnostic output
--unstable The `--unstable` flag has been deprecated. Use granular `--unstable-*` flags instead
To view the list of individual unstable feature flags, run this command again with --help=unstable

View file

@ -5,6 +5,7 @@ See the Deno 1.x to 2.x Migration Guide for migration instructions: https://docs
Usage: deno vendor [OPTIONS]
Options:
-q, --quiet Suppress diagnostic output
--unstable The `--unstable` flag has been deprecated. Use granular `--unstable-*` flags instead
To view the list of individual unstable feature flags, run this command again with --help=unstable
-h, --help[=<CONTEXT>] [possible values: unstable, full]
-q, --quiet Suppress diagnostic output
--unstable The `--unstable` flag has been deprecated. Use granular `--unstable-*` flags instead
To view the list of individual unstable feature flags, run this command again with --help=unstable