appium 2.0.0-beta.55 → 2.0.0-beta.57
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/LICENSE +1 -1
- package/README.md +3 -6
- package/build/lib/appium.d.ts +7 -12
- package/build/lib/appium.d.ts.map +1 -1
- package/build/lib/appium.js +4 -28
- package/build/lib/appium.js.map +1 -1
- package/build/lib/cli/driver-command.d.ts.map +1 -1
- package/build/lib/cli/driver-command.js +6 -1
- package/build/lib/cli/driver-command.js.map +1 -1
- package/build/lib/cli/extension-command.d.ts +23 -9
- package/build/lib/cli/extension-command.d.ts.map +1 -1
- package/build/lib/cli/extension-command.js +67 -22
- package/build/lib/cli/extension-command.js.map +1 -1
- package/build/lib/cli/plugin-command.d.ts.map +1 -1
- package/build/lib/cli/plugin-command.js +6 -1
- package/build/lib/cli/plugin-command.js.map +1 -1
- package/build/lib/config.d.ts +1 -1
- package/build/lib/config.d.ts.map +1 -1
- package/build/lib/config.js +3 -2
- package/build/lib/config.js.map +1 -1
- package/build/lib/extension/extension-config.d.ts +6 -6
- package/build/lib/extension/extension-config.d.ts.map +1 -1
- package/build/lib/extension/extension-config.js +3 -3
- package/build/lib/schema/arg-spec.d.ts +1 -1
- package/build/lib/schema/arg-spec.js +1 -1
- package/build/lib/schema/schema.d.ts +4 -3
- package/build/lib/schema/schema.d.ts.map +1 -1
- package/build/lib/schema/schema.js +61 -36
- package/build/lib/schema/schema.js.map +1 -1
- package/build/lib/utils.d.ts +13 -13
- package/build/types/cli.d.ts +11 -11
- package/build/types/cli.d.ts.map +1 -1
- package/build/types/index.d.ts +1 -1
- package/build/types/index.d.ts.map +1 -1
- package/build/types/manifest/base.d.ts +8 -8
- package/build/types/manifest/base.d.ts.map +1 -1
- package/build/types/manifest/index.d.ts +1 -1
- package/build/types/manifest/index.d.ts.map +1 -1
- package/build/types/manifest/v3.d.ts +8 -8
- package/build/types/manifest/v3.d.ts.map +1 -1
- package/lib/appium.js +20 -8
- package/lib/cli/driver-command.js +6 -1
- package/lib/cli/extension-command.js +71 -22
- package/lib/cli/plugin-command.js +6 -1
- package/lib/config.js +3 -2
- package/lib/extension/extension-config.js +3 -3
- package/lib/schema/arg-spec.js +1 -1
- package/lib/schema/schema.js +42 -39
- package/package.json +11 -11
- package/scripts/autoinstall-extensions.js +23 -0
package/lib/schema/schema.js
CHANGED
|
@@ -41,7 +41,9 @@ export class RoachHotelMap extends Map {
|
|
|
41
41
|
/**
|
|
42
42
|
* Extensions that an extension schema file can have.
|
|
43
43
|
*/
|
|
44
|
-
export const ALLOWED_SCHEMA_EXTENSIONS =
|
|
44
|
+
export const ALLOWED_SCHEMA_EXTENSIONS = Object.freeze(
|
|
45
|
+
new Set(/** @type {AllowedSchemaExtension[]} */ (['.json', '.js', '.cjs']))
|
|
46
|
+
);
|
|
45
47
|
|
|
46
48
|
const SCHEMA_KEY = '$schema';
|
|
47
49
|
|
|
@@ -57,44 +59,39 @@ class AppiumSchema {
|
|
|
57
59
|
* An "argument" is a CLI argument or a config property.
|
|
58
60
|
*
|
|
59
61
|
* Used to provide easy lookups of argument metadata when converting between different representations of those arguments.
|
|
60
|
-
* @private
|
|
61
62
|
* @type {RoachHotelMap<string,ArgSpec>}
|
|
62
63
|
*/
|
|
63
|
-
|
|
64
|
+
#argSpecs = new RoachHotelMap();
|
|
64
65
|
|
|
65
66
|
/**
|
|
66
67
|
* A map of extension types to extension names to schema objects.
|
|
67
68
|
*
|
|
68
69
|
* This data structure is used to ensure there are no naming conflicts. The schemas
|
|
69
70
|
* are stored here in memory until the instance is _finalized_.
|
|
70
|
-
* @private
|
|
71
71
|
* @type {Record<ExtensionType,Map<string,SchemaObject>>}
|
|
72
72
|
*/
|
|
73
|
-
|
|
73
|
+
#registeredSchemas = {[DRIVER_TYPE]: new Map(), [PLUGIN_TYPE]: new Map()};
|
|
74
74
|
|
|
75
75
|
/**
|
|
76
76
|
* Ajv instance
|
|
77
77
|
*
|
|
78
|
-
* @private
|
|
79
78
|
* @type {Ajv}
|
|
80
79
|
*/
|
|
81
|
-
|
|
80
|
+
#ajv;
|
|
82
81
|
|
|
83
82
|
/**
|
|
84
83
|
* Singleton instance.
|
|
85
|
-
* @private
|
|
86
84
|
* @type {AppiumSchema}
|
|
87
85
|
*/
|
|
88
|
-
static
|
|
86
|
+
static #instance;
|
|
89
87
|
|
|
90
88
|
/**
|
|
91
89
|
* Lookup of schema IDs to finalized schemas.
|
|
92
90
|
*
|
|
93
91
|
* This does not include references, but rather the root schemas themselves.
|
|
94
|
-
* @private
|
|
95
92
|
* @type {Record<string,StrictSchemaObject>?}
|
|
96
93
|
*/
|
|
97
|
-
|
|
94
|
+
#finalizedSchemas = null;
|
|
98
95
|
|
|
99
96
|
/**
|
|
100
97
|
* Initializes Ajv, adds standard formats and our custom keywords.
|
|
@@ -102,7 +99,7 @@ class AppiumSchema {
|
|
|
102
99
|
* @private
|
|
103
100
|
*/
|
|
104
101
|
constructor() {
|
|
105
|
-
this
|
|
102
|
+
this.#ajv = AppiumSchema._instantiateAjv();
|
|
106
103
|
}
|
|
107
104
|
|
|
108
105
|
/**
|
|
@@ -113,9 +110,9 @@ class AppiumSchema {
|
|
|
113
110
|
* @returns {AppiumSchema}
|
|
114
111
|
*/
|
|
115
112
|
static create() {
|
|
116
|
-
if (!AppiumSchema
|
|
113
|
+
if (!AppiumSchema.#instance) {
|
|
117
114
|
const instance = new AppiumSchema();
|
|
118
|
-
AppiumSchema
|
|
115
|
+
AppiumSchema.#instance = instance;
|
|
119
116
|
_.bindAll(instance, [
|
|
120
117
|
'finalize',
|
|
121
118
|
'flatten',
|
|
@@ -133,7 +130,7 @@ class AppiumSchema {
|
|
|
133
130
|
]);
|
|
134
131
|
}
|
|
135
132
|
|
|
136
|
-
return AppiumSchema
|
|
133
|
+
return AppiumSchema.#instance;
|
|
137
134
|
}
|
|
138
135
|
|
|
139
136
|
/**
|
|
@@ -145,7 +142,7 @@ class AppiumSchema {
|
|
|
145
142
|
* @returns {boolean} If registered
|
|
146
143
|
*/
|
|
147
144
|
hasRegisteredSchema(extType, extName) {
|
|
148
|
-
return this
|
|
145
|
+
return this.#registeredSchemas[extType].has(extName);
|
|
149
146
|
}
|
|
150
147
|
|
|
151
148
|
/**
|
|
@@ -154,11 +151,11 @@ class AppiumSchema {
|
|
|
154
151
|
* @returns {boolean} If finalized
|
|
155
152
|
*/
|
|
156
153
|
isFinalized() {
|
|
157
|
-
return Boolean(this
|
|
154
|
+
return Boolean(this.#finalizedSchemas);
|
|
158
155
|
}
|
|
159
156
|
|
|
160
157
|
getAllArgSpecs() {
|
|
161
|
-
return this
|
|
158
|
+
return this.#argSpecs;
|
|
162
159
|
}
|
|
163
160
|
|
|
164
161
|
/**
|
|
@@ -182,10 +179,10 @@ class AppiumSchema {
|
|
|
182
179
|
*/
|
|
183
180
|
finalize() {
|
|
184
181
|
if (this.isFinalized()) {
|
|
185
|
-
return /** @type {
|
|
182
|
+
return /** @type {Record<string,StrictSchemaObject>} */ (this.#finalizedSchemas);
|
|
186
183
|
}
|
|
187
184
|
|
|
188
|
-
const ajv = this
|
|
185
|
+
const ajv = this.#ajv;
|
|
189
186
|
|
|
190
187
|
// Ajv will _mutate_ the schema, so we need to clone it.
|
|
191
188
|
const baseSchema = _.cloneDeep(AppiumConfigJsonSchema);
|
|
@@ -205,7 +202,7 @@ class AppiumSchema {
|
|
|
205
202
|
extName,
|
|
206
203
|
});
|
|
207
204
|
const {arg} = argSpec;
|
|
208
|
-
this.
|
|
205
|
+
this.#argSpecs.set(arg, argSpec);
|
|
209
206
|
}
|
|
210
207
|
};
|
|
211
208
|
|
|
@@ -217,7 +214,7 @@ class AppiumSchema {
|
|
|
217
214
|
const finalizedSchemas = {};
|
|
218
215
|
|
|
219
216
|
const finalSchema = _.reduce(
|
|
220
|
-
this
|
|
217
|
+
this.#registeredSchemas,
|
|
221
218
|
/**
|
|
222
219
|
* @param {typeof baseSchema} baseSchema
|
|
223
220
|
* @param {Map<string,SchemaObject>} extensionSchemas
|
|
@@ -246,7 +243,7 @@ class AppiumSchema {
|
|
|
246
243
|
finalizedSchemas[APPIUM_CONFIG_SCHEMA_ID] = finalSchema;
|
|
247
244
|
ajv.validateSchema(finalSchema, true);
|
|
248
245
|
|
|
249
|
-
this
|
|
246
|
+
this.#finalizedSchemas = finalizedSchemas;
|
|
250
247
|
return Object.freeze(finalizedSchemas);
|
|
251
248
|
}
|
|
252
249
|
|
|
@@ -283,18 +280,18 @@ class AppiumSchema {
|
|
|
283
280
|
* @returns {void}
|
|
284
281
|
*/
|
|
285
282
|
reset() {
|
|
286
|
-
for (const schemaId of Object.keys(this
|
|
287
|
-
this.
|
|
283
|
+
for (const schemaId of Object.keys(this.#finalizedSchemas ?? {})) {
|
|
284
|
+
this.#ajv.removeSchema(schemaId);
|
|
288
285
|
}
|
|
289
|
-
this
|
|
290
|
-
this
|
|
286
|
+
this.#argSpecs = new RoachHotelMap();
|
|
287
|
+
this.#registeredSchemas = {
|
|
291
288
|
[DRIVER_TYPE]: new Map(),
|
|
292
289
|
[PLUGIN_TYPE]: new Map(),
|
|
293
290
|
};
|
|
294
|
-
this
|
|
291
|
+
this.#finalizedSchemas = null;
|
|
295
292
|
|
|
296
293
|
// Ajv seems to have an over-eager cache, so we have to dump the object entirely.
|
|
297
|
-
this
|
|
294
|
+
this.#ajv = AppiumSchema._instantiateAjv();
|
|
298
295
|
}
|
|
299
296
|
|
|
300
297
|
/**
|
|
@@ -318,14 +315,14 @@ class AppiumSchema {
|
|
|
318
315
|
}
|
|
319
316
|
const normalizedExtName = _.kebabCase(extName);
|
|
320
317
|
if (this.hasRegisteredSchema(extType, normalizedExtName)) {
|
|
321
|
-
if (_.isEqual(this
|
|
318
|
+
if (_.isEqual(this.#registeredSchemas[extType].get(normalizedExtName), schema)) {
|
|
322
319
|
return;
|
|
323
320
|
}
|
|
324
321
|
throw new SchemaNameConflictError(extType, extName);
|
|
325
322
|
}
|
|
326
|
-
this.
|
|
323
|
+
this.#ajv.validateSchema(schema, true);
|
|
327
324
|
|
|
328
|
-
this
|
|
325
|
+
this.#registeredSchemas[extType].set(normalizedExtName, schema);
|
|
329
326
|
}
|
|
330
327
|
|
|
331
328
|
/**
|
|
@@ -336,7 +333,7 @@ class AppiumSchema {
|
|
|
336
333
|
* @returns {ArgSpec|undefined} ArgSpec or `undefined` if not found
|
|
337
334
|
*/
|
|
338
335
|
getArgSpec(name, extType, extName) {
|
|
339
|
-
return this.
|
|
336
|
+
return this.#argSpecs.get(ArgSpec.toArg(name, extType, extName));
|
|
340
337
|
}
|
|
341
338
|
|
|
342
339
|
/**
|
|
@@ -347,7 +344,7 @@ class AppiumSchema {
|
|
|
347
344
|
* @returns {boolean} `true` if such an {@link ArgSpec} exists
|
|
348
345
|
*/
|
|
349
346
|
hasArgSpec(name, extType, extName) {
|
|
350
|
-
return this.
|
|
347
|
+
return this.#argSpecs.has(ArgSpec.toArg(name, extType, extName));
|
|
351
348
|
}
|
|
352
349
|
|
|
353
350
|
/**
|
|
@@ -391,7 +388,7 @@ class AppiumSchema {
|
|
|
391
388
|
|
|
392
389
|
/** @type {DefaultValues<Flattened>} */
|
|
393
390
|
const retval = {};
|
|
394
|
-
return [...this.
|
|
391
|
+
return [...this.#argSpecs.values()].reduce(reducer, retval);
|
|
395
392
|
}
|
|
396
393
|
|
|
397
394
|
/**
|
|
@@ -405,7 +402,7 @@ class AppiumSchema {
|
|
|
405
402
|
if (!this.isFinalized()) {
|
|
406
403
|
throw new SchemaFinalizationError();
|
|
407
404
|
}
|
|
408
|
-
const specs = [...this.
|
|
405
|
+
const specs = [...this.#argSpecs.values()].filter(
|
|
409
406
|
(spec) => spec.extType === extType && spec.extName === extName
|
|
410
407
|
);
|
|
411
408
|
return specs.reduce((defaults, {defaultValue, rawDest}) => {
|
|
@@ -506,7 +503,7 @@ class AppiumSchema {
|
|
|
506
503
|
* @returns {import('ajv').ValidateFunction}
|
|
507
504
|
*/
|
|
508
505
|
_getValidator(id = APPIUM_CONFIG_SCHEMA_ID) {
|
|
509
|
-
const validator = this.
|
|
506
|
+
const validator = this.#ajv.getSchema(id);
|
|
510
507
|
if (!validator) {
|
|
511
508
|
if (id === APPIUM_CONFIG_SCHEMA_ID) {
|
|
512
509
|
throw new SchemaFinalizationError();
|
|
@@ -532,11 +529,13 @@ class AppiumSchema {
|
|
|
532
529
|
|
|
533
530
|
/**
|
|
534
531
|
* Returns `true` if `filename`'s file extension is allowed (in {@link ALLOWED_SCHEMA_EXTENSIONS}).
|
|
535
|
-
* @param {string} filename
|
|
532
|
+
* @param {import('type-fest').LiteralUnion<AllowedSchemaExtension, string>} filename
|
|
536
533
|
* @returns {boolean}
|
|
537
534
|
*/
|
|
538
535
|
static isAllowedSchemaFileExtension(filename) {
|
|
539
|
-
return ALLOWED_SCHEMA_EXTENSIONS.has(
|
|
536
|
+
return ALLOWED_SCHEMA_EXTENSIONS.has(
|
|
537
|
+
/** @type {AllowedSchemaExtension} */ (path.extname(filename))
|
|
538
|
+
);
|
|
540
539
|
}
|
|
541
540
|
|
|
542
541
|
/**
|
|
@@ -720,3 +719,7 @@ export const {isAllowedSchemaFileExtension} = AppiumSchema;
|
|
|
720
719
|
* @template {boolean|undefined} Flattened
|
|
721
720
|
* @typedef {Record<string,Flattened extends true ? ArgSpecDefaultValue : ArgSpecDefaultValue | NestedArgSpecDefaultValue>} DefaultValues
|
|
722
721
|
*/
|
|
722
|
+
|
|
723
|
+
/**
|
|
724
|
+
* @typedef {'.json'|'.js'|'.cjs'} AllowedSchemaExtension
|
|
725
|
+
*/
|
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.57",
|
|
4
4
|
"description": "Automation for Apps.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"automation",
|
|
@@ -59,12 +59,12 @@
|
|
|
59
59
|
"test:unit": "mocha \"./test/unit/**/*.spec.js\""
|
|
60
60
|
},
|
|
61
61
|
"dependencies": {
|
|
62
|
-
"@appium/base-driver": "^9.3.
|
|
63
|
-
"@appium/base-plugin": "^2.2.
|
|
64
|
-
"@appium/docutils": "^0.
|
|
65
|
-
"@appium/schema": "^0.2.
|
|
66
|
-
"@appium/support": "^3.1.
|
|
67
|
-
"@appium/types": "^0.
|
|
62
|
+
"@appium/base-driver": "^9.3.3",
|
|
63
|
+
"@appium/base-plugin": "^2.2.3",
|
|
64
|
+
"@appium/docutils": "^0.3.0",
|
|
65
|
+
"@appium/schema": "^0.2.6",
|
|
66
|
+
"@appium/support": "^3.1.7",
|
|
67
|
+
"@appium/types": "^0.10.1",
|
|
68
68
|
"@sidvind/better-ajv-errors": "2.1.0",
|
|
69
69
|
"@types/argparse": "2.0.10",
|
|
70
70
|
"@types/bluebird": "3.5.38",
|
|
@@ -77,12 +77,12 @@
|
|
|
77
77
|
"argparse": "2.0.1",
|
|
78
78
|
"async-lock": "1.4.0",
|
|
79
79
|
"asyncbox": "2.9.4",
|
|
80
|
-
"axios": "1.
|
|
80
|
+
"axios": "1.3.4",
|
|
81
81
|
"bluebird": "3.7.2",
|
|
82
82
|
"cross-env": "7.0.3",
|
|
83
83
|
"find-up": "5.0.0",
|
|
84
84
|
"glob": "8.1.0",
|
|
85
|
-
"lilconfig": "2.0
|
|
85
|
+
"lilconfig": "2.1.0",
|
|
86
86
|
"lodash": "4.17.21",
|
|
87
87
|
"longjohn": "0.2.12",
|
|
88
88
|
"npmlog": "7.0.1",
|
|
@@ -92,7 +92,7 @@
|
|
|
92
92
|
"semver": "7.3.8",
|
|
93
93
|
"source-map-support": "0.5.21",
|
|
94
94
|
"teen_process": "2.0.2",
|
|
95
|
-
"type-fest": "3.
|
|
95
|
+
"type-fest": "3.6.1",
|
|
96
96
|
"winston": "3.8.2",
|
|
97
97
|
"wrap-ansi": "7.0.0",
|
|
98
98
|
"yaml": "2.2.1"
|
|
@@ -105,7 +105,7 @@
|
|
|
105
105
|
"access": "public",
|
|
106
106
|
"tag": "next"
|
|
107
107
|
},
|
|
108
|
-
"gitHead": "
|
|
108
|
+
"gitHead": "872b924a97c13142bdb8bf4218a4db324f309ce4",
|
|
109
109
|
"typedoc": {
|
|
110
110
|
"entryPoint": "./lib/main.js"
|
|
111
111
|
}
|
|
@@ -22,6 +22,8 @@
|
|
|
22
22
|
*/
|
|
23
23
|
|
|
24
24
|
const B = require('bluebird');
|
|
25
|
+
const path = require('node:path');
|
|
26
|
+
const {realpath} = require('node:fs/promises');
|
|
25
27
|
|
|
26
28
|
B.config({
|
|
27
29
|
cancellation: true,
|
|
@@ -55,11 +57,32 @@ function log(message) {
|
|
|
55
57
|
console.error(wrap(`[Appium] ${message}`));
|
|
56
58
|
}
|
|
57
59
|
|
|
60
|
+
/**
|
|
61
|
+
* This is a naive attempt at determining whether or not we are in a dev environment; in other
|
|
62
|
+
* words, is `postinstall` being run from within the `appium` monorepo?
|
|
63
|
+
*
|
|
64
|
+
* When we're in the monorepo, `npm_config_local_prefix` will be set to the root of the monorepo root
|
|
65
|
+
* dir when running this lifecycle script from an `npm install` in the monorepo root.
|
|
66
|
+
*
|
|
67
|
+
* `realpath` is necessary due to macOS omitting `/private` from paths
|
|
68
|
+
*/
|
|
69
|
+
async function isDevEnvironment() {
|
|
70
|
+
return (
|
|
71
|
+
process.env.npm_config_local_prefix &&
|
|
72
|
+
path.join(process.env.npm_config_local_prefix, 'packages', 'appium') ===
|
|
73
|
+
(await realpath(path.join(__dirname, '..')))
|
|
74
|
+
);
|
|
75
|
+
}
|
|
76
|
+
|
|
58
77
|
/**
|
|
59
78
|
* Setup / check environment if we should do anything here
|
|
60
79
|
* @returns {Promise<boolean>} `true` if Appium is built and ready to go
|
|
61
80
|
*/
|
|
62
81
|
async function init() {
|
|
82
|
+
if (await isDevEnvironment()) {
|
|
83
|
+
log('Dev environment likely; skipping automatic installation of extensions');
|
|
84
|
+
return false;
|
|
85
|
+
}
|
|
63
86
|
try {
|
|
64
87
|
({env, util, logger} = require('@appium/support'));
|
|
65
88
|
// @ts-ignore
|