appium 2.0.0-beta.24 → 2.0.0-beta.27

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 (124) hide show
  1. package/build/lib/appium-config.schema.json +278 -0
  2. package/build/lib/appium.js +45 -66
  3. package/build/lib/cli/args.js +19 -39
  4. package/build/lib/cli/driver-command.js +5 -9
  5. package/build/lib/cli/extension-command.js +73 -64
  6. package/build/lib/cli/extension.js +10 -23
  7. package/build/lib/cli/parser.js +9 -19
  8. package/build/lib/cli/plugin-command.js +5 -9
  9. package/build/lib/cli/utils.js +2 -4
  10. package/build/lib/config-file.js +5 -10
  11. package/build/lib/config.js +50 -20
  12. package/build/lib/constants.js +60 -0
  13. package/build/lib/extension/driver-config.js +190 -0
  14. package/build/lib/extension/extension-config.js +297 -0
  15. package/build/lib/extension/index.js +77 -0
  16. package/build/lib/extension/manifest.js +246 -0
  17. package/build/lib/extension/package-changed.js +68 -0
  18. package/build/lib/extension/plugin-config.js +87 -0
  19. package/build/lib/grid-register.js +2 -4
  20. package/build/lib/logger.js +2 -4
  21. package/build/lib/logsink.js +2 -4
  22. package/build/lib/main.js +42 -71
  23. package/build/lib/schema/appium-config-schema.js +2 -4
  24. package/build/lib/schema/arg-spec.js +11 -14
  25. package/build/lib/schema/cli-args.js +2 -4
  26. package/build/lib/schema/cli-transformers.js +2 -4
  27. package/build/lib/schema/index.js +2 -4
  28. package/build/lib/schema/keywords.js +2 -4
  29. package/build/lib/schema/schema.js +61 -37
  30. package/build/lib/utils.js +1 -32
  31. package/lib/appium.js +50 -68
  32. package/lib/cli/args.js +19 -23
  33. package/lib/cli/driver-command.js +10 -2
  34. package/lib/cli/extension-command.js +216 -135
  35. package/lib/cli/extension.js +7 -15
  36. package/lib/cli/parser.js +6 -14
  37. package/lib/cli/plugin-command.js +1 -2
  38. package/lib/config-file.js +12 -15
  39. package/lib/config.js +55 -24
  40. package/lib/constants.js +79 -0
  41. package/lib/extension/driver-config.js +230 -0
  42. package/lib/extension/extension-config.js +459 -0
  43. package/lib/extension/index.js +103 -0
  44. package/lib/extension/manifest.js +590 -0
  45. package/lib/extension/package-changed.js +64 -0
  46. package/lib/extension/plugin-config.js +111 -0
  47. package/lib/grid-register.js +4 -4
  48. package/lib/main.js +57 -93
  49. package/lib/schema/arg-spec.js +3 -3
  50. package/lib/schema/cli-args.js +1 -0
  51. package/lib/schema/keywords.js +1 -1
  52. package/lib/schema/schema.js +67 -29
  53. package/lib/utils.js +2 -32
  54. package/package.json +29 -21
  55. package/{postinstall.js → scripts/postinstall.js} +1 -1
  56. package/types/types.d.ts +70 -31
  57. package/bin/ios-webkit-debug-proxy-launcher.js +0 -71
  58. package/build/check-npm-pack-files.js +0 -23
  59. package/build/commands-yml/parse.js +0 -319
  60. package/build/commands-yml/validator.js +0 -130
  61. package/build/index.js +0 -19
  62. package/build/lib/cli/npm.js +0 -220
  63. package/build/lib/driver-config.js +0 -100
  64. package/build/lib/drivers.js +0 -100
  65. package/build/lib/ext-config-io.js +0 -165
  66. package/build/lib/extension-config.js +0 -320
  67. package/build/lib/plugin-config.js +0 -69
  68. package/build/lib/plugins.js +0 -18
  69. package/build/postinstall.js +0 -90
  70. package/build/test/cli/cli-e2e-specs.js +0 -221
  71. package/build/test/cli/cli-helpers.js +0 -86
  72. package/build/test/cli/cli-specs.js +0 -71
  73. package/build/test/cli/fixtures/test-driver/package.json +0 -27
  74. package/build/test/cli/schema-args-specs.js +0 -48
  75. package/build/test/cli/schema-e2e-specs.js +0 -47
  76. package/build/test/config-e2e-specs.js +0 -112
  77. package/build/test/config-file-e2e-specs.js +0 -209
  78. package/build/test/config-file-specs.js +0 -281
  79. package/build/test/config-specs.js +0 -246
  80. package/build/test/driver-e2e-specs.js +0 -435
  81. package/build/test/driver-specs.js +0 -386
  82. package/build/test/ext-config-io-specs.js +0 -181
  83. package/build/test/extension-config-specs.js +0 -365
  84. package/build/test/fixtures/allow-feat.txt +0 -5
  85. package/build/test/fixtures/caps.json +0 -3
  86. package/build/test/fixtures/config/allow-insecure.txt +0 -3
  87. package/build/test/fixtures/config/appium.config.bad-nodeconfig.json +0 -5
  88. package/build/test/fixtures/config/appium.config.bad.json +0 -32
  89. package/build/test/fixtures/config/appium.config.ext-good.json +0 -9
  90. package/build/test/fixtures/config/appium.config.ext-unknown-props.json +0 -10
  91. package/build/test/fixtures/config/appium.config.good.js +0 -40
  92. package/build/test/fixtures/config/appium.config.good.json +0 -33
  93. package/build/test/fixtures/config/appium.config.good.yaml +0 -30
  94. package/build/test/fixtures/config/appium.config.invalid.json +0 -31
  95. package/build/test/fixtures/config/appium.config.security-array.json +0 -5
  96. package/build/test/fixtures/config/appium.config.security-delimited.json +0 -5
  97. package/build/test/fixtures/config/appium.config.security-path.json +0 -5
  98. package/build/test/fixtures/config/driver-fake.config.json +0 -8
  99. package/build/test/fixtures/config/nodeconfig.json +0 -3
  100. package/build/test/fixtures/config/plugin-fake.config.json +0 -0
  101. package/build/test/fixtures/default-args.js +0 -35
  102. package/build/test/fixtures/deny-feat.txt +0 -5
  103. package/build/test/fixtures/driver.schema.js +0 -20
  104. package/build/test/fixtures/extensions.yaml +0 -27
  105. package/build/test/fixtures/flattened-schema.js +0 -532
  106. package/build/test/fixtures/plugin.schema.js +0 -20
  107. package/build/test/fixtures/schema-with-extensions.js +0 -28
  108. package/build/test/grid-register-specs.js +0 -74
  109. package/build/test/helpers.js +0 -75
  110. package/build/test/logger-specs.js +0 -76
  111. package/build/test/npm-specs.js +0 -20
  112. package/build/test/parser-specs.js +0 -319
  113. package/build/test/plugin-e2e-specs.js +0 -316
  114. package/build/test/schema/arg-spec-specs.js +0 -70
  115. package/build/test/schema/cli-args-specs.js +0 -408
  116. package/build/test/schema/schema-specs.js +0 -407
  117. package/build/test/utils-specs.js +0 -288
  118. package/lib/cli/npm.js +0 -251
  119. package/lib/driver-config.js +0 -101
  120. package/lib/drivers.js +0 -84
  121. package/lib/ext-config-io.js +0 -287
  122. package/lib/extension-config.js +0 -366
  123. package/lib/plugin-config.js +0 -63
  124. package/lib/plugins.js +0 -13
