mirror of
https://gitlab.com/openstapps/openstapps.git
synced 2026-01-21 00:52:55 +00:00
feat: migrate backend to cosmiconfig
This commit is contained in:
@@ -36,13 +36,14 @@ export class Validator {
|
||||
*/
|
||||
private readonly ajv = new Ajv.default({
|
||||
verbose: true,
|
||||
allowUnionTypes: true,
|
||||
code: {regExp: re2 as never},
|
||||
});
|
||||
|
||||
/**
|
||||
* Map of schema names to schemas
|
||||
*/
|
||||
private readonly schemas: { [type: string]: Schema } = {};
|
||||
private readonly schemas: {[type: string]: Schema} = {};
|
||||
|
||||
/**
|
||||
* A wrapper function for Ajv that transforms the error into the compatible old error
|
||||
@@ -94,7 +95,7 @@ export class Validator {
|
||||
if (schema === undefined) {
|
||||
if (isThingWithType(instance)) {
|
||||
// schema name can be inferred from type string
|
||||
const schemaSuffix = (instance as { type: string }).type
|
||||
const schemaSuffix = (instance as {type: string}).type
|
||||
.split(' ')
|
||||
.map((part: string) => {
|
||||
return part.slice(0, 1).toUpperCase() + part.slice(1);
|
||||
@@ -178,7 +179,10 @@ export async function validateFiles(
|
||||
await v.addSchemas(schemaDirectory);
|
||||
|
||||
// get a list of files to test
|
||||
const testFiles = await glob(path.posix.join(resourcesDirectory.replaceAll(path.sep, path.posix.sep), '*.json'), {absolute: true});
|
||||
const testFiles = await glob(
|
||||
path.posix.join(resourcesDirectory.replaceAll(path.sep, path.posix.sep), '*.json'),
|
||||
{absolute: true},
|
||||
);
|
||||
|
||||
if (testFiles.length === 0) {
|
||||
throw new Error(`No test files in ${resourcesDirectory}!`);
|
||||
|
||||
Reference in New Issue
Block a user