WeChat Mini Program CI tool · v2.1.31 · Node >= 16.1.0
A compilation module extracted from the WeChat Developer Tools for mini program/mini game projects. Supports both Node.js script calls and CLI commands.
bash
npm install miniprogram-ci
# Global install (for CLI usage)
npm install -g miniprogram-ci
.key file)js
const ci = require("miniprogram-ci");
(async () => {
const project = new ci.Project({
appid: "wx0000000000000000",
type: "miniProgram", // miniProgram | miniProgramPlugin | miniGame | miniGamePlugin
projectPath: "./dist/build/mp-weixin",
privateKeyPath: "./key/private.wx.xxxxx.key",
ignores: ["node_modules/**/*"],
});
// Upload code
const uploadResult = await ci.upload({
project,
version: "1.0.0",
desc: "Fixed several issues",
setting: { es6: true, minify: true },
onProgressUpdate: console.log,
robot: 1,
});
console.log("subPackageInfo:", uploadResult.subPackageInfo);
// Preview (generate QR code)
await ci.preview({
project,
desc: "Preview version",
setting: { es6: true },
qrcodeFormat: "image", // image | base64 | terminal
qrcodeOutputDest: "./preview.jpg",
pagePath: "pages/index/index",
searchQuery: "id=123",
onProgressUpdate: console.log,
robot: 1,
});
})();
MethodPurposeKey Parametersci.upload()Upload codeproject, version(required), desc, setting, robotci.preview()Preview (QR code)project, qrcodeOutputDest(required), desc, setting, robotci.buildNpm()Build npmproject, options.ignoresci.getDevSourceMap()Get latest sourceMapproject, robot(required), sourceMapSavePath(required)ci.cloudFunctionDeploy()Upload cloud functionproject, env(required), name(required), path(required)ci.cloudFileUpload()Upload cloud storage/static hostingproject, env(required), path(required) [alpha]ci.cloudContainerDeploy()Deploy cloud container versionproject, env(required), containerRoot + version [alpha]ci.proxy()Set proxyproxyUrl(optional)
js
{
es6: true, // ES6 → ES5
es7: true, // Enhanced compilation
minifyJS: true, // Minify JS
minifyWXML: true, // Minify WXML
minifyWXSS: true, // Minify WXSS
minify: true, // Minify all
codeProtect: true, // Code protection
autoPrefixWXSS: true, // Auto prefix CSS
}
js
new ci.Project({
appid: "wx...", // required
projectPath: "./dist", // required (directory containing project.config.json)
privateKeyPath: "./key", // required
type: "miniProgram", // optional, defaults to miniProgram
ignores: ["node_modules"],// optional
})
bash
# Upload
miniprogram-ci upload \
--pp ./dist \
--pkp ./key/private.key \
--appid wx0000000000000000 \
--uv 1.0.0 \
--ud "Version description" \
--r 1
# Preview
miniprogram-ci preview \
--pp ./dist \
--pkp ./key/private.key \
--appid wx0000000000000000 \
--uv 1.0.0 \
--ud "Preview description" \
--qrcode-format image \
--qrcode-output-dest ./preview.jpg
Auto-detection order: HTTPS_PROXY → https_proxy → HTTP_PROXY → http_proxy → npm config → manual
js
ci.proxy("http://127.0.0.1:8888"); // manual
ci.proxy(); // clear, restore auto
servicewechat.com is automatically added to no_proxy.
js
{
subPackageInfo: [
{ name: "__FULL__", size: 123456 }, // entire package
{ name: "__APP__", size: 100000 }, // main package
{ name: "subPack1", size: 23456 }, // sub package
],
pluginInfo: [
{ pluginProviderAppid: "wx...", version: "1.0.0", size: 12345 },
],
devPluginId: "wx...",
}
Supported since 1.0.28. Note:
ext.jsonSpecify which CI robot to use (1~30), enabling concurrent operations without conflicts.
FileContentreferences/cloud.mdCloud development (cloud functions/cloud containers/cloud storage)references/cli.mdCLI command detailed options