mirror of
https://github.com/MODSetter/SurfSense.git
synced 2026-04-25 00:36:31 +02:00
feat: validate version format in auto-updater and release workflow
- Added a check in the desktop release workflow to ensure version tags follow semantic versioning (semver) format. - Enhanced the auto-updater to log a message and skip updates if the app version is not valid semver. - Improved type definitions for event handlers in the auto-updater for better TypeScript support.
This commit is contained in:
parent
f428cd97d9
commit
6dd85dd365
2 changed files with 18 additions and 5 deletions
|
|
@ -1,16 +1,25 @@
|
|||
import { app, dialog } from 'electron';
|
||||
import { autoUpdater } from 'electron-updater';
|
||||
|
||||
const SEMVER_RE = /^\d+\.\d+\.\d+/;
|
||||
|
||||
export function setupAutoUpdater(): void {
|
||||
if (!app.isPackaged) return;
|
||||
|
||||
const version = app.getVersion();
|
||||
if (!SEMVER_RE.test(version)) {
|
||||
console.log(`Auto-updater: skipping — "${version}" is not valid semver`);
|
||||
return;
|
||||
}
|
||||
|
||||
const { autoUpdater } = require('electron-updater');
|
||||
|
||||
autoUpdater.autoDownload = true;
|
||||
|
||||
autoUpdater.on('update-available', (info) => {
|
||||
autoUpdater.on('update-available', (info: { version: string }) => {
|
||||
console.log(`Update available: ${info.version}`);
|
||||
});
|
||||
|
||||
autoUpdater.on('update-downloaded', (info) => {
|
||||
autoUpdater.on('update-downloaded', (info: { version: string }) => {
|
||||
console.log(`Update downloaded: ${info.version}`);
|
||||
dialog.showMessageBox({
|
||||
type: 'info',
|
||||
|
|
@ -18,14 +27,14 @@ export function setupAutoUpdater(): void {
|
|||
defaultId: 0,
|
||||
title: 'Update Ready',
|
||||
message: `Version ${info.version} has been downloaded. Restart to apply the update.`,
|
||||
}).then(({ response }) => {
|
||||
}).then(({ response }: { response: number }) => {
|
||||
if (response === 0) {
|
||||
autoUpdater.quitAndInstall();
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
autoUpdater.on('error', (err) => {
|
||||
autoUpdater.on('error', (err: Error) => {
|
||||
console.log('Auto-updater: update check skipped —', err.message?.split('\n')[0]);
|
||||
});
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue