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G,IAAI,IAAI,EAAE,CAAC;YAChB,OAAO,GAAG,CAAA;QACZ,CAAC;QAED,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,IAAI,CAAC,cAAc,CAAA;QAC3C,OAAO,IAAI,IAAI,IAAI,IAAI,IAAI,CAAC,IAAI,KAAK,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,WAAW,IAAI,CAAC,MAAM,IAAI,IAAI,CAAC,IAAI,IAAI,IAAI,CAAC,OAAO,EAAE,CAAA;IAC9G,CAAC;CACF;AA7JD,0BA6JC;AAED,gBAAgB;AAChB,SAAgB,wBAAwB,CAAC,UAAkB;IACzD,kGAAkG;IAClG,0LAA0L;IAC1L,OAAO,UAAU,CAAC,OAAO,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC,OAAO,CAAC,iBAAiB,EAAE,EAAE,CAAC,CAAA;AACrE,CAAC;AAJD,4DAIC","sourcesContent":["import { isEmptyOrSpaces, log } from \"builder-util\"\nimport { prerelease } from \"semver\"\nimport { PlatformSpecificBuildOptions } from \"./options/PlatformSpecificBuildOptions\"\nimport { Packager } from \"./packager\"\nimport { expandMacro } from \"./util/macroExpander\"\nimport { sanitizeFileName } from \"./util/filename\"\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\nexport class AppInfo {\n readonly description = smarten(this.info.metadata.description || \"\")\n readonly version: string\n readonly type: string | undefined\n readonly shortVersion: string | undefined\n readonly shortVersionWindows: string | undefined\n\n readonly buildNumber: string | undefined\n readonly buildVersion: string\n\n readonly productName: string\n readonly sanitizedProductName: string\n readonly productFilename: string\n\n constructor(\n private readonly info: Packager,\n buildVersion: string | null | undefined,\n private readonly platformSpecificOptions: PlatformSpecificBuildOptions | null = null,\n normalizeNfd = false\n ) {\n this.version = info.metadata.version!\n this.type = info.metadata.type\n\n if (buildVersion == null) {\n buildVersion = info.config.buildVersion\n }\n\n const buildNumberEnvs =\n process.env.BUILD_NUMBER ||\n process.env.TRAVIS_BUILD_NUMBER ||\n process.env.APPVEYOR_BUILD_NUMBER ||\n process.env.CIRCLE_BUILD_NUM ||\n process.env.BUILD_BUILDNUMBER ||\n process.env.CI_PIPELINE_IID\n this.buildNumber = info.config.buildNumber || buildNumberEnvs\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 if (info.metadata.shortVersion) {\n this.shortVersion = info.metadata.shortVersion\n }\n if (info.metadata.shortVersionWindows) {\n this.shortVersionWindows = info.metadata.shortVersionWindows\n }\n\n this.productName = info.config.productName || info.metadata.productName || info.metadata.name!\n this.sanitizedProductName = sanitizeFileName(this.productName, normalizeNfd)\n\n const executableName = platformSpecificOptions?.executableName ?? info.config.executableName\n this.productFilename = executableName != null ? sanitizeFileName(executableName, normalizeNfd) : this.sanitizedProductName\n }\n\n get channel(): string | null {\n const prereleaseInfo = prerelease(this.version)\n if (prereleaseInfo != null && prereleaseInfo.length > 0) {\n return prereleaseInfo[0] as string | null\n }\n return null\n }\n\n getVersionInWeirdWindowsForm(isSetBuildNumber = true): string {\n const [major, maybe_minor, maybe_patch] = this.version.split(\".\").map(versionPart => parseInt(versionPart))\n // The major component must be present. Here it can be either NaN or undefined, which\n // both returns true from isNaN.\n if (isNaN(major)) {\n throw new Error(`Invalid major number in: ${this.version}`)\n }\n // Allow missing version parts. Minor and patch can be left out and default to zero\n const minor = maybe_minor ?? 0\n const patch = maybe_patch ?? 0\n // ... but reject non-integer version parts. '1.a' is not going to fly\n if (isNaN(minor) || isNaN(patch)) {\n throw new Error(`Invalid minor or patch number in: ${this.version}`)\n }\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 `${major}.${minor}.${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.sanitizedProductName : 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"]}