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,KAAW,MAAX,IAAqB,CAAC,CAAC,IAAF,KAAW,KAA7D,CAAJ,EAAyE;AAC5E,cAAM,MAAM,GAAG,MAAM,QAAQ,CAAC,WAAT,CAAqB,CAAC,CAAC,IAAvB,CAArB;;AACA,YAAI,MAAM,IAAI,IAAd,EAAoB;AAClB,6BAAI,IAAJ,CAAS;AAAC,YAAA,SAAD;AAAY,YAAA,MAAM,EAAE;AAApB,WAAT,EAA+C,0BAA/C;;AACA;AACD;;AAED,cAAM,WAAW,GAAG,GAAG,UAAU,IAAI,SAAS,EAA9C;AACA,QAAA,gBAAgB,CAAC,OAAjB,CAAyB,CAAC,CAAC,IAAF,KAAW,KAAX,IAAoB,CAAC,MAAM,qBAAK,MAAL,CAAP,EAAqB,WAArB,EAApB,GAAyD,mBAAQ,MAAR,EAAgB,WAAhB,CAAzD,GAAwF,oBAAS,MAAT,EAAiB,WAAjB,CAAjH;AACD;AACF;;AACD,SAAO,MAAP;AACD,C","sourcesContent":["import { DmgOptions, Target } from \"app-builder-lib\"\nimport { findIdentity, isSignAllowed } from \"app-builder-lib/out/codeSign/macCodeSign\"\nimport MacPackager from \"app-builder-lib/out/macPackager\"\nimport { createBlockmap } from \"app-builder-lib/out/targets/differentialUpdateInfoBuilder\"\nimport { executeAppBuilderAsJson } from \"app-builder-lib/out/util/appBuilder\"\nimport { Arch, AsyncTaskManager, exec, InvalidConfigurationError, isEmptyOrSpaces, log, spawn } from \"builder-util\"\nimport { CancellationToken } from \"builder-util-runtime\"\nimport { copyDir, copyFile, exists, statOrNull } from \"builder-util/out/fs\"\nimport { stat } from \"fs-extra\"\nimport * as path from \"path\"\nimport sanitizeFileName from \"sanitize-filename\"\nimport { addLicenseToDmg } from \"./dmgLicense\"\nimport { attachAndExecute, computeBackground, detach, getDmgVendorPath, transformBackgroundFileIfNeed } from \"./dmgUtil\"\n\nexport class DmgTarget extends Target {\n readonly options: DmgOptions = this.packager.config.dmg || Object.create(null)\n\n constructor(private readonly packager: MacPackager, readonly outDir: string) {\n super(\"dmg\")\n }\n\n async build(appPath: string, arch: Arch) {\n const packager = this.packager\n // tslint:disable-next-line:no-invalid-template-strings\n const artifactName = packager.expandArtifactNamePattern(packager.config.dmg, \"dmg\", null, \"${productName}-\" + (packager.platformSpecificBuildOptions.bundleShortVersion || \"${version}\") + \".${ext}\")\n const artifactPath = path.join(this.outDir, artifactName)\n await packager.info.callArtifactBuildStarted({\n targetPresentableName: \"DMG\",\n file: artifactPath,\n arch,\n })\n\n const volumeName = sanitizeFileName(this.computeVolumeName(this.options.title))\n\n const tempDmg = await createStageDmg(await packager.getTempFile(\".dmg\"), appPath, volumeName)\n\n const specification = await this.computeDmgOptions()\n // https://github.com/electron-userland/electron-builder/issues/2115\n const backgroundFile = specification.background == null ? null : await transformBackgroundFileIfNeed(specification.background, packager.info.tempDirManager)\n const finalSize = await computeAssetSize(packager.info.cancellationToken, tempDmg, specification, backgroundFile)\n await exec(\"hdiutil\", [\"resize\", \"-size\", finalSize.toString(), tempDmg])\n\n const volumePath = path.join(\"/Volumes\", volumeName)\n if (await exists(volumePath)) {\n log.debug({volumePath}, \"unmounting previous disk image\")\n await detach(volumePath)\n }\n\n if (!await attachAndExecute(tempDmg, true, () => customizeDmg(volumePath, specification, packager, backgroundFile))) {\n return\n }\n\n // dmg file must not exist otherwise hdiutil failed (https://github.com/electron-userland/electron-builder/issues/1308#issuecomment-282847594), so, -ov must be specified\n const args = [\"convert\", tempDmg, \"-ov\", \"-format\", specification.format!!, \"-o\", artifactPath]\n if (specification.format === \"UDZO\") {\n args.push(\"-imagekey\", `zlib-level=${process.env.ELECTRON_BUILDER_COMPRESSION_LEVEL || \"9\"}`)\n }\n await spawn(\"hdiutil\", addLogLevel(args))\n if (this.options.internetEnabled) {\n await exec(\"hdiutil\", addLogLevel([\"internet-enable\"]).concat(artifactPath))\n }\n\n const licenseData = await addLicenseToDmg(packager, artifactPath)\n if (packager.packagerOptions.effectiveOptionComputed != null) {\n await packager.packagerOptions.effectiveOptionComputed({licenseData})\n }\n\n if (this.options.sign === true) {\n await this.signDmg(artifactPath)\n }\n\n const safeArtifactName = packager.computeSafeArtifactName(artifactName, \"dmg\")\n const updateInfo = this.options.writeUpdateInfo === false ? null : await createBlockmap(artifactPath, this, packager, safeArtifactName)\n await packager.info.callArtifactBuildCompleted({\n file: artifactPath,\n safeArtifactName,\n target: this,\n arch,\n packager,\n isWriteUpdateInfo: updateInfo != null,\n updateInfo,\n })\n }\n\n private async signDmg(artifactPath: string) {\n if (!isSignAllowed(false)) {\n return\n }\n\n const packager = this.packager\n const qualifier = packager.platformSpecificBuildOptions.identity\n // explicitly disabled if set to null\n if (qualifier === null) {\n // macPackager already somehow handle this situation, so, here just return\n return\n }\n\n const keychainFile = (await packager.codeSigningInfo.value).keychainFile\n const certificateType = \"Developer ID Application\"\n let identity = await findIdentity(certificateType, qualifier, keychainFile)\n if (identity == null) {\n identity = await findIdentity(\"Mac Developer\", qualifier, keychainFile)\n if (identity == null) {\n return\n }\n }\n\n const args = [\"--sign\", identity.hash]\n if (keychainFile != null) {\n args.push(\"--keychain\", keychainFile)\n }\n args.push(artifactPath)\n await exec(\"codesign\", args)\n }\n\n computeVolumeName(custom?: string | null): string {\n const appInfo = this.packager.appInfo\n const shortVersion = this.packager.platformSpecificBuildOptions.bundleShortVersion || appInfo.version\n\n if (custom == null) {\n return `${appInfo.productFilename} ${shortVersion}`\n }\n\n return custom\n .replace(/\\${shortVersion}/g, shortVersion)\n .replace(/\\${version}/g, appInfo.version)\n .replace(/\\${name}/g, appInfo.name)\n .replace(/\\${productName}/g, appInfo.productName)\n }\n\n // public to test\n async computeDmgOptions(): Promise {\n const packager = this.packager\n const specification: DmgOptions = {...this.options}\n if (specification.icon == null && specification.icon !== null) {\n specification.icon = await packager.getIconPath()\n }\n\n if (specification.icon != null && isEmptyOrSpaces(specification.icon)) {\n throw new InvalidConfigurationError(\"dmg.icon cannot be specified as empty string\")\n }\n\n const background = specification.background\n if (specification.backgroundColor != null) {\n if (background != null) {\n throw new InvalidConfigurationError(\"Both dmg.backgroundColor and dmg.background are specified — please set the only one\")\n }\n }\n else if (background == null) {\n specification.background = await computeBackground(packager)\n }\n else {\n specification.background = path.resolve(packager.info.projectDir, background)\n }\n\n if (specification.format == null) {\n if (process.env.ELECTRON_BUILDER_COMPRESSION_LEVEL != null) {\n (specification as any).format = \"UDZO\"\n }\n else if (packager.compression === \"store\") {\n specification.format = \"UDRO\"\n }\n else {\n specification.format = packager.compression === \"maximum\" ? \"UDBZ\" : \"UDZO\"\n }\n }\n\n if (specification.contents == null) {\n specification.contents = [\n {\n x: 130, y: 220\n },\n {\n x: 410, y: 220, type: \"link\", path: \"/Applications\"\n }\n ]\n }\n return specification\n }\n}\n\nasync function createStageDmg(tempDmg: string, appPath: string, volumeName: string) {\n //noinspection SpellCheckingInspection\n const imageArgs = addLogLevel([\"create\",\n \"-srcfolder\", appPath,\n \"-volname\", volumeName,\n \"-anyowners\", \"-nospotlight\",\n \"-format\", \"UDRW\",\n ])\n imageArgs.push(\"-fs\", \"HFS+\", \"-fsargs\", \"-c c=64,a=16,e=16\")\n imageArgs.push(tempDmg)\n await spawn(\"hdiutil\", imageArgs)\n return tempDmg\n}\n\nfunction addLogLevel(args: Array): Array {\n args.push(process.env.DEBUG_DMG === \"true\" ? \"-verbose\" : \"-quiet\")\n return args\n}\n\nasync function computeAssetSize(cancellationToken: CancellationToken, dmgFile: string, specification: DmgOptions, backgroundFile: string | null | undefined) {\n const asyncTaskManager = new AsyncTaskManager(cancellationToken)\n asyncTaskManager.addTask(stat(dmgFile))\n\n if (specification.icon != null) {\n asyncTaskManager.addTask(statOrNull(specification.icon))\n }\n\n if (backgroundFile != null) {\n asyncTaskManager.addTask(stat(backgroundFile))\n }\n\n let result = 32 * 1024\n for (const stat of await asyncTaskManager.awaitTasks()) {\n if (stat != null) {\n result += stat.size\n }\n }\n return result\n}\n\nasync function customizeDmg(volumePath: string, specification: DmgOptions, packager: MacPackager, backgroundFile: string | null | undefined) {\n const window = specification.window\n const env: any = {\n ...process.env,\n volumePath,\n appFileName: `${packager.appInfo.productFilename}.app`,\n iconSize: specification.iconSize || 80,\n iconTextSize: specification.iconTextSize || 12,\n\n PYTHONIOENCODING: \"utf8\",\n }\n\n if (specification.backgroundColor != null || specification.background == null) {\n env.backgroundColor = specification.backgroundColor || \"#ffffff\"\n\n if (window != null) {\n env.windowX = (window.x == null ? 100 : window.x).toString()\n env.windowY = (window.y == null ? 400 : window.y).toString()\n env.windowWidth = (window.width || 540).toString()\n env.windowHeight = (window.height || 380).toString()\n }\n }\n else {\n delete env.backgroundColor\n }\n\n const args = [\"dmg\", \"--volume\", volumePath]\n if (specification.icon != null) {\n args.push(\"--icon\", (await packager.getResource(specification.icon))!!)\n }\n if (backgroundFile != null) {\n args.push(\"--background\", backgroundFile)\n }\n\n const data: any = await executeAppBuilderAsJson(args)\n if (data.backgroundWidth != null) {\n env.windowWidth = window == null ? null : window.width\n env.windowHeight = window == null ? null : window.height\n\n if (env.windowWidth == null) {\n env.windowWidth = data.backgroundWidth.toString()\n }\n if (env.windowHeight == null) {\n env.windowHeight = data.backgroundHeight.toString()\n }\n\n if (env.windowX == null) {\n env.windowX = 400\n }\n if (env.windowY == null) {\n env.windowY = Math.round((1440 - env.windowHeight) / 2).toString()\n }\n }\n\n Object.assign(env, data)\n\n const asyncTaskManager = new AsyncTaskManager(packager.info.cancellationToken)\n env.iconLocations = await computeDmgEntries(specification, volumePath, packager, asyncTaskManager)\n await asyncTaskManager.awaitTasks()\n\n await exec(\"/usr/bin/python\", [path.join(getDmgVendorPath(), \"dmgbuild/core.py\")], {\n cwd: getDmgVendorPath(),\n env\n })\n return packager.packagerOptions.effectiveOptionComputed == null || !(await packager.packagerOptions.effectiveOptionComputed({volumePath, specification, packager}))\n}\n\nasync function computeDmgEntries(specification: DmgOptions, volumePath: string, packager: MacPackager, asyncTaskManager: AsyncTaskManager): Promise {\n let result = \"\"\n for (const c of specification.contents!!) {\n if (c.path != null && c.path.endsWith(\".app\") && c.type !== \"link\") {\n log.warn({path: c.path, reason: \"actual path to app will be used instead\"}, \"do not specify path for application\")\n }\n\n const entryPath = c.path || `${packager.appInfo.productFilename}.app`\n const entryName = c.name || path.basename(entryPath)\n if (result.length !== 0) {\n result += \",\\n\"\n }\n result += `'${entryName}': (${c.x}, ${c.y})`\n\n if (c.type === \"link\") {\n asyncTaskManager.addTask(exec(\"ln\", [\"-s\", `/${entryPath.startsWith(\"/\") ? entryPath.substring(1) : entryPath}`, `${volumePath}/${entryName}`]))\n }\n // use c.path instead of entryPath (to be sure that this logic is not applied to .app bundle) https://github.com/electron-userland/electron-builder/issues/2147\n else if (!isEmptyOrSpaces(c.path) && (c.type === \"file\" || c.type === \"dir\")) {\n const source = await packager.getResource(c.path)\n if (source == null) {\n log.warn({entryPath, reason: \"doesn't exist\"}, \"skipped DMG item copying\")\n continue\n }\n\n const destination = `${volumePath}/${entryName}`\n asyncTaskManager.addTask(c.type === \"dir\" || (await stat(source)).isDirectory() ? copyDir(source, destination) : copyFile(source, destination))\n }\n }\n return result\n}\n"],"sourceRoot":""}