mirror of
https://github.com/appium/appium.git
synced 2026-11-01 23:00:54 +08:00
Compare commits
90
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ed20e00754 | ||
|
|
9e60e80b13 | ||
|
|
1a5b8cca2d | ||
|
|
ced560206b | ||
|
|
7dbf6f2cd3 | ||
|
|
84c49b1529 | ||
|
|
81bc527be6 | ||
|
|
2e909478e9 | ||
|
|
00ae1625d7 | ||
|
|
88293f8039 | ||
|
|
54a4a8da03 | ||
|
|
598b255e8d | ||
|
|
63a5c22127 | ||
|
|
af066eb5c3 | ||
|
|
e5254b5b45 | ||
|
|
c18eb03261 | ||
|
|
d0ebbaa0c6 | ||
|
|
1629f858f8 | ||
|
|
2d124323c5 | ||
|
|
901ac711c4 | ||
|
|
7982747677 | ||
|
|
26bb0f95b9 | ||
|
|
c161ec2bad | ||
|
|
1c4737c8b4 | ||
|
|
6b2f5668e9 | ||
|
|
d904477b4c | ||
|
|
da1da3fe13 | ||
|
|
307c81a24b | ||
|
|
f4c37985eb | ||
|
|
78c6794253 | ||
|
|
c416a86120 | ||
|
|
38f86900da | ||
|
|
40fc097eda | ||
|
|
0097c8e52e | ||
|
|
1ccf857a4b | ||
|
|
c34f2eb897 | ||
|
|
1d7c58ff26 | ||
|
|
d78ca63e60 | ||
|
|
4f171ee92f | ||
|
|
fd2c72fd88 | ||
|
|
3bf406015e | ||
|
|
56499eb997 | ||
|
|
bd10bffec4 | ||
|
|
b1ee41cfc7 | ||
|
|
cc7f5f4a52 | ||
|
|
a98d9c33c7 | ||
|
|
1a2260bb15 | ||
|
|
4c52fdf1d0 | ||
|
|
a959eec9cf | ||
|
|
e96724077e | ||
|
|
dfae94e7f3 | ||
|
|
0497090a90 | ||
|
|
19277f6e14 | ||
|
|
39a59c8bb3 | ||
|
|
2766dcca4c | ||
|
|
f5b112bcca | ||
|
|
5d6458b611 | ||
|
|
d47c805468 | ||
|
|
4c61d533b8 | ||
|
|
325d237207 | ||
|
|
8f63dabb5d | ||
|
|
5a555090c5 | ||
|
|
81ed72f19d | ||
|
|
f34c75c650 | ||
|
|
39d68f17a2 | ||
|
|
528dcfe324 | ||
|
|
4d7f39b5f8 | ||
|
|
8594d13bf6 | ||
|
|
a0b434dff7 | ||
|
|
19a5ae4537 | ||
|
|
fc831d2475 | ||
|
|
cb1a97fc8e | ||
|
|
a506a0a357 | ||
|
|
63a429c53b | ||
|
|
922725b4f1 | ||
|
|
f0ebe2e02f | ||
|
|
2ca1581870 | ||
|
|
6aec50b074 | ||
|
|
426830d14a | ||
|
|
9538c34131 | ||
|
|
5d24ea1ad2 | ||
|
|
db73971018 | ||
|
|
7b17754786 | ||
|
|
ba07d2a854 | ||
|
|
ee365ad168 | ||
|
|
5e351dc503 | ||
|
|
f512e596eb | ||
|
|
3eec0227a2 | ||
|
|
ea42548442 | ||
|
|
e1fa6c2133 |
@@ -10,12 +10,6 @@
|
||||
"files": "packages/*/test/**/*",
|
||||
"rules": {"func-names": "off"}
|
||||
},
|
||||
{
|
||||
"files": ["packages/*/index.js", "packages/*/scripts/**/*.js", "test/*.js"],
|
||||
"parserOptions": {
|
||||
"sourceType": "script"
|
||||
}
|
||||
},
|
||||
{
|
||||
"files": [
|
||||
"packages/appium/support.js",
|
||||
@@ -27,9 +21,17 @@
|
||||
}
|
||||
},
|
||||
{
|
||||
"files": ["./test/setup.js", "./**/scripts/**/*.js", "./packages/*/index.js"],
|
||||
"files": [
|
||||
"./test/setup.js",
|
||||
"./**/scripts/**/*.js",
|
||||
"./packages/*/index.js",
|
||||
"./packages/docutils/bin/appium-docs.js"
|
||||
],
|
||||
"rules": {
|
||||
"@typescript-eslint/no-var-requires": "off"
|
||||
},
|
||||
"parserOptions": {
|
||||
"sourceType": "script"
|
||||
}
|
||||
},
|
||||
{
|
||||
|
||||
@@ -6,6 +6,20 @@ body:
|
||||
- type: markdown
|
||||
attributes:
|
||||
value: ':stop_sign: _For support questions, please visit [http://discuss.appium.io](http://discuss.appium.io) instead._'
|
||||
- type: checkboxes
|
||||
attributes:
|
||||
label: 'Do I have the most recent component updates?'
|
||||
description: 'Appium 1-related issues are going to be ignored as this version has reached its end of life.'
|
||||
options:
|
||||
- label: 'I use the most recent available driver/plugin and server versions'
|
||||
required: true
|
||||
- type: checkboxes
|
||||
attributes:
|
||||
label: 'Is the component officially supported by the Appium team?'
|
||||
description: 'Make sure you report an issue for a component which is officially supported/maintained by the Appium team.'
|
||||
options:
|
||||
- label: 'I have verified the component repository is present under the Appium organization in GitHub'
|
||||
required: true
|
||||
- type: checkboxes
|
||||
attributes:
|
||||
label: 'Is there an existing issue for this?'
|
||||
@@ -34,7 +48,7 @@ body:
|
||||
An easy way to get started is to copy [sample code](https://github.com/appium/appium/tree/master/packages/appium/sample-code) and modify it accordingly.
|
||||
|
||||
If the result is more than a screenful of text _or_ requires multiple files, please:
|
||||
|
||||
|
||||
- _Attach_ (do not paste) it to this textarea, _or_
|
||||
- Put it in a [Gist](https://gist.github.com) and paste the link, _or_
|
||||
- Provide a link to a new or existing public repository exhibiting the issue
|
||||
@@ -46,14 +60,12 @@ body:
|
||||
description: 'Please provide the following information about your environment; feel free to remove any items which are not relevant.'
|
||||
value: |
|
||||
- Operating system:
|
||||
- If running via `appium` CLI...
|
||||
- Appium CLI version (output of `appium --version`):
|
||||
- Node.js version (output of `node --version`):
|
||||
- `npm` version (output of `npm --version`):
|
||||
- Last `appium` version which did _not_ exhibit the problem:
|
||||
- If running Appium Desktop, its version:
|
||||
- Appium server version (output of `appium --version`):
|
||||
- Appium driver(s) and their version(s):
|
||||
- Appium plugin(s) and their version(s):
|
||||
- Node.js version (output of `node --version`):
|
||||
- `npm` version (output of `npm --version`):
|
||||
- Last component(s) version which did _not_ exhibit the problem:
|
||||
- Platform and version under test:
|
||||
- Real device or emulator/simulator:
|
||||
validations:
|
||||
@@ -63,9 +75,9 @@ body:
|
||||
label: 'Link to Appium Logs'
|
||||
description: |
|
||||
Create a [Gist](https://gist.github.com)—which contains your _full_ Appium logs—and link it here. Alternatively, you can attach a logfile to this issue (drag it into the "Further Information" field below).
|
||||
|
||||
|
||||
:warning: _Remember to redact or remove any sensitive information!_
|
||||
placeholder: 'https://gist.github.com/...'
|
||||
placeholder: 'https://gist.github.com/...'
|
||||
- type: textarea
|
||||
attributes:
|
||||
label: Futher Information
|
||||
|
||||
@@ -44,11 +44,15 @@ permissions:
|
||||
jobs:
|
||||
test:
|
||||
name: Tests
|
||||
runs-on: ubuntu-latest
|
||||
strategy:
|
||||
matrix:
|
||||
node-version: [14.x, 16.x, 18.x]
|
||||
|
||||
node-version: [16.x, 18.x, 20.x]
|
||||
os:
|
||||
- ubuntu-latest
|
||||
- windows-latest
|
||||
# TODO: Enable below envs after all tests have been verified green
|
||||
# - macos-latest
|
||||
runs-on: ${{ matrix.os }}
|
||||
steps:
|
||||
- uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab # v3
|
||||
- name: Use Node.js ${{ matrix.node-version }}
|
||||
@@ -56,7 +60,15 @@ jobs:
|
||||
with:
|
||||
node-version: ${{ matrix.node-version }}
|
||||
cache: 'npm'
|
||||
- name: Install latest npm
|
||||
- name: Install latest npm (win)
|
||||
if: ${{ matrix.os == 'windows-latest' }}
|
||||
# for some reason there's a bug in upgrading npm on win, have to install a specific version first
|
||||
# https://github.com/actions/setup-node/issues/623
|
||||
run: |
|
||||
npm install -g npm@8.3.1
|
||||
npm install -g npm@latest
|
||||
- name: Install latest npm (non-win)
|
||||
if: ${{ matrix.os != 'windows-latest' }}
|
||||
run: npm install -g npm
|
||||
- name: Install dependencies
|
||||
uses: bahmutov/npm-install@1a235c31658a322a3b024444759650ee6345c26d # tag=v1
|
||||
|
||||
@@ -14,8 +14,7 @@ jobs:
|
||||
runs-on: ${{ matrix.os }}
|
||||
strategy:
|
||||
matrix:
|
||||
# node-version: [14.x, 16.x, 18.x]
|
||||
node-version: [16.x, 18.x]
|
||||
node-version: [16.x, 18.x, 20.x]
|
||||
os: [ubuntu-latest, windows-latest, macos-latest]
|
||||
steps:
|
||||
- name: Use Node.js ${{ matrix.node-version }}
|
||||
|
||||
Vendored
+5
@@ -0,0 +1,5 @@
|
||||
{
|
||||
"recommendations": [
|
||||
"stateful.runme"
|
||||
]
|
||||
}
|
||||
Generated
+921
-2300
File diff suppressed because it is too large
Load Diff
+14
-13
@@ -34,7 +34,7 @@
|
||||
"clean": "run-s clean:distfiles clean:workspaces",
|
||||
"clean:dangerously": "run-s clean:workspaces clean:force",
|
||||
"clean:deps": "lerna clean --yes",
|
||||
"clean:distfiles": "npx rimraf \"./packages/*/build\" \"./packages/*/**/.tsconfig.tsbuildinfo\"; npx nx reset",
|
||||
"clean:distfiles": "npx rimraf --glob \"./packages/*/build\" \"./packages/*/**/.tsconfig.tsbuildinfo\"; npx nx reset",
|
||||
"clean:interactive": "git clean -d -x -i",
|
||||
"clean:force": "git clean -d -x -f",
|
||||
"clean:workspaces": "lerna run clean || true",
|
||||
@@ -85,29 +85,30 @@
|
||||
},
|
||||
"devDependencies": {
|
||||
"@colors/colors": "1.5.0",
|
||||
"@commitlint/cli": "17.6.3",
|
||||
"@commitlint/config-conventional": "17.6.3",
|
||||
"@commitlint/cli": "17.6.5",
|
||||
"@commitlint/config-conventional": "17.6.5",
|
||||
"@tsconfig/node14": "1.0.3",
|
||||
"@types/chai": "4.3.5",
|
||||
"@types/chai-as-promised": "7.1.5",
|
||||
"@types/diff": "5.0.3",
|
||||
"@types/mocha": "10.0.1",
|
||||
"@types/node": "18.16.5",
|
||||
"@types/semver": "7.3.13",
|
||||
"@types/sinon": "10.0.14",
|
||||
"@types/node": "18.16.16",
|
||||
"@types/semver": "7.5.0",
|
||||
"@types/sinon": "10.0.15",
|
||||
"@types/sinon-chai": "3.2.9",
|
||||
"@types/source-map-support": "0.5.6",
|
||||
"@types/teen_process": "2.0.0",
|
||||
"@types/ws": "8.5.4",
|
||||
"@types/yargs": "17.0.24",
|
||||
"@typescript-eslint/eslint-plugin": "5.59.2",
|
||||
"@typescript-eslint/parser": "5.59.2",
|
||||
"@typescript-eslint/eslint-plugin": "5.59.8",
|
||||
"@typescript-eslint/parser": "5.59.8",
|
||||
"asyncbox": "2.9.4",
|
||||
"chai": "4.3.7",
|
||||
"chai-as-promised": "7.1.1",
|
||||
"chai-webdriverio-async": "2.7.0",
|
||||
"conventional-changelog-conventionalcommits": "5.0.0",
|
||||
"cpy-cli": "4.2.0",
|
||||
"eslint": "8.40.0",
|
||||
"eslint": "8.42.0",
|
||||
"eslint-config-prettier": "8.8.0",
|
||||
"eslint-find-rules": "4.1.0",
|
||||
"eslint-import-resolver-typescript": "3.5.5",
|
||||
@@ -119,11 +120,11 @@
|
||||
"get-port": "5.1.1",
|
||||
"handlebars": "4.7.7",
|
||||
"husky": "8.0.3",
|
||||
"json-schema-to-typescript": "12.0.0",
|
||||
"json-schema-to-typescript": "13.0.1",
|
||||
"lerna": "6.6.2",
|
||||
"lint-staged": "13.2.2",
|
||||
"log-symbols": "4.1.0",
|
||||
"midnight-smoker": "2.0.3",
|
||||
"midnight-smoker": "2.0.4",
|
||||
"mjpeg-consumer": "2.0.0",
|
||||
"mjpeg-server": "0.3.1",
|
||||
"mocha": "10.2.0",
|
||||
@@ -131,9 +132,9 @@
|
||||
"npm-run-all": "4.1.5",
|
||||
"prettier": "2.8.8",
|
||||
"rewiremock": "3.14.5",
|
||||
"rimraf": "3.0.2",
|
||||
"rimraf": "5.0.1",
|
||||
"serve-static": "1.15.0",
|
||||
"sinon": "15.0.4",
|
||||
"sinon": "15.1.0",
|
||||
"sinon-chai": "3.7.0",
|
||||
"sync-monorepo-packages": "1.0.2",
|
||||
"through2": "4.0.2",
|
||||
|
||||
@@ -3,6 +3,76 @@
|
||||
All notable changes to this project will be documented in this file.
|
||||
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
||||
|
||||
## [2.0.0-rc.3](https://github.com/appium/appium/compare/appium@2.0.0-rc.2...appium@2.0.0-rc.3) (2023-06-15)
|
||||
|
||||
**Note:** Version bump only for package appium
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
## [2.0.0-rc.2](https://github.com/appium/appium/compare/appium@2.0.0-rc.1...appium@2.0.0-rc.2) (2023-06-14)
|
||||
|
||||
**Note:** Version bump only for package appium
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
## [2.0.0-rc.1](https://github.com/appium/appium/compare/appium@2.0.0-beta.71...appium@2.0.0-rc.1) (2023-06-14)
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* **appium:** Allow to provide ipv6 addresses and handle broadcast addresses in logs ([#18674](https://github.com/appium/appium/issues/18674)) ([8f63dab](https://github.com/appium/appium/commit/8f63dabb5dca882e522026f243e3445f5418874b))
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* **appium:** update dependency winston to v3.9.0 ([a98d9c3](https://github.com/appium/appium/commit/a98d9c33c761af6870411721cc0d6c4491b43940))
|
||||
* **docutils:** update dependency yaml to v2.3.0 ([325d237](https://github.com/appium/appium/commit/325d2372078ee01e8fb58613ffd13417f2527151))
|
||||
* **docutils:** update dependency yaml to v2.3.1 ([1a2260b](https://github.com/appium/appium/commit/1a2260bb15d75e4f4c23551dc61529108a7b0d88))
|
||||
* ensure logServerAddress gets an actual URL ([#18754](https://github.com/appium/appium/issues/18754)) ([901ac71](https://github.com/appium/appium/commit/901ac711c4e2207f30d93ad177a332b7d6f23c38))
|
||||
* **support:** update dependency @types/semver to v7.5.0 ([528dcfe](https://github.com/appium/appium/commit/528dcfe324e75e48471cdb694448c2a09ec2d828))
|
||||
* **support:** update dependency semver to v7.5.1 ([5a55509](https://github.com/appium/appium/commit/5a555090c5322318f845415d743ee5c645fb94a0))
|
||||
* **types:** fix broken appium config schema types, temporarily ([fd2c72f](https://github.com/appium/appium/commit/fd2c72fd886ecaaf0f6588a328ff8a268a54fb55))
|
||||
* **types:** update dependency type-fest to v3.11.0 ([19277f6](https://github.com/appium/appium/commit/19277f6e14a56e52b4669d633e148ad4a3da2c7a))
|
||||
* **types:** update dependency type-fest to v3.11.1 ([56499eb](https://github.com/appium/appium/commit/56499eb997b551739bed628f057de7987674ea7f))
|
||||
|
||||
|
||||
|
||||
## [2.0.0-beta.71](https://github.com/appium/appium/compare/appium@2.0.0-beta.70...appium@2.0.0-beta.71) (2023-05-19)
|
||||
|
||||
**Note:** Version bump only for package appium
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
## [2.0.0-beta.70](https://github.com/appium/appium/compare/appium@2.0.0-beta.69...appium@2.0.0-beta.70) (2023-05-19)
|
||||
|
||||
**Note:** Version bump only for package appium
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
## [2.0.0-beta.69](https://github.com/appium/appium/compare/appium@2.0.0-beta.68...appium@2.0.0-beta.69) (2023-05-19)
|
||||
|
||||
**Note:** Version bump only for package appium
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
## [2.0.0-beta.68](https://github.com/appium/appium/compare/appium@2.0.0-beta.67...appium@2.0.0-beta.68) (2023-05-19)
|
||||
|
||||
**Note:** Version bump only for package appium
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
## [2.0.0-beta.67](https://github.com/appium/appium/compare/appium@2.0.0-beta.66...appium@2.0.0-beta.67) (2023-05-17)
|
||||
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
---
|
||||
title: Contributing to Appium
|
||||
cwd: ../../../../../
|
||||
---
|
||||
|
||||
This section of Appium's documentation is for those who are interested in contributing to Appium's
|
||||
@@ -16,8 +17,105 @@ already.
|
||||
|
||||
## Ways to Contribute
|
||||
|
||||
TODO
|
||||
The project offers a variety of ways to contribute, e.g.:
|
||||
|
||||
- contributing code
|
||||
- improving documentation
|
||||
- creating educational content (blog posts, tutorials, videos, etc.)
|
||||
- spreading the good word about the project (e.g. via Twitter)
|
||||
- filing bugs if you discover them while using Appium
|
||||
- making feature requests if you are missing something in the project or help triaging bugs
|
||||
- supporting users in the [Appium forum](https://discuss.appium.io/)
|
||||
|
||||
## The Appium Development Process
|
||||
|
||||
TODO
|
||||
To contribute to the Appium code base make sure to check out the Git repository.
|
||||
|
||||
!!! info
|
||||
|
||||
If you are VS Code user you can easily check out the project using [Runme](https://runme.dev/api/runme?repository=https%3A%2F%2Fgithub.com%2Fappium%2Fappium.git&fileToOpen=packages%2Fappium%2Fdocs%2Fen%2Fcontributing%2Findex.md).
|
||||
|
||||
It is advised to [fork](https://github.com/appium/appium/fork) before cloning it to your system.
|
||||
|
||||
```sh { name=clone }
|
||||
export GITHUB_USERNAME=<your-username>
|
||||
git clone git@github.com:$GITHUB_USERNAME/appium.git
|
||||
```
|
||||
|
||||
After cloning you can go ahead and install the project dependencies:
|
||||
|
||||
```sh { name=install }
|
||||
npm install
|
||||
```
|
||||
|
||||
From here on there are several things you can do.
|
||||
|
||||
### Watch Files
|
||||
|
||||
When developing Appium code we have to watch all JavaScript and TypeScript files to re-compile them after every change. You can run this watch process via:
|
||||
|
||||
```sh { name=watch, background=true }
|
||||
npm run dev
|
||||
```
|
||||
|
||||
### Start Appium in Dev-Mode
|
||||
|
||||
To test your changes you can run Appium in dev mode via:
|
||||
|
||||
```sh { name=start }
|
||||
npm start
|
||||
```
|
||||
|
||||
### Run Tests
|
||||
|
||||
The project maintains a set of different test variations you can run to verify the quality of the code.
|
||||
|
||||
#### Linting
|
||||
|
||||
Appium uses EsLint for static code analysis and linting. You can run these checks via:
|
||||
|
||||
```sh { name=test-linting }
|
||||
npm run lint
|
||||
```
|
||||
|
||||
#### Unit
|
||||
|
||||
Run via:
|
||||
|
||||
```sh { name=test-unit }
|
||||
npm run test:unit
|
||||
```
|
||||
|
||||
You can also run tests for specific workspaces, e.g.:
|
||||
|
||||
```sh { name=test-workspace }
|
||||
export APPIUM_WORKSPACE=@appium/doctor
|
||||
npm run test:unit -w $APPIUM_WORKSPACE
|
||||
```
|
||||
|
||||
#### Smoke and e2e Tests
|
||||
|
||||
Run via:
|
||||
|
||||
```sh { name=test-slow }
|
||||
npm run test:slow
|
||||
```
|
||||
|
||||
### Deploy Docs Locally
|
||||
|
||||
Our documentation system uses [MKDocs](https://www.mkdocs.org/) and therefor requires [Python](https://www.python.org/) to be installed on your system. You can run the docs by:
|
||||
|
||||
```sh
|
||||
# installing needed Python dependencies
|
||||
pip install -r packages/docutils/requirements.txt
|
||||
# build the project
|
||||
npm run build
|
||||
# run dev server
|
||||
npm run dev:docs
|
||||
```
|
||||
|
||||
You should be able to view the page at `http://127.0.0.1:8000/docs/en`:
|
||||
|
||||
```sh
|
||||
open http://127.0.0.1:8000/docs/en
|
||||
```
|
||||
|
||||
@@ -2,11 +2,11 @@
|
||||
title: Building Docs for Appium Extensions
|
||||
---
|
||||
|
||||
Once you've [built a driver](./build-drivers.md) or [built a plugin](./build-plugins.md) for
|
||||
Appium, you will hopefully want to document how that extension works for your users. The most basic
|
||||
way of doing this is to write up a quick README and keep it in the root of your project's
|
||||
repository. However, this can involve a lot of duplication of effort, especially when documenting
|
||||
things like Appium commands.
|
||||
Once you've [built a driver](./build-drivers.md) or [built a plugin](./build-plugins.md) for Appium,
|
||||
you will hopefully want to document how that extension works for your users. The most basic way of
|
||||
doing this is to write up a quick `README.md` and keep it in the root of your project's repository.
|
||||
However, this can involve a lot of duplication of effort, especially when documenting things like
|
||||
Appium commands.
|
||||
|
||||
Let's say your driver implements ~25 of the standard WebDriver protocol commands. You could write
|
||||
up a description of these commands, how they map to the protocol, what parameters they take, and
|
||||
@@ -16,16 +16,16 @@ this information in two places creates an opportunity for the docs to get out of
|
||||
reality of the code. Wouldn't it be nice to generate command reference documentation straight from
|
||||
the code?
|
||||
|
||||
Another problem with the basic single file README approach is that many extensions might want
|
||||
a whole set of documents including longer prose guides (like this one). It might be nice to have
|
||||
code examples where you can toggle between different programming languages. It might be nice to be
|
||||
able to add a project-specific logo. And so on.
|
||||
Another problem with the basic single file `README.md` approach is that many extensions might want a
|
||||
whole set of documents including longer prose guides (like this one). It might be nice to have code
|
||||
examples where you can toggle between different programming languages. It might be nice to be able
|
||||
to add a project-specific logo. And so on.
|
||||
|
||||
Luckily, the Appium project has built tools to do all these things, and we've packaged up these
|
||||
tools so our ecosystem developers building drivers and plugins can _also_ use them. The best way to
|
||||
get going with these tools is probably to look at an existing Appium driver repo to see how it's
|
||||
done, for example the [XCUITest driver repo](https://github.com/appium/appium-xcuitest-driver). But
|
||||
this guide will outline the basic approach.
|
||||
The Appium project has built tools to do all these things, and we've packaged up these tools so our
|
||||
ecosystem developers building drivers and plugins can _also_ use them. The best way to get going
|
||||
with these tools is probably to look at an existing Appium driver repo to see how it's done, for
|
||||
example the [XCUITest driver repo](https://github.com/appium/appium-xcuitest-driver). But this guide
|
||||
will outline the basic approach.
|
||||
|
||||
### Conceptual architecture
|
||||
|
||||
@@ -42,32 +42,180 @@ The other main piece is automatic documentation generation from your code files.
|
||||
a plugin for [TypeDoc](https://typedoc.org/). This plugin is incorporated into our doc utility.
|
||||
When you give it an entrypoint for you driver or plugin, it will scan and parse all your code files
|
||||
looking for Appium command implementations. A set of Markdown reference files will be generated for these
|
||||
commands, which can then be included in your docs site.
|
||||
commands, which will then be included in your docs site.
|
||||
|
||||
> Note: Implementing an extension in TypeScript is _not_ a requirement for generating documentation,
|
||||
> but for automated doc generation to work, you will need to apply TypeScript-supported JSDoc-style
|
||||
> docstrings to your JS codebase. See ["JS Projects Utilizing TypeScript"](https://www.typescriptlang.org/docs/handbook/intro-to-js-ts.html) for more information.
|
||||
|
||||
In order to make different versions of your docs available (one for each minor release of your
|
||||
extension, typically), we also bundle [Mike](https://github.com/jimporter/mike).
|
||||
|
||||
### Setup
|
||||
### Prerequisites
|
||||
|
||||
To take advantage of Appium's documentation utilities, you'll need to make sure of the following:
|
||||
To take advantage of Appium's documentation utilities, you'll need to install:
|
||||
|
||||
- Python 3 is available
|
||||
- The appropriate Python dependencies are available (the versions used by Appium itself are listed
|
||||
- in the doc utility's
|
||||
[requirements.txt](https://github.com/appium/appium/blob/master/packages/docutils/requirements.txt)).
|
||||
It's recommended you use the same versions.
|
||||
- Include the `@appium/docutils` NPM package as a dev dependency of your project
|
||||
- Annotate your commands using TypeDoc (this works for JS projects and not just TypeScript
|
||||
projects).
|
||||
- Put your markdown docs files in a directory
|
||||
- Create a [`mkdocs.yml`](https://www.mkdocs.org/user-guide/configuration/) file that extends
|
||||
Appium's base MkDocs configuration. (If your `mkdocs.yml` file is in the root of your repo, then
|
||||
the line at the top of it should look like:
|
||||
```yml
|
||||
INHERIT: ./node_modules/@appium/docutils/base-mkdocs.yml
|
||||
```
|
||||
Basically, make sure you're inheriting the path to `@appium/docutils`'s `base-mkdocs.yml`.
|
||||
- [Python v3+](https://www.python.org/downloads/)
|
||||
- [pip](https://pip.pypa.io/en/stable/installation/) (this may be installed automatically with Python)
|
||||
- The `@appium/docutils` package:
|
||||
|
||||
```bash
|
||||
npm install --save-dev @appium/docutils
|
||||
```
|
||||
|
||||
### Initializing an Extension for Building Docs
|
||||
|
||||
To prepare your extension for generating documentation, run the following command:
|
||||
|
||||
```bash
|
||||
npx appium-docs init --entry-point <my-entry-point.js>
|
||||
```
|
||||
|
||||
...where `<my-entry-point.js>` is the **source entry point** to your extension. If you _are not_ transpiling your code via TypeScript, Babel, etc., this is typically the same as the value of the `main` property in `package.json`. If you _are_ transpiling, this is typically different. For example, your `main` property may be `dist/index.js`, but your **source entry point** is `src/index.ts`.
|
||||
|
||||
This will:
|
||||
|
||||
1. Create a `tsconfig.json` if one does not already exist. This is necessary even if your extension is not written in TypeScript.
|
||||
2. Create a `typedoc.json` with the necessary configuration for TypeDoc.
|
||||
3. Create a `mkdocs.yml` with the necessary configuration for MkDocs.
|
||||
4. Modify your `package.json` to add a `typedoc.entryPoint` property with a value of your entry point (as specified above).
|
||||
|
||||
### Documenting Your Extension
|
||||
|
||||
At this point, you can begin documenting your extension. You don't need to do this all at once, but you should make the following changes, at minimum.
|
||||
|
||||
#### `newMethodMap` and `executeMethodMap`
|
||||
|
||||
The static properties `newMethodMap` and `executeMethodMap` may be present on your extension's main class. If they are not, then you can skip to the next section. If they are, you will need to make the following changes, depending on your extension's language.
|
||||
|
||||
##### JavaScript
|
||||
|
||||
```js
|
||||
// note: this is equivalent to the TypeScript example below
|
||||
|
||||
class MyExtension {
|
||||
static newMethodMap = /** @type {const} */({
|
||||
// ...
|
||||
});
|
||||
|
||||
static executeMethodMap = /** @type {const} */({
|
||||
// ...
|
||||
});
|
||||
}
|
||||
|
||||
```
|
||||
|
||||
##### TypeScript
|
||||
|
||||
```ts
|
||||
class MyExtension {
|
||||
static newMethodMap = {
|
||||
// ...
|
||||
} as const;
|
||||
|
||||
static executeMethodMap = {
|
||||
// ...
|
||||
} as const;
|
||||
}
|
||||
```
|
||||
|
||||
#### Driver Constraints
|
||||
|
||||
> Note: Plugin authors can skip this section.
|
||||
|
||||
Your driver may have a property `desiredCapConstraints`. It should also follow the same pattern as `newMethodMap` and `executeMethodMap` above. For example:
|
||||
|
||||
```js
|
||||
class MyExtension {
|
||||
desiredCapConstraints = /** @type {const} */({
|
||||
myCapability: {
|
||||
presence: true,
|
||||
isString: true
|
||||
},
|
||||
myOtherCap: {
|
||||
isBoolean: true
|
||||
}
|
||||
});
|
||||
}
|
||||
```
|
||||
|
||||
(For extensions written in TypeScript, use `as const` as before.)
|
||||
|
||||
#### Commands
|
||||
|
||||
The documentation for a command, as defined in your extension, comes from multiple places. These sources are then combined as needed into the final output.
|
||||
|
||||
In Appium, new commands are defined in `newMethodMap` and execute methods are defined in `executeMethodMap`. **The value of these properties are used to build your documentation.** In particular, parameter names and optional/required status _override_ whatever method implementation does. So for example, if your `newMethodMap` contains:
|
||||
|
||||
```js
|
||||
class MyExtension {
|
||||
static newMethodMap = /** @type {const} */({
|
||||
'/session/:sessionId/myThing': {
|
||||
/**
|
||||
* Does my thing
|
||||
*/
|
||||
GET: {command: 'doMyThing', payloadParams: {required: ['a', 'b']}},
|
||||
}
|
||||
})
|
||||
}
|
||||
```
|
||||
|
||||
...and your `doMyThing` method implementation looks like this:
|
||||
|
||||
```js
|
||||
class MyExtension {
|
||||
/**
|
||||
* Doesn't do my thing
|
||||
* @param {any} a - Whatever
|
||||
* @param {number} d - Some number
|
||||
* @param {boolean} c - Some boolean
|
||||
* @returns {Promise<boolean>} Some other boolean
|
||||
*/
|
||||
async doMyThing(a, d = 1, c = false) {
|
||||
// ...
|
||||
return true;
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
The documentation will show that the `doMyThing` method accepts required parameters `a` and `b`. Even though `b` is named `d` in the implementation--and it's optional--it will be ignored. Likewise, since the definition in `newMethodMap` knows nothing about `c`, it too is ignored.
|
||||
|
||||
In addition, the _description_ from the docstring in `newMethodMap` overrides the description in the method implementation; it will describe the command `doMyThing` as "Does my thing".
|
||||
|
||||
The `@param` tags and `@returns` tag from the method's docstring provide information about the expected and returned types, as well as a description of each. This is not expressible via `newMethodMap` and `executeMethodMap` alone; it provides more information for your extension's users.
|
||||
|
||||
> Note for TypeScript users: while the _types_ will already be present, providing `@param` and `@returns` tags is still useful for providing descriptions.
|
||||
|
||||
All commands must be `async`, so they will return `Promise<T>` where type `T` is the type of whatever the `Promise` fulfills with. In the generated documentation, the `Promise` is ignored, and only `T` is reported. So for `doMyThing`, the return type of the command, as output in the documentation, will be `boolean`.
|
||||
|
||||
This is because while extensions must be written in JavaScript, we're documenting an API which can be called from any language; that language likely won't have a concept of a `Promise`. Likewise, `undefined` or `void` types will be output as `null` (since that is a concept that translates well to multiple languages).
|
||||
|
||||
#### Optional: `README.md`
|
||||
|
||||
If you have a `README.md`, it will be pulled in to the generated docs site automatically. This behavior can be disabled by adding the following to `typedoc.json`:
|
||||
|
||||
```json
|
||||
{
|
||||
"readme": "none"
|
||||
}
|
||||
```
|
||||
|
||||
#### Next Steps
|
||||
|
||||
Appium provides type definitions for extension authors; these are available via Appium itself and the [`@appium/types`](https://npm.im/@appium/types) package.
|
||||
|
||||
Of note, drivers should both extend `BaseDriver` _and_ implement the `ExternalDriver` interface exported by `@appium/types`. This will help ensure that your driver's implementation is correct and usable by different clients.
|
||||
|
||||
You're encouraged to look at the official test/example extensions, [`@appium/fake-driver`](https://npm.im/@appium/fake-driver) and [`@appium/fake-plugin`](https://npm.im/@appium/fake-plugin) for canonical examples of how to use these types.
|
||||
|
||||
#### Resources
|
||||
|
||||
How to type more complex return values or parameters is beyond the scope of this document. For more information, see:
|
||||
|
||||
- For extensions written in JS, the [TypeScript documentation](https://www.typescriptlang.org/docs/handbook/intro-to-js-ts.html)
|
||||
- For tags in addition to what TS natively recognizes, see the [TypeDoc documentation](https://typedoc.org/guides/doccomments/)
|
||||
|
||||
Likewise, refer to the [MkDocs documentation](https://www.mkdocs.org/user-guide/writing-your-docs/) for further information on how to customize your MkDocs output.
|
||||
|
||||
### Usage
|
||||
|
||||
@@ -77,16 +225,16 @@ examples:
|
||||
|
||||
```bash
|
||||
# Generate reference and build the mkdocs site into the site dir
|
||||
appium-docs build
|
||||
npx appium-docs build
|
||||
|
||||
# Same as build, but host the docs on a local dev server
|
||||
# and watch for changes and rebuild when files change
|
||||
appium-docs build --serve
|
||||
npx appium-docs build --serve
|
||||
|
||||
# Build the docs and deploy them with mike versioning to the docs-site branch
|
||||
# using the included commit message and rebase strategy on the branch.
|
||||
# This is particularly useful for pushing content to a GitHub pages branch!
|
||||
appium-docs build \
|
||||
npx appium-docs build \
|
||||
--deploy \
|
||||
-b docs-site \
|
||||
-m 'docs: auto-build docs for appium-xcuitest-driver@%s' \
|
||||
|
||||
@@ -32,6 +32,9 @@ import {
|
||||
isExtensionCommandArgs,
|
||||
isPluginCommandArgs,
|
||||
isServerCommandArgs,
|
||||
fetchIpAddresses,
|
||||
V4_BROADCAST_IP,
|
||||
V6_BROADCAST_IP,
|
||||
} from './utils';
|
||||
import os from 'node:os';
|
||||
|
||||
@@ -164,8 +167,8 @@ async function prepareAppiumHome(name, appiumHome) {
|
||||
}
|
||||
throw new Error(
|
||||
`The path '${appiumHome}' provided in the ${name} must point ` +
|
||||
`to a valid folder writeable for the current user account '${os.userInfo().username}'. ` +
|
||||
`Original error: ${err.message}`
|
||||
`to a valid folder writeable for the current user account '${os.userInfo().username}'. ` +
|
||||
`Original error: ${err.message}`
|
||||
);
|
||||
}
|
||||
if (!stat.isDirectory()) {
|
||||
@@ -178,8 +181,8 @@ async function prepareAppiumHome(name, appiumHome) {
|
||||
} catch (e) {
|
||||
throw new Error(
|
||||
`The folder path '${appiumHome}' provided in the ${name} must be ` +
|
||||
`writeable for the current user account '${os.userInfo().username}. ` +
|
||||
`Original error: ${e.message}`
|
||||
`writeable for the current user account '${os.userInfo().username}. ` +
|
||||
`Original error: ${e.message}`
|
||||
);
|
||||
}
|
||||
return appiumHome;
|
||||
@@ -317,6 +320,28 @@ async function init(args) {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Prints the actual server address and the list of URLs that
|
||||
* could be used to connect to the current server.
|
||||
* Properly replaces broadcast addresses in client URLs.
|
||||
*
|
||||
* @param {string} url The URL the server is listening on
|
||||
*/
|
||||
function logServerAddress(url) {
|
||||
logger.info(`Appium REST http interface listener started on ${url}`);
|
||||
const urlObj = new URL(url);
|
||||
if (![V4_BROADCAST_IP, V6_BROADCAST_IP].includes(urlObj.hostname)) {
|
||||
return;
|
||||
}
|
||||
|
||||
const ips = fetchIpAddresses(urlObj.hostname === V4_BROADCAST_IP ? 4 : 6);
|
||||
logger.info(
|
||||
`You can provide the following ${util.pluralize('URL', ips.length, false)} ` +
|
||||
`in your client code to connect to this server:\n` +
|
||||
ips.map((x) => `\t${urlObj.href.replace(urlObj.hostname, x)}`).join('\n')
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes Appium's config. Starts server if appropriate and resolves the
|
||||
* server instance if so; otherwise resolves w/ `undefined`.
|
||||
@@ -417,9 +442,7 @@ async function main(args) {
|
||||
});
|
||||
}
|
||||
|
||||
logger.info(
|
||||
`Appium REST http interface listener started on ${parsedArgs.address}:${parsedArgs.port}${parsedArgs.basePath}`
|
||||
);
|
||||
logServerAddress(`http://${parsedArgs.address}:${parsedArgs.port}${parsedArgs.basePath}`);
|
||||
|
||||
driverConfig.print();
|
||||
pluginConfig.print([...pluginClasses.values()]);
|
||||
|
||||
@@ -5,9 +5,13 @@ import {inspect as dump} from 'util';
|
||||
import {node} from '@appium/support';
|
||||
import path from 'path';
|
||||
import {SERVER_SUBCOMMAND, DRIVER_TYPE, PLUGIN_TYPE} from './constants';
|
||||
import os from 'node:os';
|
||||
|
||||
const W3C_APPIUM_PREFIX = 'appium';
|
||||
const STANDARD_CAPS_LOWERCASE = new Set([...STANDARD_CAPS].map((cap) => cap.toLowerCase()));
|
||||
export const V4_BROADCAST_IP = '0.0.0.0';
|
||||
export const V6_BROADCAST_IP = '::';
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
@@ -331,6 +335,28 @@ export function isPluginCommandArgs(args) {
|
||||
return args.subcommand === PLUGIN_TYPE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetches the list of IP addresses of the current host.
|
||||
*
|
||||
* @param {4|6|null} family Either 4 to include ipv4 addresses only,
|
||||
* 6 to include ipv6 addresses only, or null to include all of them
|
||||
* @returns {string[]} The list of matched IP addresses
|
||||
*/
|
||||
export function fetchIpAddresses (family = null) {
|
||||
let familyValue = null;
|
||||
// 'IPv4' is in Node <= 17, from 18 it's a number 4 or 6
|
||||
if (family === 4) {
|
||||
familyValue = [4, 'IPv4'];
|
||||
} else if (family === 6) {
|
||||
familyValue = [6, 'IPv6'];
|
||||
}
|
||||
return _.flatMap(_.values(os.networkInterfaces()).filter(Boolean))
|
||||
// @ts-ignore The linter does not understand the above filter
|
||||
.filter(({family}) => !familyValue || familyValue && familyValue.includes(family))
|
||||
// @ts-ignore The linter does not understand the above filter
|
||||
.map(({address}) => address);
|
||||
}
|
||||
|
||||
export {
|
||||
inspect,
|
||||
parseCapsForInnerDriver,
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "appium",
|
||||
"version": "2.0.0-beta.67",
|
||||
"version": "2.0.0-rc.3",
|
||||
"description": "Automation for Apps.",
|
||||
"keywords": [
|
||||
"automation",
|
||||
@@ -60,17 +60,17 @@
|
||||
"test:unit": "mocha \"./test/unit/**/*.spec.js\""
|
||||
},
|
||||
"dependencies": {
|
||||
"@appium/base-driver": "^9.3.8",
|
||||
"@appium/base-plugin": "^2.2.8",
|
||||
"@appium/docutils": "^0.3.10",
|
||||
"@appium/schema": "^0.2.6",
|
||||
"@appium/support": "^4.0.0",
|
||||
"@appium/types": "^0.11.1",
|
||||
"@appium/base-driver": "^9.3.13",
|
||||
"@appium/base-plugin": "^2.2.13",
|
||||
"@appium/docutils": "^0.4.2",
|
||||
"@appium/schema": "^0.3.0",
|
||||
"@appium/support": "^4.1.0",
|
||||
"@appium/types": "^0.13.0",
|
||||
"@sidvind/better-ajv-errors": "2.1.0",
|
||||
"@types/argparse": "2.0.10",
|
||||
"@types/bluebird": "3.5.38",
|
||||
"@types/fancy-log": "2.0.0",
|
||||
"@types/semver": "7.3.13",
|
||||
"@types/semver": "7.5.0",
|
||||
"@types/teen_process": "2.0.0",
|
||||
"@types/wrap-ansi": "3.0.0",
|
||||
"ajv": "8.12.0",
|
||||
@@ -89,13 +89,13 @@
|
||||
"ora": "5.4.1",
|
||||
"package-changed": "3.0.0",
|
||||
"resolve-from": "5.0.0",
|
||||
"semver": "7.5.0",
|
||||
"semver": "7.5.1",
|
||||
"source-map-support": "0.5.21",
|
||||
"teen_process": "2.0.2",
|
||||
"type-fest": "3.10.0",
|
||||
"winston": "3.8.2",
|
||||
"type-fest": "3.11.1",
|
||||
"winston": "3.9.0",
|
||||
"wrap-ansi": "7.0.0",
|
||||
"yaml": "2.2.2"
|
||||
"yaml": "2.3.1"
|
||||
},
|
||||
"engines": {
|
||||
"node": "^14.17.0 || ^16.13.0 || >=18.0.0",
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// @ts-check
|
||||
|
||||
import {exec} from 'teen_process';
|
||||
import {fs, tempDir, util} from '@appium/support';
|
||||
import {fs, system, tempDir, util} from '@appium/support';
|
||||
import path from 'path';
|
||||
import resolveFrom from 'resolve-from';
|
||||
import {
|
||||
@@ -24,6 +24,8 @@ const TEST_DRIVER_INVALID_PEERS_DIR = path.dirname(
|
||||
);
|
||||
|
||||
describe('Driver CLI', function () {
|
||||
this.timeout(90000); // some of these tests involve network and can be very slow
|
||||
|
||||
/**
|
||||
* @type {string}
|
||||
*/
|
||||
@@ -96,6 +98,10 @@ describe('Driver CLI', function () {
|
||||
});
|
||||
|
||||
it('should show updates for installed drivers with --updates', async function () {
|
||||
if (system.isWindows()) {
|
||||
// TODO figure out why this isn't working on windows
|
||||
return this.skip();
|
||||
}
|
||||
const versions = /** @type {string[]} */ (
|
||||
JSON.parse(
|
||||
(
|
||||
|
||||
@@ -6,6 +6,7 @@ import {finalizeSchema, registerSchema, resetSchema} from '../../lib/schema/sche
|
||||
import extSchema from '../fixtures/driver-schema';
|
||||
import {resolveFixture} from '../helpers';
|
||||
import _ from 'lodash';
|
||||
import {system} from '@appium/support';
|
||||
|
||||
const resolveConfigFixture = _.partial(resolveFixture, 'config');
|
||||
|
||||
@@ -314,6 +315,10 @@ describe('config file behavior', function () {
|
||||
|
||||
describe('when the config file is invalid JSON', function () {
|
||||
it('should reject with a user-friendly error message', async function () {
|
||||
if (system.isWindows()) {
|
||||
// TODO figure out why this isn't working on windows
|
||||
return this.skip();
|
||||
}
|
||||
await readConfigFile(INVALID_JSON_FILEPATH).should.be.rejectedWith(
|
||||
new RegExp(`${INVALID_JSON_FILEPATH} is invalid`)
|
||||
);
|
||||
|
||||
+1
-3
@@ -11,11 +11,9 @@ export default [
|
||||
ref: 'appium.json#/properties/server/properties/address',
|
||||
},
|
||||
schema: {
|
||||
$comment: 'I think hostname covers both DNS and IPv4...could be wrong',
|
||||
appiumCliAliases: ['a'],
|
||||
default: '0.0.0.0',
|
||||
description: 'IP address to listen on',
|
||||
format: 'hostname',
|
||||
description: 'IPv4/IPv6 address or a hostname to listen on',
|
||||
title: 'address config',
|
||||
type: 'string',
|
||||
},
|
||||
|
||||
@@ -303,7 +303,7 @@ describe('ExtensionConfig', function () {
|
||||
it('should throw', function () {
|
||||
expect(() => config.require('fake')).to.throw(
|
||||
ReferenceError,
|
||||
/^could not find a driver installed at \/some\/path\/node_modules\/flotsam/i
|
||||
/^could not find a driver installed at .+flotsam/i
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -59,7 +59,9 @@ describe('parser', function () {
|
||||
}).should.throw(/unrecognized arguments: --apple/i);
|
||||
});
|
||||
|
||||
it('should throw an error for an invalid value ("hostname")', function () {
|
||||
// FIXME: this test will not work until we restore the formatting restriction to the address validation
|
||||
// see #18716
|
||||
it.skip('should throw an error for an invalid value ("hostname")', function () {
|
||||
(() => {
|
||||
p.parseArgs(['--address', '-42']);
|
||||
}).should.throw(/must match format "hostname"/i);
|
||||
@@ -119,6 +121,18 @@ describe('parser', function () {
|
||||
p.parseArgs(['--allow-insecure', 'foo ,bar']).allowInsecure.should.eql(['foo', 'bar']);
|
||||
});
|
||||
|
||||
it('should parse --address correctly', function () {
|
||||
p.parseArgs(['--address', 'localhost']).address.should.eql('localhost');
|
||||
p.parseArgs(['--address', 'appium.net']).address.should.eql('appium.net');
|
||||
p.parseArgs(['--address', '127.0.0.1']).address.should.eql('127.0.0.1');
|
||||
p.parseArgs(['--address', '10.0.0.1']).address.should.eql('10.0.0.1');
|
||||
p.parseArgs(['--address', '::']).address.should.eql('::');
|
||||
p.parseArgs(['--address', '::1']).address.should.eql('::1');
|
||||
p.parseArgs(['--address', '2a02:8888:9a80:158:2418:a474:43c6:1b78']).address.should.eql(
|
||||
'2a02:8888:9a80:158:2418:a474:43c6:1b78'
|
||||
);
|
||||
});
|
||||
|
||||
it('should parse --deny-insecure correctly', function () {
|
||||
p.parseArgs([]).should.not.have.property('denyInsecure');
|
||||
p.parseArgs(['--deny-insecure', '']).denyInsecure.should.eql([]);
|
||||
|
||||
@@ -5,6 +5,7 @@ import {
|
||||
removeAppiumPrefixes,
|
||||
inspect,
|
||||
adjustNodePath,
|
||||
fetchIpAddresses,
|
||||
} from '../../lib/utils';
|
||||
import {BASE_CAPS, W3C_CAPS} from '../helpers';
|
||||
import _ from 'lodash';
|
||||
@@ -275,4 +276,19 @@ describe('utils', function () {
|
||||
(await fs.exists(process.env.NODE_PATH)).should.be.true;
|
||||
});
|
||||
});
|
||||
|
||||
describe('fetchIpAddresses()', function () {
|
||||
it('should fetch addresses for ipv4 only', async function () {
|
||||
fetchIpAddresses(4).length.should.be.greaterThan(0);
|
||||
});
|
||||
|
||||
it('should fetch addresses for ipv6 only', async function () {
|
||||
fetchIpAddresses(6).length.should.be.greaterThan(0);
|
||||
});
|
||||
|
||||
it('should fetch addresses for ipv4 and ipv6', async function () {
|
||||
fetchIpAddresses().length.should.be.greaterThan(0);
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
@@ -3,6 +3,52 @@
|
||||
All notable changes to this project will be documented in this file.
|
||||
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
||||
|
||||
## [9.3.13](https://github.com/appium/appium/compare/@appium/base-driver@9.3.12...@appium/base-driver@9.3.13) (2023-06-15)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* **base-driver:** update def of findElOrEls and findElOrElsWithProcessing ([54a4a8d](https://github.com/appium/appium/commit/54a4a8da030dbecde783168bb92634df837d5a41))
|
||||
* **types:** various fixes for reality ([81bc527](https://github.com/appium/appium/commit/81bc527be6aa54dd30a012156b5752b8b821ac0c))
|
||||
|
||||
|
||||
|
||||
## [9.3.12](https://github.com/appium/appium/compare/@appium/base-driver@9.3.11...@appium/base-driver@9.3.12) (2023-06-14)
|
||||
|
||||
**Note:** Version bump only for package @appium/base-driver
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
## [9.3.11](https://github.com/appium/appium/compare/@appium/base-driver@9.3.10...@appium/base-driver@9.3.11) (2023-06-14)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* **schema:** update definitelytyped ([e967240](https://github.com/appium/appium/commit/e96724077ef2b5b8aae203856195f3bb8de56116))
|
||||
* **types:** update dependency type-fest to v3.11.0 ([19277f6](https://github.com/appium/appium/commit/19277f6e14a56e52b4669d633e148ad4a3da2c7a))
|
||||
* **types:** update dependency type-fest to v3.11.1 ([56499eb](https://github.com/appium/appium/commit/56499eb997b551739bed628f057de7987674ea7f))
|
||||
|
||||
|
||||
|
||||
## [9.3.10](https://github.com/appium/appium/compare/@appium/base-driver@9.3.9...@appium/base-driver@9.3.10) (2023-05-19)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* **base-driver:** add missing @types/lodash ([63a429c](https://github.com/appium/appium/commit/63a429c53bf3da353e018ed86ec24e32bf238d18))
|
||||
|
||||
|
||||
|
||||
## [9.3.9](https://github.com/appium/appium/compare/@appium/base-driver@9.3.8...@appium/base-driver@9.3.9) (2023-05-19)
|
||||
|
||||
**Note:** Version bump only for package @appium/base-driver
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
## [9.3.8](https://github.com/appium/appium/compare/@appium/base-driver@9.3.7...@appium/base-driver@9.3.8) (2023-05-17)
|
||||
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import {Constraints, IFindCommands} from '@appium/types';
|
||||
/* eslint-disable @typescript-eslint/no-unused-vars */
|
||||
import {Constraints, Element, IFindCommands} from '@appium/types';
|
||||
import {errors} from '../../protocol';
|
||||
import {BaseDriver} from '../driver';
|
||||
import {mixin} from './mixin';
|
||||
@@ -8,6 +9,67 @@ declare module '../driver' {
|
||||
interface BaseDriver<C extends Constraints> extends IFindCommands {}
|
||||
}
|
||||
|
||||
async function findElOrEls<C extends Constraints>(
|
||||
this: BaseDriver<C>,
|
||||
strategy: string,
|
||||
selector: string,
|
||||
mult: true,
|
||||
context?: any
|
||||
): Promise<Element[]>;
|
||||
async function findElOrEls<C extends Constraints>(
|
||||
this: BaseDriver<C>,
|
||||
strategy: string,
|
||||
selector: string,
|
||||
mult: false,
|
||||
context?: any
|
||||
): Promise<Element>;
|
||||
async function findElOrEls<C extends Constraints>(
|
||||
this: BaseDriver<C>,
|
||||
strategy: string,
|
||||
selector: string,
|
||||
mult: boolean,
|
||||
context?: any
|
||||
): Promise<Element[] | Element> {
|
||||
throw new errors.NotImplementedError('Not implemented yet for find.');
|
||||
}
|
||||
|
||||
async function findElOrElsWithProcessing<C extends Constraints>(
|
||||
this: BaseDriver<C>,
|
||||
strategy: string,
|
||||
selector: string,
|
||||
mult: true,
|
||||
context?: any
|
||||
): Promise<Element[]>;
|
||||
async function findElOrElsWithProcessing<C extends Constraints>(
|
||||
this: BaseDriver<C>,
|
||||
strategy: string,
|
||||
selector: string,
|
||||
mult: false,
|
||||
context?: any
|
||||
): Promise<Element>;
|
||||
async function findElOrElsWithProcessing<C extends Constraints>(
|
||||
this: BaseDriver<C>,
|
||||
strategy: string,
|
||||
selector: string,
|
||||
mult: boolean,
|
||||
context?: any
|
||||
): Promise<Element[] | Element> {
|
||||
this.validateLocatorStrategy(strategy);
|
||||
try {
|
||||
// @ts-expect-error TS does not understand how to deal with the overload here
|
||||
return await this.findElOrEls(strategy, selector, mult, context);
|
||||
} catch (err) {
|
||||
if (this.opts.printPageSourceOnFindFailure) {
|
||||
const src = await this.getPageSource();
|
||||
this.log.debug(`Error finding element${mult ? 's' : ''}: ${err.message}`);
|
||||
this.log.debug(`Page source requested through 'printPageSourceOnFindFailure':`);
|
||||
this.log.debug(src);
|
||||
}
|
||||
// still want the error to occur
|
||||
throw err;
|
||||
}
|
||||
}
|
||||
|
||||
const FindCommands: IFindCommands = {
|
||||
async findElement<C extends Constraints>(this: BaseDriver<C>, strategy, selector) {
|
||||
return await this.findElOrElsWithProcessing(strategy, selector, false);
|
||||
@@ -35,46 +97,13 @@ const FindCommands: IFindCommands = {
|
||||
return await this.findElOrElsWithProcessing(strategy, selector, true, elementId);
|
||||
},
|
||||
|
||||
/**
|
||||
* Returns an object which adheres to the way the JSON Wire Protocol represents elements:
|
||||
*
|
||||
* Override this for your own driver!
|
||||
*/
|
||||
async findElOrEls<C extends Constraints, Mult extends boolean, Ctx = any>(
|
||||
this: BaseDriver<C>,
|
||||
strategy: string,
|
||||
selector: string,
|
||||
mult: Mult,
|
||||
context: Ctx
|
||||
) {
|
||||
throw new errors.NotImplementedError('Not implemented yet for find.');
|
||||
},
|
||||
findElOrEls,
|
||||
|
||||
async getPageSource<C extends Constraints>(this: BaseDriver<C>) {
|
||||
throw new errors.NotImplementedError('Not implemented yet for find.');
|
||||
},
|
||||
|
||||
async findElOrElsWithProcessing<C extends Constraints, Mult extends boolean, Ctx = any>(
|
||||
this: BaseDriver<C>,
|
||||
strategy: string,
|
||||
selector: string,
|
||||
mult: Mult,
|
||||
context?: Ctx
|
||||
) {
|
||||
this.validateLocatorStrategy(strategy);
|
||||
try {
|
||||
return await this.findElOrEls(strategy, selector, mult, context);
|
||||
} catch (err) {
|
||||
if (this.opts.printPageSourceOnFindFailure) {
|
||||
const src = await this.getPageSource();
|
||||
this.log.debug(`Error finding element${mult ? 's' : ''}: ${err.message}`);
|
||||
this.log.debug(`Page source requested through 'printPageSourceOnFindFailure':`);
|
||||
this.log.debug(src);
|
||||
}
|
||||
// still want the error to occur
|
||||
throw err;
|
||||
}
|
||||
},
|
||||
findElOrElsWithProcessing,
|
||||
};
|
||||
|
||||
mixin(FindCommands);
|
||||
|
||||
@@ -320,6 +320,12 @@ class JWProxy {
|
||||
return commandName;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param {string} url
|
||||
* @param {import('@appium/types').HTTPMethod} method
|
||||
* @param {any?} body
|
||||
*/
|
||||
async proxyCommand(url, method, body = null) {
|
||||
const commandName = this.requestToCommandName(url, method);
|
||||
if (!commandName) {
|
||||
@@ -330,6 +336,12 @@ class JWProxy {
|
||||
return await this.protocolConverter.convertAndProxy(commandName, url, method, body);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param {string} url
|
||||
* @param {import('@appium/types').HTTPMethod} method
|
||||
* @param {any?} body
|
||||
*/
|
||||
async command(url, method, body = null) {
|
||||
let response;
|
||||
let resBodyObj;
|
||||
|
||||
@@ -982,7 +982,13 @@ function isUnknownError(err) {
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Type guard to check if an Error is of a specific type
|
||||
* @template {Error} T
|
||||
* @param {any} err
|
||||
* @param {import('@appium/types').Class<T>} type
|
||||
* @returns {err is T}
|
||||
*/
|
||||
function isErrorType(err, type) {
|
||||
// `name` property is the constructor name
|
||||
if (type.name === ProtocolError.name) {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@appium/base-driver",
|
||||
"version": "9.3.8",
|
||||
"version": "9.3.13",
|
||||
"description": "Base driver class for Appium drivers",
|
||||
"keywords": [
|
||||
"automation",
|
||||
@@ -44,12 +44,13 @@
|
||||
"test:types": "tsd"
|
||||
},
|
||||
"dependencies": {
|
||||
"@appium/support": "^4.0.0",
|
||||
"@appium/types": "^0.11.1",
|
||||
"@appium/support": "^4.1.0",
|
||||
"@appium/types": "^0.13.0",
|
||||
"@colors/colors": "1.5.0",
|
||||
"@types/async-lock": "1.4.0",
|
||||
"@types/bluebird": "3.5.38",
|
||||
"@types/express": "4.17.17",
|
||||
"@types/lodash": "4.14.195",
|
||||
"@types/method-override": "0.0.32",
|
||||
"@types/serve-favicon": "2.5.4",
|
||||
"async-lock": "1.4.0",
|
||||
@@ -66,7 +67,7 @@
|
||||
"morgan": "1.10.0",
|
||||
"serve-favicon": "2.5.0",
|
||||
"source-map-support": "0.5.21",
|
||||
"type-fest": "3.10.0",
|
||||
"type-fest": "3.11.1",
|
||||
"validate.js": "0.13.1"
|
||||
},
|
||||
"engines": {
|
||||
|
||||
@@ -3,6 +3,46 @@
|
||||
All notable changes to this project will be documented in this file.
|
||||
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
||||
|
||||
## [2.2.13](https://github.com/appium/appium/compare/@appium/base-plugin@2.2.12...@appium/base-plugin@2.2.13) (2023-06-15)
|
||||
|
||||
**Note:** Version bump only for package @appium/base-plugin
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
## [2.2.12](https://github.com/appium/appium/compare/@appium/base-plugin@2.2.11...@appium/base-plugin@2.2.12) (2023-06-14)
|
||||
|
||||
**Note:** Version bump only for package @appium/base-plugin
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
## [2.2.11](https://github.com/appium/appium/compare/@appium/base-plugin@2.2.10...@appium/base-plugin@2.2.11) (2023-06-14)
|
||||
|
||||
**Note:** Version bump only for package @appium/base-plugin
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
## [2.2.10](https://github.com/appium/appium/compare/@appium/base-plugin@2.2.9...@appium/base-plugin@2.2.10) (2023-05-19)
|
||||
|
||||
**Note:** Version bump only for package @appium/base-plugin
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
## [2.2.9](https://github.com/appium/appium/compare/@appium/base-plugin@2.2.8...@appium/base-plugin@2.2.9) (2023-05-19)
|
||||
|
||||
**Note:** Version bump only for package @appium/base-plugin
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
## [2.2.8](https://github.com/appium/appium/compare/@appium/base-plugin@2.2.7...@appium/base-plugin@2.2.8) (2023-05-17)
|
||||
|
||||
**Note:** Version bump only for package @appium/base-plugin
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@appium/base-plugin",
|
||||
"version": "2.2.8",
|
||||
"version": "2.2.13",
|
||||
"description": "The base plugin used to create Appium 2.0 plugins",
|
||||
"keywords": [
|
||||
"automation",
|
||||
@@ -40,8 +40,8 @@
|
||||
"test:unit": "mocha \"./test/unit/**/*.spec.js\""
|
||||
},
|
||||
"dependencies": {
|
||||
"@appium/base-driver": "^9.3.8",
|
||||
"@appium/support": "^4.0.0"
|
||||
"@appium/base-driver": "^9.3.13",
|
||||
"@appium/support": "^4.1.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": "^14.17.0 || ^16.13.0 || >=18.0.0",
|
||||
|
||||
@@ -3,6 +3,41 @@
|
||||
All notable changes to this project will be documented in this file.
|
||||
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
||||
|
||||
## [2.0.19](https://github.com/appium/appium/compare/@appium/doctor@2.0.18...@appium/doctor@2.0.19) (2023-06-15)
|
||||
|
||||
**Note:** Version bump only for package @appium/doctor
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
## [2.0.18](https://github.com/appium/appium/compare/@appium/doctor@2.0.17...@appium/doctor@2.0.18) (2023-06-14)
|
||||
|
||||
**Note:** Version bump only for package @appium/doctor
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
## [2.0.17](https://github.com/appium/appium/compare/@appium/doctor@2.0.16...@appium/doctor@2.0.17) (2023-06-14)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* **doctor:** update dependency appium-adb to v9.11.3 ([a0b434d](https://github.com/appium/appium/commit/a0b434dff7a4e425f66915e12266a6e943d10372))
|
||||
* **doctor:** update dependency appium-adb to v9.11.4 ([f34c75c](https://github.com/appium/appium/commit/f34c75c65068a299ab4d3427233e771e796fc43a))
|
||||
* **doctor:** update dependency appium-adb to v9.11.5 ([78c6794](https://github.com/appium/appium/commit/78c67942534705133093aa9fa54d84efb9fe2f69))
|
||||
|
||||
|
||||
|
||||
## [2.0.16](https://github.com/appium/appium/compare/@appium/doctor@2.0.15...@appium/doctor@2.0.16) (2023-05-19)
|
||||
|
||||
**Note:** Version bump only for package @appium/doctor
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
## [2.0.15](https://github.com/appium/appium/compare/@appium/doctor@2.0.14...@appium/doctor@2.0.15) (2023-05-17)
|
||||
|
||||
|
||||
|
||||
@@ -75,7 +75,7 @@ class OptionalFfmpegCommandCheck extends DoctorCheck {
|
||||
return ffmpegPath
|
||||
? okOptional(
|
||||
`ffmpeg is installed at: ${ffmpegPath}. ${
|
||||
(await exec('ffmpeg', ['-version'])).stdout.split(EOL)[0]
|
||||
(await exec('ffmpeg', ['-version'])).stdout.split('\n')[0]
|
||||
}`
|
||||
)
|
||||
: nokOptional('ffmpeg cannot be found');
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@appium/doctor",
|
||||
"version": "2.0.15",
|
||||
"version": "2.0.19",
|
||||
"description": "Test environment for fitness to run Appium",
|
||||
"keywords": [
|
||||
"automation",
|
||||
@@ -44,11 +44,11 @@
|
||||
"test:unit": "mocha \"./test/unit/**/*.spec.js\""
|
||||
},
|
||||
"dependencies": {
|
||||
"@appium/support": "^4.0.0",
|
||||
"@appium/support": "^4.1.0",
|
||||
"@colors/colors": "1.5.0",
|
||||
"@types/bluebird": "3.5.38",
|
||||
"@types/teen_process": "2.0.0",
|
||||
"appium-adb": "9.11.2",
|
||||
"appium-adb": "9.11.5",
|
||||
"bluebird": "3.7.2",
|
||||
"inquirer": "8.2.5",
|
||||
"lodash": "4.17.21",
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
import path from 'node:path';
|
||||
import {
|
||||
EnvVarAndPathCheck,
|
||||
AndroidToolCheck,
|
||||
OptionalAppBundleCheck,
|
||||
OptionalGstreamerCheck,
|
||||
} from '../../lib/android';
|
||||
import {fs} from '@appium/support';
|
||||
import {fs, system} from '@appium/support';
|
||||
import * as adb from 'appium-adb';
|
||||
import * as utils from '../../lib/utils';
|
||||
import * as tp from 'teen_process';
|
||||
@@ -13,6 +14,9 @@ import B from 'bluebird';
|
||||
import {removeColors} from './helper';
|
||||
|
||||
describe('android', function () {
|
||||
const apkAnalyzerFilename = system.isWindows() ? 'apkanalyzer.bat' : 'apkanalyzer';
|
||||
const gstLaunchFilename = system.isWindows() ? 'gst-launch-1.0.exe' : 'gst-launch-1.0';
|
||||
const gstInspectFilename = system.isWindows() ? 'gst-inspect-1.0.exe' : 'gst-inspect-1.0';
|
||||
describe(
|
||||
'EnvVarAndPathCheck',
|
||||
withMocks({fs}, (mocks) => {
|
||||
@@ -64,12 +68,14 @@ describe('android', function () {
|
||||
});
|
||||
it('diagnose - success', async function () {
|
||||
process.env.ANDROID_HOME = '/a/b/c/d';
|
||||
mocks.adb.expects('getAndroidBinaryPath').exactly(check.tools.length)
|
||||
mocks.adb
|
||||
.expects('getAndroidBinaryPath')
|
||||
.exactly(check.tools.length)
|
||||
.returns(B.resolve('/path/to/binary'));
|
||||
(await check.diagnose()).should.deep.equal({
|
||||
ok: true,
|
||||
optional: false,
|
||||
message: 'adb, emulator, apkanalyzer exist: /a/b/c/d',
|
||||
message: `adb, emulator, ${apkAnalyzerFilename} exist: /a/b/c/d`,
|
||||
});
|
||||
mocks.verify();
|
||||
});
|
||||
@@ -79,19 +85,17 @@ describe('android', function () {
|
||||
(await check.diagnose()).should.deep.equal({
|
||||
ok: false,
|
||||
optional: false,
|
||||
message: 'adb, emulator, apkanalyzer could not be found because ' +
|
||||
'ANDROID_HOME or ANDROID_SDK_ROOT is NOT set!',
|
||||
message: `adb, emulator, ${apkAnalyzerFilename} could not be found because ANDROID_HOME or ANDROID_SDK_ROOT is NOT set!`,
|
||||
});
|
||||
mocks.verify();
|
||||
});
|
||||
it('diagnose - failure - path not valid', async function () {
|
||||
process.env.ANDROID_HOME = '/a/b/c/d';
|
||||
mocks.adb.expects('getAndroidBinaryPath').exactly(check.tools.length)
|
||||
.throws();
|
||||
mocks.adb.expects('getAndroidBinaryPath').exactly(check.tools.length).throws();
|
||||
(await check.diagnose()).should.deep.equal({
|
||||
ok: false,
|
||||
optional: false,
|
||||
message: 'adb, emulator, apkanalyzer could NOT be found in /a/b/c/d!',
|
||||
message: `adb, emulator, ${apkAnalyzerFilename} could NOT be found in /a/b/c/d!`,
|
||||
});
|
||||
mocks.verify();
|
||||
});
|
||||
@@ -102,11 +106,9 @@ describe('android', function () {
|
||||
);
|
||||
});
|
||||
it('fix - install', async function () {
|
||||
process.env.ANDROID_HOME = '/a/b/c/d';
|
||||
process.env.ANDROID_HOME = path.resolve('/', 'a', 'b', 'c', 'd');
|
||||
removeColors(await check.fix()).should.equal(
|
||||
'Manually install adb, emulator, apkanalyzer and add it to PATH. ' +
|
||||
'https://developer.android.com/studio#cmdline-tools and ' +
|
||||
'https://developer.android.com/studio/intro/update#sdk-manager may help to setup.'
|
||||
`Manually install adb, emulator, ${apkAnalyzerFilename} and add it to PATH. https://developer.android.com/studio#cmdline-tools and https://developer.android.com/studio/intro/update#sdk-manager may help to setup.`
|
||||
);
|
||||
});
|
||||
})
|
||||
@@ -138,8 +140,10 @@ describe('android', function () {
|
||||
mocks.verify();
|
||||
});
|
||||
it('fix', async function () {
|
||||
removeColors(await check.fix()).should.equal(
|
||||
'bundletool.jar is used to handle Android App Bundle. Please read http://appium.io/docs/en/writing-running-appium/android/android-appbundle/ to install it'
|
||||
removeColors(await check.fix()).should.match(
|
||||
new RegExp(
|
||||
'bundletool.jar is used to handle Android App Bundle. Please read http://appium.io/docs/en/writing-running-appium/android/android-appbundle/ to install it'
|
||||
)
|
||||
);
|
||||
});
|
||||
})
|
||||
@@ -158,8 +162,7 @@ describe('android', function () {
|
||||
(await check.diagnose()).should.deep.equal({
|
||||
ok: true,
|
||||
optional: true,
|
||||
message:
|
||||
'gst-launch-1.0 and gst-inspect-1.0 are installed at: path/to/gst-launch and path/to/gst-inspect',
|
||||
message: `${gstLaunchFilename} and ${gstInspectFilename} are installed at: path/to/gst-launch and path/to/gst-inspect`,
|
||||
});
|
||||
mocks.verify();
|
||||
});
|
||||
@@ -168,14 +171,13 @@ describe('android', function () {
|
||||
(await check.diagnose()).should.deep.equal({
|
||||
ok: false,
|
||||
optional: true,
|
||||
message: 'gst-launch-1.0 and/or gst-inspect-1.0 cannot be found',
|
||||
message: `${gstLaunchFilename} and/or ${gstInspectFilename} cannot be found`,
|
||||
});
|
||||
mocks.verify();
|
||||
});
|
||||
it('fix', async function () {
|
||||
removeColors(await check.fix()).should.equal(
|
||||
'gst-launch-1.0 and gst-inspect-1.0 are used to stream the screen of the device under test. ' +
|
||||
'Please read https://appium.io/docs/en/writing-running-appium/android/android-screen-streaming/ to install them and for more details'
|
||||
`${gstLaunchFilename} and ${gstInspectFilename} are used to stream the screen of the device under test. Please read https://appium.io/docs/en/writing-running-appium/android/android-screen-streaming/ to install them and for more details`
|
||||
);
|
||||
});
|
||||
})
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import path from 'node:path';
|
||||
import {BinaryIsInPathCheck, AndroidSdkExists} from '../../lib/dev';
|
||||
import {fs} from '@appium/support';
|
||||
import * as tp from 'teen_process';
|
||||
@@ -65,12 +66,12 @@ describe('dev', function () {
|
||||
check.autofix.should.not.be.ok;
|
||||
});
|
||||
it('diagnose - success', async function () {
|
||||
process.env.ANDROID_HOME = '/a/b/c/d';
|
||||
process.env.ANDROID_HOME = path.resolve('/', 'a', 'b', 'c', 'd');
|
||||
mocks.fs.expects('exists').once().returns(B.resolve(true));
|
||||
(await check.diagnose()).should.deep.equal({
|
||||
ok: true,
|
||||
optional: false,
|
||||
message: 'android-16 was found at: /a/b/c/d/platforms/android-16',
|
||||
message: `android-16 was found at: ${process.env.ANDROID_HOME}${path.sep}platforms${path.sep}android-16`,
|
||||
});
|
||||
mocks.verify();
|
||||
});
|
||||
@@ -84,12 +85,12 @@ describe('dev', function () {
|
||||
mocks.verify();
|
||||
});
|
||||
it('diagnose - failure - invalid path', async function () {
|
||||
process.env.ANDROID_HOME = '/a/b/c/d';
|
||||
process.env.ANDROID_HOME = path.resolve('/', 'a', 'b', 'c', 'd');
|
||||
mocks.fs.expects('exists').once().returns(B.resolve(false));
|
||||
(await check.diagnose()).should.deep.equal({
|
||||
ok: false,
|
||||
optional: false,
|
||||
message: "android-16 could NOT be found at '/a/b/c/d/platforms/android-16'!",
|
||||
message: `android-16 could NOT be found at '${process.env.ANDROID_HOME}${path.sep}platforms${path.sep}android-16'!`,
|
||||
});
|
||||
mocks.verify();
|
||||
});
|
||||
|
||||
@@ -3,6 +3,73 @@
|
||||
All notable changes to this project will be documented in this file.
|
||||
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
||||
|
||||
## [0.4.2](https://github.com/appium/appium/compare/@appium/docutils@0.4.1...@appium/docutils@0.4.2) (2023-06-15)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* **docutils:** set mike version to major.minor by default ([#18770](https://github.com/appium/appium/issues/18770)) ([1a5b8cc](https://github.com/appium/appium/commit/1a5b8cca2d22b0be0150fe87be963973c4cc04e5))
|
||||
|
||||
|
||||
|
||||
## [0.4.1](https://github.com/appium/appium/compare/@appium/docutils@0.4.0...@appium/docutils@0.4.1) (2023-06-14)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* **docutils:** fixes some weirdness with default behavior and the "implies" keyword ([#18751](https://github.com/appium/appium/issues/18751)) ([e5254b5](https://github.com/appium/appium/commit/e5254b5b4564450252fd3eb55b773c0d7c615316))
|
||||
|
||||
|
||||
|
||||
## [0.4.0](https://github.com/appium/appium/compare/@appium/docutils@0.3.13...@appium/docutils@0.4.0) (2023-06-14)
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* **appium:** Allow to provide ipv6 addresses and handle broadcast addresses in logs ([#18674](https://github.com/appium/appium/issues/18674)) ([8f63dab](https://github.com/appium/appium/commit/8f63dabb5dca882e522026f243e3445f5418874b))
|
||||
* **docutils:** init: scafffold package.json ([2766dcc](https://github.com/appium/appium/commit/2766dcca4cfdc74904cc21f4881d748ed8ffd198))
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* **docutils:** update dependency yaml to v2.3.0 ([325d237](https://github.com/appium/appium/commit/325d2372078ee01e8fb58613ffd13417f2527151))
|
||||
* **docutils:** update dependency yaml to v2.3.1 ([1a2260b](https://github.com/appium/appium/commit/1a2260bb15d75e4f4c23551dc61529108a7b0d88))
|
||||
* **support:** update dependency semver to v7.5.1 ([5a55509](https://github.com/appium/appium/commit/5a555090c5322318f845415d743ee5c645fb94a0))
|
||||
* **types:** update dependency type-fest to v3.11.0 ([19277f6](https://github.com/appium/appium/commit/19277f6e14a56e52b4669d633e148ad4a3da2c7a))
|
||||
* **types:** update dependency type-fest to v3.11.1 ([56499eb](https://github.com/appium/appium/commit/56499eb997b551739bed628f057de7987674ea7f))
|
||||
|
||||
|
||||
|
||||
## [0.3.13](https://github.com/appium/appium/compare/@appium/docutils@0.3.12...@appium/docutils@0.3.13) (2023-05-19)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* **docutils:** fix broken executable ([f0ebe2e](https://github.com/appium/appium/commit/f0ebe2e02f3e4164f07fd10ca36f460ff7a61682))
|
||||
|
||||
|
||||
|
||||
## [0.3.12](https://github.com/appium/appium/compare/@appium/docutils@0.3.11...@appium/docutils@0.3.12) (2023-05-19)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* **docutils:** add @types/which as it is exported ([9538c34](https://github.com/appium/appium/commit/9538c34131cd2f8a3c45039efd65678bc0980497))
|
||||
* **docutils:** exec mike/mkdocs via python -m ([426830d](https://github.com/appium/appium/commit/426830d14a348f163535a7f935a65b028008738d))
|
||||
* **docutils:** provide CJS executable for proper linking ([db73971](https://github.com/appium/appium/commit/db73971018b560ca47527173094720eee3d20a55))
|
||||
* **docutils:** run mkdocs via python -m ([5d24ea1](https://github.com/appium/appium/commit/5d24ea1ad294fa28f7ecce125e5342b081a84c83))
|
||||
* **docutils:** try python3 if python not in PATH ([7b17754](https://github.com/appium/appium/commit/7b177547865a8343625cf089c97cebfb93fd6955))
|
||||
|
||||
|
||||
|
||||
## [0.3.11](https://github.com/appium/appium/compare/@appium/docutils@0.3.10...@appium/docutils@0.3.11) (2023-05-19)
|
||||
|
||||
**Note:** Version bump only for package @appium/docutils
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
## [0.3.10](https://github.com/appium/appium/compare/@appium/docutils@0.3.9...@appium/docutils@0.3.10) (2023-05-17)
|
||||
|
||||
|
||||
|
||||
Executable
+15
@@ -0,0 +1,15 @@
|
||||
#!/usr/bin/env node
|
||||
// @ts-check
|
||||
|
||||
'use strict';
|
||||
require('source-map-support').install();
|
||||
|
||||
const {main} = require('../build/lib/cli');
|
||||
const {getLogger} = require('../build/lib/logger');
|
||||
|
||||
const log = getLogger('cli');
|
||||
|
||||
// eslint-disable-next-line promise/prefer-await-to-then, promise/prefer-await-to-callbacks
|
||||
main().catch((err) => {
|
||||
log.error('Caught otherwise-unhandled rejection (this is probably a bug):', err);
|
||||
});
|
||||
@@ -13,10 +13,12 @@ import {
|
||||
DEFAULT_SERVE_HOST,
|
||||
DEFAULT_SERVE_PORT,
|
||||
NAME_BIN,
|
||||
NAME_MIKE,
|
||||
NAME_MKDOCS_YML,
|
||||
NAME_PYTHON,
|
||||
} from '../constants';
|
||||
import {DocutilsError} from '../error';
|
||||
import {findMkDocsYml, readPackageJson, whichMike} from '../fs';
|
||||
import {findMike, findMkDocsYml, findPython, readPackageJson} from '../fs';
|
||||
import {getLogger} from '../logger';
|
||||
import {argify, spawnBackgroundProcess, SpawnBackgroundProcessOpts, stopwatch} from '../util';
|
||||
|
||||
@@ -24,30 +26,28 @@ const log = getLogger('builder:deploy');
|
||||
|
||||
/**
|
||||
* Runs `mike serve`
|
||||
* @param mikePath Path to `mike` executable
|
||||
* @param args Extra args to `mike build`
|
||||
* @param opts Extra options for `teen_process.Subprocess.start`
|
||||
* @param mikePath Path to `mike` executable
|
||||
*/
|
||||
async function doServe(
|
||||
mikePath: string,
|
||||
args: string[] = [],
|
||||
opts: SpawnBackgroundProcessOpts = {},
|
||||
mikePath?: string
|
||||
opts: SpawnBackgroundProcessOpts = {}
|
||||
) {
|
||||
mikePath = mikePath ?? (await whichMike());
|
||||
const finalArgs = ['serve', ...args];
|
||||
return spawnBackgroundProcess(mikePath, finalArgs, opts);
|
||||
}
|
||||
|
||||
/**
|
||||
* Runs `mike build`
|
||||
* @param mikePath Path to `mike` executable
|
||||
* @param args Extra args to `mike build`
|
||||
* @param opts Extra options to `teen_process.exec`
|
||||
* @param mikePath Path to `mike` executable
|
||||
*/
|
||||
async function doDeploy(args: string[] = [], opts: TeenProcessExecOptions = {}, mikePath?: string) {
|
||||
mikePath = mikePath ?? (await whichMike());
|
||||
async function doDeploy(mikePath: string, args: string[] = [], opts: TeenProcessExecOptions = {}) {
|
||||
const finalArgs = ['deploy', ...args];
|
||||
log.debug('Launching %s with args: %O', mikePath, finalArgs);
|
||||
log.debug('Executing %s via: %s %O', NAME_MIKE, mikePath, finalArgs);
|
||||
return await exec(mikePath, finalArgs, opts);
|
||||
}
|
||||
|
||||
@@ -64,7 +64,14 @@ async function findDeployVersion(packageJsonPath?: string, cwd = process.cwd()):
|
||||
'No "version" field found in package.json; please add one or specify a version to deploy'
|
||||
);
|
||||
}
|
||||
return version;
|
||||
|
||||
// return MAJOR.MINOR as the version by default, if that is a thing we can extract, otherwise
|
||||
// just return the version as is
|
||||
const versionParts = version.split('.');
|
||||
if (versionParts.length === 1) {
|
||||
return version;
|
||||
}
|
||||
return `${versionParts[0]}.${versionParts[1]}`;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -90,6 +97,15 @@ export async function deploy({
|
||||
execOpts,
|
||||
}: DeployOpts = {}) {
|
||||
const stop = stopwatch('deploy');
|
||||
|
||||
const pythonPath = await findPython();
|
||||
|
||||
if (!pythonPath) {
|
||||
throw new DocutilsError(
|
||||
`Could not find ${NAME_PYTHON}3/${NAME_PYTHON} executable in PATH; please install Python v3`
|
||||
);
|
||||
}
|
||||
|
||||
mkDocsYmlPath = mkDocsYmlPath ?? (await findMkDocsYml(cwd));
|
||||
if (!mkDocsYmlPath) {
|
||||
throw new DocutilsError(
|
||||
@@ -112,6 +128,13 @@ export async function deploy({
|
||||
port,
|
||||
host,
|
||||
};
|
||||
|
||||
const mikePath = await findMike();
|
||||
if (!mikePath) {
|
||||
throw new DocutilsError(
|
||||
`Could not find ${NAME_MIKE} executable; please run "${NAME_BIN} init"`
|
||||
);
|
||||
}
|
||||
if (serve) {
|
||||
const mikeArgs = [
|
||||
...argify(_.pickBy(mikeOpts, (value) => _.isNumber(value) || Boolean(value))),
|
||||
@@ -122,7 +145,7 @@ export async function deploy({
|
||||
}
|
||||
stop(); // discard
|
||||
// unsure about how SIGHUP is handled here
|
||||
await doServe(mikeArgs, serveOpts);
|
||||
await doServe(mikePath, mikeArgs, serveOpts);
|
||||
} else {
|
||||
log.info('Deploying into branch %s', branch);
|
||||
const mikeArgs = [
|
||||
@@ -137,7 +160,7 @@ export async function deploy({
|
||||
if (alias) {
|
||||
mikeArgs.push(alias);
|
||||
}
|
||||
await doDeploy(mikeArgs, execOpts);
|
||||
await doDeploy(mikePath, mikeArgs, execOpts);
|
||||
|
||||
log.success('Finished deployment into branch %s (%dms)', branch, stop());
|
||||
}
|
||||
|
||||
@@ -75,6 +75,7 @@ export function parseNav(nav: MkDocsYmlNav): ParsedNavData[] {
|
||||
const queue: QueueItem[] = [{entries, keypath: ''}];
|
||||
|
||||
while (queue.length) {
|
||||
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
||||
const {entries, keypath} = queue.shift()!;
|
||||
for (const [key, item] of entries) {
|
||||
if (_.isString(item)) {
|
||||
@@ -99,8 +100,10 @@ export function parseNav(nav: MkDocsYmlNav): ParsedNavData[] {
|
||||
}
|
||||
|
||||
/**
|
||||
* Finds all items within the list of parsed nav data which correpsond to the header. This is
|
||||
* imperfect, as it's possible for the header string to appear in multiple places in the nav, but let's just ignore that until we can't.
|
||||
* Finds all items within the list of parsed nav data which correpsond to the header.
|
||||
*
|
||||
* This is imperfect, as it's possible for the header string to appear in multiple places in the
|
||||
* nav, but let's just ignore that until we can't.
|
||||
* @param navData Some parsed nav data
|
||||
* @param header Header name
|
||||
*/
|
||||
@@ -109,6 +112,8 @@ function filterHeaderItems(navData: ParsedNavData[], header: string) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Given a root header keypath (like a prefix), a numeric offset, and some parsed nav data, compute
|
||||
* a keypath
|
||||
*
|
||||
* @param rootHeaderKeypath Root keypath as determined by {@linkcode getRootHeaderKeypath}
|
||||
* @param offset Numeric offset within the array of items for the header
|
||||
@@ -135,16 +140,16 @@ function navDataDidChange(
|
||||
newNavData: Array<Omit<ParsedNavData, 'name'>>,
|
||||
navData: ParsedNavData[]
|
||||
): boolean {
|
||||
const diff = _.xorWith(
|
||||
newNavData,
|
||||
navData,
|
||||
(a, b) => a.keypath === b.keypath && a.fileOrUrl === b.fileOrUrl
|
||||
);
|
||||
// the result should be the items from newNavData which either don't appear in
|
||||
// navdata, or the items which do appear in navData but have a different fileOrUrl
|
||||
const matchedKeypaths = _.intersectionBy(newNavData, navData, 'keypath');
|
||||
const diff = _.xorBy(newNavData, matchedKeypaths, 'fileOrUrl');
|
||||
return !_.isEmpty(diff);
|
||||
}
|
||||
|
||||
/**
|
||||
* Find the "root" keypath for a particular header
|
||||
*
|
||||
* @param headerItems Some subset of the nav data having keypaths corresponding to `header`
|
||||
* @param header Header string
|
||||
* @returns The keypath up to the header string, inclusive
|
||||
@@ -153,6 +158,7 @@ function getRootHeaderKeypath(headerItems: ParsedNavData[], header: string) {
|
||||
// these are the parts of the keypath of the first item, which will contain the header string. it
|
||||
// dosn't matter whether we pick the first one or any one; they will all contain the same root
|
||||
// keypath by definition.
|
||||
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
||||
const rootHeaderKeypathParts = _.toPath(_.first(headerItems)!.keypath);
|
||||
|
||||
// this is the keypath up to the header string, inclusive.
|
||||
@@ -165,7 +171,6 @@ function getRootHeaderKeypath(headerItems: ParsedNavData[], header: string) {
|
||||
* by `dir`; if `all` is true, we just use the default header, because we will be returning a whole
|
||||
* lot of headers).
|
||||
*
|
||||
*
|
||||
* @param dir Abs path to directory containing markdown files generated by TypeDoc
|
||||
* @param mkDocsDocsDir Configured `docs_dir` or via options
|
||||
* @param navData Nav data parsed by {@linkcode parseNav}
|
||||
@@ -200,7 +205,6 @@ async function getNavItemsForDir(
|
||||
const offset = navHeaderItems.findIndex((item) => item.fileOrUrl === fileOrUrl);
|
||||
const newOffset = offset >= 0 ? offset : navHeaderItems.length;
|
||||
const data = navHeaderItems[offset];
|
||||
log.warn(rootHeaderKeypath, newOffset, data);
|
||||
const keypath = getKeypathForHeaderItem(rootHeaderKeypath, newOffset, data);
|
||||
newNavHeaderItems.push({keypath, fileOrUrl});
|
||||
}
|
||||
|
||||
@@ -7,9 +7,9 @@
|
||||
|
||||
import path from 'node:path';
|
||||
import {exec, TeenProcessExecOptions} from 'teen_process';
|
||||
import {DEFAULT_SITE_DIR, NAME_BIN, NAME_MKDOCS_YML} from '../constants';
|
||||
import {DEFAULT_SITE_DIR, NAME_BIN, NAME_MKDOCS, NAME_MKDOCS_YML, NAME_PYTHON} from '../constants';
|
||||
import {DocutilsError} from '../error';
|
||||
import {findMkDocsYml, readMkDocsYml, whichMkDocs} from '../fs';
|
||||
import {findMkDocsYml, findPython, readMkDocsYml} from '../fs';
|
||||
import {getLogger} from '../logger';
|
||||
import {relative, spawnBackgroundProcess, SpawnBackgroundProcessOpts, stopwatch} from '../util';
|
||||
|
||||
@@ -17,37 +17,31 @@ const log = getLogger('mkdocs');
|
||||
|
||||
/**
|
||||
* Runs `mkdocs serve`
|
||||
* @param pythonPath Path to Python 3 executable
|
||||
* @param args Extra args to `mkdocs build`
|
||||
* @param opts Extra options for `teen_process.Subprocess.start`
|
||||
* @param mkDocsPath Path to `mkdocs` executable
|
||||
*/
|
||||
async function doServe(
|
||||
pythonPath: string,
|
||||
args: string[] = [],
|
||||
opts: SpawnBackgroundProcessOpts = {},
|
||||
mkDocsPath?: string
|
||||
opts: SpawnBackgroundProcessOpts = {}
|
||||
) {
|
||||
mkDocsPath = mkDocsPath ?? (await whichMkDocs());
|
||||
const finalArgs = ['serve', ...args];
|
||||
|
||||
log.debug('Launching %s with args: %s', mkDocsPath, finalArgs);
|
||||
return spawnBackgroundProcess(mkDocsPath, finalArgs, opts);
|
||||
const finalArgs = ['-m', NAME_MKDOCS, 'serve', ...args];
|
||||
log.debug('Executing %s via: %s, %O', NAME_MKDOCS, pythonPath, finalArgs);
|
||||
return spawnBackgroundProcess(pythonPath, finalArgs, opts);
|
||||
}
|
||||
|
||||
/**
|
||||
* Runs `mkdocs build`
|
||||
* @param pythonPath Path to Python 3 executable
|
||||
* @param args Extra args to `mkdocs build`
|
||||
* @param opts Extra options to `teen_process.exec`
|
||||
* @param mkDocsPath Path to `mkdocs` executable
|
||||
*/
|
||||
async function doBuild(
|
||||
args: string[] = [],
|
||||
opts: TeenProcessExecOptions = {},
|
||||
mkDocsPath?: string
|
||||
) {
|
||||
mkDocsPath = mkDocsPath ?? (await whichMkDocs());
|
||||
const finalArgs = ['build', ...args];
|
||||
log.debug('Launching %s with args: %O', mkDocsPath, finalArgs);
|
||||
return await exec(mkDocsPath, finalArgs, opts);
|
||||
async function doBuild(pythonPath: string, args: string[] = [], opts: TeenProcessExecOptions = {}) {
|
||||
const finalArgs = ['-m', NAME_MKDOCS, 'build', ...args];
|
||||
log.debug('Executing %s via: %s, %O', NAME_MKDOCS, pythonPath, finalArgs);
|
||||
return await exec(pythonPath, finalArgs, opts);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -63,6 +57,14 @@ export async function buildSite({
|
||||
execOpts,
|
||||
}: BuildMkDocsOpts = {}) {
|
||||
const stop = stopwatch('build-mkdocs');
|
||||
|
||||
const pythonPath = await findPython();
|
||||
if (!pythonPath) {
|
||||
throw new DocutilsError(
|
||||
`Could not find ${NAME_PYTHON}3/${NAME_PYTHON} executable in PATH; please install Python v3`
|
||||
);
|
||||
}
|
||||
|
||||
mkDocsYmlPath = mkDocsYmlPath
|
||||
? path.resolve(process.cwd(), mkDocsYmlPath)
|
||||
: await findMkDocsYml(cwd);
|
||||
@@ -77,10 +79,10 @@ export async function buildSite({
|
||||
}
|
||||
if (serve) {
|
||||
// unsure about how SIGHUP is handled here
|
||||
await doServe(mkdocsArgs, serveOpts);
|
||||
await doServe(pythonPath, mkdocsArgs, serveOpts);
|
||||
} else {
|
||||
log.info('Building site...');
|
||||
await doBuild(mkdocsArgs, execOpts);
|
||||
await doBuild(pythonPath, mkdocsArgs, execOpts);
|
||||
let relSiteDir;
|
||||
if (siteDir) {
|
||||
relSiteDir = relative(cwd, siteDir);
|
||||
|
||||
@@ -79,7 +79,10 @@ export async function checkMissingPaths<T extends Record<string, Options>>(
|
||||
|
||||
if (missingPaths.length) {
|
||||
return missingPaths
|
||||
.map(({id, path}) => `Path specified using --${_.kebabCase(id)} (${path}) does not exist`)
|
||||
.map(
|
||||
({id, path}) =>
|
||||
`Default or specified path via --${_.kebabCase(id)} (${path}) does not exist`
|
||||
)
|
||||
.join('\n');
|
||||
}
|
||||
|
||||
|
||||
@@ -124,7 +124,7 @@ const opts = {
|
||||
remote: {
|
||||
alias: 'r',
|
||||
describe: 'Remote to push to',
|
||||
implies: ['deploy', 'push'],
|
||||
implies: 'push',
|
||||
group: BuildCommandGroup.Deploy,
|
||||
type: 'string',
|
||||
requiresArg: true,
|
||||
@@ -133,7 +133,7 @@ const opts = {
|
||||
},
|
||||
prefix: {
|
||||
describe: 'Subdirectory within <branch> to commit to',
|
||||
implies: ['deploy', 'branch'],
|
||||
implies: 'branch',
|
||||
group: BuildCommandGroup.Deploy,
|
||||
type: 'string',
|
||||
nargs: 1,
|
||||
@@ -168,9 +168,10 @@ const opts = {
|
||||
},
|
||||
rebase: {
|
||||
describe: 'Rebase <branch> with remote before deploy',
|
||||
implies: ['deploy', 'branch', 'remote'],
|
||||
implies: 'deploy',
|
||||
group: BuildCommandGroup.Deploy,
|
||||
type: 'boolean',
|
||||
defaultDescription: 'true',
|
||||
},
|
||||
serve: {
|
||||
describe: 'Start development server',
|
||||
|
||||
@@ -30,6 +30,7 @@ const opts = {
|
||||
nargs: 1,
|
||||
requiresArg: true,
|
||||
type: 'string',
|
||||
implies: 'mkdocs',
|
||||
},
|
||||
dir: {
|
||||
default: '.',
|
||||
@@ -59,6 +60,7 @@ const opts = {
|
||||
group: InitCommandGroup.MkDocs,
|
||||
requiresArg: true,
|
||||
type: 'string',
|
||||
implies: 'mkdocs',
|
||||
},
|
||||
mkdocs: {
|
||||
default: true,
|
||||
@@ -74,6 +76,7 @@ const opts = {
|
||||
normalize: true,
|
||||
requiresArg: true,
|
||||
type: 'string',
|
||||
implies: 'mkdocs',
|
||||
},
|
||||
'package-json': {
|
||||
defaultDescription: './package.json',
|
||||
@@ -98,6 +101,7 @@ const opts = {
|
||||
normalize: true,
|
||||
requiresArg: true,
|
||||
type: 'string',
|
||||
implies: 'python',
|
||||
},
|
||||
'repo-name': {
|
||||
defaultDescription: '(derived from --repo-url)',
|
||||
@@ -106,6 +110,7 @@ const opts = {
|
||||
nargs: 1,
|
||||
requiresArg: true,
|
||||
type: 'string',
|
||||
implies: 'mkdocs',
|
||||
},
|
||||
'repo-url': {
|
||||
defaultDescription: '(from package.json)',
|
||||
@@ -114,6 +119,7 @@ const opts = {
|
||||
nargs: 1,
|
||||
requiresArg: true,
|
||||
type: 'string',
|
||||
implies: 'mkdocs',
|
||||
},
|
||||
'site-description': {
|
||||
defaultDescription: '(from package.json)',
|
||||
@@ -122,6 +128,7 @@ const opts = {
|
||||
nargs: 1,
|
||||
requiresArg: true,
|
||||
type: 'string',
|
||||
implies: 'mkdocs',
|
||||
},
|
||||
'site-name': {
|
||||
defaultDescription: '(extension package name)',
|
||||
@@ -130,6 +137,7 @@ const opts = {
|
||||
nargs: 1,
|
||||
requiresArg: true,
|
||||
type: 'string',
|
||||
implies: 'mkdocs',
|
||||
},
|
||||
'tsconfig-json': {
|
||||
defaultDescription: './tsconfig.json',
|
||||
@@ -139,12 +147,14 @@ const opts = {
|
||||
normalize: true,
|
||||
requiresArg: true,
|
||||
type: 'string',
|
||||
implies: 'typescript',
|
||||
},
|
||||
typedoc: {
|
||||
default: true,
|
||||
description: 'Create typedoc.json if needed',
|
||||
group: InitCommandGroup.Behavior,
|
||||
type: 'boolean',
|
||||
implies: 'entry-point',
|
||||
},
|
||||
'typedoc-json': {
|
||||
defaultDescription: './typedoc.json',
|
||||
@@ -154,6 +164,17 @@ const opts = {
|
||||
normalize: true,
|
||||
requiresArg: true,
|
||||
type: 'string',
|
||||
implies: 'typedoc',
|
||||
},
|
||||
'entry-point': {
|
||||
alias: 'e',
|
||||
describe: 'Source entry point of extension',
|
||||
group: InitCommandGroup.Paths,
|
||||
nargs: 1,
|
||||
normalize: false,
|
||||
requiresArg: true,
|
||||
type: 'string',
|
||||
implies: 'typedoc',
|
||||
},
|
||||
typescript: {
|
||||
default: true,
|
||||
@@ -167,6 +188,7 @@ const opts = {
|
||||
group: InitCommandGroup.Behavior,
|
||||
type: 'boolean',
|
||||
conflicts: 'force',
|
||||
implies: 'python',
|
||||
},
|
||||
} as const satisfies Record<string, Options>;
|
||||
|
||||
|
||||
@@ -50,7 +50,7 @@ const opts = {
|
||||
},
|
||||
'python-path': {
|
||||
defaultDescription: '(derived from shell)',
|
||||
description: 'Path to python 3 executable',
|
||||
description: 'Path to python3 executable',
|
||||
group: ValidateCommandGroup.Paths,
|
||||
nargs: 1,
|
||||
normalize: true,
|
||||
@@ -81,6 +81,15 @@ const opts = {
|
||||
requiresArg: true,
|
||||
type: 'string',
|
||||
},
|
||||
'typedoc-path': {
|
||||
defaultDescription: '(derived from shell)',
|
||||
description: 'Path to typedoc executable',
|
||||
group: ValidateCommandGroup.Paths,
|
||||
nargs: 1,
|
||||
normalize: true,
|
||||
requiresArg: true,
|
||||
type: 'string',
|
||||
},
|
||||
typescript: {
|
||||
default: true,
|
||||
description: 'Validate TypeScript environment',
|
||||
|
||||
@@ -8,19 +8,20 @@
|
||||
|
||||
import {getLogger} from '../logger';
|
||||
|
||||
import {fs} from '@appium/support';
|
||||
import _ from 'lodash';
|
||||
import {sync as readPkg} from 'read-pkg';
|
||||
import {hideBin} from 'yargs/helpers';
|
||||
import yargs from 'yargs/yargs';
|
||||
import {DEFAULT_LOG_LEVEL, LogLevelMap, NAME_BIN} from '../constants';
|
||||
import {DocutilsError} from '../error';
|
||||
import {build, init, validate} from './command';
|
||||
import {findConfig} from './config';
|
||||
import {fs} from '@appium/support';
|
||||
import {sync as readPkg} from 'read-pkg';
|
||||
|
||||
const pkg = readPkg({cwd: fs.findRoot(__dirname)});
|
||||
|
||||
const log = getLogger('cli');
|
||||
const IMPLICATIONS_FAILED_REGEX = /implications\s+failed:\n\s*(.+)\s->\s(.+)$/i;
|
||||
|
||||
export async function main(argv = hideBin(process.argv)) {
|
||||
const config = await findConfig(argv);
|
||||
|
||||
@@ -70,12 +71,34 @@ export async function main(argv = hideBin(process.argv)) {
|
||||
* Custom failure handler so we can log nicely.
|
||||
*/
|
||||
(msg: string | null, error) => {
|
||||
/**
|
||||
* yargs' default output if an "implication" fails (e.g., arg _A_ requires arg _B_) leaves much to be desired.
|
||||
*
|
||||
* @remarks Unfortunately, we do not have access to the parsed arguments object, since it may have failed parsing.
|
||||
* @param msg Implication failure message
|
||||
* @returns Whether the message was an implication failure
|
||||
*/
|
||||
const handleImplicationFailure = (msg: string | null): boolean => {
|
||||
let match: RegExpMatchArray | null | undefined;
|
||||
if (!(match = msg?.match(IMPLICATIONS_FAILED_REGEX))) {
|
||||
return false;
|
||||
}
|
||||
const [, arg, missingArg] = match;
|
||||
log.error(
|
||||
`Argument "--${arg}" requires "--${missingArg}"; note that "--${arg}" may be enabled by default`
|
||||
);
|
||||
return true;
|
||||
};
|
||||
|
||||
// if it is a DocutilsError, it has nothing to do with the CLI
|
||||
if (error instanceof DocutilsError) {
|
||||
log.error(error.message);
|
||||
} else {
|
||||
y.showHelp();
|
||||
log.error(`\n\n${msg ?? error.message}`);
|
||||
|
||||
if (!handleImplicationFailure(msg)) {
|
||||
log.error(`\n\n${msg ?? error.message}`);
|
||||
}
|
||||
}
|
||||
y.exit(1, error);
|
||||
}
|
||||
|
||||
+73
-22
@@ -3,28 +3,29 @@
|
||||
* @module
|
||||
*/
|
||||
|
||||
import findUp from 'find-up';
|
||||
import YAML from 'yaml';
|
||||
import readPkg, {NormalizedPackageJson, PackageJson} from 'read-pkg';
|
||||
import path from 'node:path';
|
||||
import {JsonValue} from 'type-fest';
|
||||
import {fs} from '@appium/support';
|
||||
import findUp from 'find-up';
|
||||
import * as JSON5 from 'json5';
|
||||
import _ from 'lodash';
|
||||
import path from 'node:path';
|
||||
import _pkgDir from 'pkg-dir';
|
||||
import {getLogger} from './logger';
|
||||
import readPkg, {NormalizedPackageJson, PackageJson} from 'read-pkg';
|
||||
import {JsonValue} from 'type-fest';
|
||||
import {Application, TypeDocReader} from 'typedoc';
|
||||
import YAML from 'yaml';
|
||||
import {
|
||||
NAME_TYPEDOC_JSON,
|
||||
NAME_MKDOCS_YML,
|
||||
NAME_PACKAGE_JSON,
|
||||
NAME_MKDOCS,
|
||||
NAME_NPM,
|
||||
NAME_PYTHON,
|
||||
NAME_MIKE,
|
||||
NAME_MKDOCS_YML,
|
||||
NAME_NPM,
|
||||
NAME_PACKAGE_JSON,
|
||||
NAME_PYTHON,
|
||||
NAME_TYPEDOC,
|
||||
NAME_TYPEDOC_JSON,
|
||||
} from './constants';
|
||||
import {DocutilsError} from './error';
|
||||
import {getLogger} from './logger';
|
||||
import {MkDocsYml} from './model';
|
||||
import { exec } from 'teen_process';
|
||||
|
||||
const log = getLogger('fs');
|
||||
|
||||
@@ -207,27 +208,77 @@ export function safeWriteFile(filepath: string, content: JsonValue, overwrite =
|
||||
/**
|
||||
* `which` with memoization
|
||||
*/
|
||||
export const cachedWhich = _.memoize(fs.which);
|
||||
|
||||
/**
|
||||
* Finds `mkdocs` executable
|
||||
*/
|
||||
export const whichMkDocs = _.partial(cachedWhich, NAME_MKDOCS);
|
||||
const cachedWhich = _.memoize(fs.which as typeof import('which'));
|
||||
|
||||
/**
|
||||
* Finds `npm` executable
|
||||
*/
|
||||
export const whichNpm = _.partial(cachedWhich, NAME_NPM);
|
||||
export const whichNpm = _.partial(cachedWhich, NAME_NPM, {nothrow: true});
|
||||
|
||||
/**
|
||||
* Finds `python` executable
|
||||
*/
|
||||
export const whichPython = _.partial(cachedWhich, NAME_PYTHON);
|
||||
const whichPython = _.partial(cachedWhich, NAME_PYTHON, {nothrow: true});
|
||||
|
||||
/**
|
||||
* Finds `mike` executable
|
||||
* Finds `python3` executable
|
||||
*/
|
||||
export const whichMike = _.partial(cachedWhich, NAME_MIKE);
|
||||
const whichPython3 = _.partial(cachedWhich, `${NAME_PYTHON}3`, {nothrow: true});
|
||||
|
||||
/**
|
||||
* Finds `typedoc` executable
|
||||
*/
|
||||
const whichTypeDoc = _.partial(cachedWhich, NAME_TYPEDOC, {nothrow: true});
|
||||
|
||||
/**
|
||||
* `mike` cannot be invoked via `python -m`, so we need to find the script.
|
||||
*/
|
||||
export const findMike = _.partial(async () => {
|
||||
// see if it's in PATH
|
||||
let mikePath = await cachedWhich(NAME_MIKE, {nothrow: true});
|
||||
if (mikePath) {
|
||||
return mikePath;
|
||||
}
|
||||
// if it isn't, it may be in a user dir
|
||||
const pythonPath = await findPython();
|
||||
if (!pythonPath) {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
// the user dir can be found this way.
|
||||
// usually it's something like ~/.local
|
||||
const {stdout} = await exec(pythonPath, ['-m', 'site', '--user-base']);
|
||||
if (stdout) {
|
||||
mikePath = path.join(stdout.trim(), 'bin', 'mike');
|
||||
if (await fs.isExecutable(mikePath)) {
|
||||
return mikePath;
|
||||
}
|
||||
}
|
||||
}
|
||||
catch {}
|
||||
});
|
||||
|
||||
/**
|
||||
* Finds the `typedoc` executable.
|
||||
*
|
||||
* Looks in the `node_modules/.bin` dir from the current working directory, and if this fails, in the `node_modules` dir for the file which `.bin/typedoc` should be a symlink of, and if _that_ fails, try the `PATH`.
|
||||
*/
|
||||
export const findTypeDoc = _.memoize(async (cwd = process.cwd()): Promise<string | undefined> => {
|
||||
// .cmd is for win32, of course. note that glob _always_ uses posix dir separators.
|
||||
const globResult =
|
||||
(await fs.glob('node_modules/.bin/typedoc?(.cmd)', {cwd, nodir: true})) ??
|
||||
(await fs.glob('node_modules/**/typedoc/bin/typedoc', {cwd, nodir: true, follow: true}));
|
||||
return _.first(globResult) ?? (await whichTypeDoc());
|
||||
});
|
||||
|
||||
/**
|
||||
* Finds the `python3` or `python` executable in the user's `PATH`.
|
||||
*
|
||||
* `python3` is preferred over `python`, since the latter could be Python 2.
|
||||
*/
|
||||
export const findPython = _.memoize(
|
||||
async (): Promise<string | undefined> => (await whichPython3()) ?? (await whichPython())
|
||||
);
|
||||
|
||||
/**
|
||||
* Reads an `mkdocs.yml` file, merges inherited configs, and returns the result. The result is cached.
|
||||
|
||||
@@ -11,16 +11,17 @@ import {
|
||||
NAME_PYTHON,
|
||||
REQUIREMENTS_TXT_PATH,
|
||||
NAME_TYPEDOC_JSON,
|
||||
NAME_PACKAGE_JSON,
|
||||
} from './constants';
|
||||
import YAML from 'yaml';
|
||||
import {exec} from 'teen_process';
|
||||
import {Simplify} from 'type-fest';
|
||||
import {PackageJson, Simplify} from 'type-fest';
|
||||
import {DocutilsError} from './error';
|
||||
import {createScaffoldTask, ScaffoldTaskOptions} from './scaffold';
|
||||
import {getLogger} from './logger';
|
||||
import {MkDocsYml, TsConfigJson, TypeDocJson} from './model';
|
||||
import _ from 'lodash';
|
||||
import {stringifyJson5, stringifyYaml} from './fs';
|
||||
import {findPython, stringifyJson5, stringifyYaml} from './fs';
|
||||
|
||||
/**
|
||||
* Data for the base `mkdocs.yml` file
|
||||
@@ -54,9 +55,19 @@ const BASE_TSCONFIG_JSON: Readonly<TsConfigJson> = Object.freeze({
|
||||
},
|
||||
});
|
||||
|
||||
/**
|
||||
* Data for the base `package.json` file.
|
||||
* We expect `package.json` to exist, and we are not in the business of creating it.
|
||||
* However, we will need to add a `typedoc.entryPoint` prop to it.
|
||||
*/
|
||||
const BASE_PACKAGE_JSON: Readonly<PackageJson> = Object.freeze({});
|
||||
|
||||
const log = getLogger('init');
|
||||
const dryRunLog = getLogger('dry-run', log);
|
||||
|
||||
/**
|
||||
* Files included, by default, in `tsconfig.json`
|
||||
*/
|
||||
const DEFAULT_INCLUDE = ['lib', 'test', 'index.js'];
|
||||
/**
|
||||
* Function which scaffolds a `tsconfig.json` file
|
||||
@@ -97,6 +108,26 @@ export const initTypeDocJson = createScaffoldTask<InitTypeDocOptions, TypeDocJso
|
||||
'TypeDoc configuration'
|
||||
);
|
||||
|
||||
/**
|
||||
* Function which scaffolds a `package.json` file
|
||||
*
|
||||
* This only amends prop `typedoc.entryPoint` to the `package.json` file.
|
||||
*
|
||||
* If, strangely, `package.json` did not exist, then it will now contain _only_ that prop.
|
||||
*/
|
||||
export const initTypeDocPkgJson = createScaffoldTask<InitTypeDocOptions, PackageJson>(
|
||||
NAME_PACKAGE_JSON,
|
||||
BASE_PACKAGE_JSON,
|
||||
'Package configuration for TypeDoc',
|
||||
{
|
||||
transform: (content, opts) =>
|
||||
({
|
||||
...content,
|
||||
typedoc: {entryPoint: opts.typeDocEntryPoint},
|
||||
} as PackageJson),
|
||||
}
|
||||
);
|
||||
|
||||
/**
|
||||
* Function which scaffolds an `mkdocs.yml` file
|
||||
*/
|
||||
@@ -158,10 +189,12 @@ export const initMkDocs = createScaffoldTask<InitMkDocsOptions, MkDocsYml>(
|
||||
* @param opts Options
|
||||
*/
|
||||
export async function initPython({
|
||||
pythonPath = NAME_PYTHON,
|
||||
pythonPath,
|
||||
dryRun = false,
|
||||
upgrade = false,
|
||||
}: InitPythonOptions = {}): Promise<void> {
|
||||
pythonPath = pythonPath ?? (await findPython()) ?? NAME_PYTHON;
|
||||
|
||||
const args = ['-m', 'pip', 'install', '-r', REQUIREMENTS_TXT_PATH];
|
||||
if (upgrade) {
|
||||
args.push('--upgrade');
|
||||
@@ -222,6 +255,7 @@ export async function init({
|
||||
pythonPath,
|
||||
upgrade,
|
||||
typedocJson: typeDocJsonPath,
|
||||
entryPoint: typeDocEntryPoint,
|
||||
}: InitOptions = {}): Promise<void> {
|
||||
if (!typescript && typedoc) {
|
||||
log.warn(
|
||||
@@ -248,6 +282,13 @@ export async function init({
|
||||
dryRun,
|
||||
cwd,
|
||||
});
|
||||
await initTypeDocPkgJson({
|
||||
packageJson: packageJsonPath,
|
||||
overwrite: true, // <-- always overwrite
|
||||
dryRun,
|
||||
cwd,
|
||||
typeDocEntryPoint,
|
||||
});
|
||||
}
|
||||
|
||||
if (python) {
|
||||
@@ -269,7 +310,10 @@ export async function init({
|
||||
}
|
||||
}
|
||||
|
||||
export type InitTypeDocOptions = ScaffoldTaskOptions;
|
||||
export interface InitTypeDocOptions extends ScaffoldTaskOptions {
|
||||
typeDocEntryPoint?: string;
|
||||
}
|
||||
|
||||
export interface InitTsConfigOptions extends ScaffoldTaskOptions {
|
||||
/**
|
||||
* List of source files (globs supported); typically `src` or `lib`
|
||||
@@ -332,5 +376,10 @@ export type InitOptions = Simplify<
|
||||
* If `true`, upgrade only
|
||||
*/
|
||||
upgrade?: boolean;
|
||||
|
||||
/**
|
||||
* Path to entry point of extension (source; not "main" field)
|
||||
*/
|
||||
entryPoint?: string;
|
||||
}
|
||||
>;
|
||||
|
||||
@@ -6,20 +6,19 @@
|
||||
* @module
|
||||
*/
|
||||
|
||||
import figures from 'figures';
|
||||
import logSymbols from 'log-symbols';
|
||||
import chalk, {ForegroundColor, BackgroundColor} from 'chalk';
|
||||
import chalk, {type BackgroundColor, type ForegroundColor} from 'chalk';
|
||||
import consola, {
|
||||
logType as LogType,
|
||||
ConsolaReporterLogObject,
|
||||
type Consola,
|
||||
type ConsolaReporterLogObject,
|
||||
FancyReporter,
|
||||
FancyReporterOptions,
|
||||
Consola,
|
||||
ConsolaOptions,
|
||||
LogLevel,
|
||||
type FancyReporterOptions,
|
||||
type LogLevel,
|
||||
type logType as LogType,
|
||||
} from 'consola';
|
||||
import {DEFAULT_LOG_LEVEL, LogLevelMap} from './constants';
|
||||
import figures from 'figures';
|
||||
import _ from 'lodash';
|
||||
import logSymbols from 'log-symbols';
|
||||
import {DEFAULT_LOG_LEVEL, LogLevelMap} from './constants';
|
||||
|
||||
/**
|
||||
* This is a reporter for `consola` which uses some extra/custom icons and colors.
|
||||
|
||||
@@ -92,6 +92,7 @@ export function createScaffoldTask<Opts extends ScaffoldTaskOptions, T extends J
|
||||
const relativeDest = relativePath(dest);
|
||||
log.debug('Initializing %s', relativeDest);
|
||||
let shouldWriteDest = false;
|
||||
let isNew = false;
|
||||
let destContent: T;
|
||||
let result: ScaffoldTaskResult<T>;
|
||||
try {
|
||||
@@ -105,6 +106,7 @@ export function createScaffoldTask<Opts extends ScaffoldTaskOptions, T extends J
|
||||
shouldWriteDest = true;
|
||||
log.debug('Creating new file %s', relativeDest);
|
||||
destContent = {} as T;
|
||||
isNew = true;
|
||||
}
|
||||
|
||||
const defaults: T = transform(defaultContent, opts, pkg);
|
||||
@@ -113,7 +115,7 @@ export function createScaffoldTask<Opts extends ScaffoldTaskOptions, T extends J
|
||||
shouldWriteDest = shouldWriteDest || !_.isEqual(destContent, finalDestContent);
|
||||
|
||||
if (shouldWriteDest) {
|
||||
log.info('Changes needed to %s', relativeDest);
|
||||
log.info('Changes needed in %s', relativeDest);
|
||||
log.debug('Original %s: %O', relativeDest, destContent);
|
||||
log.debug('Final %s: %O', relativeDest, finalDestContent);
|
||||
const patch = makePatch(dest, destContent, finalDestContent, serialize);
|
||||
@@ -126,6 +128,11 @@ export function createScaffoldTask<Opts extends ScaffoldTaskOptions, T extends J
|
||||
|
||||
try {
|
||||
await safeWriteFile(dest, finalDestContent, overwrite);
|
||||
if (isNew) {
|
||||
log.success('Initialized %s', description);
|
||||
} else {
|
||||
log.success('Updated %s', description);
|
||||
}
|
||||
} catch (e) {
|
||||
const err = e as NodeJS.ErrnoException;
|
||||
// this should only be thrown if `force` is false
|
||||
@@ -139,9 +146,9 @@ export function createScaffoldTask<Opts extends ScaffoldTaskOptions, T extends J
|
||||
}
|
||||
}
|
||||
} else {
|
||||
log.info('No changes to %s', relativeDest);
|
||||
log.info('No changes necessary for %s', relativeDest);
|
||||
}
|
||||
log.success('Initialized %s', description);
|
||||
log.success(`${description}: done`);
|
||||
return {path: dest, content: finalDestContent};
|
||||
};
|
||||
}
|
||||
@@ -153,7 +160,7 @@ export function createScaffoldTask<Opts extends ScaffoldTaskOptions, T extends J
|
||||
export type ScaffoldTaskTransformer<Opts extends ScaffoldTaskOptions, T extends JsonValue> = (
|
||||
content: Readonly<T>,
|
||||
opts: TaskSpecificOpts<Opts>,
|
||||
pkg: NormalizedPackageJson
|
||||
pkg: Readonly<NormalizedPackageJson>
|
||||
) => T;
|
||||
|
||||
/**
|
||||
|
||||
@@ -6,7 +6,6 @@
|
||||
import _ from 'lodash';
|
||||
import {SpawnOptions, spawn} from 'node:child_process';
|
||||
import path from 'node:path';
|
||||
import type {SubProcess} from 'teen_process';
|
||||
|
||||
/**
|
||||
* Computes a relative path, prepending `./`
|
||||
@@ -26,7 +25,7 @@ export function stopwatch(id: string) {
|
||||
const start = Date.now();
|
||||
stopwatch.cache.set(id, start);
|
||||
return () => {
|
||||
const result = Date.now() - stopwatch.cache.get(id)!;
|
||||
const result = Date.now() - (stopwatch.cache.get(id) ?? 0);
|
||||
stopwatch.cache.delete(id);
|
||||
return result;
|
||||
};
|
||||
|
||||
@@ -31,14 +31,14 @@ import {
|
||||
} from './constants';
|
||||
import {DocutilsError} from './error';
|
||||
import {
|
||||
findPkgDir,
|
||||
findMkDocsYml,
|
||||
findPkgDir,
|
||||
findTypeDoc,
|
||||
readJson5,
|
||||
readTypedocJson,
|
||||
whichMkDocs,
|
||||
whichNpm,
|
||||
whichPython,
|
||||
readMkDocsYml,
|
||||
readTypedocJson,
|
||||
whichNpm,
|
||||
findPython,
|
||||
} from './fs';
|
||||
import {getLogger} from './logger';
|
||||
import {MkDocsYml, PipPackage, TypeDocJson} from './model';
|
||||
@@ -62,7 +62,7 @@ const TYPEDOC_VERSION_REGEX = /TypeDoc\s(\d+\.\d+\..+)/;
|
||||
/**
|
||||
* Matches the MkDocs version string from `mkdocs --version`
|
||||
*/
|
||||
const MKDOCS_VERSION_REGEX = /mkdocs,\s+version\s+(\d+\.\d+\.\S+)/;
|
||||
const MKDOCS_VERSION_REGEX = /\s+version\s+(\d+\.\d+\.\S+)/;
|
||||
|
||||
const log = getLogger('validate');
|
||||
|
||||
@@ -95,12 +95,12 @@ export class DocutilsValidator extends EventEmitter {
|
||||
/**
|
||||
* Path to `npm` executable.
|
||||
*/
|
||||
protected readonly npmPath: string | undefined;
|
||||
protected readonly npmPath?: string;
|
||||
|
||||
/**
|
||||
* Path to `python` executable.
|
||||
*/
|
||||
protected readonly pythonPath: string | undefined;
|
||||
protected readonly pythonPath?: string;
|
||||
|
||||
/**
|
||||
* List of validations to perform
|
||||
@@ -120,27 +120,29 @@ export class DocutilsValidator extends EventEmitter {
|
||||
/**
|
||||
* Path to `mkdocs.yml`. If not provided, will be lazily resolved.
|
||||
*/
|
||||
protected mkDocsYmlPath: string | undefined;
|
||||
protected mkDocsYmlPath?: string;
|
||||
|
||||
/**
|
||||
* Path to `package.json`. If not provided, will be lazily resolved.
|
||||
*/
|
||||
protected packageJsonPath: string | undefined;
|
||||
protected packageJsonPath?: string;
|
||||
|
||||
/**
|
||||
* Path to the package directory. If not provided, will be lazily resolved.
|
||||
*/
|
||||
protected pkgDir: string | undefined;
|
||||
protected pkgDir?: string;
|
||||
|
||||
/**
|
||||
* Path to `tsconfig.json`. If not provided, will be lazily resolved.
|
||||
*/
|
||||
protected tsconfigJsonPath: string | undefined;
|
||||
protected tsconfigJsonPath?: string;
|
||||
|
||||
/**
|
||||
* Path to `typedoc.json`. If not provided, will be lazily resolved.
|
||||
*/
|
||||
protected typeDocJsonPath: string | undefined;
|
||||
protected typeDocJsonPath?: string;
|
||||
|
||||
protected typeDocPath?: string;
|
||||
|
||||
/**
|
||||
* Emitted when validation begins with a list of validation kinds to be performed
|
||||
@@ -181,6 +183,7 @@ export class DocutilsValidator extends EventEmitter {
|
||||
this.typeDocJsonPath = opts.typedocJson;
|
||||
this.npmPath = opts.npm;
|
||||
this.mkDocsYmlPath = opts.mkdocsYml;
|
||||
this.typeDocPath = opts.typedocPath;
|
||||
|
||||
if (opts.python) {
|
||||
this.validations.add(NAME_PYTHON);
|
||||
@@ -314,21 +317,19 @@ export class DocutilsValidator extends EventEmitter {
|
||||
* Validates that the correct version of `mkdocs` is installed
|
||||
*/
|
||||
protected async validateMkDocs() {
|
||||
let mkDocsPath: string | undefined;
|
||||
try {
|
||||
mkDocsPath = await whichMkDocs();
|
||||
} catch {
|
||||
// _pretty sure_ the exception code is always ENOENT
|
||||
const pythonPath = this.pythonPath ?? (await findPython());
|
||||
|
||||
if (!pythonPath) {
|
||||
return this.fail(
|
||||
`Could not find ${NAME_MKDOCS} executable in PATH. If it is installed, check your PATH environment variable.`
|
||||
`Could not find ${NAME_PYTHON} executable in PATH. If it is installed, check your PATH environment variable.`
|
||||
);
|
||||
}
|
||||
|
||||
let rawMkDocsVersion: string | undefined;
|
||||
try {
|
||||
({stdout: rawMkDocsVersion} = await exec(mkDocsPath, ['--version']));
|
||||
({stdout: rawMkDocsVersion} = await exec(pythonPath, ['-m', NAME_MKDOCS, '--version']));
|
||||
} catch (err) {
|
||||
return this.fail(`${mkDocsPath} --version failed: ${err}`);
|
||||
return this.fail(`Failed to get MkDocs version: ${err}`);
|
||||
}
|
||||
const match = rawMkDocsVersion.match(MKDOCS_VERSION_REGEX);
|
||||
if (match) {
|
||||
@@ -343,12 +344,12 @@ export class DocutilsValidator extends EventEmitter {
|
||||
const {version: mkDocsReqdVersion} = mkDocsPipPkg;
|
||||
if (version !== mkDocsReqdVersion) {
|
||||
return this.fail(
|
||||
`${NAME_MKDOCS} at ${mkDocsPath} is v${version}, but ${REQUIREMENTS_TXT_PATH} requires v${mkDocsReqdVersion}`
|
||||
`${NAME_MKDOCS} is v${version}, but ${REQUIREMENTS_TXT_PATH} requires v${mkDocsReqdVersion}`
|
||||
);
|
||||
}
|
||||
} else {
|
||||
throw new DocutilsError(
|
||||
`Could not parse version from "${mkDocsPath} --version". This is a bug. Output was ${rawMkDocsVersion}`
|
||||
`Could not parse version from MkDocs. This is a bug. Output was ${rawMkDocsVersion}`
|
||||
);
|
||||
}
|
||||
|
||||
@@ -423,7 +424,7 @@ export class DocutilsValidator extends EventEmitter {
|
||||
*/
|
||||
protected async validatePythonDeps() {
|
||||
let pipListOutput: string;
|
||||
const pythonPath = this.pythonPath ?? (await whichPython());
|
||||
const pythonPath = this.pythonPath ?? (await findPython());
|
||||
if (!pythonPath) {
|
||||
return this.fail(`Could not find ${NAME_PYTHON} in PATH. Is it installed?`);
|
||||
}
|
||||
@@ -499,7 +500,7 @@ export class DocutilsValidator extends EventEmitter {
|
||||
* Asserts that the Python version is 3.x
|
||||
*/
|
||||
protected async validatePythonVersion() {
|
||||
const pythonPath = this.pythonPath ?? (await whichPython());
|
||||
const pythonPath = this.pythonPath ?? (await findPython());
|
||||
if (!pythonPath) {
|
||||
return this.fail(`Could not find ${NAME_PYTHON} in PATH. Is it installed?`);
|
||||
}
|
||||
@@ -520,17 +521,30 @@ export class DocutilsValidator extends EventEmitter {
|
||||
/**
|
||||
* Asserts TypeDoc is installed, runnable, the correct version, and that the config file is readable
|
||||
* and constaints required options
|
||||
*
|
||||
* @todo Another option would be to `npm exec typedoc@<version>` which delegates to `npx`.
|
||||
*/
|
||||
protected async validateTypeDoc() {
|
||||
const pkgDir = await this.findPkgDir();
|
||||
const typeDocPath = this.typeDocPath ?? (await findTypeDoc(pkgDir));
|
||||
|
||||
if (!typeDocPath) {
|
||||
return this.fail(`Could not find ${NAME_TYPEDOC}; is it installed?`);
|
||||
}
|
||||
log.debug('Found %s at %s', NAME_TYPEDOC, typeDocPath);
|
||||
|
||||
let rawTypeDocVersion: string;
|
||||
let typeDocVersion: string;
|
||||
try {
|
||||
({stdout: rawTypeDocVersion} = await exec('npm', ['exec', NAME_TYPEDOC, '--', '--version'], {
|
||||
({stdout: rawTypeDocVersion} = await exec(process.execPath, [typeDocPath, '--version'], {
|
||||
cwd: pkgDir,
|
||||
}));
|
||||
} catch {
|
||||
return this.fail(`Could not find ${NAME_TYPEDOC} executable from ${pkgDir}`);
|
||||
} catch (err) {
|
||||
return this.fail(
|
||||
`Could not execute ${process.execPath} ${typeDocPath} from ${pkgDir}. Reason: ${
|
||||
(err as Error).message
|
||||
}`
|
||||
);
|
||||
}
|
||||
|
||||
if (rawTypeDocVersion) {
|
||||
@@ -543,7 +557,8 @@ export class DocutilsValidator extends EventEmitter {
|
||||
);
|
||||
}
|
||||
|
||||
const reqdTypeDocVersion = DOCUTILS_PKG.dependencies!.typedoc!;
|
||||
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
||||
const reqdTypeDocVersion = DOCUTILS_PKG.dependencies!.typedoc!; // this is our own package.json
|
||||
if (!satisfies(typeDocVersion, reqdTypeDocVersion)) {
|
||||
return this.fail(
|
||||
`Found TypeDoc version ${typeDocVersion}, but ${reqdTypeDocVersion} is required`
|
||||
@@ -596,7 +611,7 @@ export class DocutilsValidator extends EventEmitter {
|
||||
if (!typeDocJson.out) {
|
||||
return this.fail(
|
||||
new DocutilsError(
|
||||
`Missing "out" property in ${relTypeDocJsonPath}; path "${DEFAULT_REL_TYPEDOC_OUT_PATH} is recommended`
|
||||
`Missing "out" property in ${relTypeDocJsonPath}; path "${DEFAULT_REL_TYPEDOC_OUT_PATH}" is recommended`
|
||||
)
|
||||
);
|
||||
}
|
||||
@@ -714,6 +729,10 @@ export interface DocutilsValidatorOpts {
|
||||
* If `true`, run TypeDoc validation
|
||||
*/
|
||||
typedoc?: boolean;
|
||||
/**
|
||||
* Path to `typedoc` executable
|
||||
*/
|
||||
typedocPath?: string;
|
||||
/**
|
||||
* Path to `typedoc.json`
|
||||
*/
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@appium/docutils",
|
||||
"version": "0.3.10",
|
||||
"version": "0.4.2",
|
||||
"description": "Documentation generation utilities for Appium and related projects",
|
||||
"keywords": [
|
||||
"automation",
|
||||
@@ -28,7 +28,7 @@
|
||||
"lib": "lib"
|
||||
},
|
||||
"bin": {
|
||||
"appium-docs": "./build/lib/cli/index.js"
|
||||
"appium-docs": "./bin/appium-docs.js"
|
||||
},
|
||||
"files": [
|
||||
"index.js",
|
||||
@@ -49,10 +49,11 @@
|
||||
"start": "node ./build/lib/cli/index.js"
|
||||
},
|
||||
"dependencies": {
|
||||
"@appium/support": "^4.0.0",
|
||||
"@appium/support": "^4.1.0",
|
||||
"@appium/tsconfig": "^0.3.0",
|
||||
"@appium/typedoc-plugin-appium": "^0.6.4",
|
||||
"@appium/typedoc-plugin-appium": "^0.6.5",
|
||||
"@sliphua/lilconfig-ts-loader": "3.2.2",
|
||||
"@types/which": "3.0.0",
|
||||
"chalk": "4.1.2",
|
||||
"consola": "2.15.3",
|
||||
"diff": "5.1.0",
|
||||
@@ -64,15 +65,15 @@
|
||||
"log-symbols": "4.1.0",
|
||||
"pkg-dir": "5.0.0",
|
||||
"read-pkg": "5.2.0",
|
||||
"semver": "7.5.0",
|
||||
"semver": "7.5.1",
|
||||
"source-map-support": "0.5.21",
|
||||
"teen_process": "2.0.2",
|
||||
"type-fest": "3.10.0",
|
||||
"type-fest": "3.11.1",
|
||||
"typedoc": "0.23.28",
|
||||
"typedoc-plugin-markdown": "3.14.0",
|
||||
"typedoc-plugin-resolve-crossmodule-references": "0.3.3",
|
||||
"typescript": "4.9.5",
|
||||
"yaml": "2.2.2",
|
||||
"yaml": "2.3.1",
|
||||
"yargs": "17.7.2",
|
||||
"yargs-parser": "21.1.1"
|
||||
},
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
mkdocs==1.4.3
|
||||
mkdocs-material==9.1.9
|
||||
mkdocs-material==9.1.15
|
||||
mkdocs-material-extensions==1.1.1
|
||||
mike==1.1.2
|
||||
|
||||
@@ -3,6 +3,26 @@
|
||||
All notable changes to this project will be documented in this file.
|
||||
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
||||
|
||||
## [0.4.8](https://github.com/appium/appium/compare/@appium/driver-test-support@0.4.7...@appium/driver-test-support@0.4.8) (2023-06-15)
|
||||
|
||||
**Note:** Version bump only for package @appium/driver-test-support
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
## [0.4.7](https://github.com/appium/appium/compare/@appium/driver-test-support@0.4.6...@appium/driver-test-support@0.4.7) (2023-06-14)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* **schema:** update definitelytyped ([e967240](https://github.com/appium/appium/commit/e96724077ef2b5b8aae203856195f3bb8de56116))
|
||||
* **test-support:** update dependency sinon to v15.1.0 ([4c61d53](https://github.com/appium/appium/commit/4c61d533b8f52131a637f5cd0b019375f85f075f))
|
||||
* **types:** update dependency type-fest to v3.11.0 ([19277f6](https://github.com/appium/appium/commit/19277f6e14a56e52b4669d633e148ad4a3da2c7a))
|
||||
* **types:** update dependency type-fest to v3.11.1 ([56499eb](https://github.com/appium/appium/commit/56499eb997b551739bed628f057de7987674ea7f))
|
||||
|
||||
|
||||
|
||||
## [0.4.6](https://github.com/appium/appium/compare/@appium/driver-test-support@0.4.5...@appium/driver-test-support@0.4.6) (2023-05-17)
|
||||
|
||||
|
||||
|
||||
@@ -5,6 +5,7 @@ import B from 'bluebird';
|
||||
import {TEST_HOST, getTestPort, createAppiumURL} from './helpers';
|
||||
import chai from 'chai';
|
||||
import sinon from 'sinon';
|
||||
import { Agent } from 'node:http';
|
||||
|
||||
const should = chai.should();
|
||||
|
||||
@@ -148,6 +149,9 @@ export function driverE2ETestSuite(DriverClass, defaultCaps = {}) {
|
||||
|
||||
describe('session handling', function () {
|
||||
it('should handle idempotency while creating sessions', async function () {
|
||||
// workaround for https://github.com/node-fetch/node-fetch/issues/1735
|
||||
const httpAgent = new Agent({ keepAlive: true });
|
||||
|
||||
const sessionIds = [];
|
||||
let times = 0;
|
||||
do {
|
||||
@@ -159,11 +163,7 @@ export function driverE2ETestSuite(DriverClass, defaultCaps = {}) {
|
||||
headers: {
|
||||
'X-Idempotency-Key': '123456',
|
||||
},
|
||||
// XXX: I'm not sure what these are, as they are not documented axios options,
|
||||
// nor are they mentioned in our source
|
||||
// @ts-expect-error
|
||||
simple: false,
|
||||
resolveWithFullResponse: true,
|
||||
httpAgent,
|
||||
}
|
||||
);
|
||||
|
||||
@@ -178,6 +178,9 @@ export function driverE2ETestSuite(DriverClass, defaultCaps = {}) {
|
||||
});
|
||||
|
||||
it('should handle idempotency while creating parallel sessions', async function () {
|
||||
// workaround for https://github.com/node-fetch/node-fetch/issues/1735
|
||||
const httpAgent = new Agent({ keepAlive: true });
|
||||
|
||||
const reqs = [];
|
||||
let times = 0;
|
||||
do {
|
||||
@@ -192,6 +195,7 @@ export function driverE2ETestSuite(DriverClass, defaultCaps = {}) {
|
||||
headers: {
|
||||
'X-Idempotency-Key': '12345',
|
||||
},
|
||||
httpAgent,
|
||||
}
|
||||
)
|
||||
);
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@appium/driver-test-support",
|
||||
"version": "0.4.6",
|
||||
"version": "0.4.8",
|
||||
"description": "Test utilities for Appium drivers",
|
||||
"keywords": [
|
||||
"automation",
|
||||
@@ -41,18 +41,18 @@
|
||||
},
|
||||
"types": "./build/lib/index.d.ts",
|
||||
"dependencies": {
|
||||
"@appium/types": "^0.11.1",
|
||||
"@types/lodash": "4.14.194",
|
||||
"@appium/types": "^0.13.0",
|
||||
"@types/lodash": "4.14.195",
|
||||
"@types/stoppable": "1.1.1",
|
||||
"axios": "1.4.0",
|
||||
"bluebird": "3.7.2",
|
||||
"chai": "4.3.7",
|
||||
"get-port": "5.1.1",
|
||||
"lodash": "4.17.21",
|
||||
"sinon": "15.0.4",
|
||||
"sinon": "15.1.0",
|
||||
"source-map-support": "0.5.21",
|
||||
"stoppable": "1.1.0",
|
||||
"type-fest": "3.10.0"
|
||||
"type-fest": "3.11.1"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"appium": "^2.0.0-beta.43",
|
||||
|
||||
@@ -3,6 +3,15 @@
|
||||
All notable changes to this project will be documented in this file.
|
||||
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
||||
|
||||
## [3.0.14](https://github.com/appium/appium/compare/@appium/execute-driver-plugin@3.0.13...@appium/execute-driver-plugin@3.0.14) (2023-06-14)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* **execute-driver-plugin:** update dependency vm2 to v3.9.19 ([8594d13](https://github.com/appium/appium/commit/8594d13bf6a1cb59bc76cbe2d39976ae86cdb3b2))
|
||||
|
||||
|
||||
|
||||
## [3.0.13](https://github.com/appium/appium/compare/@appium/execute-driver-plugin@3.0.12...@appium/execute-driver-plugin@3.0.13) (2023-05-17)
|
||||
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@appium/execute-driver-plugin",
|
||||
"version": "3.0.13",
|
||||
"version": "3.0.14",
|
||||
"description": "Plugin for batching and executing driver commands with Appiums",
|
||||
"keywords": [
|
||||
"automation",
|
||||
@@ -42,7 +42,7 @@
|
||||
"bluebird": "3.7.2",
|
||||
"lodash": "4.17.21",
|
||||
"source-map-support": "0.5.21",
|
||||
"vm2": "3.9.17",
|
||||
"vm2": "3.9.19",
|
||||
"webdriverio": "7.31.1"
|
||||
},
|
||||
"peerDependencies": {
|
||||
|
||||
@@ -3,6 +3,26 @@
|
||||
All notable changes to this project will be documented in this file.
|
||||
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
||||
|
||||
## [5.2.5](https://github.com/appium/appium/compare/@appium/fake-driver@5.2.4...@appium/fake-driver@5.2.5) (2023-06-15)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* **fake-driver:** update definition of findElOrEls ([598b255](https://github.com/appium/appium/commit/598b255e8d4a2b41cca0ec0c02a54c46946eadb5))
|
||||
* **types,fake-driver:** getLog doesn't necessarily return an array ([00ae162](https://github.com/appium/appium/commit/00ae1625d73305b8840d45a0dc98ac3cc628ac37))
|
||||
* **types:** various fixes for reality ([81bc527](https://github.com/appium/appium/commit/81bc527be6aa54dd30a012156b5752b8b821ac0c))
|
||||
|
||||
|
||||
|
||||
## [5.2.4](https://github.com/appium/appium/compare/@appium/fake-driver@5.2.3...@appium/fake-driver@5.2.4) (2023-06-14)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* **universal-xml-plugin:** update dependency @xmldom/xmldom to v0.8.8 ([3bf4060](https://github.com/appium/appium/commit/3bf406015eb9854abbf6cf024e3bd724468c924d))
|
||||
|
||||
|
||||
|
||||
## [5.2.3](https://github.com/appium/appium/compare/@appium/fake-driver@5.2.2...@appium/fake-driver@5.2.3) (2023-04-03)
|
||||
|
||||
|
||||
|
||||
@@ -7,17 +7,82 @@ import {util} from '@appium/support';
|
||||
import {mixin} from './mixin';
|
||||
|
||||
const {W3C_WEB_ELEMENT_IDENTIFIER} = util;
|
||||
|
||||
async function findElOrEls<Ctx = any>(
|
||||
this: FakeDriver<any>,
|
||||
strategy: string,
|
||||
selector: string,
|
||||
mult: true,
|
||||
context?: Ctx
|
||||
): Promise<Element[]>;
|
||||
async function findElOrEls<Ctx = any>(
|
||||
this: FakeDriver<any>,
|
||||
strategy: string,
|
||||
selector: string,
|
||||
mult: false,
|
||||
context?: Ctx
|
||||
): Promise<Element>;
|
||||
async function findElOrEls<Ctx = any>(
|
||||
this: FakeDriver<any>,
|
||||
strategy: string,
|
||||
selector: string,
|
||||
mult: boolean,
|
||||
context?: Ctx
|
||||
): Promise<Element | Element[]> {
|
||||
const qMap = {
|
||||
xpath: 'xpathQuery',
|
||||
id: 'idQuery',
|
||||
'accessibility id': 'idQuery',
|
||||
'class name': 'classQuery',
|
||||
'tag name': 'classQuery',
|
||||
'css selector': 'cssQuery',
|
||||
} as Record<string, keyof FakeDriver['appModel']>;
|
||||
// TODO this error checking should probably be part of MJSONWP?
|
||||
if (!_.includes(_.keys(qMap), strategy)) {
|
||||
throw new errors.UnknownCommandError();
|
||||
}
|
||||
if (selector === 'badsel') {
|
||||
throw new errors.InvalidSelectorError();
|
||||
}
|
||||
const els = this.appModel[qMap[strategy]](selector, context);
|
||||
|
||||
let retval: Element | Element[];
|
||||
if (els.length) {
|
||||
if (mult) {
|
||||
const allEls: Element[] = [];
|
||||
for (const el of els) {
|
||||
allEls.push(this.wrapNewEl(el));
|
||||
}
|
||||
retval = allEls;
|
||||
} else {
|
||||
retval = this.wrapNewEl(els[0]);
|
||||
}
|
||||
} else if (mult) {
|
||||
retval = [];
|
||||
} else {
|
||||
throw new errors.NoSuchElementError();
|
||||
}
|
||||
return retval;
|
||||
}
|
||||
|
||||
interface FakeDriverFindMixin {
|
||||
getExistingElementForNode(node: FakeElement): string | null;
|
||||
wrapNewEl(obj: FakeElement): Element;
|
||||
|
||||
findElOrEls<Many extends boolean, Ctx = any>(
|
||||
findElOrEls(
|
||||
this: FakeDriver,
|
||||
strategy: string,
|
||||
selector: string,
|
||||
many: Many,
|
||||
context?: Ctx
|
||||
): Promise<Many extends true ? Element[] : Element>;
|
||||
mult: true,
|
||||
context?: any
|
||||
): Promise<Element[]>;
|
||||
findElOrEls(
|
||||
this: FakeDriver,
|
||||
strategy: string,
|
||||
selector: string,
|
||||
mult: false,
|
||||
context?: any
|
||||
): Promise<Element>;
|
||||
findElement(strategy: string, selector: string): Promise<Element>;
|
||||
findElements(strategy: string, selector: string): Promise<Element[]>;
|
||||
findElementFromElement(elementId: string, strategy: string, selector: string): Promise<Element>;
|
||||
@@ -56,48 +121,7 @@ const FindMixin: FakeDriverFindMixin = {
|
||||
return {ELEMENT: maxElId, [W3C_WEB_ELEMENT_IDENTIFIER]: maxElId};
|
||||
},
|
||||
|
||||
async findElOrEls<Many extends boolean, Ctx = any>(
|
||||
this: FakeDriver,
|
||||
strategy: string,
|
||||
selector: string,
|
||||
many: Many,
|
||||
context: Ctx
|
||||
): Promise<Many extends true ? Element[] : Element> {
|
||||
const qMap = {
|
||||
xpath: 'xpathQuery',
|
||||
id: 'idQuery',
|
||||
'accessibility id': 'idQuery',
|
||||
'class name': 'classQuery',
|
||||
'tag name': 'classQuery',
|
||||
'css selector': 'cssQuery',
|
||||
} as Record<string, keyof FakeDriver['appModel']>;
|
||||
// TODO this error checking should probably be part of MJSONWP?
|
||||
if (!_.includes(_.keys(qMap), strategy)) {
|
||||
throw new errors.UnknownCommandError();
|
||||
}
|
||||
if (selector === 'badsel') {
|
||||
throw new errors.InvalidSelectorError();
|
||||
}
|
||||
const els = this.appModel[qMap[strategy]](selector, context);
|
||||
|
||||
let retval: Element | Element[];
|
||||
if (els.length) {
|
||||
if (many) {
|
||||
const allEls: Element[] = [];
|
||||
for (const el of els) {
|
||||
allEls.push(this.wrapNewEl(el));
|
||||
}
|
||||
retval = allEls;
|
||||
} else {
|
||||
retval = this.wrapNewEl(els[0]);
|
||||
}
|
||||
} else if (many) {
|
||||
retval = [];
|
||||
} else {
|
||||
throw new errors.NoSuchElementError();
|
||||
}
|
||||
return retval as Many extends true ? Element[] : Element;
|
||||
},
|
||||
findElOrEls,
|
||||
|
||||
/**
|
||||
* This should override whatever's in ExternalDriver
|
||||
|
||||
@@ -8,7 +8,7 @@ const ORIENTATIONS = new Set(['LANDSCAPE', 'PORTRAIT']);
|
||||
interface FakeDriverGeneralMixin {
|
||||
title(): Promise<string>;
|
||||
keys(value: string | string[]): Promise<void>;
|
||||
setGeoLocation(location: Location): Promise<void>;
|
||||
setGeoLocation(location: Location): Promise<Location>;
|
||||
getGeoLocation(): Promise<Location>;
|
||||
getPageSource(): Promise<string>;
|
||||
getOrientation(): Promise<string>;
|
||||
@@ -22,7 +22,7 @@ interface FakeDriverGeneralMixin {
|
||||
doubleClick(): Promise<void>;
|
||||
execute(script: string, args: any[]): Promise<any>;
|
||||
fakeAddition(a: number, b: number, c?: number): Promise<number>;
|
||||
getLog(type: string): Promise<unknown[]>;
|
||||
getLog(type: string): Promise<any>;
|
||||
}
|
||||
|
||||
declare module '../driver' {
|
||||
@@ -46,6 +46,7 @@ const GeneralMixin: FakeDriverGeneralMixin = {
|
||||
// TODO test this adequately once WD bug is fixed
|
||||
this.appModel.lat = location.latitude;
|
||||
this.appModel.long = location.longitude;
|
||||
return location;
|
||||
},
|
||||
|
||||
async getGeoLocation(this: FakeDriver) {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@appium/fake-driver",
|
||||
"version": "5.2.3",
|
||||
"version": "5.2.5",
|
||||
"description": "Mock driver used internally by Appium for testing. Ignore",
|
||||
"keywords": [
|
||||
"automation",
|
||||
@@ -43,11 +43,11 @@
|
||||
"test": "npm run test:unit",
|
||||
"test:e2e": "mocha --timeout 20s --slow 10s \"./test/e2e/**/*.spec.js\"",
|
||||
"test:smoke": "node ./build/lib/index.js",
|
||||
"test:unit": "mocha \"./test/unit/**/*.spec.js\""
|
||||
"test:unit": "mocha --timeout 10s --slow 5s \"./test/unit/**/*.spec.js\""
|
||||
},
|
||||
"dependencies": {
|
||||
"@types/bluebird": "3.5.38",
|
||||
"@xmldom/xmldom": "0.8.7",
|
||||
"@xmldom/xmldom": "0.8.8",
|
||||
"asyncbox": "2.9.4",
|
||||
"bluebird": "3.7.2",
|
||||
"lodash": "4.17.21",
|
||||
|
||||
@@ -3,6 +3,46 @@
|
||||
All notable changes to this project will be documented in this file.
|
||||
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
||||
|
||||
## [3.1.17](https://github.com/appium/appium/compare/@appium/fake-plugin@3.1.16...@appium/fake-plugin@3.1.17) (2023-06-15)
|
||||
|
||||
**Note:** Version bump only for package @appium/fake-plugin
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
## [3.1.16](https://github.com/appium/appium/compare/@appium/fake-plugin@3.1.15...@appium/fake-plugin@3.1.16) (2023-06-14)
|
||||
|
||||
**Note:** Version bump only for package @appium/fake-plugin
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
## [3.1.15](https://github.com/appium/appium/compare/@appium/fake-plugin@3.1.14...@appium/fake-plugin@3.1.15) (2023-06-14)
|
||||
|
||||
**Note:** Version bump only for package @appium/fake-plugin
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
## [3.1.14](https://github.com/appium/appium/compare/@appium/fake-plugin@3.1.13...@appium/fake-plugin@3.1.14) (2023-05-19)
|
||||
|
||||
**Note:** Version bump only for package @appium/fake-plugin
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
## [3.1.13](https://github.com/appium/appium/compare/@appium/fake-plugin@3.1.12...@appium/fake-plugin@3.1.13) (2023-05-19)
|
||||
|
||||
**Note:** Version bump only for package @appium/fake-plugin
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
## [3.1.12](https://github.com/appium/appium/compare/@appium/fake-plugin@3.1.11...@appium/fake-plugin@3.1.12) (2023-05-17)
|
||||
|
||||
**Note:** Version bump only for package @appium/fake-plugin
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@appium/fake-plugin",
|
||||
"version": "3.1.12",
|
||||
"version": "3.1.17",
|
||||
"description": "A fake Appium 2.0 plugin",
|
||||
"keywords": [
|
||||
"automation",
|
||||
@@ -39,8 +39,8 @@
|
||||
"test:unit": "mocha \"./test/unit/**/*.spec.js\""
|
||||
},
|
||||
"dependencies": {
|
||||
"@appium/base-plugin": "^2.2.8",
|
||||
"@appium/support": "^4.0.0",
|
||||
"@appium/base-plugin": "^2.2.13",
|
||||
"@appium/support": "^4.1.0",
|
||||
"@types/bluebird": "3.5.38",
|
||||
"bluebird": "3.7.2",
|
||||
"lodash": "4.17.21",
|
||||
|
||||
@@ -3,6 +3,24 @@
|
||||
All notable changes to this project will be documented in this file.
|
||||
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
||||
|
||||
## [2.1.2](https://github.com/appium/appium/compare/@appium/images-plugin@2.1.1...@appium/images-plugin@2.1.2) (2023-06-14)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* **images-plugin:** Make sure the template is always a buffer ([#18696](https://github.com/appium/appium/issues/18696)) ([0497090](https://github.com/appium/appium/commit/0497090a90e6219a383125543780cd71269a4604))
|
||||
|
||||
|
||||
|
||||
## [2.1.1](https://github.com/appium/appium/compare/@appium/images-plugin@2.1.0...@appium/images-plugin@2.1.1) (2023-05-19)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* **images-plugin:** Add the missing dependency to support ([#18652](https://github.com/appium/appium/issues/18652)) ([f512e59](https://github.com/appium/appium/commit/f512e596eb54edb5ca8993b3451aa4a22184bc57))
|
||||
|
||||
|
||||
|
||||
## [2.1.0](https://github.com/appium/appium/compare/@appium/images-plugin@2.0.10...@appium/images-plugin@2.1.0) (2023-05-17)
|
||||
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import {node} from '@appium/support';
|
||||
import {node} from 'appium/support';
|
||||
|
||||
export const IMAGE_STRATEGY = '-image';
|
||||
|
||||
|
||||
@@ -239,7 +239,11 @@ export default class ImageElement {
|
||||
if (strategy !== IMAGE_STRATEGY) {
|
||||
throw new errors.InvalidSelectorError(`Lookup strategies other than '${IMAGE_STRATEGY}' are not supported`);
|
||||
}
|
||||
return await this.finder.findByImage(selector, driver, {multiple, containerRect: this.rect});
|
||||
return await this.finder.findByImage(
|
||||
Buffer.from(selector, 'base64'),
|
||||
driver,
|
||||
{multiple, containerRect: this.rect}
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -52,7 +52,7 @@ export default class ImageElementPlugin extends BasePlugin {
|
||||
return await next();
|
||||
}
|
||||
|
||||
return await this.finder.findByImage(selector, driver, {multiple});
|
||||
return await this.finder.findByImage(Buffer.from(selector, 'base64'), driver, {multiple});
|
||||
}
|
||||
|
||||
async handle(next, driver, cmdName, ...args) {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@appium/images-plugin",
|
||||
"version": "2.1.0",
|
||||
"version": "2.1.2",
|
||||
"description": "Plugin for working with images and image elements in Appium",
|
||||
"keywords": [
|
||||
"automation",
|
||||
@@ -39,7 +39,7 @@
|
||||
"test:unit": "mocha \"./test/unit/**/*.spec.js\""
|
||||
},
|
||||
"dependencies": {
|
||||
"@appium/opencv": "^2.1.0",
|
||||
"@appium/opencv": "^2.1.1",
|
||||
"lodash": "4.17.21",
|
||||
"lru-cache": "7.18.3",
|
||||
"sharp": "0.32.1",
|
||||
|
||||
@@ -3,6 +3,15 @@
|
||||
All notable changes to this project will be documented in this file.
|
||||
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
||||
|
||||
## [2.1.1](https://github.com/appium/appium/compare/@appium/opencv@2.1.0...@appium/opencv@2.1.1) (2023-06-14)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* Do not use additional checks on opencv objects ([#18714](https://github.com/appium/appium/issues/18714)) ([38f8690](https://github.com/appium/appium/commit/38f86900da462a444ae5a9c92794f64a297f79bd))
|
||||
|
||||
|
||||
|
||||
## [2.1.0](https://github.com/appium/appium/compare/@appium/opencv@2.0.10...@appium/opencv@2.1.0) (2023-05-17)
|
||||
|
||||
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
import _ from 'lodash';
|
||||
|
||||
export class OpenCvAutoreleasePool {
|
||||
/**
|
||||
* @type {Set}
|
||||
@@ -17,9 +15,7 @@ export class OpenCvAutoreleasePool {
|
||||
*/
|
||||
add(...items) {
|
||||
for (const item of items) {
|
||||
if (_.has(item, 'delete') && _.isFunction(item.delete)) {
|
||||
this._items.add(item);
|
||||
}
|
||||
this._items.add(item);
|
||||
}
|
||||
return items.length === 1 ? items[0] : items;
|
||||
}
|
||||
@@ -32,4 +28,4 @@ export class OpenCvAutoreleasePool {
|
||||
}
|
||||
this._items.clear();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@appium/opencv",
|
||||
"version": "2.1.0",
|
||||
"version": "2.1.1",
|
||||
"description": "OpenCV-related helper library",
|
||||
"keywords": [
|
||||
"automation",
|
||||
|
||||
@@ -3,6 +3,22 @@
|
||||
All notable changes to this project will be documented in this file.
|
||||
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
||||
|
||||
## [0.3.16](https://github.com/appium/appium/compare/@appium/plugin-test-support@0.3.15...@appium/plugin-test-support@0.3.16) (2023-06-15)
|
||||
|
||||
**Note:** Version bump only for package @appium/plugin-test-support
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
## [0.3.15](https://github.com/appium/appium/compare/@appium/plugin-test-support@0.3.14...@appium/plugin-test-support@0.3.15) (2023-06-14)
|
||||
|
||||
**Note:** Version bump only for package @appium/plugin-test-support
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
## [0.3.14](https://github.com/appium/appium/compare/@appium/plugin-test-support@0.3.13...@appium/plugin-test-support@0.3.14) (2023-05-17)
|
||||
|
||||
**Note:** Version bump only for package @appium/plugin-test-support
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@appium/plugin-test-support",
|
||||
"version": "0.3.14",
|
||||
"version": "0.3.16",
|
||||
"description": "Testing utilities for Appium plugins",
|
||||
"keywords": [
|
||||
"automation",
|
||||
@@ -41,7 +41,7 @@
|
||||
"test:unit": "exit 0"
|
||||
},
|
||||
"dependencies": {
|
||||
"@appium/types": "^0.11.1",
|
||||
"@appium/types": "^0.13.0",
|
||||
"get-port": "5.1.1",
|
||||
"log-symbols": "4.1.0",
|
||||
"source-map-support": "0.5.21",
|
||||
|
||||
@@ -3,6 +3,21 @@
|
||||
All notable changes to this project will be documented in this file.
|
||||
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
||||
|
||||
## [0.3.0](https://github.com/appium/appium/compare/@appium/schema@0.2.6...@appium/schema@0.3.0) (2023-06-14)
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* **appium:** Allow to provide ipv6 addresses and handle broadcast addresses in logs ([#18674](https://github.com/appium/appium/issues/18674)) ([8f63dab](https://github.com/appium/appium/commit/8f63dabb5dca882e522026f243e3445f5418874b))
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* **schema:** update definitelytyped ([e967240](https://github.com/appium/appium/commit/e96724077ef2b5b8aae203856195f3bb8de56116))
|
||||
* **types:** fix broken appium config schema types, temporarily ([fd2c72f](https://github.com/appium/appium/commit/fd2c72fd886ecaaf0f6588a328ff8a268a54fb55))
|
||||
|
||||
|
||||
|
||||
## [0.2.6](https://github.com/appium/appium/compare/@appium/schema@0.2.5...@appium/schema@0.2.6) (2023-03-08)
|
||||
|
||||
**Note:** Version bump only for package @appium/schema
|
||||
|
||||
@@ -21,13 +21,12 @@ export const AppiumConfigJsonSchema = /** @type {const} */ ({
|
||||
description: 'Configuration when running Appium as a server',
|
||||
properties: {
|
||||
address: {
|
||||
$comment: 'I think hostname covers both DNS and IPv4...could be wrong',
|
||||
appiumCliAliases: ['a'],
|
||||
default: '0.0.0.0',
|
||||
description: 'IP address to listen on',
|
||||
format: 'hostname',
|
||||
description: 'IPv4/IPv6 address or a hostname to listen on',
|
||||
title: 'address config',
|
||||
type: 'string',
|
||||
// this should be anyOf [format: "hostname" or format: "ipv6"], but there seems to be a bug in json-schema-to-typescript preventing "ipv6" from converting to type "string"'
|
||||
},
|
||||
'allow-cors': {
|
||||
description:
|
||||
@@ -338,7 +337,7 @@ export const AppiumConfigJsonSchema = /** @type {const} */ ({
|
||||
},
|
||||
},
|
||||
{
|
||||
oneOf: [{$ref: '#/$defs/logFilterText'}, {$ref: '#/$defs/logFilterRegex'}],
|
||||
anyOf: [{$ref: '#/$defs/logFilterText'}, {$ref: '#/$defs/logFilterRegex'}],
|
||||
},
|
||||
],
|
||||
},
|
||||
|
||||
@@ -14,13 +14,11 @@
|
||||
"description": "Configuration when running Appium as a server",
|
||||
"properties": {
|
||||
"address": {
|
||||
"$comment": "I think hostname covers both DNS and IPv4...could be wrong",
|
||||
"appiumCliAliases": [
|
||||
"a"
|
||||
],
|
||||
"default": "0.0.0.0",
|
||||
"description": "IP address to listen on",
|
||||
"format": "hostname",
|
||||
"description": "IPv4/IPv6 address or a hostname to listen on",
|
||||
"title": "address config",
|
||||
"type": "string"
|
||||
},
|
||||
@@ -339,7 +337,7 @@
|
||||
}
|
||||
},
|
||||
{
|
||||
"oneOf": [
|
||||
"anyOf": [
|
||||
{
|
||||
"$ref": "#/$defs/logFilterText"
|
||||
},
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@appium/schema",
|
||||
"version": "0.2.6",
|
||||
"version": "0.3.0",
|
||||
"description": "Appium Configuration Schema",
|
||||
"keywords": [
|
||||
"automation",
|
||||
@@ -38,7 +38,7 @@
|
||||
"test": "exit 0"
|
||||
},
|
||||
"dependencies": {
|
||||
"@types/json-schema": "7.0.11",
|
||||
"@types/json-schema": "7.0.12",
|
||||
"json-schema": "0.4.0",
|
||||
"source-map-support": "0.5.21"
|
||||
},
|
||||
|
||||
@@ -3,6 +3,15 @@
|
||||
All notable changes to this project will be documented in this file.
|
||||
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
||||
|
||||
## [0.3.1](https://github.com/appium/appium/compare/@appium/strongbox@0.3.0...@appium/strongbox@0.3.1) (2023-06-14)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* **strongbox:** do not force-lowercase slugged containers ([1ccf857](https://github.com/appium/appium/commit/1ccf857a4bdd77af3ccf2ad268e3410855509af8))
|
||||
|
||||
|
||||
|
||||
## [0.3.0](https://github.com/appium/appium/compare/@appium/strongbox@0.2.0...@appium/strongbox@0.3.0) (2023-04-20)
|
||||
|
||||
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import path from 'node:path';
|
||||
import slug from 'slugify';
|
||||
|
||||
export function slugify(value: string) {
|
||||
return slug(value, {lower: true});
|
||||
return slug(value);
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@appium/strongbox",
|
||||
"version": "0.3.0",
|
||||
"version": "0.3.1",
|
||||
"description": "Persistent storage for Appium extensions",
|
||||
"keywords": [
|
||||
"automation",
|
||||
|
||||
@@ -12,7 +12,7 @@ type MockFs = {
|
||||
describe('Strongbox', function () {
|
||||
let sandbox: SinonSandbox;
|
||||
let MockFs: MockFs = {} as any;
|
||||
const DATA_DIR = '/some/dir';
|
||||
const DATA_DIR = path.resolve(path.sep, 'some', 'dir');
|
||||
// note to self: looks like this is safe to do before the rewiremock.proxy call
|
||||
let BaseItem: typeof import('../../lib/base-item').BaseItem;
|
||||
|
||||
|
||||
@@ -16,7 +16,7 @@ describe('Strongbox', function () {
|
||||
let DEFAULT_SUFFIX: string;
|
||||
let MockFs: MockFs = {} as any;
|
||||
|
||||
const DATA_DIR = '/some/dir';
|
||||
const DATA_DIR = path.resolve('some', 'dir', 'strongbox');
|
||||
|
||||
beforeEach(function () {
|
||||
sandbox = createSandbox();
|
||||
@@ -44,17 +44,18 @@ describe('Strongbox', function () {
|
||||
|
||||
describe('when provided an absolute container path', function () {
|
||||
it('should use the provided container path', function () {
|
||||
expect(strongbox('test', {container: '/somewhere/else'}).container).to.equal(
|
||||
'/somewhere/else'
|
||||
);
|
||||
const container = path.resolve(path.sep, 'somewhere');
|
||||
expect(strongbox('test', {container}).container).to.equal(container);
|
||||
});
|
||||
});
|
||||
|
||||
describe('when provided a relative container path', function () {
|
||||
it('should throw an error', function () {
|
||||
expect(() => strongbox('test', {container: 'somewhere/else'})).to.throw(
|
||||
const container = path.join('somewhere', 'else');
|
||||
|
||||
expect(() => strongbox('test', {container})).to.throw(
|
||||
TypeError,
|
||||
'container slug somewhere/else must be an absolute path'
|
||||
`container slug ${container} must be an absolute path`
|
||||
);
|
||||
});
|
||||
});
|
||||
@@ -85,17 +86,13 @@ describe('Strongbox', function () {
|
||||
|
||||
it('should create an empty Item', async function () {
|
||||
expect(item).to.eql({
|
||||
id: '/some/dir/strongbox/slug-test',
|
||||
id: path.resolve(DATA_DIR, 'strongbox', 'SLUG-test'),
|
||||
name: 'SLUG test',
|
||||
encoding: 'utf8',
|
||||
value: undefined,
|
||||
container: '/some/dir/strongbox',
|
||||
container: path.resolve(DATA_DIR, 'strongbox'),
|
||||
});
|
||||
});
|
||||
|
||||
it('should slugify the id', function () {
|
||||
expect(item.id).to.equal('/some/dir/strongbox/slug-test');
|
||||
});
|
||||
});
|
||||
|
||||
describe('when the file exists', function () {
|
||||
@@ -105,11 +102,11 @@ describe('Strongbox', function () {
|
||||
it('should read its value', async function () {
|
||||
const item = await box.createItem('SLUG test');
|
||||
expect(item).to.eql({
|
||||
id: '/some/dir/strongbox/slug-test',
|
||||
id: path.resolve(DATA_DIR, 'strongbox', 'SLUG-test'),
|
||||
name: 'SLUG test',
|
||||
encoding: 'utf8',
|
||||
value: 'foo bar',
|
||||
container: '/some/dir/strongbox',
|
||||
container: path.resolve(DATA_DIR, 'strongbox'),
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -129,7 +126,7 @@ describe('Strongbox', function () {
|
||||
await item.write('boo bah');
|
||||
|
||||
expect(MockFs.writeFile).to.have.been.calledWith(
|
||||
path.join(DATA_DIR, DEFAULT_SUFFIX, 'test'),
|
||||
path.resolve(DATA_DIR, DEFAULT_SUFFIX, 'test'),
|
||||
'boo bah',
|
||||
'utf8'
|
||||
);
|
||||
@@ -148,7 +145,7 @@ describe('Strongbox', function () {
|
||||
await box.createItem('test');
|
||||
await expect(box.createItem('test')).to.be.rejectedWith(
|
||||
Error,
|
||||
'Item with id "/some/dir/strongbox/test" already exists'
|
||||
`Item with id "${path.resolve(DATA_DIR, 'strongbox', 'test')}" already exists`
|
||||
);
|
||||
});
|
||||
});
|
||||
@@ -194,7 +191,7 @@ describe('Strongbox', function () {
|
||||
it('should write the value to disk', async function () {
|
||||
await box.createItemWithValue('test', 'value');
|
||||
expect(MockFs.writeFile).to.have.been.calledWith(
|
||||
path.join(DATA_DIR, DEFAULT_SUFFIX, 'test'),
|
||||
path.resolve(DATA_DIR, DEFAULT_SUFFIX, 'test'),
|
||||
'value'
|
||||
);
|
||||
});
|
||||
|
||||
@@ -3,6 +3,45 @@
|
||||
All notable changes to this project will be documented in this file.
|
||||
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
||||
|
||||
## [4.1.0](https://github.com/appium/appium/compare/@appium/support@4.0.3...@appium/support@4.1.0) (2023-06-15)
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* **support:** export a bunch of types that weren't properly exported ([88293f8](https://github.com/appium/appium/commit/88293f803933ecf7d258b02afd08d636b310a24b))
|
||||
|
||||
|
||||
|
||||
## [4.0.3](https://github.com/appium/appium/compare/@appium/support@4.0.2...@appium/support@4.0.3) (2023-06-14)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* **support:** Require the optional sharp dep properly from mjpeg module ([#18769](https://github.com/appium/appium/issues/18769)) ([c18eb03](https://github.com/appium/appium/commit/c18eb03261a4c0f73ec71417825a387da1c59991))
|
||||
|
||||
|
||||
|
||||
## [4.0.2](https://github.com/appium/appium/compare/@appium/support@4.0.1...@appium/support@4.0.2) (2023-06-14)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* **support:** update dependency @types/semver to v7.5.0 ([528dcfe](https://github.com/appium/appium/commit/528dcfe324e75e48471cdb694448c2a09ec2d828))
|
||||
* **support:** update dependency semver to v7.5.1 ([5a55509](https://github.com/appium/appium/commit/5a555090c5322318f845415d743ee5c645fb94a0))
|
||||
* **types:** update dependency type-fest to v3.11.0 ([19277f6](https://github.com/appium/appium/commit/19277f6e14a56e52b4669d633e148ad4a3da2c7a))
|
||||
* **types:** update dependency type-fest to v3.11.1 ([56499eb](https://github.com/appium/appium/commit/56499eb997b551739bed628f057de7987674ea7f))
|
||||
|
||||
|
||||
|
||||
## [4.0.1](https://github.com/appium/appium/compare/@appium/support@4.0.0...@appium/support@4.0.1) (2023-05-19)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* **support:** add missing @types/which ([ea42548](https://github.com/appium/appium/commit/ea42548442713f3fefa711719d4ad54dff212f04))
|
||||
|
||||
|
||||
|
||||
## [4.0.0](https://github.com/appium/appium/compare/@appium/support@3.1.11...@appium/support@4.0.0) (2023-05-17)
|
||||
|
||||
|
||||
|
||||
+121
-72
@@ -1,62 +1,112 @@
|
||||
# appium-support
|
||||
|
||||
Utility functions used to support libs used across appium packages.
|
||||
Utility functions used to support Appium drivers and plugins.
|
||||
|
||||
`npm install appium-support`
|
||||
# Usage in drivers and plugins
|
||||
|
||||
Appium, as of version 1.5 is all based on promises, so this module provides promise wrappers for some common operations.
|
||||
It is recommended to have Appium as a peer dependency in driver and plugin packages.
|
||||
Add the following line to `peerDependencies` section of your module's `package.json`:
|
||||
|
||||
Most notably, we wrap `fs` for file system commands. Note the addition of `hasAccess`.
|
||||
Also note that `fs.mkdir` doesn't throw an error if the directory already exists, it will just resolve.
|
||||
```js
|
||||
"peerDependencies": {
|
||||
"appium": "^<minimum_server_version>"
|
||||
}
|
||||
```
|
||||
|
||||
### Methods
|
||||
Afterwards import it in your code similarly to the below example:
|
||||
|
||||
- system.isWindows
|
||||
- system.isMac
|
||||
- system.isLinux
|
||||
- system.isOSWin64
|
||||
- system.arch
|
||||
- system.macOsxVersion
|
||||
```js
|
||||
import {timing, util} from 'appium/support';
|
||||
```
|
||||
|
||||
- util.hasContent - returns true if input string has content
|
||||
- util.hasValue - returns true if input value is not undefined and no null
|
||||
- util.escapeSpace
|
||||
- util.escapeSpecialChars
|
||||
- util.localIp
|
||||
- util.cancellableDelay
|
||||
- util.multiResolve - multiple path.resolve
|
||||
- util.unwrapElement - parse an element ID from an element object: e.g.: `{ELEMENT: 123, "element-6066-11e4-a52e-4f735466cecf": 123}` returns `123`
|
||||
- util.wrapElement - convert an element ID to an element object of the form: e.g.: `123` returns `{ELEMENT: 123, "element-6066-11e4-a52e-4f735466cecf": 123}`
|
||||
# Usage in helper modules
|
||||
|
||||
- *fs.hasAccess* - use this over `fs.access`
|
||||
- *fs.exists* - calls `fs.hasAccess`
|
||||
- *fs.rimraf*
|
||||
- *fs.mkdir* - doesn't throw an error if directory already exists
|
||||
- *fs.copyFile*
|
||||
- fs.open
|
||||
- fs.close
|
||||
- fs.access
|
||||
- fs.readFile
|
||||
- fs.writeFile
|
||||
- fs.write
|
||||
- fs.readlink
|
||||
- fs.chmod
|
||||
- fs.unlink
|
||||
- fs.readdir
|
||||
- fs.stat
|
||||
- fs.rename
|
||||
- *fs.md5*
|
||||
If you want to use this module in a helper library, which is not a driver or a plugin,
|
||||
then add the following line to `dependencies` section of your module's `package.json`:
|
||||
|
||||
- plist.parsePlistFile
|
||||
- plist.updatePlistFile
|
||||
```js
|
||||
"dependencies": {
|
||||
"@appium/support": "<module_version>"
|
||||
}
|
||||
```
|
||||
|
||||
- mkdirp
|
||||
Afterwards import it in your code similarly to the below example:
|
||||
|
||||
- logger
|
||||
```js
|
||||
import {timing, util} from '@appium/support';
|
||||
```
|
||||
|
||||
- zip.extractAllTo - Extracts contents of a zipfile to a directory
|
||||
- zip.readEntries - Reads entries (files and directories) of a zipfile
|
||||
- zip.toInMemoryZip - Converts a directory into a base64 zipfile
|
||||
### Categories
|
||||
|
||||
All utility functions are split into a bunch of different categories. Each category has its own file under the `lib` folder. All utility functions in these files are documented.
|
||||
|
||||
#### fs
|
||||
|
||||
Most of the functions there are just thin wrappers over utility functions available in [Promises API](https://nodejs.org/api/fs.html#promises-api).
|
||||
|
||||
#### env
|
||||
|
||||
Several helpers needed by the server to cope with internal dependencies and manifests.
|
||||
|
||||
#### console
|
||||
|
||||
Wrappers for the command line interface abstraction used by the Appium server.
|
||||
|
||||
#### image-util
|
||||
|
||||
Utilities to work with images. Use [sharp](https://github.com/lovell/sharp) under the hood.
|
||||
|
||||
#### log-internal
|
||||
|
||||
Utilities needed for internal Appium log config assistance.
|
||||
|
||||
#### logging
|
||||
|
||||
See [below](#logger)
|
||||
|
||||
#### mjpeg
|
||||
|
||||
Helpers needed to implement [MJPEG streaming](https://en.wikipedia.org/wiki/Motion_JPEG#Video_streaming).
|
||||
|
||||
#### net
|
||||
|
||||
Helpers needed for network interactions, for example, upload and download of files.
|
||||
|
||||
#### node
|
||||
|
||||
Set of Node.js-specific utility functions needed, for example, to ensure objects immutability or to calculate their sizes.
|
||||
|
||||
#### npm
|
||||
|
||||
Set of [npm](https://en.wikipedia.org/wiki/Npm_(software))-related helpers.
|
||||
|
||||
#### plist
|
||||
|
||||
Set of utilities used to read and write data from [plist](https://en.wikipedia.org/wiki/Property_List) files in javascript.
|
||||
|
||||
#### process
|
||||
|
||||
Helpers for interactions with system processes. These APIs don't support Windows.
|
||||
|
||||
#### system
|
||||
|
||||
Set of helper functions needed to determine properties of the current operating system.
|
||||
|
||||
#### tempdir
|
||||
|
||||
Set of helpers that allow interactions with temporary folders.
|
||||
|
||||
#### timing
|
||||
|
||||
Helpers that allow to measure execution time.
|
||||
|
||||
#### util
|
||||
|
||||
Miscellaneous utilities.
|
||||
|
||||
#### zip
|
||||
|
||||
Helpers that allow to work with archives in .ZIP format.
|
||||
|
||||
|
||||
## logger
|
||||
@@ -85,10 +135,9 @@ Will produce
|
||||
warn mymodule a warning
|
||||
```
|
||||
|
||||
|
||||
### Environment variables
|
||||
|
||||
There are two environment variable flags that affect the way `appium-base-driver` `logger` works.
|
||||
There are two environment variable flags that affect the way `logger` works.
|
||||
|
||||
`_TESTING`
|
||||
|
||||
@@ -108,43 +157,43 @@ There are two environment variable flags that affect the way `appium-base-driver
|
||||
`log[level](message)`
|
||||
|
||||
- logs to `level`
|
||||
```js
|
||||
import { logger } from 'appium-support';
|
||||
let log = logger.getLogger('mymodule');
|
||||
```js
|
||||
import { logger } from 'appium-support';
|
||||
let log = logger.getLogger('mymodule');
|
||||
|
||||
log.info('hi!');
|
||||
// => info mymodule hi!
|
||||
```
|
||||
log.info('hi!');
|
||||
// => info mymodule hi!
|
||||
```
|
||||
|
||||
`log.unwrap()`
|
||||
|
||||
- retrieves the underlying [npmlog](https://github.com/npm/npmlog) object, in order to manage how logging is done at a low level (e.g., changing output streams, retrieving an array of messages, adding log levels, etc.).
|
||||
|
||||
```js
|
||||
import { getLogger } from 'appium-base-driver';
|
||||
let log = getLogger('mymodule');
|
||||
```js
|
||||
import { getLogger } from 'appium-base-driver';
|
||||
let log = getLogger('mymodule');
|
||||
|
||||
log.info('hi!');
|
||||
log.info('hi!');
|
||||
|
||||
let npmlogger = log.unwrap();
|
||||
let npmlogger = log.unwrap();
|
||||
|
||||
// any `npmlog` methods
|
||||
let logs = npmlogger.record;
|
||||
// logs === [ { id: 0, level: 'info', prefix: 'mymodule', message: 'hi!', messageRaw: [ 'hi!' ] }]
|
||||
```
|
||||
// any `npmlog` methods
|
||||
let logs = npmlogger.record;
|
||||
// logs === [ { id: 0, level: 'info', prefix: 'mymodule', message: 'hi!', messageRaw: [ 'hi!' ] }]
|
||||
```
|
||||
|
||||
`log.errorAndThrow(error)`
|
||||
|
||||
- logs the error passed in, at `error` level, and then throws the error. If the error passed in is not an instance of [Error](https://nodejs.org/api/errors.html#errors_class_error) (either directly, or a subclass of `Error`) it will be wrapped in a generic `Error` object.
|
||||
|
||||
```js
|
||||
import { getLogger } from 'appium-base-driver';
|
||||
let log = getLogger('mymodule');
|
||||
```js
|
||||
import { getLogger } from 'appium-base-driver';
|
||||
let log = getLogger('mymodule');
|
||||
|
||||
// previously there would be two lines
|
||||
log.error('This is an error');
|
||||
throw new Error('This is an error');
|
||||
// previously there would be two lines
|
||||
log.error('This is an error');
|
||||
throw new Error('This is an error');
|
||||
|
||||
// now is compacted
|
||||
log.errorAndThrow('This is an error');
|
||||
```
|
||||
// now is compacted
|
||||
log.errorAndThrow('This is an error');
|
||||
```
|
||||
|
||||
@@ -1,14 +1,32 @@
|
||||
import sharp from 'sharp';
|
||||
let _sharp;
|
||||
|
||||
/**
|
||||
* @returns {import('sharp')}
|
||||
*/
|
||||
export function requireSharp() {
|
||||
if (!_sharp) {
|
||||
try {
|
||||
_sharp = require('sharp');
|
||||
} catch (err) {
|
||||
throw new Error(
|
||||
`Cannot load the 'sharp' module needed for images processing. ` +
|
||||
`Consider visiting https://sharp.pixelplumbing.com/install ` +
|
||||
`for troubleshooting. Original error: ${err.message}`
|
||||
);
|
||||
}
|
||||
}
|
||||
return _sharp;
|
||||
}
|
||||
|
||||
/**
|
||||
* Crop the image by given rectangle (use base64 string as input and output)
|
||||
*
|
||||
* @param {string} base64Image The string with base64 encoded image.
|
||||
* Supports all image formats natively supported by Sharp library.
|
||||
* @param {sharp.Region} rect The selected region of image
|
||||
* @param {import('sharp').Region} rect The selected region of image
|
||||
* @return {Promise<string>} base64 encoded string of cropped image
|
||||
*/
|
||||
export async function cropBase64Image(base64Image, rect) {
|
||||
const buf = await sharp(Buffer.from(base64Image, 'base64')).extract(rect).toBuffer();
|
||||
const buf = await requireSharp()(Buffer.from(base64Image, 'base64')).extract(rect).toBuffer();
|
||||
return buf.toString('base64');
|
||||
}
|
||||
|
||||
@@ -57,3 +57,24 @@ export default {
|
||||
env,
|
||||
console,
|
||||
};
|
||||
|
||||
export type {ConsoleOpts} from './console';
|
||||
export type {ReadFn, WalkDirCallback} from './fs';
|
||||
export type {
|
||||
NetOptions,
|
||||
DownloadOptions,
|
||||
AuthCredentials,
|
||||
NotHttpUploadOptions,
|
||||
HttpUploadOptions,
|
||||
} from './net';
|
||||
export type {InstallPackageOpts, ExecOpts, NpmInstallReceipt} from './npm';
|
||||
export type {Affixes, OpenedAffixes} from './tempdir';
|
||||
export type {PluralizeOptions, EncodingOptions, LockFileOptions, NonEmptyString} from './util';
|
||||
export type {
|
||||
ExtractAllOptions,
|
||||
ZipEntry,
|
||||
ZipOptions,
|
||||
ZipCompressionOptions,
|
||||
ZipSourceOptions,
|
||||
} from './zip';
|
||||
export type {SecureValuePreprocessingRule} from './log-internal';
|
||||
@@ -1,7 +1,7 @@
|
||||
import _ from 'lodash';
|
||||
import log from './logger';
|
||||
import B from 'bluebird';
|
||||
import sharp from 'sharp';
|
||||
import {requireSharp} from './image-util';
|
||||
import {Writable} from 'stream';
|
||||
import {requirePackage} from './node';
|
||||
import axios from 'axios';
|
||||
@@ -77,7 +77,7 @@ class MJpegStream extends Writable {
|
||||
}
|
||||
|
||||
try {
|
||||
return await sharp(lastChunk).png().toBuffer();
|
||||
return await requireSharp()(lastChunk).png().toBuffer();
|
||||
} catch (e) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@appium/support",
|
||||
"version": "4.0.0",
|
||||
"version": "4.1.0",
|
||||
"description": "Support libs used across appium packages",
|
||||
"keywords": [
|
||||
"automation",
|
||||
@@ -42,7 +42,7 @@
|
||||
},
|
||||
"dependencies": {
|
||||
"@appium/tsconfig": "^0.3.0",
|
||||
"@appium/types": "^0.11.1",
|
||||
"@appium/types": "^0.13.0",
|
||||
"@colors/colors": "1.5.0",
|
||||
"@types/archiver": "5.3.2",
|
||||
"@types/base64-stream": "1.0.2",
|
||||
@@ -55,11 +55,12 @@
|
||||
"@types/ncp": "2.0.5",
|
||||
"@types/npmlog": "4.1.4",
|
||||
"@types/pluralize": "0.0.29",
|
||||
"@types/semver": "7.3.13",
|
||||
"@types/semver": "7.5.0",
|
||||
"@types/shell-quote": "1.7.1",
|
||||
"@types/supports-color": "8.1.1",
|
||||
"@types/teen_process": "2.0.0",
|
||||
"@types/uuid": "9.0.1",
|
||||
"@types/which": "3.0.0",
|
||||
"archiver": "5.3.1",
|
||||
"axios": "1.4.0",
|
||||
"base64-stream": "1.0.0",
|
||||
@@ -85,17 +86,19 @@
|
||||
"read-pkg": "5.2.0",
|
||||
"resolve-from": "5.0.0",
|
||||
"sanitize-filename": "1.6.3",
|
||||
"semver": "7.5.0",
|
||||
"sharp": "0.32.1",
|
||||
"semver": "7.5.1",
|
||||
"shell-quote": "1.8.1",
|
||||
"source-map-support": "0.5.21",
|
||||
"supports-color": "8.1.1",
|
||||
"teen_process": "2.0.2",
|
||||
"type-fest": "3.10.0",
|
||||
"type-fest": "3.11.1",
|
||||
"uuid": "9.0.0",
|
||||
"which": "3.0.1",
|
||||
"yauzl": "2.10.0"
|
||||
},
|
||||
"optionalDependencies": {
|
||||
"sharp": "0.32.1"
|
||||
},
|
||||
"engines": {
|
||||
"node": "^14.17.0 || ^16.13.0 || >=18.0.0",
|
||||
"npm": ">=8"
|
||||
|
||||
@@ -9,6 +9,12 @@ describe('isExecutable()', function () {
|
||||
});
|
||||
|
||||
describe('when the path exists', function () {
|
||||
beforeEach(function () {
|
||||
if (isWindows()) {
|
||||
return this.skip();
|
||||
}
|
||||
});
|
||||
|
||||
describe('when the path is not executable', function () {
|
||||
it('should return `false`', async function () {
|
||||
await fs.isExecutable(__filename).should.eventually.be.false;
|
||||
@@ -16,11 +22,6 @@ describe('isExecutable()', function () {
|
||||
});
|
||||
|
||||
describe('when the path is executable', function () {
|
||||
beforeEach(function () {
|
||||
if (isWindows()) {
|
||||
return this.skip();
|
||||
}
|
||||
});
|
||||
it('should return `true`', async function () {
|
||||
await fs.isExecutable('/bin/bash').should.eventually.be.true;
|
||||
});
|
||||
|
||||
@@ -2,6 +2,7 @@ import path from 'path';
|
||||
import * as zip from '../../lib/zip';
|
||||
import {tempDir, fs} from '../../lib/index';
|
||||
import {MockReadWriteStream} from '../helpers';
|
||||
import {isWindows} from '../../lib/system';
|
||||
|
||||
describe('#zip', function () {
|
||||
const optionMap = new Map([
|
||||
@@ -30,7 +31,11 @@ describe('#zip', function () {
|
||||
if (!(await fs.exists(tmpPath))) {
|
||||
continue;
|
||||
}
|
||||
await fs.rimraf(tmpPath);
|
||||
try {
|
||||
await fs.rimraf(tmpPath);
|
||||
} catch {
|
||||
// on windows, this can break due to file handles being open on files within the directory.
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
@@ -239,6 +244,10 @@ describe('#zip', function () {
|
||||
let zippedFilePath, assetsPath, tmpRoot;
|
||||
|
||||
beforeEach(async function () {
|
||||
// XXX: I don't know enough about unicode handling in the windows FS to attempt a fix here
|
||||
if (isWindows()) {
|
||||
return this.skip();
|
||||
}
|
||||
assetsPath = await tempDir.openDir();
|
||||
tmpRoot = await tempDir.openDir();
|
||||
|
||||
|
||||
@@ -76,7 +76,7 @@ describe('env', function () {
|
||||
describe('when APPIUM_HOME is set in env', function () {
|
||||
describe('when APPIUM_HOME is absolute', function () {
|
||||
beforeEach(function () {
|
||||
process.env.APPIUM_HOME = '/some/path/to/appium-home';
|
||||
process.env.APPIUM_HOME = path.resolve(path.sep, 'some', 'appium-home');
|
||||
});
|
||||
|
||||
it('should resolve APPIUM_HOME from env', async function () {
|
||||
@@ -86,11 +86,11 @@ describe('env', function () {
|
||||
|
||||
describe('when APPIUM_HOME is relative', function () {
|
||||
beforeEach(function () {
|
||||
process.env.APPIUM_HOME = 'some/path/to/appium-home';
|
||||
process.env.APPIUM_HOME = path.join('some', 'appium-home');
|
||||
});
|
||||
it('should resolve to an absolute path', async function () {
|
||||
await expect(env.resolveAppiumHome()).to.eventually.equal(
|
||||
path.join(process.cwd(), process.env.APPIUM_HOME)
|
||||
path.join(process.cwd(), /** @type {string} */ (process.env.APPIUM_HOME))
|
||||
);
|
||||
});
|
||||
});
|
||||
@@ -114,13 +114,15 @@ describe('env', function () {
|
||||
});
|
||||
|
||||
describe('when `appium` is a dependency of the package in the cwd', function () {
|
||||
const appiumHome = path.resolve(path.sep, 'somewhere');
|
||||
|
||||
describe('when the `appium` dependency spec begins with `file:`', function () {
|
||||
beforeEach(function () {
|
||||
MockReadPkg.resolves({devDependencies: {appium: 'file:../appium'}});
|
||||
});
|
||||
|
||||
it('should resolve with the identity', async function () {
|
||||
await expect(env.resolveAppiumHome('/somewhere')).to.eventually.equal('/somewhere');
|
||||
await expect(env.resolveAppiumHome(appiumHome)).to.eventually.equal(appiumHome);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -130,7 +132,7 @@ describe('env', function () {
|
||||
});
|
||||
|
||||
it('should resolve with the identity', async function () {
|
||||
await expect(env.resolveAppiumHome('/somewhere')).to.eventually.equal('/somewhere');
|
||||
await expect(env.resolveAppiumHome(appiumHome)).to.eventually.equal(appiumHome);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -139,7 +141,7 @@ describe('env', function () {
|
||||
MockReadPkg.resolves({devDependencies: {appium: '0.9.0'}});
|
||||
});
|
||||
it('should resolve with DEFAULT_APPIUM_HOME', async function () {
|
||||
await expect(env.resolveAppiumHome('/somewhere')).to.eventually.equal(
|
||||
await expect(env.resolveAppiumHome(appiumHome)).to.eventually.equal(
|
||||
env.DEFAULT_APPIUM_HOME
|
||||
);
|
||||
});
|
||||
@@ -151,7 +153,7 @@ describe('env', function () {
|
||||
});
|
||||
|
||||
it('should resolve with DEFAULT_APPIUM_HOME', async function () {
|
||||
await expect(env.resolveAppiumHome('/somewhere')).to.eventually.equal(
|
||||
await expect(env.resolveAppiumHome(appiumHome)).to.eventually.equal(
|
||||
env.DEFAULT_APPIUM_HOME
|
||||
);
|
||||
});
|
||||
@@ -159,18 +161,20 @@ describe('env', function () {
|
||||
});
|
||||
|
||||
describe('when `appium` is a dependency of the workspace root of cwd', function () {
|
||||
const appiumHome = path.resolve(path.sep, 'somewhere');
|
||||
|
||||
beforeEach(function () {
|
||||
MockTeenProcess.exec.resolves({
|
||||
stdout: JSON.stringify({
|
||||
path: '/somewhere',
|
||||
path: appiumHome,
|
||||
}),
|
||||
});
|
||||
MockReadPkg.resolves({devDependencies: {appium: '2.x'}});
|
||||
});
|
||||
|
||||
it('should resolve with the workspace root', async function () {
|
||||
await expect(env.resolveAppiumHome('/somewhere/else')).to.eventually.equal(
|
||||
'/somewhere'
|
||||
await expect(env.resolveAppiumHome(path.join(appiumHome, 'else'))).to.eventually.equal(
|
||||
appiumHome
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import {fs, tempDir} from '../../lib/index.js';
|
||||
import {fs, system, tempDir} from '../../lib';
|
||||
import path from 'path';
|
||||
import {createSandbox} from 'sinon';
|
||||
import {exec} from 'teen_process';
|
||||
@@ -140,6 +140,11 @@ describe('fs', function () {
|
||||
stat.should.have.property('atime');
|
||||
});
|
||||
describe('which()', function () {
|
||||
before(function () {
|
||||
if (system.isWindows()) {
|
||||
return this.skip();
|
||||
}
|
||||
});
|
||||
it('should find correct executable', async function () {
|
||||
let systemNpmPath = (await exec('which', ['npm'])).stdout.trim();
|
||||
let npmPath = await fs.which('npm');
|
||||
@@ -158,8 +163,9 @@ describe('fs', function () {
|
||||
|
||||
describe('walkDir()', function () {
|
||||
it('walkDir recursive', async function () {
|
||||
await chai.expect(fs.walkDir(__dirname, true, (item) => item.endsWith('logger/helpers.js')))
|
||||
.to.eventually.not.be.null;
|
||||
await chai.expect(
|
||||
fs.walkDir(__dirname, true, (item) => item.endsWith(`logger${path.sep}helpers.js`))
|
||||
).to.eventually.not.be.null;
|
||||
});
|
||||
it('should walk all elements recursive', async function () {
|
||||
await chai.expect(fs.walkDir(path.join(__dirname, '..', 'e2e', 'fixture'), true, _.noop)).to
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import AppiumSupport from '../../lib/index.js';
|
||||
import AppiumSupport from '../../lib/';
|
||||
|
||||
let {system, tempDir, util} = AppiumSupport;
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import path from 'path';
|
||||
import {plist, tempDir, fs} from '../../lib/index.js';
|
||||
import {plist, tempDir, fs} from '../../lib';
|
||||
|
||||
const binaryPlistPath = path.join(__dirname, 'assets', 'sample_binary.plist');
|
||||
const textPlistPath = path.join(__dirname, 'assets', 'sample_text.plist');
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import * as teenProcess from 'teen_process';
|
||||
import {createSandbox} from 'sinon';
|
||||
import {process} from '../../lib/index.js';
|
||||
import {process, system} from '../../lib';
|
||||
import {retryInterval} from 'asyncbox';
|
||||
|
||||
const SubProcess = teenProcess.SubProcess;
|
||||
@@ -19,11 +19,16 @@ describe('process', function () {
|
||||
describe('getProcessIds', function () {
|
||||
let proc;
|
||||
before(async function () {
|
||||
if (system.isWindows()) {
|
||||
return this.skip();
|
||||
}
|
||||
proc = new SubProcess('tail', ['-f', __filename]);
|
||||
await proc.start();
|
||||
});
|
||||
after(async function () {
|
||||
await proc.stop();
|
||||
if (proc) {
|
||||
await proc.stop();
|
||||
}
|
||||
});
|
||||
it('should get return an array for existing process', async function () {
|
||||
let pids = await process.getProcessIds('tail');
|
||||
@@ -49,6 +54,11 @@ describe('process', function () {
|
||||
|
||||
describe('killProcess', function () {
|
||||
let proc;
|
||||
before(function () {
|
||||
if (system.isWindows()) {
|
||||
return this.skip();
|
||||
}
|
||||
});
|
||||
beforeEach(async function () {
|
||||
proc = new SubProcess('tail', ['-f', __filename]);
|
||||
await proc.start();
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import {system} from '../../lib/index.js';
|
||||
import {system} from '../../lib';
|
||||
import os from 'os';
|
||||
import {createSandbox} from 'sinon';
|
||||
import * as teen_process from 'teen_process';
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import {tempDir, fs} from '../../lib/index.js';
|
||||
import {tempDir, fs} from '../../lib';
|
||||
|
||||
describe('tempdir', function () {
|
||||
afterEach(function () {
|
||||
|
||||
@@ -3,6 +3,39 @@
|
||||
All notable changes to this project will be documented in this file.
|
||||
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
||||
|
||||
## [3.0.18](https://github.com/appium/appium/compare/@appium/test-support@3.0.17...@appium/test-support@3.0.18) (2023-06-15)
|
||||
|
||||
**Note:** Version bump only for package @appium/test-support
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
## [3.0.17](https://github.com/appium/appium/compare/@appium/test-support@3.0.16...@appium/test-support@3.0.17) (2023-06-14)
|
||||
|
||||
**Note:** Version bump only for package @appium/test-support
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
## [3.0.16](https://github.com/appium/appium/compare/@appium/test-support@3.0.15...@appium/test-support@3.0.16) (2023-06-14)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* **test-support:** update dependency sinon to v15.1.0 ([4c61d53](https://github.com/appium/appium/commit/4c61d533b8f52131a637f5cd0b019375f85f075f))
|
||||
|
||||
|
||||
|
||||
## [3.0.15](https://github.com/appium/appium/compare/@appium/test-support@3.0.14...@appium/test-support@3.0.15) (2023-05-19)
|
||||
|
||||
**Note:** Version bump only for package @appium/test-support
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
## [3.0.14](https://github.com/appium/appium/compare/@appium/test-support@3.0.13...@appium/test-support@3.0.14) (2023-05-17)
|
||||
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@appium/test-support",
|
||||
"version": "3.0.14",
|
||||
"version": "3.0.18",
|
||||
"description": "A collection of test utilities used across Appium packages",
|
||||
"keywords": [
|
||||
"automation",
|
||||
@@ -45,12 +45,12 @@
|
||||
"test:unit": "mocha \"./test/unit/**/*.spec.js\""
|
||||
},
|
||||
"dependencies": {
|
||||
"@appium/support": "^4.0.0",
|
||||
"@appium/support": "^4.1.0",
|
||||
"@colors/colors": "1.5.0",
|
||||
"bluebird": "3.7.2",
|
||||
"lodash": "4.17.21",
|
||||
"loud-rejection": "2.2.0",
|
||||
"sinon": "15.0.4",
|
||||
"sinon": "15.1.0",
|
||||
"source-map-support": "0.5.21"
|
||||
},
|
||||
"engines": {
|
||||
|
||||
@@ -3,6 +3,16 @@
|
||||
All notable changes to this project will be documented in this file.
|
||||
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
||||
|
||||
## [0.6.5](https://github.com/appium/appium/compare/@appium/typedoc-plugin-appium@0.6.4...@appium/typedoc-plugin-appium@0.6.5) (2023-06-14)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* **types:** update dependency type-fest to v3.11.0 ([19277f6](https://github.com/appium/appium/commit/19277f6e14a56e52b4669d633e148ad4a3da2c7a))
|
||||
* **types:** update dependency type-fest to v3.11.1 ([56499eb](https://github.com/appium/appium/commit/56499eb997b551739bed628f057de7987674ea7f))
|
||||
|
||||
|
||||
|
||||
## [0.6.4](https://github.com/appium/appium/compare/@appium/typedoc-plugin-appium@0.6.3...@appium/typedoc-plugin-appium@0.6.4) (2023-05-17)
|
||||
|
||||
|
||||
|
||||
@@ -6,32 +6,34 @@
|
||||
|
||||
This package leverages [TypeDoc](https://typedoc.org) to generate command documentation (HTTP endpoints, payload information, etc.) for Appium v2+ drivers and plugins.
|
||||
|
||||
## Important Note
|
||||
|
||||
_If you are an Appium extension author and just want to build HTML docs_, **don't install this directly**--instead, install [`@appium/docutils`](https://github.com/appium/appium/tree/master/packages/docutils), which is a higher-level package that configures everything for you.
|
||||
|
||||
If you _only_ want to build markdown docs for your extension, then you can use this package directly.
|
||||
|
||||
## Installation
|
||||
|
||||
`npm` v8+ is required to install this package.
|
||||
|
||||
```bash
|
||||
npm install appium@next typedoc @appium/typedoc-plugin-appium --save-dev
|
||||
npm install @appium/typedoc-plugin-appium --save-dev
|
||||
```
|
||||
|
||||
`typedoc` and `appium` are peer dependencies of this package. Newer versions of `npm` will install these automatically (if possible).
|
||||
The above command installs the plugin as well as all necessary peer dependencies. See [`package.json`](https://github.com/appium/appium/blob/master/packages/docutils/package.json) for the full list of dependencies.
|
||||
|
||||
## Usage
|
||||
|
||||
TypeDoc is configured via a `typedoc.json` or `typedoc.js` file ([read the docs](https://typedoc.org/guides/options/) for more information).
|
||||
|
||||
An Appium extension author wishing to generate documentation for their extension will need to create a `typedoc.json`. At minimum, it should contain:
|
||||
|
||||
> TODO: The plugin should be able to detect the entry points automatically, so this should not be necessary
|
||||
An Appium extension author wishing to generate markdown documentation for their extension will need to create a `typedoc.json`. At minimum, it should contain:
|
||||
|
||||
```json
|
||||
{
|
||||
"entryPointStrategy": "packages",
|
||||
"entryPoints": [
|
||||
"./node_modules/appium",
|
||||
"./node_modules/@appium/base-driver",
|
||||
"./node_modules/@appium/types",
|
||||
"."
|
||||
],
|
||||
"entryPoints": ["."],
|
||||
"name": "<name of extension>",
|
||||
"theme": "appium",
|
||||
"out": "<path to output directory>"
|
||||
}
|
||||
```
|
||||
@@ -42,21 +44,37 @@ Once this file is created, you can run `typedoc` to generate the documentation,
|
||||
|
||||
This plugin supports all of the options from [typedoc-plugin-markdown](https://npm.im/typedoc-plugin-markdown), as well as the following:
|
||||
|
||||
### `commandsDir`
|
||||
### `outputModules`
|
||||
|
||||
> TODO
|
||||
|
||||
### `forceBreadcrumbs`
|
||||
|
||||
> TODO
|
||||
`boolean` - Output module, class, interface, and other type information (the usual TypeDoc output) in addition to command documentation. This is needed for full documentation of types. _Default value: `true`_
|
||||
|
||||
### `outputBuiltinCommands`
|
||||
|
||||
> TODO
|
||||
`boolean` - Outputs _all_ commands and types from Appium builtins--not just your extension. This is intended to be used by Appium itself. _Default value: `false`_
|
||||
|
||||
### `outputModules`
|
||||
### `packageTitles`
|
||||
|
||||
> TODO
|
||||
`Array<{name: string, title: string}>`: An array of objects containing module name `name` and display name `title`. By default, the module name is used for the title; use this to override that behavior. _Default value: `undefined`_
|
||||
|
||||
### `commandsDir`
|
||||
|
||||
`string` - The name of the "commands" directory relative to the TypeDoc output directory (`out`). _Default value: `commands`_
|
||||
|
||||
### `forceBreadcrumbs`
|
||||
|
||||
`boolean` - Forces breadcrumbs to be output; overrides `hideBreadcrumbs` from `typedoc-plugin-markdown`. _Default value: `false`_
|
||||
|
||||
## Development
|
||||
|
||||
This packages uses snapshot tests to assert the generated markdown is correct. If you have made changes which affect the plugin's output, you will need to update the snapshots.
|
||||
|
||||
To update the snapshots, execute:
|
||||
|
||||
```bash
|
||||
UPDATE_SNAPSHOT=1 npm test
|
||||
```
|
||||
|
||||
This will (likely) modify the snapshots in your working copy, so you will then need to commit them.
|
||||
|
||||
## License
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@appium/typedoc-plugin-appium",
|
||||
"version": "0.6.4",
|
||||
"version": "0.6.5",
|
||||
"description": "TypeDoc plugin for Appium & its extensions",
|
||||
"homepage": "https://appium.io",
|
||||
"license": "Apache-2.0",
|
||||
@@ -63,7 +63,7 @@
|
||||
"handlebars": "4.7.7",
|
||||
"lodash": "4.17.21",
|
||||
"pluralize": "8.0.0",
|
||||
"type-fest": "3.10.0"
|
||||
"type-fest": "3.11.1"
|
||||
},
|
||||
"gitHead": "8480a85ce2fa466360e0fb1a7f66628331907f02"
|
||||
}
|
||||
|
||||
@@ -264,7 +264,7 @@ Get the log for a given log type.
|
||||
|
||||
#### Response
|
||||
|
||||
\`unknown\`[]
|
||||
\`any\`
|
||||
|
||||
### \`getLog\`
|
||||
|
||||
@@ -282,7 +282,7 @@ Get the log for a given log type.
|
||||
|
||||
#### Response
|
||||
|
||||
\`unknown\`[]
|
||||
\`any\`
|
||||
|
||||
### \`getLogEvents\`
|
||||
|
||||
@@ -852,7 +852,7 @@ Get the log for a given log type.
|
||||
|
||||
#### Response
|
||||
|
||||
\`unknown\`[]
|
||||
\`any\`
|
||||
|
||||
### \`getLog\`
|
||||
|
||||
@@ -870,7 +870,7 @@ Get the log for a given log type.
|
||||
|
||||
#### Response
|
||||
|
||||
\`unknown\`[]
|
||||
\`any\`
|
||||
|
||||
### \`getLogEvents\`
|
||||
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user