1
0
mirror of https://github.com/S2-/gitlit synced 2025-08-02 20:30:05 +02:00

auto update app

This commit is contained in:
s2
2020-06-07 19:37:56 +02:00
parent a6666452d7
commit 6c2bc3397e
6 changed files with 95 additions and 2 deletions

View File

@@ -3,6 +3,7 @@ const path = require('path');
const url = require('url');
const electronLocalshortcut = require('electron-localshortcut');
const exec = require('child_process').exec;
const gau = require('github-app-updater');
const args = require('minimist')(process.defaultApp ? process.argv.slice(3) : process.argv.slice(1), {
default: {
_: process.cwd()
@@ -13,6 +14,40 @@ let win;
let repoDir = path.resolve(path.normalize(args._.join(' ')));
let repoRootDir = repoDir;
//auto update stuff
setTimeout(() => {
gau.checkForUpdate({
currentVersion: '1.0.0', //app.getVersion(),
repo: 'https://api.github.com/repos/S2-/gitlit/releases/latest',
assetMatch: /.+setup.+exe/i
});
gau.onUpdateAvailable = (version, asset) => {
console.log('onUpdateAvailable');
win.webContents.send('update', {
event: 'updateAvailable',
version: version
});
gau.downloadNewVersion(asset);
};
gau.onNewVersionReadyToInstall = (file) => {
win.webContents.send('update', {
event: 'updateReadyToInstall',
file: file
});
};
ipcMain.on('installUpdate', (event, file) => {
gau.executeUpdate(file);
win.webContents.send('update', {
event: 'updateInstalling'
});
});
}, 5000);
//end update stuff
function getLfsFileList(dir, cb) {
exec('git ls-files | git check-attr --stdin lockable', {
maxBuffer: (1024 * 1024) * 10, //10MB