@@ -182,11 +182,29 @@ export function getDemoIndexPathForType(type: SupportedDemoType): string {
182
182
}
183
183
}
184
184
185
- export function resetAngularIndex ( tree : Tree , packages ?: Array < string > ) {
185
+ export function getPackagesForIndex ( tree : Tree , packages ?: Array < string > , addingNew ?: boolean ) {
186
+ if ( addingNew ) {
187
+ // just add to all packages
188
+ const allPackages = < Array < string > > getAllPackages ( tree ) ;
189
+ for ( const p of packages ) {
190
+ if ( ! allPackages . includes ( p ) ) {
191
+ allPackages . push ( p ) ;
192
+ }
193
+ }
194
+ packages = allPackages ;
195
+ } else {
196
+ // isolate to packages or fallback to all
197
+ packages = packages && packages . length ? packages : getAllPackages ( tree ) ;
198
+ }
199
+ return packages ;
200
+ }
201
+
202
+ export function resetAngularIndex ( tree : Tree , packages ?: Array < string > , addingNew ?: boolean ) {
186
203
const angularIndexPath = `${ getDemoAppRoot ( 'angular' ) } /${ getDemoIndexPathForType ( 'angular' ) } ` ;
187
204
let angularIndex = tree . get ( angularIndexPath ) . content . toString ( ) ;
188
- const demosIndex = angularIndex . indexOf ( '[' ) ;
189
- packages = packages && packages . length ? packages : getAllPackages ( tree ) ;
205
+ const demosIndex = angularIndex . indexOf ( '[' ) ;
206
+ packages = getPackagesForIndex ( tree , packages , addingNew ) ;
207
+
190
208
angularIndex =
191
209
angularIndex . substring ( 0 , demosIndex + 1 ) +
192
210
packages
@@ -197,15 +215,15 @@ export function resetAngularIndex(tree: Tree, packages?: Array<string>) {
197
215
tree . overwrite ( angularIndexPath , angularIndex ) ;
198
216
}
199
217
200
- export function resetAngularRoutes ( tree : Tree , packages ?: Array < string > ) {
218
+ export function resetAngularRoutes ( tree : Tree , packages ?: Array < string > , addingNew ?: boolean ) {
201
219
const angularRouteModulePath = `${ getDemoAppRoot ( 'angular' ) } /src/app-routing.module.ts` ;
202
220
let angularRouteModule = tree . get ( angularRouteModulePath ) . content . toString ( ) ;
203
221
const routeDefIndex = angularRouteModule . indexOf ( 'const routes' ) ;
204
222
const routeModuleStart = angularRouteModule . substring ( 0 , routeDefIndex ) ;
205
223
const routeMoudleDefIndex = angularRouteModule . indexOf ( '@NgModule' ) ;
206
224
const routeModuleEnd = angularRouteModule . substring ( routeMoudleDefIndex , angularRouteModule . length ) ;
207
-
208
- packages = packages && packages . length ? packages : getAllPackages ( tree ) ;
225
+ packages = getPackagesForIndex ( tree , packages , addingNew ) ;
226
+
209
227
const packageRoutes =
210
228
packages
211
229
. sort ( )
0 commit comments