mirror of
https://github.com/cerc-io/watcher-ts
synced 2024-11-19 20:36:19 +00:00
Update codegen to add subgraph source to watcher readme (#514)
* Update codegen to add subgraph source to watcher readme * Update exported metrics for watcher config * Add steps to update package json and config to codegen instructions --------- Co-authored-by: Prathamesh Musale <prathamesh.musale0@gmail.com>
This commit is contained in:
parent
acf69dd554
commit
7884941e75
@ -114,6 +114,10 @@ Steps:
|
|||||||
|
|
||||||
This will create a folder containing the generated code at the path provided in config. Follow the steps in [Run Generated Watcher](#run-generated-watcher) to setup and run the generated watcher.
|
This will create a folder containing the generated code at the path provided in config. Follow the steps in [Run Generated Watcher](#run-generated-watcher) to setup and run the generated watcher.
|
||||||
|
|
||||||
|
* Update generated watcher's `package.json` with desired `version`, `description`, `repository` URL, etc.
|
||||||
|
|
||||||
|
* Update generated watcher's config (`environments/local.toml`) as required
|
||||||
|
|
||||||
## Development
|
## Development
|
||||||
|
|
||||||
* `lint`
|
* `lint`
|
||||||
|
@ -265,7 +265,7 @@ function generateWatcher (visitor: Visitor, contracts: any[], config: any, overW
|
|||||||
outStream = outputDir
|
outStream = outputDir
|
||||||
? fs.createWriteStream(path.join(outputDir, 'README.md'))
|
? fs.createWriteStream(path.join(outputDir, 'README.md'))
|
||||||
: process.stdout;
|
: process.stdout;
|
||||||
exportReadme(path.basename(outputDir), config.port, outStream);
|
exportReadme(path.basename(outputDir), config, outStream);
|
||||||
|
|
||||||
outStream = outputDir
|
outStream = outputDir
|
||||||
? fs.createWriteStream(path.join(outputDir, 'LICENSE'))
|
? fs.createWriteStream(path.join(outputDir, 'LICENSE'))
|
||||||
|
@ -15,12 +15,25 @@ const TEMPLATE_FILE = './templates/readme-template.handlebars';
|
|||||||
* @param port Watcher server port.
|
* @param port Watcher server port.
|
||||||
* @param outStream A writable output stream to write the README.md file to.
|
* @param outStream A writable output stream to write the README.md file to.
|
||||||
*/
|
*/
|
||||||
export function exportReadme (folderName: string, port: number, outStream: Writable): void {
|
export function exportReadme (
|
||||||
|
folderName: string,
|
||||||
|
config: { port: number, subgraphPath?: string },
|
||||||
|
outStream: Writable
|
||||||
|
): void {
|
||||||
|
const { port, subgraphPath } = config;
|
||||||
const templateString = fs.readFileSync(path.resolve(__dirname, TEMPLATE_FILE)).toString();
|
const templateString = fs.readFileSync(path.resolve(__dirname, TEMPLATE_FILE)).toString();
|
||||||
const template = Handlebars.compile(templateString);
|
const template = Handlebars.compile(templateString);
|
||||||
|
let subgraphRepoName;
|
||||||
|
|
||||||
|
if (subgraphPath) {
|
||||||
|
const subgraphRepoDir = path.dirname(subgraphPath);
|
||||||
|
subgraphRepoName = path.basename(subgraphRepoDir);
|
||||||
|
}
|
||||||
|
|
||||||
const readmeString = template({
|
const readmeString = template({
|
||||||
folderName,
|
folderName,
|
||||||
port
|
port,
|
||||||
|
subgraphRepoName
|
||||||
});
|
});
|
||||||
outStream.write(readmeString);
|
outStream.write(readmeString);
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,12 @@
|
|||||||
# {{folderName}}
|
# {{folderName}}
|
||||||
|
|
||||||
|
{{#if (subgraphPath)}}
|
||||||
|
## Source
|
||||||
|
|
||||||
|
<!-- TODO: Update with publised subgraph release version -->
|
||||||
|
* Subgraph: [{{subgraphRepoName}} v0.1.0](https://github.com/cerc-io/{{subgraphRepoName}}/releases/tag/v0.1.0)
|
||||||
|
|
||||||
|
{{/if}}
|
||||||
## Setup
|
## Setup
|
||||||
|
|
||||||
* Run the following command to install required packages:
|
* Run the following command to install required packages:
|
||||||
|
@ -245,6 +245,7 @@ const registerWatcherConfigMetrics = async ({ server, upstream, jobQueue }: Conf
|
|||||||
|
|
||||||
watcherConfigMetric.set({ category: 'jobqueue', field: 'num_events_in_batch' }, Number(jobQueue.eventsInBatch));
|
watcherConfigMetric.set({ category: 'jobqueue', field: 'num_events_in_batch' }, Number(jobQueue.eventsInBatch));
|
||||||
watcherConfigMetric.set({ category: 'jobqueue', field: 'block_delay_seconds' }, (Number(jobQueue.blockDelayInMilliSecs) || 0) / 1000);
|
watcherConfigMetric.set({ category: 'jobqueue', field: 'block_delay_seconds' }, (Number(jobQueue.blockDelayInMilliSecs) || 0) / 1000);
|
||||||
|
watcherConfigMetric.set({ category: 'jobqueue', field: 'block_processing_offset' }, Number(jobQueue.blockProcessingOffset) ?? 0);
|
||||||
watcherConfigMetric.set({ category: 'jobqueue', field: 'use_block_ranges' }, Number(jobQueue.useBlockRanges));
|
watcherConfigMetric.set({ category: 'jobqueue', field: 'use_block_ranges' }, Number(jobQueue.useBlockRanges));
|
||||||
watcherConfigMetric.set({ category: 'jobqueue', field: 'historical_logs_block_range' }, Number(jobQueue.historicalLogsBlockRange));
|
watcherConfigMetric.set({ category: 'jobqueue', field: 'historical_logs_block_range' }, Number(jobQueue.historicalLogsBlockRange));
|
||||||
watcherConfigMetric.set({ category: 'jobqueue', field: 'historical_max_fetch_ahead' }, Number(jobQueue.historicalMaxFetchAhead));
|
watcherConfigMetric.set({ category: 'jobqueue', field: 'historical_max_fetch_ahead' }, Number(jobQueue.historicalMaxFetchAhead));
|
||||||
|
Loading…
Reference in New Issue
Block a user