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OAAO,CAAC,GAAG;gBAChB,OAAO,EAAE,OAAO,CAAC,YAAY;gBAC7B,GAAG,EAAE,OAAO,CAAC,eAAe;gBAC5B,QAAQ,EAAE,OAAO;gBACjB,OAAO,EAAE,aAAa;gBACtB,qBAAqB,EAAE,KAAK;gBAC5B,MAAM,EAAE;oBACN,GAAG,EAAE,MAAM,CAAC,MAAM,CAAC;wBACjB,KAAK,EAAE,OAAO,CAAC,IAAI;wBACnB,OAAO,EAAE,OAAO,CAAC,OAAO;wBACxB,IAAI,EAAE,OAAO,CAAC,SAAS;wBACvB,SAAS,EAAE,OAAO,CAAC,OAAO;qBAC3B,EAAE,IAAI,CAAC,iBAAiB,CAAC;iBAC3B;aACF,CAAC,CAAC,CAAA;QACL,CAAC;KAAA;AACH,CAAC;AAnJD;6BAmJC,CAAA","sourcesContent":["import { downloadCertificate } from \"./codeSign\"\nimport { Promise as BluebirdPromise } from \"bluebird\"\nimport { tsAwaiter } from \"./awaiter\"\nimport { PlatformPackager, BuildInfo } from \"./platformPackager\"\nimport * as path from \"path\"\nimport { Stats } from \"fs\"\nimport { log } from \"./util\"\nimport { deleteFile, stat, renameFile } from \"./promisifed-fs\"\nimport * as fse from \"fs-extra\"\n\nconst __awaiter = tsAwaiter\nArray.isArray(__awaiter)\n\nconst emptyDir = BluebirdPromise.promisify(fse.emptyDir)\n\nexport default class WinPackager extends PlatformPackager<any> {\n certFilePromise: Promise<string>\n isNsis: boolean\n\n constructor(info: BuildInfo, cleanupTasks: Array<() => Promise<any>>) {\n super(info)\n\n // we are not going to support build both nsis and squirrel\n this.isNsis = this.options.target != null && this.options.target.includes(\"nsis\")\n if (this.isNsis) {\n // it is not an optimization, win.js cannot be runned in highly concurrent environment and we get\n // \"Error: EBUSY: resource busy or locked, unlink 'C:\\Users\\appveyor\\AppData\\Local\\Temp\\1\\icon.ico'\"\n // on appveyor (well, yes, it is a Windows bug)\n // Because NSIS support will be dropped some day, correct solution is not implemented\n const iconPath = this.customDistOptions == null ? null : this.customDistOptions.icon\n require(\"../lib/win\").copyAssetsToTmpFolder(iconPath || path.join(this.projectDir, \"build\", \"icon.ico\"))\n }\n\n // https://developer.mozilla.org/en-US/docs/Signing_an_executable_with_Authenticode\n // https://github.com/Squirrel/Squirrel.Windows/pull/505\n if (this.options.cscLink != null && this.options.cscKeyPassword != null && process.platform !== \"darwin\") {\n this.certFilePromise = downloadCertificate(this.options.cscLink)\n .then(path => {\n cleanupTasks.push(() => deleteFile(path, true))\n return path\n })\n }\n else {\n this.certFilePromise = BluebirdPromise.resolve(null)\n }\n }\n\n getBuildConfigurationKey() {\n return \"win\"\n }\n\n pack(platform: string, arch: string, outDir: string): Promise<any> {\n if (this.options.dist && !this.isNsis) {\n const installerOut = outDir + \"-installer\"\n log(\"Removing %s\", installerOut)\n return BluebirdPromise.all([\n super.pack(platform, arch, outDir),\n emptyDir(installerOut)\n ])\n }\n else {\n return super.pack(platform, arch, outDir)\n }\n }\n\n async packageInDistributableFormat(outDir: string, arch: string): Promise<any> {\n let iconUrl = this.metadata.build.iconUrl\n if (!iconUrl) {\n if (this.customDistOptions != null) {\n iconUrl = this.customDistOptions.iconUrl\n }\n if (!iconUrl) {\n if (this.info.repositoryInfo != null) {\n const info = await this.info.repositoryInfo.getInfo(this)\n if (info != null) {\n iconUrl = `https://raw.githubusercontent.com/${info.user}/${info.project}/master/build/icon.ico`\n }\n }\n\n if (!iconUrl) {\n throw new Error(\"iconUrl is not specified, please see https://github.com/develar/electron-complete-builder#in-short\")\n }\n }\n }\n\n const certificateFile = await this.certFilePromise\n const version = this.metadata.version\n const outputDirectory = outDir + \"-\" + (this.isNsis ? \"nsis\" : \"installer\")\n const appName = this.metadata.name\n const archSuffix = arch === \"x64\" ? \"-x64\" : \"\"\n const installerExePath = path.join(outputDirectory, appName + \"Setup-\" + version + archSuffix + \".exe\")\n const options = Object.assign({\n name: this.metadata.name,\n appDirectory: outDir,\n outputDirectory: outputDirectory,\n productName: appName,\n version: version,\n description: this.metadata.description,\n authors: this.metadata.author,\n iconUrl: iconUrl,\n setupIcon: path.join(this.projectDir, \"build\", \"icon.ico\"),\n certificateFile: certificateFile,\n certificatePassword: this.options.cscKeyPassword,\n }, this.customDistOptions)\n\n if (this.isNsis) {\n return await this.nsis(options, installerExePath)\n }\n\n try {\n await new BluebirdPromise<any>((resolve, reject) => {\n require(\"electron-winstaller-temp-fork\").build(options, (error: Error) => error == null ? resolve(null) : reject(error))\n })\n }\n catch (e) {\n if (!e.message.includes(\"Unable to set icon\")) {\n throw e\n }\n else {\n let fileInfo: Stats\n try {\n fileInfo = await stat(options.setupIcon)\n }\n catch (e) {\n throw new Error(\"Please specify correct setupIcon, file \" + options.setupIcon + \" not found\")\n }\n\n if (fileInfo.isDirectory()) {\n throw new Error(\"Please specify correct setupIcon, \" + options.setupIcon + \" is a directory\")\n }\n }\n }\n\n return await BluebirdPromise.all([\n renameFile(path.join(outputDirectory, appName + \"Setup.exe\"), installerExePath)\n .then(it => this.dispatchArtifactCreated(it)),\n renameFile(path.join(outputDirectory, appName + \"-\" + version + \"-full.nupkg\"), path.join(outputDirectory, appName + \"-\" + version + archSuffix + \"-full.nupkg\"))\n .then(it => this.dispatchArtifactCreated(it))\n ])\n }\n\n private async nsis(options: any, installerFile: string) {\n const nsisBuild = <(options: any, callback: (error: Error) => void) => void>require(\"../lib/win\").init().build\n // nsis cannot create dir\n await emptyDir(options.outputDirectory)\n return await BluebirdPromise.promisify(nsisBuild)(Object.assign(options, {\n log: console.log,\n appPath: options.appDirectory,\n out: options.outputDirectory,\n platform: \"win32\",\n outFile: installerFile,\n copyAssetsToTmpFolder: false,\n config: {\n win: Object.assign({\n title: options.name,\n version: options.version,\n icon: options.setupIcon,\n publisher: options.authors\n }, this.customDistOptions)\n }\n }))\n }\n}"]}
\No newline at end of file