appcenter-cli
Version:
Command line tool for Visual Studio App Center
91 lines (90 loc) • 4.61 kB
JavaScript
;
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
Object.defineProperty(exports, "__esModule", { value: true });
const iba = require("../../../util/misc/ios-bundle-archiver");
const path = require("path");
const pfs = require("../../../util/misc/promisfied-fs");
const commandline_1 = require("../../../util/commandline");
const help_messages_1 = require("../lib/help-messages");
const run_tests_command_1 = require("../lib/run-tests-command");
const test_cloud_error_1 = require("../lib/test-cloud-error");
const xcuitest_preparer_1 = require("../lib/xcuitest-preparer");
let RunXCUITestCommand = class RunXCUITestCommand extends run_tests_command_1.RunTestsCommand {
constructor(args) {
super(args);
this.isAppPathRequired = false;
}
prepareManifest(artifactsDir) {
const preparer = new xcuitest_preparer_1.XCUITestPreparer(artifactsDir, this.buildDir, this.testIpaPath, this.include);
return preparer.prepare();
}
validateOptions() {
return __awaiter(this, void 0, void 0, function* () {
if (this.buildDir) {
if (this.appPath && this.testIpaPath) {
throw Error("--build-dir cannot be used when both --app-path and --test-ipa-path are used");
}
if (!this.appPath) {
yield this.generateAppIpa();
}
}
else {
if (!this.appPath) {
throw Error("either --app-path or --build-dir is required");
}
if (!this.testIpaPath) {
throw Error("either --test-ipa-path or --build-dir is required");
}
}
});
}
getSourceRootDir() {
return this.buildDir;
}
generateAppIpa() {
return __awaiter(this, void 0, void 0, function* () {
const appPaths = (yield pfs.readdir(this.buildDir)).filter((appPath) => /^(?:.(?!-Runner\.app))+\.app$/.test(appPath));
if (appPaths.length === 0) {
throw new test_cloud_error_1.TestCloudError(`unable to find app within ${this.buildDir}`);
}
if (appPaths.length > 1) {
throw new test_cloud_error_1.TestCloudError(`multiple apps found within ${this.buildDir}`);
}
this.appPath = path.join(yield this.getArtifactsDir(), `${path.parse(appPaths[0]).name}.ipa`);
yield iba.archiveAppBundle(path.join(this.buildDir, appPaths[0]), this.appPath);
});
}
};
__decorate([
commandline_1.help(help_messages_1.Messages.TestCloud.Arguments.XCUITestBuildDir),
commandline_1.longName("build-dir"),
commandline_1.hasArg
], RunXCUITestCommand.prototype, "buildDir", void 0);
__decorate([
commandline_1.help(help_messages_1.Messages.TestCloud.Arguments.XCUITestIpaPath),
commandline_1.longName("test-ipa-path"),
commandline_1.hasArg
], RunXCUITestCommand.prototype, "testIpaPath", void 0);
__decorate([
commandline_1.help(help_messages_1.Messages.TestCloud.Arguments.NotSupported + " for XCUITest"),
commandline_1.longName("include"),
commandline_1.hasArg
], RunXCUITestCommand.prototype, "include", void 0);
RunXCUITestCommand = __decorate([
commandline_1.help(help_messages_1.Messages.TestCloud.Commands.RunXCUITest)
], RunXCUITestCommand);
exports.default = RunXCUITestCommand;