Merge branch 'master' into 'stable'

Auto-update capability

See merge request openflexure/openflexure-microscope-jsclient!27
This commit is contained in:
Joel Collins 2019-05-28 11:46:24 +00:00
commit 5a509037da
12 changed files with 164 additions and 173 deletions

View file

@ -17,7 +17,7 @@ build:
- npm install
- npm run build
artifacts:
name: "openflexure-ev-web"
name: "build"
paths:
- dist/
only:
@ -25,56 +25,28 @@ build:
- tags
- web
# Platform-specific Electron builds
package:rpi:
# Platform-specific Electron builds
package:
stage: package
dependencies:
- build
image: electronuserland/builder:wine
retry: 2
script:
- npm run dist:raspi
- mv ./release-builds/openflexure-ev-linux-armv7l.deb .
- npm run release
- mv ./release-builds/*.AppImage .
- mv ./release-builds/*.deb .
- mv ./release-builds/*.exe .
- mv ./release-builds/*.exe.blockmap .
- mv ./release-builds/latest*.yml .
artifacts:
name: "openflexure-ev-linux-armv7l"
name: "dist"
paths:
- openflexure-ev-linux-armv7l.deb
only:
- stable
- tags
- web
package:deb:
stage: package
dependencies:
- build
image: electronuserland/builder:wine
retry: 2
script:
- npm run dist:linux
- mv ./release-builds/openflexure-ev-linux-amd64.deb .
artifacts:
name: "openflexure-ev-linux-amd64"
paths:
- openflexure-ev-linux-amd64.deb
only:
- stable
- tags
- web
package:win32:
stage: package
dependencies:
- build
image: electronuserland/builder:wine
retry: 2
script:
- npm run dist:win
- mv ./release-builds/openflexure-ev-win.exe .
artifacts:
name: "openflexure-ev-win"
paths:
- openflexure-ev-win.exe
- "*.AppImage"
- "*.deb"
- "*.exe"
- "*.exe.blockmap"
- "latest*.yml"
only:
- stable
- tags
@ -84,7 +56,7 @@ package:win32:
meta:choco:
stage: meta
dependencies:
- package:win32
- package
image: patrickhuber/choco-linux
script:
- chmod +x ./app/make-nupkg.sh

View file

@ -6,18 +6,18 @@ email, or any other method with the owners of this repository before making a ch
Please note we have a working flow, and a code of conduct. Please follow it in all your interactions with the project.
## Flow
<img src="https://gitlab.com/openflexure/openflexure-identity/raw/master/flow.png" height="200">
### Development
* Master is the latest working version, always.
* Do not push to Master directly.
* New features should be developed on branches (or forks), and merged.
* Bugfixes likewise should be developed in branches.
* Master is the latest working version.
* New features and bug fixes should be developed on branches (or forks), and merged into master.
### Releases
* Once we've merged a few things in and want to make a release, we tag it on master.
* Once we've merged a few things in and want to make a release, we tag it on master.
* Not every commit on master will get a tag, we'll accumulate a few changes before making a release, unless there's a reason to release straight away.
* Once we're confident that the tagged release is building and stable, we merge it into the stable branch.
## Code of Conduct

View file

@ -1,15 +1,70 @@
//handle setupevents as quickly as possible
const setupEvents = require('./setupEvents')
if (setupEvents.handleSquirrelEvent()) {
// squirrel event handled and app will exit in 1000ms, so don't do anything else
return;
}
// Required packages
const electron = require('electron')
const { dialog } = require('electron')
const updater = require("electron-updater");
const autoUpdater = updater.autoUpdater;
const contextMenu = require('electron-context-menu')
const path = require('path')
// Auto upadater
autoUpdater.autoDownload = false;
autoUpdater.setFeedURL({
provider: "generic",
url: "https://gitlab.com/openflexure/openflexure-microscope-jsclient/-/jobs/artifacts/stable/raw?job=package"
});
autoUpdater.on('checking-for-update', function () {
sendStatusToWindow('Checking for update...');
});
autoUpdater.on('update-available', function (info) {
sendStatusToWindow('Update available.' + info)
dialog.showMessageBox(mainWindow, {
type: 'info',
title: 'Update available',
message: 'A new version of OpenFlexure eV is available.',
buttons: ['Download', 'Later']
}, (buttonIndex) => {
if (buttonIndex === 0) {
autoUpdater.downloadUpdate()
}
})
});
autoUpdater.on('update-downloaded', function (info) {
sendStatusToWindow('Update downloaded.' + info)
dialog.showMessageBox(mainWindow, {
type: 'info',
title: "Update downloaded",
message: 'Please restart the application to apply the update.',
buttons: ['Update', 'Later']
}, (buttonIndex) => {
if (buttonIndex === 0) {
autoUpdater.quitAndInstall();
}
})
});
autoUpdater.on('update-not-available', function (info) {
sendStatusToWindow('Update not available.');
});
autoUpdater.on('error', function (err) {
sendStatusToWindow('Error in auto-updater.');
});
autoUpdater.on('download-progress', function (progressObj) {
let log_message = "Download speed: " + progressObj.bytesPerSecond;
log_message = log_message + ' - Downloaded ' + parseInt(progressObj.percent) + '%';
log_message = log_message + ' (' + progressObj.transferred + "/" + progressObj.total + ')';
sendStatusToWindow(log_message);
});
function sendStatusToWindow(message) {
console.log(message);
}
// Set up the app
const app = electron.app
const BrowserWindow = electron.BrowserWindow
@ -36,6 +91,7 @@ function createWindow() {
});
mainWindow.loadURL(url)
autoUpdater.checkForUpdates();
// Emitted when the window is closed.
mainWindow.on('closed', function() {

View file

@ -4,6 +4,9 @@ directories:
appId: org.openflexure.ev
artifactName: ${name}-${os}-${arch}.${ext}
asar: true
publish:
- provider: generic
url: https://gitlab.com
files:
- filter:
- '**/*'

