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 🙏

© 2024 – Pkg Stats / Ryan Hefner

miniprogram-mp-ci

v1.0.7

Published

miniprogram-mp-ci.

Downloads

15

Readme

概述

miniprogram-mp-ci 是一个 npm 包,旨在简化小程序的成员管理流程。它允许开发者直接通过代码,而不是手动通过微信公众平台,来执行批量管理任务。这个工具包提供了一系列自动化功能,使得管理小程序成员变得快捷高效。

密钥及 IP 白名单配置

使用 miniprogram-mp-ci 前应访问"微信公众平台-开发-开发设置"后下载代码上传密钥,并配置 IP 白名单 开发者可选择打开 IP 白名单,打开后只有白名单中的 IP 才能调用相关接口。我们建议所有开发者默认开启这个选项,降低风险 代码上传密钥拥有预览、上传代码的权限,密钥不会明文存储在微信公众平台上,一旦遗失必须重置,请开发者妥善保管

功能

miniprogram-mp-ci 目前提供以下能力:

  1. 批量成员管理

脚本调用

npm install miniprogram-mp-ci --save

项目对象

项目对象是本模块主要的入参,可以依据下边的定义自行实现

项目对象的定义:

interface IProject {
  appid: string
  type: string
  projectPath: string
  privateKey: string
  attr(): Promise<IProjectAttr>
  stat(prefix: string, filePath: string): IStat | undefined
  getFile(prefix: string, filePath: string): Promise<Buffer>
  getFileList(prefix: string, extName: string): string[]
  updateFiles: () => void
}

| 键 | 类型 | 说明 | | ----------- | -------- | ------------------------------------------------------------------------------------------------------------------ | | appid | 属性 | 小程序/小游戏项目的 appid | | type | 属性 | 项目的类型,有效值 miniProgram/miniProgramPlugin/miniGame/miniGamePlugin | | projectPath | 属性 | 项目的路径,即 project.config.json 所在的目录 | | privateKey | 属性 | 私钥,在获取项目属性和上传时用于鉴权使用,在 微信公众平台 上登录后下载 | | attr | 异步方法 | 项目的属性,如指定了 privateKey 则会使用真实的项目属性 | | stat | 同步方法 | 特定目录下前缀下(prefix)文件路径 (filePath) 的 stat, 如果不存在则返回 undefined | | getFile | 异步方法 | 特定目录下前缀下(prefix)文件路径 (filePath) 的 Buffer | | getFileList | 同步方法 | 特定目录下前缀下(prefix)文件路径 (filePath) 下的文件列表 | | updateFile | 同步方法 | 更新项目文件 |

也可以通过指定项目路径来创建该对象

const ci = require('miniprogram-mp-ci')
// 注意: new ci.Project 调用时,请确保项目代码已经是完整的,避免编译过程出现找不到文件的报错。
const project = new ci.Project({
  appid: 'wxsomeappid',
  type: 'miniProgram',
  projectPath: 'the/project/path',
  privateKeyPath: 'the/privatekey/path',
  ignores: ['node_modules/**/*'],
})

| 键 | 类型 | 必填 | 说明 | | -------------- | -------- | ---- | -------------------------------------------------------------------------------------------------------- | | appid | string | 是 | 合法的小程序/小游戏 appid | | projectPath | string | 是 | 项目路径 | | privateKeyPath | string | 是 | 私钥的路径 | | type | string | 否 | 显示指明当前的项目类型, 默认为 miniProgram,有效值 miniProgram/miniProgramPlugin/miniGame/miniGamePlugin | | ignores | string[] | 否 | 指定需要排除的规则 |

批量成员管理

const ci = require('miniprogram-mp-ci')
;(async () => {
  const project = new ci.Project({
    appid: 'wxsomeappid',
    type: 'miniProgram',
    projectPath: 'the/project/path',
    privateKeyPath: 'the/path/to/privatekey',
    ignores: ['node_modules/**/*'],
  })
  const result = await ci.manageProjectMember({
    project,
    action: "add_project_member_data",
    robot: 1,
    member_list: [
      {   
         wechatid: "wechatid1",
         remark: "remark1"
      }
      { 
         wechatid: "wechatid2",
         remark: "remark2"
      }
    ]
  })
  console.log(result)
})()

参数

| 键 | 类型 | 必填 | 说明 | | ---------------- | -------- | ---- | ------------------------------------- | | project | IProject | 是 | #项目对象 | | action | string | 是 | #成员管理action | | robot | number | 是 | 指定使用哪一个 ci 机器人,可选值:1 ~ 30 | | member_list | array | 是 | #成员对象数组 |

成员管理action

| 可选值 | 说明 | | ---------------------------------- | ----------------------------------------------------- | | add_experiencer | 批量添加体验成员查看体验版权限 | | delete_experiencer | 批量删除体验成员查看体验版权限 | | add_experiencer_dev | 批量添加体验成员查看开发版权限 | | delete_experiencer_dev | 批量删除体验成员查看开发版权限 | | add_project_member_operator | 批量添加项目成员运营者权限 | | delete_project_member_operator | 批量删除项目成员运营者权限 | | add_project_member_developer | 批量添加项目成员开发者权限 | | delete_project_member_developer | 批量删除项目成员开发者权限 | | add_project_member_data | 批量添加项目成员数据分析者权限 | | delete_project_member_data | 批量删除项目成员数据分析者权限 |

成员对象

| 键 | 类型 | 必填 | 说明 | | ---------------- | -------- | ---- | ------------------------------------- | | wechatid | string | 是 | 目标用户的微信号 | | remark | string | 否 | 备注 |

返回

| 键 | 类型 | 必填 | 说明 | | ---------------- | -------- | ---- | ----------------------------------------- | | errCode | number | 否 | #errCode解释 | | errMsg | string | 否 | 操作失败的文字说明 |

errCode解释

| 值 | 说明 | | ---------------------------------- | ----------------------------------------------------- | | 0 | 操作成功 | | -1 | 请求失败 | | 80601 | 新增的成员已存在 | | 80602 | 删除的成员不存在 | | 80603 | 操作的微信号列表超出上限 | | 80604 | 操作的微信号列表中有微信号不存在 | | 80605 | 无法操作管理员 |