Skip to content

Commit 1516dec

Browse files
authored
Use the new auto update api (#1272)
1 parent 28c196c commit 1516dec

File tree

2 files changed

+41
-8
lines changed

2 files changed

+41
-8
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@
181181
"get-object-path": "azer/get-object-path#74eb42de0cfd02c14ffdd18552f295aba723d394",
182182
"hadron-app": "^2.0.0",
183183
"hadron-app-registry": "^7.0.0",
184-
"hadron-auto-update-manager": "^0.0.12",
184+
"hadron-auto-update-manager": "^1.0.0",
185185
"hadron-compile-cache": "^1.0.1",
186186
"hadron-ipc": "^0.0.7",
187187
"hadron-module-cache": "^0.0.3",

src/main/application.js

Lines changed: 40 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -30,15 +30,48 @@ Application.prototype.setupJavaScriptArguments = function() {
3030
app.commandLine.appendSwitch('js-flags', '--harmony');
3131
};
3232

33+
/**
34+
* Map package.json product names to API endpoint product names.
35+
*/
36+
const API_PRODUCT = {
37+
'mongodb-compass': 'compass',
38+
'mongodb-compass-community': 'compass-community'
39+
};
40+
41+
/**
42+
* Platform API mappings.
43+
*/
44+
const API_PLATFORM = {
45+
'darwin': 'osx',
46+
'win32': 'windows',
47+
'linux': 'linux'
48+
};
49+
50+
/**
51+
* Get the channel name from the version number.
52+
*
53+
* @returns {String} - The channel.
54+
*/
55+
const getChannel = () => {
56+
if (pkg.version.indexOf('beta') > -1) {
57+
return 'beta';
58+
}
59+
return 'stable';
60+
};
61+
62+
/**
63+
* TODO (imlucas) Extract .pngs from .icns so we can
64+
* have nice Compass icons in dialogs.
65+
*
66+
* path.join(__dirname, '..', 'resources', 'mongodb-compass.png')
67+
*/
3368
Application.prototype.setupAutoUpdate = function() {
3469
this.autoUpdateManager = new AutoUpdateManager(
35-
_.get(pkg, 'config.hadron.endpoint')
36-
/**
37-
* TODO (imlucas) Extract .pngs from .icns so we can
38-
* have nice Compass icons in dialogs.
39-
*
40-
* path.join(__dirname, '..', 'resources', 'mongodb-compass.png')
41-
*/
70+
_.get(pkg, 'config.hadron.endpoint'),
71+
null,
72+
API_PRODUCT[process.env.HADRON_PRODUCT],
73+
getChannel(),
74+
API_PLATFORM[process.platform]
4275
);
4376

4477
this.autoUpdateManager.on('state-change', function(newState) {

0 commit comments

Comments
 (0)