Skip to content
This repository has been archived by the owner on Nov 4, 2024. It is now read-only.

feature/COR-1670-fe-refactor-validate-all-json-script #4820

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 4 additions & 23 deletions packages/cli/src/scripts/validate-json-all.ts
Original file line number Diff line number Diff line change
@@ -1,35 +1,16 @@
import { gmData, sortTimeSeriesInDataInPlace } from '@corona-dashboard/common';
import chalk from 'chalk';
import fs from 'fs';
import meow from 'meow';
import path from 'path';
import { schemaDirectory } from '../config';
import { SchemaInfo, SchemaInfoItem, createValidateFunction, executeValidations, getSchemaInfo } from '../schema';
import { JSONObject } from '../schema/custom-validations';

const cli = meow(
`
Usage
$ validate-json-all <optional-json-path>
const schemaInfo = getSchemaInfo();

Examples
$ validate-json-all pages-tests/fixtures
`
);

const cliArgs = cli.input;

const customJsonPathArg = cliArgs[0];

const customJsonPath = customJsonPathArg ? path.join(__dirname, '..', '..', customJsonPathArg) : undefined;

const schemaInfo = getSchemaInfo(customJsonPath);

if (!customJsonPathArg) {
if (schemaInfo.gm.files.length !== gmData.length) {
console.error(chalk.bgRed.bold(`\n Expected ${gmData.length} municipal files, actually found ${schemaInfo.gm.files.length} \n`));
process.exit(1);
}
if (schemaInfo.gm.files.length !== gmData.length) {
console.error(chalk.bgRed.bold(`\n Expected ${gmData.length} municipal files, actually found ${schemaInfo.gm.files.length} \n`));
process.exit(1);
}

// The validations are asynchronous so this reducer gathers all the Promises in one array.
Expand Down
Loading