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X,CAAZ,CAAP;AAKD,C","sourcesContent":["import BluebirdPromise from \"bluebird-lst\"\nimport { asArray, executeAppBuilder, log } from \"builder-util\"\nimport { CONCURRENCY, copyDir, DO_NOT_USE_HARD_LINKS, statOrNull, unlinkIfExists } from \"builder-util/out/fs\"\nimport { emptyDir, readdir, remove, rename } from \"fs-extra\"\nimport { Lazy } from \"lazy-val\"\nimport * as path from \"path\"\nimport { Configuration } from \"../configuration\"\nimport { BeforeCopyExtraFilesOptions, Framework, PrepareApplicationStageDirectoryOptions } from \"../Framework\"\nimport { ElectronPlatformName, Packager, Platform } from \"../index\"\nimport { LinuxPackager } from \"../linuxPackager\"\nimport MacPackager from \"../macPackager\"\nimport { isSafeToUnpackElectronOnRemoteBuildServer } from \"../platformPackager\"\nimport { getTemplatePath } from \"../util/pathManager\"\nimport { createMacApp } from \"./electronMac\"\nimport { computeElectronVersion, getElectronVersionFromInstalled } from \"./electronVersion\"\n\nexport type ElectronPlatformName = \"darwin\" | \"linux\" | \"win32\" | \"mas\"\n\nexport interface ElectronDownloadOptions {\n // https://github.com/electron-userland/electron-builder/issues/3077\n // must be optional\n version?: string\n\n /**\n * The [cache location](https://github.com/electron-userland/electron-download#cache-location).\n */\n cache?: string | null\n\n /**\n * The mirror.\n */\n mirror?: string | null\n\n /** @private */\n customDir?: string | null\n /** @private */\n customFilename?: string | null\n\n strictSSL?: boolean\n isVerifyChecksum?: boolean\n\n platform?: ElectronPlatformName\n arch?: string\n}\n\nfunction createDownloadOpts(opts: Configuration, platform: ElectronPlatformName, arch: string, electronVersion: string): ElectronDownloadOptions {\n return {\n platform,\n arch,\n version: electronVersion,\n ...opts.electronDownload,\n }\n}\n\nasync function beforeCopyExtraFiles(options: BeforeCopyExtraFilesOptions) {\n const packager = options.packager\n const appOutDir = options.appOutDir\n if (packager.platform === Platform.LINUX) {\n if (!isSafeToUnpackElectronOnRemoteBuildServer(packager)) {\n const linuxPackager = (packager as LinuxPackager)\n const executable = path.join(appOutDir, linuxPackager.executableName)\n await rename(path.join(appOutDir, \"electron\"), executable)\n }\n }\n else if (packager.platform === Platform.WINDOWS) {\n const executable = path.join(appOutDir, `${packager.appInfo.productFilename}.exe`)\n await rename(path.join(appOutDir, \"electron.exe\"), executable)\n }\n else {\n await createMacApp(packager as MacPackager, appOutDir, options.asarIntegrity, (options.platformName as ElectronPlatformName) === \"mas\")\n\n const wantedLanguages = asArray(packager.platformSpecificBuildOptions.electronLanguages)\n if (wantedLanguages.length === 0) {\n return\n }\n\n // noinspection SpellCheckingInspection\n const langFileExt = \".lproj\"\n const resourcesDir = packager.getResourcesDir(appOutDir)\n await BluebirdPromise.map(readdir(resourcesDir), file => {\n if (!file.endsWith(langFileExt)) {\n return\n }\n\n const language = file.substring(0, file.length - langFileExt.length)\n if (!wantedLanguages.includes(language)) {\n return remove(path.join(resourcesDir, file))\n }\n return\n }, CONCURRENCY)\n }\n}\n\nclass ElectronFramework implements Framework {\n // noinspection JSUnusedGlobalSymbols\n readonly macOsDefaultTargets = [\"zip\", \"dmg\"]\n // noinspection JSUnusedGlobalSymbols\n readonly defaultAppIdPrefix = \"com.electron.\"\n // noinspection JSUnusedGlobalSymbols\n readonly isCopyElevateHelper = true\n // noinspection JSUnusedGlobalSymbols\n readonly isNpmRebuildRequired = true\n\n constructor(readonly name: string, readonly version: string, readonly distMacOsAppName: string) {\n }\n\n getDefaultIcon(platform: Platform) {\n if (platform === Platform.LINUX) {\n return path.join(getTemplatePath(\"icons\"), \"electron-linux\")\n }\n else {\n // default icon is embedded into app skeleton\n return null\n }\n }\n\n prepareApplicationStageDirectory(options: PrepareApplicationStageDirectoryOptions) {\n return unpack(options, createDownloadOpts(options.packager.config, options.platformName, options.arch, this.version), this.distMacOsAppName)\n }\n\n beforeCopyExtraFiles(options: BeforeCopyExtraFilesOptions) {\n return beforeCopyExtraFiles(options)\n }\n}\n\nexport async function createElectronFrameworkSupport(configuration: Configuration, packager: Packager): Promise<Framework> {\n let version = configuration.electronVersion\n if (version == null) {\n // for prepacked app asar no dev deps in the app.asar\n if (packager.isPrepackedAppAsar) {\n version = await getElectronVersionFromInstalled(packager.projectDir)\n if (version == null) {\n throw new Error(`Cannot compute electron version for prepacked asar`)\n }\n }\n else {\n version = await computeElectronVersion(packager.projectDir, new Lazy(() => Promise.resolve(packager.metadata)))\n }\n configuration.electronVersion = version\n }\n\n return new ElectronFramework(\"electron\", version, \"Electron.app\")\n}\n\nasync function unpack(prepareOptions: PrepareApplicationStageDirectoryOptions, options: ElectronDownloadOptions, distMacOsAppName: string) {\n const packager = prepareOptions.packager\n const out = prepareOptions.appOutDir\n\n let dist: string | null | undefined = packager.config.electronDist\n if (dist != null) {\n const zipFile = `electron-v${options.version}-${prepareOptions.platformName}-${options.arch}.zip`\n const resolvedDist = path.resolve(packager.projectDir, dist)\n if ((await statOrNull(path.join(resolvedDist, zipFile))) != null) {\n options.cache = resolvedDist\n dist = null\n }\n }\n\n let isFullCleanup = false\n if (dist == null) {\n if (isSafeToUnpackElectronOnRemoteBuildServer(packager)) {\n return\n }\n\n await executeAppBuilder([\"unpack-electron\", \"--configuration\", JSON.stringify([options]), \"--output\", out, \"--distMacOsAppName\", distMacOsAppName])\n }\n else {\n isFullCleanup = true\n const source = packager.getElectronSrcDir(dist)\n const destination = packager.getElectronDestinationDir(out)\n log.info({source, destination}, \"copying Electron\")\n await emptyDir(out)\n await copyDir(source, destination, {\n isUseHardLink: DO_NOT_USE_HARD_LINKS,\n })\n }\n\n await cleanupAfterUnpack(prepareOptions, distMacOsAppName, isFullCleanup)\n}\n\nfunction cleanupAfterUnpack(prepareOptions: PrepareApplicationStageDirectoryOptions, distMacOsAppName: string, isFullCleanup: boolean) {\n const out = prepareOptions.appOutDir\n const isMac = prepareOptions.packager.platform === Platform.MAC\n const resourcesPath = isMac ? path.join(out, distMacOsAppName, \"Contents\", \"Resources\") : path.join(out, \"resources\")\n\n return Promise.all([\n isFullCleanup ? unlinkIfExists(path.join(resourcesPath, \"default_app.asar\")) : Promise.resolve(),\n isFullCleanup ? unlinkIfExists(path.join(out, \"version\")) : Promise.resolve(),\n isMac ? Promise.resolve() : rename(path.join(out, \"LICENSE\"), path.join(out, \"LICENSE.electron.txt\")).catch(() => {/* ignore */}),\n ])\n}"],"sourceRoot":""}
|