Files
certd/packages/ui/certd-server/src/modules/pipeline/service/builtin-plugin-service.ts
T
xiaojunnuo 3d9620abb0 refactor(plugin): 重构插件定义和安装流程
- 更新插件配置格式,增加依赖库和插件类型字段
- 修改插件安装流程,支持安装依赖插件和第三方库
- 优化插件列表过滤逻辑,按类型筛选插件
- 调整 Dockerfile,使用 Node.js22 镜像并更新 pnpm 安装方式
2025-04-11 23:39:40 +08:00

43 lines
1.1 KiB
TypeScript

import { Provide, Scope, ScopeEnum } from '@midwayjs/core';
import { pluginGroups, pluginRegistry } from '@certd/pipeline';
import { cloneDeep } from 'lodash-es';
@Provide()
@Scope(ScopeEnum.Request, { allowDowngrade: true })
export class BuiltInPluginService {
getList() {
const collection = pluginRegistry.storage;
let list = [];
for (const key in collection) {
const Plugin = collection[key];
if (Plugin?.define?.deprecated) {
continue;
}
//@ts-ignore
if(Plugin.define?.type && Plugin.define?.type !== 'builtin'){
continue;
}
list.push({ ...Plugin.define, key });
}
list = list.sort((a, b) => {
return (a.order ?? 10 )- (b.order ?? 10);
});
return list;
}
getGroups() {
const groups:any = cloneDeep(pluginGroups);
for (const key in groups) {
const group = groups[key];
group.plugins = group.plugins.sort((a, b) => {
return (a.order ?? 10 )- (b.order ?? 10);
});
}
return groups;
}
getByType(type: string) {
return pluginRegistry.getDefine(type);
}
}