webdriver-installer 1.0.0 → 1.1.2
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/CHANGELOG.md +45 -0
- package/chrome.js +1 -3
- package/edge.js +36 -5
- package/firefox.js +1 -3
- package/main.js +9 -1
- package/package.json +5 -1
- package/utils.js +32 -26
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
### [1.1.2](https://github.com/joeyparrish/webdriver-installer/compare/v1.1.1...v1.1.2) (2022-02-03)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### Bug Fixes
|
|
7
|
+
|
|
8
|
+
* Fix CLI installation ([2f6b649](https://github.com/joeyparrish/webdriver-installer/commit/2f6b649033312f778795b1372abfc0a175d70e61))
|
|
9
|
+
|
|
10
|
+
### [1.1.1](https://github.com/joeyparrish/webdriver-installer/compare/v1.1.0...v1.1.1) (2022-02-03)
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
### Bug Fixes
|
|
14
|
+
|
|
15
|
+
* Make Windows browser version queries more robust ([85f3b27](https://github.com/joeyparrish/webdriver-installer/commit/85f3b2796e06e1a0f2171b46beef73f6a0407ecb))
|
|
16
|
+
|
|
17
|
+
## [1.1.0](https://github.com/joeyparrish/webdriver-installer/compare/v1.0.1...v1.1.0) (2022-02-03)
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
### Features
|
|
21
|
+
|
|
22
|
+
* Add MS Edge support on Linux and Mac ([59505f4](https://github.com/joeyparrish/webdriver-installer/commit/59505f49b94030c63377d72e2b4639093915ab3d))
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
### Bug Fixes
|
|
26
|
+
|
|
27
|
+
* Fix GitHub API rate limit issues getting geckodriver release ([074beb7](https://github.com/joeyparrish/webdriver-installer/commit/074beb79adf7d9807ab57b67c9edd26d9451270e))
|
|
28
|
+
|
|
29
|
+
## [1.0.1](https://github.com/joeyparrish/webdriver-installer/compare/v1.0.0...v1.0.1) (2022-02-02)
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
### Bug Fixes
|
|
33
|
+
|
|
34
|
+
* Fix execution in node v12 ([9b06017](https://github.com/joeyparrish/webdriver-installer/commit/9b06017b7c83ebfea1e600d7f667b2810ab05b5f))
|
|
35
|
+
* Fix failure to query registry for Firefox ([ce12f34](https://github.com/joeyparrish/webdriver-installer/commit/ce12f347f96406cc1f0a219c4c44cd2a9b827254))
|
|
36
|
+
* Improved error logging for CLI ([b588638](https://github.com/joeyparrish/webdriver-installer/commit/b588638774526d621983e0b497aa85ab217fcc46))
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
## [1.0.0](https://github.com/joeyparrish/webdriver-installer/commits/v1.0.0) (2022-01-27)
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
### Features
|
|
43
|
+
|
|
44
|
+
* Support for Chrome, Chrome-android, Firefox, and Edge ([5f4cc57](https://github.com/joeyparrish/webdriver-installer/commit/5f4cc578a8b911d5a6da26e46e9bf0fb95580606))
|
|
45
|
+
* Make logging optional, export main ([1d7bb17](https://github.com/joeyparrish/webdriver-installer/commit/1d7bb1755725a50b9c5a423c55402f6a84503919))
|
package/chrome.js
CHANGED
|
@@ -36,9 +36,7 @@ class ChromeWebDriverInstaller extends WebDriverInstallerBase {
|
|
|
36
36
|
} else if (os.platform() == 'darwin') {
|
|
37
37
|
return await InstallerUtils.getMacAppVersion('Google Chrome');
|
|
38
38
|
} else if (os.platform() == 'win32') {
|
|
39
|
-
return await InstallerUtils.
|
|
40
|
-
'HKEY_CURRENT_USER\\Software\\Google\\Chrome\\BLBeacon',
|
|
41
|
-
'version');
|
|
39
|
+
return await InstallerUtils.getWindowsExeVersion('chrome.exe');
|
|
42
40
|
} else {
|
|
43
41
|
throw new Error(`Unrecognized platform: ${os.platform()}`);
|
|
44
42
|
}
|
package/edge.js
CHANGED
|
@@ -28,8 +28,18 @@ class EdgeWebDriverInstaller extends WebDriverInstallerBase {
|
|
|
28
28
|
|
|
29
29
|
/** @return {!Promise<?string>} */
|
|
30
30
|
async getInstalledBrowserVersion() {
|
|
31
|
-
|
|
32
|
-
|
|
31
|
+
if (os.platform() == 'linux') {
|
|
32
|
+
const output = await InstallerUtils.getCommandOutputOrNullIfMissing(
|
|
33
|
+
['microsoft-edge', '--version']);
|
|
34
|
+
// Output is a string like "Microsoft Edge 97.0.1072.76\n"
|
|
35
|
+
return output ? output.trim().split(' ')[2] : null;
|
|
36
|
+
} else if (os.platform() == 'darwin') {
|
|
37
|
+
return await InstallerUtils.getMacAppVersion('Microsoft Edge');
|
|
38
|
+
} else if (os.platform() == 'win32') {
|
|
39
|
+
return await InstallerUtils.getWindowsExeVersion('msedge.exe');
|
|
40
|
+
} else {
|
|
41
|
+
throw new Error(`Unrecognized platform: ${os.platform()}`);
|
|
42
|
+
}
|
|
33
43
|
}
|
|
34
44
|
|
|
35
45
|
/**
|
|
@@ -65,9 +75,30 @@ class EdgeWebDriverInstaller extends WebDriverInstallerBase {
|
|
|
65
75
|
* @return {!Promise}
|
|
66
76
|
*/
|
|
67
77
|
async install(driverVersion, outputDirectory) {
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
78
|
+
let platform;
|
|
79
|
+
|
|
80
|
+
if (os.platform() == 'linux') {
|
|
81
|
+
platform = 'linux64';
|
|
82
|
+
} else if (os.platform() == 'darwin') {
|
|
83
|
+
platform = 'mac64';
|
|
84
|
+
} else if (os.platform() == 'win32') {
|
|
85
|
+
platform = 'win64';
|
|
86
|
+
} else {
|
|
87
|
+
throw new Error(`Unrecognized platform: ${os.platform()}`);
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
const archiveUrl = `${CDN_URL}/${driverVersion}/edgedriver_${platform}.zip`;
|
|
91
|
+
|
|
92
|
+
let binaryName = 'msedgedriver';
|
|
93
|
+
if (os.platform() == 'win32') {
|
|
94
|
+
binaryName += '.exe';
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
let outputName = this.getDriverName();
|
|
98
|
+
if (os.platform() == 'win32') {
|
|
99
|
+
outputName += '.exe';
|
|
100
|
+
}
|
|
101
|
+
|
|
71
102
|
return await InstallerUtils.installBinary(
|
|
72
103
|
archiveUrl, binaryName, outputName,
|
|
73
104
|
outputDirectory, /* isZip= */ true);
|
package/firefox.js
CHANGED
|
@@ -34,9 +34,7 @@ class FirefoxWebDriverInstaller extends WebDriverInstallerBase {
|
|
|
34
34
|
} else if (os.platform() == 'darwin') {
|
|
35
35
|
return await InstallerUtils.getMacAppVersion('Firefox');
|
|
36
36
|
} else if (os.platform() == 'win32') {
|
|
37
|
-
return await InstallerUtils.
|
|
38
|
-
'HKLM\\SOFTWARE\\Mozilla\\Mozilla Firefox',
|
|
39
|
-
'CurrentVersion')
|
|
37
|
+
return await InstallerUtils.getWindowsExeVersion('firefox.exe');
|
|
40
38
|
} else {
|
|
41
39
|
throw new Error(`Unrecognized platform: ${os.platform()}`);
|
|
42
40
|
}
|
package/main.js
CHANGED
|
@@ -73,7 +73,15 @@ if (require.main == module) {
|
|
|
73
73
|
process.exit(1);
|
|
74
74
|
}
|
|
75
75
|
|
|
76
|
-
|
|
76
|
+
(async () => {
|
|
77
|
+
try {
|
|
78
|
+
await main(args[0]);
|
|
79
|
+
process.exit(0);
|
|
80
|
+
} catch (error) {
|
|
81
|
+
console.error(error);
|
|
82
|
+
process.exit(1);
|
|
83
|
+
}
|
|
84
|
+
})();
|
|
77
85
|
} else {
|
|
78
86
|
module.exports = {installWebDrivers: main};
|
|
79
87
|
}
|
package/package.json
CHANGED
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "webdriver-installer",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.1.2",
|
|
4
4
|
"description": "Install the right WebDriver version for your local browsers, automatically.",
|
|
5
5
|
"main": "main.js",
|
|
6
|
+
"bin": {
|
|
7
|
+
"webdriver-installer": "main.js"
|
|
8
|
+
},
|
|
6
9
|
"repository": {
|
|
7
10
|
"type": "git",
|
|
8
11
|
"url": "https://github.com/joeyparrish/webdriver-installer"
|
|
@@ -16,6 +19,7 @@
|
|
|
16
19
|
"author": "Joey Parrish <joeyparrish@google.com>",
|
|
17
20
|
"dependencies": {
|
|
18
21
|
"node-fetch": "^2.6.7",
|
|
22
|
+
"regedit": "^5.0.0",
|
|
19
23
|
"tar-stream": "^2.2.0",
|
|
20
24
|
"yauzl": "^2.10.0"
|
|
21
25
|
},
|
package/utils.js
CHANGED
|
@@ -7,19 +7,24 @@
|
|
|
7
7
|
const childProcess = require('child_process');
|
|
8
8
|
const fetch = require('node-fetch');
|
|
9
9
|
const fs = require('fs');
|
|
10
|
-
const fsPromises = require('fs
|
|
10
|
+
const fsPromises = require('fs').promises;
|
|
11
11
|
const os = require('os');
|
|
12
12
|
const path = require('path');
|
|
13
|
+
const regedit = require('regedit');
|
|
13
14
|
const stream = require('stream');
|
|
14
15
|
const tar = require('tar-stream');
|
|
15
16
|
const util = require('util');
|
|
16
17
|
const yauzl = require('yauzl');
|
|
17
18
|
const zlib = require('zlib');
|
|
18
19
|
|
|
20
|
+
const regQuery = util.promisify(regedit.list);
|
|
19
21
|
const execFile = util.promisify(childProcess.execFile);
|
|
20
22
|
const pipeline = util.promisify(stream.pipeline);
|
|
21
23
|
const zipFromBuffer = util.promisify(yauzl.fromBuffer);
|
|
22
24
|
|
|
25
|
+
const WINDOWS_REGISTRY_APP_PATHS =
|
|
26
|
+
'HKLM\\Software\\Microsoft\\Windows\\CurrentVersion\\App\ Paths\\';
|
|
27
|
+
|
|
23
28
|
/**
|
|
24
29
|
* A static utility class for driver installers to use for common operations.
|
|
25
30
|
*/
|
|
@@ -88,26 +93,17 @@ class InstallerUtils {
|
|
|
88
93
|
return null;
|
|
89
94
|
}
|
|
90
95
|
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
if (line[0] == ' ' && line.includes(key)) {
|
|
100
|
-
// Find the section that starts with a number.
|
|
101
|
-
for (const section of line.split(' ')) {
|
|
102
|
-
if (section[0] >= '0' && section[0] <= '9') {
|
|
103
|
-
return section;
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
}
|
|
96
|
+
// Try the 64-bit registry first, then fall back to the 32-bit registry.
|
|
97
|
+
// Necessary values could be in either location.
|
|
98
|
+
let result = await regQuery(path, '64');
|
|
99
|
+
if (!result[path].exists || !result[path].values[key]) {
|
|
100
|
+
result = await regQuery(path, '32');
|
|
101
|
+
}
|
|
102
|
+
if (!result[path].exists || !result[path].values[key]) {
|
|
103
|
+
return null;
|
|
107
104
|
}
|
|
108
105
|
|
|
109
|
-
|
|
110
|
-
return null;
|
|
106
|
+
return result[path].values[key].value;
|
|
111
107
|
}
|
|
112
108
|
|
|
113
109
|
/**
|
|
@@ -137,9 +133,16 @@ class InstallerUtils {
|
|
|
137
133
|
}
|
|
138
134
|
|
|
139
135
|
if (!(await InstallerUtils.fileExists(path))) {
|
|
140
|
-
// No such file.
|
|
141
|
-
//
|
|
142
|
-
|
|
136
|
+
// No such file.
|
|
137
|
+
// If it's a relative path, ask the registry for a full one.
|
|
138
|
+
if (!path.includes('/') && !path.includes('\\')) {
|
|
139
|
+
path = await InstallerUtils.getWindowsRegistryVersion(
|
|
140
|
+
WINDOWS_REGISTRY_APP_PATHS + path,
|
|
141
|
+
'');
|
|
142
|
+
if (!path || !(await InstallerUtils.fileExists(path))) {
|
|
143
|
+
return null;
|
|
144
|
+
}
|
|
145
|
+
}
|
|
143
146
|
}
|
|
144
147
|
|
|
145
148
|
const result = await InstallerUtils.runCommand([
|
|
@@ -239,10 +242,13 @@ class InstallerUtils {
|
|
|
239
242
|
* @return {?string}
|
|
240
243
|
*/
|
|
241
244
|
static async fetchLatestGitHubTag(repo) {
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
const
|
|
245
|
-
|
|
245
|
+
// The GitHub API has rate limits, but this is public. It will redirect to
|
|
246
|
+
// a URL specific to the tag.
|
|
247
|
+
const url = `https://github.com/${repo}/releases/latest`;
|
|
248
|
+
const response = await fetch(url, {method: 'HEAD'});
|
|
249
|
+
// The redirected URL will be something like:
|
|
250
|
+
// "https://github.com/mozilla/geckodriver/releases/tag/v0.30.0"
|
|
251
|
+
return response.url.split('/').pop();
|
|
246
252
|
}
|
|
247
253
|
|
|
248
254
|
/**
|