hermex 1.1.1-beta.1 → 1.1.2
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/README.md +131 -131
- package/dist/cli.js +159 -239
- package/dist/cli.js.map +1 -1
- package/package.json +4 -1
package/README.md
CHANGED
|
@@ -1,149 +1,162 @@
|
|
|
1
|
-
#
|
|
1
|
+
# hermex
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
SWC-based AST parser for analyzing code and React component usage patterns across entire codebases
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
## 🚀 Quick Start
|
|
5
|
+
## Quick Start
|
|
8
6
|
|
|
9
7
|
```bash
|
|
10
|
-
# No installation required - use npx
|
|
11
|
-
npx hermex scan
|
|
8
|
+
# No installation required - use npx (scans current directory)
|
|
9
|
+
npx hermex scan
|
|
12
10
|
|
|
13
11
|
# Or install globally
|
|
14
12
|
npm install -g hermex
|
|
15
|
-
hermex scan
|
|
13
|
+
hermex scan
|
|
16
14
|
|
|
17
|
-
#
|
|
18
|
-
npm install hermex
|
|
15
|
+
# Scan specific directory
|
|
19
16
|
npx hermex scan "src/**/*.tsx"
|
|
20
17
|
```
|
|
21
18
|
|
|
22
|
-
##
|
|
23
|
-
- Node.js 24+
|
|
19
|
+
## Requirements
|
|
24
20
|
|
|
25
|
-
|
|
21
|
+
- Node.js 20+
|
|
22
|
+
|
|
23
|
+
## Key Features
|
|
26
24
|
|
|
27
25
|
- **Fast SWC-based Parsing**: Lightning-fast static analysis using SWC's Rust-based parser
|
|
28
|
-
- **Pattern Detection**: Identifies
|
|
29
|
-
- Direct imports
|
|
26
|
+
- **Comprehensive Pattern Detection**: Identifies 10+ React usage patterns including:
|
|
27
|
+
- Direct imports (default, named, namespace, aliased)
|
|
28
|
+
- JSX element usage
|
|
30
29
|
- Variable assignments and destructuring
|
|
31
|
-
- Conditional usage
|
|
32
|
-
-
|
|
33
|
-
-
|
|
34
|
-
-
|
|
30
|
+
- Conditional usage (ternary operators)
|
|
31
|
+
- Collection mappings (arrays and objects)
|
|
32
|
+
- Lazy and dynamic imports
|
|
33
|
+
- Advanced patterns (HOC, memo, forwardRef, portals)
|
|
35
34
|
- **Version Tracking**: Components reported with exact package versions from lockfiles
|
|
36
35
|
- **Multi-Lockfile Support**: Parses package-lock.json, yarn.lock, and pnpm-lock.yaml
|
|
37
|
-
- **Flexible Output**:
|
|
38
|
-
- **Complexity Scoring**: Categorizes usage patterns by complexity
|
|
36
|
+
- **Flexible Output**: Table and chart visualization formats
|
|
39
37
|
- **Zero Configuration**: Works out of the box with sensible defaults
|
|
40
38
|
|
|
41
|
-
##
|
|
42
|
-
|
|
43
|
-
### `scan` Command
|
|
44
|
-
|
|
45
|
-
Scan and analyze local files for React component usage patterns.
|
|
39
|
+
## Installation
|
|
46
40
|
|
|
47
41
|
```bash
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
#### Arguments
|
|
42
|
+
# Global installation
|
|
43
|
+
npm install -g hermex
|
|
52
44
|
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
| `[pattern]` | Glob pattern for files to analyze | `**/*.{tsx,jsx,ts,js}` |
|
|
45
|
+
# Or with pnpm
|
|
46
|
+
pnpm add -g hermex
|
|
56
47
|
|
|
57
|
-
|
|
48
|
+
# Or with yarn
|
|
49
|
+
yarn global add hermex
|
|
50
|
+
```
|
|
58
51
|
|
|
59
|
-
|
|
60
|
-
|--------|-------------|--------|---------|
|
|
61
|
-
| `--ignore <pattern>` | Glob pattern for files to ignore | Any glob pattern | `**/node_modules/**`, `**/dist/**`, `**/build/**` |
|
|
62
|
-
| `--verbose` | Show detailed file-by-file analysis | `true`/`false` | `false` |
|
|
63
|
-
| `--summary [mode]` | Show summary statistics | `log`, `false` | `log` |
|
|
64
|
-
| `--details` | Show detailed pattern counts | `true`/`false` | `false` |
|
|
65
|
-
| `--top-components [mode]` | Show top components | `log`, `table`, `chart` | `log` |
|
|
66
|
-
| `--components-usage [mode]` | Show components usage table/chart | `table`, `chart` | `table` |
|
|
67
|
-
| `--patterns [mode]` | Show patterns table/chart | `table`, `chart` | `table` |
|
|
52
|
+
## CLI Usage
|
|
68
53
|
|
|
69
|
-
|
|
54
|
+
### Main CLI
|
|
70
55
|
|
|
71
56
|
```bash
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
# Chart visualization
|
|
85
|
-
hermex scan "src/**/*.tsx" --top-components chart --components-usage chart
|
|
86
|
-
|
|
87
|
-
# Detailed analysis
|
|
88
|
-
hermex scan "src/**/*.tsx" --details --verbose
|
|
57
|
+
Usage: hermex [options] [command]
|
|
58
|
+
|
|
59
|
+
Analyze React component usage patterns in your codebase
|
|
60
|
+
|
|
61
|
+
Options:
|
|
62
|
+
-V, --version output the version number
|
|
63
|
+
-h, --help display help for command
|
|
64
|
+
|
|
65
|
+
Commands:
|
|
66
|
+
scan [options] [pattern] Scan and analyze local files
|
|
67
|
+
help [command] display help for command
|
|
89
68
|
```
|
|
90
69
|
|
|
91
|
-
|
|
70
|
+
### Scan Command
|
|
92
71
|
|
|
93
|
-
|
|
94
|
-
```
|
|
95
|
-
[SUMMARY] Analysis completed successfully in 0.1s
|
|
96
|
-
[SUMMARY] Files analyzed: 42
|
|
97
|
-
[SUMMARY] Total imports: 156
|
|
98
|
-
[SUMMARY] Total components: 38
|
|
99
|
-
```
|
|
72
|
+
The `scan` command analyzes local files for React component usage patterns.
|
|
100
73
|
|
|
101
|
-
|
|
74
|
+
```bash
|
|
75
|
+
Usage: hermex scan [options] [pattern]
|
|
76
|
+
|
|
77
|
+
Scan and analyze local files
|
|
78
|
+
|
|
79
|
+
Arguments:
|
|
80
|
+
pattern Glob pattern for files to analyze (defaults to
|
|
81
|
+
current directory recursively) (default:
|
|
82
|
+
"**/*.{tsx,jsx,ts,js}")
|
|
83
|
+
|
|
84
|
+
Options:
|
|
85
|
+
--ignore <pattern> Glob pattern for files to ignore (default:
|
|
86
|
+
["**/node_modules/**","**/dist/**","**/build/**"])
|
|
87
|
+
--allow-packages <pattern> Pattern for what packages to scan (default:
|
|
88
|
+
["**"])
|
|
89
|
+
--ignore-packages <pattern> Pattern for what packages to ignore (default: [])
|
|
90
|
+
--no-summary Hide summary
|
|
91
|
+
--components [mode] Show components table/chart (table, chart)
|
|
92
|
+
(default: "table")
|
|
93
|
+
--no-components Do not show components
|
|
94
|
+
--packages [mode] Show packages table/chart (table, chart)
|
|
95
|
+
(default: "table")
|
|
96
|
+
--no-packages Do not show packages
|
|
97
|
+
--patterns [mode] Show patterns table/chart (table, chart)
|
|
98
|
+
(default: "table")
|
|
99
|
+
--no-patterns Do not show patterns
|
|
100
|
+
-h, --help display help for command
|
|
102
101
|
```
|
|
103
|
-
🏆 Top Components
|
|
104
102
|
|
|
105
|
-
|
|
106
|
-
[TOP-COMPONENTS] 🥈 2. Card from @design-system/card: 32 uses
|
|
107
|
-
[TOP-COMPONENTS] 🥉 3. Input from @design-system/input: 28 uses
|
|
108
|
-
```
|
|
103
|
+
## Example Output
|
|
109
104
|
|
|
110
|
-
|
|
111
|
-
```
|
|
112
|
-
⚛️ Components Usage
|
|
113
|
-
|
|
114
|
-
┌────────────┬──────────────────────────┬─────────┬───────┐
|
|
115
|
-
│ Component │ Source │ Version │ Count │
|
|
116
|
-
├────────────┼──────────────────────────┼─────────┼───────┤
|
|
117
|
-
│ Button │ @design-system/button │ 2.1.5 │ 45 │
|
|
118
|
-
│ Card │ @design-system/card │ 1.8.3 │ 32 │
|
|
119
|
-
│ Input │ @design-system/input │ 2.0.1 │ 28 │
|
|
120
|
-
└────────────┴──────────────────────────┴─────────┴───────┘
|
|
121
|
-
```
|
|
105
|
+
Running a basic scan (uses default pattern `**/*.{tsx,jsx,ts,js}`):
|
|
122
106
|
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
│
|
|
136
|
-
|
|
137
|
-
|
|
107
|
+
```bash
|
|
108
|
+
📦 Packages
|
|
109
|
+
|
|
110
|
+
No packages found
|
|
111
|
+
|
|
112
|
+
⚛️ Components
|
|
113
|
+
|
|
114
|
+
No external components found
|
|
115
|
+
|
|
116
|
+
🔍 Code Patterns
|
|
117
|
+
|
|
118
|
+
┌──────────────────────┬───────┐
|
|
119
|
+
│ Pattern │ Count │
|
|
120
|
+
├──────────────────────┼───────┤
|
|
121
|
+
│ Named Imports │ 126 │
|
|
122
|
+
├──────────────────────┼───────┤
|
|
123
|
+
│ Default Imports │ 49 │
|
|
124
|
+
├──────────────────────┼───────┤
|
|
125
|
+
│ JSX Usage │ 45 │
|
|
126
|
+
├──────────────────────┼───────┤
|
|
127
|
+
│ Object Mappings │ 19 │
|
|
128
|
+
├──────────────────────┼───────┤
|
|
129
|
+
│ Variable Assignments │ 9 │
|
|
130
|
+
├──────────────────────┼───────┤
|
|
131
|
+
│ Conditional Usage │ 7 │
|
|
132
|
+
├──────────────────────┼───────┤
|
|
133
|
+
│ Namespace Imports │ 4 │
|
|
134
|
+
├──────────────────────┼───────┤
|
|
135
|
+
│ Aliased Imports │ 4 │
|
|
136
|
+
├──────────────────────┼───────┤
|
|
137
|
+
│ Destructuring │ 2 │
|
|
138
|
+
├──────────────────────┼───────┤
|
|
139
|
+
│ Portal Usage │ 1 │
|
|
140
|
+
└──────────────────────┴───────┘
|
|
141
|
+
|
|
142
|
+
Total: 266 patterns detected
|
|
143
|
+
|
|
144
|
+
📊 Summary
|
|
145
|
+
|
|
146
|
+
┌─────────────────────┬───────┐
|
|
147
|
+
│ Metric │ Count │
|
|
148
|
+
├─────────────────────┼───────┤
|
|
149
|
+
│ Files Analyzed │ 45 │
|
|
150
|
+
├─────────────────────┼───────┤
|
|
151
|
+
│ External Packages │ 0 │
|
|
152
|
+
├─────────────────────┼───────┤
|
|
153
|
+
│ External Components │ 0 │
|
|
154
|
+
├─────────────────────┼───────┤
|
|
155
|
+
│ Total Usages │ 0 │
|
|
156
|
+
└─────────────────────┴───────┘
|
|
138
157
|
```
|
|
139
158
|
|
|
140
|
-
##
|
|
141
|
-
|
|
142
|
-
- **[Examples](./docs/EXAMPLES.md)** - Comprehensive examples and command usage
|
|
143
|
-
- **[Patterns Guide](./docs/PATTERNS.md)** - All detectable React usage patterns
|
|
144
|
-
- **[Project Milestones](./docs/MILESTONES.md)** - Roadmap and future features
|
|
145
|
-
|
|
146
|
-
## 🎯 Use Cases
|
|
159
|
+
## Use Cases
|
|
147
160
|
|
|
148
161
|
1. **Dependency Audits** - Understand library usage before migrations
|
|
149
162
|
2. **Version Tracking** - Know exactly which component versions are in use
|
|
@@ -153,26 +166,13 @@ hermex scan "src/**/*.tsx" --details --verbose
|
|
|
153
166
|
6. **Team Insights** - Understand how your team uses component libraries
|
|
154
167
|
7. **Documentation** - Generate usage reports for component library documentation
|
|
155
168
|
|
|
156
|
-
##
|
|
157
|
-
|
|
158
|
-
Hermex detects 16+ React component usage patterns with varying complexity levels:
|
|
169
|
+
## Documentation
|
|
159
170
|
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
| Direct Import & Usage | 1/10 | `import Button from '@lib/button'` |
|
|
163
|
-
| Named Import with Alias | 2/10 | `import { Button as Btn } from '@lib'` |
|
|
164
|
-
| Variable Assignment | 3/10 | `const MyButton = Button` |
|
|
165
|
-
| Destructuring Usage | 4/10 | `const { Button } = Foundation` |
|
|
166
|
-
| Object Mapping | 5/10 | `const map = { btn: Button }` |
|
|
167
|
-
| Lazy Loading | 6/10 | `lazy(() => import('@lib/button'))` |
|
|
168
|
-
| Dynamic Import | 7/10 | `await import('@lib/button')` |
|
|
169
|
-
| HOC Wrapping | 7/10 | `withWrapper(Button)` |
|
|
170
|
-
| Context Integration | 7/10 | `useContext(ComponentContext)` |
|
|
171
|
-
| Portal Usage | 8/10 | `createPortal(<Button />)` |
|
|
171
|
+
- **[Examples](./docs/examples.md)** - Comprehensive examples and command usage
|
|
172
|
+
- **[Patterns Guide](./docs/patterns.md)** - All detectable React usage patterns
|
|
172
173
|
|
|
173
|
-
|
|
174
|
+
## Tech Stack
|
|
174
175
|
|
|
175
|
-
## 🛠️ Tech Stack
|
|
176
176
|
- **Runtime**: Node.js 24
|
|
177
177
|
- **Parser**: [@swc/core](https://swc.rs/)
|
|
178
178
|
- **CLI**: [Commander.js](https://github.com/tj/commander.js)
|
|
@@ -182,16 +182,16 @@ See the [Patterns Guide](./docs/PATTERNS.md) for complete details.
|
|
|
182
182
|
- **Linter**: [oxlint](https://oxc-project.github.io/)
|
|
183
183
|
- **Tests**: [Vitest](https://vitest.dev/)
|
|
184
184
|
|
|
185
|
-
##
|
|
185
|
+
## Contributing
|
|
186
186
|
|
|
187
187
|
Contributions are welcome! Please read our [Contributing Guide](./CONTRIBUTING.md) for details.
|
|
188
188
|
|
|
189
|
-
##
|
|
189
|
+
## License
|
|
190
190
|
|
|
191
191
|
MIT License - see [LICENSE.md](./LICENSE.md)
|
|
192
192
|
|
|
193
|
-
##
|
|
193
|
+
## Links
|
|
194
194
|
|
|
195
|
-
- [GitHub Repository](https://github.com/Gallevy/hermex)
|
|
195
|
+
- [GitHub Repository](https://github.com/Gallevy/hermex.git)
|
|
196
196
|
- [npm Package](https://www.npmjs.com/package/hermex)
|
|
197
|
-
- [Report Issues](https://github.com/Gallevy/hermex/issues)
|
|
197
|
+
- [Report Issues](https://github.com/Gallevy/hermex.git/issues)
|