@dawudesign/node-hexa-cli 0.2.4 → 0.2.5

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.
Files changed (2) hide show
  1. package/README.md +38 -108
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -2,17 +2,16 @@
2
2
 
3
3
  > Scaffold and enforce **NestJS Hexagonal DDD** architecture from the command line.
4
4
 
5
- **node-hexa** automates the repetitive parts of clean architecture in NestJS:
6
-
7
- - **Scaffold** — generates a full bounded context with dependency injection pre-wired, in one command
8
- - **Enforce** — statically analyzes your TypeScript source and reports architecture violations
9
- - **Document** — exports a Mermaid diagram and architecture report as Markdown or SVG
5
+ - **Scaffold** generate a full NestJS project or bounded context in one command
6
+ - **Enforce** — statically analyze your TypeScript source and report architecture violations
7
+ - **Document** — export a Mermaid diagram and architecture report
10
8
 
11
9
  ---
12
10
 
13
11
  ## Requirements
14
12
 
15
- - **Node.js ≥ 20**
13
+ - Node.js ≥ 20
14
+ - npm or pnpm
16
15
 
17
16
  ---
18
17
 
@@ -22,37 +21,13 @@
22
21
  npm install -g @dawudesign/node-hexa-cli
23
22
  ```
24
23
 
25
- Verify:
26
-
27
- ```bash
28
- node-hexa --version
29
- node-hexa --help
30
- ```
31
-
32
- ---
33
-
34
- ## Quickstart
35
-
36
- ```bash
37
- # 1. Create a new NestJS Hexagonal DDD project
38
- node-hexa init my-app
39
- cd my-app
40
-
41
- # 2. Start the server
42
- pnpm start:dev
43
-
44
- # 3. Verify architecture is clean
45
- node-hexa check .
46
- # ✓ Architecture check passed
47
- ```
48
-
49
24
  ---
50
25
 
51
26
  ## Commands
52
27
 
53
28
  ### `init`
54
29
 
55
- Creates a new NestJS project with the complete Hexagonal DDD structure.
30
+ Create a new NestJS project with the full Hexagonal DDD structure.
56
31
 
57
32
  ```bash
58
33
  node-hexa init <name>
@@ -60,11 +35,13 @@ node-hexa init <name>
60
35
 
61
36
  ```bash
62
37
  node-hexa init my-app
38
+ cd my-app
39
+ pnpm start:dev
63
40
  ```
64
41
 
65
- Generates:
42
+ Generated structure:
66
43
 
67
- ```text
44
+ ```
68
45
  my-app/
69
46
  ├── src/
70
47
  │ ├── main.ts
@@ -85,87 +62,55 @@ my-app/
85
62
 
86
63
  ---
87
64
 
88
- ### `generate context`
65
+ ### `generate`
89
66
 
90
- Generates a complete bounded context inside an existing NestJS project.
67
+ Generate scaffolding inside an existing project.
91
68
 
92
69
  ```bash
93
70
  node-hexa generate context <name>
71
+ node-hexa generate usecase <name> <context>
72
+ node-hexa generate aggregate <name> <context>
94
73
  ```
95
74
 
96
75
  ```bash
97
- cd my-app
76
+ # New bounded context
98
77
  node-hexa generate context orders
99
- # ✓ Context 'orders' generated at src/contexts/orders/
100
- # → Import OrdersModule in your AppModule to activate it.
101
- ```
102
-
103
- ---
104
-
105
- ### `generate usecase`
106
-
107
- Generates a use case with its DTO and Vitest spec inside an existing bounded context.
108
-
109
- ```bash
110
- node-hexa generate usecase <name> <context>
111
- ```
112
78
 
113
- ```bash
79
+ # Use case inside a context
114
80
  node-hexa generate usecase delete-user iam
115
- # ✓ Use case 'delete-user' generated in context 'iam'
116
- ```
117
-
118
- Generated files:
119
-
120
- ```text
121
- src/contexts/iam/application/use-cases/
122
- ├── delete-user.usecase.ts
123
- ├── delete-user.dto.ts
124
- └── delete-user.usecase.spec.ts
125
- ```
126
-
127
- ---
128
-
129
- ### `generate aggregate`
130
-
131
- Generates a full DDD aggregate (entity, value object, port, use case, in-memory repository, HTTP controller, NestJS module).
132
-
133
- ```bash
134
- node-hexa generate aggregate <name> <context>
135
- ```
136
81
 
137
- ```bash
82
+ # Full DDD aggregate (entity, port, use case, controller, repository)
138
83
  node-hexa generate aggregate product catalog
139
- # ✓ Aggregate 'product' generated in context 'catalog'
140
84
  ```
141
85
 
142
86
  ---
143
87
 
144
88
  ### `check`
145
89
 
146
- Checks architecture rules exits `0` if clean, `1` if violations found. Designed for CI/CD.
90
+ Check architecture violations. Exits `0` if clean, `1` if violations found. Designed for CI.
147
91
 
