@@ -7,6 +7,8 @@ import 'rxjs/add/observable/of';
77import 'rxjs/add/operator/ignoreElements' ;
88import {
99 getCollection ,
10+ getCollectionNameForSchematicName ,
11+ getCollectionNames ,
1012 getEngineHost
1113} from '../utilities/schematics' ;
1214import { DynamicPathOptions , dynamicPathParser } from '../utilities/dynamic-path-parser' ;
@@ -17,7 +19,7 @@ import { SchematicAvailableOptions } from '../tasks/schematic-get-options';
1719const Command = require ( '../ember-cli/lib/models/command' ) ;
1820const SilentError = require ( 'silent-error' ) ;
1921
20- const { cyan, yellow } = chalk ;
22+ const { cyan, yellow, white } = chalk ;
2123const separatorRegEx = / [ \/ \\ ] / g;
2224
2325
@@ -65,8 +67,10 @@ export default Command.extend({
6567 '<schematic>'
6668 ] ,
6769
68- getCollectionName ( rawArgs : string [ ] ) {
69- let collectionName = CliConfig . getValue ( 'defaults.schematics.collection' ) ;
70+ getCollectionName ( schematicName : string , rawArgs : string [ ] ) {
71+ let collectionName = getCollectionNameForSchematicName (
72+ getCollectionNames ( ) , schematicName ) ;
73+
7074 if ( rawArgs ) {
7175 const parsedArgs = this . parseArgs ( rawArgs , false ) ;
7276 if ( parsedArgs . options . collection ) {
@@ -103,7 +107,7 @@ export default Command.extend({
103107 ui : this . ui ,
104108 project : this . project
105109 } ) ;
106- const collectionName = this . getCollectionName ( rawArgs ) ;
110+ const collectionName = this . getCollectionName ( schematicName , rawArgs ) ;
107111
108112 return getOptionsTask . run ( {
109113 schematicName,
@@ -172,7 +176,7 @@ export default Command.extend({
172176 project : this . project
173177 } ) ;
174178 const collectionName = commandOptions . collection ||
175- CliConfig . getValue ( 'defaults.schematics.collection' ) ;
179+ this . getCollectionName ( schematicName ) ;
176180
177181 if ( collectionName === '@schematics/angular' && schematicName === 'interface' && rawArgs [ 2 ] ) {
178182 commandOptions . type = rawArgs [ 2 ] ;
@@ -188,10 +192,9 @@ export default Command.extend({
188192
189193 printDetailedHelp : function ( _options : any , rawArgs : any ) : string | Promise < string > {
190194 const engineHost = getEngineHost ( ) ;
191- const collectionName = this . getCollectionName ( ) ;
192- const collection = getCollection ( collectionName ) ;
193195 const schematicName = rawArgs [ 1 ] ;
194196 if ( schematicName ) {
197+ const collectionName = this . getCollectionName ( schematicName ) ;
195198 const SchematicGetHelpOutputTask = require ( '../tasks/schematic-get-help-output' ) . default ;
196199 const getHelpOutputTask = new SchematicGetHelpOutputTask ( {
197200 ui : this . ui ,
@@ -204,16 +207,22 @@ export default Command.extend({
204207 } )
205208 . then ( ( output : string [ ] ) => {
206209 return [
210+ yellow ( collectionName ) ,
207211 cyan ( `ng generate ${ schematicName } ${ cyan ( '[name]' ) } ${ cyan ( '<options...>' ) } ` ) ,
208212 ...output
209213 ] . join ( '\n' ) ;
210214 } ) ;
211215 } else {
212- const schematicNames : string [ ] = engineHost . listSchematics ( collection ) ;
213216 const output : string [ ] = [ ] ;
214- output . push ( cyan ( 'Available schematics:' ) ) ;
215- schematicNames . forEach ( schematicName => {
216- output . push ( yellow ( ` ${ schematicName } ` ) ) ;
217+ output . push ( cyan ( 'Available collections & schematics:' ) ) ;
218+ const collections = getCollectionNames ( )
219+ . map ( ( collectionName : string ) => getCollection ( collectionName ) ) ;
220+ collections . forEach ( ( collection : any ) => {
221+ output . push ( yellow ( `\n${ collection . name } ` ) ) ;
222+ const schematicNames : string [ ] = engineHost . listSchematics ( collection ) ;
223+ schematicNames . forEach ( schematicName => {
224+ output . push ( white ( ` ${ schematicName } ` ) ) ;
225+ } ) ;
217226 } ) ;
218227 return Promise . resolve ( output . join ( '\n' ) ) ;
219228 }
0 commit comments