Skip to content

Commit 4e8b172

Browse files
teobugslayerFatme Havaluova
authored and
Fatme Havaluova
committed
Implement doctor command
See #480
1 parent 3f73060 commit 4e8b172

13 files changed

+135
-12
lines changed

docs/man_pages/general/autocomplete-disable.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@ Command | Description
1515
----------|----------
1616
[autocomplete](autocomplete.html) | Asks for confirmation if command line autocompletion should be enabled for bash and zsh.
1717
[autocomplete-status](autocomplete-status.html) | Prints the current status of your command-line completion settings.
18-
[autocomplete-enable](autocomplete-enable.html) |[autocomplete](autocomplete.html) | Configures your current command-line completion settings.
18+
[autocomplete-enable](autocomplete-enable.html) | Configures your current command-line completion settings.
1919
[feature-usage-tracking](feature-usage-tracking.html) | Configures anonymous usage statistics tracking for the NativeScript command-line interface.
2020
[help](help.html) | Lists the available commands or shows information about the selected command.
21+
[doctor](doctor.html) | Checks your system and reports potential problems which may prevent developing with NativeScript.
2122
<% } %>

docs/man_pages/general/autocomplete-enable.md

+1
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,5 @@ Command | Description
1818
[autocomplete-disable](autocomplete-disable.html) | Disables command-line completion for bash and zsh shells.
1919
[feature-usage-tracking](feature-usage-tracking.html) | Configures anonymous usage statistics tracking for the NativeScript command-line interface.
2020
[help](help.html) | Lists the available commands or shows information about the selected command.
21+
[doctor](doctor.html) | Checks your system and reports potential problems which may prevent developing with NativeScript.
2122
<% } %>

docs/man_pages/general/autocomplete-status.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,9 @@ Prints your current command-line completion settings.
1313
Command | Description
1414
----------|----------
1515
[autocomplete](autocomplete.html) | Prints your current command-line completion settings. If disabled, prompts you to enable it.
16-
[autocomplete-enable](autocomplete-enable.html) |[autocomplete](autocomplete.html) | Configures your current command-line completion settings.
16+
[autocomplete-enable](autocomplete-enable.html) | Configures your current command-line completion settings.
1717
[autocomplete-disable](autocomplete-disable.html) | Disables command-line completion for bash and zsh shells.
1818
[feature-usage-tracking](feature-usage-tracking.html) | Configures anonymous usage statistics tracking for the NativeScript command-line interface.
1919
[help](help.html) | Lists the available commands or shows information about the selected command.
20+
[doctor](doctor.html) | Checks your system and reports potential problems which may prevent developing with NativeScript.
2021
<% } %>

docs/man_pages/general/autocomplete.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@ Prints your current command-line completion settings. If disabled, prompts you t
2424
Command | Description
2525
----------|----------
2626
[autocomplete-status](autocomplete-status.html) | Prints the current status of your command-line completion settings.
27-
[autocomplete-enable](autocomplete-enable.html) |[autocomplete](autocomplete.html) | Configures your current command-line completion settings.
27+
[autocomplete-enable](autocomplete-enable.html) | Configures your current command-line completion settings.
2828
[autocomplete-disable](autocomplete-disable.html) | Disables command-line completion for bash and zsh shells.
2929
[feature-usage-tracking](feature-usage-tracking.html) | Configures anonymous usage statistics tracking for the NativeScript command-line interface.
30+
[doctor](doctor.html) | Checks your system and reports potential problems which may prevent developing with NativeScript.
3031
<% } %>

docs/man_pages/general/doctor.md

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
doctor
2+
==========
3+
4+
Usage | Synopsis
5+
------|-------
6+
General | `$ tns doctor`
7+
8+
Checks your system and reports potential problems which may prevent developing with NativeScript.
9+
10+
11+
<% if(isHtml) { %>
12+
### Related Commands
13+
14+
Command | Description
15+
----------|----------
16+
[feature-usage-tracking](feature-usage-tracking.html) | Configures anonymous usage statistics tracking for the NativeScript CLI.
17+
[autocomplete](autocomplete.html) | Prints your current command-line completion settings. If disabled, prompts you to enable it.
18+
[help](help.html) | Lists the available commands or shows information about the selected command.
19+
<% } %>

docs/man_pages/general/feature-usage-tracking-disable.md

+3-2
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,9 @@ Command | Description
1414
[feature-usage-tracking](feature-usage-tracking.html) | Configures anonymous usage statistics tracking for the NativeScript CLI.
1515
[feature-usage-tracking status](feature-usage-tracking-status.html) | Shows the current configuration for anonymous usage tracking for the NativeScript CLI.
1616
[feature-usage-tracking enable](feature-usage-tracking-enable.html) | Enables anonymous usage statistics tracking.
17-
[autocomplete](autocomplete.html) |[autocomplete](autocomplete.html) | Configures your current command-line completion settings.
17+
[autocomplete](autocomplete.html) | Configures your current command-line completion settings.
1818
[autocomplete-status](autocomplete-status.html) | Prints the current status of your command-line completion settings.
19-
[autocomplete-enable](autocomplete-enable.html) |[autocomplete](autocomplete.html) | Configures your current command-line completion settings.
19+
[autocomplete-enable](autocomplete-enable.html) | Configures your current command-line completion settings.
2020
[autocomplete-disable](autocomplete-disable.html) | Disables command-line completion for bash and zsh shells.
21+
[doctor](doctor.html) | Checks your system and reports potential problems which may prevent developing with NativeScript.
2122
<% } %>

docs/man_pages/general/feature-usage-tracking-enable.md

