UNPKG

@assert-equals/dappdriver

Version:

DappDriver is an e2e testing framework designed for testing decentralized applications (dApps) using MetaMask, Rainbow or Zerion

34 lines (33 loc) 1.76 kB
"use strict"; 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_RAINBOW_VERSION) { try { const artifactName = `rainbowbx-chrome-v${version}`; let destDir = `${directory}/${artifactName}`; const exists = (0, install_1.fileExists)(destDir); if (exists) { (0, log_1.logInfo)(`Rainbow version <v${version}> already exists in ${destDir}`); return destDir; } const workflowName = 'Publish to Chrome (Prod)'; (0, install_1.checkEnvVariable)('GITHUB_TOKEN'); (0, install_1.compareVersion)(constants_1.RAINBOW, version, constants_1.RECOMMENDED_RAINBOW_VERSIONS); await (0, install_1.fetchGithubTags)(constants_1.RAINBOW, version, constants_1.RAINBOW_GITHUB_API); const workflow = await (0, install_1.fetchGithubWorkflow)(workflowName, constants_1.RAINBOW_GITHUB_API); const run = await (0, install_1.fetchGithubRun)(version, workflowName, workflow, constants_1.RAINBOW_GITHUB_API); const artifact = await (0, install_1.fetchGithubArtifact)(artifactName, run, constants_1.RAINBOW_GITHUB_API); (0, install_1.createDirectory)(directory); const fileName = await (0, install_1.downloadArtifactZipFile)(artifact, directory); destDir = (0, install_1.extractZipContents)(fileName); (0, log_1.logSuccess)(`Installed Rainbow version <v${version}>\n${destDir}`); return destDir; } catch (error) { (0, log_1.logError)(error.message); } } exports.install = install;