Skip to content

Commit 273b5d8

Browse files
Fix PR comments
1 parent d97c0d5 commit 273b5d8

File tree

8 files changed

+117
-119
lines changed

8 files changed

+117
-119
lines changed

lib/declarations.d.ts

-58
Original file line numberDiff line numberDiff line change
@@ -23,54 +23,6 @@ interface ISpawnFromEventOptions {
2323
ignoreError?: boolean;
2424
}
2525

26-
interface ISysInfoData {
27-
// os stuff
28-
/** os platform flavour, reported by os.platform */
29-
platform: string;
30-
/** Full os name, like `uname -a` on unix, registry query on win */
31-
os: string;
32-
/** .net version, applicable to windows only */
33-
dotNetVer: string;
34-
/** The command shell in use, usually bash or cmd */
35-
shell: string;
36-
37-
// node stuff
38-
/** node.js version, returned by `process.version` */
39-
nodeVer: string;
40-
/** npm version, returned by `npm -v` */
41-
npmVer: string;
42-
/** Process architecture, returned by `process.arch` */
43-
procArch: string;
44-
/** node-gyp version as returned by `node-gyp -v`*/
45-
nodeGypVer: string;
46-
47-
// dependencies
48-
/** version of java, as returned by `java -version` */
49-
javaVer: string;
50-
/** Xcode version string as returned by `xcodebuild -version`. Valid only on Mac */
51-
xcodeVer: string;
52-
/** Version string of adb, as returned by `adb version` */
53-
adbVer: string;
54-
/** Whether iTunes is installed on the machine */
55-
itunesInstalled: boolean;
56-
/** Whether `android` executable can be run */
57-
androidInstalled: boolean;
58-
/** mono version, relevant on Mac only **/
59-
monoVer: string;
60-
/** git version string, as returned by `git --version` **/
61-
gitVer: string;
62-
/** gradle version string as returned by `gradle -v` **/
63-
gradleVer: string;
64-
/** javac version string as returned by `javac -version` **/
65-
javacVersion: string;
66-
/** pod version string, as returned by `pod --version` **/
67-
cocoapodVer: string;
68-
/** xcodeproj gem location, as returned by `which gem xcodeproj` **/
69-
xcodeprojGemLocation: string;
70-
/** true id CocoaPods can successfully execute pod install **/
71-
isCocoaPodsWorkingCorrectly: boolean;
72-
}
73-
7426
/**
7527
* Describes single registry available for search.
7628
*/
@@ -111,16 +63,6 @@ interface IHiveIds {
11163
HKU: IHiveId;
11264
}
11365

114-
/**
115-
* Describes warning returned from nativescript-doctor check.
116-
*/
117-
interface IWarning {
118-
/** The warning. */
119-
warning: string;
120-
/** Additional information for the warning. */
121-
additionalInformation: string;
122-
}
123-
12466
interface IDictionary<T> {
12567
[key: string]: T
12668
}

lib/definitions/osenv.d.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
declare module "osenv" {
22
function home(): string;
33
function shell(): string;
4-
}
4+
}

lib/definitions/unzip.d.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
declare module "unzip" {
22
export function Extract(options: { path: string }): NodeJS.WritableStream;
3-
}
3+
}

lib/doctor.ts

+9-32
Original file line numberDiff line numberDiff line change
@@ -5,24 +5,25 @@ import { HostInfo } from "./host-info";
55
import { AndroidLocalBuildRequirements } from "./local-build-requirements/android-local-build-requirements";
66
import { IosLocalBuildRequirements } from "./local-build-requirements/ios-local-build-requirements";
77
import { Helpers } from "./helpers";
8+
import { IWarning } from "../typings/nativescript-doctor";
89
import * as semver from "semver";
910

