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

2 lines
17 KiB
Plaintext

{"version":3,"sources":["../../src/targets/snap.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;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AAEA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AAGA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AAEA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;;;AAEA,MAAM,YAAY,GAAG,CAAC,SAAD,EAAY,gBAAZ,EAA8B,MAA9B,EAAsC,KAAtC,EAA6C,SAA7C,EAAwD,QAAxD,EAAkE,iBAAlE,EAAqF,SAArF,EAAgG,WAAhG,EAA6G,YAA7G,EAA2H,QAA3H,CAArB;;AAEc,MAAO,UAAP,SAA0B,cAA1B,CAAgC;AAK5C,EAAA,WAAA,CAAY,IAAZ,EAA2C,QAA3C,EAAqF,MAArF,EAAyH,MAAzH,EAAuI;AACrI,UAAM,IAAN;AADyC,SAAA,QAAA,GAAA,QAAA;AAA0C,SAAA,MAAA,GAAA,MAAA;AAAoC,SAAA,MAAA,GAAA,MAAA;AAJhH,SAAA,OAAA,GAAO,MAAA,CAAA,MAAA,CAAA,EAAA,EAAoB,KAAK,QAAL,CAAc,4BAAlC,EAAoE,KAAK,QAAL,CAAc,MAAd,CAA6B,KAAK,IAAlC,CAApE,CAAP;AAEF,SAAA,gBAAA,GAAmB,KAAnB;AAIN;;AAEO,EAAA,cAAc,CAAC,MAAD,EAA2C,WAA3C,EAAqE;AACzF,UAAM,MAAM,GAAG,mCAAgB,MAAhB,EAAwB,WAAxB,CAAf;;AACA,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CAAC,GAAD,CAA/C,EAAuD;AACrD,QAAI,OAAO,IAAP,KAAgB,QAApB,EAA8B;AAC5B,MAAA,MAAM,CAAC,IAAD,CAAN,GAAe,IAAf;AACD,KAFD,MAGK;AACH,MAAA,MAAM,CAAC,MAAP,CAAc,MAAd,EAAsB,IAAtB;AACD;AACF;;AACD,SAAO,MAAP;AACD;;AAED,SAAS,uBAAT,CAAiC,IAAjC,EAA0C;AACxC,MAAI,IAAI,CAAC,KAAL,IAAc,IAAlB,EAAwB;AACtB,SAAK,MAAM,QAAX,IAAuB,MAAM,CAAC,IAAP,CAAY,IAAI,CAAC,KAAjB,CAAvB,EAAgD;AAC9C,YAAM,IAAI,GAAG,IAAI,CAAC,KAAL,CAAW,QAAX,CAAb;;AACA,UAAI,IAAI,CAAC,SAAL,KAAmB,iBAAnB,IAAwC,IAAI,CAAC,eAAD,CAAJ,KAA0B,IAAtE,EAA4E;AAC1E,eAAO,IAAP;AACD;AACF;AACF;;AACD,SAAO,KAAP;AACD;;AAED,SAAS,uBAAT,GAAgC;AAC9B;AACA;AACA,SAAO,CAAC,UAAD,EAAa,SAAb,EAAwB,SAAxB,EAAmC,oBAAnC,EAAyD,eAAzD,CAAP;AACD,C","sourcesContent":["import { Arch, deepAssign, executeAppBuilder, InvalidConfigurationError, log, replaceDefault as _replaceDefault, serializeToYaml, toLinuxArchString } from \"builder-util\"\nimport { asArray } from \"builder-util-runtime\"\nimport { outputFile, readFile } from \"fs-extra\"\nimport { safeLoad } from \"js-yaml\"\nimport * as path from \"path\"\nimport * as semver from \"semver\"\nimport { SnapOptions } from \"..\"\nimport { Target } from \"../core\"\nimport { LinuxPackager } from \"../linuxPackager\"\nimport { PlugDescriptor } from \"../options/SnapOptions\"\nimport { getTemplatePath } from \"../util/pathManager\"\nimport { LinuxTargetHelper } from \"./LinuxTargetHelper\"\nimport { createStageDirPath } from \"./targetUtil\"\n\nconst defaultPlugs = [\"desktop\", \"desktop-legacy\", \"home\", \"x11\", \"wayland\", \"unity7\", \"browser-support\", \"network\", \"gsettings\", \"pulseaudio\", \"opengl\"]\n\nexport default class SnapTarget extends Target {\n readonly options: SnapOptions = {...this.packager.platformSpecificBuildOptions, ...(this.packager.config as any)[this.name]}\n\n public isUseTemplateApp = false\n\n constructor(name: string, private readonly packager: LinuxPackager, private readonly helper: LinuxTargetHelper, readonly outDir: string) {\n super(name)\n }\n\n private replaceDefault(inList: Array<string> | null | undefined, defaultList: Array<string>) {\n const result = _replaceDefault(inList, defaultList)\n if (result !== defaultList) {\n this.isUseTemplateApp = false\n }\n return result\n }\n\n private async createDescriptor(arch: Arch): Promise<any> {\n if (!this.isElectronVersionGreaterOrEqualThen(\"4.0.0\")) {\n if (!this.isElectronVersionGreaterOrEqualThen(\"2.0.0-beta.1\")) {\n throw new InvalidConfigurationError(\"Electron 2 and higher is required to build Snap\")\n }\n\n log.warn(\"Electron 4 and higher is highly recommended for Snap\")\n }\n\n const appInfo = this.packager.appInfo\n const snapName = this.packager.executableName.toLowerCase()\n const options = this.options\n\n const plugs = normalizePlugConfiguration(this.options.plugs)\n\n const plugNames = this.replaceDefault(plugs == null ? null : Object.getOwnPropertyNames(plugs), defaultPlugs)\n const buildPackages = asArray(options.buildPackages)\n const defaultStagePackages = getDefaultStagePackages()\n const stagePackages = this.replaceDefault(options.stagePackages, defaultStagePackages)\n\n this.isUseTemplateApp = this.options.useTemplateApp !== false &&\n (arch === Arch.x64 || arch === Arch.armv7l) &&\n buildPackages.length === 0 &&\n isArrayEqualRegardlessOfSort(stagePackages, defaultStagePackages)\n\n const appDescriptor: any = {\n command: \"command.sh\",\n plugs: plugNames,\n adapter: \"none\",\n }\n\n const snap: any = safeLoad(await readFile(path.join(getTemplatePath(\"snap\"), \"snapcraft.yaml\"), \"utf-8\"))\n if (this.isUseTemplateApp) {\n delete appDescriptor.adapter\n }\n if (options.grade != null) {\n snap.grade = options.grade\n }\n if (options.confinement != null) {\n snap.confinement = options.confinement\n }\n deepAssign(snap, {\n name: snapName,\n version: appInfo.version,\n summary: options.summary || appInfo.productName,\n description: this.helper.getDescription(options),\n architectures: [toLinuxArchString(arch, \"snap\")],\n apps: {\n [snapName]: appDescriptor\n },\n parts: {\n app: {\n \"stage-packages\": stagePackages,\n }\n },\n })\n\n if (options.confinement === \"classic\") {\n delete appDescriptor.plugs\n delete snap.plugs\n }\n else {\n const archTriplet = archNameToTriplet(arch)\n appDescriptor.environment = {\n // https://github.com/electron-userland/electron-builder/issues/4007\n // https://github.com/electron/electron/issues/9056\n DISABLE_WAYLAND: \"1\",\n TMPDIR: \"$XDG_RUNTIME_DIR\",\n PATH: \"$SNAP/usr/sbin:$SNAP/usr/bin:$SNAP/sbin:$SNAP/bin:$PATH\",\n SNAP_DESKTOP_RUNTIME: \"$SNAP/gnome-platform\",\n LD_LIBRARY_PATH: [\n \"$SNAP_LIBRARY_PATH\",\n \"$SNAP/lib:$SNAP/usr/lib:$SNAP/lib/\" + archTriplet + \":$SNAP/usr/lib/\" + archTriplet,\n \"$LD_LIBRARY_PATH:$SNAP/lib:$SNAP/usr/lib\",\n \"$SNAP/lib/\" + archTriplet + \":$SNAP/usr/lib/\" + archTriplet\n ].join(\":\"),\n ...options.environment,\n }\n\n if (plugs != null) {\n for (const plugName of plugNames) {\n const plugOptions = plugs[plugName]\n if (plugOptions == null) {\n continue\n }\n\n snap.plugs[plugName] = plugOptions\n }\n }\n }\n\n if (buildPackages.length > 0) {\n snap.parts.app[\"build-packages\"] = buildPackages\n }\n if (options.after != null) {\n snap.parts.app.after = options.after\n }\n\n if (options.assumes != null) {\n snap.assumes = asArray(options.assumes)\n }\n\n return snap\n }\n\n async build(appOutDir: string, arch: Arch): Promise<any> {\n const packager = this.packager\n const options = this.options\n // tslint:disable-next-line:no-invalid-template-strings\n const artifactName = packager.expandArtifactNamePattern(this.options, \"snap\", arch, \"${name}_${version}_${arch}.${ext}\", false)\n const artifactPath = path.join(this.outDir, artifactName)\n await packager.info.callArtifactBuildStarted({\n targetPresentableName: \"snap\",\n file: artifactPath,\n arch,\n })\n\n const snap = await this.createDescriptor(arch)\n if (this.isUseTemplateApp) {\n delete snap.parts\n }\n\n const stageDir = await createStageDirPath(this, packager, arch)\n const snapArch = toLinuxArchString(arch, \"snap\")\n const args = [\n \"snap\",\n \"--app\", appOutDir,\n \"--stage\", stageDir,\n \"--arch\", snapArch,\n \"--output\", artifactPath,\n \"--executable\", this.packager.executableName,\n ]\n\n await this.helper.icons\n if (this.helper.maxIconPath != null) {\n if (!this.isUseTemplateApp) {\n snap.icon = \"snap/gui/icon.png\"\n }\n args.push(\"--icon\", this.helper.maxIconPath)\n }\n\n // snapcraft.yaml inside a snap directory\n const snapMetaDir = path.join(stageDir, this.isUseTemplateApp ? \"meta\" : \"snap\")\n const desktopFile = path.join(snapMetaDir, \"gui\", `${snap.name}.desktop`)\n await this.helper.writeDesktopEntry(this.options, packager.executableName, desktopFile, {\n // tslint:disable:no-invalid-template-strings\n Icon: \"${SNAP}/meta/gui/icon.png\"\n })\n\n if (this.isElectronVersionGreaterOrEqualThen(\"5.0.0\") && !isBrowserSandboxAllowed(snap)) {\n args.push(\"--extraAppArgs=--no-sandbox\")\n if (this.isUseTemplateApp) {\n args.push(\"--exclude\", \"chrome-sandbox\")\n }\n }\n\n if (packager.packagerOptions.effectiveOptionComputed != null && await packager.packagerOptions.effectiveOptionComputed({snap, desktopFile, args})) {\n return\n }\n\n await outputFile(path.join(snapMetaDir, this.isUseTemplateApp ? \"snap.yaml\" : \"snapcraft.yaml\"), serializeToYaml(snap))\n\n const hooksDir = await packager.getResource(options.hooks, \"snap-hooks\")\n if (hooksDir != null) {\n args.push(\"--hooks\", hooksDir)\n }\n\n if (this.isUseTemplateApp) {\n args.push(\"--template-url\", `electron4:${snapArch}`)\n }\n await executeAppBuilder(args)\n\n await packager.info.callArtifactBuildCompleted({\n file: artifactPath,\n safeArtifactName: packager.computeSafeArtifactName(artifactName, \"snap\", arch, false),\n target: this,\n arch,\n packager,\n publishConfig: options.publish == null ? {provider: \"snapStore\"} : null,\n })\n }\n\n private isElectronVersionGreaterOrEqualThen(version: string) {\n return semver.gte(this.packager.config.electronVersion || \"5.0.3\", version)\n }\n}\n\nfunction archNameToTriplet(arch: Arch): string {\n switch (arch) {\n case Arch.x64:\n return \"x86_64-linux-gnu\"\n case Arch.ia32:\n return \"i386-linux-gnu\"\n case Arch.armv7l:\n // noinspection SpellCheckingInspection\n return \"arm-linux-gnueabihf\"\n case Arch.arm64:\n return \"aarch64-linux-gnu\"\n\n default:\n throw new Error(`Unsupported arch ${arch}`)\n }\n}\n\nfunction isArrayEqualRegardlessOfSort(a: Array<string>, b: Array<string>) {\n a = a.slice()\n b = b.slice()\n a.sort()\n b.sort()\n return a.length === b.length && a.every((value, index) => value === b[index])\n}\n\nfunction normalizePlugConfiguration(raw: Array<string | PlugDescriptor> | PlugDescriptor | null | undefined): { [key: string]: {[name: string]: any; } | null } | null {\n if (raw == null) {\n return null\n }\n\n const result: any = {}\n for (const item of (Array.isArray(raw) ? raw : [raw])) {\n if (typeof item === \"string\") {\n result[item] = null\n }\n else {\n Object.assign(result, item)\n }\n }\n return result\n}\n\nfunction isBrowserSandboxAllowed(snap: any): boolean {\n if (snap.plugs != null) {\n for (const plugName of Object.keys(snap.plugs)) {\n const plug = snap.plugs[plugName]\n if (plug.interface === \"browser-support\" && plug[\"allow-sandbox\"] === true) {\n return true\n }\n }\n }\n return false\n}\n\nfunction getDefaultStagePackages() {\n // libxss1 - was \"error while loading shared libraries: libXss.so.1\" on Xubuntu 16.04\n // noinspection SpellCheckingInspection\n return [\"libnspr4\", \"libnss3\", \"libxss1\", \"libappindicator3-1\", \"libsecret-1-0\"]\n}"],"sourceRoot":""}