|
1 | 1 | # nativescript-doctor
|
2 | 2 | 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 | + ``` |
0 commit comments