0
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2025-02-08 15:21:26 -05:00

fix: removed unstable-htttp from deno help (#25216)

Closes #25210 .

Removed --unstable-http from being displayed on deno run --help=unstable

---------

Co-authored-by: Bartek Iwańczuk <biwanczuk@gmail.com>
This commit is contained in:
HasanAlrimawi 2024-08-27 14:45:27 +03:00 committed by Luca Casonato
parent 1d2116d94a
commit 9fad717c29
No known key found for this signature in database
GPG key ID: 01A83EB62563811F
6 changed files with 114 additions and 89 deletions

View file

@ -4042,18 +4042,23 @@ impl Iterator for UnstableArgsIter {
}) })
.help_heading(UNSTABLE_HEADING) .help_heading(UNSTABLE_HEADING)
} else if self.idx > 3 { } else if self.idx > 3 {
let (flag_name, help, _) = let granular_flag = crate::UNSTABLE_GRANULAR_FLAGS.get(self.idx - 4)?;
crate::UNSTABLE_GRANULAR_FLAGS.get(self.idx - 4)?; Arg::new(format!("unstable-{}", granular_flag.name))
Arg::new(format!("unstable-{}", flag_name)) .long(format!("unstable-{}", granular_flag.name))
.long(format!("unstable-{}", flag_name)) .help(granular_flag.help_text)
.help(help)
.action(ArgAction::SetTrue) .action(ArgAction::SetTrue)
.hide(true) .hide(true)
.help_heading(UNSTABLE_HEADING) .help_heading(UNSTABLE_HEADING)
// we don't render long help, so using it here as a sort of metadata // we don't render long help, so using it here as a sort of metadata
.long_help(match self.cfg { .long_help(if granular_flag.show_in_help {
UnstableArgsConfig::None | UnstableArgsConfig::ResolutionOnly => None, match self.cfg {
UnstableArgsConfig::None | UnstableArgsConfig::ResolutionOnly => {
None
}
UnstableArgsConfig::ResolutionAndRuntime => Some("true"), UnstableArgsConfig::ResolutionAndRuntime => Some("true"),
}
} else {
None
}) })
} else { } else {
return None; return None;
@ -5405,9 +5410,12 @@ fn unstable_args_parse(
matches.get_flag("unstable-sloppy-imports"); matches.get_flag("unstable-sloppy-imports");
if matches!(cfg, UnstableArgsConfig::ResolutionAndRuntime) { if matches!(cfg, UnstableArgsConfig::ResolutionAndRuntime) {
for (name, _, _) in crate::UNSTABLE_GRANULAR_FLAGS { for granular_flag in crate::UNSTABLE_GRANULAR_FLAGS {
if matches.get_flag(&format!("unstable-{}", name)) { if matches.get_flag(&format!("unstable-{}", granular_flag.name)) {
flags.unstable_config.features.push(name.to_string()); flags
.unstable_config
.features
.push(granular_flag.name.to_string());
} }
} }
} }

View file

@ -1669,7 +1669,7 @@ impl CliOptions {
let mut all_valid_unstable_flags: Vec<&str> = let mut all_valid_unstable_flags: Vec<&str> =
crate::UNSTABLE_GRANULAR_FLAGS crate::UNSTABLE_GRANULAR_FLAGS
.iter() .iter()
.map(|granular_flag| granular_flag.0) .map(|granular_flag| granular_flag.name)
.collect(); .collect();
let mut another_unstable_flags = Vec::from([ let mut another_unstable_flags = Vec::from([

View file

@ -720,9 +720,9 @@ impl CliFactory {
checker.warn_on_legacy_unstable(); checker.warn_on_legacy_unstable();
} }
let unstable_features = cli_options.unstable_features(); let unstable_features = cli_options.unstable_features();
for (flag_name, _, _) in crate::UNSTABLE_GRANULAR_FLAGS { for granular_flag in crate::UNSTABLE_GRANULAR_FLAGS {
if unstable_features.contains(&flag_name.to_string()) { if unstable_features.contains(&granular_flag.name.to_string()) {
checker.enable_feature(flag_name); checker.enable_feature(granular_flag.name);
} }
} }

View file

@ -573,9 +573,9 @@ impl CliMainWorkerFactory {
let feature_checker = shared.feature_checker.clone(); let feature_checker = shared.feature_checker.clone();
let mut unstable_features = let mut unstable_features =
Vec::with_capacity(crate::UNSTABLE_GRANULAR_FLAGS.len()); Vec::with_capacity(crate::UNSTABLE_GRANULAR_FLAGS.len());
for (feature_name, _, id) in crate::UNSTABLE_GRANULAR_FLAGS { for granular_flag in crate::UNSTABLE_GRANULAR_FLAGS {
if feature_checker.check(feature_name) { if feature_checker.check(granular_flag.name) {
unstable_features.push(*id); unstable_features.push(granular_flag.id);
} }
} }
@ -771,9 +771,9 @@ fn create_web_worker_callback(
let feature_checker = shared.feature_checker.clone(); let feature_checker = shared.feature_checker.clone();
let mut unstable_features = let mut unstable_features =
Vec::with_capacity(crate::UNSTABLE_GRANULAR_FLAGS.len()); Vec::with_capacity(crate::UNSTABLE_GRANULAR_FLAGS.len());
for (feature_name, _, id) in crate::UNSTABLE_GRANULAR_FLAGS { for granular_flag in crate::UNSTABLE_GRANULAR_FLAGS {
if feature_checker.check(feature_name) { if feature_checker.check(granular_flag.name) {
unstable_features.push(*id); unstable_features.push(granular_flag.id);
} }
} }

View file

@ -47,73 +47,90 @@ mod shared;
pub use shared::import_assertion_callback; pub use shared::import_assertion_callback;
pub use shared::runtime; pub use shared::runtime;
// NOTE(bartlomieju): keep IDs in sync with `runtime/90_deno_ns.js` (search for `unstableFeatures`) pub struct UnstableGranularFlag {
pub static UNSTABLE_GRANULAR_FLAGS: &[( pub name: &'static str,
// flag name pub help_text: &'static str,
&str, pub show_in_help: bool,
// help text
&str,
// id to enable it in runtime/99_main.js // id to enable it in runtime/99_main.js
i32, pub id: i32,
)] = &[ }
(
deno_broadcast_channel::UNSTABLE_FEATURE_NAME, // NOTE(bartlomieju): keep IDs in sync with `runtime/90_deno_ns.js` (search for `unstableFeatures`)
"Enable unstable `BroadcastChannel` API", pub static UNSTABLE_GRANULAR_FLAGS: &[UnstableGranularFlag] = &[
1, UnstableGranularFlag {
), name: deno_broadcast_channel::UNSTABLE_FEATURE_NAME,
( help_text: "Enable unstable `BroadcastChannel` API",
deno_cron::UNSTABLE_FEATURE_NAME, show_in_help: true,
"Enable unstable Deno.cron API", id: 1,
2, },
), UnstableGranularFlag {
( name: deno_cron::UNSTABLE_FEATURE_NAME,
deno_ffi::UNSTABLE_FEATURE_NAME, help_text: "Enable unstable Deno.cron API",
"Enable unstable FFI APIs", show_in_help: true,
3, id: 2,
), },
( UnstableGranularFlag {
deno_fs::UNSTABLE_FEATURE_NAME, name: deno_ffi::UNSTABLE_FEATURE_NAME,
"Enable unstable file system APIs", help_text: "Enable unstable FFI APIs",
4, show_in_help: true,
), id: 3,
( },
ops::http::UNSTABLE_FEATURE_NAME, UnstableGranularFlag {
"Enable unstable HTTP APIs", name: deno_fs::UNSTABLE_FEATURE_NAME,
5, help_text: "Enable unstable file system APIs",
), show_in_help: true,
( id: 4,
deno_kv::UNSTABLE_FEATURE_NAME, },
"Enable unstable Key-Value store APIs", UnstableGranularFlag {
6, name: ops::http::UNSTABLE_FEATURE_NAME,
), help_text: "Enable unstable HTTP APIs",
( show_in_help: false,
deno_net::UNSTABLE_FEATURE_NAME, id: 5,
"Enable unstable net APIs", },
7, UnstableGranularFlag {
), name: deno_kv::UNSTABLE_FEATURE_NAME,
( help_text: "Enable unstable Key-Value store APIs",
ops::process::UNSTABLE_FEATURE_NAME, show_in_help: true,
"Enable unstable process APIs", id: 6,
8, },
), UnstableGranularFlag {
("temporal", "Enable unstable Temporal API", 9), name: deno_net::UNSTABLE_FEATURE_NAME,
( help_text: "Enable unstable net APIs",
"unsafe-proto", show_in_help: true,
"Enable unsafe __proto__ support. This is a security risk.", id: 7,
},
UnstableGranularFlag {
name: ops::process::UNSTABLE_FEATURE_NAME,
help_text: "Enable unstable process APIs",
show_in_help: true,
id: 8,
},
UnstableGranularFlag {
name: "temporal",
help_text: "Enable unstable Temporal API",
show_in_help: true,
id: 9,
},
UnstableGranularFlag {
name: "unsafe-proto",
help_text: "Enable unsafe __proto__ support. This is a security risk.",
show_in_help: true,
// This number is used directly in the JS code. Search // This number is used directly in the JS code. Search
// for "unstableIds" to see where it's used. // for "unstableIds" to see where it's used.
10, id: 10,
), },
( UnstableGranularFlag {
deno_webgpu::UNSTABLE_FEATURE_NAME, name: deno_webgpu::UNSTABLE_FEATURE_NAME,
"Enable unstable `WebGPU` API", help_text: "Enable unstable `WebGPU` API",
11, show_in_help: true,
), id: 11,
( },
ops::worker_host::UNSTABLE_FEATURE_NAME, UnstableGranularFlag {
"Enable unstable Web Worker APIs", name: ops::worker_host::UNSTABLE_FEATURE_NAME,
12, help_text: "Enable unstable Web Worker APIs",
), show_in_help: true,
id: 12,
},
]; ];
#[cfg(test)] #[cfg(test)]
@ -124,7 +141,7 @@ mod test {
fn unstable_granular_flag_names_sorted() { fn unstable_granular_flag_names_sorted() {
let flags = UNSTABLE_GRANULAR_FLAGS let flags = UNSTABLE_GRANULAR_FLAGS
.iter() .iter()
.map(|(name, _, _)| name.to_string()) .map(|granular_flag| granular_flag.name.to_string())
.collect::<Vec<_>>(); .collect::<Vec<_>>();
let mut sorted_flags = flags.clone(); let mut sorted_flags = flags.clone();
sorted_flags.sort(); sorted_flags.sort();

View file

@ -100,9 +100,9 @@ pub fn op_bootstrap_unstable_args(state: &mut OpState) -> Vec<String> {
} }
let mut flags = Vec::new(); let mut flags = Vec::new();
for (name, _, id) in crate::UNSTABLE_GRANULAR_FLAGS.iter() { for granular_flag in crate::UNSTABLE_GRANULAR_FLAGS.iter() {
if options.unstable_features.contains(id) { if options.unstable_features.contains(&granular_flag.id) {
flags.push(format!("--unstable-{}", name)); flags.push(format!("--unstable-{}", granular_flag.name));
} }
} }
flags flags