package/lib/appium.js CHANGED
@@ -1,13 +1,11 @@
1
1
  import _ from 'lodash';
2
- import log from './logger';
3
2
  import { getBuildInfo, updateBuildInfo, APPIUM_VER } from './config';
4
- import { findMatchingDriver } from './drivers';
5
3
  import { BaseDriver, errors, isSessionCommand,
6
4
  CREATE_SESSION_COMMAND, DELETE_SESSION_COMMAND, GET_STATUS_COMMAND
7
5
  } from '@appium/base-driver';
8
6
  import AsyncLock from 'async-lock';
9
7
  import { parseCapsForInnerDriver, pullSettings } from './utils';
10
- import { util } from '@appium/support';
8
+ import { util, node, logger } from '@appium/support';
11
9
  import { getDefaultsForExtension } from './schema';
12
10
 
13
11
  const desiredCapabilityConstraints = {
@@ -62,7 +60,19 @@ class AppiumDriver extends BaseDriver {
62
60
  updateBuildInfo();
63
61
  }
64
62
 
65
- /** @type {import('./driver-config').default|undefined} */
63
+ /**
64
+ * Retrieves logger instance for the current umbrella driver instance
65
+ * @override
66
+ */
67
+ get log () {
68
+ if (!this._log) {
69
+ const instanceName = `${this.constructor.name}@${node.getObjectId(this).substring(0, 4)}`;
70
+ this._log = logger.getLogger(instanceName);
71
+ }
72
+ return this._log;
73
+ }
74
+
75
+ /** @type {import('./extension/driver-config').DriverConfig|undefined} */
66
76
  driverConfig;
67
77
 
68
78
  /** @type {import('express').Express|undefined} */
@@ -97,36 +107,28 @@ class AppiumDriver extends BaseDriver {
97
107
  }
98
108
 
99
109
  printNewSessionAnnouncement (driverName, driverVersion, driverBaseVersion) {
100
- log.info(driverVersion
110
+ this.log.info(driverVersion
101
111
  ? `Appium v${APPIUM_VER} creating new ${driverName} (v${driverVersion}) session`
102
112
  : `Appium v${APPIUM_VER} creating new ${driverName} session`
103
113
  );
104
- log.info(`Checking BaseDriver versions for Appium and ${driverName}`);
105
- log.info(AppiumDriver.baseVersion
114
+ this.log.info(`Checking BaseDriver versions for Appium and ${driverName}`);
115
+ this.log.info(AppiumDriver.baseVersion
106
116
  ? `Appium's BaseDriver version is ${AppiumDriver.baseVersion}`
107
117
  : `Could not determine Appium's BaseDriver version`
108
118
  );
109
- log.info(driverBaseVersion
119
+ this.log.info(driverBaseVersion
110
120
  ? `${driverName}'s BaseDriver version is ${driverBaseVersion}`
111
121
  : `Could not determine ${driverName}'s BaseDriver version`
112
122
  );
113
123
  }
114
124
 
115
- /**
116
- * This is just an alias for driver.js's method, which is necessary for
117
- * mocking in the test suite
118
- */
119
- _findMatchingDriver (...args) {
120
- return findMatchingDriver(...args);
121
- }
122
-
123
125
  /**
124
126
  * Validate and assign CLI args for a driver or plugin
125
127
  *
126
128
  * If the extension has provided a schema, validation has already happened.
127
129
  *
128
130
  * Any arg which is equal to its default value will not be assigned to the extension.
129
- * @param {import('./ext-config-io').ExtensionType} extType 'driver' or 'plugin'
131
+ * @param {import('./manifest').ExtensionType} extType 'driver' or 'plugin'
130
132
  * @param {string} extName the name of the extension
131
133
  * @param {Object} extInstance the driver or plugin instance
132
134
  */
@@ -189,7 +191,7 @@ class AppiumDriver extends BaseDriver {
189
191
  driver: InnerDriver,
190
192
  version: driverVersion,
191
193
  driverName
192
- } = this._findMatchingDriver(this.driverConfig, desiredCaps);
194
+ } = this.driverConfig.findMatchingDriver(desiredCaps);
193
195
  this.printNewSessionAnnouncement(InnerDriver.name, driverVersion, InnerDriver.baseVersion);
194
196
 
195
197
  if (this.args.sessionOverride) {
@@ -205,21 +207,21 @@ class AppiumDriver extends BaseDriver {
205
207
  // could have been set by a malicious user via capabilities, whereas we
206
208
  // want a guarantee the values were set by the appium server admin
207
209
  if (this.args.relaxedSecurityEnabled) {
208
- log.info(`Applying relaxed security to '${InnerDriver.name}' as per ` +
209
- `server command line argument. All insecure features will be ` +
210
- `enabled unless explicitly disabled by --deny-insecure`);
210
+ this.log.info(`Applying relaxed security to '${InnerDriver.name}' as per ` +
211
+ `server command line argument. All insecure features will be ` +
212
+ `enabled unless explicitly disabled by --deny-insecure`);
211
213
  driverInstance.relaxedSecurityEnabled = true;
212
214
  }
213
215
 
214
216
  if (!_.isEmpty(this.args.denyInsecure)) {
215
- log.info('Explicitly preventing use of insecure features:');
216
- this.args.denyInsecure.map((a) => log.info(` ${a}`));
217
+ this.log.info('Explicitly preventing use of insecure features:');
218
+ this.args.denyInsecure.map((a) => this.log.info(` ${a}`));
217
219
  driverInstance.denyInsecure = this.args.denyInsecure;
218
220
  }
219
221
 
220
222
  if (!_.isEmpty(this.args.allowInsecure)) {
221
- log.info('Explicitly enabling use of insecure features:');
222
- this.args.allowInsecure.map((a) => log.info(` ${a}`));
223
+ this.log.info('Explicitly enabling use of insecure features:');
224
+ this.args.allowInsecure.map((a) => this.log.info(` ${a}`));
223
225
  driverInstance.allowInsecure = this.args.allowInsecure;
224
226
  }
225
227
 
@@ -266,19 +268,19 @@ class AppiumDriver extends BaseDriver {
266
268
 
267
269
  this.attachUnexpectedShutdownHandler(driverInstance, innerSessionId);
268
270
 
269
- log.info(`New ${InnerDriver.name} session created successfully, session ` +
270
- `${innerSessionId} added to master session list`);
271
+ this.log.info(`New ${InnerDriver.name} session created successfully, session ` +
272
+ `${innerSessionId} added to master session list`);
271
273
 
272
274
  // set the New Command Timeout for the inner driver
273
275
  driverInstance.startNewCommandTimeout();
274
276
 
275
277
  // apply initial values to Appium settings (if provided)
276
278
  if (driverInstance.isW3CProtocol() && !_.isEmpty(w3cSettings)) {
277
- log.info(`Applying the initial values to Appium settings parsed from W3C caps: ` +
279
+ this.log.info(`Applying the initial values to Appium settings parsed from W3C caps: ` +
278
280
  JSON.stringify(w3cSettings));
279
281
  await driverInstance.updateSettings(w3cSettings);
280
282
  } else if (driverInstance.isMjsonwpProtocol() && !_.isEmpty(jwpSettings)) {
281
- log.info(`Applying the initial values to Appium settings parsed from MJSONWP caps: ` +
283
+ this.log.info(`Applying the initial values to Appium settings parsed from MJSONWP caps: ` +
282
284
  JSON.stringify(jwpSettings));
283
285
  await driverInstance.updateSettings(jwpSettings);
284
286
  }
@@ -297,24 +299,24 @@ class AppiumDriver extends BaseDriver {
297
299
 
298
300
  attachUnexpectedShutdownHandler (driver, innerSessionId) {
299
301
  const onShutdown = (cause = new Error('Unknown error')) => {
300
- log.warn(`Ending session, cause was '${cause.message}'`);
302
+ this.log.warn(`Ending session, cause was '${cause.message}'`);
301
303
 
302
304
  if (this.sessionPlugins[innerSessionId]) {
303
305
  for (const plugin of this.sessionPlugins[innerSessionId]) {
304
306
  if (_.isFunction(plugin.onUnexpectedShutdown)) {
305
- log.debug(`Plugin ${plugin.name} defines an unexpected shutdown handler; calling it now`);
307
+ this.log.debug(`Plugin ${plugin.name} defines an unexpected shutdown handler; calling it now`);
306
308
  try {
307
309
  plugin.onUnexpectedShutdown(driver, cause);
308
310
  } catch (e) {
309
- log.warn(`Got an error when running plugin ${plugin.name} shutdown handler: ${e}`);
311
+ this.log.warn(`Got an error when running plugin ${plugin.name} shutdown handler: ${e}`);
310
312
  }
311
313
  } else {
312
- log.debug(`Plugin ${plugin.name} does not define an unexpected shutdown handler`);
314
+ this.log.debug(`Plugin ${plugin.name} does not define an unexpected shutdown handler`);
313
315
  }
314
316
  }
315
317
  }
316
318
 
317
- log.info(`Removing session '${innerSessionId}' from our master session list`);
319
+ this.log.info(`Removing session '${innerSessionId}' from our master session list`);
318
320
  delete this.sessions[innerSessionId];
319
321
  delete this.sessionPlugins[innerSessionId];
320
322
  };
@@ -322,7 +324,7 @@ class AppiumDriver extends BaseDriver {
322
324
  if (_.isFunction(driver.onUnexpectedShutdown)) {
323
325
  driver.onUnexpectedShutdown(onShutdown);
324
326
  } else {
325
- log.warn(`Failed to attach the unexpected shutdown listener. ` +
327
+ this.log.warn(`Failed to attach the unexpected shutdown listener. ` +
326
328
  `Is 'onUnexpectedShutdown' method available for '${driver.constructor.name}'?`);
327
329
  }
328
330
  }
@@ -357,7 +359,7 @@ class AppiumDriver extends BaseDriver {
357
359
  .map(([, value]) => value.driverData);
358
360
  dstSession = this.sessions[sessionId];
359
361
  protocol = dstSession.protocol;
360
- log.info(`Removing session ${sessionId} from our master session list`);
362
+ this.log.info(`Removing session ${sessionId} from our master session list`);
361
363
  // regardless of whether the deleteSession completes successfully or not
362
364
  // make the session unavailable, because who knows what state it might
363
365
  // be in otherwise
@@ -369,7 +371,7 @@ class AppiumDriver extends BaseDriver {
369
371
  value: await dstSession.deleteSession(sessionId, otherSessionsData),
370
372
  };
371
373
  } catch (e) {
372
- log.error(`Had trouble ending session ${sessionId}: ${e.message}`);
374
+ this.log.error(`Had trouble ending session ${sessionId}: ${e.message}`);
373
375
  return {
374
376
  protocol,
375
377
  error: e,
@@ -380,7 +382,7 @@ class AppiumDriver extends BaseDriver {
380
382
  async deleteAllSessions (opts = {}) {
381
383
  const sessionsCount = _.size(this.sessions);
382
384
  if (0 === sessionsCount) {
383
- log.debug('There are no active sessions for cleanup');
385
+ this.log.debug('There are no active sessions for cleanup');
384
386
  return;
385
387
  }
386
388
 
@@ -388,7 +390,7 @@ class AppiumDriver extends BaseDriver {
388
390
  force = false,
389
391
  reason,
390
392
  } = opts;
391
- log.debug(`Cleaning up ${util.pluralize('active session', sessionsCount, true)}`);
393
+ this.log.debug(`Cleaning up ${util.pluralize('active session', sessionsCount, true)}`);
392
394
  const cleanupPromises = force
393
395
  ? _.values(this.sessions).map((drv) => drv.startUnexpectedShutdown(reason && new Error(reason)))
394
396
  : _.keys(this.sessions).map((id) => this.deleteSession(id));
@@ -396,7 +398,7 @@ class AppiumDriver extends BaseDriver {
396
398
  try {
397
399
  await cleanupPromise;
398
400
  } catch (e) {
399
- log.debug(e);
401
+ this.log.debug(e);
400
402
  }
401
403
  }
402
404
  }
@@ -509,7 +511,7 @@ class AppiumDriver extends BaseDriver {
509
511
  // if we're running with plugins, make sure we log that the default behavior is actually
510
512
  // happening so we can tell when the plugin call chain is unwrapping to the default behavior
511
513
  // if that's what happens
512
- plugins.length && log.info(`Executing default handling behavior for command '${cmd}'`);
514
+ plugins.length && this.log.info(`Executing default handling behavior for command '${cmd}'`);
513
515
 
514
516
  // if we make it here, we know that the default behavior is handled
515
517
  cmdHandledBy.default = true;
@@ -555,8 +557,8 @@ class AppiumDriver extends BaseDriver {
555
557
  // their createSession method and other instance methods
556
558
  if (cmd === CREATE_SESSION_COMMAND && this.sessionlessPlugins.length && !res.error) {
557
559
  const sessionId = _.first(res.value);
558
- log.info(`Promoting ${this.sessionlessPlugins.length} sessionless plugins to be attached ` +
559
- `to session ID ${sessionId}`);
560
+ this.log.info(`Promoting ${this.sessionlessPlugins.length} sessionless plugins to be attached ` +
561
+ `to session ID ${sessionId}`);
560
562
  this.sessionPlugins[sessionId] = this.sessionlessPlugins;
561
563
  this.sessionlessPlugins = [];
562
564
  }
@@ -565,7 +567,7 @@ class AppiumDriver extends BaseDriver {
565
567
  }
566
568
 
567
569
  wrapCommandWithPlugins ({driver, cmd, args, next, cmdHandledBy, plugins}) {
568
- plugins.length && log.info(`Plugins which can handle cmd '${cmd}': ${plugins.map((p) => p.name)}`);
570
+ plugins.length && this.log.info(`Plugins which can handle cmd '${cmd}': ${plugins.map((p) => p.name)}`);
569
571
 
570
572
  // now we can go through each plugin and wrap `next` around its own handler, passing the *old*
571
573
  // next in so that it can call it if it wants to
@@ -575,7 +577,7 @@ class AppiumDriver extends BaseDriver {
575
577
  // evaluated, otherwise we end up with infinite recursion of the last `next` to be defined.
576
578
  cmdHandledBy[plugin.name] = false; // we see a new plugin, so add it to the 'cmdHandledBy' object
577
579
  next = ((_next) => async () => {
578
- log.info(`Plugin ${plugin.name} is now handling cmd '${cmd}'`);
580
+ this.log.info(`Plugin ${plugin.name} is now handling cmd '${cmd}'`);
579
581
  cmdHandledBy[plugin.name] = true; // if we make it here, this plugin has attempted to handle cmd
580
582
  // first attempt to handle the command via a command-specific handler on the plugin
581
583
  if (plugin[cmd]) {
@@ -603,9 +605,9 @@ class AppiumDriver extends BaseDriver {
603
605
  const didHandle = Object.keys(cmdHandledBy).filter((k) => cmdHandledBy[k]);
604
606
  const didntHandle = Object.keys(cmdHandledBy).filter((k) => !cmdHandledBy[k]);
605
607
  if (didntHandle.length > 0) {
606
- log.info(`Command '${cmd}' was *not* handled by the following behaviours or plugins, even ` +
607
- `though they were registered to handle it: ${JSON.stringify(didntHandle)}. The ` +
608
- `command *was* handled by these: ${JSON.stringify(didHandle)}.`);
608
+ this.log.info(`Command '${cmd}' was *not* handled by the following behaviours or plugins, even ` +
609
+ `though they were registered to handle it: ${JSON.stringify(didntHandle)}. The ` +
610
+ `command *was* handled by these: ${JSON.stringify(didHandle)}.`);
609
611
  }
610
612
  }
611
613
 
@@ -674,23 +676,3 @@ export class NoDriverProxyCommandError extends Error {
674
676
  }
675
677
 
676
678
  export { AppiumDriver };
677
-
678
-
679
- /**
680
- * @typedef {Object} StaticExtMembers
681
- * @property {(app: import('express').Express, httpServer: import('http').Server) => import('type-fest').Promisable<void>} [updateServer]
682
- * @property {import('@appium/base-driver').MethodMap} [newMethodMap]
683
- */
684
-
685
- /**
686
- * @typedef {Object} StaticPluginMembers
687
- * @property {string} pluginName
688
- */
689
-
690
- /**
691
- * @typedef {import('type-fest').Class<unknown> & StaticPluginMembers & StaticExtMembers} PluginExtensionClass
692
- */
693
-
694
- /**
695
- * @typedef {import('type-fest').Class<unknown> & StaticExtMembers} DriverExtensionClass
696
- */
package/lib/cli/args.js CHANGED
@@ -2,21 +2,21 @@
2
2
 
3
3
  // @ts-ignore
4
4
  import _ from 'lodash';
5
- import DriverConfig from '../driver-config';
6
- import { APPIUM_HOME, DRIVER_TYPE, INSTALL_TYPES, PLUGIN_TYPE } from '../extension-config';
7
- import PluginConfig from '../plugin-config';
5
+ import { DRIVER_TYPE, PLUGIN_TYPE, EXT_SUBCOMMAND_INSTALL, EXT_SUBCOMMAND_LIST, EXT_SUBCOMMAND_RUN, EXT_SUBCOMMAND_UNINSTALL, EXT_SUBCOMMAND_UPDATE } from '../constants';
6
+ import { INSTALL_TYPES } from '../extension/extension-config';
8
7
  import { toParserArgs } from '../schema/cli-args';
9
-
10
8
  const DRIVER_EXAMPLE = 'xcuitest';
11
9
  const PLUGIN_EXAMPLE = 'find_by_image';
12
- const USE_ALL_PLUGINS = 'all';
10
+
11
+ /**
12
+ * This is necessary because we pass the array into `argparse`. `argparse` is bad and mutates things. We don't want that.
13
+ * Bad `argparse`! Bad!
14
+ */
15
+ const INSTALL_TYPES_ARRAY = [...INSTALL_TYPES];
13
16
 
14
17
  /** @type {Set<ExtensionType>} */
15
18
  const EXTENSION_TYPES = new Set([DRIVER_TYPE, PLUGIN_TYPE]);
16
19
 
17
- const driverConfig = DriverConfig.getInstance(APPIUM_HOME);
18
- const pluginConfig = PluginConfig.getInstance(APPIUM_HOME);
19
-
20
20
  // this set of args works for both drivers and plugins ('extensions')
21
21
  /** @type {ArgumentDefinitions} */
22
22
  const globalExtensionArgs = new Map([
@@ -32,18 +32,18 @@ const globalExtensionArgs = new Map([
32
32
  /**
33
33
  * Builds a Record of extension types to a Record of subcommands to their argument definitions
34
34
  */
35
- const getExtensionArgs = _.once(function getExtensionArgs () {
35
+ const getExtensionArgs = _.memoize(function getExtensionArgs () {
36
36
  const extensionArgs = {};
37
37
  for (const type of EXTENSION_TYPES) {
38
38
  extensionArgs[type] = {
39
- list: makeListArgs(type),
40
- install: makeInstallArgs(type),
41
- uninstall: makeUninstallArgs(type),
42
- update: makeUpdateArgs(type),
43
- run: makeRunArgs(type),
39
+ [EXT_SUBCOMMAND_LIST]: makeListArgs(type),
40
+ [EXT_SUBCOMMAND_INSTALL]: makeInstallArgs(type),
41
+ [EXT_SUBCOMMAND_UNINSTALL]: makeUninstallArgs(type),
42
+ [EXT_SUBCOMMAND_UPDATE]: makeUpdateArgs(type),
43
+ [EXT_SUBCOMMAND_RUN]: makeRunArgs(type),
44
44
  };
45
45
  }
46
- return /** @type {Record<ExtensionType, Record<string,ArgumentDefinitions[]>>} */ (extensionArgs);
46
+ return /** @type {Record<ExtensionType, Record<import('../../types/types').CliExtensionSubcommand,ArgumentDefinitions>>} */(extensionArgs);
47
47
  });
48
48
 
49
49
  /**
@@ -87,9 +87,9 @@ function makeInstallArgs (type) {
87
87
  [['--source'], {
88
88
  required: false,
89
89
  default: null,
90
- choices: INSTALL_TYPES,
90
+ choices: INSTALL_TYPES_ARRAY,
91
91
  help: `Where to look for the ${type} if it is not one of Appium's verified ` +
92
- `${type}s. Possible values: ${INSTALL_TYPES.join(', ')}`,
92
+ `${type}s. Possible values: ${INSTALL_TYPES_ARRAY.join(', ')}`,
93
93
  dest: 'installType'
94
94
  }],
95
95
  [['--package'], {
@@ -227,16 +227,12 @@ const serverArgsDisallowedInConfig = new Map([
227
227
 
228
228
  export {
229
229
  getServerArgs,
230
- getExtensionArgs,
231
- USE_ALL_PLUGINS,
232
- driverConfig,
233
- pluginConfig,
234
- APPIUM_HOME
230
+ getExtensionArgs
235
231
  };
236
232
 
237
233
  /**
238
234
  * Alias
239
- * @typedef {import('../ext-config-io').ExtensionType} ExtensionType
235
+ * @typedef {import('../extension/manifest').ExtensionType} ExtensionType
240
236
  */
241
237
 
242
238
  /**
@@ -1,12 +1,14 @@
1
1
  import _ from 'lodash';
2
2
  import ExtensionCommand from './extension-command';
3
- import { DRIVER_TYPE } from '../extension-config';
4
- import { KNOWN_DRIVERS } from '../drivers';
3
+ import { DRIVER_TYPE, KNOWN_DRIVERS } from '../constants';
5
4
 
6
5
  const REQ_DRIVER_FIELDS = ['driverName', 'automationName', 'platformNames', 'mainClass'];
7
6
 
8
7
  export default class DriverCommand extends ExtensionCommand {
9
8
 
9
+ /**
10
+ * @param {DriverCommandOptions} opts
11
+ */
10
12
  constructor ({config, json}) {
11
13
  super({config, json, type: DRIVER_TYPE});
12
14
  this.knownExtensions = KNOWN_DRIVERS;
@@ -47,3 +49,9 @@ export default class DriverCommand extends ExtensionCommand {
47
49
  }
48
50
 
49
51
  }
52
+
53
+ /**
54
+ * @typedef DriverCommandOptions
55
+ * @property {import('../extension/driver-config').DriverConfig} config
56
+ * @property {boolean} json
57
+ */