appium-geckodriver 2.2.1 → 2.2.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.
@@ -1,6 +1,5 @@
1
1
  import axios from 'axios';
2
2
  import * as semver from 'semver';
3
- import _ from 'lodash';
4
3
  import path from 'node:path';
5
4
  import { tmpdir } from 'node:os';
6
5
  import { log } from '../build/lib/logger.js';
@@ -21,7 +20,8 @@ const API_TIMEOUT_MS = 45 * 1000;
21
20
  const STABLE_VERSION = 'stable';
22
21
  const EXT_TAR_GZ = '.tar.gz';
23
22
  const EXT_ZIP = '.zip';
24
- const EXT_REGEXP = new RegExp(`(${_.escapeRegExp(EXT_TAR_GZ)}|${_.escapeRegExp(EXT_ZIP)})$`);
23
+ const escapeRegExp = (value) => value.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
24
+ const EXT_REGEXP = new RegExp(`(${escapeRegExp(EXT_TAR_GZ)}|${escapeRegExp(EXT_ZIP)})$`);
25
25
  const ARCHIVE_NAME_PREFIX = 'geckodriver-v';
26
26
  const ARCH_MAPPING = Object.freeze({
27
27
  ia32: '32',
@@ -56,7 +56,7 @@ function parseNextPageUrl(headers) {
56
56
  }
57
57
 
58
58
  for (const part of headers.link.split(';')) {
59
- const [rel, pageUrl] = part.split(',').map(_.trim);
59
+ const [rel, pageUrl] = part.split(',').map((item) => item.trim());
60
60
  if (rel === 'rel="next"' && pageUrl) {
61
61
  return pageUrl.replace(/^<|>$/g, '');
62
62
  }
@@ -123,8 +123,8 @@ async function listReleases() {
123
123
  const assetName = asset?.name;
124
124
  const downloadUrl = asset?.browser_download_url;
125
125
  if (
126
- !_.startsWith(assetName, ARCHIVE_NAME_PREFIX)
127
- || !(_.endsWith(assetName, EXT_TAR_GZ) || _.endsWith(assetName, EXT_ZIP))
126
+ !assetName?.startsWith(ARCHIVE_NAME_PREFIX)
127
+ || !(assetName?.endsWith(EXT_TAR_GZ) || assetName?.endsWith(EXT_ZIP))
128
128
  || !downloadUrl
129
129
  ) {
130
130
  continue;
@@ -154,7 +154,7 @@ function selectRelease(releases, version) {
154
154
  const stableReleasesAsc = releases
155
155
  .filter(({isDraft, isPrerelease}) => !isDraft && !isPrerelease)
156
156
  .toSorted((a, b) => a.version.compare(b.version));
157
- const dstRelease = _.last(stableReleasesAsc);
157
+ const dstRelease = stableReleasesAsc.at(-1);
158
158
  if (!dstRelease) {
159
159
  throw new Error(`Cannot find any stable GeckoDriver release: ${JSON.stringify(releases)}`);
160
160
  }
@@ -180,7 +180,7 @@ function selectRelease(releases, version) {
180
180
  * @returns {ReleaseAsset}
181
181
  */
182
182
  function selectAsset(release) {
183
- if (_.isEmpty(release.assets)) {
183
+ if (release.assets.length === 0) {
184
184
  throw new Error(`GeckoDriver v${release.version} does not contain any matching releases`);
185
185
  }
186
186
  const dstPlatform = PLATFORM_MAPPING[process.platform];
@@ -189,7 +189,7 @@ function selectAsset(release) {
189
189
  /** @type {(filterFunc: (string) => boolean) => null|ReleaseAsset} */
190
190
  const findAssetMatch = (filterFunc) => {
191
191
  for (const asset of release.assets) {
192
- if (!dstPlatform || !_.includes(asset.name, `-${dstPlatform}`)) {
192
+ if (!dstPlatform || !asset.name.includes(`-${dstPlatform}`)) {
193
193
  continue;
194
194
  }
195
195
  const nameWoExt = asset.name.replace(EXT_REGEXP, '');
@@ -203,8 +203,8 @@ function selectAsset(release) {
203
203
  // Try to find an exact match
204
204
  const exactMatch = findAssetMatch(
205
205
  (nameWoExt) =>
206
- (dstArch === 'aarch64' && _.endsWith(nameWoExt, `-${dstArch}`))
207
- || (['64', '32'].includes(dstArch) && _.endsWith(nameWoExt, `-${dstPlatform}${dstArch}`))
206
+ (dstArch === 'aarch64' && nameWoExt.endsWith(`-${dstArch}`))
207
+ || (['64', '32'].includes(dstArch) && nameWoExt.endsWith(`-${dstPlatform}${dstArch}`))
208
208
  );
209
209
  if (exactMatch) {
210
210
  return exactMatch;
@@ -212,8 +212,8 @@ function selectAsset(release) {
212
212
  // If no exact match has been been found then try a loose one
213
213
  const looseMatch = findAssetMatch(
214
214
  (nameWoExt) =>
215
- _.endsWith(nameWoExt, `-${dstPlatform}`)
216
- || (dstArch === '64' && _.endsWith(nameWoExt, `-${dstPlatform}32`))
215
+ nameWoExt.endsWith(`-${dstPlatform}`)
216
+ || (dstArch === '64' && nameWoExt.endsWith(`-${dstPlatform}32`))
217
217
  );
218
218
  if (looseMatch) {
219
219
  return looseMatch;