Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@
"name": "karin-plugin-basic",
"type": "npm",
"description": "karin plugin basic",
"home": "https://github.com/karinjs/karin-plugin-basic",
"license": {
"name": "MIT",
"url": "https://github.com/karinjs/karin-plugin-basic/blob/main/LICENSE"
Expand Down Expand Up @@ -133,6 +134,7 @@
"name": "karin-plugin-git-example",
"type": "git",
"description": "这是一个 Git 插件示例",
"home": "https://github.com/username/karin-plugin-git-example",
"license": {
"name": "MIT",
"url": "https://github.com/username/karin-plugin-git-example/blob/main/LICENSE"
Expand Down Expand Up @@ -161,6 +163,7 @@
"name": "karin-plugin-app-example",
"type": "app",
"description": "这是一个 App 插件示例",
"home": "https://github.com/username/karin-plugin-app-example",
"license": {
"name": "GPL-3.0",
"url": "https://github.com/username/karin-plugin-app-example/blob/main/LICENSE"
Expand All @@ -179,9 +182,11 @@
"branch": "main"
}
],
"files": [
"https://example.com/download/plugin-v1.0.0.js",
"https://mirror.example.com/download/plugin-v1.0.0.js"
"files": [ // 这里可以添加多个文件
{
"name": "karin-plugin-app-example.js",
"url": "https://mirror.example.com/download/karin-plugin-app-example.js"
}
]
}
]
Expand Down
272 changes: 143 additions & 129 deletions plugins.json
Original file line number Diff line number Diff line change
@@ -1,139 +1,153 @@
{
"plugins": [
{
"name": "@karinjs/plugin-basic",
"type": "npm",
"description": "karin plugin basic",
"home": "https://github.com/karinjs/karin-plugin-basic",
"license": {
"name": "MIT",
"url": "https://github.com/karinjs/karin-plugin-basic/blob/main/LICENSE"
},
"time": "2025-01-19 10:00:00",
"author": [
{
"name": "shijin",
"home": "https://github.com/sj817"
}
],
"repo": [
{
"type": "github",
"url": "https://github.com/karinjs/karin-plugin-basic",
"branch": "main"
}
]
"plugins": [
{
"name": "@karinjs/plugin-basic",
"type": "npm",
"description": "karin plugin basic",
"home": "https://github.com/karinjs/karin-plugin-basic",
"license": {
"name": "MIT",
"url": "https://github.com/karinjs/karin-plugin-basic/blob/main/LICENSE"
},
"time": "2025-01-19 10:00:00",
"author": [
{
"name": "shijin",
"home": "https://github.com/sj817"
}
],
"repo": [
{
"type": "github",
"url": "https://github.com/karinjs/karin-plugin-basic",
"branch": "main"
}
]
},
{
"name": "karin-plugin-kkk",
"type": "npm",
"description": "咕咕咕 ~",
"home": "https://github.com/ikenxuan/karin-plugin-kkk",
"license": {
"name": "GPL-3.0",
"url": "https://github.com/ikenxuan/karin-plugin-kkk/blob/main/LICENSE"
},
"time": "2025-01-25 22:47:37",
"author": [
{
"name": "ikenxuan",
"home": "https://github.com/ikenxuan"
}
],
"repo": [
{
"type": "github",
"url": "https://github.com/ikenxuan/karin-plugin-kkk",
"branch": "main"
},
{
"name": "karin-plugin-kkk",
"type": "npm",
"description": "咕咕咕 ~",
"home": "https://github.com/ikenxuan/karin-plugin-kkk",
"license": {
"name": "GPL-3.0",
"url": "https://github.com/ikenxuan/karin-plugin-kkk/blob/main/LICENSE"
},
"time": "2025-01-25 22:47:37",
"author": [
{
"name": "ikenxuan",
"home": "https://github.com/ikenxuan"
}
],
"repo": [
{
"type": "github",
"url": "https://github.com/ikenxuan/karin-plugin-kkk",
"branch": "main"
},
{
"type": "npm",
"url": "https://www.npmjs.com/package/karin-plugin-kkk",
"branch": ""
}
]
"type": "npm",
"url": "https://www.npmjs.com/package/karin-plugin-kkk",
"branch": ""
}
]
},
{
"name": "karin-plugin-ling",
"type": "npm",
"description": "希腊奶",
"home": "https://github.com/yusheng929/karin-plugin-ling",
"license": {
"name": "GPL-3.0",
"url": "https://github.com/yusheng929/karin-plugin-ling/blob/main/LICENSE"
},
"time": "2025-02-02 10:00:00",
"author": [
{
"name": "yusheng929",
"home": "https://github.com/yusheng929"
}
],
"repo": [
{
"type": "github",
"url": "https://github.com/yusheng929/karin-plugin-ling",
"branch": "main"
},
{
"name": "karin-plugin-ling",
"type": "npm",
"description": "希腊奶",
"home": "https://github.com/yusheng929/karin-plugin-ling",
"license": {
"name": "GPL-3.0",
"url": "https://github.com/yusheng929/karin-plugin-ling/blob/main/LICENSE"
},
"time": "2025-02-02 10:00:00",
"author": [
{
"name": "yusheng929",
"home": "https://github.com/yusheng929"
}
],
"repo": [
{
"type": "github",
"url": "https://github.com/yusheng929/karin-plugin-ling",
"branch": "main"
},
{
"type": "npm",
"url": "https://www.npmjs.com/package/karin-plugin-ling",
"branch": ""
}
]
"type": "npm",
"url": "https://www.npmjs.com/package/karin-plugin-ling",
"branch": ""
}
]
},
{
"name": "karin-mys-core",
"type": "npm",
"description": "前面的区域以后再来探索吧!",
"home": "https://github.com/Karin-Mys-Plugins/mys-core",
"license": {
"name": "GPL-3.0",
"url": "https://github.com/Karin-Mys-Plugins/mys-core/blob/main/LICENSE"
},
"time": "2025-02-16 11:45:14",
"author": [
{
"name": "babanbang",
"home": "https://github.com/babanbang"
}
],
"repo": [
{
"type": "github",
"url": "https://github.com/Karin-Mys-Plugins/mys-core",
"branch": "main"
},
{
"type": "npm",
"url": "https://www.npmjs.com/package/karin-mys-core",
"branch": ""
}
]
},
{
"name": "karin-plugins-alijs",
"type": "app",
"description": "一个用于 Karin 的插件集合",
"home": "https://github.com/Aliorpse/karin-plugins-alijs",
"license": {
"name": "MIT",
"url": "https://github.com/Aliorpse/karin-plugins-alijs/blob/main/LICENSE"
},
"time": "2025-02-16 11:45:14",
"author": [
{
"name": "Aliorpse",
"home": "https://github.com/Aliorpse"
}
],
"repo": [
{
"type": "github",
"url": "https://github.com/Aliorpse/karin-plugins-alijs",
"branch": "main"
}
],
"files": [
{
"name": "B站链接解析",
"url": "https://raw.githubusercontent.com/Aliorpse/karin-plugins-alijs/refs/heads/main/js/BiliParser.js"
},
{
"name": "karin-mys-core",
"type": "npm",
"description": "前面的区域以后再来探索吧!",
"home": "https://github.com/Karin-Mys-Plugins/mys-core",
"license": {
"name": "GPL-3.0",
"url": "https://github.com/Karin-Mys-Plugins/mys-core/blob/main/LICENSE"
},
"time": "2025-02-16 11:45:14",
"author": [
{
"name": "babanbang",
"home": "https://github.com/babanbang"
}
],
"repo": [
{
"type": "github",
"url": "https://github.com/Karin-Mys-Plugins/mys-core",
"branch": "main"
},
{
"type": "npm",
"url": "https://www.npmjs.com/package/karin-mys-core",
"branch": ""
}
]
"name": "Minecraft 服务器状态获取",
"url": "https://raw.githubusercontent.com/Aliorpse/karin-plugins-alijs/refs/heads/main/js/MCMotd.js"
},
{
"name": "karin-plugin-mcmotd",
"type": "app",
"description": "Minecraft 服务器状态获取",
"home": "https://github.com/Aliorpse/karin-plugins-alijs/blob/main/js/MCMotd.js",
"license": {
"name": "MIT",
"url": "https://github.com/Aliorpse/karin-plugins-alijs/blob/main/LICENSE"
},
"time": "2025-02-16 11:45:14",
"author": [
{
"name": "Aliorpse",
"home": "https://github.com/Aliorpse"
}
],
"repo": [
{
"type": "github",
"url": "https://github.com/Aliorpse/karin-plugins-alijs",
"branch": "main"
}
]
"name": "快捷执行指令",
"url": "https://raw.githubusercontent.com/Aliorpse/karin-plugins-alijs/refs/heads/main/js/RunCMD.js"
}
]
}
]
}
]
}
20 changes: 13 additions & 7 deletions scripts/validate.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ const validateBaseFields = (plugin) => {
throw new Error(`插件 ${plugin.name} 的仓库信息格式不正确`)
}

