microsoft/vscode-react-native
Publicmirrored from https://github.com/microsoft/vscode-react-nativeAvailable
src/extension/services/validationService/checks/index.ts
77lines · 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 | // also check out this cool things | |
| 5 | // https://www.npmjs.com/package/envinfo // does not list all required info | |
| 6 | // https://www.npmjs.com/package/command-exists // might find its use later on | |
| 7 | | |
8609d701AndreiLobanovich4 years ago | 8 | import * as semver from "semver"; |
60d51474AndreiLobanovich4 years ago | 9 | import { PromiseUtil } from "../../../../common/node/promise"; |
8609d701AndreiLobanovich4 years ago | 10 | import { PackageVersion } from "../../../../common/projectVersionHelper"; |
c7856462Heniker4 years ago | 11 | import { adbAndroid, adbExpo } from "./adb"; |
| 12 | import cocoaPods from "./cocoaPods"; | |
| 13 | import emulator from "./emulator"; | |
| 14 | import { androidHome } from "./env"; | |
| 15 | import gradle from "./gradle"; | |
| 16 | import java from "./java"; | |
| 17 | import nodeJs from "./nodeJS"; | |
| 18 | import npm from "./npm"; | |
| 19 | import watchman from "./watchman"; | |
| 20 | import iosDeploy from "./iosDeploy"; | |
60d51474AndreiLobanovich4 years ago | 21 | import { xcodeBuild, xcodeBuildVersionRNmacOS } from "./xcodebuild"; |
c7856462Heniker4 years ago | 22 | import expoCli from "./expoCli"; |
62af5fc4Samriel4 years ago | 23 | import devmode from "./devmode"; |
| 24 | import visualStudio from "./visualStudio"; | |
| 25 | import longPath from "./longPath"; | |
| 26 | import windows from "./windows"; | |
| 27 | import dotnet from "./dotnet"; | |
60d51474AndreiLobanovich4 years ago | 28 | import xcodecli from "./xcodecli"; |
| 29 | import macos from "./macos"; | |
62af5fc4Samriel4 years ago | 30 | |
c7856462Heniker4 years ago | 31 | import { IValidation } from "./types"; |
| 32 | | |
8609d701AndreiLobanovich4 years ago | 33 | export const getChecks = (versions: PackageVersion[] = []): IValidation[] => { |
c7856462Heniker4 years ago | 34 | // if some checks become obsolete (e.g. no need to check both npm and yarn) - write logic here |
| 35 | | |
8609d701AndreiLobanovich4 years ago | 36 | const checks: IValidation[] = [ |
c7856462Heniker4 years ago | 37 | iosDeploy, |
| 38 | adbAndroid, | |
| 39 | adbExpo, | |
| 40 | emulator, | |
| 41 | androidHome, | |
| 42 | java, | |
| 43 | nodeJs, | |
| 44 | gradle, | |
| 45 | cocoaPods, | |
| 46 | npm, | |
| 47 | watchman, | |
| 48 | expoCli, | |
62af5fc4Samriel4 years ago | 49 | devmode, |
| 50 | visualStudio, | |
| 51 | longPath, | |
| 52 | windows, | |
| 53 | dotnet, | |
60d51474AndreiLobanovich4 years ago | 54 | xcodecli, |
| 55 | macos, | |
| 56 | xcodeBuild, | |
| 57 | xcodeBuildVersionRNmacOS, | |
8609d701AndreiLobanovich4 years ago | 58 | ]; |
| 59 | | |
| 60 | const rnVersionContainer = versions.find(it => Object.keys(it).includes("reactNativeVersion")); | |
| 61 | if ( | |
| 62 | rnVersionContainer && | |
| 63 | semver.gte(rnVersionContainer.reactNativeVersion, "0.68.0") && | |
| 64 | ["linux", "darwin"].includes(process.platform) | |
| 65 | ) { | |
| 66 | const androidEnvCheck = checks.find(it => it.label === "Android Env"); | |
| 67 | if (androidEnvCheck) { | |
| 68 | androidEnvCheck.exec = androidEnvCheck.exec.bind(null, "ANDROID_SDK_ROOT"); | |
| 69 | } | |
| 70 | } | |
c7856462Heniker4 years ago | 71 | |
60d51474AndreiLobanovich4 years ago | 72 | checks.forEach(it => { |
| 73 | it.exec = PromiseUtil.promiseCacheDecorator(it.exec); | |
| 74 | }); | |
| 75 | | |
c7856462Heniker4 years ago | 76 | return checks.filter(it => (it.platform ? it.platform.includes(process.platform) : true)); |
| 77 | }; |