diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..4915e0b --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,20 @@ +{ + "json.schemas": [ + { + "fileMatch": ["resources/map/*.json"], + "url": "./resources/schema/map.json" + }, + { + "fileMatch": ["resources/scenario/*.json"], + "url": "./resources/schema/scenario.json" + }, + { + "fileMatch": ["resources/unitset/*.json"], + "url": "./resources/schema/unitset.json" + }, + { + "fileMatch": ["resources/turn-commands/*.json"], + "url": "./resources/schema/turn-commands.json" + } + ] +} diff --git a/packages/tools-scripts/src/generate-resource-schemas.ts b/packages/tools-scripts/src/generate-resource-schemas.ts index dbd62a3..411027a 100644 --- a/packages/tools-scripts/src/generate-resource-schemas.ts +++ b/packages/tools-scripts/src/generate-resource-schemas.ts @@ -18,16 +18,16 @@ const RESOURCE_ROOT = path.join(REPO_ROOT, 'resources'); const writeSchema = async (relativePath: string, schema: ZodTypeAny): Promise => { 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 => { - 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) => { diff --git a/packages/tools-scripts/src/validate-resources.ts b/packages/tools-scripts/src/validate-resources.ts index 3344783..af2254f 100644 --- a/packages/tools-scripts/src/validate-resources.ts +++ b/packages/tools-scripts/src/validate-resources.ts @@ -24,7 +24,7 @@ const RESOURCE_SCHEMAS: Record void> = { const listJsonFiles = async (dirPath: string): Promise => { 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)); }; diff --git a/resources/map/schema.json b/resources/schema/map.json similarity index 99% rename from resources/map/schema.json rename to resources/schema/map.json index 65332b4..7f1be0f 100644 --- a/resources/map/schema.json +++ b/resources/schema/map.json @@ -1,5 +1,5 @@ { - "$schema": "http://json-schema.org/draft-07/schema#", + "$schema": "https://json-schema.org/draft/2020-12/schema", "anyOf": [ { "type": "object", diff --git a/resources/scenario/schema.json b/resources/schema/scenario.json similarity index 98% rename from resources/scenario/schema.json rename to resources/schema/scenario.json index 00b7c81..a22203a 100644 --- a/resources/scenario/schema.json +++ b/resources/schema/scenario.json @@ -1,5 +1,5 @@ { - "$schema": "http://json-schema.org/draft-07/schema#", + "$schema": "https://json-schema.org/draft/2020-12/schema", "anyOf": [ { "type": "object", diff --git a/resources/turn-commands/schema.json b/resources/schema/turn-commands.json similarity index 86% rename from resources/turn-commands/schema.json rename to resources/schema/turn-commands.json index ed43b98..e4f3494 100644 --- a/resources/turn-commands/schema.json +++ b/resources/schema/turn-commands.json @@ -1,5 +1,5 @@ { - "$schema": "http://json-schema.org/draft-07/schema#", + "$schema": "https://json-schema.org/draft/2020-12/schema", "type": "object", "properties": { "general": { diff --git a/resources/unitset/schema.json b/resources/schema/unitset.json similarity index 99% rename from resources/unitset/schema.json rename to resources/schema/unitset.json index 2aaced9..608c41b 100644 --- a/resources/unitset/schema.json +++ b/resources/schema/unitset.json @@ -1,5 +1,5 @@ { - "$schema": "http://json-schema.org/draft-07/schema#", + "$schema": "https://json-schema.org/draft/2020-12/schema", "type": "object", "properties": { "id": {