appium 2.0.0-beta.23 → 2.0.0-beta.26

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.
Files changed (125) hide show
  1. package/README.md +1 -2
  2. package/build/lib/appium-config.schema.json +278 -0
  3. package/build/lib/appium.js +62 -71
  4. package/build/lib/cli/args.js +31 -53
  5. package/build/lib/cli/driver-command.js +5 -9
  6. package/build/lib/cli/extension-command.js +73 -64
  7. package/build/lib/cli/extension.js +10 -23
  8. package/build/lib/cli/parser.js +10 -20
  9. package/build/lib/cli/plugin-command.js +5 -9
  10. package/build/lib/cli/utils.js +2 -4
  11. package/build/lib/config-file.js +5 -10
  12. package/build/lib/config.js +67 -30
  13. package/build/lib/constants.js +60 -0
  14. package/build/lib/extension/driver-config.js +190 -0
  15. package/build/lib/extension/extension-config.js +297 -0
  16. package/build/lib/extension/index.js +77 -0
  17. package/build/lib/extension/manifest.js +246 -0
  18. package/build/lib/extension/package-changed.js +68 -0
  19. package/build/lib/extension/plugin-config.js +87 -0
  20. package/build/lib/grid-register.js +2 -4
  21. package/build/lib/logger.js +2 -4
  22. package/build/lib/logsink.js +2 -4
  23. package/build/lib/main.js +64 -92
  24. package/build/lib/schema/appium-config-schema.js +2 -4
  25. package/build/lib/schema/arg-spec.js +14 -15
  26. package/build/lib/schema/cli-args.js +8 -16
  27. package/build/lib/schema/cli-transformers.js +2 -4
  28. package/build/lib/schema/index.js +2 -4
  29. package/build/lib/schema/keywords.js +2 -4
  30. package/build/lib/schema/schema.js +136 -41
  31. package/build/lib/utils.js +13 -64
  32. package/lib/appium.js +74 -55
  33. package/lib/cli/args.js +36 -37
  34. package/lib/cli/driver-command.js +10 -2
  35. package/lib/cli/extension-command.js +216 -135
  36. package/lib/cli/extension.js +7 -15
  37. package/lib/cli/parser.js +7 -15
  38. package/lib/cli/plugin-command.js +1 -2
  39. package/lib/config-file.js +12 -15
  40. package/lib/config.js +111 -36
  41. package/lib/constants.js +79 -0
  42. package/lib/extension/driver-config.js +230 -0
  43. package/lib/extension/extension-config.js +459 -0
  44. package/lib/extension/index.js +103 -0
  45. package/lib/extension/manifest.js +590 -0
  46. package/lib/extension/package-changed.js +64 -0
  47. package/lib/extension/plugin-config.js +111 -0
  48. package/lib/grid-register.js +4 -4
  49. package/lib/main.js +110 -96
  50. package/lib/schema/arg-spec.js +11 -5
  51. package/lib/schema/cli-args.js +7 -30
  52. package/lib/schema/keywords.js +1 -1
  53. package/lib/schema/schema.js +206 -48
  54. package/lib/utils.js +27 -58
  55. package/package.json +29 -21
  56. package/{postinstall.js → scripts/postinstall.js} +1 -1
  57. package/types/types.d.ts +72 -28
  58. package/bin/ios-webkit-debug-proxy-launcher.js +0 -71
  59. package/build/check-npm-pack-files.js +0 -23
  60. package/build/commands-yml/parse.js +0 -319
  61. package/build/commands-yml/validator.js +0 -130
  62. package/build/index.js +0 -19
  63. package/build/lib/cli/npm.js +0 -220
  64. package/build/lib/driver-config.js +0 -100
  65. package/build/lib/drivers.js +0 -100
  66. package/build/lib/ext-config-io.js +0 -165
  67. package/build/lib/extension-config.js +0 -320
  68. package/build/lib/plugin-config.js +0 -69
  69. package/build/lib/plugins.js +0 -16
  70. package/build/postinstall.js +0 -90
  71. package/build/test/cli/cli-e2e-specs.js +0 -221
  72. package/build/test/cli/cli-helpers.js +0 -86
  73. package/build/test/cli/cli-specs.js +0 -71
  74. package/build/test/cli/fixtures/test-driver/package.json +0 -27
  75. package/build/test/cli/schema-args-specs.js +0 -48
  76. package/build/test/cli/schema-e2e-specs.js +0 -47
  77. package/build/test/config-e2e-specs.js +0 -112
  78. package/build/test/config-file-e2e-specs.js +0 -209
  79. package/build/test/config-file-specs.js +0 -281
  80. package/build/test/config-specs.js +0 -159
  81. package/build/test/driver-e2e-specs.js +0 -435
  82. package/build/test/driver-specs.js +0 -321
  83. package/build/test/ext-config-io-specs.js +0 -181
  84. package/build/test/extension-config-specs.js +0 -365
  85. package/build/test/fixtures/allow-feat.txt +0 -5
  86. package/build/test/fixtures/caps.json +0 -3
  87. package/build/test/fixtures/config/allow-insecure.txt +0 -3
  88. package/build/test/fixtures/config/appium.config.bad-nodeconfig.json +0 -5
  89. package/build/test/fixtures/config/appium.config.bad.json +0 -32
  90. package/build/test/fixtures/config/appium.config.ext-good.json +0 -9
  91. package/build/test/fixtures/config/appium.config.ext-unknown-props.json +0 -10
  92. package/build/test/fixtures/config/appium.config.good.js +0 -40
  93. package/build/test/fixtures/config/appium.config.good.json +0 -33
  94. package/build/test/fixtures/config/appium.config.good.yaml +0 -30
  95. package/build/test/fixtures/config/appium.config.invalid.json +0 -31
  96. package/build/test/fixtures/config/appium.config.security-array.json +0 -5
  97. package/build/test/fixtures/config/appium.config.security-delimited.json +0 -5
  98. package/build/test/fixtures/config/appium.config.security-path.json +0 -5
  99. package/build/test/fixtures/config/driver-fake.config.json +0 -8
  100. package/build/test/fixtures/config/nodeconfig.json +0 -3
  101. package/build/test/fixtures/config/plugin-fake.config.json +0 -0
  102. package/build/test/fixtures/default-args.js +0 -35
  103. package/build/test/fixtures/deny-feat.txt +0 -5
  104. package/build/test/fixtures/driver.schema.js +0 -20
  105. package/build/test/fixtures/extensions.yaml +0 -27
  106. package/build/test/fixtures/flattened-schema.js +0 -504
  107. package/build/test/fixtures/plugin.schema.js +0 -20
  108. package/build/test/fixtures/schema-with-extensions.js +0 -28
  109. package/build/test/grid-register-specs.js +0 -74
  110. package/build/test/helpers.js +0 -75
  111. package/build/test/logger-specs.js +0 -76
  112. package/build/test/npm-specs.js +0 -20
  113. package/build/test/parser-specs.js +0 -314
  114. package/build/test/plugin-e2e-specs.js +0 -316
  115. package/build/test/schema/arg-spec-specs.js +0 -70
  116. package/build/test/schema/cli-args-specs.js +0 -431
  117. package/build/test/schema/schema-specs.js +0 -389
  118. package/build/test/utils-specs.js +0 -266
  119. package/lib/cli/npm.js +0 -251
  120. package/lib/driver-config.js +0 -101
  121. package/lib/drivers.js +0 -84
  122. package/lib/ext-config-io.js +0 -287
  123. package/lib/extension-config.js +0 -366
  124. package/lib/plugin-config.js +0 -63
  125. package/lib/plugins.js +0 -11
