Skip to content

Implement doctor command #556

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
Jun 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
3 changes: 2 additions & 1 deletion docs/man_pages/general/autocomplete-disable.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ Command | Description
----------|----------
[autocomplete](autocomplete.html) | Asks for confirmation if command line autocompletion should be enabled for bash and zsh.
[autocomplete-status](autocomplete-status.html) | Prints the current status of your command-line completion settings.
[autocomplete-enable](autocomplete-enable.html) |[autocomplete](autocomplete.html) | Configures your current command-line completion settings.
[autocomplete-enable](autocomplete-enable.html) | Configures your current command-line completion settings.
[feature-usage-tracking](feature-usage-tracking.html) | Configures anonymous usage statistics tracking for the NativeScript command-line interface.
[help](help.html) | Lists the available commands or shows information about the selected command.
[doctor](doctor.html) | Checks your system and reports potential problems which may prevent developing with NativeScript.
<% } %>
1 change: 1 addition & 0 deletions docs/man_pages/general/autocomplete-enable.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,5 @@ Command | Description
[autocomplete-disable](autocomplete-disable.html) | Disables command-line completion for bash and zsh shells.
[feature-usage-tracking](feature-usage-tracking.html) | Configures anonymous usage statistics tracking for the NativeScript command-line interface.
[help](help.html) | Lists the available commands or shows information about the selected command.
[doctor](doctor.html) | Checks your system and reports potential problems which may prevent developing with NativeScript.
<% } %>
3 changes: 2 additions & 1 deletion docs/man_pages/general/autocomplete-status.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,9 @@ Prints your current command-line completion settings.
Command | Description
----------|----------
[autocomplete](autocomplete.html) | Prints your current command-line completion settings. If disabled, prompts you to enable it.
[autocomplete-enable](autocomplete-enable.html) |[autocomplete](autocomplete.html) | Configures your current command-line completion settings.
[autocomplete-enable](autocomplete-enable.html) | Configures your current command-line completion settings.
[autocomplete-disable](autocomplete-disable.html) | Disables command-line completion for bash and zsh shells.
[feature-usage-tracking](feature-usage-tracking.html) | Configures anonymous usage statistics tracking for the NativeScript command-line interface.
[help](help.html) | Lists the available commands or shows information about the selected command.
[doctor](doctor.html) | Checks your system and reports potential problems which may prevent developing with NativeScript.
<% } %>
3 changes: 2 additions & 1 deletion docs/man_pages/general/autocomplete.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ Prints your current command-line completion settings. If disabled, prompts you t
Command | Description
----------|----------
[autocomplete-status](autocomplete-status.html) | Prints the current status of your command-line completion settings.
[autocomplete-enable](autocomplete-enable.html) |[autocomplete](autocomplete.html) | Configures your current command-line completion settings.
[autocomplete-enable](autocomplete-enable.html) | Configures your current command-line completion settings.
[autocomplete-disable](autocomplete-disable.html) | Disables command-line completion for bash and zsh shells.
[feature-usage-tracking](feature-usage-tracking.html) | Configures anonymous usage statistics tracking for the NativeScript command-line interface.
[doctor](doctor.html) | Checks your system and reports potential problems which may prevent developing with NativeScript.
<% } %>
19 changes: 19 additions & 0 deletions docs/man_pages/general/doctor.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
doctor
==========

Usage | Synopsis
------|-------
General | `$ tns doctor`

Checks your system and reports potential problems which may prevent developing with NativeScript.


