summaryrefslogtreecommitdiff
path: root/cli/main.rs
diff options
context:
space:
mode:
authorBartek IwaƄczuk <biwanczuk@gmail.com>2023-11-01 23:15:08 +0100
committerGitHub <noreply@github.com>2023-11-01 23:15:08 +0100
commit24c3c9695865bb478f5651da4982b7e0a34afc72 (patch)
tree5afe78a8c67bb9e9c1cd69d56a9a0c68bca67515 /cli/main.rs
parent42c426e7695a0037032d1ac5237830800eeaaed4 (diff)
feat: granular --unstable-* flags (#20968)
This commit adds granular `--unstable-*` flags: - "--unstable-broadcast-channel" - "--unstable-ffi" - "--unstable-fs" - "--unstable-http" - "--unstable-kv" - "--unstable-net" - "--unstable-worker-options" - "--unstable-cron" These flags are meant to replace a "catch-all" flag - "--unstable", that gives a binary control whether unstable features are enabled or not. The downside of this flag that allowing eg. Deno KV API also enables the FFI API (though the latter is still gated with a permission). These flags can also be specified in `deno.json` file under `unstable` key. Currently, "--unstable" flag works the same way - I will open a follow up PR that will print a warning when using "--unstable" and suggest to use concrete "--unstable-*" flag instead. We plan to phase out "--unstable" completely in Deno 2.
Diffstat (limited to 'cli/main.rs')
-rw-r--r--cli/main.rs51
1 files changed, 51 insertions, 0 deletions
diff --git a/cli/main.rs b/cli/main.rs
index 7a8647a81..24b964169 100644
--- a/cli/main.rs
+++ b/cli/main.rs
@@ -256,6 +256,57 @@ fn unwrap_or_exit<T>(result: Result<T, AnyError>) -> T {
}
}
+// NOTE(bartlomieju): keep IDs in sync with `runtime/90_deno_ns.js`.
+pub(crate) static UNSTABLE_GRANULAR_FLAGS: &[(
+ // flag name
+ &str,
+ // help text
+ &str,
+ // id to enable it in runtime/99_main.js
+ i32,
+)] = &[
+ (
+ deno_runtime::deno_broadcast_channel::UNSTABLE_FEATURE_NAME,
+ "Enable unstable `BroadcastChannel` API",
+ 1,
+ ),
+ (
+ deno_runtime::deno_ffi::UNSTABLE_FEATURE_NAME,
+ "Enable unstable FFI APIs",
+ 2,
+ ),
+ (
+ deno_runtime::deno_fs::UNSTABLE_FEATURE_NAME,
+ "Enable unstable file system APIs",
+ 3,
+ ),
+ (
+ deno_runtime::deno_kv::UNSTABLE_FEATURE_NAME,
+ "Enable unstable Key-Value store APIs",
+ 4,
+ ),
+ (
+ deno_runtime::deno_net::UNSTABLE_FEATURE_NAME,
+ "Enable unstable net APIs",
+ 5,
+ ),
+ (
+ deno_runtime::ops::http::UNSTABLE_FEATURE_NAME,
+ "Enable unstable HTTP APIs",
+ 6,
+ ),
+ (
+ deno_runtime::ops::worker_host::UNSTABLE_FEATURE_NAME,
+ "Enable unstable Web Worker APIs",
+ 7,
+ ),
+ (
+ deno_runtime::deno_cron::UNSTABLE_FEATURE_NAME,
+ "Enable unstable Deno.cron API",
+ 8,
+ ),
+];
+
pub(crate) fn unstable_exit_cb(_feature: &str, api_name: &str) {
// TODO(bartlomieju): change to "The `--unstable-{feature}` flag must be provided.".
eprintln!("Unstable API '{api_name}'. The --unstable flag must be provided.");