mvn-tree-visualizer 1.0.3b4__py3-none-any.whl → 1.1.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of mvn-tree-visualizer might be problematic. Click here for more details.
- mvn_tree_visualizer/TEMPLATE.py +61 -61
- mvn_tree_visualizer/__main__.py +4 -4
- mvn_tree_visualizer/cli.py +86 -71
- mvn_tree_visualizer/diagram.py +13 -74
- mvn_tree_visualizer/get_dependencies_in_one_file.py +11 -11
- mvn_tree_visualizer/outputs/html_output.py +49 -0
- mvn_tree_visualizer/outputs/json_output.py +47 -0
- mvn_tree_visualizer-1.1.0.dist-info/METADATA +71 -0
- mvn_tree_visualizer-1.1.0.dist-info/RECORD +13 -0
- {mvn_tree_visualizer-1.0.3b4.dist-info → mvn_tree_visualizer-1.1.0.dist-info}/licenses/LICENSE +21 -21
- mvn_tree_visualizer-1.0.3b4.dist-info/METADATA +0 -41
- mvn_tree_visualizer-1.0.3b4.dist-info/RECORD +0 -11
- {mvn_tree_visualizer-1.0.3b4.dist-info → mvn_tree_visualizer-1.1.0.dist-info}/WHEEL +0 -0
- {mvn_tree_visualizer-1.0.3b4.dist-info → mvn_tree_visualizer-1.1.0.dist-info}/entry_points.txt +0 -0
mvn_tree_visualizer/TEMPLATE.py
CHANGED
|
@@ -1,61 +1,61 @@
|
|
|
1
|
-
HTML_TEMPLATE = r"""<html></html>
|
|
2
|
-
<head>
|
|
3
|
-
<style type="text/css">
|
|
4
|
-
#mySvgId {
|
|
5
|
-
height: 90%;
|
|
6
|
-
width: 90%;
|
|
7
|
-
}
|
|
8
|
-
</style>
|
|
9
|
-
<title>Dependency Diagram</title>
|
|
10
|
-
</head>
|
|
11
|
-
<body>
|
|
12
|
-
<div id="graphDiv"></div>
|
|
13
|
-
<button id="downloadButton">Download SVG</button>
|
|
14
|
-
<script src="https://cdn.jsdelivr.net/npm/svg-pan-zoom@3.5.0/dist/svg-pan-zoom.min.js"></script>
|
|
15
|
-
<script type="module">
|
|
16
|
-
import mermaid from 'https://cdn.jsdelivr.net/npm/mermaid@10.9.0/dist/mermaid.esm.min.mjs';
|
|
17
|
-
mermaid.initialize({
|
|
18
|
-
startOnLoad:true,
|
|
19
|
-
sequence:{
|
|
20
|
-
useMaxWidth:false
|
|
21
|
-
}
|
|
22
|
-
});
|
|
23
|
-
|
|
24
|
-
const drawDiagram = async function () {
|
|
25
|
-
const element = document.querySelector('#graphDiv');
|
|
26
|
-
const graphDefinition = `
|
|
27
|
-
{{diagram_definition}}
|
|
28
|
-
`;
|
|
29
|
-
const { svg } = await mermaid.render('mySvgId', graphDefinition);
|
|
30
|
-
element.innerHTML = svg.replace(/[ ]*max-width:[ 0-9\.]*px;/i , '');
|
|
31
|
-
var panZoomTiger = svgPanZoom('#mySvgId', {
|
|
32
|
-
zoomEnabled: true,
|
|
33
|
-
controlIconsEnabled: true,
|
|
34
|
-
fit: true,
|
|
35
|
-
center: true
|
|
36
|
-
})
|
|
37
|
-
};
|
|
38
|
-
await drawDiagram();
|
|
39
|
-
|
|
40
|
-
// Add event listener to the download button to download the SVG without the pan & zoom buttons
|
|
41
|
-
document.getElementById('downloadButton').addEventListener('click', function() {
|
|
42
|
-
const svg = document.querySelector('#mySvgId');
|
|
43
|
-
let svgData = new XMLSerializer().serializeToString(svg);
|
|
44
|
-
|
|
45
|
-
// To remove the pan & zoom buttons of the diagram, any element whose class contains the string 'svg-pan-zoom-*' should be removed
|
|
46
|
-
svgData = svgData.replace(/<g\b[^>]*\bclass="svg-pan-zoom-.*?".*?>.*?<\/g>/g, '');
|
|
47
|
-
// The above leaves out a closing </g> tag before the final </svg> tag, so we need to remove it
|
|
48
|
-
svgData = svgData.replace(/<\/g><\/svg>/, '</svg>');
|
|
49
|
-
|
|
50
|
-
const svgBlob = new Blob([svgData], {type: 'image/svg+xml;charset=utf-8'});
|
|
51
|
-
const svgUrl = URL.createObjectURL(svgBlob);
|
|
52
|
-
const downloadLink = document.createElement('a');
|
|
53
|
-
downloadLink.href = svgUrl;
|
|
54
|
-
downloadLink.download = 'diagram.svg';
|
|
55
|
-
document.body.appendChild(downloadLink);
|
|
56
|
-
downloadLink.click();
|
|
57
|
-
document.body.removeChild(downloadLink);
|
|
58
|
-
});
|
|
59
|
-
</script>
|
|
60
|
-
</body>
|
|
61
|
-
</html>"""
|
|
1
|
+
HTML_TEMPLATE = r"""<html></html>
|
|
2
|
+
<head>
|
|
3
|
+
<style type="text/css">
|
|
4
|
+
#mySvgId {
|
|
5
|
+
height: 90%;
|
|
6
|
+
width: 90%;
|
|
7
|
+
}
|
|
8
|
+
</style>
|
|
9
|
+
<title>Dependency Diagram</title>
|
|
10
|
+
</head>
|
|
11
|
+
<body>
|
|
12
|
+
<div id="graphDiv"></div>
|
|
13
|
+
<button id="downloadButton">Download SVG</button>
|
|
14
|
+
<script src="https://cdn.jsdelivr.net/npm/svg-pan-zoom@3.5.0/dist/svg-pan-zoom.min.js"></script>
|
|
15
|
+
<script type="module">
|
|
16
|
+
import mermaid from 'https://cdn.jsdelivr.net/npm/mermaid@10.9.0/dist/mermaid.esm.min.mjs';
|
|
17
|
+
mermaid.initialize({
|
|
18
|
+
startOnLoad:true,
|
|
19
|
+
sequence:{
|
|
20
|
+
useMaxWidth:false
|
|
21
|
+
}
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
const drawDiagram = async function () {
|
|
25
|
+
const element = document.querySelector('#graphDiv');
|
|
26
|
+
const graphDefinition = `
|
|
27
|
+
{{diagram_definition}}
|
|
28
|
+
`;
|
|
29
|
+
const { svg } = await mermaid.render('mySvgId', graphDefinition);
|
|
30
|
+
element.innerHTML = svg.replace(/[ ]*max-width:[ 0-9\.]*px;/i , '');
|
|
31
|
+
var panZoomTiger = svgPanZoom('#mySvgId', {
|
|
32
|
+
zoomEnabled: true,
|
|
33
|
+
controlIconsEnabled: true,
|
|
34
|
+
fit: true,
|
|
35
|
+
center: true
|
|
36
|
+
})
|
|
37
|
+
};
|
|
38
|
+
await drawDiagram();
|
|
39
|
+
|
|
40
|
+
// Add event listener to the download button to download the SVG without the pan & zoom buttons
|
|
41
|
+
document.getElementById('downloadButton').addEventListener('click', function() {
|
|
42
|
+
const svg = document.querySelector('#mySvgId');
|
|
43
|
+
let svgData = new XMLSerializer().serializeToString(svg);
|
|
44
|
+
|
|
45
|
+
// To remove the pan & zoom buttons of the diagram, any element whose class contains the string 'svg-pan-zoom-*' should be removed
|
|
46
|
+
svgData = svgData.replace(/<g\b[^>]*\bclass="svg-pan-zoom-.*?".*?>.*?<\/g>/g, '');
|
|
47
|
+
// The above leaves out a closing </g> tag before the final </svg> tag, so we need to remove it
|
|
48
|
+
svgData = svgData.replace(/<\/g><\/svg>/, '</svg>');
|
|
49
|
+
|
|
50
|
+
const svgBlob = new Blob([svgData], {type: 'image/svg+xml;charset=utf-8'});
|
|
51
|
+
const svgUrl = URL.createObjectURL(svgBlob);
|
|
52
|
+
const downloadLink = document.createElement('a');
|
|
53
|
+
downloadLink.href = svgUrl;
|
|
54
|
+
downloadLink.download = 'diagram.svg';
|
|
55
|
+
document.body.appendChild(downloadLink);
|
|
56
|
+
downloadLink.click();
|
|
57
|
+
document.body.removeChild(downloadLink);
|
|
58
|
+
});
|
|
59
|
+
</script>
|
|
60
|
+
</body>
|
|
61
|
+
</html>"""
|
mvn_tree_visualizer/__main__.py
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
if __name__ == "__main__":
|
|
2
|
-
from mvn_tree_visualizer.cli import cli
|
|
3
|
-
|
|
4
|
-
cli()
|
|
1
|
+
if __name__ == "__main__":
|
|
2
|
+
from mvn_tree_visualizer.cli import cli
|
|
3
|
+
|
|
4
|
+
cli()
|
mvn_tree_visualizer/cli.py
CHANGED
|
@@ -1,71 +1,86 @@
|
|
|
1
|
-
import argparse
|
|
2
|
-
from pathlib import Path
|
|
3
|
-
|
|
4
|
-
from .diagram import create_diagram
|
|
5
|
-
from .get_dependencies_in_one_file import merge_files
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
1
|
+
import argparse
|
|
2
|
+
from pathlib import Path
|
|
3
|
+
|
|
4
|
+
from .diagram import create_diagram
|
|
5
|
+
from .get_dependencies_in_one_file import merge_files
|
|
6
|
+
from .outputs.html_output import create_html_diagram
|
|
7
|
+
from .outputs.json_output import create_json_output
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
def cli():
|
|
11
|
+
parser = argparse.ArgumentParser(
|
|
12
|
+
prog="mvn-tree-visualizer",
|
|
13
|
+
description="Generate a dependency diagram from a file.",
|
|
14
|
+
)
|
|
15
|
+
parser.add_argument(
|
|
16
|
+
"directory",
|
|
17
|
+
type=str,
|
|
18
|
+
nargs="?",
|
|
19
|
+
default=".",
|
|
20
|
+
help="The directory to scan for the Maven dependency file(s). Default is the current directory.",
|
|
21
|
+
)
|
|
22
|
+
|
|
23
|
+
parser.add_argument(
|
|
24
|
+
"-o",
|
|
25
|
+
"--output",
|
|
26
|
+
type=str,
|
|
27
|
+
default="diagram.html",
|
|
28
|
+
help="The output file for the generated diagram. Default is 'diagram.html'.",
|
|
29
|
+
)
|
|
30
|
+
|
|
31
|
+
parser.add_argument(
|
|
32
|
+
"--format",
|
|
33
|
+
type=str,
|
|
34
|
+
default="html",
|
|
35
|
+
choices=["html", "json"],
|
|
36
|
+
help="The output format. Default is 'html'.",
|
|
37
|
+
)
|
|
38
|
+
|
|
39
|
+
parser.add_argument(
|
|
40
|
+
"-f",
|
|
41
|
+
"--filename",
|
|
42
|
+
type=str,
|
|
43
|
+
default="maven_dependency_file",
|
|
44
|
+
help="The name of the file to read the Maven dependencies from. Default is 'maven_dependency_file'.",
|
|
45
|
+
)
|
|
46
|
+
parser.add_argument(
|
|
47
|
+
"--keep-tree",
|
|
48
|
+
type=bool,
|
|
49
|
+
default=False,
|
|
50
|
+
help="Keep the dependency tree file after generating the diagram. Default is False.",
|
|
51
|
+
)
|
|
52
|
+
|
|
53
|
+
args = parser.parse_args()
|
|
54
|
+
directory: str = args.directory
|
|
55
|
+
output_file: str = args.output
|
|
56
|
+
filename: str = args.filename
|
|
57
|
+
keep_tree: bool = args.keep_tree
|
|
58
|
+
output_format: str = args.format
|
|
59
|
+
|
|
60
|
+
dir_to_create_files = Path(output_file).parent
|
|
61
|
+
|
|
62
|
+
dir_to_create_intermediate_files = Path(dir_to_create_files)
|
|
63
|
+
|
|
64
|
+
merge_files(
|
|
65
|
+
output_file=dir_to_create_intermediate_files / "dependency_tree.txt",
|
|
66
|
+
root_dir=directory,
|
|
67
|
+
target_filename=filename,
|
|
68
|
+
)
|
|
69
|
+
|
|
70
|
+
dependency_tree = create_diagram(
|
|
71
|
+
keep_tree=keep_tree,
|
|
72
|
+
intermediate_filename="dependency_tree.txt",
|
|
73
|
+
)
|
|
74
|
+
|
|
75
|
+
if output_format == "html":
|
|
76
|
+
create_html_diagram(dependency_tree, output_file)
|
|
77
|
+
elif output_format == "json":
|
|
78
|
+
create_json_output(dependency_tree, output_file)
|
|
79
|
+
|
|
80
|
+
print(f"Diagram generated and saved to {output_file}")
|
|
81
|
+
print("You can open it in your browser to view the dependency tree.")
|
|
82
|
+
print("Thank you for using mvn-tree-visualizer!")
|
|
83
|
+
|
|
84
|
+
|
|
85
|
+
if __name__ == "__main__":
|
|
86
|
+
cli()
|
mvn_tree_visualizer/diagram.py
CHANGED
|
@@ -1,74 +1,13 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
for line in lines:
|
|
16
|
-
if not line or line.startswith("[INFO]"):
|
|
17
|
-
continue
|
|
18
|
-
parts = line.split(":")
|
|
19
|
-
|
|
20
|
-
if len(parts) < 3:
|
|
21
|
-
continue
|
|
22
|
-
|
|
23
|
-
if len(parts) == 4:
|
|
24
|
-
group_id, artifact_id, app, version = parts
|
|
25
|
-
mermaid_lines.add(f"\t{artifact_id};")
|
|
26
|
-
|
|
27
|
-
if previous_dependency: # Re initialize the list if it wasn't empty
|
|
28
|
-
previous_dependency = []
|
|
29
|
-
|
|
30
|
-
previous_dependency.append((artifact_id, 0)) # The second element is the depth
|
|
31
|
-
else:
|
|
32
|
-
depth = len(parts[0].split(" ")) - 1
|
|
33
|
-
|
|
34
|
-
if len(parts) == 6:
|
|
35
|
-
dirty_group_id, artifact_id, app, ejb_client, version, dependency = parts
|
|
36
|
-
else:
|
|
37
|
-
dirty_group_id, artifact_id, app, version, dependency = parts
|
|
38
|
-
|
|
39
|
-
if previous_dependency[-1][1] < depth:
|
|
40
|
-
mermaid_lines.add(f"\t{previous_dependency[-1][0]} --> {artifact_id};")
|
|
41
|
-
previous_dependency.append((artifact_id, depth))
|
|
42
|
-
else:
|
|
43
|
-
# remove all dependencies that are deeper or equal to the current depth
|
|
44
|
-
while previous_dependency and previous_dependency[-1][1] >= depth:
|
|
45
|
-
previous_dependency.pop()
|
|
46
|
-
|
|
47
|
-
mermaid_lines.add(f"\t{previous_dependency[-1][0]} --> {artifact_id};")
|
|
48
|
-
previous_dependency.append((artifact_id, depth))
|
|
49
|
-
|
|
50
|
-
mermaid_diagram = f"graph LR\n{'\n'.join(sorted(mermaid_lines))}"
|
|
51
|
-
return mermaid_diagram
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
def create_diagram(keep_tree: bool = False, intermediate_filename: str = "dependency_tree.txt", output_filename: str = "diagram.html"):
|
|
55
|
-
with open(intermediate_filename, "r") as file:
|
|
56
|
-
dependency_tree = file.read()
|
|
57
|
-
|
|
58
|
-
mermaid_diagram = _convert_to_mermaid(dependency_tree)
|
|
59
|
-
|
|
60
|
-
template = Environment(loader=BaseLoader).from_string(HTML_TEMPLATE)
|
|
61
|
-
rendered = template.render(diagram_definition=mermaid_diagram)
|
|
62
|
-
|
|
63
|
-
parent_dir = Path(output_filename).parent
|
|
64
|
-
|
|
65
|
-
if not parent_dir.exists():
|
|
66
|
-
parent_dir.mkdir(parents=True, exist_ok=True)
|
|
67
|
-
|
|
68
|
-
with open(output_filename, "w") as f:
|
|
69
|
-
f.write(rendered)
|
|
70
|
-
|
|
71
|
-
if not keep_tree:
|
|
72
|
-
import os
|
|
73
|
-
|
|
74
|
-
os.remove(intermediate_filename)
|
|
1
|
+
def create_diagram(
|
|
2
|
+
keep_tree: bool = False,
|
|
3
|
+
intermediate_filename: str = "dependency_tree.txt",
|
|
4
|
+
):
|
|
5
|
+
with open(intermediate_filename, "r") as file:
|
|
6
|
+
dependency_tree = file.read()
|
|
7
|
+
|
|
8
|
+
if not keep_tree:
|
|
9
|
+
import os
|
|
10
|
+
|
|
11
|
+
os.remove(intermediate_filename)
|
|
12
|
+
|
|
13
|
+
return dependency_tree
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import os
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
def merge_files(output_file: str, root_dir: str = ".", target_filename: str = "maven_dependency_file"):
|
|
5
|
-
with open(output_file, "w", encoding="utf-8") as outfile:
|
|
6
|
-
for dirpath, _, filenames in os.walk(root_dir):
|
|
7
|
-
for fname in filenames:
|
|
8
|
-
if fname == target_filename:
|
|
9
|
-
file_path = os.path.join(dirpath, fname)
|
|
10
|
-
with open(file_path, "r", encoding="utf-8") as infile:
|
|
11
|
-
outfile.write(infile.read())
|
|
1
|
+
import os
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
def merge_files(output_file: str, root_dir: str = ".", target_filename: str = "maven_dependency_file"):
|
|
5
|
+
with open(output_file, "w", encoding="utf-8") as outfile:
|
|
6
|
+
for dirpath, _, filenames in os.walk(root_dir):
|
|
7
|
+
for fname in filenames:
|
|
8
|
+
if fname == target_filename:
|
|
9
|
+
file_path = os.path.join(dirpath, fname)
|
|
10
|
+
with open(file_path, "r", encoding="utf-8") as infile:
|
|
11
|
+
outfile.write(infile.read())
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
from pathlib import Path
|
|
2
|
+
from jinja2 import BaseLoader, Environment
|
|
3
|
+
from ..TEMPLATE import HTML_TEMPLATE
|
|
4
|
+
|
|
5
|
+
def create_html_diagram(dependency_tree: str, output_filename: str):
|
|
6
|
+
mermaid_diagram = _convert_to_mermaid(dependency_tree)
|
|
7
|
+
template = Environment(loader=BaseLoader).from_string(HTML_TEMPLATE)
|
|
8
|
+
rendered = template.render(diagram_definition=mermaid_diagram)
|
|
9
|
+
parent_dir = Path(output_filename).parent
|
|
10
|
+
if not parent_dir.exists():
|
|
11
|
+
parent_dir.mkdir(parents=True, exist_ok=True)
|
|
12
|
+
with open(output_filename, "w") as f:
|
|
13
|
+
f.write(rendered)
|
|
14
|
+
|
|
15
|
+
def _convert_to_mermaid(dependency_tree: str) -> str:
|
|
16
|
+
# generate a `graph LR` format for Mermaid
|
|
17
|
+
lines = dependency_tree.strip().split("\n")
|
|
18
|
+
mermaid_lines = set()
|
|
19
|
+
previous_dependency = []
|
|
20
|
+
for line in lines:
|
|
21
|
+
if not line:
|
|
22
|
+
continue
|
|
23
|
+
if line.startswith("[INFO] "):
|
|
24
|
+
line = line[7:] # Remove the "[INFO] " prefix
|
|
25
|
+
parts = line.split(":")
|
|
26
|
+
if len(parts) < 3:
|
|
27
|
+
continue
|
|
28
|
+
if len(parts) == 4:
|
|
29
|
+
group_id, artifact_id, app, version = parts
|
|
30
|
+
mermaid_lines.add(f"\t{artifact_id};")
|
|
31
|
+
if previous_dependency: # Re initialize the list if it wasn't empty
|
|
32
|
+
previous_dependency = []
|
|
33
|
+
previous_dependency.append((artifact_id, 0)) # The second element is the depth
|
|
34
|
+
else:
|
|
35
|
+
depth = len(parts[0].split(" ")) - 1
|
|
36
|
+
if len(parts) == 6:
|
|
37
|
+
dirty_group_id, artifact_id, app, ejb_client, version, dependency = parts
|
|
38
|
+
else:
|
|
39
|
+
dirty_group_id, artifact_id, app, version, dependency = parts
|
|
40
|
+
if previous_dependency[-1][1] < depth:
|
|
41
|
+
mermaid_lines.add(f"\t{previous_dependency[-1][0]} --> {artifact_id};")
|
|
42
|
+
previous_dependency.append((artifact_id, depth))
|
|
43
|
+
else:
|
|
44
|
+
# remove all dependencies that are deeper or equal to the current depth
|
|
45
|
+
while previous_dependency and previous_dependency[-1][1] >= depth:
|
|
46
|
+
previous_dependency.pop()
|
|
47
|
+
mermaid_lines.add(f"\t{previous_dependency[-1][0]} --> {artifact_id};")
|
|
48
|
+
previous_dependency.append((artifact_id, depth))
|
|
49
|
+
return "graph LR\n" + "\n".join(mermaid_lines)
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import json
|
|
2
|
+
|
|
3
|
+
def create_json_output(dependency_tree: str, output_filename: str):
|
|
4
|
+
lines = dependency_tree.strip().split("\n")
|
|
5
|
+
tree = {}
|
|
6
|
+
node_stack = [] # Stack to keep track of nodes and their depth
|
|
7
|
+
|
|
8
|
+
for line in lines:
|
|
9
|
+
if not line:
|
|
10
|
+
continue
|
|
11
|
+
if line.startswith("[INFO] "):
|
|
12
|
+
line = line[7:] # Remove the "[INFO] " prefix
|
|
13
|
+
|
|
14
|
+
parts = line.split(":")
|
|
15
|
+
if len(parts) < 3:
|
|
16
|
+
continue
|
|
17
|
+
|
|
18
|
+
# Root node
|
|
19
|
+
if len(parts) == 4:
|
|
20
|
+
group_id, artifact_id, _, version = parts
|
|
21
|
+
node = {"id": f"{group_id}:{artifact_id}:{version}", "children": []}
|
|
22
|
+
tree = node
|
|
23
|
+
node_stack = [(node, 0)] # Reset stack with root node at depth 0
|
|
24
|
+
# Child node
|
|
25
|
+
else:
|
|
26
|
+
# This depth calculation is based on the mermaid logic's whitespace parsing
|
|
27
|
+
depth = len(parts[0].split(" ")) - 1
|
|
28
|
+
|
|
29
|
+
if len(parts) == 6:
|
|
30
|
+
_, artifact_id, _, _, version, _ = parts
|
|
31
|
+
else:
|
|
32
|
+
_, artifact_id, _, version, _ = parts
|
|
33
|
+
|
|
34
|
+
node = {"id": f"{artifact_id}:{version}", "children": []}
|
|
35
|
+
|
|
36
|
+
# Go up the stack to find the correct parent
|
|
37
|
+
while node_stack and node_stack[-1][1] >= depth:
|
|
38
|
+
node_stack.pop()
|
|
39
|
+
|
|
40
|
+
if node_stack:
|
|
41
|
+
parent_node, _ = node_stack[-1]
|
|
42
|
+
parent_node["children"].append(node)
|
|
43
|
+
|
|
44
|
+
node_stack.append((node, depth))
|
|
45
|
+
|
|
46
|
+
with open(output_filename, "w") as f:
|
|
47
|
+
json.dump(tree, f, indent=4)
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: mvn-tree-visualizer
|
|
3
|
+
Version: 1.1.0
|
|
4
|
+
Summary: A simple command line tool to visualize the dependency tree of a Maven project in a graphical format.
|
|
5
|
+
Project-URL: source, https://github.com/dyka3773/mvn-tree-visualizer
|
|
6
|
+
Author-email: Iraklis Konsoulas <dyka3773@gmail.com>
|
|
7
|
+
License-Expression: MIT
|
|
8
|
+
License-File: LICENSE
|
|
9
|
+
Keywords: cli,command-line,dependency,graph,maven,mermaid,tool,tree,visualization
|
|
10
|
+
Classifier: Development Status :: 4 - Beta
|
|
11
|
+
Classifier: Intended Audience :: Developers
|
|
12
|
+
Classifier: Programming Language :: Python :: 3
|
|
13
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
14
|
+
Classifier: Topic :: Software Development :: Build Tools
|
|
15
|
+
Requires-Python: >=3.13
|
|
16
|
+
Requires-Dist: jinja2>=3.1.6
|
|
17
|
+
Description-Content-Type: text/markdown
|
|
18
|
+
|
|
19
|
+
# Maven Dependency Tree Visualizer
|
|
20
|
+
|
|
21
|
+
[](https://badge.fury.io/py/mvn-tree-visualizer)
|
|
22
|
+
|
|
23
|
+
A simple command-line tool to visualize the dependency tree of a Maven project in a graphical and interactive format.
|
|
24
|
+
|
|
25
|
+
This tool was born out of the frustration of not being able to easily visualize the dependency tree of a Maven project. The `mvn dependency:tree` command is great, but the output can be hard to read, especially for large projects. This tool aims to solve that problem by providing a simple way to generate an interactive diagram of the dependency tree.
|
|
26
|
+
|
|
27
|
+
## Features
|
|
28
|
+
|
|
29
|
+
* **Interactive Diagrams:** Generates an interactive HTML diagram of your dependency tree using Mermaid.js.
|
|
30
|
+
* **Easy to Use:** A simple command-line interface that gets the job done with minimal configuration.
|
|
31
|
+
* **File Merging:** Automatically finds and merges multiple `maven_dependency_file` files from different subdirectories.
|
|
32
|
+
* **Customizable Output:** Specify the output file name and location.
|
|
33
|
+
* **SVG Export:** Download the generated diagram as an SVG file directly from the HTML page.
|
|
34
|
+
|
|
35
|
+
## How to Use
|
|
36
|
+
|
|
37
|
+
1. **Generate the dependency file:**
|
|
38
|
+
Run the following command in your terminal at the root of your Maven project. This will generate a file named `maven_dependency_file` in each module's `target` directory.
|
|
39
|
+
|
|
40
|
+
```bash
|
|
41
|
+
mvn dependency:tree -DoutputFile=maven_dependency_file -DappendOutput=true
|
|
42
|
+
```
|
|
43
|
+
> You can add other options like `-Dincludes="org.example"` to filter the dependencies.
|
|
44
|
+
|
|
45
|
+
2. **Visualize the dependency tree:**
|
|
46
|
+
Use the `mvn-tree-visualizer` command to generate the diagram.
|
|
47
|
+
|
|
48
|
+
```bash
|
|
49
|
+
mvn_tree_visualizer --filename "maven_dependency_file" --output "diagram.html"
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
3. **View the diagram:**
|
|
53
|
+
Open the generated `diagram.html` file in your web browser to view the interactive dependency tree.
|
|
54
|
+
|
|
55
|
+
## Options
|
|
56
|
+
|
|
57
|
+
* `--filename`: The name of the file containing the Maven dependency tree. Defaults to `maven_dependency_file`.
|
|
58
|
+
* `--output`: The name of the output HTML file. Defaults to `diagram.html`.
|
|
59
|
+
* `--directory`: The directory to scan for the Maven dependency file(s). Defaults to the current directory.
|
|
60
|
+
* `--keep-tree`: Keep the intermediate `dependency_tree.txt` file after generating the diagram. Defaults to `False`.
|
|
61
|
+
* `--help`: Show the help message and exit.
|
|
62
|
+
|
|
63
|
+
## Contributing
|
|
64
|
+
|
|
65
|
+
Contributions are welcome! If you have any ideas, suggestions, or bug reports, please open an issue or submit a pull request.
|
|
66
|
+
|
|
67
|
+
Please read our [CONTRIBUTING.md](CONTRIBUTING.md) file for more details.
|
|
68
|
+
|
|
69
|
+
## License
|
|
70
|
+
|
|
71
|
+
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
mvn_tree_visualizer/TEMPLATE.py,sha256=WIQfSNBygUZVkBrERq7QzqouGURA0NYVqUUm-11wMvo,2499
|
|
2
|
+
mvn_tree_visualizer/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
3
|
+
mvn_tree_visualizer/__main__.py,sha256=yIQFAdWjthKAFbSzzRuz5_YGlK0c6BnR2ypjNRDq180,82
|
|
4
|
+
mvn_tree_visualizer/cli.py,sha256=P3v27Axod-aYkhtnoAh06RnScUTR2k9QZ3vVGkolHg8,2451
|
|
5
|
+
mvn_tree_visualizer/diagram.py,sha256=elUQHCFu9DPeCpcLkjlRg-xl-fAEn8TvMWpIho1vo0E,312
|
|
6
|
+
mvn_tree_visualizer/get_dependencies_in_one_file.py,sha256=sX669Lo3gsv-dTvaf4PNSQMTp3Gx3CKwqBmJQFiQF04,504
|
|
7
|
+
mvn_tree_visualizer/outputs/html_output.py,sha256=rCD55g8aUdYiPs2Mkd9VB0dBKvMZu0Va3uYGZkJxO20,2295
|
|
8
|
+
mvn_tree_visualizer/outputs/json_output.py,sha256=v9aRPaCDMG-zyVdg82YPhPRyFCNLaWXPcdRmnpzuajg,1554
|
|
9
|
+
mvn_tree_visualizer-1.1.0.dist-info/METADATA,sha256=VmIy1sZ1XHWlqnXJwzFKuG1Z3yxqZ2YV7OlEPaNvIuM,3470
|
|
10
|
+
mvn_tree_visualizer-1.1.0.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
|
11
|
+
mvn_tree_visualizer-1.1.0.dist-info/entry_points.txt,sha256=Mu3QZhrlvbYuCxqmluVGi2efgKjkQY6T8Opf-vdb7hU,68
|
|
12
|
+
mvn_tree_visualizer-1.1.0.dist-info/licenses/LICENSE,sha256=4zi6unpe17RUDMBu7ebh14jdbyvyeT-UA3n8Zl7aW74,1075
|
|
13
|
+
mvn_tree_visualizer-1.1.0.dist-info/RECORD,,
|
{mvn_tree_visualizer-1.0.3b4.dist-info → mvn_tree_visualizer-1.1.0.dist-info}/licenses/LICENSE
RENAMED
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2025 Hercules Konsoulas
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
SOFTWARE.
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Hercules Konsoulas
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
Metadata-Version: 2.4
|
|
2
|
-
Name: mvn-tree-visualizer
|
|
3
|
-
Version: 1.0.3b4
|
|
4
|
-
Summary: A simple command line tool to visualize the dependency tree of a Maven project in a graphical format.
|
|
5
|
-
Project-URL: source, https://github.com/dyka3773/mvn-tree-visualizer
|
|
6
|
-
Author-email: Iraklis Konsoulas <dyka3773@gmail.com>
|
|
7
|
-
License-Expression: MIT
|
|
8
|
-
License-File: LICENSE
|
|
9
|
-
Keywords: cli,command-line,dependency,graph,maven,mermaid,tool,tree,visualization
|
|
10
|
-
Classifier: Development Status :: 4 - Beta
|
|
11
|
-
Classifier: Intended Audience :: Developers
|
|
12
|
-
Classifier: Programming Language :: Python :: 3
|
|
13
|
-
Classifier: Programming Language :: Python :: 3.13
|
|
14
|
-
Classifier: Topic :: Software Development :: Build Tools
|
|
15
|
-
Requires-Python: >=3.13
|
|
16
|
-
Requires-Dist: jinja2>=3.1.6
|
|
17
|
-
Description-Content-Type: text/markdown
|
|
18
|
-
|
|
19
|
-
# mvn-tree-visualizer
|
|
20
|
-
|
|
21
|
-
This project provides a simple command line tool to visualize the dependency tree of a Maven project in a graphical format.
|
|
22
|
-
|
|
23
|
-
## How to Use
|
|
24
|
-
1. Run the following command in your terminal to generate the dependency tree and save it to a file:
|
|
25
|
-
```bash
|
|
26
|
-
mvn dependency:tree -DoutputFile=maven_dependency_file -DappendOutput=true
|
|
27
|
-
```
|
|
28
|
-
> Feel free to add other options to the command as needed. eg `-Dincludes="org.example"`
|
|
29
|
-
2. Use the `mvn-tree-visualizer` command to visualize the dependency tree:
|
|
30
|
-
```bash
|
|
31
|
-
python -m mvn_tree_visualizer --filename "maven_dependency_file" --output "diagram.html"
|
|
32
|
-
```
|
|
33
|
-
3. Open the generated `diagram.html` file in your web browser to view the dependency tree.
|
|
34
|
-
|
|
35
|
-
## Options
|
|
36
|
-
- `--filename`: The name of the file containing the Maven dependency tree. Default is `maven_dependency_file`.
|
|
37
|
-
- `--output`: The name of the output HTML file. Default is `diagram.html`.
|
|
38
|
-
- `--directory`: The directory to scan for the Maven dependency file(s). Default is the current directory.
|
|
39
|
-
- `--keep-tree`: Keep the tree structure file when processing is complete in the same directory as the output file. Default is false.
|
|
40
|
-
- `--help`: Show help message and exit.
|
|
41
|
-
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
mvn_tree_visualizer/TEMPLATE.py,sha256=oQa_84GV-DGvHfPpOor7ALkZwfGvk1wvCrQKCBsuOeg,2560
|
|
2
|
-
mvn_tree_visualizer/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
3
|
-
mvn_tree_visualizer/__main__.py,sha256=1UA2dYHkOCbajDc7rQyKB8N1hP9POnbajya_JpIh28k,86
|
|
4
|
-
mvn_tree_visualizer/cli.py,sha256=sMl1yeCQGwWswiC5xVEOdy1nXhF9Vx5DnoqfHuq02_U,2036
|
|
5
|
-
mvn_tree_visualizer/diagram.py,sha256=PCuR96pBH2JUOZ2RsYKRwMzG7c58CKdNJvk6t0FxuL0,2603
|
|
6
|
-
mvn_tree_visualizer/get_dependencies_in_one_file.py,sha256=d0ldXC0sYvDKLXozD0JgHsMcID_gN4xjeCUdk5TCiV4,515
|
|
7
|
-
mvn_tree_visualizer-1.0.3b4.dist-info/METADATA,sha256=YVQ_d3TKC1vq91ZKxJCZOX5NuUDFO1h9Ri1HaOyVv4E,1972
|
|
8
|
-
mvn_tree_visualizer-1.0.3b4.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
|
9
|
-
mvn_tree_visualizer-1.0.3b4.dist-info/entry_points.txt,sha256=Mu3QZhrlvbYuCxqmluVGi2efgKjkQY6T8Opf-vdb7hU,68
|
|
10
|
-
mvn_tree_visualizer-1.0.3b4.dist-info/licenses/LICENSE,sha256=c_8ezHwcOG8McIzdj7ZPgkqN1RuUMfP0hlmd6gX4gR0,1096
|
|
11
|
-
mvn_tree_visualizer-1.0.3b4.dist-info/RECORD,,
|
|
File without changes
|
{mvn_tree_visualizer-1.0.3b4.dist-info → mvn_tree_visualizer-1.1.0.dist-info}/entry_points.txt
RENAMED
|
File without changes
|