1- import {
2- getChromedriverDir ,
3- retrieveData ,
4- getOsInfo ,
5- convertToInt ,
6- getCpuType ,
7- } from '../utils' ;
1+ import { getChromedriverDir , retrieveData , getOsInfo , convertToInt , getCpuType } from '../utils' ;
82import _ from 'lodash' ;
93import B from 'bluebird' ;
104import path from 'node:path' ;
@@ -19,7 +13,10 @@ import {
1913 CPU ,
2014} from '../constants' ;
2115import { parseGoogleapiStorageXml } from './googleapis' ;
22- import { parseKnownGoodVersionsWithDownloadsJson , parseLatestKnownGoodVersionsJson } from './chromelabs' ;
16+ import {
17+ parseKnownGoodVersionsWithDownloadsJson ,
18+ parseLatestKnownGoodVersionsJson ,
19+ } from './chromelabs' ;
2320import { compareVersions } from 'compare-versions' ;
2421import * as semver from 'semver' ;
2522import type {
@@ -77,23 +74,26 @@ export class ChromedriverStorageClient {
7774 * @returns Promise<ChromedriverDetailsMapping>
7875 */
7976 async retrieveMapping ( shouldParseNotes = true ) : Promise < ChromedriverDetailsMapping > {
80- const retrieveResponseSafely = async ( { url, accept} : StorageInfo ) : Promise < string | undefined > => {
77+ const retrieveResponseSafely = async ( {
78+ url,
79+ accept,
80+ } : StorageInfo ) : Promise < string | undefined > => {
8181 try {
8282 return await retrieveData (
8383 url ,
8484 {
8585 'user-agent' : USER_AGENT ,
8686 accept : `${ accept } , */*` ,
8787 } ,
88- { timeout : this . timeout }
88+ { timeout : this . timeout } ,
8989 ) ;
9090 } catch ( e ) {
9191 const err = e as Error ;
9292 log . debug ( err . stack ) ;
9393 log . warn (
9494 `Cannot retrieve Chromedrivers info from ${ url } . ` +
9595 `Make sure this URL is accessible from your network. ` +
96- `Original error: ${ err . message } `
96+ `Original error: ${ err . message } ` ,
9797 ) ;
9898 }
9999 } ;
@@ -105,7 +105,7 @@ export class ChromedriverStorageClient {
105105 `Cannot retrieve the information about available Chromedrivers from ` +
106106 `${ STORAGE_INFOS . map ( ( { url} ) => url ) } . Please make sure these URLs are available ` +
107107 `within your local network, check Appium server logs and/or ` +
108- `consult the driver troubleshooting guide.`
108+ `consult the driver troubleshooting guide.` ,
109109 ) ;
110110 }
111111 this . mapping = xmlStr ? await parseGoogleapiStorageXml ( xmlStr , shouldParseNotes ) : { } ;
@@ -137,7 +137,7 @@ export class ChromedriverStorageClient {
137137 }
138138 log . debug (
139139 `Got ${ util . pluralize ( 'driver' , driversToSync . length , true ) } to sync: ` +
140- JSON . stringify ( driversToSync , null , 2 )
140+ JSON . stringify ( driversToSync , null , 2 ) ,
141141 ) ;
142142
143143 const synchronizedDrivers : string [ ] = [ ] ;
@@ -151,7 +151,7 @@ export class ChromedriverStorageClient {
151151 if ( await this . retrieveDriver ( idx , driverKey , archivesRoot , ! _ . isEmpty ( opts ) ) ) {
152152 synchronizedDrivers . push ( driverKey ) ;
153153 }
154- } ) ( )
154+ } ) ( ) ,
155155 ) ;
156156 promises . push ( promise ) ;
157157 chunk . push ( promise ) ;
@@ -167,7 +167,7 @@ export class ChromedriverStorageClient {
167167 if ( ! _ . isEmpty ( synchronizedDrivers ) ) {
168168 log . info (
169169 `Successfully synchronized ` +
170- `${ util . pluralize ( 'chromedriver' , synchronizedDrivers . length , true ) } `
170+ `${ util . pluralize ( 'chromedriver' , synchronizedDrivers . length , true ) } ` ,
171171 ) ;
172172 } else {
173173 log . info ( `No chromedrivers were synchronized` ) ;
@@ -190,14 +190,14 @@ export class ChromedriverStorageClient {
190190 'user-agent' : USER_AGENT ,
191191 accept : `application/json, */*` ,
192192 } ,
193- { timeout : STORAGE_REQ_TIMEOUT_MS }
193+ { timeout : STORAGE_REQ_TIMEOUT_MS } ,
194194 ) ;
195195 } catch ( e ) {
196196 const err = e as Error ;
197197 throw new Error (
198198 `Cannot fetch the latest Chromedriver version. ` +
199199 `Make sure you can access ${ CHROME_FOR_TESTING_LAST_GOOD_VERSIONS } from your machine or provide a mirror by setting ` +
200- `a custom value to CHROMELABS_URL environment variable. Original error: ${ err . message } `
200+ `a custom value to CHROMELABS_URL environment variable. Original error: ${ err . message } ` ,
201201 ) ;
202202 }
203203 return parseLatestKnownGoodVersionsJson ( jsonStr ) ;
@@ -219,7 +219,7 @@ export class ChromedriverStorageClient {
219219 // Handle only selected versions if requested
220220 log . debug ( `Selecting chromedrivers whose versions match to ${ versions } ` ) ;
221221 driversToSync = driversToSync . filter ( ( cdName ) =>
222- versions . includes ( `${ this . mapping [ cdName ] . version } ` )
222+ versions . includes ( `${ this . mapping [ cdName ] . version } ` ) ,
223223 ) ;
224224
225225 log . debug ( `Got ${ util . pluralize ( 'item' , driversToSync . length , true ) } ` ) ;
@@ -232,14 +232,14 @@ export class ChromedriverStorageClient {
232232 if ( minBrowserVersionInt !== null ) {
233233 // Only select drivers that support the current browser whose major version number equals to `minBrowserVersion`
234234 log . debug (
235- `Selecting chromedrivers whose minimum supported browser version matches to ${ minBrowserVersionInt } `
235+ `Selecting chromedrivers whose minimum supported browser version matches to ${ minBrowserVersionInt } ` ,
236236 ) ;
237237 let closestMatchedVersionNumber = 0 ;
238238 // Select the newest available and compatible chromedriver
239239 for ( const cdName of driversToSync ) {
240240 const currentMinBrowserVersion = parseInt (
241241 String ( this . mapping [ cdName ] . minBrowserVersion ) ,
242- 10
242+ 10 ,
243243 ) ;
244244 if (
245245 ! Number . isNaN ( currentMinBrowserVersion ) &&
@@ -252,7 +252,7 @@ export class ChromedriverStorageClient {
252252 driversToSync = driversToSync . filter (
253253 ( cdName ) =>
254254 `${ this . mapping [ cdName ] . minBrowserVersion } ` ===
255- `${ closestMatchedVersionNumber > 0 ? closestMatchedVersionNumber : minBrowserVersionInt } `
255+ `${ closestMatchedVersionNumber > 0 ? closestMatchedVersionNumber : minBrowserVersionInt } ` ,
256256 ) ;
257257
258258 log . debug ( `Got ${ util . pluralize ( 'item' , driversToSync . length , true ) } ` ) ;
@@ -261,7 +261,7 @@ export class ChromedriverStorageClient {
261261 }
262262 log . debug (
263263 `Will select candidate ${ util . pluralize ( 'driver' , driversToSync . length ) } ` +
264- `versioned as '${ _ . uniq ( driversToSync . map ( ( cdName ) => this . mapping [ cdName ] . version ) ) } '`
264+ `versioned as '${ _ . uniq ( driversToSync . map ( ( cdName ) => this . mapping [ cdName ] . version ) ) } '` ,
265265 ) ;
266266 }
267267
@@ -277,7 +277,7 @@ export class ChromedriverStorageClient {
277277 name,
278278 arch : ARCH . X86 ,
279279 cpu,
280- } )
280+ } ) ,
281281 ) ;
282282 }
283283 if ( _ . isEmpty ( result ) && name === OS . MAC && cpu === CPU . ARM ) {
@@ -287,7 +287,7 @@ export class ChromedriverStorageClient {
287287 name,
288288 arch,
289289 cpu : CPU . INTEL ,
290- } )
290+ } ) ,
291291 ) ;
292292 }
293293 driversToSync = result ;
@@ -328,7 +328,7 @@ export class ChromedriverStorageClient {
328328 selectedVersions . add ( sortedVersions [ 0 ] ) ;
329329 }
330330 driversToSync = driversToSync . filter ( ( cdName ) =>
331- selectedVersions . has ( this . mapping [ cdName ] . version )
331+ selectedVersions . has ( this . mapping [ cdName ] . version ) ,
332332 ) ;
333333 }
334334 }
@@ -378,7 +378,7 @@ export class ChromedriverStorageClient {
378378 index : number ,
379379 driverKey : string ,
380380 archivesRoot : string ,
381- isStrict = false
381+ isStrict = false ,
382382 ) : Promise < boolean > {
383383 const { url, etag, version} = this . mapping [ driverKey ] ;
384384 const archivePath = path . resolve ( archivesRoot , `${ index } .zip` ) ;
@@ -437,11 +437,11 @@ export class ChromedriverStorageClient {
437437 tmpRoot ,
438438 true ,
439439 ( itemPath , isDirectory ) =>
440- ! isDirectory && _ . toLower ( path . parse ( itemPath ) . name ) === 'chromedriver'
440+ ! isDirectory && _ . toLower ( path . parse ( itemPath ) . name ) === 'chromedriver' ,
441441 ) ;
442442 if ( ! chromedriverPath ) {
443443 throw new Error (
444- 'The archive was unzipped properly, but we could not find any chromedriver executable'
444+ 'The archive was unzipped properly, but we could not find any chromedriver executable' ,
445445 ) ;
446446 }
447447 log . debug ( `Moving the extracted '${ path . basename ( chromedriverPath ) } ' to '${ dst } '` ) ;
@@ -453,4 +453,3 @@ export class ChromedriverStorageClient {
453453 }
454454 }
455455}
456-
0 commit comments