Compare commits
5
Commits
2.0.3
..
bb6d82d538
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
bb6d82d538 | ||
|
|
7615dbfc48 | ||
|
|
d079cbaac5 | ||
|
|
b3d1aee9ed | ||
|
|
769127d6f0 |
Generated
+88
-1327
File diff suppressed because it is too large
Load Diff
+3
-3
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"name": "gulp-haxetool",
|
"name": "gulp-haxetool",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"version": "2.0.3",
|
"version": "2.0.4",
|
||||||
"description": "HaXe Tool with Gulp",
|
"description": "HaXe Tool with Gulp",
|
||||||
"exports": {
|
"exports": {
|
||||||
"./bin/cli": "./dist/bin/cli.mjs",
|
"./bin/cli": "./dist/bin/cli.mjs",
|
||||||
@@ -54,7 +54,7 @@
|
|||||||
"tar": "^7.5.22",
|
"tar": "^7.5.22",
|
||||||
"through2": "^5.0.12",
|
"through2": "^5.0.12",
|
||||||
"tmp-file": "^2.0.1",
|
"tmp-file": "^2.0.1",
|
||||||
"unzip-stream": "^0.3.4",
|
"unzipper": "^0.12.5",
|
||||||
"vinyl": "^3.0.1",
|
"vinyl": "^3.0.1",
|
||||||
"vinyl-fs": "^4.0.2"
|
"vinyl-fs": "^4.0.2"
|
||||||
},
|
},
|
||||||
@@ -73,7 +73,7 @@
|
|||||||
"@types/tail": "^2.2.3",
|
"@types/tail": "^2.2.3",
|
||||||
"@types/tar": "^7.0.87",
|
"@types/tar": "^7.0.87",
|
||||||
"@types/through2": "^5.0.0",
|
"@types/through2": "^5.0.0",
|
||||||
"@types/unzip-stream": "^0.3.4",
|
"@types/unzipper": "^0.10.11",
|
||||||
"eslint": "^10.13.0",
|
"eslint": "^10.13.0",
|
||||||
"prettier": "^3.9.10",
|
"prettier": "^3.9.10",
|
||||||
"tsdown": "0.22.14",
|
"tsdown": "0.22.14",
|
||||||
|
|||||||
@@ -4,9 +4,9 @@ import fse from "fs-extra";
|
|||||||
import got, { type Progress, type Request } from "got";
|
import got, { type Progress, type Request } from "got";
|
||||||
import path from "path";
|
import path from "path";
|
||||||
import ps from "promise-streams";
|
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 { x as tarX } from "tar";
|
||||||
import unzip from "unzip-stream";
|
import unzipper from "unzipper";
|
||||||
|
|
||||||
export interface DownloadOptions {
|
export interface DownloadOptions {
|
||||||
progress?: boolean;
|
progress?: boolean;
|
||||||
@@ -19,7 +19,7 @@ const DEFAULT_OPTIONS: DownloadOptions = { progress: true, strip: 1, executable:
|
|||||||
type Extractor = (stream: Request, dest: string, options: DownloadOptions) => Stream;
|
type Extractor = (stream: Request, dest: string, options: DownloadOptions) => Stream;
|
||||||
|
|
||||||
const ZIP_EXTRACTOR: 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);
|
const filePath = entry.path.split("/").slice(options.strip).join(path.sep);
|
||||||
if (filePath.length > 0) {
|
if (filePath.length > 0) {
|
||||||
if (entry.type === "Directory") {
|
if (entry.type === "Directory") {
|
||||||
@@ -94,7 +94,7 @@ const progressBar = new ProgressBar();
|
|||||||
export const download = async (url: string, dest: string, options?: DownloadOptions): Promise<void> => {
|
export const download = async (url: string, dest: string, options?: DownloadOptions): Promise<void> => {
|
||||||
options = { ...DEFAULT_OPTIONS, ...options };
|
options = { ...DEFAULT_OPTIONS, ...options };
|
||||||
fse.ensureDirSync(dest);
|
fse.ensureDirSync(dest);
|
||||||
let stream: Request = got.stream(url);
|
let stream: Request = got.stream(url, { decompress: false });
|
||||||
if (options.progress) {
|
if (options.progress) {
|
||||||
stream = progressBar.handle(stream);
|
stream = progressBar.handle(stream);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,9 +5,12 @@ import { fileURLToPath } from "url";
|
|||||||
const __filename = fileURLToPath(import.meta.url);
|
const __filename = fileURLToPath(import.meta.url);
|
||||||
const __dirname = path.dirname(__filename);
|
const __dirname = path.dirname(__filename);
|
||||||
|
|
||||||
export default new Eta({
|
export const template = new Eta({
|
||||||
autoFilter: true,
|
autoFilter: true,
|
||||||
|
escapeFunction: (val: unknown): string => String(val),
|
||||||
filterFunction: (val: unknown): string => (val === null || val === undefined ? "" : String(val)),
|
filterFunction: (val: unknown): string => (val === null || val === undefined ? "" : String(val)),
|
||||||
useWith: true,
|
useWith: true,
|
||||||
views: path.join(__dirname, "template"),
|
views: path.join(__dirname, "template"),
|
||||||
});
|
});
|
||||||
|
|
||||||
|
export default template;
|
||||||
|
|||||||
@@ -0,0 +1,40 @@
|
|||||||
|
import os from "os";
|
||||||
|
import template from "../common/template";
|
||||||
|
|
||||||
|
export type Params = Record<string, any>;
|
||||||
|
|
||||||
|
export interface Link {
|
||||||
|
version?: string;
|
||||||
|
url: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export const DefaultParams: string[][] = [
|
||||||
|
["debug", "<%= false %>"],
|
||||||
|
["os_name", "<%= {Linux:'linux',Windows_NT:'win'}[os.type()] %>"],
|
||||||
|
["os_name_long", "<%= {linux:'linux',win:'windows'}[os_name] %>"],
|
||||||
|
["os_arch", "<%= {x64:'64',ia32:''}[os.arch()] %>"],
|
||||||
|
["os_archive_ext", "<%= {linux:'tar.gz',win:'zip'}[os_name] %>"],
|
||||||
|
];
|
||||||
|
|
||||||
|
export const resolveParams = (source: Params, custom?: Params): Params => {
|
||||||
|
const params: Params = { ...source, os, debug: false };
|
||||||
|
if (custom) {
|
||||||
|
for (const [k, v] of Object.entries(custom)) {
|
||||||
|
params[k] = template.renderString(v, params);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for (const [k, v] of DefaultParams) {
|
||||||
|
if (!Object.hasOwn(params, k)) {
|
||||||
|
params[k] = template.renderString(v, params);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return params;
|
||||||
|
};
|
||||||
|
|
||||||
|
export const resolveLink = (link: Link | string, params?: Params): string => {
|
||||||
|
if (typeof link === "string") {
|
||||||
|
return template.renderString(link, resolveParams({}, params));
|
||||||
|
} else {
|
||||||
|
return template.renderString(link.url, resolveParams(link, params));
|
||||||
|
}
|
||||||
|
};
|
||||||
+9
-3
@@ -2,10 +2,13 @@ import os from "os";
|
|||||||
import path from "path";
|
import path from "path";
|
||||||
import download from "../common/download";
|
import download from "../common/download";
|
||||||
import { Logger } from "../common/log";
|
import { Logger } from "../common/log";
|
||||||
|
import { resolveLink, type Link } from "./link";
|
||||||
|
|
||||||
export class Sdk {
|
export class Sdk {
|
||||||
static _dir: string;
|
static _dir: string;
|
||||||
|
|
||||||
|
url!: string;
|
||||||
|
|
||||||
static set dir(value) {
|
static set dir(value) {
|
||||||
Sdk._dir = value;
|
Sdk._dir = value;
|
||||||
}
|
}
|
||||||
@@ -45,8 +48,11 @@ export class Sdk {
|
|||||||
throw "Not implemented";
|
throw "Not implemented";
|
||||||
}
|
}
|
||||||
|
|
||||||
get link(): string {
|
get link(): string | Link {
|
||||||
throw "Not implemented";
|
return {
|
||||||
|
version: this.version,
|
||||||
|
url: this.url,
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
prepare(strip = 1): Promise<any> {
|
prepare(strip = 1): Promise<any> {
|
||||||
@@ -55,7 +61,7 @@ export class Sdk {
|
|||||||
return Promise.resolve();
|
return Promise.resolve();
|
||||||
} else {
|
} else {
|
||||||
this.log.i("download: *%s*", this.link);
|
this.log.i("download: *%s*", this.link);
|
||||||
return download(this.link, this.path, { strip });
|
return download(resolveLink(this.link, this), this.path, { strip });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+19
-24
@@ -2,31 +2,39 @@ import fs from "fs";
|
|||||||
import os from "os";
|
import os from "os";
|
||||||
import path from "path";
|
import path from "path";
|
||||||
import through from "through2";
|
import through from "through2";
|
||||||
import download from "../common/download";
|
|
||||||
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 { HandlerWriter } from "../common/tail";
|
import { HandlerWriter } from "../common/tail";
|
||||||
import { Sdk } from "../core/sdk";
|
import { Sdk } from "../core/sdk";
|
||||||
import { Command } from "../run/command";
|
import { Command } from "../run/command";
|
||||||
|
|
||||||
|
export class AndroidNdk extends Sdk {
|
||||||
|
static ID = "android-ndk";
|
||||||
|
|
||||||
|
static VERSION_R15C = "r15c";
|
||||||
|
static VERSION_R21E = "r21e";
|
||||||
|
static VERSION = AndroidNdk.VERSION_R21E;
|
||||||
|
|
||||||
|
url = "https://dl.google.com/android/repository/android-ndk-<%= version %>-<%= os_name_long %>-x86_64.zip";
|
||||||
|
|
||||||
|
constructor(version?: string) {
|
||||||
|
super(AndroidNdk.ID, version || AndroidNdk.VERSION);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
export class Android extends Sdk {
|
export class Android extends Sdk {
|
||||||
static ID = "android";
|
static ID = "android";
|
||||||
|
|
||||||
static VERSION_7302050 = "7302050";
|
static VERSION_7302050 = "7302050";
|
||||||
static VERSION = Android.VERSION_7302050;
|
static VERSION = Android.VERSION_7302050;
|
||||||
|
|
||||||
static NDK_VERSION_R15C = "r15c";
|
private ndk: AndroidNdk;
|
||||||
static NDK_VERSION_R21E = "r21e";
|
|
||||||
static NDK_VERSION = Android.NDK_VERSION_R21E;
|
|
||||||
|
|
||||||
private ndk_version: string;
|
url = "https://dl.google.com/android/repository/commandlinetools-<%= os_name %>-<%= version %>_latest.zip";
|
||||||
private repository: string;
|
|
||||||
|
|
||||||
constructor(version?: string, ndkVersion?: string) {
|
constructor(version?: string, ndkVersion?: string) {
|
||||||
super(Android.ID, version || Android.VERSION);
|
super(Android.ID, version || Android.VERSION);
|
||||||
this.ndk_version = ndkVersion || Android.NDK_VERSION;
|
this.ndk = new AndroidNdk(ndkVersion);
|
||||||
this.repository = "https://dl.google.com/android/repository";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
get prepared(): boolean {
|
get prepared(): boolean {
|
||||||
@@ -37,16 +45,12 @@ export class Android extends Sdk {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
get link(): string {
|
|
||||||
return `${this.repository}/commandlinetools-${System.os}-${this.version}_latest.zip`;
|
|
||||||
}
|
|
||||||
|
|
||||||
get android_home(): string {
|
get android_home(): string {
|
||||||
return this.path;
|
return this.path;
|
||||||
}
|
}
|
||||||
|
|
||||||
get ndk_home(): string {
|
get ndk_home(): string {
|
||||||
return Sdk.path('android-ndk', this.ndk_version);
|
return this.ndk.path;
|
||||||
}
|
}
|
||||||
|
|
||||||
get sdkmanager_bin(): string {
|
get sdkmanager_bin(): string {
|
||||||
@@ -56,19 +60,10 @@ export class Android extends Sdk {
|
|||||||
prepare(): Promise<any> {
|
prepare(): Promise<any> {
|
||||||
const result = [];
|
const result = [];
|
||||||
result.push(super.prepare(0));
|
result.push(super.prepare(0));
|
||||||
if (!fs.existsSync(path.join(this.ndk_home))) {
|
result.push(this.ndk.prepare());
|
||||||
result.push(this.prepare_ndk());
|
|
||||||
}
|
|
||||||
return Promise.all(result);
|
return Promise.all(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
prepare_ndk(): Promise<any> {
|
|
||||||
// TODO: support windows
|
|
||||||
const url = `${this.repository}/android-ndk-${this.ndk_version}-${System.os}-x86_64.zip`;
|
|
||||||
this.log.d("download: *%s*", url);
|
|
||||||
return download(url, this.ndk_home, { executable: true });
|
|
||||||
}
|
|
||||||
|
|
||||||
sdkmanager(packages: string[]) {
|
sdkmanager(packages: string[]) {
|
||||||
this.log.i("sdkmanager: *%s*", packages.join(", "));
|
this.log.i("sdkmanager: *%s*", packages.join(", "));
|
||||||
const installedFile = path.join(this.path, ".installed");
|
const installedFile = path.join(this.path, ".installed");
|
||||||
|
|||||||
+5
-14
@@ -2,7 +2,6 @@ import fs from "fs";
|
|||||||
import fse from "fs-extra";
|
import fse from "fs-extra";
|
||||||
import os from "os";
|
import os from "os";
|
||||||
import path from "path";
|
import path from "path";
|
||||||
import env from "../common/env";
|
|
||||||
import { System } from "../common/system";
|
import { System } from "../common/system";
|
||||||
import { watch } from "../common/watch";
|
import { watch } from "../common/watch";
|
||||||
import { Sdk } from "../core/sdk";
|
import { Sdk } from "../core/sdk";
|
||||||
@@ -26,12 +25,15 @@ export class FlashPlayer extends Sdk {
|
|||||||
BASE_URL = "https://fpdownload.macromedia.com/pub/flashplayer/updaters";
|
BASE_URL = "https://fpdownload.macromedia.com/pub/flashplayer/updaters";
|
||||||
|
|
||||||
private debug: boolean;
|
private debug: boolean;
|
||||||
protected baseUrl: string;
|
|
||||||
|
url =
|
||||||
|
"https://fpdownload.macromedia.com/pub/flashplayer/updaters/" +
|
||||||
|
"<%= version %>/" +
|
||||||
|
"<%= {linux:'flash_player_sa_linux' + (debug ? '_debug' : '') +'.x86_64.tar.gz','win':'flashplayer_'+version+'_sa'+(debug ? '_debug' : '')+'.exe'}[os_name] %>";
|
||||||
|
|
||||||
constructor(debug: boolean = false, version?: string, playerId = FlashPlayer.ID) {
|
constructor(debug: boolean = false, version?: string, playerId = FlashPlayer.ID) {
|
||||||
super(playerId, version || FlashPlayer.VERSION);
|
super(playerId, version || FlashPlayer.VERSION);
|
||||||
this.debug = debug;
|
this.debug = debug;
|
||||||
this.baseUrl = env.get("FLASHPLAYER_URL") || this.BASE_URL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
prepare() {
|
prepare() {
|
||||||
@@ -46,17 +48,6 @@ export class FlashPlayer extends Sdk {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
get link(): string {
|
|
||||||
const baseUrl = `${this.baseUrl}/${this.version}`;
|
|
||||||
if (System.isWindows) {
|
|
||||||
return baseUrl + `/flashplayer_${this.version}_sa${this.debug ? "_debug" : ""}.exe`;
|
|
||||||
} else if (System.isLinux) {
|
|
||||||
return baseUrl + `/flash_player_sa_linux${this.debug ? "_debug" : ""}.x86_64.tar.gz`;
|
|
||||||
} else {
|
|
||||||
throw `Unsupported os '${os.type()}'`;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
get flashPlayerBin(): string {
|
get flashPlayerBin(): string {
|
||||||
if (System.isWindows) {
|
if (System.isWindows) {
|
||||||
const playerName = `flashplayer_${this.version}_sa${this.debug ? "_debug" : ""}.exe`;
|
const playerName = `flashplayer_${this.version}_sa${this.debug ? "_debug" : ""}.exe`;
|
||||||
|
|||||||
+17
-17
@@ -33,6 +33,11 @@ export class Haxe extends Sdk {
|
|||||||
|
|
||||||
static buildDir = path.join(process.cwd(), "build");
|
static buildDir = path.join(process.cwd(), "build");
|
||||||
|
|
||||||
|
url =
|
||||||
|
"https://github.com/HaxeFoundation/haxe/releases/download/" +
|
||||||
|
"<%= version %>/" +
|
||||||
|
"haxe-<%= version %>-<%= os_name %><%= os_arch %>.<%= os_archive_ext %>";
|
||||||
|
|
||||||
getBin(name: string) {
|
getBin(name: string) {
|
||||||
if (System.isWindows) {
|
if (System.isWindows) {
|
||||||
return path.join(this.path, name + ".exe");
|
return path.join(this.path, name + ".exe");
|
||||||
@@ -78,23 +83,18 @@ export class Haxe extends Sdk {
|
|||||||
env.addPath(this.path, "LD_LIBRARY_PATH");
|
env.addPath(this.path, "LD_LIBRARY_PATH");
|
||||||
}
|
}
|
||||||
|
|
||||||
prepare() {
|
async replaceHaxelib(version: string): Promise<any> {
|
||||||
return Promise.all([this.neko.prepare(), super.prepare()]).then(() => {
|
const haxe = new Haxe(version);
|
||||||
fs.copyFileSync(
|
await haxe.prepare();
|
||||||
path.resolve(import.meta.dirname, "template/haxe/activate"),
|
fs.copyFileSync(haxe.haxelibBin, this.haxelibBin);
|
||||||
path.resolve(this.path, "activate"),
|
|
||||||
);
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
get link(): string {
|
async prepare(): Promise<any> {
|
||||||
if (System.isWindows) {
|
await Promise.all([this.neko.prepare(), super.prepare()]);
|
||||||
return `https://github.com/HaxeFoundation/haxe/releases/download/${this.version}/haxe-${this.version}-win.zip`;
|
fs.copyFileSync(path.resolve(import.meta.dirname, "template/haxe/activate"), path.resolve(this.path, "activate"));
|
||||||
} else if (System.isLinux) {
|
// TODO: old haxelib fail with EOF
|
||||||
let arch = System.archInt;
|
if (this.intVersion < 430) {
|
||||||
return `https://github.com/HaxeFoundation/haxe/releases/download/${this.version}/haxe-${this.version}-linux${arch}.tar.gz`;
|
await this.replaceHaxelib(Haxe.VERSION_4_3_7);
|
||||||
} else {
|
|
||||||
throw `Unsupported os: ${System.os}`;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -179,7 +179,7 @@ export class Haxe extends Sdk {
|
|||||||
args.push("-debug");
|
args.push("-debug");
|
||||||
}
|
}
|
||||||
const target = path.resolve(buildDir, platform, "bin");
|
const target = path.resolve(buildDir, platform, "bin");
|
||||||
if (platform !== "cpp") {
|
if (platform !== Platform.CPP) {
|
||||||
fse.emptyDirSync(target);
|
fse.emptyDirSync(target);
|
||||||
}
|
}
|
||||||
for (const asset of config.assets) {
|
for (const asset of config.assets) {
|
||||||
@@ -193,7 +193,7 @@ export class Haxe extends Sdk {
|
|||||||
)[platform] || "**/*";
|
)[platform] || "**/*";
|
||||||
return this.haxe(args).then(() => {
|
return this.haxe(args).then(() => {
|
||||||
let r = vfs.src(`${target}/${result}`, { encoding: false });
|
let r = vfs.src(`${target}/${result}`, { encoding: false });
|
||||||
if (platform === "cpp") {
|
if (platform === Platform.CPP) {
|
||||||
r = r.pipe(rename(config.meta.filename!));
|
r = r.pipe(rename(config.meta.filename!));
|
||||||
}
|
}
|
||||||
return r;
|
return r;
|
||||||
|
|||||||
+6
-43
@@ -5,41 +5,6 @@ import env from "../common/env";
|
|||||||
import { Sdk } from "../core/sdk";
|
import { Sdk } from "../core/sdk";
|
||||||
import run from "../run/index";
|
import run from "../run/index";
|
||||||
|
|
||||||
export class NekoLink {
|
|
||||||
static get type() {
|
|
||||||
switch (os.type()) {
|
|
||||||
case "Linux":
|
|
||||||
return "linux";
|
|
||||||
case "Windows_NT":
|
|
||||||
return "win";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static get arch() {
|
|
||||||
switch (os.arch()) {
|
|
||||||
case "ia32":
|
|
||||||
return "";
|
|
||||||
case "x64":
|
|
||||||
return "64";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static get ext() {
|
|
||||||
switch (os.type()) {
|
|
||||||
case "Linux":
|
|
||||||
return "tar.gz";
|
|
||||||
case "Windows_NT":
|
|
||||||
return "zip";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static get(version: string) {
|
|
||||||
const vv = version.split("\.").join("-");
|
|
||||||
const filename = `neko-${version}-${NekoLink.type}${NekoLink.arch}.${NekoLink.ext}`;
|
|
||||||
return `https://github.com/HaxeFoundation/neko/releases/download/v${vv}/${filename}`;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
export class Neko extends Sdk {
|
export class Neko extends Sdk {
|
||||||
static ID = "neko";
|
static ID = "neko";
|
||||||
|
|
||||||
@@ -48,14 +13,15 @@ export class Neko extends Sdk {
|
|||||||
static VERSION_2_4_1 = "2.4.1";
|
static VERSION_2_4_1 = "2.4.1";
|
||||||
static VERSION = Neko.VERSION_2_4_1;
|
static VERSION = Neko.VERSION_2_4_1;
|
||||||
|
|
||||||
|
url =
|
||||||
|
"https://github.com/HaxeFoundation/neko/releases/download/" +
|
||||||
|
"v<%= version.split('.').join('-') %>/" +
|
||||||
|
"neko-<%= version %>-<%= os_name %><%= os_arch %>.<%= os_archive_ext %>";
|
||||||
|
|
||||||
constructor(version?: string) {
|
constructor(version?: string) {
|
||||||
super(Neko.ID, version || Neko.VERSION);
|
super(Neko.ID, version || Neko.VERSION);
|
||||||
}
|
}
|
||||||
|
|
||||||
get link() {
|
|
||||||
return NekoLink.get(this.version);
|
|
||||||
}
|
|
||||||
|
|
||||||
get prepared() {
|
get prepared() {
|
||||||
try {
|
try {
|
||||||
return fs.existsSync(this.nekoBin);
|
return fs.existsSync(this.nekoBin);
|
||||||
@@ -72,10 +38,7 @@ export class Neko extends Sdk {
|
|||||||
|
|
||||||
prepare() {
|
prepare() {
|
||||||
return Promise.all([super.prepare()]).then(() => {
|
return Promise.all([super.prepare()]).then(() => {
|
||||||
fs.copyFileSync(
|
fs.copyFileSync(path.resolve(import.meta.dirname, "template/neko/activate"), path.resolve(this.path, "activate"));
|
||||||
path.resolve(import.meta.dirname, "template/neko/activate"),
|
|
||||||
path.resolve(this.path, "activate"),
|
|
||||||
);
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+4
-17
@@ -1,6 +1,5 @@
|
|||||||
import os from "os";
|
import os from "os";
|
||||||
import path from "path";
|
import path from "path";
|
||||||
import env from "../common/env";
|
|
||||||
import { System } from "../common/system";
|
import { System } from "../common/system";
|
||||||
import { watch } from "../common/watch";
|
import { watch } from "../common/watch";
|
||||||
import run from "../run";
|
import run from "../run";
|
||||||
@@ -9,30 +8,18 @@ import { FlashPlayer } from "./flashplayer";
|
|||||||
export class RufflePlayer extends FlashPlayer {
|
export class RufflePlayer extends FlashPlayer {
|
||||||
static ID = "ruffle";
|
static ID = "ruffle";
|
||||||
|
|
||||||
static VERSION_2026_05_15 = "nightly-2026_05_15";
|
|
||||||
static VERSION_2026_10_13 = "nightly-2026_10_13";
|
|
||||||
static VERSION_0_5_0 = "0.5.0";
|
static VERSION_0_5_0 = "0.5.0";
|
||||||
static VERSION_0_6_0 = "0.6.0";
|
static VERSION_0_6_0 = "0.6.0";
|
||||||
static VERSION_0_7_1 = "0.7.1";
|
static VERSION_0_7_1 = "0.7.1";
|
||||||
static VERSION = RufflePlayer.VERSION_0_7_1;
|
static VERSION = RufflePlayer.VERSION_0_7_1;
|
||||||
|
|
||||||
BASE_URL = "https://github.com/ruffle-rs/ruffle/releases/download";
|
url =
|
||||||
|
"https://github.com/ruffle-rs/ruffle/releases/download/" +
|
||||||
|
"v<%= version %>/" +
|
||||||
|
"ruffle-<%= version %>-<%= os_name_long %>-x86_64.<%= os_archive_ext %>";
|
||||||
|
|
||||||
constructor(debug: boolean, version: string) {
|
constructor(debug: boolean, version: string) {
|
||||||
super(debug, version || RufflePlayer.VERSION, RufflePlayer.ID);
|
super(debug, version || RufflePlayer.VERSION, RufflePlayer.ID);
|
||||||
this.baseUrl = env.get("RUFFLE_URL") || this.BASE_URL;
|
|
||||||
}
|
|
||||||
|
|
||||||
get link(): string {
|
|
||||||
const nightly = this.version.includes("nightly");
|
|
||||||
const baseUrl = `${this.baseUrl}/${nightly ? "" : "v"}${this.version.replaceAll("_", "-")}`;
|
|
||||||
if (System.isWindows) {
|
|
||||||
return baseUrl + `/ruffle-${this.version}-windows-x86_64.zip`;
|
|
||||||
} else if (System.isLinux) {
|
|
||||||
return baseUrl + `/ruffle-${this.version}-linux-x86_64.tar.gz`;
|
|
||||||
} else {
|
|
||||||
throw `Unsupported os '${os.type()}'`;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
get flashPlayerBin(): string {
|
get flashPlayerBin(): string {
|
||||||
|
|||||||
@@ -2,7 +2,9 @@ export * from "./common/download";
|
|||||||
export * from "./common/log";
|
export * from "./common/log";
|
||||||
export * from "./common/output";
|
export * from "./common/output";
|
||||||
export * from "./common/system";
|
export * from "./common/system";
|
||||||
|
export * from "./common/template";
|
||||||
export * from "./core/config";
|
export * from "./core/config";
|
||||||
|
export * from "./core/link";
|
||||||
export * from "./core/sdk";
|
export * from "./core/sdk";
|
||||||
export * from "./core/type";
|
export * from "./core/type";
|
||||||
export * from "./impl/android";
|
export * from "./impl/android";
|
||||||
|
|||||||
@@ -1,11 +1,16 @@
|
|||||||
<% sources.forEach(function(item) { %>
|
<% sources.forEach(function(item) { %>
|
||||||
-cp "<%=item%>"<% }); %>
|
-cp "<%=item%>"
|
||||||
|
<% }); %>
|
||||||
<% libs.forEach(function(item) { %>
|
<% libs.forEach(function(item) { %>
|
||||||
-lib <%=item.name%>:<%=item.version.split('@').shift()%><% }); %>
|
-lib <%=item.name%>:<%=item.version.split('@').shift()%>
|
||||||
|
|
||||||
|
<% }); %>
|
||||||
<% macros.forEach(function(item) { %>
|
<% macros.forEach(function(item) { %>
|
||||||
--macro "<%=item%>"<% }); %>
|
--macro "<%=item%>"
|
||||||
|
<% }); %>
|
||||||
<% flags.forEach(function(item) { %>
|
<% flags.forEach(function(item) { %>
|
||||||
-D <%=item%><% }); %>
|
-D <%=item%>
|
||||||
|
<% }); %>
|
||||||
|
|
||||||
-main <%=main%>
|
-main <%=main%>
|
||||||
|
|
||||||
|
|||||||
+9
-13
@@ -5,18 +5,14 @@ import { join } from "node:path";
|
|||||||
import test from "node:test";
|
import test from "node:test";
|
||||||
import { download } from "../dist/lib/index.mjs";
|
import { download } from "../dist/lib/index.mjs";
|
||||||
|
|
||||||
const resolveTargetDir = () => mkdtempSync(join(tmpdir(), "test-"));
|
const testUrl = async (url, file) => {
|
||||||
|
const target = mkdtempSync(join(tmpdir(), "test-"));
|
||||||
const TEST_DATA = {
|
await download(url, target);
|
||||||
"https://home.shmyga.ru/public/sdk/haxe/haxe-4.2.5-win.zip": "haxe.exe",
|
assert(existsSync(join(target, file)));
|
||||||
"https://home.shmyga.ru/public/sdk/haxe/haxe-4.2.5-linux64.tar.gz": "haxe",
|
|
||||||
"https://home.shmyga.ru/public/test.txt": "test.txt",
|
|
||||||
};
|
};
|
||||||
|
|
||||||
for (const [url, file] of Object.entries(TEST_DATA)) {
|
test("zip", async () => await testUrl("https://home.shmyga.ru/public/sdk/haxe/haxe-4.2.5-win.zip", "haxe.exe"));
|
||||||
test(`Test download: ${url}`, async () => {
|
|
||||||
const target = resolveTargetDir();
|
test("tar.gz", async () => await testUrl("https://home.shmyga.ru/public/sdk/haxe/haxe-4.2.5-linux64.tar.gz", "haxe"));
|
||||||
await download(url, target);
|
|
||||||
assert(existsSync(join(target, file)));
|
test("plain", async () => await testUrl("https://home.shmyga.ru/public/test.txt", "test.txt"));
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -0,0 +1,55 @@
|
|||||||
|
import assert from "node:assert/strict";
|
||||||
|
import test from "node:test";
|
||||||
|
import { Android, AndroidNdk, FlashPlayer, Haxe, Neko, resolveLink, RufflePlayer } from "../dist/lib/index.mjs";
|
||||||
|
|
||||||
|
const testLink = (link, args) => {
|
||||||
|
for (const [params, targetUrl] of args) {
|
||||||
|
const url = resolveLink(link, params);
|
||||||
|
assert.equal(url, targetUrl);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
test("neko", () =>
|
||||||
|
testLink(new Neko().link, [
|
||||||
|
[{ os_name: "linux" }, "https://github.com/HaxeFoundation/neko/releases/download/v2-4-1/neko-2.4.1-linux64.tar.gz"],
|
||||||
|
[{ os_name: "win" }, "https://github.com/HaxeFoundation/neko/releases/download/v2-4-1/neko-2.4.1-win64.zip"],
|
||||||
|
]));
|
||||||
|
|
||||||
|
test("haxe", () =>
|
||||||
|
testLink(new Haxe().link, [
|
||||||
|
[{ os_name: "linux" }, "https://github.com/HaxeFoundation/haxe/releases/download/4.2.5/haxe-4.2.5-linux64.tar.gz"],
|
||||||
|
[{ os_name: "win" }, "https://github.com/HaxeFoundation/haxe/releases/download/4.2.5/haxe-4.2.5-win64.zip"],
|
||||||
|
]));
|
||||||
|
|
||||||
|
test("flashplayer", () =>
|
||||||
|
testLink(new FlashPlayer().link, [
|
||||||
|
[
|
||||||
|
{ os_name: "linux" },
|
||||||
|
"https://fpdownload.macromedia.com/pub/flashplayer/updaters/32/flash_player_sa_linux.x86_64.tar.gz",
|
||||||
|
],
|
||||||
|
[{ os_name: "win" }, "https://fpdownload.macromedia.com/pub/flashplayer/updaters/32/flashplayer_32_sa.exe"],
|
||||||
|
]));
|
||||||
|
|
||||||
|
test("ruffle", () =>
|
||||||
|
testLink(new RufflePlayer().link, [
|
||||||
|
[
|
||||||
|
{ os_name: "linux" },
|
||||||
|
"https://github.com/ruffle-rs/ruffle/releases/download/v0.7.1/ruffle-0.7.1-linux-x86_64.tar.gz",
|
||||||
|
],
|
||||||
|
[
|
||||||
|
{ os_name: "win" },
|
||||||
|
"https://github.com/ruffle-rs/ruffle/releases/download/v0.7.1/ruffle-0.7.1-windows-x86_64.zip",
|
||||||
|
],
|
||||||
|
]));
|
||||||
|
|
||||||
|
test("android", () =>
|
||||||
|
testLink(new Android().link, [
|
||||||
|
[{ os_name: "linux" }, "https://dl.google.com/android/repository/commandlinetools-linux-7302050_latest.zip"],
|
||||||
|
[{ os_name: "win" }, "https://dl.google.com/android/repository/commandlinetools-win-7302050_latest.zip"],
|
||||||
|
]));
|
||||||
|
|
||||||
|
test("android-ndk", () =>
|
||||||
|
testLink(new AndroidNdk().link, [
|
||||||
|
[{ os_name: "linux" }, "https://dl.google.com/android/repository/android-ndk-r21e-linux-x86_64.zip"],
|
||||||
|
[{ os_name: "win" }, "https://dl.google.com/android/repository/android-ndk-r21e-windows-x86_64.zip"],
|
||||||
|
]));
|
||||||
Reference in New Issue
Block a user