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

@yossi-lee/weixin-mp-cli

v1.0.1

Published

微信公众号 CLI 工具,支持从 Markdown 创建草稿、发布文章、管理素材

Readme

weixin-mp-cli

微信公众号 CLI 工具,支持从 Markdown / HTML 文件创建草稿、发布文章、管理素材。

安装

npm install -g @yossi-lee/weixin-mp-cli

或在项目本地使用:

npm install
npm run wx -- <command>

快速开始

# 1. 初始化配置
weixin-mp-cli init

# 2. 从 Markdown 创建草稿
weixin-mp-cli create article.md -t "文章标题" -c cover.jpg

# 3. 发布草稿
weixin-mp-cli publish <media_id>

命令

init

初始化微信公众号配置(AppID / AppSecret)。

weixin-mp-cli init

create

从 Markdown 或 HTML 文件创建草稿。传入 .md 文件时自动转换并上传正文图片,传入 .html 文件时直接使用。

weixin-mp-cli create <file> [options]

| 选项 | 说明 | |------|------| | -t, --title <title> | 文章标题(默认取文件名) | | -a, --author <author> | 作者 | | -d, --digest <digest> | 摘要 | | -c, --cover <image-path> | 封面图片路径(本地文件) | | -u, --url <url> | 原文链接 | | --comment | 开启评论 |

publish

发布草稿到公众号。

weixin-mp-cli publish <media_id>

list

列出草稿。

weixin-mp-cli list [options]

| 选项 | 说明 | |------|------| | -o, --offset <n> | 偏移量(默认 0) | | -c, --count <n> | 数量(默认 20) |

delete

删除草稿。

weixin-mp-cli delete <media_id>

material:upload

上传永久素材(用于封面等)。

weixin-mp-cli material:upload <file>

material:list

列出永久素材。

weixin-mp-cli material:list [options]

| 选项 | 说明 | |------|------| | -t, --type <type> | 素材类型:image / voice / video / news(默认 image) | | -o, --offset <n> | 偏移量(默认 0) | | -c, --count <n> | 数量(默认 20) |

material:delete

删除永久素材。

weixin-mp-cli material:delete <media_id>

material:count

查看素材统计。

weixin-mp-cli material:count

项目结构

weixin-mp-cli/
├── bin/
│   └── wx.js              # CLI 入口
└── src/
    ├── auth.js            # Token 管理(带缓存)
    ├── config.js          # 配置读写
    ├── draft.js           # 草稿操作
    ├── markdown.js        # Markdown 转 HTML + 图片上传
    ├── material.js        # 素材操作
    └── publish.js         # 发布草稿

工作流程

  1. Markdown 中的本地图片自动上传到微信服务器并替换为可用 URL
  2. 封面图片上传为永久素材获取 thumb_media_id
  3. 创建草稿到公众号草稿箱
  4. 调用发布接口将草稿发布到公众号

License

Apache-2.0