npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@johnsonhuang4396/wechat-mini-ci

v1.0.6

Published

CI for managing wechat miniprogram

Readme

wechat-mini-ci

English | 简体中文

微信小程序上传、预览一步搞定,告别手写发布脚本

本项目灵感来源若川大佬的mini-ci,感谢前辈的贡献

使用前请确保已经详细阅读 miniprogram-ci官方文档,并在 微信公众平台 开启代码上传功能 (如果是个人使用,建议关闭白名单功能,否则可能因IP变更导致发布失败)

npm version jsDocs.io github release NPM Unpacked Size NPM License NPM Downloads

如何使用:

npm i -D @johnsonhuang4396/wechat-mini-ci

npm i -g @johnsonhuang4396/wechat-mini-ci #全局安装使用

npx @johnsonhuang4396/wechat-mini-ci [command] #也可以不安装直接使用,可以确保使用最新版本

你可以通过命令行调用wechat-mini-ci,也可以通过脚本形式调用导出的previewupload函数

previewupload函数均已内置初始化功能,你不需要自行初始化。但如果有自定义的需求,可以通过调用Project并传入配置项来进行自定义操作👇:

import { Project } from '@johnsonhuang4396/wechat-mini-ci'

const {
  instance, // 初始化对象,对应miniprogram-ci的project,
  options, // 初始化时传入的配置项
  preview,
  upload
} = new Project({ ...传入配置项 }) // Project在调用时会自动初始化,不需要重复初始化

现在假设你的项目路径如下:

dist
|- build
|-- mp-weixin
│
src
├─ dir1
└─ dir2
...
|- ci.config.ts

并在ci-config.ts中配置如下代码:

import { defineConfig } from '@johnsonhuang4396/wechat-mini-ci'

export default defineConfig({
  name: 'wechat-mini-program',
  projectPath: './dist/build/mp-weixin/',
  privateKeyPath: '填入private-key所在的相对/绝对路径',
  appid: '填入小程序的appid'
})

然后在项目的根目录下打开终端,输入如下指令,即可实现上传、预览:

wmc p #预览
wmc u #上传

如果你有多个小程序管理的需求,defineConfig也支持传入数组:

export default defineConfig([
  {
    name: 'wechat-mini-program1',
    projectPath: '填入打包后的小程序路径',
    privateKeyPath: '填入private-key所在的相对/绝对路径',
    appid: '填入小程序的appid'
  },
  {
    name: 'wechat-mini-program2',
    projectPath: '填入打包后的小程序路径',
    privateKeyPath: '填入private-key所在的相对/绝对路径',
    appid: '填入小程序的appid'
  },
])

然后在项目的根目录下打开终端,可以选择操作一个、多个小程序:

wmc p #默认情况下为全量预览
wmc p -s #选择一个小程序进行预览
wmc p -m #选择多个小程序进行预览

除了wmc外,你还可以使用如下命令来调用👇 (使用前请确保没有重复的命令)

wechat-mini-ci
mini-ci
ci

当然,ci.config.ts也不局限于这个名称,下面的文件名同样会被当作wechat-mini-ci的配置文件进行处理👇:

ci.config.js
ci.config.mts
mini-ci.config.js
mini-ci.config.ts
mini-ci.config.mts
wx-mini.config.js
wx-mini.config.ts
wx-mini.config.mts

插件

提供了prevpost两种类型的插件,prev是在执行操作前运行,post则是在执行操作后运行 (如果多个小程序同时操作的情况下,将会多次执行插件,请尽可能确保插件的功能足够简单,否则可能会导致ci执行时间过长)

内置了print-qrcode插件,将在预览后打印出小程序的预览二维码

插件的实现如下👇:

// plugin.ts
export const plugin = {
  name: '插件名称',
  state: 'prev' | 'post',
  fn: ({ action, config }): void => {
    // action 是当前执行的操作,值为 preview 或 upload
    // config 包含了CLI的可选项和当前执行操作的小程序配置项
  }
}

// ci.config.ts
export default defineConfig({
  plugins: [
    plugin
  ]
})

配置项:

下面是defineConfig的配置项👇:

