2020-08-31 16:25:21 +00:00
|
|
|
import { chainsPath } from "../common/repo-structure";
|
2020-08-06 19:17:38 +00:00
|
|
|
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 () => {
|
2020-09-18 14:39:31 +00:00
|
|
|
const errors: string[] = [];
|
2020-08-06 19:17:38 +00:00
|
|
|
const files = [
|
|
|
|
...findFiles(chainsPath, 'json'),
|
|
|
|
];
|
|
|
|
|
|
|
|
await bluebird.each(files, async file => {
|
|
|
|
if (!isValidJSON(file)) {
|
2020-09-16 12:52:10 +00:00
|
|
|
errors.push(`${file} path contains invalid JSON`);
|
2020-08-06 19:17:38 +00:00
|
|
|
}
|
|
|
|
});
|
2020-09-16 12:52:10 +00:00
|
|
|
return [errors, []];
|
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;
|
|
|
|
}
|