-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathapp.js
53 lines (36 loc) · 1.27 KB
/
app.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
const $RefParser = require("json-schema-ref-parser");
const yaml = require("js-yaml");
const fs = require("fs")
var uiPath = "./build/build.js";
var uiPathJson = "./build/build.json";
const outputFolderPath = "./build";
const indexYamlPath = './configs/main.yaml'
// read yaml
async function baseYMLFile(file) {
try {
const schema = await $RefParser.dereference(file);
return schema;
} catch (error) {
console.error("Error parsing schema:", error);
}
}
function outputBuild(outputPath,flow){
fs.writeFileSync(`${outputFolderPath}/${outputPath}`, JSON.stringify(flow), "utf8");
}
// driver
(async function driver(){
const args = process.argv[2]
let config = await baseYMLFile(indexYamlPath)
config = config?.configs
if(!args){ // run all flows
let path= {flows:[]};
for (const flow of config){
outputBuild(flow.filename,flow.path)
path.flows = [...path.flows,...flow?.path?.flows]
}
outputBuild("build.json",path)
}else{ // run only specific flow
const flow = config.find((element)=>args===element.domain)
outputBuild(flow.filename,flow.path)
}
})()