| 名称 | 注释 | 类型 | 是否必填 | |--------------------|----------------------------------|------------------------------------------------------------------------------------------------------|----------| | projectPath | 项目路径 | string | 是 | | type | 项目类型选项(仅限 'miniProgram') | 'miniProgram' | 否 | | appid | 应用ID | string | 是 | | privateKey | 私钥 | string | 否 | | privateKeyPath | 私钥路径 | string | 否 | | ignores | 忽略的文件或目录列表 | string[] | 否 | | targetPlatform | 目标平台 | string | 否 | | compileDefines | 编译定义 | { [key: string]: string } | 否 | | name | 项目名称 | string | 是 | | version | 项目版本 | string | 否 | | desc | 项目描述 | string | 否 | | configPath | 配置文件路径 | string | 否 | | packageJsonPath | package.json 文件路径 | string | 否 | | plugins | 插件列表 | Plugin[] | 否 | | preview | 预览选项 | IPreviewOptions | 否 | | upload | 上传选项 | IUploadOptions | 否 |

下面是预览配置项👇:

| 名称 | 注释 | 类型 | 是否必填 | |-----------------------------|----------------------------------|------------------------------------------------------------------------------------------------------|----------| | version | 上传选项中的版本号 | string | 否 | | setting | 编译设置 | MiniProgramCI.ICompileSettings | 否 | | desc | 描述 | string | 否 | | robot | 机器人编号 | number | 否 | | threads | 线程数 | number | 否 | | useCOS | 是否使用 COS 存储 | boolean | 否 | | onProgressUpdate | 进度更新回调函数 | (task: MiniProgramCI.ITaskStatus \| string) => void | 否 | | allowIgnoreUnusedFiles | 是否忽略未使用的文件 | boolean | 否 | | test | 测试模式 | boolean | 否 | | bigPackageSizeSupport | 是否支持大包大小 | boolean | 否 | | qrcodeFormat | 二维码格式 | base64 \| image \| terminal | 否 | | qrcodeOutputDest | 二维码输出目标 | string | 否 | | pagePath | 页面路径 | string | 否 | | searchQuery | 搜索查询 | string | 否 |

下面是上传配置项👇:

| 名称 | 注释 | 类型 | 是否必填 | |--------------------------------|----------------------------------|------------------------------------------------------------------------------------------------------|----------| | version | 上传选项中的版本号 | string | 否 | | setting | 编译设置 | MiniProgramCI.ICompileSettings | 否 | | desc | 描述 | string | 否 | | robot | 机器人编号 | number | 否 | | threads | 线程数 | number | 否 | | useCOS | 是否使用 COS 存储 | boolean | 否 | | onProgressUpdate | 进度更新回调函数 | (task: MiniProgramCI.ITaskStatus \| string) => void | 否 | | allowIgnoreUnusedFiles | 是否忽略未使用的文件 | boolean | 否 | | test | 测试模式 | boolean | 否 | | bigPackageSizeSupport | 是否支持大包大小 | boolean | 否 | | qrcodeFormat | 二维码格式 | 'base64' \| 'image' \| 'terminal' | 否 | | qrcodeOutputDest | 二维码输出目标 | string | 否 | | pagePath | 页面路径 | string | 否 | | searchQuery | 搜索查询 | string | 否 | | scene | 场景值 | number | 否 |

CLI配置项:

基础配置项👇:

Usage:
  $ wechat-mini-ci <command> [options]

Commands:
  preview [root]  预览小程序
  upload [root]   上传小程序

For more info, run any command with the `--help` flag:
  $ wechat-mini-ci preview --help
  $ wechat-mini-ci upload --help

Options:
  -d, --dry      空跑
  -h, --help     Display this message
  -v, --version  Display version number

预览 | 上传配置项👇:

PS: 当配置了root时,config将会把root作为根目录进行操作

  -r, --robot <robot>   指定机器人,默认 1
  -c, --config <file>   指定一个文件为配置文件
  -s, --useSelect       选择一个配置操作
  -m, --useMultiSelect  选择多个配置操作
  -si, --silent         静默模式
  -d, --dry             空跑

最后

感谢antfu大佬的模版若川大佬的mini-ci开源

License

MIT License © Johnson Huang