@@ -4,11 +4,41 @@ import Ajv from 'ajv';
4
4
  import addFormats from 'ajv-formats';
5
5
  import _ from 'lodash';
6
6
  import path from 'path';
7
- import {DRIVER_TYPE, PLUGIN_TYPE} from '../extension-config';
8
- import {ReadonlyMap} from '../utils';
7
+ import { DRIVER_TYPE, PLUGIN_TYPE } from '../constants';
9
8
  import appiumConfigSchema from './appium-config-schema';
10
- import {ArgSpec, SERVER_PROP_NAME, APPIUM_CONFIG_SCHEMA_ID} from './arg-spec';
11
- import {keywords} from './keywords';
9
+ import { APPIUM_CONFIG_SCHEMA_ID, ArgSpec, SERVER_PROP_NAME } from './arg-spec';
10
+ import { keywords } from './keywords';
11
+
12
+ /**
13
+ * Key/value pairs go in... but they don't come out.
14
+ *
15
+ * @template K,V
16
+ * @extends {Map<K,V>}
17
+ */
18
+ export class RoachHotelMap extends Map {
19
+ /**
20
+ * @param {K} key
21
+ * @param {V} value
22
+ */
23
+ set (key, value) {
24
+ if (this.has(key)) {
25
+ throw new Error(`${key} is already set`);
26
+ }
27
+ return super.set(key, value);
28
+ }
29
+
30
+ /**
31
+ * @param {K} key
32
+ */
33
+ // eslint-disable-next-line no-unused-vars
34
+ delete (key) {
35
+ return false;
36
+ }
37
+
38
+ clear () {
39
+ throw new Error(`Cannot clear RoachHotelMap`);
40
+ }
41
+ }
12
42
 
