提交 4f93f0f5 authored 作者: lidongxu's avatar lidongxu

feat(version): 测试主版本发布

上级 e37b2abe
差异被折叠。
console.log('23412313ccc')
\ No newline at end of file
console.log('23412313cccsadfdasf')
let obj = {
'0.1.8': [
{
info: '新功能',
desc: ['新版本文件保存测试']
}, {
info: 'Bug 修复',
desc: ['bug 修改测试']
}, {
info: '风格',
desc: ['测试样式变更']
}, {
info: '重构',
desc: ['重构测试']
}
]
}
\ No newline at end of file
import fs from 'fs'
const packagePath = './package.json'
const packageData = JSON.parse(fs.readFileSync(packagePath, 'utf-8'))
function parseChangelog(changelogText) {
const result = {};
const versionRegex = /^### \[([\d.]+)\]\([^)]+\)/;
const sectionRegex = /^### (.*?) \| (.*)$/;
const descRegex = /^\* \*\*(.*?):?\*\* (.*?) \(/;
let currentVersion = null;
let currentSection = null;
const lines = changelogText.split('\n');
for (const line of lines) {
// 检查是否是版本行
const versionMatch = line.match(versionRegex);
if (versionMatch) {
currentVersion = versionMatch[1];
result[currentVersion] = [];
continue;
}
// 如果不是版本行但有当前版本,则检查是否是章节行
if (currentVersion) {
const sectionMatch = line.match(sectionRegex);
if (sectionMatch) {
currentSection = {
info: sectionMatch[2],
desc: []
};
result[currentVersion].push(currentSection);
continue;
}
// 检查是否是描述行
const descMatch = line.match(descRegex);
if (descMatch && currentSection) {
const description = descMatch[2].trim();
currentSection.desc.push(description);
}
}
}
return result;
}
const changelog = './CHANGELOG.md'
const changeData = fs.readFileSync(changelog, 'utf-8')
console.log(changeData)
const newChangeData = changeData.replace('## 0.1.5', `## ${packageData.version}`)
console.log(packageData.version)
// fs.writeFileSync(packagePath, JSON.stringify(packageData, null, 2))
const result = parseChangelog(changeData)
console.log(result)
\ No newline at end of file
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论