Skip to content

Commit b3b56d0

Browse files
Merge pull request #10 from NativeScript/milanov/add-method-to-control-sys-info-cache
Add method to control the sys info cache
2 parents e189542 + 358bfd3 commit b3b56d0

14 files changed

+780
-189
lines changed

README.md

+109-2
Original file line numberDiff line numberDiff line change
@@ -73,9 +73,12 @@ Library that helps identifying if the environment can be used for development of
7373
* Module `sysInfo`:
7474
- Usage:
7575
```TypeScript
76-
import { sysInfo } from "nativescript-doctor";
76+
import { sysInfo, setShouldCacheSysInfo } from "nativescript-doctor";
7777

7878
async function main() {
79+
// The default value is true. If set to false the result of each check for each element
80+
// of the sys info will not be cached.
81+
setShouldCacheSysInfo(false);
7982
const javaVersion = await sysInfo.getJavaVersion();
8083
console.log("java: ", javaVersion);
8184

@@ -252,11 +255,24 @@ Library that helps identifying if the environment can be used for development of
252255
*/
253256
isCocoaPodsUpdateRequired(): Promise<boolean>;
254257

258+
/**
259+
* Checks if the Android SDK Tools are installed and configured correctly.
260+
* @return {Promise<boolean>} true if the Android SDK Tools are installed and configured correctly.
261+
*/
262+
isAndroidSdkConfiguredCorrectly(): Promise<boolean>;
263+
255264
/**
256265
* Returns the whole system information.
257266
* @return {Promise<ISysInfoData>} The system information.
258267
*/
259268
getSysInfo(): Promise<ISysInfoData>;
269+
270+
/**
271+
* If set to true each method will cache it's result. The default value is true.
272+
* @param {boolean} shouldCache The cache switch.
273+
* @return {void}
274+
*/
275+
setShouldCacheSysInfo(shouldCache: boolean): void;
260276
}
261277

262278
interface ISysInfoData {
@@ -393,12 +409,18 @@ Library that helps identifying if the environment can be used for development of
393409
* Information about xcproj.
394410
* @type {string}
395411
*/
396-
xcprojInfo: IXcprojInfo
412+
xcprojInfo: IXcprojInfo;
397413

398414
/**
399415
* true if the system requires xcproj to build projects successfully and the CocoaPods version is not compatible with the Xcode.
400416
*/
401417
isCocoaPodsUpdateRequired: boolean;
418+
419+
/**
420+
* true if the Android SDK Tools are installed and configured correctly.
421+
* @type {boolean}
422+
*/
423+
isAndroidSdkConfiguredCorrectly: boolean;
402424
}
403425

404426
/**
@@ -417,6 +439,91 @@ Library that helps identifying if the environment can be used for development of
417439
}
418440
```
419441

442+
* Module `androidToolsInfo`:
443+
- Usage:
444+
```TypeScript
445+
import { androidToolsInfo } from "nativescript-doctor"
446+
447+
function main() {
448+
console.log("path to adb from android home: ", await androidToolsInfo.getPathToAdbFromAndroidHome());
449+
console.log("path to emulator executable: ", androidToolsInfo.getPathToEmulatorExecutable());
450+
console.log("android tools info: ", androidToolsInfo.getToolsInfo());
451+
console.log("ANROID_HOME validation errors: ", await androidToolsInfo.validateAndroidHomeEnvVariable());
452+
console.log("android tools info validation errors: ", await androidToolsInfo.validateInfo());
453+
console.log("javac validation errors: ", await androidToolsInfo.validateJavacVersion(await sysInfo.getJavaCompilerVersion()));
454+
}
455+
456+
main();
457+
```
458+
- Interfaces:
459+
/**
460+
* Describes methods for getting and validating Android tools.
461+
*/
462+
interface IAndroidToolsInfo {
463+
/**
464+
* Returns the Android tools info.
465+
* @return {NativeScriptDoctor.IAndroidToolsInfoData} returns the Android tools info.
466+
*/
467+
getToolsInfo(): NativeScriptDoctor.IAndroidToolsInfoData;
468+
469+
/**
470+
* Checks if the Android tools are valid.
471+
* @return {NativeScriptDoctor.IWarning[]} An array of errors from the validation checks. If there are no errors will return [].
472+
*/
473+
validateInfo(): NativeScriptDoctor.IWarning[];
474+
475+
/**
476+
* Checks if the current javac version is valid.
477+
* @param {string} installedJavaVersion The version of javac to check.
478+
* @return {NativeScriptDoctor.IWarning[]} An array of errors from the validation checks. If there are no errors will return [].
479+
*/
480+
validateJavacVersion(installedJavaVersion: string): NativeScriptDoctor.IWarning[];
481+
482+
/**
483+
* Returns the path to the adb which is located in ANDROID_HOME.
484+
* @return {Promise<string>} Path to the adb which is located in ANDROID_HOME.
485+
*/
486+
getPathToAdbFromAndroidHome(): Promise<string>;
487+
488+
/**
489+
* Checks if the ANDROID_HOME variable is set to the correct folder.
490+
* @return {NativeScriptDoctor.IWarning[]} An array of errors from the validation checks. If there are no errors will return [].
491+
*/
492+
validateAndroidHomeEnvVariable(): NativeScriptDoctor.IWarning[];
493+
494+
/**
495+
* Returns the path to the emulator executable.
496+
* @return {string} The path to the emulator executable.
497+
*/
498+
getPathToEmulatorExecutable(): string;
499+
}
500+
501+
/**
502+
* Describes information about installed Android tools and SDKs.
503+
*/
504+
interface IAndroidToolsInfoData {
505+
/**
506+
* The value of ANDROID_HOME environment variable.
507+
*/
508+
androidHomeEnvVar: string;
509+
510+
/**
511+
* The latest installed version of Android Build Tools that satisfies CLI's requirements.
512+
*/
513+
buildToolsVersion: string;
514+
515+
/**
516+
* The latest installed version of Android SDK that satisfies CLI's requirements.
517+
*/
518+
compileSdkVersion: number;
519+
520+
/**
521+
* The latest installed version of Android Support Repository that satisfies CLI's requirements.
522+
*/
523+
supportRepositoryVersion: string;
524+
}
525+
```
526+
420527
* Module `constants`:
421528
- Usage:
422529
```TypeScript

0 commit comments

Comments
 (0)