mvn-tree-visualizer 1.6.0__py3-none-any.whl → 1.8.1__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.
- mvn_tree_visualizer/cli.py +94 -17
- mvn_tree_visualizer/utils.py +29 -0
- {mvn_tree_visualizer-1.6.0.dist-info → mvn_tree_visualizer-1.8.1.dist-info}/METADATA +35 -4
- {mvn_tree_visualizer-1.6.0.dist-info → mvn_tree_visualizer-1.8.1.dist-info}/RECORD +7 -6
- {mvn_tree_visualizer-1.6.0.dist-info → mvn_tree_visualizer-1.8.1.dist-info}/WHEEL +0 -0
- {mvn_tree_visualizer-1.6.0.dist-info → mvn_tree_visualizer-1.8.1.dist-info}/entry_points.txt +0 -0
- {mvn_tree_visualizer-1.6.0.dist-info → mvn_tree_visualizer-1.8.1.dist-info}/licenses/LICENSE +0 -0
mvn_tree_visualizer/cli.py
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
import argparse
|
|
2
|
+
import sys
|
|
2
3
|
import time
|
|
4
|
+
import traceback
|
|
5
|
+
import webbrowser
|
|
6
|
+
from importlib import metadata
|
|
3
7
|
from pathlib import Path
|
|
4
8
|
from typing import NoReturn
|
|
5
9
|
|
|
@@ -9,9 +13,18 @@ from .file_watcher import FileWatcher
|
|
|
9
13
|
from .get_dependencies_in_one_file import merge_files
|
|
10
14
|
from .outputs.html_output import create_html_diagram
|
|
11
15
|
from .outputs.json_output import create_json_output
|
|
16
|
+
from .utils import add_timestamp_to_filename
|
|
12
17
|
from .validation import find_dependency_files, validate_dependency_files, validate_output_directory
|
|
13
18
|
|
|
14
19
|
|
|
20
|
+
def get_version() -> str:
|
|
21
|
+
"""Get the current version of the package."""
|
|
22
|
+
try:
|
|
23
|
+
return metadata.version("mvn-tree-visualizer")
|
|
24
|
+
except metadata.PackageNotFoundError:
|
|
25
|
+
return "unknown"
|
|
26
|
+
|
|
27
|
+
|
|
15
28
|
def generate_diagram(
|
|
16
29
|
directory: str,
|
|
17
30
|
output_file: str,
|
|
@@ -20,6 +33,8 @@ def generate_diagram(
|
|
|
20
33
|
output_format: str,
|
|
21
34
|
show_versions: bool,
|
|
22
35
|
theme: str = "minimal",
|
|
36
|
+
quiet: bool = False,
|
|
37
|
+
open_browser: bool = False,
|
|
23
38
|
) -> None:
|
|
24
39
|
"""Generate the dependency diagram with comprehensive error handling."""
|
|
25
40
|
timestamp = time.strftime("%H:%M:%S")
|
|
@@ -31,7 +46,7 @@ def generate_diagram(
|
|
|
31
46
|
|
|
32
47
|
# Show what files we found
|
|
33
48
|
dependency_files = find_dependency_files(directory, filename)
|
|
34
|
-
if len(dependency_files) > 1:
|
|
49
|
+
if len(dependency_files) > 1 and not quiet:
|
|
35
50
|
print(f"[{timestamp}] Found {len(dependency_files)} dependency files")
|
|
36
51
|
|
|
37
52
|
# Setup paths
|
|
@@ -103,24 +118,35 @@ def generate_diagram(
|
|
|
103
118
|
except Exception as e:
|
|
104
119
|
raise OutputGenerationError(f"Error generating {output_format.upper()} output: {e}")
|
|
105
120
|
|
|
106
|
-
|
|
121
|
+
if not quiet:
|
|
122
|
+
print(f"[{timestamp}] SUCCESS: Diagram generated and saved to {output_file}")
|
|
123
|
+
|
|
124
|
+
# Open in browser if requested and format is HTML
|
|
125
|
+
if open_browser and output_format == "html" and not quiet:
|
|
126
|
+
try:
|
|
127
|
+
webbrowser.open(Path(output_file).resolve().as_uri())
|
|
128
|
+
print(f"[{timestamp}] Opening diagram in your default browser...")
|
|
129
|
+
except Exception as e:
|
|
130
|
+
print(f"[{timestamp}] WARNING: Could not open browser: {e}", file=sys.stderr)
|
|
107
131
|
|
|
108
132
|
except MvnTreeVisualizerError as e:
|
|
109
133
|
# Our custom errors already have helpful messages
|
|
110
|
-
print(f"[{timestamp}]
|
|
134
|
+
print(f"[{timestamp}] ERROR: {e}", file=sys.stderr)
|
|
135
|
+
raise # Re-raise the exception for the caller to handle
|
|
111
136
|
except KeyboardInterrupt:
|
|
112
|
-
print(f"\n[{timestamp}]
|
|
137
|
+
print(f"\n[{timestamp}] Operation cancelled by user", file=sys.stderr)
|
|
138
|
+
raise # Re-raise for the caller to handle
|
|
113
139
|
except Exception as e:
|
|
114
140
|
# Unexpected errors
|
|
115
|
-
print(f"[{timestamp}]
|
|
116
|
-
print("This is an internal error. Please report this issue with the following details:")
|
|
117
|
-
print(f" - Directory: {directory}")
|
|
118
|
-
print(f" - Filename: {filename}")
|
|
119
|
-
print(f" - Output: {output_file}")
|
|
120
|
-
print(f" - Format: {output_format}")
|
|
121
|
-
import traceback
|
|
141
|
+
print(f"[{timestamp}] UNEXPECTED ERROR: {e}", file=sys.stderr)
|
|
142
|
+
print("This is an internal error. Please report this issue with the following details:", file=sys.stderr)
|
|
143
|
+
print(f" - Directory: {directory}", file=sys.stderr)
|
|
144
|
+
print(f" - Filename: {filename}", file=sys.stderr)
|
|
145
|
+
print(f" - Output: {output_file}", file=sys.stderr)
|
|
146
|
+
print(f" - Format: {output_format}", file=sys.stderr)
|
|
122
147
|
|
|
123
148
|
traceback.print_exc()
|
|
149
|
+
raise # Re-raise for the caller to handle
|
|
124
150
|
|
|
125
151
|
|
|
126
152
|
def cli() -> NoReturn:
|
|
@@ -128,6 +154,14 @@ def cli() -> NoReturn:
|
|
|
128
154
|
prog="mvn-tree-visualizer",
|
|
129
155
|
description="Generate a dependency diagram from a file.",
|
|
130
156
|
)
|
|
157
|
+
|
|
158
|
+
parser.add_argument(
|
|
159
|
+
"-v",
|
|
160
|
+
"--version",
|
|
161
|
+
action="version",
|
|
162
|
+
version=f"mvn-tree-visualizer {get_version()}",
|
|
163
|
+
)
|
|
164
|
+
|
|
131
165
|
parser.add_argument(
|
|
132
166
|
"directory",
|
|
133
167
|
type=str,
|
|
@@ -186,6 +220,25 @@ def cli() -> NoReturn:
|
|
|
186
220
|
help="Theme for the diagram visualization. Default is 'minimal'.",
|
|
187
221
|
)
|
|
188
222
|
|
|
223
|
+
parser.add_argument(
|
|
224
|
+
"-q",
|
|
225
|
+
"--quiet",
|
|
226
|
+
action="store_true",
|
|
227
|
+
help="Suppress all console output except errors. Perfect for CI/CD pipelines and scripted usage.",
|
|
228
|
+
)
|
|
229
|
+
|
|
230
|
+
parser.add_argument(
|
|
231
|
+
"--open",
|
|
232
|
+
action="store_true",
|
|
233
|
+
help="Automatically open the generated HTML diagram in your default browser. Only works with HTML output format.",
|
|
234
|
+
)
|
|
235
|
+
|
|
236
|
+
parser.add_argument(
|
|
237
|
+
"--timestamp-output",
|
|
238
|
+
action="store_true",
|
|
239
|
+
help="Append timestamp to output filename (e.g., diagram-2025-08-13-203045.html). Useful for version tracking and CI/CD.",
|
|
240
|
+
)
|
|
241
|
+
|
|
189
242
|
args = parser.parse_args()
|
|
190
243
|
directory: str = args.directory
|
|
191
244
|
output_file: str = args.output
|
|
@@ -195,20 +248,43 @@ def cli() -> NoReturn:
|
|
|
195
248
|
show_versions: bool = args.show_versions
|
|
196
249
|
watch_mode: bool = args.watch
|
|
197
250
|
theme: str = args.theme
|
|
251
|
+
quiet: bool = args.quiet
|
|
252
|
+
open_browser: bool = args.open
|
|
253
|
+
timestamp_output: bool = args.timestamp_output
|
|
254
|
+
|
|
255
|
+
# Apply timestamp to output filename if requested
|
|
256
|
+
if timestamp_output:
|
|
257
|
+
output_file = add_timestamp_to_filename(output_file)
|
|
198
258
|
|
|
199
259
|
# Generate initial diagram
|
|
200
|
-
|
|
201
|
-
|
|
260
|
+
if not quiet:
|
|
261
|
+
timestamp = time.strftime("%Y-%m-%d %H:%M:%S")
|
|
262
|
+
print(f"[{timestamp}] Generating initial diagram...")
|
|
263
|
+
|
|
264
|
+
try:
|
|
265
|
+
generate_diagram(directory, output_file, filename, keep_tree, output_format, show_versions, theme, quiet, open_browser)
|
|
266
|
+
except MvnTreeVisualizerError:
|
|
267
|
+
sys.exit(1)
|
|
268
|
+
except KeyboardInterrupt:
|
|
269
|
+
sys.exit(130) # Standard exit code for SIGINT
|
|
270
|
+
except Exception:
|
|
271
|
+
sys.exit(1)
|
|
202
272
|
|
|
203
273
|
if not watch_mode:
|
|
204
|
-
|
|
205
|
-
|
|
274
|
+
if not quiet:
|
|
275
|
+
print("You can open it in your browser to view the dependency tree.")
|
|
276
|
+
print("Thank you for using mvn-tree-visualizer!")
|
|
206
277
|
return
|
|
207
278
|
|
|
208
279
|
# Watch mode
|
|
209
280
|
def regenerate_callback():
|
|
210
281
|
"""Callback function for file watcher."""
|
|
211
|
-
|
|
282
|
+
try:
|
|
283
|
+
generate_diagram(directory, output_file, filename, keep_tree, output_format, show_versions, theme, quiet, open_browser)
|
|
284
|
+
except Exception:
|
|
285
|
+
# In watch mode, we don't want to exit on errors, just log them
|
|
286
|
+
print("Error during diagram regeneration:", file=sys.stderr)
|
|
287
|
+
traceback.print_exc()
|
|
212
288
|
|
|
213
289
|
watcher = FileWatcher(directory, filename, regenerate_callback)
|
|
214
290
|
watcher.start()
|
|
@@ -216,7 +292,8 @@ def cli() -> NoReturn:
|
|
|
216
292
|
try:
|
|
217
293
|
watcher.wait()
|
|
218
294
|
finally:
|
|
219
|
-
|
|
295
|
+
if not quiet:
|
|
296
|
+
print("Thank you for using mvn-tree-visualizer!")
|
|
220
297
|
|
|
221
298
|
|
|
222
299
|
if __name__ == "__main__":
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import time
|
|
2
|
+
from pathlib import Path
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
def add_timestamp_to_filename(filename: str) -> str:
|
|
6
|
+
"""Add timestamp to filename before the extension.
|
|
7
|
+
|
|
8
|
+
Args:
|
|
9
|
+
filename: Original filename (e.g., 'diagram.html', 'output.json', 'folder/diagram.html')
|
|
10
|
+
|
|
11
|
+
Returns:
|
|
12
|
+
Timestamped filename (e.g., 'diagram-2025-08-13-203045.html')
|
|
13
|
+
"""
|
|
14
|
+
timestamp = time.strftime("%Y-%m-%d-%H%M%S")
|
|
15
|
+
path = Path(filename)
|
|
16
|
+
|
|
17
|
+
# Handle paths by preserving directory and only modifying the filename
|
|
18
|
+
if path.parent != Path("."):
|
|
19
|
+
# Has a directory component
|
|
20
|
+
directory = path.parent
|
|
21
|
+
stem = path.stem
|
|
22
|
+
suffix = path.suffix
|
|
23
|
+
timestamped_name = f"{stem}-{timestamp}{suffix}"
|
|
24
|
+
return str(directory / timestamped_name)
|
|
25
|
+
else:
|
|
26
|
+
# No directory component
|
|
27
|
+
stem = path.stem
|
|
28
|
+
suffix = path.suffix
|
|
29
|
+
return f"{stem}-{timestamp}{suffix}"
|
|
@@ -1,19 +1,22 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: mvn-tree-visualizer
|
|
3
|
-
Version: 1.
|
|
3
|
+
Version: 1.8.1
|
|
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>
|
|
7
7
|
License-Expression: MIT
|
|
8
8
|
License-File: LICENSE
|
|
9
9
|
Keywords: cli,command-line,dependency,graph,maven,mermaid,tool,tree,visualization
|
|
10
|
-
Classifier: Development Status ::
|
|
10
|
+
Classifier: Development Status :: 5 - Production/Stable
|
|
11
11
|
Classifier: Intended Audience :: Developers
|
|
12
12
|
Classifier: Programming Language :: Python :: 3
|
|
13
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
13
16
|
Classifier: Programming Language :: Python :: 3.13
|
|
14
17
|
Classifier: Topic :: Software Development :: Build Tools
|
|
15
18
|
Classifier: Typing :: Typed
|
|
16
|
-
Requires-Python: >=3.
|
|
19
|
+
Requires-Python: >=3.10
|
|
17
20
|
Requires-Dist: jinja2>=3.1.6
|
|
18
21
|
Requires-Dist: watchdog>=6.0.0
|
|
19
22
|
Description-Content-Type: text/markdown
|
|
@@ -21,7 +24,7 @@ Description-Content-Type: text/markdown
|
|
|
21
24
|
# Maven Dependency Tree Visualizer
|
|
22
25
|
|
|
23
26
|
[](https://badge.fury.io/py/mvn-tree-visualizer)
|
|
24
|
-

|
|
25
28
|

|
|
26
29
|
[](https://pepy.tech/project/mvn-tree-visualizer)
|
|
27
30
|
[](https://github.com/dyka3773/mvn-tree-visualizer/actions)
|
|
@@ -112,6 +115,30 @@ mvn-tree-visualizer --filename "maven_dependency_file" --output "dependencies.js
|
|
|
112
115
|
mvn-tree-visualizer --filename "maven_dependency_file" --output "diagram.html" --watch
|
|
113
116
|
```
|
|
114
117
|
|
|
118
|
+
#### Quiet Mode (For Automation/Scripts)
|
|
119
|
+
```bash
|
|
120
|
+
# Only show errors, suppress success messages
|
|
121
|
+
mvn-tree-visualizer --filename "maven_dependency_file" --output "diagram.html" --quiet
|
|
122
|
+
|
|
123
|
+
# Short form also available
|
|
124
|
+
mvn-tree-visualizer --filename "maven_dependency_file" --output "diagram.html" -q
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
#### Auto-Open in Browser
|
|
128
|
+
```bash
|
|
129
|
+
# Automatically open the generated HTML diagram in your default browser
|
|
130
|
+
mvn-tree-visualizer --filename "maven_dependency_file" --output "diagram.html" --open
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
#### Timestamped Output Files
|
|
134
|
+
```bash
|
|
135
|
+
# Generate files with timestamps (e.g., diagram_20250813_143022.html)
|
|
136
|
+
mvn-tree-visualizer --filename "maven_dependency_file" --output "diagram.html" --timestamp-output
|
|
137
|
+
|
|
138
|
+
# Combine with auto-open for immediate viewing
|
|
139
|
+
mvn-tree-visualizer --filename "maven_dependency_file" --output "diagram.html" --timestamp-output --open
|
|
140
|
+
```
|
|
141
|
+
|
|
115
142
|
> **💡 Tip:** In watch mode, the tool will monitor for changes to your Maven dependency files and automatically regenerate the diagram. Perfect for development workflows! Press `Ctrl+C` to stop watching.
|
|
116
143
|
|
|
117
144
|
### Step 3: View the output
|
|
@@ -143,6 +170,10 @@ Each example includes:
|
|
|
143
170
|
| `--watch` | Watch for file changes and auto-regenerate diagram | `False` |
|
|
144
171
|
| `--directory` | The directory to scan for the Maven dependency file(s) | current directory |
|
|
145
172
|
| `--keep-tree` | Keep the intermediate `dependency_tree.txt` file | `False` |
|
|
173
|
+
| `--quiet`, `-q` | Suppress all console output except errors | `False` |
|
|
174
|
+
| `--open` | Automatically open generated HTML files in default browser | `False` |
|
|
175
|
+
| `--timestamp-output` | Add timestamp to output filename (e.g., `diagram-2025-08-13-203045.html`) | `False` |
|
|
176
|
+
| `--version`, `-v` | Show the current version and exit | - |
|
|
146
177
|
| `--help` | Show the help message and exit | - |
|
|
147
178
|
|
|
148
179
|
### Theme Options
|
|
@@ -1,17 +1,18 @@
|
|
|
1
1
|
mvn_tree_visualizer/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
2
2
|
mvn_tree_visualizer/__main__.py,sha256=yIQFAdWjthKAFbSzzRuz5_YGlK0c6BnR2ypjNRDq180,82
|
|
3
|
-
mvn_tree_visualizer/cli.py,sha256=
|
|
3
|
+
mvn_tree_visualizer/cli.py,sha256=1qrrcrLdJRM-GHYJsm0I9R1arOQ2XZxdZllazj-yME0,11134
|
|
4
4
|
mvn_tree_visualizer/diagram.py,sha256=UfvP_J4Im4JQLe3EWlY3TsP4tua3oYk5NiCGbZNQwoA,933
|
|
5
5
|
mvn_tree_visualizer/enhanced_template.py,sha256=AwK4gw5U8Ag-RmeD8Y11LXLRSnVzMFZhWja__c2iF4M,9813
|
|
6
6
|
mvn_tree_visualizer/exceptions.py,sha256=R4nnJ0xrOpd84GfPD9rFSDk40etDLoph7iZpj1CCR0c,543
|
|
7
7
|
mvn_tree_visualizer/file_watcher.py,sha256=JtmV1KW08_Az-XqpKhcd342WpxV1vUW-Dge9lodjjJY,2284
|
|
8
8
|
mvn_tree_visualizer/get_dependencies_in_one_file.py,sha256=nXhEhU-dI7tXa3TpoW1pv2t86t1K0yppSw8FYDtmTlQ,1973
|
|
9
9
|
mvn_tree_visualizer/themes.py,sha256=T7vdNVTHPtYYkh4HusGG1MUWk1mJcqFBjCc5IK5l6Dc,6338
|
|
10
|
+
mvn_tree_visualizer/utils.py,sha256=Ws6Yo-I4tioBndZ7BLES8QwoMOcHE0XiRP8CSOTx8tg,901
|
|
10
11
|
mvn_tree_visualizer/validation.py,sha256=UR_v6Jt7IGsgozE3aK0pB-t2-n1ivvS4YKxEa7p4VLQ,3206
|
|
11
12
|
mvn_tree_visualizer/outputs/html_output.py,sha256=Y0IY-UF0UMTa5w8mVFoLidgcW6BUBTxASO0iRo26hH4,5531
|
|
12
13
|
mvn_tree_visualizer/outputs/json_output.py,sha256=cXntw9ndE_BcrmFnuV61cEwZaRMp9Ev0SxaK1SUedlw,2037
|
|
13
|
-
mvn_tree_visualizer-1.
|
|
14
|
-
mvn_tree_visualizer-1.
|
|
15
|
-
mvn_tree_visualizer-1.
|
|
16
|
-
mvn_tree_visualizer-1.
|
|
17
|
-
mvn_tree_visualizer-1.
|
|
14
|
+
mvn_tree_visualizer-1.8.1.dist-info/METADATA,sha256=tnHNh02nGgqrzgf6tlsE2jIz5BLTGvmell395bVgEeQ,9865
|
|
15
|
+
mvn_tree_visualizer-1.8.1.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
|
16
|
+
mvn_tree_visualizer-1.8.1.dist-info/entry_points.txt,sha256=Mu3QZhrlvbYuCxqmluVGi2efgKjkQY6T8Opf-vdb7hU,68
|
|
17
|
+
mvn_tree_visualizer-1.8.1.dist-info/licenses/LICENSE,sha256=4zi6unpe17RUDMBu7ebh14jdbyvyeT-UA3n8Zl7aW74,1075
|
|
18
|
+
mvn_tree_visualizer-1.8.1.dist-info/RECORD,,
|
|
File without changes
|
{mvn_tree_visualizer-1.6.0.dist-info → mvn_tree_visualizer-1.8.1.dist-info}/entry_points.txt
RENAMED
|
File without changes
|
{mvn_tree_visualizer-1.6.0.dist-info → mvn_tree_visualizer-1.8.1.dist-info}/licenses/LICENSE
RENAMED
|
File without changes
|