-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Project graph and Nx implicit dependencies (#19)
- Loading branch information
1 parent
d72b387
commit 1195847
Showing
10 changed files
with
136 additions
and
52 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
use crate::nx::NxProject; | ||
use crate::projects::Project; | ||
use anyhow::Result; | ||
use petgraph::Graph; | ||
use std::path::Path; | ||
|
||
pub fn build_graph(workspace_root: &Path, project_paths: &[String]) -> Result<Graph<String, ()>> { | ||
let mut graph = Graph::new(); | ||
let projects: Vec<NxProject> = project_paths | ||
.iter() | ||
.map(|path| NxProject::load(workspace_root, path)) | ||
.collect::<Result<Vec<NxProject>>>()?; | ||
|
||
for project in projects { | ||
let project_name = project.name().unwrap_or("Unnamed"); | ||
let project_node = graph.add_node(project_name.to_string()); | ||
|
||
if let Some(dependencies) = project.implicit_dependencies { | ||
dependencies.iter().for_each(|dependency| { | ||
let dependency_node = graph.add_node(dependency.to_string()); | ||
graph.add_edge(project_node, dependency_node, ()); | ||
}); | ||
} | ||
|
||
// let project_dependencies = project.dependencies(); | ||
// for dependency in project_dependencies { | ||
// let dependency_name = dependency.name().unwrap_or("Unnamed"); | ||
// let dependency_node = graph.add_node(dependency_name.to_string()); | ||
// | ||
// graph.add_edge(project_node, dependency_node, 1); | ||
// } | ||
} | ||
|
||
Ok(graph) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters