How to use electron-builder - 10 common examples

To help you get started, we’ve selected a few electron-builder examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github electron-userland / electron-builder / test / src / windows / nsisBoring.ts View on Github external
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 => {
github electron-userland / electron-builder / test / src / windows / nsisBoring.ts View on Github external
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
github electron-userland / electron-builder / test / src / helpers / packTester.ts View on Github external
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()
github electron-userland / electron-builder / test / src / helpers / packTester.ts View on Github external
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()
}
github ubports / ubports-installer / build.js View on Github external
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 {
github BenjaminDobler / ngtron / builders / package / index_1.js View on Github external
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
        };
    });
}
github ubports / ubports-installer / build.js View on Github external
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");
github sulu-one / sulu / lib / build.js View on Github external
"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
github microsoft / BotFramework-Emulator / packages / app / main / gulpfile.js View on Github external
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);
  });
});
github microsoft / BotFramework-Emulator / packages / app / main / gulpfile.windows.js View on Github external
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);
  });
});