tornado-subgraph/create-yaml-file.js

54 lines
2.0 KiB
JavaScript
Raw Normal View History

2021-06-09 14:34:06 +02:00
'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>',
2021-06-09 15:43:04 +02:00
'defaults to "bsc" and uses the bsc start blocks config. Must set to "goerli" to use test start blocks config',
'bsc',
2021-06-09 14:34:06 +02:00
)
2021-06-10 10:49:47 +02:00
.action(async ({ env }) => {
2021-06-09 14:34:06 +02:00
const baseIndexPath = path.join(__dirname, 'mustache', 'templates', 'base', 'index.js');
2021-06-10 10:49:47 +02:00
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),
];
2021-06-09 14:34:06 +02:00
const indexData = require(baseIndexPath);
2021-06-10 10:49:47 +02:00
const specificEchoerIndexData = require(echoerIndexPath);
const specificInstancesIndexData = require(instancesIndexPath);
const specificProxyIndexData = require(proxyIndexPath);
2021-06-09 14:34:06 +02:00
2021-06-10 10:49:47 +02:00
indexData.yaml[0] = {
...indexData.yaml[0],
...specificEchoerIndexData,
...specificInstancesIndexData,
...specificProxyIndexData,
};
2021-06-09 14:34:06 +02:00
indexData.yaml[0].dataSources = dataSourcesData;
return console.log(JSON.stringify(indexData, null, 2) + '\n');
});
program.parse(process.argv);