Skip to content
This repository was archived by the owner on Oct 11, 2022. It is now read-only.

Commit 1f70fa1

Browse files
authored
Merge pull request #3233 from withspectrum/2.4.3
2.4.3
2 parents a94d9a8 + 547c1fa commit 1f70fa1

File tree

25 files changed

+1415
-466
lines changed

25 files changed

+1415
-466
lines changed

.circleci/config.yml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -201,10 +201,11 @@ workflows:
201201
test:
202202
jobs:
203203
- checkout_environment
204+
205+
# Testing
204206
- test_mobile_js:
205207
requires:
206208
- checkout_environment
207-
208209
# Disabled as Expo is fixing their critical issue with Detox
209210
# - test_mobile_native:
210211
# requires:
@@ -215,6 +216,8 @@ workflows:
215216
- test_static_js:
216217
requires:
217218
- checkout_environment
219+
220+
# Deployment
218221
- deploy_alpha:
219222
requires:
220223
- test_static_js
@@ -228,4 +231,4 @@ workflows:
228231
- test_web
229232
filters:
230233
branches:
231-
only: production
234+
only: alpha

.github/PULL_REQUEST_TEMPLATE.md

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
**Deploy after merge (delete what needn't be deployed)**
88
- api
99
- hyperion (frontend)
10+
- desktop
1011
- athena
1112
- vulcan
1213
- mercury
@@ -20,11 +21,8 @@ YES
2021

2122
**Release notes for users (delete if codebase-only change)**
2223
-
23-
2424
<!--
25-
2625
If your pull request introduces changes to the user interface on Spectrum, please share before and after screenshots of the changes (gifs or videos are encouraged for interaction changes). Please include screenshots of desktop and mobile viewports to ensure that all responsive cases are reviewed.
27-
2826
-->
2927

3028
**Related issues (delete if you don't know any existing issue(s) that could be related to this PR)**

config-overrides.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ module.exports = function override(config, env) {
8888
config.plugins.push(
8989
new webpack.optimize.CommonsChunkPlugin({
9090
names: ['bootstrap'],
91-
filename: './static/js/[name].js',
91+
filename: 'static/js/[name].js',
9292
minChunks: Infinity,
9393
})
9494
);

desktop/deployment.md

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# Desktop App Deployment
2+
3+
We have semi-continuous deployment set up for the desktop app. Here's how it works:
4+
5+
## Automatic
6+
7+
1. We merge the latest changes from `alpha` to `production`
8+
2. This prompts a CircleCI build, which packages the desktop app for all operating systems and uploads them to GitHub as a draft release. That looks something like this:
9+
10+
![screen shot 2018-05-30 at 15 42 22](https://user-images.githubusercontent.com/7525670/40724411-4b5fe9ec-6421-11e8-8e4b-d0df96b46f72.png)
11+
12+
3. Go to that draft release, download the build for your OS and test the new version locally.
13+
14+
4. If you're happy with how it works, click the "Edit" button on the draft release and you get to this screen:
15+
16+
![screenshot-2018-5-30 withspectrum spectrum](https://user-images.githubusercontent.com/7525670/40724488-77256642-6421-11e8-9911-999ed0fa5957.png)
17+
18+
4. Fill out the title and release notes of the release (like it's already done above), then click "Publish release".
19+
20+
As soon as it's published, the app will prompt existing users to upgrade to the newest version and download and install it for them.
21+
22+
## Manual
23+
24+
You can also do a manual deploy of the desktop apps. You will need to get a GitHub token from your personal GitHub settings, then run the following command:
25+
26+
```
27+
GH_TOKEN=asdf123 yarn run release:desktop
28+
```
29+

desktop/package.json

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,21 +7,23 @@
77
"email": "[email protected]"
88
},
99
"repository": "https://github.com/withspectrum/spectrum",
10-
"version": "1.0.0-beta.2",
10+
"version": "1.0.1",
1111
"main": "src/main.js",
1212
"private": true,
1313
"dependencies": {
1414
"electron-is-dev": "^0.3.0",
1515
"electron-log": "^2.2.14",
16-
"electron-updater": "^2.21.4"
16+
"electron-updater": "^2.21.4",
17+
"electron-window-state": "^4.1.1"
1718
},
1819
"devDependencies": {
1920
"electron": "^1.8.4",
2021
"electron-builder": "^20.8.1",
22+
"nodemon": "^1.17.5",
2123
"rimraf": "^2.6.2"
2224
},
2325
"scripts": {
24-
"dev": "electron ./src/main.js",
26+
"dev": "nodemon --exec \"electron ./src/main.js\" -w ./src",
2527
"prepackage": "rimraf release",
2628
"package": "build",
2729
"package:mac": "yarn run package --mac",
@@ -34,7 +36,13 @@
3436
"productName": "Spectrum",
3537
"appId": "chat.spectrum",
3638
"copyright": "Copyright © 2018 Space Program Inc.",
37-
"publish": "github",
39+
"publish": [
40+
{
41+
"provider": "github",
42+
"repo": "spectrum",
43+
"owner": "withspectrum"
44+
}
45+
],
3846
"releaseInfo": {
3947
"releaseName": "${name} Desktop App v${version}"
4048
},

desktop/src/autoUpdate.js

Lines changed: 3 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -1,63 +1,7 @@
11
// @flow
22
const { app, dialog } = require('electron');
33
const { autoUpdater } = require('electron-updater');
4-
const log = require('electron-log');
54

6-
// Setup logger
7-
autoUpdater.logger = log;
8-
autoUpdater.logger.transports.file.level = 'info';
9-
10-
log.info('App starting...');
11-
12-
// Setup update event
13-
autoUpdater.on('checking-for-update', () => {
14-
log.info('Checking for update... Please wait.');
15-
});
16-
autoUpdater.on('update-available', info => {
17-
log.info('Update available.');
18-
log.info('Vesrion', info.version);
19-
log.info('Release date', info.releaseDate);
20-
});
21-
autoUpdater.on('update-not-available', info => {
22-
log.info('Update not available.');
23-
});
24-
autoUpdater.on('download-progress', progress => {
25-
log.info(`Download progress: ${Math.floor(progress.percent)}`);
26-
});
27-
autoUpdater.on('update-downloaded', info => {
28-
log.info('Update downloaded');
29-
});
30-
autoUpdater.on('error', error => {
31-
log.info('Update error', error);
32-
});
33-
34-
function updateDownloaded() {
35-
// Ask user to update the app
36-
dialog.showMessageBox(
37-
{
38-
type: 'question',
39-
message: 'A new version of ' + app.getName() + ' has been downloaded',
40-
buttons: ['Install and Relaunch', 'Later'],
41-
defaultId: 0,
42-
},
43-
response => {
44-
if (response === 1) {
45-
dialog.showMessageBox({
46-
title: 'Installing Later',
47-
message: 'Update will be installed when you exit the app',
48-
});
49-
} else {
50-
autoUpdater.quitAndInstall();
51-
}
52-
}
53-
);
54-
}
55-
56-
function checkForUpdates() {
57-
autoUpdater.on('update-downloaded', updateDownloaded);
58-
59-
// init for updates
60-
autoUpdater.checkForUpdates();
61-
}
62-
63-
module.exports = checkForUpdates;
5+
module.exports = function checkForUpdates() {
6+
return autoUpdater.checkForUpdatesAndNotify();
7+
};

desktop/src/config.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,16 @@ const { resolve } = require('path');
99
module.exports = {
1010
APP_NAME: 'Spectrum',
1111
APP_VERSION: app.getVersion(),
12-
APP_REMOTE_URL: 'https://spectrum.chat/',
13-
APP_DEV_URL: 'http://localhost:3000',
12+
APP_REMOTE_URL: 'https://spectrum.chat/login',
13+
APP_DEV_URL: 'http://localhost:3000/login',
1414

1515
GITHUB_URL: 'https://github.com/withspectrum/spectrum',
1616
GITHUB_URL_LICENSE:
1717
'https://github.com/withspectrum/spectrum/blob/alpha/LICENSE',
1818
GITHUB_URL_ISSUES: 'https://github.com/withspectrum/spectrum/issues',
1919

20+
WINDOW_DEFAULT_HEIGHT: 800,
21+
WINDOW_DEFAULT_WIDTH: 1300,
2022
WINDOW_MIN_HEIGHT: 500,
2123
WINDOW_MIN_WIDTH: 770,
2224
WINDOW_BG_COLOR: '#F5F8FC',

desktop/src/main.js

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
11
// @flow
22
const electron = require('electron');
3+
const windowStateKeeper = require('electron-window-state');
34
const { app, BrowserWindow } = electron;
45
const isDev = require('electron-is-dev');
56

7+
const FIFTEEN_MINUTES = 900000;
8+
69
const checkForUpdates = require('./autoUpdate');
710
const buildMenu = require('./menu');
811
const CONFIG = require('./config');
@@ -17,16 +20,26 @@ const startUrl = isDev ? CONFIG.APP_DEV_URL : CONFIG.APP_REMOTE_URL;
1720

1821
function createWindow() {
1922
if (!isDev) {
20-
// trigger autoupdate check
23+
// Check for updates on startup and then every 15 minutes
2124
checkForUpdates();
25+
setInterval(() => {
26+
checkForUpdates();
27+
}, FIFTEEN_MINUTES);
2228
}
2329

24-
const { width, height } = electron.screen.getPrimaryDisplay().workAreaSize;
30+
let mainWindowState = windowStateKeeper({
31+
defaultWidth: CONFIG.WINDOW_DEFAULT_WIDTH,
32+
defaultHeight: CONFIG.WINDOW_DEFAULT_HEIGHT,
33+
});
34+
35+
const { width, height, x, y } = mainWindowState;
2536

2637
// Create the main browser window.
2738
mainWindow = new BrowserWindow({
2839
width,
2940
height,
41+
x,
42+
y,
3043
titleBarStyle: 'hiddenInset',
3144
minHeight: CONFIG.WINDOW_MIN_HEIGHT,
3245
minWidth: CONFIG.WINDOW_MIN_WIDTH,
@@ -57,9 +70,10 @@ function createWindow() {
5770

5871
// if main window is ready to show, show up the main window
5972
mainWindow.once('ready-to-show', () => {
60-
mainWindow && mainWindow.maximize();
6173
mainWindow && mainWindow.show();
6274
});
75+
76+
mainWindowState.manage(mainWindow);
6377
}
6478

6579
// This method will be called when Electron has finished

desktop/src/menu.js

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,19 @@
11
// @flow
2-
const { dialog, Menu, shell } = require('electron');
2+
const { dialog, Menu, MenuItem, shell } = require('electron');
3+
const checkForUpdates = require('./autoUpdate');
34

45
const CONFIG = require('./config');
56

7+
const UpdateMenuItem = new MenuItem({
8+
label: 'Check for updates',
9+
click() {
10+
this.enabled = false;
11+
checkForUpdates().then(() => {
12+
this.enabled = true;
13+
});
14+
},
15+
});
16+
617
/**
718
* Applications menu
819
**/
@@ -24,6 +35,7 @@ const template = [
2435
shell.openExternal(CONFIG.GITHUB_URL_LICENSE);
2536
},
2637
},
38+
UpdateMenuItem,
2739
{ type: 'separator' },
2840
{ role: 'hide' },
2941
{ role: 'quit' },
@@ -90,6 +102,11 @@ const template = [
90102
accelerator: 'CmdOrCtrl+R',
91103
role: 'reload',
92104
},
105+
{
106+
label: 'Force Reload',
107+
accelerator: 'CmdOrCtrl+Shift+R',
108+
role: 'forceReload',
109+
},
93110
{
94111
label: 'Close',
95112
accelerator: 'CmdOrCtrl+W',

0 commit comments

Comments
 (0)