feat: add resource schemas and validation scripts
- Introduced new resource schemas for maps, scenarios, unit sets, and turn commands using Zod. - Implemented a script to generate JSON schemas from Zod schemas. - Added a validation script to ensure resource JSON files conform to their respective schemas. - Updated the logic package to export new resource schemas. - Added new dependencies for schema generation and validation. - Created a tools-scripts package for resource management tasks.
This commit is contained in:
@@ -2,7 +2,7 @@ import fs from 'node:fs/promises';
|
||||
import path from 'node:path';
|
||||
import { fileURLToPath } from 'node:url';
|
||||
|
||||
import type { MapDefinition } from '@sammo-ts/logic';
|
||||
import { MapDefinitionSchema, type MapDefinition } from '@sammo-ts/logic';
|
||||
|
||||
const __filename = fileURLToPath(import.meta.url);
|
||||
const __dirname = path.dirname(__filename);
|
||||
@@ -28,7 +28,7 @@ export const resolveMapDefinitionPath = (mapName: string, options?: MapLoaderOpt
|
||||
|
||||
export const loadMapDefinition = async (mapPath: string): Promise<MapDefinition> => {
|
||||
const raw = await readJsonFile(mapPath);
|
||||
return raw as MapDefinition;
|
||||
return MapDefinitionSchema.parse(raw);
|
||||
};
|
||||
|
||||
export const loadMapDefinitionByName = async (mapName: string, options?: MapLoaderOptions): Promise<MapDefinition> => {
|
||||
|
||||
Reference in New Issue
Block a user