1011
export class Doctor {
1112
private static MIN_SUPPORTED_POD_VERSION = "0.38.2";
1213

13-
constructor(private sysInfo: SysInfo,
14+
constructor(private androidLocalBuildRequirements: AndroidLocalBuildRequirements,
15+
private helpers: Helpers,
1416
private hostInfo: HostInfo,
15-
private androidLocalBuildRequirements: AndroidLocalBuildRequirements,
16-
private iosLocalBuildRequirements: IosLocalBuildRequirements,
17-
private helpers: Helpers) { }
17+
private iOSLocalBuildRequirements: IosLocalBuildRequirements,
18+
private sysInfo: SysInfo) { }
1819

1920
public async canExecuteLocalBuild(platform: string): Promise<boolean> {
2021
this.validatePlatform(platform);
2122

22-
if (platform.toLocaleLowerCase() === Constants.ANDROID_PLATFORM_NAME.toLocaleLowerCase()) {
23+
if (platform.toLowerCase() === Constants.ANDROID_PLATFORM_NAME.toLowerCase()) {
2324
return await this.androidLocalBuildRequirements.checkRequirements();
24-
} else if (platform.toLocaleLowerCase() === Constants.IOS_PLATFORM_NAME.toLocaleLowerCase()) {
25-
return await this.iosLocalBuildRequirements.checkRequirements();
25+
} else if (platform.toLowerCase() === Constants.IOS_PLATFORM_NAME.toLowerCase()) {
26+
return await this.iOSLocalBuildRequirements.checkRequirements();
2627
}
2728

2829
return false;
@@ -93,31 +94,13 @@ export class Doctor {
9394
+ `To be able to build such projects, verify that you have at least ${Doctor.MIN_SUPPORTED_POD_VERSION} version installed.`
9495
});
9596
}
96-
97-
if (!sysInfoData.monoVer || semver.lt(sysInfoData.monoVer, "3.12.0")) {
98-
result.push({
99-
warning: "WARNING: Mono 3.12 or later is not installed or not configured properly.",
100-
additionalInformation: "You will not be able to work with Android devices in the device simulator or debug on connected Android devices." + EOL
101-
+ "To be able to work with Android in the device simulator and debug on connected Android devices," + EOL
102-
+ "download and install Mono 3.12 or later from http://www.mono-project.com/download/" + EOL
103-
});
104-
}
10597
} else {
10698
result.push({
10799
warning: "NOTE: You can develop for iOS only on Mac OS X systems.",
108100
additionalInformation: "To be able to work with iOS devices and projects, you need Mac OS X Mavericks or later." + EOL
109101
});
110102
}
111103

