@madnessengineering/uml-generator 0.1.0
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.
- package/EXAMPLES.md +249 -0
- package/LICENSE +21 -0
- package/README.md +211 -0
- package/UML-GENERATOR-README.md +165 -0
- package/package.json +63 -0
- package/tui.js +490 -0
- package/uml-generator.js +614 -0
package/EXAMPLES.md
ADDED
|
@@ -0,0 +1,249 @@
|
|
|
1
|
+
# ๐ SwarmDesk UML Generator - Examples
|
|
2
|
+
|
|
3
|
+
## ๐ Real-World Examples
|
|
4
|
+
|
|
5
|
+
### 1. Analyze Inventorium (Current Project)
|
|
6
|
+
```bash
|
|
7
|
+
node uml-generator.js .. --output inventorium-uml.json
|
|
8
|
+
```
|
|
9
|
+
|
|
10
|
+
### 2. Analyze Just the Components Directory
|
|
11
|
+
```bash
|
|
12
|
+
node uml-generator.js ../src/components --output components-only.json
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
### 3. Analyze a Public GitHub Repo (React)
|
|
16
|
+
```bash
|
|
17
|
+
# Note: This clones the repo temporarily, analyzes it, then cleans up
|
|
18
|
+
node uml-generator.js https://github.com/facebook/react
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
### 4. Analyze Three.js Library
|
|
22
|
+
```bash
|
|
23
|
+
node uml-generator.js https://github.com/mrdoob/three.js --output three-uml.json
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
### 5. Analyze Your Own GitHub Project
|
|
27
|
+
```bash
|
|
28
|
+
node uml-generator.js https://github.com/yourusername/your-project
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
### 6. Custom Include/Exclude Patterns
|
|
32
|
+
```bash
|
|
33
|
+
# Only analyze source code, skip tests and config
|
|
34
|
+
node uml-generator.js . \
|
|
35
|
+
--include "src,lib" \
|
|
36
|
+
--exclude "test,__tests__,config,scripts,node_modules"
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
### 7. Analyze Multiple Related Projects
|
|
40
|
+
```bash
|
|
41
|
+
# Generate UML for each project in your workspace
|
|
42
|
+
node uml-generator.js ~/projects/frontend --output frontend-uml.json
|
|
43
|
+
node uml-generator.js ~/projects/backend --output backend-uml.json
|
|
44
|
+
node uml-generator.js ~/projects/shared --output shared-uml.json
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
## ๐ฎ Loading in SwarmDesk
|
|
48
|
+
|
|
49
|
+
### Method 1: Copy to Data Directory
|
|
50
|
+
```bash
|
|
51
|
+
# Generate UML
|
|
52
|
+
node uml-generator.js ~/my-project --output my-project-uml.json
|
|
53
|
+
|
|
54
|
+
# Copy to SwarmDesk data folder
|
|
55
|
+
cp my-project-uml.json ../public/data/
|
|
56
|
+
|
|
57
|
+
# Access in browser
|
|
58
|
+
open http://localhost:3000?uml=my-project-uml.json
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
### Method 2: Use URL Parameter
|
|
62
|
+
1. Start SwarmDesk server: `npm start` (from Inventorium root)
|
|
63
|
+
2. Place your UML file in `public/data/`
|
|
64
|
+
3. Navigate to: `http://localhost:3000?uml=your-file.json`
|
|
65
|
+
|
|
66
|
+
### Method 3: Press 'I' Key to Cycle Data Sources
|
|
67
|
+
1. Load SwarmDesk
|
|
68
|
+
2. Press `I` key to cycle through available UML data sources
|
|
69
|
+
3. Your newly generated files will appear in the cycle
|
|
70
|
+
|
|
71
|
+
## ๐ง Advanced Usage
|
|
72
|
+
|
|
73
|
+
### GitHub Private Repos (Future Enhancement)
|
|
74
|
+
```bash
|
|
75
|
+
# Not yet implemented, but planned:
|
|
76
|
+
# node uml-generator.js https://github.com/private/repo --token YOUR_TOKEN
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
### With Custom NPM Script
|
|
80
|
+
Add to your project's `package.json`:
|
|
81
|
+
```json
|
|
82
|
+
{
|
|
83
|
+
"scripts": {
|
|
84
|
+
"visualize": "node ../SwarmDesk/uml-generator.js . --output ../public/data/my-uml.json"
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
Then run:
|
|
90
|
+
```bash
|
|
91
|
+
npm run visualize
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
### Automated CI/CD Integration
|
|
95
|
+
```yaml
|
|
96
|
+
# .github/workflows/visualize.yml
|
|
97
|
+
name: Generate 3D Visualization
|
|
98
|
+
on: [push]
|
|
99
|
+
jobs:
|
|
100
|
+
visualize:
|
|
101
|
+
runs-on: ubuntu-latest
|
|
102
|
+
steps:
|
|
103
|
+
- uses: actions/checkout@v2
|
|
104
|
+
- name: Generate UML
|
|
105
|
+
run: |
|
|
106
|
+
npm install comment-parser
|
|
107
|
+
node tools/uml-generator.js . --output visualization.json
|
|
108
|
+
- name: Upload artifact
|
|
109
|
+
uses: actions/upload-artifact@v2
|
|
110
|
+
with:
|
|
111
|
+
name: code-visualization
|
|
112
|
+
path: visualization.json
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
## ๐ Interpreting the Output
|
|
116
|
+
|
|
117
|
+
### Understanding the Metrics
|
|
118
|
+
|
|
119
|
+
**Lines of Code:**
|
|
120
|
+
- Small components: < 100 lines โ Short buildings
|
|
121
|
+
- Medium components: 100-300 lines โ Medium buildings
|
|
122
|
+
- Large components: > 300 lines โ Tall buildings
|
|
123
|
+
|
|
124
|
+
**Complexity:**
|
|
125
|
+
- Low: < 10 (if/for/while) โ Green/Cool colors
|
|
126
|
+
- Medium: 10-20 โ Yellow/Warm colors
|
|
127
|
+
- High: > 20 โ Red/Hot colors
|
|
128
|
+
|
|
129
|
+
**Git Metrics:**
|
|
130
|
+
- `commitCount`: How many times this file changed
|
|
131
|
+
- `daysAgo`: Recency of last change
|
|
132
|
+
- Frequent changes + recent = Active development area
|
|
133
|
+
|
|
134
|
+
### Building Colors in SwarmDesk
|
|
135
|
+
|
|
136
|
+
Press `F6` to cycle through visualization metrics:
|
|
137
|
+
- **Test Coverage**: Green (high) to Red (low)
|
|
138
|
+
- **Code Complexity**: Cool (simple) to Hot (complex)
|
|
139
|
+
- **Method Count**: Indicates file responsibility size
|
|
140
|
+
|
|
141
|
+
### Dependency Lines
|
|
142
|
+
|
|
143
|
+
Press `F8` to toggle dependency visualization:
|
|
144
|
+
- **Yellow lines**: Standard dependencies/imports
|
|
145
|
+
- **Orange lines**: Class inheritance (extends)
|
|
146
|
+
- **Cyan lines**: Interface implementations
|
|
147
|
+
- **Green lines**: Module imports
|
|
148
|
+
|
|
149
|
+
Press `F7` to toggle animated arrows showing data flow direction!
|
|
150
|
+
|
|
151
|
+
## ๐ฏ Use Case Scenarios
|
|
152
|
+
|
|
153
|
+
### Scenario 1: Exploring a New Codebase
|
|
154
|
+
```bash
|
|
155
|
+
# First time seeing a large React app
|
|
156
|
+
node uml-generator.js https://github.com/company/new-project
|
|
157
|
+
|
|
158
|
+
# Explore in 3D:
|
|
159
|
+
# 1. See package structure (tall vs short buildings)
|
|
160
|
+
# 2. Find main entry points (highly connected nodes)
|
|
161
|
+
# 3. Identify isolated modules (few dependencies)
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
### Scenario 2: Architecture Review
|
|
165
|
+
```bash
|
|
166
|
+
# Generate UML before refactoring
|
|
167
|
+
node uml-generator.js . --output before-refactor.json
|
|
168
|
+
|
|
169
|
+
# After refactoring
|
|
170
|
+
node uml-generator.js . --output after-refactor.json
|
|
171
|
+
|
|
172
|
+
# Compare visually in SwarmDesk
|
|
173
|
+
```
|
|
174
|
+
|
|
175
|
+
### Scenario 3: Onboarding New Developers
|
|
176
|
+
```bash
|
|
177
|
+
# Generate visualization
|
|
178
|
+
node uml-generator.js . --output team-codebase.json
|
|
179
|
+
|
|
180
|
+
# Share the 3D view:
|
|
181
|
+
# - New devs can literally "walk through" the code
|
|
182
|
+
# - See how components connect
|
|
183
|
+
# - Identify which areas are most complex
|
|
184
|
+
```
|
|
185
|
+
|
|
186
|
+
## ๐ Troubleshooting
|
|
187
|
+
|
|
188
|
+
### Error: "Path does not exist"
|
|
189
|
+
```bash
|
|
190
|
+
# Make sure path is correct
|
|
191
|
+
ls /path/to/project # Verify it exists
|
|
192
|
+
|
|
193
|
+
# Use absolute paths if relative paths aren't working
|
|
194
|
+
node uml-generator.js /absolute/path/to/project
|
|
195
|
+
```
|
|
196
|
+
|
|
197
|
+
### Error: "git command not found"
|
|
198
|
+
Git metrics will be skipped if Git isn't installed. Generator will still work but won't include commit history.
|
|
199
|
+
|
|
200
|
+
### Warning: "Could not read package.json"
|
|
201
|
+
Non-critical. The generator will use directory name as project name.
|
|
202
|
+
|
|
203
|
+
### GitHub Clone Timeout
|
|
204
|
+
```bash
|
|
205
|
+
# For large repos, git clone might timeout
|
|
206
|
+
# Try cloning manually first:
|
|
207
|
+
git clone --depth 1 https://github.com/large/repo temp-repo
|
|
208
|
+
node uml-generator.js temp-repo
|
|
209
|
+
```
|
|
210
|
+
|
|
211
|
+
## ๐ Performance Tips
|
|
212
|
+
|
|
213
|
+
1. **Use `--exclude` aggressively**: Skip test files, generated code, vendor code
|
|
214
|
+
2. **Shallow clones for GitHub**: Automatically uses `--depth 1`
|
|
215
|
+
3. **Include only source dirs**: `--include "src"` is faster than analyzing everything
|
|
216
|
+
4. **Large repos**: Expect 5-10 seconds per 100 files
|
|
217
|
+
|
|
218
|
+
## ๐จ Customization Ideas
|
|
219
|
+
|
|
220
|
+
### Create Themed Outputs
|
|
221
|
+
```bash
|
|
222
|
+
# Frontend only
|
|
223
|
+
node uml-generator.js . --include "components,pages" --output frontend.json
|
|
224
|
+
|
|
225
|
+
# Backend only
|
|
226
|
+
node uml-generator.js . --include "api,services,models" --output backend.json
|
|
227
|
+
|
|
228
|
+
# Core utilities
|
|
229
|
+
node uml-generator.js . --include "utils,lib,helpers" --output core.json
|
|
230
|
+
```
|
|
231
|
+
|
|
232
|
+
### Compare Frameworks
|
|
233
|
+
```bash
|
|
234
|
+
# Visualize different framework patterns
|
|
235
|
+
node uml-generator.js https://github.com/react-project --output react-app.json
|
|
236
|
+
node uml-generator.js https://github.com/vue-project --output vue-app.json
|
|
237
|
+
node uml-generator.js https://github.com/angular-project --output angular-app.json
|
|
238
|
+
```
|
|
239
|
+
|
|
240
|
+
## ๐ Notes
|
|
241
|
+
|
|
242
|
+
- Output files can be 100KB-1MB for medium projects
|
|
243
|
+
- GitHub clones go to `.swarmdesk-temp/` and are auto-deleted
|
|
244
|
+
- Git metrics require the analyzed directory to be a git repository
|
|
245
|
+
- TypeScript support is basic (treats as JavaScript, no type extraction yet)
|
|
246
|
+
|
|
247
|
+
---
|
|
248
|
+
|
|
249
|
+
**๐งโโ๏ธ Happy Visualizing from the Mad Laboratory!**
|
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Mad Laboratory
|
|
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.
|
package/README.md
ADDED
|
@@ -0,0 +1,211 @@
|
|
|
1
|
+
# @madnessengineering/uml-generator
|
|
2
|
+
|
|
3
|
+
[](https://www.npmjs.com/package/@madnessengineering/uml-generator)
|
|
4
|
+
[](https://opensource.org/licenses/MIT)
|
|
5
|
+
[](https://nodejs.org)
|
|
6
|
+
|
|
7
|
+
**Interactive Text User Interface for generating UML city visualizations from any codebase!**
|
|
8
|
+
|
|
9
|
+
Standalone UML generator for SwarmDesk 3D code visualization - analyze any JavaScript/TypeScript codebase with TypeScript AST parsing, dependency graph analysis, and external library detection.
|
|
10
|
+
|
|
11
|
+
## ๐ฆ Installation
|
|
12
|
+
|
|
13
|
+
### Global Installation (Recommended)
|
|
14
|
+
```bash
|
|
15
|
+
npm install -g @madnessengineering/uml-generator
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
Then run anywhere:
|
|
19
|
+
```bash
|
|
20
|
+
swarmdesk-uml
|
|
21
|
+
# or
|
|
22
|
+
swarmdesk-uml /path/to/project
|
|
23
|
+
# or
|
|
24
|
+
swarmdesk-uml https://github.com/user/repo
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
### Local Installation
|
|
28
|
+
```bash
|
|
29
|
+
npm install --save-dev @madnessengineering/uml-generator
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
Add to your package.json scripts:
|
|
33
|
+
```json
|
|
34
|
+
{
|
|
35
|
+
"scripts": {
|
|
36
|
+
"visualize": "swarmdesk-uml . --output uml-data.json"
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
---
|
|
42
|
+
|
|
43
|
+
# ๐โก Features
|
|
44
|
+
|
|
45
|
+
Now featuring a beautiful interactive TUI mode alongside the classic CLI for maximum flexibility.
|
|
46
|
+
|
|
47
|
+
## โจ What's New - TUI Mode!
|
|
48
|
+
|
|
49
|
+
Launch an interactive terminal UI with menus, progress bars, and live previews:
|
|
50
|
+
- ๐จ **Beautiful ASCII art interface** with colored output
|
|
51
|
+
- ๐ **Smart project discovery** - automatically suggests projects from common locations
|
|
52
|
+
- โ๏ธ **Interactive configuration** - customize patterns with visual prompts
|
|
53
|
+
- ๐ **Live progress indicators** - watch your analysis happen in real-time
|
|
54
|
+
- ๐๏ธ **ASCII city preview** - see building heights before loading in 3D
|
|
55
|
+
- ๐ **Batch analysis** - analyze multiple projects in one session
|
|
56
|
+
|
|
57
|
+
## ๐ Quick Start
|
|
58
|
+
|
|
59
|
+
### Interactive Mode (TUI)
|
|
60
|
+
|
|
61
|
+
Simply run without arguments to launch the TUI:
|
|
62
|
+
```bash
|
|
63
|
+
cd uml-generator-cli
|
|
64
|
+
npm install
|
|
65
|
+
node uml-generator.js
|
|
66
|
+
# or
|
|
67
|
+
npm start
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
You'll see:
|
|
71
|
+
- A beautiful SWARMDESK banner
|
|
72
|
+
- Menu to select from suggested projects
|
|
73
|
+
- Options to browse local directories or clone GitHub repos
|
|
74
|
+
- Interactive configuration wizard
|
|
75
|
+
- Real-time analysis progress with spinners
|
|
76
|
+
- Results table with top complexity components
|
|
77
|
+
- ASCII art city preview!
|
|
78
|
+
|
|
79
|
+
### Classic CLI Mode
|
|
80
|
+
|
|
81
|
+
For scripts and automation, use with arguments:
|
|
82
|
+
```bash
|
|
83
|
+
# Analyze local directory
|
|
84
|
+
node uml-generator.js /path/to/project
|
|
85
|
+
|
|
86
|
+
# Analyze GitHub repo
|
|
87
|
+
node uml-generator.js https://github.com/facebook/react
|
|
88
|
+
|
|
89
|
+
# Custom output with options
|
|
90
|
+
node uml-generator.js . --output my-project.json --include "src,lib"
|
|
91
|
+
|
|
92
|
+
# Show help
|
|
93
|
+
node uml-generator.js --help
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
## ๐ฆ Installation
|
|
97
|
+
|
|
98
|
+
```bash
|
|
99
|
+
cd uml-generator-cli
|
|
100
|
+
npm install
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
Dependencies include:
|
|
104
|
+
- `inquirer` - Interactive prompts
|
|
105
|
+
- `ora` - Elegant terminal spinners
|
|
106
|
+
- `chalk` - Colorful output
|
|
107
|
+
- `cli-table3` - Beautiful ASCII tables
|
|
108
|
+
- `boxen` - Fancy boxes
|
|
109
|
+
- `gradient-string` - Rainbow gradients
|
|
110
|
+
- `figlet` - ASCII art text
|
|
111
|
+
|
|
112
|
+
## ๐ฎ Usage Modes
|
|
113
|
+
|
|
114
|
+
### 1. TUI Mode (No Arguments)
|
|
115
|
+
**Best for:** Interactive exploration, learning, one-off analyses
|
|
116
|
+
|
|
117
|
+
```bash
|
|
118
|
+
node uml-generator.js
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
Features:
|
|
122
|
+
- Project suggestions from common locations
|
|
123
|
+
- Visual menus and prompts
|
|
124
|
+
- Real-time progress feedback
|
|
125
|
+
- Results preview with complexity metrics
|
|
126
|
+
- ASCII art city visualization
|
|
127
|
+
- Multi-project batch processing
|
|
128
|
+
|
|
129
|
+
### 2. CLI Mode (With Arguments)
|
|
130
|
+
**Best for:** Automation, CI/CD, scripting
|
|
131
|
+
|
|
132
|
+
```bash
|
|
133
|
+
node uml-generator.js [path|url] [options]
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
See [UML-GENERATOR-README.md](./UML-GENERATOR-README.md) for full CLI documentation.
|
|
137
|
+
|
|
138
|
+
## ๐จ TUI Features Showcase
|
|
139
|
+
|
|
140
|
+
**Smart Project Discovery:**
|
|
141
|
+
- Scans `~/lab`, `~/projects`, `~/dev` for projects
|
|
142
|
+
- Filters for directories with `package.json`
|
|
143
|
+
- Shows suggested projects in menu
|
|
144
|
+
|
|
145
|
+
**Live Analysis Progress:**
|
|
146
|
+
- ๐ Scanning project files...
|
|
147
|
+
- ๐ Analyzing code structure... (23/150 files)
|
|
148
|
+
- ๐ Reading project metadata...
|
|
149
|
+
- โ
Analysis complete!
|
|
150
|
+
|
|
151
|
+
**Results Dashboard:**
|
|
152
|
+
```
|
|
153
|
+
โโโโโโโโโโโโโโโโโโโฌโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
|
154
|
+
โ Metric โ Value โ
|
|
155
|
+
โโโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโโโโโโโโโโโโค
|
|
156
|
+
โ Project Name โ my-awesome-project โ
|
|
157
|
+
โ Components โ 158 โ
|
|
158
|
+
โ Packages โ 19 โ
|
|
159
|
+
โโโโโโโโโโโโโโโโโโโดโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
|
160
|
+
|
|
161
|
+
๐ฅ Most Complex Components:
|
|
162
|
+
โโโโโโโโโโโโโโโโโโโโโโฌโโโโโโโโโโโโโฌโโโโโโโโโ
|
|
163
|
+
โ Component โ Complexity โ Lines โ
|
|
164
|
+
โโโโโโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโผโโโโโโโโโค
|
|
165
|
+
โ Dashboard โ 45 โ 523 โ
|
|
166
|
+
โ ProjectManager โ 38 โ 412 โ
|
|
167
|
+
โโโโโโโโโโโโโโโโโโโโโโดโโโโโโโโโโโโโดโโโโโโโโโ
|
|
168
|
+
|
|
169
|
+
๐๏ธ City Preview (Building Heights):
|
|
170
|
+
โโโโ โโโ โโ โโโโโ โโ โ โโโ โโโโ ...
|
|
171
|
+
(Taller = More Lines, Red = Complex, Green = Simple)
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
## ๐ Notes
|
|
175
|
+
|
|
176
|
+
### When to Use TUI vs Web UI
|
|
177
|
+
|
|
178
|
+
**Use TUI when:**
|
|
179
|
+
- Working in terminal environment
|
|
180
|
+
- Analyzing private/local projects
|
|
181
|
+
- Batch processing multiple repos
|
|
182
|
+
- CI/CD automation (CLI mode)
|
|
183
|
+
- No browser available
|
|
184
|
+
|
|
185
|
+
**Use Web UI (SwarmDesk) when:**
|
|
186
|
+
- Want full 3D visualization
|
|
187
|
+
- Need to explore dependencies interactively
|
|
188
|
+
- Presenting to others
|
|
189
|
+
- Want to navigate the code city
|
|
190
|
+
|
|
191
|
+
### Compatibility
|
|
192
|
+
|
|
193
|
+
- **TUI Mode:** Requires TTY (terminal), won't work in pipes
|
|
194
|
+
- **CLI Mode:** Works anywhere, perfect for scripts
|
|
195
|
+
- Auto-detects and falls back gracefully
|
|
196
|
+
|
|
197
|
+
## ๐ฎ Advanced Features
|
|
198
|
+
|
|
199
|
+
- **GitHub cloning:** Automatically clones, analyzes, and cleans up temp repos
|
|
200
|
+
- **Git metrics:** Tracks commit history and file age
|
|
201
|
+
- **Dependency analysis:** Maps import relationships
|
|
202
|
+
- **React-aware:** Special handling for components
|
|
203
|
+
- **Multi-project:** Analyze multiple projects in one session (TUI)
|
|
204
|
+
|
|
205
|
+
## ๐งโโ๏ธ From the Mad Laboratory
|
|
206
|
+
|
|
207
|
+
This TUI edition brings the power of SwarmDesk code visualization to your terminal. Experience the thrill of watching your codebase transform into data, then load it in SwarmDesk for the full 3D city experience!
|
|
208
|
+
|
|
209
|
+
---
|
|
210
|
+
|
|
211
|
+
See [EXAMPLES.md](./EXAMPLES.md) for more usage examples.
|
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
# ๐โก SwarmDesk UML Generator
|
|
2
|
+
|
|
3
|
+
Standalone UML generator that analyzes any codebase and creates JSON data for 3D visualization in SwarmDesk!
|
|
4
|
+
|
|
5
|
+
## โจ Features
|
|
6
|
+
|
|
7
|
+
- ๐ **Analyze Local Repositories**: Point it at any project on your machine
|
|
8
|
+
- ๐ **GitHub Support**: Clone and analyze any public GitHub repository
|
|
9
|
+
- ๐ **Git Metrics**: Track commit history, contributors, and file age
|
|
10
|
+
- ๐ **Dependency Analysis**: Automatically detect imports and relationships
|
|
11
|
+
- ๐ฏ **React-Aware**: Special handling for React components
|
|
12
|
+
- ๐จ **3D Ready**: Generates UML JSON that SwarmDesk can visualize
|
|
13
|
+
|
|
14
|
+
## ๐ Quick Start
|
|
15
|
+
|
|
16
|
+
### Installation
|
|
17
|
+
|
|
18
|
+
```bash
|
|
19
|
+
cd SwarmDesk
|
|
20
|
+
npm install
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
### Usage Examples
|
|
24
|
+
|
|
25
|
+
**Analyze local directory:**
|
|
26
|
+
```bash
|
|
27
|
+
node uml-generator.js /path/to/your/project
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
**Analyze current directory:**
|
|
31
|
+
```bash
|
|
32
|
+
node uml-generator.js .
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
**Analyze GitHub repository:**
|
|
36
|
+
```bash
|
|
37
|
+
node uml-generator.js https://github.com/facebook/react
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
**Custom output file:**
|
|
41
|
+
```bash
|
|
42
|
+
node uml-generator.js . --output my-project-uml.json
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
**Filter specific directories:**
|
|
46
|
+
```bash
|
|
47
|
+
node uml-generator.js . --include "src,components" --exclude "test,dist,node_modules"
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
## ๐ Command Line Options
|
|
51
|
+
|
|
52
|
+
| Option | Description | Example |
|
|
53
|
+
|--------|-------------|---------|
|
|
54
|
+
| `[path]` | Local path or GitHub URL | `./my-project` or `https://github.com/user/repo` |
|
|
55
|
+
| `--output` | Output JSON file path | `--output data/my-uml.json` |
|
|
56
|
+
| `--include` | Comma-separated directories to include | `--include "src,lib,components"` |
|
|
57
|
+
| `--exclude` | Comma-separated patterns to exclude | `--exclude "test,dist,build"` |
|
|
58
|
+
|
|
59
|
+
## ๐ Output Format
|
|
60
|
+
|
|
61
|
+
The generator creates a JSON file compatible with SwarmDesk's 3D visualization:
|
|
62
|
+
|
|
63
|
+
```json
|
|
64
|
+
{
|
|
65
|
+
"version": "6.0",
|
|
66
|
+
"generated": "2025-10-30T...",
|
|
67
|
+
"project": {
|
|
68
|
+
"name": "my-project",
|
|
69
|
+
"description": "Project description",
|
|
70
|
+
"language": "JavaScript"
|
|
71
|
+
},
|
|
72
|
+
"packages": [...],
|
|
73
|
+
"classes": [
|
|
74
|
+
{
|
|
75
|
+
"id": "component_abc123",
|
|
76
|
+
"name": "MyComponent",
|
|
77
|
+
"type": "class",
|
|
78
|
+
"subtype": "react_component",
|
|
79
|
+
"filePath": "src/components/MyComponent.js",
|
|
80
|
+
"methods": [...],
|
|
81
|
+
"dependencies": ["Header", "Footer"],
|
|
82
|
+
"metrics": {
|
|
83
|
+
"lines": 150,
|
|
84
|
+
"complexity": 12,
|
|
85
|
+
"methodCount": 5
|
|
86
|
+
},
|
|
87
|
+
"gitMetrics": {
|
|
88
|
+
"commitCount": 23,
|
|
89
|
+
"lastCommit": {...}
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
]
|
|
93
|
+
}
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
## ๐ฎ Using in SwarmDesk
|
|
97
|
+
|
|
98
|
+
1. Generate UML for your project:
|
|
99
|
+
```bash
|
|
100
|
+
node uml-generator.js ~/my-project --output my-project-uml.json
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
2. Copy the output file to SwarmDesk data directory:
|
|
104
|
+
```bash
|
|
105
|
+
cp my-project-uml.json ../public/data/
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
3. Load in SwarmDesk by pressing `I` key to cycle data sources, or update the URL:
|
|
109
|
+
```
|
|
110
|
+
http://localhost:3000?uml=my-project-uml.json
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
## ๐งช Testing
|
|
114
|
+
|
|
115
|
+
Test the generator on itself:
|
|
116
|
+
```bash
|
|
117
|
+
npm test
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
## ๐ง Supported File Types
|
|
121
|
+
|
|
122
|
+
- `.js` - JavaScript
|
|
123
|
+
- `.jsx` - React JSX
|
|
124
|
+
- `.ts` - TypeScript
|
|
125
|
+
- `.tsx` - TypeScript React
|
|
126
|
+
- `.mjs` - ES Modules
|
|
127
|
+
|
|
128
|
+
## ๐ฆ Default Include/Exclude Patterns
|
|
129
|
+
|
|
130
|
+
**Included by default:**
|
|
131
|
+
- `src/`, `lib/`, `components/`, `pages/`, `utils/`, `hooks/`, `services/`
|
|
132
|
+
|
|
133
|
+
**Excluded by default:**
|
|
134
|
+
- `node_modules/`, `dist/`, `build/`, `.git/`, `coverage/`, `test/`, `__tests__/`
|
|
135
|
+
|
|
136
|
+
## ๐ฏ Use Cases
|
|
137
|
+
|
|
138
|
+
1. **Explore New Codebases**: Quickly visualize unfamiliar projects in 3D
|
|
139
|
+
2. **Architecture Review**: See dependency relationships and package structure
|
|
140
|
+
3. **Refactoring**: Identify tightly coupled components
|
|
141
|
+
4. **Documentation**: Generate visual documentation of code structure
|
|
142
|
+
5. **Complexity Analysis**: Spot files that might need refactoring
|
|
143
|
+
|
|
144
|
+
## ๐ฎ Future Enhancements
|
|
145
|
+
|
|
146
|
+
- [ ] TypeScript type extraction
|
|
147
|
+
- [ ] JSDoc comment parsing
|
|
148
|
+
- [ ] Test coverage integration
|
|
149
|
+
- [ ] Multiple project comparison
|
|
150
|
+
- [ ] Private GitHub repo support (with tokens)
|
|
151
|
+
- [ ] GitLab/Bitbucket support
|
|
152
|
+
|
|
153
|
+
## ๐งโโ๏ธ Mad Laboratory Notes
|
|
154
|
+
|
|
155
|
+
This tool is part of the Madness Interactive workshop - built for rapid codebase exploration and visualization. We're pushing the boundaries of what's possible with 3D code visualization!
|
|
156
|
+
|
|
157
|
+
**Pro Tips:**
|
|
158
|
+
- Use with large repos to see amazing 3D cities
|
|
159
|
+
- GitHub URLs automatically clone to `.swarmdesk-temp/` and cleanup after
|
|
160
|
+
- Git metrics work best with repositories that have commit history
|
|
161
|
+
- Combine with SwarmDesk's F7/F8 keys to see dependency arrows
|
|
162
|
+
|
|
163
|
+
## ๐ License
|
|
164
|
+
|
|
165
|
+
MIT - Part of the Madness Interactive Laboratory
|
package/package.json
ADDED
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@madnessengineering/uml-generator",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Standalone UML generator for SwarmDesk 3D code visualization - analyze any JavaScript/TypeScript codebase",
|
|
5
|
+
"main": "uml-generator.js",
|
|
6
|
+
"bin": {
|
|
7
|
+
"swarmdesk-uml": "./uml-generator.js"
|
|
8
|
+
},
|
|
9
|
+
"scripts": {
|
|
10
|
+
"start": "node uml-generator.js",
|
|
11
|
+
"tui": "node tui.js",
|
|
12
|
+
"generate": "node uml-generator.js",
|
|
13
|
+
"test": "node uml-generator.js . --output test-output.json"
|
|
14
|
+
},
|
|
15
|
+
"keywords": [
|
|
16
|
+
"uml",
|
|
17
|
+
"code-visualization",
|
|
18
|
+
"3d",
|
|
19
|
+
"swarmdesk",
|
|
20
|
+
"code-analysis",
|
|
21
|
+
"ast",
|
|
22
|
+
"typescript",
|
|
23
|
+
"javascript",
|
|
24
|
+
"react",
|
|
25
|
+
"architecture",
|
|
26
|
+
"dependency-graph",
|
|
27
|
+
"static-analysis",
|
|
28
|
+
"cli",
|
|
29
|
+
"tui"
|
|
30
|
+
],
|
|
31
|
+
"author": "Mad Laboratory <contact@madnessinteractive.cc>",
|
|
32
|
+
"license": "MIT",
|
|
33
|
+
"homepage": "https://github.com/MadTinker/swarmdesk-uml-generator#readme",
|
|
34
|
+
"repository": {
|
|
35
|
+
"type": "git",
|
|
36
|
+
"url": "https://github.com/MadTinker/swarmdesk-uml-generator.git"
|
|
37
|
+
},
|
|
38
|
+
"bugs": {
|
|
39
|
+
"url": "https://github.com/MadTinker/swarmdesk-uml-generator/issues"
|
|
40
|
+
},
|
|
41
|
+
"files": [
|
|
42
|
+
"uml-generator.js",
|
|
43
|
+
"tui.js",
|
|
44
|
+
"README.md",
|
|
45
|
+
"UML-GENERATOR-README.md",
|
|
46
|
+
"EXAMPLES.md",
|
|
47
|
+
"LICENSE"
|
|
48
|
+
],
|
|
49
|
+
"dependencies": {
|
|
50
|
+
"boxen": "^5.1.2",
|
|
51
|
+
"chalk": "^4.1.2",
|
|
52
|
+
"cli-table3": "^0.6.3",
|
|
53
|
+
"comment-parser": "^1.4.1",
|
|
54
|
+
"figlet": "^1.6.0",
|
|
55
|
+
"gradient-string": "^2.0.2",
|
|
56
|
+
"inquirer": "^8.2.5",
|
|
57
|
+
"ora": "^5.4.1",
|
|
58
|
+
"typescript": "^5.9.3"
|
|
59
|
+
},
|
|
60
|
+
"engines": {
|
|
61
|
+
"node": ">=14.0.0"
|
|
62
|
+
}
|
|
63
|
+
}
|