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I,IAAJ,GAAW,WAAX,EAAwB,IAAI,KAAK,WAAL,IAAoB,KAAK,WAAW,EAAtF;AACD;;AAED,QAAM,iBAAN,GAAuB;AACrB,UAAM,GAAG,GAAG,KAAK,IAAL,CAAU,QAAV,CAAmB,QAAnB,IAA+B,KAAK,kBAAL,CAAwB,QAAnE;;AACA,QAAI,GAAG,IAAI,IAAX,EAAiB;AACf,aAAO,GAAP;AACD;;AAED,UAAM,IAAI,GAAG,MAAM,KAAK,IAAL,CAAU,cAA7B;AACA,WAAO,IAAI,IAAI,IAAR,IAAgB,IAAI,CAAC,IAAL,KAAc,QAA9B,GAA0C,IAA1C,GAAiD,WAAW,IAAI,CAAC,MAAM,IAAI,IAAI,CAAC,IAAI,IAAI,IAAI,CAAC,OAAO,EAA3G;AACD;;AArHiB;AAwHpB;;;;;AACM,SAAU,wBAAV,CAAmC,UAAnC,EAAqD;AACzD;AACA;AACA,SAAO,UAAU,CAAC,OAAX,CAAmB,IAAnB,EAAyB,GAAzB,EAA8B,OAA9B,CAAsC,iBAAtC,EAAyD,EAAzD,CAAP;AACD,C,CAED;AACA;;;AACM,SAAU,OAAV,CAAkB,CAAlB,EAA2B;AAC/B;AACA,EAAA,CAAC,GAAG,CAAC,CAAC,OAAF,CAAU,uBAAV,EAAmC,UAAnC,CAAJ,CAF+B,CAG/B;;AACA,EAAA,CAAC,GAAG,CAAC,CAAC,OAAF,CAAU,IAAV,EAAgB,QAAhB,CAAJ,CAJ+B,CAK/B;;AACA,EAAA,CAAC,GAAG,CAAC,CAAC,OAAF,CAAU,6BAAV,EAAyC,UAAzC,CAAJ,CAN+B,CAO/B;;AACA,EAAA,CAAC,GAAG,CAAC,CAAC,OAAF,CAAU,IAAV,EAAgB,QAAhB,CAAJ;AACA,SAAO,CAAP;AACD,C","sourcesContent":["import { isEmptyOrSpaces, log } from \"builder-util\"\nimport sanitizeFileName from \"sanitize-filename\"\nimport { prerelease, SemVer } from \"semver\"\nimport { PlatformSpecificBuildOptions } from \"./options/PlatformSpecificBuildOptions\"\nimport { Packager } from \"./packager\"\nimport { expandMacro } from \"./util/macroExpander\"\n\nexport class AppInfo {\n readonly description = smarten(this.info.metadata.description || \"\")\n readonly version: string\n\n readonly buildNumber: string | undefined\n readonly buildVersion: string\n\n readonly productName: string\n readonly productFilename: string\n\n constructor(private readonly info: Packager, buildVersion: string | null | undefined, private readonly platformSpecificOptions: PlatformSpecificBuildOptions | null = null) {\n this.version = info.metadata.version!!\n\n if (buildVersion == null) {\n buildVersion = info.config.buildVersion\n }\n\n this.buildNumber = process.env.BUILD_NUMBER || process.env.TRAVIS_BUILD_NUMBER || process.env.APPVEYOR_BUILD_NUMBER || process.env.CIRCLE_BUILD_NUM || process.env.BUILD_BUILDNUMBER || process.env.CI_PIPELINE_IID\n if (buildVersion == null) {\n buildVersion = this.version\n if (!isEmptyOrSpaces(this.buildNumber)) {\n buildVersion += `.${this.buildNumber}`\n }\n }\n this.buildVersion = buildVersion\n\n this.productName = info.config.productName || info.metadata.productName || info.metadata.name!!\n this.productFilename = sanitizeFileName(this.productName)\n }\n\n get channel(): string | null {\n const prereleaseInfo = prerelease(this.version)\n if (prereleaseInfo != null && prereleaseInfo.length > 0) {\n return prereleaseInfo[0]\n }\n return null\n }\n\n getVersionInWeirdWindowsForm(isSetBuildNumber = true): string {\n const parsedVersion = new SemVer(this.version)\n // https://github.com/electron-userland/electron-builder/issues/2635#issuecomment-371792272\n let buildNumber = isSetBuildNumber ? this.buildNumber : null\n if (buildNumber == null || !/^\\d+$/.test(buildNumber)) {\n buildNumber = \"0\"\n }\n return `${parsedVersion.major}.${parsedVersion.minor}.${parsedVersion.patch}.${buildNumber}`\n }\n\n private get notNullDevMetadata() {\n return this.info.devMetadata || {}\n }\n\n get companyName(): string | null {\n const author = this.info.metadata.author || this.notNullDevMetadata.author\n return author == null ? null : author.name\n }\n\n get id(): string {\n let appId: string | null | undefined = null\n for (const options of [this.platformSpecificOptions, this.info.config]) {\n if (options != null && appId == null) {\n appId = options.appId\n }\n }\n\n const generateDefaultAppId = () => {\n const info = this.info\n return `${info.framework.defaultAppIdPrefix}${info.metadata.name!.toLowerCase()}`\n }\n\n if (appId != null && (appId === \"your.id\" || isEmptyOrSpaces(appId))) {\n const incorrectAppId = appId\n appId = generateDefaultAppId()\n log.warn(`do not use \"${incorrectAppId}\" as appId, \"${appId}\" will be used instead`)\n }\n\n return appId == null ? generateDefaultAppId() : appId\n }\n\n get macBundleIdentifier(): string {\n return filterCFBundleIdentifier(this.id)\n }\n\n get name(): string {\n return this.info.metadata.name!!\n }\n\n get linuxPackageName(): string {\n const name = this.name\n // https://github.com/electron-userland/electron-builder/issues/2963\n return name.startsWith(\"@\") ? this.productFilename : name\n }\n\n get sanitizedName(): string {\n return sanitizeFileName(this.name)\n }\n\n get updaterCacheDirName(): string {\n return this.sanitizedName.toLowerCase() + \"-updater\"\n }\n\n get copyright(): string {\n const copyright = this.info.config.copyright\n if (copyright != null) {\n return expandMacro(copyright, null, this)\n }\n return `Copyright © ${new Date().getFullYear()} ${this.companyName || this.productName}`\n }\n\n async computePackageUrl(): Promise {\n const url = this.info.metadata.homepage || this.notNullDevMetadata.homepage\n if (url != null) {\n return url\n }\n\n const info = await this.info.repositoryInfo\n return info == null || info.type !== \"github\" ? null : `https://${info.domain}/${info.user}/${info.project}`\n }\n}\n\n/** @internal */\nexport function filterCFBundleIdentifier(identifier: string) {\n // Remove special characters and allow only alphanumeric (A-Z,a-z,0-9), hyphen (-), and period (.)\n // Apple documentation: https://developer.apple.com/library/mac/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html#//apple_ref/doc/uid/20001431-102070\n return identifier.replace(/ /g, \"-\").replace(/[^a-zA-Z0-9.-]/g, \"\")\n}\n\n// fpm bug - rpm build --description is not escaped, well... decided to replace quite to smart quote\n// http://leancrew.com/all-this/2010/11/smart-quotes-in-javascript/\nexport function smarten(s: string): string {\n // opening singles\n s = s.replace(/(^|[-\\u2014\\s(\\[\"])'/g, \"$1\\u2018\")\n // closing singles & apostrophes\n s = s.replace(/'/g, \"\\u2019\")\n // opening doubles\n s = s.replace(/(^|[-\\u2014/\\[(\\u2018\\s])\"/g, \"$1\\u201c\")\n // closing doubles\n s = s.replace(/\"/g, \"\\u201d\")\n return s\n}\n"],"sourceRoot":""}