-
Notifications
You must be signed in to change notification settings - Fork 17
/
create-yaml-file.js
53 lines (41 loc) · 2.01 KB
/
create-yaml-file.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
'use strict';
const path = require('path');
const program = require('commander');
program
.command('create-yaml')
.description('Creates yaml files using the mustache templating engine')
.option(
'-e, --env <value>',
'defaults to "bsc" and uses the bsc start blocks config. Must set to "goerli" to use test start blocks config',
'bsc',
)
.action(async ({ env }) => {
const baseIndexPath = path.join(__dirname, 'mustache', 'templates', 'base', 'index.js');
const echoerIndexPath = path.join(__dirname, 'mustache', 'templates', 'echoer', 'index.js');
const dataEchoerSourcesPath = path.join(__dirname, 'mustache', 'templates', 'echoer', 'create-yaml.js');
const instancesIndexPath = path.join(__dirname, 'mustache', 'templates', 'instance', 'index.js');
const dataInstancesSourcesPath = path.join(__dirname, 'mustache', 'templates', 'instance', 'create-yaml.js');
const proxyIndexPath = path.join(__dirname, 'mustache', 'templates', 'proxy', 'index.js');
const dataProxySourcesPath = path.join(__dirname, 'mustache', 'templates', 'proxy', 'create-yaml.js');
const echoerDataSourcesData = require(dataEchoerSourcesPath);
const instancesDataSourcesData = require(dataInstancesSourcesPath);
const proxyDataSourcesData = require(dataProxySourcesPath);
const dataSourcesData = [
...echoerDataSourcesData.createYaml(env),
...instancesDataSourcesData.createYaml(env),
...proxyDataSourcesData.createYaml(env),
];
const indexData = require(baseIndexPath);
const specificEchoerIndexData = require(echoerIndexPath);
const specificInstancesIndexData = require(instancesIndexPath);
const specificProxyIndexData = require(proxyIndexPath);
indexData.yaml[0] = {
...indexData.yaml[0],
...specificEchoerIndexData,
...specificInstancesIndexData,
...specificProxyIndexData,
};
indexData.yaml[0].dataSources = dataSourcesData;
return console.log(JSON.stringify(indexData, null, 2) + '\n');
});
program.parse(process.argv);