mirror of
https://github.com/clusterio/clusterio.git
synced 2026-11-12 07:04:52 +09:00
Use a separate folder for the TypeScript build for Node.js in the dist folder. This makes each type of build consistently have its own output folder instead of being interleaved with the Node.js build.
33 lines
923 B
JavaScript
33 lines
923 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/node/src/data/message_validate.js"), "");
|
|
|
|
const { Message } = require("../dist/node/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);
|
|
function write(output) {
|
|
fs.outputFileSync(
|
|
path.join(__dirname, output),
|
|
`// generated by scripts/compile_validator.js\n// @ts-nocheck\n/* eslint-disable */\n${moduleCode}`
|
|
);
|
|
}
|
|
write("../dist/node/src/data/message_validate.js");
|
|
write("../src/data/message_validate.js");
|