11import { cyan , yellow } from 'chalk' ;
2- const stringUtils = require ( 'ember-cli-string-utils' ) ;
32import { oneLine } from 'common-tags' ;
43import { CliConfig } from '../models/config' ;
54
@@ -11,14 +10,11 @@ import {
1110} from '../utilities/schematics' ;
1211import { DynamicPathOptions , dynamicPathParser } from '../utilities/dynamic-path-parser' ;
1312import { getAppFromConfig } from '../utilities/app-utils' ;
14- import * as path from 'path' ;
1513import { SchematicAvailableOptions } from '../tasks/schematic-get-options' ;
1614
1715const Command = require ( '../ember-cli/lib/models/command' ) ;
1816const SilentError = require ( 'silent-error' ) ;
1917
20- const separatorRegEx = / [ \/ \\ ] / g;
21-
2218
2319export default Command . extend ( {
2420 name : 'generate' ,
@@ -77,16 +73,15 @@ export default Command.extend({
7773
7874 beforeRun : function ( rawArgs : string [ ] ) {
7975
80- const isHelp = [ '--help' , '-h' ] . includes ( rawArgs [ 0 ] ) ;
76+ const isHelp = [ '--help' , '-h' ] . indexOf ( rawArgs [ 0 ] ) != - 1 ;
8177 if ( isHelp ) {
8278 return ;
8379 }
8480
8581 const schematicName = rawArgs [ 0 ] ;
8682 if ( ! schematicName ) {
8783 return Promise . reject ( new SilentError ( oneLine `
88- The "ng generate" command requires a
89- schematic name to be specified.
84+ The "ng generate" command requires a schematic name to be specified.
9085 For more details, use "ng help".
9186 ` ) ) ;
9287 }
@@ -127,7 +122,6 @@ export default Command.extend({
127122 }
128123
129124 const entityName = rawArgs [ 1 ] ;
130- commandOptions . name = stringUtils . dasherize ( entityName . split ( separatorRegEx ) . pop ( ) ) ;
131125
132126 const appConfig = getAppFromConfig ( commandOptions . app ) ;
133127 const dynamicPathOptions : DynamicPathOptions = {
@@ -137,34 +131,16 @@ export default Command.extend({
137131 dryRun : commandOptions . dryRun
138132 } ;
139133 const parsedPath = dynamicPathParser ( dynamicPathOptions ) ;
140- commandOptions . sourceDir = appConfig . root ;
141- const root = appConfig . root + path . sep ;
142- commandOptions . appRoot = parsedPath . appRoot === appConfig . root ? '' :
143- parsedPath . appRoot . startsWith ( root )
144- ? parsedPath . appRoot . substr ( root . length )
145- : parsedPath . appRoot ;
146-
147- commandOptions . path = parsedPath . dir . replace ( separatorRegEx , '/' ) ;
148- commandOptions . path = parsedPath . dir === appConfig . root ? '' :
149- parsedPath . dir . startsWith ( root )
150- ? commandOptions . path . substr ( root . length )
151- : commandOptions . path ;
134+
135+ // Do not pass the schematics name itself, that's not useful.
136+ commandOptions . _ = rawArgs . slice ( 1 ) ;
137+ commandOptions . _angularCliConfig = ( CliConfig . fromProject ( ) || CliConfig . fromGlobal ( ) ) . config ;
138+ commandOptions . _angularCliAppConfig = appConfig ;
139+ commandOptions . _angularCliParsedPath = parsedPath ;
152140
153141 const cwd = this . project . root ;
154142 const schematicName = rawArgs [ 0 ] ;
155143
156- if ( [ 'component' , 'c' , 'directive' , 'd' ] . indexOf ( schematicName ) !== - 1 ) {
157- if ( commandOptions . prefix === undefined ) {
158- commandOptions . prefix = appConfig . prefix ;
159- }
160-
161- if ( schematicName === 'component' || schematicName === 'c' ) {
162- if ( commandOptions . styleext === undefined ) {
163- commandOptions . styleext = CliConfig . getValue ( 'defaults.styleExt' ) ;
164- }
165- }
166- }
167-
168144 const SchematicRunTask = require ( '../tasks/schematic-run' ) . default ;
169145 const schematicRunTask = new SchematicRunTask ( {
170146 ui : this . ui ,
@@ -173,10 +149,6 @@ export default Command.extend({
173149 const collectionName = commandOptions . collection ||
174150 CliConfig . getValue ( 'defaults.schematics.collection' ) ;
175151
176- if ( collectionName === '@schematics/angular' && schematicName === 'interface' && rawArgs [ 2 ] ) {
177- commandOptions . type = rawArgs [ 2 ] ;
178- }
179-
180152 return schematicRunTask . run ( {
181153 taskOptions : commandOptions ,
182154 workingDir : cwd ,
0 commit comments