初始化:GitHub 同步插件
This commit is contained in:
commit
b1b1c821cc
14 files changed
+925
No files matched your search
@@ -0,0 +1,84 @@
|
||||
# GitHub 同步(DSH 插件)
|
||||
|
||||
一个给 **DSH Web 界面**用的插件:在输入框里发 `/github`,就把当前项目的源码推上 GitHub,并自动生成一份带说明的 `README.md`。
|
||||
|
||||
没有按钮、没有弹窗,就是一条斜杠命令。
|
||||
|
||||
## 它做什么
|
||||
|
||||
- **建仓库**:第一次上传时自动在 GitHub 新建仓库(默认私有,可改公开),仓库名取自项目目录名
|
||||
- **写说明**:自动生成 `README.md`,包含项目名、技术栈、目录结构、同步说明;你手写的 README 不会被覆盖
|
||||
- **补忽略**:给项目补上 `.gitignore`(`node_modules`、`dist`、`.env` 之类),不把垃圾和密钥传上去
|
||||
- **提交并推送**:提交信息带上时间,推送到 `main`
|
||||
- **记状态**:记住每个项目的仓库地址、上次提交、文件数,用 `/github status` 随时查
|
||||
|
||||
## 命令
|
||||
|
||||
| 命令 | 作用 |
|
||||
| --- | --- |
|
||||
| `/github` | 上传当前工作区的项目 |
|
||||
| `/github token ghp_xxx` | 绑定 GitHub 令牌(输入不写入对话记录) |
|
||||
| `/github status` | 查令牌、账号、可见性、当前项目、上次上传 |
|
||||
| `/github all` | 上传所有识别到的项目(最多 10 个) |
|
||||
| `/github auto on` / `off` | 每轮对话结束后,自动上传本轮改过的项目 |
|
||||
|
||||
## 安装
|
||||
|
||||
```bash
|
||||
dsh plugin --profile web add <本目录>
|
||||
```
|
||||
|
||||
或者在本目录执行 `plugin_manager install_bundle`。安装后重开一个对话,在输入框里打 `/` 就能看到 **github** 命令。
|
||||
|
||||
## 令牌怎么来
|
||||
|
||||
手机上只能走浏览器(GitHub App 里没有这个页面):
|
||||
|
||||
```
|
||||
https://github.com/settings/tokens/new?scopes=repo&description=dsh
|
||||
```
|
||||
|
||||
Generate new token (classic) → 勾 `repo` → Generate → **点复制图标**(不要长按选文字,容易多粘几个字符)。
|
||||
|
||||
然后发:`/github token ghp_……`
|
||||
|
||||
令牌存在 `~/.dsh/dsh-go/github-token`(权限 600),不会写进仓库,也不会进对话记录。
|
||||
|
||||
## 配置与数据
|
||||
|
||||
| 路径 | 内容 |
|
||||
| --- | --- |
|
||||
| `~/.dsh/dsh-go/github-token` | 令牌(0600) |
|
||||
| `~/.dsh/dsh-go/github-upload.json` | 账号、可见性、自动开关、各项目上次上传记录(0600) |
|
||||
|
||||
也可以直接用环境变量 `GITHUB_TOKEN` 提供令牌。
|
||||
|
||||
## 工作区怎么判定「项目」
|
||||
|
||||
从会话的工作目录往上找最多 4 层,命中这些标记之一就算项目根:
|
||||
|
||||
`package.json`、`pubspec.yaml`、`index.html`、`Cargo.toml`、`go.mod`、`requirements.txt`、`pyproject.toml`、`composer.json`、`build.gradle`、`Podfile`、`app.json`、`main.py`、`.git`
|
||||
|
||||
## 目录结构
|
||||
|
||||
```
|
||||
github-sync/
|
||||
├── index.js 插件入口,注册 /github 命令
|
||||
├── cordis.patch.yml 安装补丁
|
||||
├── lib/
|
||||
│ ├── upload.js 一次上传的完整流程
|
||||
│ ├── github.js GitHub API(建仓库、取账号)
|
||||
│ ├── git.js git 命令封装(提交、推送、重试)
|
||||
│ ├── project.js 项目识别、README/ignore 生成、目录树
|
||||
│ └── store.js 配置与令牌读写
|
||||
├── locale/ 中文 / English 文案
|
||||
└── icon.svg
|
||||
```
|
||||
|
||||
## 与 dsh-go 手机版插件的关系
|
||||
|
||||
同一个作者的手机原生插件(`local-github-upload`,带输入框上方胶囊和面板)和本插件**共用**同一份配置和令牌,两边可以混用。
|
||||
|
||||
## 许可
|
||||
|
||||
MIT
|
||||
Reference in new issue
Block a user