2020-08-06 19:17:38 +00:00
|
|
|
import { chainsPath, pricingFolderPath } from "../common/repo-structure";
|
|
|
|
import { findFiles } from "../common/filesystem";
|
|
|
|
import { ActionInterface, CheckStepInterface } from "./interface";
|
|
|
|
import { isValidJSON } from "../common/json";
|
|
|
|
import * as bluebird from "bluebird";
|
|
|
|
|
|
|
|
export class JsonAction implements ActionInterface {
|
|
|
|
getName(): string { return "Json files"; }
|
|
|
|
|
2020-08-10 08:56:41 +00:00
|
|
|
getSanityChecks(): CheckStepInterface[] {
|
2020-08-06 19:17:38 +00:00
|
|
|
return [
|
|
|
|
{
|
|
|
|
getName: () => { return "Check all JSON files to have valid content"},
|
|
|
|
check: async () => {
|
|
|
|
var error: string = "";
|
|
|
|
const files = [
|
|
|
|
...findFiles(chainsPath, 'json'),
|
|
|
|
...findFiles(pricingFolderPath, 'json')
|
|
|
|
];
|
|
|
|
|
|
|
|
await bluebird.each(files, async file => {
|
|
|
|
if (!isValidJSON(file)) {
|
|
|
|
error += `${file} path contains invalid JSON\n`;
|
|
|
|
}
|
|
|
|
});
|
2020-08-24 15:06:21 +00:00
|
|
|
return [error, ""];
|
2020-08-06 19:17:38 +00:00
|
|
|
}
|
|
|
|
},
|
|
|
|
];
|
|
|
|
}
|
|
|
|
|
2020-08-10 08:56:41 +00:00
|
|
|
getConsistencyChecks = null;
|
|
|
|
|
|
|
|
sanityFix = null;
|
|
|
|
|
|
|
|
consistencyFix = null;
|
2020-08-06 19:17:38 +00:00
|
|
|
|
|
|
|
update = null;
|
|
|
|
}
|