@@ -25,6 +25,11 @@ import { readWorkspaceName } from '../utils';
25
25
26
26
export default function ( options : FeatureOptions ) : Rule {
27
27
return ( host : Tree ) => {
28
+
29
+ if ( ! options . app ) {
30
+ options . app = options . domain ;
31
+ }
32
+
28
33
const workspaceName = readWorkspaceName ( host ) ;
29
34
const featureName = strings . dasherize ( options . name )
30
35
? strings . dasherize ( options . name )
@@ -48,8 +53,8 @@ export default function (options: FeatureOptions): Rule {
48
53
. split ( '/' )
49
54
. join ( '-' ) ;
50
55
const domainNameAndDirectory = domainDirectory
51
- ? `${ domainName } /${ domainDirectory } `
52
- : `${ domainName } ` ;
56
+ ? `${ domainName } /${ domainDirectory } `
57
+ : `${ domainName } ` ;
53
58
const domainNameAndDirectoryDasherized = `${ domainNameAndDirectory } `
54
59
. split ( '/' )
55
60
. join ( '-' ) ;
@@ -90,37 +95,12 @@ export default function (options: FeatureOptions): Rule {
90
95
`${ featureDirectoryAndNameDasherized } Component`
91
96
) ;
92
97
const appModulePath = `apps/${ appDirectoryAndName } /src/app/app.module.ts` ;
93
- /*
94
- console.log("featureDirectoryAndName", featureDirectoryAndName);
95
- console.log("featureDirectoryAndNameDasherized", featureDirectoryAndNameDasherized);
96
- console.log("domainNameAndDirectory", domainNameAndDirectory);
97
- console.log("domainNameAndDirectoryDasherized", domainNameAndDirectoryDasherized);
98
- console.log("appDirectoryAndName", appDirectoryAndName);
99
- console.log("domainNameAndDirectoryPath", domainNameAndDirectoryPath);
100
- console.log("domainFolderPath", domainFolderPath);
101
- console.log("domainLibFolderPath", domainLibFolderPath);
102
- console.log("domainModuleFilepath", domainModuleFilepath);
103
- console.log("domainModuleClassName", domainModuleClassName);
104
- console.log("domainImportPath", domainImportPath);
105
- console.log("domainIndexPath", domainIndexPath);
106
- console.log("featureFolderName", featureFolderName);
107
- console.log("featureDirectoryAndFolderName", featureDirectoryAndFolderName);
108
- console.log("featureLibFolderPath", featureLibFolderPath);
109
- console.log("featureModuleFilepath", featureModuleFilepath);
110
- console.log("featureModuleClassName", featureModuleClassName);
111
- console.log("featureImportPath", featureImportPath);
112
- console.log("featureIndexPath", featureIndexPath);
113
- console.log("entityName", entityName);
114
- console.log("featureComponentImportPath", featureComponentImportPath);
115
- console.log("featureComponentClassName", featureComponentClassName);
116
- */
117
- if ( options . app ) {
118
- const requiredAppModulePath = `apps/${ appDirectoryAndName } /src/app/app.module.ts` ;
119
- if ( ! host . exists ( requiredAppModulePath ) ) {
120
- throw new Error (
121
- `Specified app ${ options . app } does not exist: ${ requiredAppModulePath } expected!`
122
- ) ;
123
- }
98
+
99
+ const requiredAppModulePath = `apps/${ appDirectoryAndName } /src/app/app.module.ts` ;
100
+ if ( ! host . exists ( requiredAppModulePath ) ) {
101
+ throw new Error (
102
+ `Specified app ${ options . app } does not exist: ${ requiredAppModulePath } expected!`
103
+ ) ;
124
104
}
125
105
126
106
if ( options . ngrx && ! entityName ) {
@@ -129,33 +109,33 @@ export default function (options: FeatureOptions): Rule {
129
109
) ;
130
110
}
131
111
132
- let updatedEntityNameOptions = Object . assign ( { } , options ) ;
133
- updatedEntityNameOptions . entity = featureDirectoryAndNameDasherized ;
112
+ let updatedEntityNameOptions = Object . assign ( { } , options ) ;
113
+ // updatedEntityNameOptions.entity = featureDirectoryAndNameDasherized;
134
114
135
115
const domainTemplates =
136
116
options . ngrx && entityName
137
117
? apply ( url ( './files/forDomainWithNgrx' ) , [
138
- filterTemplates ( updatedEntityNameOptions ) ,
139
- template ( { ...strings , ...updatedEntityNameOptions , workspaceName } ) ,
140
- move ( domainLibFolderPath ) ,
141
- ] )
118
+ filterTemplates ( updatedEntityNameOptions ) ,
119
+ template ( { ...strings , ...updatedEntityNameOptions , workspaceName } ) ,
120
+ move ( domainLibFolderPath ) ,
121
+ ] )
142
122
: apply ( url ( './files/forDomain' ) , [
143
- filterTemplates ( options ) ,
144
- template ( { ...strings , ...options , workspaceName } ) ,
145
- move ( domainLibFolderPath ) ,
146
- ] ) ;
123
+ filterTemplates ( options ) ,
124
+ template ( { ...strings , ...options , workspaceName } ) ,
125
+ move ( domainLibFolderPath ) ,
126
+ ] ) ;
147
127
148
128
const featureTemplates =
149
129
options . ngrx && entityName
150
130
? apply ( url ( './files/forFeatureWithNgrx' ) , [
151
- filterTemplates ( options ) ,
152
- template ( { ...strings , ...options , workspaceName } ) ,
153
- move ( featureLibFolderPath ) ,
154
- ] )
131
+ filterTemplates ( options ) ,
132
+ template ( { ...strings , ...options , workspaceName } ) ,
133
+ move ( featureLibFolderPath ) ,
134
+ ] )
155
135
: apply ( url ( './files/forFeature' ) , [
156
- template ( { ...strings , ...options , workspaceName } ) ,
157
- move ( featureLibFolderPath ) ,
158
- ] ) ;
136
+ template ( { ...strings , ...options , workspaceName } ) ,
137
+ move ( featureLibFolderPath ) ,
138
+ ] ) ;
159
139
160
140
return chain ( [
161
141
externalSchematic ( '@nrwl/angular' , 'lib' , {
@@ -168,39 +148,40 @@ export default function (options: FeatureOptions): Rule {
168
148
prefix : domainNameAndDirectoryDasherized ,
169
149
publishable : options . type === 'publishable' ,
170
150
buildable : options . type === 'buildable' ,
151
+ importPath : options . importPath
171
152
} ) ,
172
153
addImport ( featureModuleFilepath , domainImportPath , domainModuleClassName ) ,
173
154
! options . lazy && host . exists ( appModulePath )
174
155
? chain ( [
175
- addImport (
176
- appModulePath ,
177
- featureImportPath ,
178
- featureModuleClassName ,
179
- true
180
- ) ,
181
- addImport (
182
- appModulePath ,
183
- '@angular/common/http' ,
184
- 'HttpClientModule' ,
185
- true
186
- ) ,
187
- ] )
156
+ addImport (
157
+ appModulePath ,
158
+ featureImportPath ,
159
+ featureModuleClassName ,
160
+ true
161
+ ) ,
162
+ addImport (
163
+ appModulePath ,
164
+ '@angular/common/http' ,
165
+ 'HttpClientModule' ,
166
+ true
167
+ ) ,
168
+ ] )
188
169
: noop ( ) ,
189
170
mergeWith ( domainTemplates ) ,
190
171
entityName
191
172
? addTsExport ( domainIndexPath , [
192
- `./lib/entities/${ featureDirectoryAndNameDasherized } ` ,
193
- `./lib/infrastructure/${ featureDirectoryAndNameDasherized } .data.service` ,
194
- ] )
173
+ `./lib/entities/${ entityName } ` ,
174
+ `./lib/infrastructure/${ entityName } .data.service` ,
175
+ ] )
195
176
: noop ( ) ,
196
177
options . ngrx && entityName && host . exists ( domainModuleFilepath )
197
178
? chain ( [
198
- addNgRxToPackageJson ( ) ,
199
- addNgrxImportsToDomain ( domainModuleFilepath , featureDirectoryAndNameDasherized ) ,
200
- addTsExport ( domainIndexPath , [
201
- `./lib/+state/${ featureDirectoryAndNameDasherized } /${ featureDirectoryAndNameDasherized } .actions` ,
202
- ] ) ,
203
- ] )
179
+ addNgRxToPackageJson ( ) ,
180
+ addNgrxImportsToDomain ( domainModuleFilepath , entityName ) ,
181
+ addTsExport ( domainIndexPath , [
182
+ `./lib/+state/${ entityName } /${ entityName } .actions` ,
183
+ ] ) ,
184
+ ] )
204
185
: noop ( ) ,
205
186
addTsExport ( domainIndexPath , [
206
187
`./lib/application/${ featureDirectoryAndNameDasherized } .facade` , //featureDirectoryAndNameDasherized
0 commit comments