Compare commits
5
Commits
1.2.0
..
188fcc8e4c
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
188fcc8e4c | ||
|
|
c8720102f9 | ||
|
|
e58d63f260 | ||
|
|
f45effe571 | ||
|
|
bf9ac8a8bf |
@@ -1,3 +1,4 @@
|
|||||||
node_modules/
|
node_modules/
|
||||||
target/
|
target/
|
||||||
dist/
|
dist/
|
||||||
|
build/
|
||||||
@@ -1,71 +0,0 @@
|
|||||||
const gulp = require('gulp');
|
|
||||||
const gulpClean = require('gulp-clean');
|
|
||||||
const packageInfo = require('./package.json');
|
|
||||||
const {System, Sdk, Haxe, Project} = require('gulp-haxetool');
|
|
||||||
|
|
||||||
//Sdk.dir = '/opt/sdk';
|
|
||||||
|
|
||||||
exports.clean = function clean() {
|
|
||||||
return gulp.src('target/*', {read: false}).pipe(gulpClean());
|
|
||||||
};
|
|
||||||
|
|
||||||
exports.install = function install() {
|
|
||||||
const haxe = new Haxe();
|
|
||||||
return haxe.prepare().then(() => haxe.install(packageInfo.haxeDependencies));
|
|
||||||
};
|
|
||||||
|
|
||||||
const config = new Project.Config({
|
|
||||||
meta: {
|
|
||||||
title: 'Application',
|
|
||||||
filename: 'app',
|
|
||||||
icon: './resources/icon.jpg',
|
|
||||||
pack: 'com.example',
|
|
||||||
author: 'Anonim <anonim@anonim.com>',
|
|
||||||
company: 'Any company',
|
|
||||||
version: packageInfo.version,
|
|
||||||
},
|
|
||||||
name: 'app',
|
|
||||||
libs: packageInfo.haxeDependencies,
|
|
||||||
sources: ['src'],
|
|
||||||
assets: ['resources'],
|
|
||||||
main: 'Main',
|
|
||||||
});
|
|
||||||
|
|
||||||
const project = new Project(
|
|
||||||
Project.BuildSystem.OPENFL,
|
|
||||||
[
|
|
||||||
Project.Platform.FLASH,
|
|
||||||
Project.Platform.HTML5,
|
|
||||||
Project.Platform.LINUX,
|
|
||||||
Project.Platform.WINDOWS,
|
|
||||||
],
|
|
||||||
config
|
|
||||||
).bind(module);
|
|
||||||
|
|
||||||
|
|
||||||
const defaultSeries = [
|
|
||||||
exports.clean,
|
|
||||||
module.exports['app:flash:build'],
|
|
||||||
module.exports['app:flash:html'],
|
|
||||||
module.exports['app:html5:build'],
|
|
||||||
];
|
|
||||||
|
|
||||||
if (System.isLinux) {
|
|
||||||
defaultSeries.push(
|
|
||||||
module.exports['app:linux:build'],
|
|
||||||
module.exports['app:linux:archive'],
|
|
||||||
module.exports['app:linux:deb'],
|
|
||||||
|
|
||||||
module.exports['app:android:build'],
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (System.isWindows) {
|
|
||||||
defaultSeries.push(
|
|
||||||
module.exports['app:windows:build'],
|
|
||||||
module.exports['app:windows:archive'],
|
|
||||||
module.exports['app:windows:installer'],
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
module.exports.default = gulp.series(defaultSeries);
|
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
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, null, packageInfo);
|
||||||
|
export default preset.register(gulp);
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
{
|
||||||
|
"app": {
|
||||||
|
"buildSystem": "openfl",
|
||||||
|
"platforms": ["flash", "html5", "linux", "windows", "android"],
|
||||||
|
"config": {
|
||||||
|
"meta": {
|
||||||
|
"title": "Example",
|
||||||
|
"filename": "example",
|
||||||
|
"icon": "./resources/icon.jpg",
|
||||||
|
"pack": "com.example",
|
||||||
|
"author": "Anonim <anonim@anonim.com>",
|
||||||
|
"company": "Any company",
|
||||||
|
"version": "<%=package.version%>"
|
||||||
|
},
|
||||||
|
"sources": ["src"],
|
||||||
|
"main": "Main"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Generated
+7098
File diff suppressed because it is too large
Load Diff
+13
-8
@@ -1,14 +1,19 @@
|
|||||||
{
|
{
|
||||||
"name": "app",
|
"name": "example",
|
||||||
|
"type": "module",
|
||||||
"version": "0.0.1",
|
"version": "0.0.1",
|
||||||
|
"scripts": {
|
||||||
|
"build": "gulp",
|
||||||
|
"dev": "gulp app:flash:test"
|
||||||
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"gulp": "^4.0.0",
|
"gulp-cli": "^3.1.0",
|
||||||
"gulp-clean": "^0.4.0",
|
"gulp-haxetool": "^1.2.0"
|
||||||
"gulp-haxetool": "^0.1.0"
|
|
||||||
},
|
},
|
||||||
"haxeDependencies": {
|
"haxeDependencies": {
|
||||||
"lime": "7.6.0",
|
"lime": "8.0.0",
|
||||||
"openfl": "8.9.2",
|
"openfl": "9.2.0",
|
||||||
"hxcpp": "4.0.19"
|
"hxcpp": "4.2.1"
|
||||||
}
|
},
|
||||||
|
"haxe": "4.2.5"
|
||||||
}
|
}
|
||||||
|
|||||||
Generated
+846
-797
File diff suppressed because it is too large
Load Diff
+6
-13
@@ -29,24 +29,21 @@
|
|||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"homepage": "https://git.shmyga.ru/InfernalGames/gulp-haxetool#readme",
|
"homepage": "https://git.shmyga.ru/InfernalGames/gulp-haxetool#readme",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"ansi-colors": "^1.1.0",
|
"ansi-colors": "^4.1.3",
|
||||||
"async": "^2.6.0",
|
"async": "^3.2.6",
|
||||||
"cli-progress": "^3.12.0",
|
"cli-progress": "^3.12.0",
|
||||||
"dateformat": "^5.0.4",
|
"dateformat": "^5.0.5",
|
||||||
"fancy-log": "^1.3.2",
|
"eta": "^4.6.0",
|
||||||
"fs-extra": "^5.0.0",
|
"fs-extra": "^11.4.1",
|
||||||
"got": "^16.1.0",
|
"got": "^16.1.0",
|
||||||
"gulp": "^5.0.1",
|
"gulp": "^5.0.1",
|
||||||
"gulp-clean": "^0.4.0",
|
"gulp-clean": "^0.4.0",
|
||||||
"gulp-connect": "^5.7.0",
|
"gulp-connect": "^5.7.0",
|
||||||
"gulp-debian": "^0.1.9",
|
"gulp-debian": "^0.3.2",
|
||||||
"gulp-gzip": "^1.4.2",
|
"gulp-gzip": "^1.4.2",
|
||||||
"gulp-rename": "^2.1.0",
|
"gulp-rename": "^2.1.0",
|
||||||
"gulp-tar": "^5.0.0",
|
"gulp-tar": "^5.0.0",
|
||||||
"gulp-zip": "^6.1.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",
|
"promise-streams": "^2.1.1",
|
||||||
"tail": "^2.2.6",
|
"tail": "^2.2.6",
|
||||||
"tar": "^7.5.22",
|
"tar": "^7.5.22",
|
||||||
@@ -67,7 +64,6 @@
|
|||||||
"@types/gulp-rename": "^2.0.7",
|
"@types/gulp-rename": "^2.0.7",
|
||||||
"@types/gulp-tar": "^4.0.1",
|
"@types/gulp-tar": "^4.0.1",
|
||||||
"@types/gulp-zip": "^4.0.4",
|
"@types/gulp-zip": "^4.0.4",
|
||||||
"@types/lodash.template": "^4.5.3",
|
|
||||||
"@types/node": "^26.6.5",
|
"@types/node": "^26.6.5",
|
||||||
"@types/tail": "^2.2.3",
|
"@types/tail": "^2.2.3",
|
||||||
"@types/tar": "^7.0.87",
|
"@types/tar": "^7.0.87",
|
||||||
@@ -77,8 +73,5 @@
|
|||||||
"prettier": "^3.9.10",
|
"prettier": "^3.9.10",
|
||||||
"tsdown": "0.22.14",
|
"tsdown": "0.22.14",
|
||||||
"typescript": "^7.0.2"
|
"typescript": "^7.0.2"
|
||||||
},
|
|
||||||
"inlinedDependencies": {
|
|
||||||
"lodash": "4.18.1"
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,42 +0,0 @@
|
|||||||
import colors from "ansi-colors";
|
|
||||||
|
|
||||||
const _colors = {
|
|
||||||
"[DEBUG]": colors.white,
|
|
||||||
"[INFO]": colors.cyan,
|
|
||||||
"[ERROR]": colors.red,
|
|
||||||
"Called from ": colors.red,
|
|
||||||
"[WARNING]": colors.yellow,
|
|
||||||
};
|
|
||||||
|
|
||||||
export type Color = (v: string) => string;
|
|
||||||
|
|
||||||
export const getColor = (line: string): Color | null => {
|
|
||||||
for (const [tag, color] of Object.entries(_colors)) {
|
|
||||||
if (line.indexOf(tag) > -1) {
|
|
||||||
return color;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return null; // colors.reset;
|
|
||||||
};
|
|
||||||
|
|
||||||
export class Debug {
|
|
||||||
public color: Color;
|
|
||||||
|
|
||||||
constructor() {
|
|
||||||
this.color = colors.white;
|
|
||||||
this.log = this.log.bind(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
log(line: string) {
|
|
||||||
const newColor = getColor(line);
|
|
||||||
if (newColor) this.color = newColor;
|
|
||||||
if (line[0] === "\t" || line.startsWith("Called from ")) {
|
|
||||||
console.log(this.color(line));
|
|
||||||
} else {
|
|
||||||
const result = line.split(" ");
|
|
||||||
console.log(colors.gray(result.slice(0, 4).join(" ")) + " " + this.color(result.slice(4).join(" ")));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
export const DEBUG = new Debug();
|
|
||||||
+2
-2
@@ -1,8 +1,8 @@
|
|||||||
import async from "async";
|
import async from "async";
|
||||||
import child_process from "child_process";
|
import child_process from "child_process";
|
||||||
import { Log } from "./log";
|
import { Logger } from "./log";
|
||||||
|
|
||||||
const log = new Log("exec");
|
const log = new Logger("exec");
|
||||||
|
|
||||||
const queue = async.queue((task: any, done: any) => {
|
const queue = async.queue((task: any, done: any) => {
|
||||||
log.d("*%s*", task.command);
|
log.d("*%s*", task.command);
|
||||||
|
|||||||
+54
-31
@@ -1,63 +1,86 @@
|
|||||||
import colors from "ansi-colors";
|
import colors from "ansi-colors";
|
||||||
|
|
||||||
const Level = {
|
export enum Level {
|
||||||
VERBOSE: -1,
|
VERBOSE = -1,
|
||||||
DEBUG: 0,
|
DEBUG = 0,
|
||||||
INFO: 1,
|
INFO = 1,
|
||||||
WARN: 2,
|
WARNING = 2,
|
||||||
ERROR: 3,
|
ERROR = 3,
|
||||||
};
|
}
|
||||||
|
|
||||||
const level = process.argv.indexOf("--verbose") > -1 ? Level.VERBOSE : Level.INFO;
|
export const DEFAULT_LEVEL: Level = process.argv.indexOf("--verbose") > -1 ? Level.VERBOSE : Level.INFO;
|
||||||
|
|
||||||
const formatTime = (date: Date): string => date.toTimeString().split(" ")[0];
|
export type FormatPattern = [string, colors.StyleFunction];
|
||||||
|
|
||||||
export class Log {
|
export const DEFAULT_PATTERNS: FormatPattern[] = [
|
||||||
static level = level;
|
|
||||||
static colorPatterns: [string, (m: string) => string][] = [
|
|
||||||
["_", colors.cyan],
|
["_", colors.cyan],
|
||||||
["\\*", colors.magenta],
|
["\\*", colors.magenta],
|
||||||
["!", colors.red],
|
["!", colors.red],
|
||||||
];
|
];
|
||||||
|
|
||||||
static colorize(pattern: string) {
|
export class Formatter {
|
||||||
for (const item of this.colorPatterns) {
|
constructor(
|
||||||
|
private patterns: FormatPattern[] = DEFAULT_PATTERNS,
|
||||||
|
private time: boolean = true,
|
||||||
|
) {}
|
||||||
|
|
||||||
|
colorize(text: string): string {
|
||||||
|
for (const item of this.patterns) {
|
||||||
const r = new RegExp(item[0] + "(.*?)" + item[0], "g");
|
const r = new RegExp(item[0] + "(.*?)" + item[0], "g");
|
||||||
pattern = pattern.replace(r, item[1]("$1"));
|
text = text.replace(r, item[1]("$1"));
|
||||||
}
|
}
|
||||||
return pattern;
|
return text;
|
||||||
}
|
}
|
||||||
|
|
||||||
static write(level: number, tag: string, pattern: string, args: any[]) {
|
buildTime(): string {
|
||||||
|
return new Date().toTimeString().split(" ")[0];
|
||||||
|
}
|
||||||
|
|
||||||
|
format(message: string, tag: string, level: Level): string {
|
||||||
|
const values = [];
|
||||||
|
if (this.time) {
|
||||||
|
values.push(`[${colors.gray(this.buildTime())}]`);
|
||||||
|
}
|
||||||
|
if (tag) {
|
||||||
|
values.push(colors.green(tag));
|
||||||
|
}
|
||||||
|
values.push(this.colorize(message));
|
||||||
|
return values.join(" ");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export const DEFAULT_FORMATTER = new Formatter();
|
||||||
|
|
||||||
|
export class Logger {
|
||||||
|
constructor(
|
||||||
|
private tag: string,
|
||||||
|
private level: Level = DEFAULT_LEVEL,
|
||||||
|
private formatter: Formatter = DEFAULT_FORMATTER,
|
||||||
|
) {}
|
||||||
|
|
||||||
|
write(level: Level, message: string, args: any[]) {
|
||||||
if (level >= this.level) {
|
if (level >= this.level) {
|
||||||
const message = `[${colors.gray(formatTime(new Date()))}] ${colors.green(tag)} ${this.colorize(pattern)}`;
|
console.log(this.formatter.format(message, this.tag, level), ...args);
|
||||||
console.log(message, ...args);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public tag: string;
|
|
||||||
|
|
||||||
constructor(tag: string) {
|
|
||||||
this.tag = tag;
|
|
||||||
}
|
|
||||||
|
|
||||||
v(message: string, ...args: any) {
|
v(message: string, ...args: any) {
|
||||||
Log.write(-1, this.tag, message, args);
|
this.write(Level.VERBOSE, message, args);
|
||||||
}
|
}
|
||||||
|
|
||||||
d(message: string, ...args: any) {
|
d(message: string, ...args: any) {
|
||||||
Log.write(0, this.tag, message, args);
|
this.write(Level.DEBUG, message, args);
|
||||||
}
|
}
|
||||||
|
|
||||||
i(message: string, ...args: any) {
|
i(message: string, ...args: any) {
|
||||||
Log.write(1, this.tag, message, args);
|
this.write(Level.INFO, message, args);
|
||||||
}
|
}
|
||||||
|
|
||||||
w(message: string, ...args: any) {
|
w(message: string, ...args: any) {
|
||||||
Log.write(2, this.tag, message, args);
|
this.write(Level.WARNING, message, args);
|
||||||
}
|
}
|
||||||
|
|
||||||
e(message: string, ...args: any) {
|
e(message: string, ...args: any) {
|
||||||
Log.write(3, this.tag, message, args);
|
this.write(Level.ERROR, message, args);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,55 @@
|
|||||||
|
import colors from "ansi-colors";
|
||||||
|
import { Formatter, Level, Logger } from "./log";
|
||||||
|
|
||||||
|
export class OutputFormatter extends Formatter {
|
||||||
|
private colorMap: Record<Level, colors.StyleFunction> = {
|
||||||
|
[Level.VERBOSE]: colors.white,
|
||||||
|
[Level.DEBUG]: colors.white,
|
||||||
|
[Level.INFO]: colors.cyan,
|
||||||
|
[Level.ERROR]: colors.red,
|
||||||
|
[Level.WARNING]: colors.yellow,
|
||||||
|
};
|
||||||
|
|
||||||
|
format(message: string, tag: string, level: Level): string {
|
||||||
|
const color = this.colorMap[level];
|
||||||
|
if (message[0] === "\t" || message.startsWith("Called from ")) {
|
||||||
|
return color(message);
|
||||||
|
} else {
|
||||||
|
const result = message.split(" ");
|
||||||
|
return colors.gray(result.slice(0, 4).join(" ")) + " " + color(result.slice(4).join(" "));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export const DEFAULT_OUTPUT_FORMATTER = new OutputFormatter();
|
||||||
|
|
||||||
|
export class OutputLogger extends Logger {
|
||||||
|
private levelMap: Record<string, Level> = {
|
||||||
|
"[DEBUG]": Level.DEBUG,
|
||||||
|
"[INFO]": Level.INFO,
|
||||||
|
"[ERROR]": Level.ERROR,
|
||||||
|
"Called from ": Level.ERROR,
|
||||||
|
"[WARNING]": Level.WARNING,
|
||||||
|
};
|
||||||
|
|
||||||
|
constructor() {
|
||||||
|
super("", Level.VERBOSE, DEFAULT_OUTPUT_FORMATTER);
|
||||||
|
}
|
||||||
|
|
||||||
|
detectLevel(line: string): number {
|
||||||
|
for (const [tag, color] of Object.entries(this.levelMap)) {
|
||||||
|
if (line.indexOf(tag) > -1) {
|
||||||
|
return color;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return Level.DEBUG;
|
||||||
|
}
|
||||||
|
|
||||||
|
log(line: string) {
|
||||||
|
this.write(this.detectLevel(line), line, []);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export const OUTPUT_LOGGER = new OutputLogger();
|
||||||
|
|
||||||
|
export default (line: string) => OUTPUT_LOGGER.log(line);
|
||||||
@@ -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"),
|
||||||
|
});
|
||||||
+3
-3
@@ -1,7 +1,7 @@
|
|||||||
import os from "os";
|
import os from "os";
|
||||||
import path from "path";
|
import path from "path";
|
||||||
import { Downloader } from "../common/download";
|
import { Downloader } from "../common/download";
|
||||||
import { Log } from "../common/log";
|
import { Logger } from "../common/log";
|
||||||
|
|
||||||
export class Sdk {
|
export class Sdk {
|
||||||
static _dir: string;
|
static _dir: string;
|
||||||
@@ -20,12 +20,12 @@ export class Sdk {
|
|||||||
|
|
||||||
public name: string;
|
public name: string;
|
||||||
public version: string;
|
public version: string;
|
||||||
public log: Log;
|
public log: Logger;
|
||||||
public path: string;
|
public path: string;
|
||||||
|
|
||||||
constructor(name: string, version: string) {
|
constructor(name: string, version: string) {
|
||||||
this.name = name;
|
this.name = name;
|
||||||
this.log = new Log(name);
|
this.log = new Logger(name);
|
||||||
this.version = version;
|
this.version = version;
|
||||||
this.path = Sdk.path(name, version);
|
this.path = Sdk.path(name, version);
|
||||||
}
|
}
|
||||||
|
|||||||
+9
-10
@@ -1,13 +1,13 @@
|
|||||||
import fs from "fs";
|
import fs from "fs";
|
||||||
import fse from "fs-extra";
|
import fse from "fs-extra";
|
||||||
import rename from "gulp-rename";
|
import rename from "gulp-rename";
|
||||||
import template from "lodash.template";
|
|
||||||
import os from "os";
|
import os from "os";
|
||||||
import path from "path";
|
import path from "path";
|
||||||
import vfs from "vinyl-fs";
|
import vfs from "vinyl-fs";
|
||||||
import { Env } from "../common/env";
|
import { Env } from "../common/env";
|
||||||
import exec from "../common/exec";
|
import exec from "../common/exec";
|
||||||
import { System } from "../common/system";
|
import { System } from "../common/system";
|
||||||
|
import template from "../common/template";
|
||||||
import type { Config, LibDef } from "../core/config";
|
import type { Config, LibDef } from "../core/config";
|
||||||
import { Sdk } from "../core/sdk";
|
import { Sdk } from "../core/sdk";
|
||||||
import { Neko } from "./neko";
|
import { Neko } from "./neko";
|
||||||
@@ -115,10 +115,7 @@ export class Haxe extends Sdk {
|
|||||||
const buildDir = this.resolveBuildDir(config);
|
const buildDir = this.resolveBuildDir(config);
|
||||||
fse.ensureDirSync(buildDir);
|
fse.ensureDirSync(buildDir);
|
||||||
|
|
||||||
const projectTemplate = template(
|
const project = template.render("project.xml", { ...config, buildDir: buildDir });
|
||||||
fs.readFileSync(path.resolve(import.meta.dirname, "..", "template/project.xml"), "utf8"),
|
|
||||||
);
|
|
||||||
const project = projectTemplate({ ...config, buildDir: buildDir });
|
|
||||||
fs.writeFileSync(path.resolve(buildDir, "project.xml"), project);
|
fs.writeFileSync(path.resolve(buildDir, "project.xml"), project);
|
||||||
|
|
||||||
const args = ["-cwd", buildDir, "run", "openfl", command, platform];
|
const args = ["-cwd", buildDir, "run", "openfl", command, platform];
|
||||||
@@ -147,10 +144,6 @@ export class Haxe extends Sdk {
|
|||||||
const buildDir = this.resolveBuildDir(config);
|
const buildDir = this.resolveBuildDir(config);
|
||||||
fse.ensureDirSync(buildDir);
|
fse.ensureDirSync(buildDir);
|
||||||
|
|
||||||
const projectTemplate = template(
|
|
||||||
fs.readFileSync(path.resolve(import.meta.dirname, "..", "template/project.hxml"), "utf8"),
|
|
||||||
);
|
|
||||||
|
|
||||||
const ext =
|
const ext =
|
||||||
{
|
{
|
||||||
flash: ".swf",
|
flash: ".swf",
|
||||||
@@ -162,7 +155,13 @@ export class Haxe extends Sdk {
|
|||||||
flash: "swf",
|
flash: "swf",
|
||||||
}[platform] || platform;
|
}[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");
|
const projectHXML = path.resolve(buildDir, "project.hxml");
|
||||||
fs.writeFileSync(projectHXML, project);
|
fs.writeFileSync(projectHXML, project);
|
||||||
|
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
import fs from "fs";
|
import fs from "fs";
|
||||||
import fse from "fs-extra";
|
import fse from "fs-extra";
|
||||||
import template from "lodash.template";
|
|
||||||
import os from "os";
|
import os from "os";
|
||||||
import path from "path";
|
import path from "path";
|
||||||
import exec from "../common/exec";
|
import exec from "../common/exec";
|
||||||
|
import template from "../common/template";
|
||||||
import type { Config } from "../core/config";
|
import type { Config } from "../core/config";
|
||||||
import { Sdk } from "../core/sdk";
|
import { Sdk } from "../core/sdk";
|
||||||
|
|
||||||
@@ -43,10 +43,7 @@ export class InnoSetup extends Sdk {
|
|||||||
|
|
||||||
pack(config: Config, source: string, output: string) {
|
pack(config: Config, source: string, output: string) {
|
||||||
const buildDir = path.join(os.tmpdir(), "build", config.name, "innosetup");
|
const buildDir = path.join(os.tmpdir(), "build", config.name, "innosetup");
|
||||||
const appTemplate = template(
|
const app = template.render("windows/app.iss", { ...config, buildDir: buildDir, output: output });
|
||||||
fs.readFileSync(path.resolve(import.meta.dirname, "..", "template/windows/app.iss"), "utf8"),
|
|
||||||
);
|
|
||||||
const app = appTemplate({ ...config, buildDir: buildDir, output: output });
|
|
||||||
|
|
||||||
fse.ensureDirSync(buildDir);
|
fse.ensureDirSync(buildDir);
|
||||||
fse.copySync(`${source}`, `${buildDir}`);
|
fse.copySync(`${source}`, `${buildDir}`);
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import gulp from "gulp";
|
import gulp from "gulp";
|
||||||
import rename from "gulp-rename";
|
import rename from "gulp-rename";
|
||||||
import { DEBUG } from "../../common/debug";
|
import output from "../../common/output";
|
||||||
import { tail } from "../../common/tail";
|
import { tail } from "../../common/tail";
|
||||||
import { Config } from "../../core/config";
|
import { Config } from "../../core/config";
|
||||||
import { Target } from "./target";
|
import { Target } from "./target";
|
||||||
@@ -18,7 +18,7 @@ export class Runner extends Target {
|
|||||||
}
|
}
|
||||||
|
|
||||||
log(stream: any) {
|
log(stream: any) {
|
||||||
return stream.pipe(tail(DEBUG.log)).pipe(rename("out.log")).pipe(gulp.dest(this.targetPath));
|
return stream.pipe(tail(output)).pipe(rename("out.log")).pipe(gulp.dest(this.targetPath));
|
||||||
}
|
}
|
||||||
|
|
||||||
static register(platform: string, runner: RunnerFactory) {
|
static register(platform: string, runner: RunnerFactory) {
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import fs from "fs";
|
import fs from "fs";
|
||||||
import template from "lodash.template";
|
|
||||||
import path from "path";
|
import path from "path";
|
||||||
|
import template from "../../../common/template";
|
||||||
import type { Config } from "../../../core/config";
|
import type { Config } from "../../../core/config";
|
||||||
import { Platform } from "../../../core/type";
|
import { Platform } from "../../../core/type";
|
||||||
import { Packer } from "../../core/packer";
|
import { Packer } from "../../core/packer";
|
||||||
@@ -14,10 +14,7 @@ export class FlashHTMLPacker extends Packer {
|
|||||||
|
|
||||||
call() {
|
call() {
|
||||||
const target = this.targetPath;
|
const target = this.targetPath;
|
||||||
const indexTemplate = template(
|
const index = template.render("flash/index.html", this.config);
|
||||||
fs.readFileSync(path.resolve(import.meta.dirname, "..", "template/flash/index.html"), "utf8"),
|
|
||||||
);
|
|
||||||
const index = indexTemplate(this.config);
|
|
||||||
fs.writeFileSync(path.resolve(target, "index.html"), index);
|
fs.writeFileSync(path.resolve(target, "index.html"), index);
|
||||||
fs.copyFileSync(path.resolve(import.meta.dirname, "..", "template/flash/swf.js"), path.resolve(target, "swf.js"));
|
fs.copyFileSync(path.resolve(import.meta.dirname, "..", "template/flash/swf.js"), path.resolve(target, "swf.js"));
|
||||||
return Promise.resolve();
|
return Promise.resolve();
|
||||||
|
|||||||
@@ -2,9 +2,9 @@ import fs from "fs";
|
|||||||
import fse from "fs-extra";
|
import fse from "fs-extra";
|
||||||
import gulp from "gulp";
|
import gulp from "gulp";
|
||||||
import deb from "gulp-debian";
|
import deb from "gulp-debian";
|
||||||
import { template } from "lodash";
|
|
||||||
import os from "os";
|
import os from "os";
|
||||||
import path from "path";
|
import path from "path";
|
||||||
|
import template from "../../../../common/template";
|
||||||
import { Config } from "../../../../core/config";
|
import { Config } from "../../../../core/config";
|
||||||
import { Platform } from "../../../../core/type";
|
import { Platform } from "../../../../core/type";
|
||||||
import { Packer } from "../../../core/packer";
|
import { Packer } from "../../../core/packer";
|
||||||
@@ -20,10 +20,7 @@ export class LinuxDEBPacker extends Packer {
|
|||||||
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 iconfile = `${this.config.meta.filename}${path.extname(this.config.meta.icon!)}`;
|
const iconfile = `${this.config.meta.filename}${path.extname(this.config.meta.icon!)}`;
|
||||||
const desktopTemplate = template(
|
const desktop = template.render("linux/app.desktop", Object.assign({ iconfile: iconfile }, this.config));
|
||||||
fs.readFileSync(path.resolve(import.meta.dirname, "..", "template/linux/app.desktop"), "utf8"),
|
|
||||||
);
|
|
||||||
const desktop = desktopTemplate(Object.assign({ iconfile: iconfile }, this.config));
|
|
||||||
fse.ensureDirSync(`${buildDir}/usr/share/applications`);
|
fse.ensureDirSync(`${buildDir}/usr/share/applications`);
|
||||||
fs.writeFileSync(`${buildDir}/usr/share/applications/${this.config.meta.filename}.desktop`, desktop);
|
fs.writeFileSync(`${buildDir}/usr/share/applications/${this.config.meta.filename}.desktop`, desktop);
|
||||||
fse.copySync(`${target}`, `${buildDir}/usr/share/${this.config.meta.filename}/`);
|
fse.copySync(`${target}`, `${buildDir}/usr/share/${this.config.meta.filename}/`);
|
||||||
|
|||||||
@@ -1,12 +1,12 @@
|
|||||||
import dateformat from "dateformat";
|
import dateformat from "dateformat";
|
||||||
import gulp from "gulp";
|
import gulp from "gulp";
|
||||||
import gulpClean from "gulp-clean";
|
import gulpClean from "gulp-clean";
|
||||||
import template from "lodash.template";
|
|
||||||
import os from "os";
|
import os from "os";
|
||||||
import type { Task } from "undertaker";
|
import type { Task } from "undertaker";
|
||||||
import { Builder, Project } from ".";
|
import { Builder, Project } from ".";
|
||||||
import { System } from "../common/system";
|
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 { Sdk } from "../core/sdk";
|
||||||
import { Platform } from "../core/type";
|
import { Platform } from "../core/type";
|
||||||
import { Haxe } from "../impl/haxe";
|
import { Haxe } from "../impl/haxe";
|
||||||
@@ -16,7 +16,7 @@ export interface PresetConfig {
|
|||||||
BuildDir?: string;
|
BuildDir?: string;
|
||||||
Develop?: boolean;
|
Develop?: boolean;
|
||||||
UseRuffle?: boolean;
|
UseRuffle?: boolean;
|
||||||
Key?: any;
|
Key?: SignKey;
|
||||||
}
|
}
|
||||||
|
|
||||||
export const DEFAULT_CONFIG: PresetConfig = {
|
export const DEFAULT_CONFIG: PresetConfig = {
|
||||||
@@ -44,9 +44,13 @@ export class Preset {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fillPreset(preset: ProjectPreset): ProjectPreset {
|
private fillPreset(preset: ProjectPreset): ProjectPreset {
|
||||||
const configTemplate = template(JSON.stringify(preset));
|
|
||||||
return JSON.parse(
|
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,
|
||||||
|
}),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+7
-4
@@ -1,10 +1,10 @@
|
|||||||
import colors from "ansi-colors";
|
import colors from "ansi-colors";
|
||||||
import cp from "child_process";
|
import cp from "child_process";
|
||||||
import { defaults, template } from "lodash";
|
|
||||||
import path from "path";
|
import path from "path";
|
||||||
import stream from "stream";
|
import stream from "stream";
|
||||||
import util from "util";
|
import util from "util";
|
||||||
import Vinyl from "vinyl";
|
import Vinyl from "vinyl";
|
||||||
|
import template from "../common/template";
|
||||||
|
|
||||||
export class Command {
|
export class Command {
|
||||||
private command: string;
|
private command: string;
|
||||||
@@ -14,12 +14,15 @@ export class Command {
|
|||||||
constructor(command: string, options?: any) {
|
constructor(command: string, options?: any) {
|
||||||
this.command = command;
|
this.command = command;
|
||||||
this.isWindows = process.platform.lastIndexOf("win") === 0;
|
this.isWindows = process.platform.lastIndexOf("win") === 0;
|
||||||
this.options = defaults(options || {}, {
|
this.options = Object.assign(
|
||||||
|
{
|
||||||
cwd: process.cwd(),
|
cwd: process.cwd(),
|
||||||
env: process.env,
|
env: process.env,
|
||||||
verbosity: options && options.silent ? 1 : 2,
|
verbosity: options && options.silent ? 1 : 2,
|
||||||
usePowerShell: false,
|
usePowerShell: false,
|
||||||
});
|
},
|
||||||
|
options || {},
|
||||||
|
);
|
||||||
|
|
||||||
let previousPath;
|
let previousPath;
|
||||||
previousPath = this.options.env.PATH;
|
previousPath = this.options.env.PATH;
|
||||||
@@ -69,7 +72,7 @@ export class Command {
|
|||||||
// execute the command.
|
// execute the command.
|
||||||
// we spawn the command in a subshell, so things like i/o redirection
|
// 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.
|
// 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,
|
file: stdin,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user