Compare commits
9
Commits
2.0.0
..
d079cbaac5
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d079cbaac5 | ||
|
|
b3d1aee9ed | ||
|
|
769127d6f0 | ||
|
|
57f7e88fab | ||
|
|
7f62df2364 | ||
|
|
6622d53167 | ||
|
|
561dd99cba | ||
|
|
bc77380aba | ||
|
|
a20e98d730 |
Generated
+88
-1327
File diff suppressed because it is too large
Load Diff
+3
-3
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "gulp-haxetool",
|
||||
"type": "module",
|
||||
"version": "2.0.0",
|
||||
"version": "2.0.3",
|
||||
"description": "HaXe Tool with Gulp",
|
||||
"exports": {
|
||||
"./bin/cli": "./dist/bin/cli.mjs",
|
||||
@@ -54,7 +54,7 @@
|
||||
"tar": "^7.5.22",
|
||||
"through2": "^5.0.12",
|
||||
"tmp-file": "^2.0.1",
|
||||
"unzip-stream": "^0.3.4",
|
||||
"unzipper": "^0.12.5",
|
||||
"vinyl": "^3.0.1",
|
||||
"vinyl-fs": "^4.0.2"
|
||||
},
|
||||
@@ -73,7 +73,7 @@
|
||||
"@types/tail": "^2.2.3",
|
||||
"@types/tar": "^7.0.87",
|
||||
"@types/through2": "^5.0.0",
|
||||
"@types/unzip-stream": "^0.3.4",
|
||||
"@types/unzipper": "^0.10.11",
|
||||
"eslint": "^10.13.0",
|
||||
"prettier": "^3.9.10",
|
||||
"tsdown": "0.22.14",
|
||||
|
||||
+1
-1
@@ -5,5 +5,5 @@ const __filename = fileURLToPath(import.meta.url);
|
||||
const __dirname = path.dirname(__filename);
|
||||
|
||||
export default (name: string): string => {
|
||||
return path.join(__dirname, "..", "assets", name);
|
||||
return path.join(__dirname, "assets", name);
|
||||
};
|
||||
|
||||
@@ -4,9 +4,9 @@ import fse from "fs-extra";
|
||||
import got, { type Progress, type Request } from "got";
|
||||
import path from "path";
|
||||
import ps from "promise-streams";
|
||||
import type { Stream, Writable } from "stream";
|
||||
import { type Stream, type Writable } from "stream";
|
||||
import { x as tarX } from "tar";
|
||||
import unzip from "unzip-stream";
|
||||
import unzipper from "unzipper";
|
||||
|
||||
export interface DownloadOptions {
|
||||
progress?: boolean;
|
||||
@@ -19,7 +19,7 @@ const DEFAULT_OPTIONS: DownloadOptions = { progress: true, strip: 1, executable:
|
||||
type Extractor = (stream: Request, dest: string, options: DownloadOptions) => Stream;
|
||||
|
||||
const ZIP_EXTRACTOR: Extractor = (stream: Request, dest: string, options: DownloadOptions): Stream => {
|
||||
return stream.pipe(unzip.Parse()).on("entry", (entry: any) => {
|
||||
return stream.pipe(unzipper.Parse()).on("entry", (entry: unzipper.Entry) => {
|
||||
const filePath = entry.path.split("/").slice(options.strip).join(path.sep);
|
||||
if (filePath.length > 0) {
|
||||
if (entry.type === "Directory") {
|
||||
@@ -94,7 +94,7 @@ const progressBar = new ProgressBar();
|
||||
export const download = async (url: string, dest: string, options?: DownloadOptions): Promise<void> => {
|
||||
options = { ...DEFAULT_OPTIONS, ...options };
|
||||
fse.ensureDirSync(dest);
|
||||
let stream: Request = got.stream(url);
|
||||
let stream: Request = got.stream(url, { decompress: false });
|
||||
if (options.progress) {
|
||||
stream = progressBar.handle(stream);
|
||||
}
|
||||
|
||||
@@ -7,7 +7,8 @@ const __dirname = path.dirname(__filename);
|
||||
|
||||
export default new Eta({
|
||||
autoFilter: true,
|
||||
escapeFunction: (val: unknown): string => String(val),
|
||||
filterFunction: (val: unknown): string => (val === null || val === undefined ? "" : String(val)),
|
||||
useWith: true,
|
||||
views: path.join(__dirname, "..", "template"),
|
||||
views: path.join(__dirname, "template"),
|
||||
});
|
||||
|
||||
+22
-12
@@ -78,26 +78,36 @@ export class Haxe extends Sdk {
|
||||
env.addPath(this.path, "LD_LIBRARY_PATH");
|
||||
}
|
||||
|
||||
prepare() {
|
||||
return Promise.all([this.neko.prepare(), super.prepare()]).then(() => {
|
||||
fs.copyFileSync(
|
||||
path.resolve(import.meta.dirname, "..", "template/haxe/activate"),
|
||||
path.resolve(this.path, "activate"),
|
||||
);
|
||||
});
|
||||
async replaceHaxelib(version: string): Promise<any> {
|
||||
const haxe = new Haxe(version);
|
||||
await haxe.prepare();
|
||||
fs.copyFileSync(haxe.haxelibBin, this.haxelibBin);
|
||||
}
|
||||
|
||||
get link(): string {
|
||||
async prepare(): Promise<any> {
|
||||
await Promise.all([this.neko.prepare(), super.prepare()]);
|
||||
fs.copyFileSync(path.resolve(import.meta.dirname, "template/haxe/activate"), path.resolve(this.path, "activate"));
|
||||
// TODO: old haxelib fail with EOF
|
||||
if (this.intVersion < 430) {
|
||||
await this.replaceHaxelib(Haxe.VERSION_4_3_7);
|
||||
}
|
||||
}
|
||||
|
||||
static buildLink(version: string): string {
|
||||
if (System.isWindows) {
|
||||
return `https://github.com/HaxeFoundation/haxe/releases/download/${this.version}/haxe-${this.version}-win.zip`;
|
||||
return `https://github.com/HaxeFoundation/haxe/releases/download/${version}/haxe-${version}-win.zip`;
|
||||
} else if (System.isLinux) {
|
||||
let arch = System.archInt;
|
||||
return `https://github.com/HaxeFoundation/haxe/releases/download/${this.version}/haxe-${this.version}-linux${arch}.tar.gz`;
|
||||
return `https://github.com/HaxeFoundation/haxe/releases/download/${version}/haxe-${version}-linux${arch}.tar.gz`;
|
||||
} else {
|
||||
throw `Unsupported os: ${System.os}`;
|
||||
}
|
||||
}
|
||||
|
||||
get link(): string {
|
||||
return Haxe.buildLink(this.version);
|
||||
}
|
||||
|
||||
haxe(args: any) {
|
||||
this.activate();
|
||||
return exec(".", [this.haxeBin].concat(args).join(" "));
|
||||
@@ -179,7 +189,7 @@ export class Haxe extends Sdk {
|
||||
args.push("-debug");
|
||||
}
|
||||
const target = path.resolve(buildDir, platform, "bin");
|
||||
if (platform !== "cpp") {
|
||||
if (platform !== Platform.CPP) {
|
||||
fse.emptyDirSync(target);
|
||||
}
|
||||
for (const asset of config.assets) {
|
||||
@@ -193,7 +203,7 @@ export class Haxe extends Sdk {
|
||||
)[platform] || "**/*";
|
||||
return this.haxe(args).then(() => {
|
||||
let r = vfs.src(`${target}/${result}`, { encoding: false });
|
||||
if (platform === "cpp") {
|
||||
if (platform === Platform.CPP) {
|
||||
r = r.pipe(rename(config.meta.filename!));
|
||||
}
|
||||
return r;
|
||||
|
||||
+1
-1
@@ -73,7 +73,7 @@ export class Neko extends Sdk {
|
||||
prepare() {
|
||||
return Promise.all([super.prepare()]).then(() => {
|
||||
fs.copyFileSync(
|
||||
path.resolve(import.meta.dirname, "..", "template/neko/activate"),
|
||||
path.resolve(import.meta.dirname, "template/neko/activate"),
|
||||
path.resolve(this.path, "activate"),
|
||||
);
|
||||
});
|
||||
|
||||
@@ -15,7 +15,7 @@ export class FlashHTMLPacker extends Packer {
|
||||
const target = this.targetPath;
|
||||
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"));
|
||||
fs.copyFileSync(path.resolve(import.meta.dirname, "template/flash/swf.js"), path.resolve(target, "swf.js"));
|
||||
return Promise.resolve();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,11 +1,16 @@
|
||||
<% sources.forEach(function(item) { %>
|
||||
-cp "<%=item%>"<% }); %>
|
||||
-cp "<%=item%>"
|
||||
<% }); %>
|
||||
<% libs.forEach(function(item) { %>
|
||||
-lib <%=item.name%>:<%=item.version.split('@').shift()%><% }); %>
|
||||
-lib <%=item.name%>:<%=item.version.split('@').shift()%>
|
||||
|
||||
<% }); %>
|
||||
<% macros.forEach(function(item) { %>
|
||||
--macro "<%=item%>"<% }); %>
|
||||
--macro "<%=item%>"
|
||||
<% }); %>
|
||||
<% flags.forEach(function(item) { %>
|
||||
-D <%=item%><% }); %>
|
||||
-D <%=item%>
|
||||
<% }); %>
|
||||
|
||||
-main <%=main%>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user