appium 2.0.0-beta.26 → 2.0.0-beta.29
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/lib/appium.d.ts +215 -0
- package/build/lib/appium.d.ts.map +1 -0
- package/build/lib/appium.js +62 -54
- package/build/lib/cli/args.d.ts +20 -0
- package/build/lib/cli/args.d.ts.map +1 -0
- package/build/lib/cli/args.js +1 -1
- package/build/lib/cli/driver-command.d.ts +36 -0
- package/build/lib/cli/driver-command.d.ts.map +1 -0
- package/build/lib/cli/driver-command.js +8 -7
- package/build/lib/cli/extension-command.d.ts +345 -0
- package/build/lib/cli/extension-command.d.ts.map +1 -0
- package/build/lib/cli/extension-command.js +52 -38
- package/build/lib/cli/extension.d.ts +14 -0
- package/build/lib/cli/extension.d.ts.map +1 -0
- package/build/lib/cli/extension.js +7 -2
- package/build/lib/cli/parser.d.ts +79 -0
- package/build/lib/cli/parser.d.ts.map +1 -0
- package/build/lib/cli/parser.js +1 -1
- package/build/lib/cli/plugin-command.d.ts +39 -0
- package/build/lib/cli/plugin-command.d.ts.map +1 -0
- package/build/lib/cli/plugin-command.js +6 -7
- package/build/lib/cli/utils.d.ts +29 -0
- package/build/lib/cli/utils.d.ts.map +1 -0
- package/build/lib/cli/utils.js +1 -1
- package/build/lib/config-file.d.ts +100 -0
- package/build/lib/config-file.d.ts.map +1 -0
- package/build/lib/config-file.js +1 -1
- package/build/lib/config.d.ts +40 -0
- package/build/lib/config.d.ts.map +1 -0
- package/build/lib/config.js +2 -2
- package/build/lib/constants.d.ts +48 -0
- package/build/lib/constants.d.ts.map +1 -0
- package/build/lib/constants.js +1 -1
- package/build/lib/extension/driver-config.d.ts +84 -0
- package/build/lib/extension/driver-config.d.ts.map +1 -0
- package/build/lib/extension/driver-config.js +1 -1
- package/build/lib/extension/extension-config.d.ts +170 -0
- package/build/lib/extension/extension-config.d.ts.map +1 -0
- package/build/lib/extension/extension-config.js +2 -2
- package/build/lib/extension/index.d.ts +39 -0
- package/build/lib/extension/index.d.ts.map +1 -0
- package/build/lib/extension/index.js +1 -1
- package/build/lib/extension/manifest.d.ts +174 -0
- package/build/lib/extension/manifest.d.ts.map +1 -0
- package/build/lib/extension/manifest.js +1 -1
- package/build/lib/extension/package-changed.d.ts +11 -0
- package/build/lib/extension/package-changed.d.ts.map +1 -0
- package/build/lib/extension/package-changed.js +1 -1
- package/build/lib/extension/plugin-config.d.ts +62 -0
- package/build/lib/extension/plugin-config.d.ts.map +1 -0
- package/build/lib/extension/plugin-config.js +1 -1
- package/build/lib/grid-register.d.ts +10 -0
- package/build/lib/grid-register.d.ts.map +1 -0
- package/build/lib/logger.d.ts +3 -0
- package/build/lib/logger.d.ts.map +1 -0
- package/build/lib/logsink.d.ts +4 -0
- package/build/lib/logsink.d.ts.map +1 -0
- package/build/lib/logsink.js +1 -1
- package/build/lib/main.d.ts +51 -0
- package/build/lib/main.d.ts.map +1 -0
- package/build/lib/main.js +1 -1
- package/build/lib/schema/arg-spec.d.ts +143 -0
- package/build/lib/schema/arg-spec.d.ts.map +1 -0
- package/build/lib/schema/arg-spec.js +1 -1
- package/build/lib/schema/cli-args.d.ts +19 -0
- package/build/lib/schema/cli-args.d.ts.map +1 -0
- package/build/lib/schema/cli-args.js +1 -1
- package/build/lib/schema/cli-transformers.d.ts +5 -0
- package/build/lib/schema/cli-transformers.d.ts.map +1 -0
- package/build/lib/schema/cli-transformers.js +1 -1
- package/build/lib/schema/index.d.ts +3 -0
- package/build/lib/schema/index.d.ts.map +1 -0
- package/build/lib/schema/keywords.d.ts +24 -0
- package/build/lib/schema/keywords.d.ts.map +1 -0
- package/build/lib/schema/keywords.js +1 -1
- package/build/lib/schema/schema.d.ts +259 -0
- package/build/lib/schema/schema.d.ts.map +1 -0
- package/build/lib/schema/schema.js +3 -3
- package/build/lib/utils.d.ts +66 -0
- package/build/lib/utils.d.ts.map +1 -0
- package/build/lib/utils.js +6 -4
- package/build/tsconfig.tsbuildinfo +1 -0
- package/lib/appium.js +163 -81
- package/lib/cli/args.js +1 -2
- package/lib/cli/driver-command.js +11 -8
- package/lib/cli/extension-command.js +129 -80
- package/lib/cli/extension.js +13 -3
- package/lib/cli/parser.js +1 -2
- package/lib/cli/plugin-command.js +16 -6
- package/lib/cli/utils.js +1 -1
- package/lib/config-file.js +3 -4
- package/lib/config.js +12 -8
- package/lib/constants.js +0 -1
- package/lib/extension/driver-config.js +31 -12
- package/lib/extension/extension-config.js +21 -22
- package/lib/extension/index.js +1 -2
- package/lib/extension/manifest.js +23 -127
- package/lib/extension/package-changed.js +0 -1
- package/lib/extension/plugin-config.js +9 -7
- package/lib/logsink.js +4 -0
- package/lib/main.js +9 -10
- package/lib/schema/arg-spec.js +10 -6
- package/lib/schema/cli-args.js +0 -1
- package/lib/schema/cli-transformers.js +0 -1
- package/lib/schema/keywords.js +0 -1
- package/lib/schema/schema.js +2 -3
- package/lib/utils.js +49 -16
- package/package.json +12 -14
- package/types/appium-manifest.d.ts +61 -0
- package/types/cli.d.ts +134 -0
- package/types/extension.d.ts +56 -0
- package/types/external-manifest.d.ts +58 -0
- package/types/index.d.ts +7 -0
- package/build/lib/appium-config.schema.json +0 -278
- package/build/lib/schema/appium-config-schema.js +0 -251
- package/lib/schema/appium-config-schema.js +0 -287
- package/types/appium-config.d.ts +0 -197
- package/types/types.d.ts +0 -245
package/lib/schema/keywords.js
CHANGED
package/lib/schema/schema.js
CHANGED
|
@@ -1,11 +1,10 @@
|
|
|
1
|
-
// @ts-check
|
|
2
1
|
|
|
3
2
|
import Ajv from 'ajv';
|
|
4
3
|
import addFormats from 'ajv-formats';
|
|
5
4
|
import _ from 'lodash';
|
|
6
5
|
import path from 'path';
|
|
7
6
|
import { DRIVER_TYPE, PLUGIN_TYPE } from '../constants';
|
|
8
|
-
import
|
|
7
|
+
import { AppiumConfigJsonSchema } from '@appium/schema';
|
|
9
8
|
import { APPIUM_CONFIG_SCHEMA_ID, ArgSpec, SERVER_PROP_NAME } from './arg-spec';
|
|
10
9
|
import { keywords } from './keywords';
|
|
11
10
|
|
|
@@ -190,7 +189,7 @@ class AppiumSchema {
|
|
|
190
189
|
const ajv = this._ajv;
|
|
191
190
|
|
|
192
191
|
// Ajv will _mutate_ the schema, so we need to clone it.
|
|
193
|
-
const baseSchema = _.cloneDeep(
|
|
192
|
+
const baseSchema = _.cloneDeep(AppiumConfigJsonSchema);
|
|
194
193
|
|
|
195
194
|
/**
|
|
196
195
|
*
|
package/lib/utils.js
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
// @ts-check
|
|
2
1
|
|
|
3
2
|
import _ from 'lodash';
|
|
4
3
|
import logger from './logger';
|
|
5
|
-
// @ts-ignore
|
|
6
4
|
import { processCapabilities, PROTOCOLS } from '@appium/base-driver';
|
|
7
5
|
import { inspect as dump } from 'util';
|
|
8
6
|
|
|
@@ -35,25 +33,28 @@ const inspect = _.flow(
|
|
|
35
33
|
* Takes the caps that were provided in the request and translates them
|
|
36
34
|
* into caps that can be used by the inner drivers.
|
|
37
35
|
*
|
|
38
|
-
* @param {
|
|
39
|
-
* @param {
|
|
40
|
-
* @param {
|
|
41
|
-
* @param {
|
|
36
|
+
* @param {any} jsonwpCapabilities
|
|
37
|
+
* @param {W3CCapabilities} w3cCapabilities
|
|
38
|
+
* @param {import('@appium/types').Constraints} constraints
|
|
39
|
+
* @param {import('@appium/types').DefaultCapabilitiesConfig} [defaultCapabilities]
|
|
40
|
+
* @returns {ParsedDriverCaps|InvalidCaps}
|
|
42
41
|
*/
|
|
43
42
|
function parseCapsForInnerDriver (jsonwpCapabilities, w3cCapabilities, constraints = {}, defaultCapabilities = {}) {
|
|
44
43
|
// Check if the caller sent JSONWP caps, W3C caps, or both
|
|
45
44
|
const hasW3CCaps = _.isPlainObject(w3cCapabilities) &&
|
|
46
45
|
(_.has(w3cCapabilities, 'alwaysMatch') || _.has(w3cCapabilities, 'firstMatch'));
|
|
47
46
|
const hasJSONWPCaps = _.isPlainObject(jsonwpCapabilities);
|
|
48
|
-
let desiredCaps = {};
|
|
49
|
-
|
|
50
|
-
let
|
|
47
|
+
let desiredCaps = /** @type {ParsedDriverCaps['desiredCaps']} */({});
|
|
48
|
+
/** @type {ParsedDriverCaps['processedW3CCapabilities']} */
|
|
49
|
+
let processedW3CCapabilities;
|
|
50
|
+
/** @type {ParsedDriverCaps['processedJsonwpCapabilities']} */
|
|
51
|
+
let processedJsonwpCapabilities;
|
|
51
52
|
|
|
52
53
|
if (!hasW3CCaps) {
|
|
53
|
-
return {
|
|
54
|
+
return /** @type {InvalidCaps} */({
|
|
54
55
|
protocol: PROTOCOLS.W3C,
|
|
55
56
|
error: new Error('W3C capabilities should be provided'),
|
|
56
|
-
};
|
|
57
|
+
});
|
|
57
58
|
}
|
|
58
59
|
|
|
59
60
|
const {W3C} = PROTOCOLS;
|
|
@@ -93,7 +94,7 @@ function parseCapsForInnerDriver (jsonwpCapabilities, w3cCapabilities, constrain
|
|
|
93
94
|
}
|
|
94
95
|
}
|
|
95
96
|
if (hasJSONWPCaps) {
|
|
96
|
-
jsonwpCapabilities =
|
|
97
|
+
jsonwpCapabilities = {...removeAppiumPrefixes(defaultCapabilities), ...jsonwpCapabilities};
|
|
97
98
|
}
|
|
98
99
|
}
|
|
99
100
|
|
|
@@ -110,13 +111,13 @@ function parseCapsForInnerDriver (jsonwpCapabilities, w3cCapabilities, constrain
|
|
|
110
111
|
desiredCaps = processCapabilities(w3cCapabilities, constraints, true);
|
|
111
112
|
} catch (error) {
|
|
112
113
|
logger.info(`Could not parse W3C capabilities: ${error.message}`);
|
|
113
|
-
return {
|
|
114
|
+
return /** @type {InvalidCaps} */({
|
|
114
115
|
desiredCaps,
|
|
115
116
|
processedJsonwpCapabilities,
|
|
116
117
|
processedW3CCapabilities,
|
|
117
118
|
protocol,
|
|
118
119
|
error,
|
|
119
|
-
};
|
|
120
|
+
});
|
|
120
121
|
}
|
|
121
122
|
|
|
122
123
|
// Create a new w3c capabilities payload that contains only the matching caps in `alwaysMatch`
|
|
@@ -126,12 +127,13 @@ function parseCapsForInnerDriver (jsonwpCapabilities, w3cCapabilities, constrain
|
|
|
126
127
|
};
|
|
127
128
|
}
|
|
128
129
|
|
|
129
|
-
return {desiredCaps, processedJsonwpCapabilities, processedW3CCapabilities, protocol};
|
|
130
|
+
return /** @type {ParsedDriverCaps} */({desiredCaps, processedJsonwpCapabilities, processedW3CCapabilities, protocol});
|
|
130
131
|
}
|
|
131
132
|
|
|
132
133
|
/**
|
|
133
134
|
* Takes a capabilities objects and prefixes capabilities with `appium:`
|
|
134
|
-
* @param {
|
|
135
|
+
* @param {Capabilities} caps Desired capabilities object
|
|
136
|
+
* @returns {AppiumW3CCapabilities}
|
|
135
137
|
*/
|
|
136
138
|
function insertAppiumPrefixes (caps) {
|
|
137
139
|
// Standard, non-prefixed capabilities (see https://www.w3.org/TR/webdriver/#dfn-table-of-standard-capabilities)
|
|
@@ -158,11 +160,17 @@ function insertAppiumPrefixes (caps) {
|
|
|
158
160
|
return prefixedCaps;
|
|
159
161
|
}
|
|
160
162
|
|
|
163
|
+
/**
|
|
164
|
+
*
|
|
165
|
+
* @param {AppiumW3CCapabilities} caps
|
|
166
|
+
* @returns {Capabilities}
|
|
167
|
+
*/
|
|
161
168
|
function removeAppiumPrefixes (caps) {
|
|
162
169
|
if (!_.isPlainObject(caps)) {
|
|
163
170
|
return caps;
|
|
164
171
|
}
|
|
165
172
|
|
|
173
|
+
/** @type {Capabilities} */
|
|
166
174
|
const fixedCaps = {};
|
|
167
175
|
for (let [name, value] of _.toPairs(caps)) {
|
|
168
176
|
fixedCaps[removeAppiumPrefix(name)] = value;
|
|
@@ -218,3 +226,28 @@ export {
|
|
|
218
226
|
inspect, parseCapsForInnerDriver, insertAppiumPrefixes,
|
|
219
227
|
getPackageVersion, pullSettings, removeAppiumPrefixes
|
|
220
228
|
};
|
|
229
|
+
|
|
230
|
+
/**
|
|
231
|
+
* @todo protocol is more specific
|
|
232
|
+
* @typedef ParsedDriverCaps
|
|
233
|
+
* @property {Capabilities} desiredCaps
|
|
234
|
+
* @property {string} protocol
|
|
235
|
+
* @property {any} [processedJsonwpCapabilities]
|
|
236
|
+
* @property {W3CCapabilities} [processedW3CCapabilities]
|
|
237
|
+
*/
|
|
238
|
+
|
|
239
|
+
/**
|
|
240
|
+
* @todo protocol is more specific
|
|
241
|
+
* @typedef InvalidCaps
|
|
242
|
+
* @property {Error} error
|
|
243
|
+
* @property {string} protocol
|
|
244
|
+
* @property {Capabilities} [desiredCaps]
|
|
245
|
+
* @property {any} [processedJsonwpCapabilities]
|
|
246
|
+
* @property {W3CCapabilities} [processedW3CCapabilities]
|
|
247
|
+
*/
|
|
248
|
+
|
|
249
|
+
/**
|
|
250
|
+
* @typedef {import('@appium/types').W3CCapabilities} W3CCapabilities
|
|
251
|
+
* @typedef {import('@appium/types').Capabilities} Capabilities
|
|
252
|
+
* @typedef {import('@appium/types').AppiumW3CCapabilities} AppiumW3CCapabilities
|
|
253
|
+
*/
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "appium",
|
|
3
|
-
"version": "2.0.0-beta.
|
|
3
|
+
"version": "2.0.0-beta.29",
|
|
4
4
|
"description": "Automation for Apps.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"automation",
|
|
@@ -37,13 +37,10 @@
|
|
|
37
37
|
"types"
|
|
38
38
|
],
|
|
39
39
|
"scripts": {
|
|
40
|
-
"build": "babel lib --root-mode=upward --
|
|
41
|
-
"postbuild": "npm run generate-schema-json",
|
|
40
|
+
"build": "babel lib --root-mode=upward --out-dir=build/lib",
|
|
42
41
|
"dev": "npm run build -- --watch",
|
|
43
42
|
"fix": "npm run lint -- --fix",
|
|
44
43
|
"generate-docs": "node ./scripts/parse-yml-commands.js",
|
|
45
|
-
"generate-schema-json": "node ./scripts/generate-schema-json.js",
|
|
46
|
-
"generate-schema-declarations": "node ./scripts/generate-schema-declarations.js",
|
|
47
44
|
"postinstall": "node ./scripts/postinstall.js",
|
|
48
45
|
"lint": "eslint -c ../../.eslintrc --ignore-path ../../.eslintignore .",
|
|
49
46
|
"test": "npm run test:unit",
|
|
@@ -51,31 +48,31 @@
|
|
|
51
48
|
"test:unit": "mocha --require ../../test/setup-babel.js \"./test/unit/**/*.spec.js\""
|
|
52
49
|
},
|
|
53
50
|
"dependencies": {
|
|
54
|
-
"@appium/base-driver": "
|
|
51
|
+
"@appium/base-driver": "file:../base-driver",
|
|
55
52
|
"@appium/base-plugin": "1.8.1",
|
|
56
|
-
"@appium/
|
|
57
|
-
"@
|
|
53
|
+
"@appium/schema": "file:../schema",
|
|
54
|
+
"@appium/support": "file:../support",
|
|
55
|
+
"@babel/runtime": "7.17.9",
|
|
58
56
|
"@sidvind/better-ajv-errors": "1.1.1",
|
|
59
|
-
"ajv": "8.
|
|
57
|
+
"ajv": "8.11.0",
|
|
60
58
|
"ajv-formats": "2.1.1",
|
|
61
59
|
"argparse": "2.0.1",
|
|
62
60
|
"async-lock": "1.3.1",
|
|
63
61
|
"asyncbox": "2.9.2",
|
|
64
62
|
"axios": "0.26.1",
|
|
65
63
|
"bluebird": "3.7.2",
|
|
66
|
-
"continuation-local-storage": "3.2.1",
|
|
67
64
|
"find-up": "5.0.0",
|
|
68
|
-
"lilconfig": "2.0.
|
|
65
|
+
"lilconfig": "2.0.5",
|
|
69
66
|
"lodash": "4.17.21",
|
|
70
67
|
"longjohn": "0.2.12",
|
|
71
68
|
"npmlog": "6.0.1",
|
|
72
69
|
"ora": "5.4.1",
|
|
73
70
|
"package-changed": "1.9.0",
|
|
74
71
|
"resolve-from": "5.0.0",
|
|
75
|
-
"semver": "7.3.
|
|
72
|
+
"semver": "7.3.6",
|
|
76
73
|
"source-map-support": "0.5.21",
|
|
77
74
|
"teen_process": "1.16.0",
|
|
78
|
-
"winston": "3.
|
|
75
|
+
"winston": "3.7.2",
|
|
79
76
|
"word-wrap": "1.2.3",
|
|
80
77
|
"yaml": "1.10.2"
|
|
81
78
|
},
|
|
@@ -87,5 +84,6 @@
|
|
|
87
84
|
"access": "public",
|
|
88
85
|
"tag": "next"
|
|
89
86
|
},
|
|
90
|
-
"
|
|
87
|
+
"types": "./build/lib/index.d.ts",
|
|
88
|
+
"gitHead": "ec6a90a797d2dadb407922426be16efaec9def07"
|
|
91
89
|
}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { CommonMetadata, ExtMetadata, SchemaMetadata } from './external-manifest';
|
|
2
|
+
import { ExtensionType, DriverType, PluginType } from '.';
|
|
3
|
+
|
|
4
|
+
export type InstallType = 'npm' | 'git' | 'local' | 'github';
|
|
5
|
+
|
|
6
|
+
export interface InternalMetadata {
|
|
7
|
+
pkgName: string;
|
|
8
|
+
version: string;
|
|
9
|
+
installType: InstallType;
|
|
10
|
+
/**
|
|
11
|
+
* Whatever the user typed as the extension to install. May be derived from `package.json`
|
|
12
|
+
*/
|
|
13
|
+
installSpec: string;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Combination of external + internal extension data with `driverName`/`pluginName` removed (it becomes a key in an {@linkcode ExtRecord} object).
|
|
18
|
+
* Part of `extensions.yaml`.
|
|
19
|
+
*/
|
|
20
|
+
export type ExtManifest<ExtType extends ExtensionType> = Omit<
|
|
21
|
+
ExtMetadata<ExtType>,
|
|
22
|
+
ExtType extends DriverType
|
|
23
|
+
? 'driverName'
|
|
24
|
+
: ExtType extends PluginType
|
|
25
|
+
? 'pluginName'
|
|
26
|
+
: never
|
|
27
|
+
> &
|
|
28
|
+
InternalMetadata &
|
|
29
|
+
CommonMetadata; // XXX: ExtMetadata should be a union with CommonMetadata. why is this needed?
|
|
30
|
+
|
|
31
|
+
type WithSchemaManifest = {
|
|
32
|
+
schema: SchemaMetadata;
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* This is just a {@linkcode ExtManifest} except it _for sure_ has a `schema` prop.
|
|
37
|
+
*/
|
|
38
|
+
export type ExtManifestWithSchema<ExtType extends ExtensionType> =
|
|
39
|
+
ExtManifest<ExtType> & WithSchemaManifest;
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Generic type for an object keyed by extension name, with values of type {@linkcode ExtData}
|
|
43
|
+
*/
|
|
44
|
+
export type ExtRecord<ExtType extends ExtensionType> = Record<
|
|
45
|
+
string,
|
|
46
|
+
ExtManifest<ExtType>
|
|
47
|
+
>;
|
|
48
|
+
|
|
49
|
+
export type DriverRecord = ExtRecord<DriverType>;
|
|
50
|
+
export type PluginRecord = ExtRecord<PluginType>;
|
|
51
|
+
|
|
52
|
+
export type ExtName<ExtType extends ExtensionType> = keyof ExtRecord<ExtType>;
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* Represents an entire YAML manifest (`extensions.yaml`)
|
|
56
|
+
*/
|
|
57
|
+
export interface ManifestData {
|
|
58
|
+
drivers: DriverRecord;
|
|
59
|
+
plugins: PluginRecord;
|
|
60
|
+
schemaRev?: number;
|
|
61
|
+
}
|
package/types/cli.d.ts
ADDED
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
import { DriverOpts } from '@appium/types';
|
|
2
|
+
import {
|
|
3
|
+
DRIVER_TYPE as DRIVER_SUBCOMMAND,
|
|
4
|
+
EXT_SUBCOMMAND_INSTALL,
|
|
5
|
+
EXT_SUBCOMMAND_LIST,
|
|
6
|
+
EXT_SUBCOMMAND_RUN,
|
|
7
|
+
EXT_SUBCOMMAND_UNINSTALL,
|
|
8
|
+
EXT_SUBCOMMAND_UPDATE,
|
|
9
|
+
PLUGIN_TYPE as PLUGIN_SUBCOMMAND,
|
|
10
|
+
SERVER_SUBCOMMAND,
|
|
11
|
+
} from '../lib/constants';
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Possible subcommands for the `appium` CLI.
|
|
15
|
+
*/
|
|
16
|
+
type CliSubcommand =
|
|
17
|
+
| typeof SERVER_SUBCOMMAND
|
|
18
|
+
| typeof DRIVER_SUBCOMMAND
|
|
19
|
+
| typeof PLUGIN_SUBCOMMAND;
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Possible subcommands of {@link DRIVER_SUBCOMMAND} or
|
|
23
|
+
* {@link PLUGIN_SUBCOMMAND}.
|
|
24
|
+
*/
|
|
25
|
+
export type CliExtensionSubcommand =
|
|
26
|
+
| typeof EXT_SUBCOMMAND_INSTALL
|
|
27
|
+
| typeof EXT_SUBCOMMAND_LIST
|
|
28
|
+
| typeof EXT_SUBCOMMAND_RUN
|
|
29
|
+
| typeof EXT_SUBCOMMAND_UPDATE
|
|
30
|
+
| typeof EXT_SUBCOMMAND_UNINSTALL;
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Random stuff that may appear in the parsed args which has no equivalent in a
|
|
34
|
+
* config file.
|
|
35
|
+
*/
|
|
36
|
+
interface MoreArgs {
|
|
37
|
+
/**
|
|
38
|
+
* Path to config file, if any. Does not make sense for this to be allowed in a config file!
|
|
39
|
+
*/
|
|
40
|
+
configFile?: string;
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* If true, show the config and exit
|
|
44
|
+
*/
|
|
45
|
+
showConfig?: boolean;
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* If true, open a REPL
|
|
49
|
+
*/
|
|
50
|
+
shell?: boolean;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* These arguments are _not_ supported by the CLI, but only via programmatic usage / tests.
|
|
55
|
+
*/
|
|
56
|
+
interface ProgrammaticArgs {
|
|
57
|
+
/**
|
|
58
|
+
* If `true`, throw on error instead of exit.
|
|
59
|
+
*/
|
|
60
|
+
throwInsteadOfExit?: boolean;
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* Seems to only be used in tests or standalone driver calls
|
|
64
|
+
*/
|
|
65
|
+
logHandler?: (...args: any[]) => void;
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* Alternate way to set `APPIUM_HOME` for tests. Since we don't want to muck about
|
|
69
|
+
* with the environment, we just set it here.
|
|
70
|
+
*
|
|
71
|
+
* Setting this means that any discovery of the proper `APPIUM_HOME` path is bypassed
|
|
72
|
+
* and is equivalent to setting `APPIUM_HOME` in the environment.
|
|
73
|
+
*/
|
|
74
|
+
appiumHome?: string;
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* If true, show the {@link BuildInfo build info} and exit
|
|
78
|
+
*/
|
|
79
|
+
showBuildInfo?: boolean;
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* If true, show config and exit
|
|
83
|
+
*/
|
|
84
|
+
showConfig?: boolean;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* These are args that Appium assigns while parsing the args.
|
|
89
|
+
*/
|
|
90
|
+
interface InternalArgs {
|
|
91
|
+
/**
|
|
92
|
+
* Subcommands of `driver` subcommand
|
|
93
|
+
*/
|
|
94
|
+
driverCommand?: CliExtensionSubcommand;
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* Subcommands of `plugin` subcommand
|
|
98
|
+
*/
|
|
99
|
+
pluginCommand?: CliExtensionSubcommand;
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* Possible subcommands
|
|
103
|
+
*/
|
|
104
|
+
subcommand: CliSubcommand;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
/**
|
|
108
|
+
* The same as {@link ParsedArgs} but with a nullable `subcommand`.
|
|
109
|
+
* This is _not_ the same as `Partial<ParsedArgs>`.
|
|
110
|
+
*/
|
|
111
|
+
export type PartialArgs = DriverOpts &
|
|
112
|
+
MoreArgs &
|
|
113
|
+
ProgrammaticArgs &
|
|
114
|
+
Partial<InternalArgs>;
|
|
115
|
+
|
|
116
|
+
/**
|
|
117
|
+
* The Appium configuration as a flattened object, parsed via CLI args _and_ any
|
|
118
|
+
* CLI args unsupported by the config file.
|
|
119
|
+
* @todo Does not make any assumptions about property names derived from
|
|
120
|
+
* extensions.
|
|
121
|
+
*/
|
|
122
|
+
export type ParsedArgs = DriverOpts &
|
|
123
|
+
MoreArgs &
|
|
124
|
+
ProgrammaticArgs &
|
|
125
|
+
InternalArgs;
|
|
126
|
+
|
|
127
|
+
/**
|
|
128
|
+
* Shown by `appium --build-info`
|
|
129
|
+
*/
|
|
130
|
+
export type BuildInfo = {
|
|
131
|
+
version: string;
|
|
132
|
+
'git-sha'?: string;
|
|
133
|
+
built?: string;
|
|
134
|
+
};
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { BaseDriverBase } from '@appium/base-driver/lib/basedriver/driver';
|
|
2
|
+
import { Class, Driver, ExternalDriver } from '@appium/types';
|
|
3
|
+
import { DriverType, ExtensionType, PluginType } from '.';
|
|
4
|
+
|
|
5
|
+
export type DriverClass = BaseDriverBase<ExternalDriver,
|
|
6
|
+
ExternalDriverStatic>;
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Additional static props for external driver classes
|
|
10
|
+
*/
|
|
11
|
+
interface ExternalDriverStatic {
|
|
12
|
+
driverName: string;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* TODO: This should be derived from the base plugin.
|
|
17
|
+
*/
|
|
18
|
+
export type PluginClass = Class<PluginProto, ExternalPluginStatic>;
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Static props for plugin classes
|
|
22
|
+
*/
|
|
23
|
+
interface ExternalPluginStatic {
|
|
24
|
+
pluginName: string;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* A plugin must have this shape.
|
|
29
|
+
* @todo Use base plugin instead of this
|
|
30
|
+
*/
|
|
31
|
+
interface PluginProto {
|
|
32
|
+
/**
|
|
33
|
+
* I'm not sure why `plugin.name` is required, but it is.
|
|
34
|
+
*/
|
|
35
|
+
name: string;
|
|
36
|
+
/**
|
|
37
|
+
* Assigned by Appium; _not_ provided by implementor.
|
|
38
|
+
*/
|
|
39
|
+
cliArgs?: Record<string, any>;
|
|
40
|
+
/**
|
|
41
|
+
* Don't know what this is, but it's also required.
|
|
42
|
+
*/
|
|
43
|
+
onUnexpectedShutdown?: (
|
|
44
|
+
driver: Driver,
|
|
45
|
+
cause: Error | string,
|
|
46
|
+
) => Promise<void>;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* Generic to get at the class of an extension.
|
|
51
|
+
*/
|
|
52
|
+
export type ExtClass<ExtType extends ExtensionType> = ExtType extends DriverType
|
|
53
|
+
? DriverClass
|
|
54
|
+
: ExtType extends PluginType
|
|
55
|
+
? PluginClass
|
|
56
|
+
: never;
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* These types describe information about external extensions and the contents of their `package.json` files
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import { SchemaObject } from 'ajv';
|
|
6
|
+
import { PackageJson, SetRequired } from 'type-fest';
|
|
7
|
+
import { DriverType, ExtensionType, PluginType } from './index';
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* This is what is allowed in the `appium.schema` prop of an extension's `package.json`.
|
|
11
|
+
*/
|
|
12
|
+
export type SchemaMetadata = string | (SchemaObject & {[key: number]: never});
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Manifest data shared by all extensions, as contained in `package.json`
|
|
16
|
+
*/
|
|
17
|
+
export interface CommonMetadata {
|
|
18
|
+
mainClass: string;
|
|
19
|
+
scripts?: Record<string, string>;
|
|
20
|
+
schema?: SchemaMetadata;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Driver-specific manifest data as contained in `package.json`
|
|
25
|
+
*/
|
|
26
|
+
export interface DriverMetadata {
|
|
27
|
+
automationName: string;
|
|
28
|
+
platformNames: string[];
|
|
29
|
+
driverName: string;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Plugin-specific manifest data as stored in `package.json`
|
|
34
|
+
*/
|
|
35
|
+
export interface PluginMetadata {
|
|
36
|
+
pluginName: string;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Generic type to refer to either {@linkcode DriverMetadata} or {@linkcode PluginMetadata}
|
|
41
|
+
* Corresponds to the `appium` prop in an extension's `package.json`.
|
|
42
|
+
*/
|
|
43
|
+
export type ExtMetadata<ExtType extends ExtensionType> =
|
|
44
|
+
(ExtType extends DriverType
|
|
45
|
+
? DriverMetadata
|
|
46
|
+
: ExtType extends PluginType
|
|
47
|
+
? PluginMetadata
|
|
48
|
+
: never) &
|
|
49
|
+
CommonMetadata;
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* A `package.json` containing extension metadata.
|
|
53
|
+
* Required fields are `name`, `version`, and `appium`.
|
|
54
|
+
*/
|
|
55
|
+
export type ExtPackageJson<ExtType extends ExtensionType> = SetRequired<
|
|
56
|
+
PackageJson,
|
|
57
|
+
'name' | 'version'
|
|
58
|
+
> & {appium: ExtMetadata<ExtType>};
|
package/types/index.d.ts
ADDED