watcher-ts/packages/codegen/src
Ashwin Phatak 92b7967895
Generating eth_call based lazy watcher (#249)
* Add entity generation.

* Add resolvers generation.

* Add queries in resolvers generation.

* Add indexer generation.

* Extract helper code in utils.

* Add server and artifacts generation.

* Fix solidity-flattener issue.

* Update readme and cleanup misc files.

* Add queries to entity generation.

* Add database generation.

* Use snakecase in database.

* Add readme generation.

* Change template file names.

* Add method descriptions.

* Change mode to eth_call in readme.

Co-authored-by: prathamesh <prathamesh.musale0@gmail.com>
2021-09-23 16:55:46 +05:30
..
templates Generating eth_call based lazy watcher (#249) 2021-09-23 16:55:46 +05:30
types/common Generating eth_call based lazy watcher (#249) 2021-09-23 16:55:46 +05:30
utils Generating eth_call based lazy watcher (#249) 2021-09-23 16:55:46 +05:30
artifacts.ts Generating eth_call based lazy watcher (#249) 2021-09-23 16:55:46 +05:30
config.ts Generating eth_call based lazy watcher (#249) 2021-09-23 16:55:46 +05:30
database.ts Generating eth_call based lazy watcher (#249) 2021-09-23 16:55:46 +05:30
entity.ts Generating eth_call based lazy watcher (#249) 2021-09-23 16:55:46 +05:30
generate-code.ts Generating eth_call based lazy watcher (#249) 2021-09-23 16:55:46 +05:30
indexer.ts Generating eth_call based lazy watcher (#249) 2021-09-23 16:55:46 +05:30
package.ts Generating eth_call based lazy watcher (#249) 2021-09-23 16:55:46 +05:30
readme.ts Generating eth_call based lazy watcher (#249) 2021-09-23 16:55:46 +05:30
resolvers.ts Generating eth_call based lazy watcher (#249) 2021-09-23 16:55:46 +05:30
schema.ts Generating eth_call based lazy watcher (#249) 2021-09-23 16:55:46 +05:30
server.ts Generating eth_call based lazy watcher (#249) 2021-09-23 16:55:46 +05:30
tsconfig.ts Generating eth_call based lazy watcher (#249) 2021-09-23 16:55:46 +05:30
visitor.ts Generating eth_call based lazy watcher (#249) 2021-09-23 16:55:46 +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 contractName Input contract name given as title of the README.
 * @param outStream A writable output stream to write the README.md file to.
 */
export function exportReadme (folderName: string, contractName: string, outStream: Writable): void {
  const templateString = fs.readFileSync(path.resolve(__dirname, TEMPLATE_FILE)).toString();
  const template = Handlebars.compile(templateString);
  const readmeString = template({
    folderName,
    contractName
  });
  outStream.write(readmeString);
}