Skip to content

Commit bff7eaa

Browse files
authored
chore(hadron-auto-update-manager): Include real platform and arch in the auto update feed url (#3271)
1 parent 59300ae commit bff7eaa

File tree

4 files changed

+18
-29
lines changed

4 files changed

+18
-29
lines changed

packages/compass/src/main/auto-update-manager.ts

Lines changed: 2 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,6 @@ const API_PRODUCT: Record<string, string> = {
1515
'mongodb-compass-readonly': 'compass-readonly',
1616
};
1717

18-
/**
19-
* Platform API mappings.
20-
*/
21-
const API_PLATFORM: Record<string, string> = {
22-
darwin: 'osx',
23-
win32: 'windows',
24-
linux: 'linux',
25-
};
26-
2718
class CompassAutoUpdateManager {
2819
private static initCalled = false;
2920

@@ -48,26 +39,13 @@ class CompassAutoUpdateManager {
4839
return;
4940
}
5041

51-
const platform = API_PLATFORM[process.platform];
52-
if (!platform) {
53-
log.info(
54-
mongoLogId(1001000132),
55-
'CompassAutoUpdateManager',
56-
'Skipping setup on unknown platform',
57-
{
58-
platformId: process.platform,
59-
}
60-
);
61-
62-
return;
63-
}
64-
6542
const autoUpdateManagerOptions = {
6643
endpoint: process.env.HADRON_AUTO_UPDATE_ENDPOINT,
6744
icon: COMPASS_ICON,
6845
product: product,
6946
channel: process.env.HADRON_CHANNEL,
70-
platform: platform,
47+
platform: process.platform,
48+
arch: process.arch,
7149
};
7250

7351
log.info(

packages/hadron-auto-update-manager/index.d.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,16 @@ declare class AutoUpdateManager extends EventEmitter {
1616
iconURL?: NativeImage,
1717
product: string,
1818
channel: string,
19-
platform: string
19+
platform: string,
20+
arch: string
2021
);
2122
constructor(options: {
2223
endpoint: string;
2324
product: string;
2425
channel: string;
2526
platform: string;
2627
icon?: NativeImage;
28+
arch: string;
2729
});
2830
state: State;
2931
releaseNotes?: string;

packages/hadron-auto-update-manager/index.js

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,14 @@ const NoUpdateAvailableState = 'no-update-available';
2020
const ErrorState = 'error';
2121

2222

23-
function AutoUpdateManager(endpointURL, iconURL, product, channel, platform) {
23+
function AutoUpdateManager(
24+
endpointURL,
25+
iconURL,
26+
product,
27+
channel,
28+
platform,
29+
arch
30+
) {
2431
if (!endpointURL) {
2532
throw new TypeError('endpointURL is required!');
2633
}
@@ -32,6 +39,7 @@ function AutoUpdateManager(endpointURL, iconURL, product, channel, platform) {
3239
product = opts.product;
3340
channel = opts.channel;
3441
platform = opts.platform;
42+
arch = opts.arch;
3543
}
3644

3745
this.endpointURL = endpointURL;
@@ -40,7 +48,8 @@ function AutoUpdateManager(endpointURL, iconURL, product, channel, platform) {
4048
this.onUpdateError = _.bind(this.onUpdateError, this);
4149
this.onUpdateNotAvailable = _.bind(this.onUpdateNotAvailable, this);
4250
this.state = IdleState;
43-
this.feedURL = `${endpointURL}/api/v2/update/${product}/${channel}/${platform}/${this.version}`;
51+
this.feedURL =
52+
`${endpointURL}/api/v2/update/${product}/${channel}/${platform}-${arch}/${this.version}`;
4453

4554
debug('auto updater ready and waiting.', {
4655
version: this.version,

packages/hadron-auto-update-manager/test/index.test.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@ describe('hadron-auto-update-manager', () => {
1010
});
1111
it('should setup', () => {
1212
const endpoint = 'https://hadron-endpoint.herokuapp.com';
13-
const autoUpdateManager = new AutoUpdateManager(endpoint, null, 'compass', 'stable', 'linux');
13+
const autoUpdateManager = new AutoUpdateManager(endpoint, null, 'compass', 'stable', 'linux', 'x64');
1414

1515
assert.equal(autoUpdateManager.version, process.versions.electron);
1616
assert.equal(autoUpdateManager.feedURL,
17-
`https://hadron-endpoint.herokuapp.com/api/v2/update/compass/stable/linux/${process.versions.electron}`);
17+
`https://hadron-endpoint.herokuapp.com/api/v2/update/compass/stable/linux-x64/${process.versions.electron}`);
1818
});
1919
});

0 commit comments

Comments
 (0)