Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
await executeFinally((async () => {
if (projectDirCreated != null) {
await projectDirCreated(projectDir, tmpDir)
}
if (checkOptions.isInstallDepsBefore) {
// bin links required (e.g. for node-pre-gyp - if package refers to it in the install script)
await spawn(process.platform === "win32" ? "yarn.cmd" : "yarn", ["install", "--production", "--no-lockfile"], {
cwd: projectDir,
})
}
if (packagerOptions.projectDir != null) {
packagerOptions.projectDir = path.resolve(projectDir, packagerOptions.projectDir)
}
const {packager, outDir} = await packAndCheck({
projectDir,
...packagerOptions
}, checkOptions)
if (checkOptions.packed != null) {
function base(platform: Platform, arch?: Arch): string {
return path.join(outDir, `${platform.buildConfigurationKey}${getArchSuffix(arch == null ? Arch.x64 : arch)}${platform === Platform.MAC ? "" : "-unpacked"}`)
const volumePath = path.join("/Volumes", volumeName)
if (await exists(volumePath)) {
log.debug({volumePath}, "unmounting previous disk image")
await detach(volumePath)
}
if (!await attachAndExecute(tempDmg, true, () => customizeDmg(volumePath, specification, packager, backgroundFile))) {
return
}
// dmg file must not exist otherwise hdiutil failed (https://github.com/electron-userland/electron-builder/issues/1308#issuecomment-282847594), so, -ov must be specified
const args = ["convert", tempDmg, "-ov", "-format", specification.format!!, "-o", artifactPath]
if (specification.format === "UDZO") {
args.push("-imagekey", `zlib-level=${process.env.ELECTRON_BUILDER_COMPRESSION_LEVEL || "9"}`)
}
await spawn("hdiutil", addLogLevel(args))
if (this.options.internetEnabled) {
await exec("hdiutil", addLogLevel(["internet-enable"]).concat(artifactPath))
}
const licenseData = await addLicenseToDmg(packager, artifactPath)
if (packager.packagerOptions.effectiveOptionComputed != null) {
await packager.packagerOptions.effectiveOptionComputed({licenseData})
}
if (this.options.sign === true) {
await this.signDmg(artifactPath)
}
const safeArtifactName = packager.computeSafeArtifactName(artifactName, "dmg")
const updateInfo = this.options.writeUpdateInfo === false ? null : await createBlockmap(artifactPath, this, packager, safeArtifactName)
await packager.info.callArtifactBuildCompleted({
async function createStageDmg(tempDmg: string, appPath: string, volumeName: string) {
//noinspection SpellCheckingInspection
const imageArgs = addLogLevel(["create",
"-srcfolder", appPath,
"-volname", volumeName,
"-anyowners", "-nospotlight",
"-format", "UDRW",
])
imageArgs.push("-fs", "HFS+", "-fsargs", "-c c=64,a=16,e=16")
imageArgs.push(tempDmg)
await spawn("hdiutil", imageArgs)
return tempDmg
}
}
execArgs.push("--cache-min", "999999999")
}
if (execPath == null) {
execPath = getPackageToolPath()
}
else {
execArgs.unshift(execPath)
execPath = process.env.npm_node_execpath || process.env.NODE_EXE || "node"
}
if (additionalArgs != null) {
execArgs.push(...additionalArgs)
}
return spawn(execPath, execArgs, {
cwd: appDir,
env: getGypEnv(options.frameworkInfo, platform, arch, options.buildFromSource === true),
})
}
spawn(file: string, args: Array, options?: SpawnOptions, extraOptions?: ExtraSpawnOptions): Promise {
return spawn(file, args, options, extraOptions)
}
async spawn(file: string, args: Array, options?: SpawnOptions, extraOptions?: ExtraSpawnOptions): Promise {
await this.ensureThatVmStarted()
return await spawn("prlctl", ["exec", this.vm.id, file].concat(args), options, extraOptions)
.catch(error => this.handleExecuteError(error))
}
spawn(file: string, args: Array, options?: SpawnOptions, extraOptions?: ExtraSpawnOptions): Promise {
return spawn("mono", [file].concat(args), options, extraOptions)
}
}
log.info(chalk.bold('When asked to enter a password ("Create Private Key Password"), please select "None".'))
try {
await ensureDir(path.dirname(tempPrefix))
const vendorPath = path.join(await getSignVendorPath(), "windows-10", process.arch)
await exec(path.join(vendorPath, "makecert.exe"),
["-r", "-h", "0", "-n", `CN=${quoteString(publisher)}`, "-eku", "1.3.6.1.5.5.7.3.3", "-pe", "-sv", pvk, cer])
const pfx = path.join(targetDir, `${sanitizeFileName(publisher)}.pfx`)
await unlinkIfExists(pfx)
await exec(path.join(vendorPath, "pvk2pfx.exe"), ["-pvk", pvk, "-spc", cer, "-pfx", pfx])
log.info({file: pfx}, `created. Please see https://electron.build/code-signing how to use it to sign.`)
const certLocation = "Cert:\\LocalMachine\\TrustedPeople"
log.info({file: pfx, certLocation}, `importing. Operation will be succeed only if runned from root. Otherwise import file manually.`)
await spawn("powershell.exe", ["-NoProfile", "-NonInteractive", "-Command", "Import-PfxCertificate", "-FilePath", `"${pfx}"`, "-CertStoreLocation", ""])
}
finally {
await tmpDir.cleanup()
}
}
function syncReleases(outputDirectory: string, options: SquirrelOptions) {
log.info("syncing releases to build delta package")
const args = prepareArgs(["-u", options.remoteReleases!, "-r", outputDirectory], path.join(options.vendorPath, "SyncReleases.exe"))
if (options.remoteToken) {
args.push("-t", options.remoteToken)
}
return spawn(process.platform === "win32" ? path.join(options.vendorPath, "SyncReleases.exe") : "mono", args)
}