webdriver-manager
Advanced tools
Comparing version 12.0.4 to 12.0.5
@@ -27,4 +27,2 @@ import { ConfigSource } from './config_source'; | ||
cdn: string; | ||
opt_ignoreSSL: boolean; | ||
opt_proxy: string; | ||
name: string; | ||
@@ -53,6 +51,4 @@ versionDefault: string; | ||
* @param {string} version The version we are looking for. This could also be 'latest'. | ||
* @param {opt_proxy} string Option to get proxy URL. | ||
* @param {opt_ignoreSSL} boolean Option to ignore SSL. | ||
*/ | ||
getUrl(version?: string, opt_proxy?: string, opt_ignoreSSL?: boolean): Promise<BinaryUrl>; | ||
getUrl(version?: string): Promise<BinaryUrl>; | ||
/** | ||
@@ -59,0 +55,0 @@ * Gets the list of available versions available based on the xml. If no XML exists, return an |
@@ -46,12 +46,4 @@ "use strict"; | ||
* @param {string} version The version we are looking for. This could also be 'latest'. | ||
* @param {opt_proxy} string Option to get proxy URL. | ||
* @param {opt_ignoreSSL} boolean Option to ignore SSL. | ||
*/ | ||
getUrl(version, opt_proxy, opt_ignoreSSL) { | ||
this.opt_proxy = opt_proxy == undefined ? this.opt_proxy : opt_proxy; | ||
this.opt_ignoreSSL = opt_ignoreSSL == undefined ? this.opt_ignoreSSL : opt_ignoreSSL; | ||
if (this.configSource) { | ||
this.configSource.opt_proxy = this.opt_proxy; | ||
this.configSource.opt_ignoreSSL = this.opt_ignoreSSL; | ||
} | ||
getUrl(version) { | ||
if (this.alternativeDownloadUrl != null) { | ||
@@ -58,0 +50,0 @@ return Promise.resolve({ url: '', version: '' }); |
@@ -5,4 +5,2 @@ export declare abstract class ConfigSource { | ||
out_dir: string; | ||
opt_ignoreSSL: boolean; | ||
opt_proxy: string; | ||
abstract getUrl(version: string): Promise<{ | ||
@@ -9,0 +7,0 @@ url: string; |
@@ -35,10 +35,12 @@ "use strict"; | ||
let content = this.readResponse(); | ||
if (content != null) { | ||
if (content) { | ||
return Promise.resolve(content); | ||
} | ||
return this.requestXml().then(text => { | ||
let xml = this.convertXml2js(text); | ||
fs.writeFileSync(fileName, text); | ||
return xml; | ||
}); | ||
else { | ||
return this.requestXml().then(text => { | ||
let xml = this.convertXml2js(text); | ||
fs.writeFileSync(fileName, text); | ||
return xml; | ||
}); | ||
} | ||
} | ||
@@ -51,6 +53,11 @@ readResponse() { | ||
let now = Date.now(); | ||
// Ignore validating the cache OR if we are validating the cache, make | ||
// it is within the cache time. | ||
// 60 minutes * 60 seconds / minute * 1000 ms / second | ||
if (now - (60 * 60 * 1000) < timestamp) { | ||
if (config_1.Config.runCommand === 'start' || (now - (60 * 60 * 1000) < timestamp)) { | ||
return this.convertXml2js(contents); | ||
} | ||
else { | ||
return null; | ||
} | ||
} | ||
@@ -64,4 +71,2 @@ catch (err) { | ||
let options = http_utils_1.HttpUtils.initOptions(this.xmlUrl); | ||
options = http_utils_1.HttpUtils.optionsSSL(options, this.opt_ignoreSSL); | ||
options = http_utils_1.HttpUtils.optionsProxy(options, this.xmlUrl, this.opt_proxy); | ||
let req = request(options); | ||
@@ -123,3 +128,3 @@ req.on('response', response => { | ||
let content = this.readResponse(); | ||
if (content != null) { | ||
if (content) { | ||
return Promise.resolve(JSON.parse(content)); | ||
@@ -138,4 +143,2 @@ } | ||
let options = http_utils_1.HttpUtils.initOptions(this.jsonUrl); | ||
options = http_utils_1.HttpUtils.optionsSSL(options, this.opt_ignoreSSL); | ||
options = http_utils_1.HttpUtils.optionsProxy(options, this.jsonUrl, this.opt_proxy); | ||
options = http_utils_1.HttpUtils.optionsHeader(options, 'Host', 'api.github.com'); | ||
@@ -170,6 +173,8 @@ options = http_utils_1.HttpUtils.optionsHeader(options, 'User-Agent', 'request'); | ||
let now = Date.now(); | ||
// 60 minutes * 60 seconds / minute * 1000 ms / second | ||
if (now - (60 * 60 * 1000) < timestamp) { | ||
if (config_1.Config.runCommand === 'start' || (now - (60 * 60 * 1000) < timestamp)) { | ||
return contents; | ||
} | ||
else { | ||
return null; | ||
} | ||
} | ||
@@ -176,0 +181,0 @@ catch (err) { |
@@ -15,2 +15,3 @@ "use strict"; | ||
const commandName = 'start'; | ||
config_1.Config.runCommand = commandName; | ||
let logger = new cli_1.Logger('start'); | ||
@@ -17,0 +18,0 @@ let prog = new cli_1.Program() |
@@ -14,2 +14,3 @@ "use strict"; | ||
const files_1 = require("../files"); | ||
const http_utils_1 = require("../http_utils"); | ||
const utils_1 = require("../utils"); | ||
@@ -19,2 +20,3 @@ const Opt = require("./"); | ||
const opts_1 = require("./opts"); | ||
config_1.Config.runCommand = 'update'; | ||
let logger = new cli_1.Logger('update'); | ||
@@ -109,2 +111,3 @@ let prog = new cli_1.Program() | ||
let proxy = options[Opt.PROXY].getString(); | ||
http_utils_1.HttpUtils.assignOptions({ ignoreSSL, proxy }); | ||
let verbose = options[Opt.VERBOSE].getBoolean(); | ||
@@ -128,3 +131,3 @@ // setup versions for binaries | ||
let binary = binaries[binaries_1.Standalone.id]; | ||
promises.push(files_1.FileManager.downloadFile(binary, outputDir, proxy, ignoreSSL) | ||
promises.push(files_1.FileManager.downloadFile(binary, outputDir) | ||
.then((downloaded) => { | ||
@@ -198,3 +201,3 @@ if (!downloaded) { | ||
return files_1.FileManager | ||
.downloadFile(binary, outputDir, proxy, ignoreSSL, (binary, outputDir, fileName) => { | ||
.downloadFile(binary, outputDir, (binary, outputDir, fileName) => { | ||
unzip(binary, outputDir, fileName); | ||
@@ -201,0 +204,0 @@ }) |
@@ -18,2 +18,3 @@ export interface ConfigFile { | ||
export declare class Config { | ||
static runCommand: string; | ||
static configFile: string; | ||
@@ -20,0 +21,0 @@ static packageFile: string; |
@@ -15,3 +15,2 @@ import { Binary } from '../binaries'; | ||
* @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. | ||
@@ -21,3 +20,3 @@ * @returns Promise<boolean> Resolves true = downloaded. Resolves false = not downloaded. | ||
*/ | ||
static getFile(binary: Binary, fileUrl: string, fileName: string, outputDir: string, contentLength: number, opt_proxy?: string, opt_ignoreSSL?: boolean, callback?: Function): Promise<boolean>; | ||
static getFile(binary: Binary, fileUrl: string, fileName: string, outputDir: string, contentLength: number, callback?: Function): Promise<boolean>; | ||
} |
@@ -6,3 +6,2 @@ "use strict"; | ||
const request = require("request"); | ||
const url = require("url"); | ||
const cli_1 = require("../cli"); | ||
@@ -24,3 +23,2 @@ const http_utils_1 = require("../http_utils"); | ||
* @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. | ||
@@ -30,8 +28,6 @@ * @returns Promise<boolean> Resolves true = downloaded. Resolves false = not downloaded. | ||
*/ | ||
static getFile(binary, fileUrl, fileName, outputDir, contentLength, opt_proxy, opt_ignoreSSL, callback) { | ||
static getFile(binary, fileUrl, fileName, outputDir, contentLength, callback) { | ||
let filePath = path.resolve(outputDir, fileName); | ||
let file; | ||
let options = http_utils_1.HttpUtils.initOptions(fileUrl); | ||
options = http_utils_1.HttpUtils.optionsSSL(options, opt_ignoreSSL); | ||
options = http_utils_1.HttpUtils.optionsProxy(options, fileUrl, opt_proxy); | ||
let req = null; | ||
@@ -50,12 +46,2 @@ let resContentLength; | ||
else { | ||
if (opt_proxy) { | ||
let pathUrl = url.parse(options.url.toString()).path; | ||
let host = url.parse(options.url.toString()).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 | ||
@@ -62,0 +48,0 @@ file = fs.createWriteStream(filePath); |
@@ -65,3 +65,3 @@ import { Binary, BinaryMap } from '../binaries'; | ||
*/ | ||
static downloadFile<T extends Binary>(binary: T, outputDir: string, opt_proxy?: string, opt_ignoreSSL?: boolean, callback?: Function): Promise<boolean>; | ||
static downloadFile<T extends Binary>(binary: T, outputDir: string, callback?: Function): Promise<boolean>; | ||
/** | ||
@@ -68,0 +68,0 @@ * Removes the existing files found in the output directory that match the |
@@ -158,3 +158,3 @@ "use strict"; | ||
*/ | ||
static downloadFile(binary, outputDir, opt_proxy, opt_ignoreSSL, callback) { | ||
static downloadFile(binary, outputDir, callback) { | ||
return new Promise((resolve, reject) => { | ||
@@ -165,3 +165,3 @@ let outDir = config_1.Config.getSeleniumDir(); | ||
// Pass options down to binary to make request to get the latest version to download. | ||
binary.getUrl(binary.version(), opt_proxy, opt_ignoreSSL).then(fileUrl => { | ||
binary.getUrl(binary.version()).then(fileUrl => { | ||
binary.versionCustom = fileUrl.version; | ||
@@ -179,4 +179,3 @@ let filePath = path.resolve(outputDir, binary.filename()); | ||
contentLength = fs.statSync(filePath).size; | ||
downloader_1.Downloader | ||
.getFile(binary, fileUrl.url, fileName, outputDir, contentLength, opt_proxy, opt_ignoreSSL, callback) | ||
downloader_1.Downloader.getFile(binary, fileUrl.url, fileName, outputDir, contentLength, callback) | ||
.then(downloaded => { | ||
@@ -190,4 +189,3 @@ resolve(downloaded); | ||
// length of zero and download the file. | ||
downloader_1.Downloader | ||
.getFile(binary, fileUrl.url, fileName, outputDir, contentLength, opt_proxy, opt_ignoreSSL, callback) | ||
downloader_1.Downloader.getFile(binary, fileUrl.url, fileName, outputDir, contentLength, callback) | ||
.then(downloaded => { | ||
@@ -194,0 +192,0 @@ resolve(downloaded); |
/// <reference types="request" /> | ||
import { OptionsWithUrl } from 'request'; | ||
export interface RequestOptionsValue { | ||
proxy?: string; | ||
ignoreSSL?: boolean; | ||
} | ||
export declare class HttpUtils { | ||
static assignOptions(options: RequestOptionsValue): void; | ||
static initOptions(url: string, timeout?: number): OptionsWithUrl; | ||
@@ -5,0 +10,0 @@ static optionsSSL(options: OptionsWithUrl, opt_ignoreSSL: boolean): OptionsWithUrl; |
@@ -7,3 +7,7 @@ "use strict"; | ||
let logger = new logger_1.Logger('http_utils'); | ||
let requestOpts = {}; | ||
class HttpUtils { | ||
static assignOptions(options) { | ||
Object.assign(requestOpts, options); | ||
} | ||
static initOptions(url, timeout) { | ||
@@ -16,2 +20,4 @@ let options = { | ||
}; | ||
HttpUtils.optionsSSL(options, requestOpts.ignoreSSL); | ||
HttpUtils.optionsProxy(options, url, requestOpts.proxy); | ||
return options; | ||
@@ -18,0 +24,0 @@ } |
{ | ||
"name": "webdriver-manager", | ||
"version": "12.0.4", | ||
"version": "12.0.5", | ||
"description": "A selenium server and browser driver manager for your end to end tests.", | ||
@@ -5,0 +5,0 @@ "scripts": { |
@@ -0,1 +1,8 @@ | ||
# 12.0.5 | ||
## Bug Fix | ||
- ([242a72f](https://github.com/angular/webdriver-manager/commit/242a72ffc93037d651c9805e09b4fb30318d9f05)) | ||
feat(start): start selenium without making web requests (#232) | ||
# 12.0.4 | ||
@@ -2,0 +9,0 @@ |
{ | ||
"name": "webdriver-manager", | ||
"version": "12.0.4", | ||
"version": "12.0.5", | ||
"description": "A selenium server and browser driver manager for your end to end tests.", | ||
@@ -5,0 +5,0 @@ "scripts": { |
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
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
333001
4550