@@ -7,6 +7,8 @@ import 'rxjs/add/observable/of';
7
7
import 'rxjs/add/operator/ignoreElements' ;
8
8
import {
9
9
getCollection ,
10
+ getCollectionNameForSchematicName ,
11
+ getCollectionNames ,
10
12
getEngineHost
11
13
} from '../utilities/schematics' ;
12
14
import { DynamicPathOptions , dynamicPathParser } from '../utilities/dynamic-path-parser' ;
@@ -17,7 +19,7 @@ import { SchematicAvailableOptions } from '../tasks/schematic-get-options';
17
19
const Command = require ( '../ember-cli/lib/models/command' ) ;
18
20
const SilentError = require ( 'silent-error' ) ;
19
21
20
- const { cyan, yellow } = chalk ;
22
+ const { cyan, yellow, white } = chalk ;
21
23
const separatorRegEx = / [ \/ \\ ] / g;
22
24
23
25
@@ -65,8 +67,10 @@ export default Command.extend({
65
67
'<schematic>'
66
68
] ,
67
69
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
+
70
74
if ( rawArgs ) {
71
75
const parsedArgs = this . parseArgs ( rawArgs , false ) ;
72
76
if ( parsedArgs . options . collection ) {
@@ -103,7 +107,7 @@ export default Command.extend({
103
107
ui : this . ui ,
104
108
project : this . project
105
109
} ) ;
106
- const collectionName = this . getCollectionName ( rawArgs ) ;
110
+ const collectionName = this . getCollectionName ( schematicName , rawArgs ) ;
107
111
108
112
return getOptionsTask . run ( {
109
113
schematicName,
@@ -172,7 +176,7 @@ export default Command.extend({
172
176
project : this . project
173
177
} ) ;
174
178
const collectionName = commandOptions . collection ||
175
- CliConfig . getValue ( 'defaults.schematics.collection' ) ;
179
+ this . getCollectionName ( schematicName ) ;
176
180
177
181
if ( collectionName === '@schematics/angular' && schematicName === 'interface' && rawArgs [ 2 ] ) {
178
182
commandOptions . type = rawArgs [ 2 ] ;
@@ -188,10 +192,9 @@ export default Command.extend({
188
192
189
193
printDetailedHelp : function ( _options : any , rawArgs : any ) : string | Promise < string > {
190
194
const engineHost = getEngineHost ( ) ;
191
- const collectionName = this . getCollectionName ( ) ;
192
- const collection = getCollection ( collectionName ) ;
193
195
const schematicName = rawArgs [ 1 ] ;
194
196
if ( schematicName ) {
197
+ const collectionName = this . getCollectionName ( schematicName ) ;
195
198
const SchematicGetHelpOutputTask = require ( '../tasks/schematic-get-help-output' ) . default ;
196
199
const getHelpOutputTask = new SchematicGetHelpOutputTask ( {
197
200
ui : this . ui ,
@@ -204,16 +207,22 @@ export default Command.extend({
204
207
} )
205
208
. then ( ( output : string [ ] ) => {
206
209
return [
210
+ yellow ( collectionName ) ,
207
211
cyan ( `ng generate ${ schematicName } ${ cyan ( '[name]' ) } ${ cyan ( '<options...>' ) } ` ) ,
208
212
...output
209
213
] . join ( '\n' ) ;
210
214
} ) ;
211
215
} else {
212
- const schematicNames : string [ ] = engineHost . listSchematics ( collection ) ;
213
216
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
+ } ) ;
217
226
} ) ;
218
227
return Promise . resolve ( output . join ( '\n' ) ) ;
219
228
}
0 commit comments