Skip to content

Commit

Permalink
Implement auto update
Browse files Browse the repository at this point in the history
  • Loading branch information
thorpelawrence committed Jul 23, 2017
1 parent 2b5d747 commit ddfdbdc
Show file tree
Hide file tree
Showing 5 changed files with 82 additions and 15 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

![](resources/icon256.png)

ZX Spectrum style text editor
Text editor with ZX Spectrum theme

Created with Electron and NodeJS
Based on Monaco Code Editor
Expand Down
25 changes: 23 additions & 2 deletions main.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
const { app, BrowserWindow, ipcMain } = require('electron')
const log = require('electron-log')
const { autoUpdater } = require('electron-updater')

let win

Expand Down Expand Up @@ -29,15 +31,34 @@ function createWindow() {
})
}

app.on('ready', createWindow)
log.info("App starting...")

autoUpdater.logger = log
autoUpdater.logger.transports.file.level = 'info'

autoUpdater.on('download-progress', (progressObj) => {
let log_message = "Download speed: " + progressObj.bytesPerSecond;
log_message = log_message + ' - Downloaded ' + progressObj.percent + '%';
log_message = log_message + ' (' + progressObj.transferred + "/" + progressObj.total + ')';
sendStatusToWindow(log_message);
})

autoUpdater.on('update-downloaded', (info) => {
autoUpdater.quitAndInstall()
})

app.on('ready', () => {
createWindow()
autoUpdater.checkForUpdates()
})

app.on('window-all-closed', () => {
if (process.platform !== 'darwin') {
app.quit()
}
})

app.on('active', () => {
app.on('activate', () => {
if (win === null) {
createWindow()
}
Expand Down
16 changes: 12 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "spectrum-editor",
"version": "1.0.0",
"version": "1.1.0",
"main": "main.js",
"scripts": {
"start": "electron .",
Expand All @@ -9,12 +9,14 @@
},
"author": "Lawrence Thorpe",
"license": "MIT",
"description": "ZX Spectrum style text editor",
"description": "Text editor with ZX Spectrum theme",
"devDependencies": {
"electron": "^1.6.11",
"electron-builder": "^19.16.0"
},
"dependencies": {
"electron-log": "^2.2.7",
"electron-updater": "^2.7.1",
"monaco-editor": "^0.9.0",
"monaco-loader": "^0.8.2"
},
Expand All @@ -25,10 +27,16 @@
"category": "public.app-category.developer-tools"
},
"linux": {
"target": [ "tar.gz", "AppImage" ]
"target": [
"tar.gz",
"AppImage"
]
},
"win": {
"target": [ "nsis", "zip" ]
"target": [
"nsis",
"zip"
]
}
},
"repository": {
Expand Down
16 changes: 8 additions & 8 deletions renderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,15 +86,15 @@ loader().then((monaco) => {

ipcRenderer.on('open-file', (e, path) => {
if (path) {
fs.readFile(path, 'utf8', (err, data) => {
if (err) console.error(err)
if (monaco.editor.getModel(path)) {
editor.setModel(monaco.editor.getModel(path))
}
else {
if (monaco.editor.getModel(path)) {
editor.setModel(monaco.editor.getModel(path))
}
else {
fs.readFile(path, 'utf8', (err, data) => {
if (err) console.error(err)
editor.setModel(monaco.editor.createModel(data, null, path))
}
})
})
}
}
})

Expand Down
38 changes: 38 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -459,6 +459,14 @@ electron-download@^3.0.1:
semver "^5.3.0"
sumchecker "^1.2.0"

electron-is-dev@^0.2.0:
version "0.2.0"
resolved "https://registry.yarnpkg.com/electron-is-dev/-/electron-is-dev-0.2.0.tgz#4bd0457a43327266de6fbdf29a5a65852f32bef2"

electron-log@^2.2.7:
version "2.2.7"
resolved "https://registry.yarnpkg.com/electron-log/-/electron-log-2.2.7.tgz#8da0d2586b53b175392ae6b91dc510a67c195341"

[email protected]:
version "0.4.6"
resolved "https://registry.yarnpkg.com/electron-osx-sign/-/electron-osx-sign-0.4.6.tgz#2398e2d7cab5c1d8c3eeabb1cd490376528ec39a"
Expand All @@ -482,6 +490,22 @@ [email protected]:
fs-extra-p "^4.3.0"
mime "^1.3.6"

electron-updater@^2.7.1:
version "2.7.1"
resolved "https://registry.yarnpkg.com/electron-updater/-/electron-updater-2.7.1.tgz#ead9f08f38af8983c6f9185a1931dc8582b60187"
dependencies:
bluebird-lst "^1.0.2"
debug "^2.6.8"
electron-builder-http "~19.16.0"
electron-is-dev "^0.2.0"
fs-extra-p "^4.3.0"
js-yaml "^3.9.0"
lodash.isequal "^4.5.0"
semver "^5.3.0"
source-map-support "^0.4.15"
uuid-1345 "^0.99.6"
xelement "^1.0.16"

electron@^1.6.11:
version "1.6.11"
resolved "https://registry.yarnpkg.com/electron/-/electron-1.6.11.tgz#be79c0ebdcefedb5bf28117409800fa53baceffa"
Expand Down Expand Up @@ -942,6 +966,10 @@ locate-path@^2.0.0:
p-locate "^2.0.0"
path-exists "^3.0.0"

lodash.isequal@^4.5.0:
version "4.5.0"
resolved "https://registry.yarnpkg.com/lodash.isequal/-/lodash.isequal-4.5.0.tgz#415c4478f2bcc30120c22ce10ed3226f7d3e18e0"

lodash.toarray@^4.4.0:
version "4.4.0"
resolved "https://registry.yarnpkg.com/lodash.toarray/-/lodash.toarray-4.4.0.tgz#24c4bfcd6b2fba38bfd0594db1179d8e9b656561"
Expand Down Expand Up @@ -1395,6 +1423,10 @@ sanitize-filename@^1.6.1:
dependencies:
truncate-utf8-bytes "^1.0.0"

sax@^1.2.1:
version "1.2.4"
resolved "https://registry.yarnpkg.com/sax/-/sax-1.2.4.tgz#2816234e2378bddc4e5354fab5caa895df7100d9"

semver-diff@^2.0.0:
version "2.1.0"
resolved "https://registry.yarnpkg.com/semver-diff/-/semver-diff-2.1.0.tgz#4bbb8437c8d37e4b0cf1a68fd726ec6d645d6d36"
Expand Down Expand Up @@ -1746,6 +1778,12 @@ xdg-basedir@^3.0.0:
version "3.0.0"
resolved "https://registry.yarnpkg.com/xdg-basedir/-/xdg-basedir-3.0.0.tgz#496b2cc109eca8dbacfe2dc72b603c17c5870ad4"

xelement@^1.0.16:
version "1.0.16"
resolved "https://registry.yarnpkg.com/xelement/-/xelement-1.0.16.tgz#900bb46c20fc2dffadff778a9d2dc36699d0ff7e"
dependencies:
sax "^1.2.1"

[email protected]:
version "8.2.2"
resolved "https://registry.yarnpkg.com/xmlbuilder/-/xmlbuilder-8.2.2.tgz#69248673410b4ba42e1a6136551d2922335aa773"
Expand Down

0 comments on commit ddfdbdc

Please sign in to comment.