-
-
Notifications
You must be signed in to change notification settings - Fork 197
/
Copy pathcommand-base.ts
33 lines (27 loc) · 1.59 KB
/
command-base.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
export abstract class ValidatePlatformCommandBase {
constructor(protected $options: IOptions,
protected $platformsDataService: IPlatformsDataService,
protected $platformValidationService: IPlatformValidationService,
protected $projectData: IProjectData) { }
abstract allowedParameters: ICommandParameter[];
abstract execute(args: string[]): Promise<void>;
public async canExecuteCommandBase(platform: string, options?: ICanExecuteCommandOptions): Promise<boolean> {
options = options || {};
const validatePlatformOutput = await this.validatePlatformBase(platform, options.notConfiguredEnvOptions);
const canExecute = this.canExecuteCommand(validatePlatformOutput);
let result = canExecute;
if (canExecute && options.validateOptions) {
result = await this.$platformValidationService.validateOptions(this.$options.provision, this.$options.teamId, this.$projectData, platform);
}
return result;
}
private async validatePlatformBase(platform: string, notConfiguredEnvOptions: INotConfiguredEnvOptions): Promise<IValidatePlatformOutput> {
const platformData = this.$platformsDataService.getPlatformData(platform, this.$projectData);
const platformProjectService = platformData.platformProjectService;
const result = await platformProjectService.validate(this.$projectData, this.$options, notConfiguredEnvOptions);
return result;
}
private canExecuteCommand(validatePlatformOutput: IValidatePlatformOutput): boolean {
return validatePlatformOutput && validatePlatformOutput.checkEnvironmentRequirementsOutput && validatePlatformOutput.checkEnvironmentRequirementsOutput.canExecute;
}
}