Skip to content

Commit 039b6a0

Browse files
authored
Update CONTRIBUTING.md to include instructions to run sync script locally (#135)
1 parent 42823b0 commit 039b6a0

2 files changed

Lines changed: 36 additions & 15 deletions

File tree

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1-
/node_modules
1+
/node_modules
2+
/data

CONTRIBUTING.md

Lines changed: 34 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,42 +2,62 @@
22

33
Thank you for your interest in contributing to CodePVG LeetCode Ranking.
44

5-
## Getting Started
5+
## Local Setup & Development
66

7-
1. Fork the repository.
8-
2. Clone your fork:
7+
1. Fork the repository and clone your fork:
98

109
```bash
1110
git clone https://github.com/YOUR-USERNAME/leetcode-ranking.git
1211
cd leetcode-ranking
1312
```
1413

15-
3. Create a new branch for your changes:
14+
2. Create a new branch for your feature/fix:
1615

1716
```bash
1817
git checkout -b feature/your-feature-name
1918
```
2019

21-
## Development
22-
23-
Install dependencies:
20+
3. Install dependencies:
2421

2522
```bash
2623
npm install
27-
# or
28-
npm i
2924
```
3025

31-
Run the project locally:
26+
4. Start the local server:
3227

3328
```bash
3429
npm run dev
35-
# or
36-
node server.js
37-
# or
38-
npm start
3930
```
4031

32+
### Testing the Sync Script Locally
33+
34+
The leaderboard data (such as `users.json` and historical stats) lives in a separate data repository to keep the main codebase clean. To test the `scripts/sync-leaderboard.js` script locally:
35+
36+
1. Clone the data repository into a folder named `data` inside the project root (this folder is already ignored in `.gitignore`, so you never have to worry about accidentally pushing local data changes back to the main repository):
37+
38+
```bash
39+
git clone https://github.com/codepvg/leetcode-ranking-data.git data
40+
```
41+
42+
2. Run the synchronization script. It will automatically detect your local `data` folder and pull stats from the LeetCode API based on the users inside `data/users.json`:
43+
44+
```bash
45+
node scripts/sync-leaderboard.js
46+
```
47+
48+
3. Once it finishes, you can preview the newly generated `overall.json`, `daily.json`, `weekly.json`, and `monthly.json` files inside the `data` folder to verify your script changes.
49+
50+
_(Note: To prevent GitHub API rate limits when the script fetches historical commit data, you can optionally set a Personal Access Token via the `DATA_REPO_TOKEN` environment variable.)_
51+
52+
### Project Structure Overview
53+
54+
Familiarize yourself with the core directories:
55+
56+
- **`frontend/`**: Contains all static assets, HTML, CSS, and client-side JS controlling the UI.
57+
- **`scripts/`**: Contains automation logic (e.g., `sync-leaderboard.js`) used to fetch updates from the LeetCode API.
58+
- **`.github/workflows/`**: CI/CD GitHub Actions driving data synchronization and code formatting.
59+
- **`server.js`**: The Express server delivering the frontend files and configuring important security headers.
60+
4161
## Before You Start
4262

4363
- Check whether an issue already exists for the change you want to make.

0 commit comments

Comments
 (0)