Skip to content
This repository was archived by the owner on Apr 17, 2026. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions lib/binaries/android_sdk.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,13 @@ export class AndroidSDK extends Binary {
static DEFAULT_API_LEVELS = '24';
static DEFAULT_ABIS = 'x86_64';

constructor() {
super();
constructor(alternateCDN?: string) {
super(alternateCDN || Config.cdnUrls().android);

this.name = 'android-sdk';
this.versionCustom = AndroidSDK.versionDefault;
this.prefixDefault = 'android-sdk_r';
this.suffixDefault = '.zip';
this.cdn = Config.cdnUrls().android;
}

id(): string { return AndroidSDK.id; }
Expand Down
5 changes: 3 additions & 2 deletions lib/binaries/appium.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,9 @@ export class Appium extends Binary {
static isDefault = false;
static shortName = ['appium'];

constructor() {
super();
constructor(alternateCDN?: string) {
super(alternateCDN || Config.cdnUrls().appium);

this.name = 'appium';
this.versionCustom = Appium.versionDefault;
this.prefixDefault = 'appium-';
Expand Down
2 changes: 2 additions & 0 deletions lib/binaries/binary.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ export class Binary {
cdn: string; // url protocol and host
arch: string;

constructor(public cdn: string) {}

/**
* @param ostype The operating system.
* @returns The executable file type.
Expand Down
6 changes: 3 additions & 3 deletions lib/binaries/chrome_driver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@ export class ChromeDriver extends Binary {
static isDefault = true;
static shortName = ['chrome'];

constructor() {
super();
constructor(alternateCDN?: string) {
super(alternateCDN || Config.cdnUrls().chrome);

this.name = 'chromedriver';
this.versionCustom = ChromeDriver.versionDefault;
this.prefixDefault = 'chromedriver_';
this.suffixDefault = '.zip';
this.cdn = Config.cdnUrls().chrome;
}

id(): string { return ChromeDriver.id; }
Expand Down
6 changes: 3 additions & 3 deletions lib/binaries/gecko_driver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,12 @@ export class GeckoDriver extends Binary {
'Windows_NT': '-win64.zip'
};

constructor() {
super();
constructor(alternateCDN?: string) {
super(alternateCDN || Config.cdnUrls().gecko);

this.name = 'geckodriver';
this.versionCustom = GeckoDriver.versionDefault;
this.prefixDefault = 'geckodriver-';
this.cdn = Config.cdnUrls().gecko;
}

id(): string { return GeckoDriver.id; }
Expand Down
6 changes: 3 additions & 3 deletions lib/binaries/ie_driver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@ export class IEDriver extends Binary {
static isDefault = false;
static shortName = ['ie', 'ie32'];

constructor() {
super();
constructor(alternateCDN?: string) {
super(alternateCDN || Config.cdnUrls().ie);

this.name = 'IEDriverServer';
this.versionCustom = IEDriver.versionDefault;
this.prefixDefault = 'IEDriverServer';
this.suffixDefault = '.zip';
this.cdn = Config.cdnUrls().ie;
this.arch = os.arch();
}

Expand Down
6 changes: 3 additions & 3 deletions lib/binaries/stand_alone.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@ export class StandAlone extends Binary {
static isDefault = true;
static shortName = ['standalone'];

constructor() {
super();
constructor(alternateCDN?: string) {
super(alternateCDN || Config.cdnUrls().selenium);

this.name = 'selenium standalone';
this.versionCustom = StandAlone.versionDefault;
this.prefixDefault = 'selenium-server-standalone-';
this.suffixDefault = '.jar';
this.cdn = Config.cdnUrls().selenium;
}

id(): string { return StandAlone.id; }
Expand Down
2 changes: 1 addition & 1 deletion lib/cmds/update.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ function update(options: Options): void {
let proxy = options[Opt.PROXY].getString();

// setup versions for binaries
let binaries = FileManager.setupBinaries();
let binaries = FileManager.setupBinaries(options[Opt.ALTERNATE_CDN].getString());
binaries[StandAlone.id].versionCustom = options[Opt.VERSIONS_STANDALONE].getString();
binaries[ChromeDriver.id].versionCustom = options[Opt.VERSIONS_CHROME].getString();
if (options[Opt.VERSIONS_IE]) {
Expand Down
20 changes: 12 additions & 8 deletions lib/files/file_manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,37 +52,41 @@ export class FileManager {
* For the operating system, create a list that includes the binaries
* for selenium standalone, chrome, and internet explorer.
* @param osType The operating system.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

update the parameters for the JSDoc

* @param alternateCDN URL of the alternative CDN to be used instead of the default ones.
* @returns A binary map that are available for the operating system.
*/
static compileBinaries_(osType: string): BinaryMap<Binary> {
static compileBinaries_(osType: string, alternateCDN?: string): BinaryMap<Binary> {
let binaries: BinaryMap<Binary> = {};
if (FileManager.checkOS_(osType, StandAlone)) {
binaries[StandAlone.id] = new StandAlone();
binaries[StandAlone.id] = new StandAlone(alternateCDN);
}
if (FileManager.checkOS_(osType, ChromeDriver)) {
binaries[ChromeDriver.id] = new ChromeDriver();
binaries[ChromeDriver.id] = new ChromeDriver(alternateCDN);
}
if (FileManager.checkOS_(osType, GeckoDriver)) {
binaries[GeckoDriver.id] = new GeckoDriver();
binaries[GeckoDriver.id] = new GeckoDriver(alternateCDN);
}
if (FileManager.checkOS_(osType, IEDriver)) {
binaries[IEDriver.id] = new IEDriver();
binaries[IEDriver.id] = new IEDriver(alternateCDN);
}
if (FileManager.checkOS_(osType, AndroidSDK)) {
binaries[AndroidSDK.id] = new AndroidSDK();
binaries[AndroidSDK.id] = new AndroidSDK(alternateCDN);
}
if (FileManager.checkOS_(osType, Appium)) {
binaries[Appium.id] = new Appium();
binaries[Appium.id] = new Appium(alternateCDN);
}
return binaries;
}

/**
* Look up the operating system and compile a list of binaries that are available
* for the system.
* @param alternateCDN URL of the alternative CDN to be used instead of the default ones.
* @returns A binary map that is available for the operating system.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

update JSDoc @param for alternativeCDN

*/
static setupBinaries(): BinaryMap<Binary> { return FileManager.compileBinaries_(os.type()); }
static setupBinaries(alternateCDN?: string): BinaryMap<Binary> {
return FileManager.compileBinaries_(os.type(), alternateCDN);
}

/**
* Get the list of existing files from the output directory
Expand Down
52 changes: 52 additions & 0 deletions spec/files/fileManager_spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@ import * as fs from 'fs';
import * as path from 'path';
import {Binary, AndroidSDK, ChromeDriver, IEDriver, Appium, StandAlone} from '../../lib/binaries';
import {DownloadedBinary, FileManager} from '../../lib/files';
import { BinaryMap } from '../../built/lib/binaries/binary';
import { Config } from '../../lib/config';
import { GeckoDriver } from '../../lib/binaries/gecko_driver';


describe('file manager', () => {
Expand Down Expand Up @@ -211,4 +214,53 @@ describe('file manager', () => {
});
});
});

describe('configuring the CDN location', () => {

describe('when no custom CDN is specified', () => {

let defaults = Config.cdnUrls();
let binaries = FileManager.compileBinaries_('Windows_NT');

it('should use the default configuration for Android SDK', () => {
expect(binaries[AndroidSDK.id].cdn).toEqual(defaults[AndroidSDK.id]);
});

it('should use the default configuration for Appium', () => {
expect(binaries[Appium.id].cdn).toEqual(defaults[Appium.id]);
});

it('should use the default configuration for Chrome Driver', () => {
expect(binaries[ChromeDriver.id].cdn).toEqual(defaults[ChromeDriver.id]);
});

it('should use the default configuration for Gecko Driver', () => {
expect(binaries[GeckoDriver.id].cdn).toEqual(defaults[GeckoDriver.id]);
});

it('should use the default configuration for IE Driver', () => {
expect(binaries[IEDriver.id].cdn).toEqual(defaults[IEDriver.id]);
});

it('should use the default configuration for Selenium Standalone', () => {
expect(binaries[StandAlone.id].cdn).toEqual(defaults['selenium']);
});
});

describe('when custom CDN is specified', () => {

it('should configure the CDN for each binary', () => {
let customCDN = 'https://my.corporate.cdn/';
let binaries = FileManager.compileBinaries_('Windows_NT', customCDN);

forEachOf(binaries, binary => expect(binary.cdn).toEqual(customCDN, binary.name));
});
});

function forEachOf<T extends Binary>(binaries: BinaryMap<T>, fn: (binary: T) => void) {
for (var key in binaries) {
fn(binaries[key]);
}
}
});
});