* docs: update contributing docs * Update docs/content/zh-Hans/docs/contributing/index.md Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com> * Apply suggestions from code review Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com> --------- Co-authored-by-agent: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com> Co-authored-by: Rin <shinohara-rin@users.noreply.github.com>
5.2 KiB
title, description
| title | description |
|---|---|
| 环境配置与基础准备 | 参与并贡献 Project AIRI |
你好呀!感谢你有兴趣参与这个项目。本指南将帮助你快速上手
前置准备
Windows 平台相关设置
-
下载 Visual Studio, 根据这个教程安装 https://rust-lang.github.io/rustup/installation/windows-msvc.html#walkthrough-installing-visual-studio-2022
安装时请确保勾选了 Windows SDK 和 MSVC C++ build tools
::: tip
建议使用Visual Studio 2022 版以达到更好的兼容性
:::
-
打开 PowerShell
-
安装
scoopSet-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser Invoke-RestMethod -Uri https://get.scoop.sh | Invoke-Expression -
通过
scoop安装git, Node.js,rustup和msvcscoop install git nodejs rustup # Rust 相关依赖 # 如果你不打算涉及 crates 或者 apps/tamagotchi 的开发,该步骤可跳过 scoop install main/rust-msvc # Windows 平台所需内容 rustup toolchain install stable-x86_64-pc-windows-msvc rustup default stable-x86_64-pc-windows-msvc -
通过
corepack安装pnpmcorepack enable corepack prepare pnpm@latest --activate
macOS setup
-
打开 Terminal, (或者 iTerm2, Ghostty, Kitty, etc.)
-
通过
brew安装git,nodebrew install git node -
通过
corepack安装pnpmcorepack enable corepack prepare pnpm@latest --activate
Linux setup
-
打开 Terminal
-
请按照该说明的内容 nodesource/distributions: NodeSource Node.js Binary Distributions 安装
node -
请参考该页面 Git 安装
git -
通过
corepack安装pnpmcorepack enable corepack prepare pnpm@latest --activate -
如果你想进行桌面端的开发,你还需要下载如下依赖:
sudo apt install \ libssl-dev \ libglib2.0-dev \ libgtk-3-dev \ libjavascriptcoregtk-4.1-dev \ libwebkit2gtk-4.1-dev
如果你之前已经参与并贡献过本项目
::: tip
如果你并未克隆过该项目仓库,本步骤可跳过
:::
请确保你的本地仓库与主仓库保持最新同步:
git fetch --all
git checkout main
git pull upstream main --rebase
如果你有自己的开发/工作分支,请按照如下方式同步至主分支:
git checkout <your-branch-name>
git rebase main
Fork 本项目
请点击 moeru-ai/airi 页面右上角的 Fork 按钮来 fork(分叉一个归属于你的账户的副本)本项目。
克隆本项目
git clone https://github.com/<your-github-username>/airi.git
cd airi
创建你自己的工作分支
git checkout -b <your-branch-name>
安装依赖项
corepack enable
pnpm install
# Rust相关依赖
# 如果你不打算涉及 crates 或者 apps/tamagotchi 的开发,该步骤可跳过
cargo fetch
::: tip
推荐安装 @antfu/ni 来简化脚本命令
corepack enable
npm i -g @antfu/ni
安装后,你可以:
- 用
ni来替代pnpm install、npm install和yarn install命令。 - 用
nr来替代pnpm run、npm run和yarn run命令。
你无需费心选择包管理器, ni 会自动适配。
:::
提交代码(Commit)
提交前请检查
提交前请确保代码已通过 Lint(静态分析器)和 类型安全检查:
pnpm lint && pnpm typecheck
::: tip
如果你安装了 @antfu/ni,你可以通过 nr 来运行命令:
nr lint && nr typecheck
:::
执行提交
git add .
git commit -m "<your-commit-message>"
将你的代码推送(push)至先前 fork 或者拥有写入权限的 AIRI 仓库
git push origin <your-branch-name> -u
现在,你应该可以在 GitHub 上看到你的分支。
::: tip
如果这是你第一次贡献本项目,请添加上游(upstream,指向本项目):
git remote add upstream https://github.com/moeru-ai/airi.git
:::
创建拉取请求(Pull Request)
请前往 moeru-ai/airi 页面:
- 点击 Pull requests 按钮;
- 再点击 New pull request 按钮;
- 选择 Compare across forks 链接;
- 然后选择你自己fork的代码仓库。
请检查并确认你的改动,最后点击 Create pull request 按钮完成拉取请求创建。
好欸!搞定了~
恭喜你成功地为本项目提交了首次贡献!现在可以等待项目的维护人员来审核你的拉取请求啦~