UNPKG

mh-qa-cli

Version:

A command to get MissionHub QA running

71 lines (70 loc) โ€ข 2.58 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); require("colors"); const Listr = require("listr"); const util = require("util"); const constants_1 = require("./constants"); const exec = util.promisify(require('child_process').exec); const dependencies = [ { title: '๐Ÿบ Installing brew', check: 'command -v brew', install: '/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"', }, { title: '๐ŸŒต Installing git', check: 'command -v git', install: 'brew install git', }, { title: '๐Ÿ’Ž Installing RubyGems bundler', check: 'command -v bundle', install: 'gem install bundler', }, { title: '๐Ÿงถ Installing yarn', check: 'command -v yarn', install: 'brew install yarn', }, { title: '๐Ÿ“ Creating directories', check: 'cd ~/code', install: 'mkdir ~/code', }, { title: '๐ŸŒ€ Cloning repo', check: `cd ${constants_1.REPO_DIRECTORY} && git rev-parse --is-inside-work-tree`, install: 'cd ~/code && git clone https://github.com/CruGlobal/missionhub-react-native.git', }, { title: '๐Ÿž๏ธ Initializing .env', install: `cp ${constants_1.REPO_DIRECTORY}/.env.staging ${constants_1.REPO_DIRECTORY}/.env`, }, { title: '๐Ÿค– Installing android studio', check: 'ls /Applications/Android\\ Studio.app/Contents', install: 'brew cask install android-studio', }, { title: '๐Ÿ“ฑ Creating Android Emulator', check: '[ ! -f ~/Library/Android/sdk/tools/bin/avdmanager ]', install: `JAVA_HOME=/Applications/Android\\ Studio.app/Contents/jre/jdk/Contents/Home ~/Library/Android/sdk/tools/bin/sdkmanager "system-images;android-29;google_apis;x86" && ~/Library/Android/sdk/tools/bin/avdmanager create avd --name missionhub_qa_cli --package "system-images;android-29;google_apis;x86" --device pixel_xl --force && (grep -qF -- "hw.keyboard=yes" ~/.android/avd/missionhub_qa_cli.avd/config.ini || echo "hw.keyboard=yes" >> ~/.android/avd/missionhub_qa_cli.avd/config.ini)`, }, ]; const setupTasks = new Listr(dependencies.map(({ title, check, install }) => ({ title, skip: async () => { try { await exec(check); return true; } catch { return false; } }, task: async () => await exec(install), }))); exports.setup = () => setupTasks.run();