Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
W
wangxiaolu-sfa-ui
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
sfa
wangxiaolu-sfa-ui
Commits
71e865f2
提交
71e865f2
authored
7月 10, 2025
作者:
lidongxu
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
test(测试): 测试
n
上级
09a359fe
隐藏空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
32 行增加
和
11 行删除
+32
-11
updateVersion.js
updateVersion.js
+32
-11
没有找到文件。
updateVersion.js
浏览文件 @
71e865f2
...
...
@@ -2,41 +2,60 @@ import fs from 'fs'
function
parseChangelog
(
changelogText
)
{
const
result
=
{};
const
versionRegex
=
/^###
\[([\d
.
]
+
)\]\([^
)
]
+
\)
/
;
const
sectionRegex
=
/^###
(
.*
?)
\|
(
.*
)
$/
;
const
descRegex
=
/^
\*
\*\*(
.*
?)
:
?\*\*
(
.*
?)
\(
/
;
const
versionRegex
=
/^##
\[([\d
.
]
+
)\]\([^
)
]
+
\)
/
;
// 匹配二级标题版本
const
sectionRegex
=
/^###
(
.*
?)
\|
(
.*
)
$/
;
// 匹配三级标题部分
const
breakingChangesRegex
=
/^### ⚠ BREAKING CHANGES$/
;
// 匹配BREAKING CHANGES
const
descRegex
=
/^
\*
\*\*(
.*
?)
:
?\*\*
(
.*
?)
\(
/
;
// 匹配描述行
let
currentVersion
=
null
;
let
currentSection
=
null
;
let
isBreakingChanges
=
false
;
const
lines
=
changelogText
.
split
(
'
\
n'
);
for
(
const
line
of
lines
)
{
// 检查是否是版本行
// 检查是否是版本行
(二级标题)
const
versionMatch
=
line
.
match
(
versionRegex
);
if
(
versionMatch
)
{
currentVersion
=
versionMatch
[
1
];
result
[
currentVersion
]
=
[];
result
[
currentVersion
]
=
{
breakingChanges
:
[],
changes
:
[]
};
isBreakingChanges
=
false
;
continue
;
}
// 如果
不是版本行但有当前版本,则检查是否是章节行
// 如果
是当前版本下的内容
if
(
currentVersion
)
{
// 检查是否是BREAKING CHANGES部分
const
breakingMatch
=
line
.
match
(
breakingChangesRegex
);
if
(
breakingMatch
)
{
isBreakingChanges
=
true
;
continue
;
}
// 检查是否是普通的三级标题部分
const
sectionMatch
=
line
.
match
(
sectionRegex
);
if
(
sectionMatch
)
{
isBreakingChanges
=
false
;
currentSection
=
{
info
:
sectionMatch
[
2
],
type
:
sectionMatch
[
2
],
// 取 | 后面的部分作为类型
desc
:
[]
};
result
[
currentVersion
].
push
(
currentSection
);
result
[
currentVersion
].
changes
.
push
(
currentSection
);
continue
;
}
//
检查是否是描述行
//
收集描述内容
const
descMatch
=
line
.
match
(
descRegex
);
if
(
descMatch
&&
currentSection
)
{
if
(
descMatch
)
{
const
description
=
descMatch
[
2
].
trim
();
currentSection
.
desc
.
push
(
description
);
if
(
isBreakingChanges
)
{
result
[
currentVersion
].
breakingChanges
.
push
(
description
);
}
else
if
(
currentSection
)
{
currentSection
.
desc
.
push
(
description
);
}
}
}
}
...
...
@@ -47,4 +66,5 @@ function parseChangelog(changelogText) {
const
changelog
=
'./CHANGELOG.md'
const
changeData
=
fs
.
readFileSync
(
changelog
,
'utf-8'
)
const
result
=
parseChangelog
(
changeData
)
// 把对象写回到 version.js
console
.
log
(
result
)
\ No newline at end of file
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论