mirror of
https://github.com/tutao/tutanota.git
synced 2025-10-19 16:03:43 +00:00
[desktop] define options object for desktopBuilder
This commit is contained in:
parent
592b48b783
commit
a61c8fe96a
6 changed files with 105 additions and 44 deletions
|
@ -3,7 +3,17 @@ const babel = Promise.promisifyAll(require("babel-core"))
|
|||
const fs = Promise.promisifyAll(require("fs-extra"))
|
||||
const path = require("path")
|
||||
|
||||
function build(dirname, version, targets, updateUrl, nameSuffix, notarize, outDir, unpacked) {
|
||||
function build(opts) {
|
||||
let {
|
||||
dirname, // directory this was called from
|
||||
version, // application version that gets built
|
||||
targets, // which desktop targets to build and how to package them
|
||||
updateUrl, // where the client should pull its updates from, if any
|
||||
nameSuffix, // suffix used to distinguish test-, prod- or snapshot builds on the same machine
|
||||
notarize, // for the MacOs notarization feature
|
||||
outDir, // where to copy the finished artifacts
|
||||
unpacked // output desktop client without packing it into an installer
|
||||
} = opts
|
||||
const targetString = Object.keys(targets)
|
||||
.filter(k => typeof targets[k] !== "undefined")
|
||||
.join(" ")
|
||||
|
@ -17,15 +27,16 @@ function build(dirname, version, targets, updateUrl, nameSuffix, notarize, outDi
|
|||
.map(fn => path.join(dirname, './src/translations', fn))
|
||||
|
||||
console.log("Updating electron-builder config...")
|
||||
const content = require('./electron-package-json-template')(
|
||||
nameSuffix,
|
||||
version,
|
||||
updateUrl,
|
||||
path.join(dirname, "/resources/desktop-icons/logo-solo-red.png"),
|
||||
nameSuffix !== '-snapshot' && updateUrl !== "", // don't sign if it's a test build or if we don't download updates
|
||||
notarize,
|
||||
unpacked
|
||||
)
|
||||
const content = require('./electron-package-json-template')({
|
||||
nameSuffix: nameSuffix,
|
||||
version: version,
|
||||
updateUrl: updateUrl,
|
||||
iconPath: path.join(dirname, "/resources/desktop-icons/logo-solo-red.png"),
|
||||
sign: nameSuffix !== '-snapshot' && updateUrl !== "",
|
||||
nameSuffix: nameSuffix,
|
||||
notarize: notarize,
|
||||
unpacked: unpacked
|
||||
})
|
||||
let writeConfig = fs.writeFileAsync("./build/dist/package.json", JSON.stringify(content), 'utf-8')
|
||||
|
||||
//prepare files
|
||||
|
@ -53,13 +64,22 @@ function build(dirname, version, targets, updateUrl, nameSuffix, notarize, outDi
|
|||
.then(() => {
|
||||
const installerDir = path.join(distDir, 'installers')
|
||||
console.log("Move artifacts to", outDir)
|
||||
const unpackedFilter = file => file.endsWith("-unpacked") || file === "mac"
|
||||
const packedFilter = file => file.startsWith(content.name) || file.endsWith('.yml')
|
||||
const outFiles = fs.readdirSync(installerDir)
|
||||
let filesToCopy
|
||||
// the output of the builder is very inconsistently named and contains
|
||||
// files that are irrelevant to us. these filters enable us to copy them
|
||||
// without naming every possible file name explicitly
|
||||
if (unpacked) {
|
||||
// when the unpacked option is set, output is a directory for each platform, with
|
||||
// the mac directory missing the "-unpacked" suffix.
|
||||
filesToCopy = outFiles.filter(file => file.endsWith("-unpacked") || file === "mac")
|
||||
} else {
|
||||
// the installers start with the application name + suffix. the update manifests end in yml.
|
||||
filesToCopy = outFiles.filter(file => file.startsWith(content.name) || file.endsWith('.yml'))
|
||||
}
|
||||
|
||||
return Promise.all(
|
||||
fs.readdirSync(installerDir)
|
||||
.filter(unpacked ? unpackedFilter : packedFilter)
|
||||
.map(file => fs.moveAsync(
|
||||
filesToCopy.map(file => fs.moveAsync(
|
||||
path.join(installerDir, file),
|
||||
path.join(outDir, file)
|
||||
)
|
||||
|
|
|
@ -6,7 +6,9 @@ const pj = require('../package.json')
|
|||
* 2. copied to app-desktop/build/dist from dist.js (DesktopBuilder)
|
||||
*/
|
||||
|
||||
module.exports = function (nameSuffix, version, updateUrl, iconPath, sign, notarize, unpacked) {
|
||||
module.exports = function (opts) {
|
||||
const {nameSuffix, version, updateUrl, iconPath, sign, notarize, unpacked} = opts
|
||||
|
||||
return {
|
||||
"name": "tutanota-desktop" + nameSuffix,
|
||||
"main": "./src/desktop/DesktopMain.js",
|
||||
|
|
60
dist.js
60
dist.js
|
@ -185,34 +185,66 @@ function buildWebapp() {
|
|||
function buildDesktopClient() {
|
||||
if (options.desktop) {
|
||||
const desktopBuilder = require('./buildSrc/DesktopBuilder.js')
|
||||
if (options.stage === "release") {
|
||||
const updateUrl = options.customDesktopRelease
|
||||
const desktopBaseOpts = {
|
||||
dirname: __dirname,
|
||||
version: version,
|
||||
targets: options.desktop,
|
||||
updateUrl: options.customDesktopRelease
|
||||
? ""
|
||||
: "https://mail.tutanota.com/desktop"
|
||||
const notarize = !!options.customDesktopRelease
|
||||
: "https://mail.tutanota.com/desktop",
|
||||
nameSuffix: "",
|
||||
notarize: !!options.customDesktopRelease,
|
||||
outDir: options.outDir,
|
||||
unpacked: options.unpacked
|
||||
}
|
||||
if (options.stage === "release") {
|
||||
const buildPromise = createHtml(env.create(SystemConfig.distRuntimeConfig(bundles), "https://mail.tutanota.com", version, "Desktop", true), bundles)
|
||||
.then(() => desktopBuilder.build(__dirname, version, options.desktop, updateUrl, "", notarize, options.outDir, options.unpacked))
|
||||
.then(() => desktopBuilder.build(desktopBaseOpts))
|
||||
if (!options.customDesktopRelease) { // don't build the test version for manual/custom builds
|
||||
const desktopTestOpts = Object.assign({}, desktopBaseOpts, {
|
||||
updateUrl: "https://test.tutanota.com",
|
||||
nameSuffix: "-test",
|
||||
notarize: true
|
||||
})
|
||||
buildPromise.then(() => createHtml(env.create(SystemConfig.distRuntimeConfig(bundles), "https://test.tutanota.com", version, "Desktop", true), bundles))
|
||||
.then(() => desktopBuilder.build(__dirname, version, options.desktop, "https://test.tutanota.com/desktop", "-test", /*notarize*/true, options.outDir, options.unpacked))
|
||||
.then(() => desktopBuilder.build(desktopTestOpts))
|
||||
}
|
||||
return buildPromise
|
||||
} else if (options.stage === "local") {
|
||||
const desktopLocalOpts = Object.assign({}, desktopBaseOpts, {
|
||||
version: `${new Date().getTime()}.0.0`,
|
||||
updateUrl: "http://localhost:9000",
|
||||
nameSuffix: "-snapshot",
|
||||
notarize: false
|
||||
})
|
||||
return createHtml(env.create(SystemConfig.distRuntimeConfig(bundles), "http://localhost:9000", version, "Desktop", true), bundles)
|
||||
.then(() => desktopBuilder.build(__dirname, `${new Date().getTime()}.0.0`,
|
||||
options.desktop, "http://localhost:9000", "-snapshot", options.outDir, options.unpacked))
|
||||
.then(() => desktopBuilder.build(desktopLocalOpts))
|
||||
} else if (options.stage === "test") {
|
||||
const desktopTestOpts = Object.assign({}, desktopBaseOpts, {
|
||||
version: `${new Date().getTime()}.0.0`,
|
||||
updateUrl: "https://test.tutanota.com/desktop",
|
||||
nameSuffix: "-test",
|
||||
notarize: false
|
||||
})
|
||||
return createHtml(env.create(SystemConfig.distRuntimeConfig(bundles), "https://test.tutanota.com", version, "Desktop", true), bundles)
|
||||
.then(() => desktopBuilder.build(__dirname, `${new Date().getTime()}.0.0`,
|
||||
options.desktop, "https://test.tutanota.com/desktop", "-test", options.outDir, options.unpacked))
|
||||
.then(() => desktopBuilder.build(desktopTestOpts))
|
||||
} else if (options.stage === "prod") {
|
||||
const desktopProdOpts = Object.assign({}, desktopBaseOpts, {
|
||||
version: `${new Date().getTime()}.0.0`,
|
||||
updateUrl: "http://localhost:9000/desktop",
|
||||
notarize: false
|
||||
})
|
||||
return createHtml(env.create(SystemConfig.distRuntimeConfig(bundles), "https://mail.tutanota.com", version, "Desktop", true), bundles)
|
||||
.then(() => desktopBuilder.build(__dirname, `${new Date().getTime()}.0.0`,
|
||||
options.desktop, "http://localhost:9000/desktop", "", options.outDir, options.unpacked))
|
||||
.then(() => desktopBuilder.build(desktopProdOpts))
|
||||
} else { // stage = host
|
||||
const desktopHostOpts = Object.assign({}, desktopBaseOpts, {
|
||||
version: `${new Date().getTime()}.0.0`,
|
||||
updateUrl: "http://localhost:9000/desktop-snapshot",
|
||||
nameSuffix: "-snapshot",
|
||||
notarize: false
|
||||
})
|
||||
return createHtml(env.create(SystemConfig.distRuntimeConfig(bundles), options.host, version, "Desktop", true), bundles)
|
||||
.then(() => desktopBuilder.build(__dirname, `${new Date().getTime()}.0.0`,
|
||||
options.desktop, "http://localhost:9000/desktop-snapshot", "-snapshot", options.outDir, options.unpacked))
|
||||
.then(() => desktopBuilder.build(desktopHostOpts))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
14
make.js
14
make.js
|
@ -87,13 +87,13 @@ function startDesktop() {
|
|||
if (options.desktop) {
|
||||
console.log("Trying to start desktop client...")
|
||||
const version = require('./package.json').version
|
||||
const packageJSON = require('./buildSrc/electron-package-json-template.js')(
|
||||
"-debug",
|
||||
version,
|
||||
"http://localhost:9000",
|
||||
path.join(__dirname, "/resources/desktop-icons/logo-solo-red.png"),
|
||||
false
|
||||
)
|
||||
const packageJSON = require('./buildSrc/electron-package-json-template.js')({
|
||||
nameSuffix: "-debug",
|
||||
version: version,
|
||||
updateUrl: "http://localhost:9000",
|
||||
iconPath: path.join(__dirname, "/resources/desktop-icons/logo-solo-red.png"),
|
||||
sign: false
|
||||
})
|
||||
const content = JSON.stringify(packageJSON)
|
||||
return fs.writeFileAsync("./build/package.json", content, 'utf-8')
|
||||
.then(() => {
|
||||
|
|
|
@ -36,6 +36,8 @@ export class ElectronUpdater {
|
|||
error: (m: string, ...args: any) => console.error.apply(console, ["autoUpdater error:\n", m].concat(args)),
|
||||
}
|
||||
autoUpdater.logger = null
|
||||
// default behaviour is to just dl the update as soon as found, but we want to check the signature
|
||||
// before doing telling the updater to get the file.
|
||||
autoUpdater.autoDownload = false
|
||||
autoUpdater.autoInstallOnAppQuit = false
|
||||
autoUpdater.on('update-available', updateInfo => {
|
||||
|
|
|
@ -7,9 +7,14 @@ o.spec('desktop config migrator test', function () {
|
|||
o("migrations result in correct default config, client", function () {
|
||||
const migrator = n.subject('../../src/desktop/config/migrations/DesktopConfigMigrator.js').default
|
||||
const configPath = "../../../../../../buildSrc/electron-package-json-template.js"
|
||||
const oldConfig = require(configPath)(
|
||||
"", "0.0.0", "", "", "", false, false
|
||||
)["tutao-config"]["defaultDesktopConfig"]
|
||||
const oldConfig = require(configPath)({
|
||||
nameSuffix: "",
|
||||
version: "0.0.0",
|
||||
updateUrl: "",
|
||||
iconPath: "",
|
||||
sign: false,
|
||||
notarize: false
|
||||
})["tutao-config"]["defaultDesktopConfig"]
|
||||
const requiredResult = {
|
||||
"heartbeatTimeoutInSeconds": 30,
|
||||
"defaultDownloadPath": null,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue