# Summary

Miniprogram-mp-ci is an npm package designed to simplify the member management process for Weixin Mini Program. It allows developers to perform batch management tasks directly through code, rather than manually through the WeChat public platform . This toolkit provides a series of automation features that make managing Mini Program members fast and efficient.

# Key and IP whitelisting configuration

Before using miniprogram-mp-ci, you should visit " WeChat Public Platform - Administration - Development Management - Development Settings - Weixin Mini Program Code Upload" to generate a Code Upload Key and configure an IP whitelist The developer can choose to open the IP whitelist, only the IP in the whitelist can call the relevant interface. We recommend that all developers turn this option on by default to reduce the risk Code upload key has preview, upload code permissions, the key will not be stored in plain text on the WeChat public platform, once lost must be reset, please keep the developer

# function

Miniprogram-mp-ci currently offers the following capabilities:

  1. Volume member management

# Script calls

npm install miniprogram-mp-ci --save

# Project Objectives

Project objects are the main inputs to this module and can be implemented on their own according to the definitions below

Definition of Project Object:

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
}
key type Introductions
appid attribute Weixin Mini Program / MiniGame Project AppID
type attribute Type of project, valid value miniProgram/miniProgramPlugin/miniGame/miniGamePlugin
projectPath attribute The path of the project, which is the directory where project.config.json is
privateKey attribute Private key, used for authentication when obtaining project attributes and uploading, downloaded on WeChat public platform
attr Asynchronous methods Property of the project, if privateKey is specified, the real project property is used
stat Synchronization Method A stat for a prefix filePath in a specific directory, or undefined if it does not exist
getFile Asynchronous methods Buffer of filePath under prefix in specific directory
getFileList Synchronization Method A list of files under the prefix filePath in a specific directory
updateFile Synchronization Method Update project files

You can also create the object by specifying the project path

const ci = require('miniprogram-mp-ci')
// Note: When calling newci.Project, make sure that the project code is already complete to avoid a file missing error during compilation.
const project = new ci.Project({
  appid: 'wxsomeappid',
  type: 'miniProgram',
  projectPath: 'the/project/path',
  privateKeyPath: 'the/privatekey/path',
  ignores: ['node_modules/**/*'],
})
key type Required to fill in Introductions
appid string yes Legal Weixin Mini Program / MiniGame AppID
projectPath string yes Project Path
privateKeyPath string yes The path of the private key
type string no Display indicates the current project type, defaults to miniProgram, valid miniProgram/miniProgramPlugin/miniGame/miniGamePlugin
ignores string[] no Specify rules that need to be ruled out

# Volume member management

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

# parameter

key type Required to fill in Introductions
project IProject yes # Project objects
action string yes # MemberManagementAction
robot number yes Specify which ci droid to use, optional: 1 ~ 30
member_list array yes # Array of member objects

# Member management action

Optional values Introductions
add_experiencer Add Experience Members in Bulk View Experience Copyright Limits
delete_experiencer Delete Experience Members in Bulk View Experience Copyright Limits
add_experiencer_dev Add Experience Members in Bulk View Developer License Limits
delete_experiencer_dev Batch Deletion Experience Members See Developer License Limits
add_project_member_operator Add project member operators permissions in bulk
delete_project_member_operator Delete project member operators permissions in bulk
add_project_member_developer Add project member developer permissions in bulk
delete_project_member_developer Delete project member developer permissions in bulk
add_project_member_data Increase project member data analyst permissions in bulk
delete_project_member_data Delete project member data analyst permissions in bulk

# Objectives of members

key type Required to fill in Introductions
wechatid string yes The WeChat number of the target user
remark string no Remarks

# return

key type Required to fill in Introductions
errCode number no # errCode Explained
errMsg string no Text explaination of operational failure

# Errcode explained

value Introductions
0 Operation was successful.
-1 Request failed
80601 The new members already exist.
80602 The deleted member does not exist
80603 The WeChat number list for the operation exceeds the limit
80604 There is no WeChat ID in the WeChat ID list.
80605 Unable to operate administrators

# Common problem

Q1. What is the effective method? A1: Ensure that the information is correct, after the successful call, the administrator WeChat will receive the message notification from "Public Platform Security Assistant," which will take effect immediately after the administrator confirms it.