chore: plugin元数据换成yaml格式

This commit is contained in:
xiaojunnuo
2025-04-15 00:16:57 +08:00
parent cfd3b66be9
commit 91ffb0820a
129 changed files with 7037 additions and 3 deletions
+30 -3
View File
@@ -4,14 +4,12 @@ import { join } from 'path';
import fs from 'fs'
import { pathToFileURL } from "node:url";
import path from 'path'
import * as yaml from "js-yaml";
function scanDir(dir) {
const files = fs.readdirSync(dir);
const result = [];
// 扫描目录及子目录
for (const file of files) {
if (file.includes("index.js")) {
continue;
}
const filePath = join(dir, file);
const stat = fs.statSync(filePath);
@@ -50,4 +48,33 @@ const modules = await loadModules('./dist/plugins');
for (const key in modules) {
console.log(key)
const module = modules[key]
const entry = Object.entries(module)
for (const [name, value] of entry) {
if(key.includes("deploy-to-live")){
console.log("live",value)
}
//如果有define属性
if(value.define){
//那么就是插件
let location = key.substring(4)
location = location.substring(0, location.length - 3)
const pluginDefine = {
...value.define
}
if(pluginDefine.accessType){
pluginDefine.pluginType = "dnsProvider"
}else if(pluginDefine.group){
pluginDefine.pluginType = "deploy"
}else{
pluginDefine.pluginType = "access"
}
delete pluginDefine.autowire
const filePath = path.join(`./src/${location}`+".yaml")
const data = yaml.dump(pluginDefine)
fs.writeFileSync(filePath,data ,'utf8')
}
}
}