+3-2
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,9 @@ Command | Description
1414
[feature-usage-tracking](feature-usage-tracking.html) | Configures anonymous usage statistics tracking for the NativeScript CLI.
1515
[feature-usage-tracking status](feature-usage-tracking-status.html) | Shows the current configuration for anonymous usage tracking for the NativeScript CLI.
1616
[feature-usage-tracking disable](feature-usage-tracking-disable.html) | Disables anonymous usage statistics tracking.
17-
[autocomplete](autocomplete.html) |[autocomplete](autocomplete.html) | Configures your current command-line completion settings.
17+
[autocomplete](autocomplete.html) | Configures your current command-line completion settings.
1818
[autocomplete-status](autocomplete-status.html) | Prints the current status of your command-line completion settings.
19-
[autocomplete-enable](autocomplete-enable.html) |[autocomplete](autocomplete.html) | Configures your current command-line completion settings.
19+
[autocomplete-enable](autocomplete-enable.html) | Configures your current command-line completion settings.
2020
[autocomplete-disable](autocomplete-disable.html) | Disables command-line completion for bash and zsh shells.
21+
[doctor](doctor.html) | Checks your system and reports potential problems which may prevent developing with NativeScript.
2122
<% } %>

docs/man_pages/general/feature-usage-tracking-status.md

+3-2
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,9 @@ Command | Description
1414
[feature-usage-tracking](feature-usage-tracking.html) | Configures anonymous usage statistics tracking for the NativeScript CLI.
1515
[feature-usage-tracking enable](feature-usage-tracking-enable.html) | Enables anonymous usage statistics tracking.
1616
[feature-usage-tracking disable](feature-usage-tracking-disable.html) | Disables anonymous usage statistics tracking.
17-
[autocomplete](autocomplete.html) |[autocomplete](autocomplete.html) | Configures your current command-line completion settings.
17+
[autocomplete](autocomplete.html) | Configures your current command-line completion settings.
1818
[autocomplete-status](autocomplete-status.html) | Prints the current status of your command-line completion settings.
19-
[autocomplete-enable](autocomplete-enable.html) |[autocomplete](autocomplete.html) | Configures your current command-line completion settings.
19+
[autocomplete-enable](autocomplete-enable.html) | Configures your current command-line completion settings.
2020
[autocomplete-disable](autocomplete-disable.html) | Disables command-line completion for bash and zsh shells.
21+
[doctor](doctor.html) | Checks your system and reports potential problems which may prevent developing with NativeScript.
2122
<% } %>

docs/man_pages/general/feature-usage-tracking.md

+3-2
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,9 @@ Command | Description
2323
[feature-usage-tracking status](feature-usage-tracking-status.html) | Shows the current configuration for anonymous usage tracking for the NativeScript CLI.
2424
[feature-usage-tracking enable](feature-usage-tracking-enable.html) | Enables anonymous usage statistics tracking.
2525
[feature-usage-tracking disable](feature-usage-tracking-disable.html) | Disables anonymous usage statistics tracking.
26-
[autocomplete](autocomplete.html) |[autocomplete](autocomplete.html) | Configures your current command-line completion settings.
26+
[autocomplete](autocomplete.html) | Configures your current command-line completion settings.
2727
[autocomplete-status](autocomplete-status.html) | Prints the current status of your command-line completion settings.
28-
[autocomplete-enable](autocomplete-enable.html) |[autocomplete](autocomplete.html) | Configures your current command-line completion settings.
28+
[autocomplete-enable](autocomplete-enable.html) | Configures your current command-line completion settings.
2929
[autocomplete-disable](autocomplete-disable.html) | Disables command-line completion for bash and zsh shells.
30+
[doctor](doctor.html) | Checks your system and reports potential problems which may prevent developing with NativeScript.
3031
<% } %>

docs/man_pages/general/help.md

+1
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,5 @@ Command | Description
2020
----------|----------
2121
[feature-usage-tracking](feature-usage-tracking.html) | Configures anonymous usage statistics tracking for the NativeScript CLI.
2222
[autocomplete](autocomplete.html) | Prints your current command-line completion settings. If disabled, prompts you to enable it.
23+
[doctor](doctor.html) | Checks your system and reports potential problems which may prevent developing with NativeScript.
2324
<% } %>

lib/bootstrap.ts

+3-1
Original file line numberDiff line numberDiff line change
@@ -58,4 +58,6 @@ $injector.require("broccoliPluginWrapper", "./tools/broccoli/broccoli-plugin-wra
5858

5959
$injector.require("pluginsService", "./services/plugins-service");
6060
$injector.requireCommand("plugin|add", "./commands/plugin/add-plugin");
61-
$injector.requireCommand("plugin|remove", "./commands/plugin/remove-plugin");
61+
$injector.requireCommand("plugin|remove", "./commands/plugin/remove-plugin");
62+
63+
$injector.require("doctorService", "./services/doctor-service");

lib/declarations.ts

+14
Original file line numberDiff line numberDiff line change
@@ -64,3 +64,17 @@ interface IOptions extends ICommonOptions {
6464
keyStoreAliasPassword: string;
6565
sdk: string;
6666
}
67+
68+
/**
69+
* Verifies the host OS configuration and prints warnings to the users
70+
* Code behind of the "doctor" command
71+
* @interface
72+
*/
73+
interface IDoctorService {
74+
/**
75+
* Verifies the host OS configuration and prints warnings to the users
76+
*
77+
* @returns {boolean} true if at least one warning was printed
78+
*/
79+
printWarnings(): boolean;
80+
}

lib/services/doctor-service.ts

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

0 commit comments

Comments
 (0)