Skip to content

Commit 246437a

Browse files
authored
[refactor] simplify Type & Logic based on LinkeDOM (#2)
* [refactor] simplify Type & Logic based on LinkeDOM [add] VS Code extensions [optimize] replace Tab with Space for Indent * [fix] Unit tests [optimize] run Test in Git hook * [optimize] simplify Test Action steps [optimize] format Read Me documents
1 parent e8716e5 commit 246437a

15 files changed

Lines changed: 1402 additions & 394 deletions

File tree

.editorconfig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
root = true
33

44
[*]
5-
indent_style = tab
5+
indent_style = space
66
end_of_line = lf
77
charset = utf-8
88
trim_trailing_whitespace = true

.github/workflows/test.yml

Lines changed: 12 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,45 +1,34 @@
11
name: Test
2-
32
on:
43
push:
5-
branches: [main]
4+
branches:
5+
- main
66
pull_request:
7-
branches: [main]
7+
branches:
8+
- main
89

910
jobs:
1011
test:
1112
runs-on: ubuntu-latest
1213

1314
strategy:
1415
matrix:
15-
node-version: [18.x]
16+
node-version:
17+
- 20.x
18+
- 22.x
1619

1720
steps:
1821
- uses: actions/checkout@v4
1922

23+
- uses: pnpm/action-setup@v4
24+
with:
25+
version: 9
26+
2027
- name: Use Node.js ${{ matrix.node-version }}
2128
uses: actions/setup-node@v4
2229
with:
2330
node-version: ${{ matrix.node-version }}
24-
25-
- name: Install pnpm
26-
uses: pnpm/action-setup@v2
27-
with:
28-
version: 8
29-
run_install: false
30-
31-
- name: Get pnpm store directory
32-
shell: bash
33-
run: |
34-
echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV
35-
36-
- name: Setup pnpm cache
37-
uses: actions/cache@v3
38-
with:
39-
path: ${{ env.STORE_PATH }}
40-
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
41-
restore-keys: |
42-
${{ runner.os }}-pnpm-store-
31+
cache: pnpm
4332

4433
- name: Install dependencies
4534
run: pnpm install

.husky/pre-commit

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
npm test

.npmrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
auto-install-peers = false

.prettierrc

Lines changed: 0 additions & 6 deletions
This file was deleted.

.vscode/extensions.json

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{
2+
"recommendations": [
3+
"yzhang.markdown-all-in-one",
4+
"redhat.vscode-yaml",
5+
"akamud.vscode-caniuse",
6+
"visualstudioexptteam.intellicode-api-usage-examples",
7+
"pflannery.vscode-versionlens",
8+
"christian-kohler.npm-intellisense",
9+
"esbenp.prettier-vscode",
10+
"rangav.vscode-thunder-client",
11+
"cweijan.vscode-database-client2",
12+
"eamodio.gitlens",
13+
"github.vscode-pull-request-github",
14+
"github.vscode-github-actions",
15+
"github.copilot"
16+
]
17+
}

README.md

Lines changed: 88 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -4,31 +4,31 @@
44
<img src="https://github.githubassets.com/images/modules/profile/achievements/pull-shark-default.png" width="100" height="100" alt="Pull Shark Achievement" />
55
</p>
66

7-
[![License](https://img.shields.io/github/license/wangrunlin/github-achievements-api)](https://github.com/wangrunlin/github-achievements-api/blob/main/LICENSE)
8-
[![GitHub package.json version](https://img.shields.io/github/package-json/v/wangrunlin/github-achievements-api)](https://github.com/wangrunlin/github-achievements-api/blob/main/package.json)
9-
[![GitHub last commit](https://img.shields.io/github/last-commit/wangrunlin/github-achievements-api)](https://github.com/wangrunlin/github-achievements-api/commits)
10-
[![Test Status](https://img.shields.io/github/actions/workflow/status/wangrunlin/github-achievements-api/test.yml?label=test)](https://github.com/wangrunlin/github-achievements-api/actions)
11-
[![Node Version](https://img.shields.io/node/v/github-achievements-api)](https://nodejs.org)
12-
[![TypeScript](https://img.shields.io/badge/TypeScript-5.5.2-blue.svg)](https://www.typescriptlang.org/)
13-
[![code style: prettier](https://img.shields.io/badge/code_style-prettier-ff69b4.svg)](https://github.com/prettier/prettier)
14-
[![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg)](https://makeapullrequest.com)
15-
[![GitHub stars](https://img.shields.io/github/stars/wangrunlin/github-achievements-api)](https://github.com/wangrunlin/github-achievements-api/stargazers)
16-
[![GitHub forks](https://img.shields.io/github/forks/wangrunlin/github-achievements-api)](https://github.com/wangrunlin/github-achievements-api/network)
17-
[![GitHub issues](https://img.shields.io/github/issues/wangrunlin/github-achievements-api)](https://github.com/wangrunlin/github-achievements-api/issues)
18-
[![Visitors](https://visitor-badge.laobi.icu/badge?page_id=wangrunlin.github-achievements-api)](https://github.com/wangrunlin/github-achievements-api)
19-
[![Ko-fi](https://img.shields.io/badge/Ko--fi-Support-orange)](https://ko-fi.com/wangrunlin)
20-
21-
English | [简体中文](README_zh.md)
7+
[![License](https://img.shields.io/github/license/wangrunlin/github-achievements-api)][1]
8+
[![GitHub package.json version](https://img.shields.io/github/package-json/v/wangrunlin/github-achievements-api)][2]
9+
[![GitHub last commit](https://img.shields.io/github/last-commit/wangrunlin/github-achievements-api)][3]
10+
[![Test Status](https://img.shields.io/github/actions/workflow/status/wangrunlin/github-achievements-api/test.yml?label=test)][4]
11+
[![Node Version](https://img.shields.io/node/v/github-achievements-api)][5]
12+
[![TypeScript](https://img.shields.io/badge/TypeScript-5.5.2-blue.svg)][6]
13+
[![code style: prettier](https://img.shields.io/badge/code_style-prettier-ff69b4.svg)][7]
14+
[![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg)][8]
15+
[![GitHub stars](https://img.shields.io/github/stars/wangrunlin/github-achievements-api)][9]
16+
[![GitHub forks](https://img.shields.io/github/forks/wangrunlin/github-achievements-api)][10]
17+
[![GitHub issues](https://img.shields.io/github/issues/wangrunlin/github-achievements-api)][11]
18+
[![Visitors](https://visitor-badge.laobi.icu/badge?page_id=wangrunlin.github-achievements-api)][12]
19+
[![Ko-fi](https://img.shields.io/badge/Ko--fi-Support-orange)][13]
20+
21+
English | [简体中文][14]
2222

2323
A simple API service for retrieving GitHub user achievements information. Built with Cloudflare Workers.
2424

2525
## Live Demo
2626

27-
- [https://github-achievements-api.wangrunlin.workers.dev](https://github-achievements-api.wangrunlin.workers.dev)
27+
- [https://github-achievements-api.wangrunlin.workers.dev][15]
2828

2929
## Deploy to Cloudflare Workers
3030

31-
[![Deploy to Cloudflare Workers](https://deploy.workers.cloudflare.com/button)](https://deploy.workers.cloudflare.com/?url=https://github.com/wangrunlin/github-achievements-api)
31+
[![Deploy to Cloudflare Workers](https://deploy.workers.cloudflare.com/button)][16]
3232

3333
## Features
3434

@@ -56,25 +56,28 @@ GET https://<your-worker>.workers.dev/wangrunlin
5656

5757
```json
5858
{
59-
"total": {
60-
"raw": 5, // Raw achievement count (without tiers)
61-
"weighted": 8 // Weighted achievement count (with tiers)
62-
},
63-
"achievements": [
64-
{
65-
"type": "pair-extraordinaire",
66-
"tier": 3
67-
},
68-
{
69-
"type": "pull-shark",
70-
"tier": 2
71-
},
72-
{
73-
"type": "quickdraw",
74-
"tier": 1
75-
}
76-
// ...
77-
]
59+
"total": {
60+
"raw": 5, // Raw achievement count (without tiers)
61+
"weighted": 8 // Weighted achievement count (with tiers)
62+
},
63+
"achievements": [
64+
{
65+
"type": "pair-extraordinaire",
66+
"tier": 3,
67+
"image": "https://some.cdn.com/path/to/pair-extraordinaire.png"
68+
},
69+
{
70+
"type": "pull-shark",
71+
"tier": 2,
72+
"image": "https://some.cdn.com/path/to/pull-shark.png"
73+
},
74+
{
75+
"type": "quickdraw",
76+
"tier": 1,
77+
"image": "https://some.cdn.com/path/to/quickdraw.png"
78+
}
79+
// ...
80+
]
7881
}
7982
```
8083

@@ -102,7 +105,7 @@ Example error response:
102105

103106
```json
104107
{
105-
"error": "Failed to fetch GitHub achievements: Not Found"
108+
"error": "Failed to fetch GitHub achievements: Not Found"
106109
}
107110
```
108111

@@ -120,13 +123,13 @@ Example error response:
120123

121124
Support this project by becoming a sponsor. Your logo will show up here with a link to your website.
122125

123-
[![Ko-fi](https://ko-fi.com/img/githubbutton_sm.svg)](https://ko-fi.com/wangrunlin)
126+
[![Ko-fi](https://ko-fi.com/img/githubbutton_sm.svg)][17]
124127

125-
[Other sponsorship options](https://alin.run/sponsor)
128+
[Other sponsorship options][18]
126129

127130
## Who's using GitHub Achievements API?
128131

129-
Are you using this API? [Let us know](https://github.com/wangrunlin/github-achievements-api/issues/new) and we'll add your logo here!
132+
Are you using this API? [Let us know][19] and we'll add your logo here!
130133

131134
## Local Development
132135

@@ -155,13 +158,13 @@ pnpm test
155158

156159
## Deployment
157160

158-
1. Login to Cloudflare
161+
1. Login to Cloudflare
159162

160163
```bash
161164
pnpm dlx wrangler login
162165
```
163166

164-
2. Deploy Worker
167+
2. Deploy Worker
165168

166169
```bash
167170
pnpm deploy
@@ -182,21 +185,21 @@ MIT
182185

183186
Issues and Pull Requests are welcome!
184187

185-
1. Fork the repository
186-
2. Create your feature branch (`git checkout -b feature/AmazingFeature`)
187-
3. Commit your changes (`git commit -m 'Add some AmazingFeature'`)
188-
4. Push to the branch (`git push origin feature/AmazingFeature`)
189-
5. Open a Pull Request
188+
1. Fork the repository
189+
2. Create your feature branch (`git checkout -b feature/AmazingFeature`)
190+
3. Commit your changes (`git commit -m 'Add some AmazingFeature'`)
191+
4. Push to the branch (`git push origin feature/AmazingFeature`)
192+
5. Open a Pull Request
190193

191194
## Author
192195

193-
[Leo Wang](https://github.com/wangrunlin)
196+
[Leo Wang][20]
194197

195198
## Available Achievements
196199

197200
Here are all the achievements currently available on GitHub:
198201

199-
[View more details about GitHub Achievements](https://github.com/drknzz/GitHub-Achievements)
202+
[View more details about GitHub Achievements][21]
200203

201204
| Achievement | Name | Description | Max Tiers |
202205
| -------------------------------------------------------------------------------------------------------------------------------------- | --------------------- | ------------------------------------------------------------------- | --------- |
@@ -214,10 +217,39 @@ Here are all the achievements currently available on GitHub:
214217

215218
Thanks to these awesome projects and resources:
216219

217-
- [GitHub](https://github.com) - For providing the achievement system
218-
- [Cloudflare Workers](https://workers.cloudflare.com) - For the serverless platform
219-
- [GitHub Achievements List](https://github.com/drknzz/GitHub-Achievements) - For the comprehensive achievements documentation
220-
- [TypeScript](https://www.typescriptlang.org) - For the typed JavaScript
221-
- [Vitest](https://vitest.dev) - For the testing framework
222-
- [Wrangler](https://developers.cloudflare.com/workers/wrangler/) - For the development & deployment tool
223-
- [pnpm](https://pnpm.io) - For the fast package manager
220+
- [GitHub][22] - For providing the achievement system
221+
- [Cloudflare Workers][23] - For the serverless platform
222+
- [GitHub Achievements List][24] - For the comprehensive achievements documentation
223+
- [TypeScript][25] - For the typed JavaScript
224+
- [Vitest][26] - For the testing framework
225+
- [Wrangler][27] - For the development & deployment tool
226+
- [pnpm][28] - For the fast package manager
227+
228+
[1]: https://github.com/wangrunlin/github-achievements-api/blob/main/LICENSE
229+
[2]: https://github.com/wangrunlin/github-achievements-api/blob/main/package.json
230+
[3]: https://github.com/wangrunlin/github-achievements-api/commits
231+
[4]: https://github.com/wangrunlin/github-achievements-api/actions
232+
[5]: https://nodejs.org
233+
[6]: https://www.typescriptlang.org/
234+
[7]: https://github.com/prettier/prettier
235+
[8]: https://makeapullrequest.com
236+
[9]: https://github.com/wangrunlin/github-achievements-api/stargazers
237+
[10]: https://github.com/wangrunlin/github-achievements-api/network
238+
[11]: https://github.com/wangrunlin/github-achievements-api/issues
239+
[12]: https://github.com/wangrunlin/github-achievements-api
240+
[13]: https://ko-fi.com/wangrunlin
241+
[14]: README_zh.md
242+
[15]: https://github-achievements-api.wangrunlin.workers.dev
243+
[16]: https://deploy.workers.cloudflare.com/?url=https://github.com/wangrunlin/github-achievements-api
244+
[17]: https://ko-fi.com/wangrunlin
245+
[18]: https://alin.run/sponsor
246+
[19]: https://github.com/wangrunlin/github-achievements-api/issues/new
247+
[20]: https://github.com/wangrunlin
248+
[21]: https://github.com/drknzz/GitHub-Achievements
249+
[22]: https://github.com
250+
[23]: https://workers.cloudflare.com
251+
[24]: https://github.com/drknzz/GitHub-Achievements
252+
[25]: https://www.typescriptlang.org
253+
[26]: https://vitest.dev
254+
[27]: https://developers.cloudflare.com/workers/wrangler/
255+
[28]: https://pnpm.io

0 commit comments

Comments
 (0)