Skip to content

Commit

Permalink
Add auto-updater
Browse files Browse the repository at this point in the history
  • Loading branch information
lteague committed Nov 6, 2020
1 parent 09a30cb commit e43755b
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 0 deletions.
5 changes: 5 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,18 @@
"printWidth": 120
},
"build": {
"appId": "com.psddev.shot-check",
"asar": false,
"mac": {
"category": "public.app-category.developer-tools"
},
"publish": {
"provider": "github",
"releaseType": "release"
}
},
"dependencies": {
"electron-updater": "^4.3.5",
"puppeteer": "5.3.1",
"source-map-support": "0.5.19"
},
Expand Down
31 changes: 31 additions & 0 deletions src/main/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import * as os from 'os'
import ipcListeners from './ipc/ipcListeners'
import { isDevelopment } from '../common/appConfig'
import { initializeExampleProjectIfNecessary } from '../common/exampleProject'
import { autoUpdater } from 'electron-updater'

// global reference to mainWindow (necessary to prevent window from being garbage collected)
let mainWindow
Expand Down Expand Up @@ -78,6 +79,10 @@ app.on('ready', () => {
initializeExampleProjectIfNecessary()
mainWindow = createMainWindow()
ipcListeners()

if (!isDevelopment) {
autoUpdater.checkForUpdates()
}
})

// handle file:// URLs
Expand All @@ -87,3 +92,29 @@ app.whenReady().then(() => {
callback(pathname)
})
})

// Auto updater
autoUpdater.on('checking-for-update', () => {
console.log('Checking for Update. . .')
})

autoUpdater.on('update-available', (info) => {
console.log('Update Available!')
})

autoUpdater.on('update-not-available', (info) => {
console.log('Update Not Available!')
})

autoUpdater.on('error', (err) => {
console.log('Auto Updater error!', err)
})

autoUpdater.on('download-progress', (progressObj) => {
console.log('Download Progress:', progressObj)
})

autoUpdater.on('update-downloaded', (info) => {
console.log('Update Downloaded!', info)
autoUpdater.quitAndInstall()
})
23 changes: 23 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2128,6 +2128,11 @@
"@types/prop-types" "*"
csstype "^3.0.2"

"@types/semver@^7.3.1":
version "7.3.4"
resolved "https://registry.yarnpkg.com/@types/semver/-/semver-7.3.4.tgz#43d7168fec6fa0988bb1a513a697b29296721afb"
integrity sha512-+nVsLKlcUCeMzD2ufHEYuJ9a2ovstb6Dp52A5VsoKxDXgvE051XgHI/33I1EymwkRGQkwnA0LkhnUzituGs4EQ==

"@types/source-list-map@*":
version "0.1.2"
resolved "https://registry.yarnpkg.com/@types/source-list-map/-/source-list-map-0.1.2.tgz#0078836063ffaf17412349bba364087e0ac02ec9"
Expand Down Expand Up @@ -4243,6 +4248,19 @@ electron-to-chromium@^1.3.571:
resolved "https://registry.yarnpkg.com/electron-to-chromium/-/electron-to-chromium-1.3.576.tgz#2e70234484e03d7c7e90310d7d79fd3775379c34"
integrity sha512-uSEI0XZ//5ic+0NdOqlxp0liCD44ck20OAGyLMSymIWTEAtHKVJi6JM18acOnRgUgX7Q65QqnI+sNncNvIy8ew==

electron-updater@^4.3.5:
version "4.3.5"
resolved "https://registry.yarnpkg.com/electron-updater/-/electron-updater-4.3.5.tgz#4fb36f593a031c87ea07ee141c9f064d5deffb15"
integrity sha512-5jjN7ebvfj1cLI0VZMdCnJk6aC4bP+dy7ryBf21vArR0JzpRVk0OZHA2QBD+H5rm6ZSeDYHOY6+8PrMEqJ4wlQ==
dependencies:
"@types/semver" "^7.3.1"
builder-util-runtime "8.7.2"
fs-extra "^9.0.1"
js-yaml "^3.14.0"
lazy-val "^1.0.4"
lodash.isequal "^4.5.0"
semver "^7.3.2"

electron-webpack-js@~2.4.1:
version "2.4.1"
resolved "https://registry.yarnpkg.com/electron-webpack-js/-/electron-webpack-js-2.4.1.tgz#5389cc22f34c71f6416d5ba1e043f9b0fd6130af"
Expand Down Expand Up @@ -6475,6 +6493,11 @@ locate-path@^5.0.0:
dependencies:
p-locate "^4.1.0"

lodash.isequal@^4.5.0:
version "4.5.0"
resolved "https://registry.yarnpkg.com/lodash.isequal/-/lodash.isequal-4.5.0.tgz#415c4478f2bcc30120c22ce10ed3226f7d3e18e0"
integrity sha1-QVxEePK8wwEgwizhDtMib30+GOA=

lodash.memoize@^4.1.2:
version "4.1.2"
resolved "https://registry.yarnpkg.com/lodash.memoize/-/lodash.memoize-4.1.2.tgz#bcc6c49a42a2840ed997f323eada5ecd182e0bfe"
Expand Down

0 comments on commit e43755b

Please sign in to comment.