Skip to content

Commit 3214f34

Browse files
committed
feat(interactive): help users using schematics by asking questions
1 parent 8a3a474 commit 3214f34

File tree

3 files changed

+46
-6
lines changed

3 files changed

+46
-6
lines changed

libs/ddd/README.md

Lines changed: 35 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ Add this plugin to an Nx workspace:
2323
ng add @angular-architects/ddd
2424
```
2525

26-
Add domains and features:
26+
Add domains and features manually:
2727

2828
```
2929
ng g @angular-architects/ddd:domain booking
@@ -33,6 +33,39 @@ ng g @angular-architects/ddd:feature cancel --domain booking --app flight-app
3333
ng g @angular-architects/ddd:feature manage --domain boarding --app flight-app
3434
```
3535

36+
Add domains and features interactively:
37+
38+
```
39+
ng g @angular-architects/ddd:domain
40+
> ? What is the name of the domain? booking
41+
? Would you like to add an associated application? (y/N) No
42+
43+
ng g @angular-architects/ddd:domain
44+
> ? What is the name of the domain? boarding
45+
? Would you like to add an associated application? (y/N) No
46+
47+
ng g @angular-architects/ddd:feature
48+
> ? What is the name of the library? search
49+
> ? What is the name of the associated domain? booking
50+
> ? Is this feature lazy loaded? (y/N) No
51+
> [Optional] What is the associated application? (Leave blank if none) flight-app
52+
> [Optional] What is the name of the entity to create for this feature? (Leave blank if none) flight
53+
54+
ng g @angular-architects/ddd:feature
55+
> ? What is the name of the library? cancel
56+
> ? What is the name of the associated domain? booking
57+
> ? Is this feature lazy loaded? (y/N) No
58+
> [Optional] What is the associated application? (Leave blank if none) flight-app
59+
> [Optional] What is the name of the entity to create for this feature? (Leave blank if none)
60+
61+
ng g @angular-architects/ddd:feature
62+
> ? What is the name of the library? manage
63+
> ? What is the name of the associated domain? boarding
64+
> ? Is this feature lazy loaded? (y/N) No
65+
> [Optional] What is the associated application? (Leave blank if none) flight-app
66+
> [Optional] What is the name of the entity to create for this feature? (Leave blank if none)
67+
```
68+
3669
This example assumes that you have an app ``flight-app`` in place.
3770

3871
These schematics also wire up the individual libs. To see the result, create a dependency graph:
@@ -86,4 +119,4 @@ see https://github.com/angular-architects/ddd-demo
86119
- [Recording of session about this architecture](https://www.youtube.com/watch?v=94HFD391zkE&t=1s)
87120
- [Article series about DDD with Angular](https://www.softwarearchitekt.at/aktuelles/sustainable-angular-architectures-1/)
88121
- [Our eBook about this architecture](https://leanpub.com/enterprise-angular)
89-
- [Thomas Burlison's article about facades in Angular](https://medium.com/@thomasburlesonIA/push-based-architectures-with-rxjs-81b327d7c32d)
122+
- [Thomas Burlison's article about facades in Angular](https://medium.com/@thomasburlesonIA/push-based-architectures-with-rxjs-81b327d7c32d)

libs/ddd/src/schematics/domain/schema.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
"name": {
77
"type": "string",
88
"description": "Domain name",
9+
"x-prompt": "What is the name of the domain?",
910
"$default": {
1011
"$source": "argv",
1112
"index": 0
@@ -14,6 +15,7 @@
1415
"addApp": {
1516
"type": "boolean",
1617
"description": "Add an app for the domain?",
18+
"x-prompt": "Would you like to add an associated application?",
1719
"default": false
1820
}
1921
},

libs/ddd/src/schematics/feature/schema.json

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,26 +6,31 @@
66
"name": {
77
"type": "string",
88
"description": "Library name",
9+
"x-prompt": "What is the name of the library?",
910
"$default": {
1011
"$source": "argv",
1112
"index": 0
1213
}
1314
},
1415
"domain": {
1516
"type": "string",
17+
"x-prompt": "What is the name of the associated domain?",
1618
"description": "Domain name"
1719
},
18-
"app": {
19-
"type": "string",
20-
"description": "app name"
21-
},
2220
"lazy": {
2321
"type": "boolean",
2422
"description": "Is this feature module lazy loaded?",
23+
"x-prompt": "Is this feature lazy loaded?",
2524
"default": false
2625
},
26+
"app": {
27+
"type": "string",
28+
"x-prompt": "[Optional] What is the associated application? (Leave blank if none)",
29+
"description": "app name"
30+
},
2731
"entity": {
2832
"type": "string",
33+
"x-prompt": "[Optional] What is the name of the entity to create for this feature? (Leave blank if none)",
2934
"description": "Optional entity to create for this feature"
3035
}
3136
},

0 commit comments

Comments
 (0)