import fs from "fs"; import fse from "fs-extra"; import os from "os"; import path from "path"; import exec from "../common/exec"; import template from "../common/template"; import { Sdk } from "../core/sdk"; import type { Config } from "../core/type"; 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 app = template.render("windows/app.iss", { ...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(" ")); } }