@@ -25,6 +25,11 @@ import { readWorkspaceName } from '../utils';
2525
2626export default function ( options : FeatureOptions ) : Rule {
2727 return ( host : Tree ) => {
28+
29+ if ( ! options . app ) {
30+ options . app = options . domain ;
31+ }
32+
2833 const workspaceName = readWorkspaceName ( host ) ;
2934 const featureName = strings . dasherize ( options . name )
3035 ? strings . dasherize ( options . name )
@@ -48,8 +53,8 @@ export default function (options: FeatureOptions): Rule {
4853 . split ( '/' )
4954 . join ( '-' ) ;
5055 const domainNameAndDirectory = domainDirectory
51- ? `${ domainName } /${ domainDirectory } `
52- : `${ domainName } ` ;
56+ ? `${ domainName } /${ domainDirectory } `
57+ : `${ domainName } ` ;
5358 const domainNameAndDirectoryDasherized = `${ domainNameAndDirectory } `
5459 . split ( '/' )
5560 . join ( '-' ) ;
@@ -90,37 +95,12 @@ export default function (options: FeatureOptions): Rule {
9095 `${ featureDirectoryAndNameDasherized } Component`
9196 ) ;
9297 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+ ) ;
124104 }
125105
126106 if ( options . ngrx && ! entityName ) {
@@ -129,33 +109,33 @@ export default function (options: FeatureOptions): Rule {
129109 ) ;
130110 }
131111
132- let updatedEntityNameOptions = Object . assign ( { } , options ) ;
133- updatedEntityNameOptions . entity = featureDirectoryAndNameDasherized ;
112+ let updatedEntityNameOptions = Object . assign ( { } , options ) ;
113+ // updatedEntityNameOptions.entity = featureDirectoryAndNameDasherized;
134114
135115 const domainTemplates =
136116 options . ngrx && entityName
137117 ? 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+ ] )
142122 : 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+ ] ) ;
147127
148128 const featureTemplates =
149129 options . ngrx && entityName
150130 ? 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+ ] )
155135 : apply ( url ( './files/forFeature' ) , [
156- template ( { ...strings , ...options , workspaceName } ) ,
157- move ( featureLibFolderPath ) ,
158- ] ) ;
136+ template ( { ...strings , ...options , workspaceName } ) ,
137+ move ( featureLibFolderPath ) ,
138+ ] ) ;
159139
160140 return chain ( [
161141 externalSchematic ( '@nrwl/angular' , 'lib' , {
@@ -168,39 +148,40 @@ export default function (options: FeatureOptions): Rule {
168148 prefix : domainNameAndDirectoryDasherized ,
169149 publishable : options . type === 'publishable' ,
170150 buildable : options . type === 'buildable' ,
151+ importPath : options . importPath
171152 } ) ,
172153 addImport ( featureModuleFilepath , domainImportPath , domainModuleClassName ) ,
173154 ! options . lazy && host . exists ( appModulePath )
174155 ? 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+ ] )
188169 : noop ( ) ,
189170 mergeWith ( domainTemplates ) ,
190171 entityName
191172 ? addTsExport ( domainIndexPath , [
192- `./lib/entities/${ featureDirectoryAndNameDasherized } ` ,
193- `./lib/infrastructure/${ featureDirectoryAndNameDasherized } .data.service` ,
194- ] )
173+ `./lib/entities/${ entityName } ` ,
174+ `./lib/infrastructure/${ entityName } .data.service` ,
175+ ] )
195176 : noop ( ) ,
196177 options . ngrx && entityName && host . exists ( domainModuleFilepath )
197178 ? 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+ ] )
204185 : noop ( ) ,
205186 addTsExport ( domainIndexPath , [
206187 `./lib/application/${ featureDirectoryAndNameDasherized } .facade` , //featureDirectoryAndNameDasherized
0 commit comments