appium-xcuitest-driver
Version:
Appium driver for iOS using XCUITest for backend
94 lines • 3.42 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.homeEnvVarCheck = exports.xcodeToolsCheck = exports.XcodeToolsCheck = exports.xcodeCheck = exports.XcodeCheck = void 0;
const appium_xcode_1 = require("appium-xcode");
const support_1 = require("appium/support");
const teen_process_1 = require("teen_process");
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 `Install Xcode and make sure it is properly configured`;
}
hasAutofix() {
return false;
}
isOptional() {
return false;
}
}
exports.XcodeCheck = XcodeCheck;
exports.xcodeCheck = new XcodeCheck();
class XcodeToolsCheck {
log;
async diagnose() {
const errPrefix = 'Xcode Command Line Tools are not installed or are improperly configured';
try {
await (0, teen_process_1.exec)('xcodebuild', ['-version']);
}
catch (err) {
return support_1.doctor.nok(`${errPrefix}. Cannot run 'xcodebuild': ${err.stderr || err.message}`);
}
return support_1.doctor.ok(`Xcode Command Line Tools are installed and work properly`);
}
async fix() {
return `Make sure to install Xcode Command Line Tools by running 'xcode-select --install'`;
}
hasAutofix() {
return false;
}
isOptional() {
return false;
}
}
exports.XcodeToolsCheck = XcodeToolsCheck;
exports.xcodeToolsCheck = new XcodeToolsCheck();
class EnvVarAndPathCheck {
varName;
opts;
static ENVIRONMENT_VARS_TUTORIAL_URL = 'https://github.com/appium/java-client/blob/master/docs/environment.md';
log;
constructor(varName, opts = {}) {
this.varName = varName;
this.opts = opts;
}
async diagnose() {
const varValue = process.env[this.varName];
if (!varValue) {
return support_1.doctor.nok(`${this.varName} environment variable is NOT set!`);
}
if (!(await support_1.fs.exists(varValue))) {
const errMsg = `${this.varName} is set to '${varValue}' but this path does not exist!`;
return support_1.doctor.nok(errMsg);
}
const stat = await support_1.fs.stat(varValue);
if (this.opts.expectDir && !stat.isDirectory()) {
return support_1.doctor.nok(`${this.varName} is expected to be a valid folder, got a file path instead`);
}
if (this.opts.expectFile && stat.isDirectory()) {
return support_1.doctor.nok(`${this.varName} is expected to be a valid file, got a folder path instead`);
}
return support_1.doctor.ok(`${this.varName} is set to: ${varValue}`);
}
async fix() {
return (`Make sure the environment variable ${this.varName.bold} is properly configured for the Appium process. ` +
`Refer ${EnvVarAndPathCheck.ENVIRONMENT_VARS_TUTORIAL_URL} for more details.`);
}
hasAutofix() {
return false;
}
isOptional() {
return false;
}
}
exports.homeEnvVarCheck = new EnvVarAndPathCheck('HOME', { expectDir: true });
//# sourceMappingURL=required-checks.js.map