appium-chromedriver 4.26.4 → 4.27.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +6 -1
- package/build/lib/chromedriver.js +2 -2
- package/build/lib/install.js +24 -138
- package/build/lib/storage-client.js +14 -22
- package/build/lib/utils.js +55 -42
- package/config/mapping.json +4 -0
- package/lib/install.js +25 -117
- package/lib/storage-client.js +21 -21
- package/lib/utils.js +47 -40
- package/package.json +7 -7
package/lib/storage-client.js
CHANGED
|
@@ -1,4 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
getChromedriverDir, CD_CDN, retrieveData, getOsInfo,
|
|
3
|
+
OS, X64, X86, M1_ARCH_SUFFIX,
|
|
4
|
+
} from './utils';
|
|
2
5
|
import _ from 'lodash';
|
|
3
6
|
import xpath from 'xpath';
|
|
4
7
|
import { DOMParser } from 'xmldom';
|
|
@@ -13,19 +16,6 @@ const MAX_PARALLEL_DOWNLOADS = 5;
|
|
|
13
16
|
const log = logger.getLogger('ChromedriverStorageClient');
|
|
14
17
|
|
|
15
18
|
|
|
16
|
-
async function getOsInfo () {
|
|
17
|
-
let name = 'linux';
|
|
18
|
-
if (system.isWindows()) {
|
|
19
|
-
name = 'win';
|
|
20
|
-
} else if (system.isMac()) {
|
|
21
|
-
name = 'mac';
|
|
22
|
-
}
|
|
23
|
-
return {
|
|
24
|
-
name,
|
|
25
|
-
arch: await system.arch(),
|
|
26
|
-
};
|
|
27
|
-
}
|
|
28
|
-
|
|
29
19
|
async function isCrcOk (src, checksum) {
|
|
30
20
|
const md5 = await fs.hash(src, 'md5');
|
|
31
21
|
return _.toLower(md5) === _.toLower(checksum);
|
|
@@ -154,7 +144,6 @@ class ChromedriverStorageClient {
|
|
|
154
144
|
continue;
|
|
155
145
|
}
|
|
156
146
|
|
|
157
|
-
log.debug(`Processing chromedriver entry '${key}'`);
|
|
158
147
|
const etag = extractNodeText(findChildNode(driverNode, 'ETag'));
|
|
159
148
|
if (!etag) {
|
|
160
149
|
log.debug(`The entry '${key}' does not contain the checksum. Skipping it`);
|
|
@@ -254,6 +243,8 @@ class ChromedriverStorageClient {
|
|
|
254
243
|
* Can be either `mac`, `windows` or `linux`
|
|
255
244
|
* @property {string} arch - The architecture of the host OD.
|
|
256
245
|
* Can be either `32` or `64`
|
|
246
|
+
* @property {?string} hardwareName - The output of `uname -m` command
|
|
247
|
+
* on linux and mac systems. `null` on Windows
|
|
257
248
|
*/
|
|
258
249
|
|
|
259
250
|
/**
|
|
@@ -261,7 +252,7 @@ class ChromedriverStorageClient {
|
|
|
261
252
|
* chromedriver entries by operating system information
|
|
262
253
|
* and/or additional synchronization options (if provided)
|
|
263
254
|
*
|
|
264
|
-
* @param {OSInfo} osInfo
|
|
255
|
+
* @param {?OSInfo} osInfo
|
|
265
256
|
* @param {?SyncOptions} opts
|
|
266
257
|
* @returns {Array<String>} The list of filtered chromedriver
|
|
267
258
|
* entry names (version/archive name)
|
|
@@ -312,13 +303,19 @@ class ChromedriverStorageClient {
|
|
|
312
303
|
|
|
313
304
|
if (!_.isEmpty(osInfo)) {
|
|
314
305
|
// Filter out drivers for unsupported system architectures
|
|
315
|
-
let {name, arch} = osInfo;
|
|
316
|
-
if (arch ===
|
|
306
|
+
let {name, arch, hardwareName} = osInfo;
|
|
307
|
+
if (arch === X64 && !driversToSync.some((cdName) => cdName.includes(`_${name}${X64}`))) {
|
|
317
308
|
// Fall back to x86 build if x64 one is not available for the given OS
|
|
318
|
-
arch =
|
|
309
|
+
arch = X86;
|
|
310
|
+
}
|
|
311
|
+
if (name === OS.mac && _.includes(hardwareName, 'arm')
|
|
312
|
+
&& driversToSync.some((cdName) => cdName.includes(M1_ARCH_SUFFIX))) {
|
|
313
|
+
// prefer executable for M1 arch if present
|
|
314
|
+
arch += M1_ARCH_SUFFIX;
|
|
319
315
|
}
|
|
320
316
|
log.debug(`Selecting chromedrivers whose platform matches to ${name}${arch}`);
|
|
321
|
-
|
|
317
|
+
const platformRe = new RegExp(`(\\b|_)${name}${arch}\\b`);
|
|
318
|
+
driversToSync = driversToSync.filter((cdName) => platformRe.test(cdName));
|
|
322
319
|
log.debug(`Got ${util.pluralize('item', driversToSync.length, true)}`);
|
|
323
320
|
}
|
|
324
321
|
|
|
@@ -390,6 +387,9 @@ class ChromedriverStorageClient {
|
|
|
390
387
|
* @property {string|number} minBrowserVersion - The minumum supported
|
|
391
388
|
* Chrome version that downloaded chromedrivers should support. Can match
|
|
392
389
|
* multiple drivers.
|
|
390
|
+
* @property {?OSInfo} osInfo - System information used to filter out
|
|
391
|
+
* the list of the retrieved drivers. If not provided then the script
|
|
392
|
+
* will try to retrieve it.
|
|
393
393
|
*/
|
|
394
394
|
|
|
395
395
|
/**
|
|
@@ -409,7 +409,7 @@ class ChromedriverStorageClient {
|
|
|
409
409
|
throw new Error('Cannot retrieve chromedrivers mapping from Google storage');
|
|
410
410
|
}
|
|
411
411
|
|
|
412
|
-
const driversToSync = this.selectMatchingDrivers(await getOsInfo(), opts);
|
|
412
|
+
const driversToSync = this.selectMatchingDrivers(opts.osInfo ?? await getOsInfo(), opts);
|
|
413
413
|
if (_.isEmpty(driversToSync)) {
|
|
414
414
|
log.debug(`There are no drivers to sync. Exiting`);
|
|
415
415
|
return [];
|
package/lib/utils.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import _ from 'lodash';
|
|
2
|
-
import { system } from 'appium-support';
|
|
2
|
+
import { system, fs } from 'appium-support';
|
|
3
3
|
import path from 'path';
|
|
4
|
-
import semver from 'semver';
|
|
5
4
|
import compareVersions from 'compare-versions';
|
|
6
5
|
import axios from 'axios';
|
|
6
|
+
import { exec } from 'teen_process';
|
|
7
7
|
|
|
8
8
|
|
|
9
9
|
const rootDir = path.basename(__dirname) === 'lib'
|
|
@@ -19,9 +19,15 @@ const CD_BASE_DIR = path.resolve(__dirname, '..', '..', 'chromedriver');
|
|
|
19
19
|
const CD_CDN = process.env.npm_config_chromedriver_cdnurl
|
|
20
20
|
|| process.env.CHROMEDRIVER_CDNURL
|
|
21
21
|
|| 'https://chromedriver.storage.googleapis.com';
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
22
|
+
const OS = {
|
|
23
|
+
linux: 'linux',
|
|
24
|
+
windows: 'win',
|
|
25
|
+
mac: 'mac'
|
|
26
|
+
};
|
|
27
|
+
const X64 = '64';
|
|
28
|
+
const X86 = '32';
|
|
29
|
+
const M1_ARCH_SUFFIX = '_m1';
|
|
30
|
+
const CD_EXECUTABLE_PREFIX = 'chromedriver';
|
|
25
31
|
|
|
26
32
|
|
|
27
33
|
function getMostRecentChromedriver (mapping = CHROMEDRIVER_CHROME_MAPPING) {
|
|
@@ -36,39 +42,23 @@ async function getChromeVersion (adb, bundleId) {
|
|
|
36
42
|
return versionName;
|
|
37
43
|
}
|
|
38
44
|
|
|
39
|
-
function getChromedriverDir (
|
|
40
|
-
return path.resolve(CD_BASE_DIR,
|
|
45
|
+
function getChromedriverDir (osName = getOsName()) {
|
|
46
|
+
return path.resolve(CD_BASE_DIR, osName);
|
|
41
47
|
}
|
|
42
48
|
|
|
43
|
-
async function getChromedriverBinaryPath (
|
|
44
|
-
const
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
return system.isWindows() ? 'win' : (system.isMac() ? 'mac' : 'linux');
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
function getPlatforms () {
|
|
60
|
-
let plats = [
|
|
61
|
-
['win', '32'],
|
|
62
|
-
['linux', '64'],
|
|
63
|
-
];
|
|
64
|
-
const cdVer = semver.coerce(CD_VER);
|
|
65
|
-
// before 2.23 Mac version was 32 bit. After it is 64.
|
|
66
|
-
plats.push(semver.lt(cdVer, MAC_32_ONLY) ? ['mac', '32'] : ['mac', '64']);
|
|
67
|
-
// 2.34 and above linux is only supporting 64 bit
|
|
68
|
-
if (semver.lt(cdVer, LINUX_32_ONLY)) {
|
|
69
|
-
plats.push(['linux', '32']);
|
|
70
|
-
}
|
|
71
|
-
return plats;
|
|
49
|
+
async function getChromedriverBinaryPath (osName = getOsName()) {
|
|
50
|
+
const rootDir = getChromedriverDir(osName);
|
|
51
|
+
const pathSuffix = osName === OS.windows ? '.exe' : '';
|
|
52
|
+
const paths = await fs.glob(`${CD_EXECUTABLE_PREFIX}*${pathSuffix}`, {
|
|
53
|
+
cwd: rootDir,
|
|
54
|
+
absolute: true,
|
|
55
|
+
nocase: true,
|
|
56
|
+
nodir: true,
|
|
57
|
+
strict: false,
|
|
58
|
+
});
|
|
59
|
+
return _.isEmpty(paths)
|
|
60
|
+
? path.resolve(rootDir, `${CD_EXECUTABLE_PREFIX}${pathSuffix}`)
|
|
61
|
+
: _.first(paths);
|
|
72
62
|
}
|
|
73
63
|
|
|
74
64
|
async function retrieveData (url, headers, opts = {}) {
|
|
@@ -84,10 +74,27 @@ async function retrieveData (url, headers, opts = {}) {
|
|
|
84
74
|
})).data;
|
|
85
75
|
}
|
|
86
76
|
|
|
77
|
+
const getOsName = _.memoize(function getOsName () {
|
|
78
|
+
if (system.isWindows()) {
|
|
79
|
+
return OS.windows;
|
|
80
|
+
}
|
|
81
|
+
if (system.isMac()) {
|
|
82
|
+
return OS.mac;
|
|
83
|
+
}
|
|
84
|
+
return OS.linux;
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
const getOsInfo = _.memoize(async function getOsInfo () {
|
|
88
|
+
return {
|
|
89
|
+
name: getOsName(),
|
|
90
|
+
arch: await system.arch(),
|
|
91
|
+
hardwareName: system.isWindows() ? null : _.trim(await exec('uname', ['-m'])),
|
|
92
|
+
};
|
|
93
|
+
});
|
|
94
|
+
|
|
87
95
|
|
|
88
96
|
export {
|
|
89
|
-
getChromeVersion, getChromedriverDir, getChromedriverBinaryPath,
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
retrieveData,
|
|
97
|
+
getChromeVersion, getChromedriverDir, getChromedriverBinaryPath, getOsName,
|
|
98
|
+
CD_BASE_DIR, CD_CDN, CD_VER, CHROMEDRIVER_CHROME_MAPPING, getMostRecentChromedriver,
|
|
99
|
+
retrieveData, getOsInfo, OS, X64, X86, M1_ARCH_SUFFIX,
|
|
93
100
|
};
|
package/package.json
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
"chrome",
|
|
7
7
|
"android"
|
|
8
8
|
],
|
|
9
|
-
"version": "4.
|
|
9
|
+
"version": "4.27.3",
|
|
10
10
|
"author": "appium",
|
|
11
11
|
"license": "Apache-2.0",
|
|
12
12
|
"repository": {
|
|
@@ -39,16 +39,16 @@
|
|
|
39
39
|
"appium-base-driver": "^7.1.0",
|
|
40
40
|
"appium-support": "^2.46.0",
|
|
41
41
|
"asyncbox": "^2.0.2",
|
|
42
|
-
"axios": "^0.
|
|
42
|
+
"axios": "^0.x",
|
|
43
43
|
"bluebird": "^3.5.1",
|
|
44
44
|
"compare-versions": "^3.4.0",
|
|
45
45
|
"fancy-log": "^1.3.2",
|
|
46
46
|
"lodash": "^4.17.4",
|
|
47
47
|
"semver": "^7.0.0",
|
|
48
|
-
"source-map-support": "^0.
|
|
48
|
+
"source-map-support": "^0.x",
|
|
49
49
|
"teen_process": "^1.15.0",
|
|
50
|
-
"xmldom": "^0.
|
|
51
|
-
"xpath": "^0.
|
|
50
|
+
"xmldom": "^0.x",
|
|
51
|
+
"xpath": "^0.x"
|
|
52
52
|
},
|
|
53
53
|
"pre-commit": [
|
|
54
54
|
"precommit-msg",
|
|
@@ -76,8 +76,8 @@
|
|
|
76
76
|
"chai-as-promised": "^7.1.1",
|
|
77
77
|
"eslint-config-appium": "^4.0.1",
|
|
78
78
|
"gulp": "^4.0.0",
|
|
79
|
-
"mocha": "^
|
|
79
|
+
"mocha": "^9.0.0",
|
|
80
80
|
"pre-commit": "^1.1.3",
|
|
81
|
-
"sinon": "^
|
|
81
|
+
"sinon": "^11.0.0"
|
|
82
82
|
}
|
|
83
83
|
}
|