@@ -37,32 +37,38 @@ export default function (options: ApplicationOptions): Rule {
37
37
const { appDir, appRootSelector, componentOptions, folderName, sourceDir } =
38
38
await getAppOptions ( host , options ) ;
39
39
40
- const appTypeRules = options . standalone
41
- ? getStandaloneAppRules (
42
- options ,
43
- appDir ,
44
- folderName ,
45
- sourceDir ,
46
- appRootSelector ,
47
- componentOptions ,
48
- )
49
- : getModuleAppRules (
50
- options ,
51
- appDir ,
52
- folderName ,
53
- sourceDir ,
54
- appRootSelector ,
55
- componentOptions ,
56
- ) ;
57
-
58
40
return chain ( [
59
41
addAppToWorkspaceFile ( options , appDir , folderName ) ,
42
+ options . standalone
43
+ ? noop ( )
44
+ : schematic ( 'module' , {
45
+ name : 'app' ,
46
+ commonModule : false ,
47
+ flat : true ,
48
+ routing : options . routing ,
49
+ routingScope : 'Root' ,
50
+ path : sourceDir ,
51
+ project : options . name ,
52
+ } ) ,
53
+ schematic ( 'component' , {
54
+ name : 'app' ,
55
+ selector : appRootSelector ,
56
+ flat : true ,
57
+ path : sourceDir ,
58
+ skipImport : true ,
59
+ project : options . name ,
60
+ ...componentOptions ,
61
+ } ) ,
60
62
mergeWith (
61
- apply ( url ( './files/common-files' ) , [
62
- options . minimal ? filter ( minimalPathFilter ) : noop ( ) ,
63
+ apply ( url ( options . standalone ? './files/standalone-files' : './files/module-files' ) , [
64
+ options . routing ? noop ( ) : filter ( ( path ) => ! path . endsWith ( 'app.routes.ts.template' ) ) ,
65
+ componentOptions . skipTests
66
+ ? filter ( ( path ) => ! path . endsWith ( '.spec.ts.template' ) )
67
+ : noop ( ) ,
63
68
applyTemplates ( {
64
69
utils : strings ,
65
70
...options ,
71
+ ...componentOptions ,
66
72
selector : appRootSelector ,
67
73
relativePathToWorkspaceRoot : relativePathToWorkspaceRoot ( appDir ) ,
68
74
appName : options . name ,
@@ -72,23 +78,23 @@ export default function (options: ApplicationOptions): Rule {
72
78
] ) ,
73
79
MergeStrategy . Overwrite ,
74
80
) ,
75
- ...appTypeRules ,
76
81
mergeWith (
77
- apply ( url ( './files/common-other-files' ) , [
78
- options . strict ? noop ( ) : filter ( ( path ) => path !== '/package.json.template' ) ,
79
- componentOptions . inlineTemplate
80
- ? filter ( ( path ) => ! path . endsWith ( '.html.template' ) )
82
+ apply ( url ( './files/common-files' ) , [
83
+ options . minimal
84
+ ? filter ( ( path ) => ! path . endsWith ( 'tsconfig.spec.json.template' ) )
81
85
: noop ( ) ,
82
- componentOptions . skipTests
83
- ? filter ( ( path ) => ! path . endsWith ( '.spec.ts .template' ) )
86
+ componentOptions . inlineTemplate
87
+ ? filter ( ( path ) => ! path . endsWith ( 'component.html .template' ) )
84
88
: noop ( ) ,
85
89
applyTemplates ( {
86
90
utils : strings ,
87
91
...options ,
88
92
selector : appRootSelector ,
89
- ...componentOptions ,
93
+ relativePathToWorkspaceRoot : relativePathToWorkspaceRoot ( appDir ) ,
94
+ appName : options . name ,
95
+ folderName,
90
96
} ) ,
91
- move ( sourceDir ) ,
97
+ move ( appDir ) ,
92
98
] ) ,
93
99
MergeStrategy . Overwrite ,
94
100
) ,
@@ -97,122 +103,6 @@ export default function (options: ApplicationOptions): Rule {
97
103
} ;
98
104
}
99
105
100
- function getModuleAppRules (
101
- options : ApplicationOptions ,
102
- appDir : string ,
103
- folderName : string ,
104
- sourceDir : string ,
105
- appRootSelector : string ,
106
- componentOptions : Partial < ComponentOptions > ,
107
- ) : Rule [ ] {
108
- return [
109
- mergeWith (
110
- apply ( url ( './files/module-files' ) , [
111
- options . minimal ? filter ( minimalPathFilter ) : noop ( ) ,
112
- applyTemplates ( {
113
- utils : strings ,
114
- ...options ,
115
- relativePathToWorkspaceRoot : relativePathToWorkspaceRoot ( appDir ) ,
116
- appName : options . name ,
117
- folderName,
118
- } ) ,
119
- move ( appDir ) ,
120
- ] ) ,
121
- MergeStrategy . Overwrite ,
122
- ) ,
123
- schematic ( 'module' , {
124
- name : 'app' ,
125
- commonModule : false ,
126
- flat : true ,
127
- routing : options . routing ,
128
- routingScope : 'Root' ,
129
- path : sourceDir ,
130
- project : options . name ,
131
- } ) ,
132
- schematic ( 'component' , {
133
- name : 'app' ,
134
- selector : appRootSelector ,
135
- flat : true ,
136
- path : sourceDir ,
137
- skipImport : true ,
138
- project : options . name ,
139
- ...componentOptions ,
140
- } ) ,
141
- mergeWith (
142
- apply ( url ( './files/other-module-files' ) , [
143
- options . strict ? noop ( ) : filter ( ( path ) => path !== '/package.json.template' ) ,
144
- componentOptions . inlineTemplate
145
- ? filter ( ( path ) => ! path . endsWith ( '.html.template' ) )
146
- : noop ( ) ,
147
- componentOptions . skipTests ? filter ( ( path ) => ! path . endsWith ( '.spec.ts.template' ) ) : noop ( ) ,
148
- applyTemplates ( {
149
- utils : strings ,
150
- ...options ,
151
- selector : appRootSelector ,
152
- ...componentOptions ,
153
- } ) ,
154
- move ( sourceDir ) ,
155
- ] ) ,
156
- MergeStrategy . Overwrite ,
157
- ) ,
158
- ] ;
159
- }
160
-
161
- function getStandaloneAppRules (
162
- options : ApplicationOptions ,
163
- appDir : string ,
164
- folderName : string ,
165
- sourceDir : string ,
166
- appRootSelector : string ,
167
- componentOptions : Partial < ComponentOptions > ,
168
- ) : Rule [ ] {
169
- return [
170
- mergeWith (
171
- apply ( url ( './files/standalone-files' ) , [
172
- options . minimal ? filter ( minimalPathFilter ) : noop ( ) ,
173
- options . routing ? noop ( ) : filter ( ( path ) => ! path . endsWith ( 'app.routes.ts.template' ) ) ,
174
- applyTemplates ( {
175
- utils : strings ,
176
- ...options ,
177
- selector : appRootSelector ,
178
- relativePathToWorkspaceRoot : relativePathToWorkspaceRoot ( appDir ) ,
179
- appName : options . name ,
180
- folderName,
181
- } ) ,
182
- move ( appDir ) ,
183
- ] ) ,
184
- MergeStrategy . Overwrite ,
185
- ) ,
186
- schematic ( 'component' , {
187
- name : 'app' ,
188
- selector : appRootSelector ,
189
- flat : true ,
190
- path : sourceDir ,
191
- skipImport : true ,
192
- project : options . name ,
193
- standalone : true ,
194
- ...componentOptions ,
195
- } ) ,
196
- mergeWith (
197
- apply ( url ( './files/other-standalone-files' ) , [
198
- options . strict ? noop ( ) : filter ( ( path ) => path !== '/package.json.template' ) ,
199
- componentOptions . inlineTemplate
200
- ? filter ( ( path ) => ! path . endsWith ( '.html.template' ) )
201
- : noop ( ) ,
202
- componentOptions . skipTests ? filter ( ( path ) => ! path . endsWith ( '.spec.ts.template' ) ) : noop ( ) ,
203
- applyTemplates ( {
204
- utils : strings ,
205
- ...options ,
206
- selector : appRootSelector ,
207
- ...componentOptions ,
208
- } ) ,
209
- move ( sourceDir ) ,
210
- ] ) ,
211
- MergeStrategy . Overwrite ,
212
- ) ,
213
- ] ;
214
- }
215
-
216
106
function addDependenciesToPackageJson ( options : ApplicationOptions ) {
217
107
return ( host : Tree , context : SchematicContext ) => {
218
108
[
@@ -414,10 +304,6 @@ function addAppToWorkspaceFile(
414
304
} ) ;
415
305
}
416
306
417
- function minimalPathFilter ( path : string ) : boolean {
418
- return ! path . endsWith ( 'tsconfig.spec.json.template' ) ;
419
- }
420
-
421
307
async function getAppOptions (
422
308
host : Tree ,
423
309
options : ApplicationOptions ,
0 commit comments