# 引入

import { MpCI  } from 't-comm';

// or

import { MpCI } from 't-comm/lib/mp-ci/index';

# MpCI

参数

# new MpCI(options)

小程序自动化构建工具

Param Type Description
options object

选项

Example

const { MpCI, fetchRainbowConfig } = require('t-comm');

const env = "${env}"
const branch = "${branch}"

const root = "${WORKSPACE}";

async function getCIConfig() {
  let res = {};
  const str = await fetchRainbowConfig('mp_ci', {
    appId: '',
    envName: 'x',
    groupName: 'x',
  });
  try {
    res = JSON.parse(str);
  } catch (err) {}
  return res;
}

function getRobot(config = {}) {
  return config?.robotMap?.[branch]?.[env] || 1;
}

async function main() {
  const config = await getCIConfig();
  console.log('config: \n', config, typeof config);
  const {
    appName,
    appId,
    webhookUrl,
    chatId,
    cosInfo,
  } = config;

  const ci = new MpCI({
    appName,
    appId,
    root,
    env,
    robotNumber: getRobot(config),

    webhookUrl,
    chatId,

    cosInfo,
  });

  await ci.upload();
  await ci.preview();
  await ci.sendRobotMsg();
}

main();

# mpCI.upload()

上传

Kind: instance method of MpCI

# mpCI.tryPreview()

预览

Kind: instance method of MpCI

# mpCI.uploadPreviewImg()

上传预览图片到COS

Kind: instance method of MpCI

# mpCI.sendRobotMsg()

发送机器人消息

Kind: instance method of MpCI

Last Updated: 2024/10/11 07:54:02