Library that helps identifying if the environment can be used for development of {N} apps.
-
Module doctor
:
import { doctor } from "nativescript-doctor"
async function main() {
const canExecuteLocalBuildForAndroid = await doctor.canExecuteLocalBuild("Android");
const canExecuteLocalBuildForIos = await doctor.canExecuteLocalBuild("iOS");
console.log("Can execute local build for Android: ", canExecuteLocalBuildForAndroid);
console.log("Can execute local build for iOS: ", canExecuteLocalBuildForIos);
}
main();
interface IDoctor {
canExecuteLocalBuild(platform: string): Promise<boolean>;
getWarnings(): Promise<IWarning[]>;
}
interface IWarning {
warning: string;
additionalInformation: string;
platforms: string[];
}
-
Module sysInfo
:
import { sysInfo, setShouldCacheSysInfo } from "nativescript-doctor";
async function main() {
setShouldCacheSysInfo(false);
const javacVersion = await sysInfo.getJavaCompilerVersion();
console.log("javac: ", javacVersion);
const adbVersion = await sysInfo.getAdbVersion();
console.log("adb: ", adbVersion);
const cocoaPodsVersion = await sysInfo.getCocoaPodsVersion();
console.log("cocoapods: ", cocoaPodsVersion);
const gitVersion = await sysInfo.getGitVersion();
console.log("git: ", gitVersion);
const gradleVersion = await sysInfo.getGradleVersion();
console.log("gradle: ", gradleVersion);
const monoVersion = await sysInfo.getMonoVersion();
console.log("mono: ", monoVersion);
const nodeVersion = await sysInfo.getNodeVersion();
console.log("node: ", nodeVersion);
const npmVersion = await sysInfo.getNpmVersion();
console.log("npm: ", npmVersion);
const nodeGypVersion = await sysInfo.getNodeGypVersion();
console.log("node-gyp: ", nodeGypVersion);
const osName = await sysInfo.getOs();
console.log("os: ", osName);
const xcodeprojLocation = await sysInfo.getXCodeProjLocation();
console.log("xcodeproj location: ", xcodeprojLocation);
const xcodeVersion = await sysInfo.getXCodeVersion();
console.log("xcode: ", xcodeVersion);
const isAndroidInstalled = await sysInfo.isAndroidInstalled();
console.log("is Android installed: ", isAndroidInstalled);
const isITunesInstalled = await sysInfo.isITunesInstalled();
console.log("is iTunes installed: ", isITunesInstalled);
const isCocoaPodsWorkingCorrectly = await sysInfo.isCocoaPodsWorkingCorrectly();
console.log("is cocoapods working correctly: ", isCocoaPodsWorkingCorrectly);
const nativeScriptCliVersion = await sysInfo.getNativeScriptCliVersion();
console.log("{N} CLI version: ", nativeScriptCliVersion);
const xcprojInfo = await sysInfo.getXcprojInfo();
console.log("xcproj info: ", xcprojInfo);
const isCocoaPodsUpdateRequired = await sysInfo.isCocoaPodsUpdateRequired();
console.log("is CocoaPods update required: ", isCocoaPodsUpdateRequired);
const pythonInfo = await sysInfo.getPythonInfo();
console.log("python info: ", pythonInfo );
const sysInfoData = await sysInfo.getSysInfo({ projectDir: "/Users/username/myProject" });
console.log("sysInfo: ", sysInfoData);
const gitPath = await sysInfo.getGitPath();
console.log("Path to the git executable: ", gitPath);
}
main();
interface ISysInfo {
getJavaCompilerVersion(): Promise<string>;
getXcodeVersion(): Promise<string>;
getNodeVersion(): Promise<string>;
getNpmVersion(): Promise<string>;
getNodeGypVersion(): Promise<string>;
getXcodeprojLocation(): Promise<string>;
isITunesInstalled(): Promise<boolean>;
getCocoaPodsVersion(): Promise<string>;
getOs(): Promise<string>;
getAdbVersion(pathToAdb?: string): Promise<string>;
isAndroidInstalled(): Promise<boolean>;
getMonoVersion(): Promise<string>;
getGitVersion(): Promise<string>;
getGradleVersion(): Promise<string>;
isCocoaPodsWorkingCorrectly(): Promise<boolean>;
getNativeScriptCliVersion(): Promise<string>;
getXcprojInfo(): Promise<IXcprojInfo>;
isCocoaPodsUpdateRequired(): Promise<boolean>;
isAndroidSdkConfiguredCorrectly(): Promise<boolean>;
getSysInfo(config?: ISysInfoConfig): Promise<ISysInfoData>;
setShouldCacheSysInfo(shouldCache: boolean): void;
getGitPath(): Promise<string>;
}
interface ISysInfoData {
platform: string;
os: string;
dotNetVer: string;
shell: string;
nodeVer: string;
npmVer: string;
procArch: string;
nodeGypVer: string;
xcodeVer: string;
adbVer: string;
itunesInstalled: boolean;
androidInstalled: boolean;
monoVer: string;
gitVer: string;
gradleVer: string;
javacVersion: string;
cocoaPodsVer: string;
xcodeprojLocation: string;
isCocoaPodsWorkingCorrectly: boolean;
nativeScriptCliVersion: string;
xcprojInfo: IXcprojInfo;
isCocoaPodsUpdateRequired: boolean;
isAndroidSdkConfiguredCorrectly: boolean;
}
interface IXcprojInfo {
shouldUseXcproj: boolean;
xcprojAvailable: boolean;
}
-
Module androidToolsInfo
:
import { androidToolsInfo } from "nativescript-doctor"
function main() {
const projectDir = "/Users/username/myProject";
console.log("path to adb from android home: ", await androidToolsInfo.getPathToAdbFromAndroidHome());
console.log("path to emulator executable: ", androidToolsInfo.getPathToEmulatorExecutable());
console.log("android tools info: ", androidToolsInfo.getToolsInfo());
console.log("ANROID_HOME validation errors: ", await androidToolsInfo.validateAndroidHomeEnvVariable());
console.log("android tools info validation errors: ", await androidToolsInfo.validateInfo());
console.log("javac validation errors: ", await androidToolsInfo.validateJavacVersion(await sysInfo.getJavaCompilerVersion(), projectDir));
}
main();
interface IAndroidToolsInfo {
getToolsInfo(): NativeScriptDoctor.IAndroidToolsInfoData;
validateInfo(projectDir?: string): NativeScriptDoctor.IWarning[];
validateJavacVersion(installedJavaVersion: string, projectDir?: string): NativeScriptDoctor.IWarning[];
getPathToAdbFromAndroidHome(): Promise<string>;
validateAndroidHomeEnvVariable(): NativeScriptDoctor.IWarning[];
getPathToEmulatorExecutable(): string;
}
interface IAndroidToolsInfoData {
androidHomeEnvVar: string;
buildToolsVersion: string;
compileSdkVersion: number;
supportRepositoryVersion: string;
}
-
Module constants
:
import { constants } from "nativescript-doctor"
function main() {
for(let constantName in constants) {
console.log(`${constantName}: ${constants[constantName]}`);
}
}
main();
interface IConstants {
ANDROID_PLATFORM_NAME: string;
IOS_PLATFORM_NAME: string;
SUPPORTED_PLATFORMS: string[];
}