SDA-3589 (Use default channel for auto update) (#1463)

* SDA-3589 - Use default channel for auto update

* SDA-3589 - Update channel logic
This commit is contained in:
Kiran Niranjan 2022-07-29 13:23:34 +05:30 committed by GitHub
parent 44f6bb5461
commit a8bbd2f8e3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 74 additions and 16 deletions

69
package-lock.json generated
View File

@ -39,6 +39,7 @@
"@types/rimraf": "^3.0.0",
"ava": "2.4.0",
"browserify": "16.5.1",
"builder-util-runtime": "^9.0.3",
"cross-env": "5.2.0",
"del": "3.0.0",
"electron": "^19.0.10",
@ -5429,17 +5430,17 @@
}
},
"node_modules/builder-util-runtime": {
"version": "8.7.1",
"resolved": "https://repo.symphony.com/artifactory/api/npm/npm-virtual-dev/builder-util-runtime/-/builder-util-runtime-8.7.1.tgz",
"integrity": "sha1-I8gIzd1lDUN2p6FRjsHoDoXBDwA=",
"version": "9.0.3",
"resolved": "https://repo.symphony.com/artifactory/api/npm/npm-virtual-dev/builder-util-runtime/-/builder-util-runtime-9.0.3.tgz",
"integrity": "sha1-bGLEk7orc8KvkkMttAE7WjJ/ArI=",
"dev": true,
"license": "MIT",
"dependencies": {
"debug": "^4.2.0",
"debug": "^4.3.4",
"sax": "^1.2.4"
},
"engines": {
"node": ">=8.2.5"
"node": ">=12.0.0"
}
},
"node_modules/builder-util/node_modules/@types/fs-extra": {
@ -8497,6 +8498,20 @@
"temp-file": "^3.3.2"
}
},
"node_modules/electron-builder-squirrel-windows/node_modules/builder-util-runtime": {
"version": "8.9.2",
"resolved": "https://repo.symphony.com/artifactory/api/npm/npm-virtual-dev/builder-util-runtime/-/builder-util-runtime-8.9.2.tgz",
"integrity": "sha1-qWaa5bXcq/5BHe0mZ4566ZckbCg=",
"dev": true,
"license": "MIT",
"dependencies": {
"debug": "^4.3.2",
"sax": "^1.2.4"
},
"engines": {
"node": ">=12.0.0"
}
},
"node_modules/electron-builder-squirrel-windows/node_modules/builder-util/node_modules/7zip-bin": {
"version": "4.1.0",
"resolved": "https://repo.symphony.com/artifactory/api/npm/npm-virtual-dev/7zip-bin/-/7zip-bin-4.1.0.tgz",
@ -9396,6 +9411,21 @@
"temp-file": "^3.3.2"
}
},
"node_modules/electron-publish/node_modules/builder-util-runtime": {
"version": "8.9.2",
"resolved": "https://repo.symphony.com/artifactory/api/npm/npm-virtual-dev/builder-util-runtime/-/builder-util-runtime-8.9.2.tgz",
"integrity": "sha1-qWaa5bXcq/5BHe0mZ4566ZckbCg=",
"dev": true,
"license": "MIT",
"peer": true,
"dependencies": {
"debug": "^4.3.2",
"sax": "^1.2.4"
},
"engines": {
"node": ">=12.0.0"
}
},
"node_modules/electron-publish/node_modules/js-yaml": {
"version": "3.14.1",
"resolved": "https://repo.symphony.com/artifactory/api/npm/npm-virtual-dev/js-yaml/-/js-yaml-3.14.1.tgz",
@ -29518,12 +29548,12 @@
}
},
"builder-util-runtime": {
"version": "8.7.1",
"resolved": "https://repo.symphony.com/artifactory/api/npm/npm-virtual-dev/builder-util-runtime/-/builder-util-runtime-8.7.1.tgz",
"integrity": "sha1-I8gIzd1lDUN2p6FRjsHoDoXBDwA=",
"version": "9.0.3",
"resolved": "https://repo.symphony.com/artifactory/api/npm/npm-virtual-dev/builder-util-runtime/-/builder-util-runtime-9.0.3.tgz",
"integrity": "sha1-bGLEk7orc8KvkkMttAE7WjJ/ArI=",
"dev": true,
"requires": {
"debug": "^4.2.0",
"debug": "^4.3.4",
"sax": "^1.2.4"
}
},
@ -32188,6 +32218,16 @@
}
}
},
"builder-util-runtime": {
"version": "8.9.2",
"resolved": "https://repo.symphony.com/artifactory/api/npm/npm-virtual-dev/builder-util-runtime/-/builder-util-runtime-8.9.2.tgz",
"integrity": "sha1-qWaa5bXcq/5BHe0mZ4566ZckbCg=",
"dev": true,
"requires": {
"debug": "^4.3.2",
"sax": "^1.2.4"
}
},
"compress-commons": {
"version": "2.1.1",
"resolved": "https://registry.npmjs.org/compress-commons/-/compress-commons-2.1.1.tgz",
@ -32408,6 +32448,17 @@
"temp-file": "^3.3.2"
}
},
"builder-util-runtime": {
"version": "8.9.2",
"resolved": "https://repo.symphony.com/artifactory/api/npm/npm-virtual-dev/builder-util-runtime/-/builder-util-runtime-8.9.2.tgz",
"integrity": "sha1-qWaa5bXcq/5BHe0mZ4566ZckbCg=",
"dev": true,
"peer": true,
"requires": {
"debug": "^4.3.2",
"sax": "^1.2.4"
}
},
"js-yaml": {
"version": "3.14.1",
"resolved": "https://repo.symphony.com/artifactory/api/npm/npm-virtual-dev/js-yaml/-/js-yaml-3.14.1.tgz",

View File

@ -154,6 +154,7 @@
"@types/rimraf": "^3.0.0",
"ava": "2.4.0",
"browserify": "16.5.1",
"builder-util-runtime": "^9.0.3",
"cross-env": "5.2.0",
"del": "3.0.0",
"electron": "^19.0.10",

View File

@ -1,3 +1,4 @@
import { GenericServerOptions } from 'builder-util-runtime';
import electronLog from 'electron-log';
import { MacUpdater, NsisUpdater } from 'electron-updater';
@ -8,16 +9,24 @@ import { whitelistHandler } from '../common/whitelist-handler';
import { config } from './config-handler';
import { windowHandler } from './window-handler';
const DEFAULT_AUTO_UPDATE_CHANNEL = 'client-bff/static/sda-update';
export class AutoUpdate {
public isUpdateAvailable: boolean = false;
public didPublishDownloadProgress: boolean = false;
public autoUpdater: MacUpdater | NsisUpdater | undefined = undefined;
constructor() {
const { autoUpdateChannel } = config.getConfigFields(['autoUpdateChannel']);
const opts: GenericServerOptions = {
provider: 'generic',
url: this.getUpdateUrl(),
channel: autoUpdateChannel || null,
};
if (isMac) {
this.autoUpdater = new MacUpdater(this.getUpdateUrl());
this.autoUpdater = new MacUpdater(opts);
} else if (isWindowsOS) {
this.autoUpdater = new NsisUpdater(this.getUpdateUrl());
this.autoUpdater = new NsisUpdater(opts);
}
if (this.autoUpdater) {
@ -132,10 +141,7 @@ export class AutoUpdate {
public getUpdateUrl = (): string => {
const { url: userConfigURL } = config.getUserConfigFields(['url']);
const { url: globalConfigURL } = config.getGlobalConfigFields(['url']);
const { autoUpdateUrl, autoUpdateChannel } = config.getConfigFields([
'autoUpdateChannel',
'autoUpdateUrl',
]);
const { autoUpdateUrl } = config.getConfigFields(['autoUpdateUrl']);
if (autoUpdateUrl && isUrl(autoUpdateUrl)) {
logger.info(
@ -148,7 +154,7 @@ export class AutoUpdate {
const url = userConfigURL ? userConfigURL : globalConfigURL;
const { subdomain, domain, tld } = whitelistHandler.parseDomain(url);
const updateUrl = `https://${subdomain}.${domain}.${tld}/${autoUpdateChannel}`;
const updateUrl = `https://${subdomain}.${domain}.${tld}/${DEFAULT_AUTO_UPDATE_CHANNEL}`;
logger.info(`auto-update-handler: using generic pod url`, updateUrl);
return updateUrl;