projectDirCreated: projectDir => {
   return Promise.all([
     // writeFile(path.join(projectDir, "build", "license_en.txt"), "Hi"),
     writeFile(path.join(projectDir, "build", "license_de.txt"), "Hallo"),
     writeFile(path.join(projectDir, "build", "license_ru.txt"), "Привет"),
   ])
 },
 projectDirCreated: projectDir => {
   return BluebirdPromise.all([
     writeFile(path.join(projectDir, "build", "license_en.txt"), "Hi"),
     writeFile(path.join(projectDir, "build", "license_ru.txt"), "Привет"),
     writeFile(path.join(projectDir, "build", "license_ko.txt"), "Привет"),
     writeFile(path.join(projectDir, "build", "license_fi.txt"), "Привет"),
   ])
 },
Beispiel #3
0
  async prepareWine(wineDir: string) {
    await emptyDir(wineDir)
    //noinspection SpellCheckingInspection
    const env = Object.assign({}, process.env, {
      WINEDLLOVERRIDES: "winemenubuilder.exe=d",
      WINEPREFIX: wineDir
    })

    await exec("wineboot", ["--init"], {env: env})

    // regedit often doesn't modify correctly
    let systemReg = await readFile(path.join(wineDir, "system.reg"), "utf8")
    systemReg = systemReg.replace('"CSDVersion"="Service Pack 3"', '"CSDVersion"=" "')
    systemReg = systemReg.replace('"CurrentBuildNumber"="2600"', '"CurrentBuildNumber"="10240"')
    systemReg = systemReg.replace('"CurrentVersion"="5.1"', '"CurrentVersion"="10.0"')
    systemReg = systemReg.replace('"ProductName"="Microsoft Windows XP"', '"ProductName"="Microsoft Windows 10"')
    systemReg = systemReg.replace('"CSDVersion"=dword:00000300', '"CSDVersion"=dword:00000000')
    await writeFile(path.join(wineDir, "system.reg"), systemReg)

    // remove links to host OS
    const desktopDir = path.join(this.userDir, "Desktop")
    await BluebirdPromise.all([
      unlinkIfExists(desktopDir),
      unlinkIfExists(path.join(this.userDir, "My Documents")),
      unlinkIfExists(path.join(this.userDir, "My Music")),
      unlinkIfExists(path.join(this.userDir, "My Pictures")),
      unlinkIfExists(path.join(this.userDir, "My Videos")),
    ])

    await ensureDir(desktopDir)
    return env
  }
Beispiel #4
0
  async copy(src: string, dest: string, stat: Stats | undefined) {
    if (this.transformer != null && stat != null && stat.isFile()) {
      let data = this.transformer(src)
      if (data != null) {
        if (typeof (data as any).then === "function") {
          data = await data
        }

        if (data != null) {
          await writeFile(dest, data)
          return
        }
      }
    }
    const isUseHardLink = (!this.isUseHardLink || this.isUseHardLinkFunction == null) ? this.isUseHardLink : this.isUseHardLinkFunction(dest)
    await copyOrLinkFile(src, dest, stat, isUseHardLink, isUseHardLink ? () => {
      // files are copied concurrently, so, we must not check here currentIsUseHardLink — our code can be executed after that other handler will set currentIsUseHardLink to false
      if (this.isUseHardLink) {
        this.isUseHardLink = false
        return true
      }
      else {
        return false
      }
    } : null)
  }
Beispiel #5
0
  async copy(src: string, dest: string, stat: Stats | undefined) {
    try {
      if (this.transformer != null && stat != null && stat.isFile()) {
        let data = this.transformer(src)
        if (data != null) {
          if (typeof (data as any).then === "function") {
            data = await data
          }

          if (data != null) {
            await writeFile(dest, data)
            return
          }
        }
      }
      await copyOrLinkFile(src, dest, stat, (!this.isUseHardLink || this.isUseHardLinkFunction == null) ? this.isUseHardLink : this.isUseHardLinkFunction(dest))
    }
    catch (e) {
      // files are copied concurrently, so, we must not check here currentIsUseHardLink — our code can be executed after that other handler will set currentIsUseHardLink to false
      if (e.code === "EXDEV") {
        // ...but here we want to avoid excess debug log message
        if (this.isUseHardLink) {
          debug(`Cannot copy using hard link: ${e}`)
          this.isUseHardLink = false
        }

        await copyOrLinkFile(src, dest, stat, false)
      }
      else {
        throw e
      }
    }
  }
