webdriver-installer 1.1.0 → 1.1.4

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 CHANGED
@@ -1,5 +1,34 @@
1
1
  # Changelog
2
2
 
3
+ ### [1.1.4](https://github.com/joeyparrish/webdriver-installer/compare/v1.1.3...v1.1.4) (2022-02-17)
4
+
5
+
6
+ ### Bug Fixes
7
+
8
+ * Fix unlinking existing binaries ([#12](https://github.com/joeyparrish/webdriver-installer/issues/12)) ([8a43765](https://github.com/joeyparrish/webdriver-installer/commit/8a43765b54fbbf164762f7a8edf52520b4d08059))
9
+
10
+ ### [1.1.3](https://github.com/joeyparrish/webdriver-installer/compare/v1.1.2...v1.1.3) (2022-02-11)
11
+
12
+
13
+ ### Bug Fixes
14
+
15
+ * Choose platform-specific msedgedriver version ([#8](https://github.com/joeyparrish/webdriver-installer/issues/8)) ([2e0e859](https://github.com/joeyparrish/webdriver-installer/commit/2e0e8598f878c0c3fcd8ed55d4e830da398a891b))
16
+
17
+
18
+ ### [1.1.2](https://github.com/joeyparrish/webdriver-installer/compare/v1.1.1...v1.1.2) (2022-02-03)
19
+
20
+
21
+ ### Bug Fixes
22
+
23
+ * Fix CLI installation ([2f6b649](https://github.com/joeyparrish/webdriver-installer/commit/2f6b649033312f778795b1372abfc0a175d70e61))
24
+
25
+ ### [1.1.1](https://github.com/joeyparrish/webdriver-installer/compare/v1.1.0...v1.1.1) (2022-02-03)
26
+
27
+
28
+ ### Bug Fixes
29
+
30
+ * Make Windows browser version queries more robust ([85f3b27](https://github.com/joeyparrish/webdriver-installer/commit/85f3b2796e06e1a0f2171b46beef73f6a0407ecb))
31
+
3
32
  ## [1.1.0](https://github.com/joeyparrish/webdriver-installer/compare/v1.0.1...v1.1.0) (2022-02-03)
4
33
 
5
34
 
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.getWindowsRegistryVersion(
40
- 'HKCU\\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
@@ -36,8 +36,7 @@ class EdgeWebDriverInstaller extends WebDriverInstallerBase {
36
36
  } else if (os.platform() == 'darwin') {
37
37
  return await InstallerUtils.getMacAppVersion('Microsoft Edge');
38
38
  } else if (os.platform() == 'win32') {
39
- return await InstallerUtils.getWindowsExeVersion(
40
- 'C:\\Program Files (x86)\\Microsoft\\Edge\\Application\\msedge.exe');
39
+ return await InstallerUtils.getWindowsExeVersion('msedge.exe');
41
40
  } else {
42
41
  throw new Error(`Unrecognized platform: ${os.platform()}`);
43
42
  }
@@ -65,7 +64,19 @@ class EdgeWebDriverInstaller extends WebDriverInstallerBase {
65
64
  */
66
65
  async getBestDriverVersion(browserVersion) {
67
66
  const majorVersion = browserVersion.split('.')[0];
68
- const versionUrl = `${CDN_URL}/LATEST_RELEASE_${majorVersion}`;
67
+
68
+ let platform;
69
+ if (os.platform() == 'linux') {
70
+ platform = 'LINUX';
71
+ } else if (os.platform() == 'darwin') {
72
+ platform = 'MACOS';
73
+ } else if (os.platform() == 'win32') {
74
+ platform = 'WINDOWS';
75
+ } else {
76
+ throw new Error(`Unrecognized platform: ${os.platform()}`);
77
+ }
78
+
79
+ const versionUrl = `${CDN_URL}/LATEST_RELEASE_${majorVersion}_${platform}`;
69
80
  return await InstallerUtils.fetchVersionUrl(versionUrl, 'UTF-16LE');
70
81
  }
71
82
 
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.getWindowsRegistryVersion(
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/package.json CHANGED
@@ -1,8 +1,11 @@
1
1
  {
2
2
  "name": "webdriver-installer",
3
- "version": "1.1.0",
3
+ "version": "1.1.4",
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"
package/utils.js CHANGED
@@ -22,6 +22,9 @@ const execFile = util.promisify(childProcess.execFile);
22
22
  const pipeline = util.promisify(stream.pipeline);
23
23
  const zipFromBuffer = util.promisify(yauzl.fromBuffer);
24
24
 
25
+ const WINDOWS_REGISTRY_APP_PATHS =
26
+ 'HKLM\\Software\\Microsoft\\Windows\\CurrentVersion\\App\ Paths\\';
27
+
25
28
  /**
26
29
  * A static utility class for driver installers to use for common operations.
27
30
  */
@@ -81,32 +84,37 @@ class InstallerUtils {
81
84
  /**
82
85
  * Get a version number from the Windows registry.
83
86
  *
84
- * @param {string} path
87
+ * @param {string} regPath
85
88
  * @param {string} key
86
89
  * @return {!Promise<?string>}
87
90
  */
88
- static async getWindowsRegistryVersion(path, key) {
91
+ static async getWindowsRegistryVersion(regPath, key) {
89
92
  if (os.platform() != 'win32') {
90
93
  return null;
91
94
  }
92
95
 
93
- const result = await regQuery(path, '64');
94
- if (!result[path].exists || !result[path].values[key]) {
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(regPath, '64');
99
+ if (!result[regPath].exists || !result[regPath].values[key]) {
100
+ result = await regQuery(regPath, '32');
101
+ }
102
+ if (!result[regPath].exists || !result[regPath].values[key]) {
95
103
  return null;
96
104
  }
97
105
 
98
- return result[path].values[key].value;
106
+ return result[regPath].values[key].value;
99
107
  }
100
108
 
101
109
  /**
102
110
  * Test if a file exists.
103
111
  *
104
- * @param {path}
112
+ * @param {filePath}
105
113
  * @return {!Promise<boolean}
106
114
  */
107
- static async fileExists(path) {
115
+ static async fileExists(filePath) {
108
116
  try {
109
- await fsPromises.stat(path);
117
+ await fsPromises.stat(filePath);
110
118
  return true;
111
119
  } catch (error) {
112
120
  return false;
@@ -116,23 +124,31 @@ class InstallerUtils {
116
124
  /**
117
125
  * Get a version number from the metadata of a Windows executable.
118
126
  *
119
- * @param {string} path
127
+ * @param {string} executablePath
120
128
  * @return {!Promise<?string>}
121
129
  */
122
- static async getWindowsExeVersion(path) {
130
+ static async getWindowsExeVersion(executablePath) {
123
131
  if (os.platform() != 'win32') {
124
132
  return null;
125
133
  }
126
134
 
127
- if (!(await InstallerUtils.fileExists(path))) {
128
- // No such file. Avoid the need to parse "not found" errors from
129
- // powershell output.
130
- return null;
135
+ if (!(await InstallerUtils.fileExists(executablePath))) {
136
+ // No such file.
137
+ // If it's a relative path, ask the registry for a full one.
138
+ if (!executablePath.includes('/') && !executablePath.includes('\\')) {
139
+ executablePath = await InstallerUtils.getWindowsRegistryVersion(
140
+ WINDOWS_REGISTRY_APP_PATHS + executablePath,
141
+ '');
142
+ if (!executablePath ||
143
+ !(await InstallerUtils.fileExists(executablePath))) {
144
+ return null;
145
+ }
146
+ }
131
147
  }
132
148
 
133
149
  const result = await InstallerUtils.runCommand([
134
150
  'powershell',
135
- `(Get-Item "${path}").VersionInfo.ProductVersion`,
151
+ `(Get-Item "${executablePath}").VersionInfo.ProductVersion`,
136
152
  ]);
137
153
 
138
154
  const output = result.stdout.trim();
@@ -315,7 +331,7 @@ class InstallerUtils {
315
331
  // permission errors overwriting it. Unlinking it first will ensure the
316
332
  // newly-written file is a fresh filesystem inode that doesn't conflict
317
333
  // with what's running.
318
- if (await InstallerUtils.fileExists(path)) {
334
+ if (await InstallerUtils.fileExists(outputPath)) {
319
335
  await fsPromises.unlink(outputPath);
320
336
  }
321
337