Skip to content

Commit

Permalink
Merge pull request #21 from ryan4yin/feat-contributing-guidelines
Browse files Browse the repository at this point in the history
feat: add flake for dev, and contributing guidelines
  • Loading branch information
ryan4yin authored Mar 26, 2024
2 parents aac195a + 8b931fb commit d8366ba
Show file tree
Hide file tree
Showing 7 changed files with 353 additions and 7 deletions.
62 changes: 62 additions & 0 deletions .github/CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@

# 贡献指南

> _一个真正的社区,只有在成员之间进行有意义互动,加深彼此了解并促进学习的情况下才能存在_
如果你想帮助完善这份文档,或者有些有趣的想法想加到这份文档中,或者发现了一些错误 - 请 fork 这个项目,添加你的修改,然后提交 Pull Request 到 main 分支。

## 使用 GitHub 的 issues 报告错误

[GitHub issues](https://github.com/NixOS-CN/nixos-cn.github.io/issues)
是报告错误、特性请求和提交 Pull Request 的首选渠道!

但是请遵守以下限制:

-**不要**使用 issues 来请求帮助解决某问题,此类需求请移步 NixOS-CN 的 Telegram 或 Matrix 群组。
-**不要**偏离或捣乱问题。保持讨论的主题性,并尊重他人的意见。

## 许可证

本网站或项目内容采用 [Creative Commons Attribution Share Alike 4.0 International](LICENSES/CC-BY-SA-4.0.txt)
许可,样例代码则采用 [MIT](LICENSES/MIT.txt) 开源许可证。

贡献此项目即表明,您同意您贡献的内容将受到上述许可证的约束。

## Pull Request

创建 Pull Request 时,请遵守以下规则:

- 基于最新的 main 分支编写代码,以避免内容冲突
- 可能会有代码审查,以帮助完善您的 PR
- 请在 PR 中解释清楚现存问题,以及此 PR 如何解决这些问题


## 开发环境设置

您需要安装 [nix](https://github.com/NixOS/nix) 并启用 flakes 实验特性。

克隆仓库后,首先进入一个已安装 pnpm、vitepress、拼写检查器和 markdown linter 的环境:

```sh
$ nix develop
$ pnpm install
```

在本地启动文档站点,并实时重新加载源代码:


```sh
$ pnpm run docs:dev
```

如果您进行了大量更改,在提交拉取请求之前,请运行以下命令以检查拼写错误和格式化文档:

> 通常,`nix develop` 会在您提交之前添加一个预提交钩子来运行以下命令。

```sh
$ typos -w
$ prettier --write .
```

执行上述命令后,访问 <http://localhost:5173> 并尝试修改源代码。您将获得实时更新。
13 changes: 12 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,15 @@ src/.vuepress/.temp/
src/.vuepress/dist/
.vuepress/.cache/
.vuepress/.temp/
.vuepress/dist/
.vuepress/dist/

.DS_Store
.idea/
.vscode/
*.cpuprofile
*.local
*.log
*.pdf
.eslintcache
.direnv/
.pre-commit-config.yaml
9 changes: 9 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
LICENSE.md
dist/
pnpm-lock.yaml
flake.lock
vercel.json
cache
temp
.temp
.github/
6 changes: 6 additions & 0 deletions .prettierrc.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# https://prettier.io/docs/en/options
semi: false
singleQuote: false
printWidth: 80
proseWrap: always # always change wrapping in markdown text
trailingComma: es5
17 changes: 11 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

## 项目结构

本项目使用 [VuePress](https://vuepress.vuejs.org/zh/)
框架,辅以 [vuepress-hope-theme](https://theme-hope.vuejs.press/zh/) 主题完成整体构建。
本项目使用 [VuePress](https://vuepress.vuejs.org/zh/) 框架,辅以
[vuepress-hope-theme](https://theme-hope.vuejs.press/zh/) 主题完成整体构建。

```tree
├─.vuepress
Expand All @@ -20,13 +20,18 @@
└─lang // 语言教程
```

其中最为重要的两个目录是 `docs``guide`
,你应该把文档或教程分别放置在那里,如果有必要,可以单独分出一个子文件夹。若要配置顶部导航栏请修改 `navbar.ts`
,侧边栏则修改 `sidebar.ts`
其中最为重要的两个目录是 `docs``guide` ,你应该把文档或教程分别放置在那里,
如果有必要,可以单独分出一个子文件夹。若要配置顶部导航栏请修改 `navbar.ts` ,侧
边栏则修改 `sidebar.ts`

## 贡献指南

在提交 Pull Request 之前,请先阅读 [贡献指南](/.github/CONTRIBUTING.md)

## 许可证

本网站或项目内容采用 [Creative Commons Attribution Share Alike 4.0 International](LICENSES/CC-BY-SA-4.0.txt)
本网站或项目内容采用
[Creative Commons Attribution Share Alike 4.0 International](LICENSES/CC-BY-SA-4.0.txt)
许可,样例代码则采用 [MIT](LICENSES/MIT.txt) 开源许可证,使用请遵循协议。

一些特别标注的文件或片段可能采用了不同的开源许可协议,请多加注意。
186 changes: 186 additions & 0 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

67 changes: 67 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
{
description = "A Nix-flake-based Node.js development environment";

inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-23.11";
flake-utils.url = "github:numtide/flake-utils";
pre-commit-hooks.url = "github:cachix/pre-commit-hooks.nix";
};

outputs = {
self,
nixpkgs,
flake-utils,
pre-commit-hooks,
}:
flake-utils.lib.eachDefaultSystem (system: let
overlays = [
(self: super: rec {
nodejs = super.nodejs_20;
pnpm = super.nodePackages.pnpm;
yarn = super.yarn.override {inherit nodejs;};
prettier = super.nodePackages.prettier;
})
];
pkgs = import nixpkgs {inherit overlays system;};
packages = with pkgs; [
nodejs
pnpm
yarn
prettier

git
typos
alejandra
];
in {
checks = {
pre-commit-check = pre-commit-hooks.lib.${system}.run {
src = ./.;
hooks = {
typos.enable = true; # Source code spell checker
alejandra.enable = true; # Nix linter
prettier.enable = true; # Markdown & TS formatter
};
settings = {
typos = {
write = true; # Automatically fix typos
ignored-words = [];
};
prettier = {
write = true; # Automatically format files
configPath = "./.prettierrc.yaml";
};
};
};
};

devShells.default = pkgs.mkShell {
inherit packages;

shellHook = ''
echo "node `${pkgs.nodejs}/bin/node --version`"
${self.checks.${system}.pre-commit-check.shellHook}
'';
};
});
}

0 comments on commit d8366ba

Please sign in to comment.