refactor: replace lodash.template with eta
test / test (push) Failing after 3m8s

This commit is contained in:
2026-10-25 14:58:31 +03:00
parent bf9ac8a8bf
commit f45effe571
9 changed files with 789 additions and 808 deletions
+747 -768
View File
File diff suppressed because it is too large Load Diff
+2 -7
View File
@@ -30,9 +30,10 @@
"homepage": "https://git.shmyga.ru/InfernalGames/gulp-haxetool#readme",
"dependencies": {
"ansi-colors": "^1.1.0",
"async": "^2.6.0",
"async": "^3.2.6",
"cli-progress": "^3.12.0",
"dateformat": "^5.0.4",
"eta": "^4.6.0",
"fancy-log": "^1.3.2",
"fs-extra": "^5.0.0",
"got": "^16.1.0",
@@ -44,8 +45,6 @@
"gulp-rename": "^2.1.0",
"gulp-tar": "^5.0.0",
"gulp-zip": "^6.1.0",
"lodash.defaults": "^4.2.0",
"lodash.template": "^4.4.0",
"plugin-error": "^1.0.1",
"promise-streams": "^2.1.1",
"tail": "^2.2.6",
@@ -67,7 +66,6 @@
"@types/gulp-rename": "^2.0.7",
"@types/gulp-tar": "^4.0.1",
"@types/gulp-zip": "^4.0.4",
"@types/lodash.template": "^4.5.3",
"@types/node": "^26.6.5",
"@types/tail": "^2.2.3",
"@types/tar": "^7.0.87",
@@ -77,8 +75,5 @@
"prettier": "^3.9.10",
"tsdown": "0.22.14",
"typescript": "^7.0.2"
},
"inlinedDependencies": {
"lodash": "4.18.1"
}
}
+13
View File
@@ -0,0 +1,13 @@
import { Eta } from "eta";
import path from "path";
import { fileURLToPath } from "url";
const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
export default new Eta({
autoFilter: true,
filterFunction: (val: unknown): string => (val === null ? "" : String(val)),
useWith: true,
views: path.join(__dirname, "..", "template"),
});
+9 -10
View File
@@ -1,13 +1,13 @@
import fs from "fs";
import fse from "fs-extra";
import rename from "gulp-rename";
import template from "lodash.template";
import os from "os";
import path from "path";
import vfs from "vinyl-fs";
import { Env } from "../common/env";
import exec from "../common/exec";
import { System } from "../common/system";
import template from "../common/template";
import type { Config, LibDef } from "../core/config";
import { Sdk } from "../core/sdk";
import { Neko } from "./neko";
@@ -115,10 +115,7 @@ export class Haxe extends Sdk {
const buildDir = this.resolveBuildDir(config);
fse.ensureDirSync(buildDir);
const projectTemplate = template(
fs.readFileSync(path.resolve(import.meta.dirname, "..", "template/project.xml"), "utf8"),
);
const project = projectTemplate({ ...config, buildDir: buildDir });
const project = template.render("project.xml", { ...config, buildDir: buildDir });
fs.writeFileSync(path.resolve(buildDir, "project.xml"), project);
const args = ["-cwd", buildDir, "run", "openfl", command, platform];
@@ -147,10 +144,6 @@ export class Haxe extends Sdk {
const buildDir = this.resolveBuildDir(config);
fse.ensureDirSync(buildDir);
const projectTemplate = template(
fs.readFileSync(path.resolve(import.meta.dirname, "..", "template/project.hxml"), "utf8"),
);
const ext =
{
flash: ".swf",
@@ -162,7 +155,13 @@ export class Haxe extends Sdk {
flash: "swf",
}[platform] || platform;
const project = projectTemplate({ ...config, buildDir: buildDir, platform: platform, ext: ext, out: out });
const project = template.render("project.hxml", {
...config,
buildDir: buildDir,
platform: platform,
ext: ext,
out: out,
});
const projectHXML = path.resolve(buildDir, "project.hxml");
fs.writeFileSync(projectHXML, project);
+2 -5
View File
@@ -1,9 +1,9 @@
import fs from "fs";
import fse from "fs-extra";
import template from "lodash.template";
import os from "os";
import path from "path";
import exec from "../common/exec";
import template from "../common/template";
import type { Config } from "../core/config";
import { Sdk } from "../core/sdk";
@@ -43,10 +43,7 @@ export class InnoSetup extends Sdk {
pack(config: Config, source: string, output: string) {
const buildDir = path.join(os.tmpdir(), "build", config.name, "innosetup");
const appTemplate = template(
fs.readFileSync(path.resolve(import.meta.dirname, "..", "template/windows/app.iss"), "utf8"),
);
const app = appTemplate({ ...config, buildDir: buildDir, output: output });
const app = template.render("windows/app.iss", { ...config, buildDir: buildDir, output: output });
fse.ensureDirSync(buildDir);
fse.copySync(`${source}`, `${buildDir}`);
+2 -5
View File
@@ -1,6 +1,6 @@
import fs from "fs";
import template from "lodash.template";
import path from "path";
import template from "../../../common/template";
import type { Config } from "../../../core/config";
import { Platform } from "../../../core/type";
import { Packer } from "../../core/packer";
@@ -14,10 +14,7 @@ export class FlashHTMLPacker extends Packer {
call() {
const target = this.targetPath;
const indexTemplate = template(
fs.readFileSync(path.resolve(import.meta.dirname, "..", "template/flash/index.html"), "utf8"),
);
const index = indexTemplate(this.config);
const index = template.render("flash/index.html", this.config);
fs.writeFileSync(path.resolve(target, "index.html"), index);
fs.copyFileSync(path.resolve(import.meta.dirname, "..", "template/flash/swf.js"), path.resolve(target, "swf.js"));
return Promise.resolve();
+2 -5
View File
@@ -2,9 +2,9 @@ import fs from "fs";
import fse from "fs-extra";
import gulp from "gulp";
import deb from "gulp-debian";
import { template } from "lodash";
import os from "os";
import path from "path";
import template from "../../../../common/template";
import { Config } from "../../../../core/config";
import { Platform } from "../../../../core/type";
import { Packer } from "../../../core/packer";
@@ -20,10 +20,7 @@ export class LinuxDEBPacker extends Packer {
const target = this.targetPath;
const buildDir = path.join(os.tmpdir(), "build", this.config.name, "debian");
const iconfile = `${this.config.meta.filename}${path.extname(this.config.meta.icon!)}`;
const desktopTemplate = template(
fs.readFileSync(path.resolve(import.meta.dirname, "..", "template/linux/app.desktop"), "utf8"),
);
const desktop = desktopTemplate(Object.assign({ iconfile: iconfile }, this.config));
const desktop = template.render("linux/app.desktop", Object.assign({ iconfile: iconfile }, this.config));
fse.ensureDirSync(`${buildDir}/usr/share/applications`);
fs.writeFileSync(`${buildDir}/usr/share/applications/${this.config.meta.filename}.desktop`, desktop);
fse.copySync(`${target}`, `${buildDir}/usr/share/${this.config.meta.filename}/`);
+9 -5
View File
@@ -1,12 +1,12 @@
import dateformat from "dateformat";
import gulp from "gulp";
import gulpClean from "gulp-clean";
import template from "lodash.template";
import os from "os";
import type { Task } from "undertaker";
import { Builder, Project } from ".";
import { System } from "../common/system";
import { Config, type ConfigParams } from "../core/config";
import template from "../common/template";
import { Config, type ConfigParams, type SignKey } from "../core/config";
import { Sdk } from "../core/sdk";
import { Platform } from "../core/type";
import { Haxe } from "../impl/haxe";
@@ -16,7 +16,7 @@ export interface PresetConfig {
BuildDir?: string;
Develop?: boolean;
UseRuffle?: boolean;
Key?: any;
Key?: SignKey;
}
export const DEFAULT_CONFIG: PresetConfig = {
@@ -44,9 +44,13 @@ export class Preset {
}
private fillPreset(preset: ProjectPreset): ProjectPreset {
const configTemplate = template(JSON.stringify(preset));
return JSON.parse(
configTemplate({ config: this.config, package: this.packageInfo, env: process.env, dateformat: dateformat }),
template.renderString(JSON.stringify(preset), {
config: this.config,
package: this.packageInfo,
env: process.env,
dateformat: dateformat,
}),
);
}
+3 -3
View File
@@ -1,10 +1,10 @@
import colors from "ansi-colors";
import cp from "child_process";
import { defaults, template } from "lodash";
import path from "path";
import stream from "stream";
import util from "util";
import Vinyl from "vinyl";
import template from "../common/template";
export class Command {
private command: string;
@@ -14,7 +14,7 @@ export class Command {
constructor(command: string, options?: any) {
this.command = command;
this.isWindows = process.platform.lastIndexOf("win") === 0;
this.options = defaults(options || {}, {
this.options = Object.assign(options || {}, {
cwd: process.cwd(),
env: process.env,
verbosity: options && options.silent ? 1 : 2,
@@ -69,7 +69,7 @@ export class Command {
// execute the command.
// we spawn the command in a subshell, so things like i/o redirection
// just work. e.g. `echo hello world >> ./hello.txt` works as expected.
const command = template(this.command)({
const command = template.renderString(this.command, {
file: stdin,
});