Skip to content

Commit

Permalink
Travis-CI build and auto-updater support
Browse files Browse the repository at this point in the history
  • Loading branch information
lteague committed Nov 6, 2020
1 parent 8a25c73 commit 0b30f92
Show file tree
Hide file tree
Showing 6 changed files with 103 additions and 10 deletions.
12 changes: 12 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
language: node_js
node_js: "14.7.0"

jobs:
include:
- stage: Deploy Windows & Mac
if: tag IS present
os: osx
osx_image: xcode11
script:
- yarn config set version-git-tag false && yarn version --new-version ${TRAVIS_TAG/v/}
- yarn release --mac --win
20 changes: 15 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,14 @@
"name": "shot-check",
"productName": "Shot Check",
"author": "Brightspot",
"version": "0.3.1",
"version": "0.0.0-snapshot",
"license": "MIT",
"scripts": {
"format": "prettier-eslint --write 'src/**/*.js'",
"dev": "yarn format && electron-webpack dev",
"compile": "prettier-eslint --list-different 'src/**/*.js' && electron-webpack",
"dist": "yarn compile && electron-builder",
"release": "yarn compile && electron-builder -p always",
"dist": "yarn compile && electron-builder -p never",
"dist:dir": "yarn dist --dir -c.compression=store -c.mac.identity=null"
},
"electronWebpack": {
Expand All @@ -23,11 +24,20 @@
"printWidth": 120
},
"build": {
"asar": false
"appId": "com.psddev.shot-check",
"asar": false,
"mac": {
"category": "public.app-category.developer-tools"
},
"publish": {
"provider": "github",
"releaseType": "release"
}
},
"dependencies": {
"source-map-support": "0.5.19",
"puppeteer": "5.3.1"
"electron-updater": "^4.3.5",
"puppeteer": "5.3.1",
"source-map-support": "0.5.19"
},
"devDependencies": {
"@babel/core": "7.11.6",
Expand Down
2 changes: 1 addition & 1 deletion src/common/exampleProject.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ function initializeExampleProject() {
}

function initializeExampleProjectIfNecessary() {
if ((getProjects().length = 0)) {
if (getProjects().length == 0) {
initializeExampleProject()
}
}
Expand Down
10 changes: 8 additions & 2 deletions src/main/comparisonJob.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,13 +100,18 @@ function getChromiumExecPath() {
}
// This only works because package.json has `build/asar: false`
return puppeteer.executablePath()
// return puppeteer.executablePath().replace('app.asar', 'app.asar.unpacked')
}

async function openBrowser() {
const chromiumPath = getChromiumExecPath()
const chromiumPathOptions = { executablePath: chromiumPath }

try {
fs.accessSync(chromiumPath, fs.constants.R_OK)
} catch (error) {
throw 'Chrome executable not found! Update the Chrome Path in Preferences (gear icon)'
}

/*
const chromeArgs = [
'--disable-background-timer-throttling',
Expand Down Expand Up @@ -483,7 +488,8 @@ const comparisonJob = async (job, callback) => {
}
} catch (error) {
console.log(error)
callback({ message: 'Error: ' + error.message, status: 'ready' })
const message = typeof error == 'string' ? error : error.message
callback({ message: 'Error: ' + message, status: 'ready' })
return
} finally {
if (browser) {
Expand Down
46 changes: 44 additions & 2 deletions src/main/index.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
'use strict'

import { app, protocol, BrowserWindow } from 'electron'
import { app, protocol, BrowserWindow, Notification } from 'electron'
import * as path from 'path'
import { format as formatUrl } from 'url'
import * as os from 'os'
import ipcListeners from './ipc/ipcListeners'
import { isDevelopment } from '../common/appConfig'
import { APP_NAME, 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,40 @@ 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!', info)
new Notification({
title: `Version ${info.version} Available`,
body: `${APP_NAME} will restart when the updated has been downloaded and installed.`
}).show()
})

//autoUpdater.on('update-not-available', (info) => {
//})

autoUpdater.on('error', (err) => {
console.log('Error checking for updates', err)
new Notification({
title: 'Error checking for updates',
body: err
}).show()
})

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

autoUpdater.on('update-downloaded', (info) => {
console.log('Update Downloaded!', info)
new Notification({
title: 'Update Downloaded',
body: `Version ${info.version} has been installed and ${APP_NAME} will now restart.`
}).show()
setTimeout(() => autoUpdater.quitAndInstall(), 1500)
})
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 0b30f92

Please sign in to comment.