13
43
  /**
14
44
  * Extensions that an extension schema file can have.
@@ -28,9 +58,9 @@ class AppiumSchema {
28
58
  *
29
59
  * Used to provide easy lookups of argument metadata when converting between different representations of those arguments.
30
60
  * @private
31
- * @type {ReadonlyMap<string,ArgSpec>}
61
+ * @type {RoachHotelMap<string,ArgSpec>}
32
62
  */
33
- _argSpecs = new ReadonlyMap();
63
+ _argSpecs = new RoachHotelMap();
34
64
 
35
65
  /**
36
66
  * A map of extension types to extension names to schema objects.
@@ -83,23 +113,27 @@ class AppiumSchema {
83
113
  * @returns {AppiumSchema}
84
114
  */
85
115
  static create () {
86
- const instance = AppiumSchema._instance ?? new AppiumSchema();
87
- AppiumSchema._instance = instance;
88
-
89
- _.bindAll(instance, [
90
- 'finalize',
91
- 'flatten',
92
- 'getArgSpec',
93
- 'getDefaults',
94
- 'getSchema',
95
- 'hasArgSpec',
96
- 'isFinalized',
97
- 'registerSchema',
98
- 'reset',
99
- 'validate',
100
- ]);
101
-
102
- return instance;
116
+ if (!AppiumSchema._instance) {
117
+ const instance = new AppiumSchema();
118
+ AppiumSchema._instance = instance;
119
+ _.bindAll(instance, [
120
+ 'finalize',
121
+ 'flatten',
122
+ 'getAllArgSpecs',
123
+ 'getArgSpec',
124
+ 'getDefaults',
125
+ 'getDefaultsForExtension',
126
+ 'getSchema',
127
+ 'hasArgSpec',
128
+ 'isFinalized',
129
+ 'registerSchema',
130
+ 'hasRegisteredSchema',
131
+ 'reset',
132
+ 'validate',
133
+ ]);
134
+ }
135
+
136
+ return AppiumSchema._instance;
103
137
  }
104
138
 
105
139
  /**
@@ -123,6 +157,10 @@ class AppiumSchema {
123
157
  return Boolean(this._finalizedSchemas);
124
158
  }
125
159
 
160
+ getAllArgSpecs () {
161
+ return this._argSpecs;
162
+ }
163
+
126
164
  /**
127
165
  * Call this when no more schemas will be registered.
128
166
  *
@@ -144,7 +182,7 @@ class AppiumSchema {
144
182
  */
