Move schemas to public in order to use it on runtime

This commit is contained in:
Jérémy Munsch 2024-01-18 10:35:27 +01:00
parent 5411684a0f
commit 4678471761
No known key found for this signature in database
GPG key ID: 18361AF3BFEC0FEC
7 changed files with 2 additions and 2 deletions

View file

@ -67,7 +67,7 @@ export default abstract class UnzipData {
path.resolve(__dirname, "../src/assets/data.json"),
{ encoding: "utf8", flag: "r" }
);
const jsonSchemaPath = "schemas";
const jsonSchemaPath = "public/schemas";
if (!UnzipData.validateAgainstJsonSchema(jsonSchemaPath, jsonData)) {
log.warn(`Data for file ${UnzipData.zipFileToUse} is not valid JSON`);
@ -88,7 +88,7 @@ export default abstract class UnzipData {
try {
const schemaList = fs.readdirSync(jsonSchemaPath)
.filter(schemaPath => schemaPath.endsWith(".schema.json"))
.map(schemaPath => JSON.parse(fs.readFileSync(`schemas/${schemaPath}`, { encoding: "utf8", flag: "r" })) as Record<string,string|any>);
.map(schemaPath => JSON.parse(fs.readFileSync(`${jsonSchemaPath}/${schemaPath}`, { encoding: "utf8", flag: "r" })) as Record<string,string|any>);
const appSchemaIndex = schemaList.findIndex((schema) => String(schema.$id).endsWith("app.schema.json"));
if (appSchemaIndex === -1) {
throw new Error("app.schema.json not found");