diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..b512085 --- /dev/null +++ b/.travis.yml @@ -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 diff --git a/package.json b/package.json index 7a1f074..39e0db4 100644 --- a/package.json +++ b/package.json @@ -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": { @@ -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", diff --git a/src/common/exampleProject.js b/src/common/exampleProject.js index 8a8f2fa..97a01c4 100644 --- a/src/common/exampleProject.js +++ b/src/common/exampleProject.js @@ -40,7 +40,7 @@ function initializeExampleProject() { } function initializeExampleProjectIfNecessary() { - if ((getProjects().length = 0)) { + if (getProjects().length == 0) { initializeExampleProject() } } diff --git a/src/main/comparisonJob.js b/src/main/comparisonJob.js index ea1fa1d..9f061c9 100644 --- a/src/main/comparisonJob.js +++ b/src/main/comparisonJob.js @@ -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', @@ -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) { diff --git a/src/main/index.js b/src/main/index.js index 1747e33..1ecd04f 100644 --- a/src/main/index.js +++ b/src/main/index.js @@ -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 @@ -78,6 +79,10 @@ app.on('ready', () => { initializeExampleProjectIfNecessary() mainWindow = createMainWindow() ipcListeners() + + if (!isDevelopment) { + autoUpdater.checkForUpdates() + } }) // handle file:// URLs @@ -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) +}) diff --git a/yarn.lock b/yarn.lock index a9ca1a8..3ff1561 100644 --- a/yarn.lock +++ b/yarn.lock @@ -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" @@ -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" @@ -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"