From 427b73c3ec1e01ca8c670d403a85fcf31777d253 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bartek=20Iwa=C5=84czuk?= Date: Tue, 23 Jan 2024 15:33:07 +0100 Subject: feat: warn when using --unstable, prefer granular flags (#21452) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This commit deprecates "--unstable" flag. When "--unstable" flag is encountered a warning like this is printed: ``` The `--unstable` flag is deprecated, use granular `--unstable-*` flags instead. Learn more at: https://docs.deno.com/runtime/manual/tools/unstable_flags ``` When "--unstable" flag is used and an unstable API is called an additional warning like this is printed for each API call: ``` The `Deno.dlopen` API was used with `--unstable` flag. The `--unstable` flag is deprecated, use granular `--unstable-ffi` instead. Learn more at: https://docs.deno.com/runtime/manual/tools/unstable_flags ``` When no "--unstable-*" flag is provided and an unstable API is called following warning is issued before exiting: ``` Unstable API 'Deno.dlopen'. The `--unstable-ffi` flag must be provided. ``` --------- Signed-off-by: Divy Srivastava Signed-off-by: Bartek IwaƄczuk Co-authored-by: Divy Srivastava Co-authored-by: Asher Gomez --- runtime/ops/bootstrap.rs | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'runtime/ops/bootstrap.rs') diff --git a/runtime/ops/bootstrap.rs b/runtime/ops/bootstrap.rs index 1d4039d73..7de532a9f 100644 --- a/runtime/ops/bootstrap.rs +++ b/runtime/ops/bootstrap.rs @@ -17,6 +17,7 @@ deno_core::extension!( op_bootstrap_log_level, op_bootstrap_no_color, op_bootstrap_is_tty, + op_bootstrap_unstable_args, op_snapshot_options, ], options = { @@ -69,6 +70,23 @@ pub fn op_bootstrap_user_agent(state: &mut OpState) -> String { state.borrow::().user_agent.clone() } +#[op2] +#[serde] +pub fn op_bootstrap_unstable_args(state: &mut OpState) -> Vec { + let options = state.borrow::(); + if options.unstable { + return vec!["--unstable".to_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)); + } + } + flags +} + #[op2] #[string] pub fn op_bootstrap_language(state: &mut OpState) -> String { -- cgit v1.2.3