Skip to content

Commit bdaea53

Browse files
Merge pull request #6 from NativeScript/milanov/update-readme
Update README.md
2 parents 3377792 + 39c82eb commit bdaea53

File tree

6 files changed

+455
-31
lines changed

6 files changed

+455
-31
lines changed

README.md

+344
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,346 @@
11
# nativescript-doctor
22
Library that helps identifying if the environment can be used for development of {N} apps.
3+
4+
# Installation
5+
1. Using npm
6+
```bash
7+
$ npm install nativescript-doctor --save
8+
```
9+
10+
# Requirements
11+
1. Node.js 4.3.0 or later
12+
13+
# Usage
14+
* Module `doctor`:
15+
- Usage:
16+
```TypeScript
17+
import { doctor } from "nativescript-doctor"
18+
19+
async function main() {
20+
const canExecuteLocalBuildForAndroid = await doctor.canExecuteLocalBuild("Android");
21+
const canExecuteLocalBuildForIos = await doctor.canExecuteLocalBuild("iOS");
22+
console.log("Can execute local build for Android: ", canExecuteLocalBuildForAndroid);
23+
console.log("Can execute local build for iOS: ", canExecuteLocalBuildForIos);
24+
}
25+
26+
main();
27+
```
28+
29+
- Interfaces:
30+
```TypeScript
31+
/**
32+
* Describes methods which help identifying if the environment can be used for development of {N} apps.
33+
*/
34+
interface IDoctor {
35+
/**
36+
* Checks if a local build can be executed on the current machine.
37+
* @param {string} platform The platform for which to check if local build is possible.
38+
* @return {Promise<boolean>} true if local build can be executed for the provided platform.
39+
*/
40+
canExecuteLocalBuild(platform: string): Promise<boolean>;
41+
42+
/**
43+
* Executes all checks for the current environment and returns the warnings from each check.
44+
* @return {Promise<IWarning[]>} Array of all the warnings from all checks. If there are no warnings will return empty array.
45+
*/
46+
getWarnings(): Promise<IWarning[]>;
47+
}
48+
49+
/**
50+
* Describes warning returned from nativescript-doctor check.
51+
*/
52+
interface IWarning {
53+
/** The warning. */
54+
warning: string;
55+
/** Additional information for the warning. */
56+
additionalInformation: string;
57+
}
58+
```
59+
60+
* Module `sysInfo`:
61+
- Usage:
62+
```TypeScript
63+
import { sysInfo } from "nativescript-doctor";
64+
65+
async function main() {
66+
const javaVersion = await sysInfo.getJavaVersion();
67+
console.log("java: ", javaVersion);
68+
69+
const javacVersion = await sysInfo.getJavaCompilerVersion();
70+
console.log("javac: ", javacVersion);
71+
72+
const adbVersion = await sysInfo.getAdbVersion();
73+
console.log("adb: ", adbVersion);
74+
75+
const cocoaPodsVersion = await sysInfo.getCocoaPodsVersion();
76+
console.log("cocoapods: ", cocoaPodsVersion);
77+
78+
const gitVersion = await sysInfo.getGitVersion();
79+
console.log("git: ", gitVersion);
80+
81+
const gradleVersion = await sysInfo.getGradleVersion();
82+
console.log("gradle: ", gradleVersion);
83+
84+
const monoVersion = await sysInfo.getMonoVersion();
85+
console.log("mono: ", monoVersion);
86+
87+
const nodeVersion = await sysInfo.getNodeVersion();
88+
console.log("node: ", nodeVer);
89+
90+
const nodeGypVersion = await sysInfo.getNodeGypVersion();
91+
console.log("node-gyp: ", nodeGypVersion);
92+
93+
const osName = await sysInfo.getOs();
94+
console.log("os: ", osName);
95+
96+
const xcodeprojGemLocation = await sysInfo.getXCodeProjGemLocation();
97+
console.log("xcodeproj gem location: ", xcodeprojGemLocation);
98+
99+
const xcodeVersion = await sysInfo.getXCodeVersion();
100+
console.log("xcode: ", xcodeVersion);
101+
102+
const isAndroidInstalled = await sysInfo.isAndroidInstalled();
103+
console.log("is Android installed: ", isAndroidInstalled);
104+
105+
const isITunesInstalled = await sysInfo.isITunesInstalled();
106+
console.log("is iTunes installed: ", isITunesInstalled);
107+
108+
const isCocoaPodsWorkingCorrectly = await sysInfo.isCocoaPodsWorkingCorrectly();
109+
console.log("is cocoapods working correctly: ", isCocoaPodsWorkingCorrectly);
110+
111+
const sysInfoData = await sysInfo.getSysInfo();
112+
console.log("sysInfo: ", sysInfoData);
113+
}
114+
115+
main();
116+
117+
```
118+
119+
- Interfaces:
120+
```TypeScript
121+
/**
122+
* Describes methods which helps collecting system information.
123+
*/
124+
interface ISysInfo {
125+
/**
126+
* Returns the currently installed Java version.
127+
* @return {Promise<string>} The currently installed Java version.
128+
*/
129+
getJavaVersion(): Promise<string>;
130+
131+
/**
132+
* Returns the currently installed Java compiler version.
133+
* @return {Promise<string>} The currently installed Java compiler version.
134+
*/
135+
getJavaCompilerVersion(): Promise<string>;
136+
137+
/**
138+
* Returns the currently installed version of Xcode.
139+
* @return {Promise<string>} Returns the currently installed version of Xcode or null if Xcode is not installed or executed on Linux or Windows.
140+
*/
141+
getXCodeVersion(): Promise<string>;
142+
143+
/**
144+
* Returns the currently installed Node.js version.
145+
* @return {Promise<string>} Returns the currently installed Node.js version.
146+
*/
147+
getNodeVersion(): Promise<string>;
148+
149+
/**
150+
* Returns the currently installed node-gyp version.
151+
* @return {Promise<string>} Returns the currently installed node-gyp version. If node-gyp is not installed it will return null.
152+
*/
153+
getNodeGypVersion(): Promise<string>;
154+
155+
/**
156+
* Returns the xcodeproj gem location.
157+
* @return {Promise<string>} Returns the xcodeproj gem location. If the the xcodeproj gem is not installed it will return null.
158+
*/
159+
getXCodeProjGemLocation(): Promise<string>;
160+
161+
/**
162+
* Checks if iTunes is installed.
163+
* @return {Promise<string>} Returns true if iTunes is installed.
164+
*/
165+
isITunesInstalled(): Promise<boolean>;
166+
167+
/**
168+
* Returns the currently installed Cocoapods version.
169+
* @return {Promise<string>} Returns the currently installed Cocoapods version. It will return null if Cocoapods is not installed.
170+
*/
171+
getCocoaPodsVersion(): Promise<string>;
172+
173+
/**
174+
* Returns the os name.
175+
* @return {Promise<string>} Returns the os name.
176+
*/
177+
getOs(): Promise<string>;
178+
179+
/**
180+
* Returns the currently installed ADB version.
181+
* @return {Promise<string>} Returns the currently installed ADB version. It will return null if ADB is not installed.
182+
*/
183+
getAdbVersion(): Promise<string>;
184+
185+
/**
186+
* Checks if Android is installed.
187+
* @return {Promise<boolean>} Returns true if Android is installed.
188+
*/
189+
isAndroidInstalled(): Promise<boolean>;
190+
191+
/**
192+
* Returns the currently installed Mono version.
193+
* @return {Promise<string>} Returns the currently installed Mono version. It will return null if Mono is not installed.
194+
*/
195+
getMonoVersion(): Promise<string>;
196+
197+
/**
198+
* Returns the currently installed Git version.
199+
* @return {Promise<string>} Returns the currently installed Git version. It will return null if Git is not installed.
200+
*/
201+
getGitVersion(): Promise<string>;
202+
203+
/**
204+
* Returns the currently installed Gradle version.
205+
* @return {Promise<string>} Returns the currently installed Gradle version. It will return null if Gradle is not installed.
206+
*/
207+
getGradleVersion(): Promise<string>;
208+
209+
/**
210+
* Checks if CocoaPods is working correctly by trying to install one pod.
211+
* @return {Promise<boolean>} Returns true if CocoaPods is working correctly.
212+
*/
213+
isCocoaPodsWorkingCorrectly(): Promise<boolean>;
214+
215+
/**
216+
* Returns the whole system information.
217+
* @return {Promise<ISysInfoData>} The system information.
218+
*/
219+
getSysInfo(): Promise<ISysInfoData>;
220+
}
221+
222+
interface ISysInfoData {
223+
// os stuff
224+
/**
225+
* Os platform flavour, reported by os.platform.
226+
* @type {string}
227+
*/
228+
platform: string;
229+
230+
/**
231+
* Full os name, like `uname -a` on unix, registry query on win.
232+
* @type {string}
233+
*/
234+
os: string;
235+
236+
/**
237+
* .net version, applicable to windows only.
238+
* @type {string}
239+
*/
240+
dotNetVer: string;
241+
242+
/**
243+
* The command shell in use, usually bash or cmd.
244+
* @type {string}
245+
*/
246+
shell: string;
247+
248+
// node stuff
249+
/**
250+
* node.js version, returned by `process.version`.
251+
* @type {string}
252+
*/
253+
nodeVer: string;
254+
255+
/**
256+
* npm version, returned by `npm -v`.
257+
* @type {string}
258+
*/
259+
npmVer: string;
260+
261+
/**
262+
* Process architecture, returned by `process.arch`.
263+
* @type {string}
264+
*/
265+
procArch: string;
266+
267+
/**
268+
* node-gyp version as returned by `node-gyp -v`.
269+
* @type {string}
270+
*/
271+
nodeGypVer: string;
272+
273+
// dependencies
274+
/**
275+
* Version of java, as returned by `java -version`.
276+
* @type {string}
277+
*/
278+
javaVer: string;
279+
280+
/**
281+
* Xcode version string as returned by `xcodebuild -version`. Valid only on Mac.
282+
* @type {string}
283+
*/
284+
xcodeVer: string;
285+
286+
/**
287+
* Version string of adb, as returned by `adb version`.
288+
* @type {string}
289+
*/
290+
adbVer: string;
291+
292+
/**
293+
* Whether iTunes is installed on the machine.
294+
* @type {boolean}
295+
*/
296+
itunesInstalled: boolean;
297+
298+
/**
299+
* Whether `android` executable can be run.
300+
* @type {boolean}
301+
*/
302+
androidInstalled: boolean;
303+
304+
/**
305+
* mono version, relevant on Mac only.
306+
* @type {string}
307+
*/
308+
monoVer: string;
309+
310+
/**
311+
* git version string, as returned by `git --version`.
312+
* @type {string}
313+
*/
314+
gitVer: string;
315+
316+
/**
317+
* gradle version string as returned by `gradle -v`.
318+
* @type {string}
319+
*/
320+
gradleVer: string;
321+
322+
/**
323+
* javac version string as returned by `javac -version`.
324+
* @type {string}
325+
*/
326+
javacVersion: string;
327+
328+
/**
329+
* pod version string, as returned by `pod --version`.
330+
* @type {string}
331+
*/
332+
cocoaPodsVer: string;
333+
334+
/**
335+
* xcodeproj gem location, as returned by `which gem xcodeproj`.
336+
* @type {string}
337+
*/
338+
xcodeprojGemLocation: string;
339+
340+
/**
341+
* true id CocoaPods can successfully execute pod install.
342+
* @type {boolean}
343+
*/
344+
isCocoaPodsWorkingCorrectly: boolean;
345+
}
346+
```

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

0 commit comments

Comments
 (0)