6.7.0 - Alpha6 - 重构 scrapers 工具并增加中英双语注释内容
This commit is contained in:
@@ -1,9 +1,9 @@
|
||||
// scrape-and-update-readme-template-contributors-table.mjs
|
||||
|
||||
import { fetchStatistics } from './fetch-and-parse-autojs6-merged-pr-commits-statistics.mjs';
|
||||
import * as fs from 'node:fs';
|
||||
import { toYYYYMMDD } from './utils/date.mjs';
|
||||
import * as path from 'node:path';
|
||||
import { fetchStatistics } from './fetch-and-parse-autojs6-merged-pr-commits-statistics.mjs';
|
||||
import { toYYYYMMDD } from './utils/date.mjs';
|
||||
|
||||
function updateCommonJsonFile() {
|
||||
const commonJsonPath = path.resolve(process.cwd(), '../.readme/common.json');
|
||||
@@ -17,7 +17,7 @@ function updateCommonJsonFile() {
|
||||
|
||||
if (JSON.stringify(updatedCommon) !== JSON.stringify(commonObj)) {
|
||||
fs.writeFileSync(commonJsonPath, JSON.stringify(updatedCommon, null, 2), 'utf8');
|
||||
console.log('[common.json] 已更新 (贡献参与数据统计日期)');
|
||||
console.log('[common.json] Updated (contribution statistics date)');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,19 +28,19 @@ function updateCommonJsonFile() {
|
||||
const newMarkdown = stats.map(stat => `| ${stat.contributorMarkdown} | ${stat.commitsCountMarkdown} | ${stat.latestCommitMarkdown} |`).join('\n');
|
||||
|
||||
const text = fs.readFileSync(path, { encoding: 'utf-8' });
|
||||
const newText = text.replace(/((?:table_header_contribution_contributors|table_header_contribution_number_of_commits|table_header_contribution_recent_submissions).+\r?\n)([\s|:\-]+\r?\n)(\|\s*<span style=".+\r?\n)+/i, ($0, $1, $2, $3) => {
|
||||
const cr = $3.match(/\|\s*<span style=".+(\r?\n)/)[1];
|
||||
return `${$1}${$2}${newMarkdown}${cr}`;
|
||||
const contributionHeaderRegex = /(table_header_contribution_\w+.+\r?\n)([\s|:\-]+\r?\n)(?:\|\s*<span style=".+(\r?\n))+/i;
|
||||
const newText = text.replace(contributionHeaderRegex, (_, headerLine, separatorLine, eol) => {
|
||||
return `${headerLine}${separatorLine}${newMarkdown}${eol}`;
|
||||
});
|
||||
|
||||
if (text.replace(/\s+/g, '') !== newText.replace(/\s+/g, '')) {
|
||||
fs.writeFileSync(path, newText, { encoding: 'utf-8' });
|
||||
console.log('[template_readme.md] 已更新 (贡献参与统计列表)');
|
||||
console.log('[template_readme.md] Updated (contribution statistics list)');
|
||||
updateCommonJsonFile();
|
||||
} else {
|
||||
// console.log('[template_readme.md] 无需更新 (贡献参与统计列表)');
|
||||
// console.log('[template_readme.md] No update needed (contribution statistics list)');
|
||||
}
|
||||
})().catch(err => {
|
||||
console.error(err);
|
||||
process.exitCode = 1;
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user