|
| 1 | +///<reference path="../.d.ts"/> |
| 2 | +"use strict"; |
| 3 | +import os = require("os"); |
| 4 | +import helpers = require("../helpers"); |
| 5 | + |
| 6 | +class DoctorService implements IDoctorService { |
| 7 | + |
| 8 | + constructor( |
| 9 | + private $hostInfo: IHostInfo, |
| 10 | + private $sysInfo: ISysInfo, |
| 11 | + private $logger: ILogger) { } |
| 12 | + |
| 13 | + public printWarnings(): boolean { |
| 14 | + let result = false; |
| 15 | + let sysInfo = this.$sysInfo.getSysInfo(); |
| 16 | + |
| 17 | + if (!sysInfo.adbVer) { |
| 18 | + this.$logger.warn("WARNING: adb from the Android SDK is not installed or is not configured properly. "); |
| 19 | + this.$logger.out("For Android-related operations, the AppBuilder CLI will use a built-in version of adb." + os.EOL |
| 20 | + + "To avoid possible issues with the native Android emulator, Genymotion or connected" + os.EOL |
| 21 | + + "Android devices, verify that you have installed the latest Android SDK and" + os.EOL |
| 22 | + + "its dependencies as described in http://developer.android.com/sdk/index.html#Requirements" + os.EOL); |
| 23 | + |
| 24 | + this.printPackageManagerTip(); |
| 25 | + result = true; |
| 26 | + } |
| 27 | + if (!sysInfo.androidInstalled) { |
| 28 | + this.$logger.warn("WARNING: The Android SDK is not installed or is not configured properly."); |
| 29 | + this.$logger.out("You will not be able to run your apps in the native emulator. To be able to run apps" + os.EOL |
| 30 | + + "in the native Android emulator, verify that you have installed the latest Android SDK " + os.EOL |
| 31 | + + "and its dependencies as described in http://developer.android.com/sdk/index.html#Requirements" + os.EOL |
| 32 | + ); |
| 33 | + |
| 34 | + this.printPackageManagerTip(); |
| 35 | + result = true; |
| 36 | + } |
| 37 | + if (!sysInfo.itunesInstalled) { |
| 38 | + this.$logger.warn("WARNING: iTunes is not installed."); |
| 39 | + this.$logger.out("You will not be able to work with iOS devices via cable connection." + os.EOL |
| 40 | + + "To be able to work with connected iOS devices," + os.EOL |
| 41 | + + "download and install iTunes from http://www.apple.com" + os.EOL); |
| 42 | + result = true; |
| 43 | + } |
| 44 | + if(!sysInfo.javaVer) { |
| 45 | + this.$logger.warn("WARNING: The Java Development Kit (JDK) is not installed or is not configured properly."); |
| 46 | + this.$logger.out("You will not be able to work with the Android SDK and you might not be able" + os.EOL |
| 47 | + + "to perform some Android-related operations. To ensure that you can develop and" + os.EOL |
| 48 | + + "test your apps for Android, verify that you have installed the JDK as" + os.EOL |
| 49 | + + "described in http://docs.oracle.com/javase/8/docs/technotes/guides/install/install_overview.html (for JDK 8)" + os.EOL |
| 50 | + + "or http://docs.oracle.com/javase/7/docs/webnotes/install/ (for JDK 7)." + os.EOL); |
| 51 | + result = true; |
| 52 | + } |
| 53 | + if(this.$hostInfo.isDarwin && (!sysInfo.monoVer || helpers.versionCompare(sysInfo.monoVer, "3.12.0") < 0)) { |
| 54 | + this.$logger.warn("WARNING: Mono 3.12 or later is not installed or not configured properly."); |
| 55 | + this.$logger.out("You will not be able to work with Android devices in the device simulator or debug on connected Android devices." + os.EOL |
| 56 | + + "To be able to work with Android in the device simulator and debug on connected Android devices," + os.EOL |
| 57 | + + "download and install Mono 3.12 or later from http://www.mono-project.com/download/" + os.EOL); |
| 58 | + result = true; |
| 59 | + } |
| 60 | + |
| 61 | + return result; |
| 62 | + } |
| 63 | + |
| 64 | + private printPackageManagerTip() { |
| 65 | + if (this.$hostInfo.isWindows) { |
| 66 | + this.$logger.out("TIP: To avoid setting up the necessary environment variables, you can use the chocolatey package manager to install the Android SDK and its dependencies." + os.EOL); |
| 67 | + } else if (this.$hostInfo.isDarwin) { |
| 68 | + this.$logger.out("TIP: To avoid setting up the necessary environment variables, you can use the Homebrew package manager to install the Android SDK and its dependencies." + os.EOL); |
| 69 | + } |
| 70 | + } |
| 71 | +} |
| 72 | +$injector.register("doctorService", DoctorService); |
0 commit comments