参考:https://developers.weixin.qq.com/miniprogram/dev/devtools/ci.html
参考:https://www.npmjs.com/package/miniprogram-ci
npm install miniprogram-ci -S
上传文件
xx.js
const isNodeJs = typeof process !== 'undefined' && process.release != null && process.release.name === 'node';
let env = "";
if (isNodeJs) {
//文件处理
const fs = require("fs")
env = process && process.argv.slice(2)[0].split("=")[1];
fs.writeFileSync('./utils/env.js', "export let env='" + env + "'");
let version = '1.3.6';
const ci = require('miniprogram-ci');
(async () => {
const project = new ci.Project({
appid: 'wxdb4f1710594a061a',
type: 'miniProgram',
projectPath: './',
privateKeyPath: './private.wxdb4f1710594a061a.key',
ignores: ['node_modules/**/*', 'build/*', 'package.json', 'package-lock.json', 'gulpfile.js', '*.key'],
})
const uploadResult = await ci.upload({
project,
version,
desc: '小程序测试',
setting: {
minify: true,
es6: true,
es7: true,
minifyJS: true,
minifyWXML: true,
minifyWXSS: true,
autoPrefixWXSS: true
},
onProgressUpdate: console.log,
})
console.log(uploadResult, '===>')
// const previewResult = await ci.preview({
// project,
// desc: '1.1.4',
// setting:{
// es6: true,
// },
// robot:2,
// qrcodeFormat: 'image',
// qrcodeOutputDest: './test.jpg',
// onProgressUpdate: console.log,
// });
// console.log(previewResult);
})()
}