const type = ['github', 'gitee', 'gitcode', 'gitlab', 'npm']
const type = ['git', 'npm', 'app']
if (!type.includes(plugin.type)) {
throw new Error(`插件 ${plugin.name} 的类型 ${plugin.type} 无效`)
}
Expand Down Expand Up @@ -141,10 +141,13 @@ const validateNpmPackage = async (name) => {
*/
const validatePackageJson = async (plugin, repo) => {
try {
if (plugin.type === 'app') {
return // app 类型不需要验证 package.json
}
if (repo.type === 'npm') {
if (repo.branch !== '') {
throw new Error(`插件 ${plugin.name} 的 npm 仓库不应该设置 branch 字段`)
}
// if (repo.branch !== '') {
// throw new Error(`插件 ${plugin.name} 的 npm 仓库不应该设置 branch 字段`)
// }
return // npm 类型不需要验证 package.json
}

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

for (const fileUrl of plugin.files) {
if (!isValidUrl(fileUrl)) {
throw new Error(`App 类型插件 ${plugin.name} 的文件URL无效: ${fileUrl}`)
for (const file of plugin.files) {
if (!file.name) {
throw new Error(`App 类型插件 ${plugin.name} 的文件缺少 name 字段`)
}
if (!isValidUrl(file.url)) {
throw new Error(`App 类型插件 ${plugin.name} 的文件URL无效: ${file.url}`)
}
}
}
Expand Down
Loading