|
2 | 2 |
|
3 | 3 | Thank you for your interest in contributing to CodePVG LeetCode Ranking. |
4 | 4 |
|
5 | | -## Getting Started |
| 5 | +## Local Setup & Development |
6 | 6 |
|
7 | | -1. Fork the repository. |
8 | | -2. Clone your fork: |
| 7 | +1. Fork the repository and clone your fork: |
9 | 8 |
|
10 | 9 | ```bash |
11 | 10 | git clone https://github.com/YOUR-USERNAME/leetcode-ranking.git |
12 | 11 | cd leetcode-ranking |
13 | 12 | ``` |
14 | 13 |
|
15 | | -3. Create a new branch for your changes: |
| 14 | +2. Create a new branch for your feature/fix: |
16 | 15 |
|
17 | 16 | ```bash |
18 | 17 | git checkout -b feature/your-feature-name |
19 | 18 | ``` |
20 | 19 |
|
21 | | -## Development |
22 | | - |
23 | | -Install dependencies: |
| 20 | +3. Install dependencies: |
24 | 21 |
|
25 | 22 | ```bash |
26 | 23 | npm install |
27 | | -# or |
28 | | -npm i |
29 | 24 | ``` |
30 | 25 |
|
31 | | -Run the project locally: |
| 26 | +4. Start the local server: |
32 | 27 |
|
33 | 28 | ```bash |
34 | 29 | npm run dev |
35 | | -# or |
36 | | -node server.js |
37 | | -# or |
38 | | -npm start |
39 | 30 | ``` |
40 | 31 |
|
| 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 | + |
41 | 61 | ## Before You Start |
42 | 62 |
|
43 | 63 | - Check whether an issue already exists for the change you want to make. |
|
0 commit comments