/// /// import type Chalk from 'chalk'; import type * as Cheerio from 'cheerio'; import type * as childProcess from 'child_process'; import { compile } from './path-to-regexp'; import type COS from 'cos-nodejs-sdk-v5'; import type * as CronParser from 'cron-parser'; import type * as CryptoType from 'crypto'; import type * as Dotenv from 'dotenv'; import type * as DotenvExpand from 'dotenv-expand'; import type { default as FormData_2 } from 'form-data'; import { fs } from 'fs'; import type * as FsExtra from 'fs-extra'; import type * as fsModule from 'fs'; import type * as httpModule from 'http'; import type * as JoseType from 'jose'; import type * as MiniprogramCI from 'miniprogram-ci'; import type * as NetType from 'net'; import type * as osModule from 'os'; import { parse } from './path-to-regexp'; import type * as path from 'path'; import { PlatformPath } from 'path'; import { ScoreInfoType } from '../types'; import { StdioOptions } from 'child_process'; import { tokensToFunction } from './path-to-regexp'; import { tokensToRegExp } from './path-to-regexp'; import type * as UtilType from 'util'; import { WorkBook } from 'xlsx'; import { WorkSheet } from 'xlsx'; import type * as XLSX from 'xlsx'; /** * 将 ArrayBuffer 转换为字符串 * 支持多种字符编码,优先使用 TextDecoder API * @param buffer - 要转换的 ArrayBuffer * @param encoding - 字符编码,默认为 'utf-8' * @returns 转换后的字符串 * @example * ```ts * const buffer = new ArrayBuffer(8); * const str = ab2str(buffer); // 使用 UTF-8 编码 * const gbkStr = ab2str(buffer, 'gbk'); // 使用 GBK 编码 * ``` */ export declare function ab2str(buffer: ArrayBuffer, encoding?: string): string; export declare const ACT_ID_MAP: { GP: string; }; /** * 为 Vue 组件添加 emits 属性 * @param {string} filePath 组件地址 * @param {string} [fileContent] 组件内容 * @returns {string} 新的组件内容 * * @example * ```ts * addNameForComponent('xxx.vue'); * ``` */ export declare function addEmitsForComponent(filePath: string, fileContent?: string): string | undefined; /** * 添加 MSDK 原生回调监听器 * 用于监听原生层发送给 Web 层的消息 * @param callback - 回调函数,接收原生层传递的数据 * @example * ```ts * addMsdkNativeCallbackListener((data) => { * console.log('收到原生消息:', data); * }); * ``` */ export declare function addMsdkNativeCallbackListener(callback: Function): void; /** * 为 Vue 组件添加、修正 name 属性 * @param {string} filePath 组件地址 * @param {string} componentName 组件名称 * @returns {string} 新的组件内容 * * @example * ```ts * addNameForComponent('xxx.vue', 'PressUploader'); * ``` */ export declare function addNameForComponent(filePath: string, componentName: string): any; /** * add num and avoid float number * @param {number} num1 第1个数字 * @param {number} num2 第2个数字 * @returns {number} 结果 * @example * ```ts * addNumber(0.1, 0.2); // 0.3 * ``` */ export declare function addNumber(num1: number, num2: number): number; /** * 添加或更新配置 * * @param {object} config 配置信息 * @param {object} config.keyValue 配置对象 * @param {string} config.keyValue.key 配置的key * @param {string} config.keyValue.value 配置的value * @param {number} config.valueType 配置类型,1: NUMBER, 2: STRING, 3: TEXT, 4: JSON, 5: XML, 18: 日期, 20: yaml * @param {object} config.secretInfo 密钥信息 * @param {string} config.secretInfo.appId 项目Id * @param {string} config.secretInfo.userId 用户Id * @param {string} config.secretInfo.secretKey 密钥 * @param {string} config.secretInfo.envName 配置环境 * @param {string} config.secretInfo.groupName 配置组 * @returns {Promise} 请求Promise * * @example * addOrUpdateRainbowKV({ * keyValue: { * key: 'theKey', * value: 'theValue', * }, * valueType: 2, * secretInfo: { * appId: 'xxx', * userId: 'xxx', * secretKey: 'xxx', * envName: 'prod', * groupName: 'xxx', * } * }).then(() => { * * }) */ export declare function addOrUpdateRainbowKV({ keyValue, valueType, secretInfo, }: ModifyConfigParam): Promise; /** * 增加配置 * * @param {object} config 配置信息 * @param {object} config.keyValue 配置对象 * @param {string} config.keyValue.key 配置的key * @param {string} config.keyValue.value 配置的value * @param {number} config.valueType 配置类型,1: NUMBER, 2: STRING, 3: TEXT, 4: JSON, 5: XML, 18: 日期, 20: yaml * @param {object} config.secretInfo 密钥信息 * @param {string} config.secretInfo.appId 项目Id * @param {string} config.secretInfo.userId 用户Id * @param {string} config.secretInfo.secretKey 密钥 * @param {string} config.secretInfo.envName 配置环境 * @param {string} config.secretInfo.groupName 配置组 * @returns {Promise} 请求Promise * * @example * addRainbowKV({ * keyValue: { * key: 'theKey', * value: 'theValue', * }, * valueType: 2, * secretInfo: { * appId: 'xxx', * userId: 'xxx', * secretKey: 'xxx', * envName: 'prod', * groupName: 'xxx', * } * }).then(() => { * * }) */ export declare function addRainbowKV({ keyValue, valueType, secretInfo, }: ModifyConfigParam): Promise; /** * 为图片增加文字 * * @param {Object} config 配置 * @param {number} config.width 宽度 * @param {number} config.height 高度 * @param {Array} config.textList 文字列表,支持多行 * @param {string} config.imgPath 图片路径 * @returns {string} canvas.toDataURL生成的base64图片 * * @example * * ```ts * const imgUrl = addTextForImg({ * width: 300, * height: 300, * textList: ['第一行', '第二行'], * imgPath: './test.png', * }) * ``` */ export declare function addTextForImg({ width, height, textList, imgPath, }: { width: number; height: number; textList: Array; imgPath: string; }): Promise; export declare function aegisReportErrorV2(mAegisV2: any, options: ReportOptions): void; export declare function aegisReportEventV2(mAegisV2: any, options: EventOptions): void; export declare function aegisReportInfoV2(mAegisV2: any, options: ReportOptions, method?: string): void; export declare class AegisReportInPixui { static options: InitAegisOptions; static aegis: any; static init(options: InitAegisOptions): Promise; static report(info: Record): Promise; static info(info: Record): Promise; } export declare function aegisReportV2(mAegisV2: any, options: ReportOptions): void; /** * 分析首页Bundle信息 * * @export * @param config 配置 * @param {string} config.domain 域名 * @param {string} config.buildPath 打包路径 * @returns {*} * * @example * ```ts * analyzeIndexBundle({ * domain: '', * buildPath: '', * }) * ``` */ export declare function analyzeIndexBundle({ domain, buildPath }: { domain: string; buildPath: string; }): ({ file: string; size: number; time: number; } | undefined)[]; declare interface AnalyzeItem { root: string; simpleRoot: string; project: string; git: string; analyzeDir?: string; needAnalyzeSubDir?: string[]; } export declare function ApprovalRainbowReleaseTask({ secretInfo, taskId, versionName, status, rejectReason, }: { secretInfo: ISecretInfo_3; taskId: string | number; versionName: string; status?: number; rejectReason?: string; }): Promise; declare const AREA_MAP: { readonly MAINLAND: "mainland"; readonly OVERSEAS: "overseas"; }; declare const AREA_MAP_WITH_GLOBAL: { readonly MAINLAND: "mainland"; readonly OVERSEAS: "overseas"; readonly GLOBAL: "global"; }; export declare function asyncExportTencentDoc({ accessToken, clientId, openId, fileId, exportType, }: ISecretInfo_2 & { fileId: string; exportType: number; }): Promise; /** * 基本请求 * @private * @param {object} config - 配置信息 * @returns {Promise} 请求Promise */ export declare function baseRequestRainbow({ url, data: reqData, secretInfo, }: ReqParam): Promise; /** * 批量重命名文件和文件夹(同步版本) * @param {string} dirPath - 要处理的目录路径 * @param {Object} renameConfig - 重命名配置对象 { 旧名称: 新名称 } * @param {boolean} [recursive=true] - 是否递归处理子目录 */ export declare function batchRenameDirEntries(dirPath: string, renameConfig: Record, recursive?: boolean): void; /** * 批量替换文件内容(性能优化版) * 将同 dirList 的规则合并,每个文件只读写一次 * @param {Array<{ list: Array, dirList: string|string[] }>} replaceList - 替换规则列表 */ export declare function batchReplaceFileContent(replaceList: Array<{ list: Array<[string | RegExp, string]>; dirList: string | string[]; }>): void; /** * 批量发送企业微信机器人base64图片 * @param {object} config 配置信息 * @param {string} config.img base64图片 * @param {string} config.chatId 会话Id * @param {string} config.webhookUrl webhook地址 * @returns {Promise} 请求Promise * @example * * batchSendWxRobotBase64Img({ * img: 'xxx', * chatId: 'xxx', // or ['xxx], or ['ALL'], or 'ALL' * webhookUrl: 'xxx', * }).then(() => { * * }) * */ export declare function batchSendWxRobotBase64Img({ img, chatId, webhookUrl, }: { img: string; } & ISendReq): Promise; export declare function batchSendWxRobotMarkdown({ content, attachments, chatId, webhookUrl, isV2, }: { content: string; attachments?: Array; isV2?: boolean; } & ISendReq): Promise; export declare function batchSendWxRobotMsg({ content, alias, chatId, webhookUrl, }: { content: string; alias: string | Array; } & ISendReq): Promise; export declare function batchUpdateTencentSheetV3({ accessToken, clientId, openId, bookId, requests, }: ISecretInfo_2 & { bookId: string; requests: Record; }): Promise; export declare function build({ files, root, bundleName, outputDir, }: { files?: Array; root?: string; bundleName: string; outputDir?: string; }): Promise; /** * 打包并上传到服务器 * @param {object} options 配置 * @param {string} options.hostName 服务器名称 * @param {string} options.hostPwd 服务器密码 * @param {string} [options.root] 项目根目录 * @param {string} [options.bundleName] 打包文件名称 * @param {boolean} [options.wrapHostPwd=true] 是否用双引号包裹密码,默认为 true * @param {string} [options.outputDir='dist'] 打包输出目录,默认为 'dist' * @example * * await buildAndUpload({ * hostName: '9.9.9.9', * hostPwd: 'xxxx', * bundleName: 'cron-job-svr', * }); * */ export declare function buildAndUpload({ root, bundleName, hostName, hostPwd, hostTargetDir, wrapHostPwd, outputDir, }: { root?: string; bundleName?: string; hostName: string; hostPwd: string; hostTargetDir: string; wrapHostPwd?: boolean; outputDir?: string; }): Promise; /** * 构建审核通知内容数组 * * 统一拼接审核通知消息,各流水线只需传入标题和差异化字段即可。 * * @example H5 发布 * ```ts * const content = buildAuditContent({ * title: '【H5发布审核】', * projectName: 'pmd-mobile/match/gp', * creator: 'novlan1', * auditor: 'junshao', * buildUrl: 'https://devops.woa.com/xxx', * extraLines: [ * `子工程:\`gp-hor\``, * `灰度比例:50%`, * ], * }); * ``` * * @example 回滚审核 * ```ts * const content = buildAuditContent({ * title: '【`回滚`审核】', * projectName: 'pmd-mobile/match/gp', * creator: 'novlan1', * auditor: 'junshao', * buildUrl: 'https://devops.woa.com/xxx', * extraLines: [`子工程:\`gp-hor\``], * }); * ``` */ export declare function buildAuditContent(options: IBuildAuditContentOptions): string[]; /** * 记忆函数:缓存函数的运算结果 * @param {Function} fn 输入函数 * @returns {any} 函数计算结果 * * @example * function test(a) { * return a + 2 * } * * const cachedTest = cached(test) * * cachedTest(1) * * // => 3 * * cachedTest(1) * * // => 3 */ export declare function cached(fn: (arg: T) => R): (arg: T) => R; /** * 添加游戏内浏览器jssdk * @example * ```ts * callJsBrowserAdapter(); * ``` */ export declare function callJsBrowserAdapter(): Promise; /** * 设置 MSDK 浏览器退出全屏,需提前加载 sdk * @example * ```ts * callJsReSetFullScreen(); * ``` */ export declare const callJsReSetFullScreen: () => void; /** * 设置 MSDK 浏览器全屏,需提前加载 sdk * @param isFullScreen 是否全屏 * @example * ```ts * callJsSetFullScreen(); * callJsSetFullScreen(false); * ``` */ export declare const callJsSetFullScreen: (isFullScreen?: boolean) => void; /** * 横线转驼峰命名,如果第一个字符是字母,则不处理。 * @param {string} str 输入字符串 * @param {boolean} handleSnake 是否处理下划线,默认不处理 * @returns {string} 处理后的字符串 * @example * * camelize('ab-cd-ef') * * // => abCdEf * */ export declare function camelize(str?: string, handleSnake?: boolean): string; /** * 字符串首位大写 * @param {string} str 输入字符串 * @returns {string} 处理后的字符串 * * @example * * capitalize('abc') * * // => Abc */ export declare function capitalize(str: string): string; /** * 检查 localStorage 设置,并展示vConsole * @example * ```ts * checkAndShowVConsole() * ``` */ export declare function checkAndShowVConsole(): void; /** * 统一审核结果检查 * * 检查审核结果,通过则 resolve,驳回则发送企微通知并 reject。 * 适用于 H5 发布、组件库发布等所有需要审核的流水线。 * * @example H5 发布 * ```ts * const { batchSendWxRobotMarkdown, checkAuditResult } = require('t-comm'); * * await checkAuditResult({ * resultInfo, * title: '【H5发布】', * contentLines: [`项目: \`my-project\``, `子工程:\`my-sub\``], * creator: 'novlan1', * auditDesc: '需求发布', * webhookUrl: '0482249e-bf24-4168-b3e2-f72d012840c2', * sendMarkdown: batchSendWxRobotMarkdown, * }); * ``` */ export declare function checkAuditResult(options: ICheckAuditResultOptions & { /** 发送企微 Markdown 消息的函数,由调用方传入 */ sendMarkdown: (params: { content: string; chatId: string[]; webhookUrl: string; }) => Promise; }): Promise; export declare function checkExportTencentDocProgress({ accessToken, clientId, openId, fileId, operationId, }: ISecretInfo_2 & { fileId: string; operationId: string; }): Promise; export declare function checkFileBaseMinimatch({ file, include, exclude, minimatch, }: { file: string; include: string | string[]; exclude: string | string[]; minimatch: Function; }): boolean; /** * 异步并行检查目录下所有 git 仓库的工作区状态 * 相比同步版本,在仓库数量较多时有显著的性能提升 * @param dir - 要检查的父目录路径 */ export declare function checkGitClean(dir: string): Promise; /** * 同步版本,保持向后兼容 * @param dir - 要检查的父目录路径 */ export declare function checkGitCleanSync(dir: string): void; export declare function checkJSFiles(options?: { whiteDir: string[]; excludeReg: RegExp; log: boolean; }): void; export declare function checkLint({ privateToken, gitApiPrefix, workspace, mrUrl, mrId, buildUrl, repo, repoUrl, sourceBranch, targetBranch, docLink, webhookUrl, chatId, checkAll, mentionList, lintFiles, throwError, ignoreSubmodules, }: { privateToken: string; gitApiPrefix: string; workspace: string; mrUrl?: string; mrId?: string; buildUrl: string; repo: string; repoUrl?: string; sourceBranch?: string; targetBranch?: string; docLink: string; webhookUrl: string; chatId?: string[]; checkAll?: boolean; mentionList?: string[]; lintFiles?: string[]; throwError?: boolean; ignoreSubmodules?: boolean; }): Promise; /** * 检查是否是node环境 * @returns {boolean} 是否node环境 * @example const res = checkNodeEnv(); // false */ export declare const checkNodeEnv: () => boolean; /** * 检查字符串长度 * * @export * @param {string} str 字符串 * @param {number} [num = 30] 长度 * @returns {boolean} * * @example * * checkStringLength('123', 2) // true * checkStringLength('123', 3) // true * checkStringLength('123', 4) // false * * */ export declare function checkStringLength(str?: string, num?: number): boolean; export declare function checkTSErrorInMrOrAll({ privateToken, gitApiPrefix, workspace, repo, repoUrl, mrId, mrUrl, sourceBranch, targetBranch, checkAll, buildUrl, docLink, mentionList, postFixList, chatId, webhookUrl, command, }: { privateToken: string; gitApiPrefix: string; workspace: string; repo: string; repoUrl: string; mrId: string; mrUrl: string; sourceBranch: string; targetBranch: string; checkAll: boolean; buildUrl: string; docLink: string; mentionList: string[]; postFixList?: string[]; chatId?: string[]; webhookUrl: string; command?: string; }): Promise; /** * 检查是否是ios环境 * @returns {boolean} 是否是ios环境 * * @example * * checkUAIsIOS() * * // => true * */ export declare function checkUAIsIOS(): boolean; declare type ChildProcess = typeof childProcess; /** * 将数组分割成指定长度的chunk * * @param array 数组 * @param chunkSize 要分的组数 * @returns 结果数组 * @example * ```js * chunkArray([1, 2, 3, 4, 5, 6, 7, 8], 3) */ export declare function chunkArray(array: T[], chunkSize: number): T[][]; /** * 清理单个 CHANGELOG 文件 * @param {string} filePath * @param {boolean} dryRun * @returns {boolean} 是否成功 */ export declare function cleanChangelogFile(filePath: string, dryRun?: boolean): boolean; /** * 主函数 */ export declare function cleanChangelogScript(args: string[]): Promise; /** * 清除全部cookie * * @param {string} domain 域名 * * @example * * clearAll() */ export declare function clearAll(domain?: String): void; /** * 清除cookie * @param {string} key cookie键 * * @example * * clearCookie('name'); * */ export declare function clearCookie(name: string): void; /** * 持久化存储。清理。传 key 就删除。不传清理所有过期的。 * @param {string} [key] * @returns {boolean} 是否清楚成功 */ export declare function clearPersist(key?: string): boolean; declare interface ClickOutsideElement extends HTMLElement { __vueClickOutside__?: (event: MouseEvent) => void; } /** * 小程序粘贴 * * @param {string} text 待复制的文本 * @returns {Promise} * @example * * ```ts * clipboardMp('stupid').then(() => {}); * ``` */ export declare function clipboardMp(text: string): Promise; /** * 复制到剪切板 * * @param {string} text 待复制的文本 * @returns {Promise} * @example * * ```ts * clipboardMp('stupid').then(() => {}); * ``` */ export declare function clipboardWeb(text: string): Promise; /** * MSDK 浏览器中,关闭 webView * @example * ```ts * closeMsdkWebview() * ``` */ export declare function closeMsdkWebview(env?: any): void; /** * 关闭任务 * * @param {object} config 配置信息 * @param {string} config.taskId 任务Id * @param {object} config.secretInfo 密钥信息 * @param {string} config.secretInfo.appId 项目Id * @param {string} config.secretInfo.userId 用户Id * @param {string} config.secretInfo.secretKey 密钥 * @param {string} config.secretInfo.envName 配置环境 * @param {string} config.secretInfo.groupName 配置组 * @returns {Promise} 请求Promise * * @example * closeRainbowTask({ * taskId: 'taskId', * secretInfo: { * appId: 'xxx', * userId: 'xxx', * secretKey: 'xxx', * envName: 'prod', * groupName: 'xxx', * } * }).then(() => { * * }) */ export declare function closeRainbowTask({ taskId, secretInfo, }: { taskId: string; secretInfo: ISecretInfo_3; }): Promise; /** * 关闭 vConsole * @example * ```ts * closeVConsole() * ``` */ export declare function closeVConsole(): void; /** * 关闭 webView,包含 msdk 浏览器和其他浏览器 * @example * ```ts * closeWebView() * ``` */ export declare function closeWebView(): void; /** * 多参数空值合并函数 * @param {...any} args - 任意数量的参数 * @returns {any} 第一个非null/undefined的参数值 */ export declare function coalesce(...args: unknown[]): unknown; /** * 收集所有需要扫描的文件列表 */ export declare function collectFiles(options: IReplaceAliasOptions): Array; export declare function collectFilesSync(dirPath?: string, fileList?: string[]): string[]; declare interface CommitInfo { hash: string; shortHash: string; author: string; email: string; date: string; subject: string; body: string; } /** * 对比两个对象列表 * @param {Array} list 现在数据 * @param {Array} preList 参照数据 * @param {string} key 唯一key名称 * @returns {Array} 对比结果,增加为list的每一项增加previousValue和ratio属性 * @example * const list = [ * { * ProjectName: { name: 'ProjectName', value: '脚手架' }, * PagePv: { name: 'PagePv', value: 544343 }, * PageUv: { name: 'PageUv', value: 225275 }, * } * ] * * const preList = [ * { * ProjectName: { name: 'ProjectName', value: '脚手架' }, * PagePv: { name: 'PagePv', value: 123123 }, * PageUv: { name: 'PageUv', value: 33333 }, * } * ] * * compareTwoList(list, preList, 'ProjectName') * * console.log(list) * * [ * { * ProjectName: { name: 'ProjectName', value: '脚手架' }, * PagePv: { * name: 'PagePv', * value: 544343, * ratio: '+342.1%', * previousValue: 123123 * }, * PageUv: { * name: 'PageUv', * value: 225275, * ratio: '+575.8%', * previousValue: 33333 * } * } * ] */ export declare function compareTwoList(list: Array, preList: Array, key: string): IPreData[]; export declare function compareTwoObj(originObj?: Record, newObj?: Record): { ADDED: Array; UPDATED: Array; DELETED: Array; originObj: object; newObj: object; }; /** * 版本比较 * @param {string} v1 第一个版本 * @param {string} v2 第二个版本 * @returns 比较结果,1 前者大,-1 后者大,0 二者相同 * @example * ```ts * compareVersion('1.1.1', '1.2.1') * // -1 * ``` */ export declare function compareVersion(v1?: string, v2?: string): 0 | 1 | -1; declare type Complete = (success: boolean, msg?: any) => void; declare const COMPLEXITY_DEFAULT_CSV_HEADER: readonly ["NLOC", "CNN", "TOKEN_COUNT", "PARAMETER_COUNT", "LOC", "FUNCTION_NAME_AND_FILE_NAME", "FILE_NAME", "FUNCTION_NAME", "FUNCTION_METHOD", "START_LINE", "END_LINE"]; declare type ComplexityCsvHeader = typeof COMPLEXITY_DEFAULT_CSV_HEADER; declare type ComplexityKey = ComplexityCsvHeader[number]; export declare type ComponentMapList = Record; /** * 组装`url`参数,将search参数添加在后面 * @param {string} url 输入URL * @param {Object} queryObj search对象 * @returns {string} 组装后的url * * @example * composeUrlQuery('https://baidu.com', { * name: 'mike', * feel: 'cold', * age: '18', * from: 'test', * }); * // https://baidu.com?name=mike&feel=cold&age=18&from=test * * composeUrlQuery('https://baidu.com?gender=male', { * name: 'mike', * feel: 'cold', * age: '18', * from: 'test', * }); * // https://baidu.com?gender=male&name=mike&feel=cold&age=18&from=test * */ export declare function composeUrlQuery(url: string, queryObj: object): string; /** * 压缩 base64 图片 * - 通过 canvas 缩放图片到指定最大宽度,并转为 JPEG 格式降低体积 * @param {string} base64Img base64 图片字符串(可带或不带 data:image 前缀) * @param {object} options 压缩选项 * @param {number} options.maxWidth 最大宽度,默认 280 * @param {number} options.quality JPEG 质量 0-1,默认 0.8 * @returns {Promise} 压缩后的 base64 图片字符串 * * @example * * const compressed = await compressBase64Img(base64Str, { maxWidth: 280, quality: 0.8 }); */ export declare function compressBase64Img(base64Img: string, options?: CompressOptions): Promise; export declare interface CompressOptions { maxWidth?: number; quality?: number; } declare type ConfigType = unknown; export declare function configWx({ apiList, openTagList, getWxSignaturePromise, }: { apiList?: Array; openTagList?: Array; getWxSignaturePromise: IGetWxSignaturePromise; }): Promise; export declare const consoleImage: (url: string) => void; export declare function consoleInfo(shouldLog: boolean, ...args: any[]): void; export declare function consoleLog(shouldLog: boolean, ...args: any[]): void; /** * Dom转化为图片 * @param {string} trigger Dom的id * @param {string} imageElId 需要展示的图片的id * * @example * Dom2Image.convertDomToImage("app", "appImage"); */ export declare function convertDomToImage(trigger: string, imageElId: string, callback: Function): void; export declare interface ConvertExcelOptions { /** 支持的 ti18n keys 列表,默认使用 TI18N_KEYS */ ti18nKeys?: readonly string[]; /** 语言名称到 ti18n key 的映射表,默认使用 LANG_NAME_TO_TI18N_KEY */ langNameMapping?: Record; } /** * 读取 Excel,替换首行 key 为 ti18n 标准 key,输出新 Excel * @param inputPath 输入 Excel 路径 * @param outputPath 输出 Excel 路径 * @param options 转换配置选项 * @returns 转换结果,包含 jsonData 和 activeKeys * @example * ```ts * // 使用默认配置 * convertExcelToTi18n('./input.xlsx', './output.xlsx'); * * // 自定义支持的语言列表 * convertExcelToTi18n('./input.xlsx', './output.xlsx', { * ti18nKeys: ['zh', 'en', 'ja', 'ko'], // 只支持中英日韩 * }); * * // 自定义语言名称映射 * convertExcelToTi18n('./input.xlsx', './output.xlsx', { * langNameMapping: { * ...DEFAULT_LANG_NAME_TO_TI18N_KEY, * '日语': 'ja', * 'japanese': 'ja', * '韩语': 'ko', * 'korean': 'ko', * }, * }); * * // 完全自定义配置 * convertExcelToTi18n('./input.xlsx', './output.xlsx', { * ti18nKeys: ['zh', 'en', 'ja'], * langNameMapping: { * 'zh': 'zh', * 'en': 'en', * 'ja': 'ja', * '中文': 'zh', * '英文': 'en', * '日文': 'ja', * }, * }); * ``` */ export declare function convertExcelToTi18n(inputPath: string, outputPath: string, options?: ConvertExcelOptions): ConvertResult; /** * image url转canvas * @param image {Image} 图片src * @returns canvas */ export declare function convertImageToCanvas(image: HTMLImageElement): ICanvas; declare interface ConvertResult { jsonData: Record[]; activeKeys: string[]; } export declare function convertTencentFileId({ accessToken, clientId, openId, type, value, }: ISecretInfo_2 & { type: number; value: string; }): Promise; /** * 拷贝目录以及子文件 * 递归复制整个目录结构,包括所有子目录和文件 * @param src - 源目录路径 * @param dist - 目标目录路径 * @param callback - 可选的回调函数,复制完成后执行 * @example * ```ts * copyDir('/source/path', '/target/path', () => { * console.log('复制完成'); * }); * ``` */ export declare function copyDir(src: string, dist: string, callback?: Function): void; /** * 拷贝单个文件 * 将文件从源路径复制到目标路径 * @param from - 源文件路径 * @param to - 目标文件路径 * @returns 写入操作的结果 * @example * ```ts * copyFile('/source/file.txt', '/target/file.txt'); * ``` */ export declare function copyFile(from: string, to: string): void; export declare function createAutoProtectedRuleForStoryBranch({ projectName, baseUrl, privateToken, defaultRuleName, shouldUpdateExistingBranches, }: { projectName: string; baseUrl: string; privateToken: string; defaultRuleName: string; shouldUpdateExistingBranches?: boolean; }): Promise; /** * 创建canvas的table * @param {object} config 输入配置 * @param {Array} config.data 输入数据 * @param {Array} config.headers 表头列表 * @param {Array} config.cellWidthList 每一格的宽度列表 * @param {string} config.title 标题 * @returns {string} 图片url * @example * * const tableData = [ * { * ProjectName: { name: 'ProjectName', value: 'ProjectA' }, * ALL_SUMMARY: { * name: 'ALL_SUMMARY', * value: 4987, * ratio: '+26.2%', * previousValue: 3953, * idx: 0, * lastIdx: 0, * isMax: true, * isMin: false, * isSecondMax: false, * isSecondMin: false, * }, * ALL_FAIL: { * // ... * }, * }, * { * ProjectName: { name: 'ProjectName', value: 'ProjectB' }, * // ... * }, * ]; * * createCanvasTable({ * data: tableData, * headers: getHeaders(tableData), * title: `007日报 ${date}`, * cellWidthList: [ * 95, * 65, * 65, * 65, * ], * }); */ export declare function createCanvasTable({ data, headers, cellWidthList, title, }: { data: Array<{ [k: string]: { value?: number; isMax?: boolean; isMin?: boolean; isSecondMax?: boolean; isSecondMin?: boolean; ratio?: string | number; }; }>; headers: Array; cellWidthList: Array; title: string; }): string; export declare function createDevopsTemplateInstances({ projectId, templateId, host, pipelineName, pipelineParam, secretInfo, useTemplateSettings, }: ITemplateReq & { pipelineName: string; pipelineParam: Object; useTemplateSettings?: boolean; }): Promise; export declare function createIwikiDoc({ prefix, spacekey, spaceId, contenttype, title, body, parentid, otherData, paasId, paasToken, }: { prefix: string; spacekey?: string; spaceId?: string; contenttype?: string; title?: string; body?: string; parentid?: string | number; otherData?: any; paasId: string; paasToken: string; }): Promise<{ code: string; msg: string; data: { id: string; docid: string; }; request_id: string; }>; /** * 创建MR * @param {object} options 输入配置 * @param {string} options.projectName 项目名称 * @param {string} options.privateToken 密钥 * @param {string} options.sourceBranch 源分支 * @param {string} options.targetBranch 目标分支 * @returns {Promise} 请求Promise * @example * * createMR({ * projectName: 't-comm', * privateToken: 'xxxxx', * sourceBranch: 'master', * targetBranch: 'release', * }).then((resp) => { * * }) */ export declare function createMR({ projectName, privateToken, sourceBranch, targetBranch, }: { projectName: string; privateToken: string; sourceBranch: string; targetBranch: string; }): Promise; export declare function createPrefetchTask({ secretId, secretKey, targets, zoneId, }: { secretId: string; secretKey: string; targets: string[]; zoneId: string; }): Promise; export declare function createProtectedBranchRule({ projectName, privateToken, baseUrl, form, }: { projectName: string; privateToken: string; baseUrl: string; form: ProtectedRuleForm; }): Promise>; export declare function createPurgeTask({ secretId, secretKey, targets, zoneId, method, type, }: { secretId: string; secretKey: string; targets: string[]; zoneId: string; method?: IPurgeMethod; type?: IPurgeType; }): Promise; /** * 创建发布任务 * * @param {object} config 配置信息 * @param {string} config.versionName 版本信息 * @param {object} config.secretInfo 密钥信息 * @param {string} config.secretInfo.appId 项目Id * @param {string} config.secretInfo.userId 用户Id * @param {string} config.secretInfo.secretKey 密钥 * @param {string} config.secretInfo.envName 配置环境 * @param {string} config.secretInfo.groupName 配置组 * @returns {Promise} 请求Promise * * @example * createRainbowPublishJob({ * versionName: 'version', * secretInfo: { * appId: 'xxx', * userId: 'xxx', * secretKey: 'xxx', * envName: 'prod', * groupName: 'xxx', * } * }).then(() => { * * }) */ export declare function createRainbowPublishJob({ versionName, secretInfo, creator, approvers, type, }: { versionName: string; secretInfo: ISecretInfo_3; creator: string; approvers: string; type?: number; }): Promise; export declare function createTencentDoc({ accessToken, clientId, openId, type, title, folderId, }: ISecretInfo_2 & { type: number; title: string; folderId?: string; }): Promise; /** * canvas 实现 watermark * @param {object} params 参数 * @param {HTMLElement} params.container 容器 * @param {number} params.width 图片宽 * @param {number} params.height 图片高 * @param {string} params.textAlign 同 ctx.textAlign * @param {string} params.textBaseline 同 ctx.textBaseline * @param {string} params.font 同 ctx.font * @param {string} params.fillStyle 同 ctx.fillStyle * @param {string} params.content 内容 * @param {number} params.rotate 旋转角度 * @param {number} params.zIndex 层级 * * @example * * ```ts * const rtx = 'pony'; * * createWatcherMark({ * content: rtx, * width: '300', * height: '300', * textAlign: 'center', * textBaseline: 'middle', * font: '25px Microsoft Yahei', * fillStyle: 'rgba(184, 184, 184, 0.3)', * rotate: '-50', * zIndex: 1000, * }); * ``` */ export declare function createWatcherMark({ container, width, height, textAlign, textBaseline, font, fillStyle, content, rotate, zIndex, }?: { container?: HTMLElement | undefined; width?: number | undefined; height?: number | undefined; textAlign?: string | undefined; textBaseline?: string | undefined; font?: string | undefined; fillStyle?: string | undefined; content?: string | undefined; rotate?: number | undefined; zIndex?: number | undefined; }): void; /** * 每日合并 * 1. 获取昨天有活跃的分支 * 2. 对于每个分支,进行合并并推送 * - 清理 Git 环境 * - 切到主分支,并拉最新代码 * - 切到当前分支,拉最新代码 * - 尝试执行 git merge * - 对比 merge 前后的 commit 信息是否相同,作为判断 merge 是否成功的依据 * 3. 发送机器人消息 * * * @export * @async * @param {object} param0 参数 * @param {string} param0.webhookUrl 机器人地址 * @param {string} param0.appName 项目名称 * @param {string} param0.devRoot 项目根路径 * @param {string} param0.baseUrl 基础请求 url * @param {string} param0.repoName 仓库名称 * @param {string} param0.privateToken 密钥 * @param {boolean} [param0.isDryRun=false] 是否演练 * @param {string} [param0.mainBranch='develop'] 主分支 * @param {Regexp} [param0.whiteBranchReg=/^release\|develop\|hotfix\\/.+$/] 不处理的分支正则 * @returns {*} * @example * * ```ts * dailyMerge({ * webhookUrl: 'xx', * appName: 'xx', * devRoot: 'xx', * * baseUrl: 'xx', * repoName: 'xx', * privateToken: 'xx', * * isDryRun: false, * }) * ``` */ export declare function dailyMerge({ webhookUrl, appName, devRoot, baseUrl, repoName, privateToken, isDryRun, mainBranch, whiteBranchReg, }: { webhookUrl: string; appName: string; devRoot: string; baseUrl: string; repoName: string; privateToken: string; isDryRun?: boolean; mainBranch?: string; whiteBranchReg?: RegExp; }): Promise; /** * 将日期格式化 * @param {Date} date * @param {string} format * @returns {string} 格式化后的日期字符串 * @example * * const date = new Date('2020-11-27 8:23:24'); * * const res = dateFormat(date, 'yyyy-MM-dd hh:mm:ss') * * // 2020-11-27 08:23:24 */ export declare function dateFormat(date: string | number | Date, fmt: string): string; /** * 防抖,场景:搜索 * * 触发事件后在 n 秒内函数只能执行一次,如果 * 在 n 秒内又触发了事件,则会重新计算函数执行时间 * * @param {Function} fn 主函数 * @param {number} time 间隔时间,单位 `ms` * @param {boolean} immediate 是否立即执行,默认 `false` * @returns 闭包函数 * * @example * * ```ts * function count() { * console.log('xxxxx') * } * window.onscroll = debounce(count, 500) * * window.onscroll = debounce(count, 500, true) * ``` */ export declare function debounce(fn: Function, time: number, immediate?: boolean): (...args: Array) => any; /** * 不用生成中间函数的防抖 * * @example * ```ts * debounceRun(func, args, { * funcKey: 'funcKey', * wait: 500, // 默认 500 * throttle: false, // 是否是节流,默认 false * immediate: true, // 是否立即执行,默认 true * }) * `` */ export declare const debounceRun: (func: Function, args?: any[], options?: { funcKey?: any; wait?: number; throttle?: boolean; immediate?: boolean; debug?: boolean; }) => void; /** * 将 Base64 编码的字符串解码为原始字符串 * 支持 Unicode 字符(包括中文、emoji 等),兼容小程序环境 * @param str - Base64 编码的字符串 * @returns 解码后的原始字符串 * @example * ```ts * decode('SGVsbG8gV29ybGQ='); // 'Hello World' * decode('5L2g5aW95LiW55WM'); // '你好世界' * decode('8J+YgA=='); // '😀' * ``` */ export declare const decode: (str: string) => string; /** * 将字符串解码,与`encodeUrlParam`相对 * @param {string} obj 输入字符串 * @returns {object} 对象 * @example * * decodeUrlParam('%7B%22a%22%3A1%7D') * * // { a: 1 } * */ export declare function decodeUrlParam(str: string): object; /** * PostCSS 插件:将 Vue3 的 :deep() 转换为 Vue2 的 ::v-deep, * 同时处理 :slotted() 和 :global() 选择器。 * 内置平台判断,默认在所有平台执行。 * * @param {object} options - 配置选项 * @param {string[]} options.platform - 在哪些平台执行,默认所有平台 * * @example * * ```js * // postcss.config.js * const { deepSelectorPlugin } = require('t-comm'); * * module.exports = { * plugins: [ * // 所有平台都执行 * deepSelectorPlugin(), * // 仅在 h5 平台执行 * deepSelectorPlugin({ platform: ['h5'] }), * ], * }; * ``` */ export declare const deepSelectorPlugin: { (options?: DeepSelectorPluginOptions): { postcssPlugin: string; Rule(rule: any): void; }; postcss: boolean; }; declare interface DeepSelectorPluginOptions { /** 在哪些平台执行,默认所有平台。通过 process.env.UNI_PLATFORM 判断 */ platform?: string[]; } /** * 深度赋值 * @param keyStr 以点拼接的 key,比如 foo.bar * @param target 目标对象 * @param value 目标值 * @example * ```ts * const obj = { a: { b: 1 } }; * deepSet('a.c', obj, 2); * * console.log(obj); * // { a: { b: 1, c: 2 } } * ``` */ export declare function deepSet(keyStr: string, target: Record, value: unknown): void; export declare const DEFAULT_WHITE_REG: RegExp; export declare function deleteCOSEmptyFolder({ secretId, secretKey, bucket, region, prefix, }: { secretId: string; secretKey: string; bucket: string; region: string; prefix: string; }): Promise; export declare function deleteCOSLongAgoObject({ secretId, secretKey, bucket, region, prefix, keepNumber, }: { secretId: string; secretKey: string; bucket: string; region: string; prefix: string; keepNumber?: number; }): Promise; export declare function deleteCOSMultipleObject({ secretId, secretKey, keys, bucket, region, }: { secretId: string; secretKey: string; bucket: string; region: string; keys: Array; }): Promise; /** * 删除目录及其所有内容 * 递归删除目录下的所有文件和子目录 * @param tPath - 要删除的目录路径 * @example * ```ts * deleteFolder('/path/to/folder'); * ``` */ export declare function deleteFolder(tPath: string): void; /** * 递归删除文件夹(可配置是否删除文件) * 递归遍历目录,根据配置决定是否删除文件,并删除空目录 * @param path - 要处理的目录路径 * @param options - 配置选项 * @param options.deleteFile - 是否删除文件,默认为 false * @param options.log - 是否输出日志,默认为 false * @example * ```ts * // 只删除空目录 * deleteFolderRecursive('/path/to/folder'); * * // 删除所有文件和目录 * deleteFolderRecursive('/path/to/folder', { deleteFile: true, log: true }); * ``` */ export declare function deleteFolderRecursive(path: string, options?: { deleteFile: boolean; log: boolean; }): void; /** * 删除一个项目 * @param {object} options 输入配置 * @param {string} options.id 项目id * @param {string} options.privateToken 密钥 * @returns {Promise>} 请求Promise * @example * * deleteTGitProject({ * id: '123' * privateToken: 'xxxxx', * }).then((resp) => { * * }) */ export declare function deleteTGitProject({ id, privateToken, }: { id: number | string; privateToken: string; }): Promise>; declare enum DEVICE_TYPE { PC = "PC", MOBILE_HOR = "MOBILE_HORPC", MOBILE_VERT = "MOBILE_VERT" } /** * 下载腾讯云COS对象内容 * * @param secretId - 腾讯云API密钥ID * @param secretKey - 腾讯云API密钥Key * @param bucket - COS存储桶名称 * @param region - COS存储桶所在区域 * @param key - 对象键(Object Key),对象在存储桶中的唯一标识 * @param output - 输出路径或输出流,可选参数。如果指定,对象内容将写入该路径或流 * @returns Promise对象,成功时返回对象内容数据,失败时返回错误信息 * @throws 当参数不全时会抛出错误 * @example * ```typescript * // 下载到内存 * downloadCosObject({ * secretId: 'your-secret-id', * secretKey: 'your-secret-key', * bucket: 'test-bucket', * region: 'ap-beijing', * key: 'path/to/file.txt' * }) * .then(data => console.log(data)) * .catch(err => console.error(err)); * * // 下载到文件 * downloadCosObject({ * secretId: 'your-secret-id', * secretKey: 'your-secret-key', * bucket: 'test-bucket', * region: 'ap-beijing', * key: 'path/to/file.txt', * output: './local/file.txt' * }) * .then(data => console.log('下载成功')) * .catch(err => console.error(err)); * ``` */ export declare function downloadCosObject({ secretId, secretKey, bucket, region, key, output, }: { secretId: string; secretKey: string; bucket: string; region: string; key: string; output?: string | any; }): Promise; /** * 从 Blob 对象下载文件。创建一个临时链接并触发浏览器下载 * @param blob - Blob 数据 * @param fileName - 下载的文件名 * @example * ```ts * const blob = new Blob(['Hello World'], { type: 'text/plain' }); * downloadFileFromBlob({ * blob, * fileName: 'hello.txt' * }); * ``` */ export declare function downloadFileFromBlob({ blob, fileName, }: { blob: BlobPart; fileName: string; }): void; /** * 批量下载文件为 ZIP 压缩包。将多个文件打包成 ZIP 并触发下载 * @param fileList - 文件列表,每个文件包含 content 和 name * @param zipName - ZIP 文件名 * @param saveAs - FileSaver.js 的 saveAs 函数 * @param JSZip - JSZip 库实例 * @returns Promise\ - 成功返回 true,失败返回 false * @example * ```ts * import JSZip from 'jszip'; * import { saveAs } from 'file-saver'; * * downloadFilesToZip({ * fileList: [ * { content: 'file1 content', name: 'file1.txt' }, * { content: 'file2 content', name: 'file2.txt' } * ], * zipName: 'files.zip', * saveAs, * JSZip * }).then(success => { * console.log('下载结果:', success); * }); * ``` */ export declare function downloadFilesToZip({ fileList, zipName, saveAs, JSZip, }: { fileList: Array<{ content: string; name: string; }>; zipName: string; saveAs: (...args: any[]) => any; JSZip: any; }): Promise; declare namespace drag { export { dragElement, DRAG_TYPE } } declare enum DRAG_TYPE { DOT_TO_DOT = "DOT_TO_DOT", STEPS = "STEPS" } declare function dragElement({ page, source, target, mode, reverse, stepUnit, }: { page: any; source: any; target: any; mode?: DRAG_TYPE; reverse?: boolean; stepUnit?: number; }): Promise; export declare const e2e: { autoScroll(element: HTMLAnchorElement, page: any, bottomTimes?: number): Promise; dragElement({ page, source, target, mode, reverse, stepUnit, }: { page: any; source: any; target: any; mode?: drag.DRAG_TYPE | undefined; reverse?: boolean | undefined; stepUnit?: number | undefined; }): Promise; DRAG_TYPE: typeof drag.DRAG_TYPE; waitEle(element: HTMLSelectElement, page: any, timeout?: number): Promise; clickBtn(btn: any): Promise; findAndClick(element: HTMLSelectElement, page: any, timeout?: number): Promise; justWait(time: number): Promise; closeBlankPage(browser: any): Promise; getRect(element: HTMLSelectElement, page: any): Promise; getInnerText(element: HTMLSelectElement, page: any): Promise; findListItemAndClick({ page, element, innerText, }: { page: any; element: HTMLSelectElement; innerText: string; }): Promise; getHref(page: any): Promise; initBrowser({ puppeteer, args, headless, devtools, }: { puppeteer: any; args?: string[] | undefined; headless?: boolean | undefined; devtools?: boolean | undefined; }): Promise; getNewPage(browser: any, device: page.DEVICE_TYPE): Promise; openOrFindPage(browser: any, href: string, device: page.DEVICE_TYPE): Promise; setUserAgent(useragent: string, page: any): Promise; setSessionStorage(key: string, value: string, page: any): Promise; setRoute(page: any, route?: string): Promise; DEVICE_TYPE: typeof page.DEVICE_TYPE; }; /** * 使用鼠标滚轮控制元素的scrollLeft实现左右移动 * @param {HTMLElement} element - 需要控制移动的DOM元素 * @param {Object} [options] - 配置选项 * @param {number} [options.speed=50] - 移动速度(像素/滚动单位) * @param {boolean} [options.preventDefault=true] - 是否阻止默认滚动行为 * @param {boolean} [options.invertDirection=false] - 是否反转滚动方向 */ export declare function enableHorizontalScroll(element: HTMLElement, options?: {}): (() => void) | undefined; /** * 将字符串编码为 Base64 格式 * 支持 Unicode 字符(包括中文、emoji 等),兼容小程序环境 * @param str - 要编码的字符串 * @returns Base64 编码后的字符串 * @example * ```ts * encode('Hello World'); // 'SGVsbG8gV29ybGQ=' * encode('你好世界'); // '5L2g5aW95LiW55WM' * encode('😀'); // '8J+YgA==' * ``` */ export declare const encode: (str: string) => string; /** * 将对象字符串化 * @param {object} obj 输入对象 * @returns {string} 字符串 * @example * * encodeUrlParam({a: 1}) * * // '%7B%22a%22%3A1%7D' * */ export declare function encodeUrlParam(obj: object): string; export declare function ensureDir(dir: string): void; declare const ERROR_MAP: { BRANCH_EXIST: string; SAME_CONFIG: string; }; /** * 转义审核描述中的反引号,防止在企微消息中出错 * * @example * ```ts * escapeAuditDesc('修复`bug`') // => '修复\\`bug\\`' * ``` */ export declare function escapeAuditDesc(desc: string): string; /** * 事件总线类 * 实现发布-订阅模式,用于组件间通信 * @example * ```ts * const bus = new EventBus(); * * // 订阅事件 * bus.on('message', (data) => { * console.log('收到消息:', data); * }); * * // 发布事件 * bus.emit('message', 'Hello World'); * * // 取消订阅 * bus.off('message'); * ``` */ export declare class EventBus { private events; constructor(); /** * 发布事件 * 触发指定事件的所有监听器 * @param eventName - 事件名称 * @param args - 传递给监听器的参数 */ emit(eventName: string, ...args: Array): void; /** * 订阅事件 * 添加事件监听器 * @param eventName - 事件名称 * @param fn - 监听器函数 */ on(eventName: string, fn: any): void; /** * 取消订阅 * 移除指定事件的监听器 * @param eventName - 事件名称 * @param fn - 要移除的监听器函数,如果不传则移除该事件的所有监听器 */ off(eventName: string, fn: any): void; } declare type EventOptions = string | { name: string; [k: string]: string; }; /** * excel 转 json * @param {object} params 参数 * @returns jsonData * @example * * const options = { * header: ['id', 'name', 'age'], // 可选:自定义表头 * range: 1, // 可选:跳过第一行(标题行) * defval: null, // 可选:空单元格的默认值 * raw: false, // 可选:是否保留原始数据格式 * }; * * excelToJson({ * filePath: CONFIG.xlsxPath, * sheetIndex: 1, * options, * }); * * // [ * // { id: 1, name: '2', age: '3' }, * // { id: 1, name: '2', age: '3' } * // ]; * */ export declare function excelToJson({ filePath, sheetIndex, options, }: { filePath: string; sheetIndex?: number; options?: Record; }): unknown[]; /** * 在 Node.js 中调用 child_process.execSync 执行命令 * 该方法会对输出结果进行处理,默认只返回指定行的内容(默认第一行) * @param command - 要执行的命令字符串 * @param root - 执行命令的工作目录,默认为当前工作目录 * @param options - 配置选项,可以是字符串(stdio)或对象 * @param options.stdio - 标准输入输出配置,默认为 'pipe' * @param options.line - 返回结果的行号,默认为 0(第一行),设置为 -1 返回全部内容 * @param options.throwError - 是否在命令执行失败时抛出错误,默认为 false * @returns 命令执行结果字符串 * @example * ```ts * // 获取 git 分支名(第一行) * const branch = execCommand('git branch', '/path/to/repo'); * * // 获取完整输出 * const output = execCommand('ls -la', './', { line: -1 }); * * // 自定义 stdio * const result = execCommand('npm install', './', { stdio: 'inherit' }); * ``` */ export declare function execCommand(command: string, root?: string, options?: string | { stdio?: StdioOptions; line?: number; throwError?: boolean; }): string; /** * 在目标项目中执行命令 * @param command - 要执行的命令 * @param targetProject - 目标项目路径 * @example * ```ts * execCommandInTarget('npm install', '/path/to/project'); * ``` */ export declare function execCommandInTarget(command: string, targetProject: string): void; /** * execCommand 的偏函数应用版本,固定 throwError 为 true * 当命令执行失败时会直接抛出错误,而非静默返回空字符串 * @param command - 要执行的命令字符串 * @param root - 执行命令的工作目录,默认为当前工作目录 * @param options - 配置选项,可以是字符串(stdio)或对象(不含 throwError,因为已固定为 true) * @param options.stdio - 标准输入输出配置,默认为 'pipe' * @param options.line - 返回结果的行号,默认为 0(第一行),设置为 -1 返回全部内容 * @returns 命令执行结果字符串 * @example * ```ts * // 执行失败时会抛出错误 * const branch = execCommandStrict('git branch', '/path/to/repo'); * * // 配合 try-catch 使用 * try { * const result = execCommandStrict('some-command'); * } catch (err) { * console.error('命令执行失败:', err); * } * ``` */ export declare function execCommandStrict(command: string, root?: string, options?: string | { stdio?: StdioOptions; line?: number; }): string; export declare function exportTencentDoc({ accessToken, clientId, openId, fileId, exportType, waitTime, }: ISecretInfo_2 & { fileId: string; exportType: number; waitTime?: number; }): Promise; /** * 将属性混合到目标对象中 * @param {object} to 目标对象 * @param {object} from 原始对象 * @returns 处理后的对象 * * @example * const a = { name: 'lee' } * const b = { age: 3 } * extend(a, b) * * console.log(a) * * // => { name: 'lee', age: 3 } */ export declare function extend(to: Record, from: Record): object; /** * 拼接额外参数 * @param {string} url 地址 * @param {string} removeKeyArr 待添加的参数对象 * @returns 重新拼接的地址 * @example * const url1 = extendUrlParams('http://www.test.com?a=1&b=2&c=3#/detail?d=4', { e: 5 }); // 'http://www.test.com/#/detail?a=1&b=2&c=3&d=4&e=5' */ export declare function extendUrlParams(url?: string, extParamsObj?: {}, forceHistoryMode?: boolean): string; /** * 提取 Vue 组件的 class * @param {obj} params 参数 * @param {string} params.filePath 源文件地址 * @param {string} [params.targetFilePath] 输出文件地址 * @param {Regexp} [params.extractRegexp] 提取正则 * * ```ts * extractClass({ * filePath: 'xxx.vue', * }) * ``` */ export declare function extractClass({ filePath, targetFilePath, extractRegexp, }: { filePath: string; targetFilePath?: string; extractRegexp?: RegExp; }): void; /** * 提取 Vue 组件的 event * @param {obj} params 参数 * @param {string} params.filePath 源文件地址 * @param {string} [params.targetFilePath] 输出文件地址 * @param {Regexp} [params.extractRegexp] 提取正则 * * ```ts * extractEvent({ * filePath: 'xxx.vue', * }) * ``` */ export declare function extractEvent({ filePath, targetFilePath, extractRegexp, }: { filePath: string; targetFilePath?: string; extractRegexp?: RegExp; }): void; /** * 提取 Vue 组件的 props * @param {obj} params 参数 * @param {string} params.filePath 源文件地址 * @param {string} [params.targetFilePath] 输出文件地址 * @param {Regexp} [params.extractRegexp] 提取正则 * * ```ts * extractProps({ * filePath: 'xxx.vue', * }) * ``` */ export declare function extractProps({ filePath, targetFilePath, extractRegexp, }: { filePath: string; targetFilePath?: string; extractRegexp?: RegExp; }): void; declare type Fail = (err?: any) => void; export declare function fetchAllProjectsInGroup({ groupName, privateToken, baseUrl, includeSubgroups, }: { groupName: string; privateToken: string; baseUrl?: string; includeSubgroups?: boolean; }): Promise; export declare function fetchLatestOneRainbowData({ secretInfo, appName, key, valueType, fetchRainbowConfigOptions, }: { secretInfo: ISecretInfo_3; appName: string; key: string; valueType?: RainbowKeyValueType; fetchRainbowConfigOptions?: FetchRainbowConfigOptions; }): Promise<{ config: Array; originConfig: ILocalConfig; equal: boolean; }>; export declare function fetchLatestRainbowData({ secretInfo, appName, }: { secretInfo: ISecretInfo_3; appName: string; }): Promise<{ config: Array; originConfig: ILocalConfig; equal: boolean; }>; /** * 拉取七彩石配置 * @param {String} key 七彩石的key * @param {object} secretInfo 密钥信息 * @param {string} secretInfo.appId 项目Id * @param {string} secretInfo.envName 环境 * @param {string} secretInfo.groupName 组名称 * @returns {Promise} 请求Promise * * @example * * fetchRainbowConfig('test', { * appId: 'xx', * envName: 'prod', * groupName: 'robot', * }).then((resp) => { * console.log(resp) * }); * */ export declare function fetchRainbowConfig(key: string, secretInfo: Partial, options?: FetchRainbowConfigOptions): Promise; export declare function fetchRainbowConfigFromSdk({ secretInfo, sdk, initOptions, key, isFetchGroup, tryJsonParse, rainbow, }: { secretInfo: ISecretInfo_3; sdk: any; key: string; initOptions?: Record; isFetchGroup?: boolean; tryJsonParse?: boolean; rainbow?: any; }): Promise; declare interface FetchRainbowConfigOptions { sdk: any; initOptions?: Record; isFetchGroup?: boolean; tryJsonParse?: boolean; } /** * 发起 SSE 请求的核心函数,根据环境自动选择 H5 或 MP 实现 * @param {RequestParams} params - 请求参数 * @param {string} params.url - 请求地址 * @param {Object} params.data - 请求数据 * @param {Function} params.success - 成功回调 * @param {Function} params.fail - 失败回调 * @param {Function} params.complete - 完成回调 * @returns {Promise} 返回一个 Promise,包含请求任务或响应对象 * @example * ```ts * import { safeJsonParse } from 't-comm/es/json'; * * import { fetchSSECore, type RequestParams } from 't-comm/es/sse'; * * // 检查是否结束,业务自定义 * function checkFinish(str) { * const data: any = safeJsonParse(str); * return data?.status === 3; * } * * // 业务二次封装,把自己的请求数据、自定义的处理数据的逻辑放进去 * export function sendChatMessage({ * input, * sessionId, * extraInfo, * expectedOp, * * success, * fail, * complete, * }: { * input: string; * sessionId?: string; * extraInfo?: string; * expectedOp?: Record; * * success?: (data: any) => void; * fail?: RequestParams['fail']; * complete?: RequestParams['complete']; * }) { * const origin = isTestEnv() ? 'https://xx.com' : 'https://xx.com'; * const url = `${origin}/xx.xx.xx.xx/xx?g_app_tk=${cookie.get('tip_token')}&tstamp=${Date.now()}`; * const reqData = { * input, * session_id: sessionId, * extra_info: extraInfo, * expected_op: expectedOp, * }; * * const parsedSuccess = (str, fullStr) => { * const data: any = safeJsonParse(str); * const fullData: any = safeJsonParse(fullStr); * * if (checkFinish(str)) { * complete?.(str); * return; * } * * // 检查是否失败,业务自定义 * if (fullData?.err_msg) { * fail?.(data); * return; * } * * success?.(data); * }; * * return fetchSSECore({ * url, * data: reqData, * success: parsedSuccess, * fail, * complete, * isTestEnv, * }); * } * * ``` */ export declare function fetchSSECore({ url, data, success, fail, complete, isTestEnv, }: RequestParams): Promise; /** * 在 H5 环境下发起 SSE 请求的核心函数 * @param {Object} params - 参数对象 * @param {string} params.url - 请求 URL * @param {any} params.data - 请求数据 * @param {Function} params.success - 成功回调函数 * @param {Function} params.fail - 失败回调函数 * @param {Function} params.complete - 完成回调函数 * @returns {Promise} 返回一个 Promise,包含响应对象 */ export declare function fetchSSECoreInH5({ url, data, success, fail, complete, }: Pick): Promise; /** * 在 MP 环境下发起 SSE 请求的核心函数 * @param {RequestParams} params - 请求参数 * @returns {Promise} 返回一个 Promise,包含请求任务对象 */ export declare function fetchSSECoreInMP({ url, data, success, fail, complete, isTestEnv, }: RequestParams): Promise; /** * 获取天气信息 * @returns {Promise} 天气数据 * @example * * fetchWeatherData().then(content => { * console.log(content) * }) */ export declare function fetchWeatherData>(): Promise; export declare type FileMap = { [k: string]: { reg: RegExp; lintKeyword: string; outputFileName: string; outputFile?: string; isStyle?: boolean; isVue?: boolean; total?: number; errorFiles?: JSErrorFile[]; }; }; export declare function filterCommit(commits?: Array): CommitInfo[]; export declare interface FilterParams { url: string; limit: number; keepKey: string[]; forceHistoryMode?: boolean | undefined; } /** * 根据地址长度,进行过滤地址参数,允许指定保留特定参数 * @param {object} [params={ limit: 1024 }] 参数 * @param {number} params.url 待过滤地址,默认当前页面地址 * @param {number} params.limit 参数长度限制 * @param {array} params.keepKey 指定保留的参数,比如业务参数、框架参数(登录态、统计上报等) */ export declare function filterUrlParams(params?: FilterParams): string; export declare function findCurrentStage(list: Array, now: number): T | Partial; /** * 根据路由表,找到 path 对应的 路由名称 * @param {string} path 路由路径 * @param {array} routes 路由表 * @returns {object} 匹配到的路由信息 * * @example * ```ts * const { name, params, meta, path } = findRouteName(rawPath, ALL_ROUTES) || {}; * * console.log('name', name); * ``` */ export declare function findRouteName(path: string, routes: Array): { name: string | undefined; params: { [x: string]: any; }; path: string | undefined; meta: IMeta; } | undefined; /** * 递归拉平数组 * @param list 数组 * @returns 数组 * * @example * * flat([[[1, 2, 3], 4], 5]) * * // [1, 2, 3, 4, 5] */ export declare function flat(list: readonly T[]): T[]; /** * 拉平数组,不会递归处理 * @param {Array} list - 对象数组 * @param {string} key - 对象的key * @returns {object} 拉平后的对象 * * @example * * const list = [{id: 1, name: 'a'}, {id: 2, name: 'b'}] * * flatten(list, 'id') * * // {1: {id: 1, name: 'a'}, 2: {id: 2, name: 'b'}} * */ export declare function flatten, K extends keyof T>(list: T[], key: K): Record; /** * 拉平之前数据 * @param {Array} preDataList 之前的数据,作为对照 * @param {string} key 主键 * @returns {Object} preDataMap * * @example * const data = [{ * ProjectName: { name: 'ProjectName', value: '研发平台' }, * PagePv: { name: 'PagePv', value: 152 }, * PageUv: { name: 'PageUv', value: 7 }, * Score: { name: 'Score', value: 93.92 }, * PageDuration: { name: 'PageDuration', value: 1281.58 }, * PageError: { name: 'PageError', value: 2 }, * }]; * * flattenPreData(data, 'ProjectName'); * * // 输出 * { * 研发平台: { * ProjectName: '研发平台', * PagePv: 152, * PageUv: 7, * Score: 93.92, * PageDuration: 1281.58, * PageError: 2, * }, * }; */ export declare function flattenPreData(preDataList: Array, key: string): { [valueOfPrimaryKey: string]: { [key: string]: ValueType; }; }; export declare function flattenSubPackages(result: IUploadResult): Record; export declare function flattenUsingComponentMap(rawMap: Record): ComponentMapList; /** * 格式化 bite 单位,最多保留2位小数,最大单位为BB * @param number size bite 单位 * @returns 格式化的字符 * @example * * formatBite(1) * // 1B * * formatBite(100) * // 100B * * formatBite(1000) * // 1000B * * formatBite(10000) * // 9.77KB * * formatBite(100000) * // 97.66KB * * formatBite(1000000) * // 976.56KB * * formatBite(10000000) * // 9.54MB */ export declare function formatBite(size: number): string; /** * 根据传入的参数,移除原来的所有参数,根据传入的 keepParamsObj 进行重新拼接地址,以 hash 模式返回 * @param {string} url 地址 * @param {object} keepParamsObj 参数对象 * @returns 只有传入参数的地址 * @example * const url1 = formatUrlParams('http://www.test.com?a=1&b=2&c=3', { e: 5 }); // http://www.test.com/#/?e=5 * const url2 = formatUrlParams('http://www.test.com?a=1&b=2&c=3#/detail?d=4', { f: 5 }); // http://www.test.com/#/detail?f=5 */ export declare function formatUrlParams(url?: string, keepParamsObj?: Record, forceHistoryMode?: boolean): string; /** * 获取自定义事件图片并发送 * @param {object} options 配置信息 * @returns {string} 图片url * @example * * const requestMultiImgDate = Date.now() - 1 * 24 * 60 * 60 * 1000; * * const tamGroupIdList = [1, 2, 3]; * * const eventProjectMap = { * 62659: { * name: 'aaaaa', * }, * 57706: { * name: 'bbbbb', * extraProjectId: 66379, * }, * }; * * const eventMap = { * WX_SUC: { * // 总和 * type: 'SUMMARY', * target: ['ENTER_GAME_WX_SUC', 'LAUNCH_GAME_SUC_WX'], * }, * WX_FAIL: { * // 总和 * type: 'SUMMARY', * target: ['ENTER_GAME_WX_FAIL', 'LAUNCH_GAME_FAIL_WX'], * }, * }; * * const eventTableHeaderMap = { * ProjectName: { * name: '项目名称', * tableWidth: 95, * }, * ALL_SUMMARY: { * name: '拉起总数', * tableWidth: 65, * }, * }; * * genCustomEventImgAndSendRobot({ * date: requestLaunchGameDate, * secretInfo: { * getPwdCode, * encrypt, * apiKey: process.env.AEGIS_APP_KEY, * loginName: 'lee', * }, * projectIdMap: eventProjectMap, * eventMap, * tableHeaderMap: eventTableHeaderMap, * webhookUrl: tamRobotWebhook, * chatId: tamRobotChatId, * }); * */ export declare function genCustomEventImgAndSendRobot({ date, projectIdMap, env, secretInfo, eventMap, tableHeaderMap, webhookUrl, chatId, }: { date: number; projectIdMap: Array; env: string; secretInfo: SecretInfoType; eventMap: {}; tableHeaderMap: {}; webhookUrl: string; chatId: string; }): Promise; /** * 生成 CSV 文件内容,可以用于 fs.writeFileSync 输出 * * 第一行为表头 * @param {Array>} dataList 二维数据列表 * @returns 生成的字符串 * @example * * ```ts * generateCSV([['a','b'], ['1', '2']]); * ``` */ export declare function generateCSV(dataList: Array>): string; /** * 生成 CSV 所需数据,可用于传递给 generateCSV 方法 * * @param {Array>} list 数据列表 * @param {Record} headMap 数据项的 key 和表头标题的映射关系 * @returns 二维数组,第一行是表头 * * @example * ```ts * generateCSVData([ * { * file: 'a.js', * size: 88, * }, * { * file: 'b.js', * size: 66, * } * ], { file: '文件名称', size: '文件大小' }) * * * // [['文件名称', '文件大小'], ['a.js', 88], ['b.js', 66]] * ``` */ export declare function generateCSVData(list: Array>, headMap: Record): any[][]; export declare function genIterativeComponentMap(usingComponentsMap: IterativeComponentMap): void; /** * 生成多个图片并发送机器人 * @param {object} options 配置 * * @example * * const requestMultiImgDate = Date.now() - 1 * 24 * 60 * 60 * 1000; * * const tamGroupIdList = [1, 2, 3]; * * const summaryScoreTableHeaderMap = { * ProjectName: { * name: '项目名称', * tableWidth: 95, * }, * PagePv: { * name: 'PV', * tableWidth: 65, * }, * }; * * const eventProjectMap = { * 62659: { * name: 'aaaaa', * }, * 57706: { * name: 'bbbbb', * extraProjectId: 66379, * }, * }; * * const eventMap = { * WX_SUC: { * // 总和 * type: 'SUMMARY', * target: ['ENTER_GAME_WX_SUC', 'LAUNCH_GAME_SUC_WX'], * }, * WX_FAIL: { * // 总和 * type: 'SUMMARY', * target: ['ENTER_GAME_WX_FAIL', 'LAUNCH_GAME_FAIL_WX'], * }, * }; * * const eventTableHeaderMap = { * ProjectName: { * name: '项目名称', * tableWidth: 95, * }, * ALL_SUMMARY: { * name: '拉起总数', * tableWidth: 65, * }, * }; * * await genMultiImgAndSendRobot({ * date: requestMultiImgDate, * secretInfo: { * getPwdCode, * encrypt, * apiKey: process.env.AEGIS_APP_KEY, * loginName: 'lee', * }, * webhookUrl: tamRobotWebhook, * chatId: tamRobotChatId, * * groupIdList: tamGroupIdList, * eventProjectIdMap: eventProjectMap, * tableHeaderMap: summaryScoreTableHeaderMap, * * eventMap, * eventTableHeaderMap, * }); * * */ export declare function genMultiImgAndSendRobot({ date, groupIdList, secretInfo, extraDataMap, ignoreProjectIdList, tableHeaderMap, webhookUrl, chatId, env, eventMap, eventProjectIdMap, eventTableHeaderMap, }: { date: number; groupIdList: Array; secretInfo: SecretInfoType; extraDataMap?: Record; ignoreProjectIdList?: Array; tableHeaderMap?: Record; webhookUrl: string; chatId: string; env?: string; eventMap: Record; eventProjectIdMap: Record; eventTableHeaderMap: Record; }): Promise<{ data: ScoreInfoType[]; projectIdList: number[]; } | undefined>; export declare function genQueryToStr(query?: Record): string; /** * 请求签名Header生成 * @private * @param {object} signInfo 密钥信息 */ export declare function genRainbowHeaderSignature(signInfo: { appID?: string; appId?: string; userID?: string; userId?: string; secretKey: string; signMethod?: ISignMethod; }): { rainbow_sgn_type?: undefined; rainbow_version?: undefined; rainbow_app_id?: undefined; rainbow_user_id?: undefined; rainbow_timestamp?: undefined; rainbow_nonce?: undefined; rainbow_sgn_method?: undefined; rainbow_sgn_body?: undefined; rainbow_signature?: undefined; } | { rainbow_sgn_type: string; rainbow_version: string; rainbow_app_id: string | undefined; rainbow_user_id: string | undefined; rainbow_timestamp: string; rainbow_nonce: string; rainbow_sgn_method: ISignMethod; rainbow_sgn_body: string; rainbow_signature: any; }; export declare function genRobotMessage(list: Array>, separator?: string, labelSeparator?: string): string; export declare function genRUMPerfImgAndSend({ secretId, secretKey, id, startTime, endTime, type, title, chatId, webhookUrl, }: { secretId: string; secretKey: string; id: string | number; startTime: number; endTime: number; type?: string; title?: string; chatId: string; webhookUrl: string; }): Promise; /** * 获取jsAPI签名 * * 校验地址:https://mp.weixin.qq.com/debug/cgi-bin/sandbox?t=jsapisign * * 文档地址:https://developers.weixin.qq.com/doc/offiaccount/OA_Web_Apps/JS-SDK.html * @param {string} ticket 票据 * @param {string} url 当前url,不包括#之后的部分 * @returns signature */ export declare function genSignature(ticket: string, url: string): { timestamp: number; nonceStr: string; signature: string; url: string; }; /** * 生成TAM汇总数据并发送到机器人 * @param {object} options 配置 * @param {string} options.date 日期,yyyyMMdd格式 * @param {Array} options.groupIdList groupId列表 * * @param {object} options.secretInfo 密钥信息 * @param {string} options.secretInfo.apiKey apiKey * @param {string} options.secretInfo.loginName loginName * @param {Function} options.secretInfo.getPwdCode getPwdCode * @param {Function} options.secretInfo.encrypt encrypt * * @param {object} options.extraDataMap 额外数据Map * @param {object} options.ignoreProjectIdList 忽略的projectIdList * @param {object} options.tableHeaderMap 表格头部Map * * @param {object} options.webhookUrl 机器人回调地址 * @param {object} options.chatId 会话Id * * @example * const requestSummaryScoreDate = Date.now() - 1 * 24 * 60 * 60 * 1000; * * const tamGroupIdList = [1, 2, 3]; * * const summaryScoreTableHeaderMap = { * ProjectName: { * name: '项目名称', * tableWidth: 95, * }, * PagePv: { * name: 'PV', * tableWidth: 65, * }, * }; * * await genSummaryDataAndSendRobot({ * date: requestSummaryScoreDate, * groupIdList: tamGroupIdList, * secretInfo: { * getPwdCode, * encrypt, * apiKey: process.env.AEGIS_APP_KEY, * loginName: 'lee', * }, * webhookUrl: tamRobotWebhook, * chatId: tamRobotChatId, * tableHeaderMap: summaryScoreTableHeaderMap, * }); */ export declare function genSummaryDataAndSendRobot({ date, groupIdList, secretInfo, extraDataMap, ignoreProjectIdList, tableHeaderMap, webhookUrl, chatId, rumSecretList, }: { date: number; groupIdList: Array; secretInfo: SecretInfoType; extraDataMap?: {}; ignoreProjectIdList?: Array; tableHeaderMap?: {}; webhookUrl: string; chatId: string; rumSecretList?: Array; }): Promise<{ data: ScoreInfoType[]; projectIdList: number[]; } | undefined>; /** * 生成 v-console * 有几种情况: * 1. 不显示 * 2. 立即显示 * 3. 异步判断后,确定是否显示 * @param params 参数 * @example * * ```ts * genVConsole({ * immediateShow: isShowVConsole === 'true' * || isTestEnv() * || noDelay === V_CONSOLE_NO_DELAY.VALUE, * hide: isShowVConsole === 'false' || !!UserInfo.tipUid(), * asyncConfirmFunc: checkIsDevList, * }); * ``` */ export declare function genVConsole({ immediateShow, hide, vConsoleConfig, asyncConfirmFunc, }: { immediateShow?: boolean; hide?: boolean; vConsoleConfig?: Record; asyncConfirmFunc?: Function; }): void; /** * 自动生成version,核心是利用 standard-version 命令 * @param {object} config 配置信息 * @param {string} config.root 项目根路径 * @returns {boolean} 是否执行了 standard-version * @example * * genVersion({ * root: process.cwd() * }) * */ export declare function genVersion({ root, forceGenVersion, }: { root: string; forceGenVersion?: boolean; }): boolean; /** * 运行standard-version,并且发送changelog到机器人 * @param {object} options 配置 * @param {object} config.appInfo package.json信息 * @param {string} config.root 项目根路径 * @param {string} config.changeLogFilePath changelog文件地址 * @param {string} config.webhookUrl 机器人hook地址 * @param {string} config.chatId 会话id */ export declare function genVersionAndSendChangeLog({ root, changeLogFilePath, webhookUrl, chatId, forceGenVersion, pushRemote, }: { root?: string; changeLogFilePath?: string; webhookUrl: string; chatId?: string; forceGenVersion?: boolean; pushRemote?: boolean; }): Promise; /** * 生成版本信息,可以用来发送到群聊中 * @param {object} config 配置信息 * @param {string} config.readmeFilePath changelog文件地址 * @param {object} config.appInfo package.json信息 * @returns {string} 版本信息 * @example * * const appInfo = require(`${rootPath}/package.json`); * const readmeFilePath = `${rootPath}/CHANGELOG.md`; * * const content = genVersionTip({ * readmeFilePath, * appInfo, * }); */ export declare function genVersionTip({ readmeFilePath, appInfo, showNpmLink, publisher, }: { showNpmLink?: boolean; readmeFilePath: string; appInfo: IAppInfo; publisher?: string; }): string; export declare function get(source: Record, path: string, defaultValue?: any): any; /** * 获取累积宽度 * @param {Array} cellWidthList - 宽度列表 * @param {number} idx - 当前idx * @returns {number} 累计宽度 * * @example * * getAccCellWidth([20, 10, 20, 10], 1) * * // 30 */ export declare function getAccCellWidth(cellWidthList: Array, idx: number): number; export declare function getAccessToken({ appId, appSecret, }: { appId: string; appSecret: string; }): Promise; export declare function getAllDevopsTemplateInstances(reqParam: ITemplateReq & { page?: number | undefined; pageSize?: number | undefined; }): Promise; /** * 递归获取目录下所有匹配扩展名的文件 */ export declare function getAllFiles(dirPath: string, extensions?: Array, fileList?: Array): Array; /** * 获取所有 git 仓库 * * @export * @param {string} root 根路径 * @returns {array} 路径列表 * @example * ```ts * getAllGitRepo('/root/yang'); * * [ * { * root: '/root', * origin: 'git@git.address', * } * ] * ``` */ export declare function getAllGitRepo(root: string): { root: string; origin: string; }[]; /** * 获取全部流水线列表 * @param {object} params 配置信息 * @param {string} params.projectId 项目ID * @param {object} params.secretInfo 密钥信息 * @param {string} params.host 请求域名 * @param {number} params.page 第几页 * @param {number} params.pageSize 每页数据量 * @param {Array} list 结果列表,可不传,用于迭代 * @returns 流水线列表 */ export declare function getAllPipelineList(args: Parameters[0], list?: Array): Promise; /** * 获取某个token名下所有项目 * @param {string} privateToken 密钥 * @param {string} search 搜索内容 * @returns {Array} 项目列表 * @example * * const projects = await getAllProjects('xxxxx'); * * console.log(projects) */ export declare function getAllProjects(privateToken: string, search?: string): Promise>; export declare function getAPITicket(accessToken: string): Promise; /** * 根据省份城市转化为`id`数组 * @param {string} provinceStr * @param {string} cityStr * @returns {Array} 包含省份、城市ID的数组 * * @example * const res = getAreaCode('山东', '德州'); * // ['37', '14'] */ export declare function getAreaCode(provinceStr?: string, cityStr?: string): any; /** * 获取城市列表,默认不包含`全省`选项 * @param {object} [data] 原始数据 * @param {array} [areaArray = []] 结果列表 * @param {boolean} [allProvFlag = false] 是否包含`全省`选项 * @returns {Array} 城市列表 * @example * * const res = getAreaData(); * // [ * // { * // text: '北京', * // code: '11', * // children: [{ * // text: '北京', * // code: '0', * // }], * // }, * // { * // text: '天津', * // code: '12', * // children: [{ * // text: '天津', * // code: '0', * // }], * // }, * // { * // text: '河北', * // code: '13', * // { * // text: '石家庄', * // code: '1', * // }, * // { * // text: '唐山', * // code: '2', * // }, * // // ... * // ], * // }, * // // ... * // ]; * */ export declare function getAreaData(data?: { provData: { 11: string; 12: string; 13: string; 14: string; 15: string; 21: string; /** * 获取如下格式的城市列表,包含`全国`、`全省`选项 * @returns {Array} 城市列表 * @example * * const res = getAreaDataAll(); * // [ * // { * // text: '全国', * // code: '0', * // children: [{ * // text: '不限', * // code: '0', * // }], * // }, * // { * // text: '北京', * // code: '11', * // children: [{ * // text: '北京', * // code: '0', * // }], * // }, * // { * // text: '天津', * // code: '12', * // children: [{ * // text: '天津', * // code: '0', * // }], * // }, * // { * // text: '河北', * // code: '13', * // children: [{ * // text: '全省', * // code: '0', * // }, * // { * // text: '石家庄', * // code: '1', * // }, * // { * // text: '唐山', * // code: '2', * // }, * // // ... * // ], * // }, * // // ... * // ]; * */ 22: string; 23: string; 31: string; 32: string; 33: string; 34: string; 35: string; 36: string; 37: string; 41: string; 42: string; 43: string; 44: string; 45: string; 46: string; 50: string; 51: string; 52: string; 53: string; 54: string; 61: string; 62: string; 63: string; 64: string; 65: string; 71: string; 81: string; 82: string; }; cityData: { 11: string[]; 12: string[]; 13: { 1: string; 2: string; 3: string; 4: string; 5: string; 6: string; 7: string; 8: string; 9: string; 10: string; 11: string; }; 14: { 1: string; 2: string; 3: string; 4: string; 5: string; 6: string; 7: string; 8: string; 9: string; 10: string; 11: string; 12: string; }; 15: { 1: string; 2: string; 3: string; 4: string; 5: string; 6: string; 7: string; 8: string; 9: string; 22: string; 25: string; 29: string; 30: string; }; 21: { 1: string; 2: string; 3: string; 4: string; 5: string; 6: string; 7: string; 8: string; 9: string; 10: string; 11: string; 12: string; 13: string; 14: string; }; 22: { 1: string; 2: string; 3: string; 4: string; 5: string; 6: string; 7: string; 8: string; 24: string; 25: string; }; 23: { 1: string; 2: string; 3: string; 4: string; 5: string; 6: string; 7: string; 8: string; 9: string; 10: string; 11: string; 12: string; 27: string; }; 31: string[]; 32: { 1: string; 2: string; 3: string; 4: string; 5: string; 6: string; 7: string; 8: string; 9: string; 10: string; 11: string; 12: string; 13: string; }; 33: { 1: string; 2: string; 3: string; 4: string; 5: string; 6: string; 7: string; 8: string; 9: string; 10: string; 11: string; }; 34: { 1: string; 2: string; 3: string; 4: string; 5: string; 6: string; 7: string; 8: string; 10: string; 11: string; 12: string; 13: string; 14: string; 15: string; 16: string; 17: string; 18: string; }; 35: { 1: string; 2: string; 3: string; 4: string; 5: string; 6: string; 7: string; 8: string; 9: string; }; 36: { 1: string; 2: string; 3: string; 4: string; 5: string; 6: string; 7: string; 8: string; 9: string; 10: string; 11: string; }; 37: { 1: string; 2: string; 3: string; 4: string; 5: string; 6: string; 7: string; 8: string; 9: string; 10: string; 11: string; 12: string; 13: string; 14: string; 15: string; 16: string; 17: string; }; 41: { 1: string; 2: string; 3: string; 4: string; 5: string; 6: string; 7: string; 8: string; 9: string; 10: string; 11: string; 12: string; 13: string; 14: string; 15: string; 16: string; 17: string; 18: string; 19: string; }; 42: { 1: string; 2: string; 3: string; 5: string; /** * 根据省份城市转化为`id`数组 * @param {string} provinceStr * @param {string} cityStr * @returns {Array} 包含省份、城市ID的数组 * * @example * const res = getAreaCode('山东', '德州'); * // ['37', '14'] */ 6: string; 7: string; 8: string; 9: string; 10: string; 11: string; 12: string; 13: string; 28: string; 94: string; 95: string; 96: string; A21: string; }; 43: { 1: string; 2: string; 3: string; 4: string; 5: string; 6: string; 7: string; 8: string; 9: string; 10: string; 11: string; 12: string; 13: string; 31: string; }; 44: { 1: string; 2: string; 3: string; 4: string; 5: string; 6: string; 7: string; 8: string; 9: string; 12: string; 13: string; 14: string; 15: string; 16: string; 17: string; 18: string; 19: string; 20: string; 51: string; 52: string; 53: string; }; 45: { 1: string; 2: string; 3: string; 4: string; 5: string; 6: string; 7: string; 8: string; 9: string; 10: string; 11: string; 12: string; 13: string; 14: string; }; 46: { 1: string; 2: string; 91: string; 92: string; 93: string; 95: string; 96: string; 97: string; A25: string; A26: string; A27: string; A28: string; A30: string; A31: string; A33: string; A34: string; A35: string; A36: string; A37: string; A38: string; A39: string; }; 50: string[]; 51: { 1: string; 3: string; 4: string; 5: string; 6: string; 7: string; 8: string; 9: string; 10: string; 11: string; 13: string; 14: string; 15: string; 16: string; 17: string; 18: string; 19: string; 20: string; 32: string; 33: string; 34: string; }; 52: { 1: string; 2: string; 3: string; 4: string; 22: string; /** * 根据`id`获取省份名字 * @param {string | number} provinceId * @returns {string} 省份名字 * * @example * const res = getProvName(37) * // 山东 * * const res2 = getCityName(11) * // 北京 */ 23: string; 24: string; 26: string; 27: string; 31: string; 32: string; 33: string; 34: string; 35: string; 36: string; 37: string; }; 53: { 1: string; 3: string; 4: string; 5: string; 6: string; 7: string; 8: string; 9: string; 23: string; 25: string; 26: string; 28: string; 29: string; 31: string; 33: string; 34: string; }; 54: { 1: string; 21: string; 22: string; 23: string; 24: string; 25: string; 26: string; }; 61: { 1: string; 2: string; 3: string; 4: string; 5: string; 6: string; 7: string; 8: string; 9: string; 10: string; }; 62: { 1: string; 2: string; 3: string; 4: string; 5: string; 6: string; 7: string; 8: string; 9: string; 10: string; 11: string; 12: string; 29: string; 30: string; }; 63: { 1: string; 21: string; 22: string; 23: string; 25: string; 26: string; 27: string; 28: string; }; 64: { 1: string; 2: string; 3: string; 4: string; 5: string; }; 65: { 1: string; 2: string; 21: string; 22: string; 23: string; 27: string; 28: string; 29: string; 30: string; 31: string; 32: string; 40: string; 42: string; 43: string; 91: string; 92: string; 93: string; 94: string; }; 71: string[]; 81: string[]; 82: string[]; }; }, areaArray?: Array, allProvFlag?: boolean): ProvType[]; /** * 获取如下格式的城市列表,包含`全国`、`全省`选项 * @returns {Array} 城市列表 * @example * * const res = getAreaDataAll(); * // [ * // { * // text: '全国', * // code: '0', * // children: [{ * // text: '不限', * // code: '0', * // }], * // }, * // { * // text: '北京', * // code: '11', * // children: [{ * // text: '北京', * // code: '0', * // }], * // }, * // { * // text: '天津', * // code: '12', * // children: [{ * // text: '天津', * // code: '0', * // }], * // }, * // { * // text: '河北', * // code: '13', * // children: [{ * // text: '全省', * // code: '0', * // }, * // { * // text: '石家庄', * // code: '1', * // }, * // { * // text: '唐山', * // code: '2', * // }, * // // ... * // ], * // }, * // // ... * // ]; * */ export declare function getAreaDataAll(): ProvType[]; /** * 根据`id`将省份城市转化为字符串数组 * @param {string | number} provinceId * @param {string | number} cityId * @returns {Array} 包含省份、城市名字的数组 * * @example * const res = getProvName(37, 14) * // ['山东', '德州'] * * const res2 = getCityName(11) * // ['北京', '北京'] */ export declare function getAreaName(provinceId: string | number, cityId?: number): string[]; /** * 统一审核人获取方法,支持 rainbow / json / static 三种模式 * * @example rainbow 模式 - 文件路径 * ```ts * const { auditor, shouldAudit } = await getAuditor({ * type: 'rainbow', * configSource: '/data/h5_publish_auditor.json', * rainbowOptions: { projectName: 'pmd-mobile/match/gp', subProjectName: 'gp-hor', minimatch }, * }); * ``` * * @example rainbow 模式 - 异步获取数据 * ```ts * const { auditor, shouldAudit } = await getAuditor({ * type: 'rainbow', * configSource: async () => fetchRainbowConfig(), * rainbowOptions: { projectName: 'pmd-mobile/match/gp', subProjectName: 'gp-hor', minimatch }, * }); * ``` * * @example json 模式(NPM/组件库发布) * ```ts * const { auditor, shouldAudit } = await getAuditor({ * type: 'json', * configSource: '/data/library_publish_auditor.json', * jsonOptions: { projectName: 'my-lib', key: 'patch' }, * }); * ``` * * @example static 模式(灰度发布 / 回滚) * ```ts * const { auditor, shouldAudit } = await getAuditor({ * type: 'static', * staticAuditorList: ['novlan1', 'lee'], * }); * ``` * * @example 跳过审核(如非生产环境) * ```ts * const { auditor, shouldAudit } = await getAuditor({ * type: 'static', * skipAudit: !isProd, * }); * ``` */ export declare function getAuditor(options: IGetAuditorOptions): Promise; /** * 获取审核人 * @param params 参数 * @returns 审核人 * * @example * ```ts * getAuditorFromRainbowConfig({ * rainbowConfig: { "pmd-mobile/match/*": "gg", "pmd-mobile/convert-cross": "gg" }, * checkKeyList: [ 'pmd-mobile/match/gp/gp-hor', 'pmd-mobile/match/gp' ], * minimatch: require('minimatch'), * minimatchKey: 'pmd-mobile/match/gp', * }) * ``` */ export declare function getAuditorFromRainbowConfig({ rainbowConfig, checkKeyList, minimatch, minimatchKey, }: { rainbowConfig: Record; checkKeyList: string[]; minimatch: Function; minimatchKey: string; }): string; export declare function getAuthOfTai({ paasToken, paasId, }: { paasToken: string; paasId: string; }): { 'Cache-Control': string; 'Content-Type': string; 'x-rio-nonce': string; 'x-rio-signature': string; 'x-rio-timestamp': string; 'x-rio-paasid': string; }; export declare function getAutoProtectedBranchRules({ projectName, baseUrl, privateToken, }: { projectName: string; baseUrl: string; privateToken: string; }): Promise; export declare function getAvailableDiskSize(options?: { mockLog: string; }): number; /** * 获取图片,并转 base64 * * @param url 图片链接 * @returns 获取结果 * @example * ```ts * getBase64FromUrl(imgUrl).then(consoleImage); * ``` */ export declare function getBase64FromUrl(url: string): Promise; /** * 获取仓库的分支列表 * @param {object} options 输入配置 * @param {string} options.projectName 项目名称 * @param {string} options.privateToken 密钥 * @param {string} options.baseUrl baseUrl * @returns {Promise>} 请求Promise * @example * * getBranchesByProjectName({ * projectName: 't-comm', * privateToken: 'xxxxx', * }).then((resp) => { * * }) */ export declare function getBranchesByProjectName({ projectName, privateToken, baseUrl }: { projectName: string; privateToken: string; baseUrl: string; }): Promise>; /** * 获取tGit上某分支生命周期 * @param {object} options 输入配置 * @param {string} options.projectName 项目名称 * @param {string} options.branchName 分支名称 * @param {string} options.privateToken 密钥 * @returns {Promise} 请求Promise * @example * * getBranchLifeCycle({ * projectName: 't-comm', * branchName: 'master', * privateToken: 'xxxxx', * }).then((resp) => { * * }) */ export declare function getBranchLifeCycle({ projectName, branchName, privateToken }: { projectName: string; branchName: string; privateToken: string; }): Promise; export declare function getBundleBuildDesc({ root, env, branch, author, message, }: { root: string; env?: string; branch?: string; author?: string; message?: string; }): string; export declare function getBundleVersion(root: string): any; /** * 获取 canvas 库 * canvas 是一个用于在 Node.js 中使用 Canvas API 的第三方库 * @returns canvas 库 */ export declare function getCanvas(): any; /** * 获取 cdn 链接 * @param {string} url 图片地址 * @returns 新的地址 */ export declare function getCdnUrl(inUrl?: string): string; /** * 获取 chalk 库 * chalk 是一个用于在终端输出彩色文本的第三方库 * @returns chalk 库 */ export declare function getChalk(): typeof Chalk; /** * 获取 cheerio 库 * cheerio 是一个用于在服务端解析 HTML 的第三方库 * @returns cheerio 库 */ export declare function getCheerio(): typeof Cheerio; /** * 获取 Node.js child_process 模块(仅支持 Node.js 环境) * @returns child_process 模块 * @throws {Error} 当在非 Node.js 环境中调用时抛出错误 * @example * ```ts * const cp = getChildProcess(); * cp.exec('ls -la', (error, stdout, stderr) => { * console.log(stdout); * }); * ``` */ export declare function getChildProcess(): ChildProcess; /** * 根据`id`获取城市名字 * @param {string | number} provinceId * @param {string | number} cityId * @returns {string} 城市名字 * * @example * const res = getCityName(37, 14) * // 德州 * * const res2 = getCityName(11) * // 北京 */ export declare function getCityName(provinceId: number | string, cityId?: number | string): string; /** * 生成文件内容的三阶段替换规则(kebab-case + PascalCase + 类名) * @param {string[]} rawList - 组件名列表 * @param {string[]} dirList - 目标文件 glob 列表 * @param {Object} [options={}] - 可选配置 * @param {string[]} [options.needClassReplaceList=[]] - 需要额外替换类名的组件列表 * @returns {Array<{ list: Array, dirList: string[] }>} */ export declare function getComponentContentReplaceRules(rawList: string[], dirList: string[], options?: { needClassReplaceList?: string[]; }): { list: [string | RegExp, string][]; dirList: string[]; }[]; /** * 统计组件数目、wxml大小、wxss大小、js大小等 * @param dist * @returns result * * @example * ```ts * getComponentInfo('./dist/dev/mp-weixin') * ``` */ export declare function getComponentInfo(dist: string, config?: { wxmlPostfix: string; wxssPostfix: string; vendorNames: string[]; }): { componentTotal: number; wxsstTotal: number; jsTotal: number; wxmlSizeTotal: number; wxssSizeTotal: number; jsSizeTotal: number; vendorJsSize: number; }; /** * 生成 PascalCase 匹配正则(前后必须是非单词字符) * @param {string} value - kebab-case 名称 * @returns {RegExp} */ export declare function getComponentPascalReg(value: string): RegExp; /** * 处理并压缩图片 URL * @docgen * @function getCompressImgUrl * * @param {string|object} inUrl - 图片原始 URL,或包含 url/width/height 的对象 * @param {number} [inImageWidth=0] - 图片裁剪后的宽度(可选,默认为 0,表示不裁剪) * @param {number} [inImageHeight=0] - 图片裁剪后的高度(可选,默认为 0,表示不裁剪) * @return {string} 返回处理后的图片 URL * * @description * 该函数用于处理腾讯云 COS 图片,实现按需加载和压缩。 * - 自动将 http 转为 https * - 对腾讯云图片添加压缩参数 * - 自动调整图片尺寸为 2 倍(避免图片模糊) * - 宽高按 10 取整(避免图片闪烁) * * @example * * // 基础用法 * const url = 'https://image-xxx.file.myqcloud.com/test.jpg'; * const compressed = getCompressImgUrl(url, 100, 100); * * // 使用对象参数 * const compressed2 = getCompressImgUrl({ * url: 'https://image-xxx.file.myqcloud.com/test.jpg', * width: 100, * height: 100 * }); */ export declare function getCompressImgUrl(inUrl?: string | { width?: number; height?: number; url?: string; replace?: Function; }, inImageWidth?: number, inImageHeight?: number): string; /** * 获取config * @param {string} name * @return {*} {*} * * @example * getConfig('login.loginType') * getConfig('game') */ export declare function getConfig(name?: string): any; /** * 获取cookie * @param {string} key cookie键值 * @returns {string} cookie值 * * @example * * const res = getCookie('name') * * // => mike * */ export declare function getCookie(key: string): string; /** * 获取腾讯云COS存储桶中的对象列表 * * @param secretId - 腾讯云API密钥ID * @param secretKey - 腾讯云API密钥Key * @param bucket - COS存储桶名称 * @param region - COS存储桶所在区域 * @param prefix - 对象键前缀匹配,限定返回中只包含指定前缀的对象键(可选) * @param delimiter - 定界符,用于对对象键进行分组,一般是传/(可选) * @param maxKeys - 单次返回最大的条目数量,默认1000,最大为1000(可选) * @param marker - 起始对象键标记,列出从Marker开始MaxKeys条目(可选) * @param encodingType - 返回值的编码方式,可选值:url(可选) * @returns Promise对象,成功时返回存储桶内容数据,失败时返回错误信息 * @throws 当参数不全时会抛出错误 * @example * ```typescript * getCosBucket({ * secretId: 'your-secret-id', * secretKey: 'your-secret-key', * bucket: 'test-bucket', * region: 'ap-beijing' * }) * .then(data => console.log(data)) * .catch(err => console.error(err)); * ``` */ export declare function getCosBucket({ secretId, secretKey, bucket, region, prefix, delimiter, maxKeys, marker, encodingType, }: { secretId: string; secretKey: string; bucket: string; region: string; prefix?: string; delimiter?: string; maxKeys?: number; marker?: string; encodingType?: string; }): Promise; export declare function getCOSBucketList({ secretId, secretKey, bucket, region, prefix, }: { secretId: string; secretKey: string; bucket: string; region: string; prefix: string; }): Promise>; /** * 获取腾讯云COS对象的元数据信息(不返回对象内容) * * @param secretId - 腾讯云API密钥ID * @param secretKey - 腾讯云API密钥Key * @param bucket - COS存储桶名称 * @param region - COS存储桶所在区域 * @param key - 对象键(Object Key),对象在存储桶中的唯一标识 * @returns Promise对象,成功时返回对象的元数据信息(如大小、修改时间等),失败时返回错误信息 * @throws 当参数不全时会抛出错误 * @example * ```typescript * getCosHeadObject({ * secretId: 'your-secret-id', * secretKey: 'your-secret-key', * bucket: 'test-bucket', * region: 'ap-beijing', * key: 'path/to/file.txt' * }) * .then(data => console.log(data)) * .catch(err => console.error(err)); * ``` */ export declare function getCosHeadObject({ secretId, secretKey, bucket, region, key, }: { secretId: string; secretKey: string; bucket: string; region: string; key: string; }): Promise; /** * 获取 cos-nodejs-sdk-v5 库 * cos-nodejs-sdk-v5 是腾讯云对象存储 COS 的 Node.js SDK * @returns cos-nodejs-sdk-v5 库 */ export declare function getCosNodejsSdkV5(): typeof COS; export declare function getCosUrlLink({ bucket, region, dir, fileName, }: { bucket: string; region: string; dir: string; fileName: string; }): string; /** * 倒计时(eg:距开赛1天) * @param {string} time 剩余时间 * @param {SECOND | MINUTE | HOUR | DAY } [maxUnit] 最大单位 * @returns {object} 剩余时间的描述对象 * @example * * getCountDownObj(100) * // { day: 0, hour: 0, minute: 1, second: 40 } * * getCountDownObj(1*24*60*60+200) * // { day: 1, hour: 0, minute: 3, second: 20 } * * getCountDownObj(1 * 24 * 60 * 60 + 2 * 60 * 60 + 1 * 60 + 11, 'HOUR') * // 结果 => * { * fHour: '26', * fMinute: '01', * fSecond: '11', * hour: 26, * minute: 1, * second: 11, * } */ export declare function getCountDownObj(time: number | string, maxUnit?: string): { day?: Number; hour?: Number; minute?: Number; second?: Number; fDay?: String; fHour?: String; fMinute?: String; fSecond?: String; }; /** * 获取 cron-parser 库 * cron-parser 是一个用于解析 cron 表达式的第三方库 * @returns cron-parser 库 */ export declare function getCronParser(): typeof CronParser; /** * 获取 Node.js 的 crypto 模块 * 这样可以避免在浏览器环境中直接导入 crypto 模块导致的错误 * @returns crypto 模块 */ export declare function getCrypto(): typeof CryptoType; /** * 获取当前项目使用的灰度配置 * 根据子项目名称查找匹配的灰度发布配置 * @param fullSubProjectName - 完整的子项目名称 * @param globalGrayPublishConfig - 全局灰度发布配置 * @returns 匹配的灰度配置列表 * @example * ```ts * const grayList = getCurrentProjectUseGray( * 'my-project.sub-project', * globalGrayPublishConfig * ); * // [ * // { * // fullSubProjectName: 'my-project.sub-project', * // packageName: 'my-project.sub-project.dev', * // parsedBranch: '.dev', * // cookieId: 'xxx' * // } * // ] * ``` */ export declare function getCurrentProjectUseGray(fullSubProjectName: string, globalGrayPublishConfig: IGlobalGrayPublishConfig): { fullSubProjectName: string; packageName: string; parsedBranch: string; cookieId: string; }[]; export declare function getCyclomaticComplexityReportAndSendToRobot({ reportJson, detailLinks, webhookUrl, chatId, repo, }: { repo: string; reportJson: Record[]; webhookUrl?: string; chatId?: string[]; detailLinks?: Array<{ label: string; value: string; }>; }): Promise<{ list: StrictComplexityMetrics[]; info: ICyclomaticComplexityStatisticsInfo; msgList: string[]; mdTable: string[]; }>; /** * 获取几天前的终止时间戳 * @param {boolean} n 几天前 * @param {string} unit 返回时间戳的单位,默认是s(秒) * @param {string} endFlag 以什么单位作为结束时间,默认分钟,即23时59分0秒0毫秒 * @returns {number} 时间戳 */ export declare function getDayEndTimeStamp(n?: number, unit?: string, endFlag?: string): number; /** * 获取几天前的起始时间戳 * @param {boolean} n 几天前 * @returns {number} 时间戳 */ export declare function getDayStartTimestamp(n?: number, unit?: string): number; export declare function getDBYEndTimeStamp(unit?: string, endFlag?: string): number; export declare function getDBYStartTimeStamp(unit?: string): number; /** * 获取依赖列表 * @param dir 目录 * @returns dependenciesList */ export declare function getDeps(dir: string): string[]; export declare function getDevopsTemplateInstances({ projectId, templateId, host, secretInfo, page, pageSize, }: ITemplateReq & { page?: number; pageSize?: number; }): Promise; /** * 获取 dotenv 库 * dotenv 是一个用于加载环境变量的第三方库 * @returns dotenv 库 */ export declare function getDotenv(): typeof Dotenv; /** * 获取 dotenv-expand 库 * dotenv-expand 是一个用于扩展 dotenv 环境变量的第三方库 * @returns dotenv-expand 库 */ export declare function getDotenvExpand(): typeof DotenvExpand; export declare function getE2ERobotChatId({ chatIdMap, start, isFailed, isSendAll, isOnlyMe, shouldSendSuccess, }: { chatIdMap: { ALL: Array; ONLY_ME: Array; FAIL: Array; SUCCESS: Array; }; start: number; isFailed?: boolean; isSendAll?: boolean; isOnlyMe?: boolean; shouldSendSuccess?: (number: number) => boolean; }): string[]; export declare function getE2ETestRobotMessage(data: { start: number | string | Date; duration: number; passes: number; tests: number; bkStartType: keyof typeof TRIGGER_MAP; projectLink?: string; checkUrl?: string; name?: string; comment?: string; fileList?: Array<{ file: string; tests: number; passes: number; link: string; testList: ITestList; }>; }, notificationList?: never[]): { message: string; start: string | number | Date; hasFailed: boolean; }; /** * 获取useragent类型 * @returns {object} useragent的map * @example * * getEnvUAType() * * // => * { * isWeixin: false, * isWorkWeixin: false, * isQQ: false, * isPvpApp: false, * isTipApp: false, * isAndroid: false, * isIos: true, * isIOS: true, * isMsdk: false, * isMsdkV5: false, * isSlugSdk: false, * isInGame: false, * isGHelper: false, * isGHelper20004: false, * isMiniProgram: false, * isLolApp: false, * isWindowsPhone: false, * isSymbian: false, * isPc: true, * }; * */ export declare function getEnvUAType(): IEnv; export declare function getEnvVariableMap(filepath: string): Record; export declare function getESLintImportOrderRule(): { 'import/order': (string | { groups: string[]; 'newlines-between': string; alphabetize: { order: string; caseInsensitive: boolean; }; pathGroups: { pattern: string; group: string; position: string; }[]; pathGroupsExcludedImportTypes: string[]; })[]; }; export declare function getESLintImportSettings(options?: { aliasMap: Array<[string, string]>; }): { 'import/resolver': { node: { extensions: string[]; }; alias: { map: string[][]; extensions: string[]; }; }; 'import/ignore': string[]; }; /** * 从MIME类型获取文件后缀 * @param {string} mimeType - MIME类型 * @returns {string|null} 文件后缀或null */ export declare function getExtensionFromMime(mimeType: string): string | null; /** * 从文件路径中提取文件名(不含扩展名) * @param file - 文件路径 * @returns 不含扩展名的文件名 * @example * ```ts * const name = getFileName('/path/to/file.txt'); * console.log(name); // 'file' * ``` */ export declare function getFileName(file: string): string; export declare function getFlattenedDeps(deps: IDeps): Record; /** * 获取 form-data 库 * form-data 是一个用于创建表单数据的第三方库 * @returns form-data 库 */ export declare function getFormData(): typeof FormData_2; /** * 获取 fs 模块 * @returns fs 模块 * @description 仅在 Node.js 环境中可用 * @example * ```ts * import { getFs } from 't-comm'; * const fs = getFs(); * fs.readFileSync('path/to/file', 'utf-8'); * ``` */ export declare function getFs(): typeof fsModule; /** * 获取 fs-extra 库 * fs-extra 是一个扩展了 Node.js fs 模块的第三方库 * @returns fs-extra 库 */ export declare function getFsExtra(): typeof FsExtra; /** * 获取组件全称 * @param name 组件名称 * @param prefix 前缀 * @returns 全称 * @example * ```ts * getFullCompName('swiper-item', 'press-') * getFullCompName('press-swiper-item', 'press-') * * // press-swiper-item * ``` */ export declare function getFullCompName(name?: string, prefix?: string): string; /** * 获取当前用户 * @param isPriorGit - 是否优先使用git用户信息 * @returns user */ export declare function getGitAuthor(isPriorGit?: boolean, root?: string, useCache?: boolean): string; export declare function getGitCodeLink({ domain, repo, branch, localFile, line, }: { domain: string; repo: string; branch: string; localFile: string; line: string; }): string; /** * 获取提交信息 * @param {string} root 根路径 * @param {boolean} mergeCommit 是否包含 merge 的提交 * @param {boolean} splitMessage 是否去掉提交信息的前缀 * @returns {Object} 提交对象 * * @example * ```ts * getGitCommitInfo() * { * author: 'novlan1', * message: ' 优化一部分文档', * hash: '0cb71f9', * date: '2022-10-02 10:34:31 +0800', * timeStamp: '1664678071', * branch: 'master' * } * ``` */ export declare function getGitCommitInfo(root?: string, mergeCommit?: boolean, splitMessage?: boolean, useCache?: boolean): IGitCommitInfo; /** * 获取提交信息 * @param {string} root 根路径 * @param {boolean} mergeCommit 是否包含 merge 的提交 * @param {boolean} splitMessage 是否去掉提交信息的前缀 * @returns {string} 提交信息 * * @example * ```ts * getGitCommitMessage() * // '优化一部分文档' * ``` */ export declare function getGitCommitMessage(root?: string, mergeCommit?: boolean, splitMessage?: boolean, useCache?: boolean): string; /** * 获取tag到head的提交数目 * @param {string} tag git标签 * @returns {string} tag至今的提交数目 */ export declare function getGitCommitsBeforeTag(tag: string, root?: string): string; /** * 获取当前分支 * @returns {string} 分支名称 * * @example * * getGitCurBranch() * * // => master */ export declare function getGitCurBranch(root?: string, useCache?: boolean): string; /** * 获取最新tag * @returns {string} 最新tag */ export declare function getGitLastTag(root?: string): string; export declare function getGitMRLink({ domain, repo, id, }: { domain: string; repo: string; id?: string; }): string; /** * 获取打标签的时间 * @private * @param {string} tag git标签 * @returns {string} 标签时间 */ export declare function getGitTagTime(tag: string, root?: string): string; /** * 获取 glob 库 * glob 是一个用于文件匹配的第三方库 * @returns glob 库 */ export declare function getGlob(): any; /** * 小程序下,获取对应的 H5 路由信息 * @param {Object} route 路由信息 * @returns H5 Url * @example * ```ts * getH5CurrentUrl(this.$route); * ``` */ export declare function getH5CurrentUrl(route: { name?: string; meta?: { rawPath?: Array; }; params: Record; }): string; export declare function getHistoryModeConfigDiff({ secretInfo, appName, key, fetchRainbowConfigOptions, }: { secretInfo: ISecretInfo_3; appName: string; key: string; fetchRainbowConfigOptions?: FetchRainbowConfigOptions; }): Promise<{ equal: boolean; addedMap: IAddedMap; deletedMap: IAddedMap; parsed: Record; originParsed: Record; }>; export declare function getHistoryModeConfigDiffAndSendRobot({ secretInfo, appName, key, chatId, webhookUrl, mentions, fetchRainbowConfigOptions, heartbeat, }: { secretInfo: ISecretInfo_3; appName: string; key: string; chatId?: string | string[]; webhookUrl?: string; mentions?: Array; fetchRainbowConfigOptions?: FetchRainbowConfigOptions; heartbeat?: boolean; }): Promise<{ message: string; equal: boolean; addedMap: IAddedMap; deletedMap: IAddedMap; }>; /** * 获取 http 模块 * @returns http 模块 * @description 仅在 Node.js 环境中可用 * @example * ```ts * import { getHttp } from 't-comm'; * const http = getHttp(); * http.request(options, callback); * ``` */ export declare function getHttp(): typeof httpModule; /** * 将图片地址由 http 替换为 https 协议 * @param url 图片地址 * @returns 新的地址 */ export declare const getHttpsUrl: (inUrl: string) => string; /** * 获取 i18n token * * @export * @param {string} appId appId * @param {string} appKey appKey * @returns {Promise} token * @example * ```ts * getI18nToken('appId', 'appKey').then(token => { * console.log('token', token) * }) * ``` */ export declare function getI18nToken(appId: string, appKey: string): Promise; export declare function getIdentityFromTOF(headers: Record, key: string): Promise<{ staffid: any; staffname: any; }>; /** * 获取镜像名称 * 根据项目名、子项目名和分支生成镜像名称 * @param projectName - 项目名称 * @param subProjectName - 子项目名称 * @param branch - 分支名称 * @returns 镜像名称 * @example * ```ts * const imageName = getImageName({ * projectName: 'my-project', * subProjectName: 'sub-project', * branch: 'release' * }); * // 'my-project.sub-project' * ``` */ export declare function getImageName({ projectName, subProjectName, branch, }: { projectName: string; subProjectName: string; branch: string; }): string; /** * 获取 image-size 库 * image-size 是一个用于获取图片尺寸的第三方库 * @returns image-size 库 */ export declare function getImageSize(): any; /** * 获取图片md5 * @param {object} options 配置信息 * @param {string} options.savePath 本地图片地址,建议绝对路径 * @returns {Promise} 图片md5值 * * @example * getImgMd5({ * savePath: '/test.png' * }).then(md5 => { * console.log(md5) * }) * ``` */ export declare function getImgMd5({ savePath }: { savePath: string; }): Promise; export declare function getInnerBundleBuildDesc({ env, branch, author, message, }: { env: string; branch: string; author: string; message: string; }): string; /** * 获取ip地址 * @returns 字符串,形如 x.x.x.x * * @example * ```ts * getIPAddress() // 10.10.10.10 * ``` */ export declare function getIPAddress(): string; /** * * 获取ip的字符串 * @returns 字符串,形如 x_x_x_x * * @example * ```ts * getIPAddressStr() // 10_10_10_10 * ``` */ export declare function getIPAddressStr(): string; /** * 获取 jose 库 * jose 是一个用于 JSON Web Encryption (JWE) 和 JSON Web Signature (JWS) 的第三方库 * @returns jose 库 */ export declare function getJose(): typeof JoseType; /** * 从日志目录读取并解析 JSON 文件 * 读取 ./log 目录下的 JSON 文件并解析为对象 * @param file - 文件名(相对于 log 目录) * @returns 解析后的 JSON 对象,解析失败或文件不存在时返回空对象 * @example * ```ts * const data = getJsonFromLog('config.json'); * console.log(data); * ``` */ export declare function getJsonFromLog(file: string): {}; export declare function getJsonFromSheet(dataPath: string): unknown[]; /** * 获取 JSON 日志目录的绝对路径 * @returns 日志目录的绝对路径 * @example * ```ts * const logDir = getJsonLogDir(); * console.log(logDir); // /path/to/project/log * ``` */ export declare function getJsonLogDir(): string; /** * 获取对象的value列表,并输出大对象形式 * @param {Array} data * @returns {Object} 处理后的对象 * * @example * * const data = [ * { * Project: 'x', * Request: 1, * Score: 'a' * }, * { * Project: 'y', * Request: 2, * Score: 'b' * }] * * getKeyValuesMap(data) * * // 结果为: * { * Project: ['x', 'y'], * Request: [1, 2], * Score: ['a', 'b'], * } * * // 也支持参数为带value属性的对象数组,如: * * const data = [ * { * Project: { * value: 'x' * } * },{ * Project: { * value: 'y' * } * }] * * // 结果为: * { * Project: ['x', 'y'] * } */ export declare function getKeyValuesMap(data?: Array<{ [k: string]: ValueType | { value: ValueType; }; }>): Record>; /** * 读取本地数据,IDE中不生效,在真机上才生效 * 数据以 app + roleId 为维度隔离存储,。存储的信息如15天不更新,会自动清除。 * @param key 键 */ export declare const getLocalStorageInPixui: (key: string) => Promise; /** * 获取游戏定位信息,回调数据 * { * flag: LocationFlagInPixui, * lat: number, * lng: number, * } */ export declare const getLocationInPixui: (platformAPI: any) => Promise; export declare function getLoginUrlInPixui(baseUrl: string): string; /** * 获取 log-symbols 库 * log-symbols 是一个用于在终端显示彩色符号的第三方库 * @returns log-symbols 库 */ export declare function getLogSymbols(): any; /** * 匹配正则,获取匹配到的列表 * @param {string} content 输入内容 * @param {RegExp} reg 正则 * @returns 匹配列表 * * @example * ```ts * getMatchListFromReg(content, /emit\('([^',]+)'/g); * * // ['start', 'end'] * ``` */ export declare function getMatchListFromReg(content: string, reg: RegExp): string[]; /** * 给对象数组的每一项,添加isMax、isMin、、isSecondMax、isSecondMin、idx、lastIdx等属性 * @param {Array} data 原始数据 * @param {Array} reverseScoreKeys - 逆序的key列表 * @returns {Object} 处理后的数据 * * @example * const data = [{ * ProjectName: { name: 'ProjectName', value: '麻将赛事' }, * PagePv: { name: 'PagePv', value: 2877 }, * }, { * ProjectName: { name: 'ProjectName', value: '斗地主赛事' }, * PagePv: { name: 'PagePv', value: 7 }, * }, * // ... * ]; * * getMaxAndMinIdx(data, []) * * // => * [{ * ProjectName: { name: 'ProjectName', value: '麻将赛事' }, * PagePv: { * name: 'PagePv', * value: 2877, * idx: 6, * lastIdx: 6, * isMax: false, * isMin: false, * isSecondMax: false, * isSecondMin: false, * }, * }]; * */ export declare function getMaxAndMinIdx(data?: Array>, reverseScoreKeys?: Array): any[]; /** * 获取 rtx 拼接的提及字符串 * @param rawStr 原始字符串,比如 `foo,bar` * @returns 处理后的字符串,比如 <@foo><@bar> */ export declare function getMentionRtx(rawStr?: string): string; /** * 生成 meta config(如 component-config.json)的 PascalCase 替换规则 * @param {string[]} rawList - 组件名列表 * @param {string[]} dirList - 目标文件 glob 列表 * @returns {Array<{ list: Array, dirList: string[] }>} */ export declare function getMetaConfigPascalReplaceRules(rawList: string[], dirList: string[]): { list: [string, string][]; dirList: string[]; }[]; /** * 获取 miniprogram-ci 库 * miniprogram-ci 是微信小程序的命令行工具 * @returns miniprogram-ci 库 */ export declare function getMiniprogramCi(): typeof MiniprogramCI; /** * 获取一个月有多少天 * 原理:new Date()第2个参数默认为1,就是每个月的1号,把它设置为0时, * new Date()会返回上一个月的最后一天,然后通过getDate()方法得到天数 * @param {string} year 年份 * @param {string} month 月份 * @returns {number} 天数 * * @example * getMonthDay(2022, 2) // 28 * * getMonthDay(2022, 3) // 31 * * getMonthDay(2022, 4) // 30 */ export declare function getMonthDay(year: number, month: number): number; /** * 获取一个月有多少天 * * 原理:把每月的天数写在数组中,再判断时闰年还是平年确定2月分的天数 * @param {string} year 年份 * @param {string} month 月份 * @returns {number} 天数 * * @example * getMonthDay2(2022, 2) * // 28 * * getMonthDay2(2022, 3) * // 31 * * getMonthDay2(2022, 4) * // 30 */ export declare function getMonthDay2(year: number, month: number): number; /** * 摩斯密码的 Vue mixin,方便实用 * @param {array} pwd 密钥 * @param {Function} cb 回到函数 * @returns 换入内容 * @example * ```ts * getMorsePwdMixin([1, 1, 1, 1, 1], function () { * if (isInIFrame()) return; * this.onShowLaunchApp(); * }), * ``` */ export declare const getMorsePwdMixin: (pwd: number[], cb: Function) => any; /** * 获取MR列表 * @param {object} options 输入配置 * @param {string} options.projectName 项目名称 * @param {string} options.privateToken 密钥 * @returns {Promise} 请求Promise * @example * * getMrList({ * projectName: 't-comm', * privateToken: 'xxxxx', * }).then((resp) => { * * }) */ export declare function getMrList({ projectName, privateToken }: { projectName: string; privateToken: string; }): Promise; /** * msdk 浏览器全屏方法,点击外链时可全屏,返回时退出全屏 * @example * ```ts * mixins: [getMsdkFullScreen()], * ``` */ export declare function getMsdkFullScreen(): { onShow(): void; methods: { callJsReSetFullScreen(): void; }; }; /** * 获取 Node.js 的 net 模块 * 这样可以避免在浏览器环境中直接导入 net 模块导致的错误 * @returns net 模块 */ export declare function getNet(): typeof NetType; declare function getNewPage(browser: IBrowser, device: DEVICE_TYPE): Promise; export declare function getNextVersion(packageName: string | undefined, versionType: VersionType, cwd?: string): string | null; export declare function getNowBySecond(): number; /** * 获取分支详情 * @param {object} options 输入配置 * @param {string} options.projectName 项目名称 * @param {string} options.branchName 分支名称 * @param {string} options.privateToken 密钥 * @returns {Promise} 请求Promise * @example * * getOneBranchDetail({ * projectName: 't-comm', * branchName: 'master', * privateToken: 'xxxxx', * }).then((resp) => { * * }) */ export declare function getOneBranchDetail({ projectName, branchName, privateToken }: { projectName: string; branchName: string; privateToken: string; }): Promise; /** * 获取commit详情 * @param {object} options 输入配置 * @param {string} options.projectName 项目名称 * @param {string} options.commitId 提交hash * @param {string} options.privateToken 密钥 * @returns {Promise} 请求Promise * @example * * getOneCommitDetail({ * projectName: 't-comm', * commitId: 'aaaa', * privateToken: 'xxxxx', * }).then((resp) => { * * }) */ export declare function getOneCommitDetail({ projectName, commitId, privateToken }: { projectName: string; commitId: string; privateToken: string; }): Promise; /** * 获取MR的一条评论 * @param {object} options 输入配置 * @param {string} options.projectName 项目名称 * @param {string} options.privateToken 密钥 * @param {string} options.mrId 某次MR的Id * @returns {Promise} 请求Promise * @example * * getOneMrComments({ * projectName: 't-comm', * privateToken: 'xxxxx', * mrId: '1' * }).then((resp) => { * * }) */ export declare function getOneMrComments({ mrId, projectName, privateToken }: { projectName: string; mrId: string; privateToken: string; }): Promise; /** * 通过搜索获取一个项目信息 * @param {object} options 输入配置 * @param {string} options.search 搜索内容 * @param {string} options.page 起始页码 * @param {string} options.privateToken 密钥 * @returns {Promise>} 请求Promise * @example * * getOneProjectBySearch({ * search: 't-comm', * page: 1, * privateToken: 'xxxxx', * }).then((resp) => { * * }) */ export declare function getOneProjectBySearch({ search, privateToken, page, }: { search: string; privateToken: string; page?: number; }): Promise>; /** * 获取仓库详情 * @param {object} options 输入配置 * @param {string} options.projectName 项目名称 * @param {string} options.privateToken 密钥 * @returns {Promise} 请求Promise * @example * getOneProjectDetail({ * projectName: 't-comm', * privateToken: 'xxxxx', * }).then((resp) => { * * }) */ export declare function getOneProjectDetail({ projectName, privateToken, baseUrl, }: { projectName: string; privateToken: string; baseUrl?: string; }): Promise; export declare function getOpenLocationUrl({ lat, lng, name, address, }: Pick): string; /** * 获取 os 模块 * @returns os 模块 * @description 仅在 Node.js 环境中可用 * @example * ```ts * import { getOs } from 't-comm'; * const os = getOs(); * const tmpDir = os.tmpdir(); * ``` */ export declare function getOs(): typeof osModule; export declare function getPagesJsonCondition(componentConfig: Array<{ list: Array<{ name: string; }>; }>): { current: number; list: { name: any; path: string; }[]; }; /** * 统计页面总数、分包数目等 * @param dist * @returns result * * @example * ```ts * getPageTotal('./dist/dev/mp-weixin') * ``` */ export declare function getPageTotal(dist: string): { pageTotal: number; subPackageTotal: number; }; /** * 高度可配置的参数获取函数。 * 它根据提供的参数名列表,智能地将分散参数或对象参数转换为一个标准化的对象。 * * @template T - 期望返回的对象类型。 * @param {string[]} paramNames - 参数名列表,用于映射分散的参数。 * @param {any[]} args - 原始的函数参数 `arguments`。 * @returns {T} - 一个标准化的对象。 */ export declare function getParameters(paramNames: string[] | readonly string[], args?: any[]): T; /** * 获取占比 * @param {number} summary 总数据 * @param {number} part 部分数据 * @returns {number} 比例 * @example * getRatio(0, 1) * // 0 * * getRatio(1, 0) * // 0 * * getRatio(1, 1) * // 100 * * getRatio(1, .5) * // 50 */ export declare function getPartRatio(summary: number, part: number): number; /** * 获取 Node.js path 模块 * 动态导入 path 模块,避免在浏览器环境中引起错误 * @returns Node.js path 模块 * @example * ```ts * const path = getPath(); * const fullPath = path.resolve(__dirname, './file.txt'); * const basename = path.basename('/path/to/file.txt'); // 'file.txt' * ``` */ export declare function getPath(): typeof path; /** * 读取持久化存储 * @param {string} key * @returns {string} key对应的值 */ export declare function getPersist(key: string): any; export declare function getPipelineBuildDetail({ projectId, pipelineId, buildId, archiveFlag, executeCount, secretInfo, host, }: { projectId: string; pipelineId: string; buildId: string; archiveFlag?: boolean; executeCount?: number | string; secretInfo: ISecretInfo; host: string; }): Promise; /** * 获取流水线列表 * @param {object} params 配置信息 * @param {string} params.projectId 项目ID * @param {object} params.secretInfo 密钥信息 * @param {string} params.host 请求域名 * @param {number} params.page 第几页 * @param {number} params.pageSize 每页数据量 * @returns 流水线列表 */ export declare function getPipelineList({ projectId, secretInfo, host, page, pageSize, }: { projectId: string; secretInfo: ISecretInfo; host: string; page?: number; pageSize?: number; }): Promise; export declare function getPipelineReviewElement(data?: any): any; /** * 获取预发布版本标签,比如 alpha, beta * @param {string} version 版本号 * @returns 标签 * @example * ```ts * getPreReleaseTag('1.2.2-beta.0') * // beta * ``` */ export declare function getPreReleaseTag(version: string): string; /** * 生成 alpha、beta 等这些预发布的版本 * @param key 关键词 * @returns 生成的版本 */ export declare function getPreReleaseVersion(key?: string, cwd?: string): string | undefined; /** * 获取相对上次的比例,会给输入的对象数组的每一项增加 ratio、previousValue 属性 * @param {Array} data - 输入数据 * @param {Object} preDataMap - 上次数据的map * @param {string} uniqKey - 唯一键 * * @example * const data = [{ * Project: { value: 'mj-match', name: 'Project' }, * Request: { * value: 854, * name: 'Request', * idx: 19, * lastIdx: 19, * isMax: false, * isMin: false, * isSecondMax: false, * isSecondMin: true, * }, * }]; * * const preDataMap = { * 'mj-match': { * Project: 'mj-match', * Request: 4, * Score: 91.81, * FirstLoadTime: 178, * WholePageTime: 1035, * ParseDomTime: 484, * DNSLinkTime: 0, * DOMTime: 414, * TCP: 0, * HTTP: 275, * BackEnd: 60, * CGIFailNum: 0, * ErrorLogNum: 0, * CGIRequestNum: 83, * }, * }; * * getPreviousRatio(data, preDataMap); * * // data会变成: * [{ * Project: { value: 'mj-match', name: 'Project' }, * Request: { * value: 854, * name: 'Request', * idx: 19, * lastIdx: 19, * isMax: false, * isMin: false, * isSecondMax: false, * isSecondMin: true, * * previousValue: 4, // 新增属性 * ratio: "+999+%" // 新增属性 * }, * }]; */ export declare function getPreviousRatio(data?: Array, preDataMap?: Record, uniqKey?: string): void; /** * 根据 groupId 获取项目列表 * @ignore * @param {object} options 配置 * @param {number} options.groupId 小组Id * @param {object} options.secretInfo 密钥信息 * @param {string} options.secretInfo.apiKey apiKey * @param {string} options.secretInfo.loginName loginName * @param {Function} options.secretInfo.getPwdCode getPwdCode * @param {Function} options.secretInfo.encrypt encrypt * @returns {Promise>} 项目列表 * @example * getProjectByGroupId({ * groupId: 1, * secretInfo: { * apiKey: '', * loginName: '', * getPwdCode() {}, * encrypt() {}, * } * }).then(resp => { * console.log(resp) * }) * [ * { * ID: 56564, * ProjectName: 'name', * ProjectDesc: 'desc', * ProjectKey: 'xxx', * ProjectType: 'web', * GroupId: 123, * GroupName: 'xxx', * GroupKey: 'xxx', * InstanceID: 'rum-xxx', * Url: '*.qq.com', * CodePath: '', * Rate: '100', * CreateUser: 'xxx', * EnableUrlGroup: true, * KafkaHost: '', * KafkaTopic: '', * KafkaVersion: '', * SaslUserName: '', * SaslPassword: '', * SaslMechanism: '', * IsFollow: false, * CreateTime: '2021-10-01T11:34:32+08:00', * }, * { * ID: 12345, * // ... * }, * ]; * */ export declare function getProjectByGroupId({ groupId, secretInfo, }: { groupId: number; secretInfo: SecretInfoType; }): Promise; /** * 获取默认分支 * @param {object} options 输入配置 * @param {string} options.projectName 项目名称 * @param {string} options.privateToken 密钥 * @returns {Promise} 请求Promise * @example * * getProjectDefaultBranch({ * projectName: 't-comm', * privateToken: 'xxxxx', * }).then((branch) => { * console.log('branch: ', branch) * }) */ export declare function getProjectDefaultBranch({ projectName, privateToken }: { projectName: string; privateToken: string; }): Promise; export declare function getProtectedBranchRules({ projectName, baseUrl, privateToken, }: { projectName: string; baseUrl: string; privateToken: string; }): Promise>; /** * 根据`id`获取省份名字 * @param {string | number} provinceId * @returns {string} 省份名字 * * @example * const res = getProvName(37) * // 山东 * * const res2 = getCityName(11) * // 北京 */ export declare function getProvName(provinceId: string | number): string; export declare function getPublishBashPath(): string; export declare function getPublishEnvValue(key: string): string; export declare function getPublishModuleName(dir?: string): string; export declare function getPublishRootDir(): string; /** * 获取组件简称 * @param name 组件名称 * @param prefix 前缀 * @returns 简称 * ```ts * getPureCompName('press-swiper-item', 'press-') * getPureCompName('swiper-item', 'press-') // swiper-item * ``` */ export declare function getPureCompName(name?: string, prefix?: string): string; /** * 获取 qs 库 * qs 是一个用于解析和序列化查询字符串的第三方库 * @returns qs 库 */ export declare function getQs(): any; /** * url参数变对象 * @param {string} url 输入URL * @returns {Object} search对象 * * @example * * const res = getQueryObj('https://igame.qq.com?name=mike&age=18&feel=cold&from=China'); * * console.log(res); * { * name: 'mike', * age: '18', * feel: "cold", * from: 'China', * } * */ export declare function getQueryObj(url: string): Record; /** * 在区间内获取随机浮点数 * @param min - 最小值 * @param max - 最大值 * @returns 随机浮点数 * @example * ```ts * getRandomNumber(0, 10); // 3.456789 * getRandomNumber(1.5, 5.5); // 2.789123 * ``` */ export declare function getRandomNumber(min: number, max: number): number; /** * 获取随机字符串 * @param {number} length 字符串长度,默认 32 * @returns {string} 字符串 * @example * ```ts * randomString() * * randomString(16) * ``` */ export declare const getRandomString: typeof randomString; /** * A引用B时,拿引用路径 * @param pathA 路径A * @param pathB 路径B * @returns 相对路径 * @example * ```ts * getRelativePath('a', 'b'); * * // './b' * ``` */ export declare function getRelativePath(pathA: string, pathB: string): string; /** * 获取 request 库 * request 是一个第三方 HTTP 客户端库 * 注意:request 库已经被废弃,建议使用 axios 或 node-fetch 替代 * @returns request 库 */ export declare function getRequest(): any; /** * 从审核意见中提取真实审核人 * * 当审核由 pmd-mcp 等自动化工具代为操作时,审核意见中会携带真实审核人信息, * 格式为 "by pmd-mcp, from novlan1)",此函数提取其中的真实用户名。 * * @param suggest - 审核意见字符串 * @returns 提取到的审核人用户名,未匹配则返回空字符串 * * @example * ```ts * getReviewerFromSuggest('by pmd-mcp, from novlan1)') // => 'novlan1' * getReviewerFromSuggest('by pmd-mcp, from novlan1') // => 'novlan1' * getReviewerFromSuggest('LGTM') // => '' * getReviewerFromSuggest('') // => '' * ``` */ export declare function getReviewerFromSuggest(suggest: string): string; export declare function getRobotWebhookUrl(key: string): string; /** * 路由离开前记住缓存,返回后不刷新页面 * * 比如创建赛事页面,如果前往查看规则,返回后,希望保留之前的表单 * * 注意,用了这个 mixin,就不要用 onShow 了,而是用 mounted, * 否则可能会重复触发刷新 * * @param {string} config.refresh 刷新方法 * @returns 返回对象,包含 beforeRouteLeave 和 activated 方法 */ export declare function getRouteLeaveCache({ refresh, }: { refresh?: string; }): { activated(): void; mounted(): void; methods: { _jumpToCacheRoute(): void; }; }; /** * 获取当前路由部分的 url * @return {string} */ export declare function getRoutePartUrl(): string; /** * 根据路由跳转时的参数,提取 path 和其他参数 * @param route $router.push 或者 $router.replace 的参数 * @returns 解析结果 */ export declare function getRouterFuncPath(route: any): { path: any; other: any; }; /** * 获取rtx信息 * @private */ export declare function getRtxInfo(): Promise; export declare function getRtxInfoV2(defaultRtx?: string): Promise<{ rtx: string; }>; export declare function getRUMAllProject({ secretId, secretKey, }: { secretId: string; secretKey: string; }): Promise; /** * 获取腾讯云 RUM(Real User Monitoring)性能数据 * 用于查询前端性能监控数据,支持按时间范围和类型筛选 * @param secretId - 腾讯云 SecretId * @param secretKey - 腾讯云 SecretKey * @param id - RUM 项目 ID * @param startTime - 开始时间(时间戳或字符串) * @param endTime - 结束时间(时间戳或字符串) * @param type - 性能数据类型 * @returns {Promise<{data: Array}>} - 返回性能数据数组 * @example * ```ts * getRUMPerformance({ * secretId: 'your-secret-id', * secretKey: 'your-secret-key', * id: '123456', * startTime: 1640000000, * endTime: 1640086400, * type: 'page' * }).then(result => { * console.log('性能数据:', result.data); * }); * ``` */ export declare function getRUMPerformance({ secretId, secretKey, id, startTime, endTime, type, }: { secretId: string; secretKey: string; id: string | number; startTime: string | number; endTime: string | number; type: string; }): Promise; export declare function getRUMScores({ secretId, secretKey, startTime, endTime, }: { secretId: string; secretKey: string; startTime: string; endTime: string; }): Promise>; /** * 安全获取文件后缀名 * @param {File} file - 文件对象 * @returns {string} 文件后缀名(小写,不带点) */ export declare function getSafeFileExtension(file: File): string; export declare function getSomeDayEndTimeStamp(date: string | number | Date, unit?: string): number; export declare function getSomeDayStartTimeStamp(date: string | number | Date, unit?: string): number; export declare function getStylelintLinebreaksRules(value?: string): { linebreaks?: undefined; } | { linebreaks: string; }; export declare function getStylelintVendorPrefixRules(): { 'selector-no-vendor-prefix': null; 'value-no-vendor-prefix': null; 'property-no-vendor-prefix': null; 'at-rule-no-vendor-prefix': null; 'media-feature-name-no-vendor-prefix': null; }; export declare function getSubmodulePathList(file?: string): string[]; /** * 根据项目id获取分数信息 * @ignore * @param {object} options 参数 * @param {Array} options.projectIdList 项目Id列表 * @param {string} options.date 日期,yyyyMMdd格式 * @param {object} options.secretInfo 密钥信息 * @param {string} options.secretInfo.apiKey apiKey * @param {string} options.secretInfo.loginName loginName * @param {Function} options.secretInfo.getPwdCode getPwdCode * @param {Function} options.secretInfo.encrypt encrypt * @returns {Promise>} 分数信息 * @example * getTAMScoreInfoByProjectId({ * projectId: 123123, * date: 20210106 * secretInfo: { * apiKey: '', * loginName: '', * getPwdCode() {}, * encrypt() {}, * } * }).then((data) => { * console.log(data) * }) * * [ * { * ProjectName: '社区', * PagePv: 99, * PageError: 0, * PageDuration: 1409.8333, * StaticFail: 8, * CreateTime: '', * ProjectId: 123123, * PageUv: 23, * ApiNum: 521, * ApiFail: 78, * ApiDuration: 1813.3333, * StaticNum: 1494, * StaticDuration: 103.75, * Score: 80.9167, * CreateUser: 'lee', * GroupName: 'aGroup', * }, * ] * */ export declare function getTAMScoreInfoByProjectId({ projectId, startDate, secretInfo, }: { projectId: number; startDate: string; secretInfo: SecretInfoType; }): Promise>; /** * 根据 groupIdList 获取汇总数据 * @ignore * @param {object} options 配置 * @param {string} options.date 日期,yyyyMMdd格式 * @param {Array} options.groupIdList groupId列表 * @param {object} options.secretInfo 密钥信息 * @param {string} options.secretInfo.apiKey apiKey * @param {string} options.secretInfo.loginName loginName * @param {Function} options.secretInfo.getPwdCode getPwdCode * @param {Function} options.secretInfo.encrypt encrypt * @returns {Promise<({ data: object, projectIdList: Array })>} 汇总数据 * @example * getTAMSummaryScoreByGroupIdList({ * groupIdList: [1,2,3], * date: '20210106', * secretInfo: { * apiKey: '', * loginName: '', * getPwdCode() {}, * encrypt() {}, * } * }).then(resp => { * console.log(resp) * }) * * { * data: * [ * { * ProjectName: '社区', * PagePv: 99, * PageError: 0, * PageDuration: 1409.8333, * StaticFail: 8, * CreateTime: '', * ProjectId: 123123, * PageUv: 23, * ApiNum: 521, * ApiFail: 78, * ApiDuration: 1813.3333, * StaticNum: 1494, * StaticDuration: 103.75, * Score: 80.9167, * CreateUser: 'lee', * GroupName: 'aGroup', * }, * { * ProjectId: 123, * // ... * }, * ], * projectIdList: [ * 123123, * 123, * ], * }; * */ export declare function getTAMSummaryScoreByGroupIdList({ date, groupIdList, secretInfo, }: { date: string; groupIdList: Array; secretInfo: SecretInfoType; }): Promise<({ data: Array; projectIdList: Array; })>; /** * 获取 tar 库 * tar 是一个用于处理 tar 压缩包的第三方库 * @returns tar 库 */ export declare function getTar(): any; /** * 用于获取用户信息,同时也可以用来校验 AccessToken 的有效性。 */ export declare function getTencentDocUserInfo({ accessToken, }: { accessToken: string; }): Promise; /** * 获取千分位分隔符 * @param {string | number} value 输入数字 * @returns {string} 处理后的数字 * * @example * * getThousandSeparator('123123123') * * // => 123,123,123 * * getThousandSeparator('12312312') * * // => 12,312,312 */ export declare function getThousandSeparator(value: number | string): string; /** * 获取千分位分隔符,处理数字之间有空格的情况 * @param {string | number} value 输入数字 * @returns {string} 处理后的数字 * * @example * getThousandSeparator2('12345678 123456789') * * // => 12,345,678 123,456,789 * */ export declare function getThousandSeparator2(value: number | string): string; /** * 生成三阶段重命名配置(plus -> temp, key -> plus, temp -> key) * @param {string[]} rawList - 组件名列表,如 ['dialog', 'icon'] * @param {string[]} [extraList=[]] - 额外需要重命名的组件名列表 * @returns {{ renameConfig: Object, renameConfig2: Object, renameConfig3: Object }} */ export declare function getThreeStageRenameConfig(rawList: string[], extraList?: string[]): { renameConfig: Record; renameConfig2: Record; renameConfig3: Record; }; /** * 获取某个时间戳距离今天的时间 * @param {number} timestamp * @returns {string} 距离今天的时间描述 * @example * * const date = new Date('2020-11-27 8:23:24').getTime(); * getTimeAgo(date); * // 1个月前 * * const date2 = new Date('2021-11-27 8:23:24').getTime(); * getTimeAgo(date2); * // 10个月后 */ export declare function getTimeAgo(timestamp: number): string; /** * 功能:获取多久之前,若间隔超过一天,返回时刻描述 * @param {number} timestamp 时间戳 * @param {string} format 时间格式 * @returns {string} 距离今天的时间描述或者时刻描述 * @example * * getTimeAgoOrDate(Date.now() - 60 * 60 * 24 * 1 * 1000); * // 1天前 * * const date = new Date('2018-07-13 17:54:01').getTime(); * getTimeAgoOrDate(date); * // 7月13日17时54分 */ export declare function getTimeAgoOrDate(time: string | number, format: string): string | null; export declare function getTodayEndTimeStamp(unit?: string, endFlag?: string): number; export declare function getTodayStartTimestamp(unit?: string): number; export declare function getTSErrorFiles(options?: GetTSErrorFilesProps): TsErrorFile[]; declare type GetTSErrorFilesProps = { command?: string; root?: string; }; export declare function getUniRouteName({ isNavigateBack, routerParams, }: { isNavigateBack?: boolean; routerParams?: Array; }): { from: string; to: string; }; /** * 获取相对于过去数据的比例 * @param {number} value 当前数据 * @param {number} preValue 之前数据 * @returns {string} 比例 * * @example * * getUnitPreviousRatio(1, 0) * // +999+% */ export declare function getUnitPreviousRatio(value: number, preValue: number): string; /** * 小程序中,获取页面对应的 url 链接 * @param {string} baseLink 基础 URL * @return {string} */ export declare function getUrlInMP(baseLink: string): string; /** * 获取 Url 参数 * @param {string} paraName 参数 key * @param {string} search url search 部分 * @returns paraValue * * @example * ```ts * getUrlPara('gender', '?gender=male&name=mike&feel=cold&age=18&from=test') * // male * * getUrlPara('age', '?gender=male&name=mike&feel=cold&age=18&from=test') * // 18 * ``` */ export declare function getUrlPara(paraName: string, search?: string): string; /** * 获取用户组件演示数据 * 返回包含头像和昵称的用户信息对象,用于组件演示 * @returns 用户信息对象 * @returns {string} avatar - 用户头像 URL * @returns {string} nick - 用户昵称 * @example * ```ts * const user = getUserComponentDemo(); * console.log(user.avatar); // 'https://...' * console.log(user.nick); // '杨' * ``` */ export declare function getUserComponentDemo(): { avatar: string; nick: string; }; /** * 获取 Node.js 的 util 模块 * 这样可以避免在浏览器环境中直接导入 util 模块导致的错误 * @returns util 模块 */ export declare function getUtil(): typeof UtilType; /** * 获取可用的端口号 * 从指定端口开始检测,如果端口被占用则自动尝试下一个端口,直到找到可用端口 * @param port - 起始端口号 * @returns {Promise} - 返回可用的端口号 * @example * ```ts * // 从 3000 端口开始查找可用端口 * getValidPort(3000).then(port => { * console.log(`可用端口: ${port}`); * }); * ``` */ export declare function getValidPort(port: number): Promise; export declare const getVisibilityChangeMixin: (showCallback?: Function, hiddenCallback?: Function) => { mounted(): void; destroyed(): void; methods: { _watchVisibleChange(): void; }; }; /** * 获取 vue-lazyload 插件参数 * @param options 选项 * @returns 插件参数 */ export declare function getVLazyOptions(options?: { loadingImg?: string; errorImg?: string; }): { preLoad: number; attempt: number; filter: { loading(listener: any): void; error(listener: any): void; https(listener: any): void; compress(listener: any): void; cdn(listener: any): void; stopBeforeLoad(listener: any): void; }; adapter: { error(listener: any): void; }; }; /** * 获取 vue 库 * vue 是一个用于构建用户界面的渐进式框架 * @returns vue 库 */ export declare function getVue(): any; /** * 获取深圳天气信息,可用于通过机器人发送到群聊 * @returns {object} 天气信息和是否有变化 * @example * * getWeatherRobotContent().then(resp => { * const { content, isSame } = resp * * console.log(content) * // ## 深圳当前正在生效的预警如下 * // ... * * console.log(isSame) * // false * }) */ export declare function getWeatherRobotContent(): Promise<{ content: string; isSame: boolean; }>; /** * @see [企业微信自助入群工具](https://iwiki.woa.com/p/541885852#%E4%BC%81%E4%B8%9A%E5%BE%AE%E4%BF%A1%E8%87%AA%E5%8A%A9%E5%85%A5%E7%BE%A4%E5%B7%A5%E5%85%B7) * https://nops.woa.com/pigeon/v1/tools/add_chat?chatId=群会话ID */ export declare function getWxWorkAddChatLink(chatId: string): string; /** * @example * ```ts * getWxWorkMessageLink('novlan1') * // => https://github.com/novlan1 * ``` */ export declare function getWxWorkMessageLink(rtx: string): string; /** * 获取 xlsx 库 * xlsx 是一个用于处理 Excel 文件的第三方库 * @returns xlsx 库 */ export declare function getXlsx(): typeof XLSX; export declare function getYesterdayEndTimeStamp(unit?: string, endFlag?: string): number; export declare function getYesterdayStartTimeStamp(unit?: string): number; /** * * GID 映射表 * * | 名称 | 游戏 | * | --- | --- | * | GAME_LIFE | 游戏人生 | * | GAME_PVP | 王者荣耀 | * | GAME_GP | 和平精英 | * | GAME_HLDDZ | 欢乐斗地主 | * | GAME_MAJIANG | 欢乐麻将 | * | GAME_LOLM | 英雄联盟手游 | * | GAME_NBA | 最强 NBA | * | GAME_SJJQ | 神角技巧 | * | GAME_LMJX | 黎明觉醒 | * | GAME_TY | 天涯明月刀手游 | * | GAME_TLBB | 天龙八部手游 | * | GAME_CF | 穿越火线 | * | GAME_LOL | 英雄联盟 | * | GAME_CFM | 穿越火线-枪战王者 | * | GAME_X5M | QQ炫舞手游 | * | GAME_TXGD | 腾讯掼蛋 | * | GAME_SHANHAI | 妄想山海 | * | GAME_JCC | 金铲铲之战 | * | GAME_HYRZ | 火影忍者手游 | */ export declare const GID_MAP: { readonly GAME_LIFE: 100; readonly GAME_PVP: 331; readonly GAME_GP: 411; readonly GAME_HLDDZ: 323; readonly GAME_MAJIANG: 304; readonly GAME_LOLM: 425; readonly GAME_NBA: 406; readonly GAME_SJJQ: 460; readonly GAME_LMJX: 428; readonly GAME_TY: 281; readonly GAME_TLBB: 396; readonly GAME_CF: 2; readonly GAME_LOL: 26; readonly GAME_CFM: 333; readonly GAME_X5M: 507; readonly GAME_TXGD: 508; readonly GAME_SHANHAI: 429; readonly GAME_JCC: 461; readonly GAME_HYRZ: 334; }; export declare namespace GitTypes { export { IGitCommitInfo } } export declare const globalEBus: EventBus; export declare const GRAY_PUBLISH_OPERATION: { FIRST_GRAY_PUBLISH: string; UPDATE_GRAY_PERCENT: string; PUBLISH_ALL_GRAY: string; RECALL_ALL_GRAY: string; }; export declare const GRAY_PUBLISH_TITLE_MAP: { [x: string]: string; }; /** /** * 处理图片尺寸单位,将 px/rem 转换为纯数字 * @docgen * @function handleImgUnit * * @param {number|string} size - 输入的尺寸值 * @return {number} 返回处理后的数值(px) * * @description * 该函数用于处理图片尺寸,去除单位(px/rem)并转换为数字类型。 * - 纯数字:直接返回 * - px 单位:去除 'px' 后返回数字 * - rem 单位:乘以根元素的 fontSize 转换为 px 值 * * @example * * handleImgUnit(3); // 3 * handleImgUnit('10'); // 10 * handleImgUnit('30px'); // 30 * * // 假设 document.documentElement.style.fontSize = '50px' * handleImgUnit('5rem'); // 250 * * // 假设 document.documentElement.style.fontSize = '10px' * handleImgUnit('5rem'); // 50 */ export declare const handleImgUnit: (size: number | string) => string | number | undefined; export declare const hsl2hsv: (hue: number, sat: number, light: number) => { h: number; s: number; v: number; }; export declare const hsv2hsl: (hue: number, sat: number, val: number) => number[]; /** * Converts an HSV color value to RGB. * *Assumes:* h is contained in [0, 1] or [0, 360] and s and v are contained in [0, 1] or [0, 100]. * *Returns:* { r, g, b } in the set [0, 255] */ export declare function hsv2rgb(h: number, s: number, v: number): { r: number; g: number; b: number; }; /** * 驼峰命名转横线命名:拆分字符串,使用 - 相连,并且转换为小写 * @param {string} str 输入字符串 * @returns {string} 处理后的字符串 * * @example * * hyphenate('abCd') * * // => ab-cd * */ export declare function hyphenate(str: string): string; declare type IAddedMap = Record>; declare interface IAppInfo { name: string; version: string; homepage?: string; bugs?: { url: string; }; repository?: { url: string; }; } /** * checkAuditResult 的审核结果信息 */ declare interface IAuditResultInfo { /** 审核状态:PROCESS 通过 / ABORT 驳回 */ status: string; /** 审核人 */ reviewer: string; /** 审核意见 */ suggest: string; /** 构建链接 */ bkBuildUrl: string; } declare type IBaseLaunchParams = { context?: any; qrCodeLib?: any; dialogHandler?: any; otherDialogParams?: Record; launchParams?: Record; wxJSLink?: string; env?: Record; }; declare type IBrowser = any; /** * buildAuditContent 的参数 */ declare interface IBuildAuditContentOptions { /** 审核标题,如 '【H5发布审核】' */ title: string; /** 项目名,传空或不传时不展示项目行 */ projectName?: string; /** 发起人 rtx */ creator: string; /** 审核人原始字符串,逗号分隔 */ auditor: string; /** 构建链接 */ buildUrl: string; /** 差异化的额外行,如子工程、分支、灰度比例等 */ extraLines?: string[]; } declare interface ICanvas extends HTMLCanvasElement { dpi: number; } /** * checkAuditResult 的参数 */ declare interface ICheckAuditResultOptions { /** 审核结果信息 */ resultInfo: IAuditResultInfo; /** 通知标题,如 '【H5发布】' '【组件库发布】' */ title: string; /** 差异化的通知内容行(项目名、子工程、分支等) */ contentLines: string[]; /** 发起人 rtx */ creator: string; /** 审核描述 */ auditDesc: string; /** 企微机器人 webhook key */ webhookUrl: string; } declare interface ICosInfo { secretId: string; secretKey: string; bucket: string; region: string; dir: string; } declare interface ICosMeta { Key: string; LastModified: Date | string; } export declare interface ICyclomaticComplexityStatisticsInfo { fileTotal: number; funcTotal: number; cnnTotal: number; avgCNN: number; avgNLOC: number; avgToken: number; avgParameter: number; locTotal: number; nLocTotal: number; tokenTotal: number; parameterTotal: number; less5Length: number; between5And10Length: number; between10And15Length: number; between15And20Length: number; between20And25Length: number; between25And30Length: number; between30And35Length: number; greater35Length: number; parameterLadders: number[]; nlocLadders: number[]; } declare type IDeps = Record>; declare type IEnv = { isWeixin: boolean; isWorkWeixin: boolean; isQQ: boolean; isPvpApp: boolean; isTipApp: boolean; isAndroid: boolean; isIos: boolean; isIOS: boolean; isMsdk: boolean; isMsdkX: boolean; isMsdkV5: boolean; isSlugSdk: boolean; isInGame: boolean; isGHelper: boolean; isGHelper20004: boolean; isMiniProgram: boolean; isLolApp: boolean; isWindowsPhone: boolean; isSymbian: boolean; isPc: boolean; }; /** * getAuditor 的参数 */ declare interface IGetAuditorOptions { /** 审核类型:'rainbow' | 'json' | 'static' */ type: 'rainbow' | 'json' | 'static'; /** * 审核配置数据源(rainbow 和 json 模式需要) * - 传入 string:作为配置文件路径,同步读取 * - 传入函数:异步获取配置数据 */ configSource?: string | (() => Promise>); /** rainbow 模式的额外参数 */ rainbowOptions?: IRainbowAuditorOptions; /** json 模式的额外参数 */ jsonOptions?: IJsonAuditorOptions; /** 静态审核人列表(static 模式) */ staticAuditorList?: string[]; /** 是否跳过审核(例如非生产环境或由参数控制) */ skipAudit?: boolean; } /** * getAuditor 的返回值 */ declare interface IGetAuditorResult { /** 审核人,逗号分隔 */ auditor: string; /** 是否需要审核 */ shouldAudit: boolean; } export declare type IGetWxSignaturePromise = () => Promise<{ wxappid?: string; timestamp?: string; noncestr?: string; signature?: string; }>; export declare type IGitCommitInfo = { author: string; message: string; hash: string; date: string; timeStamp: string; branch: string; }; export declare type IGlobalGrayPublishConfig = Record>; declare type IHumpObject = Record | Array; export declare type IImportItem = string | Array | { sourceName?: string; sourceType?: IImportType; targetName?: string; targetType?: IImportType; }; export declare enum IImportType { ImportSpecifier = "ImportSpecifier", ImportDefaultSpecifier = "ImportDefaultSpecifier", importNamespaceSpecifier = "ImportNamespaceSpecifier", FAKE = "FAKE" } declare type IJSDocOptions = { docsPath?: string; author?: string; extraCss?: string; extraScript?: string; navHandler?: Function; isHandleNav?: boolean; }; /** * json 模式的额外参数 */ declare interface IJsonAuditorOptions { /** 项目名 */ projectName: string; /** 配置 key(如 versionType) */ key: string; } declare type ILocalConfig = Array<{ key: string; value: string; }>; declare type IMeta = { rawPath?: Array; }; declare interface IMorsePwd { pwd: Array; cb: Function; quiet?: boolean; holdTime?: number; envType: 'H5' | 'h5' | 'mp' | 'MP'; selector?: keyof HTMLElementTagNameMap; } /** * 函数实现时的参数类型(联合类型) * * @template T - 参数对象类型 * @template K - 参数键名数组(按顺序,支持 readonly) * * @example * type ImplArgs = ImplementationArgs; * // 结果: [ShowDialogParams] | [string, string?] */ export declare type ImplementationArgs = [T] | ParamsToTuple; export declare function importI18nDict({ projectId, moduleCode, versionCode, accessToken, data, }: { projectId: string; moduleCode?: string; versionCode?: string; accessToken: string; data: object; }): Promise; declare interface InitAegisOptions { Aegis: any; aegisKey: string; setupPolyfills?: () => void; url?: string; } /** * 表单等数据变更时,提示用户是否确认离开当前页面 * @param checkDataCallback 可选,用于检查是否有未保存的数据变更,返回 true 则提示用户,返回 false 则不提示 * @returns 一个数组,第一个元素是移除事件监听的函数,第二个元素是事件处理函数 * * @example * ```ts * const [removeBeforeUnload] = initBeforeUnload(() => { * return form.isDirty; // 假设 form.isDirty 表示表单是否有未保存的更改 * }); * * // 在组件卸载或不再需要提示时调用 * removeBeforeUnload(); * ``` */ export declare function initBeforeUnload(checkDataCallback?: () => boolean): [ () => void, (event: BeforeUnloadEvent) => void ]; declare function initBrowser({ puppeteer, args, headless, devtools, }: { puppeteer: any; args?: Array; headless?: boolean; devtools?: boolean; }): Promise; /** * 初始化config * @param {ConfigType} config */ export declare function initConfig(config: ConfigType): void; export declare function initCustomDialog({ title, content, confirmText, cancelText, styleId, dialogId, }: { title: string; content: string; confirmText?: string; cancelText?: string; styleId?: string; dialogId?: string; }): void; export declare function initCustomDom({ styleId, styleContent, dialogId, dialogContent, }: { styleId: string; styleContent: string; dialogId: string; dialogContent: string; }): void; /** * 挂载唯一的eBus,不同实例用不同的 * @param app Vue3 应用实例 */ export declare const initDiffVue3EBus: (app: any) => any; /** * 初始化环境信息 * 获取当前运行环境的 UA 类型信息 * @returns 环境信息对象 * @example * ```ts * const env = initEnv(); * console.log(env.isWeixin); // false * console.log(env.isIOS); // true * ``` */ export declare function initEnv(): IEnv; export declare const initEnvInPixui: () => { isPixui: boolean; }; /** * 挂载统一的eBus,所有实例共用一个 * @param app Vue3 应用实例 */ export declare const initGlobalVue3EBus: (app: any) => any; /** * 同步最新版本的更新日志 * @param {object} params 参数 * @param {string} params.changelogPath 源 change-log路径 * @param {string} params.docChangelogPath 文档 change-log 路径 * @param {string} params.packageJsonPath package.json 路径 * * @example * ```ts * const DOC_CHANGE_LOG_PATH = './docs/CHANGELOG.md'; * const SOURCE_CHANGE_LOG_PATH = './CHANGELOG.md'; * * insertDocChangeLog({ * changelogPath: SOURCE_CHANGE_LOG_PATH, * docChangeLog: DOC_CHANGE_LOG_PATH, * packageJsonPath: './package.json', * }); * ``` */ export declare function insertDocChangeLog({ changelogPath, docChangelogPath, packageJsonPath, }: { changelogPath: string; docChangelogPath: string; packageJsonPath: string; }): void; /** * 向页面 body 中插入隐藏的 HTML 元素 * 如果已存在相同 id 的元素,会先移除再插入新的 * @param options - 配置选项 * @param options.id - div 元素的 id * @param options.content - HTML 内容 * @example * ```ts * insertHtml({ * id: 'hidden-content', * content: '
隐藏的内容
' * }); * ``` */ export declare function insertHtml({ id, content, }: { id: string; content: string; }): void; /** * 向页面 head 中插入 style 标签 * 如果已存在相同 id 的 style 标签,会先移除再插入新的 * @param options - 配置选项 * @param options.id - style 标签的 id * @param options.content - CSS 样式内容 * @example * ```ts * insertStyle({ * id: 'custom-style', * content: '.my-class { color: red; }' * }); * ``` */ export declare function insertStyle({ id, content, }: { id: string; content: string; }): void; declare type IOptions = Record; declare type IPage = any; export declare type IParsedConfigItem = { source: string; target: string; sourceName: string; sourceType: IImportType; targetName: string; targetType: IImportType; }; declare type IPostFileOptions = { host: string; port: string; path: string; method?: string; }; declare interface IPreData { [key: string]: { name: string; value: ValueType; }; } declare type IPublishOptions = IPostFileOptions & { publishEnv?: string; publishTargetDir?: string; fileTar?: string; fileDir?: string; }; declare type IPurgeMethod = 'invalidate' | 'delete'; declare type IPurgeType = 'purge_url' | 'purge_prefix' | 'purge_host' | 'purge_all' | 'purge_cache_tag'; /** * rainbow 模式的额外参数 */ declare interface IRainbowAuditorOptions { /** 项目名 */ projectName: string; /** 子工程名 */ subProjectName: string; /** minimatch 方法 */ minimatch: Function; } declare type IRemoteConfig = { key: string; value: string; valueType: RainbowKeyValueType; }; declare type IRemoteInstances = Array<{ templateId: string; versionName: string; version: number; pipelineId: string; pipelineName: string; updateTime: number; hasPermission: boolean; status: string; }>; export declare interface IReplaceAliasOptions { /** 项目根目录(绝对路径) */ rootDir: string; /** alias 映射关系:alias => 对应的真实目录(相对于项目根目录) */ aliasMap: Record; /** 需要扫描的目录列表(相对于项目根目录) */ scanDirs: Array; /** 需要扫描的根目录文件(相对于项目根目录) */ scanRootFiles?: Array; /** 支持的文件扩展名,默认 ['.vue', '.js', '.ts', '.less', '.css', '.scss'] */ supportedExtensions?: Array; } export declare type IReplaceConfig = { importedList: Array; source: string | Array; target: string; }; declare interface IReplaceResult { replaced: boolean; error: string | null; } declare type IReportArr = Array<{ code_specification_score: number; code_security_score: number; codecc_url: string; project_name: string; owners: string; }>; declare interface IRequest { (): Promise; resolve?: (...args: any) => any; reject?: (...args: any) => any; } declare interface IRequestInfo { bgName: string; centerName: string; groupName: string; } declare type IRoute = { name?: string; path?: string; meta?: IMeta; }; declare interface IRumSecretItem { rumSecretId: string; rumSecretKey: string; } /** * 判断是否数组 * @param {Array} arg * @returns {Boolean} */ export declare function isArray(arg: string): boolean; /** 判断是否是普通浏览器 */ export declare function isBrowserInPixui(): boolean; /** * 判断数据是不是时间对象 * @param {any} value - 输入数据 * @returns {boolean} 是否是时间对象 * * @example * * isDate(1) * * // => false * * isDate(new Date()) * * // => true */ export declare function isDate(value: any): boolean; /** * 判断值是否已定义(不为 undefined 和 null) * @param value - 输入数据 * @returns 是否已定义 * @example * ```ts * isDef(0); // true * isDef(''); // true * isDef(null); // false * isDef(undefined); // false * ``` */ export declare function isDef(value: any): boolean; export declare function isDirectory(filePath?: string): boolean; declare interface ISearchInfo { prefix: string; } declare interface ISecretInfo { appCode: string; appSecret: string; devopsUid: string; } declare interface ISecretInfo_2 { accessToken: string; clientId: string; openId: string; } declare interface ISecretInfo_3 { appID?: string; appId?: string; userID?: string; userId?: string; secretKey: string; envName: string; groupName: string; } declare interface ISecretInfo_4 { appID: string; userID: string; secretKey: string; groupName: string; envName: string; } /** * 判断是否合法的邮箱号码 * @param {String} email 待检测的邮箱号码 */ export declare function isEmail(email: string): boolean; declare interface ISendReq { chatId: string | Array; webhookUrl: string; } /** * 判断是否外部资源 * @param {string} path * @returns {Boolean} */ export declare function isExternal(path: string): boolean; /** * 判断数据是不是函数 * @param {any} value - 输入数据 * @returns {boolean} 是否是函数 * * @example * * isFunction(1) * * // => false * * isFunction(()=>{}) * * // => true */ export declare function isFunction(value: any): boolean; /** * 判断是否合法的身份证号 * 除了基本的格式校验外,还检查了第18位是否合法,方法如下: * - 逆序排列,放到数组 list 中 * - x/X 代表数字10 * - 遍历 list,累加 `item * ((2 ** index) % 11)`,item 为list的每一位,index为下标值 * - 将上一步的累加和余11,判断是否等于1 * * @param {string} idCard 输入字符串 * @example * isIdCard('123') * // false * * isIdCard('34052419800101001X') * // true */ export declare function isIdCard(idCard: string | number): boolean; declare type ISignMethod = 'sha256' | 'sha1'; /** * 判断 URL 是否为图片地址 * 根据文件扩展名判断(jpeg、jpg、gif、png、svg、webp、jfif、bmp、dpg) * @param url - URL 地址 * @returns 是否为图片 URL * @example * ```ts * isImageUrl('https://example.com/image.jpg'); // true * isImageUrl('https://example.com/video.mp4'); // false * ``` */ export declare function isImageUrl(url: any): boolean; export declare function isInCronExpression(cronExpression: string): boolean; /** * Checks if `value` is a valid array-like index. * * @param {*} value The value to check. * @param {number} [length=MAX_SAFE_INTEGER] The upper bounds of a valid index. * @returns {boolean} Returns `true` if `value` is a valid index, else `false`. */ export declare function isIndex(value: any, length?: number): boolean; export declare function isInTimeRange({ daysOfWeek, start, end, now, }: { daysOfWeek: Array; start: string; end: string; now?: Date; }): boolean; /** * 判断数组是否全部相等 * @param {Array} list - 数组 * @returns {Boolean} 是否全部相等 * * @example * isListAllEqual([0, 0, 0]) * * // true * * isListAllEqual([0, 0, 2]) * * // false */ export declare function isListAllEqual(list?: Array): boolean; /** * 判断是否合法的手机号 * @param {String} phone 待检测的手机号 */ export declare function isMobile(phone: string): boolean; /** * 判断字符串是否为数字格式 * 支持整数和小数 * @param value - 输入值 * @returns 是否为数字格式 * @example * ```ts * isNumber('123'); // true * isNumber('123.45'); // true * isNumber('abc'); // false * ``` */ export declare function isNumber(value: any): boolean; /** * 判断是否为对象或函数 * @param x - 输入数据 * @returns 是否为对象或函数 * @example * ```ts * isObj({}); // true * isObj(() => {}); // true * isObj(null); // false * ``` */ export declare function isObj(x: any): boolean; /** * 判断是否为对象类型 * @param val - 输入数据 * @returns 是否为对象 * @example * ```ts * isObject({}); // true * isObject([]); // true * isObject(null); // false * ``` */ export declare function isObject(val: any): boolean; export declare const isObjectEqual: (obj1: unknown, obj2: unknown) => boolean; /** 判断是否是 PixUI */ export declare function isPixUI(): boolean; /** * 判断数据是否为普通对象 * 排除 null 和数组,只返回纯对象 * @param val - 输入数据 * @returns 是否为普通对象 * @example * ```ts * isPlainObject({}); // true * isPlainObject([]); // false * isPlainObject(null); // false * ``` */ export declare function isPlainObject(val: any): boolean; /** * 判断数据是否为 Promise 对象 * 检查对象是否有 then 和 catch 方法 * @param val - 输入数据 * @returns 是否为 Promise 对象 * @example * ```ts * isPromise(Promise.resolve()); // true * isPromise({}); // false * ``` */ export declare function isPromise(val: any): boolean; /** * 判断是否合法的QQ号码 * @param {String} qq 待检测的qq号 */ export declare function isQQNumber(qq: any): boolean; /** * 判断数据是不是正则对象 * @param {any} value - 输入数据 * @returns {boolean} 是否是正则对象 * * @example * * isRegExp(1) * * // => false * * isRegExp(/\d/) * * // => true */ export declare function isRegExp(value: any): boolean; /** * 判断是否是同一天 * @param {number} date1 时间戳 * @param {number} date2 时间戳 * @returns 是否相同 * @example * ```ts * isSameDay(1702613769418, 1702613769419) // true * ``` */ export declare function isSameDay(date1: number, date2: number): boolean; /** * 判断两个日期是否属于同一周 * * 原理:把两个日期均转换到周一,比较转换后的两日期是否相同。 * * @param {number} date1 第1个时间戳 * @param {number} date2 第2个时间戳 * @returns {boolean} 是否是同一周 * @example * * isSameWeek(1601308800000, 1601395200000) * * // true * * isSameWeek(1601308800000, 1601913600000) * * // false */ export declare function isSameWeek(date1: number, date2: number): boolean; /** 判断是否是模拟器 */ export declare function isSimulatorInPixui(): boolean; /** * 判断是否字符串 * @param {string} str * @returns {Boolean} */ export declare function isString(str: any): boolean; /** * 判断当前浏览器是否支持 webp * @returns {Promise }是否支持 */ export declare const isSupportedWebp: () => () => any; /** * 判断是否合法的电话号码 * @param {String} tel 待检测的电话号码 */ export declare function isTel(tel: string): boolean; export declare const isTestEnvInPixui: () => boolean; /** * 判断 URL 是否为视频地址 * 根据文件扩展名判断(mp4、mpg、mpeg、dat、asf、avi、rm、rmvb、mov、wmv、flv、mkv) * @param url - URL 地址 * @returns 是否为视频 URL * @example * ```ts * isVideoUrl('https://example.com/video.mp4'); // true * isVideoUrl('https://example.com/image.jpg'); // false * ``` */ export declare function isVideoUrl(url: any): boolean; /** * 判断当前操作系统是否为 Windows * @returns 如果是 Windows 系统返回 true,否则返回 false * @example * ```ts * if (isWindows()) { * console.log('当前运行在 Windows 系统上'); * } * ``` */ export declare function isWindows(): boolean; declare interface ITemplateReq { projectId: string; templateId: string; host: string; secretInfo: ISecretInfo; } export declare type IterativeComponentMap = Record>; declare type ITestList = Array<{ fail: number; title: string; err: { estack?: string; }; }>; export declare type IUploaderOptions = { requestHashUrl?: string | Function; uploadFileKey?: string; uploadUrlPrefix?: string; }; declare interface IUploadResult { subPackageInfo: Array<{ name: string; size: number; }>; } export declare class JsDocHandler { /** * 初始化并运行 * @static * @param {object} options 配置 * @param {string} [options.docsPath] 文档所在目录位置,默认为`./docs` * @param {string} [options.author] 作者,默认为空 * @param {string} [options.extraCss] 额外插入的css,默认为`.nav-separator`的一些样式 * @param {string} [options.navHandler] 处理API所在文件的方法 * @param {boolean} [options.isHandleNav] 是否处理导航栏,即插入文件名进行分隔,默认为false * @returns {object} JsDocHandler实例 * @example * * JsDocHandler.init({ * author: 'novlan1', * docsPath: './docs', * extraCss: '.some-class{}', * navHandler(nav) { * * } * }) * */ static init(options: IJSDocOptions): JsDocHandler; extraCss: string; extraScript: string; author: string; docsPath: string; navHandler: Function; isHandleNav: boolean; fs: fs; path: PlatformPath; /** * 处理jsdoc的脚本 * 1. 增加导航栏的分隔符 * 2. 增加css * 3. 处理footer * @constructor * @param {object} options 配置 * @param {string} [options.docsPath] 文档所在目录位置,默认为`./docs` * @param {string} [options.author] 作者,默认为空 * @param {string} [options.extraCss] 额外插入的css,默认为`.nav-separator`的一些样式 * @param {string} [options.extraScript] 额外插入的script * @param {Function} [options.navHandler] 处理API所在文件的方法 * @param {boolean} [options.isHandleNav] 是否处理导航栏,即插入文件名进行分隔,默认为false */ constructor(options?: IJSDocOptions); run(): void; getFs(): fs; getGlobalSourceMap(): Record; /** * 获取sourceMap,形如: * ```ts * { * NUMBER_CHI_MAP: 'base/number/number.ts', * parseFunction: 'base/function/function.ts', * flatten: 'base/list/list.ts', * } * ``` * @private * @param {string} content * @returns {object} sourceMap */ getSourceMap(file: string): Record; handleEveryHtml(sourceMap: Record, author: string): void; parseSourceMap(sourceMap: Record): Record; getParsedHtml(content: string, sourceMap: Record, author: string): string; appendCSS(extra: string): void; finished(): void; } export declare type JSErrorFile = Record; export declare function jsonpRequest({ url, callback, errorCallback, timeout, }: { url: string; callback: (data: any) => void; errorCallback?: (error: string) => void; timeout?: number; }): () => void; /** * json 转 excel * @param {object} params 参数 * @example { workbook, worksheet } * * const jsonData = [ * { id: 1, name: '2', age: '3' }, * { id: 1, name: '2', age: '3' }, * ]; * * jsonToExcel({ * jsonData, * outputPath: CONFIG.outputFilePath, * options: { * header: ['id', 'name', 'age'], // 可选:自定义表头顺序 * skipHeader: false, // 可选:是否跳过表头行 * }, * sheetName: 'addedData', * }); */ export declare function jsonToExcel({ jsonData, outputPath, options, sheetName, overwrite, }: { jsonData: Array>; outputPath: string; options?: Record; sheetName?: string; overwrite?: boolean; }): { workbook: WorkBook; worksheet: WorkSheet; }; /** * 除保留参数外,一律移除 * @param {string} url 地址 * @param {string} removeKeyArr 待保留的参数名集合 * @returns 重新拼接的地址 * @example * const url = keepUrlParams('http://www.test.com?a=1&b=2&c=3#/detail?d=4', ['a', 'd']); // 'http://www.test.com/#/detail?a=1&d=4' */ export declare function keepUrlParams(url: string | undefined, keepKeyArr: string[], forceHistoryMode?: boolean): string; declare const LANG_NAME_TO_TI18N_KEY: Record; export { LANG_NAME_TO_TI18N_KEY as DEFAULT_LANG_NAME_TO_TI18N_KEY } export { LANG_NAME_TO_TI18N_KEY } /** * 拉起 DDZ * @param {object} params 拉起参数 * @param {string} params.seriesId series id * @param {string} params.gameId game id * @param {string} params.uin uin * @param {object} [params.context] 上下文,可传入组件实例 this * @param {object} [params.qrCodeLib] qrcode * @param {object} [params.dialogHandler] 弹窗 handler * @param {object} [params.otherDialogParams] 弹窗的其他参数 * @param {string} [params.wxJSLink] wx js link * @param {object} [params.env] 环境对象 * @returns Promise * * @example * ```ts * launchDDZGameRoom({ * seriesId: '12', * gameId: '123', * uin: '222', * }) * ``` */ export declare const launchDDZGameRoom: ({ seriesId, gameId, uin, context, qrCodeLib, dialogHandler, otherDialogParams, wxJSLink, env, }: { gameId: string; seriesId: string; uin: string; } & IBaseLaunchParams) => Promise; /** * 拉起 GN * @param {object} params 拉起参数 * @param {string} params.roomId 房间 Id * @param {string} params.roomPwd 房间 Pwd * @param {object} [params.context] 上下文,可传入组件实例 this * @param {object} [params.qrCodeLib] qrcode * @param {object} [params.dialogHandler] 弹窗 handler * @param {object} [params.otherDialogParams] 弹窗的其他参数 * @param {string} [params.wxJSLink] wx js link * @param {object} [params.env] 环境对象 * @returns Promise * * @example * ```ts * launchGNGameRoom({ * roomId: '12', * roomPwd: '123' * }) * ``` */ export declare function launchGNGameRoom({ roomId, roomPwd, context, qrCodeLib, dialogHandler, otherDialogParams, wxJSLink, env, }: IBaseLaunchParams & { roomId: string; roomPwd: string; }): Promise; /** * 拉起 GP * @param {object} params 拉起参数 * @param {string} params.roomId 房间 Id * @param {string} params.roomPwd 房间 Pwd * @param {string} params.source 来源 * @param {string} [params.wxJSLink] wx js link * @param {object} [params.env] 环境对象 * @param {object} [params.useGPHelperSchemePrefix] 是否使用特殊 scheme * @param {object} [params.justLaunchGame] 是否仅拉起 app,不进入房间 * @returns Promise * * @example * ```ts * launchGPGameRoom({ * roomId: '12', * roomPwd: '123' * }) * ``` */ export declare function launchGPGameRoom({ roomId, roomPwd, source, wxJSLink, env, useGPHelperSchemePrefix, useTrialSchemePrefix, justLaunchGame, }: { roomId: string; roomPwd: string; source?: string | number; wxJSLink?: string; env?: Record; useGPHelperSchemePrefix?: boolean; useTrialSchemePrefix?: boolean; justLaunchGame?: boolean; }): Promise; export declare function launchMiniProgramInGame({ appId, path, type, isWxMp, }: { appId?: string | undefined; path?: string | undefined; type?: number | undefined; isWxMp?: boolean | undefined; }): void; /** * 拉起 MJ * @param {object} params 拉起参数 * @param {string} params.seriesId series id * @param {string} params.gameId game id * @param {string} params.uin uin * @param {object} [params.context] 上下文,可传入组件实例 this * @param {object} [params.qrCodeLib] qrcode * @param {object} [params.dialogHandler] 弹窗 handler * @param {object} [params.otherDialogParams] 弹窗的其他参数 * @param {string} [params.wxJSLink] wx js link * @param {object} [params.env] 环境对象 * @returns Promise * * @example * ```ts * launchMJGameRoom({ * seriesId: '12', * gameId: '123', * uin: '222', * }) * ``` */ export declare function launchMJGameRoom({ seriesId, gameId, uin, context, qrCodeLib, dialogHandler, otherDialogParams, wxJSLink, env, }: IBaseLaunchParams & { gameId: string; seriesId: string; uin: string; }): Promise; /** * 统计代码库变更情况。分析多个项目的 Git 提交记录,生成统计数据并可选上传到 COS * @param analyzeList - 要分析的项目列表 * @param saveDataDir - 保存统计数据的本地目录 * @param cosInfo - COS 上传配置信息(可选) * @param cosInfo.secretId - 腾讯云 SecretId * @param cosInfo.secretKey - 腾讯云 SecretKey * @param cosInfo.bucket - COS 存储桶名称 * @param cosInfo.region - COS 区域 * @param cosInfo.dir - COS 目录路径 * @param analyzeBlackList - 需要排除的目录黑名单(可选) * @returns {Promise} - 返回每个项目的统计结果数组 * @example * ```ts * libraryChangeStatistics({ * analyzeList: [ * { root: '/path/to/repo', project: 'my-project', git: 'https://...' } * ], * saveDataDir: '/tmp/stats', * cosInfo: { * secretId: 'xxx', * secretKey: 'xxx', * bucket: 'my-bucket', * region: 'ap-guangzhou', * dir: 'stats' * }, * analyzeBlackList: ['node_modules', 'dist'] * }).then(result => { * console.log('统计完成:', result); * }); * ``` */ export declare function libraryChangeStatistics({ analyzeList, saveDataDir, cosInfo, analyzeBlackList, }: { analyzeList: Array; saveDataDir: string; cosInfo?: { secretId: string; secretKey: string; bucket: string; region: string; dir: string; }; analyzeBlackList?: string[]; }): Promise<{ data: Array; project: (typeof analyzeList)[number]; cdnLink: string; }[]>; /** * 动态加载CSS * @param {string} url CSS链接 * @example * * loadCSS('xxx.css') */ export declare function loadCSS(url: string): void; /** * 加载样式代码块,会将样式代码包裹在 style 标签内,并加载到当前页面中 * @param {string} code 样式代码 * @param {string} className 类名 * * @example * * ```ts * loadCssCode( * '.press__cover { color: red; }', * 'load-css-code' * ); * ``` */ export declare function loadCssCode(code: string, className: string): void; /** * 用 dotenv-expand 加载环境变量 * @param file 文件路径,默认 .env.local * @param param 参数 * * @example * ```ts * loadEnv(); * * loadEnv('.env'); * * loadEnv('.env.local', { * debug: false, // 是否打印日志,默认 true * }); * ``` */ export declare function loadDotenv(file?: string, options?: { debug?: boolean; }): void; /** * 以 Callback 的方式加载 js 文件 * @param {String} src js文件路径 * @param {Function|Object} callback 加载回调 * @param {String} charset 指定js的字符集 * @param {Object} context Callback context */ export declare const loader: (src: string, callback: any, charset?: string, context?: null) => void; /** * 以 Promise 或者 Callback 的方式加载 js 文件,取决于是否传递 Callback * @param {string} url js文件路径 * @param {function} [cb] 回调 * @returns {Promise} promise */ export declare const loaderUnity: (source: string, cb?: Function, ...args: Array) => void | Promise; /** * 以 Promise 的方式加载 js 文件 * @param {string} url js文件路径 * @returns {Promise} promise */ export declare function loadJS(url: string): Promise; /** * 加载多个样式文件,并在加载前移除具有相同类名的文件 * @param {array} urls 外链地址列表 * @param {string} urlClass 外链类名 * * @example * * ```ts * loadStyles(['https://a.com/b.css'], 'load-style'); * ``` */ export declare function loadStyles(urls: Array, urlClass: string): void; /** * 加载 vConsole * @param {Object} [options = {}] vConsole 选项 * @param {Array} [plugins = []] 插件列表 * @returns {Promise} vConsole 实例 * * @example * ```ts * loadVConsole() * ``` */ export declare function loadVConsole(options?: Record, plugins?: Array): Promise; export declare function localPublish(options: IPublishOptions): Promise; export declare enum LocationFlagInPixui { LocationSuccess = 1, LocationNoPermission = 2, LocationFailed = 3 } /** * 输出日志信息 * 带有信息图标的日志输出 * @param content - 日志内容 * @param args - 额外参数 * @example * ```ts * log('正在处理...', 'file.ts'); * ``` */ export declare function log(content: string, ...args: string[]): void; /** * 通过 intl 登录 * @param {Options} options 参数 * @example * * ```ts * function loginIntl() { * const checkLoginAPI = res => new Promise((resolve, reject) => { * getScheList({ * query: { * ...INTL_CONFIG.extraQueryObject, * appid: INTL_CONFIG.gameID, * channelid: res.channel_info?.channelId, * }, * }).then((res) => { * resolve(res); * }) * .catch((err) => { * reject(err); * }); * }); * * return loginByIntl({ * cookieDomain: COOKIE_DOMAIN, * env: INTL_CONFIG.env, * gameID: INTL_CONFIG.gameID, * appID: INTL_CONFIG.appID, * webID: INTL_CONFIG.webID, * checkLoginAPI, * }); * } * * ``` */ export declare function loginByIntl(options: Options): Promise; /** * 用户登录(初始化游戏accToken等字段) */ export declare const loginInPixui: () => Promise; /** * 首字母小写 * @param {string} str 输入字符串 * @returns {string} 输出字符串 * @example * * lowerInitial('GroupId') * * // groupId */ export declare function lowerInitial(str: string): string; /** * 将语言名称映射为 ti18n key * @param name Excel 首行的语言名称 * @param langNameMapping 语言名称到 ti18n key 的映射表,默认使用 LANG_NAME_TO_TI18N_KEY * @returns 对应的 ti18n key,无法识别返回 null */ export declare function mapLangNameToKey(name: string | null | undefined, langNameMapping?: Record): Ti18nKey | null; export declare function matchParams(rawPath?: string, params?: Record): string; export declare const merge: (object: any, ...sources: any) => any; /** * 绘制多张图 * @param {object} config 输入参数 * @param {Array} config.imgs base64图片列表 * @returns {string} 图片url * * @example * * mergeMultiCanvasPic({ * imgs: [img, img2, img3], * }) */ export declare function mergeMultiCanvasPic({ imgs, }: { imgs: Array; }): Promise; /** * 88.合并两个有序数组 * * https://leetcode.cn/problems/merge-sorted-array/description/?envType=study-plan-v2&envId=top-interview-150 * * 双指针解法 * - 将两个数组看成队列,每次从数组头部取出较小数字放到结果中 * * - 时间复杂度 O(m + n) * - 空间复杂度 O(m + n) * */ export declare function mergeTwoSortedArrayV1(nums1?: number[], nums2?: number[], m?: number, n?: number): number[]; /** * 88.合并两个有序数组 * * https://leetcode.cn/problems/merge-sorted-array/description/?envType=study-plan-v2&envId=top-interview-150 * * 逆向双指针解法 * - 指针初始位置在尾部,每次向前移动 * - 不用临时数组 temp,因为不用担心前面的被覆盖 * * - 时间复杂度 O(m + n) * - 空间复杂度 O(1) * */ export declare function mergeTwoSortedArrayV2(nums1?: number[], nums2?: number[], m?: number, n?: number): number[]; declare type MessageType = string | { content: string; link?: string; label?: string; isTitle?: boolean; }; /** * 递归创建目录(同步方法) * 如果目录已存在则直接返回,否则递归创建父目录 * @param dirname - 要创建的目录路径 * @returns 创建成功返回 true * @example * ```ts * mkDirsSync('/path/to/new/directory'); * ``` */ export declare function mkDirsSync(dirname: string): boolean; export declare function modifyAutoProtectedBranchRules({ projectName, baseUrl, privateToken, rules, shouldUpdateExistingBranches, }: { projectName: string; baseUrl: string; privateToken: string; rules: string; shouldUpdateExistingBranches?: boolean; }): Promise; declare interface ModifyConfigParam { keyValue: { key: string; value: string; }; valueType: ValueType_2; secretInfo: ISecretInfo_3; } export declare function modifyProtectedBranchRule({ projectName, privateToken, baseUrl, ruleId, form, }: { projectName: string; privateToken: string; baseUrl: string; ruleId: number; form: ProtectedRuleForm; }): Promise>; export declare class MorsePwd { /** * 初始化 * @static * @param {Object} options 选项 * @param {Array} options.pwd 密码 * @param {Function} options.cb 成功回调 * @param {Boolean} options.quiet 是否安静模式(不打印日志) * @param {number} options.holdTime 等待多久后就恢复原位 * @param {'H5' | 'h5' | 'mp' | 'MP'} options.envType 环境类型 * @param {String} options.selector h5模式下的选择器 * * @example 小程序环境 * * * * @example H5环境 * * * @returns {Object} MorsePwd实例 */ static init(options: IMorsePwd): MorsePwd; pwd: Array; cb: Function; holdTime: number; quiet: Boolean; selector?: keyof HTMLElementTagNameMap; envType?: 'H5' | 'h5' | 'mp' | 'MP'; clickCode: number; longPressCode: number; curIdx: number; holdTimer: any; h5Dom: any; longPressTimer: any; isLongTouch: Boolean; /** * 摩斯密码初始化 * @constructor * @param {Object} options 选项 * @param {Array} options.pwd 密码 * @param {Function} options.cb 成功回调 * @param {Boolean} options.quiet 是否安静模式(不打印日志) * @param {number} options.holdTime 等待多久后就恢复原位 * @param {'H5' | 'h5' | 'mp' | 'MP'} options.envType 环境类型 * @param {String} options.selector h5模式下的选择器 */ constructor(options: IMorsePwd); bindEvent(): void; onTouchStart(): void; onTouchEnd(): void; onTouchMove(): void; /** * 清除监听事件 * @example * beforeDestroy() { * this.morsePwd.clear(); * } */ clear(): void; operation(type: number): void; reset(): void; click(): void; suc(): void; longPress(): void; log(...args: Array): void; } export declare const morsePwdMixin: (pwd: number[], cb: Function) => any; export declare class MpCI { ciLib: any; options: OptionsType; projectCI: any; savePreviewPath: any; appId: string; appName: string; type: string; root: string; ignores: Array; 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; tryUpload(): Promise; preview(): Promise; /** * 预览 */ tryPreview(): Promise; /** * 上传预览图片到COS */ uploadPreviewImg(previewResult: IUploadResult): Promise; getCosKey(): string; getCOSFilePath(): string; /** * 发送机器人消息 */ sendRobotMsg(hasImg?: boolean): Promise; uploadAndPreview(): Promise; uploadFiles(files: Array<{ key: string; path: string; }>): Promise; } export declare function mpUploadAndReport({ branch, env, root, rainbowConfigKey, rainbowAppId, rainbowEnvName, rainbowGroupName, rdHost, bkStartType, bkBuildUrl, bkStartUserName, bkPipelineId, commitInfo, version, buildDesc, }: Record): Promise; export declare function mpUploadAndReportByOptions(options: Record): Promise; export declare function networkHookInPixui(): void; /** * 延迟执行函数,等待下一个渲染帧 * 使用 setTimeout 延迟 33ms(约一帧的时间),返回 Promise * @returns {Promise} - 返回 Promise,resolve 值为 1 * @example * ```ts * // 等待下一帧执行 * await nextTick(); * console.log('下一帧执行'); * * // 或使用 then * nextTick().then(() => { * console.log('下一帧执行'); * }); * ``` */ export declare const nextTick: () => Promise; /** * 获取 Promise 化的 HTTP GET 请求方法 * 将 request.get 方法转换为返回 Promise 的异步函数 * @returns Promise 化的 GET 请求函数 * @example * ```ts * const get = nodeGet(); * const response = await get('https://api.example.com/data'); * ``` */ export declare function nodeGet(): Function; /** * 获取 Promise 化的 HTTP POST 请求方法 * 将 request.post 方法转换为返回 Promise 的异步函数 * @returns Promise 化的 POST 请求函数 * @example * ```ts * const post = nodePost(); * const response = await post({ * url: 'https://api.example.com/data', * json: { key: 'value' } * }); * ``` */ export declare function nodePost(): Function; /** * 获取 Promise 化的 HTTP PUT 请求方法 * 将 request.put 方法转换为返回 Promise 的异步函数 * @returns Promise 化的 PUT 请求函数 * @example * ```ts * const put = nodePut(); * const response = await put({ * url: 'https://api.example.com/data/123', * json: { key: 'updated value' } * }); * ``` */ export declare function nodePut(): Function; /** * 格式化路径 * @param path 文件路径,或目录路径 * @returns 格式化后的路径 * @example * ```ts * normalizePath('xxx/xxx/xxx'); * * normalizePath('xxx\\xxx\\xxx'); * ``` */ export declare const normalizePath: (path: string) => string; export declare function npmInstallTip({ packageName, packageLink, packagePostfix, packagePostfixEn, feedbackList, }: { packageName: string; packageLink: string; packagePostfix: string; packagePostfixEn: string; feedbackList: Array; }): void; /** * * 阿拉伯数字和中文数字映射表,0 - 32 * @type {object} * @example * * console.log(NUMBER_CHI_MAP[1]); * // '一' * * console.log(NUMBER_CHI_MAP[2]); * // '二' */ export declare const NUMBER_CHI_MAP: { 0: string; 1: string; 2: string; 3: string; 4: string; 5: string; 6: string; 7: string; 8: string; 9: string; 10: string; 11: string; 12: string; 13: string; 14: string; 15: string; 16: string; 17: string; 18: string; 19: string; 20: string; 21: string; 22: string; 23: string; 24: string; 25: string; 26: string; 27: string; 28: string; 29: string; 30: string; 31: string; 32: string; }; /** * 去掉对象中的某些属性 * @param {any} obj 对象 * @param {Array} fields 要去除的属性列表 * @returns 处理后的对象 * @example * ```ts * omit({ a: 1, b: 2, c: 3 }, ['a']) * // { b: 2, c: 3 } * ``` */ export declare function omit(obj: T, fields: K[] | readonly K[]): Omit; export declare function OneClickReleaseRainbowTask({ secretInfo, versionName, creator, updators, approvers, type, description, }: { secretInfo: ISecretInfo_3; versionName: string; creator: string; updators: string; approvers: string; type?: number; description?: string; }): Promise; export declare interface OpenLocation { lat?: string; lng?: string; name?: string; address?: string; scale?: number; context?: any; route?: string; } /** * 打开地图,查看位置 * @param param 参数 * @returns 查看Promise * @example * ```ts * openLocationInH5({ * lat, * lng, * name, * address, * * context: this, * route: '/map' * }); * ``` */ export declare function openLocationInH5({ lat, lng, name, address, route, context, }: OpenLocation): Promise; /** * 打开地图,查看位置 * @param param 参数 * @returns 查看Promise * @example * ```ts * openLocationInMp({ * lat, * lng, * name, * address, * }); * ``` */ export declare function openLocationInMp({ lat, lng, name, address, scale, }: OpenLocation): Promise; declare function openOrFindPage(browser: any, href: string, device: DEVICE_TYPE): Promise; export declare function optimizeRobotContent({ content, maxLen, concatFn, }: { content?: string | undefined; maxLen?: number | undefined; concatFn?: ((more: number | string) => string) | undefined; }): string; declare interface Options { env: string; gameID: number; appID: string; webID: string; cookieDomain: string; checkLoginAPI: (userInfo: UserInfo) => Promise; loginDomSelector?: string; [k: string]: any; } declare type OptionsType = { ci?: any; appId: string; appName?: string; robotNumber?: number; projectPath?: string; privateKeyPath?: string; ignores?: Array; type?: string; root?: string; env?: string; buildSetting?: object; buildDesc?: string; version?: string; commitInfo?: Partial; webhookUrl?: string; chatId?: string; cosInfo?: object; errorLink?: string; pagePath?: string; searchQuery?: string; }; /** * 创建支持对象参数和分散参数的函数重载类型 * * @template T - 参数对象类型 * @template K - 参数键名数组(按顺序,支持 readonly) * @template R - 返回值类型,默认为 void * * @example * interface ShowDialogParams { * content: string; * title?: string; * } * * type ShowDialogFn = OverloadedFn; * // 等价于: * // { * // (params: ShowDialogParams): void; * // (content: string, title?: string): void; * // } */ export declare type OverloadedFn = { (params: T): R; (...args: ParamsToTuple): R; }; /** * 数字左侧加 0,直到满足长度要求 * @param {string | number} num 当前数字 * @param {number} [targetLength=2] 目标长度 * @returns {string} 新的字符串 * @example * ```ts * padZero(1, 3); // 001 * ``` */ export declare function padZero(num: number | string, targetLength?: number): string; declare namespace page { export { initBrowser, getNewPage, openOrFindPage, setUserAgent, setSessionStorage, setRoute, DEVICE_TYPE } } /** * 将对象类型转换为元组类型(分散参数) * * @template T - 参数对象类型 * @template K - 参数键名数组(按顺序,支持 readonly) * * @example * interface MyParams { * name: string; * age?: number; * city?: string; * } * * // 手动指定顺序 * type MyArgs = ParamsToTuple; * // 结果: [string, number?, string?] */ export declare type ParamsToTuple = K extends readonly [infer First, ...infer Rest] ? First extends keyof T ? Rest extends readonly (keyof T)[] ? undefined extends T[First] ? [T[First]?, ...ParamsToTuple] : [T[First], ...ParamsToTuple] : [] : [] : []; export declare function parseChangeLog({ changelogStr, targetVersion, }: { changelogStr: string; targetVersion: string; }): string; export declare function parseColorToHSV(value: string): { h: number; s: number; v: number; alpha: number; }; /** * 解析带注释的 json 文件 * @param content 原始文件内容 * @returns json数据 */ export declare function parseCommentJson(content: string): Record; export declare function parseComponentPath(filePath: string, relativePath: string): string; export declare function parseCyclomaticComplexity(report?: Record[]): StrictComplexityMetrics[]; export declare function parseEslintAndSendRobot({ mrId, mrUrl, lintReportFile, repoConfig, robotInfo, }: { mrId: string | number; mrUrl: string; lintReportFile: string; repoConfig: RepoConfigType; robotInfo: { webhookUrl: string; chatId: string; }; }): Promise | undefined; /** * 将字符串转为函数 * @param {string} func 字符串 * @returns {Function} 字符串对应的函数 * * @example * * parseFunction('()=>console.log(1)') * * // ()=>console.log(1) */ export declare function parseFunction(func: unknown): ((...args: any[]) => any) | string; /** * 解析灰度发布配置 * 将嵌套的配置对象转换为平面的映射表 * @param config - 原始配置对象 * @returns 解析后的全局灰度发布配置 * @example * ```ts * const config = { * 'project1': { * 'sub1': { * 'release': { grayVersion: '1.0.0', grayPercent: '50', cookieId: 'xxx' } * } * } * }; * const parsed = parseGrayPublishConfig(config); * // { 'project1.sub1': { grayVersion: '1.0.0', ... } } * ``` */ export declare function parseGrayPublishConfig(config?: Record>>>): IGlobalGrayPublishConfig; export declare const parseHexChannel: (hex: any) => number; export declare function parseHSLString(value: string): { h: number; s: number; v: number; alpha: number; }; export declare function parseHSVString(value: string): { h: number; s: number; v: number; alpha: number; }; export declare function parseMochaAwesomeResult(report: { results: Array<{ suites: Array<{ tests: Array<{ duration: number; pass: number; fail: number; pending: number; }>; }>; file: string; }>; }): { [k: string]: { duration: number; passes: number; failures: number; pending: number; tests: number; files: { [k: string]: { duration: number; passes: number; failures: number; pending: number; tests: number; testList: Array<{}>; }; }; }; }; export declare function parseOpenSourceReport({ reportArr, date, formattedDate, searchInfo, requestInfo, maxShowLinkNum, whiteList, filterOrgPath, }: { reportArr: IReportArr; date: string; formattedDate: string; searchInfo: ISearchInfo; requestInfo: IRequestInfo; maxShowLinkNum?: number; whiteList?: Array; filterOrgPath?: string; }): string; /** * 解析替换配置 * * @param {Array} configList 配置列表 * @returns {array} 处理后的配置列表 * * @example * ```ts * parseReplaceConfig([{ * source: '', * target: '', * }]) * ``` */ export declare function parseReplaceConfig(configList: Array): { source: string; target: string; sourceName: string; sourceType: IImportType; targetName: string; targetType: IImportType; }[]; export declare function parseRGBBracket(value: string): { h: number; s: number; v: number; alpha: number; }; export declare function parseRGBHex(value: any): { r: number; g: number; b: number; alpha: number; }; export declare function parseRobotMessage(info: MessageType, labelSeparator?: string): string; /** * 解析 H5 环境下的 SSE 数据流 * @param {Object} params - 参数对象 * @param {Function} params.success - 成功回调函数 * @param {Function} params.fail - 失败回调函数 * @param {Function} params.complete - 完成回调函数 * @param {Response} params.response - 响应对象 * @returns {Promise} 返回一个 Promise,处理 SSE 数据流 */ export declare const parseSSEChunkInH5: ({ success, fail, complete, response, }: { success: RequestParams['success']; fail: RequestParams['fail']; complete: RequestParams['complete']; response: Response; }) => Promise; /** * 解析 MP 环境下的 SSE 数据块 * @param {Object} params - 参数对象 * @param {string} params.chunk - 数据块 * @param {Fail} [params.fail] - 失败回调函数 * @param {Success} [params.success] - 成功回调函数 */ export declare const parseSSEChunkInMP: ({ chunk, fail, success, }: { chunk: string; fail?: Fail | undefined; success?: Success | undefined; }) => void; /** * 功能和上面的dateFormat/timeStampFormat类型,只是参数time可以接收多种类型,且参数cFormat用的是{y}形式 * @param {(Object|string|number)} time 输入日期 * @param {string} cFormat 时间格式 * @returns {string | null} 格式化后的日期字符串 * @example * * const date = new Date('2020-11-27 8:23:24'); * * const res = parseTime(date, 'yyyy-MM-dd hh:mm:ss') * * // 2020-11-27 08:23:24 */ export declare function parseTime(time: Date | number, cFormat: string): string | null; /** * 用大驼峰,即 PascalCase 格式,来格式化字符串 * @param str 字符串 * @returns PascalCase 的字符串 * * @example * ```ts * pascalCase('ab-cd') * // AbCd * * pascalCase('ab_cd') * // AbCd * ``` */ export declare function pascalCase(str?: string): string; declare type Path = (string | number | symbol)[]; /** * Normalize the given path string, returning a regular expression. * * An empty array can be passed in for the keys, which will hold the * placeholder key descriptions. For example, using `/user/:id`, `keys` will * contain `[{ name: 'id', delimiter: '/', optional: false, repeat: false }]`. * @ignore * @param {(string|RegExp|Array)} path * @param {Array=} keys * @param {Object=} options * @returns {!RegExp} */ export declare function pathToRegexp(path: string | RegExp | Array, keys?: Array, options?: any): any; export declare namespace pathToRegexp { var parse: parse; var compile: compile; var tokensToFunction: tokensToFunction; var tokensToRegExp: tokensToRegExp; } export declare class PollingRequest { maxRequest: number; maxPollingTime: number; timeInterval: number; timer: any; /** * 轮询 * @constructor * @param {number} [maxPollingTime=10] 最大轮询次数 * @param {number} [timeInterval=2000] 轮询间隔 * @example * * ```ts * const polling = new PollingRequest(10); * const cb = () => { * this.onGetTeamList(true); * }; * polling.polling(cb); * ``` */ constructor(maxPollingTime?: number, timeInterval?: number); /** * 重置,即取消轮询 */ reset(): void; /** * 开始轮询 * @param {function} func 轮询方法 */ polling(func: Function): void; } /** * 处理彩虹配置发布任务 * @param {object} config 配置信息 * @param {string} config.taskId 任务ID * @param {object} config.secretInfo 密钥信息 * @param {string} config.secretInfo.appId 项目Id * @param {string} config.secretInfo.userId 用户Id * @param {string} config.secretInfo.secretKey 密钥 * @param {string} config.secretInfo.envName 配置环境 * @param {string} config.secretInfo.groupName 配置组 * @param {string} config.versionName 版本名称 * @returns {Promise} 请求Promise * * @example * processRainbowReleaseTask({ * taskId: 'taskId', * secretInfo: { * appId: 'xxx', * userId: 'xxx', * secretKey: 'xxx', * envName: 'prod', * groupName: 'xxx', * }, * versionName: 'version' * }).then(() => { * * }) */ export declare function processRainbowReleaseTask({ taskId, secretInfo, versionName, }: { taskId: string; secretInfo: ISecretInfo_3; versionName: string; }): Promise<{ success: boolean; taskId: string; }>; declare interface ProjectInfo { project: string; commits: Array; commitsLength: number; analyzeDir: string; git: string; } declare interface ProtectedRuleForm { name?: string; description?: string; push_access_level?: number; merge_access_level?: number; commit_force?: boolean; commit_reset?: boolean; commit_reset_rule?: number; review_check?: boolean; commit_check?: boolean; creator_can_approve?: boolean; push_create_review?: boolean; rule_modify?: boolean; note_label?: boolean; resolved_check?: boolean; auto_create_review_pre_push?: boolean; approver_rule?: number; necessary_approver_rule?: number; suggestion_reviewer?: string; necessary_reviewer?: string; path_reviewer?: string; mr_template?: string; merge_request_must_link_tapd_tickets?: boolean; allow_merge_commits?: boolean; allow_squash_merging?: boolean; allow_rebase_merging?: boolean; default_merge_method?: number; owners_review_enabled?: boolean; initial_owners_min_count?: number; forbidden_add_necessary_reviewer?: boolean; } declare type ProvType = { text?: String; code?: String | Number; children?: Array; }; declare type ProvTypeChild = { text: String; code: String | Number; }; export declare const PUBLISH_ENV_MAP: { readonly PROD: "prod"; readonly TEST: "test"; readonly DEV_CLOUD: "devcloud"; }; /** * 发布任务 * * @param {object} config 配置信息 * @param {string} config.taskId 任务Id * @param {object} config.secretInfo 密钥信息 * @param {string} config.secretInfo.appId 项目Id * @param {string} config.secretInfo.userId 用户Id * @param {string} config.secretInfo.secretKey 密钥 * @param {string} config.secretInfo.envName 配置环境 * @param {string} config.secretInfo.groupName 配置组 * @returns {Promise} 请求Promise * * @example * publishRainbowTask({ * taskId: 'taskId', * secretInfo: { * appId: 'xxx', * userId: 'xxx', * secretKey: 'xxx', * envName: 'prod', * groupName: 'xxx', * } * }).then(() => { * * }) */ export declare function publishRainbowTask({ taskId, secretInfo, }: { taskId: string; secretInfo: ISecretInfo_3; }): Promise; export declare function purgePathCache({ secretId, secretKey, area, flushType, paths, }: { secretId: string; secretKey: string; area?: (typeof AREA_MAP)[keyof typeof AREA_MAP]; flushType: 'flush' | 'delete'; paths: string[]; }): Promise; export declare function purgeUrlCache({ secretId, secretKey, area, urls, }: { secretId: string; secretKey: string; area?: (typeof AREA_MAP)[keyof typeof AREA_MAP]; urls: Array; }): Promise; export declare function pushCopyFilesInSyncCos({ fileList, cos, workspace, }: { fileList: Array<{ key: string; path: string; relativePath: string; url: string; }>; cos: { domainDir: string; cdnPrefix: string; copyList: Array<{ source: string; copyTargetPrefix?: string; }>; }; workspace: string; }): void; export declare function pushMainlandCosFilesInSyncCos({ fileList, cos, mainLandCdnInfo, toPushMainlandFiles, }: { fileList: Array<{ key: string; path: string; relativePath: string; }>; cos: { domainDir: string; }; mainLandCdnInfo: { cdnPrefix: string; domainDir: string; }; toPushMainlandFiles: Array<{ key: string; path: string; relativePath: string; url: string; }>; }): void; export declare function pushUrlCache({ secretId, secretKey, area, urls, }: { secretId: string; secretKey: string; area?: (typeof AREA_MAP_WITH_GLOBAL)[keyof typeof AREA_MAP_WITH_GLOBAL]; urls: Array; }): Promise; /** * 查询分组配置 * @param {object} config 配置信息 * @param {object} config.secretInfo 密钥信息 * @param {string} config.secretInfo.appId 项目Id * @param {string} config.secretInfo.userId 用户Id * @param {string} config.secretInfo.secretKey 密钥 * @param {string} config.secretInfo.envName 配置环境 * @param {string} config.secretInfo.groupName 配置组 * @returns {Promise>} 分组配置 * * @example * queryGroupInfo({ * secretInfo: { * appId: 'xxx', * userId: 'xxx', * secretKey: 'xxx', * envName: 'prod', * groupName: 'xxx', * } * }).then(() => { * * }) */ export declare function queryGroupInfo({ secretInfo }: { secretInfo: ISecretInfo_3; }): Promise>; export declare function queryString(options: Record, needEncode?: boolean): string; declare const RAINBOW_VALUE_TYPE_MAP: { 1: { type: string; ext: string; }; 2: { type: string; ext: string; }; 3: { type: string; ext: string; }; 4: { type: string; ext: string; }; 5: { type: string; ext: string; }; 18: { type: string; ext: string; }; 20: { type: string; ext: string; }; }; declare type RainbowKeyValueType = keyof typeof RAINBOW_VALUE_TYPE_MAP; /** * 在区间内获取随机整数 * @param {number} min 最小值 * @param {number} max 最大值 * @returns 随机数 * * @example * ```ts * random(0, 19) // 1 * ``` */ export declare function random(min: number, max: number): number; /** * 获取随机字符串 * @param {number} length 字符串长度,默认 32 * @returns {string} 字符串 * @example * ```ts * randomString() * * randomString(16) * ``` */ export declare function randomString(e?: number): string; /** * 根据边界值修正数字 * @param {number} num 待处理的数字 * @param {number} min 边界最小值 * @param {number} max 边界最大值 * @returns {number} 处理结果 * @example * ```ts * range(12, 1, 2); // 2 * ``` */ export declare function range(num: number, min: number, max: number): number; export declare const RAW_CITY_DATA: { provData: { 11: string; 12: string; 13: string; 14: string; 15: string; 21: string; 22: string; 23: string; 31: string; 32: string; 33: string; 34: string; 35: string; 36: string; 37: string; 41: string; 42: string; 43: string; 44: string; 45: string; 46: string; 50: string; 51: string; 52: string; 53: string; 54: string; 61: string; 62: string; 63: string; 64: string; 65: string; 71: string; 81: string; 82: string; }; cityData: { 11: string[]; 12: string[]; 13: { 1: string; 2: string; 3: string; 4: string; 5: string; 6: string; 7: string; 8: string; 9: string; 10: string; 11: string; }; 14: { 1: string; 2: string; 3: string; 4: string; 5: string; 6: string; 7: string; 8: string; 9: string; 10: string; 11: string; 12: string; }; 15: { 1: string; 2: string; 3: string; 4: string; 5: string; 6: string; 7: string; 8: string; 9: string; 22: string; 25: string; 29: string; 30: string; }; 21: { 1: string; 2: string; 3: string; 4: string; 5: string; 6: string; 7: string; 8: string; 9: string; 10: string; 11: string; 12: string; 13: string; 14: string; }; 22: { 1: string; 2: string; 3: string; 4: string; 5: string; 6: string; 7: string; 8: string; 24: string; 25: string; }; 23: { 1: string; 2: string; 3: string; 4: string; 5: string; 6: string; 7: string; 8: string; 9: string; 10: string; 11: string; 12: string; 27: string; }; 31: string[]; 32: { 1: string; 2: string; 3: string; 4: string; 5: string; 6: string; 7: string; 8: string; 9: string; 10: string; 11: string; 12: string; 13: string; }; 33: { 1: string; 2: string; 3: string; 4: string; 5: string; 6: string; 7: string; 8: string; 9: string; 10: string; 11: string; }; 34: { 1: string; 2: string; 3: string; 4: string; 5: string; 6: string; 7: string; 8: string; 10: string; 11: string; 12: string; 13: string; 14: string; 15: string; 16: string; 17: string; 18: string; }; 35: { 1: string; 2: string; 3: string; 4: string; 5: string; 6: string; 7: string; 8: string; 9: string; }; 36: { 1: string; 2: string; 3: string; 4: string; 5: string; 6: string; 7: string; 8: string; 9: string; 10: string; 11: string; }; 37: { 1: string; 2: string; 3: string; 4: string; 5: string; 6: string; 7: string; 8: string; 9: string; 10: string; 11: string; 12: string; 13: string; 14: string; 15: string; 16: string; 17: string; }; 41: { 1: string; 2: string; 3: string; 4: string; 5: string; 6: string; 7: string; 8: string; 9: string; 10: string; 11: string; 12: string; 13: string; 14: string; 15: string; 16: string; 17: string; 18: string; 19: string; }; 42: { 1: string; 2: string; 3: string; 5: string; 6: string; 7: string; 8: string; 9: string; 10: string; 11: string; 12: string; 13: string; 28: string; 94: string; 95: string; 96: string; A21: string; }; 43: { 1: string; 2: string; 3: string; 4: string; 5: string; 6: string; 7: string; 8: string; 9: string; 10: string; 11: string; 12: string; 13: string; 31: string; }; 44: { 1: string; 2: string; 3: string; 4: string; 5: string; 6: string; 7: string; 8: string; 9: string; 12: string; 13: string; 14: string; 15: string; 16: string; 17: string; 18: string; 19: string; 20: string; 51: string; 52: string; 53: string; }; 45: { 1: string; 2: string; 3: string; 4: string; 5: string; 6: string; 7: string; 8: string; 9: string; 10: string; 11: string; 12: string; 13: string; 14: string; }; 46: { 1: string; 2: string; 91: string; 92: string; 93: string; 95: string; 96: string; 97: string; A25: string; A26: string; A27: string; A28: string; A30: string; A31: string; A33: string; A34: string; A35: string; A36: string; A37: string; A38: string; A39: string; }; 50: string[]; 51: { 1: string; 3: string; 4: string; 5: string; 6: string; 7: string; 8: string; 9: string; 10: string; 11: string; 13: string; 14: string; 15: string; 16: string; 17: string; 18: string; 19: string; 20: string; 32: string; 33: string; 34: string; }; 52: { 1: string; 2: string; 3: string; 4: string; 22: string; 23: string; 24: string; 26: string; 27: string; 31: string; 32: string; 33: string; 34: string; 35: string; 36: string; 37: string; }; 53: { 1: string; 3: string; 4: string; 5: string; 6: string; 7: string; 8: string; 9: string; 23: string; 25: string; 26: string; 28: string; 29: string; 31: string; 33: string; 34: string; }; 54: { 1: string; 21: string; 22: string; 23: string; 24: string; 25: string; 26: string; }; 61: { 1: string; 2: string; 3: string; 4: string; 5: string; 6: string; 7: string; 8: string; 9: string; 10: string; }; 62: { 1: string; 2: string; 3: string; 4: string; 5: string; 6: string; 7: string; 8: string; 9: string; 10: string; 11: string; 12: string; 29: string; 30: string; }; 63: { 1: string; 21: string; 22: string; 23: string; 25: string; 26: string; 27: string; 28: string; }; 64: { 1: string; 2: string; 3: string; 4: string; 5: string; }; 65: { 1: string; 2: string; 21: string; 22: string; 23: string; 27: string; 28: string; 29: string; 30: string; 31: string; 32: string; 40: string; 42: string; 43: string; 91: string; 92: string; 93: string; 94: string; }; 71: string[]; 81: string[]; 82: string[]; }; }; /** * 获取带注释的 json 文件内容 * @param file 文件路径 * @returns json数据 */ export declare function readCommentJson(file: string): Record; /** * 读取文件中环境变量的值,支持: * - NPM_TOKEN=xxx * - NPM_TOKEN = xxx * @param {string} key 环境变量的key * @param {string} filepath 保存环境变量的文件路径 * @returns {string} 环境变量的值 */ export declare function readEnvVariable(key: string, filepath: string): string; /** * 读取文件 * @param {string} file 文件地址 * @param {boolean} [isJson] 是否需要 json 反序列化 * @returns {any} 文件内容 * @example * ```ts * readFileSync('b.txt', false); * * readFileSync('b.json', true); * ``` */ export declare function readFileSync(file: string, isJson?: boolean): any; /** * 解析 JSON 字符串为对象 * 安全地解析 JSON 字符串,解析失败时输出错误信息并返回空对象 * @param content - JSON 字符串内容 * @param file - 文件路径(用于错误日志) * @returns 解析后的对象,解析失败时返回空对象 * @example * ```ts * const data = readJson('{"name":"test"}', 'config.json'); * console.log(data); // { name: 'test' } * ``` */ export declare function readJson(content: string, file: string): Record; /** * 从日志目录读取 JSON 文件 * 读取 ./log 目录下的 JSON 文件内容 * @param file - 文件名(相对于 log 目录) * @param defaultContent - 文件不存在时返回的默认内容,默认为 '{}' * @returns JSON 文件内容字符串 * @example * ```ts * const content = readJsonLog('data.json', '[]'); * ``` */ export declare function readJsonLog(file: string, defaultContent?: string): any; export declare function refreshTencentDocToken({ clientId, clientSecret, refreshToken, }: { clientId: string; clientSecret: string; refreshToken: string; }): Promise; /** * 移除CSS * * @param {string} href - CSS链接 * * @example * * removeCss('https://xxx.css') */ export declare function removeCss(href: string): void; /** * * 27.移除元素 * * https://leetcode.cn/problems/remove-element/description/?envType=study-plan-v2&envId=top-interview-150 * * 双指针。 * - 右指针 right 指向当前将要处理的元素,左指针 left 指向下一个将要赋值的位置。 * - 如果右指针不等于 val,就将右指针指向的值赋值给左指针位置,左指针右移一位。 * * * - 时间复杂度:O(n),其中 n 为序列的长度。我们只需要遍历该序列至多两次。 * - 空间复杂度:O(1)。我们只需要常数的空间保存若干变量 */ export declare function removeElementInArrayV1(nums: number[], val: number): number; /** * * 27.移除元素 * * https://leetcode.cn/problems/remove-element/description/?envType=study-plan-v2&envId=top-interview-150 * * 对撞指针。 * - 两个指针初始时分别位于数组的首尾,向中间移动遍历该序列。 * - 如果左指针 left 指向的元素等于 val,此时将右指针 right 指向的元素复制到左指针 left 的位置,然后右指针 right 左移一位。否则左指针 left 右移一位。 * * - 时间复杂度:O(n),其中 n 为序列的长度。我们只需要遍历该序列至多一次。 * - 空间复杂度:O(1)。我们只需要常数的空间保存若干变量 * * 第一种是快慢指针,第二种是对撞指针,同样是双指针,前者同向出发,因此用一个 for 循环实现遍历;后者前后出发,因此用 while 循环判断指针对撞时退出循环 */ export declare function removeElementInArrayV2(nums: number[], val: number): number; /** *移除第一个和最后一个反斜杠 * * @export * @param {string} [str=''] 输入字符串 * @returns {string} 字符串 * * @example * ```ts * removeFirstAndLastSlash('/abc/') * * 'abc' * ``` */ export declare function removeFirstAndLastSlash(str?: string): string; /** * 移除第一个反斜杠 * * @export * @param {string} [str=''] 输入字符串 * @returns {string} 字符串 * @example * ```ts * removeFirstSlash('/abc/ddd/') * * 'abc/ddd/' * ``` */ export declare function removeFirstSlash(str?: string): string; /** * 移除最后一个反斜杠 * * @export * @param {string} [str=''] 输入字符串 * @returns {string} 字符串 * * @example * ```ts * removeLastSlash('/abc/') * * '/abc' * ``` */ export declare function removeLastSlash(str?: string): string; /** * 移除 MSDK 原生回调监听器 * 取消监听原生层发送给 Web 层的消息 * @param callback - 要移除的回调函数 * @example * ```ts * const callback = (data) => console.log(data); * addMsdkNativeCallbackListener(callback); * // 稍后移除 * removeMsdkNativeCallbackListener(callback); * ``` */ export declare function removeMsdkNativeCallbackListener(callback: Function): void; /** * @export removeUrlParams * @description 移除参数 * @param {string} url 地址 * @param {string} removeKeyArr 待移除的参数名集合 * @returns 重新拼接的地址 * @example * const url = removeUrlParams('http://www.test.com/#/detail?a=1&b=2&c=3', ['a', 'b']); // 'http://www.test.com/#/detail?c=3' * const url2 = removeUrlParams('http://www.test.com?d=4&f=6#/detail?a=1&b=2&c=3', ['a', 'd']); // 'http://www.test.com/#/detail?b=2&c=3&f=6' */ export declare function removeUrlParams(url: string | undefined, removeKeyArr: string[], forceHistoryMode?: boolean): string; /** * 替换文件的 rem 单位,转为 px * @param {string} filePath 文件路径 * @example * ```ts * remToPxInFile('xxx.vue'); * ``` */ export declare function remToPxInFile(filePath: string): void; /** * 执行 alias 路径替换 * @param options - 替换配置 * @returns 替换统计信息 */ export declare function replaceAlias(options: IReplaceAliasOptions): { replacedCount: number; errorCount: number; }; /** * 替换单个文件中的 alias 引入为相对路径 */ export declare function replaceAliasInFile(filePath: string, rootDir: string, aliasMap: Record): IReplaceResult; /** * polyfill for replaceAll * * @export * * @example * * replaceAllPolyfill() */ export declare function replaceAllPolyfill(): void; /** * 替换文件内容 * 批量替换目标项目中指定文件的内容 * @param replaceList - 替换配置列表 * @param targetProject - 目标项目路径 * @example * ```ts * replaceContent({ * replaceList: [ * { * dirList: ['src/*.ts'], * from: 'old-text', * to: 'new-text' * } * ], * targetProject: '/path/to/project' * }); * ``` */ export declare function replaceContent({ replaceList, targetProject, }: { replaceList: ReplaceContentOption[]; targetProject: string; }): void; export declare type ReplaceContentOption = { list?: Array<[string, string]>; from?: string; to?: string; dirList: string | string[]; }; export declare function replaceContentSimple({ replaceList, }: { replaceList: ReplaceContentSimpleOption[]; }): void; export declare type ReplaceContentSimpleOption = { list?: Array<[string | RegExp, string]>; from?: string | RegExp; to?: string; dirList: string | string[]; }; /** * 替换引用 * * @param {string} content 输入内容 * @param {Array} parsedConfigList 替换配置 * @param {string} keyword 提前返回关键词 * @returns {string} 处理后的内容 * * @example * ```ts * replaceDependencies('', [], '@tx/pmd-vue') * ``` */ export declare function replaceDependencies(content: string, parsedConfigList: Array, keyword: string): any; declare type RepoConfigType = { domain: string; repo: string; branch: string; }; export declare function reportCoreInfoInPixUI(): Promise; declare type ReportOptions = string | { msg: string; [k: string]: string; }; declare enum ReportPlatform { NOT_KNOWN = 0, H5 = 1, MP = 2 } /** * 上报数据到研发平台 * @param {object} param 参数 * @param {object} param.data 上报数据 * @param {string} param.host 请求域名 * @param {ReportType} param.type 上报类型 * @param {ReportPlatform} param.platform 上报平台 * @returns 上报结果 */ export declare function reportToRdPlatform({ data, host, type, platform, }: { data: any; host: any; type?: ReportType; platform?: ReportPlatform; }): Promise; declare enum ReportType { PERFORMANCE = 1, BUNDLE = 2, AUTO_TEST = 3, BUNDLE_MP = 4 } declare interface ReqParam { url: string; data: object; secretInfo: ISecretInfo_3; } export declare interface RequestParams { url: string; data?: Record; success?: Success; fail?: Fail; complete?: Complete; isTestEnv?: () => boolean; } /** * 从 package.json 中解析需要打包的文件列表 * @param {object} options 配置 * @param {string} [options.root] 项目根目录,默认为 process.cwd() * @returns {Array} 文件列表 */ export declare function resolveFiles({ root, }?: { root?: string; }): any; /** * 提取链接参数,兼容hash模式和history模式,以及拼接异常情况 * @param {string} [url=''] 地址 * @param {string} [key=''] 可选,若不为空,则提取返回该key对应的参数值 * @returns 地址参数对象,或者是指定参数值 * @example * const url = 'https://igame.qq.com?name=mike&age=18#/index?from=china&home=china' * const params = resolveUrlParams(url); // { from: 'china', home: 'china', name: 'mike', age: 18 } * const paramsAge = resolveUrlParams(url, 'age'); // 18 */ export declare function resolveUrlParams(url?: string, key?: string): string | Record | undefined; export declare function reviewPipeline({ host, projectId, buildId, pipelineId, stepId, elementId, reviewUsers, status, suggest, params, accessToken, }: { host: string; projectId: string; buildId: string; pipelineId?: string; elementId?: string; stepId?: string; reviewUsers?: string[] | string; status?: 'PROCESS' | 'ABORT'; suggest?: string; params?: Array<{ chineseName?: string; desc?: string; key: string; required: boolean; value?: string; valueType: any; }>; accessToken?: string; }): Promise; /** * Converts an RGB color value to HSV * *Assumes:* r, g, and b are contained in the set [0, 255] or [0, 1]. * *Returns:* { h, s, v } in [0,1] */ export declare function rgb2hsv(r: number, g: number, b: number): { h: number; s: number; v: number; }; export declare const rgbToHex: ({ r, g, b }: { r: number; g: number; b: number; }) => string; /** * 递归删除空目录 * 从指定路径开始,递归删除所有空目录(不删除包含文件的目录) * @param tPath - 要检查和删除的目录路径 * @param level - 当前递归层级,默认为 0(根层级不会被删除) * @example * ```ts * rmEmptyDir('/path/to/check'); * ``` */ export declare function rmEmptyDir(tPath: string, level?: number): void; export declare const rmFirstAndLastSlash: typeof removeFirstAndLastSlash; /** * PostCSS 插件:将 rpx 单位转换为 px * * 基于 750 设计稿,1rpx = 0.5px。 * 内置平台判断,默认仅在 h5 平台执行。 * * @param {object} options - 配置选项 * @param {number} options.ratio - rpx 到 px 的转换比例,默认 0.5 * @param {string[]} options.platform - 在哪些平台执行,默认 ['h5'] * * @example * * ```js * // postcss.config.js * const { rpxToPxPlugin } = require('t-comm'); * * module.exports = { * plugins: [ * // 默认仅在 h5 平台执行,无需外部判断 * rpxToPxPlugin(), * // 自定义比例和平台 * rpxToPxPlugin({ ratio: 1, platform: ['h5', 'mp-weixin'] }), * ], * }; * ``` */ export declare const rpxToPxPlugin: { (options?: RpxToPxPluginOptions): { postcssPlugin: string; Declaration(decl: any): void; }; postcss: boolean; }; declare interface RpxToPxPluginOptions { /** rpx 到 px 的转换比例,默认 0.5(基于 750 设计稿) */ ratio?: number; /** 在哪些平台执行,默认 ['h5']。通过 process.env.UNI_PLATFORM 判断 */ platform?: string[]; } /** * 加了 try-catch 的 JSON.parse * @param data 传入数据 * @param defaultValue 默认值,不传则为 空对象 * @returns 解析后的数据 * * @example * * ```ts * safeJsonParse(data) * * safeJsonParse(data, {}) * * safeJsonParse(data, []) * ``` */ export declare function safeJsonParse>(data: unknown, defaultValue?: T): T; /** * node环境下,保存base64图片到文件 * @param {object} config 输入配置 * @param {string} config.imgUrl base64图片Url * @param {string} config.savePath 保存路径,最好是绝对路径 * @returns {Promise} 去掉前缀的base64图片地址 * * @example * * saveBase64ImgToFile({ * imgUrl: 'xx', * savePath: '/test.png' * }).then((base64Data) => { * console.log(base64Data) * }) * */ export declare function saveBase64ImgToFile({ imgUrl, savePath }: { imgUrl: string; savePath: string; }): Promise; /** * 将 JSON 对象保存到日志文件 * 将对象序列化为 JSON 并保存到 ./log 目录下 * @param content - 要保存的对象内容 * @param file - 文件名(相对于 log 目录) * @param needLog - 是否需要保存日志,默认为 true * @example * ```ts * saveJsonToLog({ status: 'success', data: [1, 2, 3] }, 'result.json'); * ``` */ export declare function saveJsonToLog(content: object, file: string, needLog?: boolean): void; /** * 将内容追加保存到日志文件(支持保留历史记录) * 以数组形式保存多条日志记录,每条记录包含时间戳和数据,支持限制最大记录数 * @param content - 要保存的内容 * @param file - 文件名(相对于 log 目录) * @param options - 配置选项 * @param options.needLog - 是否需要保存日志,默认为 true * @param options.max - 最大保留记录数,默认为 10 * @example * ```ts * saveJsonToLogMore({ action: 'upload', status: 'success' }, 'history.json', { * needLog: true, * max: 20 * }); * ``` */ export declare function saveJsonToLogMore(content: any, file: string, options?: { needLog?: boolean; max?: number; }): void; /** * 小程序下保存图片 * @param {string} url 图片地址 * @param {object} options 提示选项 * @example * ```ts * saveMpImage('https://xxx.png'); * ``` */ export declare function saveMpImage(url: string, options?: Partial): void; /** * 写入持久化存储localStorage。仅用于浏览器端,value里不能有循环引用 * @param {string} key 键 * @param {string} value 值 * @param {number} expireMsec 过期时间,单位毫秒 * @returns {boolean} 是否存储成功 * * @example * const res = savePersist('name', 'mike', 30 * 86400 * 1000); // true * const name = getPersist('name'); // mike * * clearPersist('name'); // true * const name2 = getPersist('name'); // undefined */ export declare function savePersist(key: string, value: string, expireMsec?: number): boolean; /** * node环境下,保存网络图片到本地 * @param {object} config 输入配置 * @param {string} config.imgUrl 网络图片地址 * @param {string} config.savePath 本地图片保存路径,建议绝对路径 * @returns {Promise} 请求Promise * * @example * * saveRemoteImgToLocal({ * imgUrl: 'xx', * savePath: './test.png' * }).then(() => { * * }) */ export declare function saveRemoteImgToLocal({ imgUrl, savePath }: { imgUrl: string; savePath: string; }): Promise; export declare class Scheduler { pendingState: Array; doingJobs: number; maxConcurrency: number; /** * 异步任务调度器,同一时间只能执行 n 个任务 * @param {number} [maxConcurrency] 最多同时执行的任务数目,默认为 2 * * @example * ```ts * let scheduler; * * export async function login({ * userId, * userSig, * tim, * }: { * userId: string; * userSig: string; * tim: IChatSDK; * }) { * if (!scheduler) { * scheduler = new Scheduler(1); * } * * return await scheduler.add(innerLogin.bind(null, { * userId, * userSig, * tim, * })); * } * ``` */ constructor(maxConcurrency?: number); add(promiseCreator: IRequest): Promise; unshift(promiseCreator: IRequest): Promise; doJob: () => void; } declare type ScoreInfoType_2 = { ProjectId: number; ProjectName: string; PagePv: number; PageUv: number; PageDuration: number; PageError: number; ApiNum: number; ApiFail: number; ApiDuration: number; StaticNum: number; StaticFail: number; StaticDuration: number; Score: number; GroupName: string; CreateUser: string; CreateTime: string; [k: string]: string | number; }; export declare type SCSSErrorFile = Record; declare type SecretInfoType = { apiKey: string; loginName: string; rumSecretId: string; rumSecretKey: string; getPwdCode: Function; encrypt: Function; }; export declare function sendEmailByTai({ prefix, paasId, paasToken, from, to, title, content, cc, bcc, emailType, bodyFormat, priority, }: { prefix: string; paasId: string; paasToken: string; from: string; to: string; title: string; content: string; cc?: string; bcc?: string; emailType?: number; bodyFormat?: number; priority?: number; }): Promise; /** * 请求开源治理数据并发送 * @param options 配置信息 */ export declare function sendOpenSourceReport({ date, chatId, webhookUrl, requestInfo, searchInfo, maxShowLinkNum, whiteList, filterOrgPath, }: { date: string | number | Date; chatId: string; webhookUrl: string; requestInfo: IRequestInfo; searchInfo: ISearchInfo; maxShowLinkNum?: number; whiteList?: Array; filterOrgPath?: string; }): Promise; /** * 获取超时的流水线列表,并发送机器人消息 * @param {object} params 参数 * @param {object} params.params 获取流水线列表参数 * @param {string} params.pipelineHost 流水线 host 地址 * @param {string} params.webhookUrl 回调地址 * @param {string} params.chatId 会话id */ export declare function sendOverTimePipelineMessage({ params, pipelineHost, webhookUrl, chatId, overTimeConfigList, mentionList, }: { params: any; pipelineHost: string; webhookUrl: string; chatId: Array; overTimeConfigList?: Array<{ label: string; value: number; }>; mentionList: string[]; }): Promise; /** * MSDK 浏览器中,向原生发送数据 * @param {string} data 发送的数据 * ```ts * sendToMsdkNative('123') * ``` */ export declare function sendToMsdkNative(data?: string): void; declare const SendToRobotTypeMap: { readonly NO_SEND: 0; readonly SEND_CHANGE: 1; readonly SEND_ALL: 2; }; /** * 获取天气信息并发送 * @param {object} options 配置 * @param {string} options.webhookUrl 机器人hook地址 * @param {string} [options.chatId] 会话Id * @param {string} [options.force] 是否在和之前获取数据相同时,也发送 * @returns {Promise} 请求Promise */ export declare function sendWeatherRobotMsg({ webhookUrl, chatId, force, }: { webhookUrl: string; chatId: string | string[]; force?: boolean; }): Promise; export declare function sendWxMpCIMessageAfterPlugin({ appName, webhookUrl, previewCodeBase64Path, bundleResult, subPackageInfo, robot, root, env, branch, compressOptions, }: { appName: string; webhookUrl: string; previewCodeBase64Path: string; bundleResult: string; subPackageInfo: string; robot: number; root: string; env: string; branch: string; compressOptions?: CompressOptions; }): Promise; /** * 发送企业微信机器人base64图片,其实就是先保存到本地,然后生成md5,最后发送 * @param {object} config 配置信息 * @param {string} config.img base64图片 * @param {string} config.chatId 会话Id * @param {string} config.webhookUrl webhook地址 * @returns {Promise} 请求Promise * @example * * sendWxRobotBase64Img({ * img: 'xxx', * chatId: 'xxx', * webhookUrl: 'xxx', * }).then(() => { * * }) * */ export declare function sendWxRobotBase64Img({ img, chatId, webhookUrl, }: { img: string; chatId: string; webhookUrl: string; }): Promise; /** * 给机器人发送图片 * @param {Object} config 配置参数 * @param {string} config.webhookUrl 钩子链接 * @param {string} config.chatId 会话id * @param {string} config.content 内容 * @param {string} config.md5Val md5内容 * @returns {Promise} 请求Promise * * @example * * sendWxRobotImg({ * webhookUrl: 'xxx', * chatId: 'xxx', * content: 'xxx', * md5Val: 'xxx' * }).then(() => { * * }) */ export declare function sendWxRobotImg({ webhookUrl, chatId, content, md5Val }: { webhookUrl: string; content: string; md5Val: string; chatId?: string; }): Promise; /** * 给机器人发送Markdown消息 * @param {Object} config 配置内容 * @param {string} config.webhookUrl - 钩子链接 * @param {string} config.chatId - 会话id * @param {string} config.content - 内容 * @param {Array} config.attachments - 附加内容 * @returns {Promise} 请求Promise * @example * * sendWxRobotMarkdown({ * webhookUrl: 'xxx', * chatId: 'xxx', * content: 'xxx', * attachments: [] * }).then(() => { * * }) */ export declare function sendWxRobotMarkdown({ webhookUrl, chatId, content, attachments, isV2, }: { webhookUrl: string; content: string; chatId?: string; attachments?: Array; isV2?: boolean; }): Promise; /** * 给机器人发送普通消息 * @param {Object} config 配置内容 * @param {string} config.webhookUrl - 钩子链接 * @param {string} config.chatId - 会话id * @param {string} config.alias - 别名 * @param {string} config.content - 内容 * @returns {Promise} Promise * * @example * * sendWxRobotMsg({ * webhookUrl: 'xxx', * chatId: 'xxx', * content: 'xxx', * alias: 'xxx', * }).then(() => { * * }) */ export declare function sendWxRobotMsg({ webhookUrl, chatId, alias, content }: { webhookUrl: string; content: string; chatId?: string; alias?: string | Array; }): Promise; export declare function set(entity: Entity, paths: Path, value: Value, removeIfUndefined?: boolean): Output; /** * 设置config * * @param {string} name * @param {*} value * * @example * setConfig('login.loginType','WXPC') */ export declare function setConfig(name: string, value: unknown): void; /** * 设置cookie * @param {string} key cookie键值 * @param {string} value cookie值 * @param {number} [hours] 过期时间,单位小时 * * @example * * setCookie('name', 'mike') */ export declare function setCookie(name: string, value: string, Hours?: number): void; /** * 设置 HTML 根元素的响应式字体大小 * 基于屏幕宽度自动调整根元素的 font-size,实现移动端响应式布局 * 以 750px 为基准,根元素 font-size = 100 * (屏幕宽度 / 750) * @example * ```ts * // 在应用启动时调用 * setHtmlResponsiveFontsize(); * // 屏幕宽度为 375px 时,根元素 font-size = 50px * // 屏幕宽度为 750px 时,根元素 font-size = 100px * ``` */ export declare function setHtmlResponsiveFontsize(): void; /** * 设置本地数据,IDE中不生效,在真机上才生效 * 数据以 app + roleId 为维度隔离存储,。存储的信息如15天不更新,会自动清除。 * @param key 键 * @param value 值 */ export declare const setLocalStorageInPixui: (key: string, value: string) => Promise; declare function setRoute(page: IPage, route?: string): Promise; declare function setSessionStorage(key: string, value: string, page: IPage): Promise; declare function setUserAgent(useragent: string, page: IPage): Promise; /** * 设置对象深层属性的值(类似 Lodash 的 _.set) * @param obj 目标对象 * @param path 属性路径(字符串或数组,如 'a.b.c' 或 ['a', 'b', 'c']) * @param value 要设置的值 * @returns 修改后的对象 */ export declare function setWithString(obj: T, path: string | Array, value: any): T; /** * 是否应该执行 standard-version * 返回0,不执行 * 返回1,执行--first-release * 返回2,执行--release-as patch * @private * @param {string} [] 命令执行目录 * @returns {number} 是否应该执行 standard-version */ export declare function shouldGenVersion(root?: string, forceGenVersion?: boolean): number; export declare function shouldInclude(branch?: string, reg?: RegExp): boolean; /** * 函数式调用组件 * @param {Object} vueInstance 页面Vue实例(一般为页面this) * @param {Object} dialogComponent 弹窗组件,支持静态导入import Dialog from '..'和动态导入const Dialog = () => import('...')两种形式 * @param {Object} dialogOptions 弹窗参数Object * @returns Promise 回调组件实例 * * @example * ```ts * function showDateTimePicker(this: any, { * onConfirm, * currentDate, * }) { * showFunctionalComponent( * this, () => import('src/local-component/ui/gp-match-horz/date-picker'), * { * currentDate, * minDate: new Date(new Date().getTime() + 30 * 60 * 1000), * onClickConfirm: (date) => { * const dateNumber = Math.floor(date.getTime()); * onConfirm(date, dateNumber); * }, * }, * ); * } * ``` */ export declare function showFunctionalComponent(vueInstance: any, dialogComponent: any, dialogOptions: Record): Promise; /** * @description 根据弹窗队列(dialogList)依次弹出 * @param {object} context Vue 页面 Vue实例上下文(一般为页面this、window.app、new Vue() 等) * @param {array} dialogList 弹窗列表 * @param {Object} dialogComponent 弹窗组件,支持静态导入 import Dialog from '..' 和动态导入 const Dialog = () => import('...') 两种形式 */ export declare function showFunctionalComponentQueue(context: any, dialogList: Array, dialogComponent: any): void; /** * 展示 vConsole * @example * ```ts * showVConsole() * ``` */ export declare function showVConsole(): void; /** * 打乱数组顺序 * * @param {Array} array - 数组 * @returns {Array} 乱序后的数组 * * @example * * shuffle([1, 2, 3, 4, 5]) * * // [3, 2, 1, 4, 5] * */ export declare function shuffle(array: Array): Array; /** * 简单的摩斯密码,只有点击 * @param param {object} 参数 * * @example * ```ts * simpleMorse({ * target: 5, // 目标值 * callback: () => console.log('test'), * timeout: 300, // 超时取消 * debug: false, * }) * ``` */ export declare function simpleMorse({ target, callback, timeout, debug, }: { callback?: Function; target?: number; timeout?: number; debug?: boolean; }): void; /** * 等待一段时间 * @func * @param {number} ms 毫秒 * @returns Promise * @example * * async function main() { * await sleep(2000) * * // 等待2秒后才会打印 * console.log('hello') * } * * main() */ export declare const sleep: (ms: number) => Promise; export declare function sliceObject(info: Record, max: number): Record; export declare function sortByStr(list: Array>, key?: string, reverse?: boolean): void; export declare function sortObjectByKey(obj: Record): Record; export declare function splitLongList(list: Array, threshold?: number, max?: number): string[][]; /** * 启动流水线 * @param {object} params 配置信息 * @param {string} params.projectId 项目ID * @param {string} params.pipelineId 流水线ID * @param {object} params.secretInfo 密钥信息 * @param {string} params.host 请求域名 * @param {object} params.data 请求数据 */ export declare function startDevopsPipeline({ projectId, pipelineId, secretInfo, host, data, }: { projectId: string; pipelineId: string; secretInfo: ISecretInfo; host: string; data: Object; }): Promise; /** * 启动流水线 * * @param {object} config 配置信息 * @param {string} config.buildId 流水线构建Id * @param {object} config.data 携带的数据 * @returns Promise * * @example * * ```ts * startPipeline({ * buildId, * data: {} * }).then(() => { * * }) * ``` */ export declare function startPipeline({ buildId, data, }: { buildId: string; data: Record; }): Promise; /** * 启动 uni-app 项目 * @param options 参数 * * @example * ```ts * startUniProject(); * * startUniProject({ * debug: false, // 默认为 true,会打印参数 * }) * ``` */ export declare function startUniProject(options?: { debug?: boolean; }): void; /** * 统计组件个数 * @example * statisticsComponent('dist/build/mp-weixin'); */ export declare function statisticsComponent(dir: string): number; /** * 统计页面个数 * @example * statisticsPages('dist/build/mp-weixin/app.json') */ export declare function statisticsPages(pagesJsonPath: string): any; declare type StrictComplexityMetrics = { readonly [K in ComplexityKey]: string; }; /** * String format template * - Inspired: * https://github.com/Matt-Esch/string-template/index.js * @param {string} string 字符串 * @param {any} args 填充选项 * @example * ```ts * stringFormat('{{likes}} people have liked this', { * likes: 123, * }); * ``` */ export declare function stringFormat(string: string, ...args: any): string; declare type Success = (slicedStr: string, fullStr: string) => void; export declare function supportPrePublish(): void; /** * 节流 * * 连续触发事件但是在 n 秒中只执行一次函数 * @param {Function} fn 主函数 * @param {number} time 间隔时间,单位 `ms` * @returns 闭包函数 * * @example * * ```ts * function count() { * console.log('xxxxx') * } * window.onscroll = throttle(count, 500) * ``` */ export declare function throttle(fn: Function, time: number): (...args: Array) => void; /** * i18n 国际化配置 */ declare const TI18N_KEYS: readonly ["en", "ru", "pt-BR", "th", "vi", "zh", "zh-HK", "zh-TW", "de", "id", "fr", "es", "tr", "ar", "ms", "uz", "ur"]; export { TI18N_KEYS as DEFAULT_TI18N_KEYS } export { TI18N_KEYS } export declare type Ti18nKey = typeof TI18N_KEYS[number]; export declare interface TimeData { days: number; hours: number; minutes: number; seconds: number; milliseconds: number; } export declare interface TimeItem { digit: string; unit: string; match: string; } /** * 将时间戳格式化 * @param {number} timestamp * @param {string} fmt * @param {string} [defaultVal] * @returns {string} 格式化后的日期字符串 * @example * * const stamp = new Date('2020-11-27 8:23:24').getTime(); * * const res = timeStampFormat(stamp, 'yyyy-MM-dd hh:mm:ss') * * // 2020-11-27 08:23:24 */ export declare function timeStampFormat(timestamp: number, fmt: string, defaultVal?: string, whitePrefix?: string): string; /** * 处理图片 URL(换 CDN 域名 + 裁剪压缩) * @docgen * @function tinyImage * * @param {string} inUrl - 图片原始 URL * @param {number} [width=0] - 图片裁剪后的宽度(可选,默认为 0,表示不裁剪) * @param {number} [height=0] - 图片裁剪后的高度(可选,默认为 0,表示不裁剪) * @return {string} 返回处理后的图片 URL * * @description * 该函数是图片处理的综合方法,依次执行: * 1. 将 http 转为 https * 2. 替换为 CDN 域名 * 3. 添加压缩和裁剪参数 * * @example * * const url = 'http://igame-10037599.cos.ap-shanghai.myqcloud.com/test.jpg'; * const optimized = tinyImage(url, 200, 200); * // 结果:https 域名 + CDN + 压缩参数 */ export declare const tinyImage: (inUrl: string, imageWidth?: number, imageHeight?: number) => string; declare const TIP_MAP: { saveImage: string; saveImageSuccess: string; saveImageFail: string; saveImageFailOfAuth: string; authConfirmContent: string; authConfirmFailToast: string; }; /** * 将每个单词的首字母转换为大写 * @param {string} str 输入字符串 * @returns {string} 处理后的字符串 * * @example * * titleize('my name is yang') * * // My Name Is Yang * * titleize('foo-bar') * * // Foo-Bar */ export declare function titleize(str: string): string; export declare const toCamel: typeof camelize; /** * 切换展示 vConsole * @returns 是否展示 * @example * ```ts * toggleVConsole() * ``` */ export declare function toggleVConsole(): boolean; /** * 将对象中的key由下划线专为驼峰 * * @param {object} obj - 对象 * @returns {object} 转化后的对象 * * @example * const obj = { * a_a: 'a', * b_b: [ * { * bb_b: 'b', * }, * ], * c: { * dd_d: 'd', * e: { * ee_e: 'e', * }, * }, * }; * * toHumpObj(obj); * // { aA: 'a', bB: [ { bbB: 'b' } ], c: { ddD: 'd', e: { eeE: 'e' } } } */ export declare function toHumpObj(obj: IHumpObject, cache?: WeakMap): object; export declare const toKebab: typeof hyphenate; export declare const toPascal: typeof pascalCase; /** * 将函数转成 Promise * @param {function} promiseLike 任意函数,可以为 Promise * @returns Promise 函数 * @example * ``` * const bar = () => 1; * toPromise(bar()).then(res => console.log(res)); // 1 * function foo() { * return new Promise(resolve => setTimeout(() => resolve(2), 1000)); * } * toPromise(foo()).then(res => console.log(res)); // 2 * * ``` */ export declare function toPromise(promiseLike: any): any; /** * 将 alias 路径转换为相对路径 */ export declare function toRelativePath(filePath: string, alias: string, subPath: string, rootDir: string, aliasMap: Record): string; /** * 获取字符串的 unicode * * @param {string} str - 字符串 * @returns {string} data * * @example * * toUnicode('ABC') * * // -> '\\u0041\\u0042\\u0043' * * */ export declare function toUnicode(str: string): unknown; /** * 获取字符串指定下标的 unicode * * @param {string} str - 字符串 * @param {number} index - unicode 的下标 * @returns {string} data * * @example * * unicodeAt('ABC', 1) * * // -> '\\u0042' * */ export declare function toUnicodeAt(str: string, index?: number): string; export declare function transformGitToSSH(link?: string): string; /** * 转化 rem 单位 * @param {string} content 输入内容 * @param {number} factor 转化比例,默认 100 * @param {string} unit 转化单位,默认 rpx * @returns {string} 转化后的结果 * * @example * ```ts * transFormRem('1.22rem') * // 122rpx * * transFormRem('1.22rem', 50, 'px') * // 61px * * transFormRem('.21rem', 50, 'px') * // 10.50px * ``` */ export declare function transFormRem(content: string, factor?: number, unit?: string): string; /** * 将毫秒数time转化为倒计时 * @param time 倒计时时间,毫秒单位 * @param format 倒计时格式化字符串,例如:dd天hh小时mm分ss秒SSS毫秒,hh:mm:ss.SSS,hh:mm:ss * @example * ```ts * transformTime(1000, 'hh:mm:ss') * ``` */ export declare function transformTime(time: number, format: string): { timeText: string; timeList: TimeItem[]; timeData: TimeData; }; /** * 递归遍历文件夹,并对每个文件执行回调函数 * 遍历目录树,对每个文件(非目录)执行指定的回调函数 * @param cb - 回调函数,接收文件路径作为参数 * @param tPath - 要遍历的文件夹或文件路径 * @example * ```ts * traverseFolder((filePath) => { * console.log('处理文件:', filePath); * }, '/path/to/folder'); * ``` */ export declare function traverseFolder(cb: Function, tPath: string): void; export declare function traverseResp(data: Record, cb?: typeof updateChildId): void; export declare const TRIGGER_MAP: { MANUAL: string; TIME_TRIGGER: string; WEB_HOOK: string; SERVICE: string; PIPELINE: string; REMOTE: string; }; declare type TsErrorFile = { file: string; line: number; column: number; code: string; message: string; }; /** * node环境下,本地图片转为base64 * @param {string} savePath 本地图片保存路径 * @returns {string} base64图片地址 * * @example * * const base64str = turnLocalImg2Base64('/temp.png') * */ export declare function turnLocalImg2Base64(imgPath: string): string; /** * 拦截路由 * * @example * ```ts * uniHookRouter({ * navigateToHooks: [ * () => console.log('1') * ], * navigateBackHooks: [ * () => console.log('2') * ], * redirectToHooks: [ * () => console.log('3') * ], * debug: true, * }) * ``` */ export declare function uniHookRouter({ navigateToHooks, navigateBackHooks, redirectToHooks, tryUniInterCeptor, debug, }: { navigateToHooks?: Array; navigateBackHooks?: Array; redirectToHooks?: Array; tryUniInterCeptor?: boolean; debug?: boolean; }): void; /** * 创建唯一 ID 生成器工厂函数 * 返回一个函数,每次调用时生成递增的唯一 ID * @param compName - 组件名称,用于生成 ID 的一部分 * @param prefix - ID 前缀,默认为 't' * @returns 返回一个生成唯一 ID 的函数 * @example * ```ts * const getUniqueId = uniqueFactory('button', 'my'); * getUniqueId(); // 'my_button_0' * getUniqueId(); // 'my_button_1' * getUniqueId(); // 'my_button_2' * ``` */ export declare const uniqueFactory: (compName: string, prefix?: string) => () => string; declare function updateChildId(data: { child_id_new?: number | string; child_id?: number | string; }): void; export declare function updateDevopsMpCIPipeline({ isWxCI, forceUpdate, onlyCollectNoUsedPipeline, devopsConfig, templateIdMap, rainbowGroupSecretInfo, }: Record): Promise; export declare function updateDevopsTemplateInstances({ projectId, templateId, pipelineId, host, pipelineName, pipelineParam, useTemplateSettings, secretInfo, }: ITemplateReq & { pipelineId: string; pipelineName: string; pipelineParam: Object; useTemplateSettings?: boolean; }): Promise; /** * 更新 iwiki 文档内容 * 使用 POST /v2/doc/save 接口,通过 force: true 强制保存 */ export declare function updateIwikiDoc({ prefix, id, spacekey, title, body, contenttype, otherData, paasId, paasToken, force, }: { prefix: string; id: number | string; spacekey: string; title?: string; body?: string; contenttype?: string; otherData?: any; paasId: string; paasToken: string; force?: boolean; }): Promise<{ code: string; msg: string; data: any; request_id: string; }>; export declare function updateManager(): void; export declare function updateManifestCore({ path, value, manifest, }: { path: string; value: string; manifest: string; }): string; export declare function updateMpCIRainbowConfig({ rainbowConfig, branch, originBranch, testRobot, releaseRobot, robot, env, useMpQQ, }: { rainbowConfig: Record; branch: string; originBranch?: string; testRobot?: number; releaseRobot?: number; robot?: number; env?: string; useMpQQ?: boolean; errorMap?: typeof ERROR_MAP; }): { error: string; } | { newRainbowConfig: Record; rainbowKey: string; }; export declare function updateQQMpResultToSheet({ result, accessToken, clientId, openId, bookId, sheetId, startRow, startColumn, }: ISecretInfo_2 & { result: Record; bookId: string; sheetId: string; startRow: number; startColumn?: number; }): Promise; export declare function updateQQMpResultToSheetV0({ accessToken, clientId, openId, bookId, sheetId, startRow, qqMpQRCodePath, result, }: ISecretInfo_2 & { bookId: string; sheetId: string; startRow: number; startColumn?: number; qqMpQRCodePath: string; result: Record; }): Promise; /** * 更新彩虹配置并创建发布任务 * @param {object} config 配置信息 * @param {string} config.key 配置key * @param {string} config.value 配置value * @param {number} config.valueType 配置类型,1: NUMBER, 2: STRING, 3: TEXT, 4: JSON, 5: XML, 18: 日期, 20: yaml * @param {object} config.secretInfo 密钥信息 * @param {string} config.secretInfo.appId 项目Id * @param {string} config.secretInfo.userId 用户Id * @param {string} config.secretInfo.secretKey 密钥 * @param {string} config.secretInfo.envName 配置环境 * @param {string} config.secretInfo.groupName 配置组 * @param {string} config.creator 创建者 * @param {string} config.approvers 审批者 * @returns {Promise<{taskRes: any, versionName: string}>} 发布任务结果和版本名称 * * @example * updateRainbowConfigAndCreateTask({ * key: 'configKey', * value: 'configValue', * valueType: 2, * secretInfo: { * appId: 'xxx', * userId: 'xxx', * secretKey: 'xxx', * envName: 'prod', * groupName: 'xxx', * }, * creator: 'creatorName', * approvers: 'approverName' * }).then(({ taskRes, versionName }) => { * console.log('任务创建成功:', taskRes); * console.log('版本名称:', versionName); * }) */ export declare function updateRainbowConfigAndCreateTask({ key, value, valueType, secretInfo, creator, approvers, }: { key: string; value: string; valueType: RainbowKeyValueType; secretInfo: ISecretInfo_3; creator: string; approvers: string; }): Promise<{ taskRes: any; versionName: string; }>; /** * 修改配置 * @param {object} config 配置信息 * @param {object} config.keyValue 配置对象 * @param {string} config.keyValue.key 配置的key * @param {string} config.keyValue.value 配置的value * @param {number} config.valueType 配置类型,1: NUMBER, 2: STRING, 3: TEXT, 4: JSON, 5: XML, 18: 日期, 20: yaml * @param {object} config.secretInfo 密钥信息 * @param {string} config.secretInfo.appId 项目Id * @param {string} config.secretInfo.userId 用户Id * @param {string} config.secretInfo.secretKey 密钥 * @param {string} config.secretInfo.envName 配置环境 * @param {string} config.secretInfo.groupName 配置组 * @returns {Promise} 请求Promise * * @example * updateRainbowKV({ * keyValue: { * key: 'theKey', * value: 'theValue', * }, * valueType: 2, * secretInfo: { * appId: 'xxx', * userId: 'xxx', * secretKey: 'xxx', * envName: 'prod', * groupName: 'xxx', * } * }).then(() => { * * }) */ export declare function updateRainbowKV({ keyValue, valueType, secretInfo, }: ModifyConfigParam): Promise; /** * 更新或新增值并发布 * @param {object} config 配置信息 * @param {string} config.key 配置key * @param {string} config.value 配置value * @param {number} config.valueType 配置类型,1: NUMBER, 2: STRING, 3: TEXT, 4: JSON, 5: XML, 18: 日期, 20: yaml * @param {object} config.secretInfo 密钥信息 * @param {string} config.secretInfo.appId 项目Id * @param {string} config.secretInfo.userId 用户Id * @param {string} config.secretInfo.secretKey 密钥 * @param {string} config.secretInfo.envName 配置环境 * @param {string} config.secretInfo.groupName 配置组 * @returns {Promise} 请求Promise * * @example * updateRainbowKVAndPublish({ * key: 'key', * value: 'value', * valueType: 2, * secretInfo: { * appId: 'xxx', * userId: 'xxx', * secretKey: 'xxx', * envName: 'prod', * groupName: 'xxx', * } * }).then(() => { * * }) */ export declare function updateRainbowKVAndPublish({ key, value, valueType, secretInfo, creator, approvers, }: { key: string; value: string; valueType: RainbowKeyValueType; secretInfo: ISecretInfo_3; creator: string; approvers: string; }): Promise; export declare function updateTencentSheet({ accessToken, clientId, openId, bookId, range, values, }: ISecretInfo_2 & { bookId: string; range: string; values: Array<{}>; }): Promise; export declare function updateTencentSheetImage({ accessToken, clientId, openId, bookId, insertImages, }: ISecretInfo_2 & { bookId: string; insertImages: any; }): Promise; export declare function upload({ root, bundleName, hostName, hostPwd, hostTargetDir, wrapHostPwd, outputDir, }: { root: string; bundleName: string; hostName: string; hostPwd: string; hostTargetDir?: string; wrapHostPwd?: boolean; outputDir?: string; }): void; /** * COS上传 * @param {object} config 配置信息 * @param {Array} config.files 文件列表 * @param {string} config.files.key 文件key * @param {string} config.files.path 文件路径 * @param {string} config.secretId COS secretId * @param {string} config.secretKey COS secretKey * @param {string} config.bucket COS bucket * @param {string} config.region COS region * @returns {Promise} 请求Promise * * @example * * uploadCOSFile({ * files: [{ * key: 'key1', * path: 'path1', * }, { * key: 'key2', * path: 'path2', * }], * secretId: 'xxx', * secretKey: 'xxx', * bucket: 'xxx', * region: 'xxx', * }) */ export declare function uploadCOSFile({ files, secretId, secretKey, bucket, region, }: { files: Array<{ key: string; path: string; }>; secretId: string; secretKey: string; bucket: string; region: string; }): Promise; export declare function uploadCOSFileAndPurgeUrlCache({ secretId, secretKey, bucket, region, files, area, useEO, eoOptions, }: { secretId: string; secretKey: string; bucket: string; region: string; files: Array<{ key: string; path: string; url: string; }>; area?: (typeof AREA_MAP)[keyof typeof AREA_MAP]; useEO?: boolean; eoOptions?: { zoneId: string; type?: IPurgeType; method?: IPurgeMethod; }; }): Promise<{ uploadResult: any; purgeResult: any; code: 1 | 2; }>; export declare function uploadCOSStreamFile({ file, key, secretId, secretKey, bucket, region, }: { secretId: string; secretKey: string; bucket: string; region: string; file: { path?: string; size: number; buffer?: Buffer; }; key: string; }): Promise; export declare function uploadCOSStreamFileV2({ file, key, secretId, secretKey, bucket, region, sliceSize, }: { secretId: string; secretKey: string; bucket: string; region: string; file: { path?: string; size: number; }; key: string; sliceSize?: number; }): Promise; /** * 上传文件 * * 上传的本质: * * 1. 小程序上传文件是先用 chooseFile 获取一个文件,可以得到 * 一个临时路径,然后用 uploadFile 上传该临时路径 * * 2. H5 是 input 获取文件,然后用 FormData 上传 File 对象 * @param {File} file 文件 * @returns {Promise<{url: string}>} 上传结果 * * @example * ```ts * import { uploadFile, UploadManager } from 't-comm/lib/uploader' * * uploadFile(file).then(() => {}) * * // 可以通过 UploadManager 设置上传参数 * UploadManager.setConfig({ * requestHashUrl: `https://${location.hostname}/pvp/share/getsharecfg.php`, * uploadFileKey: 'upload_pic_input', * uploadUrlPrefix: 'https://igame.qq.com/external/uploadpic.php?_hash=', * }) * * // 可以通过 UploadManager.getInstance().updateHashCode 主动更新 hashCode * UploadManager.getInstance().updateHashCode(); * ``` */ export declare function uploadFile(file: File): Promise; /** * 文件上传管理器 * 单例模式,管理文件上传的 hash 码和上传请求 * @example * ```ts * // 设置上传配置 * UploadManager.setConfig({ * requestHashUrl: 'https://example.com/api/hash', * uploadFileKey: 'file', * uploadUrlPrefix: 'https://example.com/upload?hash=' * }); * * // 获取实例并上传文件 * const manager = UploadManager.getInstance(); * manager.requestUpload(file).then(res => { * console.log('上传成功:', res.url); * }); * ``` */ export declare class UploadManager { static uploadManager: UploadManager; /** * 获取 UploadManager 单例实例 * @returns UploadManager 实例 */ static getInstance(): UploadManager; /** * 设置上传配置 * @param options - 上传配置选项 * @param options.requestHashUrl - 请求 hash 码的 URL 或函数 * @param options.uploadFileKey - 上传文件的表单字段名 * @param options.uploadUrlPrefix - 上传文件的 URL 前缀 */ static setConfig(options: IUploaderOptions): void; hash: string; timestamp: number; isRequesting: boolean; options: IUploaderOptions; constructor(); /** * 更新 hash 码 * 从服务器获取新的 hash 码用于文件上传 * @returns Promise,resolve 时返回新的 hash 码 */ updateHashCode(): Promise; /** * 请求上传文件 * 自动管理 hash 码的更新,确保 hash 码有效 * @param file - 要上传的文件对象 * @returns Promise,resolve 时返回包含文件 URL 的对象 */ requestUpload(file: File): Promise<{ url: string; }>; } export declare function uploadTencentDocImage({ accessToken, clientId, openId, image, }: ISecretInfo_2 & { image: string; }): Promise; /** * 解决图片跨域问题,将网络图片URL转为base64 URL。 * @param {string} src 网络图片URL * @returns {Promise} Promise对象返回base64 URL * * @example * Dom2Image.urlToBase64("http://test.com/image.png").then(url=>{}); */ export declare function urlToBase64(src: string): Promise; declare interface UserInfo { openid: string; token: string; channel_info?: { channelId: number; }; } /** * vConsole 当前展示状态 */ export declare const V_CONSOLE_STATE: { show: boolean; }; /** * 判断是否字母字符串 * @param {string} str * @returns {Boolean} */ export declare function validAlphabets(str: string): boolean; /** * 验证身份证号第18位校验码是否合法 * 使用加权求和算法验证身份证号的最后一位校验码 * @param str - 身份证号字符串 * @returns 校验码是否合法 * @private * @example * ```ts * validateMoreIdCard('34052419800101001X'); // true * validateMoreIdCard('34052419800101001Y'); // false * ``` */ export declare function validateMoreIdCard(str: string): boolean; /** * 判断是否合法邮箱地址 * @param {string} email * @returns {Boolean} */ export declare function validEmail(email: string): boolean; /** * 判断是否小写 * @param {string} str * @returns {Boolean} */ export declare function validLowerCase(str: string): boolean; /** * 判断是否大写 * @param {string} str * @returns {Boolean} */ export declare function validUpperCase(str: string): boolean; /** * 判断是否URL * @param {string} url * @returns {Boolean} */ export declare function validURL(url: string): boolean; declare type ValueType = string | number; declare enum ValueType_2 { NUMBER = 1, STRING = 2, TEXT = 3, JSON = 4, XML = 5, DATE = 18, YAML = 20 } export declare const vClickoutside: { beforeMount(el: ClickOutsideElement, binding: any): void; update(): void; unmounted(el: ClickOutsideElement): void; }; export declare const version: any; declare type VersionType = keyof typeof versionTypeMap | string; declare const versionTypeMap: { alpha: string; beta: string; rc: string; patch: string; minor: string; major: string; }; /** * 监听rainbow,同步到cos,并发送到机器人 * @param {object} options 配置 * @param {object} options.rainbowSecretInfo 七彩石密钥信息 * @param {object} options.cosInfo 腾讯云信息 * @param {string} options.appName 七彩石项目名称 * * @param {string} options.webhookUrl 机器人回调 * @param {string} options.chatId 会话id * @param {0|1|2} options.sendToRobotType 发送机器人类型,0 不发送,1 发送变化的部分,2 全部发送 * * @example * * await watchRainbowToCosAndSendRobot({ * rainbowSecretInfo: { * appID: RAINBOW_OPEN_APP_ID, * userID: RAINBOW_OPEN_YGW_USER_ID, * secretKey: RAINBOW_OPEN_YGW_SECRET_KEY, * envName: 'Default', * groupName: 'group', * }, * appName: 'configApp', * cosInfo: { * secretId, * secretKey, * bucket: 'bucket', * region: 'ap-guangzhou', * dir: 'rb', * }, * webhookUrl: 'xxx', * chatId: 'xxx', * sendToRobotType: 1, * }); * */ export declare function watchRainbowToCosAndSendRobot({ rainbowSecretInfo: secretInfo, cosInfo, appName, webhookUrl, chatId, sendToRobotType, }: { rainbowSecretInfo: ISecretInfo_4; cosInfo: ICosInfo; appName: string; webhookUrl: string; chatId: string; sendToRobotType?: (typeof SendToRobotTypeMap)[keyof typeof SendToRobotTypeMap]; }): Promise; export declare function writeEnvAndPrivateKey({ branch, env, root, rainbowConfigKey, rainbowAppId, rainbowEnvName, rainbowGroupName, }: Record<'branch' | 'env' | 'rainbowConfigKey' | 'rainbowAppId' | 'rainbowEnvName' | 'rainbowGroupName' | 'root', string>): Promise; export declare function writeEnvAndPrivateKeyByOptions(options: any): Promise; export declare function writeEnvFromRainbow({ envPath, rainbowAppId, rainbowUserId, rainbowSecretKey, rainbowKey, envName, groupName, sdk, }: { envPath: string; rainbowAppId: string; rainbowUserId?: string; rainbowSecretKey?: string; rainbowKey: string; envName: string; groupName: string; sdk: any; }): Promise; /** * 将 .env.local 中 NPM_TOKEN 的值写入到 .npmrc 中 */ export declare function writeEnvTokenToNpmRC(): void; /** * 写入文件 * @param {string} file 文件地址 * @param {any} data 文件数据 * @param {boolean} [isJson] 是否需要 json 序列化 * @example * ```ts * writeFileSync('a', 'b.txt', false); * * writeFileSync({ a: 1 }, 'b.json', true); * ``` */ export declare function writeFileSync(file: string, data: any, isJson?: boolean): void; export { }