mirror of
https://github.com/clusterio/clusterio.git
synced 2026-11-11 23:04:52 +09:00
29 lines
820 B
JavaScript
29 lines
820 B
JavaScript
"use strict";
|
|
const fs = require("fs-extra");
|
|
const path = require("path");
|
|
const Ajv = require("ajv");
|
|
const standaloneCode = require("ajv/dist/standalone").default;
|
|
|
|
/* eslint-disable node/no-sync */
|
|
|
|
// Provide an empty file for message_core to load
|
|
fs.outputFileSync(path.join(__dirname, "../dist/src/data/message_validate.js"), "");
|
|
|
|
const { Message } = require("../dist/src/data/messages_core");
|
|
|
|
const ajv = new Ajv({
|
|
allowUnionTypes: true,
|
|
strict: "log",
|
|
strictTuples: false,
|
|
verbose: true,
|
|
code: {
|
|
source: true,
|
|
},
|
|
});
|
|
const validate = ajv.compile(Message.jsonSchema);
|
|
let moduleCode = standaloneCode(ajv, validate);
|
|
fs.outputFileSync(
|
|
path.join(__dirname, "../dist/src/data/message_validate.js"),
|
|
`// generated by scripts/compile_validator.js\n// @ts-nocheck\n/* eslint-disable */\n${moduleCode}`
|
|
);
|