appcenter-cli
Version:
Command line tool for Visual Studio App Center
80 lines (79 loc) • 3.15 kB
JavaScript
;
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 });
exports.TestManifest = exports.TestFrameworkData = exports.TestRunFile = void 0;
const fs = require("fs");
const crypto = require("crypto");
class TestRunFile {
constructor(sourcePath, targetRelativePath, sha256, fileType) {
if (!sourcePath) {
throw new Error("Argument sourcePath is required");
}
if (!targetRelativePath) {
throw new Error("Argument targetRelativePath is required");
}
if (!sha256) {
throw new Error("Argument sha256 is required");
}
this.sourcePath = sourcePath;
this.targetRelativePath = targetRelativePath.replace(new RegExp(/\\/, "g"), "/");
this.sha256 = sha256;
this.fileType = fileType;
}
static create(sourcePath, targetRelativePath, fileType) {
return __awaiter(this, void 0, void 0, function* () {
const hash = crypto.createHash("sha256");
return new Promise((resolve, reject) => {
fs.readFile(sourcePath, (error, data) => {
if (error) {
reject(error);
}
else {
hash.update(data);
const sha256 = hash.digest("hex");
const result = new TestRunFile(sourcePath, targetRelativePath, sha256, fileType);
resolve(result);
}
});
});
});
}
}
exports.TestRunFile = TestRunFile;
class TestFrameworkData {
constructor(name, data) {
if (!name) {
throw new Error("Argument name is required");
}
this.name = name;
this.data = data;
}
}
exports.TestFrameworkData = TestFrameworkData;
class TestManifest {
constructor(version, cliVersion, applicationFile, files, testFramework) {
if (!version) {
throw new Error("Argument version is required");
}
if (!files) {
throw new Error("Argument files is required");
}
if (!testFramework) {
throw new Error("Argument testFramework is required");
}
this.version = version;
this.cliVersion = cliVersion;
this.applicationFile = applicationFile;
this.testFiles = files;
this.testFramework = testFramework;
}
}
exports.TestManifest = TestManifest;