Skip to content

Commit e3dab64

Browse files
committed
Test to implement auto update
1 parent b276c23 commit e3dab64

File tree

8 files changed

+37
-4
lines changed

8 files changed

+37
-4
lines changed

.electron-nuxt/index.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,4 +56,6 @@ const pipe = new Pipeline({
5656
builder
5757
})
5858

59+
60+
5961
pipe.run()

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@ dist
33
build/*
44
!build/icons
55
node_modules
6+
electron-builder.yml

builder.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ const macOS = {
4444
module.exports = {
4545
asar: true,
4646
productName: 'System Companion',
47-
appId: 'com.rolaforg.projectg',
47+
appId: 'com.github.romslf.system-companion',
4848
artifactName: 'sc-${version}.${ext}',
4949
directories: {
5050
output: 'build'

electron-builder-example.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
appId: com.github.romslf.system-companion
2+
publish:
3+
provider: github
4+
token: [YOUR GITHUB ACCESS TOKEN]

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
{
22
"name": "system-companion",
3-
"version": "0.0.2",
3+
"version": "0.0.1",
44
"description": "Multi platform system informations tool.",
55
"main": "./dist/main/index.js",
66
"scripts": {
77
"dev": "cross-env-shell NODE_ENV=development node .electron-nuxt/index.js",
88
"build": "cross-env-shell NODE_ENV=production node .electron-nuxt/index.js",
9+
"deploy": "electron-builder build --publish always",
910
"test": "",
1011
"postinstall": "electron-builder --all install-app-deps "
1112
},

src/main/BrowserWinHandler.js

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { EventEmitter } from 'events'
22
import { BrowserWindow, app } from 'electron'
3+
import {autoUpdater} from 'electron-updater'
34
const isProduction = process.env.NODE_ENV === 'production'
45

56
export default class BrowserWinHandler {
@@ -19,8 +20,33 @@ export default class BrowserWinHandler {
1920
// This method will be called when Electron has finished
2021
// initialization and is ready to create browser windows.
2122
// Some APIs can only be used after this event occurs.
23+
autoUpdater.on('checking-for-update', () => {
24+
console.log("1")
25+
})
26+
autoUpdater.on('update-available', (ev, info) => {
27+
console.log("2")
28+
})
29+
autoUpdater.on('update-not-available', (ev, info) => {
30+
console.log("3")
31+
})
32+
autoUpdater.on('error', (ev, err) => {
33+
console.log("4")
34+
})
35+
autoUpdater.on('download-progress', (ev, progressObj) => {
36+
console.log("5")
37+
})
38+
autoUpdater.on('update-downloaded', (ev, info) => {
39+
// Wait 5 seconds, then quit and install
40+
// In your application, you don't need to wait 5 seconds.
41+
// You could call autoUpdater.quitAndInstall(); immediately
42+
console.log("6")
43+
autoUpdater.quitAndInstall();
44+
})
45+
2246
app.on('ready', () => {
2347
this._create()
48+
console.log("0")
49+
autoUpdater.checkForUpdates()
2450
})
2551

2652
// On macOS it's common to re-create a window in the app when the

src/main/index.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
/* globals INCLUDE_RESOURCES_PATH */
22
import { app } from 'electron'
3-
const { autoUpdater } = require("electron-updater")
4-
autoUpdater.checkForUpdatesAndNotify()
53

64
/**
75
* Set `__resources` path to resources files in renderer process

src/main/mainWindow.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ const winHandler = new BrowserWinHandler({
1313
winHandler.onCreated(browserWindow => {
1414
if (isDev) browserWindow.loadURL(DEV_SERVER_URL)
1515
else browserWindow.loadFile(INDEX_PATH)
16+
1617
})
1718

1819
export default winHandler

0 commit comments

Comments
 (0)