summaryrefslogtreecommitdiff
path: root/cli/args
diff options
context:
space:
mode:
authorDavid Sherret <dsherret@users.noreply.github.com>2023-08-06 21:56:56 -0400
committerGitHub <noreply@github.com>2023-08-06 21:56:56 -0400
commitb9b03869489213fa9b24d7416afe9e3e27c81ce7 (patch)
tree7727f2906b0864b1242c9d8030ca6416ee053409 /cli/args
parent7b5bc87f296d39e531051e1c0bb6cafa3808ab92 (diff)
feat(unstable): rename `deno_modules` to `vendor` (#20065)
Renames the unstable `deno_modules` directory and corresponding settings to `vendor` after feedback. Also causes the vendoring of the `node_modules` directory which can be disabled via `--node-modules-dir=false` or `"nodeModulesDir": false`.
Diffstat (limited to 'cli/args')
-rw-r--r--cli/args/config_file.rs18
-rw-r--r--cli/args/flags.rs42
-rw-r--r--cli/args/mod.rs35
3 files changed, 44 insertions, 51 deletions
diff --git a/cli/args/config_file.rs b/cli/args/config_file.rs
index bbbc60e4d..6b3f96cd3 100644
--- a/cli/args/config_file.rs
+++ b/cli/args/config_file.rs
@@ -673,7 +673,7 @@ pub struct ConfigFileJson {
pub lock: Option<Value>,
pub exclude: Option<Value>,
pub node_modules_dir: Option<bool>,
- pub deno_modules_dir: Option<bool>,
+ pub vendor: Option<bool>,
}
#[derive(Clone, Debug)]
@@ -855,16 +855,16 @@ impl ConfigFile {
self.json.import_map.clone()
}
- pub fn node_modules_dir(&self) -> Option<bool> {
+ pub fn node_modules_dir_flag(&self) -> Option<bool> {
self.json.node_modules_dir
}
- pub fn deno_modules_dir(&self) -> Option<bool> {
- self.json.deno_modules_dir
+ pub fn vendor_dir_flag(&self) -> Option<bool> {
+ self.json.vendor
}
- pub fn deno_modules_dir_path(&self) -> Option<PathBuf> {
- if self.json.deno_modules_dir == Some(true) {
+ pub fn vendor_dir_path(&self) -> Option<PathBuf> {
+ if self.json.vendor == Some(true) {
Some(
self
.specifier
@@ -872,7 +872,7 @@ impl ConfigFile {
.unwrap()
.parent()
.unwrap()
- .join("deno_modules"),
+ .join("vendor"),
)
} else {
None
@@ -903,8 +903,8 @@ impl ConfigFile {
Vec::new()
};
- if self.deno_modules_dir() == Some(true) {
- exclude.push("deno_modules".to_string());
+ if self.vendor_dir_flag() == Some(true) {
+ exclude.push("vendor".to_string());
}
let raw_files_config = SerializedFilesConfig {
diff --git a/cli/args/flags.rs b/cli/args/flags.rs
index 790a9d83f..fdfb65f62 100644
--- a/cli/args/flags.rs
+++ b/cli/args/flags.rs
@@ -389,7 +389,7 @@ pub struct Flags {
pub type_check_mode: TypeCheckMode,
pub config_flag: ConfigFlag,
pub node_modules_dir: Option<bool>,
- pub deno_modules_dir: Option<bool>,
+ pub vendor: Option<bool>,
pub enable_testing_features: bool,
pub ext: Option<String>,
pub ignore: Vec<PathBuf>,
@@ -1560,7 +1560,7 @@ TypeScript compiler cache: Subdirectory containing TS compiler output.",
.arg(config_arg())
.arg(import_map_arg())
.arg(node_modules_dir_arg())
- .arg(deno_modules_dir_arg())
+ .arg(vendor_arg())
.arg(
Arg::new("json")
.long("json")
@@ -2107,7 +2107,7 @@ Remote modules and multiple modules may also be specified:
.arg(import_map_arg())
.arg(lock_arg())
.arg(node_modules_dir_arg())
- .arg(deno_modules_dir_arg())
+ .arg(vendor_arg())
.arg(reload_arg())
.arg(ca_file_arg()))
}
@@ -2122,7 +2122,7 @@ fn compile_args_without_check_args(app: Command) -> Command {
.arg(no_remote_arg())
.arg(no_npm_arg())
.arg(node_modules_dir_arg())
- .arg(deno_modules_dir_arg())
+ .arg(vendor_arg())
.arg(config_arg())
.arg(no_config_arg())
.arg(reload_arg())
@@ -2846,14 +2846,14 @@ fn node_modules_dir_arg() -> Arg {
.help("Enables or disables the use of a local node_modules folder for npm packages")
}
-fn deno_modules_dir_arg() -> Arg {
- Arg::new("deno-modules-dir")
- .long("deno-modules-dir")
+fn vendor_arg() -> Arg {
+ Arg::new("vendor")
+ .long("vendor")
.num_args(0..=1)
.value_parser(value_parser!(bool))
.default_missing_value("true")
.require_equals(true)
- .help("UNSTABLE: Enables or disables the use of a local deno_modules folder for remote modules")
+ .help("UNSTABLE: Enables or disables the use of a local vendor folder for remote modules and node_modules folder for npm packages")
}
fn unsafely_ignore_certificate_errors_arg() -> Arg {
@@ -3143,7 +3143,7 @@ fn info_parse(flags: &mut Flags, matches: &mut ArgMatches) {
import_map_arg_parse(flags, matches);
location_arg_parse(flags, matches);
ca_file_arg_parse(flags, matches);
- node_and_deno_modules_dir_arg_parse(flags, matches);
+ node_modules_and_vendor_dir_arg_parse(flags, matches);
lock_arg_parse(flags, matches);
no_lock_arg_parse(flags, matches);
no_remote_arg_parse(flags, matches);
@@ -3420,7 +3420,7 @@ fn vendor_parse(flags: &mut Flags, matches: &mut ArgMatches) {
config_args_parse(flags, matches);
import_map_arg_parse(flags, matches);
lock_arg_parse(flags, matches);
- node_and_deno_modules_dir_arg_parse(flags, matches);
+ node_modules_and_vendor_dir_arg_parse(flags, matches);
reload_arg_parse(flags, matches);
flags.subcommand = DenoSubcommand::Vendor(VendorFlags {
@@ -3446,7 +3446,7 @@ fn compile_args_without_check_parse(
import_map_arg_parse(flags, matches);
no_remote_arg_parse(flags, matches);
no_npm_arg_parse(flags, matches);
- node_and_deno_modules_dir_arg_parse(flags, matches);
+ node_modules_and_vendor_dir_arg_parse(flags, matches);
config_args_parse(flags, matches);
reload_arg_parse(flags, matches);
lock_args_parse(flags, matches);
@@ -3739,12 +3739,12 @@ fn no_npm_arg_parse(flags: &mut Flags, matches: &mut ArgMatches) {
}
}
-fn node_and_deno_modules_dir_arg_parse(
+fn node_modules_and_vendor_dir_arg_parse(
flags: &mut Flags,
matches: &mut ArgMatches,
) {
flags.node_modules_dir = matches.remove_one::<bool>("node-modules-dir");
- flags.deno_modules_dir = matches.remove_one::<bool>("deno-modules-dir");
+ flags.vendor = matches.remove_one::<bool>("vendor");
}
fn reload_arg_validate(urlstr: &str) -> Result<String, String> {
@@ -6315,9 +6315,8 @@ mod tests {
}
#[test]
- fn deno_modules_dir() {
- let r =
- flags_from_vec(svec!["deno", "run", "--deno-modules-dir", "script.ts"]);
+ fn vendor_flag() {
+ let r = flags_from_vec(svec!["deno", "run", "--vendor", "script.ts"]);
assert_eq!(
r.unwrap(),
Flags {
@@ -6325,17 +6324,12 @@ mod tests {
script: "script.ts".to_string(),
watch: Default::default(),
}),
- deno_modules_dir: Some(true),
+ vendor: Some(true),
..Flags::default()
}
);
- let r = flags_from_vec(svec![
- "deno",
- "run",
- "--deno-modules-dir=false",
- "script.ts"
- ]);
+ let r = flags_from_vec(svec!["deno", "run", "--vendor=false", "script.ts"]);
assert_eq!(
r.unwrap(),
Flags {
@@ -6343,7 +6337,7 @@ mod tests {
script: "script.ts".to_string(),
watch: Default::default(),
}),
- deno_modules_dir: Some(false),
+ vendor: Some(false),
..Flags::default()
}
);
diff --git a/cli/args/mod.rs b/cli/args/mod.rs
index 7b3b0aa83..31a09216f 100644
--- a/cli/args/mod.rs
+++ b/cli/args/mod.rs
@@ -541,7 +541,7 @@ pub struct CliOptions {
flags: Flags,
initial_cwd: PathBuf,
maybe_node_modules_folder: Option<PathBuf>,
- maybe_deno_modules_folder: Option<PathBuf>,
+ maybe_vendor_folder: Option<PathBuf>,
maybe_config_file: Option<ConfigFile>,
maybe_package_json: Option<PackageJson>,
maybe_lockfile: Option<Arc<Mutex<Lockfile>>>,
@@ -577,11 +577,8 @@ impl CliOptions {
maybe_package_json.as_ref(),
)
.with_context(|| "Resolving node_modules folder.")?;
- let maybe_deno_modules_folder = resolve_deno_modules_folder(
- &initial_cwd,
- &flags,
- maybe_config_file.as_ref(),
- );
+ let maybe_vendor_folder =
+ resolve_vendor_folder(&initial_cwd, &flags, maybe_config_file.as_ref());
Ok(Self {
flags,
@@ -590,7 +587,7 @@ impl CliOptions {
maybe_lockfile,
maybe_package_json,
maybe_node_modules_folder,
- maybe_deno_modules_folder,
+ maybe_vendor_folder,
overrides: Default::default(),
})
}
@@ -863,7 +860,7 @@ impl CliOptions {
self
.maybe_config_file
.as_ref()
- .and_then(|c| c.node_modules_dir())
+ .and_then(|c| c.node_modules_dir_flag())
})
}
@@ -874,8 +871,8 @@ impl CliOptions {
.map(|path| ModuleSpecifier::from_directory_path(path).unwrap())
}
- pub fn deno_modules_dir_path(&self) -> Option<&PathBuf> {
- self.maybe_deno_modules_folder.as_ref()
+ pub fn vendor_dir_path(&self) -> Option<&PathBuf> {
+ self.maybe_vendor_folder.as_ref()
}
pub fn resolve_root_cert_store_provider(
@@ -1188,7 +1185,9 @@ fn resolve_node_modules_folder(
) -> Result<Option<PathBuf>, AnyError> {
let use_node_modules_dir = flags
.node_modules_dir
- .or_else(|| maybe_config_file.and_then(|c| c.node_modules_dir()));
+ .or_else(|| maybe_config_file.and_then(|c| c.node_modules_dir_flag()))
+ .or(flags.vendor)
+ .or_else(|| maybe_config_file.and_then(|c| c.vendor_dir_flag()));
let path = if use_node_modules_dir == Some(false) {
return Ok(None);
} else if let Some(state) = &*NPM_PROCESS_STATE {
@@ -1209,28 +1208,28 @@ fn resolve_node_modules_folder(
Ok(Some(canonicalize_path_maybe_not_exists(&path)?))
}
-fn resolve_deno_modules_folder(
+fn resolve_vendor_folder(
cwd: &Path,
flags: &Flags,
maybe_config_file: Option<&ConfigFile>,
) -> Option<PathBuf> {
- let use_deno_modules_dir = flags
- .deno_modules_dir
- .or_else(|| maybe_config_file.and_then(|c| c.deno_modules_dir()))
+ let use_vendor_dir = flags
+ .vendor
+ .or_else(|| maybe_config_file.and_then(|c| c.vendor_dir_flag()))
.unwrap_or(false);
// Unlike the node_modules directory, there is no need to canonicalize
// this directory because it's just used as a cache and the resolved
// specifier is not based on the canonicalized path (unlike the modules
// in the node_modules folder).
- if !use_deno_modules_dir {
+ if !use_vendor_dir {
None
} else if let Some(config_path) = maybe_config_file
.as_ref()
.and_then(|c| c.specifier.to_file_path().ok())
{
- Some(config_path.parent().unwrap().join("deno_modules"))
+ Some(config_path.parent().unwrap().join("vendor"))
} else {
- Some(cwd.join("deno_modules"))
+ Some(cwd.join("vendor"))
}
}