[innosetup] add innosetup installer packer
This commit is contained in:
8
gulp-haxetool.iml
Executable file
8
gulp-haxetool.iml
Executable file
@@ -0,0 +1,8 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module type="WEB_MODULE" version="4">
|
||||
<component name="NewModuleRootManager" inherit-compiler-output="true">
|
||||
<exclude-output />
|
||||
<content url="file://$MODULE_DIR$" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
</component>
|
||||
</module>
|
||||
4
haxetool/env.js
Normal file → Executable file
4
haxetool/env.js
Normal file → Executable file
@@ -7,6 +7,10 @@ class Env {
|
||||
process.env[key] = value;
|
||||
}
|
||||
|
||||
static get(key) {
|
||||
return process.env[key];
|
||||
}
|
||||
|
||||
static addPath(value, key='PATH') {
|
||||
if (!process.env[key]) {
|
||||
process.env[key] = value;
|
||||
|
||||
58
haxetool/innosetup.js
Executable file
58
haxetool/innosetup.js
Executable file
@@ -0,0 +1,58 @@
|
||||
const fs = require('fs');
|
||||
const fse = require('fs-extra');
|
||||
const os = require('os');
|
||||
const path = require('path');
|
||||
const Sdk = require('./sdk');
|
||||
const exec = require('./exec');
|
||||
const Env = require('./env');
|
||||
const template = require('lodash.template');
|
||||
|
||||
class InnoSetup extends Sdk {
|
||||
|
||||
constructor(version) {
|
||||
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');
|
||||
});
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
get isccBin() {
|
||||
return path.join(Env.get('ProgramFiles(x86)'), `Inno Setup ${this.version}`, 'ISCC.exe')
|
||||
}
|
||||
|
||||
get prepared() {
|
||||
try {
|
||||
return fs.existsSync(this.isccBin);
|
||||
} catch (e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
pack(config, source, output) {
|
||||
const buildDir = path.join(os.tmpdir(), 'build', config.name, 'innosetup');
|
||||
const appTemplate = template(fs.readFileSync(path.resolve(__dirname, '..', 'template/windows/app.iss')));
|
||||
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(' '));
|
||||
}
|
||||
}
|
||||
|
||||
InnoSetup.ID = 'innosetup';
|
||||
InnoSetup.VERSION = '6';
|
||||
|
||||
module.exports = InnoSetup;
|
||||
@@ -7,6 +7,7 @@ const Haxe = require('./haxe');
|
||||
const FlashPlayer = require('./flashplayer');
|
||||
const Android = require('./android');
|
||||
const Neko = require('./neko');
|
||||
const InnoSetup = require('./innosetup');
|
||||
const Env = require('./env');
|
||||
const debug = require('./debug');
|
||||
const webserver = require('gulp-webserver');
|
||||
@@ -214,7 +215,7 @@ class LinuxDEBPacker extends Packer {
|
||||
'fi'
|
||||
],
|
||||
_target: '/',
|
||||
_out: path.join(target, '..', 'debian'),
|
||||
_out: this.resolveTargetPath('debian'),
|
||||
_clean: true,
|
||||
_verbose: false
|
||||
}));
|
||||
@@ -248,6 +249,29 @@ LinuxArchivePacker.NAME = 'archive';
|
||||
|
||||
Packer.register(Platform.LINUX, LinuxArchivePacker.NAME, LinuxArchivePacker);
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
class WindowsInstallerPacker extends Packer {
|
||||
|
||||
constructor(config) {
|
||||
super(config, Platform.WINDOWS);
|
||||
this.innosetup = new InnoSetup();
|
||||
}
|
||||
|
||||
prepare() {
|
||||
return this.innosetup.prepare();
|
||||
}
|
||||
|
||||
call() {
|
||||
return this.innosetup.pack(this.config, this.targetPath, this.resolveTargetPath('installer'));
|
||||
}
|
||||
}
|
||||
|
||||
WindowsInstallerPacker.NAME = 'installer';
|
||||
|
||||
Packer.register(Platform.WINDOWS, WindowsInstallerPacker.NAME, WindowsInstallerPacker);
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
|
||||
@@ -63,14 +63,16 @@ class Downloader {
|
||||
let stream = got.stream(url);
|
||||
stream = stream
|
||||
.on('request', r => {
|
||||
bar.start(1, 0);
|
||||
if (bar) bar.start(1, 0);
|
||||
})
|
||||
.on('downloadProgress', p => {
|
||||
if (bar) {
|
||||
bar.setTotal(p.total);
|
||||
bar.update(p.transferred);
|
||||
if (p.total === p.transferred) {
|
||||
Downloader.releaseProgressBar(bar);
|
||||
}
|
||||
}
|
||||
});
|
||||
if (url.endsWith('.zip')) {
|
||||
stream = stream.pipe(unzip.Parse()).on('entry', entry => {
|
||||
|
||||
18
template/windows/app.iss
Executable file
18
template/windows/app.iss
Executable file
@@ -0,0 +1,18 @@
|
||||
[Setup]
|
||||
AppName=<%=meta.title%>
|
||||
AppVersion=<%=meta.version%>
|
||||
WizardStyle=modern
|
||||
DefaultDirName={autopf}\<%=meta.filename%>
|
||||
DefaultGroupName=<%=meta.title%>
|
||||
UninstallDisplayIcon={app}\<%=meta.filename%>.exe
|
||||
Compression=lzma2
|
||||
SolidCompression=yes
|
||||
OutputDir=<%=output%>
|
||||
OutputBaseFilename=<%=meta.filename%>_<%=meta.version%>
|
||||
|
||||
[Files]
|
||||
Source: *; Excludes: "*.iss,*.log"; DestDir: "{app}"; Flags: recursesubdirs
|
||||
|
||||
[Icons]
|
||||
Name: "{group}\<%=meta.title%>"; Filename: "{app}\<%=meta.filename%>.exe"
|
||||
Name: "{group}\Uninstall <%=meta.title%>"; Filename: "{uninstallexe}"
|
||||
Reference in New Issue
Block a user