@assert-equals/dappdriver
Version:
DappDriver is an e2e testing framework designed for testing decentralized applications (dApps) using MetaMask, Rainbow or Zerion
31 lines (30 loc) • 1.43 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.install = void 0;
const constants_1 = require("../constants");
const log_1 = require("../log");
const install_1 = require("../wallet/install");
async function install(directory, version = constants_1.DEFAULT_ZERION_VERSION) {
try {
const assetName = `${constants_1.DEFAULT_ZERION_ASSET}-v${version}`;
let destDir = `${directory}/${assetName}`;
const exists = (0, install_1.fileExists)(destDir);
if (exists) {
(0, log_1.logInfo)(`Zerion version <v${version}> already exists in ${destDir}`);
return destDir;
}
(0, install_1.compareVersion)(constants_1.ZERION, version, constants_1.RECOMMENDED_ZERION_VERSIONS);
const release = await (0, install_1.fetchGithubRelease)(constants_1.ZERION, version, constants_1.ZERION_GITHUB_API);
const asset = (0, install_1.findGithubAsset)(assetName, release);
(0, install_1.createDirectory)(directory);
const fileName = await (0, install_1.downloadAssetZipFile)(asset, directory);
destDir = (0, install_1.extractZipContents)(fileName);
(0, install_1.moveFiles)(destDir);
(0, log_1.logSuccess)(`Installed Zerion version <v${version}>\n${destDir}`);
return destDir;
}
catch (error) {
(0, log_1.logError)(error.message);
}
}
exports.install = install;