Socket
Socket
Sign inDemoInstall

webdriver-manager

Package Overview
Dependencies
Maintainers
1
Versions
64
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

webdriver-manager - npm Package Compare versions

Comparing version 11.0.0-beta.0 to 11.0.0

built/lib/cli_instance.d.ts

8

built/config.json
{
"webdriverVersions": {
"selenium": "3.0.1",
"chromedriver": "2.24",
"geckodriver": "v0.9.0",
"selenium": "2.53.1",
"chromedriver": "2.25",
"geckodriver": "v0.11.1",
"iedriver": "2.53.1",
"androidsdk": "24.4.1",
"appium": "1.5.3"
"appium": "1.6.0"
},

@@ -10,0 +10,0 @@ "cdnUrls": {

@@ -12,3 +12,7 @@ import { Binary, OS } from './binary';

static DEFAULT_API_LEVELS: string;
static DEFAULT_ABIS: string;
static DEFAULT_ARCHITECTURES: string;
static DEFAULT_PLATFORMS: string;
static VERSIONS: {
[api_level: number]: string;
};
constructor(alternateCDN?: string);

@@ -15,0 +19,0 @@ id(): string;

"use strict";
var __extends = (this && this.__extends) || function (d, b) {
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
var child_process = require('child_process');
var path = require('path');
var rimraf = require('rimraf');
var config_1 = require('../config');
var binary_1 = require('./binary');
const path = require("path");
const rimraf = require("rimraf");
const config_1 = require("../config");
const utils_1 = require("../utils");
const binary_1 = require("./binary");
function getAndroidArch() {
switch (config_1.Config.osArch()) {
case 'arm':
return 'armeabi-v7a';
case 'arm64':
return 'arm64-v8a';
case 'x86':
case 'x32':
case 'ia32':
case 'ppc':
return 'x86';
case 'x86-64':
case 'x64':
case 'ia64':
case 'ppc64':
return 'x86_64';
default:
return config_1.Config.osArch();
}
}
/**
* The android sdk binary.
*/
var AndroidSDK = (function (_super) {
__extends(AndroidSDK, _super);
function AndroidSDK(alternateCDN) {
_super.call(this, alternateCDN || config_1.Config.cdnUrls().android);
class AndroidSDK extends binary_1.Binary {
constructor(alternateCDN) {
super(alternateCDN || config_1.Config.cdnUrls().android);
this.name = 'android-sdk';

@@ -24,9 +38,9 @@ this.versionCustom = AndroidSDK.versionDefault;

}
AndroidSDK.prototype.id = function () {
id() {
return AndroidSDK.id;
};
AndroidSDK.prototype.versionDefault = function () {
}
versionDefault() {
return AndroidSDK.versionDefault;
};
AndroidSDK.prototype.suffix = function (ostype) {
}
suffix(ostype) {
if (ostype === 'Darwin') {

@@ -41,7 +55,7 @@ return '-macosx' + this.suffixDefault;

}
};
AndroidSDK.prototype.url = function (ostype) {
}
url(ostype) {
return this.cdn + this.filename(ostype);
};
AndroidSDK.prototype.zipContentName = function (ostype) {
}
zipContentName(ostype) {
if (ostype === 'Darwin') {

@@ -56,12 +70,12 @@ return this.name + '-macosx';

}
};
AndroidSDK.prototype.executableSuffix = function () {
}
executableSuffix() {
return '';
};
AndroidSDK.prototype.remove = function (sdkPath) {
}
remove(sdkPath) {
try {
var avds = require(path.join(sdkPath, 'available_avds.json'));
var version_1 = path.basename(sdkPath).slice(this.prefixDefault.length);
avds.forEach(function (avd) {
child_process.spawnSync(path.join(sdkPath, 'tools', 'android'), ['delete', 'avd', '-n', avd + '-v' + version_1 + '-wd-manager']);
let avds = require(path.resolve(sdkPath, 'available_avds.json'));
let version = path.basename(sdkPath).slice(this.prefixDefault.length);
avds.forEach((avd) => {
utils_1.spawnSync(path.resolve(sdkPath, 'tools', 'android'), ['delete', 'avd', '-n', avd + '-v' + version + '-wd-manager']);
});

@@ -72,13 +86,18 @@ }

rimraf.sync(sdkPath);
};
AndroidSDK.os = [binary_1.OS.Windows_NT, binary_1.OS.Linux, binary_1.OS.Darwin];
AndroidSDK.id = 'android';
AndroidSDK.versionDefault = config_1.Config.binaryVersions().android;
AndroidSDK.isDefault = false;
AndroidSDK.shortName = ['android'];
AndroidSDK.DEFAULT_API_LEVELS = '24';
AndroidSDK.DEFAULT_ABIS = 'x86_64';
return AndroidSDK;
}(binary_1.Binary));
}
}
exports.AndroidSDK = AndroidSDK;
AndroidSDK.os = [binary_1.OS.Windows_NT, binary_1.OS.Linux, binary_1.OS.Darwin];
AndroidSDK.id = 'android';
AndroidSDK.versionDefault = config_1.Config.binaryVersions().android;
AndroidSDK.isDefault = false;
AndroidSDK.shortName = ['android'];
AndroidSDK.DEFAULT_API_LEVELS = '24';
AndroidSDK.DEFAULT_ARCHITECTURES = getAndroidArch();
AndroidSDK.DEFAULT_PLATFORMS = 'google_apis';
AndroidSDK.VERSIONS = {
// Before 24 is not supported
24: '7.0',
25: '7.1'
};
//# sourceMappingURL=android_sdk.js.map
"use strict";
var __extends = (this && this.__extends) || function (d, b) {
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
var rimraf = require('rimraf');
var config_1 = require('../config');
var binary_1 = require('./binary');
const rimraf = require("rimraf");
const config_1 = require("../config");
const binary_1 = require("./binary");
/**
* The appium binary.
*/
var Appium = (function (_super) {
__extends(Appium, _super);
function Appium(alternateCDN) {
_super.call(this, alternateCDN || config_1.Config.cdnUrls().appium);
class Appium extends binary_1.Binary {
constructor(alternateCDN) {
super(alternateCDN || config_1.Config.cdnUrls().appium);
this.name = 'appium';

@@ -22,22 +16,21 @@ this.versionCustom = Appium.versionDefault;

}
Appium.prototype.id = function () {
id() {
return Appium.id;
};
Appium.prototype.versionDefault = function () {
}
versionDefault() {
return Appium.versionDefault;
};
Appium.prototype.executableSuffix = function () {
}
executableSuffix() {
return '';
};
Appium.prototype.remove = function (sdkPath) {
}
remove(sdkPath) {
rimraf.sync(sdkPath);
};
Appium.os = [binary_1.OS.Windows_NT, binary_1.OS.Linux, binary_1.OS.Darwin];
Appium.id = 'appium';
Appium.versionDefault = config_1.Config.binaryVersions().appium;
Appium.isDefault = false;
Appium.shortName = ['appium'];
return Appium;
}(binary_1.Binary));
}
}
exports.Appium = Appium;
Appium.os = [binary_1.OS.Windows_NT, binary_1.OS.Linux, binary_1.OS.Darwin];
Appium.id = 'appium';
Appium.versionDefault = config_1.Config.binaryVersions().appium;
Appium.isDefault = false;
Appium.shortName = ['appium'];
//# sourceMappingURL=appium.js.map
"use strict";
var fs = require('fs');
const fs = require("fs");
/**

@@ -15,4 +15,4 @@ * operating system enum

*/
var Binary = (function () {
function Binary(cdn) {
class Binary {
constructor(cdn) {
this.cdn = cdn;

@@ -24,3 +24,3 @@ }

*/
Binary.prototype.executableSuffix = function (ostype) {
executableSuffix(ostype) {
if (ostype == 'Windows_NT') {

@@ -32,3 +32,3 @@ return '.exe';

}
};
}
/**

@@ -38,17 +38,17 @@ * @param ostype The operating system.

*/
Binary.prototype.executableFilename = function (ostype) {
executableFilename(ostype) {
return this.prefix() + this.version() + this.executableSuffix(ostype);
};
Binary.prototype.prefix = function () {
}
prefix() {
return this.prefixDefault;
};
Binary.prototype.version = function () {
}
version() {
return this.versionCustom;
};
Binary.prototype.suffix = function (ostype, arch) {
}
suffix(ostype, arch) {
return this.suffixDefault;
};
Binary.prototype.filename = function (ostype, arch) {
}
filename(ostype, arch) {
return this.prefix() + this.version() + this.suffix(ostype, arch);
};
}
/**

@@ -58,35 +58,34 @@ * @param ostype The operating system.

*/
Binary.prototype.zipContentName = function (ostype) {
zipContentName(ostype) {
return this.name + this.executableSuffix(ostype);
};
Binary.prototype.shortVersion = function (version) {
}
shortVersion(version) {
return version.slice(0, version.lastIndexOf('.'));
};
}
/**
* A base class method that should be overridden.
*/
Binary.prototype.id = function () {
id() {
return 'not implemented';
};
}
/**
* A base class method that should be overridden.
*/
Binary.prototype.versionDefault = function () {
versionDefault() {
return 'not implemented';
};
}
/**
* A base class method that should be overridden.
*/
Binary.prototype.url = function (ostype, arch) {
url(ostype, arch) {
return 'not implemented';
};
}
/**
* Delete an instance of this binary from the file system
*/
Binary.prototype.remove = function (filename) {
remove(filename) {
fs.unlinkSync(filename);
};
return Binary;
}());
}
}
exports.Binary = Binary;
//# sourceMappingURL=binary.js.map
"use strict";
var __extends = (this && this.__extends) || function (d, b) {
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
var semver = require('semver');
var config_1 = require('../config');
var binary_1 = require('./binary');
const semver = require("semver");
const config_1 = require("../config");
const binary_1 = require("./binary");
/**
* The chrome driver binary.
*/
var ChromeDriver = (function (_super) {
__extends(ChromeDriver, _super);
function ChromeDriver(alternateCDN) {
_super.call(this, alternateCDN || config_1.Config.cdnUrls().chrome);
class ChromeDriver extends binary_1.Binary {
constructor(alternateCDN) {
super(alternateCDN || config_1.Config.cdnUrls().chrome);
this.name = 'chromedriver';

@@ -22,14 +16,14 @@ this.versionCustom = ChromeDriver.versionDefault;

}
ChromeDriver.prototype.id = function () {
id() {
return ChromeDriver.id;
};
ChromeDriver.prototype.versionDefault = function () {
}
versionDefault() {
return ChromeDriver.versionDefault;
};
ChromeDriver.prototype.suffix = function (ostype, arch) {
}
suffix(ostype, arch) {
if (ostype === 'Darwin') {
var version = this.version();
let version = this.version();
if (version.split('.').length === 2) {
// we need to make the version valid semver since there is only a major and a minor
version = version + ".0";
version = `${version}.0`;
}

@@ -56,16 +50,15 @@ if (semver.gt(version, '2.23.0')) {

}
};
ChromeDriver.prototype.url = function (ostype, arch) {
var urlBase = this.cdn + this.version() + '/';
var filename = this.prefix() + this.suffix(ostype, arch);
}
url(ostype, arch) {
let urlBase = this.cdn + this.version() + '/';
let filename = this.prefix() + this.suffix(ostype, arch);
return urlBase + filename;
};
ChromeDriver.os = [binary_1.OS.Windows_NT, binary_1.OS.Linux, binary_1.OS.Darwin];
ChromeDriver.id = 'chrome';
ChromeDriver.versionDefault = config_1.Config.binaryVersions().chrome;
ChromeDriver.isDefault = true;
ChromeDriver.shortName = ['chrome'];
return ChromeDriver;
}(binary_1.Binary));
}
}
exports.ChromeDriver = ChromeDriver;
ChromeDriver.os = [binary_1.OS.Windows_NT, binary_1.OS.Linux, binary_1.OS.Darwin];
ChromeDriver.id = 'chrome';
ChromeDriver.versionDefault = config_1.Config.binaryVersions().chrome;
ChromeDriver.isDefault = true;
ChromeDriver.shortName = ['chrome'];
//# sourceMappingURL=chrome_driver.js.map

@@ -11,5 +11,3 @@ import { Binary, OS } from './binary';

static shortName: string[];
static suffixes: {
[key: string]: string;
};
private static suffixes;
constructor(alternateCDN?: string);

@@ -16,0 +14,0 @@ id(): string;

"use strict";
var __extends = (this && this.__extends) || function (d, b) {
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
var config_1 = require('../config');
var binary_1 = require('./binary');
const semver = require("semver");
const config_1 = require("../config");
const binary_1 = require("./binary");
/**
* The gecko driver binary.
*/
var GeckoDriver = (function (_super) {
__extends(GeckoDriver, _super);
function GeckoDriver(alternateCDN) {
_super.call(this, alternateCDN || config_1.Config.cdnUrls().gecko);
class GeckoDriver extends binary_1.Binary {
constructor(alternateCDN) {
super(alternateCDN || config_1.Config.cdnUrls().gecko);
this.name = 'geckodriver';

@@ -20,35 +15,50 @@ this.versionCustom = GeckoDriver.versionDefault;

}
GeckoDriver.prototype.id = function () {
id() {
return GeckoDriver.id;
};
GeckoDriver.prototype.versionDefault = function () {
}
versionDefault() {
return GeckoDriver.versionDefault;
};
GeckoDriver.prototype.suffix = function (ostype, arch) {
if (!GeckoDriver.supports(ostype, arch)) {
}
suffix(ostype, arch) {
if (!GeckoDriver.suffixes[ostype][arch]) {
throw new Error('GeckoDriver doesn\'t support ${ostype} ${arch}!');
}
return GeckoDriver.suffixes[ostype];
};
GeckoDriver.supports = function (ostype, arch) {
return arch == 'x64' && (ostype in GeckoDriver.suffixes);
};
GeckoDriver.prototype.url = function (ostype, arch) {
var urlBase = this.cdn + this.version() + '/';
var filename = this.prefix() + this.version() + this.suffix(ostype, arch);
let version = this.version();
// No 32-bit builds before 0.10.0
if (semver.lte(version, '0.10.0')) {
if (arch === 'x64') {
throw new Error('GeckoDriver doesn\'t support ${ostype} ${arch}!');
}
}
// Special case old versions on Mac for the name change.
if (semver.lte(version, '0.9.0')) {
if (ostype === 'Darwin') {
return '-mac.tar.gz';
}
}
return GeckoDriver.suffixes[ostype][arch];
}
static supports(ostype, arch) {
return !!GeckoDriver.suffixes[ostype][arch];
}
url(ostype, arch) {
let urlBase = this.cdn + this.version() + '/';
let filename = this.prefix() + this.version() + this.suffix(ostype, arch);
return urlBase + filename;
};
GeckoDriver.os = [binary_1.OS.Windows_NT, binary_1.OS.Linux, binary_1.OS.Darwin];
GeckoDriver.id = 'gecko';
GeckoDriver.versionDefault = config_1.Config.binaryVersions().gecko;
GeckoDriver.isDefault = true;
GeckoDriver.shortName = ['gecko'];
GeckoDriver.suffixes = {
'Darwin': '-mac.tar.gz',
'Linux': '-linux64.tar.gz',
'Windows_NT': '-win64.zip'
};
return GeckoDriver;
}(binary_1.Binary));
}
}
exports.GeckoDriver = GeckoDriver;
GeckoDriver.os = [binary_1.OS.Windows_NT, binary_1.OS.Linux, binary_1.OS.Darwin];
GeckoDriver.id = 'gecko';
GeckoDriver.versionDefault = config_1.Config.binaryVersions().gecko;
GeckoDriver.isDefault = true;
GeckoDriver.shortName = ['gecko'];
GeckoDriver.suffixes = {
'Darwin': { 'x64': '-macos.tar.gz' },
'Linux': { 'x64': '-linux64.tar.gz', 'ia32': '-linux32.tar.gz' },
'Windows_NT': {
'x64': '-win64.zip',
'ia32': '-win32.zip',
}
};
//# sourceMappingURL=gecko_driver.js.map
"use strict";
var __extends = (this && this.__extends) || function (d, b) {
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
var os = require('os');
var config_1 = require('../config');
var binary_1 = require('./binary');
const config_1 = require("../config");
const binary_1 = require("./binary");
/**
* The internet explorer binary.
*/
var IEDriver = (function (_super) {
__extends(IEDriver, _super);
function IEDriver(alternateCDN) {
_super.call(this, alternateCDN || config_1.Config.cdnUrls().ie);
class IEDriver extends binary_1.Binary {
constructor(alternateCDN) {
super(alternateCDN || config_1.Config.cdnUrls().ie);
this.name = 'IEDriverServer';

@@ -21,12 +14,12 @@ this.versionCustom = IEDriver.versionDefault;

this.suffixDefault = '.zip';
this.arch = os.arch();
this.arch = config_1.Config.osArch();
}
IEDriver.prototype.id = function () {
id() {
return IEDriver.id;
};
IEDriver.prototype.versionDefault = function () {
}
versionDefault() {
return IEDriver.versionDefault;
};
IEDriver.prototype.version = function () {
if (os.type() == 'Windows_NT') {
}
version() {
if (config_1.Config.osType() == 'Windows_NT') {
if (this.arch == 'x64') {

@@ -40,16 +33,15 @@ return '_x64_' + this.versionCustom;

return '';
};
IEDriver.prototype.url = function () {
var urlBase = this.cdn + this.shortVersion(this.versionCustom) + '/';
var filename = this.prefix() + this.version() + this.suffix();
}
url() {
let urlBase = this.cdn + this.shortVersion(this.versionCustom) + '/';
let filename = this.prefix() + this.version() + this.suffix();
return urlBase + filename;
};
IEDriver.os = [binary_1.OS.Windows_NT];
IEDriver.id = 'ie';
IEDriver.versionDefault = config_1.Config.binaryVersions().ie;
IEDriver.isDefault = false;
IEDriver.shortName = ['ie', 'ie32'];
return IEDriver;
}(binary_1.Binary));
}
}
exports.IEDriver = IEDriver;
IEDriver.os = [binary_1.OS.Windows_NT];
IEDriver.id = 'ie';
IEDriver.versionDefault = config_1.Config.binaryVersions().ie;
IEDriver.isDefault = false;
IEDriver.shortName = ['ie', 'ie32'];
//# sourceMappingURL=ie_driver.js.map

@@ -5,9 +5,9 @@ "use strict";

}
__export(require('./binary'));
__export(require('./chrome_driver'));
__export(require('./gecko_driver'));
__export(require('./ie_driver'));
__export(require('./android_sdk'));
__export(require('./appium'));
__export(require('./stand_alone'));
__export(require("./binary"));
__export(require("./chrome_driver"));
__export(require("./gecko_driver"));
__export(require("./ie_driver"));
__export(require("./android_sdk"));
__export(require("./appium"));
__export(require("./stand_alone"));
//# sourceMappingURL=index.js.map
"use strict";
var __extends = (this && this.__extends) || function (d, b) {
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
var config_1 = require('../config');
var binary_1 = require('./binary');
const config_1 = require("../config");
const binary_1 = require("./binary");
/**
* The selenium server jar.
*/
var StandAlone = (function (_super) {
__extends(StandAlone, _super);
function StandAlone(alternateCDN) {
_super.call(this, alternateCDN || config_1.Config.cdnUrls().selenium);
class StandAlone extends binary_1.Binary {
constructor(alternateCDN) {
super(alternateCDN || config_1.Config.cdnUrls().selenium);
this.name = 'selenium standalone';

@@ -21,24 +15,23 @@ this.versionCustom = StandAlone.versionDefault;

}
StandAlone.prototype.id = function () {
id() {
return StandAlone.id;
};
StandAlone.prototype.versionDefault = function () {
}
versionDefault() {
return StandAlone.versionDefault;
};
StandAlone.prototype.url = function () {
var urlBase = this.cdn + this.shortVersion(this.version()) + '/';
var filename = this.prefix() + this.version() + this.suffix();
}
url() {
let urlBase = this.cdn + this.shortVersion(this.version()) + '/';
let filename = this.prefix() + this.version() + this.suffix();
return urlBase + filename;
};
StandAlone.prototype.executableSuffix = function (ostype) {
}
executableSuffix(ostype) {
return '.jar';
};
StandAlone.os = [binary_1.OS.Windows_NT, binary_1.OS.Linux, binary_1.OS.Darwin];
StandAlone.id = 'standalone';
StandAlone.versionDefault = config_1.Config.binaryVersions().selenium;
StandAlone.isDefault = true;
StandAlone.shortName = ['standalone'];
return StandAlone;
}(binary_1.Binary));
}
}
exports.StandAlone = StandAlone;
StandAlone.os = [binary_1.OS.Windows_NT, binary_1.OS.Linux, binary_1.OS.Darwin];
StandAlone.id = 'standalone';
StandAlone.versionDefault = config_1.Config.binaryVersions().selenium;
StandAlone.isDefault = true;
StandAlone.shortName = ['standalone'];
//# sourceMappingURL=stand_alone.js.map

@@ -9,4 +9,4 @@ "use strict";

*/
var Cli = (function () {
function Cli() {
class Cli {
constructor() {
this.programs = {};

@@ -18,6 +18,6 @@ }

*/
Cli.prototype.program = function (prog) {
program(prog) {
this.programs[prog.cmd] = prog;
return this;
};
}
/**

@@ -27,27 +27,27 @@ * Add a usage for the command line interface.

*/
Cli.prototype.usage = function (usageText) {
usage(usageText) {
this.usageText = usageText;
return this;
};
}
/**
* Prints help for the programs registered to the cli.
*/
Cli.prototype.printHelp = function () {
printHelp() {
console.log('Usage: ' + this.usageText);
console.log('\nCommands:');
var cmdDescriptionPos = this.posCmdDescription();
for (var cmd in this.programs) {
var prog = this.programs[cmd];
let cmdDescriptionPos = this.posCmdDescription();
for (let cmd in this.programs) {
let prog = this.programs[cmd];
prog.printCmd(cmdDescriptionPos);
}
var descriptionPos = this.posDescription();
var defaultPos = this.posDefault();
var extOptions = {};
let descriptionPos = this.posDescription();
let defaultPos = this.posDefault();
let extOptions = {};
console.log('\nOptions:');
// print all options
for (var cmd in this.programs) {
var prog = this.programs[cmd];
for (let cmd in this.programs) {
let prog = this.programs[cmd];
prog.printOptions(descriptionPos, defaultPos, extOptions);
}
};
}
/**

@@ -58,9 +58,9 @@ * For commands, gets the position where the description should start so they

*/
Cli.prototype.posCmdDescription = function () {
var position = -1;
for (var cmd in this.programs) {
posCmdDescription() {
let position = -1;
for (let cmd in this.programs) {
position = Math.max(position, cmd.length + 6);
}
return position;
};
}
/**

@@ -71,10 +71,10 @@ * For options, gets the position where the description should start so they

*/
Cli.prototype.posDescription = function () {
var position = -1;
for (var cmd in this.programs) {
var prog = this.programs[cmd];
posDescription() {
let position = -1;
for (let cmd in this.programs) {
let prog = this.programs[cmd];
position = Math.max(position, prog.posDescription());
}
return position;
};
}
/**

@@ -85,10 +85,10 @@ * For options, get the position where the default values should start so they

*/
Cli.prototype.posDefault = function () {
var position = -1;
for (var cmd in this.programs) {
var prog = this.programs[cmd];
posDefault() {
let position = -1;
for (let cmd in this.programs) {
let prog = this.programs[cmd];
position = Math.max(position, prog.posDefault());
}
return position;
};
}
/**

@@ -98,10 +98,10 @@ * Go through all programs and add options to the collection.

*/
Cli.prototype.getOptions = function () {
var allOptions = {};
for (var cmd in this.programs) {
var prog = this.programs[cmd];
getOptions() {
let allOptions = {};
for (let cmd in this.programs) {
let prog = this.programs[cmd];
allOptions = prog.getOptions_(allOptions);
}
return allOptions;
};
}
/**

@@ -112,10 +112,11 @@ * Get the options used by the programs and create the minimist options

*/
Cli.prototype.getMinimistOptions = function () {
var allOptions = this.getOptions();
var minimistOptions = {};
var minimistBoolean = [];
var minimistString = [];
var minimistNumber = [];
for (var opt in allOptions) {
var option = allOptions[opt];
getMinimistOptions() {
let allOptions = this.getOptions();
let minimistOptions = {};
let minimistBoolean = [];
let minimistString = [];
let minimistNumber = [];
let minimistDefault = {};
for (let opt in allOptions) {
let option = allOptions[opt];
if (option.type === 'boolean') {

@@ -130,2 +131,5 @@ minimistBoolean.push(option.opt);

}
if (typeof option.defaultValue !== 'undefined') {
minimistDefault[option.opt] = option.defaultValue;
}
}

@@ -135,7 +139,7 @@ minimistOptions['boolean'] = minimistBoolean;

minimistOptions['number'] = minimistNumber;
minimistOptions['default'] = minimistDefault;
return minimistOptions;
};
return Cli;
}());
}
}
exports.Cli = Cli;
//# sourceMappingURL=cli.js.map

@@ -5,6 +5,6 @@ "use strict";

}
__export(require('./cli'));
__export(require('./options'));
__export(require('./programs'));
__export(require('./logger'));
__export(require("./cli"));
__export(require("./options"));
__export(require("./programs"));
__export(require("./logger"));
//# sourceMappingURL=index.js.map
"use strict";
var fs = require('fs');
var path = require('path');
const fs = require("fs");
const path = require("path");
// Will use chalk if chalk is available to add color to console logging
var chalk;
var printRed;
var printYellow;
var printGray;
let chalk;
let printRed;
let printYellow;
let printGray;
try {

@@ -16,3 +16,3 @@ chalk = require('chalk');

catch (e) {
printRed = printYellow = printGray = function (msg) {
printRed = printYellow = printGray = (msg) => {
return msg;

@@ -35,3 +35,3 @@ };

var WriteTo = exports.WriteTo;
var logFile = 'webdriver.log'; // the default log file name
let logFile = 'webdriver.log'; // the default log file name
/**

@@ -41,3 +41,3 @@ * Logger class adds timestamp output, log levels, and identifiers to help

*/
var Logger = (function () {
class Logger {
/**

@@ -47,3 +47,3 @@ * Creates a logger instance with an ID for the logger.

*/
function Logger(id) {
constructor(id) {
this.id = id;

@@ -56,3 +56,3 @@ }

*/
Logger.setWrite = function (writeTo, opt_logFile) {
static setWrite(writeTo, opt_logFile) {
if (opt_logFile) {

@@ -66,3 +66,3 @@ logFile = opt_logFile;

}
};
}
/**

@@ -72,9 +72,5 @@ * Log INFO

*/
Logger.prototype.info = function () {
var msgs = [];
for (var _i = 0; _i < arguments.length; _i++) {
msgs[_i - 0] = arguments[_i];
}
info(...msgs) {
this.log_(LogLevel.INFO, msgs);
};
}
/**

@@ -84,9 +80,5 @@ * Log DEBUG

*/
Logger.prototype.debug = function () {
var msgs = [];
for (var _i = 0; _i < arguments.length; _i++) {
msgs[_i - 0] = arguments[_i];
}
debug(...msgs) {
this.log_(LogLevel.DEBUG, msgs);
};
}
/**

@@ -96,9 +88,5 @@ * Log WARN

*/
Logger.prototype.warn = function () {
var msgs = [];
for (var _i = 0; _i < arguments.length; _i++) {
msgs[_i - 0] = arguments[_i];
}
warn(...msgs) {
this.log_(LogLevel.WARN, msgs);
};
}
/**

@@ -108,9 +96,5 @@ * Log ERROR

*/
Logger.prototype.error = function () {
var msgs = [];
for (var _i = 0; _i < arguments.length; _i++) {
msgs[_i - 0] = arguments[_i];
}
error(...msgs) {
this.log_(LogLevel.ERROR, msgs);
};
}
/**

@@ -121,3 +105,3 @@ * For the log level set, check to see if the messages should be logged.

*/
Logger.prototype.log_ = function (logLevel, msgs) {
log_(logLevel, msgs) {
switch (Logger.logLevel) {

@@ -147,3 +131,3 @@ case LogLevel.ERROR:

}
};
}
/**

@@ -155,5 +139,5 @@ * Format with timestamp, log level, identifier, and message and log to

*/
Logger.prototype.print_ = function (logLevel, msgs) {
var consoleLog = '';
var fileLog = '';
print_(logLevel, msgs) {
let consoleLog = '';
let fileLog = '';
if (Logger.showTimestamp) {

@@ -199,3 +183,3 @@ consoleLog += Logger.timestamp_(WriteTo.CONSOLE);

}
};
}
/**

@@ -206,8 +190,8 @@ * Get a timestamp formatted with [hh:mm:ss]

*/
Logger.timestamp_ = function (writeTo) {
var d = new Date();
var ts = '[';
var hours = d.getHours() < 10 ? '0' + d.getHours() : d.getHours();
var minutes = d.getMinutes() < 10 ? '0' + d.getMinutes() : d.getMinutes();
var seconds = d.getSeconds() < 10 ? '0' + d.getSeconds() : d.getSeconds();
static timestamp_(writeTo) {
let d = new Date();
let ts = '[';
let hours = d.getHours() < 10 ? '0' + d.getHours() : d.getHours();
let minutes = d.getMinutes() < 10 ? '0' + d.getMinutes() : d.getMinutes();
let seconds = d.getSeconds() < 10 ? '0' + d.getSeconds() : d.getSeconds();
if (writeTo == WriteTo.CONSOLE) {

@@ -221,3 +205,3 @@ ts += printGray(hours + ':' + minutes + ':' + seconds) + ']';

return ts;
};
}
/**

@@ -229,4 +213,4 @@ * Get the identifier of the logger as '/<id>'

*/
Logger.id_ = function (logLevel, id, writeTo) {
var level = LogLevel[logLevel].toString();
static id_(logLevel, id, writeTo) {
let level = LogLevel[logLevel].toString();
if (writeTo === WriteTo.FILE) {

@@ -244,3 +228,3 @@ return '/' + id;

}
};
}
/**

@@ -252,4 +236,4 @@ * Get the log level formatted with the first letter. For info, it is I.

*/
Logger.level_ = function (logLevel, id, writeTo) {
var level = LogLevel[logLevel].toString();
static level_(logLevel, id, writeTo) {
let level = LogLevel[logLevel].toString();
if (writeTo === WriteTo.FILE) {

@@ -267,3 +251,3 @@ return level[0];

}
};
}
/**

@@ -274,7 +258,7 @@ * Convert the list of messages to a single string message.

*/
Logger.msgToFile_ = function (msgs) {
var log = '';
for (var pos = 0; pos < msgs.length; pos++) {
var msg = msgs[pos];
var ret = void 0;
static msgToFile_(msgs) {
let log = '';
for (let pos = 0; pos < msgs.length; pos++) {
let msg = msgs[pos];
let ret;
if (typeof msg === 'object') {

@@ -292,11 +276,10 @@ ret = JSON.stringify(msg);

return log;
};
Logger.logLevel = LogLevel.INFO;
Logger.showTimestamp = true;
Logger.showId = true;
Logger.writeTo = WriteTo.CONSOLE;
Logger.firstWrite = false;
return Logger;
}());
}
}
exports.Logger = Logger;
Logger.logLevel = LogLevel.INFO;
Logger.showTimestamp = true;
Logger.showId = true;
Logger.writeTo = WriteTo.CONSOLE;
Logger.firstWrite = false;
//# sourceMappingURL=logger.js.map

@@ -22,1 +22,2 @@ export interface MinimistArgs {

}
export declare function unparseOptions(options: Options): string[];
"use strict";
var Option = (function () {
function Option(opt, description, type, defaultValue) {
class Option {
constructor(opt, description, type, defaultValue) {
this.opt = opt;
this.description = description;
this.type = type;
if (defaultValue) {
if (defaultValue != null) {
this.defaultValue = defaultValue;
}
}
Option.prototype.getValue_ = function () {
if (this.value) {
getValue_() {
if (typeof this.value !== 'undefined') {
return this.value;

@@ -18,24 +18,50 @@ }

}
};
Option.prototype.getNumber = function () {
var value = this.getValue_();
if (value && typeof value === 'number') {
}
getNumber() {
let value = this.getValue_();
if (value != null && (typeof value === 'number' || typeof value === 'string')) {
return +value;
}
return null;
};
Option.prototype.getString = function () {
var value = this.getValue_();
if (value && typeof value === 'string') {
return '' + value;
else {
return null;
}
return null;
};
Option.prototype.getBoolean = function () {
var value = this.getValue_();
return value ? true : false;
};
return Option;
}());
}
getString() {
let value = this.getValue_();
if (value != null) {
return '' + this.getValue_();
}
else {
return '';
}
}
getBoolean() {
let value = this.getValue_();
if (value != null) {
if (typeof value === 'string') {
return !(value === '0' || value === 'false');
}
else if (typeof value === 'number') {
return value !== 0;
}
else {
return value;
}
}
return false;
}
}
exports.Option = Option;
function unparseOptions(options) {
var args = [];
for (let name in options) {
let value = options[name].getValue_();
if (value !== options[name].defaultValue) {
args.push('--' + name, '' + value);
}
}
return args;
}
exports.unparseOptions = unparseOptions;
;
//# sourceMappingURL=options.js.map

@@ -52,3 +52,3 @@ import { MinimistArgs, Option, Options } from './options';

*/
run(json: JSON): void;
run(json: JSON): Promise<void>;
private getValue_(key, json);

@@ -55,0 +55,0 @@ /**

"use strict";
var options_1 = require('./options');
const options_1 = require("./options");
/**
* A program has a command, a description, options, and a run method
*/
var Program = (function () {
function Program() {
class Program {
constructor() {
this.options = {};

@@ -16,7 +16,7 @@ }

*/
Program.prototype.command = function (cmd, cmdDescription) {
command(cmd, cmdDescription) {
this.cmd = cmd;
this.cmdDescription = cmdDescription;
return this;
};
}
/**

@@ -30,6 +30,6 @@ * Register a new option.

*/
Program.prototype.option = function (opt, description, type, opt_defaultValue) {
option(opt, description, type, opt_defaultValue) {
this.options[opt] = new options_1.Option(opt, description, type, opt_defaultValue);
return this;
};
}
/**

@@ -40,6 +40,6 @@ * Adds an option to the program.

*/
Program.prototype.addOption = function (option) {
addOption(option) {
this.options[option.opt] = option;
return this;
};
}
/**

@@ -50,6 +50,6 @@ * Registers a method that will be used to run the program.

*/
Program.prototype.action = function (runMethod) {
action(runMethod) {
this.runMethod = runMethod;
return this;
};
}
/**

@@ -60,14 +60,14 @@ * Adds the value to the options and passes the updated options to the run

*/
Program.prototype.run = function (json) {
for (var opt in this.options) {
run(json) {
for (let opt in this.options) {
this.options[opt].value = this.getValue_(opt, json);
}
this.runMethod(this.options);
};
Program.prototype.getValue_ = function (key, json) {
var keyList = key.split('.');
var tempJson = json;
return Promise.resolve(this.runMethod(this.options));
}
getValue_(key, json) {
let keyList = key.split('.');
let tempJson = json;
while (keyList.length > 0) {
var keyItem = keyList[0];
if (tempJson[keyItem]) {
let keyItem = keyList[0];
if (tempJson[keyItem] != null) {
tempJson = tempJson[keyItem];

@@ -80,4 +80,4 @@ keyList = keyList.slice(1);

}
return tempJson.toString();
};
return tempJson;
}
/**

@@ -91,7 +91,7 @@ * Prints the command with the description. The description will have spaces

*/
Program.prototype.printCmd = function (opt_posDescription) {
var log = ' ' + this.cmd;
var spacing = Program.MIN_SPACING;
printCmd(opt_posDescription) {
let log = ' ' + this.cmd;
let spacing = Program.MIN_SPACING;
if (opt_posDescription) {
var diff = opt_posDescription - log.length;
let diff = opt_posDescription - log.length;
if (diff < Program.MIN_SPACING) {

@@ -106,3 +106,3 @@ spacing = Program.MIN_SPACING;

console.log(log);
};
}
/**

@@ -118,4 +118,4 @@ * Prints the options with the option descriptions and default values.

*/
Program.prototype.printOptions = function (posDescription, posDefault, opt_extOptions) {
for (var opt in this.options) {
printOptions(posDescription, posDefault, opt_extOptions) {
for (let opt in this.options) {
// we have already logged it

@@ -125,7 +125,7 @@ if (opt_extOptions && opt_extOptions[opt]) {

}
var option = this.options[opt];
var log = ' --' + option.opt;
var spacing = Program.MIN_SPACING;
let option = this.options[opt];
let log = ' --' + option.opt;
let spacing = Program.MIN_SPACING;
// description
var diff = posDescription - log.length;
let diff = posDescription - log.length;
if (diff < Program.MIN_SPACING) {

@@ -141,8 +141,8 @@ spacing = Program.MIN_SPACING;

spacing = Program.MIN_SPACING;
var diff_1 = posDefault - log.length - 1;
if (diff_1 <= Program.MIN_SPACING) {
let diff = posDefault - log.length - 1;
if (diff <= Program.MIN_SPACING) {
spacing = Program.MIN_SPACING;
}
else {
spacing = diff_1;
spacing = diff;
}

@@ -157,3 +157,3 @@ log += Array(spacing).join(' ');

}
};
}
/**

@@ -163,3 +163,3 @@ * Assuming that the this program can run by itself, to print out the program's

*/
Program.prototype.printHelp = function () {
printHelp() {
console.log('\n' +

@@ -171,13 +171,13 @@ 'Usage: ' + this.cmd + ' [options]\n' +

this.printOptions(this.posDescription(), this.posDefault());
};
Program.prototype.posDescription = function () {
}
posDescription() {
return this.lengthOf_('opt') + 2 * Program.MIN_SPACING;
};
Program.prototype.posDefault = function () {
}
posDefault() {
return this.posDescription() + this.lengthOf_('description') + Program.MIN_SPACING;
};
Program.prototype.lengthOf_ = function (param) {
var maxLength = -1;
for (var opt in this.options) {
var option = this.options[opt];
}
lengthOf_(param) {
let maxLength = -1;
for (let opt in this.options) {
let option = this.options[opt];
if (param === 'description') {

@@ -191,3 +191,3 @@ maxLength = Math.max(maxLength, option.description.length);

return maxLength;
};
}
/**

@@ -197,8 +197,8 @@ * Create a collection of options used by this program.

*/
Program.prototype.getOptions_ = function (allOptions) {
for (var opt in this.options) {
getOptions_(allOptions) {
for (let opt in this.options) {
allOptions[opt] = this.options[opt];
}
return allOptions;
};
}
/**

@@ -209,11 +209,12 @@ * Get the options used by the program and create the minimist options

*/
Program.prototype.getMinimistOptions = function () {
var allOptions = {};
getMinimistOptions() {
let allOptions = {};
allOptions = this.getOptions_(allOptions);
var minimistOptions = {};
var minimistBoolean = [];
var minimistString = [];
var minimistNumber = [];
for (var opt in allOptions) {
var option = allOptions[opt];
let minimistOptions = {};
let minimistBoolean = [];
let minimistString = [];
let minimistNumber = [];
let minimistDefault = {};
for (let opt in allOptions) {
let option = allOptions[opt];
if (option.type === 'boolean') {

@@ -228,2 +229,5 @@ minimistBoolean.push(option.opt);

}
if (typeof option.defaultValue !== 'undefined') {
minimistDefault[option.opt] = option.defaultValue;
}
}

@@ -233,8 +237,8 @@ minimistOptions['boolean'] = minimistBoolean;

minimistOptions['number'] = minimistNumber;
minimistOptions['default'] = minimistDefault;
return minimistOptions;
};
Program.MIN_SPACING = 4;
return Program;
}());
}
}
exports.Program = Program;
Program.MIN_SPACING = 4;
//# sourceMappingURL=programs.js.map
"use strict";
var minimist = require('minimist');
var path = require('path');
var cli_1 = require('../cli');
var config_1 = require('../config');
var files_1 = require('../files');
var Opt = require('./');
var opts_1 = require('./opts');
var prog = new cli_1.Program()
const minimist = require("minimist");
const path = require("path");
const cli_1 = require("../cli");
const config_1 = require("../config");
const files_1 = require("../files");
const Opt = require("./");
const opts_1 = require("./opts");
let prog = new cli_1.Program()
.command('clean', 'removes all downloaded driver files from the out_dir')

@@ -15,3 +15,3 @@ .action(clean)

// stand alone runner
var argv = minimist(process.argv.slice(2), prog.getMinimistOptions());
let argv = minimist(process.argv.slice(2), prog.getMinimistOptions());
if (argv._[0] === 'clean-run') {

@@ -28,3 +28,3 @@ prog.run(JSON.parse(JSON.stringify(argv)));

function clean(options) {
var outputDir = config_1.Config.getSeleniumDir();
let outputDir = config_1.Config.getSeleniumDir();
if (options[Opt.OUT_DIR].getString()) {

@@ -31,0 +31,0 @@ if (path.isAbsolute(options[Opt.OUT_DIR].getString())) {

@@ -5,3 +5,3 @@ "use strict";

}
__export(require('./opts'));
__export(require("./opts"));
//# sourceMappingURL=index.js.map
import { Logger } from '../cli';
export declare function android(sdkPath: string, apiLevels: string[], abis: string[], acceptLicenses: boolean, version: string, logger: Logger): void;
export declare function android(sdkPath: string, apiLevels: string[], architectures: string[], platforms: string[], acceptLicenses: boolean, version: string, oldAVDs: string[], logger: Logger, verbose: boolean): void;
export declare function iOS(logger: Logger): void;
"use strict";
var child_process = require('child_process');
var fs = require('fs');
var glob = require('glob');
var ini = require('ini');
var os = require('os');
var path = require('path');
var q = require('q');
var noop = function () { };
const child_process_1 = require("child_process");
const fs = require("fs");
const glob = require("glob");
const ini = require("ini");
const path = require("path");
const q = require("q");
const config_1 = require("../config");
const utils_1 = require("../utils");
const noop = () => { };
// Make a function which configures a child process to automatically respond
// to a certain question
function respondFactory(question, answer) {
return function (child) {
function respondFactory(question, answer, verbose) {
return (child) => {
child.stdin.setDefaultEncoding('utf-8');
child.stdout.on('data', function (data) {
child.stdout.on('data', (data) => {
if (data != null) {
if (verbose) {
process.stdout.write(data);
}
if (data.toString().indexOf(question) != -1) {

@@ -25,4 +29,4 @@ child.stdin.write(answer + '\n');

// Run a command on the android SDK
function runAndroidSDKCommand(sdkPath, cmd, args, spawnOptions, config_fun) {
var child = child_process.spawn(path.join(sdkPath, 'tools', 'android'), [cmd].concat(args), spawnOptions);
function runAndroidSDKCommand(sdkPath, cmd, args, stdio, config_fun) {
let child = utils_1.spawn(path.resolve(sdkPath, 'tools', 'android'), [cmd].concat(args), stdio);
if (config_fun) {

@@ -32,4 +36,4 @@ config_fun(child);

;
var deferred = q.defer();
child.on('exit', function (code) {
let deferred = q.defer();
child.on('exit', (code) => {
if (deferred != null) {

@@ -45,3 +49,3 @@ if (code) {

});
child.on('error', function (err) {
child.on('error', (err) => {
if (deferred != null) {

@@ -55,64 +59,85 @@ deferred.reject(err);

// Download updates via the android SDK
function downloadAndroidUpdates(sdkPath, targets, search_all, auto_accept) {
return runAndroidSDKCommand(sdkPath, 'update', ['sdk', '-u'].concat(search_all ? ['-a'] : []).concat(['-t', targets.join(',')]), { stdio: auto_accept ? 'pipe' : 'inherit' }, auto_accept ? respondFactory('Do you accept the license', 'y') : noop);
function downloadAndroidUpdates(sdkPath, targets, search_all, auto_accept, verbose) {
return runAndroidSDKCommand(sdkPath, 'update', ['sdk', '-u'].concat(search_all ? ['-a'] : []).concat(['-t', targets.join(',')]), auto_accept ? 'pipe' : 'inherit', auto_accept ? respondFactory('Do you accept the license', 'y', verbose) : noop);
}
// Setup hardware acceleration for x86-64 emulation
function setupHardwareAcceleration(sdkPath) {
// TODO(sjelin): check that the BIOS option is set properly on linux
if (os.type() == 'Darwin') {
// TODO(sjelin): linux setup
let toolDir = path.resolve(sdkPath, 'extras', 'intel', 'Hardware_Accelerated_Execution_Manager');
if (config_1.Config.osType() == 'Darwin') {
console.log('Enabling hardware acceleration (requires root access)');
child_process.spawnSync('sudo', [path.join(sdkPath, 'extras', 'intel', 'Hardware_Accelerated_Execution_Manager', 'silent_install.sh')], { stdio: 'inherit' });
// We don't need the wrapped spawnSync because we know we're on OSX
child_process_1.spawnSync('sudo', ['silent_install.sh'], { stdio: 'inherit', cwd: toolDir });
}
else if (os.type() == 'Windows_NT') {
else if (config_1.Config.osType() == 'Windows_NT') {
console.log('Enabling hardware acceleration (requires admin access)');
child_process.spawnSync('runas', [
'/noprofile', '/user:Administrator',
path.join(sdkPath, 'extras', 'intel', 'Hardware_Accelerated_Execution_Manager', 'silent_install.bat')
], { stdio: 'inherit' });
// We don't need the wrapped spawnSync because we know we're on windows
child_process_1.spawnSync('silent_install.bat', [], { stdio: 'inherit', cwd: toolDir });
}
}
// Get a list of all the SDK download targets for a given set of APIs and ABIs
function getAndroidSDKTargets(apiLevels, abis) {
return apiLevels
.map(function (level) {
// Get a list of all the SDK download targets for a given set of APIs,
// architectures, and platforms
function getAndroidSDKTargets(apiLevels, architectures, platforms, oldAVDs) {
function getSysImgTarget(architecture, platform, level) {
if (platform.toUpperCase() == 'DEFAULT') {
platform = 'android';
}
return 'sys-img-' + architecture + '-' + platform + '-' + level;
}
let targets = apiLevels
.map((level) => {
return 'android-' + level;
})
.concat(abis.reduce(function (targets, abi) {
var abiParts = abi.split('/');
var deviceType = 'default';
var architecture;
if (abiParts.length == 1) {
architecture = abiParts[0];
.concat(architectures.reduce((targets, architecture) => {
return targets.concat.apply(targets, platforms.map((platform) => {
return apiLevels.map(getSysImgTarget.bind(null, architecture, platform));
}));
}, []));
oldAVDs.forEach((name) => {
let avd = new AVDDescriptor(name);
if (targets.indexOf(avd.api) == -1) {
targets.push(avd.api);
}
else {
deviceType = abiParts[0];
architecture = abiParts[1];
let sysImgTarget = getSysImgTarget(avd.architecture, avd.platform, avd.api.slice('android-'.length));
if (targets.indexOf(sysImgTarget) == -1) {
targets.push(sysImgTarget);
}
if (deviceType.toUpperCase() == 'DEFAULT') {
deviceType = 'android';
}
return targets.concat(apiLevels.map(function (level) {
return 'sys-img-' + architecture + '-' + deviceType + '-' + level;
}));
}, []));
});
return targets;
}
// All the information about an android virtual device
var AVDDescriptor = (function () {
function AVDDescriptor(api, deviceType, architecture) {
this.api = api;
this.deviceType = deviceType;
this.architecture = architecture;
this.abi = (deviceType.toUpperCase() == 'DEFAULT' ? '' : deviceType + '/') + architecture;
this.name = [api, deviceType, architecture].join('-');
class AVDDescriptor {
constructor(api, platform, architecture) {
if (platform != undefined) {
this.api = api;
this.platform = platform;
this.architecture = architecture;
this.name = [api, platform, architecture].join('-');
}
else {
this.name = api;
let nameParts = this.name.split('-');
this.api = nameParts[0] + '-' + nameParts[1];
if (/v[0-9]+[a-z]+/.test(nameParts[nameParts.length - 1]) &&
(nameParts[nameParts.length - 2].slice(0, 3) == 'arm')) {
this.architecture = nameParts[nameParts.length - 2] + '-' + nameParts[nameParts.length - 1];
}
else {
this.architecture = nameParts[nameParts.length - 1];
}
this.platform = this.name.slice(this.api.length + 1, -this.architecture.length - 1);
}
this.abi =
(this.platform.toUpperCase() == 'DEFAULT' ? '' : this.platform + '/') + this.architecture;
}
AVDDescriptor.prototype.avdName = function (version) {
avdName(version) {
return this.name + '-v' + version + '-wd-manager';
};
return AVDDescriptor;
}());
}
}
// Gets the descriptors for all AVDs which are possible to make given the
// SDKs which were downloaded
function getAVDDescriptors(sdkPath) {
var deferred = q.defer();
glob(path.join(sdkPath, 'system-images', '*', '*', '*'), function (err, files) {
let deferred = q.defer();
// `glob` package always prefers patterns to use `/`
glob('system-images/*/*/*', { cwd: sdkPath }, (err, files) => {
if (err) {

@@ -122,4 +147,5 @@ deferred.reject(err);

else {
deferred.resolve(files.map(function (file) {
var info = file.split(path.sep).slice(-3);
deferred.resolve(files.map((file) => {
// `file` could use `/` or `\`, so we use `path.normalize`
let info = path.normalize(file).split(path.sep).slice(-3);
return new AVDDescriptor(info[0], info[1], info[2]);

@@ -132,5 +158,5 @@ }));

function sequentialForEach(array, func) {
var ret = q(null);
array.forEach(function (x) {
ret = ret.then(function () {
let ret = q(null);
array.forEach((x) => {
ret = ret.then(() => {
return func(x);

@@ -143,11 +169,11 @@ });

function configureAVDHardware(sdkPath, desc) {
var file = path.join(sdkPath, 'system-images', desc.api, desc.deviceType, desc.architecture, 'hardware.ini');
let file = path.resolve(sdkPath, 'system-images', desc.api, desc.platform, desc.architecture, 'hardware.ini');
return q.nfcall(fs.stat, file)
.then(function (stats) {
.then((stats) => {
return q.nfcall(fs.readFile, file);
}, function (err) {
}, (err) => {
return q('');
})
.then(function (contents) {
var config = ini.parse(contents.toString());
.then((contents) => {
let config = ini.parse(contents.toString());
config['hw.keyboard'] = 'yes';

@@ -160,48 +186,48 @@ config['hw.battery'] = 'yes';

// Make an android virtual device
function makeAVD(sdkPath, desc, version) {
return runAndroidSDKCommand(sdkPath, 'delete', ['avd', '--name', desc.avdName(version)], {})
function makeAVD(sdkPath, desc, version, verbose) {
return runAndroidSDKCommand(sdkPath, 'delete', ['avd', '--name', desc.avdName(version)])
.then(noop, noop)
.then(function () {
return runAndroidSDKCommand(sdkPath, 'create', ['avd', '--name', desc.avdName(version), '--target', desc.api, '--abi', desc.abi], { stdio: 'pipe' }, respondFactory('Do you wish to create a custom hardware profile', 'no'));
.then(() => {
return runAndroidSDKCommand(sdkPath, 'create', ['avd', '--name', desc.avdName(version), '--target', desc.api, '--abi', desc.abi], 'pipe', respondFactory('Do you wish to create a custom hardware profile', 'no', verbose));
});
}
// Initialize the android SDK
function android(sdkPath, apiLevels, abis, acceptLicenses, version, logger) {
var avdDescriptors;
var tools = ['platform-tool', 'tool'];
if ((os.type() == 'Darwin') || (os.type() == 'Windows_NT')) {
function android(sdkPath, apiLevels, architectures, platforms, acceptLicenses, version, oldAVDs, logger, verbose) {
let avdDescriptors;
let tools = ['platform-tool', 'tool'];
if ((config_1.Config.osType() == 'Darwin') || (config_1.Config.osType() == 'Windows_NT')) {
tools.push('extra-intel-Hardware_Accelerated_Execution_Manager');
}
logger.info('android-sdk: Downloading additional SDK updates');
downloadAndroidUpdates(sdkPath, tools, false, acceptLicenses)
.then(function () {
downloadAndroidUpdates(sdkPath, tools, false, acceptLicenses, verbose)
.then(() => {
return setupHardwareAcceleration(sdkPath);
})
.then(function () {
.then(() => {
logger.info('android-sdk: Downloading more additional SDK updates ' +
'(this may take a while)');
return downloadAndroidUpdates(sdkPath, ['build-tools-24.0.0'].concat(getAndroidSDKTargets(apiLevels, abis)), true, acceptLicenses);
return downloadAndroidUpdates(sdkPath, ['build-tools-24.0.0'].concat(getAndroidSDKTargets(apiLevels, architectures, platforms, oldAVDs)), true, acceptLicenses, verbose);
})
.then(function () {
.then(() => {
return getAVDDescriptors(sdkPath);
})
.then(function (descriptors) {
.then((descriptors) => {
avdDescriptors = descriptors;
logger.info('android-sdk: Configuring virtual device hardware');
return sequentialForEach(avdDescriptors, function (descriptor) {
return sequentialForEach(avdDescriptors, (descriptor) => {
return configureAVDHardware(sdkPath, descriptor);
});
})
.then(function () {
return sequentialForEach(avdDescriptors, function (descriptor) {
.then(() => {
return sequentialForEach(avdDescriptors, (descriptor) => {
logger.info('android-sdk: Setting up virtual device "' + descriptor.name + '"');
return makeAVD(sdkPath, descriptor, version);
return makeAVD(sdkPath, descriptor, version, verbose);
});
})
.then(function () {
return q.nfcall(fs.writeFile, path.join(sdkPath, 'available_avds.json'), JSON.stringify(avdDescriptors.map(function (descriptor) {
.then(() => {
return q.nfcall(fs.writeFile, path.resolve(sdkPath, 'available_avds.json'), JSON.stringify(avdDescriptors.map((descriptor) => {
return descriptor.name;
})));
})
.then(function () {
.then(() => {
logger.info('android-sdk: Initialization complete');

@@ -214,3 +240,3 @@ })

function iOS(logger) {
if (os.type() != 'Darwin') {
if (config_1.Config.osType() != 'Darwin') {
throw new Error('Must be on a Mac to simulate iOS devices.');

@@ -217,0 +243,0 @@ }

import { Options } from '../cli';
export declare const OUT_DIR: string;
export declare const SELENIUM_PORT: string;
export declare const APPIUM_PORT: string;
export declare const AVD_PORT: string;
export declare const IGNORE_SSL: string;
export declare const PROXY: string;
export declare const ALTERNATE_CDN: string;
export declare const STANDALONE: string;
export declare const CHROME: string;
export declare const IE: string;
export declare const IE32: string;
export declare const EDGE: string;
export declare const GECKO: string;
export declare const ANDROID: string;
export declare const IOS: string;
export declare const VERSIONS_CHROME: string;
export declare const VERSIONS_GECKO: string;
export declare const VERSIONS_STANDALONE: string;
export declare const VERSIONS_IE: string;
export declare const VERSIONS_ANDROID: string;
export declare const VERSIONS_APPIUM: string;
export declare const CHROME_LOGS: string;
export declare const LOGGING: string;
export declare const ANDROID_API_LEVELS: string;
export declare const ANDROID_ABIS: string;
export declare const ANDROID_ACCEPT_LICENSES: string;
export declare const AVDS: string;
export declare const AVD_USE_SNAPSHOTS: string;
export declare const OUT_DIR = "out_dir";
export declare const SELENIUM_PORT = "seleniumPort";
export declare const APPIUM_PORT = "appium-port";
export declare const AVD_PORT = "avd-port";
export declare const IGNORE_SSL = "ignore_ssl";
export declare const PROXY = "proxy";
export declare const ALTERNATE_CDN = "alternate_cdn";
export declare const STANDALONE = "standalone";
export declare const CHROME = "chrome";
export declare const IE = "ie";
export declare const IE32 = "ie32";
export declare const EDGE = "edge";
export declare const GECKO = "gecko";
export declare const ANDROID = "android";
export declare const IOS = "ios";
export declare const VERSIONS_CHROME = "versions.chrome";
export declare const VERSIONS_GECKO = "versions.gecko";
export declare const VERSIONS_STANDALONE = "versions.standalone";
export declare const VERSIONS_IE = "versions.ie";
export declare const VERSIONS_ANDROID = "versions.android";
export declare const VERSIONS_APPIUM = "versions.appium";
export declare const CHROME_LOGS = "chrome_logs";
export declare const LOGGING = "logging";
export declare const ANDROID_API_LEVELS = "android-api-levels";
export declare const ANDROID_ARCHITECTURES = "android-archs";
export declare const ANDROID_PLATFORMS = "android-platorms";
export declare const ANDROID_ACCEPT_LICENSES = "android-accept-licenses";
export declare const AVDS = "avds";
export declare const AVD_USE_SNAPSHOTS = "avd-use-snapshots";
export declare const STARTED_SIGNIFIER = "started-signifier";
export declare const SIGNAL_VIA_IPC = "signal-via-ipc";
export declare const DETACH = "detach";
export declare const QUIET = "quiet";
export declare const VERBOSE = "verbose";
export declare const ALREADY_OFF_ERROR = "already-off-error";
export declare var Opts: Options;
"use strict";
var binaries_1 = require('../binaries');
var cli_1 = require('../cli');
var config_1 = require('../config');
const binaries_1 = require("../binaries");
const cli_1 = require("../cli");
const config_1 = require("../config");
exports.OUT_DIR = 'out_dir';

@@ -29,6 +29,13 @@ exports.SELENIUM_PORT = 'seleniumPort';

exports.ANDROID_API_LEVELS = 'android-api-levels';
exports.ANDROID_ABIS = 'android-abis';
exports.ANDROID_ARCHITECTURES = 'android-archs';
exports.ANDROID_PLATFORMS = 'android-platorms';
exports.ANDROID_ACCEPT_LICENSES = 'android-accept-licenses';
exports.AVDS = 'avds';
exports.AVD_USE_SNAPSHOTS = 'avd-use-snapshots';
exports.STARTED_SIGNIFIER = 'started-signifier';
exports.SIGNAL_VIA_IPC = 'signal-via-ipc';
exports.DETACH = 'detach';
exports.QUIET = 'quiet';
exports.VERBOSE = 'verbose';
exports.ALREADY_OFF_ERROR = 'already-off-error';
/**

@@ -40,5 +47,6 @@ * The options used by the commands.

opts[exports.SELENIUM_PORT] =
new cli_1.Option(exports.SELENIUM_PORT, 'Optional port for the selenium standalone server', 'string');
opts[exports.APPIUM_PORT] = new cli_1.Option(exports.APPIUM_PORT, 'Optional port for the appium server', 'string');
opts[exports.AVD_PORT] = new cli_1.Option(exports.AVD_PORT, 'Optional port for android virtual devices. See mobile.md for details', 'string');
new cli_1.Option(exports.SELENIUM_PORT, 'Optional port for the selenium standalone server', 'string', '4444');
opts[exports.APPIUM_PORT] =
new cli_1.Option(exports.APPIUM_PORT, 'Optional port for the appium server', 'string', '4723');
opts[exports.AVD_PORT] = new cli_1.Option(exports.AVD_PORT, 'Optional port for android virtual devices. See mobile.md for details', 'number', 5554);
opts[exports.IGNORE_SSL] = new cli_1.Option(exports.IGNORE_SSL, 'Ignore SSL certificates', 'boolean', false);

@@ -66,3 +74,4 @@ opts[exports.PROXY] = new cli_1.Option(exports.PROXY, 'Proxy to use for the install or update command', 'string');

opts[exports.ANDROID_API_LEVELS] = new cli_1.Option(exports.ANDROID_API_LEVELS, 'Which versions of the android API you want to emulate', 'string', binaries_1.AndroidSDK.DEFAULT_API_LEVELS);
opts[exports.ANDROID_ABIS] = new cli_1.Option(exports.ANDROID_ABIS, 'Which ABIs you want to use in android emulation', 'string', binaries_1.AndroidSDK.DEFAULT_ABIS);
opts[exports.ANDROID_ARCHITECTURES] = new cli_1.Option(exports.ANDROID_ARCHITECTURES, 'Which architectures you want to use in android emulation. By default it will try to match os.arch()', 'string', binaries_1.AndroidSDK.DEFAULT_ARCHITECTURES);
opts[exports.ANDROID_PLATFORMS] = new cli_1.Option(exports.ANDROID_PLATFORMS, 'Which platforms you want to use in android emulation', 'string', binaries_1.AndroidSDK.DEFAULT_PLATFORMS);
opts[exports.ANDROID_ACCEPT_LICENSES] =

@@ -72,3 +81,10 @@ new cli_1.Option(exports.ANDROID_ACCEPT_LICENSES, 'Automatically accept android licenses', 'boolean', false);

opts[exports.AVD_USE_SNAPSHOTS] = new cli_1.Option(exports.AVD_USE_SNAPSHOTS, 'Rather than booting a new AVD every time, save/load snapshots of the last time it was used', 'boolean', true);
opts[exports.STARTED_SIGNIFIER] = new cli_1.Option(exports.STARTED_SIGNIFIER, 'A string to be outputted once the selenium server is up and running. Useful if you are writing a script which uses webdriver-manager.', 'string');
opts[exports.SIGNAL_VIA_IPC] = new cli_1.Option(exports.SIGNAL_VIA_IPC, 'If you are using --' + exports.STARTED_SIGNIFIER +
', this flag will emit the signal string using process.send(), rather than writing it to stdout', 'boolean', false);
opts[exports.DETACH] = new cli_1.Option(exports.DETACH, 'Once the selenium server is up and running, return control to the parent process and continue running the server in the background.', 'boolean', false);
opts[exports.VERBOSE] = new cli_1.Option(exports.VERBOSE, 'Extra console output', 'boolean', false);
opts[exports.QUIET] = new cli_1.Option(exports.QUIET, 'Minimal console output', 'boolean', false);
opts[exports.ALREADY_OFF_ERROR] = new cli_1.Option(exports.ALREADY_OFF_ERROR, 'Normally if you try to shut down a selenium which is not running, you will get a warning. This turns it into an error', 'boolean', false);
exports.Opts = opts;
//# sourceMappingURL=opts.js.map
"use strict";
var childProcess = require('child_process');
var fs = require('fs');
var http = require('http');
var minimist = require('minimist');
var os = require('os');
var path = require('path');
var binaries_1 = require('../binaries');
var gecko_driver_1 = require('../binaries/gecko_driver');
var cli_1 = require('../cli');
var config_1 = require('../config');
var files_1 = require('../files');
var Opt = require('./');
var opts_1 = require('./opts');
var logger = new cli_1.Logger('start');
var prog = new cli_1.Program()
.command('start', 'start up the selenium server')
const fs = require("fs");
const http = require("http");
const minimist = require("minimist");
const path = require("path");
const binaries_1 = require("../binaries");
const gecko_driver_1 = require("../binaries/gecko_driver");
const cli_1 = require("../cli");
const config_1 = require("../config");
const files_1 = require("../files");
const utils_1 = require("../utils");
const Opt = require("./");
const opts_1 = require("./opts");
const commandName = 'start';
let logger = new cli_1.Logger('start');
let prog = new cli_1.Program()
.command(commandName, 'start up the selenium server')
.action(start)

@@ -31,7 +31,11 @@ .addOption(opts_1.Opts[Opt.OUT_DIR])

.addOption(opts_1.Opts[Opt.AVDS])
.addOption(opts_1.Opts[Opt.AVD_USE_SNAPSHOTS]);
if (os.type() === 'Darwin') {
.addOption(opts_1.Opts[Opt.AVD_USE_SNAPSHOTS])
.addOption(opts_1.Opts[Opt.STARTED_SIGNIFIER])
.addOption(opts_1.Opts[Opt.SIGNAL_VIA_IPC])
.addOption(opts_1.Opts[Opt.QUIET])
.addOption(opts_1.Opts[Opt.DETACH]);
if (config_1.Config.osType() === 'Darwin') {
prog.addOption(opts_1.Opts[Opt.IOS]);
}
if (os.type() === 'Windows_NT') {
if (config_1.Config.osType() === 'Windows_NT') {
prog.addOption(opts_1.Opts[Opt.VERSIONS_IE])

@@ -44,3 +48,3 @@ .addOption(opts_1.Opts[Opt.IE32])

// stand alone runner
var argv = minimist(process.argv.slice(2), prog.getMinimistOptions());
let argv = minimist(process.argv.slice(2), prog.getMinimistOptions());
if (argv._[0] === 'start-run') {

@@ -52,2 +56,5 @@ prog.run(JSON.parse(JSON.stringify(argv)));

}
// Manage processes used in android emulation
let androidProcesses = [];
let androidActiveAVDs = [];
/**

@@ -58,6 +65,13 @@ * Parses the options and starts the selenium standalone server.

function start(options) {
var osType = os.type();
var binaries = files_1.FileManager.setupBinaries();
var seleniumPort = options[Opt.SELENIUM_PORT].getString();
var outputDir = config_1.Config.getSeleniumDir();
if (options[Opt.DETACH].getBoolean()) {
return detachedRun(options);
}
let osType = config_1.Config.osType();
let stdio = options[Opt.QUIET].getBoolean() ? 'pipe' : 'inherit';
let binaries = files_1.FileManager.setupBinaries();
let seleniumPort = options[Opt.SELENIUM_PORT].getString();
let appiumPort = options[Opt.APPIUM_PORT].getString();
let avdPort = options[Opt.AVD_PORT].getNumber();
let android = options[Opt.ANDROID].getBoolean();
let outputDir = config_1.Config.getSeleniumDir();
if (options[Opt.OUT_DIR].getString()) {

@@ -80,4 +94,4 @@ if (path.isAbsolute(options[Opt.OUT_DIR].getString())) {

}
var chromeLogs = null;
var loggingFile = null;
let chromeLogs = null;
let loggingFile = null;
if (options[Opt.CHROME_LOGS].getString()) {

@@ -98,3 +112,3 @@ if (path.isAbsolute(options[Opt.CHROME_LOGS].getString())) {

binaries[binaries_1.Appium.id].versionCustom = options[Opt.VERSIONS_APPIUM].getString();
var downloadedBinaries = files_1.FileManager.downloadedBinaries(outputDir);
let downloadedBinaries = files_1.FileManager.downloadedBinaries(outputDir);
if (downloadedBinaries[binaries_1.StandAlone.id] == null) {

@@ -105,3 +119,3 @@ logger.error('Selenium Standalone is not present. Install with ' +

}
var args = [];
let args = [];
if (osType === 'Linux') {

@@ -126,3 +140,3 @@ // selenium server may take a long time to start because /dev/random is BLOCKING if there is not

args.push('-Dwebdriver.chrome.driver=' +
path.join(outputDir, binaries[binaries_1.ChromeDriver.id].executableFilename(osType)));
path.resolve(outputDir, binaries[binaries_1.ChromeDriver.id].executableFilename(osType)));
if (chromeLogs != null) {

@@ -134,3 +148,3 @@ args.push('-Dwebdriver.chrome.logfile=' + chromeLogs);

args.push('-Dwebdriver.gecko.driver=' +
path.join(outputDir, binaries[gecko_driver_1.GeckoDriver.id].executableFilename(osType)));
path.resolve(outputDir, binaries[gecko_driver_1.GeckoDriver.id].executableFilename(osType)));
}

@@ -142,3 +156,3 @@ if (downloadedBinaries[binaries_1.IEDriver.id] != null) {

args.push('-Dwebdriver.ie.driver=' +
path.join(outputDir, binaries[binaries_1.IEDriver.id].executableFilename(osType)));
path.resolve(outputDir, binaries[binaries_1.IEDriver.id].executableFilename(osType)));
}

@@ -148,3 +162,3 @@ if (options[Opt.EDGE]) {

try {
var edgeFile = options[Opt.EDGE].getString();
let edgeFile = options[Opt.EDGE].getString();
if (fs.statSync(edgeFile).isFile()) {

@@ -157,6 +171,6 @@ args.push('-Dwebdriver.edge.driver=' + options[Opt.EDGE].getString());

}
if (options[Opt.ANDROID].getBoolean()) {
if (android) {
if (downloadedBinaries[binaries_1.AndroidSDK.id] != null) {
var avds = options[Opt.AVDS].getString();
startAndroid(outputDir, binaries[binaries_1.AndroidSDK.id], avds.split(','), options[Opt.AVD_USE_SNAPSHOTS].getBoolean(), options[Opt.AVD_PORT].getString());
let avds = options[Opt.AVDS].getString();
startAndroid(outputDir, binaries[binaries_1.AndroidSDK.id], avds.split(','), options[Opt.AVD_USE_SNAPSHOTS].getBoolean(), avdPort, stdio);
}

@@ -168,7 +182,7 @@ else {

if (downloadedBinaries[binaries_1.Appium.id] != null) {
startAppium(outputDir, binaries[binaries_1.Appium.id], options[Opt.APPIUM_PORT].getString());
startAppium(outputDir, binaries[binaries_1.Appium.id], binaries[binaries_1.AndroidSDK.id], appiumPort, stdio);
}
// log the command to launch selenium server
args.push('-jar');
args.push(path.join(outputDir, binaries[binaries_1.StandAlone.id].filename()));
args.push(path.resolve(outputDir, binaries[binaries_1.StandAlone.id].filename()));
// Add the port parameter, has to declared after the jar file

@@ -178,40 +192,34 @@ if (seleniumPort) {

}
var argsToString = '';
for (var arg in args) {
let argsToString = '';
for (let arg in args) {
argsToString += ' ' + args[arg];
}
logger.info('java' + argsToString);
var seleniumProcess = spawnCommand('java', args);
let seleniumProcess = utils_1.spawn('java', args, stdio);
if (options[Opt.STARTED_SIGNIFIER].getString()) {
signalWhenReady(options[Opt.STARTED_SIGNIFIER].getString(), options[Opt.SIGNAL_VIA_IPC].getBoolean(), outputDir, seleniumPort, downloadedBinaries[binaries_1.Appium.id] ? appiumPort : '', binaries[binaries_1.AndroidSDK.id], avdPort, androidActiveAVDs);
}
logger.info('seleniumProcess.pid: ' + seleniumProcess.pid);
seleniumProcess.on('exit', function (code) {
seleniumProcess.on('exit', (code) => {
logger.info('Selenium Standalone has exited with code ' + code);
killAndroid();
killAppium();
process.exit(code);
shutdownEverything();
process.exit(process.exitCode || code);
});
seleniumProcess.on('error', (error) => {
logger.warn('Selenium Standalone server encountered an error: ' + error);
});
process.stdin.resume();
process.stdin.on('data', function (chunk) {
process.stdin.on('data', (chunk) => {
logger.info('Attempting to shut down selenium nicely');
var port = seleniumPort || '4444';
http.get('http://localhost:' + port + '/selenium-server/driver/?cmd=shutDownSeleniumServer');
killAndroid();
killAppium();
shutdownEverything(seleniumPort);
});
process.on('SIGINT', function () {
process.on('SIGINT', () => {
logger.info('Staying alive until the Selenium Standalone process exits');
shutdownEverything(seleniumPort);
});
}
function spawnCommand(command, args) {
var osType = os.type();
var windows = osType === 'Windows_NT';
var winCommand = windows ? 'cmd' : command;
var finalArgs = windows ? ['/c'].concat([command], args) : args;
return childProcess.spawn(winCommand, finalArgs, { stdio: 'inherit' });
}
// Manage processes used in android emulation
var androidProcesses = [];
function startAndroid(outputDir, sdk, avds, useSnapshots, port) {
var sdkPath = path.join(outputDir, sdk.executableFilename(os.type()));
function startAndroid(outputDir, sdk, avds, useSnapshots, port, stdio) {
let sdkPath = path.resolve(outputDir, sdk.executableFilename(config_1.Config.osType()));
if (avds[0] == 'all') {
avds = require(path.join(sdkPath, 'available_avds.json'));
avds = require(path.resolve(sdkPath, 'available_avds.json'));
}

@@ -221,7 +229,12 @@ else if (avds[0] == 'none') {

}
avds.forEach(function (avd, i) {
logger.info('Booting up AVD ' + avd);
const minAVDPort = 5554;
const maxAVDPort = 5586 - 2 * avds.length;
if (avds.length && ((port < minAVDPort) || (port > maxAVDPort))) {
throw new RangeError('AVD Port must be between ' + minAVDPort + ' and ' + maxAVDPort + ' to emulate ' +
avds.length + ' android devices');
}
avds.forEach((avd, i) => {
// Credit to appium-ci, which this code was adapted from
var emuBin = 'emulator'; // TODO(sjelin): get the 64bit linux version working
var emuArgs = [
let emuBin = 'emulator'; // TODO(sjelin): get the 64bit linux version working
let emuArgs = [
'-avd',

@@ -231,2 +244,3 @@ avd + '-v' + sdk.versionCustom + '-wd-manager',

];
let portArg = null;
if (!useSnapshots) {

@@ -236,3 +250,4 @@ emuArgs = emuArgs.concat(['-no-snapshot-load', '-no-snapshot-save']);

if (port) {
emuArgs = emuArgs.concat(['-ports', (port + 2 * i) + ',' + (port + 2 * i + 1)]);
portArg = port + i * 2;
emuArgs = emuArgs.concat(['-port', '' + portArg]);
}

@@ -242,16 +257,27 @@ if (emuBin !== 'emulator') {

}
androidProcesses.push(childProcess.spawn(path.join(sdkPath, 'tools', emuBin), emuArgs, { stdio: 'inherit' }));
logger.info('Starting ' + avd + ' on ' + (portArg == null ? 'default port' : 'port ' + portArg));
let child = utils_1.spawn(path.resolve(sdkPath, 'tools', emuBin), emuArgs, stdio);
child.on('error', (error) => {
logger.warn(avd + ' encountered an error: ' + error);
});
androidProcesses.push(child);
androidActiveAVDs.push(avd);
});
}
function killAndroid() {
androidProcesses.forEach(function (androidProcess) {
androidProcess.kill();
});
androidProcesses.length = 0;
for (var i = 0; i < androidProcesses.length; i++) {
logger.info('Shutting down ' + androidActiveAVDs[i]);
androidProcesses[i].kill();
}
androidProcesses.length = androidActiveAVDs.length = 0;
}
// Manage appium process
var appiumProcess;
function startAppium(outputDir, binary, port) {
let appiumProcess;
function startAppium(outputDir, binary, androidSDK, port, stdio) {
logger.info('Starting appium server');
appiumProcess = childProcess.spawn(path.join(outputDir, binary.filename(), 'node_modules', '.bin', 'appium'), port ? ['--port', port] : []);
if (androidSDK) {
process.env.ANDROID_HOME =
path.resolve(outputDir, androidSDK.executableFilename(config_1.Config.osType()));
}
appiumProcess = utils_1.spawn('npm', ['run', 'appium'].concat(port ? ['--', '--port', port] : []), stdio, { cwd: path.resolve(outputDir, binary.filename()) });
}

@@ -264,2 +290,152 @@ function killAppium() {

}
function signalWhenReady(signal, viaIPC, outputDir, seleniumPort, appiumPort, androidSDK, avdPort, avdNames) {
const maxWait = 60 * 1000;
function waitFor(getStatus, testStatus, desc) {
const checkInterval = 100;
return new Promise((resolve, reject) => {
let waited = 0;
(function recursiveCheck() {
setTimeout(() => {
getStatus()
.then((status) => {
if (!testStatus(status)) {
return Promise.reject('Invalid status' + (desc ? ' for ' + desc : '') + ': ' + status);
}
})
.then(() => {
resolve();
}, (error) => {
waited += checkInterval;
if (waited < maxWait) {
recursiveCheck();
}
else {
reject('Timed out' + (desc ? ' wating for' + desc : '') +
'. Final rejection reason: ' + JSON.stringify(error));
}
});
}, checkInterval);
})();
});
}
;
function waitForAndroid(avdPort, avdName, appiumPort) {
let sdkPath = path.resolve(outputDir, androidSDK.executableFilename(config_1.Config.osType()));
logger.info('Waiting for ' + avdName + '\'s emulator to start');
return utils_1.adb(sdkPath, avdPort, 'wait-for-device', maxWait)
.then(() => {
logger.info('Waiting for ' + avdName + '\'s OS to boot up');
return waitFor(() => {
return utils_1.adb(sdkPath, avdPort, 'shell', maxWait, ['getprop', 'sys.boot_completed']);
}, (status) => {
return status.trim() == '1';
}, avdName + '\'s OS');
}, (error) => {
return Promise.reject('Failed to wait for ' + avdName + '\'s emulator to start (' + error.code + ': ' +
error.message + ')');
})
.then(() => {
logger.info('Waiting for ' + avdName + ' to be ready to launch chrome');
let version = binaries_1.AndroidSDK.VERSIONS[parseInt(avdName.slice('android-'.length))];
return utils_1.request('POST', appiumPort, '/wd/hub/session', maxWait, {
desiredCapabilities: {
browserName: 'chrome',
platformName: 'Android',
platformVersion: version,
deviceName: 'Android Emulator'
}
})
.then((data) => {
return JSON.parse(data)['sessionId'];
}, (error) => {
return Promise.reject('Could not start chrome on ' + avdName + ' (' + error.code + ': ' +
error.message + ')');
});
})
.then((sessionId) => {
logger.info('Shutting down dummy chrome instance for ' + avdName);
return utils_1.request('DELETE', appiumPort, '/wd/hub/session/' + sessionId)
.then(() => { }, (error) => {
return Promise.reject('Could not close chrome on ' + avdName + ' (' + error.code + ': ' +
error.message + ')');
});
});
}
let pending = [waitFor(() => {
return utils_1.request('GET', seleniumPort, '/selenium-server/driver/?cmd=getLogMessages', maxWait);
}, (logs) => {
return logs.toUpperCase().indexOf('OK') != -1;
}, 'selenium server')];
if (appiumPort) {
pending.push(waitFor(() => {
return utils_1.request('GET', appiumPort, '/wd/hub/status', maxWait);
}, (status) => {
return JSON.parse(status).status == 0;
}, 'appium server'));
}
if (androidSDK && avdPort) {
for (let i = 0; i < avdNames.length; i++) {
pending.push(waitForAndroid(avdPort + 2 * i, avdNames[i], appiumPort));
}
}
Promise.all(pending).then(() => {
logger.info('Everything started');
sendStartedSignal(signal, viaIPC);
}, (error) => {
logger.error(error);
shutdownEverything(seleniumPort);
process.exitCode = 1;
});
}
function sendStartedSignal(signal, viaIPC) {
if (viaIPC) {
if (process.send) {
return process.send(signal);
}
else {
logger.warn('No IPC channel, sending signal via stdout');
}
}
console.log(signal);
}
function shutdownEverything(seleniumPort) {
if (seleniumPort) {
http.get('http://localhost:' + seleniumPort + '/selenium-server/driver/?cmd=shutDownSeleniumServer');
}
killAndroid();
killAppium();
}
function detachedRun(options) {
var file = path.resolve(__dirname, '..', 'webdriver.js');
var oldSignal = options[Opt.STARTED_SIGNIFIER].getString();
var oldViaIPC = options[Opt.SIGNAL_VIA_IPC].getBoolean();
options[Opt.DETACH].value = false;
options[Opt.STARTED_SIGNIFIER].value = 'server started';
options[Opt.SIGNAL_VIA_IPC].value = true;
let args = [file, commandName].concat(cli_1.unparseOptions(options));
var unreffed = false;
let child = utils_1.spawn(process.execPath, args, ['ignore', 1, 2, 'ipc']);
child.on('message', (message) => {
if (message == options[Opt.STARTED_SIGNIFIER].getString()) {
if (oldSignal) {
sendStartedSignal(oldSignal, oldViaIPC);
}
logger.info('Detached pid: ' + child.pid);
child.disconnect();
child.unref();
unreffed = true;
}
});
child.on('exit', (code) => {
if (!unreffed) {
if (code == 0) {
logger.warn('Server never seemed to start, and has now exited');
}
else {
logger.error('Server never seemed to start, and has probably crashed');
}
process.exit(code);
}
});
}
//# sourceMappingURL=start.js.map
"use strict";
var fs = require('fs');
var minimist = require('minimist');
var path = require('path');
var cli_1 = require('../cli');
var config_1 = require('../config');
var files_1 = require('../files');
var Opt = require('./');
var opts_1 = require('./opts');
var logger = new cli_1.Logger('status');
var prog = new cli_1.Program()
const fs = require("fs");
const minimist = require("minimist");
const path = require("path");
const cli_1 = require("../cli");
const config_1 = require("../config");
const files_1 = require("../files");
const Opt = require("./");
const opts_1 = require("./opts");
let logger = new cli_1.Logger('status');
let prog = new cli_1.Program()
.command('status', 'list the current available drivers')

@@ -17,3 +17,3 @@ .addOption(opts_1.Opts[Opt.OUT_DIR])

// stand alone runner
var argv = minimist(process.argv.slice(2), prog.getMinimistOptions());
let argv = minimist(process.argv.slice(2), prog.getMinimistOptions());
if (argv._[0] === 'status-run') {

@@ -30,4 +30,4 @@ prog.run(JSON.parse(JSON.stringify(argv)));

function status(options) {
var binaries = files_1.FileManager.setupBinaries();
var outputDir = config_1.Config.getSeleniumDir();
let binaries = files_1.FileManager.setupBinaries();
let outputDir = config_1.Config.getSeleniumDir();
if (options[Opt.OUT_DIR].value) {

@@ -50,10 +50,10 @@ if (path.isAbsolute(options[Opt.OUT_DIR].getString())) {

}
var downloadedBinaries = files_1.FileManager.downloadedBinaries(outputDir);
let downloadedBinaries = files_1.FileManager.downloadedBinaries(outputDir);
// log which binaries have been downloaded
for (var bin in downloadedBinaries) {
var downloaded = downloadedBinaries[bin];
var log = downloaded.name + ' ';
for (let bin in downloadedBinaries) {
let downloaded = downloadedBinaries[bin];
let log = downloaded.name + ' ';
log += downloaded.versions.length == 1 ? 'version available: ' : 'versions available: ';
for (var ver in downloaded.versions) {
var version = downloaded.versions[ver];
for (let ver in downloaded.versions) {
let version = downloaded.versions[ver];
log += version;

@@ -70,3 +70,3 @@ if (downloaded.binary.versionDefault() === version) {

// for binaries that are available for the operating system, show them here
for (var bin in binaries) {
for (let bin in binaries) {
if (downloadedBinaries[bin] == null) {

@@ -73,0 +73,0 @@ logger.info(binaries[bin].name + ' is not present');

import { Program } from '../cli';
export declare let program: Program;
export declare function clearBrowserFile(): void;
"use strict";
var AdmZip = require('adm-zip');
var child_process = require('child_process');
var fs = require('fs');
var minimist = require('minimist');
var os = require('os');
var path = require('path');
var q = require('q');
var rimraf = require('rimraf');
var binaries_1 = require('../binaries');
var cli_1 = require('../cli');
var config_1 = require('../config');
var files_1 = require('../files');
var Opt = require('./');
var initialize_1 = require('./initialize');
var opts_1 = require('./opts');
var logger = new cli_1.Logger('update');
var prog = new cli_1.Program()
const AdmZip = require("adm-zip");
const child_process = require("child_process");
const fs = require("fs");
const minimist = require("minimist");
const path = require("path");
const q = require("q");
const rimraf = require("rimraf");
const binaries_1 = require("../binaries");
const cli_1 = require("../cli");
const config_1 = require("../config");
const files_1 = require("../files");
const utils_1 = require("../utils");
const Opt = require("./");
const initialize_1 = require("./initialize");
const opts_1 = require("./opts");
let logger = new cli_1.Logger('update');
let prog = new cli_1.Program()
.command('update', 'install or update selected binaries')
.action(update)
.addOption(opts_1.Opts[Opt.OUT_DIR])
.addOption(opts_1.Opts[Opt.VERBOSE])
.addOption(opts_1.Opts[Opt.IGNORE_SSL])

@@ -27,13 +28,12 @@ .addOption(opts_1.Opts[Opt.PROXY])

.addOption(opts_1.Opts[Opt.CHROME])
.addOption(opts_1.Opts[Opt.GECKO])
.addOption(opts_1.Opts[Opt.ANDROID])
.addOption(opts_1.Opts[Opt.ANDROID_API_LEVELS])
.addOption(opts_1.Opts[Opt.ANDROID_ABIS])
.addOption(opts_1.Opts[Opt.ANDROID_ARCHITECTURES])
.addOption(opts_1.Opts[Opt.ANDROID_PLATFORMS])
.addOption(opts_1.Opts[Opt.ANDROID_ACCEPT_LICENSES]);
if (binaries_1.GeckoDriver.supports(os.type(), os.arch())) {
prog.addOption(opts_1.Opts[Opt.VERSIONS_GECKO]).addOption(opts_1.Opts[Opt.GECKO]);
}
if (os.type() === 'Darwin') {
if (config_1.Config.osType() === 'Darwin') {
prog.addOption(opts_1.Opts[Opt.IOS]);
}
if (os.type() === 'Windows_NT') {
if (config_1.Config.osType() === 'Windows_NT') {
prog.addOption(opts_1.Opts[Opt.IE]).addOption(opts_1.Opts[Opt.IE32]);

@@ -44,4 +44,5 @@ }

.addOption(opts_1.Opts[Opt.VERSIONS_APPIUM])
.addOption(opts_1.Opts[Opt.VERSIONS_ANDROID]);
if (os.type() === 'Windows_NT') {
.addOption(opts_1.Opts[Opt.VERSIONS_ANDROID])
.addOption(opts_1.Opts[Opt.VERSIONS_GECKO]);
if (config_1.Config.osType() === 'Windows_NT') {
prog.addOption(opts_1.Opts[Opt.VERSIONS_IE]);

@@ -51,3 +52,3 @@ }

// stand alone runner
var argv = minimist(process.argv.slice(2), prog.getMinimistOptions());
let argv = minimist(process.argv.slice(2), prog.getMinimistOptions());
if (argv._[0] === 'update-run') {

@@ -59,2 +60,3 @@ prog.run(JSON.parse(JSON.stringify(argv)));

}
let browserFile;
/**

@@ -65,10 +67,8 @@ * Parses the options and downloads binaries if they do not exist.

function update(options) {
var standalone = options[Opt.STANDALONE].getBoolean();
var chrome = options[Opt.CHROME].getBoolean();
var gecko = false;
if (binaries_1.GeckoDriver.supports(os.type(), os.arch())) {
gecko = options[Opt.GECKO].getBoolean();
}
var ie = false;
var ie32 = false;
let promises = [];
let standalone = options[Opt.STANDALONE].getBoolean();
let chrome = options[Opt.CHROME].getBoolean();
let gecko = options[Opt.GECKO].getBoolean();
let ie = false;
let ie32 = false;
if (options[Opt.IE]) {

@@ -80,11 +80,19 @@ ie = options[Opt.IE].getBoolean();

}
var android = options[Opt.ANDROID].getBoolean();
var ios = false;
let android = options[Opt.ANDROID].getBoolean();
let ios = false;
if (options[Opt.IOS]) {
ios = options[Opt.IOS].getBoolean();
}
var outputDir = config_1.Config.getSeleniumDir();
var android_api_levels = options[Opt.ANDROID_API_LEVELS].getString().split(',');
var android_abis = options[Opt.ANDROID_ABIS].getString().split(',');
var android_accept_licenses = options[Opt.ANDROID_ACCEPT_LICENSES].getBoolean();
let outputDir = options[Opt.OUT_DIR].getString();
try {
browserFile =
JSON.parse(fs.readFileSync(path.resolve(outputDir, 'update-config.json')).toString());
}
catch (err) {
browserFile = {};
}
let android_api_levels = options[Opt.ANDROID_API_LEVELS].getString().split(',');
let android_architectures = options[Opt.ANDROID_ARCHITECTURES].getString().split(',');
let android_platforms = options[Opt.ANDROID_PLATFORMS].getString().split(',');
let android_accept_licenses = options[Opt.ANDROID_ACCEPT_LICENSES].getBoolean();
if (options[Opt.OUT_DIR].getString()) {

@@ -99,6 +107,7 @@ if (path.isAbsolute(options[Opt.OUT_DIR].getString())) {

}
var ignoreSSL = options[Opt.IGNORE_SSL].getBoolean();
var proxy = options[Opt.PROXY].getString();
let ignoreSSL = options[Opt.IGNORE_SSL].getBoolean();
let proxy = options[Opt.PROXY].getString();
let verbose = options[Opt.VERBOSE].getBoolean();
// setup versions for binaries
var binaries = files_1.FileManager.setupBinaries(options[Opt.ALTERNATE_CDN].getString());
let binaries = files_1.FileManager.setupBinaries(options[Opt.ALTERNATE_CDN].getString());
binaries[binaries_1.StandAlone.id].versionCustom = options[Opt.VERSIONS_STANDALONE].getString();

@@ -118,38 +127,51 @@ binaries[binaries_1.ChromeDriver.id].versionCustom = options[Opt.VERSIONS_CHROME].getString();

if (standalone) {
var binary_1 = binaries[binaries_1.StandAlone.id];
files_1.FileManager.toDownload(binary_1, outputDir, proxy, ignoreSSL).then(function (value) {
if (value) {
files_1.Downloader.downloadBinary(binary_1, outputDir, proxy, ignoreSSL);
let binary = binaries[binaries_1.StandAlone.id];
updateBrowserFile(binary, outputDir);
promises.push(files_1.FileManager.downloadFile(binary, outputDir, proxy, ignoreSSL)
.then((downloaded) => {
if (!downloaded) {
logger.info(binary.name + ': file exists ' +
path.resolve(outputDir, binary.filename(config_1.Config.osType(), config_1.Config.osArch())));
logger.info(binary.name + ': ' + binary.versionCustom + ' up to date');
}
else {
logger.info(binary_1.name + ': file exists ' +
path.resolve(outputDir, binary_1.filename(os.type(), os.arch())));
logger.info(binary_1.name + ': v' + binary_1.versionCustom + ' up to date');
}
});
}));
}
if (chrome) {
var binary = binaries[binaries_1.ChromeDriver.id];
updateBinary(binary, outputDir, proxy, ignoreSSL);
let binary = binaries[binaries_1.ChromeDriver.id];
updateBrowserFile(binary, outputDir);
promises.push(updateBinary(binary, outputDir, proxy, ignoreSSL));
}
if (gecko) {
var binary = binaries[binaries_1.GeckoDriver.id];
updateBinary(binary, outputDir, proxy, ignoreSSL);
let binary = binaries[binaries_1.GeckoDriver.id];
updateBrowserFile(binary, outputDir);
promises.push(updateBinary(binary, outputDir, proxy, ignoreSSL));
}
if (ie) {
var binary = binaries[binaries_1.IEDriver.id];
binary.arch = os.arch(); // Win32 or x64
updateBinary(binary, outputDir, proxy, ignoreSSL);
let binary = binaries[binaries_1.IEDriver.id];
binary.arch = config_1.Config.osArch(); // Win32 or x64
updateBrowserFile(binary, outputDir);
promises.push(updateBinary(binary, outputDir, proxy, ignoreSSL));
}
if (ie32) {
var binary = binaries[binaries_1.IEDriver.id];
let binary = binaries[binaries_1.IEDriver.id];
binary.arch = 'Win32';
updateBinary(binary, outputDir, proxy, ignoreSSL);
updateBrowserFile(binary, outputDir);
promises.push(updateBinary(binary, outputDir, proxy, ignoreSSL));
}
if (android) {
var binary_2 = binaries[binaries_1.AndroidSDK.id];
var sdk_path = path.join(outputDir, binary_2.executableFilename(os.type()));
updateBinary(binary_2, outputDir, proxy, ignoreSSL).then(function () {
initialize_1.android(path.join(outputDir, binary_2.executableFilename(os.type())), android_api_levels, android_abis, android_accept_licenses, binaries[binaries_1.AndroidSDK.id].versionCustom, logger);
});
let binary = binaries[binaries_1.AndroidSDK.id];
let sdk_path = path.resolve(outputDir, binary.executableFilename(config_1.Config.osType()));
let oldAVDList;
promises.push(q.nfcall(fs.readFile, path.resolve(sdk_path, 'available_avds.json'))
.then((oldAVDs) => {
oldAVDList = oldAVDs;
}, () => {
oldAVDList = '[]';
})
.then(() => {
return updateBinary(binary, outputDir, proxy, ignoreSSL);
})
.then(() => {
initialize_1.android(path.resolve(outputDir, binary.executableFilename(config_1.Config.osType())), android_api_levels, android_architectures, android_platforms, android_accept_licenses, binaries[binaries_1.AndroidSDK.id].versionCustom, JSON.parse(oldAVDList), logger, verbose);
}));
}

@@ -162,19 +184,18 @@ if (ios) {

}
writeBrowserFile(outputDir);
return Promise.all(promises).then(() => { });
}
function updateBinary(binary, outputDir, proxy, ignoreSSL) {
return files_1.FileManager.toDownload(binary, outputDir, proxy, ignoreSSL).then(function (value) {
if (value) {
var deferred_1 = q.defer();
files_1.Downloader.downloadBinary(binary, outputDir, proxy, ignoreSSL, function (binary, outputDir, fileName) {
unzip(binary, outputDir, fileName);
deferred_1.resolve();
});
return deferred_1.promise;
}
else {
return files_1.FileManager
.downloadFile(binary, outputDir, proxy, ignoreSSL, (binary, outputDir, fileName) => {
unzip(binary, outputDir, fileName);
})
.then(downloaded => {
if (!downloaded) {
// The file did not have to download, we should unzip it.
logger.info(binary.name + ': file exists ' +
path.resolve(outputDir, binary.filename(os.type(), os.arch())));
var fileName = binary.filename(os.type(), os.arch());
path.resolve(outputDir, binary.filename(config_1.Config.osType(), config_1.Config.osArch())));
let fileName = binary.filename(config_1.Config.osType(), config_1.Config.osArch());
unzip(binary, outputDir, fileName);
logger.info(binary.name + ': v' + binary.versionCustom + ' up to date');
logger.info(binary.name + ': ' + binary.versionCustom + ' up to date');
}

@@ -185,4 +206,4 @@ });

// remove the previously saved file and unzip it
var osType = os.type();
var mv = path.join(outputDir, binary.executableFilename(osType));
let osType = config_1.Config.osType();
let mv = path.resolve(outputDir, binary.executableFilename(osType));
try {

@@ -201,3 +222,3 @@ fs.unlinkSync(mv);

if (fileName.slice(-4) == '.zip') {
var zip = new AdmZip(path.resolve(outputDir, fileName));
let zip = new AdmZip(path.resolve(outputDir, fileName));
zip.extractAllTo(outputDir, true);

@@ -210,3 +231,3 @@ }

// rename
fs.renameSync(path.join(outputDir, binary.zipContentName(osType)), mv);
fs.renameSync(path.resolve(outputDir, binary.zipContentName(osType)), mv);
// set permissions

@@ -219,4 +240,4 @@ if (osType !== 'Windows_NT') {

else {
fs.chmodSync(path.join(mv, 'tools', 'android'), '0755');
fs.chmodSync(path.join(mv, 'tools', 'emulator'), '0755');
fs.chmodSync(path.resolve(mv, 'tools', 'android'), '0755');
fs.chmodSync(path.resolve(mv, 'tools', 'emulator'), '0755');
}

@@ -227,3 +248,3 @@ }

logger.info('appium: installing appium');
var folder = path.join(outputDir, binary.filename());
let folder = path.resolve(outputDir, binary.filename());
try {

@@ -235,5 +256,39 @@ rimraf.sync(folder);

fs.mkdirSync(folder);
fs.writeFileSync(path.join(folder, 'package.json'), '{}');
child_process.spawn('npm', ['install', 'appium@' + binary.version()], { cwd: folder });
fs.writeFileSync(path.resolve(folder, 'package.json'), JSON.stringify({ scripts: { appium: 'appium' } }));
utils_1.spawn('npm', ['install', 'appium@' + binary.version()], null, { cwd: folder });
}
function updateBrowserFile(binary, outputDir) {
let currentDownload = path.resolve(outputDir, binary.executableFilename(config_1.Config.osType()));
// if browserFile[id] exists, we should update it
if (browserFile[binary.id()]) {
let binaryPath = browserFile[binary.id()];
if (binaryPath.last === currentDownload) {
return;
}
else {
binaryPath.last = currentDownload;
for (let bin of binaryPath.all) {
if (bin === currentDownload) {
return;
}
}
binaryPath.all.push(currentDownload);
}
}
else {
// The browserFile[id] does not exist / has not been downloaded previously.
// We should create the entry.
let binaryPath = { last: currentDownload, all: [currentDownload] };
browserFile[binary.id()] = binaryPath;
}
}
function writeBrowserFile(outputDir) {
let filePath = path.resolve(outputDir, 'update-config.json');
fs.writeFileSync(filePath, JSON.stringify(browserFile));
}
// for testing
function clearBrowserFile() {
browserFile = {};
}
exports.clearBrowserFile = clearBrowserFile;
//# sourceMappingURL=update.js.map

@@ -28,2 +28,12 @@ export interface ConfigFile {

static isLocalVersion: boolean;
static osArch_: string;
static osType_: string;
static noProxy_: any;
static httpsProxy_: any;
static httpProxy_: any;
static osArch(): string;
static osType(): string;
static noProxy(): string;
static httpProxy(): string;
static httpsProxy(): string;
static getConfigFile_(): string;

@@ -30,0 +40,0 @@ static getPackageFile_(): string;

"use strict";
var path = require('path');
var cli_1 = require('./cli');
var logger = new cli_1.Logger('config');
const os = require("os");
const path = require("path");
const cli_1 = require("./cli");
let logger = new cli_1.Logger('config');
/**

@@ -12,17 +13,30 @@ * The configuration for webdriver-manager

*/
var Config = (function () {
function Config() {
class Config {
static osArch() {
return Config.osArch_;
}
Config.getConfigFile_ = function () {
static osType() {
return Config.osType_;
}
static noProxy() {
return Config.noProxy_;
}
static httpProxy() {
return Config.httpProxy_;
}
static httpsProxy() {
return Config.httpsProxy_;
}
static getConfigFile_() {
return path.resolve(Config.dir, '..', Config.configFile);
};
Config.getPackageFile_ = function () {
}
static getPackageFile_() {
return path.resolve(Config.dir, '..', Config.packageFile);
};
Config.getSeleniumDir = function () {
}
static getSeleniumDir() {
return path.resolve(Config.dir, '..', '..', 'selenium/');
};
Config.getBaseDir = function () {
}
static getBaseDir() {
return path.resolve(Config.dir, '..', '..');
};
}
/**

@@ -32,5 +46,5 @@ * Get the binary versions from the configuration file.

*/
Config.binaryVersions = function () {
var configFile = require(Config.getConfigFile_());
var configVersions = {};
static binaryVersions() {
let configFile = require(Config.getConfigFile_());
let configVersions = {};
configVersions.selenium = configFile.webdriverVersions.selenium;

@@ -43,3 +57,3 @@ configVersions.chrome = configFile.webdriverVersions.chromedriver;

return configVersions;
};
}
/**

@@ -49,5 +63,5 @@ * Get the CDN urls from the configuration file.

*/
Config.cdnUrls = function () {
var configFile = require(Config.getConfigFile_());
var configCdnUrls = {};
static cdnUrls() {
let configFile = require(Config.getConfigFile_());
let configCdnUrls = {};
configCdnUrls.selenium = configFile.cdnUrls.selenium;

@@ -59,22 +73,26 @@ configCdnUrls.chrome = configFile.cdnUrls.chromedriver;

return configCdnUrls;
};
}
/**
* Get the package version.
*/
Config.getVersion = function () {
var packageFile = require(Config.getPackageFile_());
static getVersion() {
let packageFile = require(Config.getPackageFile_());
return packageFile.version;
};
Config.configFile = 'config.json';
Config.packageFile = 'package.json';
Config.nodeModuleName = 'webdriver-manager';
Config.cwd = process.cwd();
Config.parentPath = path.resolve(Config.cwd, '..');
Config.dir = __dirname;
Config.folder = Config.cwd.replace(Config.parentPath, '').substring(1);
Config.isProjectVersion = Config.folder === Config.nodeModuleName;
Config.isLocalVersion = false;
return Config;
}());
}
}
exports.Config = Config;
Config.configFile = 'config.json';
Config.packageFile = 'package.json';
Config.nodeModuleName = 'webdriver-manager';
Config.cwd = process.cwd();
Config.parentPath = path.resolve(Config.cwd, '..');
Config.dir = __dirname;
Config.folder = Config.cwd.replace(Config.parentPath, '').substring(1);
Config.isProjectVersion = Config.folder === Config.nodeModuleName;
Config.isLocalVersion = false;
Config.osArch_ = os.arch();
Config.osType_ = os.type();
Config.noProxy_ = process.env.NO_PROXY || process.env.no_proxy;
Config.httpsProxy_ = process.env.HTTPS_PROXY || process.env.https_proxy;
Config.httpProxy_ = process.env.HTTP_PROXY || process.env.http_proxy;
//# sourceMappingURL=config.js.map
"use strict";
var __extends = (this && this.__extends) || function (d, b) {
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
var binary_1 = require('../binaries/binary');
const binary_1 = require("../binaries/binary");
/**
* The downloaded binary is the binary with the list of versions downloaded.
*/
var DownloadedBinary = (function (_super) {
__extends(DownloadedBinary, _super);
function DownloadedBinary(binary) {
_super.call(this);
class DownloadedBinary extends binary_1.Binary {
constructor(binary) {
super();
this.versions = [];

@@ -20,8 +14,7 @@ this.binary = binary;

}
DownloadedBinary.prototype.id = function () {
id() {
return this.binary.id();
};
return DownloadedBinary;
}(binary_1.Binary));
}
}
exports.DownloadedBinary = DownloadedBinary;
//# sourceMappingURL=downloaded_binary.js.map

@@ -1,3 +0,1 @@

/// <reference types="q" />
import * as q from 'q';
import { Binary } from '../binaries/binary';

@@ -9,11 +7,2 @@ /**

/**
* Download the binary file.
* @param binary The binary of interest.
* @param outputDir The directory where files are downloaded and stored.
* @param opt_proxy The proxy for downloading files.
* @param opt_ignoreSSL To ignore SSL.
* @param opt_callback Callback method to be executed after the file is downloaded.
*/
static downloadBinary(binary: Binary, outputDir: string, opt_proxy?: string, opt_ignoreSSL?: boolean, opt_callback?: Function): void;
/**
* Resolves proxy based on values set

@@ -25,11 +14,17 @@ * @param fileUrl The url to download the file.

static resolveProxy_(fileUrl: string, opt_proxy?: string): string;
static httpHeadContentLength(fileUrl: string, opt_proxy?: string, opt_ignoreSSL?: boolean): q.Promise<any>;
/**
* Ceates the GET request for the file name.
* @param fileUrl The url to download the file.
* @param fileName The name of the file to download.
* @param opt_proxy The proxy to connect to to download files.
* @param opt_ignoreSSL To ignore SSL.
* Http get the file. Check the content length of the file before writing the file.
* If the content length does not match, remove it and download the file.
*
* @param binary The binary of interest.
* @param fileName The file name.
* @param outputDir The directory where files are downloaded and stored.
* @param contentLength The content length of the existing file.
* @param opt_proxy The proxy for downloading files.
* @param opt_ignoreSSL Should the downloader ignore SSL.
* @param opt_callback Callback method to be executed after the file is downloaded.
* @returns Promise<any> Resolves true = downloaded. Resolves false = not downloaded.
* Rejected with an error.
*/
static httpGetFile_(fileUrl: string, fileName: string, outputDir: string, opt_proxy?: string, opt_ignoreSSL?: boolean, callback?: Function): void;
static getFile(binary: Binary, fileUrl: string, fileName: string, outputDir: string, contentLength: number, opt_proxy?: string, opt_ignoreSSL?: boolean, callback?: Function): Promise<any>;
}
"use strict";
var fs = require('fs');
var os = require('os');
var path = require('path');
var q = require('q');
var request = require('request');
var url = require('url');
var cli_1 = require('../cli');
var logger = new cli_1.Logger('downloader');
const fs = require("fs");
const path = require("path");
const request = require("request");
const url = require("url");
const cli_1 = require("../cli");
const config_1 = require("../config");
let logger = new cli_1.Logger('downloader');
/**
* The file downloader.
*/
var Downloader = (function () {
function Downloader() {
}
class Downloader {
/**
* Download the binary file.
* @param binary The binary of interest.
* @param outputDir The directory where files are downloaded and stored.
* @param opt_proxy The proxy for downloading files.
* @param opt_ignoreSSL To ignore SSL.
* @param opt_callback Callback method to be executed after the file is downloaded.
*/
Downloader.downloadBinary = function (binary, outputDir, opt_proxy, opt_ignoreSSL, opt_callback) {
logger.info(binary.name + ': downloading version ' + binary.version());
var url = binary.url(os.type(), os.arch());
if (!url) {
logger.error(binary.name + ' v' + binary.version() + ' is not available for your system.');
return;
}
Downloader.httpGetFile_(url, binary.filename(os.type(), os.arch()), outputDir, opt_proxy, opt_ignoreSSL, function (filePath) {
if (opt_callback) {
opt_callback(binary, outputDir, filePath);
}
});
};
/**
* Resolves proxy based on values set

@@ -43,5 +19,5 @@ * @param fileUrl The url to download the file.

*/
Downloader.resolveProxy_ = function (fileUrl, opt_proxy) {
var protocol = url.parse(fileUrl).protocol;
var hostname = url.parse(fileUrl).hostname;
static resolveProxy_(fileUrl, opt_proxy) {
let protocol = url.parse(fileUrl).protocol;
let hostname = url.parse(fileUrl).hostname;
if (opt_proxy) {

@@ -54,10 +30,9 @@ return opt_proxy;

// the checks to see if it exists and equal to empty string is to help with testing
var noProxy = process.env.NO_PROXY || process.env.no_proxy;
let noProxy = config_1.Config.noProxy();
if (noProxy) {
// array of hostnames/domain names listed in the NO_PROXY environment variable
var noProxyTokens = noProxy.split(',');
let noProxyTokens = noProxy.split(',');
// check if the fileUrl hostname part does not end with one of the
// NO_PROXY environment variable's hostnames/domain names
for (var _i = 0, noProxyTokens_1 = noProxyTokens; _i < noProxyTokens_1.length; _i++) {
var noProxyToken = noProxyTokens_1[_i];
for (let noProxyToken of noProxyTokens) {
if (hostname.indexOf(noProxyToken) !== -1) {

@@ -70,43 +45,28 @@ return undefined;

if (protocol === 'https:') {
return process.env.HTTPS_PROXY || process.env.https_proxy || process.env.HTTP_PROXY ||
process.env.http_proxy;
return config_1.Config.httpsProxy() || config_1.Config.httpProxy();
}
else if (protocol === 'http:') {
return process.env.HTTP_PROXY || process.env.http_proxy;
return config_1.Config.httpProxy();
}
}
return null;
};
Downloader.httpHeadContentLength = function (fileUrl, opt_proxy, opt_ignoreSSL) {
var deferred = q.defer();
if (opt_ignoreSSL) {
logger.info('ignoring SSL certificate');
}
var options = {
method: 'HEAD',
url: fileUrl,
strictSSL: !opt_ignoreSSL,
rejectUnauthorized: !opt_ignoreSSL,
proxy: Downloader.resolveProxy_(fileUrl, opt_proxy)
};
var contentLength = 0;
request(options).on('response', function (response) {
contentLength = response.headers['content-length'];
deferred.resolve(contentLength);
});
return deferred.promise;
};
return undefined;
}
/**
* Ceates the GET request for the file name.
* @param fileUrl The url to download the file.
* @param fileName The name of the file to download.
* @param opt_proxy The proxy to connect to to download files.
* @param opt_ignoreSSL To ignore SSL.
* Http get the file. Check the content length of the file before writing the file.
* If the content length does not match, remove it and download the file.
*
* @param binary The binary of interest.
* @param fileName The file name.
* @param outputDir The directory where files are downloaded and stored.
* @param contentLength The content length of the existing file.
* @param opt_proxy The proxy for downloading files.
* @param opt_ignoreSSL Should the downloader ignore SSL.
* @param opt_callback Callback method to be executed after the file is downloaded.
* @returns Promise<any> Resolves true = downloaded. Resolves false = not downloaded.
* Rejected with an error.
*/
Downloader.httpGetFile_ = function (fileUrl, fileName, outputDir, opt_proxy, opt_ignoreSSL, callback) {
logger.info('curl -o ' + outputDir + '/' + fileName + ' ' + fileUrl);
var filePath = path.join(outputDir, fileName);
var file = fs.createWriteStream(filePath);
var contentLength = 0;
var options = {
static getFile(binary, fileUrl, fileName, outputDir, contentLength, opt_proxy, opt_ignoreSSL, callback) {
let filePath = path.resolve(outputDir, fileName);
let file;
let options = {
url: fileUrl,

@@ -124,47 +84,76 @@ // default Linux can be anywhere from 20-120 seconds

options.proxy = Downloader.resolveProxy_(fileUrl, opt_proxy);
if (options.url.indexOf('https://') === 0) {
options.url = options.url.replace('https://', 'http://');
if (url.parse(options.url).protocol === 'https:') {
options.url = options.url.replace('https:', 'http:');
}
}
request(options)
.on('response', function (response) {
if (response.statusCode !== 200) {
fs.unlinkSync(filePath);
logger.error('Error: Got code ' + response.statusCode + ' from ' + fileUrl);
}
contentLength = response.headers['content-length'];
})
.on('error', function (error) {
if (error.code === 'ETIMEDOUT') {
logger.error('Connection timeout downloading: ' + fileUrl);
logger.error('Default timeout is 4 minutes.');
}
else if (error.connect) {
logger.error('Could not connect to the server to download: ' + fileUrl);
}
logger.error(error);
fs.unlinkSync(filePath);
})
.pipe(file);
file.on('close', function () {
fs.stat(filePath, function (err, stats) {
if (err) {
logger.error('Error: Got error ' + err + ' from ' + fileUrl);
return;
let req = null;
let resContentLength;
return new Promise((resolve, reject) => {
req = request(options);
req.on('response', response => {
if (response.statusCode === 200) {
resContentLength = +response.headers['content-length'];
if (contentLength === resContentLength) {
// if the size is the same, do not download and stop here
response.destroy();
resolve(false);
}
else {
if (opt_proxy) {
let pathUrl = url.parse(options.url).path;
let host = url.parse(options.url).host;
let newFileUrl = url.resolve(opt_proxy, pathUrl);
logger.info('curl -o ' + outputDir + '/' + fileName + ' \'' + newFileUrl +
'\' -H \'host:' + host + '\'');
}
else {
logger.info('curl -o ' + outputDir + '/' + fileName + ' ' + fileUrl);
}
// only pipe if the headers are different length
file = fs.createWriteStream(filePath);
req.pipe(file);
file.on('close', () => {
fs.stat(filePath, (error, stats) => {
if (error) {
error.msg = 'Error: Got error ' + error + ' from ' + fileUrl;
reject(error);
}
if (stats.size != resContentLength) {
error.msg = 'Error: corrupt download for ' + fileName +
'. Please re-run webdriver-manager update';
fs.unlinkSync(filePath);
reject(error);
}
if (callback) {
callback(binary, outputDir, fileName);
}
resolve(true);
});
});
}
}
if (stats.size != contentLength) {
logger.error('Error: corrupt download for ' + fileName +
'. Please re-run webdriver-manager update');
fs.unlinkSync(filePath);
return;
else {
let error = new Error();
error.msg =
'Expected response code 200, received: ' + response.statusCode;
reject(error);
}
if (callback) {
callback(filePath);
});
req.on('error', error => {
if (error.code === 'ETIMEDOUT') {
error.msg = 'Connection timeout downloading: ' + fileUrl +
'. Default timeout is 4 minutes.';
}
else if (error.connect) {
error.msg = 'Could not connect to the server to download: ' + fileUrl;
}
reject(error);
});
})
.catch(error => {
logger.error(error.msg);
});
};
return Downloader;
}());
}
}
exports.Downloader = Downloader;
//# sourceMappingURL=downloader.js.map

@@ -1,3 +0,1 @@

/// <reference types="q" />
import * as q from 'q';
import { Binary, BinaryMap } from '../binaries';

@@ -61,8 +59,9 @@ import { DownloadedBinary } from './downloaded_binary';

/**
* Check to see if the binary version should be downloaded.
* Try to download the binary version.
* @param binary The binary of interest.
* @param outputDir The directory where files are downloaded and stored.
* @returns If the file should be downloaded.
* @returns Promise resolved to true for files downloaded, resolved to false for files not
* downloaded because they exist, rejected if there is an error.
*/
static toDownload<T extends Binary>(binary: T, outputDir: string, proxy: string, ignoreSSL: boolean): q.Promise<boolean>;
static downloadFile<T extends Binary>(binary: T, outputDir: string, opt_proxy?: string, opt_ignoreSSL?: boolean, callback?: Function): Promise<boolean>;
/**

@@ -69,0 +68,0 @@ * Removes the existing files found in the output directory that match the

"use strict";
var fs = require('fs');
var os = require('os');
var path = require('path');
var q = require('q');
var binaries_1 = require('../binaries');
var downloaded_binary_1 = require('./downloaded_binary');
var downloader_1 = require('./downloader');
var cli_1 = require('../cli');
var gecko_driver_1 = require('../binaries/gecko_driver');
var logger = new cli_1.Logger('file_manager');
const fs = require("fs");
const path = require("path");
const binaries_1 = require("../binaries");
const config_1 = require("../config");
const downloaded_binary_1 = require("./downloaded_binary");
const downloader_1 = require("./downloader");
const cli_1 = require("../cli");
const gecko_driver_1 = require("../binaries/gecko_driver");
let logger = new cli_1.Logger('file_manager');
/**

@@ -17,5 +16,3 @@ * The File Manager class is where the webdriver manager will compile a list of

*/
var FileManager = (function () {
function FileManager() {
}
class FileManager {
/**

@@ -25,3 +22,3 @@ * Create a directory if it does not exist.

*/
FileManager.makeOutputDirectory = function (outputDir) {
static makeOutputDirectory(outputDir) {
try {

@@ -34,3 +31,3 @@ fs.statSync(outputDir);

}
};
}
/**

@@ -43,5 +40,5 @@ * For the operating system, check against the list of operating systems that the

*/
FileManager.checkOS_ = function (osType, binary) {
for (var os_1 in binary.os) {
if (binaries_1.OS[os_1] == osType) {
static checkOS_(osType, binary) {
for (let os in binary.os) {
if (binaries_1.OS[os] == osType) {
return true;

@@ -51,3 +48,3 @@ }

return false;
};
}
/**

@@ -60,4 +57,4 @@ * For the operating system, create a list that includes the binaries

*/
FileManager.compileBinaries_ = function (osType, alternateCDN) {
var binaries = {};
static compileBinaries_(osType, alternateCDN) {
let binaries = {};
if (FileManager.checkOS_(osType, binaries_1.StandAlone)) {

@@ -82,3 +79,3 @@ binaries[binaries_1.StandAlone.id] = new binaries_1.StandAlone(alternateCDN);

return binaries;
};
}
/**

@@ -90,5 +87,5 @@ * Look up the operating system and compile a list of binaries that are available

*/
FileManager.setupBinaries = function (alternateCDN) {
return FileManager.compileBinaries_(os.type(), alternateCDN);
};
static setupBinaries(alternateCDN) {
return FileManager.compileBinaries_(config_1.Config.osType(), alternateCDN);
}
/**

@@ -99,3 +96,3 @@ * Get the list of existing files from the output directory

*/
FileManager.getExistingFiles = function (outputDir) {
static getExistingFiles(outputDir) {
try {

@@ -107,3 +104,3 @@ return fs.readdirSync(outputDir);

}
};
}
/**

@@ -117,9 +114,9 @@ * For the binary, operating system, and system architecture, look through

*/
FileManager.downloadedVersions_ = function (binary, osType, arch, existingFiles) {
var versions = [];
for (var existPos in existingFiles) {
var existFile = existingFiles[existPos];
static downloadedVersions_(binary, osType, arch, existingFiles) {
let versions = [];
for (let existPos in existingFiles) {
let existFile = existingFiles[existPos];
// use only files that have a prefix and suffix that we care about
if (existFile.indexOf(binary.prefix()) === 0) {
var editExistFile = existFile.replace(binary.prefix(), '');
let editExistFile = existFile.replace(binary.prefix(), '');
// if the suffix matches the executable suffix, add it

@@ -141,6 +138,6 @@ if (binary.suffix(osType, arch) === binary.executableSuffix(osType)) {

}
var downloadedBinary = new downloaded_binary_1.DownloadedBinary(binary);
let downloadedBinary = new downloaded_binary_1.DownloadedBinary(binary);
downloadedBinary.versions = versions;
return downloadedBinary;
};
}
/**

@@ -151,10 +148,10 @@ * Finds all the downloaded binary versions stored in the output directory.

*/
FileManager.downloadedBinaries = function (outputDir) {
var ostype = os.type();
var arch = os.arch();
var binaries = FileManager.setupBinaries();
var existingFiles = FileManager.getExistingFiles(outputDir);
var downloaded = {};
for (var bin in binaries) {
var binary = FileManager.downloadedVersions_(binaries[bin], ostype, arch, existingFiles);
static downloadedBinaries(outputDir) {
let ostype = config_1.Config.osType();
let arch = config_1.Config.osArch();
let binaries = FileManager.setupBinaries();
let existingFiles = FileManager.getExistingFiles(outputDir);
let downloaded = {};
for (let bin in binaries) {
let binary = FileManager.downloadedVersions_(binaries[bin], ostype, arch, existingFiles);
if (binary != null) {

@@ -165,44 +162,44 @@ downloaded[binary.id()] = binary;

return downloaded;
};
}
/**
* Check to see if the binary version should be downloaded.
* Try to download the binary version.
* @param binary The binary of interest.
* @param outputDir The directory where files are downloaded and stored.
* @returns If the file should be downloaded.
* @returns Promise resolved to true for files downloaded, resolved to false for files not
* downloaded because they exist, rejected if there is an error.
*/
FileManager.toDownload = function (binary, outputDir, proxy, ignoreSSL) {
var osType = os.type();
var osArch = os.arch();
var filePath;
var readData;
var deferred = q.defer();
var downloaded = FileManager.downloadedBinaries(outputDir);
if (downloaded[binary.id()]) {
var downloadedBinary = downloaded[binary.id()];
var versions = downloadedBinary.versions;
var version = binary.version();
for (var index in versions) {
var v = versions[index];
if (v === version) {
filePath = path.resolve(outputDir, binary.filename(osType, osArch));
readData = fs.readFileSync(filePath);
// we have the version, verify it is the correct file size
var contentLength = downloader_1.Downloader.httpHeadContentLength(binary.url(osType, osArch), proxy, ignoreSSL);
return contentLength.then(function (value) {
if (value == readData.length) {
return false;
}
else {
logger.warn(path.basename(filePath) + ' expected length ' + value + ', found ' +
readData.length);
logger.warn('removing file: ' + filePath);
return true;
}
});
static downloadFile(binary, outputDir, opt_proxy, opt_ignoreSSL, callback) {
return new Promise((resolve, reject) => {
let filePath = path.resolve(outputDir, binary.filename(config_1.Config.osType(), config_1.Config.osArch()));
let fileUrl = binary.url(config_1.Config.osType(), config_1.Config.osArch());
let fileName = binary.filename(config_1.Config.osType(), config_1.Config.osArch());
let outDir = config_1.Config.getSeleniumDir();
let downloaded = FileManager.downloadedBinaries(outputDir);
let contentLength = 0;
// If we have downloaded the file before, check the content length
if (downloaded[binary.id()]) {
let downloadedBinary = downloaded[binary.id()];
let versions = downloadedBinary.versions;
let version = binary.version();
for (let index in versions) {
let v = versions[index];
if (v === version) {
contentLength = fs.statSync(filePath).size;
return downloader_1.Downloader
.getFile(binary, fileUrl, fileName, outputDir, contentLength, opt_proxy, opt_ignoreSSL, callback)
.then(downloaded => {
resolve(downloaded);
});
}
}
}
}
deferred.resolve(true);
return deferred.promise;
};
// We have not downloaded it before, or the version does not exist. Use the default content
// length of zero and download the file.
downloader_1.Downloader
.getFile(binary, fileUrl, fileName, outputDir, contentLength, opt_proxy, opt_ignoreSSL, callback)
.then(downloaded => {
resolve(downloaded);
});
});
}
/**

@@ -213,3 +210,3 @@ * Removes the existing files found in the output directory that match the

*/
FileManager.removeExistingFiles = function (outputDir) {
static removeExistingFiles(outputDir) {
try {

@@ -222,3 +219,3 @@ fs.statSync(outputDir);

}
var existingFiles = FileManager.getExistingFiles(outputDir);
let existingFiles = FileManager.getExistingFiles(outputDir);
if (existingFiles.length === 0) {

@@ -228,8 +225,8 @@ logger.warn('no files found in path ' + outputDir);

}
var binaries = FileManager.setupBinaries();
existingFiles.forEach(function (file) {
for (var binPos in binaries) {
var bin = binaries[binPos];
let binaries = FileManager.setupBinaries();
existingFiles.forEach((file) => {
for (let binPos in binaries) {
let bin = binaries[binPos];
if (file.indexOf(bin.prefix()) !== -1) {
bin.remove(path.join(outputDir, file));
bin.remove(path.resolve(outputDir, file));
logger.info('removed ' + file);

@@ -239,6 +236,13 @@ }

});
};
return FileManager;
}());
let updateConfig = path.resolve(outputDir, 'update-config.json');
try {
fs.unlinkSync(updateConfig);
logger.info('removed update-config.json');
}
catch (e) {
return;
}
}
}
exports.FileManager = FileManager;
//# sourceMappingURL=file_manager.js.map

@@ -5,5 +5,5 @@ "use strict";

}
__export(require('./downloaded_binary'));
__export(require('./downloader'));
__export(require('./file_manager'));
__export(require("./downloaded_binary"));
__export(require("./downloader"));
__export(require("./file_manager"));
//# sourceMappingURL=index.js.map
"use strict";
var minimist = require('minimist');
var cli_1 = require('./cli');
var clean = require('./cmds/clean');
var start = require('./cmds/start');
var status = require('./cmds/status');
var update = require('./cmds/update');
var commandline = new cli_1.Cli()
.usage('webdriver-manager <command> [options]')
.program(clean.program)
.program(start.program)
.program(status.program)
.program(update.program);
var minimistOptions = commandline.getMinimistOptions();
var argv = minimist(process.argv.slice(2), minimistOptions);
var cmd = argv._;
if (commandline.programs[cmd[0]]) {
const minimist = require("minimist");
const cli_instance_1 = require("./cli_instance");
let minimistOptions = cli_instance_1.cli.getMinimistOptions();
let argv = minimist(process.argv.slice(2), minimistOptions);
let cmd = argv._;
if (cli_instance_1.cli.programs[cmd[0]]) {
if (cmd[0] === 'help') {
commandline.printHelp();
cli_instance_1.cli.printHelp();
}
else if (cmd[1] === 'help' || argv['help'] || argv['h']) {
commandline.programs[cmd[0]].printHelp();
cli_instance_1.cli.programs[cmd[0]].printHelp();
}
else {
commandline.programs[cmd[0]].run(JSON.parse(JSON.stringify(argv)));
cli_instance_1.cli.programs[cmd[0]].run(JSON.parse(JSON.stringify(argv)));
}
}
else {
commandline.printHelp();
cli_instance_1.cli.printHelp();
}
exports.cli = commandline;
//# sourceMappingURL=webdriver.js.map
{
"name": "webdriver-manager",
"version": "11.0.0-beta.0",
"version": "11.0.0",
"description": "A selenium server and browser driver manager for your end to end tests.",
"scripts": {
"check_format": "gulp format:enforce",
"format": "gulp format",
"prepublish": "gulp prepublish",
"test": "gulp test"
"test": "gulp test",
"test_unit": "gulp test:unit",
"test_travis": "gulp test:headless"
},

@@ -37,3 +41,3 @@ "keywords": [

"q": "^1.4.1",
"request": "^2.69.0",
"request": "^2.78.0",
"rimraf": "^2.5.2",

@@ -45,12 +49,13 @@ "semver": "^5.3.0"

"@types/chalk": "^0.4.28",
"@types/form-data": "^0.0.32",
"@types/form-data": "^0.0.33",
"@types/glob": "^5.0.29",
"@types/ini": "^1.3.28",
"@types/jasmine": "^2.2.32",
"@types/jasmine": "^2.5.37",
"@types/minimatch": "^2.0.28",
"@types/minimist": "^1.1.28",
"@types/node": "^6.0.37",
"@types/node": "^6.0.46",
"@types/q": "^0.0.32",
"@types/request": "^0.0.32",
"@types/request": "^0.0.36",
"@types/rimraf": "^0.0.28",
"@types/selenium-webdriver": "^2.53.35",
"@types/semver": "^5.3.30",

@@ -62,4 +67,5 @@ "clang-format": "^1.0.35",

"run-sequence": "^1.1.5",
"typescript": "^2.0.0"
"selenium-webdriver": "2.53.1",
"typescript": "^2.1.1"
}
}

@@ -1,5 +0,175 @@

# 11.0.0-beta.0
# 11.0.0
Update to Selenium Standalone version 3.0.1.
## Breaking Change:
- Requires node 6 since node 6 is in long term support. See (node LTS Schedule)[https://github.com/nodejs/LTS#lts-schedule].
## Features
- ([b5638ef](https://github.com/angular/webdriver-manager/commit/b5638ef0861843e1d42220af515adc3e03a2b65a))
feat(update): on update, write full binary paths to file (#140)
- Adding back in curl calls, these were removed on the new
`Downloader.getFile`. Add curl call to reflect proxies.
- Fix output dir to read from update's options instead of Config
- Feature will help directConnect users for Protractor. The file
will keep track of the last binary version as well as all other
binaries downloaded.
The file will be created in the output directory. By default this is
`selenium/update-config.json`. On `clean` this file will be removed.
```
webdriver-manager update --versions.chrome=2.20 --standalone=false
--gecko=false
```
file created:
```
{
"chrome": {
"last": "/opt/src/webdriver-manager/selenium/chromedriver_2.20",
"all": ["/opt/src/webdriver-manager/selenium/chromedriver_2.20"]
}
}
```
then the user wants to use 2.25:
```
webdriver-manager update --versions.chrome=2.25 --standalone=false
--gecko=false
```
file created:
```
{
"chrome": {
"last": "/opt/src/webdriver-manager/selenium/chromedriver_2.25",
"all": ["/opt/src/webdriver-manager/selenium/chromedriver_2.20",
"/opt/src/webdriver-manager/selenium/chromedriver_2.25"]
}
}
```
- ([473ab3e](https://github.com/angular/webdriver-manager/commit/473ab3e40c44468bb79e2a23d7b12753cf6e2b4d))
feat(android): match android arch to os.arch (#164)
The default was x86-64, but x86 cannot be emulated on ARM. This makes more sense
- ([c864c9a](https://github.com/angular/webdriver-manager/commit/c864c9af35514a4b5bf8a1d82b4339b39e5ac574))
feat(shutdown): do not error if you try to shutdown a server which is already off (#162)
When scripting, you might want to defensively run a `shutdown` command. If the shutdown fails
because the server is already off, you don't care. If it fails for another reason, you do care.
So I made trying to shutdown a server which is already off just a warning. I added a flag in case
you want the old behavior though.
- ([338fffd](https://github.com/angular/webdriver-manager/commit/338fffddf68ac2767aa5c226ba5374451b9e5308))
feat(quiet/verbose): add `--quiet` and `--verbose` flags to control the level of output (#156)
I added the `--quiet` flag for cases like:
where currently the start --detach; ./tests.sh; webdriver-manager shutdown`
selenium server output will get mixed in with other output.
I also added the `--verbose` flag for `webdriver-manager update` in case you *really* wanted to
see all the output which gets eaten by using `--android-accept-licenses`.
- ([91e36a3](https://github.com/angular/webdriver-manager/commit/91e36a3e56e712af2c104eafc45eeeba5997ad6a))
feat(android on windows): Support android VMs on windows (#154)
Closes https://github.com/angular/webdriver-manager/issues/51
- ([d533b03](https://github.com/angular/webdriver-manager/commit/d533b0389ac8a43b815890a644fdb9aa403ec769))
feat(start android): extend the --detach flag to wait for appium/android (#141)
## Bug fixes
- ([26586f1](https://github.com/angular/webdriver-manager/commit/26586f1b341e02229d73d40827a9c1af2197ebb3))
fix(start): wait for emulated android to really be ready before signaling (#161)
Before, we were just waiting for the emulator to be running, rather than waiting for the OS to be
booted up and ready to instance chrome.
While I was doing that I moved some stuff into `lib/utils.ts` since I felt like too much of
`lib/cmds/start.ts` was being devoted to this one feature.
Also closes https://github.com/angular/webdriver-manager/issues/166
- ([a7c6eb5](https://github.com/angular/webdriver-manager/commit/a7c6eb5d3d1caed2afea1ef896753d53f4ea14ed))
fix(update/android): 2a1505f broke android
- ([3ee3e1a](https://github.com/angular/webdriver-manager/commit/3ee3e1a328087cb8c5bf869e00a325cfdeb80f6d))
fix(fs): path.join does not handle absolute paths as desired (#152)
- ([deead0f](https://github.com/angular/webdriver-manager/commit/deead0fc55ecd00b282aedc234592181746a307c))
fix(downloader): destroy the request after receiving the header (#144)
Otherwise we’ll won’t terminate until the whole file was downloaded, even though we don’t need it.
- ([c16bf90](https://github.com/angular/webdriver-manager/commit/c16bf9053fc90e4b5e89ab867c514d0622ab0716))
chore(es6): allow to use es6 promises (#160)
- with node 6 on LTS, we can update the tsconfig to es6
- update travis tests to use node 6 and 7
# 10.2.8
## Features
- ([1f9713a](https://github.com/angular/webdriver-manager/commit/1f9713aff1e7d44de900ed3c74abac532d3e25ff))
feat(start and shutdown): Added `--detach` option for `start` command and new `shutdown` command
(#130)
- ([88cf46b](https://github.com/angular/webdriver-manager/commit/88cf46b715250559ba8a726370a83c5c2f4daed1))
feat(version): have a way to get the package version (#136)
closes #119
## Bug fixes
- ([5966b6a](https://github.com/angular/webdriver-manager/commit/5966b6ac7329878e9e16f5b1b88261c5b7f7e438))
fix(cli): fix setting flag to false (#135)
- This fixes `webdriver-manager update --gecko=false`
- This does not fix `webdriver-manager update --gecko=0`. Minimist interprets 0 as true.
- Add options and programs unit tests
closes #110
- ([35676ee](https://github.com/angular/webdriver-manager/commit/35676ee70c816d43f045fa33d02e41bf502a3a14))
fix(gecko): follow redirects for content-length (#133)
# 10.2.7
## Features
- ([66776a0](https://github.com/angular/webdriver-manager/commit/66776a0edc97e0b2718f2fdf4eeb2c2c8b40df73))
feat(start): add way to programmatically detect when the selenium server is running (#120)
## Bug fixes
- ([dc2f9f9](https://github.com/angular/webdriver-manager/commit/dc2f9f99ebd9675b02addf06732a4d8d348046bc))
fix(cli): fix default option values, boolean and string handling (#110) (#122)
- default option values initialize properly for `minimist`
- user-supplied boolean-type option values respected
- string-type option values are always strings
- simplify boolean-type option value access
- ([88d6105](https://github.com/angular/webdriver-manager/commit/88d6105f538f075968c152935131bf19bf289532))
fix(gecko): Update geckodriver to 0.11.0 and fix suffixes. (#128)
Fixes #111
- ([707e015](https://github.com/angular/webdriver-manager/commit/707e015737ee3ca4b26b6d89979251f8d8c2d11d))
fix(android): fixed four things for android: (#116)
- Make appium default to 1.6.0 (Android N didn't work on 1.5.x)
- Make virtual devices default to `google_apis`
- Don't delete old virtual devices on update
- Update documentation
- ([9fe4b22](https://github.com/angular/webdriver-manager/commit/9fe4b226d58fbbce2e9cf49df58f45dee7f13cf2))
fix typo in webdriver-manager/spec/files (#125)
# 10.2.6
## Features
- ([f892ec4](https://github.com/angular/webdriver-manager/commit/f892ec41c09c210527998c966a69edc081cf418e))
chore(chromedriver): update chromedriver version to 2.25
# 10.2.5

@@ -6,0 +176,0 @@

{
"webdriverVersions": {
"selenium": "3.0.1",
"chromedriver": "2.24",
"geckodriver": "v0.9.0",
"selenium": "2.53.1",
"chromedriver": "2.25",
"geckodriver": "v0.11.1",
"iedriver": "2.53.1",
"androidsdk": "24.4.1",
"appium": "1.5.3"
"appium": "1.6.0"
},

@@ -10,0 +10,0 @@ "cdnUrls": {

'use strict';
var path = require('path');
var gulp = require('gulp');

@@ -7,21 +8,23 @@ var runSequence = require('run-sequence');

var runSpawn = function(done, task, opt_arg) {
opt_arg = typeof opt_arg !== 'undefined' ? opt_arg : [];
var child = spawn(task, opt_arg, {stdio: 'inherit'});
var runSpawn = function(task, args, done) {
done = done || function() {};
var child = spawn(task, args, {stdio: 'inherit'});
var running = false;
child.on('close', function() {
child.on('close', function(code) {
if (!running) {
running = true;
done();
done(code);
}
});
child.on('error', function() {
child.on('error', function(err) {
if (!running) {
console.error('gulp encountered a child error');
running = true;
done();
done(err || 1);
}
});
return child;
};
// Build
gulp.task('copy', function() {

@@ -32,6 +35,8 @@ return gulp.src(['config.json', 'package.json'])

var tsGlobs = ['lib/**/*.ts', '*spec/**/*.ts'];
gulp.task('format:enforce', () => {
const format = require('gulp-clang-format');
const clangFormat = require('clang-format');
return gulp.src(['lib/**/*.ts']).pipe(
return gulp.src(tsGlobs).pipe(
format.checkFormat('file', clangFormat, {verbose: true, fail: true}));

@@ -43,3 +48,3 @@ });

const clangFormat = require('clang-format');
return gulp.src(['lib/**/*.ts'], { base: '.' }).pipe(
return gulp.src(tsGlobs, { base: '.' }).pipe(
format.format('file', clangFormat)).pipe(gulp.dest('.'));

@@ -49,16 +54,55 @@ });

gulp.task('tsc', function(done) {
runSpawn(done, 'node', ['node_modules/typescript/bin/tsc']);
runSpawn(process.execPath, ['node_modules/typescript/bin/tsc'], done);
});
gulp.task('prepublish', function(done) {
runSequence('format', 'tsc', 'copy', done);
runSequence('tsc', 'copy', done);
});
gulp.task('default',['prepublish']);
gulp.task('build',['prepublish']);
gulp.task('default', ['prepublish']);
gulp.task('build', ['prepublish']);
gulp.task('test', ['build'], function(done) {
var opt_arg = [];
opt_arg.push('node_modules/jasmine/bin/jasmine.js');
runSpawn(done, 'node', opt_arg);
// Command line commands
gulp.task('update', ['build'], function(done) {
runSpawn(process.execPath, ['bin/webdriver-manager', 'update', '--android',
'--android-accept-licenses'], done);
});
gulp.task('start', ['build', 'shutdown'], function(done) {
runSpawn(process.execPath, ['bin/webdriver-manager', 'start', '--detach', '--seleniumPort',
'4444', '--android', '--appium-port', '4723', '--quiet'], done);
});
gulp.task('start:headless', ['build', 'shutdown'], function(done) {
runSpawn(process.execPath, ['bin/webdriver-manager', 'start', '--detach', '--seleniumPort',
'4444', '--android', '--appium-port', '4723', '--quiet', '--avds', 'none'], done);
});
gulp.task('shutdown', ['build'], function(done) {
runSpawn(process.execPath, ['bin/webdriver-manager', 'shutdown'], done);
});
// Test
gulp.task('test:unit', ['format', 'build'], function(done) {
runSpawn(process.execPath, ['node_modules/jasmine/bin/jasmine.js'], done);
});
gulp.task('test:e2e:inner', ['build'], function(done) {
runSpawn(process.execPath, ['node_modules/jasmine/bin/jasmine.js', 'JASMINE_CONFIG_PATH=' +
path.join('e2e_spec', 'support', 'jasmine.json')], done);
});
gulp.task('test:e2e:inner:headless', ['build'], function(done) {
runSpawn(process.execPath, ['node_modules/jasmine/bin/jasmine.js', 'JASMINE_CONFIG_PATH=' +
path.join('e2e_spec', 'support', 'headless.json')], done);
});
gulp.task('test:e2e:no_update', function(done) {
runSequence('start', 'test:e2e:inner', 'shutdown', done);
});
gulp.task('test:e2e', function(done) {
runSequence('update', 'test:e2e:no_update', done);
});
gulp.task('test:e2e:headless', function(done) {
runSequence('update', 'start:headless', 'test:e2e:inner:headless', 'shutdown', done);
});
gulp.task('test', ['test:unit', 'test:e2e']);
gulp.task('test:no_update', ['test:unit', 'test:e2e:no_update']);
gulp.task('test:headless', ['test:unit', 'test:e2e:headless']);

@@ -19,13 +19,22 @@ Mobile Browser Support

```
webdriver-manager update --android --android-api-levels 23 --android-abis armeabi-v7a
webdriver-manager update --android --android-api-levels 24 --android-archs armeabi-v7a
```
Valid values for the `--android-api-levels` flag are: `2`, `3`, `4`, `5`, ..., `24`
Valid values for the `--android-api-levels` flag are: `24` and `25`. You *can* specify a lower
API level, but the virtual device create will not have Chrome installed.
Valid values for the `--android-abi` flag are: `x86_64`, `armeabi-v7a`, `x86`, `mips`,
`android-wear/x86_64`, `android-wear/armeabi-v7a`, `android-wear/x86`, `android-wear/mips`,
`android-tv/x86_64`, `android-tv/armeabi-v7a`, `android-tv/x86`, `android-tv/mips`,
`google_apis/x86_64`, `google_apis/armeabi-v7a`, `google_apis/x86`, `google_apis/mips`
Valid values for the `--android-archs` flag are:
* `x86`
* `x86_64`
* `armeabi-v7a` (or possibly some other 32-bit ARM architecture)
* `arm64-v8a` (or possibly some other 64-bit ARM architecture)
* `mips`
Note that we always use the `google_apis/*` ABIs, since only those versions comes with chrome. So
if you specify `--android-archs x86_64`, this tool will use the ABI `google_apis/x86_64`. If you
wish to use a different platform (i.e. `android-wear`, `android-tv` or `default`), you can do so
with the `--android-platforms` flag. But only the `google_apis` version comes with Chrome.
As a practical matter, if you don't want to manually accept the license agreements, you can use

@@ -50,2 +59,12 @@ `--android-accept-licenses`, which will accept them on your behalf.

### "Welcome to Chome" UI
Every time appium boots up chrome, a "Welcome to Chrome" dialog will pop up. It won't interfere
with your tests, since the webpage still renders underneath the dialog, and those tests access the
webpage directly. However, you won't be able to watch what's going on unless you manually click
"Accept & Continue". Also, since webdriver boots up a fresh chrome instance every time, chrome
won't remember that you've clicked "Accept & Continue" between tests. Any time you want to actually
watch the test as it's run, you'll need to click through the dialog again. For now, there is no
good way around this sadly (https://github.com/appium/appium/issues/6618).
iOS

@@ -52,0 +71,0 @@ ---------

{
"name": "webdriver-manager",
"version": "11.0.0-beta.0",
"version": "11.0.0",
"description": "A selenium server and browser driver manager for your end to end tests.",
"scripts": {
"check_format": "gulp format:enforce",
"format": "gulp format",
"prepublish": "gulp prepublish",
"test": "gulp test"
"test": "gulp test",
"test_unit": "gulp test:unit",
"test_travis": "gulp test:headless"
},

@@ -37,3 +41,3 @@ "keywords": [

"q": "^1.4.1",
"request": "^2.69.0",
"request": "^2.78.0",
"rimraf": "^2.5.2",

@@ -45,12 +49,13 @@ "semver": "^5.3.0"

"@types/chalk": "^0.4.28",
"@types/form-data": "^0.0.32",
"@types/form-data": "^0.0.33",
"@types/glob": "^5.0.29",
"@types/ini": "^1.3.28",
"@types/jasmine": "^2.2.32",
"@types/jasmine": "^2.5.37",
"@types/minimatch": "^2.0.28",
"@types/minimist": "^1.1.28",
"@types/node": "^6.0.37",
"@types/node": "^6.0.46",
"@types/q": "^0.0.32",
"@types/request": "^0.0.32",
"@types/request": "^0.0.36",
"@types/rimraf": "^0.0.28",
"@types/selenium-webdriver": "^2.53.35",
"@types/semver": "^5.3.30",

@@ -62,4 +67,5 @@ "clang-format": "^1.0.35",

"run-sequence": "^1.1.5",
"typescript": "^2.0.0"
"selenium-webdriver": "2.53.1",
"typescript": "^2.1.1"
}
}

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc