← 返回
未分类 Key

WeChat Mini Program CI

Automate WeChat Mini Program code upload, preview, npm build, and cloud deployments with CI/CD support using Node.js or CLI without opening DevTools.
使用 Node.js 或 CLI,无需打开 DevTools,即可自动化微信小程序代码上传、预览、npm 构建及云端部署,支持 CI/CD。
openlark openlark 来源
未分类 clawhub v1.0.0 1 版本 100000 Key: 需要
★ 0
Stars
📥 165
下载
💾 0
安装
1
版本
#latest

概述

miniprogram-ci

> 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.

Installation

npm install miniprogram-ci
# Global install (for CLI usage)
npm install -g miniprogram-ci

Prerequisites

  1. Get AppID — appid of your mini program/mini game
  2. Generate private key — WeChat Official Platform → Management → Development → Development Settings → Mini Program Code Upload → Generate "Upload Private Key" (.key file)
  3. Configure IP whitelist (recommended) — Only whitelisted IPs can call upload/preview APIs
  4. Key security — Private keys are not stored in plaintext on the platform. Must reset if lost.

Quick Start

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,
  });
})();

Main API

MethodPurposeKey Parameters
--------------------------------
ci.upload()Upload codeproject, version(required), desc, setting, robot
ci.preview()Preview (QR code)project, qrcodeOutputDest(required), desc, setting, robot
ci.buildNpm()Build npmproject, options.ignores
ci.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)

Compile Settings

{
  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
}

Project Object

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
})

CLI Commands

# 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

Proxy Configuration

Auto-detection order: HTTPS_PROXYhttps_proxyHTTP_PROXYhttp_proxy → npm config → manual

ci.proxy("http://127.0.0.1:8888");   // manual
ci.proxy();                           // clear, restore auto

servicewechat.com is automatically added to no_proxy.

Return Values (upload/preview)

{
  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...",
}

Third-Party Platform

Supported since 1.0.28. Note:

  • Project must have a valid ext.json
  • Use the private key of the development mini program bound to the third-party platform
  • IP whitelist also belongs to that development mini program
  • The appid passed in must be the bound development mini program's appid

Robot Parameter

Specify which CI robot to use (1~30), enabling concurrent operations without conflicts.

Reference Files

FileContent
---------------
references/cloud.mdCloud development (cloud functions/cloud containers/cloud storage)
references/cli.mdCLI command detailed options

版本历史

共 1 个版本

  • v1.0.0 当前
    2026-06-01 21:25

安全检测

腾讯云安全 (Keen)

队列中

腾讯云安全 (Sanbu)

队列中

🔗 相关推荐

it-ops-security

MoltGuard - Security & Antivirus & Guardrails

thomaslwang
MoltGuard — OpenClaw 安全守卫,由 OpenGuardrails 提供。安装后可防止您和您的用户受到提示注入、数据泄露及恶意行为的侵害。
★ 116 📥 31,103
it-ops-security

Free Ride - Unlimited free AI

shaivpidadi
管理OpenClaw的OpenRouter免费AI模型,自动按质量排名模型,配置速率限制备用方案,并更新opencla...
★ 473 📥 79,080
content-creation

Toutiao Graphic Publisher

openlark
通过浏览器自动化在头条发布图文内容,支持智能排版、自动生成热门标签等功能。
★ 2 📥 1,094