-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
545394a
commit 6e57ec7
Showing
7 changed files
with
131 additions
and
17 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,52 @@ | ||
import React, { FC, useEffect, useRef } from 'react'; | ||
import { Edge, Network, Node } from 'vis-network/standalone'; | ||
|
||
type Props = {}; | ||
|
||
const DepGraph: FC<Props> = () => { | ||
const containerRef = useRef<HTMLDivElement>(null); | ||
|
||
useEffect(() => { | ||
if (containerRef.current) { | ||
const nodes: Node[] = [ | ||
{ id: 1, label: 'Node 1' }, | ||
{ id: 2, label: 'Node 2' }, | ||
{ id: 3, label: 'Node 3' }, | ||
{ id: 4, label: 'Node 4' }, | ||
{ id: 5, label: 'Node 5' }, | ||
]; | ||
|
||
const edges: Edge[] = [ | ||
{ from: 1, to: 3 }, | ||
{ from: 1, to: 2 }, | ||
{ from: 2, to: 4 }, | ||
{ from: 2, to: 5 }, | ||
{ from: 3, to: 3 }, | ||
]; | ||
|
||
const network = new Network( | ||
containerRef.current, | ||
{ edges, nodes }, | ||
{ | ||
edges: { | ||
arrows: 'to', | ||
}, | ||
layout: { | ||
hierarchical: { | ||
sortMethod: 'directed', | ||
}, | ||
}, | ||
}, | ||
); | ||
} | ||
}, [containerRef.current]); | ||
|
||
return ( | ||
<div | ||
ref={containerRef} | ||
style={{ height: '50vh', width: '100%', border: '1px solid grey' }} | ||
></div> | ||
); | ||
}; | ||
|
||
export default DepGraph; |
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,15 @@ | ||
import { Module, ModuleDeps } from './types'; | ||
|
||
export function getModules(moduleDeps: ModuleDeps): Module[] { | ||
return moduleDeps.paths.map(path => moduleDeps.modules[path]); | ||
} | ||
|
||
// TODO: implement | ||
export declare function createGraph(args: { | ||
moduleDeps: ModuleDeps; | ||
rootModules: string[]; | ||
leafModules: string[]; | ||
}): { | ||
modules: Module[]; | ||
imports: { fromPath: string; toPath: string }[]; | ||
}; |
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,5 +1,12 @@ | ||
export type Module = { | ||
path: string; | ||
source: string; | ||
alias?: string; | ||
isLocal: boolean; | ||
}; | ||
|
||
export type ModuleDeps = { | ||
modules: Record<string, Module>; | ||
paths: string[]; | ||
deps: Record<string, string[]>; | ||
}; |