async function setPackageVersions(packageData: Array<any>) {
  const versions = await getLatestVersions(packageData)
  let publishScript = `#!/usr/bin/env bash
set -e
  
ln -f README.md packages/electron-builder/README.md
`

  for (let i = 0; i < packageData.length; i++) {
    const packageMetadata = packageData[i]
    const packageName = packageMetadata.name
    const versionInfo = versions[i]
    const latestVersion = versionInfo.next || versionInfo.latest
    if (latestVersion == null || packageMetadata.version === latestVersion || semver.lt(latestVersion, packageMetadata.version)) {
      continue
    }

    packageMetadata.version = latestVersion
    console.log(`Set ${packageName} version to ${latestVersion}`)
    await writeJson(path.join(packageDir, packageName, "package.json"), packageMetadata, {spaces: 2})
  }

  for (let i = 0; i < packageData.length; i++) {
    const packageMetadata = packageData[i]
    const versionInfo = versions[i]
    const latestVersion = versionInfo.next || versionInfo.latest
    if (latestVersion != null && semver.gt(packageMetadata.version, latestVersion)) {
      publishScript += `npm publish packages/${packageMetadata.name}\n`
    }
  }

  await writeFile(path.join(rootDir, "__publish.sh"), publishScript)
}
Beispiel #7
0
async function createFiles(appDir: string) {
  await BluebirdPromise.all([
    outputFile(path.join(appDir, "assets", "file"), "data"),
    outputFile(path.join(appDir, "b2", "file"), "data"),
    outputFile(path.join(appDir, "do-not-unpack-dir", "file.json"), "{}")
      .then(() => writeFile(path.join(appDir, "do-not-unpack-dir", "must-be-not-unpacked"), "{}"))
  ])

  const dir = path.join(appDir, "do-not-unpack-dir", "dir-2", "dir-3", "dir-3")
  await mkdirs(dir)
  await writeFile(path.join(dir, "file-in-asar"), "{}")
}
      packed: async context => {
        const outDir = context.outDir
        outDirs.push(outDir)
        const targetOutDir = path.join(outDir, "nsis-web")
        const updateInfoFile = path.join(targetOutDir, "latest.yml")

        const updateInfo: UpdateInfo = safeLoad(await readFile(updateInfoFile, "utf-8"))
        const fd = await open(path.join(targetOutDir, `TestApp-${version}-x64.nsis.7z`), "r")
        try {
          const packageInfo = updateInfo.packages!!.x64
          const buffer = Buffer.allocUnsafe(packageInfo.blockMapSize!!)
          await read(fd, buffer, 0, buffer.length, packageInfo.size - buffer.length)
          const inflateRaw: any = BluebirdPromise.promisify(require("zlib").inflateRaw)
          const blockMapData = (await inflateRaw(buffer)).toString()
          await writeFile(path.join(outDir, "win-unpacked", BLOCK_MAP_FILE_NAME), blockMapData)
        }
        finally {
          await close(fd)
        }
      }
Beispiel #9
0
export async function addLicenseToDmg(packager: PlatformPackager<any>, 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(" ")}`)
  }

  const tempFile = await packager.getTempFile(".r")
  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") {
  $"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++
  }

  await writeFile(tempFile, data)
  await exec("hdiutil", ["unflatten", dmgPath])
  await exec("Rez", ["-a", tempFile, "-o", dmgPath])
  await exec("hdiutil", ["flatten", dmgPath])
}
  async copy(src: string, dest: string, stat: Stats | undefined) {
    let afterCopyTransformer: AfterCopyFileTransformer | null = null
    if (this.transformer != null && stat != null && stat.isFile()) {
      let data = this.transformer(src)
      if (data != null) {
        if (typeof data === "object" && "then" in data) {
          data = await data
        }

        if (data != null) {
          if (data instanceof CopyFileTransformer) {
            afterCopyTransformer = data.afterCopyTransformer
          }
          else {
            await writeFile(dest, data)
            return
          }
        }
      }
    }

    const isUseHardLink = afterCopyTransformer == null && ((!this.isUseHardLink || this.isUseHardLinkFunction == null) ? this.isUseHardLink : this.isUseHardLinkFunction(dest))
    await copyOrLinkFile(src, dest, stat, isUseHardLink, isUseHardLink ? () => {
      // files are copied concurrently, so, we must not check here currentIsUseHardLink — our code can be executed after that other handler will set currentIsUseHardLink to false
      if (this.isUseHardLink) {
        this.isUseHardLink = false
        return true
      }
      else {
        return false
      }
    } : null)

    if (afterCopyTransformer != null) {
      await afterCopyTransformer(dest)
    }
  }