mirror of
https://github.com/cerc-io/watcher-ts
synced 2025-10-26 10:04:09 +00:00
* Handle user defined types in visitor methods when continuing on error * Handle unnamed arguments in solidity methods * Update graph-cli package version --------- Co-authored-by: Shreerang Kale <shreerangkale@gmail.com> |
||
|---|---|---|
| .. | ||
| assets | ||
| data/entities | ||
| templates | ||
| types/common | ||
| utils | ||
| artifacts.ts | ||
| backfill-events-data.ts | ||
| checkpoint.ts | ||
| client.ts | ||
| config.ts | ||
| database.ts | ||
| entity.ts | ||
| export-state.ts | ||
| fill.ts | ||
| generate-code.ts | ||
| hooks.ts | ||
| import-state.ts | ||
| index-block.ts | ||
| indexer.ts | ||
| inspect-cid.ts | ||
| job-runner.ts | ||
| lint.ts | ||
| package.ts | ||
| readme.ts | ||
| reset.ts | ||
| resolvers.ts | ||
| schema.ts | ||
| server.ts | ||
| subscriber.ts | ||
| tsconfig.ts | ||
| types.ts | ||
| visitor.ts | ||
| watch-contract.ts | ||
//
// 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,
config: { port: number, subgraphPath?: string },
outStream: Writable
): void {
const { port, subgraphPath } = config;
const templateString = fs.readFileSync(path.resolve(__dirname, TEMPLATE_FILE)).toString();
const template = Handlebars.compile(templateString);
let subgraphRepoName;
if (subgraphPath) {
const subgraphRepoDir = path.dirname(subgraphPath);
subgraphRepoName = path.basename(subgraphRepoDir);
}
const readmeString = template({
folderName,
port,
subgraphRepoName
});
outStream.write(readmeString);
}