mirror of
https://github.com/cerc-io/watcher-ts
synced 2025-07-27 10:42:06 +00:00
Add required codegen template
This commit is contained in:
parent
52309ef72b
commit
eb46645a70
@ -9,6 +9,7 @@ import { ConnectionOptions, Repository } from 'typeorm';
|
|||||||
import debug from 'debug';
|
import debug from 'debug';
|
||||||
|
|
||||||
import { DEFAULT_CONFIG_PATH, JSONbigNative, DatabaseInterface, Config, EventInterface } from '@cerc-io/util';
|
import { DEFAULT_CONFIG_PATH, JSONbigNative, DatabaseInterface, Config, EventInterface } from '@cerc-io/util';
|
||||||
|
|
||||||
import { BaseCmd } from './base';
|
import { BaseCmd } from './base';
|
||||||
|
|
||||||
const log = debug('vulcanize:backfill-events-data');
|
const log = debug('vulcanize:backfill-events-data');
|
||||||
|
21
packages/codegen/src/backfill-events-data.ts
Normal file
21
packages/codegen/src/backfill-events-data.ts
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
//
|
||||||
|
// Copyright 2024 Vulcanize, Inc.
|
||||||
|
//
|
||||||
|
|
||||||
|
import fs from 'fs';
|
||||||
|
import path from 'path';
|
||||||
|
import Handlebars from 'handlebars';
|
||||||
|
import { Writable } from 'stream';
|
||||||
|
|
||||||
|
const TEMPLATE_FILE = './templates/backfill-events-data-template.handlebars';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Writes the backfill-events-data file generated from a template to a stream.
|
||||||
|
* @param outStream A writable output stream to write the backfill-events-data file to.
|
||||||
|
*/
|
||||||
|
export function exportBackfillEventsData (outStream: Writable): void {
|
||||||
|
const templateString = fs.readFileSync(path.resolve(__dirname, TEMPLATE_FILE)).toString();
|
||||||
|
const template = Handlebars.compile(templateString);
|
||||||
|
const content = template({});
|
||||||
|
outStream.write(content);
|
||||||
|
}
|
@ -40,6 +40,7 @@ import { exportIndexBlock } from './index-block';
|
|||||||
import { exportSubscriber } from './subscriber';
|
import { exportSubscriber } from './subscriber';
|
||||||
import { exportReset } from './reset';
|
import { exportReset } from './reset';
|
||||||
import { filterInheritedContractNodes, writeFileToStream } from './utils/helpers';
|
import { filterInheritedContractNodes, writeFileToStream } from './utils/helpers';
|
||||||
|
import { exportBackfillEventsData } from './backfill-events-data';
|
||||||
|
|
||||||
const main = async (): Promise<void> => {
|
const main = async (): Promise<void> => {
|
||||||
const argv = await yargs(hideBin(process.argv))
|
const argv = await yargs(hideBin(process.argv))
|
||||||
@ -389,6 +390,11 @@ function generateWatcher (visitor: Visitor, contracts: any[], configFile: string
|
|||||||
: process.stdout;
|
: process.stdout;
|
||||||
exportIndexBlock(outStream);
|
exportIndexBlock(outStream);
|
||||||
|
|
||||||
|
outStream = outputDir
|
||||||
|
? fs.createWriteStream(path.join(outputDir, 'src/cli/backfill-events-data.ts'))
|
||||||
|
: process.stdout;
|
||||||
|
exportBackfillEventsData(outStream);
|
||||||
|
|
||||||
if (config.subgraphPath) {
|
if (config.subgraphPath) {
|
||||||
outStream = outputDir
|
outStream = outputDir
|
||||||
? fs.createWriteStream(path.join(outputDir, 'src/entity/Subscriber.ts'))
|
? fs.createWriteStream(path.join(outputDir, 'src/entity/Subscriber.ts'))
|
||||||
|
@ -0,0 +1,26 @@
|
|||||||
|
//
|
||||||
|
// Copyright 2024 Vulcanize, Inc.
|
||||||
|
//
|
||||||
|
|
||||||
|
import 'reflect-metadata';
|
||||||
|
import debug from 'debug';
|
||||||
|
|
||||||
|
import { BackfillEventsDataCmd } from '@cerc-io/cli';
|
||||||
|
|
||||||
|
import { Database } from '../database';
|
||||||
|
import { Event } from '../entity/Event';
|
||||||
|
|
||||||
|
const log = debug('vulcanize:backfill-events-data');
|
||||||
|
|
||||||
|
const main = async (): Promise<void> => {
|
||||||
|
const backFillCmd = new BackfillEventsDataCmd();
|
||||||
|
await backFillCmd.init(Database);
|
||||||
|
|
||||||
|
await backFillCmd.exec(Event);
|
||||||
|
};
|
||||||
|
|
||||||
|
main().catch(err => {
|
||||||
|
log(err);
|
||||||
|
}).finally(() => {
|
||||||
|
process.exit(0);
|
||||||
|
});
|
Loading…
Reference in New Issue
Block a user