mirror of
https://github.com/cerc-io/watcher-ts
synced 2025-01-07 20:08:06 +00:00
63a2c5804e
* Use watch-contract CLI from cli package in codegen * Use reset CLIs from cli package in codegen * Use create checkpoint CLI from cli package in codegen * Use inspect-cid CLI from cli package in codegen * Use import state CLI from cli package in codegen * Use export-state and verify-checkpoint CLI from cli package in codegen * Use server CLI from cli package in codegen * Use job-runner CLI from cli package in codegen * Use index-block CLI from cli package in codegen * Use fill CLI from cli package in codegen * Minor codegen fixes * Update watcher instructions to run job-runner before server
36 lines
1.6 KiB
TypeScript
36 lines
1.6 KiB
TypeScript
//
|
|
// Copyright 2021 Vulcanize, Inc.
|
|
//
|
|
|
|
import fs from 'fs';
|
|
import path from 'path';
|
|
import Handlebars from 'handlebars';
|
|
import { Writable } from 'stream';
|
|
|
|
const CHECKPOINT_TEMPLATE_FILE = './templates/checkpoint-template.handlebars';
|
|
const CREATE_TEMPLATE_FILE = './templates/checkpoint-create-template.handlebars';
|
|
const VERIFY_TEMPLATE_FILE = './templates/checkpoint-verify-template.handlebars';
|
|
|
|
/**
|
|
* Writes the checkpoint file generated from a template to a stream.
|
|
* @param outStream A writable output stream to write the checkpoint file to.
|
|
*/
|
|
export function exportCheckpoint (checkpointOutStream: Writable, checkpointCreateOutStream: Writable, checkpointVerifyOutStream: Writable | undefined): void {
|
|
const checkpointTemplateString = fs.readFileSync(path.resolve(__dirname, CHECKPOINT_TEMPLATE_FILE)).toString();
|
|
const checkpointTemplate = Handlebars.compile(checkpointTemplateString);
|
|
const checkpoint = checkpointTemplate({});
|
|
checkpointOutStream.write(checkpoint);
|
|
|
|
const createCheckpointTemplateString = fs.readFileSync(path.resolve(__dirname, CREATE_TEMPLATE_FILE)).toString();
|
|
const createCheckpointTemplate = Handlebars.compile(createCheckpointTemplateString);
|
|
const createCheckpoint = createCheckpointTemplate({});
|
|
checkpointCreateOutStream.write(createCheckpoint);
|
|
|
|
if (checkpointVerifyOutStream) {
|
|
const verifyCheckpointTemplateString = fs.readFileSync(path.resolve(__dirname, VERIFY_TEMPLATE_FILE)).toString();
|
|
const verifyCheckpointTemplate = Handlebars.compile(verifyCheckpointTemplateString);
|
|
const verifyCheckpointString = verifyCheckpointTemplate({});
|
|
checkpointVerifyOutStream.write(verifyCheckpointString);
|
|
}
|
|
}
|