summaryrefslogtreecommitdiff
path: root/cli/lsp/config.rs
diff options
context:
space:
mode:
authorDavid Sherret <dsherret@users.noreply.github.com>2024-07-03 20:54:33 -0400
committerGitHub <noreply@github.com>2024-07-04 00:54:33 +0000
commit147411e64b22fe74cb258125acab83f9182c9f81 (patch)
treea1f63dcbf0404c20534986b10f02b649df5a3ad5 /cli/lsp/config.rs
parentdd6d19e12051fac2ea5639f621501f4710a1b8e1 (diff)
feat: npm workspace and better Deno workspace support (#24334)
Adds much better support for the unstable Deno workspaces as well as support for npm workspaces. npm workspaces is still lacking in that we only install packages into the root node_modules folder. We'll make it smarter over time in order for it to figure out when to add node_modules folders within packages. This includes a breaking change in config file resolution where we stop searching for config files on the first found package.json unless it's in a workspace. For the previous behaviour, the root deno.json needs to be updated to be a workspace by adding `"workspace": ["./path-to-pkg-json-folder-goes-here"]`. See details in https://github.com/denoland/deno_config/pull/66 Closes #24340 Closes #24159 Closes #24161 Closes #22020 Closes #18546 Closes #16106 Closes #24160
Diffstat (limited to 'cli/lsp/config.rs')
-rw-r--r--cli/lsp/config.rs34
1 files changed, 12 insertions, 22 deletions
diff --git a/cli/lsp/config.rs b/cli/lsp/config.rs
index e1f3e3207..4b96511c0 100644
--- a/cli/lsp/config.rs
+++ b/cli/lsp/config.rs
@@ -16,7 +16,6 @@ use crate::util::fs::canonicalize_path_maybe_not_exists;
use deno_ast::MediaType;
use deno_config::FmtOptionsConfig;
use deno_config::TsConfig;
-use deno_core::anyhow::anyhow;
use deno_core::normalize_path;
use deno_core::serde::de::DeserializeOwned;
use deno_core::serde::Deserialize;
@@ -27,6 +26,8 @@ use deno_core::serde_json::Value;
use deno_core::ModuleSpecifier;
use deno_lint::linter::LintConfig;
use deno_npm::npm_rc::ResolvedNpmRc;
+use deno_runtime::deno_fs::DenoConfigFsAdapter;
+use deno_runtime::deno_fs::RealFs;
use deno_runtime::deno_node::PackageJson;
use deno_runtime::deno_permissions::PermissionsContainer;
use deno_runtime::fs_util::specifier_to_file_path;
@@ -935,7 +936,7 @@ impl Config {
pub fn specifier_enabled(&self, specifier: &ModuleSpecifier) -> bool {
let config_file = self.tree.config_file_for_specifier(specifier);
if let Some(cf) = config_file {
- if let Ok(files) = cf.to_files_config() {
+ if let Ok(files) = cf.to_exclude_files_config() {
if !files.matches_specifier(specifier) {
return false;
}
@@ -952,7 +953,7 @@ impl Config {
specifier: &ModuleSpecifier,
) -> bool {
if let Some(cf) = self.tree.config_file_for_specifier(specifier) {
- if let Some(options) = cf.to_test_config().ok().flatten() {
+ if let Ok(options) = cf.to_test_config() {
if !options.files.matches_specifier(specifier) {
return false;
}
@@ -1135,8 +1136,9 @@ impl ConfigData {
) -> Self {
if let Some(specifier) = config_file_specifier {
match ConfigFile::from_specifier(
+ &DenoConfigFsAdapter::new(&RealFs),
specifier.clone(),
- &deno_config::ParseOptions::default(),
+ &deno_config::ConfigParseOptions::default(),
) {
Ok(config_file) => {
lsp_log!(
@@ -1230,13 +1232,7 @@ impl ConfigData {
.and_then(|config_file| {
config_file
.to_fmt_config()
- .and_then(|o| {
- let base_path = config_file
- .specifier
- .to_file_path()
- .map_err(|_| anyhow!("Invalid base path."))?;
- FmtOptions::resolve(o, None, &base_path)
- })
+ .and_then(|o| FmtOptions::resolve(o, &Default::default(), None))
.inspect_err(|err| {
lsp_warn!(" Couldn't read formatter configuration: {}", err)
})
@@ -1264,13 +1260,7 @@ impl ConfigData {
.and_then(|config_file| {
config_file
.to_lint_config()
- .and_then(|o| {
- let base_path = config_file
- .specifier
- .to_file_path()
- .map_err(|_| anyhow!("Invalid base path."))?;
- LintOptions::resolve(o, None, &base_path)
- })
+ .and_then(|o| LintOptions::resolve(o, Default::default(), None))
.inspect_err(|err| {
lsp_warn!(" Couldn't read lint configuration: {}", err)
})
@@ -2115,7 +2105,7 @@ mod tests {
ConfigFile::new(
"{}",
root_uri.join("deno.json").unwrap(),
- &deno_config::ParseOptions::default(),
+ &deno_config::ConfigParseOptions::default(),
)
.unwrap(),
)
@@ -2173,7 +2163,7 @@ mod tests {
})
.to_string(),
root_uri.join("deno.json").unwrap(),
- &deno_config::ParseOptions::default(),
+ &deno_config::ConfigParseOptions::default(),
)
.unwrap(),
)
@@ -2199,7 +2189,7 @@ mod tests {
})
.to_string(),
root_uri.join("deno.json").unwrap(),
- &deno_config::ParseOptions::default(),
+ &deno_config::ConfigParseOptions::default(),
)
.unwrap(),
)
@@ -2217,7 +2207,7 @@ mod tests {
})
.to_string(),
root_uri.join("deno.json").unwrap(),
- &deno_config::ParseOptions::default(),
+ &deno_config::ConfigParseOptions::default(),
)
.unwrap(),
)