/* eslint-disable */
/**
* 根据环境变量初始化一些第三方库需要的key
*/
const { m: target } = require('yargs').argv
const { OPENINSTALL_APPKEY } = require('../configs').appConfigs
const { readFileSync, writeFileSync, removeSync } = require('fs-extra')
const installMissing = require('@quasar/app/lib/mode/install-missing')
// 配置openInstall appKey和scheme
const initOpenInstall = function initOpenInstall() {
const pkg = JSON.parse(readFileSync('./src-cordova/package.json', 'utf-8'))
openInstall = pkg.cordova.plugins['cordova-plugin-openinstall']
openInstall.OPENINSTALL_APPKEY = OPENINSTALL_APPKEY
openInstall.OPENINSTALL_SCHEME = OPENINSTALL_APPKEY
writeFileSync('./src-cordova/package.json', JSON.stringify(pkg, null, 2), 'utf-8')
removeSync('./src-cordova/plugins')
removeSync('./src-cordova/platforms')
installMissing('cordova', target)
}
module.exports = function initKeys() {
if (target) {
initOpenInstall()
}
}