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alidConfigurationError, log, safeStringifyJson, serializeToYaml, TmpDir } from \"builder-util\"\nimport { CancellationToken } from \"builder-util-runtime\"\nimport { executeFinally, orNullIfFileNotExist } from \"builder-util/out/promise\"\nimport { EventEmitter } from \"events\"\nimport { mkdirs, chmod, outputFile } from \"fs-extra\"\nimport isCI from \"is-ci\"\nimport { Lazy } from \"lazy-val\"\nimport * as path from \"path\"\nimport { getArtifactArchName } from \"builder-util/out/arch\"\nimport { AppInfo } from \"./appInfo\"\nimport { readAsarJson } from \"./asar/asar\"\nimport { createElectronFrameworkSupport } from \"./electron/ElectronFramework\"\nimport { LibUiFramework } from \"./frameworks/LibUiFramework\"\nimport { AfterPackContext, Configuration, Framework, Platform, SourceRepositoryInfo, Target } from \"./index\"\nimport MacPackager from \"./macPackager\"\nimport { Metadata } from \"./options/metadata\"\nimport { ArtifactBuildStarted, ArtifactCreated, PackagerOptions } from \"./packagerApi\"\nimport { PlatformPackager, resolveFunction } from \"./platformPackager\"\nimport { ProtonFramework } from \"./ProtonFramework\"\nimport { computeArchToTargetNamesMap, createTargets, NoOpTarget } from \"./targets/targetFactory\"\nimport { computeDefaultAppDirectory, getConfig, validateConfig } from \"./util/config\"\nimport { expandMacro } from \"./util/macroExpander\"\nimport { createLazyProductionDeps, NodeModuleDirInfo } from \"./util/packageDependencies\"\nimport { checkMetadata, readPackageJson } from \"./util/packageMetadata\"\nimport { getRepositoryInfo } from \"./util/repositoryInfo\"\nimport { getGypEnv, installOrRebuild } from \"./util/yarn\"\nimport { WinPackager } from \"./winPackager\"\n\nfunction addHandler(emitter: EventEmitter, event: string, handler: (...args: Array) => void) {\n emitter.on(event, handler)\n}\n\ndeclare const PACKAGE_VERSION: string\n\nasync function createFrameworkInfo(configuration: Configuration, packager: Packager): Promise {\n let framework = configuration.framework\n if (framework != null) {\n framework = framework.toLowerCase()\n }\n\n let nodeVersion = configuration.nodeVersion\n if (framework === \"electron\" || framework == null) {\n return await createElectronFrameworkSupport(configuration, packager)\n }\n\n if (nodeVersion == null || nodeVersion === \"current\") {\n nodeVersion = process.versions.node\n }\n\n const distMacOsName = `${packager.appInfo.productFilename}.app`\n const isUseLaunchUi = configuration.launchUiVersion !== false\n if (framework === \"proton\" || framework === \"proton-native\") {\n return new ProtonFramework(nodeVersion, distMacOsName, isUseLaunchUi)\n }\n else if (framework === \"libui\") {\n return new LibUiFramework(nodeVersion, distMacOsName, isUseLaunchUi)\n }\n else {\n throw new InvalidConfigurationError(`Unknown framework: ${framework}`)\n }\n}\n\nexport class Packager {\n readonly projectDir: string\n\n private _appDir: string\n get appDir(): string {\n return this._appDir\n }\n\n private _metadata: Metadata | null = null\n get metadata(): Metadata {\n return this._metadata!!\n }\n\n private _nodeModulesHandledExternally: boolean = false\n\n get areNodeModulesHandledExternally(): boolean {\n return this._nodeModulesHandledExternally\n }\n\n private _isPrepackedAppAsar: boolean = false\n\n get isPrepackedAppAsar(): boolean {\n return this._isPrepackedAppAsar\n }\n\n private _devMetadata: Metadata | null = null\n get devMetadata(): Metadata | null {\n return this._devMetadata\n }\n\n private _configuration: Configuration | null = null\n\n get config(): Configuration {\n return this._configuration!!\n }\n\n isTwoPackageJsonProjectLayoutUsed = false\n\n readonly eventEmitter = new EventEmitter()\n\n _appInfo: AppInfo | null = null\n get appInfo(): AppInfo {\n return this._appInfo!!\n }\n\n readonly tempDirManager = new TmpDir(\"packager\")\n\n private _repositoryInfo = new Lazy(() => getRepositoryInfo(this.projectDir, this.metadata, this.devMetadata))\n\n private readonly afterPackHandlers: Array<(context: AfterPackContext) => Promise | null> = []\n\n readonly options: PackagerOptions\n\n readonly debugLogger = new DebugLogger(log.isDebugEnabled)\n\n get repositoryInfo(): Promise {\n return this._repositoryInfo.value\n }\n\n private nodeDependencyInfo = new Map>>()\n\n getNodeDependencyInfo(platform: Platform | null): Lazy> {\n let key = \"\"\n let excludedDependencies: Array | null = null\n if (platform != null && this.framework.getExcludedDependencies != null) {\n excludedDependencies = this.framework.getExcludedDependencies(platform)\n if (excludedDependencies != null) {\n key += `-${platform.name}`\n }\n }\n\n let result = this.nodeDependencyInfo.get(key)\n if (result == null) {\n result = createLazyProductionDeps(this.appDir, excludedDependencies)\n this.nodeDependencyInfo.set(key, result)\n }\n return result\n }\n\n stageDirPathCustomizer: (target: Target, packager: PlatformPackager, arch: Arch) => string = (target, packager, arch) => {\n return path.join(target.outDir, `__${target.name}-${getArtifactArchName(arch, target.name)}`)\n }\n\n private _buildResourcesDir: string | null = null\n\n get buildResourcesDir(): string {\n let result = this._buildResourcesDir\n if (result == null) {\n result = path.resolve(this.projectDir, this.relativeBuildResourcesDirname)\n this._buildResourcesDir = result\n }\n return result\n }\n\n get relativeBuildResourcesDirname(): string {\n return this.config.directories!!.buildResources!!\n }\n\n private _framework: Framework | null = null\n get framework(): Framework {\n return this._framework!!\n }\n\n private readonly toDispose: Array<() => Promise> = []\n\n disposeOnBuildFinish(disposer: () => Promise) {\n this.toDispose.push(disposer)\n }\n\n //noinspection JSUnusedGlobalSymbols\n constructor(options: PackagerOptions, readonly cancellationToken = new CancellationToken()) {\n if (\"devMetadata\" in options) {\n throw new InvalidConfigurationError(\"devMetadata in the options is deprecated, please use config instead\")\n }\n if (\"extraMetadata\" in options) {\n throw new InvalidConfigurationError(\"extraMetadata in the options is deprecated, please use config.extraMetadata instead\")\n }\n\n const targets = options.targets || new Map>>()\n if (options.targets == null) {\n options.targets = targets\n }\n\n function processTargets(platform: Platform, types: Array) {\n function commonArch(currentIfNotSpecified: boolean): Array {\n if (platform === Platform.MAC) {\n return currentIfNotSpecified ? [Arch.x64] : []\n }\n\n const result = Array()\n return result.length === 0 && currentIfNotSpecified ? [archFromString(process.arch)] : result\n }\n\n let archToType = targets.get(platform)\n if (archToType == null) {\n archToType = new Map>()\n targets.set(platform, archToType)\n }\n\n if (types.length === 0) {\n for (const arch of commonArch(false)) {\n archToType.set(arch, [])\n }\n return\n }\n\n for (const type of types) {\n const suffixPos = type.lastIndexOf(\":\")\n if (suffixPos > 0) {\n addValue(archToType, archFromString(type.substring(suffixPos + 1)), type.substring(0, suffixPos))\n }\n else {\n for (const arch of commonArch(true)) {\n addValue(archToType, arch, type)\n }\n }\n }\n }\n\n if (options.mac != null) {\n processTargets(Platform.MAC, options.mac)\n }\n if (options.linux != null) {\n processTargets(Platform.LINUX, options.linux)\n }\n if (options.win != null) {\n processTargets(Platform.WINDOWS, options.win)\n }\n\n this.projectDir = options.projectDir == null ? process.cwd() : path.resolve(options.projectDir)\n this._appDir = this.projectDir\n this.options = {\n ...options,\n prepackaged: options.prepackaged == null ? null : path.resolve(this.projectDir, options.prepackaged)\n }\n\n try {\n log.info({version: PACKAGE_VERSION, os: require(\"os\").release()}, \"electron-builder\")\n }\n catch (e) {\n // error in dev mode without babel\n if (!(e instanceof ReferenceError)) {\n throw e\n }\n }\n }\n\n addAfterPackHandler(handler: (context: AfterPackContext) => Promise | null) {\n this.afterPackHandlers.push(handler)\n }\n\n artifactCreated(handler: (event: ArtifactCreated) => void): Packager {\n addHandler(this.eventEmitter, \"artifactCreated\", handler)\n return this\n }\n\n async callArtifactBuildStarted(event: ArtifactBuildStarted, logFields?: any): Promise {\n log.info(logFields || {\n target: event.targetPresentableName,\n arch: event.arch == null ? null : Arch[event.arch],\n file: log.filePath(event.file),\n }, \"building\")\n const handler = resolveFunction(this.config.artifactBuildStarted, \"artifactBuildStarted\")\n if (handler != null) {\n await Promise.resolve(handler(event))\n }\n }\n\n /**\n * Only for sub artifacts (update info), for main artifacts use `callArtifactBuildCompleted`.\n */\n dispatchArtifactCreated(event: ArtifactCreated): void {\n this.eventEmitter.emit(\"artifactCreated\", event)\n }\n\n async callArtifactBuildCompleted(event: ArtifactCreated): Promise {\n this.dispatchArtifactCreated(event)\n\n const handler = resolveFunction(this.config.artifactBuildCompleted, \"artifactBuildCompleted\")\n if (handler != null) {\n await Promise.resolve(handler(event))\n }\n }\n\n async build(): Promise {\n let configPath: string | null = null\n let configFromOptions = this.options.config\n if (typeof configFromOptions === \"string\") {\n // it is a path to config file\n configPath = configFromOptions\n configFromOptions = null\n }\n else if (configFromOptions != null && configFromOptions.extends != null && configFromOptions.extends.includes(\".\")) {\n configPath = configFromOptions.extends\n delete configFromOptions.extends\n }\n\n const projectDir = this.projectDir\n\n const devPackageFile = path.join(projectDir, \"package.json\")\n this._devMetadata = await orNullIfFileNotExist(readPackageJson(devPackageFile))\n\n const devMetadata = this.devMetadata\n const configuration = await getConfig(projectDir, configPath, configFromOptions, new Lazy(() => Promise.resolve(devMetadata)))\n if (log.isDebugEnabled) {\n log.debug({config: getSafeEffectiveConfig(configuration)}, \"effective config\")\n }\n\n this._appDir = await computeDefaultAppDirectory(projectDir, configuration.directories!!.app)\n this.isTwoPackageJsonProjectLayoutUsed = this._appDir !== projectDir\n\n const appPackageFile = this.isTwoPackageJsonProjectLayoutUsed ? path.join(this.appDir, \"package.json\") : devPackageFile\n\n // tslint:disable:prefer-conditional-expression\n if (this.devMetadata != null && !this.isTwoPackageJsonProjectLayoutUsed) {\n this._metadata = this.devMetadata\n }\n else {\n this._metadata = await this.readProjectMetadataIfTwoPackageStructureOrPrepacked(appPackageFile)\n }\n deepAssign(this.metadata, configuration.extraMetadata)\n\n if (this.isTwoPackageJsonProjectLayoutUsed) {\n log.debug({devPackageFile, appPackageFile}, \"two package.json structure is used\")\n }\n checkMetadata(this.metadata, this.devMetadata, appPackageFile, devPackageFile)\n\n return await this._build(configuration, this._metadata, this._devMetadata)\n }\n\n // external caller of this method always uses isTwoPackageJsonProjectLayoutUsed=false and appDir=projectDir, no way (and need) to use another values\n async _build(configuration: Configuration, metadata: Metadata, devMetadata: Metadata | null, repositoryInfo?: SourceRepositoryInfo): Promise {\n await validateConfig(configuration, this.debugLogger)\n this._configuration = configuration\n this._metadata = metadata\n this._devMetadata = devMetadata\n\n if (repositoryInfo != null) {\n this._repositoryInfo.value = Promise.resolve(repositoryInfo)\n }\n\n this._appInfo = new AppInfo(this, null)\n this._framework = await createFrameworkInfo(this.config, this)\n\n const commonOutDirWithoutPossibleOsMacro = path.resolve(this.projectDir, expandMacro(configuration.directories!!.output!!, null, this._appInfo, {\n os: \"\",\n }))\n\n if (!isCI && (process.stdout as any).isTTY) {\n const effectiveConfigFile = path.join(commonOutDirWithoutPossibleOsMacro, \"builder-effective-config.yaml\")\n log.info({file: log.filePath(effectiveConfigFile)}, \"writing effective config\")\n await outputFile(effectiveConfigFile, getSafeEffectiveConfig(configuration))\n }\n\n // because artifact event maybe dispatched several times for different publish providers\n const artifactPaths = new Set()\n this.artifactCreated(event => {\n if (event.file != null) {\n artifactPaths.add(event.file)\n }\n })\n\n this.disposeOnBuildFinish(() => this.tempDirManager.cleanup())\n const platformToTargets = await executeFinally(this.doBuild(), async () => {\n if (this.debugLogger.isEnabled) {\n await this.debugLogger.save(path.join(commonOutDirWithoutPossibleOsMacro, \"builder-debug.yml\"))\n }\n\n const toDispose = this.toDispose.slice()\n this.toDispose.length = 0\n for (const disposer of toDispose) {\n await disposer().catch(e => {\n log.warn({error: e}, \"cannot dispose\")\n })\n }\n })\n\n return {\n outDir: commonOutDirWithoutPossibleOsMacro,\n artifactPaths: Array.from(artifactPaths),\n platformToTargets,\n configuration,\n }\n }\n\n private async readProjectMetadataIfTwoPackageStructureOrPrepacked(appPackageFile: string): Promise {\n let data = await orNullIfFileNotExist(readPackageJson(appPackageFile))\n if (data != null) {\n return data\n }\n\n data = await orNullIfFileNotExist(readAsarJson(path.join(this.projectDir, \"app.asar\"), \"package.json\"))\n if (data != null) {\n this._isPrepackedAppAsar = true\n return data\n }\n\n throw new Error(`Cannot find package.json in the ${path.dirname(appPackageFile)}`)\n }\n\n private async doBuild(): Promise>> {\n const taskManager = new AsyncTaskManager(this.cancellationToken)\n\n const platformToTarget = new Map>()\n const createdOutDirs = new Set()\n\n for (const [platform, archToType] of this.options.targets!!) {\n if (this.cancellationToken.cancelled) {\n break\n }\n\n if (platform === Platform.MAC && process.platform === Platform.WINDOWS.nodeName) {\n throw new InvalidConfigurationError(\"Build for macOS is supported only on macOS, please see https://electron.build/multi-platform-build\")\n }\n\n const packager = this.createHelper(platform)\n const nameToTarget: Map = new Map()\n platformToTarget.set(platform, nameToTarget)\n\n for (const [arch, targetNames] of computeArchToTargetNamesMap(archToType, packager, platform)) {\n if (this.cancellationToken.cancelled) {\n break\n }\n\n await this.installAppDependencies(platform, arch)\n\n if (this.cancellationToken.cancelled) {\n break\n }\n\n // support os and arch macro in output value\n const outDir = path.resolve(this.projectDir, packager.expandMacro(this._configuration!!.directories!!.output!!, Arch[arch]))\n const targetList = createTargets(nameToTarget, targetNames.length === 0 ? packager.defaultTarget : targetNames, outDir, packager)\n await createOutDirIfNeed(targetList, createdOutDirs)\n await packager.pack(outDir, arch, targetList, taskManager)\n }\n\n if (this.cancellationToken.cancelled) {\n break\n }\n\n for (const target of nameToTarget.values()) {\n taskManager.addTask(target.finishBuild())\n }\n }\n\n await taskManager.awaitTasks()\n return platformToTarget\n }\n\n private createHelper(platform: Platform): PlatformPackager {\n if (this.options.platformPackagerFactory != null) {\n return this.options.platformPackagerFactory!(this, platform)\n }\n\n switch (platform) {\n case Platform.MAC: {\n const helperClass: typeof MacPackager = require(\"./macPackager\").default\n return new helperClass(this)\n }\n\n case Platform.WINDOWS: {\n const helperClass: typeof WinPackager = require(\"./winPackager\").WinPackager\n return new helperClass(this)\n }\n\n case Platform.LINUX:\n return new (require(\"./linuxPackager\").LinuxPackager)(this)\n\n default:\n throw new Error(`Unknown platform: ${platform}`)\n }\n }\n\n private async installAppDependencies(platform: Platform, arch: Arch): Promise {\n if (this.options.prepackaged != null || this.framework.isNpmRebuildRequired !== true) {\n return\n }\n\n const frameworkInfo = {version: this.framework.version, useCustomDist: true}\n const config = this.config\n if (config.nodeGypRebuild === true) {\n log.info({arch: Arch[arch]}, \"executing node-gyp rebuild\")\n await exec(process.platform === \"win32\" ? \"node-gyp.cmd\" : \"node-gyp\", [\"rebuild\"], {\n env: getGypEnv(frameworkInfo, platform.nodeName, Arch[arch], true),\n })\n }\n\n if (config.npmRebuild === false) {\n log.info({reason: \"npmRebuild is set to false\"}, \"skipped dependencies rebuild\")\n return\n }\n\n const beforeBuild = resolveFunction(config.beforeBuild, \"beforeBuild\")\n if (beforeBuild != null) {\n const performDependenciesInstallOrRebuild = await beforeBuild({\n appDir: this.appDir,\n electronVersion: this.config.electronVersion!,\n platform,\n arch: Arch[arch]\n })\n\n // If beforeBuild resolves to false, it means that handling node_modules is done outside of electron-builder.\n this._nodeModulesHandledExternally = !performDependenciesInstallOrRebuild\n if (!performDependenciesInstallOrRebuild) {\n return\n }\n }\n\n if (config.buildDependenciesFromSource === true && platform.nodeName !== process.platform) {\n log.info({reason: \"platform is different and buildDependenciesFromSource is set to true\"}, \"skipped dependencies rebuild\")\n }\n else {\n await installOrRebuild(config, this.appDir, {\n frameworkInfo,\n platform: platform.nodeName,\n arch: Arch[arch],\n productionDeps: this.getNodeDependencyInfo(null),\n })\n }\n }\n\n async afterPack(context: AfterPackContext): Promise {\n const afterPack = resolveFunction(this.config.afterPack, \"afterPack\")\n const handlers = this.afterPackHandlers.slice()\n if (afterPack != null) {\n // user handler should be last\n handlers.push(afterPack)\n }\n\n for (const handler of handlers) {\n await Promise.resolve(handler(context))\n }\n }\n}\n\nfunction createOutDirIfNeed(targetList: Array, createdOutDirs: Set): Promise {\n const ourDirs = new Set()\n for (const target of targetList) {\n // noinspection SuspiciousInstanceOfGuard\n if (target instanceof NoOpTarget) {\n continue\n }\n\n const outDir = (target as Target).outDir\n if (!createdOutDirs.has(outDir)) {\n ourDirs.add(outDir)\n }\n }\n\n if (ourDirs.size === 0) {\n return Promise.resolve()\n }\n\n return Promise.all(Array.from(ourDirs).sort().map(dir => {\n return mkdirs(dir)\n .then(() => chmod(dir, 0o755) /* set explicitly */)\n .then(() => createdOutDirs.add(dir))\n }))\n}\n\nexport interface BuildResult {\n readonly outDir: string\n readonly artifactPaths: Array\n readonly platformToTargets: Map>\n readonly configuration: Configuration\n}\n\nfunction getSafeEffectiveConfig(configuration: Configuration): string {\n const o = JSON.parse(safeStringifyJson(configuration))\n if (o.cscLink != null) {\n o.cscLink = \"\"\n }\n return serializeToYaml(o, true)\n}"],"sourceRoot":""}