2023-04-28 15:26:09 +08:00
|
|
|
import fs from 'fs';
|
|
|
|
import path from 'path';
|
2023-11-02 15:10:56 +08:00
|
|
|
import remove from 'lodash/remove';
|
|
|
|
import sortBy from 'lodash/sortBy';
|
|
|
|
import unionBy from 'lodash/unionBy';
|
2023-04-28 15:26:09 +08:00
|
|
|
import simpleGit from 'simple-git';
|
2020-10-10 10:34:41 +08:00
|
|
|
|
|
|
|
const cwd = process.cwd();
|
|
|
|
const git = simpleGit(cwd);
|
|
|
|
|
|
|
|
const excludes = [
|
|
|
|
'users.noreply.github.com',
|
|
|
|
'gitter.im',
|
|
|
|
'.local',
|
|
|
|
'alibaba-inc.com',
|
|
|
|
'alipay.com',
|
|
|
|
'taobao.com',
|
2021-02-28 14:03:31 +08:00
|
|
|
'ant-design-bot',
|
2020-10-10 10:34:41 +08:00
|
|
|
];
|
|
|
|
|
|
|
|
async function execute() {
|
2023-09-07 20:55:34 +08:00
|
|
|
let { all } = await git.log();
|
2023-11-02 15:10:56 +08:00
|
|
|
all = remove(all, ({ author_email: email }) => {
|
2020-10-10 10:34:41 +08:00
|
|
|
for (let i = 0; i < excludes.length; i++) {
|
|
|
|
const item = excludes[i];
|
2022-10-21 11:45:55 +08:00
|
|
|
if (email.includes(item)) {
|
2020-10-10 10:34:41 +08:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
});
|
2023-09-07 20:55:34 +08:00
|
|
|
|
2023-11-02 15:10:56 +08:00
|
|
|
all = sortBy(unionBy(all, 'author_email'), 'author_name');
|
2023-09-07 20:55:34 +08:00
|
|
|
|
2020-10-10 10:34:41 +08:00
|
|
|
fs.writeFileSync(
|
2023-09-07 20:55:34 +08:00
|
|
|
path.join(cwd, 'contributors.json'),
|
|
|
|
JSON.stringify(
|
|
|
|
Array.from(new Set<string>(all.map((authorItem) => authorItem.author_name))),
|
|
|
|
null,
|
|
|
|
2,
|
|
|
|
),
|
2020-10-10 10:34:41 +08:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
execute();
|