UNPKG

appium-mac2-driver

Version:

XCTest-based Appium driver for macOS apps automation

69 lines 2.54 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"); class XcodeCheck { log; 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(); class XcodebuildCheck { log; static XCODE_VER_PATTERN = /^Xcode\s+([\d.]+)$/m; static MIN_XCODE_VERSION = 13; async diagnose() { let xcodeVerMatch; let stdout; let stderr; try { ({ stdout, stderr } = await (0, teen_process_1.exec)('xcodebuild', ['-version'])); xcodeVerMatch = XcodebuildCheck.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 < XcodebuildCheck.MIN_XCODE_VERSION) { return support_1.doctor.nok(`The actual Xcode version (${xcodeVerMatch[0]}) is older than the expected ` + `one (${XcodebuildCheck.MIN_XCODE_VERSION})`); } return support_1.doctor.ok(`xcodebuild is installed and has a matching version number ` + `(${xcodeVerMatch[1]} >= ${XcodebuildCheck.MIN_XCODE_VERSION})`); } async fix() { return `Install ${'Xcode'.bold} ${XcodebuildCheck.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