Skip to content

Commit

Permalink
Test to implement auto update
Browse files Browse the repository at this point in the history
  • Loading branch information
romslf committed Jan 25, 2020
1 parent b276c23 commit e3dab64
Show file tree
Hide file tree
Showing 8 changed files with 37 additions and 4 deletions.
2 changes: 2 additions & 0 deletions .electron-nuxt/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,4 +56,6 @@ const pipe = new Pipeline({
builder
})



pipe.run()
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ dist
build/*
!build/icons
node_modules
electron-builder.yml
2 changes: 1 addition & 1 deletion builder.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ const macOS = {
module.exports = {
asar: true,
productName: 'System Companion',
appId: 'com.rolaforg.projectg',
appId: 'com.github.romslf.system-companion',
artifactName: 'sc-${version}.${ext}',
directories: {
output: 'build'
Expand Down
4 changes: 4 additions & 0 deletions electron-builder-example.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
appId: com.github.romslf.system-companion
publish:
provider: github
token: [YOUR GITHUB ACCESS TOKEN]
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
{
"name": "system-companion",
"version": "0.0.2",
"version": "0.0.1",
"description": "Multi platform system informations tool.",
"main": "./dist/main/index.js",
"scripts": {
"dev": "cross-env-shell NODE_ENV=development node .electron-nuxt/index.js",
"build": "cross-env-shell NODE_ENV=production node .electron-nuxt/index.js",
"deploy": "electron-builder build --publish always",
"test": "",
"postinstall": "electron-builder --all install-app-deps "
},
Expand Down
26 changes: 26 additions & 0 deletions src/main/BrowserWinHandler.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { EventEmitter } from 'events'
import { BrowserWindow, app } from 'electron'
import {autoUpdater} from 'electron-updater'
const isProduction = process.env.NODE_ENV === 'production'

export default class BrowserWinHandler {
Expand All @@ -19,8 +20,33 @@ export default class BrowserWinHandler {
// This method will be called when Electron has finished
// initialization and is ready to create browser windows.
// Some APIs can only be used after this event occurs.
autoUpdater.on('checking-for-update', () => {
console.log("1")
})
autoUpdater.on('update-available', (ev, info) => {
console.log("2")
})
autoUpdater.on('update-not-available', (ev, info) => {
console.log("3")
})
autoUpdater.on('error', (ev, err) => {
console.log("4")
})
autoUpdater.on('download-progress', (ev, progressObj) => {
console.log("5")
})
autoUpdater.on('update-downloaded', (ev, info) => {
// Wait 5 seconds, then quit and install
// In your application, you don't need to wait 5 seconds.
// You could call autoUpdater.quitAndInstall(); immediately
console.log("6")
autoUpdater.quitAndInstall();
})

app.on('ready', () => {
this._create()
console.log("0")
autoUpdater.checkForUpdates()
})

// On macOS it's common to re-create a window in the app when the
Expand Down
2 changes: 0 additions & 2 deletions src/main/index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
/* globals INCLUDE_RESOURCES_PATH */
import { app } from 'electron'
const { autoUpdater } = require("electron-updater")
autoUpdater.checkForUpdatesAndNotify()

/**
* Set `__resources` path to resources files in renderer process
Expand Down
1 change: 1 addition & 0 deletions src/main/mainWindow.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ const winHandler = new BrowserWinHandler({
winHandler.onCreated(browserWindow => {
if (isDev) browserWindow.loadURL(DEV_SERVER_URL)
else browserWindow.loadFile(INDEX_PATH)

})

export default winHandler

0 comments on commit e3dab64

Please sign in to comment.