UNPKG

t-comm

Version:

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

126 lines (125 loc) 2.81 kB
import type { IUploadResult, OptionsType } from './types'; declare class MpCI { ciLib: any; options: OptionsType; projectCI: any; savePreviewPath: any; appId: string; appName: string; type: string; root: string; ignores: Array<string>; pkgFile: string; env: string; robotNumber: number; webhookUrl?: string; chatId?: string; buildSetting: any; projectPath: string; privateKeyPath: string; cosInfo: any; commitInfo: any; buildDesc: string; buildTime?: string; version: string; previewResult: IUploadResult; errorLink?: string; pagePath?: string; searchQuery?: string; tryTimesMap: { UPLOAD: number; PREVIEW: number; }; /** * 小程序自动化构建工具 * @param {object} options 选项 * * @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(); */ constructor(options: OptionsType); validateOptions(): void; initBaseInfo(): void; init(): void; getBuildTime(): void; /** * 上传 */ upload(): Promise<void>; tryUpload(): Promise<void>; preview(): Promise<void>; /** * 预览 */ tryPreview(): Promise<void>; /** * 上传预览图片到COS */ uploadPreviewImg(previewResult: IUploadResult): Promise<void>; getCosKey(): string; getCOSFilePath(): string; /** * 发送机器人消息 */ sendRobotMsg(hasImg?: boolean): Promise<void>; uploadAndPreview(): Promise<void>; uploadFiles(files: Array<{ key: string; path: string; }>): Promise<void>; } export { MpCI };