|
| 1 | +# Contribute to Rin |
| 2 | + |
| 3 | +We are happy to accept your patches and contributions to this project. You just need to follow some small guidelines. |
| 4 | + |
| 5 | +## Commit-msg hooks |
| 6 | + |
| 7 | +We have a sample commit-msg hook in `scripts/commit-msg.sh`. Please run the following command to set it up: |
| 8 | + |
| 9 | +```sh |
| 10 | +ln -s ../../scripts/commit-msg.sh commit-msg |
| 11 | +``` |
| 12 | + |
| 13 | +On Windows, copy the `commit-msg.sh` file directly to `.git/hooks/commit-msg`. |
| 14 | + |
| 15 | +```powershell |
| 16 | +cp .\scripts\commit-msg.sh .\.git\hooks\commit-msg |
| 17 | +``` |
| 18 | + |
| 19 | +This will run the following checks before each commit: |
| 20 | + |
| 21 | +1. `tsc` Checks the code for syntax errors and unused variables and references. |
| 22 | +2. check that the commit message starts with one of the following: feature|chore|fix|docs|ci|style|test|pref |
| 23 | + |
| 24 | +If you want to skip the hook, run `git commit` with the `--no-verify` option. |
| 25 | + |
| 26 | +## Setting up your development environment |
| 27 | + |
| 28 | +1. Fork & Clone the repository |
| 29 | + |
| 30 | +2. Install [Node](https://nodejs.org/en/download/package-manager) & [Bun](https://bun.sh/) |
| 31 | + |
| 32 | +3. Install dependencies |
| 33 | + ```sh |
| 34 | + bun i |
| 35 | + ``` |
| 36 | + |
| 37 | +4. Copy the `wrangler.example.toml` file to `wrangler.toml` and fill in the necessary information |
| 38 | + |
| 39 | +:::tip |
| 40 | +Normally, you only need to fill in the `database_name` and `database_id` fields.\ |
| 41 | +S3 configuration is not required, but if you want to use the image upload feature, you need to fill in the S3 |
| 42 | +configuration. |
| 43 | +::: |
| 44 | + |
| 45 | +5. Copy the `client/.env.example` file to `client/.env` and change the necessary configuration. |
| 46 | + |
| 47 | +:::tip |
| 48 | +Typically, you only need to fill in `AVATAR`, `NAME` and `DESCRIPTION`. |
| 49 | +::: |
| 50 | + |
| 51 | +6. Perform the database migration |
| 52 | + |
| 53 | +:::tip |
| 54 | +If your database name (`database_name` in `wrangler.toml`) is not `rin`\ |
| 55 | +Please modify the `DB_NAME` field in `scripts/dev-migrator.sh` before performing the migration |
| 56 | +::: |
| 57 | +```sh |
| 58 | +bun m |
| 59 | +``` |
| 60 | + |
| 61 | +7. Configuring the `.dev.vars' file |
| 62 | + Copy `.dev.example.vars` to `.dev.vars` and fill in the required information |
| 63 | +
|
| 64 | +:::tip |
| 65 | +Typically, you need to fill in the `RIN_GITHUB_CLIENT_ID` and `RIN_GITHUB_CLIENT_SECRET` as well as |
| 66 | + the `JWT_SECRET` fields. |
| 67 | +In the development environment, you need to create a separate GitHub OAuth service with a callback address |
| 68 | + of `http://localhost:11498/user/github/callback` \ |
| 69 | +If you have changed the listening port of the server manually, please also change the port number in the callback |
| 70 | + address. |
| 71 | +::: |
| 72 | +
|
| 73 | +8. Start the development server |
| 74 | + ```sh |
| 75 | + bun dev |
| 76 | + ``` |
| 77 | +
|
| 78 | +9. For better control of the development server, you can run the client and server dev commands in two separate |
| 79 | + terminals: |
| 80 | + ```sh |
| 81 | + # tty1 |
| 82 | + bun dev:client |
| 83 | + |
| 84 | + # tty2 |
| 85 | + bun dev:server |
| 86 | + ``` |
| 87 | +
|
| 88 | +## Committing Changes |
| 89 | +
|
| 90 | +1. for simple patches, they can usually be reviewed within 10 minutes during the day in the UTC+8 time zone. 2. |
| 91 | +
|
| 92 | +2. Do not force push minor changes after the PR is ready for review. Doing so forces maintainers to re-read your entire |
| 93 | + PR, which delays the review process. 3. |
| 94 | +
|
| 95 | +3. Always keep the CI green. |
| 96 | +
|
| 97 | +4. If the CI fails on your PR, do not push it. Even if you don't think it's the patch's fault. If something else is |
| 98 | + breaking the CI, help fix the root cause before you push. |
| 99 | +
|
| 100 | +*Start writing code happily!* |
| 101 | +
|
| 102 | +## Code review |
| 103 | +
|
| 104 | +All commits, including those from project members, need to be reviewed. We use GitHub pull requests for this purpose. |
| 105 | +For more information on using pull requests, see the GitHub Help. |
0 commit comments