Export codegen config in a generated watcher (#522)

* Export codegen config in a generated watcher

* Update instructions with build step
This commit is contained in:
prathamesh0 2024-06-13 16:41:49 +05:30 committed by GitHub
parent 467c173a0d
commit 9c4b06652e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 25 additions and 3 deletions

View File

@ -118,6 +118,8 @@ Steps:
* Update generated watcher's config (`environments/local.toml`) as required
* Update generated codegen config (`codegen-config.yml`) to remove / replace your system's absolute paths
## Development
* `lint`
@ -158,6 +160,12 @@ Steps:
yarn
```
* Run build:
```bash
yarn build
```
* In the config file (`environments/local.toml`):
* Update the state checkpoint settings.

View File

@ -65,7 +65,8 @@ const main = async (): Promise<void> => {
})
.argv;
const config = await getConfig(path.resolve(argv['config-file']));
const configFile = path.resolve(argv['config-file']);
const config = await getConfig(configFile);
// Create an array of flattened contract strings.
const contracts: any[] = [];
@ -120,7 +121,7 @@ const main = async (): Promise<void> => {
parseAndVisit(visitor, contracts, config.mode);
generateWatcher(visitor, contracts, config, overwriteExisting);
generateWatcher(visitor, contracts, configFile, config, overwriteExisting);
};
function parseAndVisit (visitor: Visitor, contracts: any[], mode: string) {
@ -162,7 +163,7 @@ function parseAndVisit (visitor: Visitor, contracts: any[], mode: string) {
}
}
function generateWatcher (visitor: Visitor, contracts: any[], config: any, overWriteExisting = false) {
function generateWatcher (visitor: Visitor, contracts: any[], configFile: string, config: any, overWriteExisting = false) {
// Prepare directory structure for the watcher.
let outputDir = '';
@ -198,6 +199,13 @@ function generateWatcher (visitor: Visitor, contracts: any[], config: any, overW
let outStream: Writable;
// Export the codegen config file
const configFileContent = fs.readFileSync(configFile, 'utf8');
outStream = outputDir
? fs.createWriteStream(path.join(outputDir, 'codegen-config.yml'))
: process.stdout;
outStream.write(configFileContent);
// Export artifacts for the contracts.
contracts.forEach((contract: any) => {
outStream = outputDir

View File

@ -15,6 +15,12 @@
yarn
```
* Run build:
```bash
yarn build
```
* Create a postgres12 database for the watcher:
```bash