145
183
  finalize () {
146
184
  if (this.isFinalized()) {
147
- return /** @type {Record<string,StrictSchemaObject>} */ (
185
+ return /** @type {NonNullable<typeof this._finalizedSchemas>} */ (
148
186
  this._finalizedSchemas
149
187
  );
150
188
  }
@@ -152,7 +190,7 @@ class AppiumSchema {
152
190
  const ajv = this._ajv;
153
191
 
154
192
  // Ajv will _mutate_ the schema, so we need to clone it.
155
- const baseSchema = _.cloneDeep(/** @type {StrictSchemaObject} */(appiumConfigSchema));
193
+ const baseSchema = _.cloneDeep(appiumConfigSchema);
156
194
 
157
195
  /**
158
196
  *
@@ -202,7 +240,7 @@ class AppiumSchema {
202
240
  ajv.validateSchema(schema, true);
203
241
  addArgSpecs(schema.properties, extType, extName);
204
242
  ajv.addSchema(schema, $ref);
205
- finalizedSchemas[$ref] = /** @type {StrictSchemaObject} */(schema);
243
+ finalizedSchemas[$ref] = /** @type {StrictSchemaObject} */ (schema);
206
244
  });
207
245
  return baseSchema;
208
246
  },
@@ -253,7 +291,7 @@ class AppiumSchema {
253
291
  for (const schemaId of Object.keys(this._finalizedSchemas ?? {})) {
254
292
  this._ajv.removeSchema(schemaId);
255
293
  }
256
- this._argSpecs = new ReadonlyMap();
294
+ this._argSpecs = new RoachHotelMap();
257
295
  this._registeredSchemas = {
258
296
  [DRIVER_TYPE]: new Map(),
259
297
  [PLUGIN_TYPE]: new Map(),
@@ -270,19 +308,21 @@ class AppiumSchema {
270
308
  * This is "fail-fast" in that the schema will immediately be validated against JSON schema draft-07 _or_ whatever the value of the schema's `$schema` prop is.
271
309
  *
272
310
  * Does _not_ add the schema to the `ajv` instance (this is done by {@link AppiumSchema.finalize}).
273
- * @param {import('../ext-config-io').ExtensionType} extType - Extension type
311
+ * @param {ExtensionType} extType - Extension type
274
312
  * @param {string} extName - Unique extension name for `type`
275
313
  * @param {SchemaObject} schema - Schema object
276
314
  * @throws {SchemaNameConflictError} If the schema is an invalid
277
315
  * @returns {void}
278
316
  */
279
317
  registerSchema (extType, extName, schema) {
280
- if (!(extType && extName && !_.isEmpty(schema))) {
318
+ if (!(extType && extName) || _.isUndefined(schema)) {
281
319
  throw new TypeError(
282
- 'Expected nonempty extension type, extension name and schema parameters',
320
+ 'Expected extension type, extension name, and a defined schema',
283
321
  );
284
322
  }
285
-
323
+ if (!AppiumSchema.isSupportedSchemaType(schema)) {
324
+ throw new SchemaUnsupportedSchemaError(schema, extType, extName);
325
+ }
286
326
  const normalizedExtName = _.kebabCase(extName);
287
327
  if (this.hasRegisteredSchema(extType, normalizedExtName)) {
288
328
  if (this._registeredSchemas[extType].get(normalizedExtName) === schema) {
@@ -320,22 +360,67 @@ class AppiumSchema {
320
360
  /**
321
361
  * Returns a `Record` of argument "dest" strings to default values.
322
362
  *
323
- * The "dest" string is the property name in object returned by `argparse.ArgumentParser['parse_args']`.
324
- * @returns {Record<string,ArgSpec['defaultValue']>}
363
+ * The "dest" string is the property name in object returned by
364
+ * `argparse.ArgumentParser['parse_args']`.
365
+ * @template {boolean|undefined} Flattened
366
+ * @param {Flattened} [flatten=true] - If `true`, flattens the returned object
367
+ * using "keypath"-style keys of the format `<extType>.<extName>.<argName>`.
368
+ * Otherwise, returns a nested object using `extType` and `extName` as
369
+ * properties. Base arguments (server arguments) are always at the top level.
370
+ * @returns {DefaultValues<Flattened>}
325
371
  */
326
- getDefaults () {
372
+ getDefaults (flatten = /** @type {Flattened} */ (true)) {
327
373
  if (!this.isFinalized()) {
328
374
  throw new SchemaFinalizationError();
329
375
  }
330
- return [...this._argSpecs.values()].reduce(
331
- (defaults, {defaultValue, dest}) => {
376
+
377
+ /**
378
+ * @private
379
+ * @callback DefaultReducer
380
+ * @param {DefaultValues<Flattened>} defaults
381
+ * @param {ArgSpec} argSpec
382
+ * @returns {DefaultValues<Flattened>}
383
+ */
384
+ /** @type {DefaultReducer} */
385
+ const reducer = flatten
386
+ ? (defaults, {defaultValue, dest}) => {
332
387
  if (!_.isUndefined(defaultValue)) {
333
388
  defaults[dest] = defaultValue;
334
389
  }
335
390
  return defaults;
336
- },
337
- {},
391
+ }
392
+ : (defaults, {defaultValue, dest}) => {
393
+ if (!_.isUndefined(defaultValue)) {
394
+ _.set(defaults, dest, defaultValue);
395
+ }
396
+ return defaults;
397
+ };
398
+
399
+ /** @type {DefaultValues<Flattened>} */
400
+ const retval = {};
401
+ return [...this._argSpecs.values()].reduce(reducer, retval);
402
+ }
403
+
404
+ /**
405
+ * Returns a flattened Record of defaults for a specific extension. Keys will
406
+ * be of format `<argName>`.
407
+ * @param {ExtensionType} extType - Extension type
408
+ * @param {string} extName - Extension name
409
+ * @returns {Record<string,ArgSpecDefaultValue>}
410
+ */
411
+ getDefaultsForExtension (extType, extName) {
412
+ if (!this.isFinalized()) {
413
+ throw new SchemaFinalizationError();
414
+ }
415
+ const specs = [...this._argSpecs.values()].filter(
416
+ (spec) => spec.extType === extType && spec.extName === extName,
338
417
  );
418
+ return specs.reduce((defaults, {defaultValue, rawDest}) => {
419
+ if (!_.isUndefined(defaultValue)) {
420
+ defaults[rawDest] = defaultValue;
421
+ }
422
+ return defaults;
423
+ }, {});
339
424
  }
340
425
 
341
426
  /**
@@ -355,7 +440,7 @@ class AppiumSchema {
355
440
  flatten () {
356
441
  const schema = this.getSchema();
357
442
 
358
- /** @type {{properties: SchemaObject, prefix: string[]}[]} */
443
+ /** @type { {properties: SchemaObject, prefix: string[]}[] } */
359
444
  const stack = [{properties: schema.properties, prefix: []}];
360
445
  /** @type {FlattenedSchema} */
361
446
  const flattened = [];
@@ -416,7 +501,7 @@ class AppiumSchema {
416
501
  * Retrieves the schema itself
417
502
  * @public
418
503
  * @param {string} [ref] - Schema ID
419
- * @throws If the schema has not yet been _finalized_
504
+ * @throws If the schema has not yet been finalized
420
505
  * @returns {SchemaObject}
421
506
  */
422
507
  getSchema (ref = APPIUM_CONFIG_SCHEMA_ID) {
@@ -450,9 +535,7 @@ class AppiumSchema {
450
535
  * @returns {import('ajv').ErrorObject[]} Array of errors, if any.
451
536
  */
452
537
  validate (value, ref = APPIUM_CONFIG_SCHEMA_ID) {
453
- const validator = /** @type {import('ajv').ValidateFunction} */ (
454
- this._getValidator(ref)
455
- );
538
+ const validator = this._getValidator(ref);
456
539
  return !validator(value) && _.isArray(validator.errors)
457
540
  ? [...validator.errors]
458
541
  : [];
@@ -466,6 +549,15 @@ class AppiumSchema {
466
549
  static isAllowedSchemaFileExtension (filename) {
467
550
  return ALLOWED_SCHEMA_EXTENSIONS.has(path.extname(filename));
468
551
  }
552
+
553
+ /**
554
+ * Returns `true` if `schema` is a plain object with a non-true `$async` property.
555
+ * @param {any} schema - Schema to check
556
+ * @returns {schema is SchemaObject}
557
+ */
558
+ static isSupportedSchemaType (schema) {
559
+ return _.isPlainObject(schema) && schema.$async !== true;
560
+ }
469
561
  }
470
562
 
471
563
  /**
@@ -534,10 +626,59 @@ export class SchemaUnknownSchemaError extends ReferenceError {
534
626
  }
535
627
  }
536
628
 
629
+ /**
630
+ * Thrown when a schema is provided, but it's of an unsupported type.
631
+ *
632
+ * "Valid" schemas which are unsupported include boolean schemas and async schemas
633
+ * (having a `true` `$async` property).
634
+ */
635
+ export class SchemaUnsupportedSchemaError extends TypeError {
636
+ /**
637
+ * @type {Readonly<string>}
638
+ */
639
+ code = 'APPIUMERR_SCHEMA_UNSUPPORTED_SCHEMA';
640
+
641
+ /**
642
+ * @type {Readonly<{schema: any, extType: ExtensionType, extName: string}>}
643
+ */
644
+ data;
645
+
646
+ /**
647
+ * @param {any} schema
648
+ * @param {ExtensionType} extType
649
+ * @param {string} extName
650
+ */
651
+ constructor (schema, extType, extName) {
652
+ // https://github.com/Microsoft/TypeScript/issues/8277
653
+ super(
654
+ (() => {
655
+ let msg = `Unsupported schema from ${extType} "${extName}":`;
656
+ if (_.isBoolean(schema)) {
657
+ return `${msg} schema cannot be a boolean`;
658
+ }
659
+ if (_.isPlainObject(schema)) {
660
+ if (schema.$async) {
661
+ return `${msg} schema cannot be an async schema`;
662
+ }
663
+ /* istanbul ignore next */
664
+ throw new TypeError(
665
+ `schema IS supported; this error should not be thrown (this is a bug). value of schema: ${JSON.stringify(
666
+ schema,
667
+ )}`,
668
+ );
669
+ }
670
+ return `${msg} schema must be a plain object without a true "$async" property`;
671
+ })(),
672
+ );
673
+ this.data = {schema, extType, extName};
674
+ }
675
+ }
676
+
537
677
  const appiumSchema = AppiumSchema.create();
538
678
 
539
679
  export const {
540
680
  registerSchema,
681
+ getAllArgSpecs,
541
682
  getArgSpec,
542
683
  hasArgSpec,
543
684
  isFinalized,
@@ -546,21 +687,23 @@ export const {
546
687
  validate,
547
688
  getSchema,
548
689
  flatten: flattenSchema,
549
- getDefaults: getDefaultsFromSchema,
690
+ getDefaults: getDefaultsForSchema,
691
+ getDefaultsForExtension,
550
692
  } = appiumSchema;
551
693
  export const {isAllowedSchemaFileExtension} = AppiumSchema;
552
694
 
553
695
  /**
554
- * @typedef {import('ajv').SchemaObject} SchemaObject
696
+ * Appium only supports schemas that are plain objects; not arrays.
697
+ * @typedef {import('ajv').SchemaObject & {[key: number]: never}} SchemaObject
555
698
  */
556
699
 
557
700
  /**
558
- * @typedef {import('../ext-config-io').ExtensionType} ExtensionType
701
+ * @typedef {import('../extension/manifest').ExtensionType} ExtensionType
559
702
  */
560
703
 
561
704
  /**
562
705
  * An object having property `additionalProperties: false`
563
- * @typedef {Object} StrictProp
706
+ * @typedef StrictProp
564
707
  * @property {false} additionalProperties
565
708
  */
566
709
 
@@ -573,5 +716,20 @@ export const {isAllowedSchemaFileExtension} = AppiumSchema;
573
716
  * A list of schemas associated with properties and their corresponding {@link ArgSpec} objects.
574
717
  *
575
718
  * Intermediate data structure used when converting the entire schema down to CLI arguments.
576
- * @typedef {{schema: SchemaObject, argSpec: ArgSpec}[]} FlattenedSchema
719
+ * @typedef { {schema: SchemaObject, argSpec: ArgSpec}[] } FlattenedSchema
720
+ */
721
+
722
+ /**
723
+ * @typedef {ArgSpec['defaultValue']} ArgSpecDefaultValue
724
+ */
725
+
726
+ /**
727
+ * e.g. `{driver: {foo: 'bar'}}` where `foo` is the arg name and `bar` is the default value.
728
+ * @typedef {Record<string,Record<string,ArgSpecDefaultValue>>} NestedArgSpecDefaultValue
729
+ */
730
+
731
+ /**
732
+ * Helper type for the return value of {@link AppiumSchema.getDefaults}
733
+ * @template {boolean|undefined} Flattened
734
+ * @typedef {Record<string,Flattened extends true ? ArgSpecDefaultValue : ArgSpecDefaultValue | NestedArgSpecDefaultValue>} DefaultValues
577
735
  */
package/lib/utils.js CHANGED
@@ -1,37 +1,35 @@
1
+ // @ts-check
2
+
1
3
  import _ from 'lodash';
2
4
  import logger from './logger';
5
+ // @ts-ignore
3
6
  import { processCapabilities, PROTOCOLS } from '@appium/base-driver';
4
- import { fs } from '@appium/support';
7
+ import { inspect as dump } from 'util';
5
8
 
6
9
  const W3C_APPIUM_PREFIX = 'appium';
7
10
 
8
- function inspectObject (args) {
9
- function getValueArray (obj, indent = ' ') {
10
- if (!_.isObject(obj)) {
11
- return [obj];
12
- }
11
+ /**
12
+ *
13
+ * If `stdout` is a TTY, this is `true`.
14
+ *
15
+ * Used for tighter control over log output.
16
+ * @type {boolean}
17
+ */
18
+ const isStdoutTTY = process.stdout.isTTY;
13
19
 
14
- let strArr = ['{'];
15
- for (let [arg, value] of _.toPairs(obj)) {
16
- if (!_.isObject(value)) {
17
- strArr.push(`${indent} ${arg}: ${value}`);
18
- } else {
19
- value = getValueArray(value, `${indent} `);
20
- strArr.push(`${indent} ${arg}: ${value.shift()}`);
21
- strArr.push(...value);
22
- }
23
- }
24
- strArr.push(`${indent}}`);
25
- return strArr;
26
- }
27
- for (let [arg, value] of _.toPairs(args)) {
28
- value = getValueArray(value);
29
- logger.info(` ${arg}: ${value.shift()}`);
30
- for (let val of value) {
31
- logger.info(val);
32
- }
33
- }
34
- }
20
+ /**
21
+ * Dumps to value to the console using `info` logger.
22
+ *
23
+ * @todo May want to force color to be `false` if {@link isStdoutTTY} is `false`.
24
+ */
25
+ const inspect = _.flow(
26
+ _.partialRight(
27
+ /** @type {(object: any, options: import('util').InspectOptions) => string} */(dump),
28
+ {colors: true, depth: null, compact: !isStdoutTTY}
29
+ ),
30
+ (...args) => {
31
+ logger.info(...args);
32
+ });
35
33
 
36
34
  /**
37
35
  * Takes the caps that were provided in the request and translates them
@@ -216,36 +214,7 @@ function pullSettings (caps) {
216
214
  return result;
217
215
  }
218
216
 
219
- const rootDir = fs.findRoot(__dirname);
220
-
221
-
222
- /**
223
- * A Map where you can set properties, but only once. And you can't remove anything. So there.
224
- * @template K,V
225
- * @extends {Map<K,V>}
226
- */
227
- class ReadonlyMap extends Map {
228
- /**
229
- * @param {K} key
230
- * @param {V} value
231
- */
232
- set (key, value) {
233
- if (this.has(key)) {
234
- throw new Error(`${key} is already set`);
235
- }
236
- return super.set(key, value);
237
- }
238
-
239
- delete (key) {
240
- throw new Error(`${key} cannot be deleted`);
241
- }
242
-
243
- clear () {
244
- throw new Error(`Cannot clear ReadonlyMap`);
245
- }
246
- }
247
-
248
217
  export {
249
- inspectObject, parseCapsForInnerDriver, insertAppiumPrefixes, rootDir,
250
- getPackageVersion, pullSettings, removeAppiumPrefixes, ReadonlyMap
218
+ inspect, parseCapsForInnerDriver, insertAppiumPrefixes,
219
+ getPackageVersion, pullSettings, removeAppiumPrefixes
251
220
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "appium",
3
- "version": "2.0.0-beta.23",
3
+ "version": "2.0.0-beta.26",
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,52 @@
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
- "generate-docs": "gulp transpile && node ./build/commands-yml/parse.js",
40
- "postinstall": "node ./postinstall.js",
41
- "upload": "gulp github-upload",
42
- "zip": "zip -qr appium.zip .",
43
- "zip-and-upload": "npm run zip && npm run upload"
40
+ "build": "babel lib --root-mode=upward --delete-dir-on-start --out-dir=build/lib",
41
+ "postbuild": "npm run generate-schema-json",
42
+ "dev": "npm run build -- --watch",
43
+ "fix": "npm run lint -- --fix",
44
+ "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
+ "postinstall": "node ./scripts/postinstall.js",
48
+ "lint": "eslint -c ../../.eslintrc --ignore-path ../../.eslintignore .",
49
+ "test": "npm run test:unit",
50
+ "test:e2e": "mocha --require ../../test/setup-babel.js --timeout 20s --slow 10s \"./test/e2e/**/*.spec.js\"",
51
+ "test:unit": "mocha --require ../../test/setup-babel.js \"./test/unit/**/*.spec.js\""
44
52
  },
45
53
  "dependencies": {
46
- "@appium/base-driver": "^8.2.2",
47
- "@appium/base-plugin": "1.8.0",
48
- "@appium/support": "^2.55.2",
49
- "@babel/runtime": "7.16.3",
50
- "@sidvind/better-ajv-errors": "0.9.2",
51
- "ajv": "8.8.2",
54
+ "@appium/base-driver": "^8.3.0",
55
+ "@appium/base-plugin": "1.8.1",
56
+ "@appium/support": "^2.56.0",
57
+ "@babel/runtime": "7.17.8",
58
+ "@sidvind/better-ajv-errors": "1.1.1",
59
+ "ajv": "8.10.0",
52
60
  "ajv-formats": "2.1.1",
53
61
  "argparse": "2.0.1",
54
- "async-lock": "1.3.0",
62
+ "async-lock": "1.3.1",
55
63
  "asyncbox": "2.9.2",
56
- "axios": "0.24.0",
64
+ "axios": "0.26.1",
57
65
  "bluebird": "3.7.2",
58
66
  "continuation-local-storage": "3.2.1",
59
67
  "find-up": "5.0.0",
60
68
  "lilconfig": "2.0.4",
61
69
  "lodash": "4.17.21",
62
70
  "longjohn": "0.2.12",
63
- "npmlog": "5.0.1",
71
+ "npmlog": "6.0.1",
64
72
  "ora": "5.4.1",
73
+ "package-changed": "1.9.0",
65
74
  "resolve-from": "5.0.0",
66
75
  "semver": "7.3.5",
67
76
  "source-map-support": "0.5.21",
68
77
  "teen_process": "1.16.0",
69
- "winston": "3.3.3",
78
+ "winston": "3.6.0",
70
79
  "word-wrap": "1.2.3",
71
80
  "yaml": "1.10.2"
72
81
  },
@@ -78,6 +87,5 @@
78
87
  "access": "public",
79
88
  "tag": "next"
80
89
  },
81
- "homepage": "https://appium.io",
82
- "gitHead": "280d409df6c02d36b4ffc4d02a95ab3f4649b08c"
90
+ "gitHead": "f5cce0f29d31699decea63ed94c4506f7af469df"
83
91
  }
@@ -12,7 +12,7 @@ async function main () {
12
12
 
13
13
  let extension;
14
14
  try {
15
- extension = require('./build/lib/cli/extension');
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})`);