View file

@ -1,11 +0,0 @@
extends: app/builder-config-base.yaml
linux:
target:
- target: deb
arch:
- x64
icon: app/icons/png/
category: Science
deb:
category: Science
electronVersion: 4.1.5

View file

@ -1,12 +1,14 @@
extends: app/builder-config-base.yaml
electronVersion: 3.0.13
linux:
target:
- target: deb
arch:
- armv7l
- target: appImage
arch:
- armv7l
icon: app/icons/png/
category: Science
deb:
category: Science
fpm: ['--architecture', 'armhf']
electronVersion: 3.0.13

View file

@ -1,6 +0,0 @@
extends: app/builder-config-base.yaml
win:
target:
- NSIS
icon: app/icons/win/icon.ico
electronVersion: 4.1.5

View file

@ -1,4 +1,19 @@
extends: app/builder-config-base.yaml
electronVersion: 4.1.5
win:
target:
- NSIS
icon: app/icons/win/icon.ico
linux:
target:
- target: deb
arch:
- x64
- target: appImage
arch:
- x64
icon: app/icons/png/
category: Science
mac:
icon: app/icons/mac/icon.icns
category: public.app-category.utilities
@ -10,4 +25,3 @@ dmg:
y: 150
type: link
path: /Applications
electronVersion: 4.1.5

View file

@ -1,4 +1,6 @@
const { app, Menu } = require('electron')
const updater = require("electron-updater");
const autoUpdater = updater.autoUpdater;
const path = require('path')
const openAboutWindow = require('about-window').default
@ -47,6 +49,12 @@ const template = [
homepage: "https://gitlab.com/openflexure/openflexure-microscope-jsclient",
})
}
},
{
label: 'Check for Updates',
click () {
autoUpdater.checkForUpdates();
}
}
]
}

View file

@ -1,67 +0,0 @@
const electron = require('electron')
const app = electron.app
module.exports = {
handleSquirrelEvent: function () {
if (process.argv.length === 1) {
return false;
}
const ChildProcess = require('child_process');
const path = require('path');
const appFolder = path.resolve(process.execPath, '..');
const rootAtomFolder = path.resolve(appFolder, '..');
const updateDotExe = path.resolve(path.join(rootAtomFolder, 'Update.exe'));
const exeName = path.basename(process.execPath);
const spawn = function (command, args) {
let spawnedProcess, error;
try {
spawnedProcess = ChildProcess.spawn(command, args, {
detached: true
});
} catch (error) {}
return spawnedProcess;
};
const spawnUpdate = function (args) {
return spawn(updateDotExe, args);
};
const squirrelEvent = process.argv[1];
switch (squirrelEvent) {
case '--squirrel-install':
case '--squirrel-updated':
// Optionally do things such as:
// - Add your .exe to the PATH
// - Write to the registry for things like file associations and
// explorer context menus
// Install desktop and start menu shortcuts
spawnUpdate(['--createShortcut', exeName]);
setTimeout(app.quit, 1000);
return true;
case '--squirrel-uninstall':
// Undo anything you did in the --squirrel-install and
// --squirrel-updated handlers
// Remove desktop and start menu shortcuts
spawnUpdate(['--removeShortcut', exeName]);
setTimeout(app.quit, 1000);
return true;
case '--squirrel-obsolete':
// This is called on the outgoing version of your app before
// we update to the new version - it's the opposite of
// --squirrel-updated
app.quit();
return true;
}
}
}

