Skip to content

Commit cc193a6

Browse files
chore: merge upstream tag 'v17.1.1'
2 parents d536f11 + f410756 commit cc193a6

18 files changed

Lines changed: 517 additions & 104 deletions

.npmrc

Lines changed: 0 additions & 1 deletion
This file was deleted.

README.md

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,10 @@ CONTRIBKIT_GITLAB_CONTRIBUTORS_REPO_ID=
6969
; Token requires the `read:user` and `read:org` scopes.
7070
CONTRIBKIT_GITHUB_TOKEN=
7171
CONTRIBKIT_GITHUB_LOGIN=
72+
; Optional data mode:
73+
; - sponsors: people sponsoring you (default)
74+
; - sponsees: people you have sponsored, including past sponsorships
75+
CONTRIBKIT_MODE=sponsors
7276

7377
; Patreon provider.
7478
; Create v2 API key at https://www.patreon.com/portal/registration/register-clients
@@ -144,6 +148,11 @@ Create `contribkit.config.js` file with:
144148
import { defineConfig, tierPresets } from '@lizardbyte/contribkit'
145149

146150
export default defineConfig({
151+
// Data mode:
152+
// - sponsors: people sponsoring you (default)
153+
// - sponsees: people you have sponsored, including past sponsorships
154+
mode: 'sponsors',
155+
147156
// Providers configs
148157
github: {
149158
login: 'antfu',
@@ -243,7 +252,7 @@ export default defineConfig({
243252

244253
<p align="center">
245254
<a href="https://cdn.jsdelivr.net/gh/antfu/static/sponsors.svg">
246-
<img src='https://cdn.jsdelivr.net/gh/antfu/static/sponsors.svg'/>
255+
<img src='https://cdn.jsdelivr.net/gh/antfu/static/sponsors.svg' alt="Sponsors"/>
247256
</a>
248257
</p>
249258

@@ -258,7 +267,7 @@ export default defineConfig({
258267

259268
<p align="center">
260269
<a href="https://cdn.jsdelivr.net/gh/antfu/static/sponsors.circles.svg">
261-
<img src='https://cdn.jsdelivr.net/gh/antfu/static/sponsors.circles.svg'/>
270+
<img src='https://cdn.jsdelivr.net/gh/antfu/static/sponsors.circles.svg' alt="Sponsors"/>
262271
</a>
263272
</p>
264273

package-lock.json

Lines changed: 20 additions & 30 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
"scripts": {
3737
"build": "unbuild",
3838
"stub": "unbuild --stub",
39-
"dev": "esno src/cli.ts",
39+
"dev": "tsx src/cli.ts",
4040
"test": "npm-run-all test:unit test:report test:lint test:typecheck",
4141
"test:unit": "jest --coverage",
4242
"test:report": "jest --reporters=jest-junit",
@@ -47,39 +47,39 @@
4747
},
4848
"dependencies": {
4949
"@crowdin/crowdin-api-client": "^1.41.2",
50-
"ansis": "^4.2.0",
51-
"cac": "^6.7.14",
52-
"consola": "^3.4.0",
53-
"dotenv": "^17.3.1",
54-
"ofetch": "^1.4.1",
50+
"ansis": "^4.3.0",
51+
"cac": "^7.0.0",
52+
"consola": "^3.4.2",
53+
"dotenv": "^17.4.2",
54+
"ofetch": "^1.5.1",
5555
"sharp": "^0.34.5",
56-
"unconfig": "^7.3.0"
56+
"unconfig": "^7.5.0"
5757
},
5858
"devDependencies": {
59-
"@antfu/ni": "^30.0.0",
60-
"@antfu/utils": "^9.1.0",
59+
"@antfu/ni": "^30.1.0",
60+
"@antfu/utils": "^9.3.0",
6161
"@babel/core": "7.29.7",
6262
"@babel/preset-env": "7.29.7",
6363
"@codecov/webpack-plugin": "2.0.1",
6464
"@eslint/js": "^10.0.1",
65-
"@fast-csv/parse": "^5.0.2",
65+
"@fast-csv/parse": "^5.0.7",
6666
"@types/d3-hierarchy": "^3.1.7",
67-
"@types/node": "^25.2.3",
68-
"bumpp": "^11.0.1",
67+
"@types/node": "^25.9.1",
68+
"bumpp": "^11.1.0",
6969
"d3-hierarchy": "^3.1.2",
70-
"eslint": "^10.0.0",
70+
"eslint": "^10.4.0",
7171
"eslint-plugin-jest": "29.15.2",
7272
"globals": "17.6.0",
7373
"jest": "30.4.2",
7474
"jest-environment-jsdom": "30.4.1",
7575
"jest-junit": "17.0.0",
76-
"jiti": "^2.4.2",
76+
"jiti": "^2.7.0",
7777
"normalize-url": "^9.0.0",
7878
"npm-run-all2": "9.0.1",
7979
"p-limit": "^7.3.0",
80-
"tsx": "^4.19.3",
81-
"typescript": "^5.8.2",
82-
"unbuild": "^3.5.0"
80+
"tsx": "^4.22.3",
81+
"typescript": "^5.9.2",
82+
"unbuild": "^3.6.1"
8383
},
8484
"jest": {
8585
"collectCoverageFrom": [

src/cli.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import cac from 'cac'
33
import { version } from '../package.json'
44
import { run } from './run'
55

6+
const RE_FILTER = /([<>=]+)(\d+)/
67
const cli = cac('contributors-svg')
78
.version(version)
89
.help()
@@ -36,7 +37,7 @@ cli.parse()
3637
* @param template
3738
*/
3839
function createFilterFromString(template: string): ContribkitConfig['filter'] {
39-
const [_, op, value] = template.split(/([<>=]+)/)
40+
const [_, op, value] = template.split(RE_FILTER)
4041
const num = Number.parseInt(value)
4142
if (op === '<')
4243
return s => s.monthlyDollars < num

src/configs/defaults.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,12 +45,13 @@ text {
4545
`
4646

4747
export const defaultConfig: ContribkitConfig = {
48+
mode: 'sponsors',
4849
width: 800,
4950
outputDir: './contribkit',
5051
cacheFile: '.cache.json',
52+
cacheFileSponsees: '.cache.sponsees.json',
5153
formats: ['json', 'svg', 'png'],
5254
tiers: defaultTiers,
53-
name: 'sponsors',
5455
includePrivate: false,
5556
svgInlineCSS: defaultInlineCSS,
5657
}

src/configs/env.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,10 @@ function getDeprecatedEnv(name: string, replacement: string) {
1010
}
1111

1212
export function loadEnv(): Partial<ContribkitConfig> {
13-
dotenv.config()
13+
dotenv.config({ quiet: true })
1414

1515
const config: Partial<ContribkitConfig> = {
16+
mode: process.env.CONTRIBKIT_MODE as ContribkitConfig['mode'] | undefined,
1617
github: {
1718
login: process.env.CONTRIBKIT_GITHUB_LOGIN || process.env.GITHUB_LOGIN,
1819
token: process.env.CONTRIBKIT_GITHUB_TOKEN || process.env.GITHUB_TOKEN,

src/configs/index.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,11 @@ export async function loadConfig(inlineConfig: ContribkitConfig = {}): Promise<R
6464
},
6565
} as Required<ContribkitConfig>
6666

67+
if (!['sponsors', 'sponsees'].includes(resolved.mode))
68+
throw new Error(`Invalid mode: ${resolved.mode}. Expected "sponsors" or "sponsees".`)
69+
70+
resolved.name = inlineConfig.name || config.name || env.name || resolved.mode
71+
6772
return resolved
6873
}
6974

src/processing/svg.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ export class SvgComposer {
113113

114114
generateSvg() {
115115
return `<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="0 0 ${this.config.width} ${this.height}" width="${this.config.width}" height="${this.height}">
116-
<!-- Generated by https://github.com/antfu/sponsorskit -->
116+
<!-- Generated by https://github.com/LizardByte/contribkit -->
117117
<style>${this.config.svgInlineCSS}</style>
118118
${this.body}
119119
</svg>

src/providers/afdian.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,11 @@ import { $fetch } from 'ofetch'
77
export const AfdianProvider: Provider = {
88
name: 'afdian',
99
fetchSponsors(config) {
10+
if (config.mode === 'sponsees') {
11+
console.warn('[contribkit] Afdian provider does not support `mode: "sponsees"` yet')
12+
return Promise.resolve([])
13+
}
14+
1015
return fetchAfdianSponsors(config.afdian)
1116
},
1217
}
@@ -29,7 +34,7 @@ export async function fetchAfdianSponsors(options: ContribkitConfig['afdian'] =
2934
let pages = 1
3035
do {
3136
const params = JSON.stringify({ page })
32-
const ts = Math.round(+new Date() / 1000)
37+
const ts = Math.round(Date.now() / 1000)
3338
const sign = md5(token, params, ts, userId)
3439
const sponsorshipData = await $fetch(sponsorshipApi, {
3540
method: 'POST',

0 commit comments

Comments
 (0)