diff --git a/.github/workflows/update-continew-contribs.yaml b/.github/workflows/update-continew-contribs.yaml index 522b701..d95cea5 100644 --- a/.github/workflows/update-continew-contribs.yaml +++ b/.github/workflows/update-continew-contribs.yaml @@ -40,7 +40,7 @@ jobs: run: pnpm install - name: Run generation script - run: pnpm tsx src/main.ts -t ${{ secrets.TOKEN }} -o continew-org + run: pnpm tsx src/main.ts -t ${{ secrets.TOKEN }} -o continew-org -e continew-cloud - name: Copy uses: appleboy/scp-action@v0.1.7 diff --git a/.gitignore b/.gitignore index 32434a3..762ce22 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,8 @@ node_modules .DS_Store lib + +# IDE setting files +.idea +!.idea/icon.png +.vscode \ No newline at end of file diff --git a/src/fetch.ts b/src/fetch.ts index 8d8f8c5..bd6268b 100644 --- a/src/fetch.ts +++ b/src/fetch.ts @@ -137,6 +137,9 @@ export async function fetchContributorsInfo(params: { const allContributorsInfos = new Map() contributorsData.forEach(contributor => { const [userName, avatarURL] = [contributor.login, contributor.avatar_url] + if (!userName || !avatarURL) { + return + } const userInfoByName = allContributorsInfos.get(userName) if (!userInfoByName) { allContributorsInfos.set(userName, { diff --git a/src/main.ts b/src/main.ts index 21f21d4..e447762 100644 --- a/src/main.ts +++ b/src/main.ts @@ -8,16 +8,17 @@ import type { CliOptions, RepoInfo, ContributorsInfo } from './types' async function main() { - const { Github_token: defaultToken, Github_owner: defaultOwner } = process.env - const defaultRepoName = await getRepoName() + // const { Github_token: defaultToken, Github_owner: defaultOwner } = process.env + // const defaultRepoName = await getRepoName() const GITHUBReg = /https:\/\/github.com\/([\w\-_]+)\/([\w\-_]+)/ let urlInfo = null program .name('gh-contrib-svg') .arguments('[url]') - .option('-t, --token ', 'Personal GitHub token', defaultToken) - .option('-o, --owner ', 'Repo owner name', defaultOwner) - .option('-r, --repo ', 'GitHub repo path', defaultRepoName) + .option('-t, --token ', 'Personal GitHub token') + .option('-o, --owner ', 'Repo owner name') + .option('-r, --repo ', 'GitHub repo path') + .option('-e, --exclude ', 'Exclude gitHub repo path') .option('-s, --size ', 'Single avatar block size (pixel)', "120") .option('-w, --width ', 'Output image width (pixel)', "1000") .option('-c, --count ', 'Avatar count in one line', "8") @@ -34,7 +35,7 @@ async function main() { }) .parse(process.argv) const options = Object.assign(program.opts(), urlInfo) - const { token, repo, owner, size: avatarBlockSize, width, count: lineCount } = options as CliOptions + const { token, repo, owner, exclude, size: avatarBlockSize, width, count: lineCount } = options as CliOptions if (token && owner) { let repos: RepoInfo[] = [] @@ -55,9 +56,17 @@ async function main() { const startTime = performance.now() const allContributorsInfos = new Map() for (const { owner, repo } of repos) { + if (exclude && repo === exclude) { + continue + } const contributorsInfos = await fetchContributorsInfo({ token, repo, owner }); contributorsInfos.forEach((info, username) => { - allContributorsInfos.set(username, info); + const userInfoByName = allContributorsInfos.get(username) + if (!userInfoByName) { + allContributorsInfos.set(username, info) + } else { + userInfoByName.commitURLs = [...userInfoByName.commitURLs, ...info.commitURLs] + } }); } diff --git a/src/types.ts b/src/types.ts index a38de1c..c3ea3fe 100644 --- a/src/types.ts +++ b/src/types.ts @@ -2,6 +2,7 @@ export interface CliOptions { token: string // Github access token owner: string repo: string + exclude: string size: string width: string count: string