Skip to content

Commit 9092cb0

Browse files
Add methods descriptions in the definition file.
1 parent 3377792 commit 9092cb0

File tree

5 files changed

+111
-31
lines changed

5 files changed

+111
-31
lines changed

lib/doctor.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -69,15 +69,15 @@ export class Doctor {
6969
});
7070
}
7171

72-
if (!sysInfoData.cocoapodVer) {
72+
if (!sysInfoData.cocoaPodsVer) {
7373
result.push({
7474
warning: "WARNING: CocoaPods is not installed or is not configured properly.",
7575
additionalInformation: "You will not be able to build your projects for iOS if they contain plugin with CocoaPod file." + EOL
7676
+ "To be able to build such projects, verify that you have installed CocoaPods."
7777
});
7878
}
7979

80-
if (sysInfoData.xcodeVer && sysInfoData.cocoapodVer) {
80+
if (sysInfoData.xcodeVer && sysInfoData.cocoaPodsVer) {
8181
let isCocoaPodsWorkingCorrectly = await this.sysInfo.isCocoaPodsWorkingCorrectly();
8282
if (!isCocoaPodsWorkingCorrectly) {
8383
result.push({
@@ -87,7 +87,7 @@ export class Doctor {
8787
}
8888
}
8989

90-
if (sysInfoData.cocoapodVer && semver.valid(sysInfoData.cocoapodVer) && semver.lt(sysInfoData.cocoapodVer, Doctor.MIN_SUPPORTED_POD_VERSION)) {
90+
if (sysInfoData.cocoaPodsVer && semver.valid(sysInfoData.cocoaPodsVer) && semver.lt(sysInfoData.cocoaPodsVer, Doctor.MIN_SUPPORTED_POD_VERSION)) {
9191
result.push({
9292
warning: `WARNING: Your current CocoaPods version is earlier than ${Doctor.MIN_SUPPORTED_POD_VERSION}.`,
9393
additionalInformation: "You will not be able to build your projects for iOS if they contain plugin with CocoaPod file." + EOL

lib/local-build-requirements/ios-local-build-requirements.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ export class IosLocalBuildRequirements {
77

88
public async checkRequirements(): Promise<boolean> {
99
if (!this.hostInfo.isDarwin ||
10-
!await this.sysInfo.getXCodeVersion() ||
11-
!await this.sysInfo.getXCodeProjGemLocation()) {
10+
!await this.sysInfo.getXcodeVersion() ||
11+
!await this.sysInfo.getXcodeprojGemLocation()) {
1212
return false;
1313
}
1414

lib/sys-info.ts

+12-12
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ export class SysInfo {
2929
private nodeGypVerCache: string;
3030
private xCodeprojGemLocationCache: string;
3131
private iTunesInstalledCache: boolean = null;
32-
private cocoapodVerCache: string;
32+
private cocoaPodsVerCache: string;
3333
private osCache: string;
3434
private adbVerCache: string;
3535
private androidInstalledCache: boolean = null;
@@ -75,7 +75,7 @@ export class SysInfo {
7575
return this.javaCompilerVerCache;
7676
}
7777

78-
public async getXCodeVersion(): Promise<string> {
78+
public async getXcodeVersion(): Promise<string> {
7979
if (!this.xCodeVerCache && this.hostInfo.isDarwin) {
8080
const output = await this.execCommand("xcodebuild -version");
8181
const xcodeVersionMatch = output && output.match(SysInfo.XCODE_VERSION_REGEXP);
@@ -110,7 +110,7 @@ export class SysInfo {
110110
return this.nodeGypVerCache;
111111
}
112112

113-
public async getXCodeProjGemLocation(): Promise<string> {
113+
public async getXcodeprojGemLocation(): Promise<string> {
114114
if (!this.xCodeprojGemLocationCache && this.hostInfo.isDarwin) {
115115
const output = await this.execCommand("gem which xcodeproj");
116116
this.xCodeprojGemLocationCache = output ? output.trim() : null;
@@ -139,19 +139,19 @@ export class SysInfo {
139139
return !!this.iTunesInstalledCache;
140140
}
141141

142-
public async getCocoapodVersion(): Promise<string> {
143-
if (!this.cocoapodVerCache && this.hostInfo.isDarwin) {
142+
public async getCocoaPodsVersion(): Promise<string> {
143+
if (!this.cocoaPodsVerCache && this.hostInfo.isDarwin) {
144144
if (this.hostInfo.isDarwin) {
145145
const output = await this.execCommand("pod --version");
146146
// Output of pod --version could contain some warnings. Find the version in it.
147-
const cocoapodVersionMatch = output && output.match(SysInfo.VERSION_REGEXP);
148-
if (cocoapodVersionMatch && cocoapodVersionMatch[0]) {
149-
this.cocoapodVerCache = cocoapodVersionMatch[0].trim();
147+
const cocoaPodsVersionMatch = output && output.match(SysInfo.VERSION_REGEXP);
148+
if (cocoaPodsVersionMatch && cocoaPodsVersionMatch[0]) {
149+
this.cocoaPodsVerCache = cocoaPodsVersionMatch[0].trim();
150150
}
151151
}
152152
}
153153

154-
return this.cocoapodVerCache;
154+
return this.cocoaPodsVerCache;
155155
}
156156

157157
public async getOs(): Promise<string> {
@@ -242,10 +242,10 @@ export class SysInfo {
242242
result.dotNetVer = await this.hostInfo.dotNetVersion();
243243
result.javaVer = await this.getJavaVersion();
244244
result.javacVersion = await this.getJavaCompilerVersion();
245-
result.xcodeVer = await this.getXCodeVersion();
246-
result.xcodeprojGemLocation = await this.getXCodeProjGemLocation();
245+
result.xcodeVer = await this.getXcodeVersion();
246+
result.xcodeprojGemLocation = await this.getXcodeprojGemLocation();
247247
result.itunesInstalled = await this.isITunesInstalled();
248-
result.cocoapodVer = await this.getCocoapodVersion();
248+
result.cocoaPodsVer = await this.getCocoaPodsVersion();
249249
result.adbVer = await this.getAdbVersion();
250250
result.androidInstalled = await this.isAndroidInstalled();
251251
result.monoVer = await this.getMonoVersion();

test/sys-info.ts

+8-8
Original file line numberDiff line numberDiff line change
@@ -212,23 +212,23 @@ describe("SysInfo unit tests", () => {
212212
let result = await sysInfo.getSysInfo();
213213
assertCommonValues(result);
214214
assert.deepEqual(result.xcodeVer, null);
215-
assert.deepEqual(result.cocoapodVer, null);
215+
assert.deepEqual(result.cocoaPodsVer, null);
216216
});
217217

218218
it("on Mac", async () => {
219219
sysInfo = mockSysInfo(childProcessResult, { isWindows: false, isDarwin: true, dotNetVersion: "4.5.1" });
220220
let result = await sysInfo.getSysInfo();
221221
assertCommonValues(result);
222222
assert.deepEqual(result.xcodeVer, "6.4.0");
223-
assert.deepEqual(result.cocoapodVer, childProcessResult.podVersion.result.stdout);
223+
assert.deepEqual(result.cocoaPodsVer, childProcessResult.podVersion.result.stdout);
224224
});
225225

226226
it("on Linux", async () => {
227227
sysInfo = mockSysInfo(childProcessResult, { isWindows: false, isDarwin: false, dotNetVersion: "4.5.1" });
228228
let result = await sysInfo.getSysInfo();
229229
assertCommonValues(result);
230230
assert.deepEqual(result.xcodeVer, null);
231-
assert.deepEqual(result.cocoapodVer, null);
231+
assert.deepEqual(result.cocoaPodsVer, null);
232232
});
233233
});
234234

@@ -238,27 +238,27 @@ describe("SysInfo unit tests", () => {
238238
childProcessResult.podVersion = { shouldThrowError: true };
239239
sysInfo = mockSysInfo(childProcessResult, { isWindows: false, isDarwin: true, dotNetVersion: "4.5.1" });
240240
let result = await sysInfo.getSysInfo();
241-
assert.deepEqual(result.cocoapodVer, null);
241+
assert.deepEqual(result.cocoaPodsVer, null);
242242
});
243243

244244
it("is null when OS is not Mac", async () => {
245245
sysInfo = mockSysInfo(childProcessResult, { isWindows: true, isDarwin: false, dotNetVersion: "4.5.1" });
246246
let result = await sysInfo.getSysInfo();
247-
assert.deepEqual(result.cocoapodVer, null);
247+
assert.deepEqual(result.cocoaPodsVer, null);
248248
});
249249

250250
it("is correct when cocoapods output has warning after version output", async () => {
251251
childProcessResult.podVersion = { result: setStdOut("0.38.2\nWARNING:\n") };
252252
sysInfo = mockSysInfo(childProcessResult, { isWindows: false, isDarwin: true, dotNetVersion: "4.5.1" });
253253
let result = await sysInfo.getSysInfo();
254-
assert.deepEqual(result.cocoapodVer, "0.38.2");
254+
assert.deepEqual(result.cocoaPodsVer, "0.38.2");
255255
});
256256

257257
it("is correct when cocoapods output has warnings before version output", async () => {
258258
childProcessResult.podVersion = { result: setStdOut("WARNING\nWARNING2\n0.38.2") };
259259
sysInfo = mockSysInfo(childProcessResult, { isWindows: false, isDarwin: true, dotNetVersion: "4.5.1" });
260260
let result = await sysInfo.getSysInfo();
261-
assert.deepEqual(result.cocoapodVer, "0.38.2");
261+
assert.deepEqual(result.cocoaPodsVer, "0.38.2");
262262
});
263263
});
264264

@@ -294,7 +294,7 @@ describe("SysInfo unit tests", () => {
294294
assert.deepEqual(result.monoVer, null);
295295
assert.deepEqual(result.gradleVer, null);
296296
assert.deepEqual(result.gitVer, null);
297-
assert.deepEqual(result.cocoapodVer, null);
297+
assert.deepEqual(result.cocoaPodsVer, null);
298298
};
299299

300300
it("on Windows", () => {

typings/nativescript-doctor.d.ts

+86-6
Original file line numberDiff line numberDiff line change
@@ -2,42 +2,122 @@ declare module NativeScriptDoctor {
22
export const doctor: IDoctor;
33
export const sysInfo: ISysInfo;
44

5+
/**
6+
* Describes methods which helps collecting system information.
7+
*/
58
export interface ISysInfo {
9+
/**
10+
* Returns the currently installed Java version.
11+
* @return {Promise<string>} The currently installed Java version.
12+
*/
613
getJavaVersion(): Promise<string>;
714

15+
/**
16+
* Returns the currently installed Java compiler version.
17+
* @return {Promise<string>} The currently installed Java compiler version.
18+
*/
819
getJavaCompilerVersion(): Promise<string>;
920

10-
getXCodeVersion(): Promise<string>;
21+
/**
22+
* Returns the currently installed version of Xcode.
23+
* @return {Promise<string>} Returns the currently installed version of Xcode or null if Xcode is not installed or executed on Linux or Windows.
24+
*/
25+
getXcodeVersion(): Promise<string>;
1126

27+
/**
28+
* Returns the currently installed Node.js version.
29+
* @return {Promise<string>} Returns the currently installed Node.js version.
30+
*/
1231
getNodeVersion(): Promise<string>;
1332

33+
/**
34+
* Returns the currently installed node-gyp version.
35+
* @return {Promise<string>} Returns the currently installed node-gyp version. If node-gyp is not installed it will return null.
36+
*/
1437
getNodeGypVersion(): Promise<string>;
1538

16-
getXCodeProjGemLocation(): Promise<string>;
39+
/**
40+
* Returns the xcodeproj gem location.
41+
* @return {Promise<string>} Returns the xcodeproj gem location. If the the xcodeproj gem is not installed it will return null.
42+
*/
43+
getXcodeprojGemLocation(): Promise<string>;
1744

45+
/**
46+
* Checks if iTunes is installed.
47+
* @return {Promise<string>} Returns true if iTunes is installed.
48+
*/
1849
isITunesInstalled(): Promise<boolean>;
1950

20-
getCocoapodVersion(): Promise<string>;
51+
/**
52+
* Returns the currently installed Cocoapods version.
53+
* @return {Promise<string>} Returns the currently installed Cocoapods version. It will return null if Cocoapods is not installed.
54+
*/
55+
getCocoaPodsVersion(): Promise<string>;
2156

57+
/**
58+
* Returns the os name.
59+
* @return {Promise<string>} Returns the os name.
60+
*/
2261
getOs(): Promise<string>;
2362

63+
/**
64+
* Returns the currently installed ADB version.
65+
* @return {Promise<string>} Returns the currently installed ADB version. It will return null if ADB is not installed.
66+
*/
2467
getAdbVersion(): Promise<string>;
2568

69+
/**
70+
* Checks if Android is installed.
71+
* @return {Promise<boolean>} Returns true if Android is installed.
72+
*/
2673
isAndroidInstalled(): Promise<boolean>;
2774

75+
/**
76+
* Returns the currently installed Mono version.
77+
* @return {Promise<string>} Returns the currently installed Mono version. It will return null if Mono is not installed.
78+
*/
2879
getMonoVersion(): Promise<string>;
2980

81+
/**
82+
* Returns the currently installed Git version.
83+
* @return {Promise<string>} Returns the currently installed Git version. It will return null if Git is not installed.
84+
*/
3085
getGitVersion(): Promise<string>;
3186

87+
/**
88+
* Returns the currently installed Gradle version.
89+
* @return {Promise<string>} Returns the currently installed Gradle version. It will return null if Gradle is not installed.
90+
*/
3291
getGradleVersion(): Promise<string>;
3392

34-
getSysInfo(): Promise<ISysInfoData>;
93+
/**
94+
* Checks if CocoaPods is working correctly by trying to install one pod.
95+
* @return {Promise<boolean>} Returns true if CocoaPods is working correctly.
96+
*/
97+
isCocoaPodsWorkingCorrectly(): Promise<boolean>;
3598

36-
isCocoaPodsWorkingCorrectly(): Promise<boolean>
99+
/**
100+
* Returns the whole system information.
101+
* @return {Promise<ISysInfoData>} The system information.
102+
*/
103+
getSysInfo(): Promise<ISysInfoData>;
37104
}
38105

106+
/**
107+
* Describes methods which help identifying if the environment can be used for development of {N} apps.
108+
*/
39109
export interface IDoctor {
110+
/**
111+
* Checks if a local build can be executed on the current machine.
112+
* @param {string} platform The platform for which to check if local build is possible.
113+
* @return {Promise<boolean>} true if local build can be executed for the provided platform.
114+
*/
40115
canExecuteLocalBuild(platform: string): Promise<boolean>;
116+
117+
/**
118+
* Executes all checks for the current environment and returns the warnings from each check.
119+
* @return {Promise<IWarning[]>} Array of all the warnings from all checks. If there are no warnings will return empty array.
120+
*/
41121
getWarnings(): Promise<IWarning[]>;
42122
}
43123

@@ -151,7 +231,7 @@ declare module NativeScriptDoctor {
151231
* pod version string, as returned by `pod --version`.
152232
* @type {string}
153233
*/
154-
cocoapodVer: string;
234+
cocoaPodsVer: string;
155235

156236
/**
157237
* xcodeproj gem location, as returned by `which gem xcodeproj`.

0 commit comments

Comments
 (0)