From 71bc87b838650590c4bcdd6cc80daf0d1a5c2730 Mon Sep 17 00:00:00 2001 From: Miles Johnson Date: Tue, 10 Oct 2023 12:54:57 -0700 Subject: [PATCH] Polish. --- nextgen/config/src/project/dep_config.rs | 2 +- nextgen/project-builder/src/project_builder.rs | 4 ++-- nextgen/project-builder/tests/project_builder_test.rs | 2 +- nextgen/project-graph/src/project_graph_builder.rs | 9 +++++---- nextgen/test-utils/src/project_graph.rs | 7 ++++--- 5 files changed, 13 insertions(+), 11 deletions(-) diff --git a/nextgen/config/src/project/dep_config.rs b/nextgen/config/src/project/dep_config.rs index 374d0a6e5fc..8200433f38f 100644 --- a/nextgen/config/src/project/dep_config.rs +++ b/nextgen/config/src/project/dep_config.rs @@ -10,7 +10,7 @@ derive_enum!( #[default] Production, - // Special case when dependening on the root-level project + // Special case when depending on the root-level project Root, } ); diff --git a/nextgen/project-builder/src/project_builder.rs b/nextgen/project-builder/src/project_builder.rs index 2aeb25d4b4b..98dafab9ff6 100644 --- a/nextgen/project-builder/src/project_builder.rs +++ b/nextgen/project-builder/src/project_builder.rs @@ -27,7 +27,7 @@ impl Event for DetectLanguageEvent { pub struct ProjectBuilderContext<'app> { pub detect_language: &'app Emitter, pub detect_platform: &'app Emitter, - pub root_id: Option<&'app Id>, + pub root_project_id: Option<&'app Id>, pub toolchain_config: &'app ToolchainConfig, pub workspace_root: &'app Path, } @@ -269,7 +269,7 @@ impl<'app> ProjectBuilder<'app> { dep_id.to_owned(), DependencyConfig { id: dep_id.to_owned(), - scope: if self.context.root_id.is_some_and(|r| r == dep_id) { + scope: if self.context.root_project_id.is_some_and(|id| id == dep_id) { DependencyScope::Root } else { DependencyScope::Peer diff --git a/nextgen/project-builder/tests/project_builder_test.rs b/nextgen/project-builder/tests/project_builder_test.rs index a4beff0ca56..6f68ba269c6 100644 --- a/nextgen/project-builder/tests/project_builder_test.rs +++ b/nextgen/project-builder/tests/project_builder_test.rs @@ -56,7 +56,7 @@ impl Stub { ProjectBuilderContext { detect_language: &self.detect_language, detect_platform: &self.detect_platform, - root_id: None, + root_project_id: None, toolchain_config: &self.toolchain_config, workspace_root: &self.workspace_root, }, diff --git a/nextgen/project-graph/src/project_graph_builder.rs b/nextgen/project-graph/src/project_graph_builder.rs index 6807eb93da8..b6bb7331760 100644 --- a/nextgen/project-graph/src/project_graph_builder.rs +++ b/nextgen/project-graph/src/project_graph_builder.rs @@ -60,7 +60,8 @@ pub struct ProjectGraphBuilder<'app> { nodes: FxHashMap, /// The root project ID. - root_id: Option, + #[serde(skip)] + root_project_id: Option, /// Mapping of project IDs to file system sources, /// derived from the `workspace.projects` setting. @@ -80,7 +81,7 @@ impl<'app> ProjectGraphBuilder<'app> { aliases: FxHashMap::default(), graph: DiGraph::new(), nodes: FxHashMap::default(), - root_id: None, + root_project_id: None, sources: FxHashMap::default(), }; @@ -297,7 +298,7 @@ impl<'app> ProjectGraphBuilder<'app> { ProjectBuilderContext { detect_language: &context.detect_language, detect_platform: &context.detect_platform, - root_id: self.root_id.as_ref(), + root_project_id: self.root_project_id.as_ref(), toolchain_config: context.toolchain_config, workspace_root: context.workspace_root, }, @@ -465,7 +466,7 @@ impl<'app> ProjectGraphBuilder<'app> { .await?; // Find the root project - self.root_id = sources.iter().find_map(|(id, source)| { + self.root_project_id = sources.iter().find_map(|(id, source)| { if source.as_str().is_empty() || source.as_str() == "." { Some(id.to_owned()) } else { diff --git a/nextgen/test-utils/src/project_graph.rs b/nextgen/test-utils/src/project_graph.rs index c70893b0106..5fd4cad59e6 100644 --- a/nextgen/test-utils/src/project_graph.rs +++ b/nextgen/test-utils/src/project_graph.rs @@ -53,9 +53,10 @@ impl ProjectGraphContainer { } // Use folders as project names - let mut projects = WorkspaceProjectsConfig::default(); - - projects.globs = vec!["*".into()]; + let mut projects = WorkspaceProjectsConfig { + globs: vec!["*".into()], + ..WorkspaceProjectsConfig::default() + }; if root.join("moon.yml").exists() { projects.sources.insert("root".into(), ".".into());