feat: add "hxt" cli command
test / test (push) Failing after 5m52s

This commit is contained in:
2026-10-28 20:46:12 +03:00
parent ce51ab817c
commit 05be4ab622
13 changed files with 2572 additions and 1883 deletions
-7
View File
@@ -1,7 +0,0 @@
import gulp from "gulp";
import { Preset } from "gulp-haxetool";
import presetData from "./haxetool.json" with { type: "json" };
import packageInfo from "./package.json" with { type: "json" };
const preset = new Preset(presetData, { UseRuffle: true }, packageInfo);
export default preset.register(gulp);
+6
View File
@@ -12,6 +12,12 @@
"company": "Any company", "company": "Any company",
"version": "<%=package.version%>" "version": "<%=package.version%>"
}, },
"haxe": "4.2.5",
"libs": {
"lime": "8.0.0",
"openfl": "9.2.0",
"hxcpp": "4.2.1"
},
"sources": ["src"], "sources": ["src"],
"main": "Main" "main": "Main"
} }
+2341 -1838
View File
File diff suppressed because it is too large Load Diff
+5 -11
View File
@@ -3,17 +3,11 @@
"type": "module", "type": "module",
"version": "0.0.1", "version": "0.0.1",
"scripts": { "scripts": {
"build": "gulp", "tasks": "hxt",
"dev": "gulp app:flash:test" "build": "hxt default",
"dev": "hxt app:flash:test"
}, },
"devDependencies": { "devDependencies": {
"gulp-cli": "^3.1.0", "gulp-haxetool": "file:.."
"gulp-haxetool": "^1.2.0" }
},
"haxeDependencies": {
"lime": "8.0.0",
"openfl": "9.2.0",
"hxcpp": "4.2.1"
},
"haxe": "4.2.5"
} }
+70
View File
@@ -0,0 +1,70 @@
{
"$id": "https://shmyga.ru/public/haxetool.schema.json",
"title": "Haxe tool",
"description": "Haxe tool presets",
"type": "object",
"patternProperties": {
".*": {
"type": "object",
"properties": {
"buildSystem": { "enum": ["haxe", "openfl"] },
"platforms": {
"type": "array",
"items": { "enum": ["flash", "html5", "linux", "windows", "android", "neko", "cpp"] }
},
"config": {
"type": "object",
"properties": {
"name": { "type": "string" },
"main": { "type": "string" },
"preloader": { "type": "string" },
"sources": { "type": "array", "items": { "type": "string" } },
"assets": { "type": "array", "items": { "type": "string" } },
"libs": { "type": "object", "patternProperties": { ".*": { "type": "string" } } },
"macros": { "type": "array", "items": { "type": "string" } },
"flags": { "type": "array", "items": { "type": "string" } },
"meta": {
"type": "object",
"properties": {
"title": { "type": "string" },
"filename": { "type": "string" },
"icon": { "type": "string" },
"version": { "type": "string" },
"pack": { "type": "string" },
"author": { "type": "string" },
"company": { "type": "string" },
"width": { "type": "number" },
"height": { "type": "number" },
"mobileWidth": { "type": "number" },
"mobileHeight": { "type": "number" },
"fps": { "type": "number" }
},
"additionalProperties": false
},
"key": {
"type": "object",
"properties": {
"store": { "type": "string" },
"pass": { "type": "string" }
},
"required": ["store", "pass"]
},
"android": {
"type": "array",
"items": {
"type": "object",
"properties": {
"path": { "type": "string" },
"extensions": { "type": "array", "items": { "type": "string" } }
}
}
},
"haxe": { "type": "string" }
},
"additionalProperties": false
}
},
"additionalProperties": false
}
}
}
+63 -13
View File
@@ -9,6 +9,7 @@
"version": "1.2.0", "version": "1.2.0",
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {
"ajv": "^8.20.0",
"ansi-colors": "^4.1.3", "ansi-colors": "^4.1.3",
"async": "^3.2.6", "async": "^3.2.6",
"cli-progress": "^3.12.0", "cli-progress": "^3.12.0",
@@ -33,6 +34,9 @@
"vinyl": "^3.0.1", "vinyl": "^3.0.1",
"vinyl-fs": "^4.0.2" "vinyl-fs": "^4.0.2"
}, },
"bin": {
"gulp-haxetool": "dist/bin/cli.mjs"
},
"devDependencies": { "devDependencies": {
"@types/async": "^3.2.26", "@types/async": "^3.2.26",
"@types/cli-progress": "^3.11.6", "@types/cli-progress": "^3.11.6",
@@ -1762,16 +1766,15 @@
} }
}, },
"node_modules/ajv": { "node_modules/ajv": {
"version": "6.15.0", "version": "8.20.0",
"resolved": "https://registry.npmjs.org/ajv/-/ajv-6.15.0.tgz", "resolved": "https://registry.npmjs.org/ajv/-/ajv-8.20.0.tgz",
"integrity": "sha512-fgFx7Hfoq60ytK2c7DhnF8jIvzYgOMxfugjLOSMHjLIPgenqa7S7oaagATUq99mV6IYvN2tRmC0wnTYX6iPbMw==", "integrity": "sha512-Thbli+OlOj+iMPYFBVBfJ3OmCAnaSyNn4M1vz9T6Gka5Jt9ba/HIR56joy65tY6kx/FCF5VXNB819Y7/GUrBGA==",
"dev": true,
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {
"fast-deep-equal": "^3.1.1", "fast-deep-equal": "^3.1.3",
"fast-json-stable-stringify": "^2.0.0", "fast-uri": "^3.0.1",
"json-schema-traverse": "^0.4.1", "json-schema-traverse": "^1.0.0",
"uri-js": "^4.2.2" "require-from-string": "^2.0.2"
}, },
"funding": { "funding": {
"type": "github", "type": "github",
@@ -3520,6 +3523,23 @@
"url": "https://opencollective.com/eslint" "url": "https://opencollective.com/eslint"
} }
}, },
"node_modules/eslint/node_modules/ajv": {
"version": "6.15.0",
"resolved": "https://registry.npmjs.org/ajv/-/ajv-6.15.0.tgz",
"integrity": "sha512-fgFx7Hfoq60ytK2c7DhnF8jIvzYgOMxfugjLOSMHjLIPgenqa7S7oaagATUq99mV6IYvN2tRmC0wnTYX6iPbMw==",
"dev": true,
"license": "MIT",
"dependencies": {
"fast-deep-equal": "^3.1.1",
"fast-json-stable-stringify": "^2.0.0",
"json-schema-traverse": "^0.4.1",
"uri-js": "^4.2.2"
},
"funding": {
"type": "github",
"url": "https://github.com/sponsors/epoberezkin"
}
},
"node_modules/eslint/node_modules/glob-parent": { "node_modules/eslint/node_modules/glob-parent": {
"version": "6.0.2", "version": "6.0.2",
"resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-6.0.2.tgz", "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-6.0.2.tgz",
@@ -3533,6 +3553,13 @@
"node": ">=10.13.0" "node": ">=10.13.0"
} }
}, },
"node_modules/eslint/node_modules/json-schema-traverse": {
"version": "0.4.1",
"resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-0.4.1.tgz",
"integrity": "sha512-xbbCH5dCYU5T8LcEhhuh7HJ88HXuW3qsI3Y0zOZFKfZEHcpWiHU/Jxzk629Brsab/mMiHQti9wMP+845RPe3Vg==",
"dev": true,
"license": "MIT"
},
"node_modules/espree": { "node_modules/espree": {
"version": "11.2.0", "version": "11.2.0",
"resolved": "https://registry.npmjs.org/espree/-/espree-11.2.0.tgz", "resolved": "https://registry.npmjs.org/espree/-/espree-11.2.0.tgz",
@@ -3695,7 +3722,6 @@
"version": "3.1.3", "version": "3.1.3",
"resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-3.1.3.tgz", "resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-3.1.3.tgz",
"integrity": "sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q==", "integrity": "sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q==",
"dev": true,
"license": "MIT" "license": "MIT"
}, },
"node_modules/fast-fifo": { "node_modules/fast-fifo": {
@@ -3718,6 +3744,22 @@
"dev": true, "dev": true,
"license": "MIT" "license": "MIT"
}, },
"node_modules/fast-uri": {
"version": "3.1.9",
"resolved": "https://registry.npmjs.org/fast-uri/-/fast-uri-3.1.9.tgz",
"integrity": "sha512-hS/0Wt3Ya043oKXs0sIxrMpKQITXhMLIrVAKKXi4gozGC9v7YRWVnXIZzjNPTO02M9BdxLCWqK1yRXgNziVyJQ==",
"funding": [
{
"type": "github",
"url": "https://github.com/sponsors/fastify"
},
{
"type": "opencollective",
"url": "https://opencollective.com/fastify"
}
],
"license": "BSD-3-Clause"
},
"node_modules/fastest-levenshtein": { "node_modules/fastest-levenshtein": {
"version": "1.0.16", "version": "1.0.16",
"resolved": "https://registry.npmjs.org/fastest-levenshtein/-/fastest-levenshtein-1.0.16.tgz", "resolved": "https://registry.npmjs.org/fastest-levenshtein/-/fastest-levenshtein-1.0.16.tgz",
@@ -5934,10 +5976,9 @@
} }
}, },
"node_modules/json-schema-traverse": { "node_modules/json-schema-traverse": {
"version": "0.4.1", "version": "1.0.0",
"resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-0.4.1.tgz", "resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-1.0.0.tgz",
"integrity": "sha512-xbbCH5dCYU5T8LcEhhuh7HJ88HXuW3qsI3Y0zOZFKfZEHcpWiHU/Jxzk629Brsab/mMiHQti9wMP+845RPe3Vg==", "integrity": "sha512-NM8/P9n3XjXhIZn1lLhkFaACTOURQXjWhV4BA/RnOv8xvgqtqpAX9IO4mRQxSx1Rlo4tqzeqb0sOlruaOy3dug==",
"dev": true,
"license": "MIT" "license": "MIT"
}, },
"node_modules/json-stable-stringify-without-jsonify": { "node_modules/json-stable-stringify-without-jsonify": {
@@ -7127,6 +7168,15 @@
"node": ">=0.10.0" "node": ">=0.10.0"
} }
}, },
"node_modules/require-from-string": {
"version": "2.0.2",
"resolved": "https://registry.npmjs.org/require-from-string/-/require-from-string-2.0.2.tgz",
"integrity": "sha512-Xf0nWe6RseziFMu+Ap9biiUbmplq6S9/p+7w7YXP/JBHhrUDDUhwa+vANyubuqfZWTveU//DYVGsDG7RKL/vEw==",
"license": "MIT",
"engines": {
"node": ">=0.10.0"
}
},
"node_modules/resolve": { "node_modules/resolve": {
"version": "1.22.13", "version": "1.22.13",
"resolved": "https://registry.npmjs.org/resolve/-/resolve-1.22.13.tgz", "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.22.13.tgz",
+7 -1
View File
@@ -4,9 +4,14 @@
"version": "1.2.0", "version": "1.2.0",
"description": "HaXe Tool for Gulp", "description": "HaXe Tool for Gulp",
"exports": { "exports": {
".": "./dist/index.mjs", "./bin/cli": "./dist/bin/cli.mjs",
"./lib": "./dist/lib/index.mjs",
"./package.json": "./package.json" "./package.json": "./package.json"
}, },
"bin": {
"hxt": "./dist/bin/cli.mjs"
},
"types": "./dist/lib/index.d.mts",
"files": [ "files": [
"template", "template",
"dist" "dist"
@@ -29,6 +34,7 @@
"license": "MIT", "license": "MIT",
"homepage": "https://git.shmyga.ru/InfernalGames/gulp-haxetool#readme", "homepage": "https://git.shmyga.ru/InfernalGames/gulp-haxetool#readme",
"dependencies": { "dependencies": {
"ajv": "^8.20.0",
"ansi-colors": "^4.1.3", "ansi-colors": "^4.1.3",
"async": "^3.2.6", "async": "^3.2.6",
"cli-progress": "^3.12.0", "cli-progress": "^3.12.0",
+62
View File
@@ -0,0 +1,62 @@
#!/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" };
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"));
};
const runTask = async (name: string) => {
const task = gulp.task(name);
if (!task) {
throw `task '${name}' not found`;
}
return await task((error) => {
if (error) {
console.error(error);
}
});
};
export const main = async () => {
const preset = loadPreset();
preset.register(gulp);
if (process.argv.length > 2) {
await runTask(process.argv[2]);
} else {
showTasks();
}
};
export default main;
await main();
+4
View File
@@ -13,6 +13,7 @@ export interface ConfigParams {
meta?: ConfigMeta; meta?: ConfigMeta;
key?: SignKey; key?: SignKey;
android?: AndroidPreset[]; android?: AndroidPreset[];
haxe?: string;
} }
export interface ConfigMeta { export interface ConfigMeta {
@@ -60,6 +61,7 @@ export class Config {
public meta: ConfigMeta; public meta: ConfigMeta;
public key: SignKey | null; public key: SignKey | null;
public android: AndroidPreset[]; public android: AndroidPreset[];
public haxe: string | null;
private _params: ConfigParams[]; private _params: ConfigParams[];
@@ -81,6 +83,7 @@ export class Config {
}; };
this.key = null; this.key = null;
this.android = []; this.android = [];
this.haxe = null;
if (params) { if (params) {
this.update(params); this.update(params);
this.afterUpdate(); this.afterUpdate();
@@ -113,6 +116,7 @@ export class Config {
this.android = this.android.concat( this.android = this.android.concat(
params.android.map((item) => ({ path: Config.absolutePath(item.path), extensions: item.extensions })), params.android.map((item) => ({ path: Config.absolutePath(item.path), extensions: item.extensions })),
); );
if (params.haxe !== undefined) this.haxe = params.haxe;
if (this.meta.icon) this.icon = Config.absolutePath(this.meta.icon); if (this.meta.icon) this.icon = Config.absolutePath(this.meta.icon);
} }
+1 -1
View File
@@ -13,7 +13,7 @@ export class HaxeBuilder extends Builder {
constructor(config: Config, platform: Platform, buildSystem: BuildSystem, debug: boolean = false) { constructor(config: Config, platform: Platform, buildSystem: BuildSystem, debug: boolean = false) {
super(config, platform, buildSystem, debug); super(config, platform, buildSystem, debug);
this.haxe = new Haxe(); this.haxe = new Haxe(config.haxe ? config.haxe : undefined);
this.android = new Android(); this.android = new Android();
} }
-6
View File
@@ -9,12 +9,6 @@ import { RuffleRunner } from "./impl/runner/ruffle";
export * from "./core"; export * from "./core";
export class Project { export class Project {
// TODO: compatibility
static Config = Config;
static BuildSystem = BuildSystem;
static Platform = Platform;
static Builder = Builder;
public buildSystem: BuildSystem; public buildSystem: BuildSystem;
public platforms: Platform[]; public platforms: Platform[];
public config: Config; public config: Config;
+3 -5
View File
@@ -79,10 +79,6 @@ export class Preset {
Project.useRuffle(); Project.useRuffle();
} }
if (this.packageInfo.haxe) {
Haxe.VERSION = this.packageInfo.haxe;
}
if (this.config.SdkDir) { if (this.config.SdkDir) {
Sdk.dir = resolvePath(this.config.SdkDir); Sdk.dir = resolvePath(this.config.SdkDir);
} }
@@ -174,6 +170,8 @@ export class Preset {
} }
} }
return _gulp.series(defaultSeries); const defaultTask = _gulp.series(defaultSeries);
_gulp.task("default", defaultTask);
return defaultTask;
} }
} }
+10 -1
View File
@@ -1,9 +1,18 @@
import { defineConfig } from "tsdown"; import { defineConfig } from "tsdown";
export default defineConfig({ export default defineConfig({
entry: {
"bin/cli": "src/cli.ts",
"lib/index": "src/index.ts",
},
copy: ["haxetool.schema.json"],
dts: { dts: {
tsgo: true, tsgo: true,
}, },
exports: true, exports: {
bin: {
hxt: "src/cli.ts",
},
},
sourcemap: true, sourcemap: true,
}); });