66
package-lock.json generated
View file

@ -1657,7 +1657,6 @@
"version": "1.0.10",
"resolved": "https://registry.npmjs.org/argparse/-/argparse-1.0.10.tgz",
"integrity": "sha512-o5Roy6tNG4SL/FOkCAN6RzjiakZS25RLYFrcMttJqbdd8BWrnA+fGz57iN5Pb06pvBGvl5gQ0B48dJlslXvoTg==",
"dev": true,
"requires": {
"sprintf-js": "~1.0.2"
}
@ -2071,14 +2070,12 @@
"bluebird": {
"version": "3.5.4",
"resolved": "https://registry.npmjs.org/bluebird/-/bluebird-3.5.4.tgz",
"integrity": "sha512-FG+nFEZChJrbQ9tIccIfZJBz3J7mLrAhxakAbnrJWn8d7aKOC+LWifa0G+p4ZqKp4y13T7juYvdhq9NzKdsrjw==",
"dev": true
"integrity": "sha512-FG+nFEZChJrbQ9tIccIfZJBz3J7mLrAhxakAbnrJWn8d7aKOC+LWifa0G+p4ZqKp4y13T7juYvdhq9NzKdsrjw=="
},
"bluebird-lst": {
"version": "1.0.7",
"resolved": "https://registry.npmjs.org/bluebird-lst/-/bluebird-lst-1.0.7.tgz",
"integrity": "sha512-5ix04IbXVIZ6nSRM4aZnwQfk40Td0D57WAl8LfhnICF6XwT4efCZYh0veOHvfDmgpbqE4ju5L5XEAMIcAe13Kw==",
"dev": true,
"requires": {
"bluebird": "^3.5.3"
}
@ -2347,8 +2344,7 @@
"buffer-from": {
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/buffer-from/-/buffer-from-1.1.1.tgz",
"integrity": "sha512-MQcXEUbCKtEo7bhqEs6560Hyd4XaovZlO/k9V3hjVUF/zwW7KBVdSK4gIt/bzwS9MbR5qob+F5jusZsb0YQK2A==",
"dev": true
"integrity": "sha512-MQcXEUbCKtEo7bhqEs6560Hyd4XaovZlO/k9V3hjVUF/zwW7KBVdSK4gIt/bzwS9MbR5qob+F5jusZsb0YQK2A=="
},
"buffer-indexof": {
"version": "1.1.1",
@ -4218,6 +4214,35 @@
"integrity": "sha512-lyoC8aoqbbDqsprb6aPdt9n3DpOZZzdz/T4IZKsR0/dkZIxnJVUjjcpOSwA66jPRIOyDAamCTAUqweU05kKNSg==",
"dev": true
},
"electron-updater": {
"version": "4.0.6",
"resolved": "https://registry.npmjs.org/electron-updater/-/electron-updater-4.0.6.tgz",
"integrity": "sha512-JPGLME6fxJcHG8hX7HWFl6Aew6iVm0DkcrENreKa5SUJCHG+uUaAhxDGDt+YGcNkyx1uJ6eBGMvFxDTLUv67pg==",
"requires": {
"bluebird-lst": "^1.0.6",
"builder-util-runtime": "~8.1.0",
"fs-extra-p": "^7.0.0",
"js-yaml": "^3.12.0",
"lazy-val": "^1.0.3",
"lodash.isequal": "^4.5.0",
"pako": "^1.0.7",
"semver": "^5.6.0",
"source-map-support": "^0.5.9"
},
"dependencies": {
"builder-util-runtime": {
"version": "8.1.1",
"resolved": "https://registry.npmjs.org/builder-util-runtime/-/builder-util-runtime-8.1.1.tgz",
"integrity": "sha512-+ieS4PMB33vVE2S3ZNWBEQJ1zKmAs/agrBdh7XadE1lKLjrH4aXYuOh9OOGdxqIRldhlhNBaF+yKMMEFOdNVig==",
"requires": {
"bluebird-lst": "^1.0.6",
"debug": "^4.1.1",
"fs-extra-p": "^7.0.0",
"sax": "^1.2.4"
}
}
}
},
"electron-windows-store": {
"version": "2.1.0",
"resolved": "https://registry.npmjs.org/electron-windows-store/-/electron-windows-store-2.1.0.tgz",
@ -4376,8 +4401,7 @@
"esprima": {
"version": "4.0.1",
"resolved": "https://registry.npmjs.org/esprima/-/esprima-4.0.1.tgz",
"integrity": "sha512-eGuFFw7Upda+g4p+QHvnW0RyTX/SVeJBDM/gCtMARO0cLuT2HcEKnTPvhjV6aGeqrCB/sbNop0Kszm0jsaWU4A==",
"dev": true
"integrity": "sha512-eGuFFw7Upda+g4p+QHvnW0RyTX/SVeJBDM/gCtMARO0cLuT2HcEKnTPvhjV6aGeqrCB/sbNop0Kszm0jsaWU4A=="
},
"esrecurse": {
"version": "4.2.1",
@ -5003,7 +5027,6 @@
"version": "7.0.1",
"resolved": "https://registry.npmjs.org/fs-extra-p/-/fs-extra-p-7.0.1.tgz",
"integrity": "sha512-yhd2OV0HnHt2oitlp+X9hl2ReX4X/7kQeL7/72qzPHTZj5eUPGzAKOvEglU02Fa1OeG2rSy/aKB4WGVaLiF8tw==",
"dev": true,
"requires": {
"bluebird-lst": "^1.0.7",
"fs-extra": "^7.0.1"
@ -6726,7 +6749,6 @@
"version": "3.13.1",
"resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.13.1.tgz",
"integrity": "sha512-YfbcO7jXDdyj0DGxYVSlSeQNHbD7XPWvrVWeVUujrQEoZzWJIRrCPoyk6kL6IAjAG2IolMK4T0hNUe0HOUs5Jw==",
"dev": true,
"requires": {
"argparse": "^1.0.7",
"esprima": "^4.0.0"
@ -6852,8 +6874,7 @@
"lazy-val": {
"version": "1.0.4",
"resolved": "https://registry.npmjs.org/lazy-val/-/lazy-val-1.0.4.tgz",
"integrity": "sha512-u93kb2fPbIrfzBuLjZE+w+fJbUUMhNDXxNmMfaqNgpfQf1CO5ZSe2LfsnBqVAk7i/2NF48OSoRj+Xe2VT+lE8Q==",
"dev": true
"integrity": "sha512-u93kb2fPbIrfzBuLjZE+w+fJbUUMhNDXxNmMfaqNgpfQf1CO5ZSe2LfsnBqVAk7i/2NF48OSoRj+Xe2VT+lE8Q=="
},
"lcid": {
"version": "2.0.0",
@ -7013,6 +7034,11 @@
"integrity": "sha1-vsECT4WxvZbL6kBbI8FK1kQ6b4E=",
"dev": true
},
"lodash.isequal": {
"version": "4.5.0",
"resolved": "https://registry.npmjs.org/lodash.isequal/-/lodash.isequal-4.5.0.tgz",
"integrity": "sha1-QVxEePK8wwEgwizhDtMib30+GOA="
},
"lodash.kebabcase": {
"version": "4.1.1",
"resolved": "https://registry.npmjs.org/lodash.kebabcase/-/lodash.kebabcase-4.1.1.tgz",
@ -7972,8 +7998,7 @@
"pako": {
"version": "1.0.10",
"resolved": "https://registry.npmjs.org/pako/-/pako-1.0.10.tgz",
"integrity": "sha512-0DTvPVU3ed8+HNXOu5Bs+o//Mbdj9VNQMUOe9oKCwh8l0GNwpTDMKCWbRjgtD291AWnkAgkqA/LOnQS8AmS1tw==",
"dev": true
"integrity": "sha512-0DTvPVU3ed8+HNXOu5Bs+o//Mbdj9VNQMUOe9oKCwh8l0GNwpTDMKCWbRjgtD291AWnkAgkqA/LOnQS8AmS1tw=="
},
"parallel-transform": {
"version": "1.1.0",
@ -9672,8 +9697,7 @@
"sax": {
"version": "1.2.4",
"resolved": "https://registry.npmjs.org/sax/-/sax-1.2.4.tgz",
"integrity": "sha512-NqVDv9TpANUjFm0N8uM5GxL36UgKi9/atZw+x7YFnQ8ckwFGKrl4xX4yWtrey3UJm5nP1kUbnYgLopqWNSRhWw==",
"dev": true
"integrity": "sha512-NqVDv9TpANUjFm0N8uM5GxL36UgKi9/atZw+x7YFnQ8ckwFGKrl4xX4yWtrey3UJm5nP1kUbnYgLopqWNSRhWw=="
},
"schema-utils": {
"version": "0.4.7",
@ -9703,8 +9727,7 @@
"semver": {
"version": "5.7.0",
"resolved": "https://registry.npmjs.org/semver/-/semver-5.7.0.tgz",
"integrity": "sha512-Ya52jSX2u7QKghxeoFGpLwCtGlt7j0oY9DYb5apt9nPlJ42ID+ulTXESnt/qAQcoSERyZ5sl3LDIOw0nAn/5DA==",
"dev": true
"integrity": "sha512-Ya52jSX2u7QKghxeoFGpLwCtGlt7j0oY9DYb5apt9nPlJ42ID+ulTXESnt/qAQcoSERyZ5sl3LDIOw0nAn/5DA=="
},
"semver-diff": {
"version": "2.1.0",
@ -10172,7 +10195,6 @@
"version": "0.5.12",
"resolved": "https://registry.npmjs.org/source-map-support/-/source-map-support-0.5.12.tgz",
"integrity": "sha512-4h2Pbvyy15EE02G+JOZpUCmqWJuqrs+sEkzewTm++BPi7Hvn/HwcqLAcNxYAyI0x13CpPPn+kMjl+hplXMHITQ==",
"dev": true,
"requires": {
"buffer-from": "^1.0.0",
"source-map": "^0.6.0"
@ -10181,8 +10203,7 @@
"source-map": {
"version": "0.6.1",
"resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz",
"integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==",
"dev": true
"integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g=="
}
}
},
@ -10282,8 +10303,7 @@
"sprintf-js": {
"version": "1.0.3",
"resolved": "https://registry.npmjs.org/sprintf-js/-/sprintf-js-1.0.3.tgz",
"integrity": "sha1-BOaSb2YolTVPPdAVIDYzuFcpfiw=",
"dev": true
"integrity": "sha1-BOaSb2YolTVPPdAVIDYzuFcpfiw="
},
"sshpk": {
"version": "1.16.1",

View file

@ -11,13 +11,12 @@
"license": "GNU General Public License v3.0 ",
"main": "./app/app.js",
"scripts": {
"dist:all": "npm run dist:linux && npm run dist:raspi && npm run dist:win",
"dist:linux": "electron-builder --linux --config app/builder-config-linux.yaml",
"release": "electron-builder --linux --config app/builder-config-raspi.yaml & electron-builder --win --linux --config app/builder-config-x86_64.yaml",
"dist:linux": "electron-builder --linux --config app/builder-config-x86_64.yaml",
"dist:raspi": "electron-builder --linux --config app/builder-config-raspi.yaml",
"dist:win": "electron-builder --win --config app/builder-config-win.yaml",
"dist:win": "electron-builder --win --config app/builder-config-x86_64.yaml",
"dist:dmg": "electron-builder --mac --config app/builder-config-x86_64.yaml",
"dist:appx": "electron-builder --win --config app/builder-config-appx.yaml",
"dist:dmg": "electron-builder --mac --config app/builder-config-dmg.yaml",
"release": "npm run build && npm run dist:all",
"build": "vue-cli-service build",
"electron:run": "electron .",
"electron:dev": "electron app/app.dev.js",
@ -25,7 +24,8 @@
},
"dependencies": {
"about-window": "^1.12.1",
"electron-context-menu": "^0.11.0"
"electron-context-menu": "^0.11.0",
"electron-updater": "^4.0.6"
},
"devDependencies": {
"@vue/cli-plugin-babel": "^3.3.0",
@ -54,4 +54,4 @@
"last 2 versions",
"not ie <= 8"
]
}
}