From 8d5c0112fbbed188f97218ace2357feba3a8746f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bartek=20Iwa=C5=84czuk?= Date: Thu, 10 Nov 2022 22:03:28 +0100 Subject: feat: don't require --unstable flag for npm programs (#16520) This PR adds copies of several unstable APIs that are available in "Deno[Deno.internal].nodeUnstable" namespace. These copies do not perform unstable check (ie. don't require "--unstable" flag to be present). Otherwise they work exactly the same, including permission checks. These APIs are not meant to be used by users directly and can change at any time. Copies of following APIs are available in that namespace: - Deno.spawnChild - Deno.spawn - Deno.spawnSync - Deno.serve - Deno.upgradeHttpRaw - Deno.listenDatagram --- cli/ops/mod.rs | 6 ------ cli/proc_state.rs | 1 + cli/tests/integration/npm_tests.rs | 11 ++--------- 3 files changed, 3 insertions(+), 15 deletions(-) (limited to 'cli') diff --git a/cli/ops/mod.rs b/cli/ops/mod.rs index df3331353..c02b951b2 100644 --- a/cli/ops/mod.rs +++ b/cli/ops/mod.rs @@ -1,7 +1,6 @@ // Copyright 2018-2022 the Deno authors. All rights reserved. MIT license. use crate::proc_state::ProcState; -use deno_core::anyhow::bail; use deno_core::error::AnyError; use deno_core::op; use deno_core::Extension; @@ -27,10 +26,5 @@ fn init_proc_state(ps: ProcState) -> Extension { #[op] fn op_npm_process_state(state: &mut OpState) -> Result { let proc_state = state.borrow_mut::(); - if !proc_state.options.unstable() { - bail!( - "Unstable use of npm process state. The --unstable flag must be provided." - ) - } Ok(proc_state.npm_resolver.get_npm_process_state()) } diff --git a/cli/proc_state.rs b/cli/proc_state.rs index 117451c56..29f4ce3bd 100644 --- a/cli/proc_state.rs +++ b/cli/proc_state.rs @@ -274,6 +274,7 @@ impl ProcState { /// module before attempting to `load()` it from a `JsRuntime`. It will /// populate `self.graph_data` in memory with the necessary source code, write /// emits where necessary or report any module graph / type checking errors. + #[allow(clippy::too_many_arguments)] pub async fn prepare_module_load( &self, roots: Vec, diff --git a/cli/tests/integration/npm_tests.rs b/cli/tests/integration/npm_tests.rs index 1eb476287..ced9ad8a3 100644 --- a/cli/tests/integration/npm_tests.rs +++ b/cli/tests/integration/npm_tests.rs @@ -103,7 +103,7 @@ itest!(dual_cjs_esm { }); itest!(child_process_fork_test { - args: "run --unstable -A --quiet npm/child_process_fork_test/main.ts", + args: "run -A --quiet npm/child_process_fork_test/main.ts", output: "npm/child_process_fork_test/main.out", envs: env_vars(), http_server: true, @@ -621,7 +621,7 @@ itest!(node_modules_dir_with_deps { }); itest!(node_modules_dir_yargs { - args: "run --allow-read --allow-env --unstable --node-modules-dir $TESTDATA/npm/cjs_yargs/main.js", + args: "run --allow-read --allow-env --node-modules-dir $TESTDATA/npm/cjs_yargs/main.js", output: "npm/cjs_yargs/main.out", envs: env_vars(), http_server: true, @@ -1050,7 +1050,6 @@ fn peer_deps_with_copied_folders_and_lockfile() { let deno = util::deno_cmd_with_deno_dir(&deno_dir) .current_dir(temp_dir.path()) .arg("run") - .arg("--unstable") .arg("-A") .arg("main.ts") .envs(env_vars()) @@ -1082,7 +1081,6 @@ fn peer_deps_with_copied_folders_and_lockfile() { let deno = util::deno_cmd_with_deno_dir(&deno_dir) .current_dir(temp_dir.path()) .arg("run") - .arg("--unstable") .arg("-A") .arg("main.ts") .envs(env_vars()) @@ -1097,7 +1095,6 @@ fn peer_deps_with_copied_folders_and_lockfile() { let deno = util::deno_cmd_with_deno_dir(&deno_dir) .current_dir(temp_dir.path()) .arg("run") - .arg("--unstable") .arg("--reload") .arg("-A") .arg("main.ts") @@ -1114,7 +1111,6 @@ fn peer_deps_with_copied_folders_and_lockfile() { let deno = util::deno_cmd_with_deno_dir(&deno_dir) .current_dir(temp_dir.path()) .arg("run") - .arg("--unstable") .arg("--node-modules-dir") .arg("-A") .arg("main.ts") @@ -1139,7 +1135,6 @@ fn peer_deps_with_copied_folders_and_lockfile() { let deno = util::deno_cmd_with_deno_dir(&deno_dir) .current_dir(temp_dir.path()) .arg("run") - .arg("--unstable") .arg("--node-modules-dir") .arg("-A") .arg("main.ts") @@ -1156,7 +1151,6 @@ fn peer_deps_with_copied_folders_and_lockfile() { let deno = util::deno_cmd_with_deno_dir(&deno_dir) .current_dir(temp_dir.path()) .arg("run") - .arg("--unstable") .arg("--node-modules-dir") .arg("--reload") .arg("-A") @@ -1174,7 +1168,6 @@ fn peer_deps_with_copied_folders_and_lockfile() { let deno = util::deno_cmd_with_deno_dir(&deno_dir) .current_dir(temp_dir.path()) .arg("run") - .arg("--unstable") .arg("--node-modules-dir") .arg("--no-lock") .arg("--reload") -- cgit v1.2.3