Merge pull request #2653 from vector-im/dbkr/electron_dist_tweaks
Final bits to prepare electron distribtion:
This commit is contained in:
commit
b6aa7f430c
|
@ -10,3 +10,4 @@
|
||||||
.DS_Store
|
.DS_Store
|
||||||
npm-debug.log
|
npm-debug.log
|
||||||
electron/dist
|
electron/dist
|
||||||
|
electron/pub
|
||||||
|
|
|
@ -107,6 +107,9 @@ You can configure the app by copying `config.sample.json` to
|
||||||
valid location on this network. This is used as a hint to the user to indicate
|
valid location on this network. This is used as a hint to the user to indicate
|
||||||
when a valid location has been entered so it's not necessary for this to be
|
when a valid location has been entered so it's not necessary for this to be
|
||||||
exactly correct. Optional.
|
exactly correct. Optional.
|
||||||
|
1. `update_base_url` (electron app only): HTTPS URL to a web server to download
|
||||||
|
updates from. This should be the path to the directory containing `install`
|
||||||
|
and `update`.
|
||||||
1. `cross_origin_renderer_url`: URL to a static HTML page hosting code to help display
|
1. `cross_origin_renderer_url`: URL to a static HTML page hosting code to help display
|
||||||
encrypted file attachments. This MUST be hosted on a completely separate domain to
|
encrypted file attachments. This MUST be hosted on a completely separate domain to
|
||||||
anything else since it is used to isolate the privileges of file attachments to this
|
anything else since it is used to isolate the privileges of file attachments to this
|
||||||
|
|
|
@ -0,0 +1,4 @@
|
||||||
|
This directory contains the config file for the official riot.im distribution
|
||||||
|
of Riot Desktop. You probably do not want to build with this config unless
|
||||||
|
you're building the official riot.im distribution, or you'll find your builds
|
||||||
|
will replace themselves with the riot.im build.
|
|
@ -1,5 +1,5 @@
|
||||||
{
|
{
|
||||||
"update_url": "https://riot.im/download/desktop/",
|
"update_base_url": "https://riot.im/download/desktop/",
|
||||||
"default_hs_url": "https://matrix.org",
|
"default_hs_url": "https://matrix.org",
|
||||||
"default_is_url": "https://vector.im",
|
"default_is_url": "https://vector.im",
|
||||||
"brand": "Riot",
|
"brand": "Riot",
|
|
@ -30,7 +30,7 @@ const VectorMenu = require('./vectormenu');
|
||||||
|
|
||||||
let vectorConfig = {};
|
let vectorConfig = {};
|
||||||
try {
|
try {
|
||||||
vectorConfig = require('../../vector/config.json');
|
vectorConfig = require('../../webapp/config.json');
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
// it would be nice to check the error code here and bail if the config
|
// it would be nice to check the error code here and bail if the config
|
||||||
// is unparseable, but we get MODULE_NOT_FOUND in the case of a missing
|
// is unparseable, but we get MODULE_NOT_FOUND in the case of a missing
|
||||||
|
@ -101,9 +101,9 @@ function pollForUpdates() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function startAutoUpdate(update_url) {
|
function startAutoUpdate(update_base_url) {
|
||||||
if (update_url.slice(-1) !== '/') {
|
if (update_base_url.slice(-1) !== '/') {
|
||||||
update_url = update_url + '/';
|
update_base_url = update_base_url + '/';
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
// For reasons best known to Squirrel, the way it checks for updates
|
// For reasons best known to Squirrel, the way it checks for updates
|
||||||
|
@ -112,9 +112,9 @@ function startAutoUpdate(update_url) {
|
||||||
// 204 No Content. On windows it takes a base path and looks for
|
// 204 No Content. On windows it takes a base path and looks for
|
||||||
// files under that path.
|
// files under that path.
|
||||||
if (process.platform == 'darwin') {
|
if (process.platform == 'darwin') {
|
||||||
electron.autoUpdater.setFeedURL(update_url);
|
electron.autoUpdater.setFeedURL(update_base_url + 'macos/');
|
||||||
} else if (process.platform == 'win32') {
|
} else if (process.platform == 'win32') {
|
||||||
electron.autoUpdater.setFeedURL(update_url + 'win32/');
|
electron.autoUpdater.setFeedURL(update_base_url + 'win32/' + process.arch + '/');
|
||||||
} else {
|
} else {
|
||||||
// Squirrel / electron only supports auto-update on these two platforms.
|
// Squirrel / electron only supports auto-update on these two platforms.
|
||||||
// I'm not even going to try to guess which feed style they'd use if they
|
// I'm not even going to try to guess which feed style they'd use if they
|
||||||
|
@ -149,11 +149,11 @@ process.on('uncaughtException', function (error) {
|
||||||
electron.ipcMain.on('install_update', installUpdate);
|
electron.ipcMain.on('install_update', installUpdate);
|
||||||
|
|
||||||
electron.app.on('ready', () => {
|
electron.app.on('ready', () => {
|
||||||
if (vectorConfig.update_url) {
|
if (vectorConfig.update_base_url) {
|
||||||
console.log("Starting auto update with URL: " + vectorConfig.update_url);
|
console.log("Starting auto update with base URL: " + vectorConfig.update_base_url);
|
||||||
startAutoUpdate(vectorConfig.update_url);
|
startAutoUpdate(vectorConfig.update_base_url);
|
||||||
} else {
|
} else {
|
||||||
console.log("No update_url is defined: auto update is disabled");
|
console.log("No update_base_url is defined: auto update is disabled");
|
||||||
}
|
}
|
||||||
|
|
||||||
mainWindow = new electron.BrowserWindow({
|
mainWindow = new electron.BrowserWindow({
|
||||||
|
|
15
package.json
15
package.json
|
@ -35,7 +35,7 @@
|
||||||
"build:compile": "babel --source-maps -d lib src",
|
"build:compile": "babel --source-maps -d lib src",
|
||||||
"build:bundle": "NODE_ENV=production webpack -p --progress",
|
"build:bundle": "NODE_ENV=production webpack -p --progress",
|
||||||
"build:bundle:dev": "webpack --optimize-occurence-order --progress",
|
"build:bundle:dev": "webpack --optimize-occurence-order --progress",
|
||||||
"build:electron": "npm run clean && npm run build && cpx electron/config.json webapp/ && build -lwm",
|
"build:electron": "npm run clean && npm run build && build -wml --ia32 --x64",
|
||||||
"build": "node scripts/babelcheck.js && npm run build:res && npm run build:config && npm run build:emojione && npm run build:css && npm run build:bundle",
|
"build": "node scripts/babelcheck.js && npm run build:res && npm run build:config && npm run build:emojione && npm run build:css && npm run build:bundle",
|
||||||
"build:dev": "node scripts/babelcheck.js && npm run build:res && npm run build:config && npm run build:emojione && npm run build:css && npm run build:bundle:dev",
|
"build:dev": "node scripts/babelcheck.js && npm run build:res && npm run build:config && npm run build:emojione && npm run build:css && npm run build:bundle:dev",
|
||||||
"dist": "scripts/package.sh",
|
"dist": "scripts/package.sh",
|
||||||
|
@ -47,7 +47,7 @@
|
||||||
"start:skins:css": "mkdirp build && catw \"src/skins/vector/css/**/*.css\" -o build/components.css",
|
"start:skins:css": "mkdirp build && catw \"src/skins/vector/css/**/*.css\" -o build/components.css",
|
||||||
"start": "node scripts/babelcheck.js && parallelshell \"npm run start:emojione\" \"npm run start:res\" \"npm run start:config\" \"npm run start:js\" \"npm run start:skins:css\"",
|
"start": "node scripts/babelcheck.js && parallelshell \"npm run start:emojione\" \"npm run start:res\" \"npm run start:config\" \"npm run start:js\" \"npm run start:skins:css\"",
|
||||||
"start:prod": "parallelshell \"npm run start:emojione\" \"npm run start:js:prod\" \"npm run start:skins:css\"",
|
"start:prod": "parallelshell \"npm run start:emojione\" \"npm run start:js:prod\" \"npm run start:skins:css\"",
|
||||||
"clean": "rimraf build lib webapp",
|
"clean": "rimraf build lib webapp electron/dist",
|
||||||
"prepublish": "npm run build:compile",
|
"prepublish": "npm run build:compile",
|
||||||
"test": "karma start --single-run=true --autoWatch=false --browsers PhantomJS --colors=false",
|
"test": "karma start --single-run=true --autoWatch=false --browsers PhantomJS --colors=false",
|
||||||
"test:multi": "karma start"
|
"test:multi": "karma start"
|
||||||
|
@ -97,7 +97,7 @@
|
||||||
"catw": "^1.0.1",
|
"catw": "^1.0.1",
|
||||||
"cpx": "^1.3.2",
|
"cpx": "^1.3.2",
|
||||||
"css-raw-loader": "^0.1.1",
|
"css-raw-loader": "^0.1.1",
|
||||||
"electron-builder": "^7.23.2",
|
"electron-builder": "^10.4.1",
|
||||||
"emojione": "^2.2.3",
|
"emojione": "^2.2.3",
|
||||||
"expect": "^1.16.0",
|
"expect": "^1.16.0",
|
||||||
"fs-extra": "^0.30.0",
|
"fs-extra": "^0.30.0",
|
||||||
|
@ -134,14 +134,17 @@
|
||||||
"dereference": true,
|
"dereference": true,
|
||||||
"//files": "We bundle everything, so we only need to include webapp/",
|
"//files": "We bundle everything, so we only need to include webapp/",
|
||||||
"files": [
|
"files": [
|
||||||
"!**/*",
|
|
||||||
"electron/src/**",
|
"electron/src/**",
|
||||||
"electron/img/**",
|
"electron/img/**",
|
||||||
"webapp/**",
|
"webapp/**",
|
||||||
"package.json"
|
"package.json"
|
||||||
],
|
],
|
||||||
"squirrelWindows": {
|
"linux": {
|
||||||
"iconUrl": "https://riot.im/favicon.ico"
|
"target": "deb",
|
||||||
|
"maintainer": "support@riot.im"
|
||||||
|
},
|
||||||
|
"win": {
|
||||||
|
"target": "squirrel"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"directories": {
|
"directories": {
|
||||||
|
|
|
@ -0,0 +1,131 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
set -e
|
||||||
|
|
||||||
|
usage() {
|
||||||
|
echo "Usage: $0 -v <version> -c <config file> [-n]"
|
||||||
|
echo
|
||||||
|
echo "version: commit-ish to check out and build"
|
||||||
|
echo "config file: a path to a json config file to"
|
||||||
|
echo "ship with the build. In addition, update_base_url:"
|
||||||
|
echo "from this file is used to set up auto-update."
|
||||||
|
echo "-n: build with no config file."
|
||||||
|
echo
|
||||||
|
echo "Values may also be passed as environment variables"
|
||||||
|
}
|
||||||
|
|
||||||
|
conffile=
|
||||||
|
version=
|
||||||
|
skipcfg=0
|
||||||
|
while getopts "c:v:n" opt; do
|
||||||
|
case $opt in
|
||||||
|
c)
|
||||||
|
conffile=$OPTARG
|
||||||
|
;;
|
||||||
|
v)
|
||||||
|
version=$OPTARG
|
||||||
|
;;
|
||||||
|
n)
|
||||||
|
skipcfg=1
|
||||||
|
;;
|
||||||
|
\?)
|
||||||
|
echo "Invalid option: -$OPTARG" >&2
|
||||||
|
usage
|
||||||
|
exit
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
|
||||||
|
if [ -z "$version" ]; then
|
||||||
|
echo "No version supplied"
|
||||||
|
usage
|
||||||
|
exit
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -z "$conffile" ] && [ "$skipcfg" = 0 ]; then
|
||||||
|
echo "No config file given. Use -c to supply a config file or"
|
||||||
|
echo "-n to build with no config file (and no auto update)."
|
||||||
|
exit
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -n "$conffile" ]; then
|
||||||
|
update_base_url=`jq -r .update_base_url $conffile`
|
||||||
|
|
||||||
|
if [ -z "$update_base_url" ]; then
|
||||||
|
echo "No update URL supplied. Use update_base_url: null if you really"
|
||||||
|
echo "want a build with no auto-update."
|
||||||
|
usage
|
||||||
|
exit
|
||||||
|
fi
|
||||||
|
# Make sure the base URL ends in a slash if it doesn't already
|
||||||
|
update_base_url=`echo $update_base_url | sed -e 's#\([^\/]\)$#\1\/#'`
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ ! -f package.json ]; then
|
||||||
|
echo "No package.json found. This script must be run from"
|
||||||
|
echo "the vector-web directory."
|
||||||
|
exit
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "Building $version using Update base URL $update_base_url"
|
||||||
|
|
||||||
|
projdir=`pwd`
|
||||||
|
builddir=`mktemp -d 2>/dev/null || mktemp -d -t 'buildtmp'`
|
||||||
|
pushd "$builddir"
|
||||||
|
git clone "$projdir" .
|
||||||
|
git checkout "$version"
|
||||||
|
|
||||||
|
if [ -n "$conffile" ]; then
|
||||||
|
popd
|
||||||
|
cp "$conffile" "$builddir/"
|
||||||
|
pushd "$builddir"
|
||||||
|
fi
|
||||||
|
|
||||||
|
npm install
|
||||||
|
npm run build:electron
|
||||||
|
|
||||||
|
popd
|
||||||
|
|
||||||
|
distdir="$builddir/electron/dist"
|
||||||
|
pubdir="$projdir/electron/pub"
|
||||||
|
rm -r "$pubdir" || true
|
||||||
|
mkdir -p "$pubdir"
|
||||||
|
|
||||||
|
# figure out what version this build is known as
|
||||||
|
# (since we could be building from a branch or indeed
|
||||||
|
# any commit-ish, not just a version tag)
|
||||||
|
vername=`python -c 'import yaml; import sys; print yaml.load(sys.stdin)["version"]' < $builddir/electron/dist/latest.yml`
|
||||||
|
|
||||||
|
# Install packages: what the user downloads the first time,
|
||||||
|
# (DMGs for mac, exe installer for windows)
|
||||||
|
mkdir -p "$pubdir/install/macos"
|
||||||
|
cp $distdir/mac/*.dmg "$pubdir/install/macos/"
|
||||||
|
|
||||||
|
mkdir -p "$pubdir/install/win32/ia32/"
|
||||||
|
cp $distdir/win-ia32/*.exe "$pubdir/install/win32/ia32/"
|
||||||
|
|
||||||
|
mkdir -p "$pubdir/install/win32/x64/"
|
||||||
|
cp $distdir/win/*.exe "$pubdir/install/win32/x64/"
|
||||||
|
|
||||||
|
# Packages for auto-update
|
||||||
|
mkdir -p "$pubdir/update/macos"
|
||||||
|
cp $distdir/mac/*.zip "$pubdir/update/macos/"
|
||||||
|
echo "$ver" > "$pubdir/update/macos/latest"
|
||||||
|
|
||||||
|
mkdir -p "$pubdir/update/win32/ia32/"
|
||||||
|
cp $distdir/win-ia32/*.nupkg "$pubdir/update/win32/ia32/"
|
||||||
|
cp $distdir/win-ia32/RELEASES "$pubdir/install/win32/ia32/"
|
||||||
|
|
||||||
|
mkdir -p "$pubdir/update/win32/x64/"
|
||||||
|
cp $distdir/win/*.nupkg "$pubdir/update/win32/x64/"
|
||||||
|
cp $distdir/win/RELEASES "$pubdir/update/win32x64ia32/"
|
||||||
|
|
||||||
|
# Move the debs to the main project dir's dist folder
|
||||||
|
rm -r "$projdir/electron/dist" || true
|
||||||
|
mkdir -p "$projdir/electron/dist"
|
||||||
|
cp $distdir/*.deb "$projdir/electron/dist/"
|
||||||
|
|
||||||
|
rm -rf "$builddir"
|
||||||
|
|
||||||
|
echo "Riot Desktop $vername is ready to go in $pubdir: this directory can be hosted on your web server."
|
||||||
|
echo "deb archives are in electron/dist/ - these should be added into your debian repository"
|
Loading…
Reference in New Issue