webdriver-installer 1.1.6 → 1.1.7

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,13 @@
1
1
  # Changelog
2
2
 
3
+ ## [1.1.7](https://github.com/shaka-project/webdriver-installer/compare/v1.1.6...v1.1.7) (2023-08-17)
4
+
5
+
6
+ ### Bug Fixes
7
+
8
+ * Fix Chromedriver download for version 115+ ([#28](https://github.com/shaka-project/webdriver-installer/issues/28)) ([1d17e40](https://github.com/shaka-project/webdriver-installer/commit/1d17e40c70be980067f4972d538ddb55db88c759))
9
+ * Get the correct binary for Edge on M1 macs ([#30](https://github.com/shaka-project/webdriver-installer/issues/30)) ([b5303ea](https://github.com/shaka-project/webdriver-installer/commit/b5303ea26653cee24a122208a1e7088021a77ebe))
10
+
3
11
  ## [1.1.6](https://github.com/shaka-project/webdriver-installer/compare/v1.1.5...v1.1.6) (2023-07-19)
4
12
 
5
13
 
package/chrome.js CHANGED
@@ -11,6 +11,9 @@ const os = require('os');
11
11
  const path = require('path');
12
12
 
13
13
  const CDN_URL = 'https://chromedriver.storage.googleapis.com';
14
+ const VERSION_DATA_URL = 'https://googlechromelabs.github.io/chrome-for-testing/latest-versions-per-milestone-with-downloads.json';
15
+ // Chrome distribution changed in version 115.
16
+ const NEW_CHROME_DISTRIBUTION_VERSION = 115;
14
17
 
15
18
  /**
16
19
  * An installer for chromedriver for desktop Chrome.
@@ -64,25 +67,59 @@ class ChromeWebDriverInstaller extends WebDriverInstallerBase {
64
67
  */
65
68
  async getBestDriverVersion(browserVersion) {
66
69
  const idealMajorVersion = parseInt(browserVersion.split('.')[0], 10);
67
- return await InstallerUtils.fetchVersionUrlWithAutomaticDowngrade(
68
- idealMajorVersion,
69
- /* minMajorVersion */ idealMajorVersion - 2,
70
- (majorVersion) => `${CDN_URL}/LATEST_RELEASE_${majorVersion}`);
70
+
71
+ if (idealMajorVersion < NEW_CHROME_DISTRIBUTION_VERSION) {
72
+ return await InstallerUtils.fetchVersionUrl(
73
+ `${CDN_URL}/LATEST_RELEASE_${idealMajorVersion}`);
74
+ } else {
75
+ const data = await this.getVersionData_();
76
+
77
+ // Fall back on the major version if necessary.
78
+ // We haven't seen this become necessary yet since the new distribution
79
+ // mechanism debuted, but better safe than sorry.
80
+ let majorVersion = idealMajorVersion;
81
+ while (majorVersion >= NEW_CHROME_DISTRIBUTION_VERSION) {
82
+ if (majorVersion in data['milestones']) {
83
+ return data['milestones'][majorVersion]['version'];
84
+ }
85
+ majorVersion -= 1;
86
+ }
87
+
88
+ throw new Error(`Unable to locate chromedriver ${idealMajorVersion}!`);
89
+ }
71
90
  }
72
91
 
73
92
  /**
74
93
  * @param {string} driverVersion
75
94
  * @param {string} outputDirectory
76
- * @param {string=} outputName
77
95
  * @return {!Promise}
78
96
  */
79
97
  async install(driverVersion, outputDirectory) {
98
+ const majorVersion = parseInt(driverVersion.split('.')[0], 10);
99
+
100
+ if (majorVersion < NEW_CHROME_DISTRIBUTION_VERSION) {
101
+ await this.installOld_(driverVersion, outputDirectory);
102
+ } else {
103
+ await this.installNew_(majorVersion, driverVersion, outputDirectory);
104
+ }
105
+ }
106
+
107
+ /**
108
+ * @param {string} driverVersion
109
+ * @param {string} outputDirectory
110
+ * @return {!Promise}
111
+ */
112
+ async installOld_(driverVersion, outputDirectory) {
80
113
  let platform;
81
114
 
82
115
  if (os.platform() == 'linux') {
83
116
  platform = 'linux64';
84
117
  } else if (os.platform() == 'darwin') {
85
- platform = 'mac64';
118
+ if (process.arch == 'arm64') {
119
+ platform = 'mac_arm64';
120
+ } else {
121
+ platform = 'mac64';
122
+ }
86
123
  } else if (os.platform() == 'win32') {
87
124
  platform = 'win32';
88
125
  } else {
@@ -106,6 +143,73 @@ class ChromeWebDriverInstaller extends WebDriverInstallerBase {
106
143
  archiveUrl, binaryName, outputName,
107
144
  outputDirectory, /* isZip= */ true);
108
145
  }
146
+
147
+ /**
148
+ * @param {number} majorVersion
149
+ * @param {string} driverVersion
150
+ * @param {string} outputDirectory
151
+ * @return {!Promise}
152
+ */
153
+ async installNew_(majorVersion, driverVersion, outputDirectory) {
154
+ let platform;
155
+
156
+ if (os.platform() == 'linux') {
157
+ platform = 'linux64';
158
+ } else if (os.platform() == 'darwin') {
159
+ if (process.arch == 'arm64') {
160
+ platform = 'mac-arm64';
161
+ } else {
162
+ platform = 'mac-x64';
163
+ }
164
+ } else if (os.platform() == 'win32') {
165
+ platform = 'win64';
166
+ } else {
167
+ throw new Error(`Unrecognized platform: ${os.platform()}`);
168
+ }
169
+
170
+ let binaryName = `chromedriver-${platform}/chromedriver`;
171
+ if (os.platform() == 'win32') {
172
+ binaryName += '.exe';
173
+ }
174
+
175
+ let outputName = this.getDriverName();
176
+ if (os.platform() == 'win32') {
177
+ outputName += '.exe';
178
+ }
179
+
180
+ const data = await this.getVersionData_();
181
+ const downloads = data['milestones'][majorVersion]['downloads']['chromedriver'];
182
+
183
+ let archiveUrl;
184
+ for (const download of downloads) {
185
+ if (download['platform'] == platform) {
186
+ archiveUrl = download['url'];
187
+ break;
188
+ }
189
+ }
190
+
191
+ if (!archiveUrl) {
192
+ throw new Error(
193
+ `Unable to locate chromedriver ${majorVersion} for ${platform}!`);
194
+ }
195
+
196
+ return await InstallerUtils.installBinary(
197
+ archiveUrl, binaryName, outputName,
198
+ outputDirectory, /* isZip= */ true);
199
+ }
200
+
201
+ /**
202
+ * @return {!Object}
203
+ * @private
204
+ */
205
+ async getVersionData_() {
206
+ if (!this.versionDataCache_) {
207
+ const response = await InstallerUtils.fetchUrl(VERSION_DATA_URL);
208
+ this.versionDataCache_ = await response.json();
209
+ }
210
+
211
+ return this.versionDataCache_;
212
+ }
109
213
  }
110
214
 
111
215
  module.exports = {ChromeWebDriverInstaller};
package/edge.js CHANGED
@@ -90,7 +90,6 @@ class EdgeWebDriverInstaller extends WebDriverInstallerBase {
90
90
  /**
91
91
  * @param {string} driverVersion
92
92
  * @param {string} outputDirectory
93
- * @param {string=} outputName
94
93
  * @return {!Promise}
95
94
  */
96
95
  async install(driverVersion, outputDirectory) {
@@ -99,7 +98,11 @@ class EdgeWebDriverInstaller extends WebDriverInstallerBase {
99
98
  if (os.platform() == 'linux') {
100
99
  platform = 'linux64';
101
100
  } else if (os.platform() == 'darwin') {
102
- platform = 'mac64';
101
+ if (process.arch == 'arm64') {
102
+ platform = 'mac64_m1';
103
+ } else {
104
+ platform = 'mac64';
105
+ }
103
106
  } else if (os.platform() == 'win32') {
104
107
  platform = 'win64';
105
108
  } else {
package/firefox.js CHANGED
@@ -74,7 +74,6 @@ class FirefoxWebDriverInstaller extends WebDriverInstallerBase {
74
74
  /**
75
75
  * @param {string} driverVersion
76
76
  * @param {string} outputDirectory
77
- * @param {string=} outputName
78
77
  * @return {!Promise}
79
78
  */
80
79
  async install(driverVersion, outputDirectory) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "webdriver-installer",
3
- "version": "1.1.6",
3
+ "version": "1.1.7",
4
4
  "description": "Install the right WebDriver version for your local browsers, automatically.",
5
5
  "main": "main.js",
6
6
  "bin": {