Skip to content

引入

ts
import { libraryChangeStatistics } from 't-comm';

// 不支持 tree-shaking 的项目
import { libraryChangeStatistics} from 't-comm/lib/git-change/index';

// 只支持 ESM 的项目
import { libraryChangeStatistics} from 't-comm/es/git-change/index';

libraryChangeStatistics(analyzeList, saveDataDir, cosInfo, analyzeBlackList)

描述

统计代码库变更情况。分析多个项目的 Git 提交记录,生成统计数据并可选上传到 COS

参数

参数名描述
analyzeList

要分析的项目列表

saveDataDir

保存统计数据的本地目录

cosInfo

COS 上传配置信息(可选)

cosInfo.secretId

腾讯云 SecretId

cosInfo.secretKey

腾讯云 SecretKey

cosInfo.bucket

COS 存储桶名称

cosInfo.region

COS 区域

cosInfo.dir

COS 目录路径

analyzeBlackList

需要排除的目录黑名单(可选)

返回: Promise.<Array>

  • 返回每个项目的统计结果数组

示例

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