thedesk/app/node_modules/app-builder-lib/out/targets/pkg.js.map
2019-09-12 23:38:13 +09:00

2 lines
14 KiB
Plaintext

{"version":3,"sources":["../../src/targets/pkg.ts"],"names":[],"mappings":";;;;;;;;AAAA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;;AAEA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;;;AAGA,MAAM,QAAQ,GAAG,wBAAjB,C,CAEA;AACA;AACA;AACA;;AACM,MAAO,SAAP,SAAyB,cAAzB,CAA+B;AAQnC,EAAA,WAAA,CAA6B,QAA7B,EAA6D,MAA7D,EAA2E;AACzE,UAAM,KAAN;AAD2B,SAAA,QAAA,GAAA,QAAA;AAAgC,SAAA,MAAA,GAAA,MAAA;AAPpD,SAAA,OAAA,GAAO,MAAA,CAAA,MAAA,CAAA;AACd,MAAA,aAAa,EAAE,IADD;AAEd,MAAA,oBAAoB,EAAE,IAFR;AAGd,MAAA,kBAAkB,EAAE;AAHN,KAAA,EAIX,KAAK,QAAL,CAAc,MAAd,CAAqB,GAJV,CAAP;AASR;;AAED,QAAM,KAAN,CAAY,OAAZ,EAA6B,IAA7B,EAAuC;AACrC,UAAM,QAAQ,GAAG,KAAK,QAAtB;AACA,UAAM,OAAO,GAAG,KAAK,OAArB;AACA,UAAM,OAAO,GAAG,QAAQ,CAAC,OAAzB,CAHqC,CAKrC;;AACA,UAAM,YAAY,GAAG,QAAQ,CAAC,yBAAT,CAAmC,OAAnC,EAA4C,KAA5C,CAArB;AACA,UAAM,YAAY,GAAG,IAAI,CAA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builder-util/out/fs\"\nimport { executeAppBuilderAndWriteJson, executeAppBuilderAsJson } from \"../util/appBuilder\"\nimport { getNotLocalizedLicenseFile } from \"../util/license\"\nimport { readFile, unlink, writeFile } from \"fs-extra\"\nimport * as path from \"path\"\nimport { PkgOptions } from \"..\"\nimport { filterCFBundleIdentifier } from \"../appInfo\"\nimport { findIdentity, Identity } from \"../codeSign/macCodeSign\"\nimport { Target } from \"../core\"\nimport MacPackager from \"../macPackager\"\n\nconst certType = \"Developer ID Installer\"\n\n// http://www.shanekirk.com/2013/10/creating-flat-packages-in-osx/\n// to use --scripts, we must build .app bundle separately using pkgbuild\n// productbuild --scripts doesn't work (because scripts in this case not added to our package)\n// https://github.com/electron-userland/electron-osx-sign/issues/96#issuecomment-274986942\nexport class PkgTarget extends Target {\n readonly options: PkgOptions = {\n allowAnywhere: true,\n allowCurrentUserHome: true,\n allowRootDirectory: true,\n ...this.packager.config.pkg,\n }\n\n constructor(private readonly packager: MacPackager, readonly outDir: string) {\n super(\"pkg\")\n }\n\n async build(appPath: string, arch: Arch): Promise<any> {\n const packager = this.packager\n const options = this.options\n const appInfo = packager.appInfo\n\n // pkg doesn't like not ASCII symbols (Could not open package to list files: /Volumes/test/t-gIjdGK/test-project-0/dist/Test App ßW-1.1.0.pkg)\n const artifactName = packager.expandArtifactNamePattern(options, \"pkg\")\n const artifactPath = path.join(this.outDir, artifactName)\n\n await packager.info.callArtifactBuildStarted({\n targetPresentableName: \"pkg\",\n file: artifactPath,\n arch,\n })\n\n const keychainFile = (await packager.codeSigningInfo.value).keychainFile\n\n const appOutDir = this.outDir\n // https://developer.apple.com/library/content/documentation/DeveloperTools/Reference/DistributionDefinitionRef/Chapters/Distribution_XML_Ref.html\n const distInfoFile = path.join(appOutDir, \"distribution.xml\")\n\n const innerPackageFile = path.join(appOutDir, `${filterCFBundleIdentifier(appInfo.id)}.pkg`)\n const componentPropertyListFile = path.join(appOutDir, `${filterCFBundleIdentifier(appInfo.id)}.plist`)\n const identity = (await Promise.all([\n findIdentity(certType, options.identity || packager.platformSpecificBuildOptions.identity, keychainFile),\n this.customizeDistributionConfiguration(distInfoFile, appPath),\n this.buildComponentPackage(appPath, componentPropertyListFile, innerPackageFile),\n ]))[0]\n\n if (identity == null && packager.forceCodeSigning) {\n throw new Error(`Cannot find valid \"${certType}\" to sign standalone installer, please see https://electron.build/code-signing`)\n }\n\n const args = prepareProductBuildArgs(identity, keychainFile)\n args.push(\"--distribution\", distInfoFile)\n args.push(artifactPath)\n use(options.productbuild, it => args.push(...it as any))\n await exec(\"productbuild\", args, {\n cwd: appOutDir,\n })\n await Promise.all([unlink(innerPackageFile), unlink(distInfoFile)])\n\n await packager.dispatchArtifactCreated(artifactPath, this, arch, packager.computeSafeArtifactName(artifactName, \"pkg\", arch))\n }\n\n private async customizeDistributionConfiguration(distInfoFile: string, appPath: string) {\n await exec(\"productbuild\", [\"--synthesize\", \"--component\", appPath, distInfoFile], {\n cwd: this.outDir,\n })\n\n const options = this.options\n let distInfo = await readFile(distInfoFile, \"utf-8\")\n const insertIndex = distInfo.lastIndexOf(\"</installer-gui-script>\")\n distInfo = distInfo.substring(0, insertIndex) + ` <domains enable_anywhere=\"${options.allowAnywhere}\" enable_currentUserHome=\"${options.allowCurrentUserHome}\" enable_localSystem=\"${options.allowRootDirectory}\" />\\n` + distInfo.substring(insertIndex)\n\n if (options.background != null) {\n const background = await this.packager.getResource(options.background.file)\n if (background != null) {\n const alignment = options.background.alignment || \"center\"\n // noinspection SpellCheckingInspection\n const scaling = options.background.scaling || \"tofit\"\n distInfo = distInfo.substring(0, insertIndex) + ` <background file=\"${background}\" alignment=\"${alignment}\" scaling=\"${scaling}\"/>\\n` + distInfo.substring(insertIndex)\n }\n }\n\n const welcome = await this.packager.getResource(options.welcome)\n if (welcome != null) {\n distInfo = distInfo.substring(0, insertIndex) + ` <welcome file=\"${welcome}\"/>\\n` + distInfo.substring(insertIndex)\n }\n\n const license = await getNotLocalizedLicenseFile(options.license, this.packager)\n if (license != null) {\n distInfo = distInfo.substring(0, insertIndex) + ` <license file=\"${license}\"/>\\n` + distInfo.substring(insertIndex)\n }\n\n const conclusion = await this.packager.getResource(options.conclusion)\n if (conclusion != null) {\n distInfo = distInfo.substring(0, insertIndex) + ` <conclusion file=\"${conclusion}\"/>\\n` + distInfo.substring(insertIndex)\n }\n\n debug(distInfo)\n await writeFile(distInfoFile, distInfo)\n }\n\n private async buildComponentPackage(appPath: string, propertyListOutputFile: string, packageOutputFile: string) {\n const options = this.options\n const rootPath = path.dirname(appPath)\n\n // first produce a component plist template\n await exec(\"pkgbuild\", [\n \"--analyze\",\n \"--root\", rootPath,\n propertyListOutputFile,\n ])\n\n // process the template plist\n const plistInfo = (await executeAppBuilderAsJson<Array<any>>([\"decode-plist\", \"-f\", propertyListOutputFile]))[0]\n if (plistInfo.length > 0) {\n const packageInfo = plistInfo[0]\n\n // ChildBundles lists all of electron binaries within the .app.\n // There is no particular reason for removing that key, except to be as close as possible to\n // the PackageInfo generated by previous versions of electron-builder.\n delete packageInfo.ChildBundles\n\n if (options.isRelocatable != null) {\n packageInfo.BundleIsRelocatable = options.isRelocatable\n }\n\n if (options.isVersionChecked != null) {\n packageInfo.BundleIsVersionChecked = options.isVersionChecked\n }\n\n if (options.hasStrictIdentifier != null) {\n packageInfo.BundleHasStrictIdentifier = options.hasStrictIdentifier\n }\n\n if (options.overwriteAction != null) {\n packageInfo.BundleOverwriteAction = options.overwriteAction\n }\n\n await executeAppBuilderAndWriteJson([\"encode-plist\"], {[propertyListOutputFile]: plistInfo})\n }\n\n // now build the package\n const args = [\n \"--root\", rootPath,\n \"--component-plist\", propertyListOutputFile,\n ]\n\n use(this.options.installLocation || \"/Applications\", it => args.push(\"--install-location\", it!))\n if (options.scripts != null) {\n args.push(\"--scripts\", path.resolve(this.packager.info.buildResourcesDir, options.scripts))\n }\n else if (options.scripts !== null) {\n const dir = path.join(this.packager.info.buildResourcesDir, \"pkg-scripts\")\n const stat = await statOrNull(dir)\n if (stat != null && stat.isDirectory()) {\n args.push(\"--scripts\", dir)\n }\n }\n\n args.push(packageOutputFile)\n\n await exec(\"pkgbuild\", args)\n }\n}\n\nexport function prepareProductBuildArgs(identity: Identity | null, keychain: string | null | undefined): Array<string> {\n const args: Array<string> = []\n if (identity != null) {\n args.push(\"--sign\", identity.hash)\n if (keychain != null) {\n args.push(\"--keychain\", keychain)\n }\n }\n return args\n}\n"],"sourceRoot":""}