mirror of
https://github.com/appium/appium.git
synced 2026-11-03 15:56:15 +08:00
Compare commits
77
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8476bd3f65 | ||
|
|
c6aa31bda0 | ||
|
|
ffaffc11d9 | ||
|
|
8edc4143a8 | ||
|
|
ca9e79b00d | ||
|
|
d870b7aca7 | ||
|
|
6cb9e846cc | ||
|
|
5b33298ca7 | ||
|
|
e88ea8c783 | ||
|
|
c9ecc152c9 | ||
|
|
97c62676fc | ||
|
|
9e9cbdeaf1 | ||
|
|
2422e44082 | ||
|
|
05a562ca9e | ||
|
|
a17291db4e | ||
|
|
1cc2e3324a | ||
|
|
1be94b9f7a | ||
|
|
bd9ce0c78e | ||
|
|
649e997e07 | ||
|
|
d782d28326 | ||
|
|
17f25ecb33 | ||
|
|
eb559dc833 | ||
|
|
a765ff99d5 | ||
|
|
7979351543 | ||
|
|
55da22fc40 | ||
|
|
d4a0126ad5 | ||
|
|
846c60a3c7 | ||
|
|
3b054fe8d1 | ||
|
|
dafc7abaec | ||
|
|
f6eb67e838 | ||
|
|
1e07b227a1 | ||
|
|
1de5d0a0e8 | ||
|
|
25c0600b9f | ||
|
|
229f24d2e3 | ||
|
|
804b1a3c15 | ||
|
|
742ad1e9b5 | ||
|
|
71bfb5ada9 | ||
|
|
49d8b242e4 | ||
|
|
2b4b4c2a39 | ||
|
|
228e479785 | ||
|
|
a82476f2fc | ||
|
|
fcc66a1b4c | ||
|
|
d7e383c5f4 | ||
|
|
28b091a450 | ||
|
|
f55de14a4f | ||
|
|
d334ad4b4a | ||
|
|
423ef391bb | ||
|
|
283cd2c695 | ||
|
|
2e08ebbe16 | ||
|
|
7713985a50 | ||
|
|
e508e217ed | ||
|
|
f09640ccf3 | ||
|
|
8f30a5461e | ||
|
|
6ba28ebc28 | ||
|
|
c24d2ac461 | ||
|
|
4e381ada17 | ||
|
|
5b971de540 | ||
|
|
de737bba73 | ||
|
|
d8225d0176 | ||
|
|
aaab7b956e | ||
|
|
8d77bd3e06 | ||
|
|
b7dcd3f7b9 | ||
|
|
eccae91099 | ||
|
|
3425da9cf6 | ||
|
|
603d1e7fb2 | ||
|
|
f800c9d760 | ||
|
|
8f5a6c47a9 | ||
|
|
157108c70c | ||
|
|
7c5e3ee86e | ||
|
|
6e836e0860 | ||
|
|
65492d7f3b | ||
|
|
c07045ea48 | ||
|
|
1f68195ff3 | ||
|
|
fd09d7fa0f | ||
|
|
04f140a4ad | ||
|
|
3f077db410 | ||
|
|
3bda97f3c5 |
@@ -56,9 +56,9 @@ jobs:
|
||||
prepare_matrix:
|
||||
runs-on: ubuntu-latest
|
||||
outputs:
|
||||
versions: ${{ steps.generate-matrix.outputs.active }}
|
||||
versions: ${{ steps.generate-matrix.outputs.lts }}
|
||||
steps:
|
||||
- name: Select all active LTS versions of Node.js
|
||||
- name: Select all current LTS versions of Node.js
|
||||
id: generate-matrix
|
||||
uses: msimerson/node-lts-versions@v1
|
||||
|
||||
|
||||
@@ -12,9 +12,9 @@ jobs:
|
||||
prepare_matrix:
|
||||
runs-on: ubuntu-latest
|
||||
outputs:
|
||||
versions: ${{ steps.generate-matrix.outputs.active }}
|
||||
versions: ${{ steps.generate-matrix.outputs.lts }}
|
||||
steps:
|
||||
- name: Select all active LTS versions of Node.js
|
||||
- name: Select all current LTS versions of Node.js
|
||||
id: generate-matrix
|
||||
uses: msimerson/node-lts-versions@v1
|
||||
|
||||
|
||||
Generated
+1360
-1398
File diff suppressed because it is too large
Load Diff
+16
-16
@@ -85,17 +85,17 @@
|
||||
},
|
||||
"devDependencies": {
|
||||
"@colors/colors": "1.6.0",
|
||||
"@eslint/js": "9.22.0",
|
||||
"@eslint/js": "9.25.1",
|
||||
"@tsconfig/node14": "14.1.3",
|
||||
"@types/argparse": "2.0.17",
|
||||
"@types/archiver": "6.0.3",
|
||||
"@types/async-lock": "1.4.2",
|
||||
"@types/base64-stream": "1.0.5",
|
||||
"@types/bluebird": "3.5.42",
|
||||
"@types/chai": "5.2.0",
|
||||
"@types/chai": "5.2.1",
|
||||
"@types/chai-as-promised": "8.0.2",
|
||||
"@types/diff": "7.0.1",
|
||||
"@types/express": "5.0.0",
|
||||
"@types/diff": "7.0.2",
|
||||
"@types/express": "5.0.1",
|
||||
"@types/jsftp": "2.1.5",
|
||||
"@types/json-schema": "7.0.15",
|
||||
"@types/klaw": "3.0.6",
|
||||
@@ -105,9 +105,9 @@
|
||||
"@types/mocha": "10.0.10",
|
||||
"@types/mv": "2.1.4",
|
||||
"@types/ncp": "2.0.8",
|
||||
"@types/node": "22.13.10",
|
||||
"@types/node": "22.14.1",
|
||||
"@types/pluralize": "0.0.33",
|
||||
"@types/semver": "7.5.8",
|
||||
"@types/semver": "7.7.0",
|
||||
"@types/serve-favicon": "2.5.7",
|
||||
"@types/shell-quote": "1.7.5",
|
||||
"@types/sinon": "17.0.4",
|
||||
@@ -118,7 +118,7 @@
|
||||
"@types/uuid": "10.0.0",
|
||||
"@types/which": "3.0.4",
|
||||
"@types/wrap-ansi": "3.0.0",
|
||||
"@types/ws": "8.18.0",
|
||||
"@types/ws": "8.18.1",
|
||||
"@types/xmldom": "0.1.34",
|
||||
"@types/yargs": "17.0.33",
|
||||
"asyncbox": "3.0.0",
|
||||
@@ -127,16 +127,16 @@
|
||||
"conventional-changelog-conventionalcommits": "7.0.2",
|
||||
"cpy-cli": "5.0.0",
|
||||
"cross-env": "7.0.3",
|
||||
"eslint": "9.22.0",
|
||||
"eslint-config-prettier": "10.1.1",
|
||||
"eslint-import-resolver-typescript": "3.8.4",
|
||||
"eslint": "9.25.1",
|
||||
"eslint-config-prettier": "10.1.2",
|
||||
"eslint-import-resolver-typescript": "4.3.4",
|
||||
"eslint-plugin-import": "2.31.0",
|
||||
"eslint-plugin-mocha": "10.5.0",
|
||||
"eslint-plugin-promise": "7.2.1",
|
||||
"finalhandler": "2.1.0",
|
||||
"get-port": "5.1.1",
|
||||
"json-schema-to-typescript": "15.0.4",
|
||||
"lerna": "8.2.1",
|
||||
"lerna": "8.2.2",
|
||||
"log-symbols": "4.1.0",
|
||||
"midnight-smoker": "8.0.0",
|
||||
"mjpeg-consumer": "2.0.0",
|
||||
@@ -147,14 +147,14 @@
|
||||
"rewiremock": "3.14.5",
|
||||
"rimraf": "5.0.10",
|
||||
"serve-static": "1.16.2",
|
||||
"sinon": "19.0.2",
|
||||
"sinon": "20.0.0",
|
||||
"sync-monorepo-packages": "1.0.2",
|
||||
"ts-node": "10.9.2",
|
||||
"tsd": "0.31.2",
|
||||
"typescript": "5.8.2",
|
||||
"typescript-eslint": "8.26.1",
|
||||
"tsd": "0.32.0",
|
||||
"typescript": "5.8.3",
|
||||
"typescript-eslint": "8.31.0",
|
||||
"validate.js": "0.13.1",
|
||||
"webdriverio": "9.10.1",
|
||||
"webdriverio": "9.12.7",
|
||||
"ws": "8.18.1",
|
||||
"yaml-js": "0.3.1"
|
||||
},
|
||||
|
||||
@@ -3,6 +3,23 @@
|
||||
All notable changes to this project will be documented in this file.
|
||||
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
||||
|
||||
## [2.18.0](https://github.com/appium/appium/compare/appium@2.17.1...appium@2.18.0) (2025-04-25)
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* **base-driver:** Accept `x-request-id` as override to generated requestId in `handleLogContext` ([#21154](https://github.com/appium/appium/issues/21154)) ([a82476f](https://github.com/appium/appium/commit/a82476f2fcb4aa3a3c4660d96fdd261a98afa4af))
|
||||
|
||||
|
||||
|
||||
## [2.17.1](https://github.com/appium/appium/compare/appium@2.17.0...appium@2.17.1) (2025-03-17)
|
||||
|
||||
**Note:** Version bump only for package appium
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
## [2.17.0](https://github.com/appium/appium/compare/appium@2.16.2...appium@2.17.0) (2025-03-11)
|
||||
|
||||
|
||||
|
||||
@@ -44,6 +44,7 @@ These drivers are not maintained by the Appium team and can be used to target ad
|
||||
|[Tizen](https://github.com/Samsung/appium-tizen-driver)|`--source=npm appium-tizen-driver`|Android|Native|Community / Samsung|
|
||||
|[TizenTV](https://github.com/headspinio/appium-tizen-tv-driver)|`--source=npm appium-tizen-tv-driver`|Samsung TV|Web|HeadSpin|
|
||||
|[Youi](https://github.com/YOU-i-Labs/appium-youiengine-driver)|`--source=npm appium-youiengine-driver`|iOS, Android, macOS, Linux, tvOS|Native|Community / You.i|
|
||||
|[NovaWindows](https://github.com/AutomateThePlanet/appium-novawindows-driver)|`--source=npm appium-novawindows-driver`|Windows|Native|Community / Automate The Planet|
|
||||
|
||||
!!! note
|
||||
|
||||
|
||||
@@ -42,7 +42,7 @@ Here is a list of all the globally-recognized Appium capabilities:
|
||||
| `appium:app` | `string` | no | The path to an installable application |
|
||||
| `appium:deviceName` | `string` | no | The name of a particular device to automate, e.g., `iPhone 14` (currently only actually useful for specifying iOS simulators, since in other situations it's typically recommended to use a specific device id via the `appium:udid` capability). |
|
||||
| `appium:platformVersion` | `string` | no | The version of a platform, e.g., for iOS, `16.0` |
|
||||
| `appium:newCommandTimeout` | `number` | no | The number of seconds the Appium server should wait for clients to send commands before deciding that the client has gone away and the session should shut down |
|
||||
| `appium:newCommandTimeout` | `number` | no | The number of seconds the Appium server should wait for clients to send commands before deciding that the client has gone away and the session should shut down. `60` seconds by default. Setting it to zero disables the timer. |
|
||||
| `appium:noReset` | `boolean` | no | If true, instruct an Appium driver to avoid its usual reset logic during session start and cleanup (default `false`) |
|
||||
| `appium:fullReset` | `boolean` | no | If true, instruct an Appium driver to augment its usual reset logic with additional steps to ensure maximum environmental reproducibility (default `false`) |
|
||||
| `appium:eventTimings` | `boolean` | no | If true, instruct an Appium driver to collect [Event Timings](./event-timing.md) (default `false`) |
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
---
|
||||
title: Header Handling
|
||||
---
|
||||
|
||||
# Header Handling
|
||||
|
||||
## Request ID Tracking
|
||||
|
||||
Appium supports setting the request ID for each request through the `x-request-id` header. This is useful for tracing requests through your system, especially in environments where multiple services are involved or when debugging across different requests.
|
||||
|
||||
### Using `x-request-id`
|
||||
|
||||
When making requests to Appium, you can include an `x-request-id` header with a unique identifier. This ID will be:
|
||||
|
||||
- Used to track the request through Appium's logging system
|
||||
- Preserved across the entire request lifecycle
|
||||
- Generated automatically (as a UUID) if not provided
|
||||
@@ -6,141 +6,74 @@ This document is a guide for those who are using Appium 1 and wish to migrate to
|
||||
contains a list of breaking changes and how to migrate your environments or test suites to ensure
|
||||
compatibility with Appium 2.
|
||||
|
||||
!!! note
|
||||
Appium 2 is the biggest Appium release in over 5 years. It is _not_ focused on changing the
|
||||
automation behavior for any particular platform, but instead re-envisions Appium into an
|
||||
_ecosystem_ of automation tools:
|
||||
|
||||
Latest Appium drivers/plugins would have update since we created this documentation
|
||||
because we keep developing the ecosystem.
|
||||
|
||||
## Overview of Appium 2
|
||||
|
||||
Appium 2 is the most major new release of Appium in over 5 years. The changes in Appium 2 are _not_
|
||||
primarily related to changes in automation behaviors for specific platforms. Instead, Appium 2
|
||||
reenvisions Appium as a _platform_ where "drivers" (code projects that introduce support for
|
||||
automation of a given platform) and "plugins" (code projects that allow for overriding, altering,
|
||||
extending, or adding behaviors to Appium) can be easily created and shared.
|
||||
* The core Appium module retains only platform-agnostic functionality
|
||||
* Functionality for automating specific platforms is moved to separate _driver_ modules
|
||||
* Functionality for altering/extending Appium is moved to separate _plugin_ modules
|
||||
|
||||
At the same time, the Appium project is taking the opportunity to remove many old and deprecated
|
||||
bits of functionality.
|
||||
|
||||
Together these do introduce a few breaking changes to how Appium is installed, how drivers and
|
||||
various features are managed, and protocol support. These are detailed below.
|
||||
Since Appium 2 is a major architectural change, ^^we do not recommend directly updating your
|
||||
Appium 1 installations to Appium 2^^. Instead, please uninstall Appium 1 first, and only install
|
||||
Appium 2 afterwards.
|
||||
|
||||
## Breaking Changes
|
||||
|
||||
### :bangbang: Default server base path
|
||||
### Drivers Installed Separately
|
||||
|
||||
With Appium 1, the server would accept commands by default on `http://localhost:4723/wd/hub`. The
|
||||
`/wd/hub` base path was a legacy convention from the days of migrating from Selenium 1 to Selenium
|
||||
2, and is no longer relevant. As such the default base path for the server is now `/`. If you want
|
||||
to retain the old behaviour, you can set the base path via a command line argument as follows:
|
||||
When installing Appium 1, all available drivers would be installed alongside the main Appium
|
||||
server. In Appium 2, due to its modular structure, this is no longer the case - by default,
|
||||
installing it only installs the core Appium server, without any drivers.
|
||||
|
||||
```
|
||||
appium --base-path=/wd/hub
|
||||
```
|
||||
|
||||
You can also set server arguments as [Config file](./config.md) properties.
|
||||
|
||||
### :bangbang: Installing drivers during setup
|
||||
|
||||
When you installed Appium 1, all available drivers would be installed at the same time as the main
|
||||
Appium server. This is no longer the case. Simply installing Appium 2 (e.g., by `npm i -g appium`),
|
||||
will install the Appium server only, but no drivers. To install drivers, you must instead use the
|
||||
new [Appium extension CLI](../cli/extensions.md). For example, to install the latest versions of the
|
||||
XCUITest and UiAutomator2 drivers, after installing Appium you would run the following commands:
|
||||
|
||||
```bash
|
||||
appium driver install uiautomator2 # installs the latest driver version
|
||||
appium driver install xcuitest@4.12.2 # installs a specific driver version
|
||||
```
|
||||
|
||||
At this point, your drivers are installed and ready. There's a lot more you can do with the Appium 2
|
||||
command line, so be sure to check out [its documentation](../cli/index.md). If you're running in a CI
|
||||
environment or want to install Appium along with some drivers all in one step, you can do so using
|
||||
some special flags during install, for example:
|
||||
When it comes to installing Appium 2 drivers, there are several approaches you can take:
|
||||
|
||||
* Add the `--drivers` flag when installing Appium, for example:
|
||||
```bash
|
||||
npm i -g appium --drivers=xcuitest,uiautomator2
|
||||
```
|
||||
* Use the [Appium Extension CLI](../cli/extensions.md), for example:
|
||||
```bash
|
||||
appium driver install uiautomator2
|
||||
```
|
||||
* Use the [Appium Setup CLI command](../cli/setup.md) (added in Appium `2.6`), for example:
|
||||
```bash
|
||||
appium setup mobile
|
||||
```
|
||||
|
||||
This will install Appium and the two drivers for you in one go. Please uninstall any existing Appium 1
|
||||
`npm` packages (with `npm uninstall -g appium`) if you get an installation or startup error.
|
||||
Check the [Managing Drivers and Plugins guide](./managing-exts.md) for more information.
|
||||
|
||||
### :bangbang: Drivers installation path
|
||||
!!! info "Actions Needed"
|
||||
|
||||
When you installed Appium 1, all available drivers would be installed at the same time as the main
|
||||
Appium server, at `/path/to/appium/node_modules`. For example, `appium-webdriveragent` was located
|
||||
When installing Appium 2, use one of the above approaches for installing your desired drivers
|
||||
|
||||
### Driver Installation Path Changed
|
||||
|
||||
When installing Appium 1, all available drivers would be installed as dependencies of the main
|
||||
Appium server, in `/path/to/appium/node_modules`. For example, `appium-webdriveragent` was located
|
||||
at `/path/to/appium/node_modules/appium-xcuitest-driver/node_modules/appium-webdriveragent`.
|
||||
|
||||
Appium 2 installs such dependencies in the path defined by the `APPIUM_HOME` environment variable.
|
||||
The default path is `~/.appium`. So, `appium-webdriveragent` would now be located at
|
||||
`$APPIUM_HOME/node_modules/appium-xcuitest-driver/node_modules/appium-webdriveragent`.
|
||||
In Appium 2, drivers (and plugins) are installed at the path defined by the `APPIUM_HOME`
|
||||
environment variable, whose default value is `~/.appium`. So, `appium-webdriveragent` would now be
|
||||
located at `$APPIUM_HOME/node_modules/appium-xcuitest-driver/node_modules/appium-webdriveragent`.
|
||||
|
||||
### :bangbang: Chromedriver installation flags
|
||||
!!! info "Actions Needed"
|
||||
|
||||
In Appium 1, it was possible to customize the way Chromedriver was installed (as part of the
|
||||
UiAutomator2 driver for example), using the following command line flags:
|
||||
If your code uses paths to Appium driver files, update it to use the `APPIUM_HOME` environment
|
||||
variable
|
||||
|
||||
* `--chromedriver-skip-install`
|
||||
* `--chromedriver-version`
|
||||
* `--chromedriver-cdnurl`
|
||||
### Drivers Updated Separately
|
||||
|
||||
Because Appium 2 now installs drivers for you, and because these flags were implemented as `npm`
|
||||
config flags, they will no longer work. Instead, use the following environment variables during
|
||||
driver installation:
|
||||
In Appium 1, in order to get updates to your drivers, you would simply wait for those updates to be
|
||||
rolled into a new release of Appium, and then update your Appium version. With Appium 2, since the
|
||||
server and drivers are separate packages, they can release new versions independently from each
|
||||
other - this means that you no longer need to wait for a new Appium server release, but can install
|
||||
the latest driver versions right away.
|
||||
|
||||
* `APPIUM_SKIP_CHROMEDRIVER_INSTALL`
|
||||
* `CHROMEDRIVER_VERSION`
|
||||
* `CHROMEDRIVER_CDNURL`
|
||||
|
||||
For example:
|
||||
|
||||
```bash
|
||||
APPIUM_SKIP_CHROMEDRIVER_INSTALL=1 appium driver install uiautomator2
|
||||
```
|
||||
|
||||
### :bangbang: Driver-specific command line options
|
||||
|
||||
With Appium 1, command-line options specific to particular drivers were all hosted on the main
|
||||
Appium server. So, for example, `--chromedriver-executable` was a CLI parameter you could use with
|
||||
Appium to set the location of a specific Chromedriver version for use with, say, the UiAutomator2 driver.
|
||||
|
||||
With Appium 2, all driver- and platform-specific CLI params have been moved to the drivers themselves.
|
||||
To access the corresponding functionality, you'll need to refer to the driver/plugin documentation.
|
||||
In some cases, the extension will continue to expose CLI parameters. For example, the XCUITest driver
|
||||
used to expose a parameter `--webdriveragent-port`. Now, to access this parameter, it should be
|
||||
prefixed with `driver-xcuitest`, to differentiate it from parameters other drivers might also expose.
|
||||
To use this parameter, you thus need to start Appium with something like:
|
||||
|
||||
```bash
|
||||
appium --driver-xcuitest-webdriveragent-port=5000
|
||||
```
|
||||
|
||||
Some drivers have done away with CLI args entirely in favour of default capabilities. With the
|
||||
above-mentioned `--chromedriver-executable` parameter for example, you now need to take advantage
|
||||
of the `appium:chromedriverExecutable` capability supported by the UiAutomator2 driver. To set this
|
||||
capability from the command line, do the following:
|
||||
|
||||
```bash
|
||||
appium --default-capabilities '{"appium:chromedriverExecutable": "/path/to/chromedriver"}'
|
||||
```
|
||||
|
||||
### :bangbang: Driver-specific automation commands
|
||||
|
||||
The definition of certain commands that pertain only to specific drivers has been moved to those
|
||||
drivers' implementations. For example, `pressKeyCode` is specific to the UiAutomator2 driver and is
|
||||
now understood only by that driver. In practice, the only breaking change here is the kind of error
|
||||
you would encounter if the appropriate driver is not installed. Previously, you would get a `501
|
||||
Not Yet Implemented` error if using a driver that didn't implement the command. Now, you will get
|
||||
a `404 Not Found` error because if a driver that doesn't know about the command is not active, the
|
||||
main Appium server will not define the route corresponding to the command.
|
||||
|
||||
### :bangbang: Driver updates
|
||||
|
||||
In the past, to get updates to your iOS or Android drivers, you'd simply wait for those updates to
|
||||
be rolled into a new release of Appium, and then update your Appium version. With Appium 2, the
|
||||
Appium server and the Appium drivers are versioned and released separately. This means that drivers
|
||||
can be on their own release cadence, and you can get the latest driver version right away, rather
|
||||
than waiting for a new Appium server release. The way to check for driver updates is with the CLI:
|
||||
Checking for driver updates is done by using the [Appium Extension CLI](../cli/extensions.md):
|
||||
|
||||
```bash
|
||||
appium driver list --updates
|
||||
@@ -152,213 +85,284 @@ If any updates are available, you can then run the `update` command for any give
|
||||
appium driver update xcuitest
|
||||
```
|
||||
|
||||
(For a complete description of the update command, check out the
|
||||
[Extension CLI](../cli/extensions.md#update) documentation)
|
||||
|
||||
To update the Appium server itself, you do the same thing as in the past: `npm install -g appium`.
|
||||
Now, installing new versions of the Appium server will leave your drivers intact, so the whole
|
||||
process will be much more quick.
|
||||
|
||||
If you would like to update to a specific driver version, not the latest, please uninstall the driver
|
||||
and install the desired version using the `install` subcommand instead of `update`.
|
||||
Updating the Appium server itself is the same as before:
|
||||
|
||||
```bash
|
||||
appium driver uninstall xcuitest
|
||||
appium driver install xcuitest@4.11.1
|
||||
npm update -g appium
|
||||
```
|
||||
|
||||
### :bangbang: Protocol changes
|
||||
However, in Appium 2 this process is a lot quicker, since drivers are no longer bundled with the
|
||||
server package.
|
||||
|
||||
!!! info "Actions Needed"
|
||||
|
||||
Make sure to use the [Appium Extension CLI](../cli/extensions.md) to manage your drivers
|
||||
|
||||
### Deprecated Packages No Longer Supported
|
||||
|
||||
The Appium 1 ecosystem included several drivers, clients and other packages that had since been
|
||||
deprecated and replaced with newer packages. Appium 2 no longer includes support for these packages,
|
||||
and it is recommended to migrate to the following replacements:
|
||||
|
||||
|Appium 1 Package|Replacement in Appium 2|
|
||||
|--|--|
|
||||
|iOS Driver|[XCUITest Driver](https://appium.github.io/appium-xcuitest-driver/latest/)|
|
||||
|UiAutomator Driver|[UiAutomator2](https://github.com/appium/appium-uiautomator2-driver/)|
|
||||
|`wd` Client|[WebdriverIO Client](https://webdriver.io/)|
|
||||
|Appium Desktop|[Appium Inspector](https://github.com/appium/appium-inspector)|
|
||||
|
||||
!!! info "Actions Needed"
|
||||
|
||||
If you are using any of the aforementioned package(s), migrate to their recommended replacement(s)
|
||||
|
||||
### Default Server Base Path Changed
|
||||
|
||||
In Appium 1, the default Appium server URL was `http://localhost:4723/wd/hub`, where the `/wd/hub`
|
||||
part (the base path) was a legacy convention from Selenium 1. Appium 2 changes the default base
|
||||
path to `/`, therefore the default server URL is now `http://localhost:4723/`.
|
||||
|
||||
!!! info "Actions Needed"
|
||||
|
||||
In your test scripts, change the base path of the target server URL from `/wd/hub` to `/`.
|
||||
Alternatively, you can retain the Appium 1 base path by launching Appium with the
|
||||
`--base-path=/wd/hub` [command-line argument](../cli/args.md).
|
||||
|
||||
### Server Port 0 No Longer Supported
|
||||
|
||||
In Appium 1, it was possible to specify `--port 0` during server startup, which had the effect of
|
||||
starting Appium on a random free port. Appium 2 no longer allows this, and requires port values to
|
||||
be `1` or higher. If you wish to start Appium on a random port, you must now take care of this on
|
||||
your own prior to launching the server.
|
||||
|
||||
!!! info "Actions Needed"
|
||||
|
||||
If you are launching Appium with `--port 0`, change the port number value to `1` or higher
|
||||
|
||||
### Driver-Specific CLI Options Changed
|
||||
|
||||
With Appium 1, command-line options specific to particular drivers were all hosted on the main
|
||||
Appium server. So, for example, `--chromedriver-executable` was a CLI parameter you could use to
|
||||
set the Chromedriver location for the UiAutomator2 driver.
|
||||
|
||||
In Appium 2, all driver-specific CLI options have been moved to the drivers themselves. However,
|
||||
depending on the driver, these options may now need to be passed in another way:
|
||||
|
||||
* Some options can still be passed as different CLI flags, for example:
|
||||
```bash
|
||||
appium --webdriveragent-port=5000 # Appium 1
|
||||
appium --driver-xcuitest-webdriveragent-port=5000 # Appium 2
|
||||
```
|
||||
* Some options can now be passed as environment variables, for example:
|
||||
```bash
|
||||
appium --chromedriver-version=100 # Appium 1
|
||||
CHROMEDRIVER_VERSION=100 appium # Appium 2
|
||||
```
|
||||
* Some options can now be passed as [capabilities](https://appium.io/docs/en/latest/guides/caps/),
|
||||
for example:
|
||||
```
|
||||
appium --chromedriver-executable=/path/to/chromedriver # Appium 1
|
||||
{"appium:chromedriverExecutable": "/path/to/chromedriver"} # Appium 2
|
||||
```
|
||||
|
||||
!!! info "Actions Needed"
|
||||
|
||||
If you are using driver-specific CLI options, refer to that driver's documentation for how to
|
||||
apply them in Appium 2
|
||||
|
||||
### Filepaths No Longer Supported for Some CLI Options
|
||||
|
||||
In Appium 1, some server command-line options could be invoked by passing a filepath as their
|
||||
value, and Appium would then parse the contents of that file as the actual value for that option.
|
||||
There were four options that supported this:
|
||||
|
||||
* `--nodeconfig`
|
||||
* `--default-capabilities`
|
||||
* `--allow-insecure`
|
||||
* `--deny-insecure`
|
||||
|
||||
Appium 2 no longer attempts to parse the contents of filepaths passed to these options, and offers
|
||||
two ways to specify the value for these options:
|
||||
|
||||
* As strings, directly on the command line
|
||||
* `--nodeconfig` / `--default-capabilities`: JSON string
|
||||
* `--allow-insecure` / `--deny-insecure`: comma-separated list
|
||||
* In the [Appium Configuration file](./config.md)
|
||||
|
||||
!!! info "Actions Needed"
|
||||
|
||||
If you are using any of the aforementioned CLI options with a filepath value, update your code
|
||||
to pass the file contents either directly or through the Appium config file
|
||||
|
||||
### Old Protocols Dropped
|
||||
|
||||
Appium's API is based on the [W3C WebDriver Protocol](https://www.w3.org/TR/webdriver/), and it has
|
||||
supported this protocol for years. Before the W3C WebDriver Protocol was designed as a web standard,
|
||||
several other protocols were used for both Selenium and Appium. These protocols were the "JSONWP"
|
||||
(JSON Wire Protocol) and "MJSONWP" (Mobile JSON Wire Protocol). The W3C Protocol differs from the
|
||||
(M)JSONWP protocols in a few small ways.
|
||||
supported this protocol for years. Before this protocol was designed as a web standard, the
|
||||
[JSON Wire Protocol](https://www.selenium.dev/documentation/legacy/json_wire_protocol/) (JSONWP)
|
||||
and [Mobile JSON Wire Protocol](https://github.com/SeleniumHQ/mobile-spec/blob/master/spec-draft.md)
|
||||
(MJSONWP) were used instead.
|
||||
|
||||
Up until Appium 2, Appium supported both protocols, so that older Selenium/Appium clients could
|
||||
still communicate with newer Appium servers. Appium 2 removes support for older protocols and is
|
||||
now only compatible with the W3C WebDriver Protocol.
|
||||
In Appium 1, all of these protocols were supported, so that older Selenium/Appium clients could
|
||||
still communicate with newer Appium servers. Appium 2 removes support for JSONWP/MJSONWP and is now
|
||||
only compatible with the W3C WebDriver Protocol.
|
||||
|
||||
### :bangbang: Capabilities must use vendor prefix
|
||||
!!! info "Actions Needed"
|
||||
|
||||
One significant difference between old and new protocols is in the format of capabilities.
|
||||
Previously called "desired capabilities", and now called simply "capabilities", there is now a
|
||||
requirement for a so-called "vendor prefix" on any non-standard capabilities. The list of standard
|
||||
capabilities is given in the [WebDriver Protocol spec](https://www.w3.org/TR/webdriver/#capabilities),
|
||||
and includes a few commonly used capabilities such as `browserName` and `platformName`.
|
||||
Make sure you are using Selenium/Appium clients compatible with the W3C WebDriver Protocol
|
||||
|
||||
These standard capabilities continue to be used as-is. All other capabilities must include a
|
||||
"vendor prefix" in their name. A vendor prefix is a string followed by a colon, such as `appium:`.
|
||||
Most of Appium's capabilities go beyond the standard W3C capabilities and must therefore include
|
||||
vendor prefixes (we recommend that you use `appium:` unless directed otherwise by documentation).
|
||||
For example:
|
||||
### Capabilities Require Vendor Prefix
|
||||
|
||||
- `appium:app`
|
||||
- `appium:noReset`
|
||||
- `appium:deviceName`
|
||||
In Appium 1, in order to create a session, you had to specify certain desired capabilities, which
|
||||
would indicate session parameters, e.g. the driver you want to use. Appium 2 retains this behavior
|
||||
and continues to accept desired capabilities (now renamed simply to 'capabilities'), but as part of
|
||||
the W3C WebDriver Protocol specification, all non-standard capabilities are now required to use a
|
||||
vendor prefix.
|
||||
|
||||
This requirement may or may not be a breaking change for your test suites when targeting Appium 2.
|
||||
If you're using an updated Appium client (at least one maintained by the Appium team), the client
|
||||
will add the `appium:` prefix for you on all necessary capabilities automatically. New versions of
|
||||
[Appium Inspector](https://github.com/appium/appium-inspector) will also do this. Cloud-based Appium
|
||||
providers may also do this. So simply be aware that if you get any messages to the effect that your
|
||||
capabilities lack a vendor prefix, this is how you solve that problem.
|
||||
The list of standard capabilities is described in the [WebDriver Protocol specification](https://www.w3.org/TR/webdriver/#capabilities),
|
||||
and includes a few commonly used capabilities like `browserName` and `platformName`. All other
|
||||
capabilities must now start with the vendor name and a colon (the vendor prefix), for example,
|
||||
`moz:` or `goog:`. Since most of Appium's capabilities go beyond the standard W3C capabilities,
|
||||
all of them must include the `appium:` prefix (unless specified otherwise):
|
||||
|
||||
To make everyone's lives a bit easier, we've also introduced the option of grouping up all
|
||||
Appium-related capabilities into one object capability, `appium:options`. You can bundle together
|
||||
anything that you would normally put an `appium:` prefix on into this one capability. Here's an
|
||||
example (in raw JSON) of how you might start an iOS session on the Safari browser using `appium:options`:
|
||||
|
||||
```json
|
||||
{
|
||||
"platformName": "iOS",
|
||||
"browserName": "Safari",
|
||||
"appium:options": {
|
||||
"platformVersion": "14.4",
|
||||
"deviceName": "iPhone 11",
|
||||
"automationName": "XCUITest"
|
||||
}
|
||||
}
|
||||
```
|
||||
deviceName # Appium 1
|
||||
appium:deviceName # Appium 2
|
||||
```
|
||||
|
||||
(Of course, each client will have a different way of creating structured capabilities like
|
||||
`appium:options` or other ones that you might have seen such as `goog:chromeOptions`).
|
||||
This requirement may or may not be a breaking change for your test suites. Up-to-date versions of
|
||||
official Appium clients and the Appium Inspector will automatically add the `appium:` prefix to all
|
||||
non-standard capabilities, and the same may apply to cloud-based Appium providers.
|
||||
|
||||
!!! note
|
||||
Additionally, if you are starting a session with multiple Appium-specific capabilities (which will
|
||||
likely be the case), it may seem repetitive to add the `appium:` prefix to each individual
|
||||
capability. To avoid this, you can optionally group up all these capabilities under a single object
|
||||
capability, `appium:options`, for example:
|
||||
|
||||
=== "Default Approach"
|
||||
|
||||
```json
|
||||
{
|
||||
"platformName": "iOS",
|
||||
"browserName": "Safari",
|
||||
"appium:platformVersion": "14.4",
|
||||
"appium:deviceName": "iPhone 11",
|
||||
"appium:automationName": "XCUITest"
|
||||
}
|
||||
```
|
||||
|
||||
=== "With `appium:options`"
|
||||
|
||||
```json
|
||||
{
|
||||
"platformName": "iOS",
|
||||
"browserName": "Safari",
|
||||
"appium:options": {
|
||||
"platformVersion": "14.4",
|
||||
"deviceName": "iPhone 11",
|
||||
"automationName": "XCUITest"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
!!! warning
|
||||
|
||||
Capabilities included in the `appium:options` object will overwrite capabilities of the same
|
||||
name that are used outside of this object. (The `appium:options` syntax support by cloud
|
||||
providers may vary.)
|
||||
name that are used outside of this object. Note that cloud provider support for the
|
||||
`appium:options` syntax may vary.
|
||||
|
||||
For more information on capabilities, have a look at the [Capabilities Guide](./caps.md).
|
||||
|
||||
### :bangbang: Removed Commands
|
||||
!!! info "Actions Needed"
|
||||
|
||||
In addition to commands which have been moved to driver implementations, commands which were a part
|
||||
of the old JSON Wire Protocol and not a part of the W3C Protocol are no longer available:
|
||||
Add the `appium:` prefix to all Appium-specific capabilities used in your tests, or wrap them
|
||||
inside an `appium:options` object
|
||||
|
||||
- TODO (these commands are being identified and removed and will be updated here when complete)
|
||||
### Advanced Features Moved to Plugins
|
||||
|
||||
If you use a modern Appium or Selenium client, you should no longer have access to these anyway,
|
||||
so any breaking changes should appear on the client side first and foremost.
|
||||
One of the design goals for Appium 2 is to extract non-core features into special extensions called
|
||||
[plugins](../ecosystem/plugins.md). Two such features of Appium 1 have been moved to plugins, and
|
||||
are no longer bundled with Appium 2:
|
||||
|
||||
### :bangbang: Image analysis features moved to plugin
|
||||
|Feature|Plugin Name|
|
||||
|--|--|
|
||||
|Image-related features (comparison, search by image, etc...)|[`images`](https://github.com/appium/appium/tree/master/packages/images-plugin)|
|
||||
|The Execute Driver Script feature|[`execute-driver`](https://github.com/appium/appium/tree/master/packages/execute-driver-plugin)|
|
||||
|
||||
One of the design goals for Appium 2 is to migrate non-core features into special extensions called
|
||||
[plugins](../ecosystem/plugins.md). This allows people to opt into features which require extra time
|
||||
to download or extra system setup. The various image-related features of Appium (image comparison,
|
||||
finding elements by image, etc...) have been moved into an officially supported plugin called
|
||||
[images](https://github.com/appium/appium/tree/master/packages/images-plugin).
|
||||
!!! info "Actions Needed"
|
||||
|
||||
If you use these image-related methods, to continue accessing them you will need to do two things:
|
||||
If you were using the image-related features and/or the execute driver script feature in Appium
|
||||
1, first install their plugin(s):
|
||||
```
|
||||
appium plugin install images
|
||||
appium plugin install execute-driver
|
||||
```
|
||||
Afterwards, make sure to activate the plugin(s) upon launching the Appium server:
|
||||
```
|
||||
appium --use-plugins=images,execute-driver
|
||||
```
|
||||
|
||||
1. Install the plugin: `appium plugin install images`
|
||||
2. Ensure you start the Appium server with access to run the plugin by including it in the list of
|
||||
plugins designated on the command line, e.g., `appium --use-plugins=images`
|
||||
### Endpoint Changes
|
||||
|
||||
Image-related commands will also be removed on the client side of things, which means you will need
|
||||
to follow the instructions on the plugin README for installing client-side plugins to access these features.
|
||||
A few server endpoints used in Appium 1 were accepting old or unused parameters. Appium 2 removes
|
||||
support for these parameters. The following is a list of these changed endpoints, along with the
|
||||
parameters they no longer accept, as well as the parameters they continue to accept in Appium 2.
|
||||
|
||||
### :bangbang: Execute Driver Script command moved to plugin
|
||||
* `POST /session/:sessionId/appium/device/gsm_signal`
|
||||
* :octicons-x-24: `signalStrengh`
|
||||
* :octicons-check-24: `signalStrength`
|
||||
* `POST /session/:sessionId/appium/element/:elementId/value`
|
||||
* :octicons-x-24: `value`
|
||||
* :octicons-check-24: `text`
|
||||
* `POST /session/:sessionId/appium/element/:elementId/replace_value`
|
||||
* :octicons-x-24: `value`
|
||||
* :octicons-check-24: `text`
|
||||
|
||||
If you use the advanced Execute Driver Script feature (which allows you to send in a WebdriverIO
|
||||
script to have it executed completely on the server instead of command-by-command from the client),
|
||||
this functionality has been moved to a plugin. Here's what to do to keep using it:
|
||||
!!! info "Actions Needed"
|
||||
|
||||
1. Install the plugin: `appium plugin install execute-driver`
|
||||
2. Ensure you start the Appium server with access to run the plugin by including it in the list of
|
||||
plugins designated on the command line, e.g., `appium --use-plugins=execute-driver`
|
||||
Check your Appium client documentation for the methods using these endpoints, and adjust your
|
||||
code to only use the accepted parameters
|
||||
|
||||
### :bangbang: External Files No Longer Supported for `--nodeconfig`, `--default-capabilities`, `--allow-insecure` and `--deny-insecure`
|
||||
### Internal Packages Renamed
|
||||
|
||||
These options can be provided as strings on the command line (a JSON string for `--nodeconfig` and
|
||||
a comma-separated list of strings for `--allow-insecure` and `--deny-insecure`). Arguments provided
|
||||
on the command line will likely need to be quoted or escaped.
|
||||
In Appium 1, the internal dependency packages were each located in their own repository. Appium 2
|
||||
moves to a monorepo structure and therefore renames many of these packages, for example:
|
||||
|
||||
The recommended method to provide these options is through a [configuration file](./config.md).
|
||||
```
|
||||
appium-base-driver # Appium 1
|
||||
@appium/base-driver # Appium 2
|
||||
```
|
||||
|
||||
In summary, if you are using a JSON Appium config file, you can simply cut-and-paste the contents
|
||||
of your "nodeconfig" JSON file into the value of the `server.nodeconfig` property. Any CSV-like
|
||||
files you had previously provided for `--allow-insecure` and `--deny-insecure` become the values
|
||||
of the `server.allow-insecure` and `server.deny-insecure` properties in the Appium config files
|
||||
(respectively); both are arrays of strings.
|
||||
!!! info "Actions Needed"
|
||||
|
||||
### :bangbang: Old drivers removed
|
||||
|
||||
The old iOS and Android (UiAutomator 1) drivers and related tools (e.g., `authorize-ios`) have been
|
||||
removed. They haven't been relevant for many years anyway.
|
||||
|
||||
### :bangbang: Server can no longer be started with `--port 0`
|
||||
|
||||
In Appium 1, it was possible to specify `--port 0` during server startup. This had the effect of
|
||||
starting Appium on a random free port. In Appium 2, port values must be `1` or higher. The random
|
||||
port assignment was never an intentional feature of Appium 1, but a consequence of how Node's
|
||||
HTTP servers work and the fact that there was no port input validation in Appium 1. If you want
|
||||
to find a random free port to start Appium on, you must now take care of this on your own prior to
|
||||
starting Appium. Starting Appium on an explicit and known port is the correct practice moving
|
||||
forward.
|
||||
|
||||
### :warning: Internal packages renamed
|
||||
|
||||
Some Appium-internal NPM packages have been renamed (for example, `appium-base-driver` is now
|
||||
`@appium/base-driver`). This is not a breaking change for Appium users, only for people who have
|
||||
built software that directly incorporates Appium's code.
|
||||
|
||||
### :warning: `wd` JavaScript client library no longer supported
|
||||
|
||||
For many years, some of Appium's authors maintained the [WD](https://github.com/admc/wd) client
|
||||
library. This library has been deprecated and has not been updated for use with the W3C WebDriver
|
||||
protocol. As such, if you're using this library you'll need to move to a more modern one. We
|
||||
recommend [WebdriverIO](https://webdriver.io).
|
||||
|
||||
### :warning: Appium Desktop replaced with Appium Inspector
|
||||
|
||||
The inspector functionality of Appium Desktop has been moved to its own app:
|
||||
[Appium Inspector](https://github.com/appium/appium-inspector). It is fully compatible with
|
||||
standalone Appium 2 servers, but also works with later versions of Appium 1 servers. Appium Desktop
|
||||
itself has been deprecated and is not compatible with Appium 2.
|
||||
|
||||
In addition to the app, Appium Inspector also has a browser version, accessible at
|
||||
[inspector.appiumpro.com](https://inspector.appiumpro.com). Note that in order to use the
|
||||
browser version with a local Appium server, you'll need to first start the server with the
|
||||
`--allow-cors` flag.
|
||||
If you do not directly import Appium packages into your code - none! However, if you do, make
|
||||
sure to update the names of your Appium package imports!
|
||||
|
||||
## Major New Features
|
||||
|
||||
Apart from the breaking changes mentioned above, in this section is a list of some of the major new
|
||||
features you may wish to take advantage of with Appium 2.
|
||||
Apart from the breaking changes mentioned above, here are some of the major new features you may
|
||||
wish to take advantage of with Appium 2:
|
||||
|
||||
### Plugins
|
||||
### Third-Party Drivers and Plugins
|
||||
|
||||
#### :tada: Server Plugins
|
||||
You are no longer limited to official drivers or plugins, or ones that the Appium team even knows
|
||||
about! Developers can now create their own custom drivers or plugins, which can be installed via
|
||||
Appium's [Extension CLI](../cli/extensions.md) from `npm`, `git`, GitHub, or even the local
|
||||
filesystem. Interested in building a driver or plugin? Check out the
|
||||
[Building Drivers](../developing/build-drivers.md) and
|
||||
[Building Plugins](../developing/build-plugins.md) guides.
|
||||
|
||||
Appium extension authors can now develop their own server plugins, which can intercept and modify
|
||||
any Appium command, or even adjust the way the underlying Appium HTTP server itself works. To learn
|
||||
more about plugins, read the new [Appium Introduction](../intro/index.md). Interested in building
|
||||
a plugin? Check out the [Building Plugins](../developing/build-plugins.md) guide.
|
||||
### Configuration Files
|
||||
|
||||
### :tada: Install drivers and plugins from anywhere
|
||||
|
||||
You're no longer limited to the drivers that come with Appium, or that the Appium team even knows
|
||||
about! Appium extension authors can now develop custom drivers, which can be downloaded or
|
||||
installed via Appium's [Extension CLI](../cli/extensions.md) from `npm`, `git`, GitHub, or even the
|
||||
local filesystem. Interested in building a driver? Check out the [Building
|
||||
Drivers](../developing/build-drivers.md) guide.
|
||||
|
||||
### :tada: Configuration Files
|
||||
|
||||
Appium now supports _configuration files_ in addition to command-line arguments. In a nutshell,
|
||||
nearly all arguments which Appium 1 required to be provided on the CLI are now able to be expressed
|
||||
via a configuration file. Configuration files may be in JSON, JS, or YAML format. See the
|
||||
[Config Guide](./config.md) for a full explanation.
|
||||
Appium now supports _configuration files_ in addition to command-line arguments. Nearly all options
|
||||
or flags that had to be specified on the CLI in Appium 1, can now also be provided in a
|
||||
configuration file. The file can be in JSON, JS, or YAML format. For more information, refer to
|
||||
the [Config File Guide](./config.md).
|
||||
|
||||
## Special Notes for Cloud Providers
|
||||
|
||||
The rest of this document has applied to Appium generally, but some of the architectural changes in
|
||||
Appium 2 will constitute breaking changes for Appium-related service providers, whether a
|
||||
cloud-based Appium host or an internal service. At the end of the day, the maintainer of the Appium
|
||||
server is responsible for installing and making available the various Appium drivers and plugins
|
||||
that end users may wish to use.
|
||||
Most of this guide has applied to Appium end users or developers, but some of the architectural
|
||||
changes in Appium 2 will constitute breaking changes for different Appium service providers. At the
|
||||
end of the day, the maintainer of the Appium server is responsible for installing and exposing the
|
||||
various Appium drivers and plugins that end users may wish to use.
|
||||
|
||||
We encourage cloud providers to thoroughly read and understand our [recommendation for cloud
|
||||
provider capabilities](./caps.md#special-notes-for-cloud-providers) in order to support user needs in
|
||||
|
||||
@@ -12,13 +12,6 @@ title: Welcome
|
||||
}
|
||||
</style>
|
||||
|
||||
<div style="text-align:center;width:100%;background-color:#ec366d;margin-top:-3em;margin-bottom:2em;">
|
||||
<h3 style="color:#ffffff;padding: 8px;">
|
||||
AppiumConf 2025 is partnering with SeleniumConf<br/> <span style="font-size:0.8em;">March 26-28 in Valencia, Spain. Join us to learn and connect with the community!</span><br/>
|
||||
<a style="color:#fcba12" href="https://seleniumconf.com/" target="_blank">Register Now</a>
|
||||
</h3>
|
||||
</div>
|
||||
|
||||
<div style="text-align: center">
|
||||
<img src="assets/images/appium-logo-horiz.png" style="max-width: 400px;" />
|
||||
</div>
|
||||
|
||||
@@ -57,6 +57,7 @@ nav:
|
||||
- guides/config.md
|
||||
- guides/security.md
|
||||
- guides/log-filters.md
|
||||
- guides/headers.md
|
||||
- guides/grid.md
|
||||
- guides/caching.md
|
||||
- guides/tls.md
|
||||
|
||||
@@ -180,45 +180,31 @@ Appium会使用`appiumCliTransformer: 'csv'`。
|
||||
|
||||
不需要这种特殊处理的属性直接使用`ajv`进行验证。这是如何工作的一些解释,所以接下来就是这样。
|
||||
|
||||
#### Validation of Individual Arguments via `ajv`
|
||||
#### 通过 `ajv` 实现单个参数的验证
|
||||
|
||||
When we think of a JSON schema, we tend to think, "I have this JSON file and I want to validate it
|
||||
against the schema". That's valid, and in fact Appium does just that with config files! However,
|
||||
Appium does not do this when validating arguments.
|
||||
当我们思考 JSON 模式时,通常会认为“我有一个 JSON 文件需要根据模式进行验证”。这种理解是正确的,实际上 Appium 在处理配置文件时正是这样做的!不过,Appium 在验证参数时采用了不同的方式。
|
||||
|
||||
!!! 注意
|
||||
|
||||
During implementation, I was tempted to mash all of the arguments together into
|
||||
a config-file-like data structure and then validate it all at once. I think that would have
|
||||
been _possible_, but since an object full of CLI arguments is a flat key/value structure and
|
||||
the schema is not, this seemed like trouble.
|
||||
在实现过程中,我曾试图将所有参数组合成一个类似配置文件的数据结构进行统一验证。虽然这在理论上是可行的,但由于 CLI 参数对象是扁平的键/值结构,而模式本身并非扁平结构,这种做法可能会引发问题。
|
||||
|
||||
Instead, Appium validates a value against a specific property _within_ the schema. To do this, it
|
||||
maintains a mapping between a CLI argument definition and its corresponding property. The mapping
|
||||
itself is a `Map` with a unique identifier for the argument as the key, and an `ArgSpec`
|
||||
(`lib/schema/arg-spec.js`) object as the value.
|
||||
Appium 实际采用的方式是:针对模式中特定的属性对参数值进行验证。为此,系统维护了 CLI 参数定义与对应模式属性之间的映射关系。这个映射关系通过一个 `Map` 实现,其中键是参数的唯一标识符,值是一个 `ArgSpec` 对象(定义于 `lib/schema/arg-spec.js`)。
|
||||
|
||||
An `ArgSpec` object stores the following metadata:
|
||||
`ArgSpec` 对象包含以下元数据:
|
||||
|
||||
| Property Name | Description |
|
||||
| --------------- | ------------------------------------------------------------------------------------- |
|
||||
| `name` | Canonical name of the argument, corresponding to the property name in the schema. |
|
||||
| `extType?` | `driver` or `plugin`, if appropriate |
|
||||
| `extName?` | Extension name, if appropriate |
|
||||
| `ref` | Computed `$id` of the property in the schema |
|
||||
| `arg` | Argument as accepted on CLI, without leading dashes |
|
||||
| `dest` | Property name in parsed arguments object (as returned by `argparse`'s `parse_args()`) |
|
||||
| `defaultValue?` | Value of the `default` keyword in schema, if appropriate |
|
||||
| 属性名称 | 描述 |
|
||||
| --------------- | --------------------------------------------------------------------------------------- |
|
||||
| `name` | 参数的规范名称,对应模式中的属性名 |
|
||||
| `extType?` | 扩展类型(`driver` 或 `plugin`),如果适用 |
|
||||
| `extName?` | 扩展名称,如果适用 |
|
||||
| `ref` | 模式中该属性的计算后 `$id` 引用 |
|
||||
| `arg` | CLI 接受的参数名(不带前导短横线) |
|
||||
| `dest` | 解析后参数对象的属性名(由 `argparse` 的 `parse_args()` 返回) |
|
||||
| `defaultValue?` | 模式中 `default` 关键字对应的值(如果存在) |
|
||||
|
||||
When a schema is [finalized](#schema-finalization), the `Map` is populated with `ArgSpec` objects
|
||||
for all known arguments.
|
||||
当模式完成[最终化](#schema-finalization)时,该 `Map` 会被填充所有已知参数的 `ArgSpec` 对象。
|
||||
|
||||
So when the adapter is creating the pipeline of functions for the argument's `type`, it already has
|
||||
an `ArgSpec` for the argument. It creates a function which calls `validate(value, ref)` (in
|
||||
`lib/schema/schema.js`) where `value` is whatever the user provided, and `ref` is the `ref`
|
||||
property of the `ArgSpec`. The concept is that `ajv` can validate using _any_ `ref` it knows about;
|
||||
each property in a schema can be referenced by this `ref` whether it's defined or not. To help
|
||||
visualize, if a schema is:
|
||||
在适配器为参数的 `type` 创建函数管道时,系统已经拥有该参数的 `ArgSpec`。它会创建一个调用 `validate(value, ref)` 的函数(位于 `lib/schema/schema.js`),其中 `value` 是用户提供的参数值,`ref` 是 `ArgSpec` 的 `ref` 属性。核心原理在于 `ajv` 可以使用任何已知的 `ref` 进行验证——无论该属性是否被显式定义,模式中的每个属性都可以通过其 `ref` 被引用。以下列模式为例:
|
||||
|
||||
```json
|
||||
{
|
||||
@@ -232,76 +218,50 @@ visualize, if a schema is:
|
||||
}
|
||||
```
|
||||
|
||||
The `ref` of `foo` would be `my-schema.json#/properties/foo`. Assuming our `Ajv` instance knows
|
||||
about this `my-schema.json`, then we can call its `getSchema(ref)` method (which has a `schema`
|
||||
property, but is a misnomer nonetheless) to get a validation function; `validate(value, ref)` in
|
||||
`schema.js` calls this validation function.
|
||||
其中 `foo` 的 `ref` 应为 `my-schema.json#/properties/foo`。假设我们的 `Ajv` 实例已注册该模式,即可通过 `getSchema(ref)` 方法(虽然名称有误,但其 `schema` 属性有效)获取验证函数;`schema.js` 中的 `validate(value, ref)` 方法正是调用此验证函数。
|
||||
|
||||
!!! 注意
|
||||
|
||||
The schema spec says a schema author can supply an explicit `$id` keyword to override this;
|
||||
it's unsupported by Appium at this time. If needed, extension authors must carefully use `$ref`
|
||||
without custom `$id`s. It's highly unlikely an extension would have a schema so complicated as
|
||||
to need this, however; Appium itself doesn't even use `$ref` to define its own properties!
|
||||
虽然模式规范允许通过显式声明 `$id` 来覆盖默认引用标识,但 Appium 目前不支持此特性。如有需要,扩展开发者必须谨慎使用不包含自定义 `$id` 的 `$ref` 引用。不过 Appium 自身的模式定义都未使用 `$ref`,可见扩展通常不需要如此复杂的模式结构。
|
||||
|
||||
Next, let's take a look at how Appium loads schemas. This actually happens _before_ any argument
|
||||
validation.
|
||||
接下来我们将探讨 Appium 如何加载模式。值得注意的是,模式加载过程实际上发生在参数验证之前。
|
||||
|
||||
## Schema Loading
|
||||
## 模式加载
|
||||
|
||||
Let's ignore extensions for a moment, and start with the base schema.
|
||||
让我们暂时忽略扩展功能,先从基础模式开始解析。
|
||||
|
||||
When something first imports the `lib/schema/schema.js` module, an instance of an `AppiumSchema` is
|
||||
created. This is a singleton, and its methods are exported from the module (all of which are bound
|
||||
to the instance).
|
||||
当首次导入 `lib/schema/schema.js` 模块时,系统会创建一个 `AppiumSchema` 实例。该实例为单例模式,其所有方法(均已绑定到实例)都通过该模块对外暴露。
|
||||
|
||||
The constructor does very little; it instantiates an `Ajv` instance and configures it with Appium's
|
||||
[custom keywords](#custom-keyword-reference) and adds support for the `format` keyword via the
|
||||
[ajv-formats](https://npm.im/ajv-formats) module.
|
||||
构造函数仅执行基础操作:实例化一个 `Ajv` 验证器实例,并通过以下方式对其进行配置:添加 Appium 的[自定义关键字](#custom-keyword-reference);
|
||||
通过 [ajv-formats](https://npm.im/ajv-formats) 模块启用 `format` 关键字支持。
|
||||
|
||||
Otherwise, the `AppiumSchema` instance does not interact with the `Ajv` instance until its
|
||||
`finalize()` method (exported as `finalizeSchema()`) is called. When this method is called, we're
|
||||
saying "we are not going to add any more schemas; go ahead and create `ArgSpec` objects and
|
||||
register schemas with `ajv`".
|
||||
在调用 `finalize()` 方法(导出为 `finalizeSchema()`)之前,`AppiumSchema` 实例不会与 `Ajv` 实例产生交互。此方法的调用标志着"模式定义阶段结束,将开始创建 `ArgSpec` 对象并向 `ajv` 注册最终模式"。
|
||||
|
||||
When does finalization happen? Well:
|
||||
最终化触发的时机如下:
|
||||
|
||||
1. When the `appium` executable begins, it _checks for and configures extensions_ (hand-wave) in `APPIUM_HOME`.
|
||||
2. Only then does it start to think about arguments--it instantiates an `ArgParser`, which (as you'll recall) runs the adapter to convert the schema to arguments.
|
||||
3. _Finalization happens here_--when creating the parser. Appium need the schema(s) to be registered with `ajv` in order to create validation functions for arguments.
|
||||
4. Thereafter, Appium parses the arguments with the `ArgParser`.
|
||||
5. Finally, decides what to do with the returned object.
|
||||
1. 当 `appium` 可执行文件启动时,首先在 `APPIUM_HOME` 目录中检查并配置扩展(此处简化处理)
|
||||
2. 随后开始处理参数——实例化 `ArgParser`,该操作会运行适配器将模式转换为参数定义
|
||||
3. 最终化在此处发生:创建解析器时,Appium 需要向 `ajv` 注册模式以生成参数验证函数
|
||||
4. 通过 `ArgParser`完成参数解析
|
||||
5. 最终根据解析结果决定后续操作流程
|
||||
|
||||
Without extensions, `finalize()` still knows about the Appium base schema
|
||||
(`appium-config-schema.js`), and just registers that. However, step 1. above is doing a _lot of
|
||||
work_, so let's look at how extensions come into play.
|
||||
即使没有扩展功能,`finalize()` 仍会识别 Appium 的基础模式(`appium-config-schema.js`)并进行注册。不过上述步骤 1 实际涉及复杂的扩展处理机制,接下来我们将深入探讨扩展功能的影响。
|
||||
|
||||
## Extension Support
|
||||
## 扩展支持
|
||||
|
||||
One of the design goals of this system is the following:
|
||||
本系统的设计目标之一是:
|
||||
|
||||
_An extension should be able to register custom CLI arguments with the Appium, and a user should be
|
||||
able to use them like any other argument_.
|
||||
扩展应该能够向Appium注册自定义CLI参数,用户应该能够像使用其他参数一样使用它们。
|
||||
|
||||
Previously, Appium 2 accepted arguments in this manner (via `--driverArgs`), but validation was
|
||||
hand-rolled and required extension implementors to use a custom API. It also required the user to
|
||||
awkwardly pass a JSON string as the configuration on the command-line. Further, no contextual help
|
||||
(via `--help`) existed for these arguments.
|
||||
此前,Appium 2通过`--driverArgs`方式接受参数,但验证过程需要手动实现,并要求扩展开发者使用自定义API。这种方式还要求用户在命令行中笨拙地传递JSON字符串作为配置。此外,这些参数没有上下文帮助信息(通过`--help`)。
|
||||
|
||||
Now, by providing a schema for its options, a driver or plugin can register CLI arguments and
|
||||
config file schemas with Appium.
|
||||
现在,通过为选项提供模式(schema),驱动或插件可以向Appium注册CLI参数和配置文件模式。
|
||||
|
||||
To register a schema, an extension must provide the `appium.schema` property in its `package.json`.
|
||||
The value may be a schema or a path to a schema. If the latter, the schema should be JSON or
|
||||
a CommonJS module (ESM not supported at this time, nor is YAML).
|
||||
要注册模式,扩展必须在其`package.json`中提供`appium.schema`属性。该值可以是模式本身或模式文件的路径。如果是路径,模式文件应为JSON或CommonJS模块(目前不支持ESM和YAML)。
|
||||
|
||||
For any property in this schema, the property will appear as a CLI argument of the form
|
||||
`--<extension-type>-<extension-name>-<property-name>`. For example, if the `fake` driver provides
|
||||
a property `foo`, the argument will be `--driver-fake-foo`, and will show in `appium server --help`
|
||||
like any other CLI argument.
|
||||
对于该模式中的任何属性,都将以`--<扩展类型>-<扩展名称>-<属性名称>`的形式作为CLI参数出现。例如,如果`fake`驱动提供了`foo`属性,对应的参数将是`--driver-fake-foo`,并会像其他CLI参数一样显示在`appium server --help`中。
|
||||
|
||||
The corresponding property in a config file would be
|
||||
`server.<extension-type>.<extension-name>.<property-name>`, e.g.:
|
||||
配置文件中对应的属性路径为`server.<扩展类型>.<扩展名称>.<属性名称>`,例如:
|
||||
|
||||
```json
|
||||
{
|
||||
@@ -315,47 +275,35 @@ The corresponding property in a config file would be
|
||||
}
|
||||
```
|
||||
|
||||
The naming convention described above avoids problems of one extension type having a name conflict
|
||||
with a different extension type.
|
||||
上述命名约定避免了不同扩展类型之间的名称冲突问题。
|
||||
|
||||
!!! 注意
|
||||
|
||||
While an extension can provide aliases via `appiumCliAliases`, "short" flags are disallowed,
|
||||
since all arguments from extensions are prefixed with `--<extension-type>-<extension-name>-`.
|
||||
The extension name and argument name will be kebab-cased for the CLI, according to [Lodash's
|
||||
rules](https://lodash.com/docs/4.17.15#kebabCase) around kebab-casing.
|
||||
虽然扩展可以通过`appiumCliAliases`提供别名,但禁止使用"短"标志(short flags),因为所有扩展参数都带有`--<扩展类型>-<扩展名称>-`前缀。根据[Lodash的kebab-case规则](https://lodash.com/docs/4.17.15#kebabCase),扩展名称和参数名称在CLI中将被转换为kebab-case格式。
|
||||
|
||||
The schema object will look much like Appium's base schema, but it will only have top-level
|
||||
properties (nested properties are currently unsupported). Example:
|
||||
模式对象的结构与Appium基础模式相似,但仅支持顶层属性(目前不支持嵌套属性)。示例:
|
||||
|
||||
```json
|
||||
{
|
||||
"title": "my rad schema for the cowabunga driver",
|
||||
"title": "为cowabunga驱动设计的超棒模式",
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"fizz": {
|
||||
"type": "string",
|
||||
"default": "buzz",
|
||||
"$comment": "corresponds to CLI --driver-cowabunga-fizz"
|
||||
"$comment": "对应CLI参数--driver-cowabunga-fizz"
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
As written in a user's config file, this would be the `server.driver.cowabunga.fizz` property.
|
||||
在用户的配置文件中,该属性将表示为`server.driver.cowabunga.fizz`。
|
||||
|
||||
When extensions are loaded, the `schema` property is verified and the schema is registered with the
|
||||
`AppiumSchema` (it is _not_ registered with `Ajv` until `finalize()` is called).
|
||||
当扩展被加载时,`schema`属性会被验证,并且模式会被注册到`AppiumSchema`中(在调用`finalize()`之前不会注册到`Ajv`)。
|
||||
|
||||
During finalization, each registered schema is added to the `Ajv` instance. The schema is assigned
|
||||
an `$id` based on the extension type and name (which overrides whatever the extension provides, if
|
||||
anything). Schemas are also forced to disallowed unknown arguments via the `additionalProperties:
|
||||
false` keyword.
|
||||
在最终化阶段,每个注册的模式都会被添加到`Ajv`实例中。模式会根据扩展类型和名称分配一个`$id`(这会覆盖扩展可能提供的任何现有ID)。模式还会通过`additionalProperties: false`强制禁止未知参数。
|
||||
|
||||
Behind the scenes, the base schema has `driver` and `plugin` properties which are objects. When
|
||||
finalized, a property is added to each--corresponding to an extension name--and the value of this
|
||||
property is a reference to the `$id` of a property in the extension schema. For example, the
|
||||
`server.driver` property will look like this:
|
||||
在底层实现中,基础模式包含`driver`和`plugin`属性(都是对象类型)。最终化时,会为每个属性添加对应扩展名称的子属性,其值是对扩展模式中`$id`的引用。例如,`server.driver`属性将如下所示:
|
||||
|
||||
```json
|
||||
{
|
||||
@@ -367,45 +315,30 @@ property is a reference to the `$id` of a property in the extension schema. For
|
||||
}
|
||||
```
|
||||
|
||||
This is why we call it the "base" schema--it is _mutated_ when extensions provide schemas. The
|
||||
extension schemas are kept separately, but the _references_ are added to the schema before it's
|
||||
ultimately added to `ajv`. This works because an `Ajv` instance understands references _from_ any
|
||||
schema it knows about _to_ any schema it knows about.
|
||||
这就是为什么我们称之为“基础”模式——当扩展提供模式时,它会发生变化。扩展模式是分开保存的,但在最终将其添加到`ajv`之前,会将引用添加到模式中。这是有效的,因为`Ajv`实例能够理解已注册模式之间的相互引用。
|
||||
|
||||
!!! 注意
|
||||
|
||||
This makes it impossible to provide a complete static schema for Appium _and_ the installed
|
||||
extensions (as of Nov 5 2021). A static `.json` schema _is_ generated from the base (via a Gulp
|
||||
task), but it does not contain any extension schemas. The static schema also has uses beyond
|
||||
Appium; e.g., IDEs can provide contextual error-checking of config files this way. Let's solve
|
||||
this?
|
||||
这使得为Appium及其安装的扩展提供完整的静态模式变得不可能(截至2021年11月5日)。基础模式会通过Gulp任务生成静态`.json`模式文件,但不包含任何扩展模式。这种静态模式还有其他用途,例如IDE可以通过这种方式提供配置文件的上下文错误检查。这个问题需要后续解决?
|
||||
|
||||
Just like how we look up the reference ID of a particular argument in the base schema, validation
|
||||
of arguments from extensions happens the exact same way. If the `cowabunga` driver has the schema
|
||||
ID `driver-cowabunga.json`, then the `fizz` property can be referenced from any schema registered
|
||||
with `ajv` via `driver-cowabunga.json#/properties/fizz`. "Base" schema arguments begin with
|
||||
`appium.json#properties/` instead.
|
||||
与在基础模式中查找参数的引用ID方式相同,扩展参数的验证过程完全一致。如果`cowabunga`驱动的模式ID是`driver-cowabunga.json`,那么`fizz`属性可以通过`driver-cowabunga.json#/properties/fizz`路径在任意已注册模式中被引用。“基础”模式参数的引用路径则以`appium.json#properties/`开头。
|
||||
|
||||
## Development Environment Support
|
||||
## 开发环境支持
|
||||
|
||||
During the flow of development, a couple extra tasks have been automated to maintain the base
|
||||
schema:
|
||||
在开发流程中,我们自动化了以下几个任务来维护基础模式:
|
||||
|
||||
- As a post-transpilation step, a `lib/appium-config.schema.json` gets generated from
|
||||
- `lib/schema/appium-config-schema.js` (in addition to its CJS counterpart generated by Babel).
|
||||
- This file is under version control. It ends up being _copied_ to
|
||||
- `build/lib/appium-config.schema.json` in this step. A pre-commit hook (see
|
||||
- `scripts/generate-schema-declarations.js` in the root monorepo) generates
|
||||
- a `types/appium-config-schema.d.ts` from the above JSON file. The types in `types/types.d.ts`
|
||||
- depend upon this file. This file is under version control.
|
||||
- 作为后置转译步骤,会从 `lib/schema/appium-config-schema.js` 生成 `lib/appium-config.schema.json`(除了 Babel 生成的 CJS 对应文件外)
|
||||
- 该文件受版本控制管理。在此步骤中会被复制到 `build/lib/appium-config.schema.json`
|
||||
- 通过预提交钩子(参见 monorepo 根目录的 `scripts/generate-schema-declarations.js`)会从上述 JSON 文件生成 `types/appium-config-schema.d.ts`
|
||||
- `types/types.d.ts` 中的类型定义依赖此文件,该文件受版本控制管理
|
||||
|
||||
## Custom Keyword Reference
|
||||
## 自定义关键字参考
|
||||
|
||||
Keywords are defined in `lib/schema/keywords.js`.
|
||||
关键字定义于 `lib/schema/keywords.js`
|
||||
|
||||
- `appiumCliAliases`: allows a schema to express aliases (e.g., a CLI argument can be `--verbose` or `-v`). This is an array of strings. Strings shorter than three (3) characters will begin with a single dash (`-`) instead of a double-dash (`--`). Note that any argument provided by an extension will begin with a double-dash, because these are required to have the `--<extension-type>-<extension-name>-` prefix.
|
||||
- `appiumCliDest`: allows a schema to specify a custom property name in the post-`argprase` arguments objects. If not set, this becomes a camelCased string.
|
||||
- `appiumCliDescription`: allows a schema to override the description of the argument when displayed on the command-line. This is useful paired with `appiumCliTransformer` (or `array`/`object`-typed properties), since there's a substantial difference between what a CLI-using user can provide vs. what a config-file-using user can provide.
|
||||
- `appiumCliTransformer`: currently a choice between `csv` and `json`. These are custom functions which post-process a value. They are not used when loading & validating config files, but the idea should be that they result in the same object you'd get if you used whatever the config file wanted (e.g., an array of strings). `csv` is for comma-delimited strings and CSV files; `json` is for raw JSON strings and `.json` files.
|
||||
- `appiumCliIgnore`: If `true`, do not support this property on the CLI.
|
||||
- `appiumDeprecated`: If `true`, the property is considered "deprecated", and will be displayed as such to the user (e.g., in the `--help` output). Note the JSON Schema draft-2019-09 introduces a new keyword `deprecated` which we should use instead if upgrading to this metaschema. When doing so, `appiumDeprecated` should itself be marked as `deprecated`.
|
||||
- `appiumCliAliases`: 允许模式声明参数别名(例如 CLI 参数可以是 `--verbose` 或 `-v`)。值为字符串数组。短于三(3)个字符的字符串将使用单短横线(`-`)而非双短横线(`--`)开头。注意任何由扩展提供的参数都必须以双短横线开头,因为这些参数需要带有 `--<extension-type>-<extension-name>-` 前缀
|
||||
- `appiumCliDest`: 允许模式指定 `argparse` 解析后参数对象中的自定义属性名。若未设置,将转换为驼峰式命名
|
||||
- `appiumCliDescription`: 允许模式覆盖命令行显示的参数描述。与 `appiumCliTransformer`(或 `array`/`object` 类型属性)配合使用时非常有用,因为 CLI 用户可提供的内容与配置文件用户可提供的内容存在显著差异
|
||||
- `appiumCliTransformer`: 目前支持 `csv` 和 `json` 两种选项。这些是用于后处理值的自定义函数。在加载和验证配置文件时不使用这些转换器,但核心思想是它们应该产生与使用配置文件相同的对象(例如字符串数组)。`csv` 用于逗号分隔字符串和 CSV 文件;`json` 用于原始 JSON 字符串和 `.json` 文件
|
||||
- `appiumCliIgnore`: 若为 `true`,则不在 CLI 中支持该属性
|
||||
- `appiumDeprecated`: 若为 `true`,该属性将被视为"已弃用",并会向用户显示为弃用状态(例如在 `--help` 输出中)。注意 JSON Schema draft-2019-09 引入了新的 `deprecated` 关键字,如果我们升级到该元模式应该改用此关键字。迁移时,`appiumDeprecated` 本身应被标记为 `deprecated`
|
||||
@@ -43,6 +43,7 @@ appium driver install <驱动名称>
|
||||
|[Tizen](https://github.com/Samsung/appium-tizen-driver)|`--source=npm appium-tizen-driver`|Android|Native|Community / Samsung|
|
||||
|[TizenTV](https://github.com/headspinio/appium-tizen-tv-driver)|`--source=npm appium-tizen-tv-driver`|Samsung TV|Web|HeadSpin|
|
||||
|[Youi](https://github.com/YOU-i-Labs/appium-youiengine-driver)|`--source=npm appium-youiengine-driver`|iOS, Android, macOS, Linux, tvOS|Native|Community / You.i|
|
||||
|[NovaWindows](https://github.com/AutomateThePlanet/appium-novawindows-driver)|`--source=npm appium-novawindows-driver`|Windows|Native|Community / Automate The Planet|
|
||||
|
||||
!!! 注意
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "appium",
|
||||
"version": "2.17.0",
|
||||
"version": "2.18.0",
|
||||
"description": "Automation for Apps.",
|
||||
"keywords": [
|
||||
"automation",
|
||||
@@ -60,20 +60,20 @@
|
||||
"test:unit": "mocha \"./test/unit/**/*.spec.js\""
|
||||
},
|
||||
"dependencies": {
|
||||
"@appium/base-driver": "^9.16.3",
|
||||
"@appium/base-plugin": "^2.3.4",
|
||||
"@appium/docutils": "^1.0.33",
|
||||
"@appium/logger": "^1.6.1",
|
||||
"@appium/base-driver": "^9.17.0",
|
||||
"@appium/base-plugin": "^2.3.6",
|
||||
"@appium/docutils": "^1.1.0",
|
||||
"@appium/logger": "^1.7.0",
|
||||
"@appium/schema": "^0.8.1",
|
||||
"@appium/support": "^6.0.7",
|
||||
"@appium/types": "^0.25.2",
|
||||
"@appium/support": "^6.1.0",
|
||||
"@appium/types": "^0.25.3",
|
||||
"@sidvind/better-ajv-errors": "3.0.1",
|
||||
"ajv": "8.17.1",
|
||||
"ajv-formats": "3.0.1",
|
||||
"argparse": "2.0.1",
|
||||
"async-lock": "1.4.1",
|
||||
"asyncbox": "3.0.0",
|
||||
"axios": "1.8.2",
|
||||
"axios": "1.8.4",
|
||||
"bluebird": "3.7.2",
|
||||
"lilconfig": "3.1.3",
|
||||
"lodash": "4.17.21",
|
||||
@@ -84,11 +84,11 @@
|
||||
"semver": "7.7.1",
|
||||
"source-map-support": "0.5.21",
|
||||
"teen_process": "2.3.1",
|
||||
"type-fest": "4.37.0",
|
||||
"type-fest": "4.40.0",
|
||||
"winston": "3.17.0",
|
||||
"wrap-ansi": "7.0.0",
|
||||
"ws": "8.18.1",
|
||||
"yaml": "2.7.0"
|
||||
"yaml": "2.7.1"
|
||||
},
|
||||
"engines": {
|
||||
"node": "^14.17.0 || ^16.13.0 || >=18.0.0",
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
{
|
||||
"devDependencies": {
|
||||
"webdriverio": "9.10.1"
|
||||
"webdriverio": "9.12.7"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -287,7 +287,7 @@ describe('FakeDriver via HTTP', function () {
|
||||
should.exist(driver.sessionId);
|
||||
driver.sessionId.should.be.a('string');
|
||||
await driver.deleteSession();
|
||||
await driver.getTitle().should.eventually.be.rejectedWith(/terminated/);
|
||||
await driver.getTitle().should.eventually.be.rejected;
|
||||
});
|
||||
|
||||
it('should be able to run two FakeDriver sessions simultaneously', async function () {
|
||||
|
||||
@@ -3,6 +3,25 @@
|
||||
All notable changes to this project will be documented in this file.
|
||||
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
||||
|
||||
## [9.17.0](https://github.com/appium/appium/compare/@appium/base-driver@9.16.4...@appium/base-driver@9.17.0) (2025-04-25)
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* Add a possibility to mask sensitive log values depending on request headers ([#21123](https://github.com/appium/appium/issues/21123)) ([c24d2ac](https://github.com/appium/appium/commit/c24d2ac46123f41ee9b54e0adefacfabd149089c))
|
||||
* **base-driver:** Accept `x-request-id` as override to generated requestId in `handleLogContext` ([#21154](https://github.com/appium/appium/issues/21154)) ([a82476f](https://github.com/appium/appium/commit/a82476f2fcb4aa3a3c4660d96fdd261a98afa4af))
|
||||
|
||||
|
||||
|
||||
## [9.16.4](https://github.com/appium/appium/compare/@appium/base-driver@9.16.3...@appium/base-driver@9.16.4) (2025-03-17)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* **base-driver:** Exclude proxied headers from the server response ([#21120](https://github.com/appium/appium/issues/21120)) ([f800c9d](https://github.com/appium/appium/commit/f800c9d760ab3271532c42a507fbaf2bf190fc4b))
|
||||
|
||||
|
||||
|
||||
## [9.16.3](https://github.com/appium/appium/compare/@appium/base-driver@9.16.2...@appium/base-driver@9.16.3) (2025-03-11)
|
||||
|
||||
|
||||
|
||||
@@ -78,12 +78,17 @@ export function fixPythonContentType(basePath) {
|
||||
* @returns {any}
|
||||
*/
|
||||
export function handleLogContext(req, res, next) {
|
||||
const requestId = util.uuidV4();
|
||||
const requestId = fetchHeaderValue(req, 'x-request-id') || util.uuidV4();
|
||||
|
||||
const sessionId = SESSION_ID_PATTERN.exec(req.url)?.[1];
|
||||
const sessionInfo = sessionId ? {sessionId, sessionSignature: calcSignature(sessionId)} : {};
|
||||
const isSensitiveHeaderValue = fetchHeaderValue(req, 'x-appium-is-sensitive');
|
||||
|
||||
log.updateAsyncContext({requestId, ...sessionInfo}, true);
|
||||
log.updateAsyncContext({
|
||||
requestId,
|
||||
...sessionInfo,
|
||||
isSensitive: ['true', '1', 'yes'].includes(_.toLower(isSensitiveHeaderValue)),
|
||||
}, true);
|
||||
|
||||
return next();
|
||||
}
|
||||
@@ -181,6 +186,11 @@ export function catch404Handler(req, res) {
|
||||
|
||||
const SESSION_ID_PATTERN = /\/session\/([^/]+)/;
|
||||
|
||||
/**
|
||||
* @param {import('express').Request} req
|
||||
* @param {any} body
|
||||
* @returns {any}
|
||||
*/
|
||||
function patchWithSessionId(req, body) {
|
||||
const match = SESSION_ID_PATTERN.exec(req.url);
|
||||
if (match) {
|
||||
@@ -188,3 +198,14 @@ function patchWithSessionId(req, body) {
|
||||
}
|
||||
return body;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {import('express').Request} req
|
||||
* @param {string} name
|
||||
* @returns {string | undefined}
|
||||
*/
|
||||
function fetchHeaderValue(req, name) {
|
||||
return _.isArray(req.headers[name])
|
||||
? req.headers[name][0]
|
||||
: req.headers[name];
|
||||
}
|
||||
|
||||
@@ -428,18 +428,13 @@ export class JWProxy {
|
||||
/** @type {import('@appium/types').HTTPMethod} */ (req.method),
|
||||
req.body
|
||||
);
|
||||
for (const [name, value] of _.toPairs(response.headers)) {
|
||||
if (!_.isNil(value)) {
|
||||
res.setHeader(name, _.isBoolean(value) ? String(value) : value);
|
||||
}
|
||||
}
|
||||
statusCode = response.statusCode;
|
||||
} catch (err) {
|
||||
[statusCode, resBodyObj] = getResponseForW3CError(
|
||||
isErrorType(err, errors.ProxyRequestError) ? err.getActualError() : err
|
||||
);
|
||||
}
|
||||
res.set('content-type', 'application/json; charset=utf-8');
|
||||
res.setHeader('content-type', 'application/json; charset=utf-8');
|
||||
if (!_.isPlainObject(resBodyObj)) {
|
||||
const error = new errors.UnknownError(
|
||||
`The downstream server response with the status code ${statusCode} is not a valid JSON object: ` +
|
||||
|
||||
@@ -12,7 +12,13 @@ import {
|
||||
validateExecuteMethodParams,
|
||||
} from './protocol';
|
||||
import {NO_SESSION_ID_COMMANDS, ALL_COMMANDS, METHOD_MAP, routeToCommandName} from './routes';
|
||||
import {errors, isErrorType, errorFromMJSONWPStatusCode, errorFromW3CJsonCode} from './errors';
|
||||
import {
|
||||
errors,
|
||||
isErrorType,
|
||||
errorFromMJSONWPStatusCode,
|
||||
errorFromW3CJsonCode,
|
||||
getResponseForW3CError,
|
||||
} from './errors';
|
||||
|
||||
export {
|
||||
routeConfiguringFunction,
|
||||
@@ -34,4 +40,5 @@ export {
|
||||
GET_STATUS_COMMAND,
|
||||
LIST_DRIVER_COMMANDS_COMMAND,
|
||||
LIST_DRIVER_EXTENSIONS_COMMAND,
|
||||
getResponseForW3CError,
|
||||
};
|
||||
|
||||
@@ -304,19 +304,23 @@ export const METHOD_MAP = /** @type {const} */ ({
|
||||
// Appium specific
|
||||
//
|
||||
'/session/:sessionId/ime/available_engines': {
|
||||
GET: {command: 'availableIMEEngines'},
|
||||
GET: {command: 'availableIMEEngines', deprecated: true},
|
||||
},
|
||||
'/session/:sessionId/ime/active_engine': {
|
||||
GET: {command: 'getActiveIMEEngine'},
|
||||
GET: {command: 'getActiveIMEEngine', deprecated: true},
|
||||
},
|
||||
'/session/:sessionId/ime/activated': {
|
||||
GET: {command: 'isIMEActivated'},
|
||||
GET: {command: 'isIMEActivated', deprecated: true},
|
||||
},
|
||||
'/session/:sessionId/ime/deactivate': {
|
||||
POST: {command: 'deactivateIMEEngine'},
|
||||
POST: {command: 'deactivateIMEEngine', deprecated: true},
|
||||
},
|
||||
'/session/:sessionId/ime/activate': {
|
||||
POST: {command: 'activateIMEEngine', payloadParams: {required: ['engine']}},
|
||||
POST: {
|
||||
command: 'activateIMEEngine',
|
||||
payloadParams: {required: ['engine']},
|
||||
deprecated: true,
|
||||
},
|
||||
},
|
||||
'/session/:sessionId/rotation': {
|
||||
GET: {command: 'getRotation'},
|
||||
@@ -341,16 +345,18 @@ export const METHOD_MAP = /** @type {const} */ ({
|
||||
GET: {command: 'getContexts'},
|
||||
},
|
||||
'/session/:sessionId/network_connection': {
|
||||
GET: {command: 'getNetworkConnection'},
|
||||
GET: {command: 'getNetworkConnection', deprecated: true},
|
||||
POST: {
|
||||
command: 'setNetworkConnection',
|
||||
payloadParams: {unwrap: 'parameters', required: ['type']},
|
||||
deprecated: true,
|
||||
},
|
||||
},
|
||||
'/session/:sessionId/receive_async_response': {
|
||||
POST: {
|
||||
command: 'receiveAsyncResponse',
|
||||
payloadParams: {required: ['status', 'value']},
|
||||
deprecated: true,
|
||||
},
|
||||
},
|
||||
'/appium/sessions': {
|
||||
|
||||
@@ -10,6 +10,9 @@ function msValidator(ms) {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated
|
||||
*/
|
||||
const validators = {
|
||||
setUrl: (url) => {
|
||||
// either an `xyz://`, `about:`, or `data:` scheme is allowed
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@appium/base-driver",
|
||||
"version": "9.16.3",
|
||||
"version": "9.17.0",
|
||||
"description": "Base driver class for Appium drivers",
|
||||
"keywords": [
|
||||
"automation",
|
||||
@@ -44,12 +44,12 @@
|
||||
"test:types": "tsd"
|
||||
},
|
||||
"dependencies": {
|
||||
"@appium/support": "^6.0.7",
|
||||
"@appium/types": "^0.25.2",
|
||||
"@appium/support": "^6.1.0",
|
||||
"@appium/types": "^0.25.3",
|
||||
"@colors/colors": "1.6.0",
|
||||
"async-lock": "1.4.1",
|
||||
"asyncbox": "3.0.0",
|
||||
"axios": "1.8.2",
|
||||
"axios": "1.8.4",
|
||||
"bluebird": "3.7.2",
|
||||
"body-parser": "1.20.3",
|
||||
"express": "4.21.2",
|
||||
@@ -62,7 +62,7 @@
|
||||
"path-to-regexp": "8.2.0",
|
||||
"serve-favicon": "2.5.0",
|
||||
"source-map-support": "0.5.21",
|
||||
"type-fest": "4.37.0",
|
||||
"type-fest": "4.40.0",
|
||||
"validate.js": "0.13.1"
|
||||
},
|
||||
"optionalDependencies": {
|
||||
|
||||
@@ -1,4 +1,7 @@
|
||||
import {match} from 'path-to-regexp';
|
||||
import sinon from 'sinon';
|
||||
import log from '../../../lib/express/logger';
|
||||
import {handleLogContext} from '../../../lib/express/middleware';
|
||||
|
||||
describe('middleware', function () {
|
||||
before(async function () {
|
||||
@@ -21,4 +24,55 @@ describe('middleware', function () {
|
||||
match(pathname)(currentPathname).should.not.be.false;
|
||||
});
|
||||
});
|
||||
|
||||
describe('handleLogContext', function () {
|
||||
let req, res, next, updateAsyncContextStub;
|
||||
|
||||
beforeEach(function () {
|
||||
req = {
|
||||
headers: {},
|
||||
url: '/some/path'
|
||||
};
|
||||
res = {};
|
||||
next = sinon.spy();
|
||||
updateAsyncContextStub = sinon.stub(log, 'updateAsyncContext');
|
||||
});
|
||||
|
||||
afterEach(function () {
|
||||
updateAsyncContextStub.restore();
|
||||
});
|
||||
|
||||
it('should use provided x-request-id header', function () {
|
||||
const testRequestId = '123-test-id';
|
||||
req.headers['x-request-id'] = testRequestId;
|
||||
|
||||
handleLogContext(req, res, next);
|
||||
|
||||
updateAsyncContextStub.calledOnce.should.be.true;
|
||||
updateAsyncContextStub.firstCall.args[0].should.have.property('requestId', testRequestId);
|
||||
next.calledOnce.should.be.true;
|
||||
});
|
||||
|
||||
it('should handle x-request-id when provided as array', function () {
|
||||
const testRequestId = '123-test-id';
|
||||
req.headers['x-request-id'] = [testRequestId, 'ignored-id'];
|
||||
|
||||
handleLogContext(req, res, next);
|
||||
|
||||
updateAsyncContextStub.calledOnce.should.be.true;
|
||||
updateAsyncContextStub.firstCall.args[0].should.have.property('requestId', testRequestId);
|
||||
next.calledOnce.should.be.true;
|
||||
});
|
||||
|
||||
it('should generate uuid when x-request-id is not provided', function () {
|
||||
handleLogContext(req, res, next);
|
||||
|
||||
updateAsyncContextStub.calledOnce.should.be.true;
|
||||
updateAsyncContextStub.firstCall.args[0].should.have.property('requestId');
|
||||
updateAsyncContextStub.firstCall.args[0].requestId.should.match(
|
||||
/^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i
|
||||
);
|
||||
next.calledOnce.should.be.true;
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -7,9 +7,6 @@ function buildReqRes(url, method, body) {
|
||||
let req = {originalUrl: url, method, body};
|
||||
let res = {};
|
||||
res.headers = {};
|
||||
res.set = (k, v) => {
|
||||
res[k] = v;
|
||||
};
|
||||
res.setHeader = (k, v) => {
|
||||
res.headers[k] = v;
|
||||
};
|
||||
|
||||
@@ -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.
|
||||
|
||||
## [2.3.6](https://github.com/appium/appium/compare/@appium/base-plugin@2.3.5...@appium/base-plugin@2.3.6) (2025-04-25)
|
||||
|
||||
**Note:** Version bump only for package @appium/base-plugin
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
## [2.3.5](https://github.com/appium/appium/compare/@appium/base-plugin@2.3.4...@appium/base-plugin@2.3.5) (2025-03-17)
|
||||
|
||||
**Note:** Version bump only for package @appium/base-plugin
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
## [2.3.4](https://github.com/appium/appium/compare/@appium/base-plugin@2.3.3...@appium/base-plugin@2.3.4) (2025-03-11)
|
||||
|
||||
**Note:** Version bump only for package @appium/base-plugin
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@appium/base-plugin",
|
||||
"version": "2.3.4",
|
||||
"version": "2.3.6",
|
||||
"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.16.3",
|
||||
"@appium/support": "^6.0.7"
|
||||
"@appium/base-driver": "^9.17.0",
|
||||
"@appium/support": "^6.1.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": "^14.17.0 || ^16.13.0 || >=18.0.0",
|
||||
|
||||
@@ -3,6 +3,28 @@
|
||||
All notable changes to this project will be documented in this file.
|
||||
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
||||
|
||||
## [1.1.0](https://github.com/appium/appium/compare/@appium/docutils@1.0.34...@appium/docutils@1.1.0) (2025-04-25)
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* **docutils:** add MkDocs Material codeblock & text format features ([#21184](https://github.com/appium/appium/issues/21184)) ([55da22f](https://github.com/appium/appium/commit/55da22fc4000a1142782cc5fddcb526cb30b2f09))
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* **docutils:** add & adjust various log messages ([#21160](https://github.com/appium/appium/issues/21160)) ([804b1a3](https://github.com/appium/appium/commit/804b1a3c15acdf95066d45e7c36518cb8600dbbb))
|
||||
|
||||
|
||||
|
||||
## [1.0.34](https://github.com/appium/appium/compare/@appium/docutils@1.0.33...@appium/docutils@1.0.34) (2025-03-17)
|
||||
|
||||
**Note:** Version bump only for package @appium/docutils
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
## [1.0.33](https://github.com/appium/appium/compare/@appium/docutils@1.0.32...@appium/docutils@1.0.33) (2025-03-11)
|
||||
|
||||
**Note:** Version bump only for package @appium/docutils
|
||||
|
||||
@@ -1,20 +1,30 @@
|
||||
markdown_extensions:
|
||||
- meta
|
||||
- attr_list
|
||||
- admonition
|
||||
- attr_list
|
||||
- footnotes
|
||||
- md_in_html
|
||||
- pymdownx.highlight:
|
||||
anchor_linenums: true
|
||||
- pymdownx.inlinehilite
|
||||
- pymdownx.snippets
|
||||
- pymdownx.superfences
|
||||
- meta
|
||||
- pymdownx.caret
|
||||
- pymdownx.critic
|
||||
- pymdownx.details
|
||||
- pymdownx.tabbed:
|
||||
alternate_style: true
|
||||
- pymdownx.emoji:
|
||||
emoji_index: !!python/name:material.extensions.emoji.twemoji
|
||||
emoji_generator: !!python/name:material.extensions.emoji.to_svg
|
||||
- footnotes
|
||||
- pymdownx.highlight:
|
||||
anchor_linenums: true
|
||||
line_spans: __span
|
||||
pygments_lang_class: true
|
||||
- pymdownx.inlinehilite
|
||||
- pymdownx.keys
|
||||
- pymdownx.mark
|
||||
- pymdownx.snippets
|
||||
- pymdownx.superfences
|
||||
- pymdownx.tabbed:
|
||||
alternate_style: true
|
||||
- pymdownx.tasklist:
|
||||
custom_checkbox: true
|
||||
- pymdownx.tilde
|
||||
- tables
|
||||
- toc:
|
||||
permalink: true
|
||||
|
||||
@@ -63,6 +73,9 @@ theme:
|
||||
quote: octicons/quote-16
|
||||
features:
|
||||
- content.action.edit
|
||||
- content.code.annotate
|
||||
- content.code.copy
|
||||
- content.tabs.link
|
||||
- navigation.sections
|
||||
- navigation.tabs
|
||||
- navigation.top
|
||||
|
||||
@@ -16,10 +16,9 @@ import {
|
||||
NAME_BIN,
|
||||
NAME_MIKE,
|
||||
NAME_MKDOCS_YML,
|
||||
NAME_PYTHON,
|
||||
} from '../constants';
|
||||
import {DocutilsError} from '../error';
|
||||
import {findMike, findMkDocsYml, findPython, readPackageJson} from '../fs';
|
||||
import {findMike, findMkDocsYml, isMkDocsInstalled, readPackageJson, requirePython} from '../fs';
|
||||
import {getLogger} from '../logger';
|
||||
import {argify, spawnBackgroundProcess, SpawnBackgroundProcessOpts, stopwatch} from '../util';
|
||||
|
||||
@@ -37,6 +36,7 @@ async function doServe(
|
||||
opts: SpawnBackgroundProcessOpts = {},
|
||||
) {
|
||||
const finalArgs = ['serve', ...args];
|
||||
log.debug('Executing %s via: %s %O', NAME_MIKE, mikePath, finalArgs);
|
||||
return spawnBackgroundProcess(mikePath, finalArgs, opts);
|
||||
}
|
||||
|
||||
@@ -99,18 +99,17 @@ export async function deploy({
|
||||
}: DeployOpts = {}) {
|
||||
const stop = stopwatch('deploy');
|
||||
|
||||
const pythonPath = await findPython();
|
||||
await requirePython();
|
||||
|
||||
if (!pythonPath) {
|
||||
throw new DocutilsError(
|
||||
`Could not find ${NAME_PYTHON}3/${NAME_PYTHON} executable in PATH; please install Python v3`,
|
||||
);
|
||||
const mkdocsInstalled = await isMkDocsInstalled();
|
||||
if (!mkdocsInstalled) {
|
||||
throw new DocutilsError(`Could not find MkDocs executable; please run "${NAME_BIN} init"`);
|
||||
}
|
||||
|
||||
mkDocsYmlPath = mkDocsYmlPath ?? (await findMkDocsYml(cwd));
|
||||
if (!mkDocsYmlPath) {
|
||||
throw new DocutilsError(
|
||||
`Could not find ${NAME_MKDOCS_YML} from ${cwd}; run "${NAME_BIN} init" to create it`,
|
||||
`Could not find ${NAME_MKDOCS_YML} from ${cwd}; please run "${NAME_BIN} init"`,
|
||||
);
|
||||
}
|
||||
version = version ?? (await findDeployVersion(packageJsonPath, cwd));
|
||||
|
||||
@@ -7,9 +7,9 @@
|
||||
|
||||
import path from 'node:path';
|
||||
import {exec, TeenProcessExecOptions} from 'teen_process';
|
||||
import {DEFAULT_SITE_DIR, NAME_BIN, NAME_MKDOCS, NAME_MKDOCS_YML, NAME_PYTHON} from '../constants';
|
||||
import {DEFAULT_SITE_DIR, NAME_BIN, NAME_MKDOCS, NAME_MKDOCS_YML} from '../constants';
|
||||
import {DocutilsError} from '../error';
|
||||
import {findMkDocsYml, findPython, readMkDocsYml} from '../fs';
|
||||
import {findMkDocsYml, isMkDocsInstalled, readMkDocsYml, requirePython} from '../fs';
|
||||
import {getLogger} from '../logger';
|
||||
import {relative, spawnBackgroundProcess, SpawnBackgroundProcessOpts, stopwatch} from '../util';
|
||||
|
||||
@@ -58,11 +58,11 @@ export async function buildSite({
|
||||
}: 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`,
|
||||
);
|
||||
const pythonPath = await requirePython();
|
||||
|
||||
const mkdocsInstalled = await isMkDocsInstalled();
|
||||
if (!mkdocsInstalled) {
|
||||
throw new DocutilsError(`Could not find MkDocs executable; please run "${NAME_BIN} init"`);
|
||||
}
|
||||
|
||||
mkDocsYmlPath = mkDocsYmlPath
|
||||
@@ -70,7 +70,7 @@ export async function buildSite({
|
||||
: await findMkDocsYml(cwd);
|
||||
if (!mkDocsYmlPath) {
|
||||
throw new DocutilsError(
|
||||
`Could not find ${NAME_MKDOCS_YML} from ${cwd}; run "${NAME_BIN} init" to create it`,
|
||||
`Could not find ${NAME_MKDOCS_YML} from ${cwd}; please run "${NAME_BIN} init"`,
|
||||
);
|
||||
}
|
||||
const mkdocsArgs = ['-f', mkDocsYmlPath];
|
||||
|
||||
@@ -73,11 +73,6 @@ export const NAME_TYPESCRIPT = 'typescript';
|
||||
*/
|
||||
export const NAME_ERR_ENOENT = 'ENOENT';
|
||||
|
||||
/**
|
||||
* Code for a "file already exists" error
|
||||
*/
|
||||
export const NAME_ERR_EEXIST = 'EEXIST';
|
||||
|
||||
/**
|
||||
* Name of the default theme
|
||||
*/
|
||||
@@ -153,3 +148,8 @@ export const DEFAULT_SITE_DIR = 'site';
|
||||
* To ensure backwards compatibility, its environment variable version is used
|
||||
*/
|
||||
export const PIP_ENV_VARS = {PIP_BREAK_SYSTEM_PACKAGES: '1'};
|
||||
|
||||
/**
|
||||
* Error message emitted when the path to Python was not found
|
||||
*/
|
||||
export const MESSAGE_PYTHON_MISSING = 'Could not find Python in PATH. Is it installed?';
|
||||
|
||||
@@ -11,7 +11,15 @@ import _pkgDir from 'pkg-dir';
|
||||
import readPkg, {NormalizedPackageJson, PackageJson} from 'read-pkg';
|
||||
import {JsonValue} from 'type-fest';
|
||||
import YAML from 'yaml';
|
||||
import {NAME_MIKE, NAME_MKDOCS_YML, NAME_NPM, NAME_PACKAGE_JSON, NAME_PYTHON} from './constants';
|
||||
import {
|
||||
MESSAGE_PYTHON_MISSING,
|
||||
NAME_MIKE,
|
||||
NAME_MKDOCS,
|
||||
NAME_MKDOCS_YML,
|
||||
NAME_NPM,
|
||||
NAME_PACKAGE_JSON,
|
||||
NAME_PYTHON,
|
||||
} from './constants';
|
||||
import {DocutilsError} from './error';
|
||||
import {getLogger} from './logger';
|
||||
import {MkDocsYml} from './model';
|
||||
@@ -152,18 +160,14 @@ export const readJson = _.memoize(
|
||||
);
|
||||
|
||||
/**
|
||||
* Writes a file, but will not overwrite an existing file unless `overwrite` is true
|
||||
*
|
||||
* Will stringify JSON objects
|
||||
* Writes contents to a file. Any JSON objects are stringified
|
||||
* @param filepath - Path to file
|
||||
* @param content - File contents
|
||||
* @param overwrite - If `true`, overwrite existing files
|
||||
*/
|
||||
export function safeWriteFile(filepath: string, content: JsonValue, overwrite = false) {
|
||||
export function writeFileString(filepath: string, content: JsonValue) {
|
||||
const data: string = _.isString(content) ? content : JSON.stringify(content, undefined, 2);
|
||||
return fs.writeFile(filepath, data, {
|
||||
encoding: 'utf8',
|
||||
flag: overwrite ? 'w' : 'wx',
|
||||
});
|
||||
}
|
||||
|
||||
@@ -189,6 +193,28 @@ const whichPython = _.partial(cachedWhich, NAME_PYTHON, {nothrow: true});
|
||||
*/
|
||||
const whichPython3 = _.partial(cachedWhich, `${NAME_PYTHON}3`, {nothrow: true});
|
||||
|
||||
/**
|
||||
* Check if `mkdocs` is installed
|
||||
*/
|
||||
export const isMkDocsInstalled = _.memoize(async (): Promise<boolean> => {
|
||||
// see if it's in PATH
|
||||
const mkDocsPath = await cachedWhich(NAME_MKDOCS, {nothrow: true});
|
||||
if (mkDocsPath) {
|
||||
return true;
|
||||
}
|
||||
// if it isn't, it should be invokable via `python -m`
|
||||
const pythonPath = await findPython();
|
||||
if (!pythonPath) {
|
||||
return false;
|
||||
}
|
||||
try {
|
||||
await exec(pythonPath, ['-m', NAME_MKDOCS]);
|
||||
return true;
|
||||
} catch {
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
/**
|
||||
* `mike` cannot be invoked via `python -m`, so we need to find the script.
|
||||
*/
|
||||
@@ -225,6 +251,17 @@ export const findPython = _.memoize(
|
||||
async (): Promise<string | null> => (await whichPython3()) ?? (await whichPython()),
|
||||
);
|
||||
|
||||
/**
|
||||
* Check if a path to Python exists, otherwise raise DocutilsError
|
||||
*/
|
||||
export async function requirePython(pythonPath?: string): Promise<string> {
|
||||
const foundPythonPath = pythonPath ?? (await findPython());
|
||||
if (!foundPythonPath) {
|
||||
throw new DocutilsError(MESSAGE_PYTHON_MISSING);
|
||||
}
|
||||
return foundPythonPath;
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads an `mkdocs.yml` file, merges inherited configs, and returns the result. The result is cached.
|
||||
*
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
*/
|
||||
|
||||
import * as JSON5 from 'json5';
|
||||
import {NAME_MKDOCS_YML, NAME_TSCONFIG_JSON, NAME_PYTHON, PIP_ENV_VARS, REQUIREMENTS_TXT_PATH} from './constants';
|
||||
import {NAME_MKDOCS_YML, NAME_TSCONFIG_JSON, PIP_ENV_VARS, REQUIREMENTS_TXT_PATH} from './constants';
|
||||
import YAML from 'yaml';
|
||||
import {exec} from 'teen_process';
|
||||
import {Simplify} from 'type-fest';
|
||||
@@ -15,7 +15,7 @@ import type { ScaffoldTask } from './scaffold';
|
||||
import {getLogger} from './logger';
|
||||
import {MkDocsYml, TsConfigJson} from './model';
|
||||
import _ from 'lodash';
|
||||
import {findPython, stringifyJson5, stringifyYaml} from './fs';
|
||||
import {requirePython, stringifyJson5, stringifyYaml} from './fs';
|
||||
|
||||
/**
|
||||
* Data for the base `mkdocs.yml` file
|
||||
@@ -139,7 +139,7 @@ export async function initPython({
|
||||
dryRun = false,
|
||||
upgrade = false,
|
||||
}: InitPythonOptions = {}): Promise<void> {
|
||||
pythonPath = pythonPath ?? (await findPython()) ?? NAME_PYTHON;
|
||||
const foundPythonPath = await requirePython(pythonPath);
|
||||
|
||||
const args = ['-m', 'pip', 'install', '-r', REQUIREMENTS_TXT_PATH];
|
||||
if (upgrade) {
|
||||
@@ -148,19 +148,19 @@ export async function initPython({
|
||||
if (dryRun) {
|
||||
dryRunLog.info(
|
||||
'Would execute command: %s %s (environment variables: %s)',
|
||||
pythonPath,
|
||||
foundPythonPath,
|
||||
args.join(' '),
|
||||
PIP_ENV_VARS,
|
||||
);
|
||||
} else {
|
||||
log.debug('Executing command: %s %s (environment variables: %s)',
|
||||
pythonPath,
|
||||
foundPythonPath,
|
||||
args.join(' '),
|
||||
PIP_ENV_VARS,
|
||||
);
|
||||
log.info('Installing Python dependencies...');
|
||||
try {
|
||||
const result = await exec(pythonPath, args, {env: PIP_ENV_VARS, shell: true});
|
||||
const result = await exec(foundPythonPath, args, {env: PIP_ENV_VARS, shell: true});
|
||||
const {code, stdout} = result;
|
||||
if (code !== 0) {
|
||||
throw new DocutilsError(`Could not install Python dependencies. Reason: ${stdout}`);
|
||||
@@ -171,7 +171,7 @@ export async function initPython({
|
||||
);
|
||||
}
|
||||
}
|
||||
log.success('Installed Python dependencies (or dependencies already installed)');
|
||||
log.success('Successfully installed Python dependencies');
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -12,8 +12,8 @@ import {JsonValue, JsonObject} from 'type-fest';
|
||||
import {DocutilsError} from './error';
|
||||
import {relative} from './util';
|
||||
import _ from 'lodash';
|
||||
import {stringifyJson, readPackageJson, safeWriteFile} from './fs';
|
||||
import {NAME_ERR_ENOENT, NAME_ERR_EEXIST} from './constants';
|
||||
import {stringifyJson, readPackageJson, writeFileString} from './fs';
|
||||
import {NAME_ERR_ENOENT} from './constants';
|
||||
|
||||
const log = getLogger('init');
|
||||
const dryRunLog = getLogger('dry-run', log);
|
||||
@@ -91,7 +91,7 @@ export function createScaffoldTask<Opts extends ScaffoldTaskOptions, T extends J
|
||||
dest = dest ?? path.join(pkgDir, defaultFilename);
|
||||
const relativeDest = relativePath(dest);
|
||||
log.debug('Initializing %s', relativeDest);
|
||||
let shouldWriteDest = false;
|
||||
let destChangesNeeded = false;
|
||||
let isNew = false;
|
||||
let destContent: T;
|
||||
let result: ScaffoldTaskResult<T>;
|
||||
@@ -103,7 +103,7 @@ export function createScaffoldTask<Opts extends ScaffoldTaskOptions, T extends J
|
||||
if (err.code !== NAME_ERR_ENOENT) {
|
||||
throw err;
|
||||
}
|
||||
shouldWriteDest = true;
|
||||
destChangesNeeded = true;
|
||||
log.debug('Creating new file %s', relativeDest);
|
||||
destContent = {} as T;
|
||||
isNew = true;
|
||||
@@ -112,9 +112,9 @@ export function createScaffoldTask<Opts extends ScaffoldTaskOptions, T extends J
|
||||
const defaults: T = transform(defaultContent, opts, pkg);
|
||||
const finalDestContent: T = _.defaultsDeep({}, destContent, defaults);
|
||||
|
||||
shouldWriteDest = shouldWriteDest || !_.isEqual(destContent, finalDestContent);
|
||||
destChangesNeeded = destChangesNeeded || !_.isEqual(destContent, finalDestContent);
|
||||
|
||||
if (shouldWriteDest) {
|
||||
if (destChangesNeeded) {
|
||||
log.info('Changes needed in %s', relativeDest);
|
||||
log.debug('Original %s: %O', relativeDest, destContent);
|
||||
log.debug('Final %s: %O', relativeDest, finalDestContent);
|
||||
@@ -126,20 +126,19 @@ export function createScaffoldTask<Opts extends ScaffoldTaskOptions, T extends J
|
||||
return result;
|
||||
}
|
||||
|
||||
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
|
||||
if (err.code === NAME_ERR_EEXIST) {
|
||||
log.info(`${relativeDest} already exists; continuing...`);
|
||||
log.debug(`Tried to apply patch:\n\n${patch}`);
|
||||
} else {
|
||||
if (!isNew && !overwrite) {
|
||||
log.info('File %s already exists, continuing (enable overwrite with "--force")', relativeDest);
|
||||
log.debug('Tried to apply patch:\n\n%s', patch);
|
||||
} else {
|
||||
try {
|
||||
await writeFileString(dest, finalDestContent);
|
||||
if (isNew) {
|
||||
log.success('Initialized %s', description);
|
||||
} else {
|
||||
log.success('Updated %s', description);
|
||||
}
|
||||
} catch (e) {
|
||||
const err = e as NodeJS.ErrnoException;
|
||||
throw new DocutilsError(`Could not write to ${relativeDest}. Reason: ${err.message}`, {
|
||||
cause: err,
|
||||
});
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
* @module
|
||||
*/
|
||||
|
||||
import {fs, util} from '@appium/support';
|
||||
import {fs, npm, util} from '@appium/support';
|
||||
import chalk from 'chalk';
|
||||
import _ from 'lodash';
|
||||
import {EventEmitter} from 'node:events';
|
||||
@@ -13,6 +13,7 @@ import {satisfies} from 'semver';
|
||||
import {exec} from 'teen_process';
|
||||
import {
|
||||
DOCUTILS_PKG,
|
||||
MESSAGE_PYTHON_MISSING,
|
||||
NAME_BIN,
|
||||
NAME_ERR_ENOENT,
|
||||
NAME_MKDOCS,
|
||||
@@ -27,7 +28,15 @@ import {
|
||||
REQUIREMENTS_TXT_PATH,
|
||||
} from './constants';
|
||||
import {DocutilsError} from './error';
|
||||
import {findMkDocsYml, findPkgDir, readJson5, readMkDocsYml, whichNpm, findPython} from './fs';
|
||||
import {
|
||||
findMkDocsYml,
|
||||
findPkgDir,
|
||||
isMkDocsInstalled,
|
||||
readJson5,
|
||||
readMkDocsYml,
|
||||
whichNpm,
|
||||
findPython,
|
||||
} from './fs';
|
||||
import {getLogger} from './logger';
|
||||
import {MkDocsYml, PipPackage} from './model';
|
||||
import {relative} from './util';
|
||||
@@ -281,12 +290,16 @@ export class DocutilsValidator extends EventEmitter {
|
||||
* Validates that the correct version of `mkdocs` is installed
|
||||
*/
|
||||
protected async validateMkDocs() {
|
||||
const pythonPath = this.pythonPath ?? (await findPython());
|
||||
log.debug(`Validating MkDocs version`);
|
||||
|
||||
const pythonPath = this.pythonPath ?? (await findPython());
|
||||
if (!pythonPath) {
|
||||
return this.fail(
|
||||
`Could not find ${NAME_PYTHON} executable in PATH. If it is installed, check your PATH environment variable.`,
|
||||
);
|
||||
return this.fail(MESSAGE_PYTHON_MISSING);
|
||||
}
|
||||
|
||||
const mkdocsInstalled = await isMkDocsInstalled();
|
||||
if (!mkdocsInstalled) {
|
||||
return this.fail(`Could not find MkDocs executable; please run "${NAME_BIN} init"`);
|
||||
}
|
||||
|
||||
let rawMkDocsVersion: string | undefined;
|
||||
@@ -296,26 +309,21 @@ export class DocutilsValidator extends EventEmitter {
|
||||
return this.fail(`Failed to get MkDocs version: ${err}`);
|
||||
}
|
||||
const match = rawMkDocsVersion.match(MKDOCS_VERSION_REGEX);
|
||||
if (match) {
|
||||
const version = match[1];
|
||||
const reqs = await this.parseRequirementsTxt();
|
||||
const mkDocsPipPkg = _.find(reqs, {name: NAME_MKDOCS});
|
||||
if (!mkDocsPipPkg) {
|
||||
throw new DocutilsError(
|
||||
`No ${NAME_MKDOCS} package in ${REQUIREMENTS_TXT_PATH}. This is a bug.`,
|
||||
);
|
||||
}
|
||||
const {version: mkDocsReqdVersion} = mkDocsPipPkg;
|
||||
if (version !== mkDocsReqdVersion) {
|
||||
return this.fail(
|
||||
`${NAME_MKDOCS} is v${version}, but ${REQUIREMENTS_TXT_PATH} requires v${mkDocsReqdVersion}`,
|
||||
);
|
||||
}
|
||||
} else {
|
||||
if (!match) {
|
||||
return this.fail(`Could not parse MkDocs version. Output was ${rawMkDocsVersion}`);
|
||||
}
|
||||
const version = match[1];
|
||||
const reqs = await this.parseRequirementsTxt();
|
||||
const mkDocsPipPkg = _.find(reqs, {name: NAME_MKDOCS});
|
||||
if (!mkDocsPipPkg) {
|
||||
throw new DocutilsError(
|
||||
`Could not parse version from MkDocs. This is a bug. Output was ${rawMkDocsVersion}`,
|
||||
`No ${NAME_MKDOCS} package in ${REQUIREMENTS_TXT_PATH}. This is a bug`,
|
||||
);
|
||||
}
|
||||
const {version: mkDocsReqdVersion} = mkDocsPipPkg;
|
||||
if (version !== mkDocsReqdVersion) {
|
||||
return this.fail(`MkDocs v${version} is installed, but v${mkDocsReqdVersion} is required`);
|
||||
}
|
||||
|
||||
this.ok('MkDocs install OK');
|
||||
}
|
||||
@@ -325,13 +333,16 @@ export class DocutilsValidator extends EventEmitter {
|
||||
*
|
||||
* It checks if the file exists, if it can be parsed as YAML, and if it has a `site_name` property.
|
||||
*/
|
||||
protected async validateMkDocsConfig(mkDocsYmlPath?: string) {
|
||||
mkDocsYmlPath = mkDocsYmlPath ?? this.mkDocsYmlPath ?? (await findMkDocsYml(this.cwd));
|
||||
protected async validateMkDocsConfig() {
|
||||
log.debug(`Validating ${NAME_MKDOCS_YML}`);
|
||||
|
||||
const mkDocsYmlPath = this.mkDocsYmlPath ?? (await findMkDocsYml(this.cwd));
|
||||
if (!mkDocsYmlPath) {
|
||||
return this.fail(
|
||||
`Could not find ${NAME_MKDOCS_YML} from ${this.cwd}. Run "${NAME_BIN} init" to create it`,
|
||||
`Could not find ${NAME_MKDOCS_YML} from ${this.cwd}; please run "${NAME_BIN} init"`,
|
||||
);
|
||||
}
|
||||
|
||||
let mkDocsYml: MkDocsYml;
|
||||
try {
|
||||
mkDocsYml = await readMkDocsYml(mkDocsYmlPath);
|
||||
@@ -358,24 +369,25 @@ export class DocutilsValidator extends EventEmitter {
|
||||
* This is required because other validators need `npm exec` to work, which is only available in npm 7+.
|
||||
*/
|
||||
protected async validateNpmVersion() {
|
||||
log.debug(`Validating ${NAME_NPM} version`);
|
||||
|
||||
const npmEngineRange = DOCUTILS_PKG.engines?.npm;
|
||||
if (!npmEngineRange) {
|
||||
throw new DocutilsError('Could not find property engines.npm in package.json. This is a bug');
|
||||
throw new DocutilsError(`Could not find property 'engines.npm' in ${NAME_PACKAGE_JSON}. This is a bug`);
|
||||
}
|
||||
|
||||
const npmPath = this.npmPath ?? (await whichNpm());
|
||||
if (!npmPath) {
|
||||
throw new DocutilsError(`Could not find ${NAME_NPM} in PATH. That seems weird, doesn't it?`);
|
||||
}
|
||||
|
||||
try {
|
||||
const npmPath = this.npmPath ?? (await whichNpm());
|
||||
if (!npmPath) {
|
||||
throw new DocutilsError(
|
||||
`Could not find ${NAME_NPM} in PATH. That seems weird, doesn't it?`,
|
||||
);
|
||||
}
|
||||
const {stdout: npmVersion} = await exec(npmPath, ['-v']);
|
||||
const {stdout: npmVersion} = await npm.exec('-v', [], {cwd: this.cwd});
|
||||
if (!satisfies(npmVersion.trim(), npmEngineRange)) {
|
||||
this.fail(`${NAME_NPM} is version ${npmVersion}, but ${npmEngineRange} is required`);
|
||||
return;
|
||||
return this.fail(`${NAME_NPM} v${npmVersion} is installed, but ${npmEngineRange} is required`);
|
||||
}
|
||||
} catch {
|
||||
return this.fail(`Could not find ${this.npmPath} in PATH. Is it installed?`);
|
||||
return this.fail(`Could not retrieve ${NAME_NPM} version`);
|
||||
}
|
||||
this.ok(`${NAME_NPM} version OK`);
|
||||
}
|
||||
@@ -387,11 +399,14 @@ export class DocutilsValidator extends EventEmitter {
|
||||
* contents of our `requirements.txt`. Versions _must_ match exactly.
|
||||
*/
|
||||
protected async validatePythonDeps() {
|
||||
let pipListOutput: string;
|
||||
log.debug(`Validating required ${NAME_PYTHON} package versions`);
|
||||
|
||||
const pythonPath = this.pythonPath ?? (await findPython());
|
||||
if (!pythonPath) {
|
||||
return this.fail(`Could not find ${NAME_PYTHON} in PATH. Is it installed?`);
|
||||
return this.fail(MESSAGE_PYTHON_MISSING);
|
||||
}
|
||||
|
||||
let pipListOutput: string;
|
||||
try {
|
||||
({stdout: pipListOutput} = await exec(pythonPath, [
|
||||
'-m',
|
||||
@@ -401,16 +416,16 @@ export class DocutilsValidator extends EventEmitter {
|
||||
'json',
|
||||
]));
|
||||
} catch {
|
||||
return this.fail(`Could not find ${NAME_PIP} in PATH. Is it installed?`);
|
||||
return this.fail(
|
||||
`Could not find ${NAME_PIP} installation for Python at ${pythonPath}. Is it installed?`
|
||||
);
|
||||
}
|
||||
|
||||
let installedPkgs: PipPackage[];
|
||||
try {
|
||||
installedPkgs = JSON.parse(pipListOutput) as PipPackage[];
|
||||
} catch {
|
||||
throw new DocutilsError(
|
||||
`Could not parse output of "${NAME_PIP} list" as JSON: ${pipListOutput}`,
|
||||
);
|
||||
return this.fail(`Could not parse output of "${NAME_PIP} list" as JSON: ${pipListOutput}`);
|
||||
}
|
||||
|
||||
const pkgsByName = _.mapValues(_.keyBy(installedPkgs, 'name'), 'version');
|
||||
@@ -423,8 +438,7 @@ export class DocutilsValidator extends EventEmitter {
|
||||
const version = pkgsByName[reqdPkg.name];
|
||||
if (!version) {
|
||||
missingPackages.push(reqdPkg);
|
||||
}
|
||||
if (version !== reqdPkg.version) {
|
||||
} else if (version !== reqdPkg.version) {
|
||||
invalidVersionPackages.push([reqdPkg, {name: reqdPkg.name, version}]);
|
||||
}
|
||||
}
|
||||
@@ -464,36 +478,44 @@ export class DocutilsValidator extends EventEmitter {
|
||||
* Asserts that the Python version is 3.x
|
||||
*/
|
||||
protected async validatePythonVersion() {
|
||||
log.debug(`Validating ${NAME_PYTHON} version`);
|
||||
|
||||
const pythonPath = this.pythonPath ?? (await findPython());
|
||||
if (!pythonPath) {
|
||||
return this.fail(`Could not find ${NAME_PYTHON} in PATH. Is it installed?`);
|
||||
return this.fail(MESSAGE_PYTHON_MISSING);
|
||||
}
|
||||
|
||||
try {
|
||||
const {stdout} = await exec(pythonPath, ['--version']);
|
||||
if (!stdout.includes(PYTHON_VER_STR)) {
|
||||
return this.fail(
|
||||
`Could not find Python 3.x in PATH; found ${stdout}. Please use --python-path`,
|
||||
);
|
||||
return this.fail(`Could not find Python 3.x in PATH; found ${stdout}`);
|
||||
}
|
||||
} catch {
|
||||
return this.fail(`Could not find Python 3.x in PATH.`);
|
||||
return this.fail(`Could not retrieve Python version`);
|
||||
}
|
||||
this.ok('Python version OK');
|
||||
}
|
||||
|
||||
/**
|
||||
* Asserts that TypeScript is installed, runnable, the correct version, and a parseable `tsconfig.json` exists.
|
||||
* Asserts that TypeScript is installed, runnable, and the correct version.
|
||||
*/
|
||||
protected async validateTypeScript() {
|
||||
log.debug(`Validating ${NAME_TYPESCRIPT} version`);
|
||||
|
||||
const pkgDir = await this.findPkgDir();
|
||||
if (!pkgDir) {
|
||||
return this.fail(`Could not find package.json in ${this.cwd}`);
|
||||
return this.fail(`Could not find ${NAME_PACKAGE_JSON} in ${this.cwd}`);
|
||||
}
|
||||
|
||||
const npmPath = this.npmPath ?? (await whichNpm());
|
||||
if (!npmPath) {
|
||||
throw new DocutilsError(`Could not find ${NAME_NPM} in PATH. That seems weird, doesn't it?`);
|
||||
}
|
||||
|
||||
let typeScriptVersion: string;
|
||||
let rawTypeScriptVersion: string;
|
||||
try {
|
||||
({stdout: rawTypeScriptVersion} = await exec(NAME_NPM, ['exec', 'tsc', '--', '--version'], {
|
||||
({stdout: rawTypeScriptVersion} = await npm.exec('exec', ['tsc', '--', '--version'], {
|
||||
cwd: pkgDir,
|
||||
}));
|
||||
} catch {
|
||||
@@ -510,16 +532,15 @@ export class DocutilsValidator extends EventEmitter {
|
||||
}
|
||||
|
||||
const reqdTypeScriptVersion = DOCUTILS_PKG.dependencies?.typescript;
|
||||
|
||||
if (!reqdTypeScriptVersion) {
|
||||
throw new DocutilsError(
|
||||
`Could not find a dep for ${NAME_TYPESCRIPT} in ${NAME_PACKAGE_JSON}. This is a bug.`,
|
||||
`Could not find ${NAME_TYPESCRIPT} dependency in ${NAME_PACKAGE_JSON}. This is a bug`,
|
||||
);
|
||||
}
|
||||
|
||||
if (!satisfies(typeScriptVersion, reqdTypeScriptVersion)) {
|
||||
return this.fail(
|
||||
`Found TypeScript version ${typeScriptVersion}, but ${reqdTypeScriptVersion} is required`,
|
||||
`TypeScript v${typeScriptVersion} is installed, but v${reqdTypeScriptVersion} is required`,
|
||||
);
|
||||
}
|
||||
this.ok('TypeScript install OK');
|
||||
@@ -529,25 +550,23 @@ export class DocutilsValidator extends EventEmitter {
|
||||
* Validates a `tsconfig.json` file
|
||||
*/
|
||||
protected async validateTypeScriptConfig() {
|
||||
log.debug(`Validating ${NAME_TSCONFIG_JSON}`);
|
||||
|
||||
const pkgDir = await this.findPkgDir();
|
||||
if (!pkgDir) {
|
||||
return this.fail(new DocutilsError(`Could not find package.json in ${this.cwd}`));
|
||||
return this.fail(`Could not find ${NAME_PACKAGE_JSON} in ${this.cwd}`);
|
||||
}
|
||||
const tsconfigJsonPath = (this.tsconfigJsonPath =
|
||||
this.tsconfigJsonPath ?? path.join(pkgDir, NAME_TSCONFIG_JSON));
|
||||
|
||||
const tsconfigJsonPath = this.tsconfigJsonPath ?? path.join(pkgDir, NAME_TSCONFIG_JSON);
|
||||
const relTsconfigJsonPath = relative(this.cwd, tsconfigJsonPath);
|
||||
try {
|
||||
await readJson5(tsconfigJsonPath);
|
||||
} catch (e) {
|
||||
if (e instanceof SyntaxError) {
|
||||
return this.fail(
|
||||
new DocutilsError(`Unparseable ${NAME_TSCONFIG_JSON} at ${relTsconfigJsonPath}: ${e}`),
|
||||
);
|
||||
return this.fail(`Could not parse ${NAME_TSCONFIG_JSON} at ${relTsconfigJsonPath}: ${e}`);
|
||||
}
|
||||
return this.fail(
|
||||
new DocutilsError(
|
||||
`Missing ${NAME_TSCONFIG_JSON} at ${relTsconfigJsonPath}; "${NAME_BIN} init" can help`,
|
||||
),
|
||||
`Could not find ${NAME_TSCONFIG_JSON} at ${relTsconfigJsonPath}; please run "${NAME_BIN} init"`,
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@appium/docutils",
|
||||
"version": "1.0.33",
|
||||
"version": "1.1.0",
|
||||
"description": "Documentation generation utilities for Appium and related projects",
|
||||
"keywords": [
|
||||
"automation",
|
||||
@@ -48,11 +48,11 @@
|
||||
"start": "node ./build/lib/cli/index.js"
|
||||
},
|
||||
"dependencies": {
|
||||
"@appium/support": "^6.0.7",
|
||||
"@appium/support": "^6.1.0",
|
||||
"@appium/tsconfig": "^0.3.5",
|
||||
"@sliphua/lilconfig-ts-loader": "3.2.2",
|
||||
"chalk": "4.1.2",
|
||||
"consola": "3.4.0",
|
||||
"consola": "3.4.2",
|
||||
"diff": "7.0.0",
|
||||
"json5": "2.2.3",
|
||||
"lilconfig": "3.1.3",
|
||||
@@ -62,9 +62,9 @@
|
||||
"semver": "7.7.1",
|
||||
"source-map-support": "0.5.21",
|
||||
"teen_process": "2.3.1",
|
||||
"type-fest": "4.37.0",
|
||||
"typescript": "5.8.2",
|
||||
"yaml": "2.7.0",
|
||||
"type-fest": "4.40.0",
|
||||
"typescript": "5.8.3",
|
||||
"yaml": "2.7.1",
|
||||
"yargs": "17.7.2",
|
||||
"yargs-parser": "21.1.1"
|
||||
},
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
mkdocs==1.6.1
|
||||
mkdocs-git-revision-date-localized-plugin==1.4.4
|
||||
mkdocs-material==9.6.7
|
||||
mkdocs-git-revision-date-localized-plugin==1.4.5
|
||||
mkdocs-material==9.6.12
|
||||
mkdocs-redirects==1.2.2
|
||||
mike==2.1.3
|
||||
|
||||
@@ -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.7.9](https://github.com/appium/appium/compare/@appium/driver-test-support@0.7.8...@appium/driver-test-support@0.7.9) (2025-04-25)
|
||||
|
||||
**Note:** Version bump only for package @appium/driver-test-support
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
## [0.7.8](https://github.com/appium/appium/compare/@appium/driver-test-support@0.7.7...@appium/driver-test-support@0.7.8) (2025-03-17)
|
||||
|
||||
**Note:** Version bump only for package @appium/driver-test-support
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
## [0.7.7](https://github.com/appium/appium/compare/@appium/driver-test-support@0.7.6...@appium/driver-test-support@0.7.7) (2025-03-11)
|
||||
|
||||
**Note:** Version bump only for package @appium/driver-test-support
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@appium/driver-test-support",
|
||||
"version": "0.7.7",
|
||||
"version": "0.7.9",
|
||||
"description": "Test utilities for Appium drivers",
|
||||
"keywords": [
|
||||
"automation",
|
||||
@@ -41,16 +41,16 @@
|
||||
},
|
||||
"types": "./build/lib/index.d.ts",
|
||||
"dependencies": {
|
||||
"@appium/types": "^0.25.2",
|
||||
"axios": "1.8.2",
|
||||
"@appium/types": "^0.25.3",
|
||||
"axios": "1.8.4",
|
||||
"bluebird": "3.7.2",
|
||||
"chai": "5.2.0",
|
||||
"chai-as-promised": "8.0.1",
|
||||
"get-port": "5.1.1",
|
||||
"lodash": "4.17.21",
|
||||
"sinon": "19.0.2",
|
||||
"sinon": "20.0.0",
|
||||
"source-map-support": "0.5.21",
|
||||
"type-fest": "4.37.0"
|
||||
"type-fest": "4.40.0"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"appium": "^2.0.0-beta.43",
|
||||
|
||||
@@ -3,6 +3,14 @@
|
||||
All notable changes to this project will be documented in this file.
|
||||
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
||||
|
||||
## [1.0.4](https://github.com/appium/appium/compare/@appium/eslint-config-appium-ts@1.0.3...@appium/eslint-config-appium-ts@1.0.4) (2025-04-25)
|
||||
|
||||
**Note:** Version bump only for package @appium/eslint-config-appium-ts
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
## [1.0.3](https://github.com/appium/appium/compare/@appium/eslint-config-appium-ts@1.0.2...@appium/eslint-config-appium-ts@1.0.3) (2025-02-19)
|
||||
|
||||
**Note:** Version bump only for package @appium/eslint-config-appium-ts
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "@appium/eslint-config-appium-ts",
|
||||
"type": "module",
|
||||
"version": "1.0.3",
|
||||
"version": "1.0.4",
|
||||
"description": "Shared ESLint config for Appium projects (TypeScript version)",
|
||||
"keywords": [
|
||||
"eslint",
|
||||
@@ -33,7 +33,7 @@
|
||||
"@eslint/js": "^9.0.0",
|
||||
"eslint": "^9.0.0",
|
||||
"eslint-config-prettier": "^9.0.0 || ^10.0.0",
|
||||
"eslint-import-resolver-typescript": "^3.5.0",
|
||||
"eslint-import-resolver-typescript": "^3.5.0 || ^4.0.0",
|
||||
"eslint-plugin-import": "^2.30.0",
|
||||
"eslint-plugin-mocha": "^10.4.0",
|
||||
"eslint-plugin-promise": "^7.0.0",
|
||||
|
||||
@@ -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.
|
||||
|
||||
## [4.0.5](https://github.com/appium/appium/compare/@appium/execute-driver-plugin@4.0.4...@appium/execute-driver-plugin@4.0.5) (2025-04-25)
|
||||
|
||||
**Note:** Version bump only for package @appium/execute-driver-plugin
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
## [4.0.4](https://github.com/appium/appium/compare/@appium/execute-driver-plugin@4.0.3...@appium/execute-driver-plugin@4.0.4) (2025-03-17)
|
||||
|
||||
**Note:** Version bump only for package @appium/execute-driver-plugin
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
## [4.0.3](https://github.com/appium/appium/compare/@appium/execute-driver-plugin@4.0.2...@appium/execute-driver-plugin@4.0.3) (2025-03-11)
|
||||
|
||||
**Note:** Version bump only for package @appium/execute-driver-plugin
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@appium/execute-driver-plugin",
|
||||
"version": "4.0.3",
|
||||
"version": "4.0.5",
|
||||
"description": "Plugin for batching and executing driver commands with Appiums",
|
||||
"keywords": [
|
||||
"automation",
|
||||
@@ -41,7 +41,7 @@
|
||||
"bluebird": "3.7.2",
|
||||
"lodash": "4.17.21",
|
||||
"source-map-support": "0.5.21",
|
||||
"webdriverio": "9.10.1"
|
||||
"webdriverio": "9.12.7"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"appium": "^2.0.0-beta.35"
|
||||
|
||||
@@ -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.
|
||||
|
||||
## [3.2.6](https://github.com/appium/appium/compare/@appium/fake-plugin@3.2.5...@appium/fake-plugin@3.2.6) (2025-04-25)
|
||||
|
||||
**Note:** Version bump only for package @appium/fake-plugin
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
## [3.2.5](https://github.com/appium/appium/compare/@appium/fake-plugin@3.2.4...@appium/fake-plugin@3.2.5) (2025-03-17)
|
||||
|
||||
**Note:** Version bump only for package @appium/fake-plugin
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
## [3.2.4](https://github.com/appium/appium/compare/@appium/fake-plugin@3.2.3...@appium/fake-plugin@3.2.4) (2025-03-11)
|
||||
|
||||
**Note:** Version bump only for package @appium/fake-plugin
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@appium/fake-plugin",
|
||||
"version": "3.2.4",
|
||||
"version": "3.2.6",
|
||||
"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.3.4",
|
||||
"@appium/support": "^6.0.7",
|
||||
"@appium/base-plugin": "^2.3.6",
|
||||
"@appium/support": "^6.1.0",
|
||||
"bluebird": "3.7.2",
|
||||
"lodash": "4.17.21",
|
||||
"source-map-support": "0.5.21"
|
||||
|
||||
@@ -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.
|
||||
|
||||
## [3.1.2](https://github.com/appium/appium/compare/@appium/images-plugin@3.1.1...@appium/images-plugin@3.1.2) (2025-04-25)
|
||||
|
||||
**Note:** Version bump only for package @appium/images-plugin
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
## [3.1.1](https://github.com/appium/appium/compare/@appium/images-plugin@3.1.0...@appium/images-plugin@3.1.1) (2025-03-17)
|
||||
|
||||
**Note:** Version bump only for package @appium/images-plugin
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
## [3.1.0](https://github.com/appium/appium/compare/@appium/images-plugin@3.0.30...@appium/images-plugin@3.1.0) (2025-03-11)
|
||||
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@appium/images-plugin",
|
||||
"version": "3.1.0",
|
||||
"version": "3.1.2",
|
||||
"description": "Plugin for working with images and image elements in Appium",
|
||||
"keywords": [
|
||||
"automation",
|
||||
@@ -39,11 +39,11 @@
|
||||
"test:unit": "mocha \"./test/unit/**/*.spec.*js\""
|
||||
},
|
||||
"dependencies": {
|
||||
"@appium/opencv": "^3.0.8",
|
||||
"@appium/support": "^6.0.7",
|
||||
"@appium/opencv": "^3.0.9",
|
||||
"@appium/support": "^6.1.0",
|
||||
"lodash": "4.17.21",
|
||||
"lru-cache": "10.4.3",
|
||||
"sharp": "0.33.5",
|
||||
"sharp": "0.34.1",
|
||||
"source-map-support": "0.5.21"
|
||||
},
|
||||
"peerDependencies": {
|
||||
|
||||
@@ -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.
|
||||
|
||||
## [1.7.0](https://github.com/appium/appium/compare/@appium/logger@1.6.1...@appium/logger@1.7.0) (2025-04-25)
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* Add a possibility to mask sensitive log values depending on request headers ([#21123](https://github.com/appium/appium/issues/21123)) ([c24d2ac](https://github.com/appium/appium/commit/c24d2ac46123f41ee9b54e0adefacfabd149089c))
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* **appium:** Return hostname as web socket url for BiDi if a broadcast address is assigned to the server ([#20603](https://github.com/appium/appium/issues/20603)) ([f0de55d](https://github.com/appium/appium/commit/f0de55da0da2fc0305876a948704c1f0a2a5990f))
|
||||
* **logger:** Error stack logging ([#21176](https://github.com/appium/appium/issues/21176)) ([1de5d0a](https://github.com/appium/appium/commit/1de5d0a0e8994b170a44eebe2d0575d5c74c3ff2))
|
||||
|
||||
|
||||
|
||||
## [1.6.1](https://github.com/appium/appium/compare/@appium/logger@1.6.0...@appium/logger@1.6.1) (2024-08-07)
|
||||
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import log from './lib/log';
|
||||
export { markSensitive } from './lib/log';
|
||||
export type * from './lib/types';
|
||||
|
||||
import log from './lib/log';
|
||||
export {log};
|
||||
export default log;
|
||||
|
||||
+46
-11
@@ -16,7 +16,10 @@ import type {
|
||||
import type {Writable} from 'node:stream';
|
||||
import {AsyncLocalStorage} from 'node:async_hooks';
|
||||
import { unleakString } from './utils';
|
||||
import { SecureValuesPreprocessor } from './secure-values-preprocessor';
|
||||
import {
|
||||
DEFAULT_SECURE_REPLACER,
|
||||
SecureValuesPreprocessor
|
||||
} from './secure-values-preprocessor';
|
||||
import { LRUCache } from 'lru-cache';
|
||||
|
||||
const DEFAULT_LOG_LEVELS = [
|
||||
@@ -32,6 +35,7 @@ const DEFAULT_LOG_LEVELS = [
|
||||
['silent', Infinity],
|
||||
] as const;
|
||||
const DEFAULT_HISTORY_SIZE = 10000;
|
||||
const SENSITIVE_MESSAGE_KEY = 'f2b06625-35a2-4ed3-939a-b0b0a4abc750';
|
||||
|
||||
setBlocking(true);
|
||||
|
||||
@@ -230,16 +234,13 @@ export class Log extends EventEmitter implements Logger {
|
||||
}
|
||||
|
||||
const messageArguments: any[] = [];
|
||||
let stack: string | null = null;
|
||||
for (const formatArg of [message, ...args]) {
|
||||
messageArguments.push(formatArg);
|
||||
// resolve stack traces to a plain string.
|
||||
if (_.isError(formatArg) && formatArg.stack) {
|
||||
Object.defineProperty(formatArg, 'stack', {
|
||||
value: (stack = formatArg.stack + ''),
|
||||
enumerable: true,
|
||||
writable: true,
|
||||
});
|
||||
let stack: string | undefined;
|
||||
for (const arg of [message, ...args]) {
|
||||
const result = this._formatLogArgument(arg);
|
||||
if (result.stack) {
|
||||
stack = result.stack;
|
||||
} else {
|
||||
messageArguments.push(result.arg);
|
||||
}
|
||||
}
|
||||
if (stack) {
|
||||
@@ -382,10 +383,44 @@ export class Log extends EventEmitter implements Logger {
|
||||
}
|
||||
}
|
||||
|
||||
private _formatLogArgument(arg: any): ArgumentFormatResult {
|
||||
const result: ArgumentFormatResult = {
|
||||
arg,
|
||||
stack: undefined,
|
||||
};
|
||||
|
||||
// mask sensitive data
|
||||
if (_.has(result.arg, SENSITIVE_MESSAGE_KEY)) {
|
||||
const { isSensitive } = this._asyncStorage.getStore() ?? {};
|
||||
result.arg = isSensitive ? DEFAULT_SECURE_REPLACER : result.arg[SENSITIVE_MESSAGE_KEY];
|
||||
}
|
||||
|
||||
// resolve stack traces to a plain string
|
||||
if (_.isError(result.arg) && result.arg.stack) {
|
||||
result.stack = result.arg.stack + '';
|
||||
Object.defineProperty(result.arg, 'stack', {
|
||||
value: result.stack,
|
||||
enumerable: true,
|
||||
writable: true,
|
||||
});
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
// this functionality has been deliberately disabled
|
||||
private clearProgress(): void {}
|
||||
private showProgress(): void {}
|
||||
}
|
||||
|
||||
export function markSensitive<T=any>(logMessage: T): {[SENSITIVE_MESSAGE_KEY]: T} {
|
||||
return {[SENSITIVE_MESSAGE_KEY]: logMessage};
|
||||
}
|
||||
|
||||
interface ArgumentFormatResult {
|
||||
arg: any,
|
||||
stack: string | undefined,
|
||||
}
|
||||
|
||||
export const GLOBAL_LOG = new Log();
|
||||
export default GLOBAL_LOG;
|
||||
|
||||
@@ -6,7 +6,7 @@ import type {
|
||||
LogFilter,
|
||||
} from './types';
|
||||
|
||||
const DEFAULT_REPLACER = '**SECURE**';
|
||||
export const DEFAULT_SECURE_REPLACER = '**SECURE**';
|
||||
|
||||
/**
|
||||
* Type guard for log filter type
|
||||
@@ -42,7 +42,7 @@ export class SecureValuesPreprocessor {
|
||||
*/
|
||||
parseRule(rule: string | LogFilter): SecureValuePreprocessingRule {
|
||||
let pattern: string | undefined;
|
||||
let replacer = DEFAULT_REPLACER;
|
||||
let replacer = DEFAULT_SECURE_REPLACER;
|
||||
let flags = ['g'];
|
||||
if (_.isString(rule)) {
|
||||
if (rule.length === 0) {
|
||||
@@ -142,7 +142,7 @@ export class SecureValuesPreprocessor {
|
||||
|
||||
let result = str;
|
||||
for (const rule of this._rules) {
|
||||
result = result.replace(rule.pattern, rule.replacer ?? DEFAULT_REPLACER);
|
||||
result = result.replace(rule.pattern, rule.replacer ?? DEFAULT_SECURE_REPLACER);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@appium/logger",
|
||||
"version": "1.6.1",
|
||||
"version": "1.7.0",
|
||||
"author": "https://github.com/appium",
|
||||
"description": "A Universal Logger For The Appium Ecosystem",
|
||||
"repository": {
|
||||
|
||||
@@ -1,10 +1,12 @@
|
||||
/* eslint-disable no-console */
|
||||
import { Log } from '../../lib/log';
|
||||
import { Log, markSensitive} from '../../lib/log';
|
||||
import { unleakString } from '../../lib/utils';
|
||||
import {Stream} from 'node:stream';
|
||||
import _ from 'lodash';
|
||||
|
||||
describe('basic', function () {
|
||||
let chai;
|
||||
/** @type {Log} */
|
||||
let log;
|
||||
|
||||
before(async function () {
|
||||
@@ -360,6 +362,15 @@ describe('basic', function () {
|
||||
});
|
||||
});
|
||||
|
||||
it('replaces senstive messages', async function() {
|
||||
log.updateAsyncStorage({isSensitive: true}, true);
|
||||
log.log('verbose', 'test', markSensitive('log 1'));
|
||||
_.last(log.record).message.should.eql('**SECURE**');
|
||||
log.updateAsyncStorage({isSensitive: false}, true);
|
||||
log.log('verbose', 'test', markSensitive('log 1'));
|
||||
_.last(log.record).message.should.eql('log 1');
|
||||
});
|
||||
|
||||
it('max record size', function() {
|
||||
log.maxRecordSize = 3;
|
||||
log.log('verbose', 'test', 'log 1');
|
||||
|
||||
@@ -3,6 +3,14 @@
|
||||
All notable changes to this project will be documented in this file.
|
||||
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
||||
|
||||
## [3.0.9](https://github.com/appium/appium/compare/@appium/opencv@3.0.8...@appium/opencv@3.0.9) (2025-04-25)
|
||||
|
||||
**Note:** Version bump only for package @appium/opencv
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
## [3.0.8](https://github.com/appium/appium/compare/@appium/opencv@3.0.7...@appium/opencv@3.0.8) (2025-02-19)
|
||||
|
||||
**Note:** Version bump only for package @appium/opencv
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@appium/opencv",
|
||||
"version": "3.0.8",
|
||||
"version": "3.0.9",
|
||||
"description": "OpenCV-related helper library",
|
||||
"keywords": [
|
||||
"automation",
|
||||
@@ -44,7 +44,7 @@
|
||||
"bluebird": "3.7.2",
|
||||
"lodash": "4.17.21",
|
||||
"opencv-bindings": "4.5.5",
|
||||
"sharp": "0.33.5",
|
||||
"sharp": "0.34.1",
|
||||
"source-map-support": "0.5.21"
|
||||
},
|
||||
"engines": {
|
||||
|
||||
@@ -3,6 +3,14 @@
|
||||
All notable changes to this project will be documented in this file.
|
||||
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
||||
|
||||
## [0.3.53](https://github.com/appium/appium/compare/@appium/plugin-test-support@0.3.52...@appium/plugin-test-support@0.3.53) (2025-04-25)
|
||||
|
||||
**Note:** Version bump only for package @appium/plugin-test-support
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
## [0.3.52](https://github.com/appium/appium/compare/@appium/plugin-test-support@0.3.51...@appium/plugin-test-support@0.3.52) (2025-03-11)
|
||||
|
||||
**Note:** Version bump only for package @appium/plugin-test-support
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@appium/plugin-test-support",
|
||||
"version": "0.3.52",
|
||||
"version": "0.3.53",
|
||||
"description": "Testing utilities for Appium plugins",
|
||||
"keywords": [
|
||||
"automation",
|
||||
@@ -41,7 +41,7 @@
|
||||
"test:unit": "exit 0"
|
||||
},
|
||||
"dependencies": {
|
||||
"@appium/types": "^0.25.2",
|
||||
"@appium/types": "^0.25.3",
|
||||
"get-port": "5.1.1",
|
||||
"log-symbols": "4.1.0",
|
||||
"source-map-support": "0.5.21",
|
||||
|
||||
@@ -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.1.2](https://github.com/appium/appium/compare/@appium/storage-plugin@0.1.1...@appium/storage-plugin@0.1.2) (2025-04-25)
|
||||
|
||||
**Note:** Version bump only for package @appium/storage-plugin
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
## [0.1.1](https://github.com/appium/appium/compare/@appium/storage-plugin@0.1.0...@appium/storage-plugin@0.1.1) (2025-03-17)
|
||||
|
||||
**Note:** Version bump only for package @appium/storage-plugin
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
## 0.1.0 (2025-03-11)
|
||||
|
||||
|
||||
|
||||
@@ -4,11 +4,11 @@ import _ from 'lodash';
|
||||
import { tempDir, fs, logger } from '@appium/support';
|
||||
import { AddRequestResult, ItemOptions, StorageItem } from './types';
|
||||
import type { Express, Request, Response } from 'express';
|
||||
import { toW3cResponseError } from './utils';
|
||||
import { AppiumServer } from '@appium/types';
|
||||
import { LRUCache } from 'lru-cache';
|
||||
import WebSocket from 'ws';
|
||||
import { EventEmitter } from 'node:stream';
|
||||
import { toW3cResponseError } from './utils';
|
||||
|
||||
const log = logger.getLogger('StoragePlugin');
|
||||
|
||||
|
||||
@@ -1,8 +1,12 @@
|
||||
import _ from 'lodash';
|
||||
import { errors } from 'appium/driver';
|
||||
import { errors, getResponseForW3CError } from 'appium/driver';
|
||||
|
||||
|
||||
export function toW3cResponseError(err: any): [number, Record<string, any>] {
|
||||
if (_.isFunction(getResponseForW3CError)) {
|
||||
return getResponseForW3CError(err) as [number, Record<string, any>];
|
||||
}
|
||||
// TODO: deprecate the below after the plugin only supports Appium3+
|
||||
const protocolError = _.has(err, 'w3cStatus') ? err : new errors.UnknownError(err);
|
||||
return [protocolError.w3cStatus, {
|
||||
value: {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@appium/storage-plugin",
|
||||
"version": "0.1.0",
|
||||
"version": "0.1.2",
|
||||
"description": "Server-side storage plugin",
|
||||
"keywords": [
|
||||
"automation",
|
||||
@@ -41,8 +41,7 @@
|
||||
"test:e2e": "mocha --timeout 20s --slow 10s \"./test/e2e/**/*.spec.*js\""
|
||||
},
|
||||
"dependencies": {
|
||||
"@appium/base-plugin": "^2.3.4",
|
||||
"@appium/support": "^6.0.7",
|
||||
"@appium/support": "^6.1.0",
|
||||
"async-lock": "1.4.1",
|
||||
"bluebird": "3.7.2",
|
||||
"lodash": "4.17.21",
|
||||
|
||||
@@ -3,6 +3,23 @@
|
||||
All notable changes to this project will be documented in this file.
|
||||
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
||||
|
||||
## [6.1.0](https://github.com/appium/appium/compare/@appium/support@6.0.8...@appium/support@6.1.0) (2025-04-25)
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* Add a possibility to mask sensitive log values depending on request headers ([#21123](https://github.com/appium/appium/issues/21123)) ([c24d2ac](https://github.com/appium/appium/commit/c24d2ac46123f41ee9b54e0adefacfabd149089c))
|
||||
|
||||
|
||||
|
||||
## [6.0.8](https://github.com/appium/appium/compare/@appium/support@6.0.7...@appium/support@6.0.8) (2025-03-17)
|
||||
|
||||
**Note:** Version bump only for package @appium/support
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
## [6.0.7](https://github.com/appium/appium/compare/@appium/support@6.0.6...@appium/support@6.0.7) (2025-03-11)
|
||||
|
||||
**Note:** Version bump only for package @appium/support
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import globalLog from '@appium/logger';
|
||||
import globalLog, { markSensitive as _markSensitive } from '@appium/logger';
|
||||
import _ from 'lodash';
|
||||
import moment from 'moment';
|
||||
|
||||
@@ -84,6 +84,23 @@ export function getLogger(prefix = null) {
|
||||
return /** @type {AppiumLogger} */ (wrappedLogger);
|
||||
}
|
||||
|
||||
/**
|
||||
* Marks arbitrary log message as sensitive.
|
||||
* This message will then be replaced with the default replacer
|
||||
* while being logged by any `info`, `debug`, etc. methods if the
|
||||
* asyncStorage has `isSensitive` flag enabled in its async context.
|
||||
* The latter is enabled by the corresponding HTTP middleware
|
||||
* in response to the `X-Appium-Is-Sensitive` request header
|
||||
* being set to 'true'.
|
||||
*
|
||||
* @template {any} T
|
||||
* @param {T} logMessage
|
||||
* @returns {{[k: string]: T}}
|
||||
*/
|
||||
export function markSensitive(logMessage) {
|
||||
return _markSensitive(logMessage);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @returns {[import('@appium/logger').Logger, boolean]}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@appium/support",
|
||||
"version": "6.0.7",
|
||||
"version": "6.1.0",
|
||||
"description": "Support libs used across appium packages",
|
||||
"keywords": [
|
||||
"automation",
|
||||
@@ -41,12 +41,12 @@
|
||||
"test:unit": "mocha \"./test/unit/**/*.spec.js\""
|
||||
},
|
||||
"dependencies": {
|
||||
"@appium/logger": "^1.6.1",
|
||||
"@appium/logger": "^1.7.0",
|
||||
"@appium/tsconfig": "^0.3.5",
|
||||
"@appium/types": "^0.25.2",
|
||||
"@appium/types": "^0.25.3",
|
||||
"@colors/colors": "1.6.0",
|
||||
"archiver": "7.0.1",
|
||||
"axios": "1.8.2",
|
||||
"axios": "1.8.4",
|
||||
"base64-stream": "1.0.0",
|
||||
"bluebird": "3.7.2",
|
||||
"bplist-creator": "0.1.1",
|
||||
@@ -73,13 +73,13 @@
|
||||
"source-map-support": "0.5.21",
|
||||
"supports-color": "8.1.1",
|
||||
"teen_process": "2.3.1",
|
||||
"type-fest": "4.37.0",
|
||||
"type-fest": "4.40.0",
|
||||
"uuid": "11.1.0",
|
||||
"which": "4.0.0",
|
||||
"yauzl": "3.2.0"
|
||||
},
|
||||
"optionalDependencies": {
|
||||
"sharp": "0.33.5"
|
||||
"sharp": "0.34.1"
|
||||
},
|
||||
"engines": {
|
||||
"node": "^14.17.0 || ^16.13.0 || >=18.0.0",
|
||||
|
||||
@@ -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.
|
||||
|
||||
## [3.1.9](https://github.com/appium/appium/compare/@appium/test-support@3.1.8...@appium/test-support@3.1.9) (2025-04-25)
|
||||
|
||||
**Note:** Version bump only for package @appium/test-support
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
## [3.1.8](https://github.com/appium/appium/compare/@appium/test-support@3.1.7...@appium/test-support@3.1.8) (2025-03-17)
|
||||
|
||||
**Note:** Version bump only for package @appium/test-support
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
## [3.1.7](https://github.com/appium/appium/compare/@appium/test-support@3.1.6...@appium/test-support@3.1.7) (2025-03-11)
|
||||
|
||||
**Note:** Version bump only for package @appium/test-support
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
import B from 'bluebird';
|
||||
import sinon from 'sinon';
|
||||
|
||||
/**
|
||||
@@ -68,7 +67,7 @@ export class MockStore {
|
||||
if (this.#mocks) {
|
||||
throw new ReferenceError('Cannot create mocks twice; call `reset()` first.');
|
||||
}
|
||||
this.sandbox = this.sandbox ?? sinon.createSandbox().usingPromise(B);
|
||||
this.sandbox = this.sandbox ?? sinon.createSandbox();
|
||||
for (const [key, value] of Object.entries(mockDefs)) {
|
||||
this[key] = this.sandbox.mock(value);
|
||||
}
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import sinon from 'sinon';
|
||||
import _ from 'lodash';
|
||||
import B from 'bluebird';
|
||||
import {MockStore} from './mock-utils';
|
||||
|
||||
/**
|
||||
@@ -59,7 +58,7 @@ export class SandboxStore {
|
||||
* @param {Mocks} mocks
|
||||
*/
|
||||
createSandbox(mocks = /** @type {Mocks} */ ({})) {
|
||||
this.sandbox = this.sandbox ?? sinon.createSandbox().usingPromise(B);
|
||||
this.sandbox = this.sandbox ?? sinon.createSandbox();
|
||||
this.mocks = new MockStore(this.sandbox).createMocks(mocks);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@appium/test-support",
|
||||
"version": "3.1.7",
|
||||
"version": "3.1.9",
|
||||
"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": "^6.0.7",
|
||||
"@appium/support": "^6.1.0",
|
||||
"@colors/colors": "1.6.0",
|
||||
"bluebird": "3.7.2",
|
||||
"lodash": "4.17.21",
|
||||
"loud-rejection": "2.2.0",
|
||||
"sinon": "19.0.2",
|
||||
"sinon": "20.0.0",
|
||||
"source-map-support": "0.5.21"
|
||||
},
|
||||
"engines": {
|
||||
|
||||
@@ -3,6 +3,14 @@
|
||||
All notable changes to this project will be documented in this file.
|
||||
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
||||
|
||||
## [0.25.3](https://github.com/appium/appium/compare/@appium/types@0.25.2...@appium/types@0.25.3) (2025-04-25)
|
||||
|
||||
**Note:** Version bump only for package @appium/types
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
## [0.25.2](https://github.com/appium/appium/compare/@appium/types@0.25.1...@appium/types@0.25.2) (2025-03-11)
|
||||
|
||||
**Note:** Version bump only for package @appium/types
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@appium/types",
|
||||
"version": "0.25.2",
|
||||
"version": "0.25.3",
|
||||
"description": "Various type declarations used across Appium",
|
||||
"keywords": [
|
||||
"automation",
|
||||
@@ -38,10 +38,10 @@
|
||||
"test:types": "tsd"
|
||||
},
|
||||
"dependencies": {
|
||||
"@appium/logger": "^1.6.1",
|
||||
"@appium/logger": "^1.7.0",
|
||||
"@appium/schema": "^0.8.1",
|
||||
"@appium/tsconfig": "^0.3.5",
|
||||
"type-fest": "4.37.0"
|
||||
"type-fest": "4.40.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": "^14.17.0 || ^16.13.0 || >=18.0.0",
|
||||
|
||||
@@ -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.
|
||||
|
||||
## [1.0.33](https://github.com/appium/appium/compare/@appium/universal-xml-plugin@1.0.32...@appium/universal-xml-plugin@1.0.33) (2025-04-25)
|
||||
|
||||
**Note:** Version bump only for package @appium/universal-xml-plugin
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
## [1.0.32](https://github.com/appium/appium/compare/@appium/universal-xml-plugin@1.0.31...@appium/universal-xml-plugin@1.0.32) (2025-03-17)
|
||||
|
||||
**Note:** Version bump only for package @appium/universal-xml-plugin
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
## [1.0.31](https://github.com/appium/appium/compare/@appium/universal-xml-plugin@1.0.30...@appium/universal-xml-plugin@1.0.31) (2025-03-11)
|
||||
|
||||
**Note:** Version bump only for package @appium/universal-xml-plugin
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@appium/universal-xml-plugin",
|
||||
"version": "1.0.31",
|
||||
"version": "1.0.33",
|
||||
"description": "Appium plugin for making XML source and XPath queries the same across iOS and Android",
|
||||
"keywords": [
|
||||
"automation",
|
||||
@@ -38,7 +38,7 @@
|
||||
},
|
||||
"dependencies": {
|
||||
"@xmldom/xmldom": "0.9.8",
|
||||
"fast-xml-parser": "5.0.8",
|
||||
"fast-xml-parser": "5.2.1",
|
||||
"lodash": "4.17.21",
|
||||
"source-map-support": "0.5.21",
|
||||
"xpath": "0.0.34"
|
||||
|
||||
Reference in New Issue
Block a user