diff --git a/electron/config.js b/electron/config.js index 0eaa1bd3..05339bb3 100644 --- a/electron/config.js +++ b/electron/config.js @@ -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}, }, }, @@ -45,6 +46,7 @@ const defaults = { emacsMetaKey: "meta", showLineNumberGutter: true, showFoldGutter: true, + allowBetaVersions: false, }, theme: "system", } diff --git a/electron/main/auto-update.ts b/electron/main/auto-update.ts index 63252f64..a8fe37c3 100644 --- a/electron/main/auto-update.ts +++ b/electron/main/auto-update.ts @@ -1,5 +1,6 @@ import { autoUpdater } from "electron-updater" import { app, dialog, ipcMain } from "electron" +import CONFIG from "../config" import { UPDATE_AVAILABLE_EVENT, @@ -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 @@ -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()) @@ -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; } diff --git a/electron/main/index.ts b/electron/main/index.ts index 981a44a3..5fd27991 100644 --- a/electron/main/index.ts +++ b/electron/main/index.ts @@ -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'; @@ -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 @@ -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) diff --git a/package-lock.json b/package-lock.json index 9dc539d0..41d4b8d2 100644 --- a/package-lock.json +++ b/package-lock.json @@ -38,7 +38,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", @@ -1328,12 +1328,6 @@ "@types/node": "*" } }, - "node_modules/@types/semver": { - "version": "7.3.13", - "resolved": "https://registry.npmjs.org/@types/semver/-/semver-7.3.13.tgz", - "integrity": "sha512-21cFJr9z3g5dW8B0CVI9g2O9beqaThGQ6ZFBqHfwhzLDKUxaqTIy3vnfah/UPkfOiF2pLq+tGz+W8RyCskuslw==", - "dev": true - }, "node_modules/@types/verror": { "version": "1.10.6", "resolved": "https://registry.npmjs.org/@types/verror/-/verror-1.10.6.tgz", @@ -3039,20 +3033,32 @@ } }, "node_modules/electron-updater": { - "version": "5.3.0", - "resolved": "https://registry.npmjs.org/electron-updater/-/electron-updater-5.3.0.tgz", - "integrity": "sha512-iKEr7yQBcvnQUPnSDYGSWC9t0eF2YbZWeYYYZzYxdl+HiRejXFENjYMnYjoOm2zxyD6Cr2JTHZhp9pqxiXuCOw==", + "version": "6.1.7", + "resolved": "https://registry.npmjs.org/electron-updater/-/electron-updater-6.1.7.tgz", + "integrity": "sha512-SNOhYizjkm4ET+Y8ilJyUzcVsFJDtINzVN1TyHnZeMidZEG3YoBebMyXc/J6WSiXdUaOjC7ngekN6rNp6ardHA==", "dev": true, "dependencies": { - "@types/semver": "^7.3.6", - "builder-util-runtime": "9.1.1", - "fs-extra": "^10.0.0", + "builder-util-runtime": "9.2.3", + "fs-extra": "^10.1.0", "js-yaml": "^4.1.0", "lazy-val": "^1.0.5", "lodash.escaperegexp": "^4.1.2", "lodash.isequal": "^4.5.0", - "semver": "^7.3.5", - "typed-emitter": "^2.1.0" + "semver": "^7.3.8", + "tiny-typed-emitter": "^2.1.0" + } + }, + "node_modules/electron-updater/node_modules/builder-util-runtime": { + "version": "9.2.3", + "resolved": "https://registry.npmjs.org/builder-util-runtime/-/builder-util-runtime-9.2.3.tgz", + "integrity": "sha512-FGhkqXdFFZ5dNC4C+yuQB9ak311rpGAw+/ASz8ZdxwODCv1GGMWgLDeofRkdi0F3VCHQEWy/aXcJQozx2nOPiw==", + "dev": true, + "dependencies": { + "debug": "^4.3.4", + "sax": "^1.2.4" + }, + "engines": { + "node": ">=12.0.0" } }, "node_modules/electron-updater/node_modules/fs-extra": { @@ -4854,16 +4860,6 @@ "node": ">=12" } }, - "node_modules/rxjs": { - "version": "7.8.0", - "resolved": "https://registry.npmjs.org/rxjs/-/rxjs-7.8.0.tgz", - "integrity": "sha512-F2+gxDshqmIub1KdvZkaEfGDwLNpPvk9Fs6LD/MyQxNgMds/WH9OdDDXOmxUZpME+iSK3rQCctkL0DYyytUqMg==", - "dev": true, - "optional": true, - "dependencies": { - "tslib": "^2.1.0" - } - }, "node_modules/safer-buffer": { "version": "2.1.2", "resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz", @@ -5252,6 +5248,12 @@ "node": ">= 10.0.0" } }, + "node_modules/tiny-typed-emitter": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/tiny-typed-emitter/-/tiny-typed-emitter-2.1.0.tgz", + "integrity": "sha512-qVtvMxeXbVej0cQWKqVSSAHmKZEHAvxdF8HEUBFWts8h+xEo5m/lEiPakuyZ3BnCBjOD8i24kzNOiOLLgsSxhA==", + "dev": true + }, "node_modules/tmp": { "version": "0.2.1", "resolved": "https://registry.npmjs.org/tmp/-/tmp-0.2.1.tgz", @@ -5294,13 +5296,6 @@ "utf8-byte-length": "^1.0.1" } }, - "node_modules/tslib": { - "version": "2.5.0", - "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.5.0.tgz", - "integrity": "sha512-336iVw3rtn2BUK7ORdIAHTyxHGRIHVReokCR3XjbckJMK7ms8FysBfhLR8IXnAgy7T0PTPNBWKiH514FOW/WSg==", - "dev": true, - "optional": true - }, "node_modules/type-fest": { "version": "0.13.1", "resolved": "https://registry.npmjs.org/type-fest/-/type-fest-0.13.1.tgz", @@ -5314,15 +5309,6 @@ "url": "https://github.com/sponsors/sindresorhus" } }, - "node_modules/typed-emitter": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/typed-emitter/-/typed-emitter-2.1.0.tgz", - "integrity": "sha512-g/KzbYKbH5C2vPkaXGu8DJlHrGKHLsM25Zg9WuC9pMGfuvT+X25tZQWo5fK1BjBm8+UrVE9LDCvaY0CQk+fXDA==", - "dev": true, - "optionalDependencies": { - "rxjs": "*" - } - }, "node_modules/typescript": { "version": "4.9.4", "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.9.4.tgz", diff --git a/package.json b/package.json index 0c50cf23..0c010e80 100644 --- a/package.json +++ b/package.json @@ -14,6 +14,7 @@ }, "build": { "appId": "com.heynote.app", + "generateUpdatesFilesForAllChannels": true, "directories": { "buildResources": "resources" } @@ -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", diff --git a/src/components/App.vue b/src/components/App.vue index f7d70d77..0e0370bf 100644 --- a/src/components/App.vue +++ b/src/components/App.vue @@ -121,6 +121,7 @@ :languageAuto="languageAuto" :theme="theme" :systemTheme="systemTheme" + :allowBetaVersions="settings.allowBetaVersions" @toggleTheme="toggleTheme" @openLanguageSelector="openLanguageSelector" @formatCurrentBlock="formatCurrentBlock" diff --git a/src/components/StatusBar.vue b/src/components/StatusBar.vue index 2deb8813..7681b6b9 100644 --- a/src/components/StatusBar.vue +++ b/src/components/StatusBar.vue @@ -13,6 +13,7 @@ "languageAuto", "theme", "systemTheme", + "allowBetaVersions", ], components: { @@ -63,7 +64,7 @@ > - +
diff --git a/src/components/UpdateStatusItem.vue b/src/components/UpdateStatusItem.vue index 464b459e..a57b5ec4 100644 --- a/src/components/UpdateStatusItem.vue +++ b/src/components/UpdateStatusItem.vue @@ -1,5 +1,9 @@