<% if(isHtml) { %>
### Related Commands

Command | Description
----------|----------
[feature-usage-tracking](feature-usage-tracking.html) | Configures anonymous usage statistics tracking for the NativeScript CLI.
[autocomplete](autocomplete.html) | Prints your current command-line completion settings. If disabled, prompts you to enable it.
[help](help.html) | Lists the available commands or shows information about the selected command.
<% } %>
5 changes: 3 additions & 2 deletions docs/man_pages/general/feature-usage-tracking-disable.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,9 @@ Command | Description
[feature-usage-tracking](feature-usage-tracking.html) | Configures anonymous usage statistics tracking for the NativeScript CLI.
[feature-usage-tracking status](feature-usage-tracking-status.html) | Shows the current configuration for anonymous usage tracking for the NativeScript CLI.
[feature-usage-tracking enable](feature-usage-tracking-enable.html) | Enables anonymous usage statistics tracking.
[autocomplete](autocomplete.html) |[autocomplete](autocomplete.html) | Configures your current command-line completion settings.
[autocomplete](autocomplete.html) | Configures your current command-line completion settings.
[autocomplete-status](autocomplete-status.html) | Prints the current status of your command-line completion settings.
[autocomplete-enable](autocomplete-enable.html) |[autocomplete](autocomplete.html) | Configures your current command-line completion settings.
[autocomplete-enable](autocomplete-enable.html) | Configures your current command-line completion settings.
[autocomplete-disable](autocomplete-disable.html) | Disables command-line completion for bash and zsh shells.
[doctor](doctor.html) | Checks your system and reports potential problems which may prevent developing with NativeScript.
<% } %>
5 changes: 3 additions & 2 deletions docs/man_pages/general/feature-usage-tracking-enable.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,9 @@ Command | Description
[feature-usage-tracking](feature-usage-tracking.html) | Configures anonymous usage statistics tracking for the NativeScript CLI.
[feature-usage-tracking status](feature-usage-tracking-status.html) | Shows the current configuration for anonymous usage tracking for the NativeScript CLI.
[feature-usage-tracking disable](feature-usage-tracking-disable.html) | Disables anonymous usage statistics tracking.
[autocomplete](autocomplete.html) |[autocomplete](autocomplete.html) | Configures your current command-line completion settings.
[autocomplete](autocomplete.html) | Configures your current command-line completion settings.
[autocomplete-status](autocomplete-status.html) | Prints the current status of your command-line completion settings.
[autocomplete-enable](autocomplete-enable.html) |[autocomplete](autocomplete.html) | Configures your current command-line completion settings.
[autocomplete-enable](autocomplete-enable.html) | Configures your current command-line completion settings.
[autocomplete-disable](autocomplete-disable.html) | Disables command-line completion for bash and zsh shells.
[doctor](doctor.html) | Checks your system and reports potential problems which may prevent developing with NativeScript.
<% } %>
5 changes: 3 additions & 2 deletions docs/man_pages/general/feature-usage-tracking-status.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,9 @@ Command | Description
[feature-usage-tracking](feature-usage-tracking.html) | Configures anonymous usage statistics tracking for the NativeScript CLI.
[feature-usage-tracking enable](feature-usage-tracking-enable.html) | Enables anonymous usage statistics tracking.
[feature-usage-tracking disable](feature-usage-tracking-disable.html) | Disables anonymous usage statistics tracking.
[autocomplete](autocomplete.html) |[autocomplete](autocomplete.html) | Configures your current command-line completion settings.
[autocomplete](autocomplete.html) | Configures your current command-line completion settings.
[autocomplete-status](autocomplete-status.html) | Prints the current status of your command-line completion settings.
[autocomplete-enable](autocomplete-enable.html) |[autocomplete](autocomplete.html) | Configures your current command-line completion settings.
[autocomplete-enable](autocomplete-enable.html) | Configures your current command-line completion settings.
[autocomplete-disable](autocomplete-disable.html) | Disables command-line completion for bash and zsh shells.
[doctor](doctor.html) | Checks your system and reports potential problems which may prevent developing with NativeScript.
<% } %>
5 changes: 3 additions & 2 deletions docs/man_pages/general/feature-usage-tracking.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,9 @@ Command | Description
[feature-usage-tracking status](feature-usage-tracking-status.html) | Shows the current configuration for anonymous usage tracking for the NativeScript CLI.
[feature-usage-tracking enable](feature-usage-tracking-enable.html) | Enables anonymous usage statistics tracking.
[feature-usage-tracking disable](feature-usage-tracking-disable.html) | Disables anonymous usage statistics tracking.
[autocomplete](autocomplete.html) |[autocomplete](autocomplete.html) | Configures your current command-line completion settings.
[autocomplete](autocomplete.html) | Configures your current command-line completion settings.
[autocomplete-status](autocomplete-status.html) | Prints the current status of your command-line completion settings.
[autocomplete-enable](autocomplete-enable.html) |[autocomplete](autocomplete.html) | Configures your current command-line completion settings.
[autocomplete-enable](autocomplete-enable.html) | Configures your current command-line completion settings.
[autocomplete-disable](autocomplete-disable.html) | Disables command-line completion for bash and zsh shells.
[doctor](doctor.html) | Checks your system and reports potential problems which may prevent developing with NativeScript.
<% } %>
1 change: 1 addition & 0 deletions docs/man_pages/general/help.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,5 @@ Command | Description
----------|----------
[feature-usage-tracking](feature-usage-tracking.html) | Configures anonymous usage statistics tracking for the NativeScript CLI.
[autocomplete](autocomplete.html) | Prints your current command-line completion settings. If disabled, prompts you to enable it.
[doctor](doctor.html) | Checks your system and reports potential problems which may prevent developing with NativeScript.
<% } %>
4 changes: 3 additions & 1 deletion lib/bootstrap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,4 +58,6 @@ $injector.require("broccoliPluginWrapper", "./tools/broccoli/broccoli-plugin-wra

$injector.require("pluginsService", "./services/plugins-service");
$injector.requireCommand("plugin|add", "./commands/plugin/add-plugin");
$injector.requireCommand("plugin|remove", "./commands/plugin/remove-plugin");
$injector.requireCommand("plugin|remove", "./commands/plugin/remove-plugin");

$injector.require("doctorService", "./services/doctor-service");
2 changes: 1 addition & 1 deletion lib/common
14 changes: 14 additions & 0 deletions lib/declarations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,3 +63,17 @@ interface IOptions extends ICommonOptions {
keyStoreAlias: string;
keyStoreAliasPassword: string;
}

/**
* Verifies the host OS configuration and prints warnings to the users
* Code behind of the "doctor" command
* @interface
*/
interface IDoctorService {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please remove this, you've already added it to common

/**
* Verifies the host OS configuration and prints warnings to the users
*
* @returns {boolean} true if at least one warning was printed
*/
printWarnings(): boolean;
}
79 changes: 79 additions & 0 deletions lib/services/doctor-service.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
///<reference path="../.d.ts"/>
"use strict";
import os = require("os");

class DoctorService implements IDoctorService {

constructor(
private $hostInfo: IHostInfo,
private $sysInfo: ISysInfo,
private $logger: ILogger) { }

public printWarnings(): boolean {
let result = false;
let sysInfo = this.$sysInfo.getSysInfo();

if (!sysInfo.adbVer) {
this.$logger.warn("WARNING: adb from the Android SDK is not installed or is not configured properly.");
this.$logger.out("For Android-related operations, the NativeScript CLI will use a built-in version of adb." + os.EOL
+ "To avoid possible issues with the native Android emulator, Genymotion or connected" + os.EOL
+ "Android devices, verify that you have installed the latest Android SDK and" + os.EOL
+ "its dependencies as described in http://developer.android.com/sdk/index.html#Requirements" + os.EOL);

this.printPackageManagerTip();
result = true;
}
if (!sysInfo.antVer) {
this.$logger.warn("WARNING: Apache Ant is not installed or is not configured properly.");
this.$logger.out("You will not be able to build your projects for Android." + os.EOL
+ "To be able to build for Android, download and install Apache Ant and" + os.EOL
+ "its dependencies as described in http://ant.apache.org/manual/index.html" + os.EOL);

this.printPackageManagerTip();
result = true;
}
if (!sysInfo.androidInstalled) {
this.$logger.warn("WARNING: The Android SDK is not installed or is not configured properly.");
this.$logger.out("You will not be able to build your projects for Android and run them in the native emulator." + os.EOL
+ "To be able to build for Android and run apps in the native emulator, verify that you have" + os.EOL
+ "installed the latest Android SDK and its dependencies as described in http://developer.android.com/sdk/index.html#Requirements" + os.EOL
);

this.printPackageManagerTip();
result = true;
}
if (this.$hostInfo.isDarwin && !sysInfo.xcodeVer) {
this.$logger.warn("WARNING: Xcode is not installed or is not configured properly.");
this.$logger.out("You will not be able to build your projects for iOS or run them in the iOS Simulator." + os.EOL
+ "To be able to build for iOS and run apps in the native emulator, verify that you have installed Xcode." + os.EOL);
result = true;
}
if (!sysInfo.itunesInstalled) {
this.$logger.warn("WARNING: iTunes is not installed.");
this.$logger.out("You will not be able to work with iOS devices via cable connection." + os.EOL
+ "To be able to work with connected iOS devices," + os.EOL
+ "download and install iTunes from http://www.apple.com" + os.EOL);
result = true;
}
if(!sysInfo.javaVer) {
this.$logger.warn("WARNING: The Java Development Kit (JDK) is not installed or is not configured properly.");
this.$logger.out("You will not be able to work with the Android SDK and you might not be able" + os.EOL
+ "to perform some Android-related operations. To ensure that you can develop and" + os.EOL
+ "test your apps for Android, verify that you have installed the JDK as" + os.EOL
+ "described in http://docs.oracle.com/javase/8/docs/technotes/guides/install/install_overview.html (for JDK 8)" + os.EOL
+ "or http://docs.oracle.com/javase/7/docs/webnotes/install/ (for JDK 7)." + os.EOL);
result = true;
}

return result;
}

private printPackageManagerTip() {
if (this.$hostInfo.isWindows) {
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);
} else if (this.$hostInfo.isDarwin) {
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);
}
}
}
$injector.register("doctorService", DoctorService);