refactor: rewrite on typescript

This commit is contained in:
2026-10-13 21:11:57 +03:00
parent be54ce5d25
commit f735be8bf9
40 changed files with 2333 additions and 2175 deletions
+55
View File
@@ -0,0 +1,55 @@
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 type { Config } from "../core/config";
import { Sdk } from "../core/sdk";
export class InnoSetup extends Sdk {
static ID = "innosetup";
static VERSION = "6";
constructor(version?: string) {
super(InnoSetup.ID, version || InnoSetup.VERSION);
}
get link() {
return "http://www.jrsoftware.org/download.php/is.exe";
}
prepare(strip = 1) {
let result = super.prepare(strip);
if (!this.prepared) {
result = result.then(() => {
return exec(this.path, `is.exe /VERYSILENT /SUPPRESSMSGBOXES /DIR=${this.path}`);
});
}
return result;
}
get isccBin() {
return path.join(this.path, "ISCC.exe");
}
get prepared() {
try {
return fs.existsSync(this.isccBin);
} catch (e) {
return false;
}
}
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 });
fse.ensureDirSync(buildDir);
fse.copySync(`${source}`, `${buildDir}`);
fs.writeFileSync(path.resolve(buildDir, "app.iss"), app);
return exec(buildDir, [`"${this.isccBin}"`, "app.iss"].join(" "));
}
}