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,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE,IAAI,IAAI,CAAC,WAAW,IAAI,IAAI,CAAC,WAAW,EAAE,CAAA;IAC1F,CAAC;IAED,KAAK,CAAC,iBAAiB;QACrB,MAAM,GAAG,GAAG,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,QAAQ,IAAI,IAAI,CAAC,kBAAkB,CAAC,QAAQ,CAAA;QAC3E,IAAI,GAAG,IAAI,IAAI,EAAE;YACf,OAAO,GAAG,CAAA;SACX;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;AAvID,0BAuIC;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, SemVer } 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 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(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 =\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    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)\n    this.productFilename = platformSpecificOptions?.executableName != null ? sanitizeFileName(platformSpecificOptions.executableName) : 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 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.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<string | null> {\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"]}