I'm trying to debug my updater on my app. I got the basic checkForUpdatesAndNotify working. However i am trying to add custom dialog boxes because the base dialog is kind of clunky. It shows com.electron for the name, and theres status of any thing and it just closes and eventually reopens. The issue I'm having is its not alerting me. So im trying to implement a electron-log so i can whats going on. However webstorm is telling me TS2339: Property transports does not exist on type (...params: any[]) => void
for the log.transports line. And its telling me TS2322: Type (...params: any[]) => void is not assignable to type Logger
for the autoUpdater.logger line.
Can someone please enlighten me on what i am doing wrong?
My logger code is this...
import { autoUpdater } from "electron-updater";
import { log } from "electron-log/node";
log.transports.file.level = "debug";
autoUpdater.logger = log;
autoUpdater.autoDownload = false;
My dialog code is this...
autoUpdater.checkForUpdates();
log(autoUpdater);
autoUpdater.on("checking-for-update", () => {
dialog.showMessageBox({
type: "info",
title: "Checking for Updates",
message: "Checking for updates...",
});
});
autoUpdater.on("update-available", () => {
dialog.showMessageBox(
{
// @ts-ignore
type: "info",
title: "Update Available",
message: "A new version of the app is available. Do you want to update now?",
buttons: ["Update", "No"],
},
(index: any) => {
if (index === 0) {
autoUpdater.downloadUpdate();
}
},
);
});
Through many hours of searching and finding different ways to test i have discovered that you can use catch to get any errors. Apparently the stuff that pulls up in google search is old. As for the dialog box its also not done like that anymore. For anyone wanting to know this is the updated code...
autoUpdater.checkForUpdates().catch((err)=>log(err));
autoUpdater.on("update-available", () => {
dialog
.showMessageBox({
type: "question",
title: "Update Available",
message: "A new version of the app is available. Do you want to update now?",
buttons: ["Update", "No"],
})
.then((response) => {
if (response.response === 0) {
autoUpdater.downloadUpdate().catch((err)=>log(err));
}
});
});
Hoping this helps someone. Maybe this is common knowledge and i didn't look in the right place.