refactor: fix typescript errors

This commit is contained in:
2026-10-22 23:18:06 +03:00
parent 84d905dbb3
commit a25f223b61
16 changed files with 739 additions and 392 deletions
+665 -369
View File
File diff suppressed because it is too large Load Diff
+6 -3
View File
@@ -42,9 +42,8 @@
"gulp-debian": "^0.1.9", "gulp-debian": "^0.1.9",
"gulp-gzip": "^1.4.2", "gulp-gzip": "^1.4.2",
"gulp-rename": "^2.1.0", "gulp-rename": "^2.1.0",
"gulp-spawn": "^0.4.0", "gulp-tar": "^5.0.0",
"gulp-tar": "^3.0.0", "gulp-zip": "^6.1.0",
"gulp-zip": "^5.0.0",
"lodash.defaults": "^4.2.0", "lodash.defaults": "^4.2.0",
"lodash.template": "^4.4.0", "lodash.template": "^4.4.0",
"plugin-error": "^1.0.1", "plugin-error": "^1.0.1",
@@ -60,10 +59,14 @@
"devDependencies": { "devDependencies": {
"@types/async": "^3.2.26", "@types/async": "^3.2.26",
"@types/cli-progress": "^3.11.6", "@types/cli-progress": "^3.11.6",
"@types/dateformat": "^5.0.3",
"@types/fs-extra": "^11.0.4", "@types/fs-extra": "^11.0.4",
"@types/gulp": "^4.0.18", "@types/gulp": "^4.0.18",
"@types/gulp-connect": "^5.0.10", "@types/gulp-connect": "^5.0.10",
"@types/gulp-gzip": "^0.0.36",
"@types/gulp-rename": "^2.0.7", "@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/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",
+9
View File
@@ -0,0 +1,9 @@
declare module "gulp-clean" {
import type { WritableStream } from "stream";
export interface Options {
force?: boolean;
}
export default (options?: Options) => WritableStream;
}
+32
View File
@@ -0,0 +1,32 @@
declare module "gulp-debian" {
import type { WritableStream } from "stream";
export interface Options {
package: string;
version: string;
section: string;
priority: string;
architecture: string;
maintainer?: string;
description?: string;
preinst?: string[];
postinst?: string[];
prerm?: string[];
postrm?: string[];
conffiles?: string;
changelog?: {
version: string;
distribution: string;
urgency: string;
date: Date;
changes: string[];
}[];
_target?: string;
_out?: string;
_copyright?: string;
_clean?: boolean;
_verbose?: boolean;
}
export default (options: Options) => WritableStream;
}
View File
@@ -4,7 +4,7 @@ import fse from "fs-extra";
import got from "got"; import got from "got";
import path from "path"; import path from "path";
import ps from "promise-streams"; import ps from "promise-streams";
import type Stream from "stream"; import type { Stream, Writable } from "stream";
import * as tar from "tar"; import * as tar from "tar";
import unzip from "unzip-stream"; import unzip from "unzip-stream";
@@ -75,7 +75,7 @@ export class Downloader {
} }
}); });
} else if (url.endsWith("tar.gz")) { } else if (url.endsWith("tar.gz")) {
stream = stream.pipe(tar.x({ C: dest, strip })); stream = stream.pipe(tar.x({ C: dest, strip }) as unknown as Writable);
} else { } else {
stream = stream.pipe(fs.createWriteStream(path.join(dest, url.split("/").pop()!))); stream = stream.pipe(fs.createWriteStream(path.join(dest, url.split("/").pop()!)));
} }
+1 -1
View File
@@ -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 { Log } from "../common/log"; import { Log } from "../common/log";
import { Downloader } from "./download";
export class Sdk { export class Sdk {
static _dir: string; static _dir: string;
+1
View File
@@ -1,3 +1,4 @@
// @ts-nocheck
import fs from "fs"; import fs from "fs";
import gulp from "gulp"; import gulp from "gulp";
import through from "through2"; import through from "through2";
+1 -1
View File
@@ -2,11 +2,11 @@ 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 { Downloader } 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 { System } from "../common/system";
import { HandlerWriter } from "../common/tail"; import { HandlerWriter } from "../common/tail";
import { Downloader } from "../core/download";
import { Sdk } from "../core/sdk"; import { Sdk } from "../core/sdk";
import { Command } from "../run/command"; import { Command } from "../run/command";
+3 -4
View File
@@ -59,7 +59,6 @@ export class FlashPlayer extends Sdk {
get flashPlayerBin(): string { get flashPlayerBin(): string {
if (System.isWindows) { if (System.isWindows) {
const v = this.version.split(".");
const playerName = `flashplayer_${this.version}_sa${this.debug ? "_debug" : ""}.exe`; const playerName = `flashplayer_${this.version}_sa${this.debug ? "_debug" : ""}.exe`;
return path.join(this.path, playerName); return path.join(this.path, playerName);
} else if (System.isLinux) { } else if (System.isLinux) {
@@ -73,7 +72,7 @@ export class FlashPlayer extends Sdk {
static get flashPlayerDir(): string { static get flashPlayerDir(): string {
if (os.type() === "Windows_NT") { if (os.type() === "Windows_NT") {
return path.join(process.env.APPDATA, "Macromedia", "Flash Player"); return path.join(process.env.APPDATA!, "Macromedia", "Flash Player");
} else if (os.type() === "Linux") { } else if (os.type() === "Linux") {
return path.join(os.homedir(), ".macromedia", "Flash_Player"); return path.join(os.homedir(), ".macromedia", "Flash_Player");
} else { } else {
@@ -89,7 +88,7 @@ export class FlashPlayer extends Sdk {
const filename = path.join(os.homedir(), "mm.cfg"); const filename = path.join(os.homedir(), "mm.cfg");
const value = "TraceOutputFileEnable=1"; const value = "TraceOutputFileEnable=1";
if (fs.existsSync(filename)) { if (fs.existsSync(filename)) {
const data = fs.readFileSync(filename); const data = fs.readFileSync(filename, "utf8");
if (data.indexOf(value) === -1) { if (data.indexOf(value) === -1) {
fs.appendFileSync(filename, `${value}\n`); fs.appendFileSync(filename, `${value}\n`);
} }
@@ -103,7 +102,7 @@ export class FlashPlayer extends Sdk {
static trust(value: string) { static trust(value: string) {
const filename = path.join(this.flashPlayerDir, "#Security", "FlashPlayerTrust", "gulp.cfg"); const filename = path.join(this.flashPlayerDir, "#Security", "FlashPlayerTrust", "gulp.cfg");
if (fs.existsSync(filename)) { if (fs.existsSync(filename)) {
const data = fs.readFileSync(filename); const data = fs.readFileSync(filename, "utf8");
if (data.indexOf(value) === -1) { if (data.indexOf(value) === -1) {
fs.appendFileSync(filename, `${value}\n`); fs.appendFileSync(filename, `${value}\n`);
} }
+7 -3
View File
@@ -115,7 +115,9 @@ 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.xml"))); const projectTemplate = template(
fs.readFileSync(path.resolve(import.meta.dirname, "..", "template/project.xml"), "utf8"),
);
const project = projectTemplate({ ...config, buildDir: buildDir }); const project = projectTemplate({ ...config, buildDir: buildDir });
fs.writeFileSync(path.resolve(buildDir, "project.xml"), project); fs.writeFileSync(path.resolve(buildDir, "project.xml"), project);
@@ -145,7 +147,9 @@ 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"))); const projectTemplate = template(
fs.readFileSync(path.resolve(import.meta.dirname, "..", "template/project.hxml"), "utf8"),
);
const ext = const ext =
{ {
@@ -180,7 +184,7 @@ export class Haxe extends Sdk {
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 === "cpp") {
r = r.pipe(rename(config.meta.filename)); r = r.pipe(rename(config.meta.filename!));
} }
return r; return r;
}); });
+3 -1
View File
@@ -43,7 +43,9 @@ 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(fs.readFileSync(path.resolve(import.meta.dirname, "..", "template/windows/app.iss"), "utf8")); 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 = appTemplate({ ...config, buildDir: buildDir, output: output });
fse.ensureDirSync(buildDir); fse.ensureDirSync(buildDir);
+1 -1
View File
@@ -1,6 +1,6 @@
export * from "./common/system"; export * from "./common/system";
export * from "./core/config"; export * from "./core/config";
export * from "./core/download"; export * from "./common/download";
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 -1
View File
@@ -15,7 +15,7 @@ export class FlashHTMLPacker extends Packer {
call() { call() {
const target = this.targetPath; const target = this.targetPath;
const indexTemplate = template( const indexTemplate = template(
fs.readFileSync(path.resolve(import.meta.dirname, "..", "template/flash/index.html")), fs.readFileSync(path.resolve(import.meta.dirname, "..", "template/flash/index.html"), "utf8"),
); );
const index = indexTemplate(this.config); const index = indexTemplate(this.config);
fs.writeFileSync(path.resolve(target, "index.html"), index); fs.writeFileSync(path.resolve(target, "index.html"), index);
+4 -4
View File
@@ -2,7 +2,7 @@ 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.template"; import { template } from "lodash";
import os from "os"; import os from "os";
import path from "path"; import path from "path";
import { Config } from "../../../../core/config"; import { Config } from "../../../../core/config";
@@ -21,7 +21,7 @@ export class LinuxDEBPacker extends Packer {
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 desktopTemplate = template(
fs.readFileSync(path.resolve(import.meta.dirname, "..", "template/linux/app.desktop")), fs.readFileSync(path.resolve(import.meta.dirname, "..", "template/linux/app.desktop"), "utf8"),
); );
const desktop = desktopTemplate(Object.assign({ iconfile: iconfile }, this.config)); const desktop = desktopTemplate(Object.assign({ iconfile: iconfile }, this.config));
fse.ensureDirSync(`${buildDir}/usr/share/applications`); fse.ensureDirSync(`${buildDir}/usr/share/applications`);
@@ -30,8 +30,8 @@ export class LinuxDEBPacker extends Packer {
fse.copySync(this.config.meta.icon!, `${buildDir}/usr/share/${this.config.meta.filename}/${iconfile}`); fse.copySync(this.config.meta.icon!, `${buildDir}/usr/share/${this.config.meta.filename}/${iconfile}`);
return gulp.src(`${buildDir}/*`).pipe( return gulp.src(`${buildDir}/*`).pipe(
deb({ deb({
package: this.config.meta.filename, package: this.config.meta.filename!,
version: this.config.meta.version, version: this.config.meta.version!,
section: "base", section: "base",
priority: "optional", priority: "optional",
architecture: "all", architecture: "all",
+2 -1
View File
@@ -14,7 +14,8 @@
"esModuleInterop": true, "esModuleInterop": true,
"isolatedModules": true, "isolatedModules": true,
"verbatimModuleSyntax": true, "verbatimModuleSyntax": true,
"skipLibCheck": true "skipLibCheck": true,
"noImplicitThis": false,
}, },
"include": ["src"] "include": ["src"]
} }