diff --git a/app/package.json b/app/package.json index 9357fa22..ee584182 100644 --- a/app/package.json +++ b/app/package.json @@ -1,6 +1,7 @@ { "name": "terminus", "description": "A terminal for a modern age", + "repository": "https://github.com/eugeny/terminus", "author": { "name": "Eugene Pankov", "email": "e@ajenti.org" diff --git a/scripts/build-macos.js b/scripts/build-macos.js index c80ec55b..a116f852 100755 --- a/scripts/build-macos.js +++ b/scripts/build-macos.js @@ -4,7 +4,7 @@ const vars = require('./vars') builder({ dir: true, - mac: ['dmg'], + mac: ['dmg', 'zip'], config: { extraMetadata: { version: vars.version, diff --git a/terminus-core/package.json b/terminus-core/package.json index ef04e661..be0f2a57 100644 --- a/terminus-core/package.json +++ b/terminus-core/package.json @@ -21,7 +21,6 @@ "@types/node": "^7.0.37", "@types/webpack-env": "^1.13.0", "@types/winston": "^2.3.6", - "axios": "0.16.2", "bootstrap": "^4.1.3", "core-js": "^2.4.1", "electron-updater": "^2.8.9", diff --git a/terminus-core/src/components/appRoot.component.pug b/terminus-core/src/components/appRoot.component.pug index 9bbd6486..474e01bb 100644 --- a/terminus-core/src/components/appRoot.component.pug +++ b/terminus-core/src/components/appRoot.component.pug @@ -50,7 +50,7 @@ title-bar( ) button.btn.btn-secondary.btn-tab-bar.btn-update( - *ngIf='appUpdate', + *ngIf='updatesAvailable', title='Update available', (click)='updateApp()', [innerHTML]='updateIcon' diff --git a/terminus-core/src/components/appRoot.component.ts b/terminus-core/src/components/appRoot.component.ts index 09943e28..94db1ba0 100644 --- a/terminus-core/src/components/appRoot.component.ts +++ b/terminus-core/src/components/appRoot.component.ts @@ -11,7 +11,7 @@ import { ConfigService } from '../services/config.service' import { DockingService } from '../services/docking.service' import { TabRecoveryService } from '../services/tabRecovery.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 { BaseTabComponent } from './baseTab.component' @@ -63,8 +63,8 @@ export class AppRootComponent { tabsDragging = false unsortedTabs: BaseTabComponent[] = [] updateIcon: SafeHtml + updatesAvailable = false private logger: Logger - private appUpdate: Update constructor ( private docking: DockingService, @@ -132,8 +132,8 @@ export class AppRootComponent { ngbModal.open(SafeModeModalComponent) } - this.updater.check().then(update => { - this.appUpdate = update + this.updater.check().then(() => { + this.updatesAvailable = true }) this.touchbar.update() @@ -217,7 +217,7 @@ export class AppRootComponent { } updateApp () { - this.electron.shell.openExternal(this.appUpdate.url) + this.updater.update() } onTabDragStart () { diff --git a/terminus-core/src/services/electron.service.ts b/terminus-core/src/services/electron.service.ts index cf703324..4a53c5c4 100644 --- a/terminus-core/src/services/electron.service.ts +++ b/terminus-core/src/services/electron.service.ts @@ -12,6 +12,7 @@ export class ElectronService { nativeImage: any screen: any remote: any + autoUpdater: any TouchBar: typeof TouchBar BrowserWindow: typeof BrowserWindow Menu: typeof Menu @@ -29,6 +30,7 @@ export class ElectronService { this.ipcRenderer = this.electron.ipcRenderer this.globalShortcut = this.remote.globalShortcut this.nativeImage = this.remote.nativeImage + this.autoUpdater = this.remote.autoUpdater this.TouchBar = this.remote.TouchBar this.BrowserWindow = this.remote.BrowserWindow this.Menu = this.remote.Menu diff --git a/terminus-core/src/services/updater.service.ts b/terminus-core/src/services/updater.service.ts index 027d0057..a21424d3 100644 --- a/terminus-core/src/services/updater.service.ts +++ b/terminus-core/src/services/updater.service.ts @@ -1,36 +1,41 @@ -import axios from 'axios' +import * as os from 'os' import { Injectable } from '@angular/core' import { Logger, LogService } from './log.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() export class UpdaterService { private logger: Logger + private downloaded: Promise constructor ( log: LogService, private electron: ElectronService, ) { 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(resolve => { + this.electron.autoUpdater.once('update-downloaded', resolve) + }) + + this.logger.debug('Checking for updates') + this.electron.autoUpdater.checkForUpdates() } - async check (): Promise { - this.logger.debug('Checking for updates') - let response = await axios.get(UPDATES_URL) - let data = response.data - let version = data.tag_name.substring(1) - if (this.electron.app.getVersion() !== version) { - this.logger.info('Update available:', version) - return { version, url: data.html_url } - } - this.logger.info('No updates') - return null + check (): Promise { + return this.downloaded + } + + async update () { + await this.downloaded + this.electron.autoUpdater.quitAndInstall() } } diff --git a/terminus-core/yarn.lock b/terminus-core/yarn.lock index d150de83..7fb29463 100644 --- a/terminus-core/yarn.lock +++ b/terminus-core/yarn.lock @@ -73,14 +73,6 @@ aws4@^1.6.0: resolved "https://registry.yarnpkg.com/aws4/-/aws4-1.8.0.tgz#f0e003d9ca9e7f59c7a508945d7b2ef9a04a542f" 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: version "1.0.2" resolved "https://registry.yarnpkg.com/bcrypt-pbkdf/-/bcrypt-pbkdf-1.0.2.tgz#a4301d389b6a43f9b67ff3ca11a3f6637e360e9e" @@ -170,13 +162,6 @@ dashdash@^1.12.0: dependencies: 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: version "3.1.0" 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" 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: version "0.6.1" 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" 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: version "1.0.0" resolved "https://registry.yarnpkg.com/is-typedarray/-/is-typedarray-1.0.0.tgz#e479c80858df0c1b11ddda6940f96011fcda4a9a"