7
7
*/
8
8
9
9
import { strings } from '@angular-devkit/core' ;
10
+ import { Collection } from '@angular-devkit/schematics' ;
11
+ import {
12
+ FileSystemCollectionDescription ,
13
+ FileSystemSchematicDescription ,
14
+ } from '@angular-devkit/schematics/tools' ;
10
15
import { Argv } from 'yargs' ;
11
16
import {
12
17
CommandModuleError ,
@@ -69,7 +74,6 @@ export class GenerateCommandModule
69
74
const {
70
75
'x-deprecated' : xDeprecated ,
71
76
description = schematicDescription ,
72
- aliases = schematicAliases ,
73
77
hidden = schematicHidden ,
74
78
} = schemaJson ;
75
79
const options = await this . getSchematicOptions ( collection , schematicName , workflow ) ;
@@ -79,8 +83,8 @@ export class GenerateCommandModule
79
83
// When 'describe' is set to false, it results in a hidden command.
80
84
describe : hidden === true ? false : typeof description === 'string' ? description : '' ,
81
85
deprecated : xDeprecated === true || typeof xDeprecated === 'string' ? xDeprecated : false ,
82
- aliases : Array . isArray ( aliases )
83
- ? await this . generateCommandAliasesStrings ( collectionName , aliases as string [ ] )
86
+ aliases : Array . isArray ( schematicAliases )
87
+ ? await this . generateCommandAliasesStrings ( collectionName , schematicAliases )
84
88
: undefined ,
85
89
builder : ( localYargs ) => this . addSchemaOptionsToCommand ( localYargs , options ) . strict ( ) ,
86
90
handler : ( options ) =>
@@ -205,13 +209,37 @@ export class GenerateCommandModule
205
209
// If a schematic with this same name is already registered skip.
206
210
if ( ! seenNames . has ( schematicName ) ) {
207
211
seenNames . add ( schematicName ) ;
208
- const { aliases } = collection . description . schematics [ schematicName ] ;
209
- const schematicAliases = aliases && new Set ( aliases ) ;
210
212
211
- yield { schematicName, schematicAliases, collectionName } ;
213
+ yield {
214
+ schematicName,
215
+ collectionName,
216
+ schematicAliases : this . listSchematicAliases ( collection , schematicName ) ,
217
+ } ;
218
+ }
219
+ }
220
+ }
221
+ }
222
+
223
+ private listSchematicAliases (
224
+ collection : Collection < FileSystemCollectionDescription , FileSystemSchematicDescription > ,
225
+ schematicName : string ,
226
+ ) : Set < string > | undefined {
227
+ const description = collection . description . schematics [ schematicName ] ;
228
+ if ( description ) {
229
+ return description . aliases && new Set ( description . aliases ) ;
230
+ }
231
+
232
+ // Extended collections
233
+ if ( collection . baseDescriptions ) {
234
+ for ( const base of collection . baseDescriptions ) {
235
+ const description = base . schematics [ schematicName ] ;
236
+ if ( description ) {
237
+ return description . aliases && new Set ( description . aliases ) ;
212
238
}
213
239
}
214
240
}
241
+
242
+ return undefined ;
215
243
}
216
244
217
245
/**
0 commit comments