mvn-tree-visualizer 1.1.0__tar.gz → 1.2.0__tar.gz
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-1.1.0 → mvn_tree_visualizer-1.2.0}/.github/workflows/publish.yml +5 -2
- mvn_tree_visualizer-1.2.0/CHANGELOG.md +49 -0
- {mvn_tree_visualizer-1.1.0 → mvn_tree_visualizer-1.2.0}/PKG-INFO +31 -8
- {mvn_tree_visualizer-1.1.0 → mvn_tree_visualizer-1.2.0}/README.md +29 -7
- {mvn_tree_visualizer-1.1.0 → mvn_tree_visualizer-1.2.0}/issues.md +4 -26
- {mvn_tree_visualizer-1.1.0 → mvn_tree_visualizer-1.2.0}/pyproject.toml +2 -1
- {mvn_tree_visualizer-1.1.0 → mvn_tree_visualizer-1.2.0}/src/mvn_tree_visualizer/cli.py +12 -4
- {mvn_tree_visualizer-1.1.0 → mvn_tree_visualizer-1.2.0}/src/mvn_tree_visualizer/diagram.py +6 -5
- {mvn_tree_visualizer-1.1.0 → mvn_tree_visualizer-1.2.0}/src/mvn_tree_visualizer/get_dependencies_in_one_file.py +4 -2
- {mvn_tree_visualizer-1.1.0 → mvn_tree_visualizer-1.2.0}/src/mvn_tree_visualizer/outputs/html_output.py +32 -16
- {mvn_tree_visualizer-1.1.0 → mvn_tree_visualizer-1.2.0}/src/mvn_tree_visualizer/outputs/json_output.py +20 -8
- mvn_tree_visualizer-1.2.0/tests/test_html_output.py +159 -0
- mvn_tree_visualizer-1.2.0/tests/test_json_output.py +192 -0
- mvn_tree_visualizer-1.1.0/tests/test_html_output.py +0 -85
- mvn_tree_visualizer-1.1.0/tests/test_json_output.py +0 -100
- {mvn_tree_visualizer-1.1.0 → mvn_tree_visualizer-1.2.0}/.gitignore +0 -0
- {mvn_tree_visualizer-1.1.0 → mvn_tree_visualizer-1.2.0}/.python-version +0 -0
- {mvn_tree_visualizer-1.1.0 → mvn_tree_visualizer-1.2.0}/CODE_OF_CONDUCT.md +0 -0
- {mvn_tree_visualizer-1.1.0 → mvn_tree_visualizer-1.2.0}/CONTRIBUTING.md +0 -0
- {mvn_tree_visualizer-1.1.0 → mvn_tree_visualizer-1.2.0}/LICENSE +0 -0
- {mvn_tree_visualizer-1.1.0 → mvn_tree_visualizer-1.2.0}/ROADMAP.md +0 -0
- {mvn_tree_visualizer-1.1.0 → mvn_tree_visualizer-1.2.0}/ruff.toml +0 -0
- {mvn_tree_visualizer-1.1.0 → mvn_tree_visualizer-1.2.0}/src/mvn_tree_visualizer/TEMPLATE.py +0 -0
- {mvn_tree_visualizer-1.1.0 → mvn_tree_visualizer-1.2.0}/src/mvn_tree_visualizer/__init__.py +0 -0
- {mvn_tree_visualizer-1.1.0 → mvn_tree_visualizer-1.2.0}/src/mvn_tree_visualizer/__main__.py +0 -0
- {mvn_tree_visualizer-1.1.0 → mvn_tree_visualizer-1.2.0}/uv.lock +0 -0
|
@@ -16,11 +16,14 @@ jobs:
|
|
|
16
16
|
- name: Install dependencies
|
|
17
17
|
run: |
|
|
18
18
|
python -m pip install --upgrade pip
|
|
19
|
-
pip install
|
|
19
|
+
pip install .
|
|
20
|
+
pip install pytest twine build
|
|
21
|
+
- name: Run tests
|
|
22
|
+
run: pytest
|
|
20
23
|
- name: Build package
|
|
21
24
|
run: python -m build
|
|
22
25
|
- name: Publish package
|
|
23
26
|
env:
|
|
24
27
|
TWINE_USERNAME: __token__
|
|
25
28
|
TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }}
|
|
26
|
-
run: twine upload dist/*
|
|
29
|
+
run: twine upload dist/*
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to this project will be documented in this file.
|
|
4
|
+
|
|
5
|
+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
6
|
+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
|
+
|
|
8
|
+
## [Unreleased]
|
|
9
|
+
|
|
10
|
+
## [1.2.0] - 2025-07-09
|
|
11
|
+
|
|
12
|
+
### Added
|
|
13
|
+
- Comprehensive type hints throughout the entire codebase
|
|
14
|
+
- `--show-versions` flag to display dependency versions in both HTML and JSON outputs
|
|
15
|
+
- Support for complex dependency trees with real-world examples
|
|
16
|
+
- "Typing :: Typed" classifier in pyproject.toml to indicate type hint support
|
|
17
|
+
- CHANGELOG.md to track project changes
|
|
18
|
+
|
|
19
|
+
### Changed
|
|
20
|
+
- Enhanced CLI help text to reflect new features
|
|
21
|
+
- Improved code documentation and readability with type hints
|
|
22
|
+
- Updated README.md with new feature documentation and usage examples
|
|
23
|
+
|
|
24
|
+
### Fixed
|
|
25
|
+
- Better static type checking support for development tools
|
|
26
|
+
|
|
27
|
+
## [1.1.0] - 2025-07-08
|
|
28
|
+
|
|
29
|
+
### Added
|
|
30
|
+
- JSON output format support alongside existing HTML format
|
|
31
|
+
- `--format` CLI argument to choose between HTML and JSON outputs
|
|
32
|
+
- Comprehensive test suite for both output formats
|
|
33
|
+
- GitHub Actions workflow for automated PyPI publishing
|
|
34
|
+
|
|
35
|
+
### Changed
|
|
36
|
+
- Decoupled output generation logic from core diagram creation
|
|
37
|
+
- Improved code modularity with separate output modules
|
|
38
|
+
|
|
39
|
+
### Fixed
|
|
40
|
+
- Enhanced project structure and maintainability
|
|
41
|
+
|
|
42
|
+
## [1.0.0] - Initial Release
|
|
43
|
+
|
|
44
|
+
### Added
|
|
45
|
+
- HTML diagram generation using Mermaid.js
|
|
46
|
+
- Interactive SVG export functionality
|
|
47
|
+
- File merging from multiple Maven dependency files
|
|
48
|
+
- Basic CLI interface with essential options
|
|
49
|
+
- Project documentation and contribution guidelines
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: mvn-tree-visualizer
|
|
3
|
-
Version: 1.
|
|
3
|
+
Version: 1.2.0
|
|
4
4
|
Summary: A simple command line tool to visualize the dependency tree of a Maven project in a graphical format.
|
|
5
5
|
Project-URL: source, https://github.com/dyka3773/mvn-tree-visualizer
|
|
6
6
|
Author-email: Iraklis Konsoulas <dyka3773@gmail.com>
|
|
@@ -12,6 +12,7 @@ Classifier: Intended Audience :: Developers
|
|
|
12
12
|
Classifier: Programming Language :: Python :: 3
|
|
13
13
|
Classifier: Programming Language :: Python :: 3.13
|
|
14
14
|
Classifier: Topic :: Software Development :: Build Tools
|
|
15
|
+
Classifier: Typing :: Typed
|
|
15
16
|
Requires-Python: >=3.13
|
|
16
17
|
Requires-Dist: jinja2>=3.1.6
|
|
17
18
|
Description-Content-Type: text/markdown
|
|
@@ -22,11 +23,14 @@ Description-Content-Type: text/markdown
|
|
|
22
23
|
|
|
23
24
|
A simple command-line tool to visualize the dependency tree of a Maven project in a graphical and interactive format.
|
|
24
25
|
|
|
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
|
+
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 or a structured JSON output of the dependency tree.
|
|
26
27
|
|
|
27
28
|
## Features
|
|
28
29
|
|
|
29
|
-
* **
|
|
30
|
+
* **Multiple Output Formats:**
|
|
31
|
+
* **HTML:** Generates an interactive HTML diagram of your dependency tree using Mermaid.js.
|
|
32
|
+
* **JSON:** Creates a structured JSON representation of the dependency tree, perfect for scripting or integration with other tools.
|
|
33
|
+
* **Version Display:** Show or hide dependency versions in both HTML and JSON outputs using the `--show-versions` flag.
|
|
30
34
|
* **Easy to Use:** A simple command-line interface that gets the job done with minimal configuration.
|
|
31
35
|
* **File Merging:** Automatically finds and merges multiple `maven_dependency_file` files from different subdirectories.
|
|
32
36
|
* **Customizable Output:** Specify the output file name and location.
|
|
@@ -45,17 +49,36 @@ This tool was born out of the frustration of not being able to easily visualize
|
|
|
45
49
|
2. **Visualize the dependency tree:**
|
|
46
50
|
Use the `mvn-tree-visualizer` command to generate the diagram.
|
|
47
51
|
|
|
52
|
+
**For an HTML diagram:**
|
|
48
53
|
```bash
|
|
49
|
-
mvn_tree_visualizer --filename "maven_dependency_file" --output "diagram.html"
|
|
54
|
+
mvn_tree_visualizer --filename "maven_dependency_file" --output "diagram.html" --format html
|
|
50
55
|
```
|
|
51
56
|
|
|
52
|
-
|
|
53
|
-
|
|
57
|
+
**For a JSON output:**
|
|
58
|
+
```bash
|
|
59
|
+
mvn_tree_visualizer --filename "maven_dependency_file" --output "dependencies.json" --format json
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
**With version information displayed:**
|
|
63
|
+
```bash
|
|
64
|
+
mvn_tree_visualizer --filename "maven_dependency_file" --output "diagram.html" --show-versions
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
**JSON output with versions:**
|
|
68
|
+
```bash
|
|
69
|
+
mvn_tree_visualizer --filename "maven_dependency_file" --output "dependencies.json" --format json --show-versions
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
3. **View the output:**
|
|
73
|
+
* Open the generated `diagram.html` file in your web browser to view the interactive dependency tree.
|
|
74
|
+
* Use the `dependencies.json` file in your scripts or other tools.
|
|
54
75
|
|
|
55
76
|
## Options
|
|
56
77
|
|
|
57
78
|
* `--filename`: The name of the file containing the Maven dependency tree. Defaults to `maven_dependency_file`.
|
|
58
|
-
* `--output`: The name of the output
|
|
79
|
+
* `--output`: The name of the output file. Defaults to `diagram.html`.
|
|
80
|
+
* `--format`: The output format. Can be `html` or `json`. Defaults to `html`.
|
|
81
|
+
* `--show-versions`: Show dependency versions in the diagram. Applicable to both HTML and JSON output formats.
|
|
59
82
|
* `--directory`: The directory to scan for the Maven dependency file(s). Defaults to the current directory.
|
|
60
83
|
* `--keep-tree`: Keep the intermediate `dependency_tree.txt` file after generating the diagram. Defaults to `False`.
|
|
61
84
|
* `--help`: Show the help message and exit.
|
|
@@ -68,4 +91,4 @@ Please read our [CONTRIBUTING.md](CONTRIBUTING.md) file for more details.
|
|
|
68
91
|
|
|
69
92
|
## License
|
|
70
93
|
|
|
71
|
-
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
|
|
94
|
+
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
|
|
@@ -4,11 +4,14 @@
|
|
|
4
4
|
|
|
5
5
|
A simple command-line tool to visualize the dependency tree of a Maven project in a graphical and interactive format.
|
|
6
6
|
|
|
7
|
-
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.
|
|
7
|
+
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 or a structured JSON output of the dependency tree.
|
|
8
8
|
|
|
9
9
|
## Features
|
|
10
10
|
|
|
11
|
-
* **
|
|
11
|
+
* **Multiple Output Formats:**
|
|
12
|
+
* **HTML:** Generates an interactive HTML diagram of your dependency tree using Mermaid.js.
|
|
13
|
+
* **JSON:** Creates a structured JSON representation of the dependency tree, perfect for scripting or integration with other tools.
|
|
14
|
+
* **Version Display:** Show or hide dependency versions in both HTML and JSON outputs using the `--show-versions` flag.
|
|
12
15
|
* **Easy to Use:** A simple command-line interface that gets the job done with minimal configuration.
|
|
13
16
|
* **File Merging:** Automatically finds and merges multiple `maven_dependency_file` files from different subdirectories.
|
|
14
17
|
* **Customizable Output:** Specify the output file name and location.
|
|
@@ -27,17 +30,36 @@ This tool was born out of the frustration of not being able to easily visualize
|
|
|
27
30
|
2. **Visualize the dependency tree:**
|
|
28
31
|
Use the `mvn-tree-visualizer` command to generate the diagram.
|
|
29
32
|
|
|
33
|
+
**For an HTML diagram:**
|
|
30
34
|
```bash
|
|
31
|
-
mvn_tree_visualizer --filename "maven_dependency_file" --output "diagram.html"
|
|
35
|
+
mvn_tree_visualizer --filename "maven_dependency_file" --output "diagram.html" --format html
|
|
32
36
|
```
|
|
33
37
|
|
|
34
|
-
|
|
35
|
-
|
|
38
|
+
**For a JSON output:**
|
|
39
|
+
```bash
|
|
40
|
+
mvn_tree_visualizer --filename "maven_dependency_file" --output "dependencies.json" --format json
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
**With version information displayed:**
|
|
44
|
+
```bash
|
|
45
|
+
mvn_tree_visualizer --filename "maven_dependency_file" --output "diagram.html" --show-versions
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
**JSON output with versions:**
|
|
49
|
+
```bash
|
|
50
|
+
mvn_tree_visualizer --filename "maven_dependency_file" --output "dependencies.json" --format json --show-versions
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
3. **View the output:**
|
|
54
|
+
* Open the generated `diagram.html` file in your web browser to view the interactive dependency tree.
|
|
55
|
+
* Use the `dependencies.json` file in your scripts or other tools.
|
|
36
56
|
|
|
37
57
|
## Options
|
|
38
58
|
|
|
39
59
|
* `--filename`: The name of the file containing the Maven dependency tree. Defaults to `maven_dependency_file`.
|
|
40
|
-
* `--output`: The name of the output
|
|
60
|
+
* `--output`: The name of the output file. Defaults to `diagram.html`.
|
|
61
|
+
* `--format`: The output format. Can be `html` or `json`. Defaults to `html`.
|
|
62
|
+
* `--show-versions`: Show dependency versions in the diagram. Applicable to both HTML and JSON output formats.
|
|
41
63
|
* `--directory`: The directory to scan for the Maven dependency file(s). Defaults to the current directory.
|
|
42
64
|
* `--keep-tree`: Keep the intermediate `dependency_tree.txt` file after generating the diagram. Defaults to `False`.
|
|
43
65
|
* `--help`: Show the help message and exit.
|
|
@@ -50,4 +72,4 @@ Please read our [CONTRIBUTING.md](CONTRIBUTING.md) file for more details.
|
|
|
50
72
|
|
|
51
73
|
## License
|
|
52
74
|
|
|
53
|
-
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
|
|
75
|
+
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
|
|
@@ -9,14 +9,6 @@ This document outlines potential improvements and new features for the `mvn-tree
|
|
|
9
9
|
|
|
10
10
|
**Status:** ✅ Done
|
|
11
11
|
|
|
12
|
-
* **Description:** Currently, the tool only outputs an HTML file with a Mermaid diagram. Adding support for other formats would greatly increase its versatility and appeal to a wider audience.
|
|
13
|
-
* **Suggestions:**
|
|
14
|
-
* **JSON:** A structured JSON output of the dependency tree would allow for easy integration with other tools and scripts.
|
|
15
|
-
* **GraphML/GEXF/Graphviz (DOT):** These are standard graph formats that can be used with various graph visualization and analysis tools like Gephi, Cytoscape, or Graphviz. This would allow for more advanced analysis and visualization of the dependency graph.
|
|
16
|
-
* **Plain Text:** A simple, indented text representation of the dependency tree.
|
|
17
|
-
* **Implementation:**
|
|
18
|
-
* Add a `--format` option to the CLI to specify the output format.
|
|
19
|
-
* Create separate functions for generating each output format.
|
|
20
12
|
|
|
21
13
|
### 2. Dependency Highlighting and Filtering
|
|
22
14
|
|
|
@@ -31,11 +23,8 @@ This document outlines potential improvements and new features for the `mvn-tree
|
|
|
31
23
|
|
|
32
24
|
### 3. Display Dependency Versions
|
|
33
25
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
* Add an option `--show-versions` to display the version of each dependency in the diagram.
|
|
37
|
-
* **Implementation:**
|
|
38
|
-
* Modify the `_convert_to_mermaid` function to include the version number in the node labels.
|
|
26
|
+
**Status:** ✅ Done
|
|
27
|
+
|
|
39
28
|
|
|
40
29
|
### 4. "Watch" Mode
|
|
41
30
|
|
|
@@ -74,13 +63,6 @@ This document outlines potential improvements and new features for the `mvn-tree
|
|
|
74
63
|
|
|
75
64
|
**Status:** ✅ Done
|
|
76
65
|
|
|
77
|
-
* **Description:** The project currently lacks unit tests. Adding tests would improve the code's reliability and make it easier to refactor and add new features in the future.
|
|
78
|
-
* **Suggestions:**
|
|
79
|
-
* Use the `unittest` or `pytest` framework to write tests for the core logic of the application, especially the `_convert_to_mermaid` function.
|
|
80
|
-
* Create a `tests` directory to store the test files.
|
|
81
|
-
* **Implementation:**
|
|
82
|
-
* Create a `tests/test_diagram.py` file with tests for the `_convert_to_mermaid` function.
|
|
83
|
-
* Use mock objects to simulate file I/O and other external dependencies.
|
|
84
66
|
|
|
85
67
|
### 2. Code Modularity
|
|
86
68
|
|
|
@@ -93,14 +75,10 @@ This document outlines potential improvements and new features for the `mvn-tree
|
|
|
93
75
|
|
|
94
76
|
### 3. Type Hinting
|
|
95
77
|
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
* Add type hints to all function signatures and variable declarations.
|
|
99
|
-
* **Implementation:**
|
|
100
|
-
* Use the `typing` module to add type hints to the code.
|
|
78
|
+
**Status:** ✅ Done
|
|
79
|
+
|
|
101
80
|
|
|
102
81
|
## 📚 Documentation & Community
|
|
103
82
|
|
|
104
83
|
**Status:** ✅ Done
|
|
105
84
|
|
|
106
|
-
We have enhanced the `README.md`, and created the `CONTRIBUTING.md`, `CODE_OF_CONDUCT.md`, and `ROADMAP.md` files.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[project]
|
|
2
2
|
name = "mvn-tree-visualizer"
|
|
3
|
-
version = "1.
|
|
3
|
+
version = "1.2.0"
|
|
4
4
|
authors = [
|
|
5
5
|
{ name = "Iraklis Konsoulas", email = "dyka3773@gmail.com" },
|
|
6
6
|
]
|
|
@@ -25,6 +25,7 @@ classifiers = [
|
|
|
25
25
|
"Programming Language :: Python :: 3",
|
|
26
26
|
"Programming Language :: Python :: 3.13",
|
|
27
27
|
"Topic :: Software Development :: Build Tools",
|
|
28
|
+
"Typing :: Typed",
|
|
28
29
|
]
|
|
29
30
|
dependencies = [
|
|
30
31
|
"jinja2>=3.1.6",
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import argparse
|
|
2
2
|
from pathlib import Path
|
|
3
|
+
from typing import NoReturn
|
|
3
4
|
|
|
4
5
|
from .diagram import create_diagram
|
|
5
6
|
from .get_dependencies_in_one_file import merge_files
|
|
@@ -7,7 +8,7 @@ from .outputs.html_output import create_html_diagram
|
|
|
7
8
|
from .outputs.json_output import create_json_output
|
|
8
9
|
|
|
9
10
|
|
|
10
|
-
def cli():
|
|
11
|
+
def cli() -> NoReturn:
|
|
11
12
|
parser = argparse.ArgumentParser(
|
|
12
13
|
prog="mvn-tree-visualizer",
|
|
13
14
|
description="Generate a dependency diagram from a file.",
|
|
@@ -50,12 +51,19 @@ def cli():
|
|
|
50
51
|
help="Keep the dependency tree file after generating the diagram. Default is False.",
|
|
51
52
|
)
|
|
52
53
|
|
|
54
|
+
parser.add_argument(
|
|
55
|
+
"--show-versions",
|
|
56
|
+
action="store_true",
|
|
57
|
+
help="Show dependency versions in the diagram. Applicable to both HTML and JSON output formats.",
|
|
58
|
+
)
|
|
59
|
+
|
|
53
60
|
args = parser.parse_args()
|
|
54
61
|
directory: str = args.directory
|
|
55
62
|
output_file: str = args.output
|
|
56
63
|
filename: str = args.filename
|
|
57
64
|
keep_tree: bool = args.keep_tree
|
|
58
65
|
output_format: str = args.format
|
|
66
|
+
show_versions: bool = args.show_versions
|
|
59
67
|
|
|
60
68
|
dir_to_create_files = Path(output_file).parent
|
|
61
69
|
|
|
@@ -73,9 +81,9 @@ def cli():
|
|
|
73
81
|
)
|
|
74
82
|
|
|
75
83
|
if output_format == "html":
|
|
76
|
-
create_html_diagram(dependency_tree, output_file)
|
|
84
|
+
create_html_diagram(dependency_tree, output_file, show_versions)
|
|
77
85
|
elif output_format == "json":
|
|
78
|
-
create_json_output(dependency_tree, output_file)
|
|
86
|
+
create_json_output(dependency_tree, output_file, show_versions)
|
|
79
87
|
|
|
80
88
|
print(f"Diagram generated and saved to {output_file}")
|
|
81
89
|
print("You can open it in your browser to view the dependency tree.")
|
|
@@ -83,4 +91,4 @@ def cli():
|
|
|
83
91
|
|
|
84
92
|
|
|
85
93
|
if __name__ == "__main__":
|
|
86
|
-
cli()
|
|
94
|
+
cli()
|
|
@@ -1,13 +1,14 @@
|
|
|
1
|
+
import os
|
|
2
|
+
|
|
3
|
+
|
|
1
4
|
def create_diagram(
|
|
2
5
|
keep_tree: bool = False,
|
|
3
6
|
intermediate_filename: str = "dependency_tree.txt",
|
|
4
|
-
):
|
|
7
|
+
) -> str:
|
|
5
8
|
with open(intermediate_filename, "r") as file:
|
|
6
|
-
dependency_tree = file.read()
|
|
9
|
+
dependency_tree: str = file.read()
|
|
7
10
|
|
|
8
11
|
if not keep_tree:
|
|
9
|
-
import os
|
|
10
|
-
|
|
11
12
|
os.remove(intermediate_filename)
|
|
12
|
-
|
|
13
|
+
|
|
13
14
|
return dependency_tree
|
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import os
|
|
2
|
+
from pathlib import Path
|
|
3
|
+
from typing import Union
|
|
2
4
|
|
|
3
5
|
|
|
4
|
-
def merge_files(output_file: str, root_dir: str = ".", target_filename: str = "maven_dependency_file"):
|
|
6
|
+
def merge_files(output_file: Union[str, Path], root_dir: str = ".", target_filename: str = "maven_dependency_file") -> None:
|
|
5
7
|
with open(output_file, "w", encoding="utf-8") as outfile:
|
|
6
8
|
for dirpath, _, filenames in os.walk(root_dir):
|
|
7
9
|
for fname in filenames:
|
|
8
10
|
if fname == target_filename:
|
|
9
|
-
file_path = os.path.join(dirpath, fname)
|
|
11
|
+
file_path: str = os.path.join(dirpath, fname)
|
|
10
12
|
with open(file_path, "r", encoding="utf-8") as infile:
|
|
11
13
|
outfile.write(infile.read())
|
|
@@ -1,49 +1,65 @@
|
|
|
1
1
|
from pathlib import Path
|
|
2
|
+
from typing import List, Set, Tuple
|
|
3
|
+
|
|
2
4
|
from jinja2 import BaseLoader, Environment
|
|
5
|
+
|
|
3
6
|
from ..TEMPLATE import HTML_TEMPLATE
|
|
4
7
|
|
|
5
|
-
|
|
6
|
-
|
|
8
|
+
|
|
9
|
+
def create_html_diagram(dependency_tree: str, output_filename: str, show_versions: bool = False) -> None:
|
|
10
|
+
mermaid_diagram: str = _convert_to_mermaid(dependency_tree, show_versions)
|
|
7
11
|
template = Environment(loader=BaseLoader).from_string(HTML_TEMPLATE)
|
|
8
|
-
rendered = template.render(diagram_definition=mermaid_diagram)
|
|
9
|
-
parent_dir = Path(output_filename).parent
|
|
12
|
+
rendered: str = template.render(diagram_definition=mermaid_diagram)
|
|
13
|
+
parent_dir: Path = Path(output_filename).parent
|
|
10
14
|
if not parent_dir.exists():
|
|
11
15
|
parent_dir.mkdir(parents=True, exist_ok=True)
|
|
12
16
|
with open(output_filename, "w") as f:
|
|
13
17
|
f.write(rendered)
|
|
14
18
|
|
|
15
|
-
|
|
19
|
+
|
|
20
|
+
def _convert_to_mermaid(dependency_tree: str, show_versions: bool = False) -> str:
|
|
16
21
|
# generate a `graph LR` format for Mermaid
|
|
17
|
-
lines = dependency_tree.strip().split("\n")
|
|
18
|
-
mermaid_lines = set()
|
|
19
|
-
previous_dependency = []
|
|
22
|
+
lines: List[str] = dependency_tree.strip().split("\n")
|
|
23
|
+
mermaid_lines: Set[str] = set()
|
|
24
|
+
previous_dependency: List[Tuple[str, int]] = []
|
|
20
25
|
for line in lines:
|
|
21
26
|
if not line:
|
|
22
27
|
continue
|
|
23
28
|
if line.startswith("[INFO] "):
|
|
24
29
|
line = line[7:] # Remove the "[INFO] " prefix
|
|
25
|
-
parts = line.split(":")
|
|
30
|
+
parts: List[str] = line.split(":")
|
|
26
31
|
if len(parts) < 3:
|
|
27
32
|
continue
|
|
28
33
|
if len(parts) == 4:
|
|
29
34
|
group_id, artifact_id, app, version = parts
|
|
30
|
-
|
|
35
|
+
if show_versions:
|
|
36
|
+
node_label: str = f"{artifact_id}:{version}"
|
|
37
|
+
mermaid_lines.add(f"\t{node_label};")
|
|
38
|
+
else:
|
|
39
|
+
node_label: str = artifact_id
|
|
40
|
+
mermaid_lines.add(f"\t{artifact_id};")
|
|
31
41
|
if previous_dependency: # Re initialize the list if it wasn't empty
|
|
32
42
|
previous_dependency = []
|
|
33
|
-
previous_dependency.append((
|
|
43
|
+
previous_dependency.append((node_label, 0)) # The second element is the depth
|
|
34
44
|
else:
|
|
35
|
-
depth = len(parts[0].split(" ")) - 1
|
|
45
|
+
depth: int = len(parts[0].split(" ")) - 1
|
|
36
46
|
if len(parts) == 6:
|
|
37
47
|
dirty_group_id, artifact_id, app, ejb_client, version, dependency = parts
|
|
38
48
|
else:
|
|
39
49
|
dirty_group_id, artifact_id, app, version, dependency = parts
|
|
50
|
+
|
|
51
|
+
if show_versions:
|
|
52
|
+
node_label: str = f"{artifact_id}:{version}"
|
|
53
|
+
else:
|
|
54
|
+
node_label: str = artifact_id
|
|
55
|
+
|
|
40
56
|
if previous_dependency[-1][1] < depth:
|
|
41
|
-
mermaid_lines.add(f"\t{previous_dependency[-1][0]} --> {
|
|
42
|
-
previous_dependency.append((
|
|
57
|
+
mermaid_lines.add(f"\t{previous_dependency[-1][0]} --> {node_label};")
|
|
58
|
+
previous_dependency.append((node_label, depth))
|
|
43
59
|
else:
|
|
44
60
|
# remove all dependencies that are deeper or equal to the current depth
|
|
45
61
|
while previous_dependency and previous_dependency[-1][1] >= depth:
|
|
46
62
|
previous_dependency.pop()
|
|
47
|
-
mermaid_lines.add(f"\t{previous_dependency[-1][0]} --> {
|
|
48
|
-
previous_dependency.append((
|
|
63
|
+
mermaid_lines.add(f"\t{previous_dependency[-1][0]} --> {node_label};")
|
|
64
|
+
previous_dependency.append((node_label, depth))
|
|
49
65
|
return "graph LR\n" + "\n".join(mermaid_lines)
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import json
|
|
2
|
+
from typing import Any, Dict, List, Tuple
|
|
2
3
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
4
|
+
|
|
5
|
+
def create_json_output(dependency_tree: str, output_filename: str, show_versions: bool = False) -> None:
|
|
6
|
+
lines: List[str] = dependency_tree.strip().split("\n")
|
|
7
|
+
tree: Dict[str, Any] = {}
|
|
8
|
+
node_stack: List[Tuple[Dict[str, Any], int]] = [] # Stack to keep track of nodes and their depth
|
|
7
9
|
|
|
8
10
|
for line in lines:
|
|
9
11
|
if not line:
|
|
@@ -11,33 +13,43 @@ def create_json_output(dependency_tree: str, output_filename: str):
|
|
|
11
13
|
if line.startswith("[INFO] "):
|
|
12
14
|
line = line[7:] # Remove the "[INFO] " prefix
|
|
13
15
|
|
|
14
|
-
parts = line.split(":")
|
|
16
|
+
parts: List[str] = line.split(":")
|
|
15
17
|
if len(parts) < 3:
|
|
16
18
|
continue
|
|
17
19
|
|
|
18
20
|
# Root node
|
|
19
21
|
if len(parts) == 4:
|
|
20
22
|
group_id, artifact_id, _, version = parts
|
|
21
|
-
|
|
23
|
+
if show_versions:
|
|
24
|
+
node_id: str = f"{group_id}:{artifact_id}:{version}"
|
|
25
|
+
else:
|
|
26
|
+
node_id: str = f"{group_id}:{artifact_id}"
|
|
27
|
+
node: Dict[str, Any] = {"id": node_id, "children": []}
|
|
22
28
|
tree = node
|
|
23
29
|
node_stack = [(node, 0)] # Reset stack with root node at depth 0
|
|
24
30
|
# Child node
|
|
25
31
|
else:
|
|
26
32
|
# This depth calculation is based on the mermaid logic's whitespace parsing
|
|
27
|
-
depth = len(parts[0].split(" ")) - 1
|
|
33
|
+
depth: int = len(parts[0].split(" ")) - 1
|
|
28
34
|
|
|
29
35
|
if len(parts) == 6:
|
|
30
36
|
_, artifact_id, _, _, version, _ = parts
|
|
31
37
|
else:
|
|
32
38
|
_, artifact_id, _, version, _ = parts
|
|
33
39
|
|
|
34
|
-
|
|
40
|
+
if show_versions:
|
|
41
|
+
node_id: str = f"{artifact_id}:{version}"
|
|
42
|
+
else:
|
|
43
|
+
node_id: str = artifact_id
|
|
44
|
+
|
|
45
|
+
node: Dict[str, Any] = {"id": node_id, "children": []}
|
|
35
46
|
|
|
36
47
|
# Go up the stack to find the correct parent
|
|
37
48
|
while node_stack and node_stack[-1][1] >= depth:
|
|
38
49
|
node_stack.pop()
|
|
39
50
|
|
|
40
51
|
if node_stack:
|
|
52
|
+
parent_node: Dict[str, Any]
|
|
41
53
|
parent_node, _ = node_stack[-1]
|
|
42
54
|
parent_node["children"].append(node)
|
|
43
55
|
|
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
from mvn_tree_visualizer.outputs.html_output import _convert_to_mermaid
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
def test_convert_to_mermaid_simple():
|
|
5
|
+
dependency_tree = r"""[INFO] com.example:my-app:jar:1.0.0
|
|
6
|
+
[INFO] +- org.springframework.boot:spring-boot-starter-web:jar:2.5.4:compile
|
|
7
|
+
[INFO] | +- org.springframework.boot:spring-boot-starter:jar:2.5.4:compile
|
|
8
|
+
[INFO] | | \- org.yaml:snakeyaml:jar:1.28:compile
|
|
9
|
+
[INFO] | \- org.springframework:spring-webmvc:jar:5.3.9:compile
|
|
10
|
+
[INFO] \- org.apache.commons:commons-lang3:jar:3.12.0:compile
|
|
11
|
+
"""
|
|
12
|
+
expected_mermaid_diagram_lines = {
|
|
13
|
+
"graph LR",
|
|
14
|
+
"\tmy-app --> commons-lang3;",
|
|
15
|
+
"\tmy-app --> spring-boot-starter-web;",
|
|
16
|
+
"\tmy-app;",
|
|
17
|
+
"\tspring-boot-starter --> snakeyaml;",
|
|
18
|
+
"\tspring-boot-starter-web --> spring-boot-starter;",
|
|
19
|
+
"\tspring-boot-starter-web --> spring-webmvc;",
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
actual_lines = set(_convert_to_mermaid(dependency_tree).strip().split("\n"))
|
|
23
|
+
assert actual_lines == expected_mermaid_diagram_lines
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
def test_convert_to_mermaid_deeper_tree():
|
|
27
|
+
dependency_tree = r"""[INFO] com.example:my-app:jar:1.0.0
|
|
28
|
+
[INFO] +- a:b:jar:1.0.0:compile
|
|
29
|
+
[INFO] | +- c:d:jar:1.0.0:compile
|
|
30
|
+
[INFO] | | +- e:f:jar:1.0.0:compile
|
|
31
|
+
[INFO] | | | \- g:h:jar:1.0.0:compile
|
|
32
|
+
[INFO] | | \- i:j:jar:1.0.0:compile
|
|
33
|
+
[INFO] | \- k:l:jar:1.0.0:compile
|
|
34
|
+
[INFO] \- m:n:jar:1.0.0:compile
|
|
35
|
+
"""
|
|
36
|
+
expected_mermaid_diagram_lines = {
|
|
37
|
+
"graph LR",
|
|
38
|
+
"\tb --> d;",
|
|
39
|
+
"\tb --> l;",
|
|
40
|
+
"\td --> f;",
|
|
41
|
+
"\td --> j;",
|
|
42
|
+
"\tf --> h;",
|
|
43
|
+
"\tmy-app --> b;",
|
|
44
|
+
"\tmy-app --> n;",
|
|
45
|
+
"\tmy-app;",
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
actual_lines = set(_convert_to_mermaid(dependency_tree).strip().split("\n"))
|
|
49
|
+
assert actual_lines == expected_mermaid_diagram_lines
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
def test_convert_to_mermaid_multiple_top_level():
|
|
53
|
+
dependency_tree = r"""[INFO] com.example:my-app:jar:1.0.0
|
|
54
|
+
[INFO] +- a:b:jar:1.0.0:compile
|
|
55
|
+
[INFO] \- c:d:jar:1.0.0:compile
|
|
56
|
+
"""
|
|
57
|
+
expected_mermaid_diagram_lines = {
|
|
58
|
+
"graph LR",
|
|
59
|
+
"\tmy-app --> b;",
|
|
60
|
+
"\tmy-app --> d;",
|
|
61
|
+
"\tmy-app;",
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
actual_lines = set(_convert_to_mermaid(dependency_tree).strip().split("\n"))
|
|
65
|
+
assert actual_lines == expected_mermaid_diagram_lines
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
def test_convert_to_mermaid_duplicate_dependencies():
|
|
69
|
+
dependency_tree = r"""[INFO] com.example:my-app:jar:1.0.0
|
|
70
|
+
[INFO] +- a:b:jar:1.0.0:compile
|
|
71
|
+
[INFO] | \- c:d:jar:1.0.0:compile
|
|
72
|
+
[INFO] \- e:f:jar:1.0.0:compile
|
|
73
|
+
[INFO] \- c:d:jar:1.0.0:compile
|
|
74
|
+
"""
|
|
75
|
+
expected_mermaid_diagram_lines = {
|
|
76
|
+
"graph LR",
|
|
77
|
+
"\tb --> d;",
|
|
78
|
+
"\tf --> d;",
|
|
79
|
+
"\tmy-app --> b;",
|
|
80
|
+
"\tmy-app --> f;",
|
|
81
|
+
"\tmy-app;",
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
actual_lines = set(_convert_to_mermaid(dependency_tree).strip().split("\n"))
|
|
85
|
+
assert actual_lines == expected_mermaid_diagram_lines
|
|
86
|
+
|
|
87
|
+
|
|
88
|
+
def test_convert_to_mermaid_with_show_versions():
|
|
89
|
+
dependency_tree = r"""[INFO] com.example:my-app:jar:1.0.0
|
|
90
|
+
[INFO] +- org.springframework.boot:spring-boot-starter-web:jar:2.5.4:compile
|
|
91
|
+
[INFO] | \- org.springframework.boot:spring-boot-starter:jar:2.5.4:compile
|
|
92
|
+
[INFO] \- org.apache.commons:commons-lang3:jar:3.12.0:compile
|
|
93
|
+
"""
|
|
94
|
+
expected_mermaid_diagram_lines = {
|
|
95
|
+
"graph LR",
|
|
96
|
+
"\tmy-app:1.0.0 --> commons-lang3:3.12.0;",
|
|
97
|
+
"\tmy-app:1.0.0 --> spring-boot-starter-web:2.5.4;",
|
|
98
|
+
"\tmy-app:1.0.0;",
|
|
99
|
+
"\tspring-boot-starter-web:2.5.4 --> spring-boot-starter:2.5.4;",
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
actual_lines = set(_convert_to_mermaid(dependency_tree, show_versions=True).strip().split("\n"))
|
|
103
|
+
assert actual_lines == expected_mermaid_diagram_lines
|
|
104
|
+
|
|
105
|
+
|
|
106
|
+
def test_convert_to_mermaid_with_show_versions_false():
|
|
107
|
+
dependency_tree = r"""[INFO] com.example:my-app:jar:1.0.0
|
|
108
|
+
[INFO] +- org.springframework.boot:spring-boot-starter-web:jar:2.5.4:compile
|
|
109
|
+
[INFO] | \- org.springframework.boot:spring-boot-starter:jar:2.5.4:compile
|
|
110
|
+
[INFO] \- org.apache.commons:commons-lang3:jar:3.12.0:compile
|
|
111
|
+
"""
|
|
112
|
+
expected_mermaid_diagram_lines = {
|
|
113
|
+
"graph LR",
|
|
114
|
+
"\tmy-app --> commons-lang3;",
|
|
115
|
+
"\tmy-app --> spring-boot-starter-web;",
|
|
116
|
+
"\tmy-app;",
|
|
117
|
+
"\tspring-boot-starter-web --> spring-boot-starter;",
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
actual_lines = set(_convert_to_mermaid(dependency_tree, show_versions=False).strip().split("\n"))
|
|
121
|
+
assert actual_lines == expected_mermaid_diagram_lines
|
|
122
|
+
|
|
123
|
+
|
|
124
|
+
def test_convert_to_mermaid_real_life_example():
|
|
125
|
+
dependency_tree = r"""[INFO] [dependency:tree]
|
|
126
|
+
[INFO] org.apache.maven.plugins:maven-dependency-plugin:maven-plugin:2.0-alpha-5-SNAPSHOT
|
|
127
|
+
[INFO] \- org.apache.maven.doxia:doxia-site-renderer:jar:1.0-alpha-8:compile
|
|
128
|
+
[INFO] \- org.codehaus.plexus:plexus-velocity:jar:1.1.3:compile
|
|
129
|
+
[INFO] \- velocity:velocity:jar:1.4:compile
|
|
130
|
+
"""
|
|
131
|
+
expected_mermaid_diagram_lines = {
|
|
132
|
+
"graph LR",
|
|
133
|
+
"\tmaven-dependency-plugin --> doxia-site-renderer;",
|
|
134
|
+
"\tmaven-dependency-plugin;",
|
|
135
|
+
"\tdoxia-site-renderer --> plexus-velocity;",
|
|
136
|
+
"\tplexus-velocity --> velocity;",
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
actual_lines = set(_convert_to_mermaid(dependency_tree).strip().split("\n"))
|
|
140
|
+
assert actual_lines == expected_mermaid_diagram_lines
|
|
141
|
+
|
|
142
|
+
|
|
143
|
+
def test_convert_to_mermaid_real_life_example_show_versions():
|
|
144
|
+
dependency_tree = r"""[INFO] [dependency:tree]
|
|
145
|
+
[INFO] org.apache.maven.plugins:maven-dependency-plugin:maven-plugin:2.0-alpha-5-SNAPSHOT
|
|
146
|
+
[INFO] \- org.apache.maven.doxia:doxia-site-renderer:jar:1.0-alpha-8:compile
|
|
147
|
+
[INFO] \- org.codehaus.plexus:plexus-velocity:jar:1.1.3:compile
|
|
148
|
+
[INFO] \- velocity:velocity:jar:1.4:compile
|
|
149
|
+
"""
|
|
150
|
+
expected_mermaid_diagram_lines = {
|
|
151
|
+
"graph LR",
|
|
152
|
+
"\tmaven-dependency-plugin:2.0-alpha-5-SNAPSHOT --> doxia-site-renderer:1.0-alpha-8;",
|
|
153
|
+
"\tmaven-dependency-plugin:2.0-alpha-5-SNAPSHOT;",
|
|
154
|
+
"\tdoxia-site-renderer:1.0-alpha-8 --> plexus-velocity:1.1.3;",
|
|
155
|
+
"\tplexus-velocity:1.1.3 --> velocity:1.4;",
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
actual_lines = set(_convert_to_mermaid(dependency_tree, show_versions=True).strip().split("\n"))
|
|
159
|
+
assert actual_lines == expected_mermaid_diagram_lines
|
|
@@ -0,0 +1,192 @@
|
|
|
1
|
+
import json
|
|
2
|
+
import os
|
|
3
|
+
|
|
4
|
+
from mvn_tree_visualizer.outputs.json_output import create_json_output
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
def test_create_json_output_simple():
|
|
8
|
+
dependency_tree = r"""[INFO] com.example:my-app:jar:1.0.0
|
|
9
|
+
[INFO] +- org.springframework.boot:spring-boot-starter-web:jar:2.5.4:compile
|
|
10
|
+
[INFO] | \- org.springframework.boot:spring-boot-starter:jar:2.5.4:compile
|
|
11
|
+
[INFO] \- org.apache.commons:commons-lang3:jar:3.12.0:compile
|
|
12
|
+
"""
|
|
13
|
+
expected_json = {
|
|
14
|
+
"id": "com.example:my-app",
|
|
15
|
+
"children": [
|
|
16
|
+
{"id": "spring-boot-starter-web", "children": [{"id": "spring-boot-starter", "children": []}]},
|
|
17
|
+
{"id": "commons-lang3", "children": []},
|
|
18
|
+
],
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
output_filename = "test_output.json"
|
|
22
|
+
create_json_output(dependency_tree, output_filename)
|
|
23
|
+
|
|
24
|
+
with open(output_filename, "r") as f:
|
|
25
|
+
actual_json = json.load(f)
|
|
26
|
+
|
|
27
|
+
os.remove(output_filename)
|
|
28
|
+
assert actual_json == expected_json
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
def test_create_json_output_deeper_tree():
|
|
32
|
+
dependency_tree = r"""[INFO] com.example:my-app:jar:1.0.0
|
|
33
|
+
[INFO] +- a:b:jar:1.0.0:compile
|
|
34
|
+
[INFO] | +- c:d:jar:1.0.0:compile
|
|
35
|
+
[INFO] | | +- e:f:jar:1.0.0:compile
|
|
36
|
+
[INFO] | | | \- g:h:jar:1.0.0:compile
|
|
37
|
+
[INFO] | | \- i:j:jar:1.0.0:compile
|
|
38
|
+
[INFO] | \- k:l:jar:1.0.0:compile
|
|
39
|
+
[INFO] \- m:n:jar:1.0.0:compile
|
|
40
|
+
"""
|
|
41
|
+
expected_json = {
|
|
42
|
+
"id": "com.example:my-app",
|
|
43
|
+
"children": [
|
|
44
|
+
{
|
|
45
|
+
"id": "b",
|
|
46
|
+
"children": [
|
|
47
|
+
{
|
|
48
|
+
"id": "d",
|
|
49
|
+
"children": [{"id": "f", "children": [{"id": "h", "children": []}]}, {"id": "j", "children": []}],
|
|
50
|
+
},
|
|
51
|
+
{"id": "l", "children": []},
|
|
52
|
+
],
|
|
53
|
+
},
|
|
54
|
+
{"id": "n", "children": []},
|
|
55
|
+
],
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
output_filename = "test_output_deep.json"
|
|
59
|
+
create_json_output(dependency_tree, output_filename)
|
|
60
|
+
|
|
61
|
+
with open(output_filename, "r") as f:
|
|
62
|
+
actual_json = json.load(f)
|
|
63
|
+
|
|
64
|
+
os.remove(output_filename)
|
|
65
|
+
assert actual_json == expected_json
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
def test_create_json_output_duplicate_dependencies():
|
|
69
|
+
dependency_tree = r"""[INFO] com.example:my-app:jar:1.0.0
|
|
70
|
+
[INFO] +- a:b:jar:1.0.0:compile
|
|
71
|
+
[INFO] | \- c:d:jar:1.0.0:compile
|
|
72
|
+
[INFO] \- e:f:jar:1.0.0:compile
|
|
73
|
+
[INFO] \- c:d:jar:1.0.0:compile
|
|
74
|
+
"""
|
|
75
|
+
expected_json = {
|
|
76
|
+
"id": "com.example:my-app",
|
|
77
|
+
"children": [
|
|
78
|
+
{"id": "b", "children": [{"id": "d", "children": []}]},
|
|
79
|
+
{"id": "f", "children": [{"id": "d", "children": []}]},
|
|
80
|
+
],
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
output_filename = "test_output_duplicates.json"
|
|
84
|
+
create_json_output(dependency_tree, output_filename)
|
|
85
|
+
|
|
86
|
+
with open(output_filename, "r") as f:
|
|
87
|
+
actual_json = json.load(f)
|
|
88
|
+
|
|
89
|
+
os.remove(output_filename)
|
|
90
|
+
assert actual_json == expected_json
|
|
91
|
+
|
|
92
|
+
|
|
93
|
+
def test_create_json_output_with_show_versions_true():
|
|
94
|
+
dependency_tree = r"""[INFO] com.example:my-app:jar:1.0.0
|
|
95
|
+
[INFO] +- org.springframework.boot:spring-boot-starter-web:jar:2.5.4:compile
|
|
96
|
+
[INFO] | \- org.springframework.boot:spring-boot-starter:jar:2.5.4:compile
|
|
97
|
+
[INFO] \- org.apache.commons:commons-lang3:jar:3.12.0:compile
|
|
98
|
+
"""
|
|
99
|
+
expected_json = {
|
|
100
|
+
"id": "com.example:my-app:1.0.0",
|
|
101
|
+
"children": [
|
|
102
|
+
{"id": "spring-boot-starter-web:2.5.4", "children": [{"id": "spring-boot-starter:2.5.4", "children": []}]},
|
|
103
|
+
{"id": "commons-lang3:3.12.0", "children": []},
|
|
104
|
+
],
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
output_filename = "test_output_show_versions_true.json"
|
|
108
|
+
create_json_output(dependency_tree, output_filename, show_versions=True)
|
|
109
|
+
|
|
110
|
+
with open(output_filename, "r") as f:
|
|
111
|
+
actual_json = json.load(f)
|
|
112
|
+
|
|
113
|
+
os.remove(output_filename)
|
|
114
|
+
assert actual_json == expected_json
|
|
115
|
+
|
|
116
|
+
|
|
117
|
+
def test_create_json_output_with_show_versions_false():
|
|
118
|
+
dependency_tree = r"""[INFO] com.example:my-app:jar:1.0.0
|
|
119
|
+
[INFO] +- org.springframework.boot:spring-boot-starter-web:jar:2.5.4:compile
|
|
120
|
+
[INFO] | \- org.springframework.boot:spring-boot-starter:jar:2.5.4:compile
|
|
121
|
+
[INFO] \- org.apache.commons:commons-lang3:jar:3.12.0:compile
|
|
122
|
+
"""
|
|
123
|
+
expected_json = {
|
|
124
|
+
"id": "com.example:my-app",
|
|
125
|
+
"children": [
|
|
126
|
+
{"id": "spring-boot-starter-web", "children": [{"id": "spring-boot-starter", "children": []}]},
|
|
127
|
+
{"id": "commons-lang3", "children": []},
|
|
128
|
+
],
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
output_filename = "test_output_show_versions_false.json"
|
|
132
|
+
create_json_output(dependency_tree, output_filename, show_versions=False)
|
|
133
|
+
|
|
134
|
+
with open(output_filename, "r") as f:
|
|
135
|
+
actual_json = json.load(f)
|
|
136
|
+
|
|
137
|
+
os.remove(output_filename)
|
|
138
|
+
assert actual_json == expected_json
|
|
139
|
+
|
|
140
|
+
|
|
141
|
+
def test_create_json_output_real_life_example():
|
|
142
|
+
dependency_tree = r"""[INFO] [dependency:tree]
|
|
143
|
+
[INFO] org.apache.maven.plugins:maven-dependency-plugin:maven-plugin:2.0-alpha-5-SNAPSHOT
|
|
144
|
+
[INFO] \- org.apache.maven.doxia:doxia-site-renderer:jar:1.0-alpha-8:compile
|
|
145
|
+
[INFO] \- org.codehaus.plexus:plexus-velocity:jar:1.1.3:compile
|
|
146
|
+
[INFO] \- velocity:velocity:jar:1.4:compile
|
|
147
|
+
"""
|
|
148
|
+
expected_json = {
|
|
149
|
+
"id": "org.apache.maven.plugins:maven-dependency-plugin",
|
|
150
|
+
"children": [
|
|
151
|
+
{
|
|
152
|
+
"id": "doxia-site-renderer",
|
|
153
|
+
"children": [{"id": "plexus-velocity", "children": [{"id": "velocity", "children": []}]}],
|
|
154
|
+
}
|
|
155
|
+
],
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
output_filename = "test_output_real_life.json"
|
|
159
|
+
create_json_output(dependency_tree, output_filename)
|
|
160
|
+
|
|
161
|
+
with open(output_filename, "r") as f:
|
|
162
|
+
actual_json = json.load(f)
|
|
163
|
+
|
|
164
|
+
os.remove(output_filename)
|
|
165
|
+
assert actual_json == expected_json
|
|
166
|
+
|
|
167
|
+
|
|
168
|
+
def test_create_json_output_real_life_example_show_versions():
|
|
169
|
+
dependency_tree = r"""[INFO] [dependency:tree]
|
|
170
|
+
[INFO] org.apache.maven.plugins:maven-dependency-plugin:maven-plugin:2.0-alpha-5-SNAPSHOT
|
|
171
|
+
[INFO] \- org.apache.maven.doxia:doxia-site-renderer:jar:1.0-alpha-8:compile
|
|
172
|
+
[INFO] \- org.codehaus.plexus:plexus-velocity:jar:1.1.3:compile
|
|
173
|
+
[INFO] \- velocity:velocity:jar:1.4:compile
|
|
174
|
+
"""
|
|
175
|
+
expected_json = {
|
|
176
|
+
"id": "org.apache.maven.plugins:maven-dependency-plugin:2.0-alpha-5-SNAPSHOT",
|
|
177
|
+
"children": [
|
|
178
|
+
{
|
|
179
|
+
"id": "doxia-site-renderer:1.0-alpha-8",
|
|
180
|
+
"children": [{"id": "plexus-velocity:1.1.3", "children": [{"id": "velocity:1.4", "children": []}]}],
|
|
181
|
+
}
|
|
182
|
+
],
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
output_filename = "test_output_real_life_show_versions.json"
|
|
186
|
+
create_json_output(dependency_tree, output_filename, show_versions=True)
|
|
187
|
+
|
|
188
|
+
with open(output_filename, "r") as f:
|
|
189
|
+
actual_json = json.load(f)
|
|
190
|
+
|
|
191
|
+
os.remove(output_filename)
|
|
192
|
+
assert actual_json == expected_json
|
|
@@ -1,85 +0,0 @@
|
|
|
1
|
-
from mvn_tree_visualizer.outputs.html_output import _convert_to_mermaid
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
def test_convert_to_mermaid_simple():
|
|
5
|
-
dependency_tree = r"""[INFO] com.example:my-app:jar:1.0.0
|
|
6
|
-
[INFO] +- org.springframework.boot:spring-boot-starter-web:jar:2.5.4:compile
|
|
7
|
-
[INFO] | +- org.springframework.boot:spring-boot-starter:jar:2.5.4:compile
|
|
8
|
-
[INFO] | | \- org.yaml:snakeyaml:jar:1.28:compile
|
|
9
|
-
[INFO] | \- org.springframework:spring-webmvc:jar:5.3.9:compile
|
|
10
|
-
[INFO] \- org.apache.commons:commons-lang3:jar:3.12.0:compile
|
|
11
|
-
"""
|
|
12
|
-
expected_mermaid_diagram_lines = {
|
|
13
|
-
"graph LR",
|
|
14
|
-
"\tmy-app --> commons-lang3;",
|
|
15
|
-
"\tmy-app --> spring-boot-starter-web;",
|
|
16
|
-
"\tmy-app;",
|
|
17
|
-
"\tspring-boot-starter --> snakeyaml;",
|
|
18
|
-
"\tspring-boot-starter-web --> spring-boot-starter;",
|
|
19
|
-
"\tspring-boot-starter-web --> spring-webmvc;",
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
actual_lines = set(_convert_to_mermaid(dependency_tree).strip().split('\n'))
|
|
23
|
-
assert actual_lines == expected_mermaid_diagram_lines
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
def test_convert_to_mermaid_deeper_tree():
|
|
27
|
-
dependency_tree = r"""[INFO] com.example:my-app:jar:1.0.0
|
|
28
|
-
[INFO] +- a:b:jar:1.0.0:compile
|
|
29
|
-
[INFO] | +- c:d:jar:1.0.0:compile
|
|
30
|
-
[INFO] | | +- e:f:jar:1.0.0:compile
|
|
31
|
-
[INFO] | | | \- g:h:jar:1.0.0:compile
|
|
32
|
-
[INFO] | | \- i:j:jar:1.0.0:compile
|
|
33
|
-
[INFO] | \- k:l:jar:1.0.0:compile
|
|
34
|
-
[INFO] \- m:n:jar:1.0.0:compile
|
|
35
|
-
"""
|
|
36
|
-
expected_mermaid_diagram_lines = {
|
|
37
|
-
"graph LR",
|
|
38
|
-
"\tb --> d;",
|
|
39
|
-
"\tb --> l;",
|
|
40
|
-
"\td --> f;",
|
|
41
|
-
"\td --> j;",
|
|
42
|
-
"\tf --> h;",
|
|
43
|
-
"\tmy-app --> b;",
|
|
44
|
-
"\tmy-app --> n;",
|
|
45
|
-
"\tmy-app;",
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
actual_lines = set(_convert_to_mermaid(dependency_tree).strip().split('\n'))
|
|
49
|
-
assert actual_lines == expected_mermaid_diagram_lines
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
def test_convert_to_mermaid_multiple_top_level():
|
|
53
|
-
dependency_tree = r"""[INFO] com.example:my-app:jar:1.0.0
|
|
54
|
-
[INFO] +- a:b:jar:1.0.0:compile
|
|
55
|
-
[INFO] \- c:d:jar:1.0.0:compile
|
|
56
|
-
"""
|
|
57
|
-
expected_mermaid_diagram_lines = {
|
|
58
|
-
"graph LR",
|
|
59
|
-
"\tmy-app --> b;",
|
|
60
|
-
"\tmy-app --> d;",
|
|
61
|
-
"\tmy-app;",
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
actual_lines = set(_convert_to_mermaid(dependency_tree).strip().split('\n'))
|
|
65
|
-
assert actual_lines == expected_mermaid_diagram_lines
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
def test_convert_to_mermaid_duplicate_dependencies():
|
|
69
|
-
dependency_tree = r"""[INFO] com.example:my-app:jar:1.0.0
|
|
70
|
-
[INFO] +- a:b:jar:1.0.0:compile
|
|
71
|
-
[INFO] | \- c:d:jar:1.0.0:compile
|
|
72
|
-
[INFO] \- e:f:jar:1.0.0:compile
|
|
73
|
-
[INFO] \- c:d:jar:1.0.0:compile
|
|
74
|
-
"""
|
|
75
|
-
expected_mermaid_diagram_lines = {
|
|
76
|
-
"graph LR",
|
|
77
|
-
"\tb --> d;",
|
|
78
|
-
"\tf --> d;",
|
|
79
|
-
"\tmy-app --> b;",
|
|
80
|
-
"\tmy-app --> f;",
|
|
81
|
-
"\tmy-app;",
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
actual_lines = set(_convert_to_mermaid(dependency_tree).strip().split('\n'))
|
|
85
|
-
assert actual_lines == expected_mermaid_diagram_lines
|
|
@@ -1,100 +0,0 @@
|
|
|
1
|
-
import json
|
|
2
|
-
import os
|
|
3
|
-
from mvn_tree_visualizer.outputs.json_output import create_json_output
|
|
4
|
-
|
|
5
|
-
def test_create_json_output_simple():
|
|
6
|
-
dependency_tree = r"""[INFO] com.example:my-app:jar:1.0.0
|
|
7
|
-
[INFO] +- org.springframework.boot:spring-boot-starter-web:jar:2.5.4:compile
|
|
8
|
-
[INFO] | \- org.springframework.boot:spring-boot-starter:jar:2.5.4:compile
|
|
9
|
-
[INFO] \- org.apache.commons:commons-lang3:jar:3.12.0:compile
|
|
10
|
-
"""
|
|
11
|
-
expected_json = {
|
|
12
|
-
"id": "com.example:my-app:1.0.0",
|
|
13
|
-
"children": [
|
|
14
|
-
{
|
|
15
|
-
"id": "spring-boot-starter-web:2.5.4",
|
|
16
|
-
"children": [
|
|
17
|
-
{
|
|
18
|
-
"id": "spring-boot-starter:2.5.4",
|
|
19
|
-
"children": []
|
|
20
|
-
}
|
|
21
|
-
]
|
|
22
|
-
},
|
|
23
|
-
{
|
|
24
|
-
"id": "commons-lang3:3.12.0",
|
|
25
|
-
"children": []
|
|
26
|
-
}
|
|
27
|
-
]
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
output_filename = "test_output.json"
|
|
31
|
-
create_json_output(dependency_tree, output_filename)
|
|
32
|
-
|
|
33
|
-
with open(output_filename, "r") as f:
|
|
34
|
-
actual_json = json.load(f)
|
|
35
|
-
|
|
36
|
-
os.remove(output_filename)
|
|
37
|
-
assert actual_json == expected_json
|
|
38
|
-
|
|
39
|
-
def test_create_json_output_deeper_tree():
|
|
40
|
-
dependency_tree = r"""[INFO] com.example:my-app:jar:1.0.0
|
|
41
|
-
[INFO] +- a:b:jar:1.0.0:compile
|
|
42
|
-
[INFO] | +- c:d:jar:1.0.0:compile
|
|
43
|
-
[INFO] | | +- e:f:jar:1.0.0:compile
|
|
44
|
-
[INFO] | | | \- g:h:jar:1.0.0:compile
|
|
45
|
-
[INFO] | | \- i:j:jar:1.0.0:compile
|
|
46
|
-
[INFO] | \- k:l:jar:1.0.0:compile
|
|
47
|
-
[INFO] \- m:n:jar:1.0.0:compile
|
|
48
|
-
"""
|
|
49
|
-
expected_json = {
|
|
50
|
-
"id": "com.example:my-app:1.0.0",
|
|
51
|
-
"children": [
|
|
52
|
-
{
|
|
53
|
-
"id": "b:1.0.0",
|
|
54
|
-
"children": [
|
|
55
|
-
{
|
|
56
|
-
"id": "d:1.0.0",
|
|
57
|
-
"children": [
|
|
58
|
-
{"id": "f:1.0.0", "children": [{"id": "h:1.0.0", "children": []}]},
|
|
59
|
-
{"id": "j:1.0.0", "children": []}
|
|
60
|
-
]
|
|
61
|
-
},
|
|
62
|
-
{"id": "l:1.0.0", "children": []}
|
|
63
|
-
]
|
|
64
|
-
},
|
|
65
|
-
{"id": "n:1.0.0", "children": []}
|
|
66
|
-
]
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
output_filename = "test_output_deep.json"
|
|
70
|
-
create_json_output(dependency_tree, output_filename)
|
|
71
|
-
|
|
72
|
-
with open(output_filename, "r") as f:
|
|
73
|
-
actual_json = json.load(f)
|
|
74
|
-
|
|
75
|
-
os.remove(output_filename)
|
|
76
|
-
assert actual_json == expected_json
|
|
77
|
-
|
|
78
|
-
def test_create_json_output_duplicate_dependencies():
|
|
79
|
-
dependency_tree = r"""[INFO] com.example:my-app:jar:1.0.0
|
|
80
|
-
[INFO] +- a:b:jar:1.0.0:compile
|
|
81
|
-
[INFO] | \- c:d:jar:1.0.0:compile
|
|
82
|
-
[INFO] \- e:f:jar:1.0.0:compile
|
|
83
|
-
[INFO] \- c:d:jar:1.0.0:compile
|
|
84
|
-
"""
|
|
85
|
-
expected_json = {
|
|
86
|
-
"id": "com.example:my-app:1.0.0",
|
|
87
|
-
"children": [
|
|
88
|
-
{"id": "b:1.0.0", "children": [{"id": "d:1.0.0", "children": []}]},
|
|
89
|
-
{"id": "f:1.0.0", "children": [{"id": "d:1.0.0", "children": []}]}
|
|
90
|
-
]
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
output_filename = "test_output_duplicates.json"
|
|
94
|
-
create_json_output(dependency_tree, output_filename)
|
|
95
|
-
|
|
96
|
-
with open(output_filename, "r") as f:
|
|
97
|
-
actual_json = json.load(f)
|
|
98
|
-
|
|
99
|
-
os.remove(output_filename)
|
|
100
|
-
assert actual_json == expected_json
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|