watcher-ts/packages/codegen/src
prathamesh0 e30af92901
Add a CLI in eden-watcher to fill state for a given range (#176)
* Add a CLI to fill state for a given range

* Refactor code

* Add a CLI to reset IPLD state

* Replace ORDER BY clause in the query to get latest IPLD block

* Optimize delete query in CLI to reset IPLD state

* Add an option to decouple subgraph state creation from mapping code

* Use a raw SQL query to delete IPLD blocks in a block range

* Accomodate changes in codegen
2022-09-09 16:23:41 +05:30
..
data/entities Handle getStorage calls for old blocks (#145) 2022-07-20 10:37:17 +05:30
templates Add a CLI in eden-watcher to fill state for a given range (#176) 2022-09-09 16:23:41 +05:30
types/common Generate GQL client (#259) 2021-10-04 11:04:06 +05:30
utils Update codegen with changes implemented in mobymask watcher (#148) 2022-07-22 13:17:56 +05:30
artifacts.ts Generate schema from ABI when using subgraph path (#101) 2021-12-28 16:08:05 +05:30
checkpoint.ts Fix codegen for non subgraph watchers (#120) 2022-05-26 18:00:17 +05:30
client.ts Add a CLI in eden-watcher to fill state for a given range (#176) 2022-09-09 16:23:41 +05:30
config.ts Generate GQL API for subgraph entities and auto-diff based on store set (#38) 2021-12-28 16:08:05 +05:30
database.ts Change initial checkpoint hook and hook status entity naming (#269) 2021-12-28 16:08:04 +05:30
entity.ts Implement query for multiple entities and nested relation fields in eden-watcher (#166) 2022-09-01 14:17:43 +05:30
events.ts Support storage mode for code generator (#251) 2021-09-27 10:13:50 +05:30
export-state.ts Fix codegen for non subgraph watchers (#120) 2022-05-26 18:00:17 +05:30
fill.ts Add a CLI in eden-watcher to fill state for a given range (#176) 2022-09-09 16:23:41 +05:30
generate-code.ts Add a CLI in eden-watcher to fill state for a given range (#176) 2022-09-09 16:23:41 +05:30
hooks.ts Generate IPLD blocks table and related GQL API (#260) 2021-12-28 16:08:04 +05:30
import-state.ts Fix codegen for non subgraph watchers (#120) 2022-05-26 18:00:17 +05:30
index-block.ts Update codegen with changes implemented in mobymask watcher (#148) 2022-07-22 13:17:56 +05:30
indexer.ts Add a CLI in eden-watcher to fill state for a given range (#176) 2022-09-09 16:23:41 +05:30
inspect-cid.ts Fix codegen for non subgraph watchers (#120) 2022-05-26 18:00:17 +05:30
job-runner.ts Fix codegen for non subgraph watchers (#120) 2022-05-26 18:00:17 +05:30
lint.ts Generate entities from YAML templates and lint support in generated watchers (#253) 2021-09-27 18:03:04 +05:30
package.ts Generating eth_call based lazy watcher (#249) 2021-09-23 16:55:46 +05:30
readme.ts Parse events for multiple contracts in the generated code (#95) 2021-12-28 16:08:05 +05:30
reset.ts Add a CLI in eden-watcher to fill state for a given range (#176) 2022-09-09 16:23:41 +05:30
resolvers.ts Generate GQL API for subgraph entities and auto-diff based on store set (#38) 2021-12-28 16:08:05 +05:30
schema.ts Add GQL query for sync status (#159) 2022-08-09 13:25:46 +05:30
server.ts Fix codegen for non subgraph watchers (#120) 2022-05-26 18:00:17 +05:30
tsconfig.ts Generating eth_call based lazy watcher (#249) 2021-09-23 16:55:46 +05:30
types.ts Handle subgraph entities field name conflicts and enum types in codegen (#86) 2021-12-28 16:08:05 +05:30
visitor.ts Add a CLI in eden-watcher to fill state for a given range (#176) 2022-09-09 16:23:41 +05:30
watch-contract.ts Fix codegen for non subgraph watchers (#120) 2022-05-26 18:00:17 +05:30

//
// Copyright 2021 Vulcanize, Inc.
//

import fs from 'fs';
import path from 'path';
import Handlebars from 'handlebars';
import { Writable } from 'stream';

const TEMPLATE_FILE = './templates/readme-template.handlebars';

/**
 * Writes the README.md file generated from a template to a stream.
 * @param folderName Watcher folder name to be passed to the template.
 * @param port Watcher server port.
 * @param outStream A writable output stream to write the README.md file to.
 */
export function exportReadme (folderName: string, port: number, outStream: Writable): void {
  const templateString = fs.readFileSync(path.resolve(__dirname, TEMPLATE_FILE)).toString();
  const template = Handlebars.compile(templateString);
  const readmeString = template({
    folderName,
    port
  });
  outStream.write(readmeString);
}