mirror of
https://github.com/certd/certd.git
synced 2026-04-23 19:57:27 +08:00
chore: plugin元数据换成yaml格式
This commit is contained in:
@@ -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')
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user