45 Star 131 Fork 86

GVPHalo-E/HaloE-Design

Create your Gitee Account
Explore and code with more than 12 million developers,Free private repositories !:)
Sign up
Clone or Download
log.js 2.26 KB
Copy Edit Raw Blame History
zhangjinpeng authored 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

Search