mirror of
https://github.com/openclaw/openclaw.git
synced 2026-08-12 21:53:00 -06:00
refactor(codex): deduplicate generated protocol schemas (#117382)
This commit is contained in:
committed by
GitHub
parent
b830a65821
commit
8738fe1354
@@ -2,6 +2,7 @@
|
||||
import fs from "node:fs/promises";
|
||||
import path from "node:path";
|
||||
import {
|
||||
compactCodexAppServerProtocolJsonSchemas,
|
||||
formatCodexAppServerProtocolJsonText,
|
||||
generateExperimentalCodexAppServerProtocolSource,
|
||||
selectedCodexAppServerJsonSchemas,
|
||||
@@ -20,15 +21,21 @@ await main().catch((error: unknown) => {
|
||||
async function main(): Promise<void> {
|
||||
const source = await generateExperimentalCodexAppServerProtocolSource();
|
||||
try {
|
||||
const selectedSchemas = new Map<string, unknown>();
|
||||
for (const schema of selectedCodexAppServerJsonSchemas) {
|
||||
const schemaSource = await fs.readFile(path.join(source.jsonRoot, schema), "utf8");
|
||||
selectedSchemas.set(schema, JSON.parse(schemaSource));
|
||||
}
|
||||
const compactedSchemas = compactCodexAppServerProtocolJsonSchemas(selectedSchemas);
|
||||
|
||||
await fs.rm(targetRoot, { recursive: true, force: true });
|
||||
await fs.mkdir(targetRoot, { recursive: true });
|
||||
|
||||
for (const schema of selectedCodexAppServerJsonSchemas) {
|
||||
for (const [schema, value] of compactedSchemas) {
|
||||
await fs.mkdir(path.dirname(path.join(targetRoot, "json", schema)), { recursive: true });
|
||||
const schemaSource = await fs.readFile(path.join(source.jsonRoot, schema), "utf8");
|
||||
await fs.writeFile(
|
||||
path.join(targetRoot, "json", schema),
|
||||
formatCodexAppServerProtocolJsonText(schemaSource),
|
||||
formatCodexAppServerProtocolJsonText(JSON.stringify(value)),
|
||||
);
|
||||
}
|
||||
} finally {
|
||||
|
||||
Reference in New Issue
Block a user