mirror of
https://github.com/denoland/deno.git
synced 2024-11-21 15:04:11 -05:00
refactor: remove DENO_FUTURE (#25314)
This commit is contained in:
parent
55137c9db4
commit
f891e73bbf
42 changed files with 248 additions and 478 deletions
4
Cargo.lock
generated
4
Cargo.lock
generated
|
@ -1375,9 +1375,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "deno_config"
|
||||
version = "0.31.0"
|
||||
version = "0.32.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "efba70c2fbec59e6d0c6040376644803f2cebbb4d55a651cbab4794e390a8592"
|
||||
checksum = "c774f2e49b4ca47f1fe5c39e1775d1434280a4f168252fed8f4a3f2230868448"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"deno_package_json",
|
||||
|
|
|
@ -65,7 +65,7 @@ winres.workspace = true
|
|||
[dependencies]
|
||||
deno_ast = { workspace = true, features = ["bundler", "cjs", "codegen", "proposal", "react", "sourcemap", "transforms", "typescript", "view", "visit"] }
|
||||
deno_cache_dir = { workspace = true }
|
||||
deno_config = { version = "=0.31.0", features = ["workspace", "sync"] }
|
||||
deno_config = { version = "=0.32.0", features = ["workspace", "sync"] }
|
||||
deno_core = { workspace = true, features = ["include_js_files_for_snapshotting"] }
|
||||
deno_doc = { version = "0.148.0", features = ["html", "syntect"] }
|
||||
deno_emit = "=0.45.0"
|
||||
|
|
|
@ -10,7 +10,7 @@ use clap::ColorChoice;
|
|||
use clap::Command;
|
||||
use clap::ValueHint;
|
||||
use color_print::cstr;
|
||||
use deno_config::deno_json::NodeModulesMode;
|
||||
use deno_config::deno_json::NodeModulesDirMode;
|
||||
use deno_config::glob::FilePatterns;
|
||||
use deno_config::glob::PathOrPatternSet;
|
||||
use deno_core::anyhow::bail;
|
||||
|
@ -41,7 +41,6 @@ use crate::args::resolve_no_prompt;
|
|||
use crate::util::fs::canonicalize_path;
|
||||
|
||||
use super::flags_net;
|
||||
use super::DENO_FUTURE;
|
||||
|
||||
#[derive(Clone, Debug, Default, Eq, PartialEq)]
|
||||
pub enum ConfigFlag {
|
||||
|
@ -580,7 +579,6 @@ fn parse_packages_allowed_scripts(s: &str) -> Result<String, AnyError> {
|
|||
pub struct UnstableConfig {
|
||||
pub legacy_flag_enabled: bool, // --unstable
|
||||
pub bare_node_builtins: bool, // --unstable-bare-node-builts
|
||||
pub byonm: bool,
|
||||
pub sloppy_imports: bool,
|
||||
pub features: Vec<String>, // --unstabe-kv --unstable-cron
|
||||
}
|
||||
|
@ -602,8 +600,7 @@ pub struct Flags {
|
|||
pub cached_only: bool,
|
||||
pub type_check_mode: TypeCheckMode,
|
||||
pub config_flag: ConfigFlag,
|
||||
pub node_modules_dir: Option<bool>,
|
||||
pub node_modules_mode: Option<NodeModulesMode>,
|
||||
pub node_modules_dir: Option<NodeModulesDirMode>,
|
||||
pub vendor: Option<bool>,
|
||||
pub enable_op_summary_metrics: bool,
|
||||
pub enable_testing_features: bool,
|
||||
|
@ -1114,7 +1111,6 @@ static ENV_VARIABLES_HELP: &str = cstr!(
|
|||
<g>DENO_AUTH_TOKENS</> A semi-colon separated list of bearer tokens and hostnames
|
||||
to use when fetching remote modules from private repositories
|
||||
<p(245)>(e.g. "abcde12345@deno.land;54321edcba@github.com")</>
|
||||
<g>DENO_FUTURE</> Set to "1" to enable APIs that will take effect in Deno 2
|
||||
<g>DENO_CERT</> Load certificate authorities from PEM encoded file
|
||||
<g>DENO_DIR</> Set the cache directory
|
||||
<g>DENO_INSTALL_ROOT</> Set deno install's output directory
|
||||
|
@ -1508,11 +1504,7 @@ pub fn clap_root() -> Command {
|
|||
.subcommand(fmt_subcommand())
|
||||
.subcommand(init_subcommand())
|
||||
.subcommand(info_subcommand())
|
||||
.subcommand(if *DENO_FUTURE {
|
||||
future_install_subcommand()
|
||||
} else {
|
||||
install_subcommand()
|
||||
})
|
||||
.subcommand(future_install_subcommand())
|
||||
.subcommand(json_reference_subcommand())
|
||||
.subcommand(jupyter_subcommand())
|
||||
.subcommand(uninstall_subcommand())
|
||||
|
@ -2365,7 +2357,7 @@ TypeScript compiler cache: Subdirectory containing TS compiler output.",
|
|||
.arg(no_lock_arg())
|
||||
.arg(config_arg())
|
||||
.arg(import_map_arg())
|
||||
.args(node_modules_args())
|
||||
.arg(node_modules_dir_arg())
|
||||
.arg(vendor_arg())
|
||||
.arg(
|
||||
Arg::new("json")
|
||||
|
@ -2375,22 +2367,13 @@ TypeScript compiler cache: Subdirectory containing TS compiler output.",
|
|||
))
|
||||
}
|
||||
|
||||
fn install_args(cmd: Command, deno_future: bool) -> Command {
|
||||
let cmd = if deno_future {
|
||||
cmd.arg(
|
||||
Arg::new("cmd")
|
||||
.required_if_eq("global", "true")
|
||||
.num_args(1..)
|
||||
.value_hint(ValueHint::FilePath),
|
||||
)
|
||||
} else {
|
||||
cmd.arg(
|
||||
Arg::new("cmd")
|
||||
.required_unless_present("help")
|
||||
.num_args(1..)
|
||||
.value_hint(ValueHint::FilePath),
|
||||
)
|
||||
};
|
||||
fn install_args(cmd: Command) -> Command {
|
||||
let cmd = cmd.arg(
|
||||
Arg::new("cmd")
|
||||
.required_if_eq("global", "true")
|
||||
.num_args(1..)
|
||||
.value_hint(ValueHint::FilePath),
|
||||
);
|
||||
cmd
|
||||
.arg(
|
||||
Arg::new("name")
|
||||
|
@ -2466,40 +2449,7 @@ These must be added to the path manually if required.", UnstableArgsConfig::Reso
|
|||
.visible_alias("i")
|
||||
.defer(|cmd| {
|
||||
let cmd = runtime_args(cmd, true, true).arg(check_arg(true)).arg(allow_scripts_arg());
|
||||
install_args(cmd, true)
|
||||
})
|
||||
}
|
||||
|
||||
fn install_subcommand() -> Command {
|
||||
command("install",
|
||||
"Installs a script as an executable in the installation root's bin directory.
|
||||
|
||||
deno install --global --allow-net --allow-read jsr:@std/http/file-server
|
||||
deno install -g https://examples.deno.land/color-logging.ts
|
||||
|
||||
To change the executable name, use -n/--name:
|
||||
deno install -g --allow-net --allow-read -n serve jsr:@std/http/file-server
|
||||
|
||||
The executable name is inferred by default:
|
||||
- Attempt to take the file stem of the URL path. The above example would
|
||||
become 'file_server'.
|
||||
- If the file stem is something generic like 'main', 'mod', 'index' or 'cli',
|
||||
and the path has no parent, take the file name of the parent path. Otherwise
|
||||
settle with the generic name.
|
||||
- If the resulting name has an '@...' suffix, strip it.
|
||||
|
||||
To change the installation root, use --root:
|
||||
deno install -g --allow-net --allow-read --root /usr/local jsr:@std/http/file-server
|
||||
|
||||
The installation root is determined, in order of precedence:
|
||||
- --root option
|
||||
- DENO_INSTALL_ROOT environment variable
|
||||
- $HOME/.deno
|
||||
|
||||
These must be added to the path manually if required.", UnstableArgsConfig::ResolutionAndRuntime)
|
||||
.defer(|cmd| {
|
||||
let cmd = runtime_args(cmd, true, true).arg(check_arg(true));
|
||||
install_args(cmd, false)
|
||||
install_args(cmd)
|
||||
})
|
||||
}
|
||||
|
||||
|
@ -3180,7 +3130,7 @@ Remote modules and multiple modules may also be specified:
|
|||
.arg(config_arg())
|
||||
.arg(import_map_arg())
|
||||
.arg(lock_arg())
|
||||
.args(node_modules_args())
|
||||
.arg(node_modules_dir_arg())
|
||||
.arg(vendor_arg())
|
||||
.arg(reload_arg())
|
||||
.arg(ca_file_arg())
|
||||
|
@ -3242,7 +3192,7 @@ fn compile_args_without_check_args(app: Command) -> Command {
|
|||
.arg(import_map_arg())
|
||||
.arg(no_remote_arg())
|
||||
.arg(no_npm_arg())
|
||||
.args(node_modules_args())
|
||||
.arg(node_modules_dir_arg())
|
||||
.arg(vendor_arg())
|
||||
.arg(config_arg())
|
||||
.arg(no_config_arg())
|
||||
|
@ -3919,48 +3869,35 @@ fn no_npm_arg() -> Arg {
|
|||
}
|
||||
|
||||
fn node_modules_arg_parse(flags: &mut Flags, matches: &mut ArgMatches) {
|
||||
if *DENO_FUTURE {
|
||||
let value = matches.remove_one::<NodeModulesMode>("node-modules");
|
||||
if let Some(mode) = value {
|
||||
flags.node_modules_mode = Some(mode);
|
||||
}
|
||||
} else {
|
||||
flags.node_modules_dir = matches.remove_one::<bool>("node-modules-dir");
|
||||
let value = matches.remove_one::<NodeModulesDirMode>("node-modules-dir");
|
||||
if let Some(mode) = value {
|
||||
flags.node_modules_dir = Some(mode);
|
||||
}
|
||||
}
|
||||
|
||||
fn node_modules_args() -> Vec<Arg> {
|
||||
if *DENO_FUTURE {
|
||||
vec![
|
||||
Arg::new("node-modules")
|
||||
.long("node-modules")
|
||||
.num_args(0..=1)
|
||||
.value_parser(NodeModulesMode::parse)
|
||||
.value_name("MODE")
|
||||
.require_equals(true)
|
||||
.help("Sets the node modules management mode for npm packages")
|
||||
.help_heading(DEPENDENCY_MANAGEMENT_HEADING),
|
||||
Arg::new("node-modules-dir")
|
||||
.long("node-modules-dir")
|
||||
.num_args(0..=1)
|
||||
.value_parser(clap::builder::UnknownArgumentValueParser::suggest_arg(
|
||||
"--node-modules",
|
||||
))
|
||||
.require_equals(true),
|
||||
]
|
||||
} else {
|
||||
vec![
|
||||
Arg::new("node-modules-dir")
|
||||
.long("node-modules-dir")
|
||||
.num_args(0..=1)
|
||||
.value_parser(value_parser!(bool))
|
||||
.value_name("ENABLED")
|
||||
.default_missing_value("true")
|
||||
.require_equals(true)
|
||||
.help("Enables or disables the use of a local node_modules folder for npm packages")
|
||||
.help_heading(DEPENDENCY_MANAGEMENT_HEADING)
|
||||
]
|
||||
fn node_modules_dir_arg() -> Arg {
|
||||
fn parse_node_modules_dir_mode(
|
||||
s: &str,
|
||||
) -> Result<NodeModulesDirMode, String> {
|
||||
match s {
|
||||
"auto" | "true" => Ok(NodeModulesDirMode::Auto),
|
||||
"manual" => Ok(NodeModulesDirMode::Manual),
|
||||
"none" | "false" => Ok(NodeModulesDirMode::None),
|
||||
_ => Err(format!(
|
||||
"Invalid value '{}': expected \"auto\", \"manual\" or \"none\"",
|
||||
s
|
||||
)),
|
||||
}
|
||||
}
|
||||
|
||||
Arg::new("node-modules-dir")
|
||||
.long("node-modules-dir")
|
||||
.num_args(0..=1)
|
||||
.value_parser(clap::builder::ValueParser::new(parse_node_modules_dir_mode))
|
||||
.value_name("MODE")
|
||||
.require_equals(true)
|
||||
.help("Sets the node modules management mode for npm packages")
|
||||
.help_heading(DEPENDENCY_MANAGEMENT_HEADING)
|
||||
}
|
||||
|
||||
fn vendor_arg() -> Arg {
|
||||
|
@ -4039,7 +3976,6 @@ impl Iterator for UnstableArgsIter {
|
|||
Arg::new("unstable-byonm")
|
||||
.long("unstable-byonm")
|
||||
.help("Enable unstable 'bring your own node_modules' feature")
|
||||
.env("DENO_UNSTABLE_BYONM")
|
||||
.value_parser(FalseyValueParser::new())
|
||||
.action(ArgAction::SetTrue)
|
||||
.hide(true)
|
||||
|
@ -4476,7 +4412,7 @@ fn install_parse(flags: &mut Flags, matches: &mut ArgMatches) {
|
|||
runtime_args_parse(flags, matches, true, true);
|
||||
|
||||
let global = matches.get_flag("global");
|
||||
if global || !*DENO_FUTURE {
|
||||
if global {
|
||||
let root = matches.remove_one::<String>("root");
|
||||
let force = matches.get_flag("force");
|
||||
let name = matches.remove_one::<String>("name");
|
||||
|
@ -5422,7 +5358,6 @@ fn unstable_args_parse(
|
|||
|
||||
flags.unstable_config.bare_node_builtins =
|
||||
matches.get_flag("unstable-bare-node-builtins");
|
||||
flags.unstable_config.byonm = matches.get_flag("unstable-byonm");
|
||||
flags.unstable_config.sloppy_imports =
|
||||
matches.get_flag("unstable-sloppy-imports");
|
||||
|
||||
|
|
|
@ -239,12 +239,6 @@ impl CliLockfile {
|
|||
}
|
||||
let lockfile = self.lockfile.lock();
|
||||
if lockfile.has_content_changed {
|
||||
let suggested = if *super::DENO_FUTURE {
|
||||
"`deno cache --frozen=false`, `deno install --frozen=false`,"
|
||||
} else {
|
||||
"`deno cache --frozen=false`"
|
||||
};
|
||||
|
||||
let contents =
|
||||
std::fs::read_to_string(&lockfile.filename).unwrap_or_default();
|
||||
let new_contents = lockfile.as_json_string();
|
||||
|
@ -252,7 +246,7 @@ impl CliLockfile {
|
|||
// has an extra newline at the end
|
||||
let diff = diff.trim_end();
|
||||
Err(deno_core::anyhow::anyhow!(
|
||||
"The lockfile is out of date. Run {suggested} or rerun with `--frozen=false` to update it.\nchanges:\n{diff}"
|
||||
"The lockfile is out of date. Run `deno cache --frozen=false`, `deno install --frozen=false`, or rerun with `--frozen=false` to update it.\nchanges:\n{diff}"
|
||||
))
|
||||
} else {
|
||||
Ok(())
|
||||
|
|
131
cli/args/mod.rs
131
cli/args/mod.rs
|
@ -8,8 +8,9 @@ mod lockfile;
|
|||
mod package_json;
|
||||
|
||||
use deno_ast::SourceMapOption;
|
||||
use deno_config::deno_json::NodeModulesMode;
|
||||
use deno_config::deno_json::NodeModulesDirMode;
|
||||
use deno_config::workspace::CreateResolverOptions;
|
||||
use deno_config::workspace::FolderConfigs;
|
||||
use deno_config::workspace::PackageJsonDepResolution;
|
||||
use deno_config::workspace::VendorEnablement;
|
||||
use deno_config::workspace::Workspace;
|
||||
|
@ -51,7 +52,6 @@ use deno_core::anyhow::Context;
|
|||
use deno_core::error::AnyError;
|
||||
use deno_core::serde_json;
|
||||
use deno_core::url::Url;
|
||||
use deno_runtime::deno_node::PackageJson;
|
||||
use deno_runtime::deno_permissions::PermissionsOptions;
|
||||
use deno_runtime::deno_tls::deno_native_certs::load_native_certs;
|
||||
use deno_runtime::deno_tls::rustls;
|
||||
|
@ -64,6 +64,7 @@ use dotenvy::from_filename;
|
|||
use once_cell::sync::Lazy;
|
||||
use serde::Deserialize;
|
||||
use serde::Serialize;
|
||||
use std::borrow::Cow;
|
||||
use std::collections::HashMap;
|
||||
use std::env;
|
||||
use std::io::BufReader;
|
||||
|
@ -117,9 +118,6 @@ pub static DENO_DISABLE_PEDANTIC_NODE_WARNINGS: Lazy<bool> = Lazy::new(|| {
|
|||
.is_some()
|
||||
});
|
||||
|
||||
// TODO(2.0): remove this in a follow up.
|
||||
pub static DENO_FUTURE: Lazy<bool> = Lazy::new(|| true);
|
||||
|
||||
pub fn jsr_url() -> &'static Url {
|
||||
static JSR_URL: Lazy<Url> = Lazy::new(|| {
|
||||
let env_var_name = "JSR_URL";
|
||||
|
@ -814,15 +812,12 @@ impl CliOptions {
|
|||
}
|
||||
|
||||
let maybe_lockfile = maybe_lockfile.filter(|_| !force_global_cache);
|
||||
let root_folder = start_dir.workspace.root_folder_configs();
|
||||
let deno_dir_provider =
|
||||
Arc::new(DenoDirProvider::new(flags.cache_path.clone()));
|
||||
let maybe_node_modules_folder = resolve_node_modules_folder(
|
||||
&initial_cwd,
|
||||
&flags,
|
||||
&start_dir.workspace,
|
||||
root_folder.deno_json.as_deref(),
|
||||
root_folder.pkg_json.as_deref(),
|
||||
&deno_dir_provider,
|
||||
)
|
||||
.with_context(|| "Resolving node_modules folder.")?;
|
||||
|
@ -919,10 +914,6 @@ impl CliOptions {
|
|||
};
|
||||
|
||||
for diagnostic in start_dir.workspace.diagnostics() {
|
||||
// TODO(2.0): remove
|
||||
if matches!(diagnostic.kind, deno_config::workspace::WorkspaceDiagnosticKind::DeprecatedNodeModulesDirOption(_)) && !*DENO_FUTURE {
|
||||
continue;
|
||||
}
|
||||
log::warn!("{} {}", colors::yellow("Warning"), diagnostic);
|
||||
}
|
||||
|
||||
|
@ -1143,10 +1134,6 @@ impl CliOptions {
|
|||
self.flags.env_file.as_ref()
|
||||
}
|
||||
|
||||
pub fn enable_future_features(&self) -> bool {
|
||||
*DENO_FUTURE
|
||||
}
|
||||
|
||||
pub fn resolve_main_module(&self) -> Result<ModuleSpecifier, AnyError> {
|
||||
let main_module = match &self.flags.subcommand {
|
||||
DenoSubcommand::Bundle(bundle_flags) => {
|
||||
|
@ -1261,29 +1248,13 @@ impl CliOptions {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn node_modules_mode(&self) -> Result<Option<NodeModulesMode>, AnyError> {
|
||||
if *DENO_FUTURE {
|
||||
if let Some(flag) = self.flags.node_modules_mode {
|
||||
return Ok(Some(flag));
|
||||
}
|
||||
self.workspace().node_modules_mode().map_err(Into::into)
|
||||
} else {
|
||||
Ok(
|
||||
self
|
||||
.flags
|
||||
.node_modules_dir
|
||||
.or_else(|| self.workspace().node_modules_dir())
|
||||
.map(|enabled| {
|
||||
if enabled && self.byonm_enabled() {
|
||||
NodeModulesMode::LocalManual
|
||||
} else if enabled {
|
||||
NodeModulesMode::LocalAuto
|
||||
} else {
|
||||
NodeModulesMode::GlobalAuto
|
||||
}
|
||||
}),
|
||||
)
|
||||
pub fn node_modules_dir(
|
||||
&self,
|
||||
) -> Result<Option<NodeModulesDirMode>, AnyError> {
|
||||
if let Some(flag) = self.flags.node_modules_dir {
|
||||
return Ok(Some(flag));
|
||||
}
|
||||
self.workspace().node_modules_dir_mode().map_err(Into::into)
|
||||
}
|
||||
|
||||
pub fn vendor_dir_path(&self) -> Option<&PathBuf> {
|
||||
|
@ -1637,17 +1608,15 @@ impl CliOptions {
|
|||
|
||||
fn byonm_enabled(&self) -> bool {
|
||||
// check if enabled via unstable
|
||||
self.flags.unstable_config.byonm
|
||||
self.node_modules_dir().ok().flatten() == Some(NodeModulesDirMode::Manual)
|
||||
|| NPM_PROCESS_STATE
|
||||
.as_ref()
|
||||
.map(|s| matches!(s.kind, NpmProcessStateKind::Byonm))
|
||||
.unwrap_or(false)
|
||||
|| self.workspace().has_unstable("byonm")
|
||||
}
|
||||
|
||||
pub fn use_byonm(&self) -> bool {
|
||||
if self.enable_future_features()
|
||||
&& self.node_modules_mode().ok().flatten().is_none()
|
||||
if self.node_modules_dir().ok().flatten().is_none()
|
||||
&& self.maybe_node_modules_folder.is_some()
|
||||
&& self
|
||||
.workspace()
|
||||
|
@ -1680,19 +1649,17 @@ impl CliOptions {
|
|||
}
|
||||
});
|
||||
|
||||
// TODO(2.0): remove this conditional and enable these features in `99_main.js` by default.
|
||||
if *DENO_FUTURE {
|
||||
let future_features = [
|
||||
deno_runtime::deno_ffi::UNSTABLE_FEATURE_NAME.to_string(),
|
||||
deno_runtime::deno_fs::UNSTABLE_FEATURE_NAME.to_string(),
|
||||
deno_runtime::deno_webgpu::UNSTABLE_FEATURE_NAME.to_string(),
|
||||
];
|
||||
future_features.iter().for_each(|future_feature| {
|
||||
if !from_config_file.contains(future_feature) {
|
||||
from_config_file.push(future_feature.to_string());
|
||||
}
|
||||
});
|
||||
}
|
||||
// TODO(2.0): remove this code and enable these features in `99_main.js` by default.
|
||||
let future_features = [
|
||||
deno_runtime::deno_ffi::UNSTABLE_FEATURE_NAME.to_string(),
|
||||
deno_runtime::deno_fs::UNSTABLE_FEATURE_NAME.to_string(),
|
||||
deno_runtime::deno_webgpu::UNSTABLE_FEATURE_NAME.to_string(),
|
||||
];
|
||||
future_features.iter().for_each(|future_feature| {
|
||||
if !from_config_file.contains(future_feature) {
|
||||
from_config_file.push(future_feature.to_string());
|
||||
}
|
||||
});
|
||||
|
||||
if !from_config_file.is_empty() {
|
||||
// collect unstable granular flags
|
||||
|
@ -1792,54 +1759,54 @@ fn resolve_node_modules_folder(
|
|||
cwd: &Path,
|
||||
flags: &Flags,
|
||||
workspace: &Workspace,
|
||||
maybe_config_file: Option<&ConfigFile>,
|
||||
maybe_package_json: Option<&PackageJson>,
|
||||
deno_dir_provider: &Arc<DenoDirProvider>,
|
||||
) -> Result<Option<PathBuf>, AnyError> {
|
||||
let use_node_modules_dir = if *DENO_FUTURE {
|
||||
if let Some(mode) = flags.node_modules_mode {
|
||||
Some(mode.uses_node_modules_dir())
|
||||
} else {
|
||||
workspace
|
||||
.node_modules_mode()?
|
||||
.map(|m| m.uses_node_modules_dir())
|
||||
.or(flags.vendor)
|
||||
.or_else(|| maybe_config_file.and_then(|c| c.json.vendor))
|
||||
}
|
||||
fn resolve_from_root(root_folder: &FolderConfigs, cwd: &Path) -> PathBuf {
|
||||
root_folder
|
||||
.deno_json
|
||||
.as_ref()
|
||||
.map(|c| Cow::Owned(c.dir_path()))
|
||||
.or_else(|| {
|
||||
root_folder
|
||||
.pkg_json
|
||||
.as_ref()
|
||||
.map(|c| Cow::Borrowed(c.dir_path()))
|
||||
})
|
||||
.unwrap_or(Cow::Borrowed(cwd))
|
||||
.join("node_modules")
|
||||
}
|
||||
|
||||
let root_folder = workspace.root_folder_configs();
|
||||
let use_node_modules_dir = if let Some(mode) = flags.node_modules_dir {
|
||||
Some(mode.uses_node_modules_dir())
|
||||
} else {
|
||||
flags
|
||||
.node_modules_dir
|
||||
.or_else(|| maybe_config_file.and_then(|c| c.json.node_modules_dir))
|
||||
workspace
|
||||
.node_modules_dir_mode()?
|
||||
.map(|m| m.uses_node_modules_dir())
|
||||
.or(flags.vendor)
|
||||
.or_else(|| maybe_config_file.and_then(|c| c.json.vendor))
|
||||
.or_else(|| root_folder.deno_json.as_ref().and_then(|c| c.json.vendor))
|
||||
};
|
||||
let path = if use_node_modules_dir == Some(false) {
|
||||
return Ok(None);
|
||||
} else if let Some(state) = &*NPM_PROCESS_STATE {
|
||||
return Ok(state.local_node_modules_path.as_ref().map(PathBuf::from));
|
||||
} else if let Some(package_json_path) = maybe_package_json.map(|c| &c.path) {
|
||||
} else if workspace.package_jsons().next().is_some() {
|
||||
let node_modules_dir = resolve_from_root(root_folder, cwd);
|
||||
if let Ok(deno_dir) = deno_dir_provider.get_or_create() {
|
||||
// `deno_dir.root` can be symlink in macOS
|
||||
if let Ok(root) = canonicalize_path_maybe_not_exists(&deno_dir.root) {
|
||||
if package_json_path.starts_with(root) {
|
||||
if node_modules_dir.starts_with(root) {
|
||||
// if the package.json is in deno_dir, then do not use node_modules
|
||||
// next to it as local node_modules dir
|
||||
return Ok(None);
|
||||
}
|
||||
}
|
||||
}
|
||||
// auto-discover the local_node_modules_folder when a package.json exists
|
||||
// and it's not in deno_dir
|
||||
package_json_path.parent().unwrap().join("node_modules")
|
||||
node_modules_dir
|
||||
} else if use_node_modules_dir.is_none() {
|
||||
return Ok(None);
|
||||
} else if let Some(config_path) = maybe_config_file
|
||||
.as_ref()
|
||||
.and_then(|c| c.specifier.to_file_path().ok())
|
||||
{
|
||||
config_path.parent().unwrap().join("node_modules")
|
||||
} else {
|
||||
cwd.join("node_modules")
|
||||
resolve_from_root(root_folder, cwd)
|
||||
};
|
||||
Ok(Some(canonicalize_path_maybe_not_exists(&path)?))
|
||||
}
|
||||
|
|
|
@ -793,20 +793,12 @@ impl CliFactory {
|
|||
self.maybe_inspector_server()?.clone(),
|
||||
cli_options.maybe_lockfile().cloned(),
|
||||
self.feature_checker()?.clone(),
|
||||
self.create_cli_main_worker_options()?,
|
||||
cli_options.node_ipc_fd(),
|
||||
cli_options.serve_port(),
|
||||
cli_options.serve_host(),
|
||||
cli_options.enable_future_features(),
|
||||
// TODO(bartlomieju): temporarily disabled
|
||||
// cli_options.disable_deprecated_api_warning,
|
||||
true,
|
||||
cli_options.verbose_deprecated_api_warning,
|
||||
if cli_options.code_cache_enabled() {
|
||||
Some(self.code_cache()?.clone())
|
||||
} else {
|
||||
None
|
||||
},
|
||||
self.create_cli_main_worker_options()?,
|
||||
))
|
||||
}
|
||||
|
||||
|
@ -871,6 +863,13 @@ impl CliFactory {
|
|||
unstable: cli_options.legacy_unstable_flag(),
|
||||
create_hmr_runner,
|
||||
create_coverage_collector,
|
||||
node_ipc: cli_options.node_ipc_fd(),
|
||||
serve_port: cli_options.serve_port(),
|
||||
serve_host: cli_options.serve_host(),
|
||||
// TODO(bartlomieju): temporarily disabled
|
||||
disable_deprecated_api_warning: true,
|
||||
verbose_deprecated_api_warning: cli_options
|
||||
.verbose_deprecated_api_warning,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
|
@ -543,7 +543,7 @@ impl ModuleGraphBuilder {
|
|||
// opted into using a node_modules directory
|
||||
if self
|
||||
.options
|
||||
.node_modules_mode()?
|
||||
.node_modules_dir()?
|
||||
.map(|m| m.uses_node_modules_dir())
|
||||
.unwrap_or(false)
|
||||
{
|
||||
|
|
|
@ -5,7 +5,7 @@ use deno_config::deno_json::DenoJsonCache;
|
|||
use deno_config::deno_json::FmtConfig;
|
||||
use deno_config::deno_json::FmtOptionsConfig;
|
||||
use deno_config::deno_json::LintConfig;
|
||||
use deno_config::deno_json::NodeModulesMode;
|
||||
use deno_config::deno_json::NodeModulesDirMode;
|
||||
use deno_config::deno_json::TestConfig;
|
||||
use deno_config::deno_json::TsConfig;
|
||||
use deno_config::fs::DenoConfigFs;
|
||||
|
@ -55,7 +55,6 @@ use crate::args::CliLockfile;
|
|||
use crate::args::ConfigFile;
|
||||
use crate::args::LintFlags;
|
||||
use crate::args::LintOptions;
|
||||
use crate::args::DENO_FUTURE;
|
||||
use crate::cache::FastInsecureHasher;
|
||||
use crate::file_fetcher::FileFetcher;
|
||||
use crate::lsp::logging::lsp_warn;
|
||||
|
@ -1388,24 +1387,14 @@ impl ConfigData {
|
|||
}
|
||||
}
|
||||
|
||||
let byonm = std::env::var("DENO_UNSTABLE_BYONM").is_ok()
|
||||
|| member_dir.workspace.has_unstable("byonm")
|
||||
|| (*DENO_FUTURE
|
||||
&& matches!(
|
||||
member_dir.workspace.node_modules_mode().unwrap_or_default(),
|
||||
Some(NodeModulesMode::LocalManual)
|
||||
))
|
||||
|| (
|
||||
*DENO_FUTURE
|
||||
&& member_dir.workspace.package_jsons().next().is_some()
|
||||
&& member_dir
|
||||
.workspace
|
||||
.node_modules_mode()
|
||||
.ok()
|
||||
.flatten()
|
||||
.is_none()
|
||||
// TODO(2.0): remove
|
||||
);
|
||||
let node_modules_dir = member_dir
|
||||
.workspace
|
||||
.node_modules_dir_mode()
|
||||
.unwrap_or_default();
|
||||
let byonm = match node_modules_dir {
|
||||
Some(mode) => mode == NodeModulesDirMode::Manual,
|
||||
None => member_dir.workspace.package_jsons().next().is_some(),
|
||||
};
|
||||
if byonm {
|
||||
lsp_log!(" Enabled 'bring your own node_modules'.");
|
||||
}
|
||||
|
@ -1879,27 +1868,16 @@ fn resolve_node_modules_dir(
|
|||
// `nodeModulesDir: true` setting in the deno.json file. This is to
|
||||
// reduce the chance of modifying someone's node_modules directory
|
||||
// without them having asked us to do so.
|
||||
let node_modules_mode = workspace.node_modules_mode().ok().flatten();
|
||||
let node_modules_dir_option = workspace.node_modules_dir();
|
||||
let explicitly_disabled = if *DENO_FUTURE {
|
||||
node_modules_mode == Some(NodeModulesMode::GlobalAuto)
|
||||
} else {
|
||||
node_modules_dir_option == Some(false)
|
||||
};
|
||||
let node_modules_mode = workspace.node_modules_dir_mode().ok().flatten();
|
||||
let explicitly_disabled = node_modules_mode == Some(NodeModulesDirMode::None);
|
||||
if explicitly_disabled {
|
||||
return None;
|
||||
}
|
||||
let enabled = if *DENO_FUTURE {
|
||||
byonm
|
||||
|| node_modules_mode
|
||||
.map(|m| m.uses_node_modules_dir())
|
||||
.unwrap_or(false)
|
||||
|| workspace.vendor_dir_path().is_some()
|
||||
} else {
|
||||
byonm
|
||||
|| workspace.node_modules_dir() == Some(true)
|
||||
|| workspace.vendor_dir_path().is_some()
|
||||
};
|
||||
let enabled = byonm
|
||||
|| node_modules_mode
|
||||
.map(|m| m.uses_node_modules_dir())
|
||||
.unwrap_or(false)
|
||||
|| workspace.vendor_dir_path().is_some();
|
||||
|
||||
if !enabled {
|
||||
return None;
|
||||
|
|
28
cli/main.rs
28
cli/main.rs
|
@ -32,7 +32,6 @@ mod worker;
|
|||
use crate::args::flags_from_vec;
|
||||
use crate::args::DenoSubcommand;
|
||||
use crate::args::Flags;
|
||||
use crate::args::DENO_FUTURE;
|
||||
use crate::graph_container::ModuleGraphContainer;
|
||||
use crate::util::display;
|
||||
use crate::util::v8::get_v8_flags_from_env;
|
||||
|
@ -454,30 +453,19 @@ fn resolve_flags_and_init(
|
|||
// https://github.com/microsoft/vscode/blob/48d4ba271686e8072fc6674137415bc80d936bc7/extensions/typescript-language-features/src/configuration/configuration.ts#L213-L214
|
||||
DenoSubcommand::Lsp => vec!["--max-old-space-size=3072".to_string()],
|
||||
_ => {
|
||||
if *DENO_FUTURE {
|
||||
// TODO(bartlomieju): I think this can be removed as it's handled by `deno_core`
|
||||
// and its settings.
|
||||
// deno_ast removes TypeScript `assert` keywords, so this flag only affects JavaScript
|
||||
// TODO(petamoriken): Need to check TypeScript `assert` keywords in deno_ast
|
||||
vec!["--no-harmony-import-assertions".to_string()]
|
||||
} else {
|
||||
vec![
|
||||
// TODO(bartlomieju): I think this can be removed as it's handled by `deno_core`
|
||||
// and its settings.
|
||||
// If we're still in v1.X version we want to support import assertions.
|
||||
// V8 12.6 unshipped the support by default, so force it by passing a
|
||||
// flag.
|
||||
"--harmony-import-assertions".to_string(),
|
||||
// Verify with DENO_FUTURE for now.
|
||||
"--no-maglev".to_string(),
|
||||
]
|
||||
}
|
||||
// TODO(bartlomieju): I think this can be removed as it's handled by `deno_core`
|
||||
// and its settings.
|
||||
// deno_ast removes TypeScript `assert` keywords, so this flag only affects JavaScript
|
||||
// TODO(petamoriken): Need to check TypeScript `assert` keywords in deno_ast
|
||||
vec!["--no-harmony-import-assertions".to_string()]
|
||||
}
|
||||
};
|
||||
|
||||
init_v8_flags(&default_v8_flags, &flags.v8_flags, get_v8_flags_from_env());
|
||||
// TODO(bartlomieju): remove last argument in Deno 2.
|
||||
deno_core::JsRuntime::init_platform(None, !*DENO_FUTURE);
|
||||
deno_core::JsRuntime::init_platform(
|
||||
None, /* import assertions enabled */ false,
|
||||
);
|
||||
util::logger::init(flags.log_level);
|
||||
|
||||
Ok(flags)
|
||||
|
|
|
@ -831,22 +831,14 @@ async fn sync_resolution_with_fs(
|
|||
}
|
||||
|
||||
if !packages_with_scripts_not_run.is_empty() {
|
||||
let (maybe_install, maybe_install_example) = if *crate::args::DENO_FUTURE {
|
||||
(
|
||||
" or `deno install`",
|
||||
" or `deno install --allow-scripts=pkg1,pkg2`",
|
||||
)
|
||||
} else {
|
||||
("", "")
|
||||
};
|
||||
let packages = packages_with_scripts_not_run
|
||||
.iter()
|
||||
.map(|(_, p)| format!("npm:{p}"))
|
||||
.collect::<Vec<_>>()
|
||||
.join(", ");
|
||||
log::warn!("{}: Packages contained npm lifecycle scripts (preinstall/install/postinstall) that were not executed.
|
||||
This may cause the packages to not work correctly. To run them, use the `--allow-scripts` flag with `deno cache`{maybe_install}
|
||||
(e.g. `deno cache --allow-scripts=pkg1,pkg2 <entrypoint>`{maybe_install_example}):\n {packages}", crate::colors::yellow("warning"));
|
||||
This may cause the packages to not work correctly. To run them, use the `--allow-scripts` flag with `deno cache` or `deno install`
|
||||
(e.g. `deno cache --allow-scripts=pkg1,pkg2 <entrypoint>` or `deno install --allow-scripts=pkg1,pkg2`):\n {packages}", crate::colors::yellow("warning"));
|
||||
for (scripts_warned_path, _) in packages_with_scripts_not_run {
|
||||
let _ignore_err = fs::write(scripts_warned_path, "");
|
||||
}
|
||||
|
|
|
@ -225,13 +225,8 @@ impl CliNodeResolver {
|
|||
let package_json_path = package_folder.join("package.json");
|
||||
if !self.fs.exists_sync(&package_json_path) {
|
||||
return Err(anyhow!(
|
||||
"Could not find '{}'. Deno expects the node_modules/ directory to be up to date. Did you forget to run `{}`?",
|
||||
"Could not find '{}'. Deno expects the node_modules/ directory to be up to date. Did you forget to run `deno install`?",
|
||||
package_json_path.display(),
|
||||
if *crate::args::DENO_FUTURE {
|
||||
"deno install"
|
||||
} else {
|
||||
"npm install"
|
||||
},
|
||||
));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -629,7 +629,6 @@ impl<'a> DenoCompileBinaryWriter<'a> {
|
|||
unstable_config: UnstableConfig {
|
||||
legacy_flag_enabled: cli_options.legacy_unstable_flag(),
|
||||
bare_node_builtins: cli_options.unstable_bare_node_builtins(),
|
||||
byonm: cli_options.use_byonm(),
|
||||
sloppy_imports: cli_options.unstable_sloppy_imports(),
|
||||
features: cli_options.unstable_features(),
|
||||
},
|
||||
|
|
|
@ -706,6 +706,8 @@ pub async fn run(
|
|||
None,
|
||||
None,
|
||||
feature_checker,
|
||||
// Code cache is not supported for standalone binary yet.
|
||||
None,
|
||||
CliMainWorkerOptions {
|
||||
argv: metadata.argv,
|
||||
log_level: WorkerLogLevel::Info,
|
||||
|
@ -732,17 +734,13 @@ pub async fn run(
|
|||
unstable: metadata.unstable_config.legacy_flag_enabled,
|
||||
create_hmr_runner: None,
|
||||
create_coverage_collector: None,
|
||||
node_ipc: None,
|
||||
serve_port: None,
|
||||
serve_host: None,
|
||||
// TODO(bartlomieju): temporarily disabled
|
||||
disable_deprecated_api_warning: true,
|
||||
verbose_deprecated_api_warning: false,
|
||||
},
|
||||
None,
|
||||
None,
|
||||
None,
|
||||
false,
|
||||
// TODO(bartlomieju): temporarily disabled
|
||||
// metadata.disable_deprecated_api_warning,
|
||||
true,
|
||||
false,
|
||||
// Code cache is not supported for standalone binary yet.
|
||||
None,
|
||||
);
|
||||
|
||||
// Initialize v8 once from the main thread.
|
||||
|
|
|
@ -140,10 +140,10 @@ impl DenoOrPackageJson {
|
|||
),
|
||||
factory,
|
||||
)),
|
||||
(None, Some(package_json)) if options.enable_future_features() => {
|
||||
(None, Some(package_json)) => {
|
||||
Ok((DenoOrPackageJson::Npm(package_json.clone(), None), factory))
|
||||
}
|
||||
(None, Some(_) | None) => {
|
||||
(None, None) => {
|
||||
std::fs::write(options.initial_cwd().join("deno.json"), "{}\n")
|
||||
.context("Failed to create deno.json file")?;
|
||||
drop(factory); // drop to prevent use
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
use std::io::Read;
|
||||
use std::sync::Arc;
|
||||
|
||||
use deno_config::deno_json::NodeModulesDirMode;
|
||||
use deno_core::error::AnyError;
|
||||
use deno_runtime::deno_permissions::Permissions;
|
||||
use deno_runtime::deno_permissions::PermissionsContainer;
|
||||
|
@ -194,11 +195,8 @@ pub async fn eval_command(
|
|||
pub async fn maybe_npm_install(factory: &CliFactory) -> Result<(), AnyError> {
|
||||
// ensure an "npm install" is done if the user has explicitly
|
||||
// opted into using a managed node_modules directory
|
||||
if factory
|
||||
.cli_options()?
|
||||
.node_modules_mode()?
|
||||
.map(|m| m.uses_node_modules_dir())
|
||||
.unwrap_or(false)
|
||||
if factory.cli_options()?.node_modules_dir()?
|
||||
== Some(NodeModulesDirMode::Auto)
|
||||
{
|
||||
if let Some(npm_resolver) = factory.npm_resolver().await?.as_managed() {
|
||||
npm_resolver.ensure_top_level_package_json_install().await?;
|
||||
|
|
14
cli/tools/vendor/mod.rs
vendored
14
cli/tools/vendor/mod.rs
vendored
|
@ -89,7 +89,7 @@ pub async fn vendor(
|
|||
let npm_package_count = graph.npm_packages.len();
|
||||
let try_add_node_modules_dir = npm_package_count > 0
|
||||
&& cli_options
|
||||
.node_modules_mode()?
|
||||
.node_modules_dir()?
|
||||
.map(|m| m.uses_node_modules_dir())
|
||||
.unwrap_or(true);
|
||||
|
||||
|
@ -344,7 +344,7 @@ fn update_config_text(
|
|||
let insert_position = obj.range.end - 1;
|
||||
text_changes.push(TextChange {
|
||||
range: insert_position..insert_position,
|
||||
new_text: r#""nodeModulesDir": true"#.to_string(),
|
||||
new_text: r#""nodeModulesDir": "auto""#.to_string(),
|
||||
});
|
||||
should_format = true;
|
||||
modified_result.added_node_modules_dir = true;
|
||||
|
@ -454,7 +454,7 @@ mod internal_test {
|
|||
assert_eq!(
|
||||
result.new_text.unwrap(),
|
||||
r#"{
|
||||
"nodeModulesDir": true,
|
||||
"nodeModulesDir": "auto",
|
||||
"importMap": "./vendor/import_map.json"
|
||||
}
|
||||
"#
|
||||
|
@ -467,7 +467,7 @@ mod internal_test {
|
|||
assert_eq!(
|
||||
result.new_text.unwrap(),
|
||||
r#"{
|
||||
"nodeModulesDir": true
|
||||
"nodeModulesDir": "auto"
|
||||
}
|
||||
"#
|
||||
);
|
||||
|
@ -546,10 +546,10 @@ mod internal_test {
|
|||
|
||||
#[test]
|
||||
fn no_update_node_modules_dir() {
|
||||
// will not update if this is already set (even if it's false)
|
||||
// will not update if this is already set (even if it's "none")
|
||||
let result = update_config_text(
|
||||
r#"{
|
||||
"nodeModulesDir": false
|
||||
"nodeModulesDir": "none"
|
||||
}
|
||||
"#,
|
||||
&Default::default(),
|
||||
|
@ -563,7 +563,7 @@ mod internal_test {
|
|||
|
||||
let result = update_config_text(
|
||||
r#"{
|
||||
"nodeModulesDir": true
|
||||
"nodeModulesDir": "auto"
|
||||
}
|
||||
"#,
|
||||
&Default::default(),
|
||||
|
|
|
@ -116,6 +116,11 @@ pub struct CliMainWorkerOptions {
|
|||
pub skip_op_registration: bool,
|
||||
pub create_hmr_runner: Option<CreateHmrRunnerCb>,
|
||||
pub create_coverage_collector: Option<CreateCoverageCollectorCb>,
|
||||
pub node_ipc: Option<i64>,
|
||||
pub serve_port: Option<u16>,
|
||||
pub serve_host: Option<String>,
|
||||
pub disable_deprecated_api_warning: bool,
|
||||
pub verbose_deprecated_api_warning: bool,
|
||||
}
|
||||
|
||||
struct SharedWorkerState {
|
||||
|
@ -135,13 +140,8 @@ struct SharedWorkerState {
|
|||
maybe_inspector_server: Option<Arc<InspectorServer>>,
|
||||
maybe_lockfile: Option<Arc<CliLockfile>>,
|
||||
feature_checker: Arc<FeatureChecker>,
|
||||
node_ipc: Option<i64>,
|
||||
enable_future_features: bool,
|
||||
disable_deprecated_api_warning: bool,
|
||||
verbose_deprecated_api_warning: bool,
|
||||
code_cache: Option<Arc<dyn code_cache::CodeCache>>,
|
||||
serve_port: Option<u16>,
|
||||
serve_host: Option<String>,
|
||||
}
|
||||
|
||||
impl SharedWorkerState {
|
||||
|
@ -434,14 +434,8 @@ impl CliMainWorkerFactory {
|
|||
maybe_inspector_server: Option<Arc<InspectorServer>>,
|
||||
maybe_lockfile: Option<Arc<CliLockfile>>,
|
||||
feature_checker: Arc<FeatureChecker>,
|
||||
options: CliMainWorkerOptions,
|
||||
node_ipc: Option<i64>,
|
||||
serve_port: Option<u16>,
|
||||
serve_host: Option<String>,
|
||||
enable_future_features: bool,
|
||||
disable_deprecated_api_warning: bool,
|
||||
verbose_deprecated_api_warning: bool,
|
||||
code_cache: Option<Arc<dyn code_cache::CodeCache>>,
|
||||
options: CliMainWorkerOptions,
|
||||
) -> Self {
|
||||
Self {
|
||||
shared: Arc::new(SharedWorkerState {
|
||||
|
@ -461,12 +455,8 @@ impl CliMainWorkerFactory {
|
|||
maybe_inspector_server,
|
||||
maybe_lockfile,
|
||||
feature_checker,
|
||||
node_ipc,
|
||||
serve_port,
|
||||
serve_host,
|
||||
enable_future_features,
|
||||
disable_deprecated_api_warning,
|
||||
verbose_deprecated_api_warning,
|
||||
// TODO(2.0): remove?
|
||||
enable_future_features: true,
|
||||
code_cache,
|
||||
}),
|
||||
}
|
||||
|
@ -602,13 +592,17 @@ impl CliMainWorkerFactory {
|
|||
has_node_modules_dir: shared.options.has_node_modules_dir,
|
||||
argv0: shared.options.argv0.clone(),
|
||||
node_debug: shared.options.node_debug.clone(),
|
||||
node_ipc_fd: shared.node_ipc,
|
||||
disable_deprecated_api_warning: shared.disable_deprecated_api_warning,
|
||||
verbose_deprecated_api_warning: shared.verbose_deprecated_api_warning,
|
||||
node_ipc_fd: shared.options.node_ipc,
|
||||
disable_deprecated_api_warning: shared
|
||||
.options
|
||||
.disable_deprecated_api_warning,
|
||||
verbose_deprecated_api_warning: shared
|
||||
.options
|
||||
.verbose_deprecated_api_warning,
|
||||
future: shared.enable_future_features,
|
||||
mode,
|
||||
serve_port: shared.serve_port,
|
||||
serve_host: shared.serve_host.clone(),
|
||||
serve_port: shared.options.serve_port,
|
||||
serve_host: shared.options.serve_host.clone(),
|
||||
},
|
||||
extensions: custom_extensions,
|
||||
startup_snapshot: crate::js::deno_isolate_init(),
|
||||
|
@ -801,12 +795,16 @@ fn create_web_worker_callback(
|
|||
argv0: shared.options.argv0.clone(),
|
||||
node_debug: shared.options.node_debug.clone(),
|
||||
node_ipc_fd: None,
|
||||
disable_deprecated_api_warning: shared.disable_deprecated_api_warning,
|
||||
verbose_deprecated_api_warning: shared.verbose_deprecated_api_warning,
|
||||
disable_deprecated_api_warning: shared
|
||||
.options
|
||||
.disable_deprecated_api_warning,
|
||||
verbose_deprecated_api_warning: shared
|
||||
.options
|
||||
.verbose_deprecated_api_warning,
|
||||
future: shared.enable_future_features,
|
||||
mode: WorkerExecutionMode::Worker,
|
||||
serve_port: shared.serve_port,
|
||||
serve_host: shared.serve_host.clone(),
|
||||
serve_port: shared.options.serve_port,
|
||||
serve_host: shared.options.serve_host.clone(),
|
||||
},
|
||||
extensions: vec![],
|
||||
startup_snapshot: crate::js::deno_isolate_init(),
|
||||
|
|
|
@ -989,7 +989,7 @@ fn run_npm_bin_compile_test(opts: RunNpmBinCompileOptions) {
|
|||
args.extend(opts.compile_args.iter().map(|s| s.to_string()));
|
||||
|
||||
if opts.node_modules_local {
|
||||
args.push("--node-modules=local-auto".to_string());
|
||||
args.push("--node-modules-dir=auto".to_string());
|
||||
}
|
||||
|
||||
if let Some(bin_name) = opts.input_name {
|
||||
|
@ -1052,7 +1052,7 @@ fn compile_node_modules_symlink_outside() {
|
|||
// compile folder
|
||||
let output = context
|
||||
.new_command()
|
||||
.args("compile --allow-read --node-modules=local-auto --output bin main.ts")
|
||||
.args("compile --allow-read --node-modules-dir=auto --output bin main.ts")
|
||||
.run();
|
||||
output.assert_exit_code(0);
|
||||
output.assert_matches_file(
|
||||
|
@ -1075,7 +1075,7 @@ fn compile_node_modules_symlink_outside() {
|
|||
// compile
|
||||
let output = context
|
||||
.new_command()
|
||||
.args("compile --allow-read --node-modules=local-auto --output bin main.ts")
|
||||
.args("compile --allow-read --node-modules-dir=auto --output bin main.ts")
|
||||
.run();
|
||||
output.assert_exit_code(0);
|
||||
output.assert_matches_file(
|
||||
|
@ -1105,7 +1105,7 @@ console.log(getValue());"#,
|
|||
// compile folder
|
||||
let output = context
|
||||
.new_command()
|
||||
.args("compile --allow-read --node-modules=local-auto --output bin main.ts")
|
||||
.args("compile --allow-read --node-modules-dir=auto --output bin main.ts")
|
||||
.run();
|
||||
output.assert_exit_code(0);
|
||||
output.assert_matches_text(
|
||||
|
|
|
@ -9035,7 +9035,7 @@ fn lsp_completions_node_specifier_node_modules_dir() {
|
|||
temp_dir.write(
|
||||
temp_dir.path().join("deno.json"),
|
||||
json!({
|
||||
"nodeModulesDir": true,
|
||||
"nodeModulesDir": "auto",
|
||||
})
|
||||
.to_string(),
|
||||
);
|
||||
|
@ -9442,7 +9442,7 @@ fn lsp_npmrc() {
|
|||
temp_dir.write(
|
||||
temp_dir.path().join("deno.json"),
|
||||
json!({
|
||||
"nodeModules": "local-auto",
|
||||
"nodeModulesDir": "auto",
|
||||
})
|
||||
.to_string(),
|
||||
);
|
||||
|
@ -12372,7 +12372,7 @@ fn lsp_node_modules_dir() {
|
|||
temp_dir.write(
|
||||
"deno.json",
|
||||
json!({
|
||||
"nodeModules": "global-auto",
|
||||
"nodeModulesDir": "none",
|
||||
})
|
||||
.to_string(),
|
||||
);
|
||||
|
@ -12413,7 +12413,7 @@ fn lsp_node_modules_dir() {
|
|||
|
||||
temp_dir.write(
|
||||
temp_dir.path().join("deno.json"),
|
||||
"{ \"nodeModules\": \"local-auto\", \"lock\": false }\n",
|
||||
"{ \"nodeModulesDir\": \"auto\", \"lock\": false }\n",
|
||||
);
|
||||
let refresh_config = |client: &mut LspClient| {
|
||||
client.change_configuration(json!({ "deno": {
|
||||
|
@ -12449,7 +12449,7 @@ fn lsp_node_modules_dir() {
|
|||
// now add a lockfile and cache
|
||||
temp_dir.write(
|
||||
temp_dir.path().join("deno.json"),
|
||||
"{ \"nodeModules\": \"local-auto\" }\n",
|
||||
"{ \"nodeModulesDir\": \"auto\" }\n",
|
||||
);
|
||||
refresh_config(&mut client);
|
||||
cache(&mut client);
|
||||
|
@ -13056,21 +13056,21 @@ fn lsp_deno_json_scopes_node_modules_dir() {
|
|||
temp_dir.write(
|
||||
"project1/deno.json",
|
||||
json!({
|
||||
"nodeModules": "local-auto",
|
||||
"nodeModulesDir": "auto",
|
||||
})
|
||||
.to_string(),
|
||||
);
|
||||
temp_dir.write(
|
||||
"project2/deno.json",
|
||||
json!({
|
||||
"nodeModules": "local-auto",
|
||||
"nodeModulesDir": "auto",
|
||||
})
|
||||
.to_string(),
|
||||
);
|
||||
temp_dir.write(
|
||||
"project2/project3/deno.json",
|
||||
json!({
|
||||
"nodeModules": "local-auto",
|
||||
"nodeModulesDir": "auto",
|
||||
})
|
||||
.to_string(),
|
||||
);
|
||||
|
@ -14247,7 +14247,7 @@ fn lsp_deno_json_workspace_node_modules_dir() {
|
|||
"project1/deno.json",
|
||||
json!({
|
||||
"workspace": ["project2"],
|
||||
"nodeModules": "local-auto",
|
||||
"nodeModulesDir": "auto",
|
||||
})
|
||||
.to_string(),
|
||||
);
|
||||
|
@ -14383,7 +14383,7 @@ fn lsp_npm_workspace() {
|
|||
temp_dir.write(
|
||||
"deno.json",
|
||||
json!({
|
||||
"nodeModules": "local-auto",
|
||||
"nodeModulesDir": "auto",
|
||||
})
|
||||
.to_string(),
|
||||
);
|
||||
|
@ -14625,11 +14625,8 @@ fn lsp_jupyter_byonm_diagnostics() {
|
|||
}
|
||||
|
||||
#[test]
|
||||
fn lsp_deno_future_env_byonm() {
|
||||
let context = TestContextBuilder::for_npm()
|
||||
.env("DENO_FUTURE", "1")
|
||||
.use_temp_cwd()
|
||||
.build();
|
||||
fn lsp_byonm() {
|
||||
let context = TestContextBuilder::for_npm().use_temp_cwd().build();
|
||||
let temp_dir = context.temp_dir();
|
||||
temp_dir.path().join("package.json").write_json(&json!({
|
||||
"dependencies": {
|
||||
|
@ -15187,7 +15184,6 @@ fn lsp_cjs_internal_types_default_export() {
|
|||
.use_http_server()
|
||||
.use_temp_cwd()
|
||||
.add_npm_env_vars()
|
||||
.env("DENO_FUTURE", "1")
|
||||
.build();
|
||||
let temp_dir = context.temp_dir();
|
||||
temp_dir.write("deno.json", r#"{}"#);
|
||||
|
@ -15236,7 +15232,6 @@ fn lsp_cjs_import_dual() {
|
|||
.use_http_server()
|
||||
.use_temp_cwd()
|
||||
.add_npm_env_vars()
|
||||
.env("DENO_FUTURE", "1")
|
||||
.build();
|
||||
let temp_dir = context.temp_dir();
|
||||
temp_dir.write("deno.json", r#"{}"#);
|
||||
|
|
|
@ -107,7 +107,6 @@ fn node_unit_test(test: String) {
|
|||
|
||||
let mut deno = util::deno_cmd()
|
||||
.current_dir(util::root_path())
|
||||
.env("DENO_FUTURE", "1")
|
||||
.arg("test")
|
||||
.arg("--config")
|
||||
.arg(deno_config_path())
|
||||
|
|
|
@ -140,7 +140,7 @@ itest!(mixed_case_package_name_global_dir {
|
|||
|
||||
itest!(mixed_case_package_name_local_dir {
|
||||
args:
|
||||
"run --node-modules=local-auto -A $TESTDATA/npm/mixed_case_package_name/local.ts",
|
||||
"run --node-modules-dir=auto -A $TESTDATA/npm/mixed_case_package_name/local.ts",
|
||||
output: "npm/mixed_case_package_name/local.out",
|
||||
exit_code: 0,
|
||||
envs: env_vars_for_npm_tests(),
|
||||
|
@ -374,7 +374,7 @@ itest!(permissions_outside_package {
|
|||
});
|
||||
|
||||
itest!(run_existing_npm_package {
|
||||
args: "run --allow-read --node-modules=local-auto npm:@denotest/bin",
|
||||
args: "run --allow-read --node-modules-dir=auto npm:@denotest/bin",
|
||||
output: "npm/run_existing_npm_package/main.out",
|
||||
envs: env_vars_for_npm_tests(),
|
||||
http_server: true,
|
||||
|
@ -385,7 +385,7 @@ itest!(run_existing_npm_package {
|
|||
|
||||
itest!(run_existing_npm_package_with_subpath {
|
||||
args:
|
||||
"run --allow-read --node-modules=local-auto npm:@denotest/bin/cli-esm dev --help",
|
||||
"run --allow-read --node-modules-dir=auto npm:@denotest/bin/cli-esm dev --help",
|
||||
output: "npm/run_existing_npm_package_with_subpath/main.out",
|
||||
envs: env_vars_for_npm_tests(),
|
||||
http_server: true,
|
||||
|
@ -813,7 +813,7 @@ itest!(builtin_module_module {
|
|||
|
||||
itest!(node_modules_dir_require_added_node_modules_folder {
|
||||
args:
|
||||
"run --node-modules=local-auto -A --quiet $TESTDATA/npm/require_added_nm_folder/main.js",
|
||||
"run --node-modules-dir=auto -A --quiet $TESTDATA/npm/require_added_nm_folder/main.js",
|
||||
output: "npm/require_added_nm_folder/main.out",
|
||||
envs: env_vars_for_npm_tests(),
|
||||
http_server: true,
|
||||
|
@ -831,7 +831,7 @@ itest!(node_modules_dir_require_main_entry {
|
|||
});
|
||||
|
||||
itest!(node_modules_dir_with_deps {
|
||||
args: "run --allow-read --allow-env --node-modules=local-auto $TESTDATA/npm/cjs_with_deps/main.js",
|
||||
args: "run --allow-read --allow-env --node-modules-dir=auto $TESTDATA/npm/cjs_with_deps/main.js",
|
||||
output: "npm/cjs_with_deps/main_node_modules.out",
|
||||
envs: env_vars_for_npm_tests(),
|
||||
http_server: true,
|
||||
|
@ -839,7 +839,7 @@ itest!(node_modules_dir_with_deps {
|
|||
});
|
||||
|
||||
itest!(node_modules_dir_yargs {
|
||||
args: "run --allow-read --allow-env --node-modules=local-auto $TESTDATA/npm/cjs_yargs/main.js",
|
||||
args: "run --allow-read --allow-env --node-modules-dir=auto $TESTDATA/npm/cjs_yargs/main.js",
|
||||
output: "npm/cjs_yargs/main.out",
|
||||
envs: env_vars_for_npm_tests(),
|
||||
http_server: true,
|
||||
|
@ -855,7 +855,7 @@ fn node_modules_dir_cache() {
|
|||
let deno = util::deno_cmd_with_deno_dir(&deno_dir)
|
||||
.current_dir(deno_dir.path())
|
||||
.arg("cache")
|
||||
.arg("--node-modules=local-auto")
|
||||
.arg("--node-modules-dir=auto")
|
||||
.arg("--quiet")
|
||||
.arg(util::testdata_path().join("npm/dual_cjs_esm/main.ts"))
|
||||
.envs(env_vars_for_npm_tests())
|
||||
|
@ -888,7 +888,7 @@ fn node_modules_dir_cache() {
|
|||
let deno = util::deno_cmd_with_deno_dir(&deno_dir)
|
||||
.current_dir(deno_dir.path())
|
||||
.arg("run")
|
||||
.arg("--node-modules=local-auto")
|
||||
.arg("--node-modules-dir=auto")
|
||||
.arg("--quiet")
|
||||
.arg("-A")
|
||||
.arg(util::testdata_path().join("npm/dual_cjs_esm/main.ts"))
|
||||
|
@ -1496,7 +1496,7 @@ fn peer_deps_with_copied_folders_and_lockfile() {
|
|||
// now run with local node modules
|
||||
let output = context
|
||||
.new_command()
|
||||
.args("run -A --node-modules=local-auto main.ts")
|
||||
.args("run -A --node-modules-dir=auto main.ts")
|
||||
.run();
|
||||
output.assert_exit_code(0);
|
||||
output.assert_matches_file(
|
||||
|
@ -1514,7 +1514,7 @@ fn peer_deps_with_copied_folders_and_lockfile() {
|
|||
// now again run with local node modules
|
||||
let output = context
|
||||
.new_command()
|
||||
.args("run -A --node-modules=local-auto main.ts")
|
||||
.args("run -A --node-modules-dir=auto main.ts")
|
||||
.run();
|
||||
output.assert_exit_code(0);
|
||||
output.assert_matches_text("1\n2\n");
|
||||
|
@ -1522,7 +1522,7 @@ fn peer_deps_with_copied_folders_and_lockfile() {
|
|||
// now ensure it works with reloading
|
||||
let output = context
|
||||
.new_command()
|
||||
.args("run -A --reload --node-modules=local-auto main.ts")
|
||||
.args("run -A --reload --node-modules-dir=auto main.ts")
|
||||
.run();
|
||||
output.assert_exit_code(0);
|
||||
output.assert_matches_file(
|
||||
|
@ -1532,7 +1532,7 @@ fn peer_deps_with_copied_folders_and_lockfile() {
|
|||
// now ensure it works with reloading and no lockfile
|
||||
let output = context
|
||||
.new_command()
|
||||
.args("run -A --reload --node-modules=local-auto --no-lock main.ts")
|
||||
.args("run -A --reload --node-modules-dir=auto --no-lock main.ts")
|
||||
.run();
|
||||
output.assert_exit_code(0);
|
||||
output.assert_matches_file(
|
||||
|
@ -1880,7 +1880,7 @@ fn binary_package_with_optional_dependencies() {
|
|||
|
||||
let output = context
|
||||
.new_command()
|
||||
.args("run -A --node-modules=local-auto main.js")
|
||||
.args("run -A --node-modules-dir=auto main.js")
|
||||
.run();
|
||||
|
||||
#[cfg(target_os = "windows")]
|
||||
|
@ -1971,7 +1971,7 @@ fn node_modules_dir_config_file() {
|
|||
let node_modules_dir = temp_dir.path().join("node_modules");
|
||||
let rm_node_modules = || std::fs::remove_dir_all(&node_modules_dir).unwrap();
|
||||
|
||||
temp_dir.write("deno.json", r#"{ "nodeModules": "local-auto" }"#);
|
||||
temp_dir.write("deno.json", r#"{ "nodeModulesDir": "auto" }"#);
|
||||
temp_dir.write("main.ts", "import 'npm:@denotest/esm-basic';");
|
||||
|
||||
let deno_cache_cmd = test_context.new_command().args("cache --quiet main.ts");
|
||||
|
@ -1985,7 +1985,7 @@ fn node_modules_dir_config_file() {
|
|||
assert!(node_modules_dir.exists());
|
||||
|
||||
rm_node_modules();
|
||||
temp_dir.write("deno.json", r#"{ "nodeModules": "global-auto" }"#);
|
||||
temp_dir.write("deno.json", r#"{ "nodeModulesDir": "none" }"#);
|
||||
|
||||
deno_cache_cmd.run();
|
||||
assert!(!node_modules_dir.exists());
|
||||
|
@ -1996,7 +1996,7 @@ fn node_modules_dir_config_file() {
|
|||
|
||||
test_context
|
||||
.new_command()
|
||||
.args("cache --quiet --node-modules=local-auto main.ts")
|
||||
.args("cache --quiet --node-modules-dir=auto main.ts")
|
||||
.run();
|
||||
assert!(node_modules_dir.exists());
|
||||
|
||||
|
@ -2004,7 +2004,7 @@ fn node_modules_dir_config_file() {
|
|||
rm_node_modules();
|
||||
test_context
|
||||
.new_command()
|
||||
.args("cache --quiet --node-modules=global-auto --vendor main.ts")
|
||||
.args("cache --quiet --node-modules-dir=none --vendor main.ts")
|
||||
.run();
|
||||
assert!(!node_modules_dir.exists());
|
||||
}
|
||||
|
@ -2021,7 +2021,7 @@ fn top_level_install_package_json_explicit_opt_in() {
|
|||
|
||||
// when the node_modules_dir is explicitly opted into, we should always
|
||||
// ensure a top level package.json install occurs
|
||||
temp_dir.write("deno.json", "{ \"nodeModules\": \"local-auto\" }");
|
||||
temp_dir.write("deno.json", "{ \"nodeModulesDir\": \"auto\" }");
|
||||
temp_dir.write(
|
||||
"package.json",
|
||||
"{ \"dependencies\": { \"@denotest/esm-basic\": \"1.0\" }}",
|
||||
|
@ -2110,7 +2110,7 @@ itest!(check_package_file_dts_dmts_dcts {
|
|||
});
|
||||
|
||||
itest!(require_resolve_url_paths {
|
||||
args: "run -A --quiet --node-modules=local-auto url_paths.ts",
|
||||
args: "run -A --quiet --node-modules-dir=auto url_paths.ts",
|
||||
output: "npm/require_resolve_url/url_paths.out",
|
||||
envs: env_vars_for_npm_tests(),
|
||||
http_server: true,
|
||||
|
@ -2121,10 +2121,7 @@ itest!(require_resolve_url_paths {
|
|||
|
||||
#[test]
|
||||
fn byonm_cjs_esm_packages() {
|
||||
let test_context = TestContextBuilder::for_npm()
|
||||
.env("DENO_UNSTABLE_BYONM", "1")
|
||||
.use_temp_cwd()
|
||||
.build();
|
||||
let test_context = TestContextBuilder::for_npm().use_temp_cwd().build();
|
||||
let dir = test_context.temp_dir();
|
||||
|
||||
test_context.run_npm("init -y");
|
||||
|
@ -2206,10 +2203,7 @@ console.log(getKind());
|
|||
|
||||
#[test]
|
||||
fn future_byonm_cjs_esm_packages() {
|
||||
let test_context = TestContextBuilder::for_npm()
|
||||
.env("DENO_FUTURE", "1")
|
||||
.use_temp_cwd()
|
||||
.build();
|
||||
let test_context = TestContextBuilder::for_npm().use_temp_cwd().build();
|
||||
let dir = test_context.temp_dir();
|
||||
|
||||
test_context.run_npm("init -y");
|
||||
|
@ -2290,59 +2284,13 @@ console.log(getKind());
|
|||
}
|
||||
|
||||
#[test]
|
||||
fn byonm_import_map() {
|
||||
fn node_modules_dir_manual_import_map() {
|
||||
let test_context = TestContextBuilder::for_npm().use_temp_cwd().build();
|
||||
let dir = test_context.temp_dir();
|
||||
dir.write(
|
||||
"deno.json",
|
||||
r#"{
|
||||
"imports": {
|
||||
"basic": "npm:@denotest/esm-basic"
|
||||
},
|
||||
"unstable": [ "byonm" ]
|
||||
}"#,
|
||||
);
|
||||
dir.write(
|
||||
"package.json",
|
||||
r#"{
|
||||
"name": "my-project",
|
||||
"version": "1.0.0",
|
||||
"type": "module",
|
||||
"dependencies": {
|
||||
"@denotest/esm-basic": "^1.0"
|
||||
}
|
||||
}"#,
|
||||
);
|
||||
test_context.run_npm("install");
|
||||
|
||||
dir.write(
|
||||
"main.ts",
|
||||
r#"
|
||||
// import map should resolve
|
||||
import { getValue } from "basic";
|
||||
// and resolving via node resolution
|
||||
import { setValue } from "@denotest/esm-basic";
|
||||
|
||||
setValue(5);
|
||||
console.log(getValue());
|
||||
"#,
|
||||
);
|
||||
let output = test_context.new_command().args("run main.ts").run();
|
||||
output.assert_matches_text("5\n");
|
||||
let output = test_context.new_command().args("check main.ts").run();
|
||||
output.assert_matches_text("Check file:///[WILDCARD]/main.ts\n");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn future_byonm_import_map() {
|
||||
let test_context = TestContextBuilder::for_npm()
|
||||
.env("DENO_FUTURE", "1")
|
||||
.use_temp_cwd()
|
||||
.build();
|
||||
let dir = test_context.temp_dir();
|
||||
dir.write(
|
||||
"deno.json",
|
||||
r#"{
|
||||
"nodeModulesDir": "manual",
|
||||
"imports": {
|
||||
"basic": "npm:@denotest/esm-basic"
|
||||
}
|
||||
|
@ -2381,10 +2329,7 @@ console.log(getValue());
|
|||
|
||||
#[test]
|
||||
fn byonm_package_specifier_not_installed_and_invalid_subpath() {
|
||||
let test_context = TestContextBuilder::for_npm()
|
||||
.env("DENO_UNSTABLE_BYONM", "1")
|
||||
.use_temp_cwd()
|
||||
.build();
|
||||
let test_context = TestContextBuilder::for_npm().use_temp_cwd().build();
|
||||
let dir = test_context.temp_dir();
|
||||
dir.path().join("package.json").write_json(&json!({
|
||||
"dependencies": {
|
||||
|
@ -2525,10 +2470,7 @@ console.log(getValue());
|
|||
|
||||
#[test]
|
||||
fn future_byonm_npm_workspaces() {
|
||||
let test_context = TestContextBuilder::for_npm()
|
||||
.env("DENO_FUTURE", "1")
|
||||
.use_temp_cwd()
|
||||
.build();
|
||||
let test_context = TestContextBuilder::for_npm().use_temp_cwd().build();
|
||||
let dir = test_context.temp_dir();
|
||||
|
||||
dir.write(
|
||||
|
@ -2781,7 +2723,7 @@ fn cjs_export_analysis_import_cjs_directly_relative_import() {
|
|||
|
||||
itest!(imports_package_json {
|
||||
args:
|
||||
"run --no-lock --node-modules=global-auto npm/imports_package_json/main.js",
|
||||
"run --no-lock --node-modules-dir=none npm/imports_package_json/main.js",
|
||||
output: "npm/imports_package_json/main.out",
|
||||
envs: env_vars_for_npm_tests(),
|
||||
http_server: true,
|
||||
|
@ -2789,7 +2731,7 @@ itest!(imports_package_json {
|
|||
|
||||
itest!(imports_package_json_import_not_defined {
|
||||
args:
|
||||
"run --no-lock --node-modules=global-auto npm/imports_package_json/import_not_defined.js",
|
||||
"run --no-lock --node-modules-dir=none npm/imports_package_json/import_not_defined.js",
|
||||
output: "npm/imports_package_json/import_not_defined.out",
|
||||
envs: env_vars_for_npm_tests(),
|
||||
exit_code: 1,
|
||||
|
@ -2798,7 +2740,7 @@ itest!(imports_package_json_import_not_defined {
|
|||
|
||||
itest!(imports_package_json_sub_path_import_not_defined {
|
||||
args:
|
||||
"run --no-lock --node-modules=global-auto npm/imports_package_json/sub_path_import_not_defined.js",
|
||||
"run --no-lock --node-modules-dir=none npm/imports_package_json/sub_path_import_not_defined.js",
|
||||
output: "npm/imports_package_json/sub_path_import_not_defined.out",
|
||||
envs: env_vars_for_npm_tests(),
|
||||
exit_code: 1,
|
||||
|
@ -2806,7 +2748,7 @@ itest!(imports_package_json_sub_path_import_not_defined {
|
|||
});
|
||||
|
||||
itest!(different_nested_dep_node_modules_dir_false {
|
||||
args: "run --quiet --no-lock --node-modules=global-auto npm/different_nested_dep/main.js",
|
||||
args: "run --quiet --no-lock --node-modules-dir=none npm/different_nested_dep/main.js",
|
||||
output: "npm/different_nested_dep/main.out",
|
||||
envs: env_vars_for_npm_tests(),
|
||||
exit_code: 0,
|
||||
|
@ -2814,7 +2756,7 @@ itest!(different_nested_dep_node_modules_dir_false {
|
|||
});
|
||||
|
||||
itest!(different_nested_dep_node_modules_dir_true {
|
||||
args: "run --no-lock --quiet --node-modules=local-auto main.js",
|
||||
args: "run --no-lock --quiet --node-modules-dir=auto main.js",
|
||||
output: "npm/different_nested_dep/main.out",
|
||||
copy_temp_dir: Some("npm/different_nested_dep/"),
|
||||
cwd: Some("npm/different_nested_dep/"),
|
||||
|
@ -2848,11 +2790,7 @@ fn different_nested_dep_byonm_future() {
|
|||
|
||||
test_context.run_npm("install");
|
||||
|
||||
let output = test_context
|
||||
.new_command()
|
||||
.args("run main.js")
|
||||
.env("DENO_FUTURE", "1")
|
||||
.run();
|
||||
let output = test_context.new_command().args("run main.js").run();
|
||||
output.assert_matches_file("npm/different_nested_dep/main.out");
|
||||
}
|
||||
|
||||
|
|
|
@ -1106,7 +1106,7 @@ fn lock_deno_json_package_json_deps_workspace() {
|
|||
// deno.json
|
||||
let deno_json = temp_dir.join("deno.json");
|
||||
deno_json.write_json(&json!({
|
||||
"nodeModules": "local-auto"
|
||||
"nodeModulesDir": "auto"
|
||||
}));
|
||||
|
||||
// package.json
|
||||
|
|
|
@ -1,3 +1,3 @@
|
|||
{
|
||||
"nodeModules": "local-auto"
|
||||
"nodeModulesDir": "auto"
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
{
|
||||
"nodeModules": "local-auto",
|
||||
"nodeModulesDir": "auto",
|
||||
"tasks": {
|
||||
"cat": "cat",
|
||||
"rm_node_modules": "rm -rf node_modules"
|
||||
|
|
|
@ -1,3 +1,3 @@
|
|||
{
|
||||
"nodeModules": "local-auto"
|
||||
"nodeModulesDir": "auto"
|
||||
}
|
||||
|
|
|
@ -15,12 +15,12 @@
|
|||
}]
|
||||
},
|
||||
"auto_install": {
|
||||
"args": "check --node-modules=local-auto --quiet main.ts",
|
||||
"args": "check --node-modules-dir=auto --quiet main.ts",
|
||||
"exitCode": 1,
|
||||
"output": "expected.out"
|
||||
},
|
||||
"global_folder": {
|
||||
"args": "check --node-modules=global-auto --quiet main.ts",
|
||||
"args": "check --node-modules-dir=none --quiet main.ts",
|
||||
"exitCode": 1,
|
||||
"output": "expected.out"
|
||||
}
|
||||
|
|
|
@ -15,12 +15,12 @@
|
|||
}]
|
||||
},
|
||||
"auto_install": {
|
||||
"args": "check --node-modules=local-auto --quiet main_auto_install.ts",
|
||||
"args": "check --node-modules-dir=auto --quiet main_auto_install.ts",
|
||||
"exitCode": 1,
|
||||
"output": "expected.out"
|
||||
},
|
||||
"global_folder": {
|
||||
"args": "check --node-modules=global-auto --quiet main_auto_install.ts",
|
||||
"args": "check --node-modules-dir=none --quiet main_auto_install.ts",
|
||||
"exitCode": 1,
|
||||
"output": "expected.out"
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
{
|
||||
"tempDir": true,
|
||||
"args": "run --allow-read --node-modules=local-auto main.js",
|
||||
"args": "run --allow-read --node-modules-dir=auto main.js",
|
||||
"output": "main.out"
|
||||
}
|
||||
|
|
|
@ -10,11 +10,11 @@
|
|||
"exitCode": 1
|
||||
}, {
|
||||
// this should override byonm
|
||||
"args": "run --node-modules=global-auto --quiet main.ts",
|
||||
"args": "run --node-modules-dir=none --quiet main.ts",
|
||||
"output": "main.out"
|
||||
}, {
|
||||
// same with this
|
||||
"args": "run --node-modules=local-auto --quiet main.ts",
|
||||
"args": "run --node-modules-dir=auto --quiet main.ts",
|
||||
"output": "main.out"
|
||||
}]
|
||||
}
|
||||
|
|
|
@ -135,7 +135,7 @@
|
|||
"output": ""
|
||||
},
|
||||
{
|
||||
"args": "cache --allow-scripts --node-modules=local-auto no_deno_json.js",
|
||||
"args": "cache --allow-scripts --node-modules-dir=auto no_deno_json.js",
|
||||
"output": "no_deno_json.out"
|
||||
}
|
||||
]
|
||||
|
@ -148,7 +148,7 @@
|
|||
"output": ""
|
||||
},
|
||||
{
|
||||
"args": "cache --allow-scripts --node-modules=local-auto conflicting_bin.js",
|
||||
"args": "cache --allow-scripts --node-modules-dir=auto conflicting_bin.js",
|
||||
"output": "conflicting_bin.out"
|
||||
}
|
||||
]
|
||||
|
|
|
@ -1,3 +1,3 @@
|
|||
{
|
||||
"nodeModules": "local-auto"
|
||||
"nodeModulesDir": "auto"
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
{
|
||||
"nodeModules": "local-auto",
|
||||
"nodeModulesDir": "auto",
|
||||
"imports": {
|
||||
"preact": "npm:preact",
|
||||
"preact-render-to-string": "npm:preact-render-to-string"
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
{
|
||||
"args": "run --node-modules=local-auto --allow-read main.mjs",
|
||||
"args": "run --node-modules-dir=auto --allow-read main.mjs",
|
||||
"output": "main.out",
|
||||
"exitCode": 0,
|
||||
"tempDir": true
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
}]
|
||||
},
|
||||
"run_node_modules_dir": {
|
||||
"args": "run --node-modules=local-auto -A --quiet main.js",
|
||||
"args": "run --node-modules-dir=auto -A --quiet main.js",
|
||||
"output": "main.out"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,13 +3,13 @@
|
|||
"tests": {
|
||||
"auth_success": {
|
||||
"cwd": "success",
|
||||
"args": "run --node-modules=local-auto -A main.js",
|
||||
"args": "run --node-modules-dir=auto -A main.js",
|
||||
"output": "success/main.out",
|
||||
"exitCode": 1
|
||||
},
|
||||
"auth_fail": {
|
||||
"cwd": "fail",
|
||||
"args": "run --node-modules=local-auto -A main.js",
|
||||
"args": "run --node-modules-dir=auto -A main.js",
|
||||
"output": "fail/main.out",
|
||||
"exitCode": 1
|
||||
}
|
||||
|
|
|
@ -2,15 +2,15 @@
|
|||
"tempDir": true,
|
||||
"tests": {
|
||||
"global_cache": {
|
||||
"args": "run --node-modules=global-auto b/main.ts",
|
||||
"args": "run --node-modules-dir=none b/main.ts",
|
||||
"output": "b/main_global_cache.out"
|
||||
},
|
||||
"global_cache_bare_specifier_not_in_pkg": {
|
||||
"args": "run --node-modules=global-auto main.ts",
|
||||
"args": "run --node-modules-dir=none main.ts",
|
||||
"output": "main.out"
|
||||
},
|
||||
"node_modules_dir": {
|
||||
"args": "run --node-modules=local-auto b/main.ts",
|
||||
"args": "run --node-modules-dir=auto b/main.ts",
|
||||
"output": "b/main_node_modules_dir.out"
|
||||
},
|
||||
"byonm": {
|
||||
|
|
|
@ -1,3 +1,3 @@
|
|||
{
|
||||
"nodeModules": "local-auto"
|
||||
"nodeModulesDir": "auto"
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
{
|
||||
"args": "run --node-modules=global-auto main.ts",
|
||||
"args": "run --node-modules-dir=none main.ts",
|
||||
"output": "main.out"
|
||||
}
|
||||
|
|
|
@ -4,5 +4,5 @@
|
|||
"exports": {
|
||||
".": "./mod.ts"
|
||||
},
|
||||
"nodeModules": "global-auto"
|
||||
"nodeModulesDir": "none"
|
||||
}
|
||||
|
|
|
@ -1,3 +1,3 @@
|
|||
{
|
||||
"nodeModules": "local-auto"
|
||||
"nodeModulesDir": "auto"
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
{
|
||||
"nodeModules": "local-auto",
|
||||
"nodeModulesDir": "auto",
|
||||
"tasks": {
|
||||
"repro": "echo hi"
|
||||
}
|
||||
|
|
|
@ -51,9 +51,6 @@ const validPrefixes = [
|
|||
"Reland ",
|
||||
// Allow landing breaking changes that are properly marked
|
||||
"BREAKING",
|
||||
// Allow landing breaking changes that will be applied in Deno 2, or available
|
||||
// immediately with DENO_FUTURE=1 env var
|
||||
"FUTURE",
|
||||
];
|
||||
|
||||
if (validPrefixes.some((prefix) => prTitle.startsWith(prefix))) {
|
||||
|
|
Loading…
Reference in a new issue