Skip to content

Commit d1c865e

Browse files
committed
1 parent 2bced8e commit d1c865e

File tree

4 files changed

+94
-1
lines changed

4 files changed

+94
-1
lines changed

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 AppBuilder CLI.
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+
<% } %>

lib/bootstrap.ts

+2
Original file line numberDiff line numberDiff line change
@@ -185,3 +185,5 @@ $injector.requireCommand("screenbuilder", "./commands/screenbuilder");
185185
$injector.require("webViewService", "./services/web-view-service");
186186
$injector.requireCommand("webview|*list", "./commands/web-view/list-web-views");
187187
$injector.requireCommand("webview|set", "./commands/web-view/set-web-view");
188+
189+
$injector.require("doctorService", "./services/doctor-service");

lib/services/doctor-service.ts

+72
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
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

Comments
 (0)