microsoft/vscode-react-native
Publicmirrored from https://github.com/microsoft/vscode-react-nativeAvailable
src/extension/services/validationService/checks/adb.ts
75lines · modeblame
c7856462Heniker4 years ago | 1 | // Copyright (c) Microsoft Corporation. All rights reserved. |
| 2 | // Licensed under the MIT license. See LICENSE file in the project root for details. | |
| 3 | | |
| 4 | import * as nls from "vscode-nls"; | |
948a0d44Heniker4 years ago | 5 | import { |
| 6 | basicCheck, | |
| 7 | createNotFoundMessage, | |
| 8 | createVersionErrorMessage, | |
| 9 | parseVersion, | |
| 10 | } from "../util"; | |
09f6024fHeniker4 years ago | 11 | import { ValidationCategoryE, IValidation, ValidationResultT } from "./types"; |
c7856462Heniker4 years ago | 12 | |
| 13 | nls.config({ | |
| 14 | messageFormat: nls.MessageFormat.bundle, | |
| 15 | bundleFormat: nls.BundleFormat.standalone, | |
| 16 | })(); | |
| 17 | | |
| 18 | const toLocale = nls.loadMessageBundle(); | |
| 19 | | |
| 20 | const label = "ADB"; | |
| 21 | | |
| 22 | async function test(): Promise<ValidationResultT> { | |
948a0d44Heniker4 years ago | 23 | const result = await basicCheck({ |
| 24 | command: "adb", | |
| 25 | versionRange: "30.0.0", | |
60d51474AndreiLobanovich4 years ago | 26 | getVersion: parseVersion.bind(null, "adb --version", /Version \d+\.\d+\.\d+/), |
948a0d44Heniker4 years ago | 27 | }); |
| 28 | | |
| 29 | if (!result.exists) { | |
c7856462Heniker4 years ago | 30 | return { |
| 31 | status: "failure", | |
| 32 | comment: createNotFoundMessage(label), | |
| 33 | }; | |
| 34 | } | |
| 35 | | |
948a0d44Heniker4 years ago | 36 | if (result.versionCompare === undefined) { |
c7856462Heniker4 years ago | 37 | return { |
| 38 | status: "failure", | |
| 39 | comment: createVersionErrorMessage(label), | |
| 40 | }; | |
| 41 | } | |
| 42 | | |
948a0d44Heniker4 years ago | 43 | if (result.versionCompare === -1) { |
| 44 | return { | |
| 45 | status: "partial-success", | |
| 46 | comment: | |
| 47 | "Detected version is older than 30.0.0. " + | |
| 48 | "Please update SDK tools in case of errors", | |
| 49 | }; | |
| 50 | } | |
| 51 | | |
| 52 | return { status: "success" }; | |
c7856462Heniker4 years ago | 53 | } |
| 54 | | |
| 55 | const adbAndroid: IValidation = { | |
| 56 | label, | |
| 57 | description: toLocale( | |
| 58 | "AdbCheckAndroidDescription", | |
948a0d44Heniker4 years ago | 59 | "Required for app installation. Minimal version is 12", |
c7856462Heniker4 years ago | 60 | ), |
| 61 | category: ValidationCategoryE.Android, | |
| 62 | exec: test, | |
| 63 | }; | |
| 64 | | |
| 65 | const adbExpo: IValidation = { | |
| 66 | label, | |
| 67 | description: toLocale( | |
| 68 | "AdbCheckExpoDescription", | |
| 69 | "Required for correct extension integration with Expo", | |
| 70 | ), | |
| 71 | category: ValidationCategoryE.Expo, | |
| 72 | exec: test, | |
| 73 | }; | |
| 74 | | |
| 75 | export { adbAndroid, adbExpo }; |