appium 2.0.0-beta.25 → 2.0.0-beta.28
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 +94 -101
- 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 +19 -39
- 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 +10 -13
- 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 +117 -94
- 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 +14 -22
- 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 +9 -19
- 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 +9 -14
- 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 +2 -4
- 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 +2 -4
- package/build/lib/config.d.ts +40 -0
- package/build/lib/config.d.ts.map +1 -0
- package/build/lib/config.js +8 -7
- package/build/lib/constants.d.ts +48 -0
- package/build/lib/constants.d.ts.map +1 -0
- package/build/lib/constants.js +60 -0
- 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 +190 -0
- 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 +297 -0
- 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 +77 -0
- 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 +246 -0
- 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 +68 -0
- 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 +87 -0
- package/build/lib/grid-register.d.ts +10 -0
- package/build/lib/grid-register.d.ts.map +1 -0
- package/build/lib/grid-register.js +2 -4
- package/build/lib/logger.d.ts +3 -0
- package/build/lib/logger.d.ts.map +1 -0
- package/build/lib/logger.js +2 -4
- package/build/lib/logsink.d.ts +4 -0
- package/build/lib/logsink.d.ts.map +1 -0
- package/build/lib/logsink.js +2 -4
- package/build/lib/main.d.ts +51 -0
- package/build/lib/main.d.ts.map +1 -0
- package/build/lib/main.js +40 -68
- 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 +11 -14
- 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 +2 -4
- 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 +2 -4
- package/build/lib/schema/index.d.ts +3 -0
- package/build/lib/schema/index.d.ts.map +1 -0
- package/build/lib/schema/index.js +2 -4
- 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 +2 -4
- 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 +57 -39
- package/build/lib/utils.d.ts +66 -0
- package/build/lib/utils.d.ts.map +1 -0
- package/build/lib/utils.js +6 -35
- package/build/tsconfig.tsbuildinfo +1 -0
- package/lib/appium.js +188 -117
- package/lib/cli/args.js +19 -24
- package/lib/cli/driver-command.js +19 -8
- package/lib/cli/extension-command.js +314 -184
- package/lib/cli/extension.js +18 -16
- package/lib/cli/parser.js +7 -16
- package/lib/cli/plugin-command.js +16 -7
- package/lib/cli/utils.js +1 -1
- package/lib/config-file.js +6 -7
- package/lib/config.js +17 -12
- package/lib/constants.js +78 -0
- package/lib/extension/driver-config.js +249 -0
- package/lib/extension/extension-config.js +458 -0
- package/lib/extension/index.js +102 -0
- package/lib/extension/manifest.js +486 -0
- package/lib/extension/package-changed.js +63 -0
- package/lib/extension/plugin-config.js +113 -0
- package/lib/grid-register.js +4 -4
- package/lib/logsink.js +4 -0
- package/lib/main.js +54 -92
- package/lib/schema/arg-spec.js +11 -7
- package/lib/schema/cli-args.js +1 -1
- package/lib/schema/cli-transformers.js +0 -1
- package/lib/schema/keywords.js +1 -2
- package/lib/schema/schema.js +62 -31
- package/lib/utils.js +48 -45
- package/package.json +30 -24
- package/{postinstall.js → scripts/postinstall.js} +1 -1
- 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/bin/ios-webkit-debug-proxy-launcher.js +0 -71
- package/build/check-npm-pack-files.js +0 -23
- package/build/commands-yml/parse.js +0 -319
- package/build/commands-yml/validator.js +0 -130
- package/build/index.js +0 -19
- package/build/lib/appium-config.schema.json +0 -0
- package/build/lib/cli/npm.js +0 -220
- package/build/lib/driver-config.js +0 -100
- package/build/lib/drivers.js +0 -100
- package/build/lib/ext-config-io.js +0 -165
- package/build/lib/extension-config.js +0 -320
- package/build/lib/plugin-config.js +0 -69
- package/build/lib/plugins.js +0 -18
- package/build/lib/schema/appium-config-schema.js +0 -253
- package/build/postinstall.js +0 -90
- package/build/test/cli/cli-e2e-specs.js +0 -221
- package/build/test/cli/cli-helpers.js +0 -86
- package/build/test/cli/cli-specs.js +0 -71
- package/build/test/cli/fixtures/test-driver/package.json +0 -27
- package/build/test/cli/schema-args-specs.js +0 -48
- package/build/test/cli/schema-e2e-specs.js +0 -47
- package/build/test/config-e2e-specs.js +0 -112
- package/build/test/config-file-e2e-specs.js +0 -191
- package/build/test/config-file-specs.js +0 -281
- package/build/test/config-specs.js +0 -258
- package/build/test/driver-e2e-specs.js +0 -435
- package/build/test/driver-specs.js +0 -386
- package/build/test/ext-config-io-specs.js +0 -181
- package/build/test/extension-config-specs.js +0 -365
- package/build/test/fixtures/allow-feat.txt +0 -5
- package/build/test/fixtures/caps.json +0 -3
- package/build/test/fixtures/config/allow-insecure.txt +0 -3
- package/build/test/fixtures/config/appium.config.bad-nodeconfig.json +0 -5
- package/build/test/fixtures/config/appium.config.bad.json +0 -32
- package/build/test/fixtures/config/appium.config.ext-good.json +0 -9
- package/build/test/fixtures/config/appium.config.ext-unknown-props.json +0 -10
- package/build/test/fixtures/config/appium.config.good.js +0 -40
- package/build/test/fixtures/config/appium.config.good.json +0 -33
- package/build/test/fixtures/config/appium.config.good.yaml +0 -30
- package/build/test/fixtures/config/appium.config.invalid.json +0 -31
- package/build/test/fixtures/config/appium.config.security-array.json +0 -5
- package/build/test/fixtures/config/appium.config.security-delimited.json +0 -5
- package/build/test/fixtures/config/appium.config.security-path.json +0 -5
- package/build/test/fixtures/config/driver-fake.config.json +0 -8
- package/build/test/fixtures/config/nodeconfig.json +0 -3
- package/build/test/fixtures/config/plugin-fake.config.json +0 -0
- package/build/test/fixtures/default-args.js +0 -35
- package/build/test/fixtures/deny-feat.txt +0 -5
- package/build/test/fixtures/driver.schema.js +0 -20
- package/build/test/fixtures/extensions.yaml +0 -27
- package/build/test/fixtures/flattened-schema.js +0 -532
- package/build/test/fixtures/plugin.schema.js +0 -20
- package/build/test/fixtures/schema-with-extensions.js +0 -28
- package/build/test/grid-register-specs.js +0 -74
- package/build/test/helpers.js +0 -75
- package/build/test/logger-specs.js +0 -76
- package/build/test/npm-specs.js +0 -20
- package/build/test/parser-specs.js +0 -319
- package/build/test/plugin-e2e-specs.js +0 -316
- package/build/test/schema/arg-spec-specs.js +0 -70
- package/build/test/schema/cli-args-specs.js +0 -408
- package/build/test/schema/schema-specs.js +0 -407
- package/build/test/utils-specs.js +0 -288
- package/lib/cli/npm.js +0 -251
- package/lib/driver-config.js +0 -101
- package/lib/drivers.js +0 -84
- package/lib/ext-config-io.js +0 -287
- package/lib/extension-config.js +0 -366
- package/lib/plugin-config.js +0 -63
- package/lib/plugins.js +0 -13
- package/lib/schema/appium-config-schema.js +0 -287
- package/types/appium-config.d.ts +0 -197
- package/types/types.d.ts +0 -206
package/lib/utils.js
CHANGED
|
@@ -1,10 +1,7 @@
|
|
|
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
|
-
import { fs } from '@appium/support';
|
|
8
5
|
import { inspect as dump } from 'util';
|
|
9
6
|
|
|
10
7
|
const W3C_APPIUM_PREFIX = 'appium';
|
|
@@ -36,25 +33,28 @@ const inspect = _.flow(
|
|
|
36
33
|
* Takes the caps that were provided in the request and translates them
|
|
37
34
|
* into caps that can be used by the inner drivers.
|
|
38
35
|
*
|
|
39
|
-
* @param {
|
|
40
|
-
* @param {
|
|
41
|
-
* @param {
|
|
42
|
-
* @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}
|
|
43
41
|
*/
|
|
44
42
|
function parseCapsForInnerDriver (jsonwpCapabilities, w3cCapabilities, constraints = {}, defaultCapabilities = {}) {
|
|
45
43
|
// Check if the caller sent JSONWP caps, W3C caps, or both
|
|
46
44
|
const hasW3CCaps = _.isPlainObject(w3cCapabilities) &&
|
|
47
45
|
(_.has(w3cCapabilities, 'alwaysMatch') || _.has(w3cCapabilities, 'firstMatch'));
|
|
48
46
|
const hasJSONWPCaps = _.isPlainObject(jsonwpCapabilities);
|
|
49
|
-
let desiredCaps = {};
|
|
50
|
-
|
|
51
|
-
let
|
|
47
|
+
let desiredCaps = /** @type {ParsedDriverCaps['desiredCaps']} */({});
|
|
48
|
+
/** @type {ParsedDriverCaps['processedW3CCapabilities']} */
|
|
49
|
+
let processedW3CCapabilities;
|
|
50
|
+
/** @type {ParsedDriverCaps['processedJsonwpCapabilities']} */
|
|
51
|
+
let processedJsonwpCapabilities;
|
|
52
52
|
|
|
53
53
|
if (!hasW3CCaps) {
|
|
54
|
-
return {
|
|
54
|
+
return /** @type {InvalidCaps} */({
|
|
55
55
|
protocol: PROTOCOLS.W3C,
|
|
56
56
|
error: new Error('W3C capabilities should be provided'),
|
|
57
|
-
};
|
|
57
|
+
});
|
|
58
58
|
}
|
|
59
59
|
|
|
60
60
|
const {W3C} = PROTOCOLS;
|
|
@@ -94,7 +94,7 @@ function parseCapsForInnerDriver (jsonwpCapabilities, w3cCapabilities, constrain
|
|
|
94
94
|
}
|
|
95
95
|
}
|
|
96
96
|
if (hasJSONWPCaps) {
|
|
97
|
-
jsonwpCapabilities =
|
|
97
|
+
jsonwpCapabilities = {...removeAppiumPrefixes(defaultCapabilities), ...jsonwpCapabilities};
|
|
98
98
|
}
|
|
99
99
|
}
|
|
100
100
|
|
|
@@ -111,13 +111,13 @@ function parseCapsForInnerDriver (jsonwpCapabilities, w3cCapabilities, constrain
|
|
|
111
111
|
desiredCaps = processCapabilities(w3cCapabilities, constraints, true);
|
|
112
112
|
} catch (error) {
|
|
113
113
|
logger.info(`Could not parse W3C capabilities: ${error.message}`);
|
|
114
|
-
return {
|
|
114
|
+
return /** @type {InvalidCaps} */({
|
|
115
115
|
desiredCaps,
|
|
116
116
|
processedJsonwpCapabilities,
|
|
117
117
|
processedW3CCapabilities,
|
|
118
118
|
protocol,
|
|
119
119
|
error,
|
|
120
|
-
};
|
|
120
|
+
});
|
|
121
121
|
}
|
|
122
122
|
|
|
123
123
|
// Create a new w3c capabilities payload that contains only the matching caps in `alwaysMatch`
|
|
@@ -127,12 +127,13 @@ function parseCapsForInnerDriver (jsonwpCapabilities, w3cCapabilities, constrain
|
|
|
127
127
|
};
|
|
128
128
|
}
|
|
129
129
|
|
|
130
|
-
return {desiredCaps, processedJsonwpCapabilities, processedW3CCapabilities, protocol};
|
|
130
|
+
return /** @type {ParsedDriverCaps} */({desiredCaps, processedJsonwpCapabilities, processedW3CCapabilities, protocol});
|
|
131
131
|
}
|
|
132
132
|
|
|
133
133
|
/**
|
|
134
134
|
* Takes a capabilities objects and prefixes capabilities with `appium:`
|
|
135
|
-
* @param {
|
|
135
|
+
* @param {Capabilities} caps Desired capabilities object
|
|
136
|
+
* @returns {AppiumW3CCapabilities}
|
|
136
137
|
*/
|
|
137
138
|
function insertAppiumPrefixes (caps) {
|
|
138
139
|
// Standard, non-prefixed capabilities (see https://www.w3.org/TR/webdriver/#dfn-table-of-standard-capabilities)
|
|
@@ -159,11 +160,17 @@ function insertAppiumPrefixes (caps) {
|
|
|
159
160
|
return prefixedCaps;
|
|
160
161
|
}
|
|
161
162
|
|
|
163
|
+
/**
|
|
164
|
+
*
|
|
165
|
+
* @param {AppiumW3CCapabilities} caps
|
|
166
|
+
* @returns {Capabilities}
|
|
167
|
+
*/
|
|
162
168
|
function removeAppiumPrefixes (caps) {
|
|
163
169
|
if (!_.isPlainObject(caps)) {
|
|
164
170
|
return caps;
|
|
165
171
|
}
|
|
166
172
|
|
|
173
|
+
/** @type {Capabilities} */
|
|
167
174
|
const fixedCaps = {};
|
|
168
175
|
for (let [name, value] of _.toPairs(caps)) {
|
|
169
176
|
fixedCaps[removeAppiumPrefix(name)] = value;
|
|
@@ -215,36 +222,32 @@ function pullSettings (caps) {
|
|
|
215
222
|
return result;
|
|
216
223
|
}
|
|
217
224
|
|
|
218
|
-
|
|
219
|
-
|
|
225
|
+
export {
|
|
226
|
+
inspect, parseCapsForInnerDriver, insertAppiumPrefixes,
|
|
227
|
+
getPackageVersion, pullSettings, removeAppiumPrefixes
|
|
228
|
+
};
|
|
220
229
|
|
|
221
230
|
/**
|
|
222
|
-
*
|
|
223
|
-
* @
|
|
224
|
-
* @
|
|
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]
|
|
225
237
|
*/
|
|
226
|
-
class ReadonlyMap extends Map {
|
|
227
|
-
/**
|
|
228
|
-
* @param {K} key
|
|
229
|
-
* @param {V} value
|
|
230
|
-
*/
|
|
231
|
-
set (key, value) {
|
|
232
|
-
if (this.has(key)) {
|
|
233
|
-
throw new Error(`${key} is already set`);
|
|
234
|
-
}
|
|
235
|
-
return super.set(key, value);
|
|
236
|
-
}
|
|
237
238
|
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
}
|
|
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
|
+
*/
|
|
246
248
|
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
}
|
|
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.28",
|
|
4
4
|
"description": "Automation for Apps.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"automation",
|
|
@@ -12,12 +12,14 @@
|
|
|
12
12
|
"firefoxos",
|
|
13
13
|
"testing"
|
|
14
14
|
],
|
|
15
|
+
"homepage": "https://appium.io",
|
|
15
16
|
"bugs": {
|
|
16
17
|
"url": "https://github.com/appium/appium/issues"
|
|
17
18
|
},
|
|
18
19
|
"repository": {
|
|
19
20
|
"type": "git",
|
|
20
|
-
"url": "https://github.com/appium/appium.git"
|
|
21
|
+
"url": "https://github.com/appium/appium.git",
|
|
22
|
+
"directory": "packages/appium"
|
|
21
23
|
},
|
|
22
24
|
"license": "Apache-2.0",
|
|
23
25
|
"author": "https://github.com/appium",
|
|
@@ -28,45 +30,49 @@
|
|
|
28
30
|
"lib": "./lib"
|
|
29
31
|
},
|
|
30
32
|
"files": [
|
|
31
|
-
"bin",
|
|
32
33
|
"lib",
|
|
33
34
|
"build",
|
|
34
35
|
"index.js",
|
|
35
|
-
"postinstall.js",
|
|
36
|
+
"scripts/postinstall.js",
|
|
36
37
|
"types"
|
|
37
38
|
],
|
|
38
39
|
"scripts": {
|
|
39
|
-
"
|
|
40
|
-
"
|
|
41
|
-
"
|
|
42
|
-
"
|
|
43
|
-
"
|
|
40
|
+
"build": "babel lib --root-mode=upward --out-dir=build/lib",
|
|
41
|
+
"dev": "npm run build -- --watch",
|
|
42
|
+
"fix": "npm run lint -- --fix",
|
|
43
|
+
"generate-docs": "node ./scripts/parse-yml-commands.js",
|
|
44
|
+
"postinstall": "node ./scripts/postinstall.js",
|
|
45
|
+
"lint": "eslint -c ../../.eslintrc --ignore-path ../../.eslintignore .",
|
|
46
|
+
"test": "npm run test:unit",
|
|
47
|
+
"test:e2e": "mocha --require ../../test/setup-babel.js --timeout 20s --slow 10s \"./test/e2e/**/*.spec.js\"",
|
|
48
|
+
"test:unit": "mocha --require ../../test/setup-babel.js \"./test/unit/**/*.spec.js\""
|
|
44
49
|
},
|
|
45
50
|
"dependencies": {
|
|
46
|
-
"@appium/base-driver": "^8.
|
|
47
|
-
"@appium/base-plugin": "1.8.
|
|
48
|
-
"@appium/
|
|
49
|
-
"@
|
|
50
|
-
"@
|
|
51
|
-
"ajv": "
|
|
51
|
+
"@appium/base-driver": "^8.4.0",
|
|
52
|
+
"@appium/base-plugin": "1.8.1",
|
|
53
|
+
"@appium/schema": "^0.0.1",
|
|
54
|
+
"@appium/support": "^2.57.0",
|
|
55
|
+
"@babel/runtime": "7.17.9",
|
|
56
|
+
"@sidvind/better-ajv-errors": "1.1.1",
|
|
57
|
+
"ajv": "8.11.0",
|
|
52
58
|
"ajv-formats": "2.1.1",
|
|
53
59
|
"argparse": "2.0.1",
|
|
54
|
-
"async-lock": "1.3.
|
|
60
|
+
"async-lock": "1.3.1",
|
|
55
61
|
"asyncbox": "2.9.2",
|
|
56
|
-
"axios": "0.
|
|
62
|
+
"axios": "0.26.1",
|
|
57
63
|
"bluebird": "3.7.2",
|
|
58
|
-
"continuation-local-storage": "3.2.1",
|
|
59
64
|
"find-up": "5.0.0",
|
|
60
|
-
"lilconfig": "2.0.
|
|
65
|
+
"lilconfig": "2.0.5",
|
|
61
66
|
"lodash": "4.17.21",
|
|
62
67
|
"longjohn": "0.2.12",
|
|
63
|
-
"npmlog": "
|
|
68
|
+
"npmlog": "6.0.1",
|
|
64
69
|
"ora": "5.4.1",
|
|
70
|
+
"package-changed": "1.9.0",
|
|
65
71
|
"resolve-from": "5.0.0",
|
|
66
|
-
"semver": "7.3.
|
|
72
|
+
"semver": "7.3.6",
|
|
67
73
|
"source-map-support": "0.5.21",
|
|
68
74
|
"teen_process": "1.16.0",
|
|
69
|
-
"winston": "3.
|
|
75
|
+
"winston": "3.7.2",
|
|
70
76
|
"word-wrap": "1.2.3",
|
|
71
77
|
"yaml": "1.10.2"
|
|
72
78
|
},
|
|
@@ -78,6 +84,6 @@
|
|
|
78
84
|
"access": "public",
|
|
79
85
|
"tag": "next"
|
|
80
86
|
},
|
|
81
|
-
"
|
|
82
|
-
"gitHead": "
|
|
87
|
+
"types": "./build/lib/index.d.ts",
|
|
88
|
+
"gitHead": "3ec3a0efa590e22e264ffbd23316ee5714a12081"
|
|
83
89
|
}
|
|
@@ -12,7 +12,7 @@ async function main () {
|
|
|
12
12
|
|
|
13
13
|
let extension;
|
|
14
14
|
try {
|
|
15
|
-
extension = require('
|
|
15
|
+
extension = require('../build/lib/cli/extension');
|
|
16
16
|
} catch (e) {
|
|
17
17
|
throw new Error(`Could not load extension CLI file; has the project been transpiled? ` +
|
|
18
18
|
`(${e.message})`);
|
|
@@ -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
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
/* eslint no-console:0 */
|
|
4
|
-
|
|
5
|
-
/*
|
|
6
|
-
* Small tool, launching and monitoring ios-web-kit-proxy, and relaunching
|
|
7
|
-
* on predefined errors.
|
|
8
|
-
*
|
|
9
|
-
* Usage:
|
|
10
|
-
* ./bin/ios-webkit-debug-proxy-launcher.js [args]
|
|
11
|
-
* args: ios-webkit-debug-proxy args (they will be passed over)
|
|
12
|
-
*
|
|
13
|
-
* Example:
|
|
14
|
-
* ./bin/ios-webkit-debug-proxy-launcher.js -c <UDID>:27753 -d
|
|
15
|
-
*
|
|
16
|
-
* Note:
|
|
17
|
-
* For iOS8.1 try this first:
|
|
18
|
-
* brew install --HEAD ideviceinstaller
|
|
19
|
-
*/
|
|
20
|
-
|
|
21
|
-
'use strict';
|
|
22
|
-
|
|
23
|
-
const spawn = require('child_process').spawn;
|
|
24
|
-
const _ = require('lodash');
|
|
25
|
-
|
|
26
|
-
const args = process.argv.slice(2);
|
|
27
|
-
|
|
28
|
-
const RESTART_ON_MESSAGES = [
|
|
29
|
-
'Invalid message _rpc_applicationUpdated',
|
|
30
|
-
'Invalid message _rpc_applicationSentListing'];
|
|
31
|
-
|
|
32
|
-
const PROXY_CMD = 'ios_webkit_debug_proxy';
|
|
33
|
-
let proxy;
|
|
34
|
-
|
|
35
|
-
const handleKillProcess = function (exitCode) {
|
|
36
|
-
console.log('\nKilling proxy process!');
|
|
37
|
-
proxy.kill('SIGTERM');
|
|
38
|
-
process.exit((exitCode || 0));
|
|
39
|
-
};
|
|
40
|
-
|
|
41
|
-
const startProxy = function () {
|
|
42
|
-
console.log(`RUNNING: ${PROXY_CMD} ${args.join(' ')}`);
|
|
43
|
-
|
|
44
|
-
proxy = spawn(PROXY_CMD, args);
|
|
45
|
-
|
|
46
|
-
proxy.stdout.on('data', function onStdout (data) {
|
|
47
|
-
console.log(`stdout: ${data}`);
|
|
48
|
-
});
|
|
49
|
-
|
|
50
|
-
proxy.stderr.on('data', function onStderr (data) {
|
|
51
|
-
console.log(`stderr: ${data}`);
|
|
52
|
-
const restartMessage = _(RESTART_ON_MESSAGES).find(function findMessage (message) {
|
|
53
|
-
return ('' + data).indexOf(message) >= 0;
|
|
54
|
-
});
|
|
55
|
-
if (restartMessage) {
|
|
56
|
-
console.log(`Detected error message: ${restartMessage}`);
|
|
57
|
-
console.log('Killing proxy!');
|
|
58
|
-
proxy.kill('SIGTERM');
|
|
59
|
-
process.nextTick(startProxy);
|
|
60
|
-
}
|
|
61
|
-
});
|
|
62
|
-
|
|
63
|
-
proxy.on('close', function onClose (code) {
|
|
64
|
-
console.log(`Child process exited with code ${code}`);
|
|
65
|
-
});
|
|
66
|
-
};
|
|
67
|
-
|
|
68
|
-
process.on('SIGINT', handleKillProcess);
|
|
69
|
-
process.on('SIGTERM', handleKillProcess);
|
|
70
|
-
|
|
71
|
-
startProxy();
|