|
1 |
| -import { AAB_NOT_SUPPORTED_BY_COMMNAND_MESSAGE } from "../constants"; |
| 1 | +import * as semver from "semver"; |
| 2 | +import * as util from "util"; |
| 3 | +import { AndroidBundleValidatorMessages, TNS_ANDROID_RUNTIME_NAME } from "../constants"; |
2 | 4 |
|
3 | 5 | export class AndroidBundleValidatorHelper implements IAndroidBundleValidatorHelper {
|
| 6 | + public static MIN_RUNTIME_VERSION = "5.0.0"; |
| 7 | + |
4 | 8 | constructor(protected $projectData: IProjectData,
|
5 | 9 | protected $errors: IErrors,
|
6 |
| - protected $options: IOptions) { |
| 10 | + protected $options: IOptions, |
| 11 | + protected $projectDataService: IProjectDataService) { |
7 | 12 | }
|
8 | 13 |
|
9 |
| - public validateNoAab(minSupportedVersion?: string): void { |
10 |
| - if(this.$options.aab) { |
11 |
| - this.$errors.fail(AAB_NOT_SUPPORTED_BY_COMMNAND_MESSAGE); |
| 14 | + public validateNoAab(): void { |
| 15 | + if (this.$options.aab) { |
| 16 | + this.$errors.fail(AndroidBundleValidatorMessages.AAB_NOT_SUPPORTED_BY_COMMNAND_MESSAGE); |
| 17 | + } |
| 18 | + } |
| 19 | + |
| 20 | + public validateRuntimeVersion(projectData: IProjectData): void { |
| 21 | + if (this.$options.aab) { |
| 22 | + const androidRuntimeInfo = this.$projectDataService.getNSValue(projectData.projectDir, TNS_ANDROID_RUNTIME_NAME); |
| 23 | + const androidRuntimeVersion = androidRuntimeInfo ? androidRuntimeInfo.version : ""; |
| 24 | + |
| 25 | + if (androidRuntimeVersion) { |
| 26 | + const shouldSkipCheck = !semver.valid(androidRuntimeVersion) && !semver.validRange(androidRuntimeVersion); |
| 27 | + if (!shouldSkipCheck) { |
| 28 | + const isAndroidBundleSupported = semver.gte(semver.coerce(androidRuntimeVersion), semver.coerce(AndroidBundleValidatorHelper.MIN_RUNTIME_VERSION)); |
| 29 | + if (!isAndroidBundleSupported) { |
| 30 | + this.$errors.failWithoutHelp(util.format(AndroidBundleValidatorMessages.RUNTIME_VERSION_TOO_LOW, AndroidBundleValidatorHelper.MIN_RUNTIME_VERSION)); |
| 31 | + } |
| 32 | + } |
| 33 | + } |
12 | 34 | }
|
13 | 35 | }
|
14 | 36 | }
|
|
0 commit comments