Add an executable for compare-entity CLI (#69)

This commit is contained in:
prathamesh0 2021-12-01 16:34:56 +05:30 committed by nabarun
parent c79647548e
commit 475c34b3fa
4 changed files with 16 additions and 10 deletions

View File

@ -61,7 +61,7 @@
* Fire a query and get the diff of the results from the two GQL endpoints: * Fire a query and get the diff of the results from the two GQL endpoints:
```bash ```bash
yarn compare-entity --config-file <config-file-path> --query-dir [query-dir] --query-name <query-name> --block-hash <block-hash> --entity-id <entity-id> --raw-json [true | false] ./bin/compare-entity --config-file <config-file-path> --query-dir [query-dir] --query-name <query-name> --block-hash <block-hash> --entity-id <entity-id> --raw-json [true | false]
``` ```
* `config-file`(alias: `cf`): Configuration file path (toml) (required). * `config-file`(alias: `cf`): Configuration file path (toml) (required).
@ -74,7 +74,7 @@
Example: Example:
```bash ```bash
yarn compare-entity --config-file environments/compare-cli-config.toml --query-name author --block-hash 0xceed7ee9d3de97c99db12e42433cae9115bb311c516558539fb7114fa17d545b --entity-id 0xdc7d7a8920c8eecc098da5b7522a5f31509b5bfc ./bin/compare-entity --config-file environments/compare-cli-config.toml --query-name author --block-hash 0xceed7ee9d3de97c99db12e42433cae9115bb311c516558539fb7114fa17d545b --entity-id 0xdc7d7a8920c8eecc098da5b7522a5f31509b5bfc
``` ```
* The program will exit with code `1` if the query results are not equal. * The program will exit with code `1` if the query results are not equal.

View File

@ -0,0 +1,9 @@
#! /usr/bin/env node
const { main } = require('../dist/cli/compare/compare-entity')
main().catch(err => {
console.log(err);
}).finally(() => {
process.exit(0);
});

View File

@ -24,6 +24,9 @@
"ts-node": "^10.0.0", "ts-node": "^10.0.0",
"typescript": "^4.3.2" "typescript": "^4.3.2"
}, },
"bin": {
"compare-entity": "bin/compare-entity"
},
"scripts": { "scripts": {
"lint": "eslint .", "lint": "eslint .",
"build": "tsc", "build": "tsc",
@ -33,7 +36,7 @@
"test": "yarn asbuild:debug && DEBUG=vulcanize:* mocha src/**/*.test.ts", "test": "yarn asbuild:debug && DEBUG=vulcanize:* mocha src/**/*.test.ts",
"build:example": "cd test/subgraph/example1 && yarn && yarn build", "build:example": "cd test/subgraph/example1 && yarn && yarn build",
"watch": "DEBUG=vulcanize:* nodemon --watch src src/watcher.ts", "watch": "DEBUG=vulcanize:* nodemon --watch src src/watcher.ts",
"compare-entity": "DEBUG=vulcanize:* ts-node src/cli/compare/compare-entity.ts" "compare-entity": "node bin/compare-entity"
}, },
"dependencies": { "dependencies": {
"@apollo/client": "^3.3.19", "@apollo/client": "^3.3.19",

View File

@ -27,7 +27,7 @@ interface Config {
queries: QueryConfig; queries: QueryConfig;
} }
const main = async (): Promise<void> => { export const main = async (): Promise<void> => {
const argv = await yargs.parserConfiguration({ const argv = await yargs.parserConfiguration({
'parse-numbers': false 'parse-numbers': false
}).options({ }).options({
@ -142,9 +142,3 @@ async function getClients (config: Config, queryDir?: string): Promise<{
client2 client2
}; };
} }
main().catch(err => {
console.log(err);
}).finally(() => {
process.exit(0);
});