112-
if (!sysInfoData.itunesInstalled) {
113-
result.push({
114-
warning: "WARNING: iTunes is not installed.",
115-
additionalInformation: "You will not be able to work with iOS devices via cable connection." + EOL
116-
+ "To be able to work with connected iOS devices," + EOL
117-
+ "download and install iTunes from http://www.apple.com" + EOL
118-
});
119-
}
120-
121104
if (!sysInfoData.javaVer) {
122105
result.push({
123106
warning: "WARNING: The Java Development Kit (JDK) is not installed or is not configured properly.",
@@ -142,13 +125,7 @@ export class Doctor {
142125
}
143126

144127
private isPlatformSupported(platform: string): boolean {
145-
return Constants.SUPPORTED_PLATFORMS.reduce((prevValue, currentValue) => {
146-
if (!prevValue) {
147-
return currentValue.toLocaleLowerCase() === platform.toLocaleLowerCase();
148-
} else {
149-
return prevValue;
150-
}
151-
}, false);
128+
return Constants.SUPPORTED_PLATFORMS.map(pl => pl.toLowerCase()).indexOf(platform.toLowerCase()) !== -1;
152129
}
153130

154131
private validatePlatform(platform: string): void {

lib/index.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,11 @@ const winreg = new WinReg();
1313
const hostInfo = new HostInfo(winreg);
1414
const fileSystem = new FileSystem();
1515
const helpers = new Helpers();
16-
const sysInfo = new SysInfo(childProcess, hostInfo, fileSystem, winreg, helpers);
16+
const sysInfo = new SysInfo(childProcess, fileSystem, helpers, hostInfo, winreg);
1717

1818
const androidLocalBuildRequirements = new AndroidLocalBuildRequirements(sysInfo);
19-
const iosLocalBuildRequirements = new IosLocalBuildRequirements(sysInfo, hostInfo);
20-
const doctor = new Doctor(sysInfo, hostInfo, androidLocalBuildRequirements, iosLocalBuildRequirements, helpers);
19+
const iOSLocalBuildRequirements = new IosLocalBuildRequirements(sysInfo, hostInfo);
20+
const doctor = new Doctor(androidLocalBuildRequirements, helpers, hostInfo, iOSLocalBuildRequirements, sysInfo);
2121

2222
export {
2323
sysInfo,

lib/sys-info.ts

+4-3
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { ExecOptions } from "child_process";
55
import { WinReg } from "./winreg";
66
import { Helpers } from "./helpers";
77
import { platform } from "os";
8+
import { ISysInfoData } from "../typings/nativescript-doctor";
89
import * as path from "path";
910
import * as osenv from "osenv";
1011
import * as temp from "temp";
@@ -39,10 +40,10 @@ export class SysInfo {
3940
private isCocoaPodsWorkingCorrectlyCache: boolean = null;
4041

4142
constructor(private childProcess: ChildProcess,
42-
private hostInfo: HostInfo,
4343
private fileSystem: FileSystem,
44-
private winreg: WinReg,
45-
private helpers: Helpers) { }
44+
private helpers: Helpers,
45+
private hostInfo: HostInfo,
46+
private winreg: WinReg) { }
4647

4748
public async getJavaVersion(): Promise<string> {
4849
if (!this.javaVerCache) {

test/sys-info.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import * as assert from "assert";
22
import * as path from "path";
33
import { SysInfo } from "../lib/sys-info";
44
import { ChildProcess } from "../lib/wrappers/child-process";
5+
import { ISysInfoData } from "../typings/nativescript-doctor";
56

67
const JavaHomeName = "JAVA_HOME";
78
const AndroidHomeName = "ANDROID_HOME";
@@ -96,7 +97,7 @@ function mockSysInfo(childProcessResult: IChildProcessResults, hostInfoOptions?:
9697
extractZip: () => Promise.resolve()
9798
};
9899

99-
return new SysInfo(childProcess, hostInfo, fileSystem, winreg, null);
100+
return new SysInfo(childProcess, fileSystem, null, hostInfo, winreg);
100101
}
101102

102103
function setStdOut(value: string): { stdout: string } {

typings/nativescript-doctor.d.ts

+97-20
Original file line numberDiff line numberDiff line change
@@ -43,49 +43,126 @@ declare module NativeScriptDoctor {
4343

4444
export interface ISysInfoData {
4545
// os stuff
46-
/** os platform flavour, reported by os.platform */
46+
/**
47+
* Os platform flavour, reported by os.platform.
48+
* @type {string}
49+
*/
4750
platform: string;
48-
/** Full os name, like `uname -a` on unix, registry query on win */
51+
52+
/**
53+
* Full os name, like `uname -a` on unix, registry query on win.
54+
* @type {string}
55+
*/
4956
os: string;
50-
/** .net version, applicable to windows only */
57+
58+
/**
59+
* .net version, applicable to windows only.
60+
* @type {string}
61+
*/
5162
dotNetVer: string;
52-
/** The command shell in use, usually bash or cmd */
63+
64+
/**
65+
* The command shell in use, usually bash or cmd.
66+
* @type {string}
67+
*/
5368
shell: string;
5469

5570
// node stuff
56-
/** node.js version, returned by `process.version` */
71+
/**
72+
* node.js version, returned by `process.version`.
73+
* @type {string}
74+
*/
5775
nodeVer: string;
58-
/** npm version, returned by `npm -v` */
76+
77+
/**
78+
* npm version, returned by `npm -v`.
79+
* @type {string}
80+
*/
5981
npmVer: string;
60-
/** Process architecture, returned by `process.arch` */
82+
83+
/**
84+
* Process architecture, returned by `process.arch`.
85+
* @type {string}
86+
*/
6187
procArch: string;
62-
/** node-gyp version as returned by `node-gyp -v`*/
88+
89+
/**
90+
* node-gyp version as returned by `node-gyp -v`.
91+
* @type {string}
92+
*/
6393
nodeGypVer: string;
6494

6595
// dependencies
66-
/** version of java, as returned by `java -version` */
96+
/**
97+
* Version of java, as returned by `java -version`.
98+
* @type {string}
99+
*/
67100
javaVer: string;
68-
/** Xcode version string as returned by `xcodebuild -version`. Valid only on Mac */
101+
102+
/**
103+
* Xcode version string as returned by `xcodebuild -version`. Valid only on Mac.
104+
* @type {string}
105+
*/
69106
xcodeVer: string;
70-
/** Version string of adb, as returned by `adb version` */
107+
108+
/**
109+
* Version string of adb, as returned by `adb version`.
110+
* @type {string}
111+
*/
71112
adbVer: string;
72-
/** Whether iTunes is installed on the machine */
113+
114+
/**
115+
* Whether iTunes is installed on the machine.
116+
* @type {boolean}
117+
*/
73118
itunesInstalled: boolean;
74-
/** Whether `android` executable can be run */
119+
120+
/**
121+
* Whether `android` executable can be run.
122+
* @type {boolean}
123+
*/
75124
androidInstalled: boolean;
76-
/** mono version, relevant on Mac only **/
125+
126+
/**
127+
* mono version, relevant on Mac only.
128+
* @type {string}
129+
*/
77130
monoVer: string;
78-
/** git version string, as returned by `git --version` **/
131+
132+
/**
133+
* git version string, as returned by `git --version`.
134+
* @type {string}
135+
*/
79136
gitVer: string;
80-
/** gradle version string as returned by `gradle -v` **/
137+
138+
/**
139+
* gradle version string as returned by `gradle -v`.
140+
* @type {string}
141+
*/
81142
gradleVer: string;
82-
/** javac version string as returned by `javac -version` **/
143+
144+
/**
145+
* javac version string as returned by `javac -version`.
146+
* @type {string}
147+
*/
83148
javacVersion: string;
84-
/** pod version string, as returned by `pod --version` **/
149+
150+
/**
151+
* pod version string, as returned by `pod --version`.
152+
* @type {string}
153+
*/
85154
cocoapodVer: string;
86-
/** xcodeproj gem location, as returned by `which gem xcodeproj` **/
155+
156+
/**
157+
* xcodeproj gem location, as returned by `which gem xcodeproj`.
158+
* @type {string}
159+
*/
87160
xcodeprojGemLocation: string;
88-
/** true id CocoaPods can successfully execute pod install **/
161+
162+
/**
163+
* true id CocoaPods can successfully execute pod install.
164+
* @type {boolean}
165+
*/
89166
isCocoaPodsWorkingCorrectly: boolean;
90167
}
91168

0 commit comments

Comments
 (0)