@dawudesign/node-hexa-cli 0.2.7 → 0.2.9
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 +6 -6
- package/dist/index.js +11 -6
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -41,7 +41,7 @@ pnpm start:dev
|
|
|
41
41
|
|
|
42
42
|
Generated structure:
|
|
43
43
|
|
|
44
|
-
```
|
|
44
|
+
```text
|
|
45
45
|
my-app/
|
|
46
46
|
├── src/
|
|
47
47
|
│ ├── main.ts
|
|
@@ -102,13 +102,13 @@ node-hexa check . --watch
|
|
|
102
102
|
|
|
103
103
|
Output:
|
|
104
104
|
|
|
105
|
-
```
|
|
105
|
+
```text
|
|
106
106
|
✓ Architecture check passed
|
|
107
107
|
```
|
|
108
108
|
|
|
109
109
|
or:
|
|
110
110
|
|
|
111
|
-
```
|
|
111
|
+
```text
|
|
112
112
|
✗ Architecture violations detected
|
|
113
113
|
|
|
114
114
|
[CRITICAL] Domain must not depend on infrastructure → UserEntity
|
|
@@ -137,7 +137,7 @@ node-hexa list <path>
|
|
|
137
137
|
|
|
138
138
|
Output:
|
|
139
139
|
|
|
140
|
-
```
|
|
140
|
+
```text
|
|
141
141
|
Bounded Contexts (2)
|
|
142
142
|
|
|
143
143
|
IAM
|
|
@@ -187,7 +187,7 @@ node-hexa graph <path>
|
|
|
187
187
|
```
|
|
188
188
|
|
|
189
189
|
| Key | Type | Default | Description |
|
|
190
|
-
|
|
190
|
+
| --- | ---- | ------- | ----------- |
|
|
191
191
|
| `architecture` | `string` | `"hexagonal-ddd"` | Architecture type |
|
|
192
192
|
| `strict` | `boolean` | `true` | `false` silences `MEDIUM` violations |
|
|
193
193
|
| `contextsDir` | `string` | `"src/contexts"` | Path to bounded contexts directory |
|
|
@@ -197,7 +197,7 @@ node-hexa graph <path>
|
|
|
197
197
|
## Violation rules
|
|
198
198
|
|
|
199
199
|
| Violation | Severity |
|
|
200
|
-
|
|
200
|
+
| --------- | -------- |
|
|
201
201
|
| Domain imports from infrastructure or adapter | `CRITICAL` |
|
|
202
202
|
| Domain imports from application | `CRITICAL` |
|
|
203
203
|
| Domain imports a framework (`@nestjs/*`, `prisma`…) | `CRITICAL` |
|
package/dist/index.js
CHANGED
|
@@ -505,6 +505,7 @@ function generateContext(name) {
|
|
|
505
505
|
dirs.forEach((dir) => {
|
|
506
506
|
import_node_fs6.default.mkdirSync(import_node_path7.default.join(base, dir), { recursive: true });
|
|
507
507
|
});
|
|
508
|
+
import_node_fs6.default.writeFileSync(import_node_path7.default.join(base, "domain/value-objects/.gitkeep"), "");
|
|
508
509
|
const pascal = capitalize(name);
|
|
509
510
|
const token = `${name.toUpperCase().replaceAll("-", "_")}_REPOSITORY_PORT`;
|
|
510
511
|
import_node_fs6.default.writeFileSync(
|
|
@@ -536,6 +537,10 @@ import {
|
|
|
536
537
|
} from '../../domain/ports/${name}.repository.port';
|
|
537
538
|
import { randomUUID } from 'node:crypto';
|
|
538
539
|
|
|
540
|
+
export interface Create${pascal}Dto {
|
|
541
|
+
id?: string;
|
|
542
|
+
}
|
|
543
|
+
|
|
539
544
|
@Injectable()
|
|
540
545
|
export class Create${pascal}UseCase {
|
|
541
546
|
constructor(
|
|
@@ -543,8 +548,8 @@ export class Create${pascal}UseCase {
|
|
|
543
548
|
private readonly repository: ${pascal}RepositoryPort,
|
|
544
549
|
) {}
|
|
545
550
|
|
|
546
|
-
async execute(
|
|
547
|
-
const entity = new ${pascal}(id ?? randomUUID());
|
|
551
|
+
async execute(dto: Create${pascal}Dto = {}): Promise<${pascal}> {
|
|
552
|
+
const entity = new ${pascal}(dto.id ?? randomUUID());
|
|
548
553
|
await this.repository.save(entity);
|
|
549
554
|
return entity;
|
|
550
555
|
}
|
|
@@ -553,16 +558,16 @@ export class Create${pascal}UseCase {
|
|
|
553
558
|
);
|
|
554
559
|
import_node_fs6.default.writeFileSync(
|
|
555
560
|
import_node_path7.default.join(base, "infrastructure/http", `${name}.controller.ts`),
|
|
556
|
-
`import { Controller, Post } from '@nestjs/common';
|
|
557
|
-
import { Create${pascal}UseCase } from '../../application/use-cases/create-${name}.usecase';
|
|
561
|
+
`import { Body, Controller, Post } from '@nestjs/common';
|
|
562
|
+
import { Create${pascal}UseCase, Create${pascal}Dto } from '../../application/use-cases/create-${name}.usecase';
|
|
558
563
|
|
|
559
564
|
@Controller('${name}')
|
|
560
565
|
export class ${pascal}Controller {
|
|
561
566
|
constructor(private readonly create${pascal}: Create${pascal}UseCase) {}
|
|
562
567
|
|
|
563
568
|
@Post()
|
|
564
|
-
async create() {
|
|
565
|
-
return this.create${pascal}.execute();
|
|
569
|
+
async create(@Body() dto: Create${pascal}Dto) {
|
|
570
|
+
return this.create${pascal}.execute(dto);
|
|
566
571
|
}
|
|
567
572
|
}
|
|
568
573
|
`
|