Add release channels (Stable and Beta)

This commit is contained in:
Jonatan Heyman 2023-12-06 13:31:47 +01:00
parent 4b73d8d35c
commit 0c55dcecb0
5 changed files with 46 additions and 3 deletions

View File

@ -25,6 +25,7 @@ const schema = {
"emacsMetaKey": { "enum": [null, "alt", "meta"], default: null }, "emacsMetaKey": { "enum": [null, "alt", "meta"], default: null },
"showLineNumberGutter": {type: "boolean", default:true}, "showLineNumberGutter": {type: "boolean", default:true},
"showFoldGutter": {type: "boolean", default:true}, "showFoldGutter": {type: "boolean", default:true},
"releaseChannel": {enum: [null, "beta"], default: null},
}, },
}, },
@ -45,6 +46,7 @@ const defaults = {
emacsMetaKey: "meta", emacsMetaKey: "meta",
showLineNumberGutter: true, showLineNumberGutter: true,
showFoldGutter: true, showFoldGutter: true,
releaseChannel: null,
}, },
theme: "system", theme: "system",
} }

View File

@ -1,5 +1,6 @@
import { autoUpdater } from "electron-updater" import { autoUpdater } from "electron-updater"
import { app, dialog, ipcMain } from "electron" import { app, dialog, ipcMain } from "electron"
import CONFIG from "../config"
import { import {
UPDATE_AVAILABLE_EVENT, UPDATE_AVAILABLE_EVENT,
@ -24,6 +25,9 @@ autoUpdater.logger.transports.file.level = "info"
autoUpdater.autoDownload = false autoUpdater.autoDownload = false
// set channel
autoUpdater.channel = CONFIG.get("settings.releaseChannel")
autoUpdater.on('error', (error) => { autoUpdater.on('error', (error) => {
window?.webContents.send(UPDATE_ERROR, error == null ? "unknown" : (error.stack || error).toString()) window?.webContents.send(UPDATE_ERROR, error == null ? "unknown" : (error.stack || error).toString())
//dialog.showErrorBox('Error: ', error == null ? "unknown" : (error.stack || error).toString()) //dialog.showErrorBox('Error: ', error == null ? "unknown" : (error.stack || error).toString())
@ -63,12 +67,19 @@ ipcMain.handle(UPDATE_INSTALL_AND_RESTART, () => {
setImmediate(() => autoUpdater.quitAndInstall(true, true)) setImmediate(() => autoUpdater.quitAndInstall(true, true))
}) })
ipcMain.handle(UPDATE_CHECK_FOR_UPDATES, () => {
export function checkForUpdates() {
const settingsChannel = CONFIG.get("settings.releaseChannel")
autoUpdater.channel = (settingsChannel === null ? "latest" : settingsChannel)
autoUpdater.checkForUpdates() autoUpdater.checkForUpdates()
// for development, the autoUpdater will not work, so we need to trigger the event manually // for development, the autoUpdater will not work, so we need to trigger the event manually
if (process.env.NODE_ENV === "development") { if (process.env.NODE_ENV === "development") {
window?.webContents.send(UPDATE_NOT_AVAILABLE_EVENT) window?.webContents.send(UPDATE_NOT_AVAILABLE_EVENT)
} }
}
ipcMain.handle(UPDATE_CHECK_FOR_UPDATES, () => {
checkForUpdates()
}) })
export function initializeAutoUpdate(win) { export function initializeAutoUpdate(win) {

View File

@ -9,7 +9,7 @@ import { WINDOW_CLOSE_EVENT, SETTINGS_CHANGE_EVENT } from '../constants';
import CONFIG from "../config" import CONFIG from "../config"
import { onBeforeInputEvent } from "../keymap" import { onBeforeInputEvent } from "../keymap"
import { isMac } from '../detect-platform'; import { isMac } from '../detect-platform';
import { initializeAutoUpdate } from './auto-update'; import { initializeAutoUpdate, checkForUpdates } from './auto-update';
import { fixElectronCors } from './cors'; import { fixElectronCors } from './cors';
@ -59,6 +59,12 @@ const isDev = !!process.env.VITE_DEV_SERVER_URL
let currentKeymap = CONFIG.get("settings.keymap") let currentKeymap = CONFIG.get("settings.keymap")
let contentSaved = false let contentSaved = false
// if this version is a beta version, set the release channel to beta
const isBetaVersion = app.getVersion().includes("beta")
if (isBetaVersion) {
CONFIG.set("settings.releaseChannel", "beta")
}
async function createWindow() { async function createWindow() {
// read any stored window settings from config, or use defaults // read any stored window settings from config, or use defaults
@ -206,6 +212,13 @@ ipcMain.handle('settings:set', (event, settings) => {
if (settings.keymap !== CONFIG.get("settings.keymap")) { if (settings.keymap !== CONFIG.get("settings.keymap")) {
currentKeymap = settings.keymap currentKeymap = settings.keymap
} }
const releaseChannelChanged = settings.releaseChannel !== CONFIG.get("settings.releaseChannel")
CONFIG.set("settings", settings) CONFIG.set("settings", settings)
if (releaseChannelChanged) {
// release channel changed, check for updates
checkForUpdates()
}
win?.webContents.send(SETTINGS_CHANGE_EVENT, settings) win?.webContents.send(SETTINGS_CHANGE_EVENT, settings)
}) })

View File

@ -14,6 +14,7 @@
}, },
"build": { "build": {
"appId": "com.heynote.app", "appId": "com.heynote.app",
"generateUpdatesFilesForAllChannels": true,
"directories": { "directories": {
"buildResources": "resources" "buildResources": "resources"
} }

View File

@ -16,6 +16,11 @@
isMac: window.heynote.platform.isMac, isMac: window.heynote.platform.isMac,
showLineNumberGutter: this.initialSettings.showLineNumberGutter, showLineNumberGutter: this.initialSettings.showLineNumberGutter,
showFoldGutter: this.initialSettings.showFoldGutter, showFoldGutter: this.initialSettings.showFoldGutter,
releaseChannels: [
{ name: "Stable", value: null },
{ name: "Beta", value: "beta" },
],
releaseChannel: this.initialSettings.releaseChannel,
} }
}, },
@ -40,6 +45,7 @@
showFoldGutter: this.showFoldGutter, showFoldGutter: this.showFoldGutter,
keymap: this.keymap, keymap: this.keymap,
emacsMetaKey: this.metaKey, emacsMetaKey: this.metaKey,
releaseChannel: this.releaseChannel,
}) })
} }
} }
@ -91,6 +97,16 @@
</div> </div>
</div> </div>
</div> </div>
<div class="row">
<div class="entry">
<h2>Release Channel</h2>
<select ref="releaseChannelSelector" v-model="releaseChannel" @change="updateSettings">
<template v-for="rc in releaseChannels" :key="rc.value">
<option :selected="rc.value === releaseChannel" :value="rc.value">{{ rc.name }}</option>
</template>
</select>
</div>
</div>
</div> </div>
<button <button
@click="$emit('closeSettings')" @click="$emit('closeSettings')"