appcenter-cli
Version:
Command line tool for Visual Studio App Center
88 lines (87 loc) • 4.41 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 commandline_1 = require("../../../util/commandline");
const help_messages_1 = require("../lib/help-messages");
const path = require("path");
const promisfied_fs_1 = require("../../../util/misc/promisfied-fs");
const xmldom_1 = require("@xmldom/xmldom");
const xml_util_builder_1 = require("../lib/xml-util-builder");
const fs_helper_1 = require("../../../util/misc/fs-helper");
const run_tests_download_result_command_1 = require("../lib/run-tests-download-result-command");
let RunManifestTestsCommand = class RunManifestTestsCommand extends run_tests_download_result_command_1.RunTestsDownloadResultCommand {
constructor(args) {
super(args);
this.isAppPathRequired = false;
}
getArtifactsDir() {
return __awaiter(this, void 0, void 0, function* () {
return path.dirname(this.manifestPath);
});
}
prepareManifest(artifactsDir) {
return __awaiter(this, void 0, void 0, function* () {
return this.manifestPath;
});
}
cleanupArtifactsDir(artifactsDir) {
return __awaiter(this, void 0, void 0, function* () {
return;
});
}
getSourceRootDir() {
return path.dirname(this.manifestPath);
}
mergeTestArtifacts() {
return __awaiter(this, void 0, void 0, function* () {
if (!this.outputXmlName) {
return;
}
const files = yield promisfied_fs_1.walk(this.testOutputDir);
const archive = files.find((file) => {
return path.extname(file) === ".zip";
});
if (!archive) {
throw new Error('"test-output-dir" doesn\'t contain any mergeable test results (.zip archives containing .xml documents)');
}
const xmlUtil = xml_util_builder_1.XmlUtilBuilder.buildXmlUtilByString(path.basename(archive));
const outputDir = fs_helper_1.generateAbsolutePath(this.testOutputDir);
const pathToArchive = path.join(outputDir, xmlUtil.getArchiveName());
const xml = yield xmlUtil.mergeXmlResults(pathToArchive);
if (!xml) {
throw new Error("XML merging has ended with an error");
}
const strXml = new xmldom_1.XMLSerializer().serializeToString(xml);
yield promisfied_fs_1.writeFile(path.join(outputDir, this.outputXmlName), strXml);
});
}
};
__decorate([
commandline_1.help("Path to manifest file"),
commandline_1.longName("manifest-path"),
commandline_1.hasArg,
commandline_1.required
], RunManifestTestsCommand.prototype, "manifestPath", void 0);
__decorate([
commandline_1.help(help_messages_1.Messages.TestCloud.Arguments.MergedFileName),
commandline_1.longName("merged-file-name"),
commandline_1.hasArg
], RunManifestTestsCommand.prototype, "outputXmlName", void 0);
RunManifestTestsCommand = __decorate([
commandline_1.help(help_messages_1.Messages.TestCloud.Commands.RunManifest)
], RunManifestTestsCommand);
exports.default = RunManifestTestsCommand;