Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
test.ifNotCiMac("boring, MUI_HEADER as option", () => {
let installerHeaderPath: string | null = null
return assertPack("test-app-one", {
targets: Platform.WINDOWS.createTarget(["nsis"], Arch.ia32, Arch.x64),
config: {
nsis: {
oneClick: false,
installerHeader: "foo.bmp"
}
},
effectiveOptionComputed: async (it) => {
const defines = it[0]
expect(defines.MUI_HEADERIMAGE).toBeNull()
expect(defines.MUI_HEADERIMAGE_BITMAP).toEqual(installerHeaderPath)
expect(defines.MUI_HEADERIMAGE_RIGHT).toBeNull()
// test that we can build such installer
return false
}
}, {
projectDirCreated: projectDir => {
import { Platform, Arch } from "electron-builder"
import { assertPack, app, copyTestAsset } from "../helpers/packTester"
import * as path from "path"
import { archFromString } from "electron-builder-core"
import { safeLoad } from "js-yaml"
import { readFile } from "fs-extra-p";
import { doTest, expectUpdateMetadata } from "../helpers/winHelper"
const nsisTarget = Platform.WINDOWS.createTarget(["nsis"])
test.ifNotCiMac("boring, MUI_HEADER", () => {
let installerHeaderPath: string | null = null
return assertPack("test-app-one", {
targets: nsisTarget,
config: {
nsis: {
oneClick: false,
}
},
effectiveOptionComputed: async(it) => {
const defines = it[0]
expect(defines.MUI_HEADERIMAGE).toBeNull()
expect(defines.MUI_HEADERIMAGE_BITMAP).toEqual(installerHeaderPath)
expect(defines.MUI_HEADERIMAGE_RIGHT).toBeNull()
// speedup, do not build - another MUI_HEADER test will test build
async function checkLinuxResult(outDir: string, packager: Packager, arch: Arch, nameToTarget: Map) {
if (!nameToTarget.has("deb")) {
return
}
const appInfo = packager.appInfo
const packageFile = `${outDir}/TestApp_${appInfo.version}_${arch === Arch.ia32 ? "i386" : (arch === Arch.x64 ? "amd64" : "armv7l")}.deb`
expect(await getContents(packageFile)).toMatchSnapshot()
if (arch === Arch.ia32) {
expect(await getContents(`${outDir}/TestApp_${appInfo.version}_i386.deb`)).toMatchSnapshot()
}
const control = parseDebControl(await execShell(`ar p '${packageFile}' control.tar.gz | ${await getTarExecutable()} zx --to-stdout ./control`, {
maxBuffer: 10 * 1024 * 1024,
}))
delete control.Version
delete control.Size
const description = control.Description
delete control.Description
expect(control).toMatchSnapshot()
// strange difference on linux and mac (no leading space on Linux)
expect(description.trim()).toMatchSnapshot()
async function checkLinuxResult(outDir: string, packager: Packager, arch: Arch, nameToTarget: Map) {
if (!nameToTarget.has("deb")) {
return
}
const appInfo = packager.appInfo
const packageFile = `${outDir}/TestApp_${appInfo.version}_${arch === Arch.ia32 ? "i386" : (arch === Arch.x64 ? "amd64" : "armv7l")}.deb`
expect(await getContents(packageFile)).toMatchSnapshot()
if (arch === Arch.ia32) {
expect(await getContents(`${outDir}/TestApp_${appInfo.version}_i386.deb`)).toMatchSnapshot()
}
const control = parseDebControl(await execShell(`ar p '${packageFile}' control.tar.gz | ${await getTarExecutable()} zx --to-stdout ./control`, {
maxBuffer: 10 * 1024 * 1024,
}))
delete control.Version
delete control.Size
const description = control.Description
delete control.Description
expect(control).toMatchSnapshot()
// strange difference on linux and mac (no leading space on Linux)
expect(description.trim()).toMatchSnapshot()
}
var build = () => {
// Build
if (!cli.downloadOnly) {
builder
.build({
targets: builder.createTargets([targetOs]),
config: Object.assign(buildConfig, {
extraMetadata: cli.package
? Object.assign(cli.extraMetadata, { package: cli.package })
: cli.extraMetadata
})
})
.then(() => {
console.log("Done");
})
.catch(e => {
if (
e.message.indexOf("GitHub Personal Access Token is not set") !== -1
) {
console.log("Done");
process.exit(0);
} else {
let result;
try {
result = yield server.result;
}
catch (error) {
context.reportStatus("Error: " + error);
}
// Copy electron main
const fromMain = path_1.join(context.workspaceRoot, options.electronMain);
const toMain = path_1.join(result.outputPath, path_1.basename(options.electronMain));
fs_1.copyFileSync(fromMain, toMain);
// write electron package to dist
fs_1.writeFileSync(path_1.join(result.outputPath, "package.json"), JSON.stringify(options.electronPackage), { encoding: "utf-8" });
// Build!
try {
yield builder.build(options.packagerConfig);
}
catch (e) {
console.log("Publish error", e);
}
return {
success: true
};
});
}
var build = () => {
// Build
if (!cli.downloadOnly) {
builder
.build({
targets: builder.createTargets([targetOs]),
config: Object.assign(buildConfig, {
extraMetadata: cli.package
? Object.assign(cli.extraMetadata, { package: cli.package })
: cli.extraMetadata
})
})
.then(() => {
console.log("Done");
})
.catch(e => {
if (
e.message.indexOf("GitHub Personal Access Token is not set") !== -1
) {
console.log("Done");
"use strict"
const path = require("path")
const builder = require("electron-builder")
const Platform = builder.Platform
var argv = require('minimist')(process.argv.slice(2));
console.dir();
var fs = require('fs');
var os = argv.os.toUpperCase() // "ia32"
var arch = argv.arch // "ia32"
var p = require("./../package.json");
var fn = path.join(__dirname, "../dist","sulu Setup " + p.version + ".exe");
var fn2 = path.join(__dirname, "../dist","sulu-fileexplorer-" + os + "-" + arch + "-" + p.version + "." + p.stability + ".exe");
var p2 = path.join(__dirname, "../app","package.json");
console.info("patch ", p2, p.version);
var pp2 = JSON.parse(fs.readFileSync(p2).toString())
pp2.version = p.version
gulp.task('redist:linux', function () {
var rename = require('gulp-rename');
var builder = require('electron-builder');
const config = getConfig("linux");
console.log(`Electron mirror: ${getElectronMirrorUrl()}`);
return builder.build({
targets: builder.Platform.LINUX.createTarget(["deb", "AppImage"], builder.Arch.ia32, builder.Arch.x64),
config,
prepackaged: './dist/linux-unpacked'
}).then((filenames) => {
return gulp.src(filenames, { allowEmpty: true })
.pipe(rename(function (path) {
path.basename = setReleaseFilename(path.basename, {
replaceWhitespace: true
});
}))
.pipe(gulp.dest('./dist'));
}).then(() => {
// Wait for the files to be written to disk and closed.
return delay(10000);
});
});
gulp.task('redist:binaries', async () => {
const { getConfig, getElectronMirrorUrl, getReleaseFilename } = common;
var rename = require('gulp-rename');
var builder = require('electron-builder');
const config = getConfig("windows", "nsis");
console.log(`Electron mirror: ${getElectronMirrorUrl()}`);
// create installers
const filenames = await builder.build({
targets: builder.Platform.WINDOWS.createTarget(["nsis"], builder.Arch.ia32),
config,
prepackaged: './dist/win-ia32-unpacked'
});
// rename and move the files to the /dist/ directory
await new Promise(resolve => {
gulp
.src(filenames, { allowEmpty: true })
.pipe(rename(path => {
path.basename = getReleaseFilename();
}))
.pipe(gulp.dest('./dist'))
.on('end', resolve);
});
});