Skip to content

Commit f55ed12

Browse files
Aliorpsesj817
andauthored
feat: 添加插件*2 (#18)
* Update plugins.json * fix: app --------- Co-authored-by: 时瑾 <74231782+sj817@users.noreply.github.com>
1 parent 0818d95 commit f55ed12

File tree

3 files changed

+164
-139
lines changed

3 files changed

+164
-139
lines changed

README.md

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,7 @@
105105
"name": "karin-plugin-basic",
106106
"type": "npm",
107107
"description": "karin plugin basic",
108+
"home": "https://github.com/karinjs/karin-plugin-basic",
108109
"license": {
109110
"name": "MIT",
110111
"url": "https://github.com/karinjs/karin-plugin-basic/blob/main/LICENSE"
@@ -133,6 +134,7 @@
133134
"name": "karin-plugin-git-example",
134135
"type": "git",
135136
"description": "这是一个 Git 插件示例",
137+
"home": "https://github.com/username/karin-plugin-git-example",
136138
"license": {
137139
"name": "MIT",
138140
"url": "https://github.com/username/karin-plugin-git-example/blob/main/LICENSE"
@@ -161,6 +163,7 @@
161163
"name": "karin-plugin-app-example",
162164
"type": "app",
163165
"description": "这是一个 App 插件示例",
166+
"home": "https://github.com/username/karin-plugin-app-example",
164167
"license": {
165168
"name": "GPL-3.0",
166169
"url": "https://github.com/username/karin-plugin-app-example/blob/main/LICENSE"
@@ -179,9 +182,11 @@
179182
"branch": "main"
180183
}
181184
],
182-
"files": [
183-
"https://example.com/download/plugin-v1.0.0.js",
184-
"https://mirror.example.com/download/plugin-v1.0.0.js"
185+
"files": [ // 这里可以添加多个文件
186+
{
187+
"name": "karin-plugin-app-example.js",
188+
"url": "https://mirror.example.com/download/karin-plugin-app-example.js"
189+
}
185190
]
186191
}
187192
]

plugins.json

Lines changed: 143 additions & 129 deletions
Original file line numberDiff line numberDiff line change
@@ -1,139 +1,153 @@
11
{
2-
"plugins": [
3-
{
4-
"name": "@karinjs/plugin-basic",
5-
"type": "npm",
6-
"description": "karin plugin basic",
7-
"home": "https://github.com/karinjs/karin-plugin-basic",
8-
"license": {
9-
"name": "MIT",
10-
"url": "https://github.com/karinjs/karin-plugin-basic/blob/main/LICENSE"
11-
},
12-
"time": "2025-01-19 10:00:00",
13-
"author": [
14-
{
15-
"name": "shijin",
16-
"home": "https://github.com/sj817"
17-
}
18-
],
19-
"repo": [
20-
{
21-
"type": "github",
22-
"url": "https://github.com/karinjs/karin-plugin-basic",
23-
"branch": "main"
24-
}
25-
]
2+
"plugins": [
3+
{
4+
"name": "@karinjs/plugin-basic",
5+
"type": "npm",
6+
"description": "karin plugin basic",
7+
"home": "https://github.com/karinjs/karin-plugin-basic",
8+
"license": {
9+
"name": "MIT",
10+
"url": "https://github.com/karinjs/karin-plugin-basic/blob/main/LICENSE"
11+
},
12+
"time": "2025-01-19 10:00:00",
13+
"author": [
14+
{
15+
"name": "shijin",
16+
"home": "https://github.com/sj817"
17+
}
18+
],
19+
"repo": [
20+
{
21+
"type": "github",
22+
"url": "https://github.com/karinjs/karin-plugin-basic",
23+
"branch": "main"
24+
}
25+
]
26+
},
27+
{
28+
"name": "karin-plugin-kkk",
29+
"type": "npm",
30+
"description": "咕咕咕 ~",
31+
"home": "https://github.com/ikenxuan/karin-plugin-kkk",
32+
"license": {
33+
"name": "GPL-3.0",
34+
"url": "https://github.com/ikenxuan/karin-plugin-kkk/blob/main/LICENSE"
35+
},
36+
"time": "2025-01-25 22:47:37",
37+
"author": [
38+
{
39+
"name": "ikenxuan",
40+
"home": "https://github.com/ikenxuan"
41+
}
42+
],
43+
"repo": [
44+
{
45+
"type": "github",
46+
"url": "https://github.com/ikenxuan/karin-plugin-kkk",
47+
"branch": "main"
2648
},
2749
{
28-
"name": "karin-plugin-kkk",
29-
"type": "npm",
30-
"description": "咕咕咕 ~",
31-
"home": "https://github.com/ikenxuan/karin-plugin-kkk",
32-
"license": {
33-
"name": "GPL-3.0",
34-
"url": "https://github.com/ikenxuan/karin-plugin-kkk/blob/main/LICENSE"
35-
},
36-
"time": "2025-01-25 22:47:37",
37-
"author": [
38-
{
39-
"name": "ikenxuan",
40-
"home": "https://github.com/ikenxuan"
41-
}
42-
],
43-
"repo": [
44-
{
45-
"type": "github",
46-
"url": "https://github.com/ikenxuan/karin-plugin-kkk",
47-
"branch": "main"
48-
},
49-
{
50-
"type": "npm",
51-
"url": "https://www.npmjs.com/package/karin-plugin-kkk",
52-
"branch": ""
53-
}
54-
]
50+
"type": "npm",
51+
"url": "https://www.npmjs.com/package/karin-plugin-kkk",
52+
"branch": ""
53+
}
54+
]
55+
},
56+
{
57+
"name": "karin-plugin-ling",
58+
"type": "npm",
59+
"description": "希腊奶",
60+
"home": "https://github.com/yusheng929/karin-plugin-ling",
61+
"license": {
62+
"name": "GPL-3.0",
63+
"url": "https://github.com/yusheng929/karin-plugin-ling/blob/main/LICENSE"
64+
},
65+
"time": "2025-02-02 10:00:00",
66+
"author": [
67+
{
68+
"name": "yusheng929",
69+
"home": "https://github.com/yusheng929"
70+
}
71+
],
72+
"repo": [
73+
{
74+
"type": "github",
75+
"url": "https://github.com/yusheng929/karin-plugin-ling",
76+
"branch": "main"
5577
},
5678
{
57-
"name": "karin-plugin-ling",
58-
"type": "npm",
59-
"description": "希腊奶",
60-
"home": "https://github.com/yusheng929/karin-plugin-ling",
61-
"license": {
62-
"name": "GPL-3.0",
63-
"url": "https://github.com/yusheng929/karin-plugin-ling/blob/main/LICENSE"
64-
},
65-
"time": "2025-02-02 10:00:00",
66-
"author": [
67-
{
68-
"name": "yusheng929",
69-
"home": "https://github.com/yusheng929"
70-
}
71-
],
72-
"repo": [
73-
{
74-
"type": "github",
75-
"url": "https://github.com/yusheng929/karin-plugin-ling",
76-
"branch": "main"
77-
},
78-
{
79-
"type": "npm",
80-
"url": "https://www.npmjs.com/package/karin-plugin-ling",
81-
"branch": ""
82-
}
83-
]
79+
"type": "npm",
80+
"url": "https://www.npmjs.com/package/karin-plugin-ling",
81+
"branch": ""
82+
}
83+
]
84+
},
85+
{
86+
"name": "karin-mys-core",
87+
"type": "npm",
88+
"description": "前面的区域以后再来探索吧!",
89+
"home": "https://github.com/Karin-Mys-Plugins/mys-core",
90+
"license": {
91+
"name": "GPL-3.0",
92+
"url": "https://github.com/Karin-Mys-Plugins/mys-core/blob/main/LICENSE"
93+
},
94+
"time": "2025-02-16 11:45:14",
95+
"author": [
96+
{
97+
"name": "babanbang",
98+
"home": "https://github.com/babanbang"
99+
}
100+
],
101+
"repo": [
102+
{
103+
"type": "github",
104+
"url": "https://github.com/Karin-Mys-Plugins/mys-core",
105+
"branch": "main"
106+
},
107+
{
108+
"type": "npm",
109+
"url": "https://www.npmjs.com/package/karin-mys-core",
110+
"branch": ""
111+
}
112+
]
113+
},
114+
{
115+
"name": "karin-plugins-alijs",
116+
"type": "app",
117+
"description": "一个用于 Karin 的插件集合",
118+
"home": "https://github.com/Aliorpse/karin-plugins-alijs",
119+
"license": {
120+
"name": "MIT",
121+
"url": "https://github.com/Aliorpse/karin-plugins-alijs/blob/main/LICENSE"
122+
},
123+
"time": "2025-02-16 11:45:14",
124+
"author": [
125+
{
126+
"name": "Aliorpse",
127+
"home": "https://github.com/Aliorpse"
128+
}
129+
],
130+
"repo": [
131+
{
132+
"type": "github",
133+
"url": "https://github.com/Aliorpse/karin-plugins-alijs",
134+
"branch": "main"
135+
}
136+
],
137+
"files": [
138+
{
139+
"name": "B站链接解析",
140+
"url": "https://raw.githubusercontent.com/Aliorpse/karin-plugins-alijs/refs/heads/main/js/BiliParser.js"
84141
},
85142
{
86-
"name": "karin-mys-core",
87-
"type": "npm",
88-
"description": "前面的区域以后再来探索吧!",
89-
"home": "https://github.com/Karin-Mys-Plugins/mys-core",
90-
"license": {
91-
"name": "GPL-3.0",
92-
"url": "https://github.com/Karin-Mys-Plugins/mys-core/blob/main/LICENSE"
93-
},
94-
"time": "2025-02-16 11:45:14",
95-
"author": [
96-
{
97-
"name": "babanbang",
98-
"home": "https://github.com/babanbang"
99-
}
100-
],
101-
"repo": [
102-
{
103-
"type": "github",
104-
"url": "https://github.com/Karin-Mys-Plugins/mys-core",
105-
"branch": "main"
106-
},
107-
{
108-
"type": "npm",
109-
"url": "https://www.npmjs.com/package/karin-mys-core",
110-
"branch": ""
111-
}
112-
]
143+
"name": "Minecraft 服务器状态获取",
144+
"url": "https://raw.githubusercontent.com/Aliorpse/karin-plugins-alijs/refs/heads/main/js/MCMotd.js"
113145
},
114146
{
115-
"name": "karin-plugin-mcmotd",
116-
"type": "app",
117-
"description": "Minecraft 服务器状态获取",
118-
"home": "https://github.com/Aliorpse/karin-plugins-alijs/blob/main/js/MCMotd.js",
119-
"license": {
120-
"name": "MIT",
121-
"url": "https://github.com/Aliorpse/karin-plugins-alijs/blob/main/LICENSE"
122-
},
123-
"time": "2025-02-16 11:45:14",
124-
"author": [
125-
{
126-
"name": "Aliorpse",
127-
"home": "https://github.com/Aliorpse"
128-
}
129-
],
130-
"repo": [
131-
{
132-
"type": "github",
133-
"url": "https://github.com/Aliorpse/karin-plugins-alijs",
134-
"branch": "main"
135-
}
136-
]
147+
"name": "快捷执行指令",
148+
"url": "https://raw.githubusercontent.com/Aliorpse/karin-plugins-alijs/refs/heads/main/js/RunCMD.js"
137149
}
138-
]
139-
}
150+
]
151+
}
152+
]
153+
}

scripts/validate.js

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ const validateBaseFields = (plugin) => {
6464
throw new Error(`插件 ${plugin.name} 的仓库信息格式不正确`)
6565
}
6666

67-
const type = ['github', 'gitee', 'gitcode', 'gitlab', 'npm']
67+
const type = ['git', 'npm', 'app']
6868
if (!type.includes(plugin.type)) {
6969
throw new Error(`插件 ${plugin.name} 的类型 ${plugin.type} 无效`)
7070
}
@@ -141,10 +141,13 @@ const validateNpmPackage = async (name) => {
141141
*/
142142
const validatePackageJson = async (plugin, repo) => {
143143
try {
144+
if (plugin.type === 'app') {
145+
return // app 类型不需要验证 package.json
146+
}
144147
if (repo.type === 'npm') {
145-
if (repo.branch !== '') {
146-
throw new Error(`插件 ${plugin.name} 的 npm 仓库不应该设置 branch 字段`)
147-
}
148+
// if (repo.branch !== '') {
149+
// throw new Error(`插件 ${plugin.name} 的 npm 仓库不应该设置 branch 字段`)
150+
// }
148151
return // npm 类型不需要验证 package.json
149152
}
150153

@@ -199,9 +202,12 @@ const validateAppPlugin = (plugin) => {
199202
throw new Error(`App 类型插件 ${plugin.name} 缺少 files 数组`)
200203
}
201204

202-
for (const fileUrl of plugin.files) {
203-
if (!isValidUrl(fileUrl)) {
204-
throw new Error(`App 类型插件 ${plugin.name} 的文件URL无效: ${fileUrl}`)
205+
for (const file of plugin.files) {
206+
if (!file.name) {
207+
throw new Error(`App 类型插件 ${plugin.name} 的文件缺少 name 字段`)
208+
}
209+
if (!isValidUrl(file.url)) {
210+
throw new Error(`App 类型插件 ${plugin.name} 的文件URL无效: ${file.url}`)
205211
}
206212
}
207213
}

0 commit comments

Comments
 (0)