How to use electron-builder-util - 10 common examples

To help you get started, we’ve selected a few electron-builder-util 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 / packages / electron-builder / src / targets / dmgLicense.ts View on Github external
data += "};\n\n"
    // noinspection SpellCheckingInspection
    data += `data 'styl' (${counter}, "${item.langName} SLA") {
  $"0003 0000 0000 000C 0009 0014 0000 0000"
  $"0000 0000 0000 0000 0027 000C 0009 0014"
  $"0100 0000 0000 0000 0000 0000 002A 000C"
  $"0009 0014 0000 0000 0000 0000 0000"
};`

    counter++
  }

  const tempFile = await packager.getTempFile(".r")
  await writeFile(tempFile, data)
  await exec("hdiutil", ["unflatten", dmgPath])
  await exec("Rez", ["-a", tempFile, "-o", dmgPath])
  await exec("hdiutil", ["flatten", dmgPath])
}
github electron-userland / electron-builder / packages / electron-builder / src / cli / node-gyp-rebuild.ts View on Github external
async function main() {
  const projectDir = process.cwd()
  const config = await loadConfig(projectDir)
  log(`Execute node-gyp rebuild for ${args.platform}:${args.arch}`)
  // this script must be used only for electron
  await exec(process.platform === "win32" ? "node-gyp.cmd" : "node-gyp", ["rebuild"], {
    env: getGypEnv({version: await getElectronVersion(config, projectDir), useCustomDist: true}, args.platform, args.arch, true),
  })
}
github electron-userland / electron-builder / packages / electron-builder / src / targets / dmgLicense.ts View on Github external
// noinspection SpellCheckingInspection
    data += `data 'styl' (${counter}, "${item.langName} SLA") {
  $"0003 0000 0000 000C 0009 0014 0000 0000"
  $"0000 0000 0000 0000 0027 000C 0009 0014"
  $"0100 0000 0000 0000 0000 0000 002A 000C"
  $"0009 0014 0000 0000 0000 0000 0000"
};`

    counter++
  }

  const tempFile = await packager.getTempFile(".r")
  await writeFile(tempFile, data)
  await exec("hdiutil", ["unflatten", dmgPath])
  await exec("Rez", ["-a", tempFile, "-o", dmgPath])
  await exec("hdiutil", ["flatten", dmgPath])
}
github electron-userland / electron-builder / packages / electron-builder / src / packager / dirPackager.ts View on Github external
async function unpack(packager: PlatformPackager, out: string, platform: string, options: any) {
  const dist = packager.config.electronDist
  if (dist == null) {
    const zipPath = (await BluebirdPromise.all([
      downloadElectron(options),
      emptyDir(out)
    ]))[0]

    await spawn(path7za, debug7zArgs("x").concat(zipPath, `-o${out}`))
  }
  else {
    await emptyDir(out)
    await copyDir(path.resolve(packager.info.projectDir, dist, "Electron.app"), path.join(out, "Electron.app"))
  }

  if (platform === "linux") {
    // https://github.com/electron-userland/electron-builder/issues/786
    // fix dir permissions — opposite to extract-zip, 7za creates dir with no-access for other users, but dir must be readable for non-root users
    await BluebirdPromise.all([
      chmod(path.join(out, "locales"), "0755"),
      chmod(path.join(out, "resources"), "0755")
    ])
  }
}
github electron-userland / electron-builder / packages / electron-builder / src / packager / dirPackager.ts View on Github external
async function unpack(packager: PlatformPackager, out: string, platform: string, options: any) {
  const dist = packager.config.electronDist
  if (dist == null) {
    const zipPath = (await BluebirdPromise.all([
      downloadElectron(options),
      emptyDir(out)
    ]))[0]

    await spawn(path7za, debug7zArgs("x").concat(zipPath, `-o${out}`))
  }
  else {
    await emptyDir(out)
    await copyDir(path.resolve(packager.info.projectDir, dist, "Electron.app"), path.join(out, "Electron.app"))
  }

  if (platform === "linux") {
    // https://github.com/electron-userland/electron-builder/issues/786
    // fix dir permissions — opposite to extract-zip, 7za creates dir with no-access for other users, but dir must be readable for non-root users
    await BluebirdPromise.all([
      chmod(path.join(out, "locales"), "0755"),
      chmod(path.join(out, "resources"), "0755")
    ])
  }
}
github electron-userland / electron-builder / packages / electron-builder / src / targets / dmgLicense.ts View on Github external
export async function addLicenseToDmg(packager: PlatformPackager, dmgPath: string) {
  // http://www.owsiak.org/?p=700
  const licenseFiles = await getLicenseFiles(packager)
  if (licenseFiles.length === 0) {
    return
  }

  if (debug.enabled) {
    debug(`License files: ${licenseFiles.join(" ")}`)
  }

  let data = await readFile(path.join(__dirname, "..", "..", "templates", "dmg", "license.txt"), "utf8")
  let counter = 5000
  for (const item of licenseFiles) {
    const kind = item.file.toLowerCase().endsWith(".rtf") ? "RTF" : "TEXT"
    data += `data '${kind}' (${counter}, "${item.langName} SLA") {\n`

    const hex = (await readFile(item.file)).toString("hex").toUpperCase()
    for (let i = 0; i < hex.length; i += 32) {
      data += '$"' + hex.substring(i, Math.min(i + 32, hex.length)) + '"\n'
    }

    data += "};\n\n"
    // noinspection SpellCheckingInspection
    data += `data 'styl' (${counter}, "${item.langName} SLA") {
github electron-userland / electron-builder / packages / electron-builder / src / targets / dmgLicense.ts View on Github external
export async function addLicenseToDmg(packager: PlatformPackager, dmgPath: string) {
  // http://www.owsiak.org/?p=700
  const licenseFiles = await getLicenseFiles(packager)
  if (licenseFiles.length === 0) {
    return
  }

  if (debug.enabled) {
    debug(`License files: ${licenseFiles.join(" ")}`)
  }

  let data = await readFile(path.join(__dirname, "..", "..", "templates", "dmg", "license.txt"), "utf8")
  let counter = 5000
  for (const item of licenseFiles) {
    const kind = item.file.toLowerCase().endsWith(".rtf") ? "RTF" : "TEXT"
    data += `data '${kind}' (${counter}, "${item.langName} SLA") {\n`

    const hex = (await readFile(item.file)).toString("hex").toUpperCase()
    for (let i = 0; i < hex.length; i += 32) {
      data += '$"' + hex.substring(i, Math.min(i + 32, hex.length)) + '"\n'
    }

    data += "};\n\n"
    // noinspection SpellCheckingInspection
github electron-userland / electron-builder / packages / electron-builder / src / cli / node-gyp-rebuild.ts View on Github external
async function main() {
  const projectDir = process.cwd()
  const config = await loadConfig(projectDir)
  log(`Execute node-gyp rebuild for ${args.platform}:${args.arch}`)
  // this script must be used only for electron
  await exec(process.platform === "win32" ? "node-gyp.cmd" : "node-gyp", ["rebuild"], {
    env: getGypEnv({version: await getElectronVersion(config, projectDir), useCustomDist: true}, args.platform, args.arch, true),
  })
}
github electron-userland / electron-builder / packages / electron-builder / src / packager / dirPackager.ts View on Github external
function createDownloadOpts(opts: any, platform: string, arch: string, electronVersion: string) {
  if (opts.download != null) {
    warn(`"build.download is deprecated — please use build.electronDownload instead`)
  }

  const downloadOpts = Object.assign({
    cache: opts.cache,
    strictSSL: opts["strict-ssl"]
  }, opts.electronDownload || opts.download)

  subOptionWarning(downloadOpts, "download", "platform", platform)
  subOptionWarning(downloadOpts, "download", "arch", arch)
  subOptionWarning(downloadOpts, "download", "version", electronVersion)
  return downloadOpts
}
github electron-userland / electron-builder / packages / electron-builder / src / packager / dirPackager.ts View on Github external
function subOptionWarning (properties: any, optionName: any, parameter: any, value: any) {
  if (properties.hasOwnProperty(parameter)) {
    warn(`${optionName}.${parameter} will be inferred from the main options`)
  }
  properties[parameter] = value
}

electron-builder-util

Part of [electron-builder](https://github.com/electron-userland/electron-builder).

MIT
Latest version published 7 years ago

Package Health Score

66 / 100
Full package analysis

Similar packages