mirror of
https://github.com/denoland/deno.git
synced 2025-01-21 04:52:26 -05:00
refactor: deno_config 0.45 (#27660)
This commit is contained in:
parent
a1f50a7422
commit
1e95c20561
10 changed files with 12 additions and 47 deletions
5
Cargo.lock
generated
5
Cargo.lock
generated
|
@ -1497,11 +1497,12 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "deno_config"
|
name = "deno_config"
|
||||||
version = "0.43.0"
|
version = "0.45.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "6c4c11bd51ef6738cabfc3c53f16c209a0b8615cb1e4e5bf3b14e3b5deebfe21"
|
checksum = "47a47412627aa0d08414eca0e8329128013ab70bdb2cdfdc5456c2214cf24c8f"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"boxed_error",
|
"boxed_error",
|
||||||
|
"capacity_builder 0.5.0",
|
||||||
"deno_error",
|
"deno_error",
|
||||||
"deno_package_json",
|
"deno_package_json",
|
||||||
"deno_path_util",
|
"deno_path_util",
|
||||||
|
|
|
@ -51,7 +51,7 @@ deno_ast = { version = "=0.44.0", features = ["transpiling"] }
|
||||||
deno_core = { version = "0.330.0" }
|
deno_core = { version = "0.330.0" }
|
||||||
|
|
||||||
deno_bench_util = { version = "0.179.0", path = "./bench_util" }
|
deno_bench_util = { version = "0.179.0", path = "./bench_util" }
|
||||||
deno_config = { version = "=0.43.0", features = ["workspace", "sync"] }
|
deno_config = { version = "=0.45.0", features = ["workspace", "sync"] }
|
||||||
deno_lockfile = "=0.24.0"
|
deno_lockfile = "=0.24.0"
|
||||||
deno_media_type = { version = "0.2.3", features = ["module_specifier"] }
|
deno_media_type = { version = "0.2.3", features = ["module_specifier"] }
|
||||||
deno_npm = "=0.27.2"
|
deno_npm = "=0.27.2"
|
||||||
|
|
|
@ -56,7 +56,6 @@ use deno_core::error::AnyError;
|
||||||
use deno_core::resolve_url_or_path;
|
use deno_core::resolve_url_or_path;
|
||||||
use deno_core::serde_json;
|
use deno_core::serde_json;
|
||||||
use deno_core::url::Url;
|
use deno_core::url::Url;
|
||||||
use deno_error::JsErrorBox;
|
|
||||||
use deno_graph::GraphKind;
|
use deno_graph::GraphKind;
|
||||||
pub use deno_json::check_warn_tsconfig;
|
pub use deno_json::check_warn_tsconfig;
|
||||||
use deno_lint::linter::LintConfig as DenoLintConfig;
|
use deno_lint::linter::LintConfig as DenoLintConfig;
|
||||||
|
@ -842,8 +841,6 @@ impl CliOptions {
|
||||||
} else {
|
} else {
|
||||||
&[]
|
&[]
|
||||||
};
|
};
|
||||||
let config_parse_options =
|
|
||||||
deno_config::deno_json::ConfigParseOptions::default();
|
|
||||||
let discover_pkg_json = flags.config_flag != ConfigFlag::Disabled
|
let discover_pkg_json = flags.config_flag != ConfigFlag::Disabled
|
||||||
&& !flags.no_npm
|
&& !flags.no_npm
|
||||||
&& !has_flag_env_var("DENO_NO_PACKAGE_JSON");
|
&& !has_flag_env_var("DENO_NO_PACKAGE_JSON");
|
||||||
|
@ -854,7 +851,6 @@ impl CliOptions {
|
||||||
deno_json_cache: None,
|
deno_json_cache: None,
|
||||||
pkg_json_cache: Some(&node_resolver::PackageJsonThreadLocalCache),
|
pkg_json_cache: Some(&node_resolver::PackageJsonThreadLocalCache),
|
||||||
workspace_cache: None,
|
workspace_cache: None,
|
||||||
config_parse_options,
|
|
||||||
additional_config_file_names,
|
additional_config_file_names,
|
||||||
discover_pkg_json,
|
discover_pkg_json,
|
||||||
maybe_vendor_override,
|
maybe_vendor_override,
|
||||||
|
@ -1103,11 +1099,11 @@ impl CliOptions {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
Ok(self.workspace().create_resolver(
|
Ok(self.workspace().create_resolver(
|
||||||
|
&CliSys::default(),
|
||||||
CreateResolverOptions {
|
CreateResolverOptions {
|
||||||
pkg_json_dep_resolution,
|
pkg_json_dep_resolution,
|
||||||
specified_import_map: cli_arg_specified_import_map,
|
specified_import_map: cli_arg_specified_import_map,
|
||||||
},
|
},
|
||||||
|path| std::fs::read_to_string(path).map_err(JsErrorBox::from_err),
|
|
||||||
)?)
|
)?)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2126,12 +2122,7 @@ mod test {
|
||||||
let cwd = &std::env::current_dir().unwrap();
|
let cwd = &std::env::current_dir().unwrap();
|
||||||
let config_specifier =
|
let config_specifier =
|
||||||
ModuleSpecifier::parse("file:///deno/deno.jsonc").unwrap();
|
ModuleSpecifier::parse("file:///deno/deno.jsonc").unwrap();
|
||||||
let config_file = ConfigFile::new(
|
let config_file = ConfigFile::new(config_text, config_specifier).unwrap();
|
||||||
config_text,
|
|
||||||
config_specifier,
|
|
||||||
&deno_config::deno_json::ConfigParseOptions::default(),
|
|
||||||
)
|
|
||||||
.unwrap();
|
|
||||||
let actual = resolve_import_map_specifier(
|
let actual = resolve_import_map_specifier(
|
||||||
Some("import-map.json"),
|
Some("import-map.json"),
|
||||||
Some(&config_file),
|
Some(&config_file),
|
||||||
|
@ -2150,12 +2141,7 @@ mod test {
|
||||||
let config_text = r#"{}"#;
|
let config_text = r#"{}"#;
|
||||||
let config_specifier =
|
let config_specifier =
|
||||||
ModuleSpecifier::parse("file:///deno/deno.jsonc").unwrap();
|
ModuleSpecifier::parse("file:///deno/deno.jsonc").unwrap();
|
||||||
let config_file = ConfigFile::new(
|
let config_file = ConfigFile::new(config_text, config_specifier).unwrap();
|
||||||
config_text,
|
|
||||||
config_specifier,
|
|
||||||
&deno_config::deno_json::ConfigParseOptions::default(),
|
|
||||||
)
|
|
||||||
.unwrap();
|
|
||||||
let actual = resolve_import_map_specifier(
|
let actual = resolve_import_map_specifier(
|
||||||
None,
|
None,
|
||||||
Some(&config_file),
|
Some(&config_file),
|
||||||
|
|
|
@ -41,7 +41,6 @@ use deno_core::serde_json::json;
|
||||||
use deno_core::serde_json::Value;
|
use deno_core::serde_json::Value;
|
||||||
use deno_core::url::Url;
|
use deno_core::url::Url;
|
||||||
use deno_core::ModuleSpecifier;
|
use deno_core::ModuleSpecifier;
|
||||||
use deno_error::JsErrorBox;
|
|
||||||
use deno_lint::linter::LintConfig as DenoLintConfig;
|
use deno_lint::linter::LintConfig as DenoLintConfig;
|
||||||
use deno_npm::npm_rc::ResolvedNpmRc;
|
use deno_npm::npm_rc::ResolvedNpmRc;
|
||||||
use deno_package_json::PackageJsonCache;
|
use deno_package_json::PackageJsonCache;
|
||||||
|
@ -1247,7 +1246,6 @@ impl ConfigData {
|
||||||
pkg_json_cache: Some(pkg_json_cache),
|
pkg_json_cache: Some(pkg_json_cache),
|
||||||
workspace_cache: Some(workspace_cache),
|
workspace_cache: Some(workspace_cache),
|
||||||
discover_pkg_json: !has_flag_env_var("DENO_NO_PACKAGE_JSON"),
|
discover_pkg_json: !has_flag_env_var("DENO_NO_PACKAGE_JSON"),
|
||||||
config_parse_options: Default::default(),
|
|
||||||
maybe_vendor_override: None,
|
maybe_vendor_override: None,
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
@ -1572,11 +1570,11 @@ impl ConfigData {
|
||||||
let resolver = member_dir
|
let resolver = member_dir
|
||||||
.workspace
|
.workspace
|
||||||
.create_resolver(
|
.create_resolver(
|
||||||
|
&CliSys::default(),
|
||||||
CreateResolverOptions {
|
CreateResolverOptions {
|
||||||
pkg_json_dep_resolution,
|
pkg_json_dep_resolution,
|
||||||
specified_import_map,
|
specified_import_map,
|
||||||
},
|
},
|
||||||
|path| std::fs::read_to_string(path).map_err(JsErrorBox::from_err),
|
|
||||||
)
|
)
|
||||||
.inspect_err(|err| {
|
.inspect_err(|err| {
|
||||||
lsp_warn!(
|
lsp_warn!(
|
||||||
|
@ -2078,7 +2076,6 @@ impl deno_config::workspace::WorkspaceCache for WorkspaceMemCache {
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use deno_config::deno_json::ConfigParseOptions;
|
|
||||||
use deno_core::resolve_url;
|
use deno_core::resolve_url;
|
||||||
use deno_core::serde_json;
|
use deno_core::serde_json;
|
||||||
use deno_core::serde_json::json;
|
use deno_core::serde_json::json;
|
||||||
|
@ -2352,12 +2349,7 @@ mod tests {
|
||||||
config
|
config
|
||||||
.tree
|
.tree
|
||||||
.inject_config_file(
|
.inject_config_file(
|
||||||
ConfigFile::new(
|
ConfigFile::new("{}", root_uri.join("deno.json").unwrap()).unwrap(),
|
||||||
"{}",
|
|
||||||
root_uri.join("deno.json").unwrap(),
|
|
||||||
&ConfigParseOptions::default(),
|
|
||||||
)
|
|
||||||
.unwrap(),
|
|
||||||
)
|
)
|
||||||
.await;
|
.await;
|
||||||
assert!(config.specifier_enabled(&root_uri));
|
assert!(config.specifier_enabled(&root_uri));
|
||||||
|
@ -2413,7 +2405,6 @@ mod tests {
|
||||||
})
|
})
|
||||||
.to_string(),
|
.to_string(),
|
||||||
root_uri.join("deno.json").unwrap(),
|
root_uri.join("deno.json").unwrap(),
|
||||||
&ConfigParseOptions::default(),
|
|
||||||
)
|
)
|
||||||
.unwrap(),
|
.unwrap(),
|
||||||
)
|
)
|
||||||
|
@ -2439,7 +2430,6 @@ mod tests {
|
||||||
})
|
})
|
||||||
.to_string(),
|
.to_string(),
|
||||||
root_uri.join("deno.json").unwrap(),
|
root_uri.join("deno.json").unwrap(),
|
||||||
&ConfigParseOptions::default(),
|
|
||||||
)
|
)
|
||||||
.unwrap(),
|
.unwrap(),
|
||||||
)
|
)
|
||||||
|
@ -2457,7 +2447,6 @@ mod tests {
|
||||||
})
|
})
|
||||||
.to_string(),
|
.to_string(),
|
||||||
root_uri.join("deno.json").unwrap(),
|
root_uri.join("deno.json").unwrap(),
|
||||||
&ConfigParseOptions::default(),
|
|
||||||
)
|
)
|
||||||
.unwrap(),
|
.unwrap(),
|
||||||
)
|
)
|
||||||
|
|
|
@ -1695,12 +1695,7 @@ mod tests {
|
||||||
let mut config = Config::new_with_roots([root_uri.clone()]);
|
let mut config = Config::new_with_roots([root_uri.clone()]);
|
||||||
if let Some((relative_path, json_string)) = maybe_import_map {
|
if let Some((relative_path, json_string)) = maybe_import_map {
|
||||||
let base_url = root_uri.join(relative_path).unwrap();
|
let base_url = root_uri.join(relative_path).unwrap();
|
||||||
let config_file = ConfigFile::new(
|
let config_file = ConfigFile::new(json_string, base_url).unwrap();
|
||||||
json_string,
|
|
||||||
base_url,
|
|
||||||
&deno_config::deno_json::ConfigParseOptions::default(),
|
|
||||||
)
|
|
||||||
.unwrap();
|
|
||||||
config.tree.inject_config_file(config_file).await;
|
config.tree.inject_config_file(config_file).await;
|
||||||
}
|
}
|
||||||
let resolver =
|
let resolver =
|
||||||
|
|
|
@ -1767,7 +1767,6 @@ fn bytes_to_content(
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use deno_config::deno_json::ConfigFile;
|
use deno_config::deno_json::ConfigFile;
|
||||||
use deno_config::deno_json::ConfigParseOptions;
|
|
||||||
use deno_core::serde_json;
|
use deno_core::serde_json;
|
||||||
use deno_core::serde_json::json;
|
use deno_core::serde_json::json;
|
||||||
use pretty_assertions::assert_eq;
|
use pretty_assertions::assert_eq;
|
||||||
|
@ -1924,7 +1923,6 @@ console.log(b, "hello deno");
|
||||||
})
|
})
|
||||||
.to_string(),
|
.to_string(),
|
||||||
config.root_uri().unwrap().join("deno.json").unwrap(),
|
config.root_uri().unwrap().join("deno.json").unwrap(),
|
||||||
&ConfigParseOptions::default(),
|
|
||||||
)
|
)
|
||||||
.unwrap(),
|
.unwrap(),
|
||||||
)
|
)
|
||||||
|
@ -1968,7 +1966,6 @@ console.log(b, "hello deno");
|
||||||
})
|
})
|
||||||
.to_string(),
|
.to_string(),
|
||||||
config.root_uri().unwrap().join("deno.json").unwrap(),
|
config.root_uri().unwrap().join("deno.json").unwrap(),
|
||||||
&ConfigParseOptions::default(),
|
|
||||||
)
|
)
|
||||||
.unwrap(),
|
.unwrap(),
|
||||||
)
|
)
|
||||||
|
|
|
@ -3621,8 +3621,6 @@ impl Inner {
|
||||||
deno_json_cache: None,
|
deno_json_cache: None,
|
||||||
pkg_json_cache: None,
|
pkg_json_cache: None,
|
||||||
workspace_cache: None,
|
workspace_cache: None,
|
||||||
config_parse_options:
|
|
||||||
deno_config::deno_json::ConfigParseOptions::default(),
|
|
||||||
additional_config_file_names: &[],
|
additional_config_file_names: &[],
|
||||||
discover_pkg_json: !has_flag_env_var("DENO_NO_PACKAGE_JSON"),
|
discover_pkg_json: !has_flag_env_var("DENO_NO_PACKAGE_JSON"),
|
||||||
maybe_vendor_override: if force_global_cache {
|
maybe_vendor_override: if force_global_cache {
|
||||||
|
|
|
@ -5589,7 +5589,6 @@ mod tests {
|
||||||
})
|
})
|
||||||
.to_string(),
|
.to_string(),
|
||||||
temp_dir.url().join("deno.json").unwrap(),
|
temp_dir.url().join("deno.json").unwrap(),
|
||||||
&Default::default(),
|
|
||||||
)
|
)
|
||||||
.unwrap(),
|
.unwrap(),
|
||||||
)
|
)
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
error: Failed to parse "lint" configuration
|
error: Failed to parse "lint" configuration
|
||||||
|
|
||||||
Caused by:
|
Caused by:
|
||||||
unknown field `dont_know_this_field`, expected one of `rules`, `include`, `exclude`, `files`, `report`
|
unknown field `dont_know_this_field`, expected one of `rules`, `include`, `exclude`, `files`, `report`, `plugins`
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
error: Failed to parse "lint" configuration
|
error: Failed to parse "lint" configuration
|
||||||
|
|
||||||
Caused by:
|
Caused by:
|
||||||
unknown field `dont_know_this_field`, expected one of `rules`, `include`, `exclude`, `files`, `report`
|
unknown field `dont_know_this_field`, expected one of `rules`, `include`, `exclude`, `files`, `report`, `plugins`
|
||||||
|
|
Loading…
Add table
Reference in a new issue