mirror of
https://github.com/tornadocash/tornado-subgraph.git
synced 2024-12-22 17:33:17 +01:00
39 lines
1.3 KiB
JavaScript
39 lines
1.3 KiB
JavaScript
'use strict';
|
|
|
|
const path = require('path');
|
|
const program = require('commander');
|
|
|
|
program
|
|
.command('create-yaml')
|
|
.description('Creates yaml files using the mustache templating engine')
|
|
.option(
|
|
'-s, --subgraph <value>',
|
|
'the subgraph for which you are creating the yaml file. Currently only "proxy", "instance" and "echoer" are supported',
|
|
)
|
|
.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 ({ subgraph, env }) => {
|
|
const baseIndexPath = path.join(__dirname, 'mustache', 'templates', 'base', 'index.js');
|
|
const specificIndexPath = path.join(__dirname, 'mustache', 'templates', subgraph, 'index.js');
|
|
const dataSourcesPath = path.join(__dirname, 'mustache', 'templates', subgraph, 'create-yaml.js');
|
|
|
|
const subgraphDataSourcesData = require(dataSourcesPath);
|
|
const dataSourcesData = [
|
|
...subgraphDataSourcesData.createYaml(env),
|
|
];
|
|
|
|
const indexData = require(baseIndexPath);
|
|
|
|
const specificIndexData = require(specificIndexPath);
|
|
|
|
indexData.yaml[0] = { ...indexData.yaml[0], ...specificIndexData };
|
|
indexData.yaml[0].dataSources = dataSourcesData;
|
|
|
|
return console.log(JSON.stringify(indexData, null, 2) + '\n');
|
|
});
|
|
|
|
program.parse(process.argv);
|