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:
2024-06-11 14:42:54 +05:30
committed by GitHub
co-authored by prathamesh
parent acf69dd554
commit 7884941e75
5 changed files with 28 additions and 3 deletions
+4
View File
@@ -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.
* Update generated watcher's `package.json` with desired `version`, `description`, `repository` URL, etc.
* Update generated watcher's config (`environments/local.toml`) as required
## Development
* `lint`
+1 -1
View File
@@ -265,7 +265,7 @@ function generateWatcher (visitor: Visitor, contracts: any[], config: any, overW
outStream = outputDir
? fs.createWriteStream(path.join(outputDir, 'README.md'))
: process.stdout;
exportReadme(path.basename(outputDir), config.port, outStream);
exportReadme(path.basename(outputDir), config, outStream);
outStream = outputDir
? fs.createWriteStream(path.join(outputDir, 'LICENSE'))
+15 -2
View File
@@ -15,12 +15,25 @@ const TEMPLATE_FILE = './templates/readme-template.handlebars';
* @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 {
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
port,
subgraphRepoName
});
outStream.write(readmeString);
}
@@ -1,5 +1,12 @@
# {{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
* Run the following command to install required packages: