feat: 리소스 스키마 및 검증 스크립트 추가, 기존 스키마 파일 삭제
This commit is contained in:
@@ -18,16 +18,16 @@ const RESOURCE_ROOT = path.join(REPO_ROOT, 'resources');
|
||||
|
||||
const writeSchema = async (relativePath: string, schema: ZodTypeAny): Promise<void> => {
|
||||
const outputPath = path.join(RESOURCE_ROOT, relativePath);
|
||||
const jsonSchema = z.toJSONSchema(schema, { target: 'draft-07' });
|
||||
const jsonSchema = z.toJSONSchema(schema);
|
||||
const serialized = `${JSON.stringify(jsonSchema, null, 4)}\n`;
|
||||
await fs.writeFile(outputPath, serialized, 'utf8');
|
||||
};
|
||||
|
||||
const main = async (): Promise<void> => {
|
||||
await writeSchema(path.join('map', 'schema.json'), MapResourceSchema);
|
||||
await writeSchema(path.join('scenario', 'schema.json'), ScenarioResourceSchema);
|
||||
await writeSchema(path.join('unitset', 'schema.json'), UnitSetDefinitionInputSchema);
|
||||
await writeSchema(path.join('turn-commands', 'schema.json'), TurnCommandProfileInputSchema);
|
||||
await writeSchema(path.join('schema', 'map.json'), MapResourceSchema);
|
||||
await writeSchema(path.join('schema', 'scenario.json'), ScenarioResourceSchema);
|
||||
await writeSchema(path.join('schema', 'unitset.json'), UnitSetDefinitionInputSchema);
|
||||
await writeSchema(path.join('schema', 'turn-commands.json'), TurnCommandProfileInputSchema);
|
||||
};
|
||||
|
||||
main().catch((error) => {
|
||||
|
||||
@@ -24,7 +24,7 @@ const RESOURCE_SCHEMAS: Record<string, (value: unknown) => void> = {
|
||||
const listJsonFiles = async (dirPath: string): Promise<string[]> => {
|
||||
const entries = await fs.readdir(dirPath, { withFileTypes: true });
|
||||
return entries
|
||||
.filter((entry) => entry.isFile() && entry.name.endsWith('.json') && entry.name !== 'schema.json')
|
||||
.filter((entry) => entry.isFile() && entry.name.endsWith('.json'))
|
||||
.map((entry) => entry.name)
|
||||
.sort((a, b) => a.localeCompare(b));
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user