feat: improve monorepo dev experience

This commit is contained in:
2023-10-30 17:31:40 +01:00
parent f65fb52def
commit 8466976b3c
59 changed files with 157 additions and 2662 deletions

View File

@@ -1,10 +1,11 @@
import {createGenerator, SchemaGenerator} from 'ts-json-schema-generator';
import {createGenerator} from 'ts-json-schema-generator';
import {getValidatableTypes} from './get-validatable-types.js';
import {JSONSchema7} from 'json-schema';
/**
* Compile the JSON schema for a path
*/
export function compileSchema(path: string, tsconfig: string): ReturnType<SchemaGenerator['createSchema']> {
export function compileSchema(path: string, tsconfig: string): [schma: JSONSchema7, type: string] {
const generator = createGenerator({
path,
tsconfig,
@@ -23,5 +24,11 @@ export function compileSchema(path: string, tsconfig: string): ReturnType<Schema
Object.assign(fullSchema.definitions, generator.createSchema(schema).definitions);
}
return fullSchema;
const schemaTypes = `import {JSONSchema7} from 'json-schema';\n\nexport interface SchemaMap {\n${[
...schemaNames,
]
.map(schemaName => ` '${schemaName}': core.${schemaName};`)
.join('\n')}\n}\n\nconst schema: JSONSchema7;\nexport default schema;`;
return [fullSchema, schemaTypes];
}