Skip to content

Commit a4f5dd4

Browse files
committed
🔨 添加更新日志生成脚本
1 parent 1895122 commit a4f5dd4

3 files changed

Lines changed: 63 additions & 3 deletions

File tree

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "scriptcat",
3-
"version": "0.18.2-beta",
3+
"version": "0.18.2",
44
"description": "脚本猫,一个可以执行用户脚本的浏览器扩展,万物皆可脚本化,让你的浏览器可以做更多的事情!",
55
"author": "CodFrm",
66
"license": "GPLv3",
@@ -16,7 +16,7 @@
1616
"format": "prettier --write .",
1717
"lint": "eslint .",
1818
"lint-fix": "eslint --fix .",
19-
"changlog": "gitmoji-changelog",
19+
"changlog": "node ./scripts/changlog.js",
2020
"crowdin": "crowdin"
2121
},
2222
"dependencies": {

scripts/changlog.js

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
#!/usr/bin/env node
2+
3+
const { execSync } = require('child_process');
4+
const fs = require('fs');
5+
const path = require('path');
6+
7+
/**
8+
* 生成changelog并处理文件内容
9+
*/
10+
function generateChangelog() {
11+
try {
12+
console.log('🚀 开始生成 CHANGELOG.md...');
13+
14+
// 执行 npm run changlog 命令
15+
console.log('📝 执行 gitmoji-changelog 生成changelog...');
16+
execSync('gitmoji-changelog --author --group-similar-commits', {
17+
stdio: 'inherit',
18+
cwd: process.cwd()
19+
});
20+
21+
console.log('✅ changelog 生成完成');
22+
23+
// 读取生成的 CHANGELOG.md 文件
24+
const changelogPath = path.join(process.cwd(), 'CHANGELOG.md');
25+
26+
if (!fs.existsSync(changelogPath)) {
27+
console.error('❌ CHANGELOG.md 文件不存在');
28+
process.exit(1);
29+
}
30+
31+
console.log('📖 读取 CHANGELOG.md 文件...');
32+
let content = fs.readFileSync(changelogPath, 'utf8');
33+
34+
// 使用正则表达式替换 (by (\w) -> (by @$1
35+
console.log('🔄 处理文件内容,添加 @ 符号...');
36+
const updatedContent = content.replace(/\(by (\w)/g, '(by @$1');
37+
38+
// 检查是否有内容被替换
39+
if (content !== updatedContent) {
40+
// 写回文件
41+
fs.writeFileSync(changelogPath, updatedContent, 'utf8');
42+
console.log('✅ 文件内容已更新,作者名前已添加 @ 符号');
43+
} else {
44+
console.log('ℹ️ 没有找到需要替换的内容');
45+
}
46+
47+
console.log('🎉 CHANGELOG.md 处理完成!');
48+
49+
} catch (error) {
50+
console.error('❌ 生成changelog时出错:', error.message);
51+
process.exit(1);
52+
}
53+
}
54+
55+
// 如果直接运行此脚本
56+
if (require.main === module) {
57+
generateChangelog();
58+
}
59+
60+
module.exports = { generateChangelog };

src/manifest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"manifest_version": 3,
33
"name": "__MSG_scriptcat__",
4-
"version": "0.18.2.1100",
4+
"version": "0.18.2",
55
"author": "CodFrm",
66
"description": "__MSG_scriptcat_description__",
77
"options_ui": {

0 commit comments

Comments
 (0)