@@ -21,11 +21,11 @@ function readIntoSourceFile(host: Tree, modulePath: string): ts.SourceFile {
21
21
}
22
22
23
23
function addImport (
24
- modulePath : string ,
25
- ngModuleToImportPath : string ,
26
- ngModuleToImportName : string ,
24
+ modulePath : string ,
25
+ ngModuleToImportPath : string ,
26
+ ngModuleToImportName : string ,
27
27
optional = false ) : Rule {
28
-
28
+
29
29
return ( host : Tree ) => {
30
30
31
31
if ( optional && ! host . exists ( modulePath ) ) {
@@ -35,9 +35,9 @@ function addImport(
35
35
const source = readIntoSourceFile ( host , modulePath ) ;
36
36
37
37
const changes = addImportToModule (
38
- source ,
39
- modulePath ,
40
- ngModuleToImportName ,
38
+ source ,
39
+ modulePath ,
40
+ ngModuleToImportName ,
41
41
ngModuleToImportPath )
42
42
43
43
const declarationRecorder = host . beginUpdate ( modulePath ) ;
@@ -51,16 +51,16 @@ function addImport(
51
51
}
52
52
53
53
function addDeclaration (
54
- modulePath : string ,
55
- componentToImportPath : string ,
54
+ modulePath : string ,
55
+ componentToImportPath : string ,
56
56
componentToImportName : string ) : Rule {
57
-
57
+
58
58
return ( host : Tree ) => {
59
59
60
60
const source = readIntoSourceFile ( host , modulePath ) ;
61
61
62
62
const changes = addDeclarationToModule (
63
- source ,
63
+ source ,
64
64
modulePath ,
65
65
componentToImportName ,
66
66
componentToImportPath ) ;
@@ -76,16 +76,16 @@ function addDeclaration(
76
76
}
77
77
78
78
function addExport (
79
- modulePath : string ,
80
- componentToImportPath : string ,
79
+ modulePath : string ,
80
+ componentToImportPath : string ,
81
81
componentToImportName : string ) : Rule {
82
-
82
+
83
83
return ( host : Tree ) => {
84
84
85
85
const source = readIntoSourceFile ( host , modulePath ) ;
86
86
87
87
const changes = addExportToModule (
88
- source ,
88
+ source ,
89
89
modulePath ,
90
90
componentToImportName ,
91
91
componentToImportPath ) ;
@@ -103,7 +103,7 @@ function addExport(
103
103
function addTsExport ( filePath : string , filesToExport : string [ ] ) : Rule {
104
104
return ( host : Tree ) => {
105
105
let content = host . read ( filePath ) + '\n' ;
106
-
106
+
107
107
for ( const file of filesToExport ) {
108
108
content += `export * from '${ file } ';\n` ;
109
109
}
@@ -131,24 +131,22 @@ export default function(options: FeatureOptions): Rule {
131
131
132
132
const workspaceName = readWorkspaceName ( host ) ;
133
133
134
- const domainName = strings . dasherize ( options . domain ) ;
135
- const domainFolderName = domainName ;
134
+ const domainFolderName = strings . dasherize ( options . domain ) ;
136
135
const domainPath = `libs/${ domainFolderName } /domain/src/lib` ;
137
- const domainModulePath = `${ domainPath } /${ domainFolderName } -domain.module.ts` ;
138
136
const domainModuleClassName = strings . classify ( options . domain ) + "DomainModule" ;
139
137
const domainImportPath = `${ workspaceName } /${ domainFolderName } /domain` ;
140
138
const domainIndexPath = `libs/${ domainFolderName } /domain/src/index.ts` ;
141
139
142
140
const featureName = strings . dasherize ( options . name ) ;
143
- const featureFolderName = 'feature-' + featureName ;
141
+ const featureFolderName = ( options . prefix ? 'feature-' : '' ) + featureName ;
144
142
const featurePath = `libs/${ domainFolderName } /${ featureFolderName } /src/lib` ;
145
143
const featureModulePath = `${ featurePath } /${ domainFolderName } -${ featureFolderName } .module.ts` ;
146
144
const featureModuleClassName = strings . classify ( `${ options . domain } -${ featureFolderName } Module` ) ;
147
145
const featureImportPath = `${ workspaceName } /${ domainFolderName } /${ featureFolderName } ` ;
148
146
const featureIndexPath = `libs/${ domainFolderName } /${ featureFolderName } /src/index.ts` ;
149
147
150
148
const entityName = options . entity ? strings . dasherize ( options . entity ) : '' ;
151
-
149
+
152
150
const featureComponentImportPath = `./${ featureName } .component` ;
153
151
const featureComponentClassName = strings . classify ( `${ featureName } Component` ) ;
154
152
@@ -185,14 +183,14 @@ export default function(options: FeatureOptions): Rule {
185
183
buildable : options . type === 'buildable' ,
186
184
} ) ,
187
185
addImport ( featureModulePath , domainImportPath , domainModuleClassName ) ,
188
- ( ! options . lazy && host . exists ( appModulePath ) ) ?
186
+ ( ! options . lazy && host . exists ( appModulePath ) ) ?
189
187
chain ( [
190
188
addImport ( appModulePath , featureImportPath , featureModuleClassName , true ) ,
191
189
addImport ( appModulePath , '@angular/common/http' , 'HttpClientModule' , true )
192
190
] ) :
193
191
noop ( ) ,
194
192
mergeWith ( domainTemplates ) ,
195
- ( options . entity ) ?
193
+ ( options . entity ) ?
196
194
addTsExport ( domainIndexPath , [
197
195
`./lib/entities/${ entityName } ` ,
198
196
`./lib/infrastructure/${ entityName } .data.service`
0 commit comments