@cc123hh/gitee-cli 0.0.0-stage → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +236 -3
- package/bin/gitee.js +838 -0
- package/lib/args.js +165 -0
- package/lib/config.js +128 -0
- package/lib/httputil.js +208 -0
- package/package.json +24 -6
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 cc123hh
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,236 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
<h1 align="center">gitee</h1>
|
|
2
|
+
|
|
3
|
+
<p align="center">
|
|
4
|
+
<img src="https://gitee.com/cc123hh/gitee-cli/raw/main/docs/banner.jpg" alt="gitee banner" width="760">
|
|
5
|
+
</p>
|
|
6
|
+
|
|
7
|
+
<p align="center">
|
|
8
|
+
<img src="https://gitee.com/cc123hh/gitee-cli/raw/main/docs/badges/python.svg" alt="python 3.8+">
|
|
9
|
+
<img src="https://gitee.com/cc123hh/gitee-cli/raw/main/docs/badges/platform.svg" alt="platform">
|
|
10
|
+
<img src="https://gitee.com/cc123hh/gitee-cli/raw/main/docs/badges/deps.svg" alt="dependencies">
|
|
11
|
+
<img src="https://gitee.com/cc123hh/gitee-cli/raw/main/docs/badges/tests.svg" alt="tests">
|
|
12
|
+
<img src="https://gitee.com/cc123hh/gitee-cli/raw/main/docs/badges/license.svg" alt="license">
|
|
13
|
+
</p>
|
|
14
|
+
|
|
15
|
+
<p align="center">
|
|
16
|
+
<b>在终端里把 Gitee 管起来:建仓、推送、看 Issue,一条命令。</b><br>
|
|
17
|
+
零依赖 · 跨平台 · 单文件脚本 · 直接调 Gitee OpenAPI v5
|
|
18
|
+
</p>
|
|
19
|
+
|
|
20
|
+
---
|
|
21
|
+
|
|
22
|
+
## 📑 目录
|
|
23
|
+
|
|
24
|
+
- [快速开始](#-快速开始)
|
|
25
|
+
- [特性](#-特性)
|
|
26
|
+
- [安装](#-安装)
|
|
27
|
+
- [配置](#-配置)
|
|
28
|
+
- [命令一览](#-命令一览)
|
|
29
|
+
- [常见问题](#-常见问题)
|
|
30
|
+
- [License](#license)
|
|
31
|
+
|
|
32
|
+
## 🚀 快速开始
|
|
33
|
+
|
|
34
|
+
```console
|
|
35
|
+
$ gitee list
|
|
36
|
+
仓库 可见性 ★ 更新
|
|
37
|
+
--------------------------------------------------------------------
|
|
38
|
+
cc123hh/imgen-cli 公开 0 2026-11-04 13:15
|
|
39
|
+
cc123hh/emb-cli 公开 0 2026-11-04 12:40
|
|
40
|
+
cc123hh/private-notes 私有 0 2026-11-03 21:08
|
|
41
|
+
|
|
42
|
+
$ gitee info emb-cli
|
|
43
|
+
仓库: cc123hh/emb-cli
|
|
44
|
+
地址: https://gitee.com/cc123hh/emb-cli
|
|
45
|
+
可见性: 公开
|
|
46
|
+
统计: ★ 0 Fork 0 Watch 1
|
|
47
|
+
默认分支: main
|
|
48
|
+
|
|
49
|
+
$ cd ~/Scripts/new-tool && gitee push --public -d "我的新工具"
|
|
50
|
+
仓库不存在,正在创建 cc123hh/new-tool …
|
|
51
|
+
推送 main → https://gitee.com/cc123hh/new-tool.git …
|
|
52
|
+
已添加 remote origin
|
|
53
|
+
已设为公开
|
|
54
|
+
完成:https://gitee.com/cc123hh/new-tool
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
## ✨ 特性
|
|
58
|
+
|
|
59
|
+
| | |
|
|
60
|
+
|---|---|
|
|
61
|
+
| 🪶 **零依赖** | Python 版只用标准库;npm 版纯 Node 内置模块,双实现 |
|
|
62
|
+
| 🖥️ **跨平台** | macOS / Linux / Windows,安装脚本全覆盖 |
|
|
63
|
+
| 📦 **仓库管理** | 列出、查看、创建、删除、公开/私有切换 |
|
|
64
|
+
| 🚀 **建仓推送一体** | `gitee push` 自动建仓 + 推送 + 设可见性 |
|
|
65
|
+
| 📋 **Issue / PR** | 命令行直接看列表与状态 |
|
|
66
|
+
| 🀄 **中文对齐** | 表格按中日韩字符显示宽度排版,不乱 |
|
|
67
|
+
| 🔒 **令牌不落库** | 只从 `GITEE_TOKEN` 读取 |
|
|
68
|
+
|
|
69
|
+
## 📥 安装
|
|
70
|
+
|
|
71
|
+
> 前提:Python 3.8+(npm 版为纯 JS,只需 Node ≥ 16)
|
|
72
|
+
|
|
73
|
+
### macOS / Linux
|
|
74
|
+
|
|
75
|
+
```bash
|
|
76
|
+
git clone https://gitee.com/cc123hh/gitee-cli.git
|
|
77
|
+
cd gitee-cli
|
|
78
|
+
./install.sh
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
### Windows
|
|
82
|
+
|
|
83
|
+
```powershell
|
|
84
|
+
git clone https://gitee.com/cc123hh/gitee-cli.git
|
|
85
|
+
cd gitee-cli
|
|
86
|
+
powershell -ExecutionPolicy Bypass -File .\install.ps1
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
免安装直接用:`gitee.cmd list`
|
|
90
|
+
|
|
91
|
+
### 所有平台(pipx)
|
|
92
|
+
|
|
93
|
+
```bash
|
|
94
|
+
pipx install git+https://gitee.com/cc123hh/gitee-cli.git
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
### 所有平台(npm / pnpm)
|
|
98
|
+
|
|
99
|
+
纯 Node 实现(无需 Python),装完即得 `gitee` 命令:
|
|
100
|
+
|
|
101
|
+
```bash
|
|
102
|
+
pnpm add -g @cc123hh/gitee-cli # 或 npm i -g @cc123hh/gitee-cli
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
## ⚙️ 配置
|
|
106
|
+
|
|
107
|
+
优先级(高 → 低):**命令行参数(`--token` / `--api` / `--proxy` / `--timeout`)> 内部配置文件 > 环境变量 > 内置默认值**
|
|
108
|
+
|
|
109
|
+
推荐用内部配置持久化(不依赖环境变量注入,GUI 进程 / 非交互 shell 也稳定可用):
|
|
110
|
+
|
|
111
|
+
```bash
|
|
112
|
+
gitee set # 查看当前配置及来源(token 自动脱敏)
|
|
113
|
+
gitee set token <TOKEN> # 设置私人令牌(写入 ~/.config/gitee/config.json,600 权限)
|
|
114
|
+
gitee set proxy <URL> # 设置代理
|
|
115
|
+
gitee unset token # 删除某项
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
环境变量作为兜底层仍然支持:
|
|
119
|
+
|
|
120
|
+
```bash
|
|
121
|
+
# 必需(除非已 gitee set token):私人令牌(https://gitee.com/profile/personal_access_tokens)
|
|
122
|
+
export GITEE_TOKEN="你的令牌"
|
|
123
|
+
|
|
124
|
+
# 可选
|
|
125
|
+
export GITEE_API="https://gitee.com/api/v5"
|
|
126
|
+
export GITEE_PROXY="http://127.0.0.1:7890"
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
Windows:`setx GITEE_TOKEN "你的令牌"`
|
|
130
|
+
|
|
131
|
+
> 令牌权限建议只勾:`projects`(仓库读写)、`pull_requests`、`issues`。
|
|
132
|
+
|
|
133
|
+
## 🧰 命令一览
|
|
134
|
+
|
|
135
|
+
### 账号
|
|
136
|
+
|
|
137
|
+
```bash
|
|
138
|
+
gitee whoami
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
### 仓库
|
|
142
|
+
|
|
143
|
+
```bash
|
|
144
|
+
gitee list # 我的仓库(按更新时间)
|
|
145
|
+
gitee list -n 50 --json # 更多条数 / 原始 JSON
|
|
146
|
+
gitee info emb-cli # 详情
|
|
147
|
+
gitee create my-tool -d "简介" # 新建(默认私有)
|
|
148
|
+
gitee create my-tool --public # 尝试公开(空仓库需推送后生效)
|
|
149
|
+
gitee public my-tool # 设为公开
|
|
150
|
+
gitee private my-tool # 设为私有
|
|
151
|
+
gitee delete my-tool -y # 删除(-y 跳过确认)
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
### 一键建仓并推送
|
|
155
|
+
|
|
156
|
+
```bash
|
|
157
|
+
cd ~/Scripts/mytool
|
|
158
|
+
gitee push --public -d "我的小工具"
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
会自动:检查仓库是否存在 → 不存在则创建 → `git push` → 添加 `origin` → 需要时设为公开。
|
|
162
|
+
|
|
163
|
+
### Issue / Pull Request
|
|
164
|
+
|
|
165
|
+
```bash
|
|
166
|
+
gitee issues emb-cli # 列出 Issue
|
|
167
|
+
gitee issues emb-cli -s all -n 50
|
|
168
|
+
gitee issue view emb-cli IKVADU # 查看详情
|
|
169
|
+
gitee issue create emb-cli -t "发现bug" -b "复现步骤" -l bug -a 用户名 # 创建
|
|
170
|
+
gitee issue edit emb-cli IKVADU -t "新标题" -b "新正文" -l bug,docs # 修改
|
|
171
|
+
gitee issue edit emb-cli IKVADU -f 正文.md # 正文从 UTF-8 文件读(与 -b 互斥)
|
|
172
|
+
gitee issue close emb-cli IKVADU # 关闭(open 为重开)
|
|
173
|
+
gitee issue comment emb-cli IKVADU -m "已修复" # 加评论
|
|
174
|
+
gitee close emb-cli IKVADU # 顶层快捷:关闭 / 重开
|
|
175
|
+
gitee reopen emb-cli IKVADU
|
|
176
|
+
gitee prs emb-cli
|
|
177
|
+
```
|
|
178
|
+
|
|
179
|
+
`repo` 参数写 `仓库名` 会自动补上你的用户名,也可以写完整的 `owner/repo`;
|
|
180
|
+
Issue 相关命令省略 `repo` 时取当前目录同名仓库,只写编号也能定位
|
|
181
|
+
(如 `gitee issue view IKVADU`)。Issue 编号是 Gitee 生成的字符串标识
|
|
182
|
+
(如 `IKVADU`),带不带 `#` 前缀都可以(shell 里 `#` 要加引号)。
|
|
183
|
+
Gitee 无删除 Issue 的接口(已实测 405),`issue delete` 不提供。
|
|
184
|
+
|
|
185
|
+
## 📋 参数
|
|
186
|
+
|
|
187
|
+
| 参数 | 适用命令 | 说明 |
|
|
188
|
+
|---|---|---|
|
|
189
|
+
| `-n/--limit` | list / issues / prs | 返回条数 |
|
|
190
|
+
| `--json` | list | 输出原始 JSON |
|
|
191
|
+
| `-s/--state` | issues / prs / issue | 列表筛选 `open`/`closed`/`all`;`issue edit` 修改状态 `open`/`progressing`/`closed` |
|
|
192
|
+
| `-t/--title` | issue create / edit | 标题(create 必填) |
|
|
193
|
+
| `-b/--body` | issue create / edit | 正文(与 `-f` 互斥) |
|
|
194
|
+
| `-f/--file` | issue create / edit / comment | 从 UTF-8 文件读正文/评论 |
|
|
195
|
+
| `-l/--labels` | issue create / edit | 标签,逗号分隔 |
|
|
196
|
+
| `-a/--assignee` | issue create / edit | 负责人 username |
|
|
197
|
+
| `-m/--message` | issue comment | 评论内容 |
|
|
198
|
+
| `-y/--yes` | delete | 跳过确认 |
|
|
199
|
+
| `-d/--description` | create / push | 仓库简介 |
|
|
200
|
+
| `--public` | create / push | 目标可见性 |
|
|
201
|
+
| `--name` | push | 仓库名(默认取目录名) |
|
|
202
|
+
| `--api/--proxy/--timeout` | 全部 | 覆盖环境变量 |
|
|
203
|
+
|
|
204
|
+
## ❓ 常见问题
|
|
205
|
+
|
|
206
|
+
<details>
|
|
207
|
+
<summary><b>提示鉴权失败(401/403)?</b></summary>
|
|
208
|
+
|
|
209
|
+
检查 `GITEE_TOKEN` 是否有效、是否勾选 `projects` 权限;令牌过期请重新生成。
|
|
210
|
+
</details>
|
|
211
|
+
|
|
212
|
+
<details>
|
|
213
|
+
<summary><b>创建时选了公开,结果还是私有?</b></summary>
|
|
214
|
+
|
|
215
|
+
Gitee 限制空仓库不能设为公开。推送首个提交后再执行 `gitee public 仓库名`;用 `gitee push --public` 会自动在推送后切换。
|
|
216
|
+
</details>
|
|
217
|
+
|
|
218
|
+
<details>
|
|
219
|
+
<summary><b>push 报「不是 git 仓库」?</b></summary>
|
|
220
|
+
|
|
221
|
+
`gitee push` 不会替你 `git init`,只负责建仓与推送。请先初始化并提交。
|
|
222
|
+
</details>
|
|
223
|
+
|
|
224
|
+
<details>
|
|
225
|
+
<summary><b>表格里中文对不齐?</b></summary>
|
|
226
|
+
|
|
227
|
+
已按 `unicodedata.east_asian_width` 计算显示宽度;若终端字体非等宽仍可能有偏差,属字体问题。
|
|
228
|
+
</details>
|
|
229
|
+
|
|
230
|
+
## 🤝 贡献
|
|
231
|
+
|
|
232
|
+
欢迎 Issue / PR。
|
|
233
|
+
|
|
234
|
+
## License
|
|
235
|
+
|
|
236
|
+
[MIT](https://gitee.com/cc123hh/gitee-cli/blob/main/LICENSE)
|