refactor(preset): rework preset
test / test (push) Failing after 5m32s

This commit is contained in:
2026-10-29 20:35:53 +03:00
parent d9e8976e85
commit 2605c1bbc8
41 changed files with 475 additions and 473 deletions
+8 -26
View File
@@ -1,34 +1,14 @@
#!/usr/bin/env node
import Ajv from "ajv";
import fs from "fs";
import gulp from "gulp";
import path from "path";
import { fileURLToPath } from "url";
import { Preset, type ProjectPreset } from ".";
import { name, version } from "../package.json" with { type: "json" };
import compiler from "./preset/compiler";
import loader from "./preset/loader";
import register from "./preset/register";
import validator from "./preset/validator";
console.log(`[${name} ${version}]`);
const loadPreset = (): Preset => {
const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
const presetData: Record<string, ProjectPreset> = JSON.parse(fs.readFileSync("haxetool.json", "utf8"));
const ajv = new Ajv();
const presetSchema = ajv.compile(
JSON.parse(fs.readFileSync(path.join(__dirname, "..", "haxetool.schema.json"), "utf-8")),
);
const valid = presetSchema(presetData);
if (!valid) {
throw presetSchema.errors;
}
const packageInfo = JSON.parse(fs.readFileSync("package.json", "utf8"));
const configData = fs.existsSync("config.json") ? JSON.parse(fs.readFileSync("config.json", "utf8")) : null;
return new Preset(presetData, configData, packageInfo);
};
const showTasks = () => {
const tree = gulp.tree({ deep: true });
console.log(tree.nodes.map((node) => node.label).join("\n"));
@@ -47,8 +27,10 @@ const runTask = async (name: string) => {
};
export const main = async () => {
const preset = loadPreset();
preset.register(gulp);
const preset = loader();
validator(preset);
const projects = compiler(preset);
register(projects);
if (process.argv.length > 2) {
await runTask(process.argv[2]);