@candriajs/karin-plugin-git 1.4.0 → 1.5.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 +35 -0
- package/README.md +3 -3
- package/lib/apps/admin.js +1 -1
- package/lib/apps/commit.js +1 -1
- package/lib/apps/help.js +1 -1
- package/lib/apps/push.js +1 -1
- package/lib/{common-DJ-f21cV.js → common-DZ40JEMm.js} +1 -1
- package/lib/{models-qDLDUVt0.js → models-D_S-DAOz.js} +1 -1
- package/lib/web.config.js +1 -1
- package/package.json +1 -1
- /package/resources/{repo.svg → icons/repo.svg} +0 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,40 @@
|
|
|
1
1
|
# 变更日志
|
|
2
2
|
|
|
3
|
+
## [1.5.0](https://github.com/CandriaJS/karin-plugin-git/compare/core-v1.4.0...core-v1.5.0) (2026-02-26)
|
|
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
|
+
* 修复ci发版 ([ef880b8](https://github.com/CandriaJS/karin-plugin-git/commit/ef880b88bdd5cba704adfdd3096a98e8b8c31e74))
|
|
17
|
+
* 修复图标路径 ([e12ef68](https://github.com/CandriaJS/karin-plugin-git/commit/e12ef68da2e8d2ecc9c0b3405d00675ad0565f7c))
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
### 🔧 其他更新
|
|
21
|
+
|
|
22
|
+
* **core:** 更新 nipaw 依赖版本 ([6575fc9](https://github.com/CandriaJS/karin-plugin-git/commit/6575fc9832f56419300be40c48f704159c2f293f))
|
|
23
|
+
* release main ([dace4f9](https://github.com/CandriaJS/karin-plugin-git/commit/dace4f92809005877ee404ce985ad0a7499b6cd8))
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
### ♻️ 代码重构
|
|
27
|
+
|
|
28
|
+
* **config:** 重构配置文件结构 ([84cbfa9](https://github.com/CandriaJS/karin-plugin-git/commit/84cbfa9dcd7fdc6bc36371b2765fddd23e3ad367))
|
|
29
|
+
* **core:** 重构核心实现 ([#14](https://github.com/CandriaJS/karin-plugin-git/issues/14)) ([fa15ee1](https://github.com/CandriaJS/karin-plugin-git/commit/fa15ee174127db957b7b18584daf6ac157cf370a))
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
### Dependencies
|
|
33
|
+
|
|
34
|
+
* The following workspace dependencies were updated
|
|
35
|
+
* devDependencies
|
|
36
|
+
* @candriajs/template bumped to 1.5.0
|
|
37
|
+
|
|
3
38
|
## [1.4.0](https://github.com/CandriaJS/karin-plugin-git/compare/v1.3.0...v1.4.0) (2026-01-31)
|
|
4
39
|
|
|
5
40
|
|
package/README.md
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
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="
|
|
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="git-plugin" width="640" height="320" />
|
|
5
5
|
|
|
6
|
-
<a href="https://github.com/KarinJS/Karin"><img src="https://badgen.net/npm/v/node-karin?label=Karin" alt="Gitee"
|
|
6
|
+
<a href="https://github.com/KarinJS/Karin"><img src="https://badgen.net/npm/v/node-karin?label=Karin" alt="Gitee">>
|
|
7
7
|
|
|
8
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
9
|
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
|
|
14
14
|
## 介绍 📝
|
|
15
15
|
|
|
16
|
-
|
|
16
|
+
`karin-plugin-git` 是一个 `Karin` 的扩展插件,提供bot对Git仓库操作功能。
|
|
17
17
|
|
|
18
18
|
## 安装与更新 🔧
|
|
19
19
|
|
package/lib/apps/admin.js
CHANGED
|
@@ -1 +1 @@
|
|
|
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-
|
|
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-DZ40JEMm.js";import{d as f,f as p,l as m,u as h}from"../models-D_S-DAOz.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};
|
package/lib/apps/commit.js
CHANGED
|
@@ -1,3 +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-
|
|
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-DZ40JEMm.js";import{d as a,f as o,l as s,u as c}from"../models-D_S-DAOz.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
2
|
`),n={owner:m,repo:h,sha:e.sha,title:t[0],content:t.slice(1).join(`
|
|
3
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-q84D5Ojp.js";import{t}from"../common-
|
|
1
|
+
import{t as e}from"../root-q84D5Ojp.js";import{t}from"../common-DZ40JEMm.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 +1 @@
|
|
|
1
|
-
import"../root-q84D5Ojp.js";import"../db-DhpZxiAN.js";import{i as e}from"../common-
|
|
1
|
+
import"../root-q84D5Ojp.js";import"../db-DhpZxiAN.js";import{i as e}from"../common-DZ40JEMm.js";import{c as t,i as n,n as r,o as i}from"../models-D_S-DAOz.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};
|
|
@@ -247,4 +247,4 @@ var fn=C((e=>{var t=k();function n(e,t){return e===t&&(e!==0||1/e==1/t)||e!==e&&
|
|
|
247
247
|
</div>
|
|
248
248
|
</body>
|
|
249
249
|
</html>
|
|
250
|
-
`;let nc=function(e){return e.GitHub=`GitHub`,e.Gitee=`Gitee`,e.GitCode=`GitCode`,e.CnbCool=`CnbCool`,e}({}),rc=function(e){return e.Push=`push`,e.Release=`release`,e}({});const ic={async render(t,n){let r=tc(t),i=d.join(o,e.Plugin_Name),a=m(`md5`).update(r).digest(`hex`).substring(0,16),c=d.join(i,`${n}_${a}.html`);p.existsSync(i)||await p.promises.mkdir(i,{recursive:!0}),await p.promises.writeFile(c,r,`utf-8`);let u=await s.render({file:c,scale:1,screensEval:`#root`,pageGotoParams:{waitUntil:`networkidle0`,timeout:6e4}});return l.image(`base64://${u
|
|
250
|
+
`;let nc=function(e){return e.GitHub=`GitHub`,e.Gitee=`Gitee`,e.GitCode=`GitCode`,e.CnbCool=`CnbCool`,e}({}),rc=function(e){return e.Push=`push`,e.Release=`release`,e}({});const ic={async render(t,n){let r=tc(t),i=d.join(o,e.Plugin_Name),a=m(`md5`).update(r).digest(`hex`).substring(0,16),c=d.join(i,`${n}_${a}.html`);p.existsSync(i)||await p.promises.mkdir(i,{recursive:!0}),await p.promises.writeFile(c,r,`utf-8`);let u=await s.render({file:c,scale:1,screensEval:`#root`,pageGotoParams:{waitUntil:`networkidle0`,timeout:6e4}});return l.image(u.startsWith(`base64`)?u:`base64://${u}`)},async commit(e=nc.GitHub,t){let n=`commit`;switch(e){case nc.GitHub:return await ic.render(Hs.Commit({...t}),n);case nc.Gitee:return await ic.render(Gs.Commit({...t}),n);case nc.GitCode:return await ic.render(Js.Commit({...t}),n);case nc.CnbCool:return await ic.render(Zs.Commit({...t}),n)}},help:f.help};export{g as i,rc as n,nc as r,ic as t};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import{c as e,i as t,p as n,r,u as i}from"./db-DhpZxiAN.js";import{i as a,n as o,r as s,t as c}from"./common-
|
|
1
|
+
import{c as e,i as t,p as n,r,u as i}from"./db-DhpZxiAN.js";import{i as a,n as o,r as s,t as c}from"./common-DZ40JEMm.js";import{components as l,contactGroup as u,getBot as d,logger as f}from"node-karin";import{isEmpty as p}from"es-toolkit/compat";import{CnbClient as m,GitCodeClient as h,GiteeClient as g,GithubClient as _}from"nipaw";const v=()=>{let e=new _;return p(a.proxy.reverseProxy)?p(a.proxy.proxy)||e.setProxy(a.proxy.proxy):e.setReverseProxy(a.proxy.reverseProxy),p(a.token.github)||e.setToken(a.token.github),e},y=()=>{let e=new g;return p(a.proxy.proxy)||e.setProxy(a.proxy.proxy),p(a.token.gitee)||e.setToken(a.token.gitee),e},b=()=>{let e=new h;return p(a.proxy.proxy)||e.setProxy(a.proxy.proxy),p(a.token.gitcode)||e.setToken(a.token.gitcode),e},x=()=>{let e=new m;return p(a.proxy.proxy)||e.setProxy(a.proxy.proxy),p(a.token.cnbcool)||e.setToken(a.token.cnbcool),e};var S=class{platform;client;constructor(e,t){this.platform=e,this.client=t}async action(){let[a,o]=await Promise.all([r(),i()]),s=a.filter(e=>e.platform===this.platform).map(e=>e.id),l=o.filter(e=>s.includes(e.repoId)),p=this.client.commit();l.forEach(async r=>{let i=await t(r.id);f.debug(`开始处理 ${this.platform} ${i.owner}/${i.repo} ${r.branch}}`);let a=await e(r.sessionId),o=await p.info({owner:i.owner,repo:i.repo},r.branch);if(o.sha===r.commitSha)return;let s=d(a.botId);if(!s)throw Error(`Bot ${a.botId} not found`);let l=o.commit.message.split(`
|
|
2
2
|
`),m={owner:i.owner,repo:i.repo,branch:r.branch,sha:o.sha,author:o.commit.author,committer:o.commit.committer,title:l[0],content:l.slice(1).join(`
|
|
3
3
|
`),stats:o.stats,files:o.files},h=await c.commit(this.platform,m),g=u(a.groupId);await s.sendMsg(g,[h]),await n(r.repoId,r.sessionId,r.branch,o.sha)})}},C=class extends S{constructor(){super(s.GitHub,v())}};const w=e=>[l.accordion.create(`github`,{label:`Github 相关`,children:[l.accordion.createItem(`config:github`,{title:`Github 相关`,subtitle:`Github 相关配置`,children:[l.input.string(`cron`,{label:`推送任务执行时间`,description:`推送任务执行时间`,placeholder:`请输入推送任务Cron 表达式`,defaultValue:a.github.cron})]})]}),l.accordionPro.create(`pushlist:github`,e.map(e=>({title:`${e.owner}/${e.repo}:${e.branch}`,subtitle:`${e.botId}:${e.groupId}`,...e})),{label:`Github 推送仓库列表`,children:l.accordion.createItem(`accordion-item-github`,{children:[l.input.string(`owner`,{label:`仓库所有者`,placeholder:`请输入 Github 仓库所有者`}),l.input.string(`repo`,{label:`仓库名称`,placeholder:`请输入 Github 仓库名称`}),l.input.string(`branch`,{label:`仓库分支`,placeholder:`请输入 Github 仓库分支`}),l.input.string(`botId`,{label:`推送机器人`,placeholder:`请输入 推送机器人账号`}),l.input.string(`groupId`,{label:`推送群组`,placeholder:`请输入 推送群组ID`}),l.checkbox.group(`event`,{label:`推送事件`,checkbox:[l.checkbox.create(`event:push`,{label:`push`,value:o.Push}),l.checkbox.create(`event:release`,{label:`release`,value:o.Release,isDisabled:!0})]})]})})];var T=class extends S{constructor(){super(s.Gitee,y())}};const E=e=>[l.accordion.create(`gitee`,{label:`Gitee 相关`,children:[l.accordion.createItem(`config:gitee`,{title:`Gitee 相关`,subtitle:`Gitee 相关配置`,children:[l.input.string(`cron`,{label:`推送任务执行时间`,description:`推送任务执行时间`,placeholder:`请输入推送任务Cron 表达式`,defaultValue:a.gitee.cron})]})]}),l.accordionPro.create(`pushlist:gitee`,e.map(e=>({title:`${e.owner}/${e.repo}:${e.branch}`,...e})),{label:`Gitee 推送仓库列表`,children:l.accordion.createItem(`accordion-item-gitee`,{subtitle:`Gitee 仓库`,children:[l.input.string(`owner`,{label:`仓库所有者`,placeholder:`请输入 Gitee 仓库所有者`}),l.input.string(`repo`,{label:`仓库名称`,placeholder:`请输入 Gitee 仓库名称`}),l.input.string(`branch`,{label:`仓库分支`,placeholder:`请输入 Gitee 仓库分支`,isRequired:!0}),l.checkbox.group(`event`,{label:`推送事件`,checkbox:[l.checkbox.create(`event:push`,{label:`push`,value:o.Push}),l.checkbox.create(`event:release`,{label:`release`,value:o.Release,isDisabled:!0})]})]})})];var D=class extends S{constructor(){super(s.GitCode,b())}};const O=e=>[l.accordion.create(`gitcode`,{label:`GitCode 相关`,children:[l.accordion.createItem(`config:gitcode`,{title:`GitCode 相关`,subtitle:`GitCode 相关配置`,children:[l.input.string(`cron`,{label:`推送任务执行时间`,description:`推送任务执行时间`,placeholder:`请输入推送任务Cron 表达式`,defaultValue:a.gitcode.cron})]})]}),l.accordionPro.create(`pushlist:gitcode`,e.map(e=>({title:`${e.owner}/${e.repo}:${e.branch}`,...e})),{label:`GitCode 推送仓库列表`,children:l.accordion.createItem(`accordion-item-gitcode`,{subtitle:`GitCode 仓库`,children:[l.input.string(`owner`,{label:`仓库所有者`,placeholder:`请输入 GitCode 仓库所有者`}),l.input.string(`repo`,{label:`仓库名称`,placeholder:`请输入 GitCode 仓库名称`}),l.input.string(`branch`,{label:`仓库分支`,placeholder:`请输入 GitCode 仓库分支`}),l.checkbox.group(`event`,{label:`推送事件`,checkbox:[l.checkbox.create(`event:push`,{label:`push`,value:o.Push}),l.checkbox.create(`event:release`,{label:`release`,value:o.Release,isDisabled:!0})]})]})})];var k=class extends S{constructor(){super(s.CnbCool,x())}};const A=e=>[l.accordion.create(`cnbcool`,{label:`CnbCool 相关`,children:[l.accordion.createItem(`config:gitcode`,{title:`CnbCool 相关`,subtitle:`CnbCool 相关配置`,children:[l.input.string(`cron`,{label:`推送任务执行时间`,description:`推送任务执行时间`,placeholder:`请输入推送任务Cron 表达式`,defaultValue:a.cnbcool.cron})]})]}),l.accordionPro.create(`pushlist:cnbcool`,e.map(e=>({title:`${e.owner}/${e.repo}:${e.branch}`,...e})),{label:`CnbCool 推送仓库列表`,children:l.accordion.createItem(`accordion-item-cnbcoool`,{subtitle:`CnbCool 仓库`,children:[l.input.string(`owner`,{label:`仓库所有者`,placeholder:`请输入 CnbCool 仓库所有者`}),l.input.string(`repo`,{label:`仓库名称`,placeholder:`请输入 CnbCool 仓库名称`}),l.input.string(`branch`,{label:`仓库分支`,placeholder:`请输入 CnbCool 仓库分支`}),l.checkbox.group(`event`,{label:`推送事件`,checkbox:[l.checkbox.create(`event:push`,{label:`push`,value:o.Push}),l.checkbox.create(`event:release`,{label:`release`,value:o.Release,isDisabled:!0})]})]})})];export{E as a,C as c,y as d,v as f,D as i,x as l,k as n,T as o,O as r,w as s,A as t,b as u};
|
package/lib/web.config.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import"./root-q84D5Ojp.js";import{c as e,d as t,f as n,i as r,l as i,n as a,s as o,u as s}from"./db-DhpZxiAN.js";import{i as c,n as l,r as u}from"./common-
|
|
1
|
+
import"./root-q84D5Ojp.js";import{c as e,d as t,f as n,i as r,l as i,n as a,s as o,u as s}from"./db-DhpZxiAN.js";import{i as c,n as l,r as u}from"./common-DZ40JEMm.js";import{a as d,r as f,s as p,t as m}from"./models-D_S-DAOz.js";import{components as h,defineConfig as g}from"node-karin";import{differenceWith as _}from"es-toolkit/array";const v=async t=>{let n=await s();if(!n.length)return[];let i=[...new Set(n.map(e=>e.repoId))],a=[...new Set(n.map(e=>e.sessionId))],[o,c]=await Promise.all([Promise.all(i.map(e=>r(e))),Promise.all(a.map(t=>e(t)))]),u=new Map(o.filter(Boolean).map(e=>[e.id,e])),d=new Map(c.filter(Boolean).map(e=>[e.id,e]));return n.filter(e=>{let n=u.get(e.repoId),r=d.get(e.sessionId);return n&&r&&(!t||n.platform===t)}).map(e=>{let t=u.get(e.repoId),n=d.get(e.sessionId);return{owner:t.owner,repo:t.repo,botId:n.botId,groupId:n.groupId,branch:e.branch,event:[l.Push]}})},y=(e,t)=>e.owner===t.owner&&e.repo===t.repo&&e.branch===t.branch&&e.botId===t.botId&&e.groupId===t.groupId,b=async(n,s)=>{n.length&&await Promise.all(n.map(async n=>{let[c,u]=await Promise.all([r(s,n.owner,n.repo),e(n.botId,n.groupId)]);u||=(await o(n.botId,n.groupId),await e(n.botId,n.groupId)),c||=(await a(s,n.owner,n.repo),await r(s,n.owner,n.repo)),n.event.includes(l.Push)&&(await t(c.id,u.id,n.branch)||await i(c.id,u.id,n.branch,``))}))},x=async(i,a)=>{i.length&&await Promise.all(i.map(async i=>{let[o,s]=await Promise.all([r(a,i.owner,i.repo),e(i.botId,i.groupId)]);!o||!s||i.event.includes(l.Push)&&await t(o.id,s.id,i.branch)&&await n(o.id,s.id,i.branch)}))};var S=g({info:{id:`@candriajs/karin-plugin-git`,name:`karin-plugin-git`,author:{name:`CandriaJS`,home:`https://github.com/CandriaJS`,avatar:`https://avatars.githubusercontent.com/u/196008293?s=200&v=4`}},components:async()=>[h.divider.create(`divider-1`,{description:`基础配置`,descPosition:50}),h.accordion.create(`token`,{label:`Token 配置`,children:[h.accordion.createItem(`config:github`,{title:`token 相关`,subtitle:`建议, 否则大部分功能不可用`,children:[h.input.string(`github`,{label:`Github`,description:`Github 访问令牌`,placeholder:`请输入 Github 访问令牌`,defaultValue:c.token.github,isClearable:!0,isRequired:!1}),h.input.string(`gitee`,{label:`Gitee`,description:`Gitee 访问令牌`,placeholder:`请输入 Gitee 访问令牌`,defaultValue:c.token.gitee,isClearable:!0,isRequired:!1}),h.input.string(`gitcode`,{label:`GitCode`,description:`GitCode 访问令牌`,placeholder:`请输入 GitCode 访问令牌`,defaultValue:c.token.gitcode,isClearable:!0,isRequired:!1}),h.input.string(`cnbcool`,{label:`CnbCool`,description:`CnbCool 访问令牌`,placeholder:`请输入 CnbCool 访问令牌`,defaultValue:c.token.cnbcool,isClearable:!0,isRequired:!1})]})]}),h.accordion.create(`proxy`,{label:`代理配置`,children:[h.accordion.createItem(`config:proxy`,{title:`代理相关`,subtitle:`此处用于网络访问请求`,children:[h.input.string(`proxy`,{label:`系统代理`,description:`系统代理`,placeholder:`请输入系统代理`,defaultValue:c.proxy.proxy,isClearable:!0,isRequired:!1}),h.input.string(`reverseProxy`,{label:`反向代理`,description:`反向代理`,placeholder:`请输入反向代理`,defaultValue:c.proxy.reverseProxy,isClearable:!0,isRequired:!1})]})]}),h.divider.create(`divider-2`,{description:`平台配置`,descPosition:50}),...p(await v(u.GitHub)),...d(await v(u.Gitee)),...f(await v(u.GitCode)),...m(await v(u.CnbCool))],save:async e=>{console.log(`config`,e);let t=e.token[0],n=e.proxy[0];c.Modify(`proxy`,`proxy`,n.proxy),c.Modify(`proxy`,`reverseProxy`,n.reverseProxy);{c.Modify(`token`,`github`,t.github);let n=u.GitHub,r=e.github[0],i=e[`pushlist:github`],a=_(i,await v(n),y),o=_(await v(n),i,y);await b(a,n),await x(o,n),c.Modify(`github`,`cron`,r.cron)}{c.Modify(`token`,`gitee`,t.gitee);let n=e.gitee[0],r=u.GitHub;c.Modify(`gitee`,`cron`,n.cron);let i=e[`pushlist:gitee`],a=_(i,await v(r),y),o=_(await v(r),i,y);await b(a,r),await x(o,r)}{c.Modify(`token`,`gitcode`,t.gitcode);let n=e.gitcode[0],r=u.GitCode,i=e[`pushlist:gitcode`];c.Modify(`gitcode`,`cron`,n.cron);let a=_(i,await v(r),y),o=_(await v(r),i,y);await b(a,r),await x(o,r)}{c.Modify(`token`,`cnbcool`,t.cnbcool);let n=e.cnbcool[0],r=u.CnbCool,i=e[`pushlist:cnbcool`],a=_(i,await v(r),y),o=_(await v(r),i,y);await b(a,r),await x(o,r),c.Modify(`cnbcool`,`cron`,n.cron)}return{success:!0,message:`保存成功 Ciallo~(∠・ω< )⌒☆`}}});export{S as default};
|
package/package.json
CHANGED
|
File without changes
|