mirror of
https://github.com/Eugeny/tabby.git
synced 2025-06-27 06:49:53 +00:00
auto-updater (fixes #348)
This commit is contained in:
parent
462232a2fb
commit
991294e61a
@ -1,6 +1,7 @@
|
|||||||
{
|
{
|
||||||
"name": "terminus",
|
"name": "terminus",
|
||||||
"description": "A terminal for a modern age",
|
"description": "A terminal for a modern age",
|
||||||
|
"repository": "https://github.com/eugeny/terminus",
|
||||||
"author": {
|
"author": {
|
||||||
"name": "Eugene Pankov",
|
"name": "Eugene Pankov",
|
||||||
"email": "e@ajenti.org"
|
"email": "e@ajenti.org"
|
||||||
|
@ -4,7 +4,7 @@ const vars = require('./vars')
|
|||||||
|
|
||||||
builder({
|
builder({
|
||||||
dir: true,
|
dir: true,
|
||||||
mac: ['dmg'],
|
mac: ['dmg', 'zip'],
|
||||||
config: {
|
config: {
|
||||||
extraMetadata: {
|
extraMetadata: {
|
||||||
version: vars.version,
|
version: vars.version,
|
||||||
|
@ -21,7 +21,6 @@
|
|||||||
"@types/node": "^7.0.37",
|
"@types/node": "^7.0.37",
|
||||||
"@types/webpack-env": "^1.13.0",
|
"@types/webpack-env": "^1.13.0",
|
||||||
"@types/winston": "^2.3.6",
|
"@types/winston": "^2.3.6",
|
||||||
"axios": "0.16.2",
|
|
||||||
"bootstrap": "^4.1.3",
|
"bootstrap": "^4.1.3",
|
||||||
"core-js": "^2.4.1",
|
"core-js": "^2.4.1",
|
||||||
"electron-updater": "^2.8.9",
|
"electron-updater": "^2.8.9",
|
||||||
|
@ -50,7 +50,7 @@ title-bar(
|
|||||||
)
|
)
|
||||||
|
|
||||||
button.btn.btn-secondary.btn-tab-bar.btn-update(
|
button.btn.btn-secondary.btn-tab-bar.btn-update(
|
||||||
*ngIf='appUpdate',
|
*ngIf='updatesAvailable',
|
||||||
title='Update available',
|
title='Update available',
|
||||||
(click)='updateApp()',
|
(click)='updateApp()',
|
||||||
[innerHTML]='updateIcon'
|
[innerHTML]='updateIcon'
|
||||||
|
@ -11,7 +11,7 @@ import { ConfigService } from '../services/config.service'
|
|||||||
import { DockingService } from '../services/docking.service'
|
import { DockingService } from '../services/docking.service'
|
||||||
import { TabRecoveryService } from '../services/tabRecovery.service'
|
import { TabRecoveryService } from '../services/tabRecovery.service'
|
||||||
import { ThemesService } from '../services/themes.service'
|
import { ThemesService } from '../services/themes.service'
|
||||||
import { UpdaterService, Update } from '../services/updater.service'
|
import { UpdaterService } from '../services/updater.service'
|
||||||
import { TouchbarService } from '../services/touchbar.service'
|
import { TouchbarService } from '../services/touchbar.service'
|
||||||
|
|
||||||
import { BaseTabComponent } from './baseTab.component'
|
import { BaseTabComponent } from './baseTab.component'
|
||||||
@ -63,8 +63,8 @@ export class AppRootComponent {
|
|||||||
tabsDragging = false
|
tabsDragging = false
|
||||||
unsortedTabs: BaseTabComponent[] = []
|
unsortedTabs: BaseTabComponent[] = []
|
||||||
updateIcon: SafeHtml
|
updateIcon: SafeHtml
|
||||||
|
updatesAvailable = false
|
||||||
private logger: Logger
|
private logger: Logger
|
||||||
private appUpdate: Update
|
|
||||||
|
|
||||||
constructor (
|
constructor (
|
||||||
private docking: DockingService,
|
private docking: DockingService,
|
||||||
@ -132,8 +132,8 @@ export class AppRootComponent {
|
|||||||
ngbModal.open(SafeModeModalComponent)
|
ngbModal.open(SafeModeModalComponent)
|
||||||
}
|
}
|
||||||
|
|
||||||
this.updater.check().then(update => {
|
this.updater.check().then(() => {
|
||||||
this.appUpdate = update
|
this.updatesAvailable = true
|
||||||
})
|
})
|
||||||
|
|
||||||
this.touchbar.update()
|
this.touchbar.update()
|
||||||
@ -217,7 +217,7 @@ export class AppRootComponent {
|
|||||||
}
|
}
|
||||||
|
|
||||||
updateApp () {
|
updateApp () {
|
||||||
this.electron.shell.openExternal(this.appUpdate.url)
|
this.updater.update()
|
||||||
}
|
}
|
||||||
|
|
||||||
onTabDragStart () {
|
onTabDragStart () {
|
||||||
|
@ -12,6 +12,7 @@ export class ElectronService {
|
|||||||
nativeImage: any
|
nativeImage: any
|
||||||
screen: any
|
screen: any
|
||||||
remote: any
|
remote: any
|
||||||
|
autoUpdater: any
|
||||||
TouchBar: typeof TouchBar
|
TouchBar: typeof TouchBar
|
||||||
BrowserWindow: typeof BrowserWindow
|
BrowserWindow: typeof BrowserWindow
|
||||||
Menu: typeof Menu
|
Menu: typeof Menu
|
||||||
@ -29,6 +30,7 @@ export class ElectronService {
|
|||||||
this.ipcRenderer = this.electron.ipcRenderer
|
this.ipcRenderer = this.electron.ipcRenderer
|
||||||
this.globalShortcut = this.remote.globalShortcut
|
this.globalShortcut = this.remote.globalShortcut
|
||||||
this.nativeImage = this.remote.nativeImage
|
this.nativeImage = this.remote.nativeImage
|
||||||
|
this.autoUpdater = this.remote.autoUpdater
|
||||||
this.TouchBar = this.remote.TouchBar
|
this.TouchBar = this.remote.TouchBar
|
||||||
this.BrowserWindow = this.remote.BrowserWindow
|
this.BrowserWindow = this.remote.BrowserWindow
|
||||||
this.Menu = this.remote.Menu
|
this.Menu = this.remote.Menu
|
||||||
|
@ -1,36 +1,41 @@
|
|||||||
import axios from 'axios'
|
import * as os from 'os'
|
||||||
import { Injectable } from '@angular/core'
|
import { Injectable } from '@angular/core'
|
||||||
import { Logger, LogService } from './log.service'
|
import { Logger, LogService } from './log.service'
|
||||||
import { ElectronService } from './electron.service'
|
import { ElectronService } from './electron.service'
|
||||||
|
|
||||||
const UPDATES_URL = 'https://api.github.com/repos/eugeny/terminus/releases/latest'
|
|
||||||
|
|
||||||
export interface Update {
|
|
||||||
version: string
|
|
||||||
url: string
|
|
||||||
}
|
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class UpdaterService {
|
export class UpdaterService {
|
||||||
private logger: Logger
|
private logger: Logger
|
||||||
|
private downloaded: Promise<void>
|
||||||
|
|
||||||
constructor (
|
constructor (
|
||||||
log: LogService,
|
log: LogService,
|
||||||
private electron: ElectronService,
|
private electron: ElectronService,
|
||||||
) {
|
) {
|
||||||
this.logger = log.create('updater')
|
this.logger = log.create('updater')
|
||||||
|
electron.autoUpdater.setFeedURL(`https://terminus-updates.herokuapp.com/update/${os.platform()}/${electron.app.getVersion()}`)
|
||||||
|
|
||||||
|
this.electron.autoUpdater.on('update-available', () => {
|
||||||
|
this.logger.info('Update available')
|
||||||
|
})
|
||||||
|
this.electron.autoUpdater.once('update-not-available', () => {
|
||||||
|
this.logger.info('No updates')
|
||||||
|
})
|
||||||
|
|
||||||
|
this.downloaded = new Promise<void>(resolve => {
|
||||||
|
this.electron.autoUpdater.once('update-downloaded', resolve)
|
||||||
|
})
|
||||||
|
|
||||||
|
this.logger.debug('Checking for updates')
|
||||||
|
this.electron.autoUpdater.checkForUpdates()
|
||||||
}
|
}
|
||||||
|
|
||||||
async check (): Promise<Update> {
|
check (): Promise<void> {
|
||||||
this.logger.debug('Checking for updates')
|
return this.downloaded
|
||||||
let response = await axios.get(UPDATES_URL)
|
}
|
||||||
let data = response.data
|
|
||||||
let version = data.tag_name.substring(1)
|
async update () {
|
||||||
if (this.electron.app.getVersion() !== version) {
|
await this.downloaded
|
||||||
this.logger.info('Update available:', version)
|
this.electron.autoUpdater.quitAndInstall()
|
||||||
return { version, url: data.html_url }
|
|
||||||
}
|
|
||||||
this.logger.info('No updates')
|
|
||||||
return null
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -73,14 +73,6 @@ aws4@^1.6.0:
|
|||||||
resolved "https://registry.yarnpkg.com/aws4/-/aws4-1.8.0.tgz#f0e003d9ca9e7f59c7a508945d7b2ef9a04a542f"
|
resolved "https://registry.yarnpkg.com/aws4/-/aws4-1.8.0.tgz#f0e003d9ca9e7f59c7a508945d7b2ef9a04a542f"
|
||||||
integrity sha512-ReZxvNHIOv88FlT7rxcXIIC0fPt4KZqZbOlivyWtXLt8ESx84zd3kMC6iK5jVeS2qt+g7ftS7ye4fi06X5rtRQ==
|
integrity sha512-ReZxvNHIOv88FlT7rxcXIIC0fPt4KZqZbOlivyWtXLt8ESx84zd3kMC6iK5jVeS2qt+g7ftS7ye4fi06X5rtRQ==
|
||||||
|
|
||||||
axios@0.16.2:
|
|
||||||
version "0.16.2"
|
|
||||||
resolved "https://registry.yarnpkg.com/axios/-/axios-0.16.2.tgz#ba4f92f17167dfbab40983785454b9ac149c3c6d"
|
|
||||||
integrity sha1-uk+S8XFn37q0CYN4VFS5rBScPG0=
|
|
||||||
dependencies:
|
|
||||||
follow-redirects "^1.2.3"
|
|
||||||
is-buffer "^1.1.5"
|
|
||||||
|
|
||||||
bcrypt-pbkdf@^1.0.0:
|
bcrypt-pbkdf@^1.0.0:
|
||||||
version "1.0.2"
|
version "1.0.2"
|
||||||
resolved "https://registry.yarnpkg.com/bcrypt-pbkdf/-/bcrypt-pbkdf-1.0.2.tgz#a4301d389b6a43f9b67ff3ca11a3f6637e360e9e"
|
resolved "https://registry.yarnpkg.com/bcrypt-pbkdf/-/bcrypt-pbkdf-1.0.2.tgz#a4301d389b6a43f9b67ff3ca11a3f6637e360e9e"
|
||||||
@ -170,13 +162,6 @@ dashdash@^1.12.0:
|
|||||||
dependencies:
|
dependencies:
|
||||||
assert-plus "^1.0.0"
|
assert-plus "^1.0.0"
|
||||||
|
|
||||||
debug@^2.4.5:
|
|
||||||
version "2.6.8"
|
|
||||||
resolved "https://registry.yarnpkg.com/debug/-/debug-2.6.8.tgz#e731531ca2ede27d188222427da17821d68ff4fc"
|
|
||||||
integrity sha1-5zFTHKLt4n0YgiJCfaF4IdaP9Pw=
|
|
||||||
dependencies:
|
|
||||||
ms "2.0.0"
|
|
||||||
|
|
||||||
debug@^3.0.0:
|
debug@^3.0.0:
|
||||||
version "3.1.0"
|
version "3.1.0"
|
||||||
resolved "https://registry.yarnpkg.com/debug/-/debug-3.1.0.tgz#5bb5a0672628b64149566ba16819e61518c67261"
|
resolved "https://registry.yarnpkg.com/debug/-/debug-3.1.0.tgz#5bb5a0672628b64149566ba16819e61518c67261"
|
||||||
@ -276,13 +261,6 @@ fast-json-stable-stringify@^2.0.0:
|
|||||||
resolved "https://registry.yarnpkg.com/fast-json-stable-stringify/-/fast-json-stable-stringify-2.0.0.tgz#d5142c0caee6b1189f87d3a76111064f86c8bbf2"
|
resolved "https://registry.yarnpkg.com/fast-json-stable-stringify/-/fast-json-stable-stringify-2.0.0.tgz#d5142c0caee6b1189f87d3a76111064f86c8bbf2"
|
||||||
integrity sha1-1RQsDK7msRifh9OnYREGT4bIu/I=
|
integrity sha1-1RQsDK7msRifh9OnYREGT4bIu/I=
|
||||||
|
|
||||||
follow-redirects@^1.2.3:
|
|
||||||
version "1.2.4"
|
|
||||||
resolved "https://registry.yarnpkg.com/follow-redirects/-/follow-redirects-1.2.4.tgz#355e8f4d16876b43f577b0d5ce2668b9723214ea"
|
|
||||||
integrity sha512-Suw6KewLV2hReSyEOeql+UUkBVyiBm3ok1VPrVFRZnQInWpdoZbbiG5i8aJVSjTr0yQ4Ava0Sh6/joCg1Brdqw==
|
|
||||||
dependencies:
|
|
||||||
debug "^2.4.5"
|
|
||||||
|
|
||||||
forever-agent@~0.6.1:
|
forever-agent@~0.6.1:
|
||||||
version "0.6.1"
|
version "0.6.1"
|
||||||
resolved "https://registry.yarnpkg.com/forever-agent/-/forever-agent-0.6.1.tgz#fbc71f0c41adeb37f96c577ad1ed42d8fdacca91"
|
resolved "https://registry.yarnpkg.com/forever-agent/-/forever-agent-0.6.1.tgz#fbc71f0c41adeb37f96c577ad1ed42d8fdacca91"
|
||||||
@ -363,11 +341,6 @@ http-signature@~1.2.0:
|
|||||||
jsprim "^1.2.2"
|
jsprim "^1.2.2"
|
||||||
sshpk "^1.7.0"
|
sshpk "^1.7.0"
|
||||||
|
|
||||||
is-buffer@^1.1.5:
|
|
||||||
version "1.1.5"
|
|
||||||
resolved "https://registry.yarnpkg.com/is-buffer/-/is-buffer-1.1.5.tgz#1f3b26ef613b214b88cbca23cc6c01d87961eecc"
|
|
||||||
integrity sha1-Hzsm72E7IUuIy8ojzGwB2Hlh7sw=
|
|
||||||
|
|
||||||
is-typedarray@~1.0.0:
|
is-typedarray@~1.0.0:
|
||||||
version "1.0.0"
|
version "1.0.0"
|
||||||
resolved "https://registry.yarnpkg.com/is-typedarray/-/is-typedarray-1.0.0.tgz#e479c80858df0c1b11ddda6940f96011fcda4a9a"
|
resolved "https://registry.yarnpkg.com/is-typedarray/-/is-typedarray-1.0.0.tgz#e479c80858df0c1b11ddda6940f96011fcda4a9a"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user