Compare commits

..
4 Commits
Author SHA1 Message Date
shmyga 705651eddc refactor(task): rework setup task
test / test (push) Successful in 1m6s
2026-11-12 20:35:06 +03:00
shmyga f59ef2893e ci(version): 2.1.0
release / release (push) Successful in 57s
test / test (push) Successful in 1m33s
2026-11-11 22:05:54 +03:00
shmyga 6a887d10ff docs: remove CHANGELOG.md
test / test (push) Successful in 58s
2026-11-11 21:54:07 +03:00
shmyga 6940c65b88 feat: add task module
test / test (push) Successful in 2m13s
2026-11-11 21:34:11 +03:00
19 changed files with 153 additions and 160 deletions
-29
View File
@@ -1,29 +0,0 @@
## v0.2.0 (2026-05-15)
### Feat
- **ruffle**: add alternative ruffle flash target runner
## 0.1.9 (2021-05-24)
### Feat
- **android**: up android sdk version
## 0.1.8 (2020-03-30)
## 0.1.7 (2020-03-25)
## 0.1.6 (2020-02-19)
## 0.1.5 (2020-02-18)
## 0.1.0 (2019-09-03)
## 0.0.18 (2019-05-20)
## 0.0.17 (2019-03-28)
## 0.0.16 (2019-03-14)
## 0.0.15 (2019-03-14)
+2 -2
View File
@@ -1,12 +1,12 @@
{ {
"name": "gulp-haxetool", "name": "gulp-haxetool",
"version": "2.0.4", "version": "2.1.0",
"lockfileVersion": 3, "lockfileVersion": 3,
"requires": true, "requires": true,
"packages": { "packages": {
"": { "": {
"name": "gulp-haxetool", "name": "gulp-haxetool",
"version": "2.0.4", "version": "2.1.0",
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {
"ajv": "^8.20.0", "ajv": "^8.20.0",
+1 -1
View File
@@ -1,7 +1,7 @@
{ {
"name": "gulp-haxetool", "name": "gulp-haxetool",
"type": "module", "type": "module",
"version": "2.0.4", "version": "2.1.0",
"description": "HaXe Tool with Gulp", "description": "HaXe Tool with Gulp",
"exports": { "exports": {
"./bin/cli": "./dist/bin/cli.mjs", "./bin/cli": "./dist/bin/cli.mjs",
+2 -2
View File
@@ -84,8 +84,8 @@ export const branch = (config: Config, source: ConfigSource | Config): Config =>
if (source.haxe !== undefined) { if (source.haxe !== undefined) {
result.haxe = source.haxe; result.haxe = source.haxe;
} }
if (result.meta.icon) { if (result.icon) {
result.icon = absolutePath(result.meta.icon); result.icon = absolutePath(result.icon);
} }
if (!result.meta.mobileWidth) { if (!result.meta.mobileWidth) {
+5 -3
View File
@@ -18,7 +18,7 @@ export class Sdk {
} }
static path(name: string, version: string) { static path(name: string, version: string) {
return path.join(this.dir, name, version); return path.resolve(path.join(this.dir, name, version));
} }
public name: string; public name: string;
@@ -26,6 +26,8 @@ export class Sdk {
public log: Logger; public log: Logger;
public path: string; public path: string;
protected strip: number = 1;
constructor(name: string, version: string) { constructor(name: string, version: string) {
this.name = name; this.name = name;
this.log = new Logger(name); this.log = new Logger(name);
@@ -55,14 +57,14 @@ export class Sdk {
}; };
} }
prepare(strip = 1): Promise<any> { prepare(): Promise<any> {
this.log.i("version: *%s*", this.version); this.log.i("version: *%s*", this.version);
if (this.prepared) { if (this.prepared) {
return Promise.resolve(); return Promise.resolve();
} else { } else {
const url = resolveLink(this.link, { name: this.name, version: this.version }); const url = resolveLink(this.link, { name: this.name, version: this.version });
this.log.i("download: *%s*", url); this.log.i("download: *%s*", url);
return download(url, this.path, { strip }); return download(url, this.path, { strip: this.strip });
} }
} }
} }
+1 -2
View File
@@ -24,7 +24,6 @@ export interface LibDef {
export interface ConfigMeta { export interface ConfigMeta {
title?: string; title?: string;
filename?: string; filename?: string;
icon?: string;
version?: string; version?: string;
pack?: string; pack?: string;
author?: string; author?: string;
@@ -74,7 +73,7 @@ export interface Config {
libs: LibDef[]; libs: LibDef[];
macros: string[]; macros: string[];
flags: string[]; flags: string[];
icon: string | null; icon: string;
meta: ConfigMeta; meta: ConfigMeta;
key: SignKey | null; key: SignKey | null;
android: AndroidPreset[]; android: AndroidPreset[];
+3 -1
View File
@@ -40,6 +40,8 @@ export class Android extends Sdk {
url = "https://dl.google.com/android/repository/commandlinetools-<%= os_name %>-<%= version %>_latest.zip"; url = "https://dl.google.com/android/repository/commandlinetools-<%= os_name %>-<%= version %>_latest.zip";
protected strip = 0;
constructor(version?: string, ndkVersion?: string) { constructor(version?: string, ndkVersion?: string) {
super(Android.ID, version || Android.VERSION); super(Android.ID, version || Android.VERSION);
this.ndk = new AndroidNdk(ndkVersion); this.ndk = new AndroidNdk(ndkVersion);
@@ -67,7 +69,7 @@ export class Android extends Sdk {
prepare(): Promise<any> { prepare(): Promise<any> {
const result = []; const result = [];
result.push(super.prepare(0)); result.push(super.prepare());
result.push(this.ndk.prepare()); result.push(this.ndk.prepare());
return Promise.all(result); return Promise.all(result);
} }
+2 -4
View File
@@ -26,6 +26,8 @@ export class FlashPlayer extends Sdk {
private debug: boolean; private debug: boolean;
protected strip = 0;
url = url =
"https://fpdownload.macromedia.com/pub/flashplayer/updaters/" + "https://fpdownload.macromedia.com/pub/flashplayer/updaters/" +
"<%= version %>/" + "<%= version %>/" +
@@ -36,10 +38,6 @@ export class FlashPlayer extends Sdk {
this.debug = debug; this.debug = debug;
} }
prepare() {
return super.prepare(0);
}
get prepared() { get prepared() {
try { try {
return fs.existsSync(this.flashPlayerBin); return fs.existsSync(this.flashPlayerBin);
+2 -2
View File
@@ -19,8 +19,8 @@ export class InnoSetup extends Sdk {
return "http://www.jrsoftware.org/download.php/is.exe"; return "http://www.jrsoftware.org/download.php/is.exe";
} }
prepare(strip = 1) { prepare() {
let result = super.prepare(strip); let result = super.prepare();
if (!this.prepared) { if (!this.prepared) {
result = result.then(() => { result = result.then(() => {
return exec(this.path, `is.exe /VERYSILENT /SUPPRESSMSGBOXES /DIR=${this.path}`); return exec(this.path, `is.exe /VERYSILENT /SUPPRESSMSGBOXES /DIR=${this.path}`);
+25 -31
View File
@@ -1,3 +1,4 @@
import type Stream from "stream";
import vfs from "vinyl-fs"; import vfs from "vinyl-fs";
import exec from "../../../common/exec"; import exec from "../../../common/exec";
import { streamToPromise } from "../../../common/util"; import { streamToPromise } from "../../../common/util";
@@ -16,50 +17,43 @@ export class HaxeBuilder extends Builder {
this.android = new Android(); this.android = new Android();
} }
setup() { async setup(): Promise<any> {
let result: Promise<any> = this.haxe.prepare().then(() => this.haxe.install(this.config.libs)); await this.haxe.prepare();
await this.haxe.install(this.config.libs);
if (this.buildSystem === BuildSystem.OPENFL) { if (this.buildSystem === BuildSystem.OPENFL) {
if (this.platform === Platform.ANDROID) { if (this.platform === Platform.ANDROID) {
result = result await this.android.prepare();
.then(() => this.android.prepare()) this.android.activate();
.then(() => this.android.activate()) await this.android.sdkmanager([
.then(() => // TODO: android sdk dependencies config?
this.android.sdkmanager([ "platform-tools",
// ToDo: android sdk dependencies config? "build-tools;27.0.3",
//'tools', "platforms;android-28",
"platform-tools", "cmake;3.6.4111459",
"build-tools;27.0.3", ]);
"platforms;android-28", //ToDo: lime version 7.6.0 -> 28; 7.0.0 -> 26
//'ndk-bundle',
//'lldb;3.1',
"cmake;3.6.4111459",
]),
);
const AndroidSDK = this.android.android_home; const AndroidSDK = this.android.android_home;
const AndroidNDK = this.android.ndk_home; const AndroidNDK = this.android.ndk_home;
const answer = `echo "${[AndroidSDK, AndroidNDK].join("\n")}"`; const answer = `echo "${[AndroidSDK, AndroidNDK].join("\n")}"`;
result = result.then(() => { await exec(".", [answer, "|", this.haxe.haxelibBin, "run", "openfl", "setup", this.platform].join(" "));
return exec(".", [answer, "|", this.haxe.haxelibBin, "run", "openfl", "setup", this.platform].join(" "));
});
} }
} }
return result;
} }
call() { async call(): Promise<any> {
const target = this.targetPath; const target = this.targetPath;
let stream: Stream;
switch (this.buildSystem) { switch (this.buildSystem) {
case BuildSystem.OPENFL: case BuildSystem.OPENFL:
return this.haxe.openfl("build", this.platform, this.config, this.debug).then((result) => { stream = await this.haxe.openfl("build", this.platform, this.config, this.debug);
if (this.platform === Platform.ANDROID && this.config.key) { if (this.platform === Platform.ANDROID && this.config.key) {
result = result.pipe(this.android.sign(this.config.key.store, this.config.key.pass)); stream = stream.pipe(this.android.sign(this.config.key.store, this.config.key.pass));
} }
return streamToPromise(result.pipe(vfs.dest(target))); return streamToPromise(stream.pipe(vfs.dest(target)));
});
case BuildSystem.HAXE: case BuildSystem.HAXE:
return this.haxe stream = await this.haxe.build(this.platform, this.config, this.debug);
.build(this.platform, this.config, this.debug) return streamToPromise(stream.pipe(vfs.dest(target)));
.then((result) => streamToPromise(result.pipe(vfs.dest(target)))); default:
return super.call();
} }
} }
} }
+8 -6
View File
@@ -8,6 +8,12 @@ import template from "../../../../common/template";
import { type Config, Platform } from "../../../../core/type"; import { type Config, Platform } from "../../../../core/type";
import { Packer } from "../../../core/packer"; import { Packer } from "../../../core/packer";
const UPDATE_MENUS = `
if [ "$1" = "configure" ] && [ -x "\`which update-menus 2>/dev/null\`" ] ; then
update-menus
fi
`;
export class LinuxDEBPacker extends Packer { export class LinuxDEBPacker extends Packer {
static NAME = "deb"; static NAME = "deb";
@@ -18,7 +24,7 @@ export class LinuxDEBPacker extends Packer {
call() { call() {
const target = this.targetPath; const target = this.targetPath;
const buildDir = path.join(os.tmpdir(), "build", this.config.name, "debian"); const buildDir = path.join(os.tmpdir(), "build", this.config.name, "debian");
const icon = this.config.meta.icon!; const icon = this.config.icon;
const iconfile = `${this.config.meta.filename}${path.extname(icon)}`; const iconfile = `${this.config.meta.filename}${path.extname(icon)}`;
const desktop = template.render("linux/app.desktop", { iconfile: iconfile, ...this.config }); const desktop = template.render("linux/app.desktop", { iconfile: iconfile, ...this.config });
fse.ensureDirSync(`${buildDir}/usr/share/applications`); fse.ensureDirSync(`${buildDir}/usr/share/applications`);
@@ -35,11 +41,7 @@ export class LinuxDEBPacker extends Packer {
maintainer: this.config.meta.author, maintainer: this.config.meta.author,
description: this.config.meta.title, description: this.config.meta.title,
changelog: [], changelog: [],
postinst: [ postinst: [UPDATE_MENUS],
'if [ "$1" = "configure" ] && [ -x "`which update-menus 2>/dev/null`" ] ; then\n' +
" update-menus\n" +
"fi",
],
_target: "/", _target: "/",
_out: this.resolveTargetPath("debian"), _out: this.resolveTargetPath("debian"),
_clean: true, _clean: true,
+5 -11
View File
@@ -1,6 +1,6 @@
import { branch, compile } from "../core/config"; import { branch, compile } from "../core/config";
import type { Config } from "../core/type"; import type { Config } from "../core/type";
import type { TaskBundle, TaskCompilerType } from "./core"; import type { TaskCompilerType, TaskDef } from "./core";
import { CleanTaskCompiler } from "./impl/clean"; import { CleanTaskCompiler } from "./impl/clean";
import { FormatTaskCompiler } from "./impl/format"; import { FormatTaskCompiler } from "./impl/format";
import { ProjectTaskCompiler } from "./impl/project"; import { ProjectTaskCompiler } from "./impl/project";
@@ -10,20 +10,14 @@ import { SetupTaskCompiler } from "./impl/setup";
const COMPILERS: TaskCompilerType[] = [FormatTaskCompiler, CleanTaskCompiler, SetupTaskCompiler, ProtoTaskCompiler]; const COMPILERS: TaskCompilerType[] = [FormatTaskCompiler, CleanTaskCompiler, SetupTaskCompiler, ProtoTaskCompiler];
const PROJECT_COMPILERS: TaskCompilerType[] = [ProjectTaskCompiler]; const PROJECT_COMPILERS: TaskCompilerType[] = [ProjectTaskCompiler];
export default (projects: Config[]): TaskBundle => { export default function* (projects: Config[]): Iterable<TaskDef> {
const bundle: TaskBundle = {};
const config = projects.reduce((config, project) => branch(config, project), compile({})); const config = projects.reduce((config, project) => branch(config, project), compile({}));
for (const compiler of COMPILERS) { for (const compiler of COMPILERS) {
for (const [name, task] of Object.entries(new compiler(config).compile())) { yield* new compiler(config).compile();
bundle[name] = task;
}
} }
for (const compiler of PROJECT_COMPILERS) { for (const compiler of PROJECT_COMPILERS) {
for (const project of projects) { for (const project of projects) {
for (const [name, task] of Object.entries(new compiler(project).compile())) { yield* new compiler(project).compile();
bundle[name] = task;
}
} }
} }
return bundle; }
};
+4 -4
View File
@@ -1,22 +1,22 @@
import type { TaskFunction } from "gulp"; import type { TaskFunction } from "gulp";
import type { Config } from "../core/type"; import type { Config } from "../core/type";
export type TaskBundle = Record<string, TaskFunction>;
export interface TaskCompiler { export interface TaskCompiler {
config: Config; config: Config;
debug?: boolean; debug?: boolean;
compile(): TaskBundle; compile(): Iterable<TaskDef>;
} }
export type TaskDef = readonly [string, TaskFunction] | readonly [string, TaskFunction, boolean];
export abstract class TaskCompilerImpl implements TaskCompiler { export abstract class TaskCompilerImpl implements TaskCompiler {
constructor( constructor(
public config: Config, public config: Config,
public debug?: boolean, public debug?: boolean,
) {} ) {}
abstract compile(): TaskBundle; abstract compile(): Iterable<TaskDef>;
} }
export type TaskCompilerType = new (config: Config, debug?: boolean) => TaskCompiler; export type TaskCompilerType = new (config: Config, debug?: boolean) => TaskCompiler;
+3 -7
View File
@@ -1,13 +1,9 @@
import gulp from "gulp"; import gulp from "gulp";
import gulpClean from "gulp-clean"; import gulpClean from "gulp-clean";
import { TaskCompilerImpl, type TaskBundle } from "../core"; import { TaskCompilerImpl, type TaskDef } from "../core";
export class CleanTaskCompiler extends TaskCompilerImpl { export class CleanTaskCompiler extends TaskCompilerImpl {
compile(): TaskBundle { *compile(): Iterable<TaskDef> {
return { yield ["clean", () => gulp.src("target/*", { read: false }).pipe(gulpClean()), true];
clean: () => {
return gulp.src("target/*", { read: false }).pipe(gulpClean());
},
};
} }
} }
+31 -22
View File
@@ -1,27 +1,36 @@
import fs from "fs";
import path from "path";
import { Haxe } from "../../impl/haxe"; import { Haxe } from "../../impl/haxe";
import { TaskCompilerImpl, type TaskBundle } from "../core"; import { TaskCompilerImpl, type TaskDef } from "../core";
export class FormatTaskCompiler extends TaskCompilerImpl { export class FormatTaskCompiler extends TaskCompilerImpl {
compile(): TaskBundle { *compile(): Iterable<TaskDef> {
return { const hxformatFile = path.join(".", "hxformat.json");
check: async () => { if (fs.existsSync(hxformatFile)) {
const haxe = new Haxe(this.config.haxe); yield [
await haxe.install({ formatter: "" }); "check",
await haxe.haxelib( async () => {
["run", "formatter", "--check"].concat( const haxe = new Haxe(this.config.haxe);
this.config.sources.reduce<string[]>((sources, source) => sources.concat(["-s", source]), []), await haxe.install({ formatter: "" });
), await haxe.haxelib(
); ["run", "formatter", "--check"].concat(
}, this.config.sources.reduce<string[]>((sources, source) => sources.concat(["-s", source]), []),
format: async () => { ),
const haxe = new Haxe(this.config.haxe); );
await haxe.install({ formatter: "" }); },
await haxe.haxelib( ];
["run", "formatter"].concat( yield [
this.config.sources.reduce<string[]>((sources, source) => sources.concat(["-s", source]), []), "format",
), async () => {
); const haxe = new Haxe(this.config.haxe);
}, await haxe.install({ formatter: "" });
}; await haxe.haxelib(
["run", "formatter"].concat(
this.config.sources.reduce<string[]>((sources, source) => sources.concat(["-s", source]), []),
),
);
},
];
}
} }
} }
+20 -9
View File
@@ -1,31 +1,42 @@
import gulp from "gulp"; import gulp from "gulp";
import os from "os";
import { Platform } from "../../core/type";
import { Builder, Packer, Runner } from "../../project"; import { Builder, Packer, Runner } from "../../project";
import { TaskCompilerImpl, type TaskBundle } from "../core"; import { TaskCompilerImpl, type TaskDef } from "../core";
const isPlatformSupported = (platform: Platform): boolean => {
switch (platform) {
case Platform.LINUX:
return os.type() === "Linux";
case Platform.WINDOWS:
return os.type() === "Windows_NT";
default:
return true;
}
};
export class ProjectTaskCompiler extends TaskCompilerImpl { export class ProjectTaskCompiler extends TaskCompilerImpl {
compile(): TaskBundle { *compile(): Iterable<TaskDef> {
const tasks: TaskBundle = {}; for (const platform of this.config.platforms.filter(isPlatformSupported)) {
for (const platform of this.config.platforms) {
const builder = Builder.new(this.config, platform, this.config.buildSystem, this.debug); const builder = Builder.new(this.config, platform, this.config.buildSystem, this.debug);
const setupKey = `${this.config.name}:${platform}:setup`; const setupKey = `${this.config.name}:${platform}:setup`;
const buildKey = `${this.config.name}:${platform}:build`; const buildKey = `${this.config.name}:${platform}:build`;
tasks[setupKey] = builder.setup.bind(builder); yield [setupKey, builder.setup.bind(builder)];
tasks[buildKey] = gulp.series(builder.setup.bind(builder), builder.call.bind(builder)); yield [buildKey, gulp.series(builder.setup.bind(builder), builder.call.bind(builder)), true];
if (Runner.factory[platform]) { if (Runner.factory[platform]) {
const testKey = `${this.config.name}:${platform}:test`; const testKey = `${this.config.name}:${platform}:test`;
const runner = Runner.new(this.config, platform, this.debug); const runner = Runner.new(this.config, platform, this.debug);
tasks[testKey] = gulp.series(builder.setup.bind(builder), runner.setup.bind(runner), runner.call.bind(runner)); yield [testKey, gulp.series(builder.setup.bind(builder), runner.setup.bind(runner), runner.call.bind(runner))];
} }
if (Packer.factory[platform]) { if (Packer.factory[platform]) {
for (const name of Object.keys(Packer.factory[platform])) { for (const name of Object.keys(Packer.factory[platform])) {
const packKey = `${this.config.name}:${platform}:${name}`; const packKey = `${this.config.name}:${platform}:${name}`;
const packer = Packer.new(this.config, platform, name); const packer = Packer.new(this.config, platform, name);
tasks[packKey] = gulp.series(packer.setup.bind(packer), packer.call.bind(packer)); yield [packKey, gulp.series(packer.setup.bind(packer), packer.call.bind(packer)), true];
} }
} }
} }
return tasks;
} }
} }
+18 -11
View File
@@ -1,16 +1,23 @@
import fs from "fs";
import path from "path";
import { Haxe } from "../../impl/haxe"; import { Haxe } from "../../impl/haxe";
import { TaskCompilerImpl, type TaskBundle } from "../core"; import { TaskCompilerImpl, type TaskDef } from "../core";
export class ProtoTaskCompiler extends TaskCompilerImpl { export class ProtoTaskCompiler extends TaskCompilerImpl {
compile(): TaskBundle { *compile(): Iterable<TaskDef> {
return { const protohxFile = path.join(".", "protohx.json");
"protohx:generate": async () => { if (fs.existsSync(protohxFile)) {
const haxe = new Haxe(this.config.haxe); yield [
const result = await haxe.haxelib(["run", "protohx", "generate", "protohx.json"]); "protohx:generate",
if (result.stdout.indexOf("FAIL") > -1) { async () => {
throw result.stdout; const haxe = new Haxe(this.config.haxe);
} const result = await haxe.haxelib(["run", "protohx", "generate", "protohx.json"]);
}, if (result.stdout.indexOf("FAIL") > -1) {
}; throw result.stdout;
}
},
true,
];
}
} }
} }
+10 -9
View File
@@ -1,14 +1,15 @@
import { Builder } from "../../project"; import { Haxe } from "../../impl/haxe";
import { TaskCompilerImpl, type TaskBundle } from "../core"; import { TaskCompilerImpl, type TaskDef } from "../core";
export class SetupTaskCompiler extends TaskCompilerImpl { export class SetupTaskCompiler extends TaskCompilerImpl {
compile(): TaskBundle { *compile(): Iterable<TaskDef> {
return { yield [
clean: () => { "setup",
return Promise.all( async () => {
this.config.platforms.map((platform) => Builder.new(this.config, platform, this.config.buildSystem).setup()), const haxe = new Haxe(this.config.haxe);
); await haxe.prepare();
await haxe.install(this.config.libs);
}, },
}; ];
} }
} }
+11 -4
View File
@@ -1,8 +1,15 @@
import gulp from "gulp"; import gulp from "gulp";
import type { TaskBundle } from "./core"; import type { TaskDef } from "./core";
export default (tasks: TaskBundle) => { export default (tasks: Iterable<TaskDef>) => {
for (const [name, task] of Object.entries(tasks)) { const defaultTasks = [];
gulp.task(name, task); for (const item of tasks) {
gulp.task(item[0], item[1]);
if (item[2]) {
defaultTasks.push(item[0]);
}
}
if (defaultTasks.length > 0) {
gulp.task("default", gulp.series(defaultTasks));
} }
}; };