148
92
  ```bash
149
- node-hexa check <path> [--watch]
93
+ node-hexa check <path>
94
+ node-hexa check <path> --watch
150
95
  ```
151
96
 
152
97
  ```bash
153
98
  # One-shot (CI)
154
99
  node-hexa check .
155
100
 
156
- # Watch mode (development)
101
+ # Watch mode
157
102
  node-hexa check . --watch
158
103
  ```
159
104
 
160
105
  Output:
161
106
 
162
- ```text
107
+ ```
163
108
  ✓ Architecture check passed
164
109
  ```
165
110
 
166
111
  or:
167
112
 
168
- ```text
113
+ ```
169
114
  ✗ Architecture violations detected
170
115
 
171
116
  [CRITICAL] Domain must not depend on infrastructure → UserEntity
@@ -182,27 +127,19 @@ Full analysis: layers, violations, bounded contexts, Mermaid diagram, and score.
182
127
  node-hexa analyze <path>
183
128
  ```
184
129
 
185
- ```bash
186
- node-hexa analyze .
187
- ```
188
-
189
130
  ---
190
131
 
191
132
  ### `list`
192
133
 
193
- Lists all bounded contexts and their components.
134
+ List all bounded contexts and their components.
194
135
 
195
136
  ```bash
196
137
  node-hexa list <path>
197
138
  ```
198
139
 
199
- ```bash
200
- node-hexa list .
201
- ```
202
-
203
140
  Output:
204
141
 
205
- ```text
142
+ ```
206
143
  Bounded Contexts (2)
207
144
 
208
145
  IAM
@@ -220,27 +157,21 @@ Bounded Contexts (2)
220
157
 
221
158
  ### `docs`
222
159
 
223
- Generates an `architecture.md` at the project root with the Mermaid diagram, violations, and score.
160
+ Generate an `architecture.md` at the project root with the Mermaid diagram and violations.
224
161
 
225
162
  ```bash
226
163
  node-hexa docs <path>
227
164
  ```
228
165
 
229
- ```bash
230
- node-hexa docs .
231
- # Architecture documentation generated: ./architecture.md
232
- ```
233
-
234
166
  ---
235
167
 
236
168
  ### `graph`
237
169
 
238
- Generates an `architecture.svg` dependency graph (requires `@mermaid-js/mermaid-cli`).
170
+ Generate an `architecture.svg` dependency graph (requires `@mermaid-js/mermaid-cli`).
239
171
 
240
172
  ```bash
241
173
  npm install -g @mermaid-js/mermaid-cli
242
- node-hexa graph .
243
- # Architecture graph generated: ./architecture.svg
174
+ node-hexa graph <path>
244
175
  ```
245
176
 
246
177
  ---
@@ -258,8 +189,8 @@ node-hexa graph .
258
189
  ```
259
190
 
260
191
  | Key | Type | Default | Description |
261
- | --- | --- | --- | --- |
262
- | `architecture` | `string` | required | Architecture type — `hexagonal-ddd` |
192
+ |-----|------|---------|-------------|
193
+ | `architecture` | `string` | `"hexagonal-ddd"` | Architecture type |
263
194
  | `strict` | `boolean` | `true` | `false` silences `MEDIUM` violations |
264
195
  | `contextsDir` | `string` | `"src/contexts"` | Path to bounded contexts directory |
265
196
 
@@ -267,17 +198,16 @@ node-hexa graph .
267
198
 
268
199
  ## Violation rules
269
200
 
270
- | Violation | Severity | Score penalty |
271
- | --- | --- | --- |
272
- | Domain imports from infrastructure / adapter | `CRITICAL` | −25 pts |
273
- | Domain imports from application | `CRITICAL` | −25 pts |
274
- | Application imports from infrastructure / adapter | `HIGH` | −15 pts |
275
- | Domain imports a framework (`@nestjs/*`, `prisma`, etc.) | `CRITICAL` | −25 pts |
276
-
277
- Score = `100 − sum of penalties`, minimum 0.
201
+ | Violation | Severity |
202
+ |-----------|----------|
203
+ | Domain imports from infrastructure or adapter | `CRITICAL` |
204
+ | Domain imports from application | `CRITICAL` |
205
+ | Domain imports a framework (`@nestjs/*`, `prisma`…) | `CRITICAL` |
206
+ | Application imports from infrastructure or adapter | `HIGH` |
278
207
 
279
208
  ---
280
209
 
281
210
  ## License
282
211
 
283
- MIT — free to use, modify and distribute.
212
+ MIT
213
+
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dawudesign/node-hexa-cli",
3
- "version": "0.2.4",
3
+ "version": "0.2.5",
4
4
  "description": "CLI to scaffold and analyze NestJS Hexagonal DDD projects",
5
5
  "keywords": [
6
6
  "nestjs",