@candriajs/karin-plugin-git 1.2.0 → 1.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/CHANGELOG.md +44 -0
- package/README.md +23 -2
- package/config/defSet/{cnb.yaml → cnbcool.yaml} +0 -2
- package/config/defSet/gitcode.yaml +0 -2
- package/config/defSet/gitee.yaml +0 -2
- package/config/defSet/github.yaml +0 -3
- package/config/defSet/proxy.yaml +5 -0
- package/config/defSet/token.yaml +11 -0
- package/lib/apps/admin.js +1 -1
- package/lib/apps/commit.js +3 -0
- package/lib/apps/help.js +1 -1
- package/lib/apps/push.js +1 -5
- package/lib/common-DJ-f21cV.js +250 -0
- package/lib/db-DhpZxiAN.js +55 -0
- package/lib/index.js +1 -1
- package/lib/models-qDLDUVt0.js +3 -0
- package/lib/web.config.js +1 -0
- package/package.json +6 -26
- package/resources/background.webp +0 -0
- package/lib/apps/issue.js +0 -1
- package/lib/common-Df1uHYOv.js +0 -1
- package/lib/db-DZFBXSmG.js +0 -44
- package/lib/types-7HeFLBYV.js +0 -1
- package/resources/commit/index.css +0 -293
- package/resources/commit/index.html +0 -123
- package/resources/fonts/DouyinSansBold.woff2 +0 -0
- package/resources/fonts/NotoColorEmoji-Regular.woff2 +0 -0
- package/resources/fonts/SmileySans-Oblique.woff2 +0 -0
- package/resources/help/index.css +0 -124
- package/resources/help/index.html +0 -84
- package/resources/help/version-info.css +0 -31
- package/resources/help/version-info.html +0 -22
- package/resources/icons/branch.svg +0 -1
- package/resources/icons/cnb.svg +0 -1
- package/resources/icons/commit.svg +0 -1
- package/resources/icons/gitcode.svg +0 -1
- package/resources/icons/gitee.svg +0 -1
- package/resources/icons/github.svg +0 -1
- package/resources/icons/issue.svg +0 -1
- package/resources/issue/index.css +0 -229
- package/resources/issue/index.html +0 -79
- /package/lib/{root-C9I_RrRd.js → root-q84D5Ojp.js} +0 -0
- /package/resources/{icons/repo.svg → repo.svg} +0 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,49 @@
|
|
|
1
1
|
# 变更日志
|
|
2
2
|
|
|
3
|
+
## [1.4.0](https://github.com/CandriaJS/karin-plugin-git/compare/v1.3.0...v1.4.0) (2026-01-31)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### ✨ 新功能
|
|
7
|
+
|
|
8
|
+
* **core:** 添加仓库绑定功能并重构数据库结构 ([84cbfa9](https://github.com/CandriaJS/karin-plugin-git/commit/84cbfa9dcd7fdc6bc36371b2765fddd23e3ad367))
|
|
9
|
+
* **models:** 实现session和bind数据模型 ([84cbfa9](https://github.com/CandriaJS/karin-plugin-git/commit/84cbfa9dcd7fdc6bc36371b2765fddd23e3ad367))
|
|
10
|
+
* **web:** 添加平台推送仓库列表配置界面 ([c720bf1](https://github.com/CandriaJS/karin-plugin-git/commit/c720bf169ad727f39484e1e4e3b68c7500e2582e))
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
### 🐛 错误修复
|
|
14
|
+
|
|
15
|
+
* **commit:** 优化提交信息查询逻辑 ([84cbfa9](https://github.com/CandriaJS/karin-plugin-git/commit/84cbfa9dcd7fdc6bc36371b2765fddd23e3ad367))
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
### 🔧 其他更新
|
|
19
|
+
|
|
20
|
+
* **core:** 更新 nipaw 依赖版本 ([6575fc9](https://github.com/CandriaJS/karin-plugin-git/commit/6575fc9832f56419300be40c48f704159c2f293f))
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
### ♻️ 代码重构
|
|
24
|
+
|
|
25
|
+
* **config:** 重构配置文件结构 ([84cbfa9](https://github.com/CandriaJS/karin-plugin-git/commit/84cbfa9dcd7fdc6bc36371b2765fddd23e3ad367))
|
|
26
|
+
* **core:** 重构核心实现 ([#14](https://github.com/CandriaJS/karin-plugin-git/issues/14)) ([fa15ee1](https://github.com/CandriaJS/karin-plugin-git/commit/fa15ee174127db957b7b18584daf6ac157cf370a))
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
### Dependencies
|
|
30
|
+
|
|
31
|
+
* The following workspace dependencies were updated
|
|
32
|
+
* devDependencies
|
|
33
|
+
* @candriajs/template bumped to 1.4.0
|
|
34
|
+
|
|
35
|
+
## [1.3.0](https://github.com/CandriaJS/karin-plugin-git/compare/v1.2.0...v1.3.0) (2025-11-29)
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
### ✨ 新功能
|
|
39
|
+
|
|
40
|
+
* **git:** 添加议题和提交变更的日志记录功能 ([cb7622b](https://github.com/CandriaJS/karin-plugin-git/commit/cb7622b875d7074137eb9ac52cf0a7ee18fd5121))
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
### 🐛 错误修复
|
|
44
|
+
|
|
45
|
+
* **admin:** 修正仓库订阅事件处理逻辑 ([3fd76bf](https://github.com/CandriaJS/karin-plugin-git/commit/3fd76bfdcfd52ceb231d829328679b3e33b2e92a))
|
|
46
|
+
|
|
3
47
|
## [1.2.0](https://github.com/CandriaJS/karin-plugin-git/compare/v1.1.1...v1.2.0) (2025-11-12)
|
|
4
48
|
|
|
5
49
|
|
package/README.md
CHANGED
|
@@ -1,3 +1,24 @@
|
|
|
1
|
-
# karin-plugin-git
|
|
1
|
+
# <h1 align="center">karin-plugin-git</h1>
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
<div align="center">
|
|
4
|
+
<img src="https://socialify.git.ci/CandriaJS/karin-plugin-git/image?description=1&forks=1&issues=1&language=1&name=1&owner=1&pulls=1&stargazers=1&theme=Light" alt="emojimix-plugin" width="640" height="320" />
|
|
5
|
+
|
|
6
|
+
<a href="https://github.com/KarinJS/Karin"><img src="https://badgen.net/npm/v/node-karin?label=Karin" alt="Gitee"></a><a href="https://qm.qq.com/q/gBs8Ri3nIQ"><img src="https://img.shields.io/badge/group-272040396-blue" alt="Gitee"></a>
|
|
7
|
+
|
|
8
|
+
<img alt="Release" src="https://badgen.net/github/release/CandriaJS/karin-plugin-git/stable"><img alt="GitHub repo size" src="https://img.shields.io/github/repo-size/CandriaJS/karin-plugin-git">
|
|
9
|
+
|
|
10
|
+
<img src="https://badgen.net/npm/v/@candriajs/karin-plugin-git?label=karin-plugin-git" alt="npm Version">
|
|
11
|
+
<a href="https://pkg-size.dev/@candriajs/karin-plugin-git@beta"><img src="https://pkg-size.dev/badge/bundle/1606131" title="Bundle size for karin-plugin-git"></a>
|
|
12
|
+
</div>
|
|
13
|
+
|
|
14
|
+
## 介绍 📝
|
|
15
|
+
|
|
16
|
+
`柠糖图片操作` 是一个 `Karin` 的扩展插件,提供bot对Git仓库操作功能。
|
|
17
|
+
|
|
18
|
+
## 安装与更新 🔧
|
|
19
|
+
|
|
20
|
+
在`Karin`目录执行以下命令
|
|
21
|
+
|
|
22
|
+
```bash
|
|
23
|
+
pnpm add @candriajs/karin-plugin-git@latest -w
|
|
24
|
+
```
|
package/config/defSet/gitee.yaml
CHANGED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
# Github 访问令牌 https://github.com/settings/tokens
|
|
2
|
+
github:
|
|
3
|
+
|
|
4
|
+
# Gitee 访问令牌 https://gitee.com/profile/personal_access_tokens
|
|
5
|
+
gitee:
|
|
6
|
+
|
|
7
|
+
# GitCode 访问令牌 https://gitcode.com/setting/token-classic
|
|
8
|
+
gitcode:
|
|
9
|
+
|
|
10
|
+
# CnbCool 访问令牌 https://cnb.cool/profile/token
|
|
11
|
+
cnbcool:
|
package/lib/apps/admin.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import"../root-
|
|
1
|
+
import"../root-q84D5Ojp.js";import{a as e,c as t,d as n,f as r,i,l as a,n as o,o as s,s as c}from"../db-DhpZxiAN.js";import{i as l,n as u,r as d}from"../common-DJ-f21cV.js";import{d as f,f as p,l as m,u as h}from"../models-qDLDUVt0.js";import g from"node-karin";const _=g.command(/^#?git(?:添加|add)(?:订阅仓库|repo)(?:([a-zA-Z]+):([^/\s]+)\/([^:\s]+))(?:\s+([^/\s]+))?$/i,async e=>{let[,r,s,l,g]=e.msg.match(_.reg),v=g?g.toLocaleLowerCase().split(`,`).map(e=>e.trim()).filter(e=>e):[u.Push];v.length||v.push(u.Push);let y=e.selfId,b=e.groupId,x=d.GitHub,S=p();switch(r.toLowerCase()){case`github`:S=p(),x=d.GitHub;break;case`gitcode`:S=h(),x=d.GitCode;break;case`gitee`:S=f(),x=d.Gitee;break;case`cnb`:case`cnbcool`:S=m(),x=d.CnbCool;break;default:return await e.reply(`未找到该平台, 请重试`)}let[C,w]=await Promise.all([i(x,s,l),t(y,b)]);if(C||=(await o(x,s,l),await i(x,s,l)),w||=(await c(y,b),await t(y,b)),!C||!w)return await e.reply(`添加订阅仓库失败,请重试`);let T=`添加订阅仓库成功, 平台: ${x}, 仓库: ${s}/${l}, 订阅类型: ${v.join(`,`)}`;if(v.includes(u.Push)){let e=S.repo(),t;try{t=(await e.info({owner:s,repo:l})).defaultBranch}catch{t=`main`}await n(C.id,w.id,t)?T=`仓库 ${s}/${l} 的推送订阅已存在, 请勿重复订阅`:(await a(C.id,w.id,t),T+=`, 分支: ${t}`)}await e.reply(T)},{name:`admin:addRepo`,priority:500,event:`message.group`,permission:`master`}),v=g.command(/^#?git(?:绑定|bind)(?:仓库|repo)(?:([a-zA-Z]+):([^/\s]+)\/([^:\s]+))$/i,async t=>{let[,n,r,a]=t.msg.match(v.reg),c=d.GitHub;switch(n.toLowerCase()){case`github`:c=d.GitHub;break;case`gitcode`:c=d.GitCode;break;case`gitee`:c=d.Gitee;break;case`cnb`:case`cnbcool`:c=d.CnbCool;break;default:return await t.reply(`未找到该平台, 请重试`)}let l=await i(c,r,a);if(l||=(await o(c,r,a),await i(c,r,a)),!l)return await t.reply(`绑定仓库失败, 请重试`);if(await s(t.groupId))return await t.reply(`该群已绑定该仓库, 请勿重复绑定`);await e(t.groupId,l.id),await t.reply(`绑定仓库成功, 平台: ${c}, 仓库: ${r}/${a}`)},{name:`admin:bindRepo`,event:`message.group`}),y=g.command(/^#?git(?:移除|删除|remove)(?:订阅仓库|repo)(?:([a-zA-Z]+):([^/\s]+)\/([^:\s]+))$/i,async e=>{let[,n,a,o]=e.msg.match(y.reg),s=e.selfId,c=e.groupId,l=d.GitHub;switch(n.toLowerCase()){case`github`:l=d.GitHub;break;case`gitcode`:l=d.GitCode;break;case`gitee`:l=d.Gitee;break;case`cnb`:case`cnbcool`:l=d.CnbCool;break;default:return await e.reply(`未找到该平台, 请重试`)}let[u,f]=await Promise.all([i(l,a,o),t(s,c)]);if(!u||!f)return await e.reply(`未找到该订阅仓库, 删除失败,请重试`);await r(u.id,f.id),await e.reply(`删除订阅仓库成功`)},{name:`admin:removeRepo`,priority:500,event:`message.group`,permission:`master`}),b=g.command(/^#?git(?:设置|set)([^\s]+)?(?:token|访问令牌)([\s\S]+)$/i,async e=>{let[,t,n]=e.msg.match(b.reg),r;switch(t.toLowerCase()){case`github`:r=`github`;break;case`gitcode`:r=`gitcode`;break;case`gitee`:r=`gitee`;break;case`cnb`:case`cnbcool`:r=`cnbcool`;break;default:return await e.reply(`未找到该平台, 请重试`)}l.Modify(r,`token`,n),await e.reply(`设置${t.toLowerCase()}访问令牌成功`)},{name:`admin:SetToken`,priority:500,event:`message.friend`,permission:`master`});export{_ as AddRepo,v as BindRepo,y as RemoveRepo,b as SetToken};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import"../root-q84D5Ojp.js";import{i as e,o as t}from"../db-DhpZxiAN.js";import{i as n,r,t as i}from"../common-DJ-f21cV.js";import{d as a,f as o,l as s,u as c}from"../models-qDLDUVt0.js";import l,{logger as u}from"node-karin";import{isEmpty as d}from"es-toolkit/compat";const f=l.command(/^#?(?:git(?:commit|提交信息|提交记录))\s*(\w+)(?::(?:([^\/\s]+)\/([^:\s]+)))?(?::([^\/\s]+))?$/i,async l=>{let[,p,m,h,g]=l.msg.match(f.reg);if(!m||!h){let n=await t(l.groupId);if(!n)return await l.reply(`请先绑定仓库或指定仓库`);let r=await e(n.repoId);m=r.owner,h=r.repo}let _,v=n.token.github,y=r.GitHub;switch(p.toLowerCase()){case`github`:y=r.GitHub,_=o(),v=n.token.github;break;case`gitcode`:y=r.GitCode,_=c(),v=n.token.gitcode;break;case`gitee`:y=r.Gitee,_=a(),v=n.token.gitee;break;case`cnbcool`:y=r.CnbCool,_=s(),v=n.token.cnbcool;break;default:return await l.reply(`未找到该平台, 请重试`)}if(p.toLowerCase()!==`github`&&d(v))return await l.reply(`请先配置访问令牌`);let b=_.commit();try{let e=await b.info({owner:m,repo:h},g),t=e.commit.message.split(`
|
|
2
|
+
`),n={owner:m,repo:h,sha:e.sha,title:t[0],content:t.slice(1).join(`
|
|
3
|
+
`),stats:e.stats,files:e.files,author:e.commit.author,committer:e.commit.committer,branch:g},r=await i.commit(y,n);return await l.reply(r)}catch(e){return u.error(`获取${p.toLowerCase()}提交信息出错: ${m}/${h}:${g||``} - ${e.message}`),await l.reply(`获取提交信息失败, 请重试`)}},{name:`commit:info`,event:`message.group`});export{f as commit};
|
package/lib/apps/help.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{t as e}from"../root-
|
|
1
|
+
import{t as e}from"../root-q84D5Ojp.js";import{t}from"../common-DJ-f21cV.js";import n,{segment as r}from"node-karin";import i from"node:fs";const a=n.command(/^#?(?:(git))(?:命令|帮助|菜单|help|说明|功能|指令|使用说明)$/i,async n=>{let a=[{name:`常用操作`,list:[{name:`订阅git仓库`,desc:`订阅git仓库并推送, 支持github,gitee,gitcode,cnbcool`,icon:await i.promises.readFile(`${e.Plugin_Path}/resources/icons/repo.svg`)}]}];if(n.isMaster){let t=await i.promises.readFile(`${e.Plugin_Path}/resources/icons/subscription.svg`),n=await i.promises.readFile(`${e.Plugin_Path}/resources/icons/token.svg`);a.push({name:`管理命令`,list:[{name:`#git添加订阅仓库[platform:]owner/repo[:event]`,desc:`添加一个订阅仓库, event可选:push`,icon:t},{name:`#git删除订阅仓库[platform:]owner/repo`,desc:`删除一个订阅仓库`,icon:t},{name:`#git设置[platform]token + token`,desc:`设置一个平台的访问令牌`,icon:n}]})}let o=await i.promises.readFile(`${e.Plugin_Path}/resources/background.webp`),s=await t.help({title:`Git 帮助`,theme:{backgroundImage:o},list:a});return await n.reply(r.image(`base64://${s.toString(`base64`)}`)),!0},{name:`help`,priority:500,event:`message`,permission:`all`});export{a as help};
|
package/lib/apps/push.js
CHANGED
|
@@ -1,5 +1 @@
|
|
|
1
|
-
import"../root-
|
|
2
|
-
`),i={...t,owner:h.owner,repo:h.repo,branch:e.branch,botId:n,groupId:m,title:await d.markdown(r[0]),body:await d.markdown(r.slice(1).join(`
|
|
3
|
-
`)),commitDate:f(t.commit.committer.date)};return await d.render(`commit/index`,{commit:i})}catch(t){return y.warn(`获取仓库 ${h.owner}/${h.repo} 分支 ${e.branch} 提交信息失败:`,t),null}}),x=(await Promise.allSettled(v)).filter(e=>e.status===`fulfilled`).map(e=>e.value).filter(e=>e!==null);_.push(...x);let S=(await a(i.id)).map(async e=>{if(b(e))return null;let t=await g.getIssueInfo(h.owner,h.repo,e.issueId),n={owner:h.owner,repo:h.repo,title:await d.markdown(t.title),body:t.body?await d.markdown(t.body):null,user:t.user,state:t.state,issueDate:f(t.createdAt)};return await d.render(`issue/index`,{issue:n})}),C=(await Promise.allSettled(S)).filter(e=>e.status===`fulfilled`).map(e=>e.value).filter(e=>e!==null);_.push(...C)}_.length>0&&await D(n,m,_)}catch(e){y.error(e)}},{name:`karin-plugin-git:pushRepo`,priority:500,event:`message.group`,permission:`master`}),E=async(a,o)=>{let s=await i(o,m.Push);if(b(s))return;let c=new Map;for(let i of s){let o=await e(i.repoId);if(!o)continue;let s=`${o.groupId}-${o.botId}`,l=await r(i.id);if(b(l)){let{defaultBranch:e}=await a.getRepoInfo(o.owner,o.repo);await t(i.id,e),l=await r(i.repoId)}for(let e of l){let t=await a.getCommitInfo(o.owner,o.repo,e.branch);!t||t.sha===e.commitSha||(c.has(s)||c.set(s,[]),c.get(s).push({pushRepo:e,pushRepoInfo:o,commitInfo:t}),await n(e.eventId,e.branch,t.sha))}}for(let[e,t]of c.entries()){let[n,r]=e.split(`-`),i=t.map(async e=>{let t=e.commitInfo.commit.message.split(`
|
|
4
|
-
`),n={...e.commitInfo,owner:e.pushRepoInfo.owner,repo:e.pushRepoInfo.repo,branch:e.pushRepo.branch,botId:e.pushRepoInfo.botId,groupId:e.pushRepoInfo.groupId,title:await d.markdown(t[0]),body:await d.markdown(t.slice(1).join(`
|
|
5
|
-
`)),commitDate:f(e.commitInfo.commit.committer.date)};return await d.render(`commit/index`,{commit:n})}),a=(await Promise.allSettled(i)).filter(e=>e.status===`fulfilled`&&e.value!==null).map(e=>e.value);a.length>0&&await D(r,n,a)}},D=async(e,t,n)=>{let r=v(e),i=await _(t);if(n.length>1){let t=await g.makeForward(n,e,r?.account.name);await r?.sendForwardMsg(i,t,{source:`仓库推送合集`,summary:`查看${t.length}张仓库推送消息`,prompt:`Gitub仓库推送结果`,news:[{text:`点击查看推送结果`}]})}else await r?.sendMsg(i,n)};export{w as cnb,C as gitcode,S as gitee,x as github,T as push};
|
|
1
|
+
import"../root-q84D5Ojp.js";import"../db-DhpZxiAN.js";import{i as e}from"../common-DJ-f21cV.js";import{c as t,i as n,n as r,o as i}from"../models-qDLDUVt0.js";import a,{logger as o}from"node-karin";import{isEmpty as s}from"es-toolkit/compat";const c=a.task(`commit:push:github`,e.github.cron||`0 */5 * * * *`,async()=>{let n=e.token.github;if(s(n))return o.warn(`未配置GitHub Token, 跳过任务`);try{await new t().action()}catch(e){o.error(e)}}),l=a.task(`commit:push:gitee`,e.gitee.cron||`0 */5 * * * *`,async()=>{let t=e.token.gitee;if(s(t))return o.warn(`未配置 Gitee Token, 跳过任务`);try{await new i().action()}catch(e){o.error(e)}}),u=a.task(`commit:push:gitcode`,e.gitcode.cron||`0 */5 * * * *`,async()=>{let t=e.token.gitcode;if(s(t))return o.warn(`未配置 GitCode Token, 跳过任务`);try{await new n().action()}catch(e){o.error(e)}}),d=a.task(`commit:push:cnbcool`,e.cnbcool.cron||`0 */5 * * * *`,async()=>{let t=e.token.cnbcool;if(s(t))return o.warn(`未配置 CnbCol Token, 跳过任务`);try{await new r().action()}catch(e){o.error(`推送CnbCool仓库提交信息失败: ${e}`)}});export{d as cnbcool,u as gitcode,l as gitee,c as github};
|