|
1 |
| -export class CleanAppCommandBase { |
| 1 | +export class CleanAppCommandBase implements ICommand { |
| 2 | + public allowedParameters: ICommandParameter[] = []; |
| 3 | + |
| 4 | + protected platform: string; |
| 5 | + |
2 | 6 | constructor(protected $options: IOptions,
|
3 | 7 | protected $projectData: IProjectData,
|
4 |
| - protected $platformService: IPlatformService) { |
| 8 | + protected $platformService: IPlatformService, |
| 9 | + protected $errors: IErrors, |
| 10 | + protected $devicePlatformsConstants: Mobile.IDevicePlatformsConstants, |
| 11 | + protected $platformsData: IPlatformsData) { |
| 12 | + |
5 | 13 | this.$projectData.initializeProjectData();
|
6 | 14 | }
|
7 | 15 |
|
8 | 16 | public async execute(args: string[]): Promise<void> {
|
9 |
| - let platform = args[0].toLowerCase(); |
10 | 17 | const appFilesUpdaterOptions: IAppFilesUpdaterOptions = { bundle: this.$options.bundle, release: this.$options.release };
|
11 |
| - return this.$platformService.cleanDestinationApp(platform, appFilesUpdaterOptions, this.$options.platformTemplate, this.$projectData, this.$options); |
| 18 | + return this.$platformService.cleanDestinationApp(this.platform.toLowerCase(), appFilesUpdaterOptions, this.$options.platformTemplate, this.$projectData, this.$options); |
| 19 | + } |
| 20 | + |
| 21 | + public async canExecute(args: string[]): Promise<boolean> { |
| 22 | + if (!this.$platformService.isPlatformSupportedForOS(this.platform, this.$projectData)) { |
| 23 | + this.$errors.fail(`Applications for platform ${this.platform} can not be built on this OS`); |
| 24 | + } |
| 25 | + |
| 26 | + let platformData = this.$platformsData.getPlatformData(this.platform, this.$projectData); |
| 27 | + let platformProjectService = platformData.platformProjectService; |
| 28 | + await platformProjectService.validate(this.$projectData); |
| 29 | + return true; |
12 | 30 | }
|
13 | 31 | }
|
14 | 32 |
|
15 | 33 | export class CleanAppIosCommand extends CleanAppCommandBase implements ICommand {
|
16 | 34 | constructor(protected $options: IOptions,
|
17 |
| - private $devicePlatformsConstants: Mobile.IDevicePlatformsConstants, |
18 |
| - private $platformsData: IPlatformsData, |
19 |
| - private $errors: IErrors, |
| 35 | + protected $devicePlatformsConstants: Mobile.IDevicePlatformsConstants, |
| 36 | + protected $platformsData: IPlatformsData, |
| 37 | + protected $errors: IErrors, |
20 | 38 | $platformService: IPlatformService,
|
21 | 39 | $projectData: IProjectData) {
|
22 |
| - super($options, $projectData, $platformService); |
| 40 | + super($options, $projectData, $platformService, $errors, $devicePlatformsConstants, $platformsData); |
23 | 41 | }
|
24 | 42 |
|
25 |
| - public allowedParameters: ICommandParameter[] = []; |
26 |
| - |
27 |
| - public async execute(args: string[]): Promise<void> { |
28 |
| - if (!this.$platformService.isPlatformSupportedForOS(this.$devicePlatformsConstants.iOS, this.$projectData)) { |
29 |
| - this.$errors.fail(`Applications for platform ${this.$devicePlatformsConstants.iOS} can not be built on this OS`); |
30 |
| - } |
31 |
| - return super.execute([this.$platformsData.availablePlatforms.iOS]); |
| 43 | + protected get platform(): string { |
| 44 | + return this.$devicePlatformsConstants.iOS; |
32 | 45 | }
|
33 | 46 | }
|
34 | 47 |
|
35 | 48 | $injector.registerCommand("clean-app|ios", CleanAppIosCommand);
|
36 | 49 |
|
37 | 50 | export class CleanAppAndroidCommand extends CleanAppCommandBase implements ICommand {
|
38 |
| - public allowedParameters: ICommandParameter[] = []; |
39 |
| - |
40 | 51 | constructor(protected $options: IOptions,
|
41 |
| - private $devicePlatformsConstants: Mobile.IDevicePlatformsConstants, |
42 |
| - private $platformsData: IPlatformsData, |
43 |
| - private $errors: IErrors, |
| 52 | + protected $devicePlatformsConstants: Mobile.IDevicePlatformsConstants, |
| 53 | + protected $platformsData: IPlatformsData, |
| 54 | + protected $errors: IErrors, |
44 | 55 | $platformService: IPlatformService,
|
45 | 56 | $projectData: IProjectData) {
|
46 |
| - super($options, $projectData, $platformService); |
| 57 | + super($options, $projectData, $platformService, $errors, $devicePlatformsConstants, $platformsData); |
47 | 58 | }
|
48 | 59 |
|
49 |
| - public async execute(args: string[]): Promise<void> { |
50 |
| - if (!this.$platformService.isPlatformSupportedForOS(this.$devicePlatformsConstants.iOS, this.$projectData)) { |
51 |
| - this.$errors.fail(`Applications for platform ${this.$devicePlatformsConstants.iOS} can not be built on this OS`); |
52 |
| - } |
53 |
| - return super.execute([this.$platformsData.availablePlatforms.Android]); |
| 60 | + protected get platform(): string { |
| 61 | + return this.$devicePlatformsConstants.Android; |
54 | 62 | }
|
55 | 63 | }
|
56 | 64 |
|
|
0 commit comments