|
1 | | -import { tags } from '@angular-devkit/core'; |
2 | | -import { Command, Option } from '../models/command'; |
| 1 | +import { CommandScope, Option } from '../models/command'; |
| 2 | +import { CoreSchematicOptions, SchematicCommand } from '../models/schematic-command'; |
3 | 3 |
|
4 | 4 |
|
5 | | -export default class EjectCommand extends Command { |
| 5 | +export interface EjectOptions extends CoreSchematicOptions { } |
| 6 | + |
| 7 | +export default class EjectCommand extends SchematicCommand { |
6 | 8 | public readonly name = 'eject'; |
7 | | - public readonly description = 'Temporarily disabled. Ejects your app and output the proper ' |
8 | | - + 'webpack configuration and scripts.'; |
9 | | - public readonly arguments: string[] = []; |
10 | | - public readonly options: Option[] = []; |
| 9 | + public readonly description = 'Create a basic Webpack configuration for your app.'; |
| 10 | + public static aliases: string[] = []; |
| 11 | + public readonly scope = CommandScope.everywhere; |
| 12 | + public arguments: string[] = []; |
| 13 | + public options: Option[] = []; |
| 14 | + |
| 15 | + private collectionName = '@schematics/angular'; |
| 16 | + private schematicName = 'update'; |
11 | 17 |
|
12 | | - run() { |
13 | | - this.logger.info(tags.stripIndents` |
14 | | - The 'eject' command has been temporarily disabled, as it is not yet compatible with the new |
15 | | - angular.json format. The new configuration format provides further flexibility to modify the |
16 | | - configuration of your workspace without ejecting. Ejection will be re-enabled in a future |
17 | | - release of the CLI. |
| 18 | + private initialized = false; |
| 19 | + public async initialize(options: any) { |
| 20 | + if (this.initialized) { |
| 21 | + return; |
| 22 | + } |
| 23 | + super.initialize(options); |
| 24 | + this.initialized = true; |
| 25 | + |
| 26 | + const schematicOptions = await this.getOptions({ |
| 27 | + schematicName: this.schematicName, |
| 28 | + collectionName: this.collectionName, |
| 29 | + }); |
| 30 | + this.options = this.options.concat(schematicOptions.options); |
| 31 | + this.arguments = this.arguments.concat(schematicOptions.arguments.map(a => a.name)); |
| 32 | + } |
18 | 33 |
|
19 | | - If you need to eject today, use CLI 1.7 to eject your project. |
20 | | - `); |
| 34 | + public async run(options: EjectOptions) { |
| 35 | + return this.runSchematic({ |
| 36 | + collectionName: this.collectionName, |
| 37 | + schematicName: this.schematicName, |
| 38 | + schematicOptions: options, |
| 39 | + dryRun: options.dryRun, |
| 40 | + force: false, |
| 41 | + showNothingDone: false, |
| 42 | + }); |
21 | 43 | } |
22 | 44 | } |
0 commit comments