mirror of
https://github.com/velopack/velopack.git
synced 2025-10-25 15:19:22 +00:00
Remove console logger from electron sample
This commit is contained in:
@@ -1,20 +1,54 @@
|
||||
import { app, BrowserWindow } from 'electron';
|
||||
import { VelopackApp, setVelopackLogger } from "velopack";
|
||||
import { initializeUpdates } from "./update"
|
||||
import { app, ipcMain, BrowserWindow } from 'electron';
|
||||
import { VelopackApp, UpdateManager } from "velopack";
|
||||
|
||||
// This allows TypeScript to pick up the magic constants that's auto-generated by Forge's Webpack
|
||||
// plugin that tells the Electron app where to look for the Webpack-bundled app code (depending on
|
||||
// whether you're running in development or production).
|
||||
declare const MAIN_WINDOW_WEBPACK_ENTRY: string;
|
||||
declare const MAIN_WINDOW_PRELOAD_WEBPACK_ENTRY: string;
|
||||
|
||||
|
||||
// VelopackApp should be the first thing to run in startup
|
||||
// as it may need to quit / restart the application at certain points
|
||||
setVelopackLogger((lvl, msg) => console.log(`Velopack [${lvl}] ${msg}`));
|
||||
VelopackApp.build().run();
|
||||
VelopackApp.build()
|
||||
.onFirstRun(() => { console.log("Show welcome to new user on first run?"); })
|
||||
.run();
|
||||
|
||||
|
||||
// replace me
|
||||
const updateUrl = "C:\\Source\\velopack\\samples\\NodeJSElectron\\releases";
|
||||
|
||||
|
||||
// Configure IPC listener for Velopack update messages
|
||||
initializeUpdates();
|
||||
ipcMain.handle("velopack:get-version", () => {
|
||||
try {
|
||||
const updateManager = new UpdateManager(updateUrl);
|
||||
return updateManager.getCurrentVersion();
|
||||
} catch (e) {
|
||||
return `Not Installed (${e})`;
|
||||
}
|
||||
});
|
||||
|
||||
ipcMain.handle("velopack:check-for-update", async () => {
|
||||
const updateManager = new UpdateManager(updateUrl);
|
||||
return await updateManager.checkForUpdatesAsync();
|
||||
});
|
||||
|
||||
ipcMain.handle("velopack:download-update", async (_, updateInfo) => {
|
||||
const updateManager = new UpdateManager(updateUrl);
|
||||
await updateManager.downloadUpdateAsync(updateInfo);
|
||||
return true;
|
||||
});
|
||||
|
||||
ipcMain.handle("velopack:apply-update", async (_, updateInfo) => {
|
||||
const updateManager = new UpdateManager(updateUrl);
|
||||
await updateManager.waitExitThenApplyUpdate(updateInfo);
|
||||
app.quit();
|
||||
return true;
|
||||
});
|
||||
|
||||
|
||||
// Create the browser window.
|
||||
const createWindow = (): void => {
|
||||
// Create the browser window.
|
||||
const mainWindow = new BrowserWindow({
|
||||
|
||||
Reference in New Issue
Block a user