uniApp微信小程序CI機(jī)器人自動化部署
1. 微信公眾平臺上,在開發(fā)設(shè)置里面小程序代碼,將上傳代碼的服務(wù)IP地址填充下,生成一個上傳秘鑰下載下來
2. 將下載的秘鑰文件放在uni-cli 項(xiàng)目的根目錄下
文章來源:http://www.zghlxwxcb.cn/news/detail-610149.html
3. npm 微信官方的miniprogram-ci模塊
const ci = require('miniprogram-ci')
const path = require('path') // 需要用到項(xiàng)目目錄文件
const project = await new ci.Project({
appid: appid, //appid
type: 'miniProgram',
projectPath: path.resolve(__dirname, './dist/build/mp-weixin'), //項(xiàng)目路徑
privateKeyPath: path.resolve(__dirname, `./private.${appid}.key`), //小程序后臺的上傳密匙
ignores: ['node_modules/**/*'],
});
// 預(yù)覽小程序
const previewResult = await ci.preview({
project,
desc: '預(yù)覽', // 此備注將顯示在“小程序助手”開發(fā)版列表中
setting: {
es6: true,
},
qrcodeFormat: 'image',
qrcodeOutputDest: path.resolve(__dirname, `./preview/previewQrcode.jpg`),
onProgressUpdate: console.log
});
let env_object = {
production: 1,
master: 2,
test: 3,
test02: 5,
development: 4
}
// 上傳代碼方法以及回調(diào)
const uploadResult = await ci.upload({
project,
robot: env_object[status],
version: mainfest.versionName,
desc: mainfest.description,
setting: mainfest['mp-weixin'].setting,
onProgressUpdate: console.log,
}).then(res => {
console.log(`版本${mainfest.versionName}`)
}).catch(error => {
throw error
})
4. 把上面的代碼寫到一個js 文件放在項(xiàng)目根目錄下
文章來源地址http://www.zghlxwxcb.cn/news/detail-610149.html
5. 在package.json里面寫好打包和啟動的scripts腳本命令
"dev:mp-weixin": "cross-env NODE_ENV=development ENV_STATUS=development START_UP=dev UNI_PLATFORM=mp-weixin node autoUpload.js",
6.剩下的操作就是你上傳好代碼,打包交給jenkins構(gòu)建工具就好了
到了這里,關(guān)于uni-app 微信小程序CI機(jī)器人自動化部署方案的文章就介紹完了。如果您還想了解更多內(nèi)容,請?jiān)谟疑辖撬阉鱐OY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!