UNPKG

t-comm

Version:

专业、稳定、纯粹的工具库

121 lines (118 loc) 3.53 kB
import { sortObjectByKey } from '../../object/sort.mjs'; import { sortRobotMapByRobot, updateQQTencentSheetLine } from './helper.mjs'; import '../../tslib.es6-096fffdd.js'; function changeRobot(_a) { var info = _a.info, robot = _a.robot, env = _a.env, testRobot = _a.testRobot, releaseRobot = _a.releaseRobot; if (robot && env) { info[env] = robot; } else { info.test = testRobot; info.release = releaseRobot; } } function updateMpCIRainbowConfig(_a) { var _b, _c; var rainbowConfig = _a.rainbowConfig, branch = _a.branch, originBranch = _a.originBranch, testRobot = _a.testRobot, releaseRobot = _a.releaseRobot, robot = _a.robot, env = _a.env, useMpQQ = _a.useMpQQ; function setWxRobot() { if (!rainbowConfig.robotMap[branch]) { rainbowConfig.robotMap[branch] = {}; } changeRobot({ info: rainbowConfig.robotMap[branch], testRobot: testRobot, releaseRobot: releaseRobot, robot: robot, env: env }); } function setQQRobot() { var _a; if (!rainbowConfig.qqRobotMap) { rainbowConfig.qqRobotMap = {}; } if (useMpQQ) { if (!rainbowConfig.qqRobotMap[branch]) { rainbowConfig.qqRobotMap[branch] = {}; } changeRobot({ info: rainbowConfig.qqRobotMap[branch], testRobot: testRobot, releaseRobot: releaseRobot, robot: robot, env: env }); } else { if ((_a = rainbowConfig.qqRobotMap) === null || _a === void 0 ? void 0 : _a[branch]) { delete rainbowConfig.qqRobotMap[branch].test; delete rainbowConfig.qqRobotMap[branch].release; } } } // const originUseMpQQ = !!rainbowConfig.qqRobotMap?.[branch]; if (originBranch) { if ((_b = rainbowConfig.robotMap) === null || _b === void 0 ? void 0 : _b[originBranch]) { delete rainbowConfig.robotMap[originBranch].test; delete rainbowConfig.robotMap[originBranch].release; } if ((_c = rainbowConfig.qqRobotMap) === null || _c === void 0 ? void 0 : _c[originBranch]) { delete rainbowConfig.qqRobotMap[originBranch].test; delete rainbowConfig.qqRobotMap[originBranch].release; delete rainbowConfig.qqRobotMap[originBranch].tencentDocsLine; } } setWxRobot(); setQQRobot(); // 新增 // if (!originBranch) { // // 该分支已经有配置了 // if (rainbowConfig.robotMap[branch]) { // return { // error: errorMap.BRANCH_EXIST, // }; // } // setWxRobot(); // setQQRobot(); // } else { // // 修改 // // 分支相同,说明是仅修改qq配置 // if (originBranch === branch) { // if (originUseMpQQ === useMpQQ) { // return { // error: errorMap.SAME_CONFIG, // }; // } // setQQRobot(); // } else { // if (rainbowConfig.robotMap[branch]) { // return { // error: errorMap.BRANCH_EXIST, // }; // } // setWxRobot(); // setQQRobot(); // delete rainbowConfig.robotMap[originBranch]; // delete rainbowConfig.qqRobotMap[originBranch]; // } // } rainbowConfig.robotMap = sortRobotMapByRobot(rainbowConfig.robotMap); var rainbowKey = rainbowConfig.rainbowKey; delete rainbowConfig.rainbowKey; var newRainbowConfig = sortObjectByKey(rainbowConfig); updateQQTencentSheetLine(newRainbowConfig); return { newRainbowConfig: newRainbowConfig, rainbowKey: rainbowKey }; } export { updateMpCIRainbowConfig };