-
-
Notifications
You must be signed in to change notification settings - Fork 164
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
new: Add interactive dependency and project graphs. (#439)
* refactor(cli::graph): change module location * feat(visualizer): add project * build: hoist lazy_static to workspace root Also add tiny-http dependency. * feat(cli::project_graph): add workspace data to rendered html * fix(cli/graph): get correct url for js static files * ci(vis): specify port for serving js files * build)vis): add cytoscape deps * feat(vis): render basic graph * build: hoist petgraph as workspace dependency * feat(cli::vis): support rendering graph for deps * chore(vis): fix linting issues * feat(cli): add `dot` flag to dep and project graph * chore(cli::graph): log server address * fix(cli:graph): generate repr only when needed * refactor(cli/graph): rename modules and templates * refactor: extract core vis func to package Also rename the visualizer package to visualizer-browser. * ci(prettier): ignore dist folder from formatter * ci(prettier): ignore timestamp files * test(cli): load workspace before generating dep graph * test(graph): use new strategy * chore(vis): change names of interfaces * refactor(vis): extract func to respond to indv. requests * refactor(cli/vis): rename function that serializes project * ci(vis-browser): change extension to cjs * ci(vis-browser): enable typecheck command * build(vis-browser): use semver ranges * ci(vis-browser): remove useless settings This commit removes the common options that were being repeated, since we are extending from another tsconfig. * fix(cli/graph): change names of expected env vars * refactor(cli/graph): extract constants to module * refactor(vis): move all code to single package * refactor(cli/graph): add func to get node * ci: add temp generated files to prettierignore * refactor(website): move tailwind config to workspace root This will allow us to share it as a preset across multiple projects. ci(website): disable preflight only for project * build(vis): add tailwind to project * feat(cli/vis): pass page title in context * feat(vis): enable dagre style graph * feat(vis): render arrows in graph * style(vis): fix formatting issues * fix(core): add required imports * Fix some stuff. * Get build working. * Test package. * Fix lints. * Add version. Co-authored-by: Miles Johnson <[email protected]>
- Loading branch information
Showing
49 changed files
with
1,423 additions
and
329 deletions.
There are no files selected for viewing
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 |
---|---|---|
|
@@ -12,6 +12,7 @@ umd/ | |
*.min.js | ||
*.map | ||
*.snap | ||
*.d.ts | ||
|
||
# Test fixtures | ||
/tests |
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 |
---|---|---|
|
@@ -19,6 +19,7 @@ esm/ | |
lib/ | ||
mjs/ | ||
umd/ | ||
dist/ | ||
|
||
# Artifacts | ||
.eslintcache | ||
|
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 |
---|---|---|
@@ -1,9 +1,10 @@ | ||
releases: | ||
"@moonrepo/cli": minor | ||
"@moonrepo/core-linux-arm64-gnu": minor | ||
"@moonrepo/core-linux-arm64-musl": minor | ||
"@moonrepo/core-linux-x64-gnu": minor | ||
"@moonrepo/core-linux-x64-musl": minor | ||
"@moonrepo/core-macos-arm64": minor | ||
"@moonrepo/core-macos-x64": minor | ||
"@moonrepo/core-windows-x64-msvc": minor | ||
'@moonrepo/cli': minor | ||
'@moonrepo/core-linux-arm64-gnu': minor | ||
'@moonrepo/core-linux-arm64-musl': minor | ||
'@moonrepo/core-linux-x64-gnu': minor | ||
'@moonrepo/core-linux-x64-musl': minor | ||
'@moonrepo/core-macos-arm64': minor | ||
'@moonrepo/core-macos-x64': minor | ||
'@moonrepo/core-windows-x64-msvc': minor | ||
'@moonrepo/visualizer': minor |
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
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,21 @@ | ||
use moon_config::ProjectID; | ||
use serde::{Deserialize, Serialize}; | ||
|
||
#[derive(Debug, Hash, Eq, PartialEq, Serialize, Deserialize)] | ||
pub struct GraphNodeDto { | ||
pub id: usize, | ||
pub label: String, | ||
} | ||
|
||
#[derive(Debug, Serialize, Deserialize)] | ||
pub struct GraphEdgeDto { | ||
pub id: ProjectID, | ||
pub source: usize, | ||
pub target: usize, | ||
} | ||
|
||
#[derive(Debug, Serialize, Deserialize)] | ||
pub struct GraphInfoDto { | ||
pub nodes: Vec<GraphNodeDto>, | ||
pub edges: Vec<GraphEdgeDto>, | ||
} |
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,16 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8" /> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> | ||
<title>Moon Visualizer</title> | ||
<script type="module" crossorigin src="{{ js_url }}"></script> | ||
</head> | ||
<body> | ||
<script> | ||
window.GRAPH_DATA = '{{ graph_data | safe }}'; | ||
window.PAGE_TITLE = '{{ page_title }}'; | ||
</script> | ||
<div id="app"></div> | ||
</body> | ||
</html> |
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,6 @@ | ||
pub mod dep; | ||
mod dto; | ||
pub mod project; | ||
mod utils; | ||
|
||
pub const LOG_TARGET: &str = "moon: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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
use crate::commands::graph::{ | ||
utils::{project_graph_repr, respond_to_request, setup_server}, | ||
LOG_TARGET, | ||
}; | ||
use moon::{build_project_graph, load_workspace}; | ||
use moon_logger::info; | ||
|
||
pub async fn project_graph( | ||
project_id: &Option<String>, | ||
dot: bool, | ||
) -> Result<(), Box<dyn std::error::Error>> { | ||
let mut workspace = load_workspace().await?; | ||
let mut project_build = build_project_graph(&mut workspace)?; | ||
|
||
if let Some(id) = project_id { | ||
project_build.load(id)?; | ||
} else { | ||
project_build.load_all()?; | ||
} | ||
|
||
let project_graph = project_build.build(); | ||
|
||
if dot { | ||
println!("{}", project_graph.to_dot()); | ||
|
||
return Ok(()); | ||
} | ||
|
||
let (server, mut tera) = setup_server().await?; | ||
let graph_info = project_graph_repr(&project_graph).await; | ||
|
||
info!( | ||
target: LOG_TARGET, | ||
r#"Starting server on "{}""#, | ||
server.server_addr() | ||
); | ||
|
||
for req in server.incoming_requests() { | ||
respond_to_request(req, &mut tera, &graph_info, "Project".to_owned())?; | ||
} | ||
|
||
Ok(()) | ||
} |
Oops, something went wrong.