Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Beta release channel #4

Merged
merged 5 commits into from
Dec 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions electron/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ const schema = {
"emacsMetaKey": { "enum": [null, "alt", "meta"], default: null },
"showLineNumberGutter": {type: "boolean", default:true},
"showFoldGutter": {type: "boolean", default:true},
"allowBetaVersions": {type: "boolean", default: false},
},
},

Expand All @@ -45,6 +46,7 @@ const defaults = {
emacsMetaKey: "meta",
showLineNumberGutter: true,
showFoldGutter: true,
allowBetaVersions: false,
},
theme: "system",
}
Expand Down
25 changes: 23 additions & 2 deletions electron/main/auto-update.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { autoUpdater } from "electron-updater"
import { app, dialog, ipcMain } from "electron"
import CONFIG from "../config"

import {
UPDATE_AVAILABLE_EVENT,
Expand All @@ -10,7 +11,7 @@ import {
UPDATE_START_DOWNLOAD,
UPDATE_INSTALL_AND_RESTART,
UPDATE_CHECK_FOR_UPDATES,
} from '../constants'
} from '../constants'


// will reference the main window
Expand All @@ -23,6 +24,7 @@ autoUpdater.logger = log
autoUpdater.logger.transports.file.level = "info"

autoUpdater.autoDownload = false
autoUpdater.allowDowngrade = true

autoUpdater.on('error', (error) => {
window?.webContents.send(UPDATE_ERROR, error == null ? "unknown" : (error.stack || error).toString())
Expand Down Expand Up @@ -63,14 +65,33 @@ ipcMain.handle(UPDATE_INSTALL_AND_RESTART, () => {
setImmediate(() => autoUpdater.quitAndInstall(true, true))
})

ipcMain.handle(UPDATE_CHECK_FOR_UPDATES, () => {

export function checkForUpdates() {
autoUpdater.allowPrerelease = CONFIG.get("settings.allowBetaVersions")
autoUpdater.checkForUpdates()
// for development, the autoUpdater will not work, so we need to trigger the event manually
if (process.env.NODE_ENV === "development") {
window?.webContents.send(UPDATE_NOT_AVAILABLE_EVENT)
}
}

ipcMain.handle(UPDATE_CHECK_FOR_UPDATES, () => {
checkForUpdates()
})

export function initializeAutoUpdate(win) {
window = win

/**
* To debug auto updates (actually downloading an update won't work),
* uncomment the lines below, and create a dev-app-update.yml with the content:
*
* owner: heyman
* repo: heynote
* provider: github
*/
// Useful for some dev/debugging tasks, but download can
// not be validated becuase dev app is not signed
//autoUpdater.updateConfigPath = "/Users/heyman/projects/heynote/dev-app-update.yml" //path.join(__dirname, 'dev-app-update.yml');
//autoUpdater.forceDevUpdateConfig = true;
}
10 changes: 8 additions & 2 deletions electron/main/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { WINDOW_CLOSE_EVENT, SETTINGS_CHANGE_EVENT } from '../constants';
import CONFIG from "../config"
import { onBeforeInputEvent } from "../keymap"
import { isMac } from '../detect-platform';
import { initializeAutoUpdate } from './auto-update';
import { initializeAutoUpdate, checkForUpdates } from './auto-update';
import { fixElectronCors } from './cors';


Expand Down Expand Up @@ -59,6 +59,12 @@ const isDev = !!process.env.VITE_DEV_SERVER_URL
let currentKeymap = CONFIG.get("settings.keymap")
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.allowBetaVersions", true)
}


async function createWindow() {
// read any stored window settings from config, or use defaults
Expand Down Expand Up @@ -203,7 +209,7 @@ ipcMain.handle('buffer-content:saveAndQuit', async (event, content) => {
})

ipcMain.handle('settings:set', (event, settings) => {
if (settings.keymap !== CONFIG.get("keymap")) {
if (settings.keymap !== CONFIG.get("settings.keymap")) {
currentKeymap = settings.keymap
}
CONFIG.set("settings", settings)
Expand Down
68 changes: 27 additions & 41 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
},
"build": {
"appId": "com.heynote.app",
"generateUpdatesFilesForAllChannels": true,
"directories": {
"buildResources": "resources"
}
Expand Down Expand Up @@ -52,7 +53,7 @@
"electron-builder": "^23.6.0",
"electron-builder-notarize": "^1.5.1",
"electron-store": "^8.1.0",
"electron-updater": "^5.3.0",
"electron-updater": "^6.1.7",
"fs-jetpack": "^5.1.0",
"prettier": "^2.8.4",
"rollup-plugin-license": "^3.0.1",
Expand Down
1 change: 1 addition & 0 deletions src/components/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@
:languageAuto="languageAuto"
:theme="theme"
:systemTheme="systemTheme"
:allowBetaVersions="settings.allowBetaVersions"
@toggleTheme="toggleTheme"
@openLanguageSelector="openLanguageSelector"
@formatCurrentBlock="formatCurrentBlock"
Expand Down
3 changes: 2 additions & 1 deletion src/components/StatusBar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
"languageAuto",
"theme",
"systemTheme",
"allowBetaVersions",
],

components: {
Expand Down Expand Up @@ -63,7 +64,7 @@
>
<span class="icon icon-format"></span>
</div>
<UpdateStatusItem />
<UpdateStatusItem :allowBetaVersions="allowBetaVersions" />
<div class="status-block theme clickable" @click="$emit('toggleTheme')" title="Toggle dark/light mode">
<span :class="'icon ' + systemTheme"></span>
</div>
Expand Down
13 changes: 13 additions & 0 deletions src/components/UpdateStatusItem.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
<script>
export default {
props: [
"allowBetaVersions",
],

data() {
return {
updateAvailable: false,
Expand Down Expand Up @@ -62,6 +66,14 @@
}
},

watch: {
allowBetaVersions: {
handler: function (newValue) {
this.checkForUpdate()
},
}
},

computed: {
statusText() {
if (this.downloading) {
Expand Down Expand Up @@ -123,6 +135,7 @@
},

checkForUpdate() {
this.updateAvailable = false
this.checkingForUpdate = true
window.heynote.autoUpdate.checkForUpdates()
}
Expand Down
16 changes: 16 additions & 0 deletions src/components/settings/Settings.vue
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
isMac: window.heynote.platform.isMac,
showLineNumberGutter: this.initialSettings.showLineNumberGutter,
showFoldGutter: this.initialSettings.showFoldGutter,
allowBetaVersions: this.initialSettings.allowBetaVersions,
}
},

Expand All @@ -40,6 +41,7 @@
showFoldGutter: this.showFoldGutter,
keymap: this.keymap,
emacsMetaKey: this.metaKey,
allowBetaVersions: this.allowBetaVersions,
})
}
}
Expand Down Expand Up @@ -91,6 +93,20 @@
</div>
</div>
</div>
<div class="row">
<div class="entry">
<h2>Beta Versions</h2>
<div class="checkbox">
<input
type="checkbox"
id="allowBetaVersions"
v-model="allowBetaVersions"
@change="updateSettings"
/>
<label for="allowBetaVersions">Use beta versions of Heynote</label>
</div>
</div>
</div>
</div>
<button
@click="$emit('closeSettings')"
Expand Down