-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathapp.js
50 lines (45 loc) · 1.2 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
const $RefParser = require("json-schema-ref-parser");
const fs = require("fs");
const indexYamlPath = "./configs/index.yaml";
const outputFolderPath = "./build";
const argsList = ["trv", "fis", "nts" , "igm"];
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) {
path.flows.push(flow.path);
}
outputBuild("build.json", path);
} else {
if (!argsList.includes(args)) {
console.error(`
"${args}" not a valid parameter.
Possible valid parameter include: ${argsList}
`);
return;
}
// run only specific flow
const flow = config.find((element) => args === element.domain);
outputBuild(flow.filename, flow.path);
}
})();