diff --git a/.github/workflows/scheduler.yml b/.github/workflows/scheduler.yml index 78ed864..ce0d545 100644 --- a/.github/workflows/scheduler.yml +++ b/.github/workflows/scheduler.yml @@ -30,10 +30,8 @@ jobs: - name: Update sponsors run: pnpm exec sponsorkit --dir . env: - SPONSORKIT_GITHUB_LOGIN: LittleSound - SPONSORKIT_GITHUB_TOKEN: ${{ secrets.SPONSORKIT_GITHUB_TOKEN }} - # SPONSORKIT_AFDIAN_USER_ID: ${{ secrets.SPONSORKIT_AFDIAN_USER_ID }} - # SPONSORKIT_AFDIAN_TOKEN: ${{ secrets.SPONSORKIT_AFDIAN_TOKEN }} + SPONSORKIT_GITHUB_TOKEN_LITTLESOUND: ${{ secrets.SPONSORKIT_GITHUB_TOKEN_LITTLESOUND }} + SPONSORKIT_GITHUB_TOKEN_NEKOMEOWWW: ${{ secrets.SPONSORKIT_GITHUB_TOKEN_NEKOMEOWWW }} - name: Commit uses: EndBug/add-and-commit@v9 diff --git a/.gitignore b/.gitignore index 4a208a0..6ff2d07 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,4 @@ node_modules .DS_Store *.json !package.json +.env diff --git a/package.json b/package.json index 24530b4..7d1a4cc 100644 --- a/package.json +++ b/package.json @@ -2,6 +2,9 @@ "private": true, "type": "module", "packageManager": "pnpm@9.12.0", + "scripts": { + "dev": "rm -f .cache.json && sponsorkit --dir ." + }, "dependencies": { "sponsorkit": "^0.15.5" }, diff --git a/sponsorkit.config.ts b/sponsorkit.config.ts index f1775b7..9d205c3 100644 --- a/sponsorkit.config.ts +++ b/sponsorkit.config.ts @@ -1,4 +1,4 @@ -import { defineConfig, tierPresets } from 'sponsorkit' +import { defineConfig, tierPresets, fetchSponsors, Sponsorship } from 'sponsorkit' export default defineConfig({ formats: ['svg', 'png', 'json'], @@ -6,6 +6,35 @@ export default defineConfig({ afdian: { exechangeRate: 6.8, }, + + github: { + login: 'LittleSound', + token: process.env.SPONSORKIT_GITHUB_TOKEN_LITTLESOUND, + }, + + async onSponsorsAllFetched(sponsors) { + const res = await fetchSponsors({ + github: { + login: 'nekomeowww', + token: process.env.SPONSORKIT_GITHUB_TOKEN_NEKOMEOWWW, + }, + }) + + sponsors.push(...res) + + const sponsorMap = new Map() + for (const sponsor of sponsors) { + const key = sponsor.sponsor.login || Math.random().toString() + const theSame = sponsorMap.get(key) + if (theSame) { + theSame.monthlyDollars += sponsor.monthlyDollars + } else { + sponsorMap.set(key, sponsor) + } + } + return Array.from(sponsorMap.values()) + }, + tiers: [ { title: 'Past Sponsors',