tutanota/buildSrc/electron-package-json-template.js

175 lines
5.4 KiB
JavaScript
Raw Normal View History

import path from "node:path"
import { readFileSync } from "node:fs"
import { getElectronVersion } from "./getInstalledModuleVersion.js"
2019-09-13 13:49:11 +02:00
/**
* This is used for launching electron:
2019-02-05 15:15:05 +01:00
* 1. copied to app-desktop/build from make.js
2023-10-05 10:51:49 +02:00
* 2. copied to app-desktop/build from dist.js (DesktopBuilder)
*
* @param p {object}
* @param p.nameSuffix {string}
* @param p.version {string}
* @param p.updateUrl {string}
* @param p.iconPath {string}
* @param p.sign {boolean}
* @param [p.notarize] {boolean}
* @param [p.unpacked] {boolean}
* @param p.architecture
*/
export default async function generateTemplate({ nameSuffix, version, updateUrl, iconPath, sign, notarize, unpacked, architecture }) {
const appName = "tutanota-desktop" + nameSuffix
const appId = "de.tutao.tutanota" + nameSuffix
if (process.env.JENKINS_HOME && process.env.DEBUG_SIGN) throw new Error("Tried to DEBUG_SIGN in CI!")
2022-12-27 15:37:40 +01:00
const debugKey = process.env.DEBUG_SIGN ? readFileSync(path.join(process.env.DEBUG_SIGN, "test.pubkey"), { encoding: "utf8" }) : undefined
const log = console.log.bind(console)
2019-07-18 15:16:13 +02:00
return {
2022-12-27 15:37:40 +01:00
name: appName,
main: "./desktop/DesktopMain.js",
version: version,
author: "Tutao GmbH",
description: "The desktop client for Tutanota, the secure e-mail service.",
scripts: {
start: "electron .",
2019-07-18 15:16:13 +02:00
},
"tutao-config": {
2022-12-27 15:37:40 +01:00
pubKeys: [
"-----BEGIN PUBLIC KEY-----\n" +
"MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAhFrLW999Y/ODqGfGKSzh\n" +
"7SFm6UgIj5scpb1r+KmEgVr/3zmd973+u2z5gG/wtayUbdVUGlzTgxqTE76BGTBR\n" +
"szq932uTsPfjRbtbyjIOzfzPvkyAB1Ew91gQk5ubrO1VCbXAZyuFi7RxDibuklLO\n" +
"lzHyjKyEIVTTdOqOTE+mg/vr41MxDW0X4nZw5MT1mIV/aYGeOSdtNdFsL69aR+d7\n" +
"KufD43J60FUS9G0tf4KmyQInmGqC8MSXCO0SMwwEJZDxDzkBsSensKfS0HzIjCXS\n" +
"or/Ahu6RwhEhjm7MyXbhiDyis+kGHSfatsO5KWWuZ4xgCEUO0L6vMQwr5M/qYOj1\n" +
"7QIDAQAB\n" +
"-----END PUBLIC KEY-----",
"-----BEGIN PUBLIC KEY-----\n" +
"MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAk4NkSbs41KjuNZfFco2l\n" +
"unXXFOIkrdBfDmIiVfVTYagEk2cN9HkjCkiNsHucLHPuHb0reHsaxrDVE1lWGTPI\n" +
"0Lh5diLYdxJ+AGy/8j9jsO51hONqTujdD0mJs14YkVfOUXyHQh1z6WJCLc9jrN9+\n" +
"3dgKOlQRYW2mYise8ggYYcrRs/CY40s3/cQvrFSprFMPS6E+9lmIDp0hPKr9q90t\n" +
"IXmzihQyc8Q0VmAfCqEwUtx6RY6BGkqKiDoMh4Qs5ZwFxhoSfgrJiwBmv0HcX1yv\n" +
"QGNSdxrpLuMA/afCPdf49x3iwy+p+paXHKirgM5z6rnikk10Lko7dNXV0735PsZd\n" +
"dQIDAQAB\n" +
"-----END PUBLIC KEY-----",
debugKey,
],
2022-12-27 15:37:40 +01:00
pollingInterval: 1000 * 60 * 60 * 3, // 3 hours
iconName: "logo-solo-red.png",
fileManagerTimeout: 30000,
2019-07-18 15:16:13 +02:00
// true if this version checks its updates. use to prevent local builds from checking sigs.
2022-12-27 15:37:40 +01:00
checkUpdateSignature: sign,
appUserModelId: appId,
initialSseConnectTimeoutInSeconds: 60,
maxSseConnectTimeoutInSeconds: 2400,
configMigrationFunction: "migrateClient",
updateUrl,
2022-12-27 15:37:40 +01:00
defaultDesktopConfig: {
/**
* do not change defaultDesktopConfig
* instead, add migrations to src/desktop/DesktopConfigMigrator.js
*/
2022-12-27 15:37:40 +01:00
heartbeatTimeoutInSeconds: 30,
defaultDownloadPath: null,
enableAutoUpdate: true,
runAsTrayApp: true,
},
2019-07-18 15:16:13 +02:00
},
dependencies: {},
2022-12-27 15:37:40 +01:00
build: {
electronVersion: await getElectronVersion(log),
icon: iconPath,
appId: appId,
productName: nameSuffix.length > 0 ? nameSuffix.slice(1) + " Tuta Mail" : "Tuta Mail",
2022-12-27 15:37:40 +01:00
artifactName: "${name}-${os}.${ext}",
asarUnpack: "desktop/*.node",
afterSign: notarize ? "buildSrc/notarize.cjs" : undefined,
protocols: [
2019-07-18 15:16:13 +02:00
{
2022-12-27 15:37:40 +01:00
name: "Mailto Links",
schemes: ["mailto"],
role: "Editor",
},
2019-07-18 15:16:13 +02:00
],
2022-12-27 15:37:40 +01:00
forceCodeSigning: sign,
publish: updateUrl
? {
2022-12-27 15:37:40 +01:00
provider: "generic",
url: updateUrl,
channel: "latest",
publishAutoUpdate: true,
useMultipleRangeRequest: false,
}
: undefined,
2022-12-27 15:37:40 +01:00
directories: {
output: "installers",
2019-07-18 15:16:13 +02:00
},
2022-12-27 15:37:40 +01:00
extraResources: {
from: path.dirname(iconPath),
to: "./icons/",
2019-07-18 15:16:13 +02:00
},
2022-12-27 15:37:40 +01:00
win: {
// relative to the project dirm which is ./build/
2022-12-27 15:37:40 +01:00
extraFiles: ["mapirs.dll"],
verifyUpdateCodeSignature: sign,
signDlls: sign,
publisherName: "Tutao GmbH",
sign: sign ? "./buildSrc/winsigner.cjs" : undefined,
signingHashAlgorithms: sign ? ["sha256"] : undefined,
target: [
2019-07-18 15:16:13 +02:00
{
2022-12-27 15:37:40 +01:00
target: unpacked ? "dir" : "nsis",
arch: architecture,
2022-12-27 15:37:40 +01:00
},
],
2019-07-18 15:16:13 +02:00
},
2022-12-27 15:37:40 +01:00
nsis: {
oneClick: false,
perMachine: false,
createStartMenuShortcut: true,
allowElevation: true,
allowToChangeInstallationDirectory: true,
include: path.join("..", "..", "buildSrc", "windows-installer.nsh"),
warningsAsErrors: true,
2019-07-18 15:16:13 +02:00
},
2022-12-27 15:37:40 +01:00
mac: {
hardenedRuntime: true,
type: "distribution",
gatekeeperAssess: false,
entitlements: "buildSrc/mac-entitlements.plist",
entitlementsInherit: "buildSrc/mac-entitlements.plist",
icon: path.join(path.dirname(iconPath), "logo-solo-red.png.icns"),
extendInfo: {
LSUIElement: 1, //hide dock icon on startup
2019-07-18 15:16:13 +02:00
},
2022-12-27 15:37:40 +01:00
target: unpacked
? [{ target: "dir", arch: architecture }]
: [
2022-12-27 15:37:40 +01:00
{
target: "zip",
arch: architecture,
2022-12-27 15:37:40 +01:00
},
{
target: "dmg",
arch: architecture,
},
2022-12-27 15:37:40 +01:00
],
2019-07-18 15:16:13 +02:00
},
2022-12-27 15:37:40 +01:00
linux: {
icon: path.join(path.dirname(iconPath), "icon/"),
2023-11-03 17:01:47 +01:00
synopsis: "Tuta Mail Desktop Client",
2022-12-27 15:37:40 +01:00
category: "Network",
desktop: {
StartupWMClass: appName,
2019-07-18 15:16:13 +02:00
},
2022-12-27 15:37:40 +01:00
target: [
2019-07-18 15:16:13 +02:00
{
2022-12-27 15:37:40 +01:00
target: unpacked ? "dir" : "AppImage",
arch: architecture,
2022-12-27 15:37:40 +01:00
},
],
},
},
2019-07-18 15:16:13 +02:00
}
2019-02-27 17:57:08 +01:00
}