mirror of
https://github.com/cerc-io/watcher-ts
synced 2024-11-19 20:36:19 +00:00
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:
parent
467c173a0d
commit
9c4b06652e
@ -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.
|
||||
|
@ -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
|
||||
|
@ -15,6 +15,12 @@
|
||||
yarn
|
||||
```
|
||||
|
||||
* Run build:
|
||||
|
||||
```bash
|
||||
yarn build
|
||||
```
|
||||
|
||||
* Create a postgres12 database for the watcher:
|
||||
|
||||
```bash
|
||||
|
Loading…
Reference in New Issue
Block a user