Skip to content

Fix doctor command output #906

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 11, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions lib/android-tools-info.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,9 @@ export class AndroidToolsInfo implements IAndroidToolsInfo {
}).future<IAndroidToolsInfoData>()();
}

public validateInfo(options?: {showWarningsAsErrors: boolean, validateTargetSdk: boolean}): IFuture<void> {
return (() => {
public validateInfo(options?: {showWarningsAsErrors: boolean, validateTargetSdk: boolean}): IFuture<boolean> {
return (() : boolean => {
let detectedErrors = false;
this.showWarningsAsErrors = options && options.showWarningsAsErrors;
let toolsInfoData = this.getToolsInfo().wait();
if(!toolsInfoData.androidHomeEnvVar || !this.$fs.exists(toolsInfoData.androidHomeEnvVar).wait()) {
Expand All @@ -51,6 +52,7 @@ export class AndroidToolsInfo implements IAndroidToolsInfo {
if(!toolsInfoData.compileSdkVersion) {
this.printMessage(`Cannot find a compatible Android SDK for compilation. To be able to build for Android, install Android SDK ${AndroidToolsInfo.MIN_REQUIRED_COMPILE_TARGET} or later.`,
"Run `$ android` to manage your Android SDK versions.");
detectedErrors = true;
}

if(!toolsInfoData.buildToolsVersion) {
Expand All @@ -65,11 +67,13 @@ export class AndroidToolsInfo implements IAndroidToolsInfo {

this.printMessage("You need to have the Android SDK Build-tools installed on your system. " + message,
'Run "android" from your command-line to install required Android Build Tools.');
detectedErrors = true;
}

if(!toolsInfoData.supportRepositoryVersion) {
this.printMessage(`You need to have the latest Android Support Repository installed on your system.`,
'Run `$ android` to manage the Android Support Repository.');
detectedErrors = true;
}

if(options && options.validateTargetSdk) {
Expand All @@ -81,12 +85,15 @@ export class AndroidToolsInfo implements IAndroidToolsInfo {

if(targetSdk && (targetSdk < minSupportedVersion)) {
this.printMessage(`The selected Android target SDK ${newTarget} is not supported. You must target ${minSupportedVersion} or later.`);
detectedErrors = true;
} else if(!targetSdk || targetSdk > this.getMaxSupportedVersion()) {
this.$logger.warn(`Support for the selected Android target SDK ${newTarget} is not verified. Your Android app might not work as expected.`);
}
}
}
}).future<void>()();

return detectedErrors;
}).future<boolean>()();
}

/**
Expand Down
4 changes: 2 additions & 2 deletions lib/declarations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,9 +105,9 @@ interface IAndroidToolsInfo {
/**
* Validates the information about required Android tools and SDK versions.
* @param {any} options Defines if the warning messages should treated as error and if the targetSdk value should be validated as well.
* @return {void}
* @return {boolean} True if there are detected issues, false otherwise.
*/
validateInfo(options?: {showWarningsAsErrors: boolean, validateTargetSdk: boolean}): IFuture<void>;
validateInfo(options?: {showWarningsAsErrors: boolean, validateTargetSdk: boolean}): IFuture<boolean>;
}

/**
Expand Down
7 changes: 5 additions & 2 deletions lib/services/doctor-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,23 +69,26 @@ class DoctorService implements IDoctorService {
this.$logger.warn("WARNING: Gradle is not installed or is not configured properly.");
this.$logger.out("You will not be able to build your projects for Android or run them in the emulator or on a connected device." + EOL
+ "To be able to build for Android and run apps in the emulator or on a connected device, verify that you have installed Gradle.");
result = true;
}

if(sysInfo.gradleVer && helpers.versionCompare(sysInfo.gradleVer, DoctorService.MIN_SUPPORTED_GRADLE_VERSION) === -1) {
this.$logger.warn(`WARNING: Gradle version is lower than ${DoctorService.MIN_SUPPORTED_GRADLE_VERSION}.`);
this.$logger.out("You will not be able to build your projects for Android or run them in the emulator or on a connected device." + EOL
+ `To be able to build for Android and run apps in the emulator or on a connected device, verify thqt you have at least ${DoctorService.MIN_SUPPORTED_GRADLE_VERSION} version installed.`);
result = true;
}

if(!sysInfo.javacVersion) {
this.$logger.warn("WARNING: Javac is not installed or is not configured properly.");
this.$logger.out("You will not be able to build your projects for Android." + EOL
+ "To be able to build for Android, verify that you have installed The Java Development Kit (JDK) and configured it according to system requirements as" + EOL +
" described in https://github.com/NativeScript/nativescript-cli#system-requirements.");
result = true;
}

this.$androidToolsInfo.validateInfo().wait();
return result;
let androidToolsIssues = this.$androidToolsInfo.validateInfo().wait();
return result || androidToolsIssues;
}

private printPackageManagerTip() {
Expand Down