diff --git a/packages/angular/cli/src/commands/generate/cli.ts b/packages/angular/cli/src/commands/generate/cli.ts index eaa0dad05429..2124f2333a25 100644 --- a/packages/angular/cli/src/commands/generate/cli.ts +++ b/packages/angular/cli/src/commands/generate/cli.ts @@ -7,6 +7,11 @@ */ import { strings } from '@angular-devkit/core'; +import { Collection } from '@angular-devkit/schematics'; +import { + FileSystemCollectionDescription, + FileSystemSchematicDescription, +} from '@angular-devkit/schematics/tools'; import { Argv } from 'yargs'; import { CommandModuleError, @@ -69,7 +74,6 @@ export class GenerateCommandModule const { 'x-deprecated': xDeprecated, description = schematicDescription, - aliases = schematicAliases, hidden = schematicHidden, } = schemaJson; const options = await this.getSchematicOptions(collection, schematicName, workflow); @@ -79,8 +83,8 @@ export class GenerateCommandModule // When 'describe' is set to false, it results in a hidden command. describe: hidden === true ? false : typeof description === 'string' ? description : '', deprecated: xDeprecated === true || typeof xDeprecated === 'string' ? xDeprecated : false, - aliases: Array.isArray(aliases) - ? await this.generateCommandAliasesStrings(collectionName, aliases as string[]) + aliases: Array.isArray(schematicAliases) + ? await this.generateCommandAliasesStrings(collectionName, schematicAliases) : undefined, builder: (localYargs) => this.addSchemaOptionsToCommand(localYargs, options).strict(), handler: (options) => @@ -205,13 +209,37 @@ export class GenerateCommandModule // If a schematic with this same name is already registered skip. if (!seenNames.has(schematicName)) { seenNames.add(schematicName); - const { aliases } = collection.description.schematics[schematicName]; - const schematicAliases = aliases && new Set(aliases); - yield { schematicName, schematicAliases, collectionName }; + yield { + schematicName, + collectionName, + schematicAliases: this.listSchematicAliases(collection, schematicName), + }; + } + } + } + } + + private listSchematicAliases( + collection: Collection, + schematicName: string, + ): Set | undefined { + const description = collection.description.schematics[schematicName]; + if (description) { + return description.aliases && new Set(description.aliases); + } + + // Extended collections + if (collection.baseDescriptions) { + for (const base of collection.baseDescriptions) { + const description = base.schematics[schematicName]; + if (description) { + return description.aliases && new Set(description.aliases); } } } + + return undefined; } /**