1
0
Fork 0
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:
David Sherret 2025-01-14 07:00:31 -05:00 committed by GitHub
parent a1f50a7422
commit 1e95c20561
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
10 changed files with 12 additions and 47 deletions

5
Cargo.lock generated
View file

@ -1497,11 +1497,12 @@ dependencies = [
[[package]]
name = "deno_config"
version = "0.43.0"
version = "0.45.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6c4c11bd51ef6738cabfc3c53f16c209a0b8615cb1e4e5bf3b14e3b5deebfe21"
checksum = "47a47412627aa0d08414eca0e8329128013ab70bdb2cdfdc5456c2214cf24c8f"
dependencies = [
"boxed_error",
"capacity_builder 0.5.0",
"deno_error",
"deno_package_json",
"deno_path_util",

View file

@ -51,7 +51,7 @@ deno_ast = { version = "=0.44.0", features = ["transpiling"] }
deno_core = { version = "0.330.0" }
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_media_type = { version = "0.2.3", features = ["module_specifier"] }
deno_npm = "=0.27.2"

View file

@ -56,7 +56,6 @@ use deno_core::error::AnyError;
use deno_core::resolve_url_or_path;
use deno_core::serde_json;
use deno_core::url::Url;
use deno_error::JsErrorBox;
use deno_graph::GraphKind;
pub use deno_json::check_warn_tsconfig;
use deno_lint::linter::LintConfig as DenoLintConfig;
@ -842,8 +841,6 @@ impl CliOptions {
} else {
&[]
};
let config_parse_options =
deno_config::deno_json::ConfigParseOptions::default();
let discover_pkg_json = flags.config_flag != ConfigFlag::Disabled
&& !flags.no_npm
&& !has_flag_env_var("DENO_NO_PACKAGE_JSON");
@ -854,7 +851,6 @@ impl CliOptions {
deno_json_cache: None,
pkg_json_cache: Some(&node_resolver::PackageJsonThreadLocalCache),
workspace_cache: None,
config_parse_options,
additional_config_file_names,
discover_pkg_json,
maybe_vendor_override,
@ -1103,11 +1099,11 @@ impl CliOptions {
}
};
Ok(self.workspace().create_resolver(
&CliSys::default(),
CreateResolverOptions {
pkg_json_dep_resolution,
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 config_specifier =
ModuleSpecifier::parse("file:///deno/deno.jsonc").unwrap();
let config_file = ConfigFile::new(
config_text,
config_specifier,
&deno_config::deno_json::ConfigParseOptions::default(),
)
.unwrap();
let config_file = ConfigFile::new(config_text, config_specifier).unwrap();
let actual = resolve_import_map_specifier(
Some("import-map.json"),
Some(&config_file),
@ -2150,12 +2141,7 @@ mod test {
let config_text = r#"{}"#;
let config_specifier =
ModuleSpecifier::parse("file:///deno/deno.jsonc").unwrap();
let config_file = ConfigFile::new(
config_text,
config_specifier,
&deno_config::deno_json::ConfigParseOptions::default(),
)
.unwrap();
let config_file = ConfigFile::new(config_text, config_specifier).unwrap();
let actual = resolve_import_map_specifier(
None,
Some(&config_file),

View file

@ -41,7 +41,6 @@ use deno_core::serde_json::json;
use deno_core::serde_json::Value;
use deno_core::url::Url;
use deno_core::ModuleSpecifier;
use deno_error::JsErrorBox;
use deno_lint::linter::LintConfig as DenoLintConfig;
use deno_npm::npm_rc::ResolvedNpmRc;
use deno_package_json::PackageJsonCache;
@ -1247,7 +1246,6 @@ impl ConfigData {
pkg_json_cache: Some(pkg_json_cache),
workspace_cache: Some(workspace_cache),
discover_pkg_json: !has_flag_env_var("DENO_NO_PACKAGE_JSON"),
config_parse_options: Default::default(),
maybe_vendor_override: None,
},
)
@ -1572,11 +1570,11 @@ impl ConfigData {
let resolver = member_dir
.workspace
.create_resolver(
&CliSys::default(),
CreateResolverOptions {
pkg_json_dep_resolution,
specified_import_map,
},
|path| std::fs::read_to_string(path).map_err(JsErrorBox::from_err),
)
.inspect_err(|err| {
lsp_warn!(
@ -2078,7 +2076,6 @@ impl deno_config::workspace::WorkspaceCache for WorkspaceMemCache {
#[cfg(test)]
mod tests {
use deno_config::deno_json::ConfigParseOptions;
use deno_core::resolve_url;
use deno_core::serde_json;
use deno_core::serde_json::json;
@ -2352,12 +2349,7 @@ mod tests {
config
.tree
.inject_config_file(
ConfigFile::new(
"{}",
root_uri.join("deno.json").unwrap(),
&ConfigParseOptions::default(),
)
.unwrap(),
ConfigFile::new("{}", root_uri.join("deno.json").unwrap()).unwrap(),
)
.await;
assert!(config.specifier_enabled(&root_uri));
@ -2413,7 +2405,6 @@ mod tests {
})
.to_string(),
root_uri.join("deno.json").unwrap(),
&ConfigParseOptions::default(),
)
.unwrap(),
)
@ -2439,7 +2430,6 @@ mod tests {
})
.to_string(),
root_uri.join("deno.json").unwrap(),
&ConfigParseOptions::default(),
)
.unwrap(),
)
@ -2457,7 +2447,6 @@ mod tests {
})
.to_string(),
root_uri.join("deno.json").unwrap(),
&ConfigParseOptions::default(),
)
.unwrap(),
)

View file

@ -1695,12 +1695,7 @@ mod tests {
let mut config = Config::new_with_roots([root_uri.clone()]);
if let Some((relative_path, json_string)) = maybe_import_map {
let base_url = root_uri.join(relative_path).unwrap();
let config_file = ConfigFile::new(
json_string,
base_url,
&deno_config::deno_json::ConfigParseOptions::default(),
)
.unwrap();
let config_file = ConfigFile::new(json_string, base_url).unwrap();
config.tree.inject_config_file(config_file).await;
}
let resolver =

View file

@ -1767,7 +1767,6 @@ fn bytes_to_content(
#[cfg(test)]
mod tests {
use deno_config::deno_json::ConfigFile;
use deno_config::deno_json::ConfigParseOptions;
use deno_core::serde_json;
use deno_core::serde_json::json;
use pretty_assertions::assert_eq;
@ -1924,7 +1923,6 @@ console.log(b, "hello deno");
})
.to_string(),
config.root_uri().unwrap().join("deno.json").unwrap(),
&ConfigParseOptions::default(),
)
.unwrap(),
)
@ -1968,7 +1966,6 @@ console.log(b, "hello deno");
})
.to_string(),
config.root_uri().unwrap().join("deno.json").unwrap(),
&ConfigParseOptions::default(),
)
.unwrap(),
)

View file

@ -3621,8 +3621,6 @@ impl Inner {
deno_json_cache: None,
pkg_json_cache: None,
workspace_cache: None,
config_parse_options:
deno_config::deno_json::ConfigParseOptions::default(),
additional_config_file_names: &[],
discover_pkg_json: !has_flag_env_var("DENO_NO_PACKAGE_JSON"),
maybe_vendor_override: if force_global_cache {

View file

@ -5589,7 +5589,6 @@ mod tests {
})
.to_string(),
temp_dir.url().join("deno.json").unwrap(),
&Default::default(),
)
.unwrap(),
)

View file

@ -1,4 +1,4 @@
error: Failed to parse "lint" configuration
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`

View file

@ -1,4 +1,4 @@
error: Failed to parse "lint" configuration
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`