开源许可证模板镜像,供 cnb-rs repo license 命令使用。
| 项 | 值 |
|---|---|
| 上游 commit | ed8cbf2 |
| 同步时间 | 2026-05-17 23:17:19 +08:00 (Asia/Shanghai) |
| 许可证数量 | 47 |
来自 github/choosealicense.com _licenses/ 目录的全部许可证文本。
.
├── README.md
├── seed.py # 一键从上游同步许可证的脚本
├── .gitignore # 忽略 seed.py 的临时目录
└── templates/ # 许可证数据全部在这里,与脚手架文件隔离
├── .metadata.json # 元数据:spdx_id / title / featured / hidden(cnb-rs --featured 读这里)
├── 0BSD.txt
├── Apache-2.0.txt
├── ...
└── Zlib.txt # 共 47 个
cnb-rs repo license list/view 命令只读 templates/ 子目录,根目录的 README.md / seed.py / .gitignore 不会污染许可证列表。
.metadata.json 由 seed.py 在解析上游 frontmatter 时一并生成,schema:
{
"version": 1,
"upstream_commit": "<sha>",
"synced_at": "<北京时间>",
"total": 47,
"featured_count": 3,
"hidden_count": 0,
"licenses": [
{"spdx_id": "MIT", "title": "MIT License", "featured": true, "hidden": false}
]
}
cnb-rs repo license list --featured 会拉这个文件 filter;如果文件缺失(手动维护的仓库 / 旧版 seed),会 fallback 列出所有 license 并给出 warn。
每个许可证放在 templates/ 目录,文件名 <SPDX-ID>.txt,SPDX-ID 大小写遵循 SPDX 标准,取自上游 frontmatter 的 spdx-id 字段(如 MIT、Apache-2.0、BSD-3-Clause)。
文件内容已剥除上游的 YAML frontmatter(站点用元数据,含 title / description / permissions 等字段),仅保留可直接复制到项目 LICENSE 文件的纯文本。
许可证文本中的 [year] / [fullname] / [email] 等占位符保留原样,由使用者按需替换。
# 列出所有可用许可证(自动剥除 .txt 后缀)
cnb-rs repo license list
# 只列 featured 的(MIT / Apache-2.0 / GPL-3.0)
cnb-rs repo license list --featured
# 查看指定许可证内容(裸 SPDX-ID 即可)
cnb-rs repo license view MIT
cnb-rs repo license view Apache-2.0
# 直接写入到当前目录的 LICENSE
cnb-rs repo license view MIT > LICENSE
需要 Python 3.8+ 和 git 在 PATH。脚本只用标准库,无需 pip install。
# 默认从 GitHub 直连,跑完停在 staged 区让你 review
python3 seed.py
# 或指定镜像(国内场景)/ 已有的本地 clone
python3 seed.py --upstream https://kkgithub.com/github/choosealicense.com.git
python3 seed.py --upstream /path/to/local/github-choosealicense-clone
# 跑完自动 git commit(commit message 自动带 SHA + 北京时间 + 许可证数)
python3 seed.py --commit
# 跑完自动 commit + push(--push 隐含 --commit)
python3 seed.py --commit --push
seed.py 会:
_upstream/(远端 URL 走 --depth=1,本地路径全量 clone;目录被 .gitignore 忽略)templates/ 整个清空后重建_upstream/_licenses/*.txt,剥 YAML frontmatter,按 spdx-id 字段重命名为 templates/<SPDX-ID>.txttitle / featured / hidden / nickname 字段写到 templates/.metadata.jsonBEGIN_UPSTREAM_STATUS ... END_UPSTREAM_STATUS 段_upstream/--commit,自动 git add -A && git commit;如果传了 --push,再 git push不带 --commit 时跑完会停留,请 git diff 检查改动后手工 commit & push。