UNPKG

appium-mac2-driver

Version:

XCTest-based Appium driver for macOS apps automation

71 lines 2.61 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.xcodebuildCheck = exports.XcodebuildCheck = exports.xcodeCheck = exports.XcodeCheck = void 0; const support_1 = require("appium/support"); const teen_process_1 = require("teen_process"); const appium_xcode_1 = require("appium-xcode"); require("@colors/colors"); /** @satisfies {import('@appium/types').IDoctorCheck} */ class XcodeCheck { async diagnose() { try { const xcodePath = await (0, appium_xcode_1.getPath)(); return support_1.doctor.ok(`xCode is installed at '${xcodePath}'`); } catch (err) { return support_1.doctor.nok(err.message); } } async fix() { return `Manually install ${'Xcode'.bold} and configure the active developer directory path using the xcode-select tool`; } hasAutofix() { return false; } isOptional() { return false; } } exports.XcodeCheck = XcodeCheck; exports.xcodeCheck = new XcodeCheck(); /** @satisfies {import('@appium/types').IDoctorCheck} */ class XcodebuildCheck { constructor() { this.XCODE_VER_PATTERN = /^Xcode\s+([\d.]+)$/m; this.MIN_XCODE_VERSION = 13; } async diagnose() { let xcodeVerMatch; let stdout; let stderr; try { ({ stdout, stderr } = await (0, teen_process_1.exec)('xcodebuild', ['-version'])); xcodeVerMatch = this.XCODE_VER_PATTERN.exec(stdout); } catch (err) { return support_1.doctor.nok(`Cannot run 'xcodebuild': ${err.stderr || err.message}`); } if (!xcodeVerMatch) { return support_1.doctor.nok(`Cannot determine Xcode version. stdout: ${stdout}; stderr: ${stderr}`); } const xcodeMajorVer = parseInt(xcodeVerMatch[1], 10); if (xcodeMajorVer < this.MIN_XCODE_VERSION) { return support_1.doctor.nok(`The actual Xcode version (${xcodeVerMatch[0]}) is older than the expected ` + `one (${this.MIN_XCODE_VERSION})`); } return support_1.doctor.ok(`xcodebuild is installed and has a matching version number ` + `(${xcodeVerMatch[1]} >= ${this.MIN_XCODE_VERSION})`); } async fix() { return `Install ${'Xcode'.bold} ${this.MIN_XCODE_VERSION}+ or upgrade the existing setup`; } hasAutofix() { return false; } isOptional() { return false; } } exports.XcodebuildCheck = XcodebuildCheck; exports.xcodebuildCheck = new XcodebuildCheck(); //# sourceMappingURL=required-checks.js.map