-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
releasing v1 for desktop with update
- Loading branch information
1 parent
e07ce5b
commit 08a0159
Showing
4 changed files
with
248 additions
and
319 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,79 +1,73 @@ | ||
const autoUpdater = require('electron-updater'); | ||
const { autoUpdater } = require("electron-updater"); | ||
const { dialog, BrowserWindow, ipcMain } = require('electron'); | ||
const log = require('electron-log'); | ||
|
||
let downloadProgress; | ||
log.transports.file.level = "debug"; | ||
autoUpdater.autoUpdater.logger = log; | ||
autoUpdater.logger = log; | ||
|
||
autoUpdater.autoUpdater.autoDownload = false; | ||
autoUpdater.autoDownload = false; | ||
|
||
autoUpdater.autoUpdater.setFeedURL({ | ||
autoUpdater.setFeedURL({ | ||
provider: "github", | ||
owner: "hannydevelop", | ||
repo: "peppubuild-desktop", | ||
}); | ||
|
||
function check() { | ||
autoUpdater.autoUpdater.checkForUpdates(); | ||
|
||
autoUpdater.autoUpdater.on('checking-for-update', () => { | ||
const response = dialog.showMessageBox(null); | ||
console.log(response); | ||
dialog.showMessageBox({ | ||
type: 'info', | ||
title: 'Update Available', | ||
message: 'A new version of app is available. Do you want to update now?', | ||
buttons: ['Update', 'No'] | ||
}, (index) => { | ||
if (index) { | ||
return; | ||
} else { | ||
autoUpdater.autoUpdater.downloadUpdate(); | ||
|
||
let proWin = new BrowserWindow({ | ||
width: 350, | ||
height: 35, | ||
useContentSize: true, | ||
autoHideMenuBar: true, | ||
maximizable: false, | ||
fullscreen: false, | ||
fullscreenable: false, | ||
resizable: false, | ||
title: 'Downloading Update' | ||
}); | ||
proWin.loadURL(`file://$(__dirname)/progress`); | ||
|
||
proWin.on('closed', () => { | ||
proWin = null; | ||
}); | ||
|
||
ipcMain.on('download-progress-request', (e) => { | ||
e.returnValue = downloadProgress; | ||
}); | ||
|
||
autoUpdater.autoUpdater.on('download-progress', (d) => { | ||
downloadProgress = d.percent; | ||
autoUpdater.autoUpdater.logger.info(downloadProgress); | ||
}); | ||
|
||
autoUpdater.autoUpdater.on('update-downloaded', () => { | ||
if (progressWindow) progressWindow.close(); | ||
autoUpdater.setFeedURL({ | ||
provider: "github", | ||
owner: "hannydevelop", | ||
repo: "peppubuild-desktop", | ||
}); | ||
|
||
autoUpdater.on("checking-for-update", function (_arg1) { | ||
return log.info("Checking for update..."); | ||
}); | ||
autoUpdater.on("update-available", function (_arg2) { | ||
dialog.showMessageBox({ | ||
type: 'info', | ||
title: 'Update Available', | ||
message: 'A new version of Peppubuild is available. Do you want to update now?', | ||
buttons: ['Update', 'No'] | ||
}).then((response) => { | ||
if (process.platform == "darwin" && response.response == 0) { | ||
dialog.showMessageBox({ | ||
type: 'info', | ||
title: 'Update Ready', | ||
message: 'A new version of app is ready. Quit and Install now?', | ||
buttons: ['Yes', 'Later'] | ||
}, (index) => { | ||
if (!index) { | ||
autoUpdater.autoUpdater.quitAndInstall(); | ||
} | ||
}); | ||
}); | ||
} | ||
type: 'error', | ||
title: 'Auto Update Unsucessful', | ||
message: 'Auto-update prohibited for MacOS. You can download latest version from https://github.com/hannydevelop/peppubuild-desktop/releases/latest ', | ||
buttons: ['Okay'] | ||
}) | ||
} else if (response.response == 1) { | ||
return | ||
} else { | ||
autoUpdater.downloadUpdate(); | ||
} | ||
}) | ||
}); | ||
}); | ||
autoUpdater.on("update-not-available", function (_arg3) { | ||
return log.info("Update not available."); | ||
}); | ||
autoUpdater.on("error", function (err) { | ||
return log.info("Error in auto-updater. " + err); | ||
}); | ||
autoUpdater.on("download-progress", function (progressObj) { | ||
return log.info("downloading update"); | ||
}); | ||
autoUpdater.on("update-downloaded", function (_arg4) { | ||
if (progressWindow) progressWindow.close(); | ||
|
||
dialog.showMessageBox({ | ||
type: 'info', | ||
title: 'Update Ready', | ||
message: 'A new version of Peppubuild is ready. Quit and Install now?', | ||
buttons: ['Yes', 'Later'] | ||
}, (index) => { | ||
if (!index) { | ||
autoUpdater.quitAndInstall(); | ||
} | ||
}); | ||
}); | ||
|
||
} | ||
|
||
module.exports.check = check; |
Oops, something went wrong.