From df1daddeef5c63a4e27cca0d3c9b40ecbf1ed230 Mon Sep 17 00:00:00 2001 From: Mykola Mokhnach Date: Fri, 26 Jan 2024 10:12:09 +0100 Subject: [PATCH 1/2] chore: Remove on-commit hooks --- .husky/commit-msg | 4 ---- .husky/pre-commit | 4 ---- commitlint.config.js | 11 ----------- lib/commands/context/helpers.js | 20 +++++++++++--------- lib/commands/device/common.js | 2 +- lib/commands/lock/exports.js | 1 - lib/commands/resources.js | 2 +- lib/index.ts | 10 +++++----- package.json | 15 ++------------- 9 files changed, 20 insertions(+), 49 deletions(-) delete mode 100755 .husky/commit-msg delete mode 100755 .husky/pre-commit delete mode 100644 commitlint.config.js diff --git a/.husky/commit-msg b/.husky/commit-msg deleted file mode 100755 index 424f44d4..00000000 --- a/.husky/commit-msg +++ /dev/null @@ -1,4 +0,0 @@ -#!/usr/bin/env sh -. "$(dirname -- "$0")/_/husky.sh" - -npm run lint:commit -- --edit ${1} diff --git a/.husky/pre-commit b/.husky/pre-commit deleted file mode 100755 index 26e0c553..00000000 --- a/.husky/pre-commit +++ /dev/null @@ -1,4 +0,0 @@ -#!/usr/bin/env sh -. "$(dirname -- "$0")/_/husky.sh" - -npm run lint:staged diff --git a/commitlint.config.js b/commitlint.config.js deleted file mode 100644 index dd1f77d7..00000000 --- a/commitlint.config.js +++ /dev/null @@ -1,11 +0,0 @@ -module.exports = { - extends: ['@commitlint/config-conventional'], - rules: { - 'body-leading-blank': [0], - 'body-max-line-length': [0], - 'footer-max-line-length': [0], - 'header-max-length': [0], - 'subject-case': [0], - 'subject-full-stop': [0], - }, -}; diff --git a/lib/commands/context/helpers.js b/lib/commands/context/helpers.js index 366edf02..fa90424d 100644 --- a/lib/commands/context/helpers.js +++ b/lib/commands/context/helpers.js @@ -96,15 +96,17 @@ async function getFreePort() { * @returns {Promise} */ async function cdpGetRequest(host, port, endpoint) { - return (await axios({ - url: `http://${host}:${port}${endpoint}`, - timeout: CDP_REQ_TIMEOUT, - // We need to set this from Node.js v19 onwards. - // Otherwise, in situation with multiple webviews, - // the preceding webview pages will be incorrectly retrieved as the current ones. - // https://nodejs.org/en/blog/announcements/v19-release-announce#https11-keepalive-by-default - httpAgent: new http.Agent({keepAlive: false}), - })).data; + return ( + await axios({ + url: `http://${host}:${port}${endpoint}`, + timeout: CDP_REQ_TIMEOUT, + // We need to set this from Node.js v19 onwards. + // Otherwise, in situation with multiple webviews, + // the preceding webview pages will be incorrectly retrieved as the current ones. + // https://nodejs.org/en/blog/announcements/v19-release-announce#https11-keepalive-by-default + httpAgent: new http.Agent({keepAlive: false}), + }) + ).data; } /** diff --git a/lib/commands/device/common.js b/lib/commands/device/common.js index 15d2b9d9..ee744dfe 100644 --- a/lib/commands/device/common.js +++ b/lib/commands/device/common.js @@ -87,7 +87,7 @@ export async function getDeviceInfoFromCaps() { ((!_.includes(this.opts.platformVersion, '.') && /** @type {semver.SemVer} */ (semverPV).major === /** @type {semver.SemVer} */ (semverDO).major) || - (/** @type {semver.SemVer} */ (semverPV).major === + /** @type {semver.SemVer} */ ((semverPV).major === /** @type {semver.SemVer} */ (semverDO).major && /** @type {semver.SemVer} */ (semverPV).minor === /** @type {semver.SemVer} */ (semverDO).minor)) && diff --git a/lib/commands/lock/exports.js b/lib/commands/lock/exports.js index 219e468d..6c683b4c 100644 --- a/lib/commands/lock/exports.js +++ b/lib/commands/lock/exports.js @@ -17,7 +17,6 @@ import { } from './helpers'; import _ from 'lodash'; - /** * @this {AndroidDriver} * @param {import('../types').LockOpts} opts diff --git a/lib/commands/resources.js b/lib/commands/resources.js index 2f10422c..f950dc56 100644 --- a/lib/commands/resources.js +++ b/lib/commands/resources.js @@ -66,7 +66,7 @@ async function extractStringsFromResources(language, opts = null) { app = await this.adb.pullApk(caps.appPackage, tmpRoot); } catch (e) { throw new Error( - `Could not extract app strings, failed to pull an apk from '${caps.appPackage}'. Original error: ${e.message}` + `Could not extract app strings, failed to pull an apk from '${caps.appPackage}'. Original error: ${e.message}`, ); } } diff --git a/lib/index.ts b/lib/index.ts index cd9e2bfd..00c60ccc 100644 --- a/lib/index.ts +++ b/lib/index.ts @@ -2,12 +2,12 @@ import {install} from 'source-map-support'; install(); import {AndroidDriver} from './driver'; -import { getChromePkg } from './commands/context/helpers'; -import { parseArray, requireArgs } from './utils'; +import {getChromePkg} from './commands/context/helpers'; +import {parseArray, requireArgs} from './utils'; export const utils = { - getChromePkg, - parseArray, - requireArgs, + getChromePkg, + parseArray, + requireArgs, } as const; export type * from './commands/types'; export {ANDROID_DRIVER_CONSTRAINTS as commonCapConstraints} from './constraints'; diff --git a/package.json b/package.json index b8a05f81..454ee955 100644 --- a/package.json +++ b/package.json @@ -36,19 +36,12 @@ "clean": "npm run build -- --clean", "dev": "npm run build -- --watch", "lint": "eslint .", - "lint:commit": "commitlint", "lint:fix": "npm run lint -- --fix", - "lint:staged": "lint-staged", - "prepare": "husky install; npm run rebuild", + "prepare": "npm run rebuild", "rebuild": "npm run clean; npm run build", + "format": "prettier -w ./lib", "test": "mocha --exit --timeout 1m \"./test/unit/**/*-specs.js\"" }, - "lint-staged": { - "*.(js|ts)": [ - "eslint --fix", - "prettier --write" - ] - }, "prettier": { "bracketSpacing": false, "printWidth": 100, @@ -80,8 +73,6 @@ "@appium/test-support": "^3.0.20", "@appium/tsconfig": "^0.x", "@appium/types": "^0.x", - "@commitlint/cli": "^18.0.0", - "@commitlint/config-conventional": "^18.0.0", "@semantic-release/changelog": "^6.0.1", "@semantic-release/git": "^10.0.1", "@types/bluebird": "^3.5.38", @@ -110,8 +101,6 @@ "eslint-plugin-import": "^2.27.5", "eslint-plugin-mocha": "^10.1.0", "eslint-plugin-promise": "^6.1.1", - "husky": "^8.0.3", - "lint-staged": "^15.0.1", "mocha": "^10.0.0", "prettier": "^3.0.1", "rimraf": "^5.0.0", From 3b2516d2833967ef5ff0d6093a161402cd7fa6c6 Mon Sep 17 00:00:00 2001 From: Mykola Mokhnach Date: Fri, 26 Jan 2024 10:20:52 +0100 Subject: [PATCH 2/2] fix format --- lib/commands/device/common.js | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/lib/commands/device/common.js b/lib/commands/device/common.js index ee744dfe..4f44fce5 100644 --- a/lib/commands/device/common.js +++ b/lib/commands/device/common.js @@ -83,14 +83,13 @@ export async function getDeviceInfoFromCaps() { continue; } + const pvMajor = /** @type {semver.SemVer} */ (semverPV).major; + const pvMinor = /** @type {semver.SemVer} */ (semverPV).minor; + const dvMajor = /** @type {semver.SemVer} */ (semverDO).major; + const dvMinor = /** @type {semver.SemVer} */ (semverDO).minor; if ( - ((!_.includes(this.opts.platformVersion, '.') && - /** @type {semver.SemVer} */ (semverPV).major === - /** @type {semver.SemVer} */ (semverDO).major) || - /** @type {semver.SemVer} */ ((semverPV).major === - /** @type {semver.SemVer} */ (semverDO).major && - /** @type {semver.SemVer} */ (semverPV).minor === - /** @type {semver.SemVer} */ (semverDO).minor)) && + ((!_.includes(this.opts.platformVersion, '.') && pvMajor === dvMajor) || + (pvMajor === dvMajor && pvMinor === dvMinor)) && // Got a partial match - make sure we consider the most recent // device version available on the host system ((partialMatchCandidate && semver.gt(deviceOS, _.values(partialMatchCandidate)[0])) ||