9
9
// tslint:disable:no-global-tslint-disable no-any
10
10
import { tags , terminal } from '@angular-devkit/core' ;
11
11
import { NodePackageDoesNotSupportSchematics } from '@angular-devkit/schematics/tools' ;
12
- import { CommandScope , Option } from '../models/command' ;
13
12
import { parseOptions } from '../models/command-runner' ;
14
13
import { SchematicCommand } from '../models/schematic-command' ;
15
14
import { NpmInstall } from '../tasks/npm-install' ;
16
15
import { getPackageManager } from '../utilities/config' ;
17
16
18
17
19
18
export class AddCommand extends SchematicCommand {
20
- readonly name = 'add' ;
21
- readonly description = 'Add support for a library to your project.' ;
22
19
readonly allowPrivateSchematics = true ;
23
- static aliases = [ ] ;
24
- static scope = CommandScope . inProject ;
25
- arguments = [ 'collection' ] ;
26
- options : Option [ ] = [ ] ;
27
20
28
21
private async _parseSchematicOptions ( collectionName : string ) : Promise < any > {
29
22
const schematicOptions = await this . getOptions ( {
30
23
schematicName : 'ng-add' ,
31
24
collectionName,
32
25
} ) ;
26
+ this . addOptions ( schematicOptions ) ;
33
27
34
- const options = this . options . concat ( schematicOptions . options ) ;
35
- const args = schematicOptions . arguments . map ( arg => arg . name ) ;
36
-
37
- return parseOptions ( this . _rawArgs , options , args , this . argStrategy ) ;
28
+ return parseOptions ( this . _rawArgs , this . options ) ;
38
29
}
39
30
40
31
validate ( options : any ) {
41
32
const collectionName = options . _ [ 0 ] ;
42
33
43
34
if ( ! collectionName ) {
44
35
this . logger . fatal (
45
- `The "ng ${ this . name } " command requires a name argument to be specified eg. `
36
+ `The "ng add " command requires a name argument to be specified eg. `
46
37
+ `${ terminal . yellow ( 'ng add [name] ' ) } . For more details, use "ng help".` ,
47
38
) ;
48
39
@@ -57,7 +48,7 @@ export class AddCommand extends SchematicCommand {
57
48
58
49
if ( ! firstArg ) {
59
50
this . logger . fatal (
60
- `The "ng ${ this . name } " command requires a name argument to be specified eg. `
51
+ `The "ng add " command requires a name argument to be specified eg. `
61
52
+ `${ terminal . yellow ( 'ng add [name] ' ) } . For more details, use "ng help".` ,
62
53
) ;
63
54
0 commit comments