summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHasanAlrimawi <141642411+HasanAlrimawi@users.noreply.github.com>2024-08-27 14:45:27 +0300
committerGitHub <noreply@github.com>2024-08-27 13:45:27 +0200
commit672ce3041a3dd9e2a6aab5f0ef79ec2be9cf1cba (patch)
tree4ae58965c192806280c7c9711d5764a6377db0df
parent7e68cce8159d55fd597f0da3e00f794200b9928f (diff)
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>
-rw-r--r--cli/args/flags.rs30
-rw-r--r--cli/args/mod.rs2
-rw-r--r--cli/factory.rs6
-rw-r--r--cli/worker.rs12
-rw-r--r--runtime/lib.rs147
-rw-r--r--runtime/ops/bootstrap.rs6
6 files changed, 114 insertions, 89 deletions
diff --git a/cli/args/flags.rs b/cli/args/flags.rs
index de6358359..877b26de2 100644
--- a/cli/args/flags.rs
+++ b/cli/args/flags.rs
@@ -4042,18 +4042,23 @@ impl Iterator for UnstableArgsIter {
})
.help_heading(UNSTABLE_HEADING)
} else if self.idx > 3 {
- let (flag_name, help, _) =
- crate::UNSTABLE_GRANULAR_FLAGS.get(self.idx - 4)?;
- Arg::new(format!("unstable-{}", flag_name))
- .long(format!("unstable-{}", flag_name))
- .help(help)
+ let granular_flag = crate::UNSTABLE_GRANULAR_FLAGS.get(self.idx - 4)?;
+ Arg::new(format!("unstable-{}", granular_flag.name))
+ .long(format!("unstable-{}", granular_flag.name))
+ .help(granular_flag.help_text)
.action(ArgAction::SetTrue)
.hide(true)
.help_heading(UNSTABLE_HEADING)
// we don't render long help, so using it here as a sort of metadata
- .long_help(match self.cfg {
- UnstableArgsConfig::None | UnstableArgsConfig::ResolutionOnly => None,
- UnstableArgsConfig::ResolutionAndRuntime => Some("true"),
+ .long_help(if granular_flag.show_in_help {
+ match self.cfg {
+ UnstableArgsConfig::None | UnstableArgsConfig::ResolutionOnly => {
+ None
+ }
+ UnstableArgsConfig::ResolutionAndRuntime => Some("true"),
+ }
+ } else {
+ None
})
} else {
return None;
@@ -5405,9 +5410,12 @@ fn unstable_args_parse(
matches.get_flag("unstable-sloppy-imports");
if matches!(cfg, UnstableArgsConfig::ResolutionAndRuntime) {
- for (name, _, _) in crate::UNSTABLE_GRANULAR_FLAGS {
- if matches.get_flag(&format!("unstable-{}", name)) {
- flags.unstable_config.features.push(name.to_string());
+ for granular_flag in crate::UNSTABLE_GRANULAR_FLAGS {
+ if matches.get_flag(&format!("unstable-{}", granular_flag.name)) {
+ flags
+ .unstable_config
+ .features
+ .push(granular_flag.name.to_string());
}
}
}
diff --git a/cli/args/mod.rs b/cli/args/mod.rs
index 056dcb2af..a6b547fd7 100644
--- a/cli/args/mod.rs
+++ b/cli/args/mod.rs
@@ -1669,7 +1669,7 @@ impl CliOptions {
let mut all_valid_unstable_flags: Vec<&str> =
crate::UNSTABLE_GRANULAR_FLAGS
.iter()
- .map(|granular_flag| granular_flag.0)
+ .map(|granular_flag| granular_flag.name)
.collect();
let mut another_unstable_flags = Vec::from([
diff --git a/cli/factory.rs b/cli/factory.rs
index 224984643..1d1639815 100644
--- a/cli/factory.rs
+++ b/cli/factory.rs
@@ -723,9 +723,9 @@ impl CliFactory {
checker.warn_on_legacy_unstable();
}
let unstable_features = cli_options.unstable_features();
- for (flag_name, _, _) in crate::UNSTABLE_GRANULAR_FLAGS {
- if unstable_features.contains(&flag_name.to_string()) {
- checker.enable_feature(flag_name);
+ for granular_flag in crate::UNSTABLE_GRANULAR_FLAGS {
+ if unstable_features.contains(&granular_flag.name.to_string()) {
+ checker.enable_feature(granular_flag.name);
}
}
diff --git a/cli/worker.rs b/cli/worker.rs
index 09aa1aec4..31a88ae4e 100644
--- a/cli/worker.rs
+++ b/cli/worker.rs
@@ -573,9 +573,9 @@ impl CliMainWorkerFactory {
let feature_checker = shared.feature_checker.clone();
let mut unstable_features =
Vec::with_capacity(crate::UNSTABLE_GRANULAR_FLAGS.len());
- for (feature_name, _, id) in crate::UNSTABLE_GRANULAR_FLAGS {
- if feature_checker.check(feature_name) {
- unstable_features.push(*id);
+ for granular_flag in crate::UNSTABLE_GRANULAR_FLAGS {
+ if feature_checker.check(granular_flag.name) {
+ unstable_features.push(granular_flag.id);
}
}
@@ -771,9 +771,9 @@ fn create_web_worker_callback(
let feature_checker = shared.feature_checker.clone();
let mut unstable_features =
Vec::with_capacity(crate::UNSTABLE_GRANULAR_FLAGS.len());
- for (feature_name, _, id) in crate::UNSTABLE_GRANULAR_FLAGS {
- if feature_checker.check(feature_name) {
- unstable_features.push(*id);
+ for granular_flag in crate::UNSTABLE_GRANULAR_FLAGS {
+ if feature_checker.check(granular_flag.name) {
+ unstable_features.push(granular_flag.id);
}
}
diff --git a/runtime/lib.rs b/runtime/lib.rs
index 6b89d0611..0b3abba3d 100644
--- a/runtime/lib.rs
+++ b/runtime/lib.rs
@@ -47,73 +47,90 @@ mod shared;
pub use shared::import_assertion_callback;
pub use shared::runtime;
-// NOTE(bartlomieju): keep IDs in sync with `runtime/90_deno_ns.js` (search for `unstableFeatures`)
-pub static UNSTABLE_GRANULAR_FLAGS: &[(
- // flag name
- &str,
- // help text
- &str,
+pub struct UnstableGranularFlag {
+ pub name: &'static str,
+ pub help_text: &'static str,
+ pub show_in_help: bool,
// id to enable it in runtime/99_main.js
- i32,
-)] = &[
- (
- deno_broadcast_channel::UNSTABLE_FEATURE_NAME,
- "Enable unstable `BroadcastChannel` API",
- 1,
- ),
- (
- deno_cron::UNSTABLE_FEATURE_NAME,
- "Enable unstable Deno.cron API",
- 2,
- ),
- (
- deno_ffi::UNSTABLE_FEATURE_NAME,
- "Enable unstable FFI APIs",
- 3,
- ),
- (
- deno_fs::UNSTABLE_FEATURE_NAME,
- "Enable unstable file system APIs",
- 4,
- ),
- (
- ops::http::UNSTABLE_FEATURE_NAME,
- "Enable unstable HTTP APIs",
- 5,
- ),
- (
- deno_kv::UNSTABLE_FEATURE_NAME,
- "Enable unstable Key-Value store APIs",
- 6,
- ),
- (
- deno_net::UNSTABLE_FEATURE_NAME,
- "Enable unstable net APIs",
- 7,
- ),
- (
- ops::process::UNSTABLE_FEATURE_NAME,
- "Enable unstable process APIs",
- 8,
- ),
- ("temporal", "Enable unstable Temporal API", 9),
- (
- "unsafe-proto",
- "Enable unsafe __proto__ support. This is a security risk.",
+ pub id: i32,
+}
+
+// NOTE(bartlomieju): keep IDs in sync with `runtime/90_deno_ns.js` (search for `unstableFeatures`)
+pub static UNSTABLE_GRANULAR_FLAGS: &[UnstableGranularFlag] = &[
+ UnstableGranularFlag {
+ name: deno_broadcast_channel::UNSTABLE_FEATURE_NAME,
+ help_text: "Enable unstable `BroadcastChannel` API",
+ show_in_help: true,
+ id: 1,
+ },
+ UnstableGranularFlag {
+ name: deno_cron::UNSTABLE_FEATURE_NAME,
+ help_text: "Enable unstable Deno.cron API",
+ show_in_help: true,
+ id: 2,
+ },
+ UnstableGranularFlag {
+ name: deno_ffi::UNSTABLE_FEATURE_NAME,
+ help_text: "Enable unstable FFI APIs",
+ show_in_help: true,
+ id: 3,
+ },
+ UnstableGranularFlag {
+ name: deno_fs::UNSTABLE_FEATURE_NAME,
+ help_text: "Enable unstable file system APIs",
+ show_in_help: true,
+ id: 4,
+ },
+ UnstableGranularFlag {
+ name: ops::http::UNSTABLE_FEATURE_NAME,
+ help_text: "Enable unstable HTTP APIs",
+ show_in_help: false,
+ id: 5,
+ },
+ UnstableGranularFlag {
+ name: deno_kv::UNSTABLE_FEATURE_NAME,
+ help_text: "Enable unstable Key-Value store APIs",
+ show_in_help: true,
+ id: 6,
+ },
+ UnstableGranularFlag {
+ name: deno_net::UNSTABLE_FEATURE_NAME,
+ help_text: "Enable unstable net APIs",
+ show_in_help: true,
+ 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
// for "unstableIds" to see where it's used.
- 10,
- ),
- (
- deno_webgpu::UNSTABLE_FEATURE_NAME,
- "Enable unstable `WebGPU` API",
- 11,
- ),
- (
- ops::worker_host::UNSTABLE_FEATURE_NAME,
- "Enable unstable Web Worker APIs",
- 12,
- ),
+ id: 10,
+ },
+ UnstableGranularFlag {
+ name: deno_webgpu::UNSTABLE_FEATURE_NAME,
+ help_text: "Enable unstable `WebGPU` API",
+ show_in_help: true,
+ id: 11,
+ },
+ UnstableGranularFlag {
+ name: ops::worker_host::UNSTABLE_FEATURE_NAME,
+ help_text: "Enable unstable Web Worker APIs",
+ show_in_help: true,
+ id: 12,
+ },
];
#[cfg(test)]
@@ -124,7 +141,7 @@ mod test {
fn unstable_granular_flag_names_sorted() {
let flags = UNSTABLE_GRANULAR_FLAGS
.iter()
- .map(|(name, _, _)| name.to_string())
+ .map(|granular_flag| granular_flag.name.to_string())
.collect::<Vec<_>>();
let mut sorted_flags = flags.clone();
sorted_flags.sort();
diff --git a/runtime/ops/bootstrap.rs b/runtime/ops/bootstrap.rs
index 0d8c1dab8..a60544534 100644
--- a/runtime/ops/bootstrap.rs
+++ b/runtime/ops/bootstrap.rs
@@ -100,9 +100,9 @@ pub fn op_bootstrap_unstable_args(state: &mut OpState) -> Vec<String> {
}
let mut flags = Vec::new();
- for (name, _, id) in crate::UNSTABLE_GRANULAR_FLAGS.iter() {
- if options.unstable_features.contains(id) {
- flags.push(format!("--unstable-{}", name));
+ for granular_flag in crate::UNSTABLE_GRANULAR_FLAGS.iter() {
+ if options.unstable_features.contains(&granular_flag.id) {
+ flags.push(format!("--unstable-{}", granular_flag.name));
}
}
flags