cordova插件根据 不同环境设置不同key

/* 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()
  }
}

 

上一篇:vue中使用cocordova-plugin-android-permissions判断是否打开定位权限


下一篇:Cordova开发遇到的问题