Skip to content

Commit

Permalink
Adds auto update features.
Browse files Browse the repository at this point in the history
  • Loading branch information
steveruizok committed Mar 4, 2021
1 parent 52d953f commit f8e648e
Show file tree
Hide file tree
Showing 7 changed files with 201 additions and 23 deletions.
144 changes: 126 additions & 18 deletions app/background.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion app/background.js.map

Large diffs are not rendered by default.

38 changes: 37 additions & 1 deletion main/background.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { app, globalShortcut } from "electron"
import { app, autoUpdater, globalShortcut } from "electron"
import serve from "electron-serve"
import { createWindow } from "./helpers"
import updater from "update-electron-app"

const isProd = process.env.NODE_ENV === "production"

Expand All @@ -13,6 +14,39 @@ if (isProd) {
;(async () => {
await app.whenReady()

// Auto Updates

const server = "https://update.electronjs.org"
const feed = `${server}/OWNER/REPO/${process.platform}-${
process.arch
}/${app.getVersion()}`

autoUpdater.setFeedURL(feed)

setInterval(() => {
autoUpdater.checkForUpdates()
}, 10 * 60 * 1000)

autoUpdater.on("update-downloaded", (event, releaseNotes, releaseName) => {
const dialogOpts = {
type: "info",
buttons: ["Restart", "Later"],
title: "Application Update",
message: releaseName,
detail:
"A new version has been downloaded. Restart the application to apply the updates.",
}

dialog.showMessageBox(dialogOpts).then((returnValue) => {
if (returnValue.response === 0) autoUpdater.quitAndInstall()
})
})

autoUpdater.on("error", (message) => {
console.error("There was a problem updating the application")
console.error(message)
})

// Create window

const mainWindow = createWindow("main", {
Expand Down Expand Up @@ -82,3 +116,5 @@ if (isProd) {
app.on("window-all-closed", () => {
app.quit()
})

updater()
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"description": "A drawing app for streaming.",
"author": "Steve Ruiz @steveruizok",
"homepage": "https://github.com/steveruizok/telestrator",
"repository": "https://github.com/steveruizok/telestrator",
"main": "app/background.js",
"scripts": {
"dev": "nextron",
Expand All @@ -27,7 +28,8 @@
"perfect-freehand": "^0.3.0",
"react-feather": "^2.0.9",
"state-designer": "^1.5.6",
"styled-components": "^5.2.1"
"styled-components": "^5.2.1",
"update-electron-app": "^2.0.1"
},
"devDependencies": {
"@types/lodash": "^4.14.168",
Expand Down
2 changes: 1 addition & 1 deletion renderer/lib/defaults.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,4 @@ export const colors = [
// "177, 62, 83",
]

export const sizes = [16, 32, 64]
export const sizes = [8, 16, 32]
2 changes: 1 addition & 1 deletion renderer/lib/state.ts
Original file line number Diff line number Diff line change
Expand Up @@ -776,7 +776,7 @@ function getFreehandPath(mark: Mark, isPressure: boolean) {
const path = new Path2D(
getSvgPathFromStroke(
getStroke(points, {
size: mark.size,
size: mark.size * 2,
thinning: 0.618,
simulatePressure: mark.pointerType !== "pen",
})
Expand Down
32 changes: 32 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2696,6 +2696,11 @@ electron-builder@^22.9.1:
update-notifier "^4.1.1"
yargs "^16.0.3"

electron-is-dev@^0.3.0:
version "0.3.0"
resolved "https://registry.yarnpkg.com/electron-is-dev/-/electron-is-dev-0.3.0.tgz#14e6fda5c68e9e4ecbeff9ccf037cbd7c05c5afe"
integrity sha1-FOb9pcaOnk7L7/nM8DfL18BcWv4=

electron-notarize@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/electron-notarize/-/electron-notarize-1.0.0.tgz#bc925b1ccc3f79e58e029e8c4706572b01a9fd8f"
Expand Down Expand Up @@ -3259,6 +3264,13 @@ [email protected]:
resolved "https://registry.yarnpkg.com/github-from-package/-/github-from-package-0.0.0.tgz#97fb5d96bfde8973313f20e8288ef9a167fa64ce"
integrity sha1-l/tdlr/eiXMxPyDoKI75oWf6ZM4=

github-url-to-object@^4.0.4:
version "4.0.4"
resolved "https://registry.yarnpkg.com/github-url-to-object/-/github-url-to-object-4.0.4.tgz#a9797b7026e18d53b50b07f45b7e169b55fd90ee"
integrity sha512-1Ri1pR8XTfzLpbtPz5MlW/amGNdNReuExPsbF9rxLsBfO1GH9RtDBamhJikd0knMWq3RTTQDbTtw0GGvvEAJEA==
dependencies:
is-url "^1.1.0"

glob-parent@^3.1.0:
version "3.1.0"
resolved "https://registry.yarnpkg.com/glob-parent/-/glob-parent-3.1.0.tgz#9e6af6299d8d3bd2bd40430832bd113df906c5ae"
Expand Down Expand Up @@ -3808,6 +3820,11 @@ is-typedarray@^1.0.0:
resolved "https://registry.yarnpkg.com/is-typedarray/-/is-typedarray-1.0.0.tgz#e479c80858df0c1b11ddda6940f96011fcda4a9a"
integrity sha1-5HnICFjfDBsR3dppQPlgEfzaSpo=

is-url@^1.1.0, is-url@^1.2.4:
version "1.2.4"
resolved "https://registry.yarnpkg.com/is-url/-/is-url-1.2.4.tgz#04a4df46d28c4cff3d73d01ff06abeb318a1aa52"
integrity sha512-ITvGim8FhRiYe4IQ5uHSkj7pVaPDrCTkNd3yq3cV7iZAcJdHTUMPMEHcqSOy9xZ9qFenQCvi+2wjH9a1nXqHww==

is-windows@^1.0.2:
version "1.0.2"
resolved "https://registry.yarnpkg.com/is-windows/-/is-windows-1.0.2.tgz#d1850eb9791ecd18e6182ce12a30f396634bb19d"
Expand Down Expand Up @@ -4282,6 +4299,11 @@ [email protected]:
resolved "https://registry.yarnpkg.com/ms/-/ms-2.1.2.tgz#d09d1f357b443f493382a8eb3ccd183872ae6009"
integrity sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==

ms@^2.1.1:
version "2.1.3"
resolved "https://registry.yarnpkg.com/ms/-/ms-2.1.3.tgz#574c8138ce1d2b5861f0b44579dbadd60c6615b2"
integrity sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==

nan@^2.12.1:
version "2.14.2"
resolved "https://registry.yarnpkg.com/nan/-/nan-2.14.2.tgz#f5376400695168f4cc694ac9393d0c9585eeea19"
Expand Down Expand Up @@ -6163,6 +6185,16 @@ upath@^1.1.1:
resolved "https://registry.yarnpkg.com/upath/-/upath-1.2.0.tgz#8f66dbcd55a883acdae4408af8b035a5044c1894"
integrity sha512-aZwGpamFO61g3OlfT7OQCHqhGnW43ieH9WZeP7QxN/G/jS4jfqUkZxoryvJgVPEcrl5NL/ggHsSmLMHuH64Lhg==

update-electron-app@^2.0.1:
version "2.0.1"
resolved "https://registry.yarnpkg.com/update-electron-app/-/update-electron-app-2.0.1.tgz#229dbeb4534f51ec949e6a46ae1ac32f68a17eed"
integrity sha512-e4xEner89UZZaBGYJbYlMdL1uUrC0VjOsTAL2N4opPjzFtn+j7mdsJJsnyXZzUVeLY+8tuCX4XEsUM98oBHmZg==
dependencies:
electron-is-dev "^0.3.0"
github-url-to-object "^4.0.4"
is-url "^1.2.4"
ms "^2.1.1"

update-notifier@^4.1.1:
version "4.1.3"
resolved "https://registry.yarnpkg.com/update-notifier/-/update-notifier-4.1.3.tgz#be86ee13e8ce48fb50043ff72057b5bd598e1ea3"
Expand Down

0 comments on commit f8e648e

Please sign in to comment.