appium 2.0.0-beta.34 → 2.0.0-beta.38
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 +41 -52
- package/build/lib/appium.d.ts.map +1 -1
- package/build/lib/appium.js +32 -15
- package/build/lib/cli/args.d.ts +1 -1
- package/build/lib/cli/args.d.ts.map +1 -1
- package/build/lib/cli/args.js +1 -1
- package/build/lib/cli/driver-command.d.ts +5 -5
- package/build/lib/cli/driver-command.d.ts.map +1 -1
- package/build/lib/cli/driver-command.js +8 -8
- package/build/lib/cli/extension-command.d.ts +78 -51
- package/build/lib/cli/extension-command.d.ts.map +1 -1
- package/build/lib/cli/extension-command.js +135 -80
- package/build/lib/cli/extension.d.ts +9 -5
- package/build/lib/cli/extension.d.ts.map +1 -1
- package/build/lib/cli/extension.js +5 -7
- package/build/lib/cli/parser.d.ts +3 -3
- package/build/lib/cli/parser.d.ts.map +1 -1
- package/build/lib/cli/parser.js +1 -1
- package/build/lib/cli/plugin-command.d.ts +9 -15
- package/build/lib/cli/plugin-command.d.ts.map +1 -1
- package/build/lib/cli/plugin-command.js +8 -8
- package/build/lib/cli/utils.js +1 -1
- package/build/lib/config-file.d.ts.map +1 -1
- package/build/lib/config-file.js +1 -1
- package/build/lib/config.d.ts +4 -4
- package/build/lib/config.d.ts.map +1 -1
- package/build/lib/config.js +1 -1
- package/build/lib/constants.d.ts.map +1 -1
- package/build/lib/constants.js +1 -1
- package/build/lib/extension/driver-config.d.ts +29 -32
- package/build/lib/extension/driver-config.d.ts.map +1 -1
- package/build/lib/extension/driver-config.js +7 -20
- package/build/lib/extension/extension-config.d.ts +108 -36
- package/build/lib/extension/extension-config.d.ts.map +1 -1
- package/build/lib/extension/extension-config.js +199 -60
- package/build/lib/extension/index.d.ts +16 -7
- package/build/lib/extension/index.d.ts.map +1 -1
- package/build/lib/extension/index.js +15 -18
- package/build/lib/extension/manifest.d.ts +12 -12
- package/build/lib/extension/manifest.d.ts.map +1 -1
- package/build/lib/extension/manifest.js +13 -3
- package/build/lib/extension/package-changed.d.ts.map +1 -1
- package/build/lib/extension/package-changed.js +1 -1
- package/build/lib/extension/plugin-config.d.ts +19 -24
- package/build/lib/extension/plugin-config.d.ts.map +1 -1
- package/build/lib/extension/plugin-config.js +9 -18
- package/build/lib/grid-register.d.ts.map +1 -1
- package/build/lib/grid-register.js +1 -1
- package/build/lib/logger.d.ts +1 -1
- package/build/lib/logger.d.ts.map +1 -1
- package/build/lib/logger.js +1 -1
- package/build/lib/logsink.d.ts.map +1 -1
- package/build/lib/logsink.js +3 -2
- package/build/lib/main.d.ts +13 -12
- package/build/lib/main.d.ts.map +1 -1
- package/build/lib/main.js +4 -4
- package/build/lib/schema/arg-spec.d.ts +4 -4
- package/build/lib/schema/arg-spec.d.ts.map +1 -1
- package/build/lib/schema/arg-spec.js +1 -1
- package/build/lib/schema/cli-args.d.ts.map +1 -1
- package/build/lib/schema/cli-args.js +1 -1
- package/build/lib/schema/cli-transformers.d.ts.map +1 -1
- package/build/lib/schema/cli-transformers.js +1 -1
- package/build/lib/schema/keywords.d.ts.map +1 -1
- package/build/lib/schema/keywords.js +1 -1
- package/build/lib/schema/schema.d.ts +2 -2
- package/build/lib/schema/schema.d.ts.map +1 -1
- package/build/lib/schema/schema.js +1 -1
- package/build/lib/utils.d.ts.map +1 -1
- package/build/lib/utils.js +1 -1
- package/build/tsconfig.tsbuildinfo +1 -1
- package/build/types/appium-manifest.d.ts +23 -4
- package/build/types/appium-manifest.d.ts.map +1 -1
- package/build/types/cli.d.ts.map +1 -1
- package/build/types/{external-manifest.d.ts → extension-manifest.d.ts} +15 -7
- package/build/types/extension-manifest.d.ts.map +1 -0
- package/build/types/index.d.ts +6 -5
- package/build/types/index.d.ts.map +1 -1
- package/driver.d.ts +1 -0
- package/driver.js +14 -0
- package/lib/appium.js +208 -124
- package/lib/cli/args.js +143 -93
- package/lib/cli/driver-command.js +46 -26
- package/lib/cli/extension-command.js +314 -157
- package/lib/cli/extension.js +15 -19
- package/lib/cli/parser.js +19 -31
- package/lib/cli/plugin-command.js +39 -24
- package/lib/cli/utils.js +8 -14
- package/lib/config-file.js +21 -25
- package/lib/config.js +82 -64
- package/lib/constants.js +4 -13
- package/lib/extension/driver-config.js +171 -171
- package/lib/extension/extension-config.js +347 -126
- package/lib/extension/index.js +72 -58
- package/lib/extension/manifest.js +48 -57
- package/lib/extension/package-changed.js +9 -8
- package/lib/extension/plugin-config.js +62 -62
- package/lib/grid-register.js +29 -18
- package/lib/logger.js +1 -2
- package/lib/logsink.js +29 -31
- package/lib/main.js +111 -73
- package/lib/schema/arg-spec.js +10 -13
- package/lib/schema/cli-args.js +14 -37
- package/lib/schema/cli-transformers.js +7 -14
- package/lib/schema/keywords.js +15 -13
- package/lib/schema/schema.js +58 -75
- package/lib/utils.js +50 -25
- package/package.json +25 -18
- package/plugin.d.ts +1 -0
- package/plugin.js +13 -0
- package/scripts/autoinstall-extensions.js +177 -0
- package/support.d.ts +1 -0
- package/support.js +13 -0
- package/types/appium-manifest.ts +27 -15
- package/types/cli.ts +2 -9
- package/types/{external-manifest.ts → extension-manifest.ts} +21 -15
- package/types/index.ts +12 -5
- package/build/types/extension.d.ts +0 -43
- package/build/types/extension.d.ts.map +0 -1
- package/build/types/external-manifest.d.ts.map +0 -1
- package/lib/appium-config.schema.json +0 -278
- package/scripts/postinstall.js +0 -71
- package/types/extension.ts +0 -56
package/lib/schema/keywords.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
import { transformers } from './cli-transformers';
|
|
1
|
+
import {transformers} from './cli-transformers';
|
|
3
2
|
|
|
4
3
|
/**
|
|
5
4
|
* Collection of keyword definitions to add to the singleton `Ajv` instance.
|
|
@@ -27,7 +26,8 @@ export const keywords = {
|
|
|
27
26
|
},
|
|
28
27
|
minItems: 1,
|
|
29
28
|
uniqueItems: true,
|
|
30
|
-
description:
|
|
29
|
+
description:
|
|
30
|
+
'List of aliases for the argument. Aliases shorter than three (3) characters will be prefixed with a single dash; otherwise two (2).',
|
|
31
31
|
},
|
|
32
32
|
},
|
|
33
33
|
/**
|
|
@@ -45,7 +45,7 @@ export const keywords = {
|
|
|
45
45
|
metaSchema: {
|
|
46
46
|
type: 'string',
|
|
47
47
|
minLength: 1,
|
|
48
|
-
description: 'Name of the associated property in the parsed CLI arguments object'
|
|
48
|
+
description: 'Name of the associated property in the parsed CLI arguments object',
|
|
49
49
|
},
|
|
50
50
|
},
|
|
51
51
|
|
|
@@ -63,7 +63,7 @@ export const keywords = {
|
|
|
63
63
|
metaSchema: {
|
|
64
64
|
type: 'string',
|
|
65
65
|
minLength: 1,
|
|
66
|
-
description: 'Description to provide in the --help text of the CLI. Overrides `description`'
|
|
66
|
+
description: 'Description to provide in the --help text of the CLI. Overrides `description`',
|
|
67
67
|
},
|
|
68
68
|
},
|
|
69
69
|
|
|
@@ -77,7 +77,8 @@ export const keywords = {
|
|
|
77
77
|
metaSchema: {
|
|
78
78
|
type: 'string',
|
|
79
79
|
enum: Object.keys(transformers),
|
|
80
|
-
description:
|
|
80
|
+
description:
|
|
81
|
+
'The name of a custom transformer to run against the value as provided via the CLI.',
|
|
81
82
|
},
|
|
82
83
|
},
|
|
83
84
|
|
|
@@ -89,9 +90,10 @@ export const keywords = {
|
|
|
89
90
|
keyword: 'appiumCliIgnored',
|
|
90
91
|
metaSchema: {
|
|
91
92
|
type: 'boolean',
|
|
92
|
-
description:
|
|
93
|
-
|
|
94
|
-
|
|
93
|
+
description:
|
|
94
|
+
'If `true`, Appium will not provide this property as a CLI argument. This is NOT the same as a "hidden" argument.',
|
|
95
|
+
enum: [true],
|
|
96
|
+
},
|
|
95
97
|
},
|
|
96
98
|
|
|
97
99
|
/**
|
|
@@ -104,9 +106,10 @@ export const keywords = {
|
|
|
104
106
|
type: 'boolean',
|
|
105
107
|
description: 'If `true`, this property will be displayed as "deprecated" to the user',
|
|
106
108
|
enum: [true],
|
|
107
|
-
$comment:
|
|
108
|
-
|
|
109
|
-
|
|
109
|
+
$comment:
|
|
110
|
+
'JSON schema draft-2019-09 keyword `deprecated` serves the same purpose. This keyword should itself be deprecated if we move to draft-2019-09!',
|
|
111
|
+
},
|
|
112
|
+
},
|
|
110
113
|
};
|
|
111
114
|
|
|
112
115
|
/**
|
|
@@ -128,7 +131,6 @@ export const keywords = {
|
|
|
128
131
|
* @property {boolean} [appiumDeprecated]
|
|
129
132
|
*/
|
|
130
133
|
|
|
131
|
-
|
|
132
134
|
/**
|
|
133
135
|
* @typedef {import('ajv').KeywordDefinition} KeywordDefinition
|
|
134
136
|
*/
|
package/lib/schema/schema.js
CHANGED
|
@@ -1,12 +1,11 @@
|
|
|
1
|
-
|
|
2
1
|
import Ajv from 'ajv';
|
|
3
2
|
import addFormats from 'ajv-formats';
|
|
4
3
|
import _ from 'lodash';
|
|
5
4
|
import path from 'path';
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
5
|
+
import {DRIVER_TYPE, PLUGIN_TYPE} from '../constants';
|
|
6
|
+
import {AppiumConfigJsonSchema} from '@appium/schema';
|
|
7
|
+
import {APPIUM_CONFIG_SCHEMA_ID, ArgSpec, SERVER_PROP_NAME} from './arg-spec';
|
|
8
|
+
import {keywords} from './keywords';
|
|
10
9
|
|
|
11
10
|
/**
|
|
12
11
|
* Key/value pairs go in... but they don't come out.
|
|
@@ -19,7 +18,7 @@ export class RoachHotelMap extends Map {
|
|
|
19
18
|
* @param {K} key
|
|
20
19
|
* @param {V} value
|
|
21
20
|
*/
|
|
22
|
-
set
|
|
21
|
+
set(key, value) {
|
|
23
22
|
if (this.has(key)) {
|
|
24
23
|
throw new Error(`${key} is already set`);
|
|
25
24
|
}
|
|
@@ -30,11 +29,11 @@ export class RoachHotelMap extends Map {
|
|
|
30
29
|
* @param {K} key
|
|
31
30
|
*/
|
|
32
31
|
// eslint-disable-next-line no-unused-vars
|
|
33
|
-
delete
|
|
32
|
+
delete(key) {
|
|
34
33
|
return false;
|
|
35
34
|
}
|
|
36
35
|
|
|
37
|
-
clear
|
|
36
|
+
clear() {
|
|
38
37
|
throw new Error(`Cannot clear RoachHotelMap`);
|
|
39
38
|
}
|
|
40
39
|
}
|
|
@@ -100,7 +99,7 @@ class AppiumSchema {
|
|
|
100
99
|
* @see https://npm.im/ajv-formats
|
|
101
100
|
* @private
|
|
102
101
|
*/
|
|
103
|
-
constructor
|
|
102
|
+
constructor() {
|
|
104
103
|
this._ajv = AppiumSchema._instantiateAjv();
|
|
105
104
|
}
|
|
106
105
|
|
|
@@ -111,7 +110,7 @@ class AppiumSchema {
|
|
|
111
110
|
* Binds public methods to the instance.
|
|
112
111
|
* @returns {AppiumSchema}
|
|
113
112
|
*/
|
|
114
|
-
static create
|
|
113
|
+
static create() {
|
|
115
114
|
if (!AppiumSchema._instance) {
|
|
116
115
|
const instance = new AppiumSchema();
|
|
117
116
|
AppiumSchema._instance = instance;
|
|
@@ -143,7 +142,7 @@ class AppiumSchema {
|
|
|
143
142
|
* @param {string} extName - Name
|
|
144
143
|
* @returns {boolean} If registered
|
|
145
144
|
*/
|
|
146
|
-
hasRegisteredSchema
|
|
145
|
+
hasRegisteredSchema(extType, extName) {
|
|
147
146
|
return this._registeredSchemas[extType].has(extName);
|
|
148
147
|
}
|
|
149
148
|
|
|
@@ -152,11 +151,11 @@ class AppiumSchema {
|
|
|
152
151
|
* successfully and {@link AppiumSchema.reset reset} has not been called since.
|
|
153
152
|
* @returns {boolean} If finalized
|
|
154
153
|
*/
|
|
155
|
-
isFinalized
|
|
154
|
+
isFinalized() {
|
|
156
155
|
return Boolean(this._finalizedSchemas);
|
|
157
156
|
}
|
|
158
157
|
|
|
159
|
-
getAllArgSpecs
|
|
158
|
+
getAllArgSpecs() {
|
|
160
159
|
return this._argSpecs;
|
|
161
160
|
}
|
|
162
161
|
|
|
@@ -179,11 +178,9 @@ class AppiumSchema {
|
|
|
179
178
|
* @throws {Error} If the schema is not valid
|
|
180
179
|
* @returns {Readonly<Record<string,StrictSchemaObject>>} Record of schema IDs to full schema objects
|
|
181
180
|
*/
|
|
182
|
-
finalize
|
|
181
|
+
finalize() {
|
|
183
182
|
if (this.isFinalized()) {
|
|
184
|
-
return /** @type {NonNullable<typeof this._finalizedSchemas>} */ (
|
|
185
|
-
this._finalizedSchemas
|
|
186
|
-
);
|
|
183
|
+
return /** @type {NonNullable<typeof this._finalizedSchemas>} */ (this._finalizedSchemas);
|
|
187
184
|
}
|
|
188
185
|
|
|
189
186
|
const ajv = this._ajv;
|
|
@@ -210,12 +207,7 @@ class AppiumSchema {
|
|
|
210
207
|
}
|
|
211
208
|
};
|
|
212
209
|
|
|
213
|
-
addArgSpecs(
|
|
214
|
-
_.omit(baseSchema.properties.server.properties, [
|
|
215
|
-
DRIVER_TYPE,
|
|
216
|
-
PLUGIN_TYPE,
|
|
217
|
-
]),
|
|
218
|
-
);
|
|
210
|
+
addArgSpecs(_.omit(baseSchema.properties.server.properties, [DRIVER_TYPE, PLUGIN_TYPE]));
|
|
219
211
|
|
|
220
212
|
/**
|
|
221
213
|
* @type {Record<string,StrictSchemaObject>}
|
|
@@ -234,8 +226,10 @@ class AppiumSchema {
|
|
|
234
226
|
const $ref = ArgSpec.toSchemaBaseRef(extType, extName);
|
|
235
227
|
schema.$id = $ref;
|
|
236
228
|
schema.additionalProperties = false; // this makes `schema` become a `StrictSchemaObject`
|
|
237
|
-
baseSchema.properties.server.properties[extType].properties[extName] =
|
|
238
|
-
|
|
229
|
+
baseSchema.properties.server.properties[extType].properties[extName] = {
|
|
230
|
+
$ref,
|
|
231
|
+
$comment: extName,
|
|
232
|
+
};
|
|
239
233
|
ajv.validateSchema(schema, true);
|
|
240
234
|
addArgSpecs(schema.properties, extType, extName);
|
|
241
235
|
ajv.addSchema(schema, $ref);
|
|
@@ -243,7 +237,7 @@ class AppiumSchema {
|
|
|
243
237
|
});
|
|
244
238
|
return baseSchema;
|
|
245
239
|
},
|
|
246
|
-
baseSchema
|
|
240
|
+
baseSchema
|
|
247
241
|
);
|
|
248
242
|
|
|
249
243
|
ajv.addSchema(finalSchema, APPIUM_CONFIG_SCHEMA_ID);
|
|
@@ -259,12 +253,12 @@ class AppiumSchema {
|
|
|
259
253
|
* @private
|
|
260
254
|
* @returns {Ajv}
|
|
261
255
|
*/
|
|
262
|
-
static _instantiateAjv
|
|
256
|
+
static _instantiateAjv() {
|
|
263
257
|
const ajv = addFormats(
|
|
264
258
|
new Ajv({
|
|
265
259
|
// without this not much validation actually happens
|
|
266
260
|
allErrors: true,
|
|
267
|
-
})
|
|
261
|
+
})
|
|
268
262
|
);
|
|
269
263
|
|
|
270
264
|
// add custom keywords to ajv. see schema-keywords.js
|
|
@@ -286,7 +280,7 @@ class AppiumSchema {
|
|
|
286
280
|
* If you need to call {@link AppiumSchema.finalize} again, you'll want to call this first.
|
|
287
281
|
* @returns {void}
|
|
288
282
|
*/
|
|
289
|
-
reset
|
|
283
|
+
reset() {
|
|
290
284
|
for (const schemaId of Object.keys(this._finalizedSchemas ?? {})) {
|
|
291
285
|
this._ajv.removeSchema(schemaId);
|
|
292
286
|
}
|
|
@@ -313,11 +307,9 @@ class AppiumSchema {
|
|
|
313
307
|
* @throws {SchemaNameConflictError} If the schema is an invalid
|
|
314
308
|
* @returns {void}
|
|
315
309
|
*/
|
|
316
|
-
registerSchema
|
|
310
|
+
registerSchema(extType, extName, schema) {
|
|
317
311
|
if (!(extType && extName) || _.isUndefined(schema)) {
|
|
318
|
-
throw new TypeError(
|
|
319
|
-
'Expected extension type, extension name, and a defined schema',
|
|
320
|
-
);
|
|
312
|
+
throw new TypeError('Expected extension type, extension name, and a defined schema');
|
|
321
313
|
}
|
|
322
314
|
if (!AppiumSchema.isSupportedSchemaType(schema)) {
|
|
323
315
|
throw new SchemaUnsupportedSchemaError(schema, extType, extName);
|
|
@@ -341,7 +333,7 @@ class AppiumSchema {
|
|
|
341
333
|
* @param {string} [extName] - Extension name
|
|
342
334
|
* @returns {ArgSpec|undefined} ArgSpec or `undefined` if not found
|
|
343
335
|
*/
|
|
344
|
-
getArgSpec
|
|
336
|
+
getArgSpec(name, extType, extName) {
|
|
345
337
|
return this._argSpecs.get(ArgSpec.toArg(name, extType, extName));
|
|
346
338
|
}
|
|
347
339
|
|
|
@@ -352,7 +344,7 @@ class AppiumSchema {
|
|
|
352
344
|
* @param {string} [extName] - Extension name
|
|
353
345
|
* @returns {boolean} `true` if such an {@link ArgSpec} exists
|
|
354
346
|
*/
|
|
355
|
-
hasArgSpec
|
|
347
|
+
hasArgSpec(name, extType, extName) {
|
|
356
348
|
return this._argSpecs.has(ArgSpec.toArg(name, extType, extName));
|
|
357
349
|
}
|
|
358
350
|
|
|
@@ -368,7 +360,7 @@ class AppiumSchema {
|
|
|
368
360
|
* properties. Base arguments (server arguments) are always at the top level.
|
|
369
361
|
* @returns {DefaultValues<Flattened>}
|
|
370
362
|
*/
|
|
371
|
-
getDefaults
|
|
363
|
+
getDefaults(flatten = /** @type {Flattened} */ (true)) {
|
|
372
364
|
if (!this.isFinalized()) {
|
|
373
365
|
throw new SchemaFinalizationError();
|
|
374
366
|
}
|
|
@@ -383,17 +375,17 @@ class AppiumSchema {
|
|
|
383
375
|
/** @type {DefaultReducer} */
|
|
384
376
|
const reducer = flatten
|
|
385
377
|
? (defaults, {defaultValue, dest}) => {
|
|
386
|
-
|
|
387
|
-
|
|
378
|
+
if (!_.isUndefined(defaultValue)) {
|
|
379
|
+
defaults[dest] = defaultValue;
|
|
380
|
+
}
|
|
381
|
+
return defaults;
|
|
388
382
|
}
|
|
389
|
-
return defaults;
|
|
390
|
-
}
|
|
391
383
|
: (defaults, {defaultValue, dest}) => {
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
384
|
+
if (!_.isUndefined(defaultValue)) {
|
|
385
|
+
_.set(defaults, dest, defaultValue);
|
|
386
|
+
}
|
|
387
|
+
return defaults;
|
|
388
|
+
};
|
|
397
389
|
|
|
398
390
|
/** @type {DefaultValues<Flattened>} */
|
|
399
391
|
const retval = {};
|
|
@@ -407,12 +399,12 @@ class AppiumSchema {
|
|
|
407
399
|
* @param {string} extName - Extension name
|
|
408
400
|
* @returns {Record<string,ArgSpecDefaultValue>}
|
|
409
401
|
*/
|
|
410
|
-
getDefaultsForExtension
|
|
402
|
+
getDefaultsForExtension(extType, extName) {
|
|
411
403
|
if (!this.isFinalized()) {
|
|
412
404
|
throw new SchemaFinalizationError();
|
|
413
405
|
}
|
|
414
406
|
const specs = [...this._argSpecs.values()].filter(
|
|
415
|
-
(spec) => spec.extType === extType && spec.extName === extName
|
|
407
|
+
(spec) => spec.extType === extType && spec.extName === extName
|
|
416
408
|
);
|
|
417
409
|
return specs.reduce((defaults, {defaultValue, rawDest}) => {
|
|
418
410
|
if (!_.isUndefined(defaultValue)) {
|
|
@@ -436,7 +428,7 @@ class AppiumSchema {
|
|
|
436
428
|
* @throws If {@link AppiumSchema.finalize} has not been called yet.
|
|
437
429
|
* @returns {FlattenedSchema}
|
|
438
430
|
*/
|
|
439
|
-
flatten
|
|
431
|
+
flatten() {
|
|
440
432
|
const schema = this.getSchema();
|
|
441
433
|
|
|
442
434
|
/** @type { {properties: SchemaObject, prefix: string[]}[] } */
|
|
@@ -463,12 +455,11 @@ class AppiumSchema {
|
|
|
463
455
|
// this can happen if an extension schema supplies a $ref to a non-existent schema
|
|
464
456
|
throw new SchemaUnknownSchemaError($ref);
|
|
465
457
|
}
|
|
466
|
-
const {normalizedExtName} =
|
|
467
|
-
ArgSpec.extensionInfoFromRootSchemaId($ref);
|
|
458
|
+
const {normalizedExtName} = ArgSpec.extensionInfoFromRootSchemaId($ref);
|
|
468
459
|
if (!normalizedExtName) {
|
|
469
460
|
/* istanbul ignore next */
|
|
470
461
|
throw new ReferenceError(
|
|
471
|
-
`Could not determine extension name from schema ID ${$ref}. This is a bug
|
|
462
|
+
`Could not determine extension name from schema ID ${$ref}. This is a bug.`
|
|
472
463
|
);
|
|
473
464
|
}
|
|
474
465
|
stack.push({
|
|
@@ -477,15 +468,11 @@ class AppiumSchema {
|
|
|
477
468
|
});
|
|
478
469
|
} else if (key !== DRIVER_TYPE && key !== PLUGIN_TYPE) {
|
|
479
470
|
const [extType, extName] = prefix;
|
|
480
|
-
const argSpec = this.getArgSpec(
|
|
481
|
-
key,
|
|
482
|
-
/** @type {ExtensionType} */ (extType),
|
|
483
|
-
extName,
|
|
484
|
-
);
|
|
471
|
+
const argSpec = this.getArgSpec(key, /** @type {ExtensionType} */ (extType), extName);
|
|
485
472
|
if (!argSpec) {
|
|
486
473
|
/* istanbul ignore next */
|
|
487
474
|
throw new ReferenceError(
|
|
488
|
-
`Unknown argument with key ${key}, extType ${extType} and extName ${extName}. This is a bug
|
|
475
|
+
`Unknown argument with key ${key}, extType ${extType} and extName ${extName}. This is a bug.`
|
|
489
476
|
);
|
|
490
477
|
}
|
|
491
478
|
flattened.push({schema: _.cloneDeep(value), argSpec});
|
|
@@ -503,7 +490,7 @@ class AppiumSchema {
|
|
|
503
490
|
* @throws If the schema has not yet been finalized
|
|
504
491
|
* @returns {SchemaObject}
|
|
505
492
|
*/
|
|
506
|
-
getSchema
|
|
493
|
+
getSchema(ref = APPIUM_CONFIG_SCHEMA_ID) {
|
|
507
494
|
return /** @type {SchemaObject} */ (this._getValidator(ref).schema);
|
|
508
495
|
}
|
|
509
496
|
|
|
@@ -513,7 +500,7 @@ class AppiumSchema {
|
|
|
513
500
|
* @private
|
|
514
501
|
* @returns {import('ajv').ValidateFunction}
|
|
515
502
|
*/
|
|
516
|
-
_getValidator
|
|
503
|
+
_getValidator(id = APPIUM_CONFIG_SCHEMA_ID) {
|
|
517
504
|
const validator = this._ajv.getSchema(id);
|
|
518
505
|
if (!validator) {
|
|
519
506
|
if (id === APPIUM_CONFIG_SCHEMA_ID) {
|
|
@@ -533,11 +520,9 @@ class AppiumSchema {
|
|
|
533
520
|
* @public
|
|
534
521
|
* @returns {import('ajv').ErrorObject[]} Array of errors, if any.
|
|
535
522
|
*/
|
|
536
|
-
validate
|
|
523
|
+
validate(value, ref = APPIUM_CONFIG_SCHEMA_ID) {
|
|
537
524
|
const validator = this._getValidator(ref);
|
|
538
|
-
return !validator(value) && _.isArray(validator.errors)
|
|
539
|
-
? [...validator.errors]
|
|
540
|
-
: [];
|
|
525
|
+
return !validator(value) && _.isArray(validator.errors) ? [...validator.errors] : [];
|
|
541
526
|
}
|
|
542
527
|
|
|
543
528
|
/**
|
|
@@ -545,7 +530,7 @@ class AppiumSchema {
|
|
|
545
530
|
* @param {string} filename
|
|
546
531
|
* @returns {boolean}
|
|
547
532
|
*/
|
|
548
|
-
static isAllowedSchemaFileExtension
|
|
533
|
+
static isAllowedSchemaFileExtension(filename) {
|
|
549
534
|
return ALLOWED_SCHEMA_EXTENSIONS.has(path.extname(filename));
|
|
550
535
|
}
|
|
551
536
|
|
|
@@ -554,7 +539,7 @@ class AppiumSchema {
|
|
|
554
539
|
* @param {any} schema - Schema to check
|
|
555
540
|
* @returns {schema is SchemaObject}
|
|
556
541
|
*/
|
|
557
|
-
static isSupportedSchemaType
|
|
542
|
+
static isSupportedSchemaType(schema) {
|
|
558
543
|
return _.isPlainObject(schema) && schema.$async !== true;
|
|
559
544
|
}
|
|
560
545
|
}
|
|
@@ -569,7 +554,7 @@ export class SchemaFinalizationError extends Error {
|
|
|
569
554
|
*/
|
|
570
555
|
code = 'APPIUMERR_SCHEMA_FINALIZATION';
|
|
571
556
|
|
|
572
|
-
constructor
|
|
557
|
+
constructor() {
|
|
573
558
|
super('Schema not yet finalized; `finalize()` must be called first.');
|
|
574
559
|
}
|
|
575
560
|
}
|
|
@@ -594,10 +579,8 @@ export class SchemaNameConflictError extends Error {
|
|
|
594
579
|
* @param {ExtensionType} extType
|
|
595
580
|
* @param {string} extName
|
|
596
581
|
*/
|
|
597
|
-
constructor
|
|
598
|
-
super(
|
|
599
|
-
`Name for ${extType} schema "${extName}" conflicts with an existing schema`,
|
|
600
|
-
);
|
|
582
|
+
constructor(extType, extName) {
|
|
583
|
+
super(`Name for ${extType} schema "${extName}" conflicts with an existing schema`);
|
|
601
584
|
this.data = {extType, extName};
|
|
602
585
|
}
|
|
603
586
|
}
|
|
@@ -619,7 +602,7 @@ export class SchemaUnknownSchemaError extends ReferenceError {
|
|
|
619
602
|
/**
|
|
620
603
|
* @param {string} schemaId
|
|
621
604
|
*/
|
|
622
|
-
constructor
|
|
605
|
+
constructor(schemaId) {
|
|
623
606
|
super(`Unknown schema: "${schemaId}"`);
|
|
624
607
|
this.data = {schemaId};
|
|
625
608
|
}
|
|
@@ -647,7 +630,7 @@ export class SchemaUnsupportedSchemaError extends TypeError {
|
|
|
647
630
|
* @param {ExtensionType} extType
|
|
648
631
|
* @param {string} extName
|
|
649
632
|
*/
|
|
650
|
-
constructor
|
|
633
|
+
constructor(schema, extType, extName) {
|
|
651
634
|
// https://github.com/Microsoft/TypeScript/issues/8277
|
|
652
635
|
super(
|
|
653
636
|
(() => {
|
|
@@ -662,12 +645,12 @@ export class SchemaUnsupportedSchemaError extends TypeError {
|
|
|
662
645
|
/* istanbul ignore next */
|
|
663
646
|
throw new TypeError(
|
|
664
647
|
`schema IS supported; this error should not be thrown (this is a bug). value of schema: ${JSON.stringify(
|
|
665
|
-
schema
|
|
666
|
-
)}
|
|
648
|
+
schema
|
|
649
|
+
)}`
|
|
667
650
|
);
|
|
668
651
|
}
|
|
669
652
|
return `${msg} schema must be a plain object without a true "$async" property`;
|
|
670
|
-
})()
|
|
653
|
+
})()
|
|
671
654
|
);
|
|
672
655
|
this.data = {schema, extType, extName};
|
|
673
656
|
}
|
package/lib/utils.js
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
|
|
2
1
|
import _ from 'lodash';
|
|
3
2
|
import logger from './logger';
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
3
|
+
import {processCapabilities, PROTOCOLS} from '@appium/base-driver';
|
|
4
|
+
import {inspect as dump} from 'util';
|
|
6
5
|
|
|
7
6
|
const W3C_APPIUM_PREFIX = 'appium';
|
|
8
7
|
|
|
@@ -22,12 +21,13 @@ const isStdoutTTY = process.stdout.isTTY;
|
|
|
22
21
|
*/
|
|
23
22
|
const inspect = _.flow(
|
|
24
23
|
_.partialRight(
|
|
25
|
-
/** @type {(object: any, options: import('util').InspectOptions) => string} */(dump),
|
|
24
|
+
/** @type {(object: any, options: import('util').InspectOptions) => string} */ (dump),
|
|
26
25
|
{colors: true, depth: null, compact: !isStdoutTTY}
|
|
27
26
|
),
|
|
28
27
|
(...args) => {
|
|
29
28
|
logger.info(...args);
|
|
30
|
-
}
|
|
29
|
+
}
|
|
30
|
+
);
|
|
31
31
|
|
|
32
32
|
/**
|
|
33
33
|
* Takes the caps that were provided in the request and translates them
|
|
@@ -39,19 +39,25 @@ const inspect = _.flow(
|
|
|
39
39
|
* @param {import('@appium/types').DefaultCapabilitiesConfig} [defaultCapabilities]
|
|
40
40
|
* @returns {ParsedDriverCaps|InvalidCaps}
|
|
41
41
|
*/
|
|
42
|
-
function parseCapsForInnerDriver
|
|
42
|
+
function parseCapsForInnerDriver(
|
|
43
|
+
jsonwpCapabilities,
|
|
44
|
+
w3cCapabilities,
|
|
45
|
+
constraints = {},
|
|
46
|
+
defaultCapabilities = {}
|
|
47
|
+
) {
|
|
43
48
|
// Check if the caller sent JSONWP caps, W3C caps, or both
|
|
44
|
-
const hasW3CCaps =
|
|
49
|
+
const hasW3CCaps =
|
|
50
|
+
_.isPlainObject(w3cCapabilities) &&
|
|
45
51
|
(_.has(w3cCapabilities, 'alwaysMatch') || _.has(w3cCapabilities, 'firstMatch'));
|
|
46
52
|
const hasJSONWPCaps = _.isPlainObject(jsonwpCapabilities);
|
|
47
|
-
let desiredCaps = /** @type {ParsedDriverCaps['desiredCaps']} */({});
|
|
53
|
+
let desiredCaps = /** @type {ParsedDriverCaps['desiredCaps']} */ ({});
|
|
48
54
|
/** @type {ParsedDriverCaps['processedW3CCapabilities']} */
|
|
49
55
|
let processedW3CCapabilities;
|
|
50
56
|
/** @type {ParsedDriverCaps['processedJsonwpCapabilities']} */
|
|
51
57
|
let processedJsonwpCapabilities;
|
|
52
58
|
|
|
53
59
|
if (!hasW3CCaps) {
|
|
54
|
-
return /** @type {InvalidCaps} */({
|
|
60
|
+
return /** @type {InvalidCaps} */ ({
|
|
55
61
|
protocol: PROTOCOLS.W3C,
|
|
56
62
|
error: new Error('W3C capabilities should be provided'),
|
|
57
63
|
});
|
|
@@ -70,16 +76,23 @@ function parseCapsForInnerDriver (jsonwpCapabilities, w3cCapabilities, constrain
|
|
|
70
76
|
for (const [defaultCapKey, defaultCapValue] of _.toPairs(defaultCapabilities)) {
|
|
71
77
|
let isCapAlreadySet = false;
|
|
72
78
|
// Check if the key is already present in firstMatch entries
|
|
73
|
-
for (const firstMatchEntry of
|
|
74
|
-
if (
|
|
75
|
-
|
|
79
|
+
for (const firstMatchEntry of w3cCapabilities.firstMatch || []) {
|
|
80
|
+
if (
|
|
81
|
+
_.isPlainObject(firstMatchEntry) &&
|
|
82
|
+
_.has(removeAppiumPrefixes(firstMatchEntry), removeAppiumPrefix(defaultCapKey))
|
|
83
|
+
) {
|
|
76
84
|
isCapAlreadySet = true;
|
|
77
85
|
break;
|
|
78
86
|
}
|
|
79
87
|
}
|
|
80
88
|
// Check if the key is already present in alwaysMatch entries
|
|
81
|
-
isCapAlreadySet =
|
|
82
|
-
|
|
89
|
+
isCapAlreadySet =
|
|
90
|
+
isCapAlreadySet ||
|
|
91
|
+
(_.isPlainObject(w3cCapabilities.alwaysMatch) &&
|
|
92
|
+
_.has(
|
|
93
|
+
removeAppiumPrefixes(w3cCapabilities.alwaysMatch),
|
|
94
|
+
removeAppiumPrefix(defaultCapKey)
|
|
95
|
+
));
|
|
83
96
|
if (isCapAlreadySet) {
|
|
84
97
|
// Skip if the key is already present in the provided caps
|
|
85
98
|
continue;
|
|
@@ -94,7 +107,10 @@ function parseCapsForInnerDriver (jsonwpCapabilities, w3cCapabilities, constrain
|
|
|
94
107
|
}
|
|
95
108
|
}
|
|
96
109
|
if (hasJSONWPCaps) {
|
|
97
|
-
jsonwpCapabilities = {
|
|
110
|
+
jsonwpCapabilities = {
|
|
111
|
+
...removeAppiumPrefixes(defaultCapabilities),
|
|
112
|
+
...jsonwpCapabilities,
|
|
113
|
+
};
|
|
98
114
|
}
|
|
99
115
|
}
|
|
100
116
|
|
|
@@ -111,7 +127,7 @@ function parseCapsForInnerDriver (jsonwpCapabilities, w3cCapabilities, constrain
|
|
|
111
127
|
desiredCaps = processCapabilities(w3cCapabilities, constraints, true);
|
|
112
128
|
} catch (error) {
|
|
113
129
|
logger.info(`Could not parse W3C capabilities: ${error.message}`);
|
|
114
|
-
return /** @type {InvalidCaps} */({
|
|
130
|
+
return /** @type {InvalidCaps} */ ({
|
|
115
131
|
desiredCaps,
|
|
116
132
|
processedJsonwpCapabilities,
|
|
117
133
|
processedW3CCapabilities,
|
|
@@ -127,7 +143,12 @@ function parseCapsForInnerDriver (jsonwpCapabilities, w3cCapabilities, constrain
|
|
|
127
143
|
};
|
|
128
144
|
}
|
|
129
145
|
|
|
130
|
-
return /** @type {ParsedDriverCaps} */({
|
|
146
|
+
return /** @type {ParsedDriverCaps} */ ({
|
|
147
|
+
desiredCaps,
|
|
148
|
+
processedJsonwpCapabilities,
|
|
149
|
+
processedW3CCapabilities,
|
|
150
|
+
protocol,
|
|
151
|
+
});
|
|
131
152
|
}
|
|
132
153
|
|
|
133
154
|
/**
|
|
@@ -135,7 +156,7 @@ function parseCapsForInnerDriver (jsonwpCapabilities, w3cCapabilities, constrain
|
|
|
135
156
|
* @param {Capabilities} caps Desired capabilities object
|
|
136
157
|
* @returns {AppiumW3CCapabilities}
|
|
137
158
|
*/
|
|
138
|
-
function insertAppiumPrefixes
|
|
159
|
+
function insertAppiumPrefixes(caps) {
|
|
139
160
|
// Standard, non-prefixed capabilities (see https://www.w3.org/TR/webdriver/#dfn-table-of-standard-capabilities)
|
|
140
161
|
const STANDARD_CAPS = [
|
|
141
162
|
'browserName',
|
|
@@ -146,7 +167,7 @@ function insertAppiumPrefixes (caps) {
|
|
|
146
167
|
'proxy',
|
|
147
168
|
'setWindowRect',
|
|
148
169
|
'timeouts',
|
|
149
|
-
'unhandledPromptBehavior'
|
|
170
|
+
'unhandledPromptBehavior',
|
|
150
171
|
];
|
|
151
172
|
|
|
152
173
|
let prefixedCaps = {};
|
|
@@ -165,7 +186,7 @@ function insertAppiumPrefixes (caps) {
|
|
|
165
186
|
* @param {AppiumW3CCapabilities} caps
|
|
166
187
|
* @returns {Capabilities}
|
|
167
188
|
*/
|
|
168
|
-
function removeAppiumPrefixes
|
|
189
|
+
function removeAppiumPrefixes(caps) {
|
|
169
190
|
if (!_.isPlainObject(caps)) {
|
|
170
191
|
return caps;
|
|
171
192
|
}
|
|
@@ -178,12 +199,12 @@ function removeAppiumPrefixes (caps) {
|
|
|
178
199
|
return fixedCaps;
|
|
179
200
|
}
|
|
180
201
|
|
|
181
|
-
function removeAppiumPrefix
|
|
202
|
+
function removeAppiumPrefix(key) {
|
|
182
203
|
const prefix = `${W3C_APPIUM_PREFIX}:`;
|
|
183
204
|
return _.startsWith(key, prefix) ? key.substring(prefix.length) : key;
|
|
184
205
|
}
|
|
185
206
|
|
|
186
|
-
function getPackageVersion
|
|
207
|
+
function getPackageVersion(pkgName) {
|
|
187
208
|
const pkgInfo = require(`${pkgName}/package.json`) || {};
|
|
188
209
|
return pkgInfo.version;
|
|
189
210
|
}
|
|
@@ -204,7 +225,7 @@ function getPackageVersion (pkgName) {
|
|
|
204
225
|
* setting items or a dictionary containing parsed Appium setting names along with
|
|
205
226
|
* their values.
|
|
206
227
|
*/
|
|
207
|
-
function pullSettings
|
|
228
|
+
function pullSettings(caps) {
|
|
208
229
|
if (!_.isPlainObject(caps) || _.isEmpty(caps)) {
|
|
209
230
|
return {};
|
|
210
231
|
}
|
|
@@ -223,8 +244,12 @@ function pullSettings (caps) {
|
|
|
223
244
|
}
|
|
224
245
|
|
|
225
246
|
export {
|
|
226
|
-
inspect,
|
|
227
|
-
|
|
247
|
+
inspect,
|
|
248
|
+
parseCapsForInnerDriver,
|
|
249
|
+
insertAppiumPrefixes,
|
|
250
|
+
getPackageVersion,
|
|
251
|
+
pullSettings,
|
|
252
|
+
removeAppiumPrefixes,
|
|
228
253
|
};
|
|
229
254
|
|
|
230
255
|
/**
|