45 Star 136 Fork 91

GVPHalo-E/HaloE-Design

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
log.js 2.26 KB
一键复制 编辑 原始数据 按行查看 历史
zhangjinpeng 提交于 2023-04-20 11:13 . feat:新增日志生成
const fs = require('fs');
const componentName = ['button', 'icon', 'layout', 'pagination', 'tabs', 'steps', 'breadcrumb', 'menu', 'checkbox', 'select', 'switch', 'radio', 'search', 'cascader', 'filtrate', 'inputNumber', 'input', 'slider', 'transfer', 'upload', 'timePicker', 'badge', 'collapse', 'tooltips', 'tag', 'timeline', 'table', 'progress', 'spin', 'alert', 'drawer', 'message', 'modal', 'notification', 'popconfirm']
const logs = () => {
let logPath = ['./dataFeat.json', './dataFix.json', './dataOther.json']
for (let p of logPath) {
if (p.includes("Feat")) {
extractFs(p, '_feat')
}
if (p.includes('Fix')) {
extractFs(p, '_fix')
}
if (p.includes('Other')) {
extractFs(p, '_other')
}
// if (p.includes('Null')) {
// extractFs(p, '_null')
// }
}
}
const extractFs = (p, mode) => {
fs.readFile(p, 'utf-8', (err, data) => {
if (!err) {
let objs = {
[mode]: []
};
const lines = data.split(/\r?\n/);
lines.forEach((line) => {
if (line) {
let temp = JSON.parse(line);
let type = temp.type
let header = temp.header
let hash = temp.hash.substring(0, 7)
let jira = temp.issue ? temp.issue : "";
let commitData = temp.committerDate
//匹配描述中的组件名
let arr=findComponent(header);
let obj = {
'type': type,
'header': header,
'hash': hash,
'jira': jira,
'commitData': commitData,
name:arr
}
objs[mode].push(obj)
}
});
const ws = fs.createWriteStream(`./${mode}.json`, { flags: 'w' })
ws.write(JSON.stringify(objs, null, "\t"))
ws.close();
console.log(mode + ' 生成成功!!')
} else {
console.log(mode + " 生成失败")
}
})
}
const findComponent=(str)=>{
let arr=[];
for(let name of componentName){
let pattern=name;
if(name[name.length-1]==='s'){
pattern=name.substring(0,name.length-1)
}
let re=new RegExp(pattern,'i')
//
if(re.test(str)){
// console.log('ok',name)
arr.push(name)
}
}
return arr;
}
logs()
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
JavaScript
1
https://gitee.com/halo-e/haloe-design.git
git@gitee.com:halo-e/haloe-design.git
halo-e
haloe-design
HaloE-Design
develop

搜索帮助