appium 2.0.0-beta.4 → 2.0.0-beta.42

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 (153) hide show
  1. package/README.md +10 -11
  2. package/build/lib/appium.d.ts +204 -0
  3. package/build/lib/appium.d.ts.map +1 -0
  4. package/build/lib/appium.js +256 -131
  5. package/build/lib/cli/args.d.ts +17 -0
  6. package/build/lib/cli/args.d.ts.map +1 -0
  7. package/build/lib/cli/args.js +96 -282
  8. package/build/lib/cli/driver-command.d.ts +37 -0
  9. package/build/lib/cli/driver-command.d.ts.map +1 -0
  10. package/build/lib/cli/driver-command.js +27 -18
  11. package/build/lib/cli/extension-command.d.ts +376 -0
  12. package/build/lib/cli/extension-command.d.ts.map +1 -0
  13. package/build/lib/cli/extension-command.js +287 -156
  14. package/build/lib/cli/extension.d.ts +22 -0
  15. package/build/lib/cli/extension.d.ts.map +1 -0
  16. package/build/lib/cli/extension.js +31 -17
  17. package/build/lib/cli/parser.d.ts +84 -0
  18. package/build/lib/cli/parser.d.ts.map +1 -0
  19. package/build/lib/cli/parser.js +164 -94
  20. package/build/lib/cli/plugin-command.d.ts +34 -0
  21. package/build/lib/cli/plugin-command.d.ts.map +1 -0
  22. package/build/lib/cli/plugin-command.js +26 -19
  23. package/build/lib/cli/utils.d.ts +29 -0
  24. package/build/lib/cli/utils.d.ts.map +1 -0
  25. package/build/lib/cli/utils.js +27 -3
  26. package/build/lib/config-file.d.ts +100 -0
  27. package/build/lib/config-file.d.ts.map +1 -0
  28. package/build/lib/config-file.js +136 -0
  29. package/build/lib/config.d.ts +49 -0
  30. package/build/lib/config.d.ts.map +1 -0
  31. package/build/lib/config.js +119 -96
  32. package/build/lib/constants.d.ts +48 -0
  33. package/build/lib/constants.d.ts.map +1 -0
  34. package/build/lib/constants.js +60 -0
  35. package/build/lib/extension/driver-config.d.ts +81 -0
  36. package/build/lib/extension/driver-config.d.ts.map +1 -0
  37. package/build/lib/extension/driver-config.js +177 -0
  38. package/build/lib/extension/extension-config.d.ts +242 -0
  39. package/build/lib/extension/extension-config.d.ts.map +1 -0
  40. package/build/lib/extension/extension-config.js +436 -0
  41. package/build/lib/extension/index.d.ts +48 -0
  42. package/build/lib/extension/index.d.ts.map +1 -0
  43. package/build/lib/extension/index.js +75 -0
  44. package/build/lib/extension/manifest.d.ts +174 -0
  45. package/build/lib/extension/manifest.d.ts.map +1 -0
  46. package/build/lib/extension/manifest.js +256 -0
  47. package/build/lib/extension/package-changed.d.ts +11 -0
  48. package/build/lib/extension/package-changed.d.ts.map +1 -0
  49. package/build/lib/extension/package-changed.js +66 -0
  50. package/build/lib/extension/plugin-config.d.ts +57 -0
  51. package/build/lib/extension/plugin-config.d.ts.map +1 -0
  52. package/build/lib/extension/plugin-config.js +78 -0
  53. package/build/lib/grid-register.d.ts +10 -0
  54. package/build/lib/grid-register.d.ts.map +1 -0
  55. package/build/lib/grid-register.js +21 -25
  56. package/build/lib/logger.d.ts +3 -0
  57. package/build/lib/logger.d.ts.map +1 -0
  58. package/build/lib/logger.js +4 -6
  59. package/build/lib/logsink.d.ts +4 -0
  60. package/build/lib/logsink.d.ts.map +1 -0
  61. package/build/lib/logsink.js +14 -17
  62. package/build/lib/main.d.ts +55 -0
  63. package/build/lib/main.d.ts.map +1 -0
  64. package/build/lib/main.js +183 -91
  65. package/build/lib/schema/arg-spec.d.ts +143 -0
  66. package/build/lib/schema/arg-spec.d.ts.map +1 -0
  67. package/build/lib/schema/arg-spec.js +119 -0
  68. package/build/lib/schema/cli-args.d.ts +19 -0
  69. package/build/lib/schema/cli-args.d.ts.map +1 -0
  70. package/build/lib/schema/cli-args.js +178 -0
  71. package/build/lib/schema/cli-transformers.d.ts +5 -0
  72. package/build/lib/schema/cli-transformers.d.ts.map +1 -0
  73. package/build/lib/schema/cli-transformers.js +74 -0
  74. package/build/lib/schema/index.d.ts +3 -0
  75. package/build/lib/schema/index.d.ts.map +1 -0
  76. package/build/lib/schema/index.js +34 -0
  77. package/build/lib/schema/keywords.d.ts +24 -0
  78. package/build/lib/schema/keywords.d.ts.map +1 -0
  79. package/build/lib/schema/keywords.js +70 -0
  80. package/build/lib/schema/schema.d.ts +259 -0
  81. package/build/lib/schema/schema.d.ts.map +1 -0
  82. package/build/lib/schema/schema.js +450 -0
  83. package/build/lib/utils.d.ts +66 -0
  84. package/build/lib/utils.d.ts.map +1 -0
  85. package/build/lib/utils.js +35 -139
  86. package/build/tsconfig.tsbuildinfo +1 -0
  87. package/build/types/appium-manifest.d.ts +59 -0
  88. package/build/types/appium-manifest.d.ts.map +1 -0
  89. package/build/types/cli.d.ts +123 -0
  90. package/build/types/cli.d.ts.map +1 -0
  91. package/build/types/extension-manifest.d.ts +55 -0
  92. package/build/types/extension-manifest.d.ts.map +1 -0
  93. package/build/types/index.d.ts +16 -0
  94. package/build/types/index.d.ts.map +1 -0
  95. package/driver.d.ts +1 -0
  96. package/driver.js +14 -0
  97. package/index.js +11 -0
  98. package/lib/appium.js +520 -186
  99. package/lib/cli/args.js +267 -422
  100. package/lib/cli/driver-command.js +58 -23
  101. package/lib/cli/extension-command.js +613 -260
  102. package/lib/cli/extension.js +47 -17
  103. package/lib/cli/parser.js +263 -83
  104. package/lib/cli/plugin-command.js +48 -20
  105. package/lib/cli/utils.js +24 -10
  106. package/lib/config-file.js +219 -0
  107. package/lib/config.js +243 -110
  108. package/lib/constants.js +69 -0
  109. package/lib/extension/driver-config.js +249 -0
  110. package/lib/extension/extension-config.js +677 -0
  111. package/lib/extension/index.js +116 -0
  112. package/lib/extension/manifest.js +475 -0
  113. package/lib/extension/package-changed.js +64 -0
  114. package/lib/extension/plugin-config.js +113 -0
  115. package/lib/grid-register.js +49 -35
  116. package/lib/logger.js +1 -2
  117. package/lib/logsink.js +38 -33
  118. package/lib/main.js +308 -100
  119. package/lib/schema/arg-spec.js +229 -0
  120. package/lib/schema/cli-args.js +238 -0
  121. package/lib/schema/cli-transformers.js +115 -0
  122. package/lib/schema/index.js +2 -0
  123. package/lib/schema/keywords.js +136 -0
  124. package/lib/schema/schema.js +717 -0
  125. package/lib/utils.js +121 -140
  126. package/package.json +85 -85
  127. package/plugin.d.ts +1 -0
  128. package/plugin.js +13 -0
  129. package/scripts/autoinstall-extensions.js +185 -0
  130. package/support.d.ts +1 -0
  131. package/support.js +13 -0
  132. package/test.d.ts +7 -0
  133. package/test.js +13 -0
  134. package/types/appium-manifest.ts +73 -0
  135. package/types/cli.ts +150 -0
  136. package/types/extension-manifest.ts +64 -0
  137. package/types/index.ts +21 -0
  138. package/CHANGELOG.md +0 -3515
  139. package/bin/ios-webkit-debug-proxy-launcher.js +0 -71
  140. package/build/lib/cli/npm.js +0 -206
  141. package/build/lib/cli/parser-helpers.js +0 -82
  142. package/build/lib/driver-config.js +0 -77
  143. package/build/lib/drivers.js +0 -96
  144. package/build/lib/extension-config.js +0 -253
  145. package/build/lib/plugin-config.js +0 -59
  146. package/build/lib/plugins.js +0 -14
  147. package/lib/cli/npm.js +0 -183
  148. package/lib/cli/parser-helpers.js +0 -79
  149. package/lib/driver-config.js +0 -46
  150. package/lib/drivers.js +0 -81
  151. package/lib/extension-config.js +0 -209
  152. package/lib/plugin-config.js +0 -34
  153. package/lib/plugins.js +0 -10
package/lib/cli/args.js CHANGED
@@ -1,443 +1,288 @@
1
- import { DEFAULT_BASE_PATH } from 'appium-base-driver';
2
- import { parseSecurityFeatures, parseDefaultCaps, parsePluginNames, parseInstallTypes } from './parser-helpers';
3
- import { INSTALL_TYPES, DEFAULT_APPIUM_HOME, DRIVER_TYPE, PLUGIN_TYPE } from '../extension-config';
4
-
1
+ import _ from 'lodash';
2
+ import {
3
+ DRIVER_TYPE,
4
+ PLUGIN_TYPE,
5
+ EXT_SUBCOMMAND_INSTALL,
6
+ EXT_SUBCOMMAND_LIST,
7
+ EXT_SUBCOMMAND_RUN,
8
+ EXT_SUBCOMMAND_UNINSTALL,
9
+ EXT_SUBCOMMAND_UPDATE,
10
+ } from '../constants';
11
+ import {INSTALL_TYPES} from '../extension/extension-config';
12
+ import {toParserArgs} from '../schema/cli-args';
5
13
  const DRIVER_EXAMPLE = 'xcuitest';
6
14
  const PLUGIN_EXAMPLE = 'find_by_image';
7
- const USE_ALL_PLUGINS = 'all';
8
-
9
- // sharedArgs will be added to every subcommand
10
- const sharedArgs = [
11
- [['-ah', '--home', '--appium-home'], {
12
- required: false,
13
- defaultValue: process.env.APPIUM_HOME || DEFAULT_APPIUM_HOME,
14
- help: 'The path to the directory where Appium will keep installed drivers, plugins, and any other metadata necessary for its operation',
15
- dest: 'appiumHome',
16
- }],
17
-
18
- [['--log-filters'], {
19
- dest: 'logFilters',
20
- defaultValue: null,
21
- required: false,
22
- help: 'Set the full path to a JSON file containing one or more log filtering rules',
23
- example: '/home/rules.json',
24
- }],
25
- ];
26
-
27
- const serverArgs = [
28
- [['--shell'], {
29
- required: false,
30
- defaultValue: null,
31
- help: 'Enter REPL mode',
32
- nargs: 0,
33
- dest: 'shell',
34
- }],
35
-
36
- [['--plugins'], {
37
- required: false,
38
- defaultValue: [],
39
- help: `A comma-separated list of installed plugin names that should be active for this ` +
40
- `server. To activate all plugins, you can use the single string "${USE_ALL_PLUGINS}" ` +
41
- `as the value (e.g. --plugins=${USE_ALL_PLUGINS})`,
42
- type: parsePluginNames,
43
- dest: 'plugins',
44
- }],
45
-
46
- [['--allow-cors'], {
47
- required: false,
48
- defaultValue: false,
49
- action: 'storeTrue',
50
- help: 'Whether the Appium server should allow web browser connections from any host',
51
- nargs: 0,
52
- dest: 'allowCors',
53
- }],
54
-
55
- [['--reboot'], {
56
- defaultValue: false,
57
- dest: 'reboot',
58
- action: 'storeTrue',
59
- required: false,
60
- help: '(Android-only) reboot emulator after each session and kill it at the end',
61
- nargs: 0,
62
- }],
63
-
64
- [['-a', '--address'], {
65
- defaultValue: '0.0.0.0',
66
- required: false,
67
- example: '0.0.0.0',
68
- help: 'IP Address to listen on',
69
- dest: 'address',
70
- }],
71
-
72
- [['-p', '--port'], {
73
- defaultValue: 4723,
74
- required: false,
75
- type: 'int',
76
- example: '4723',
77
- help: 'port to listen on',
78
- dest: 'port',
79
- }],
80
-
81
- [['-pa', '--base-path'], {
82
- required: false,
83
- defaultValue: DEFAULT_BASE_PATH,
84
- dest: 'basePath',
85
- example: '/path/prefix',
86
- help: 'Base path to use as the prefix for all webdriver routes running' +
87
- `on this server (default: ${DEFAULT_BASE_PATH})`
88
- }],
89
-
90
- [['-ca', '--callback-address'], {
91
- required: false,
92
- dest: 'callbackAddress',
93
- defaultValue: null,
94
- example: '127.0.0.1',
95
- help: 'callback IP Address (default: same as --address)',
96
- }],
97
-
98
- [['-cp', '--callback-port'], {
99
- required: false,
100
- dest: 'callbackPort',
101
- defaultValue: null,
102
- type: 'int',
103
- example: '4723',
104
- help: 'callback port (default: same as port)',
105
- }],
106
-
107
- [['--session-override'], {
108
- defaultValue: false,
109
- dest: 'sessionOverride',
110
- action: 'storeTrue',
111
- required: false,
112
- help: 'Enables session override (clobbering)',
113
- nargs: 0,
114
- }],
115
-
116
- [['-g', '--log'], {
117
- defaultValue: null,
118
- dest: 'logFile',
119
- required: false,
120
- example: '/path/to/appium.log',
121
- help: 'Also send log output to this file',
122
- }],
123
-
124
- [['--log-level'], {
125
- choices: [
126
- 'info', 'info:debug', 'info:info', 'info:warn', 'info:error',
127
- 'warn', 'warn:debug', 'warn:info', 'warn:warn', 'warn:error',
128
- 'error', 'error:debug', 'error:info', 'error:warn', 'error:error',
129
- 'debug', 'debug:debug', 'debug:info', 'debug:warn', 'debug:error',
130
- ],
131
- defaultValue: 'debug',
132
- dest: 'loglevel',
133
- required: false,
134
- example: 'debug',
135
- help: 'log level; default (console[:file]): debug[:debug]',
136
- }],
137
-
138
- [['--log-timestamp'], {
139
- defaultValue: false,
140
- required: false,
141
- help: 'Show timestamps in console output',
142
- nargs: 0,
143
- action: 'storeTrue',
144
- dest: 'logTimestamp',
145
- }],
146
-
147
- [['--local-timezone'], {
148
- defaultValue: false,
149
- required: false,
150
- help: 'Use local timezone for timestamps',
151
- nargs: 0,
152
- action: 'storeTrue',
153
- dest: 'localTimezone',
154
- }],
155
-
156
- [['--log-no-colors'], {
157
- defaultValue: false,
158
- required: false,
159
- help: 'Do not use colors in console output',
160
- nargs: 0,
161
- action: 'storeTrue',
162
- dest: 'logNoColors',
163
- }],
164
-
165
- [['-G', '--webhook'], {
166
- defaultValue: null,
167
- required: false,
168
- example: 'localhost:9876',
169
- dest: 'webhook',
170
- help: 'Also send log output to this HTTP listener',
171
- }],
172
-
173
- [['--nodeconfig'], {
174
- required: false,
175
- defaultValue: null,
176
- dest: 'nodeconfig',
177
- help: 'Configuration JSON file to register appium with selenium grid',
178
- example: '/abs/path/to/nodeconfig.json',
179
- }],
180
-
181
- [['--chromedriver-port'], {
182
- defaultValue: null,
183
- dest: 'chromeDriverPort',
184
- required: false,
185
- type: 'int',
186
- example: '9515',
187
- help: 'Port upon which ChromeDriver will run. If not given, Android driver will pick a random available port.',
188
- }],
189
-
190
- [['--chromedriver-executable'], {
191
- defaultValue: null,
192
- dest: 'chromedriverExecutable',
193
- required: false,
194
- help: 'ChromeDriver executable full path',
195
- }],
196
-
197
- [['--show-config'], {
198
- defaultValue: false,
199
- dest: 'showConfig',
200
- action: 'storeTrue',
201
- required: false,
202
- help: 'Show info about the appium server configuration and exit',
203
- }],
204
-
205
- [['--no-perms-check'], {
206
- defaultValue: false,
207
- dest: 'noPermsCheck',
208
- action: 'storeTrue',
209
- required: false,
210
- help: 'Bypass Appium\'s checks to ensure we can read/write necessary files',
211
- }],
212
-
213
- [['--strict-caps'], {
214
- defaultValue: false,
215
- dest: 'enforceStrictCaps',
216
- action: 'storeTrue',
217
- required: false,
218
- help: 'Cause sessions to fail if desired caps are sent in that Appium ' +
219
- 'does not recognize as valid for the selected device',
220
- nargs: 0,
221
- }],
222
-
223
- [['--tmp'], {
224
- defaultValue: null,
225
- dest: 'tmpDir',
226
- required: false,
227
- help: 'Absolute path to directory Appium can use to manage temporary ' +
228
- 'files, like built-in iOS apps it needs to move around. On *nix/Mac ' +
229
- 'defaults to /tmp, on Windows defaults to C:\\Windows\\Temp',
230
- }],
231
-
232
- [['--trace-dir'], {
233
- defaultValue: null,
234
- dest: 'traceDir',
235
- required: false,
236
- help: 'Absolute path to directory Appium use to save ios instruments ' +
237
- 'traces, defaults to <tmp dir>/appium-instruments',
238
- }],
239
-
240
- [['--debug-log-spacing'], {
241
- dest: 'debugLogSpacing',
242
- defaultValue: false,
243
- action: 'storeTrue',
244
- required: false,
245
- help: 'Add exaggerated spacing in logs to help with visual inspection',
246
- }],
247
-
248
- [['--suppress-adb-kill-server'], {
249
- dest: 'suppressKillServer',
250
- defaultValue: false,
251
- action: 'storeTrue',
252
- required: false,
253
- help: '(Android-only) If set, prevents Appium from killing the adb server instance',
254
- nargs: 0,
255
- }],
256
-
257
- [['--long-stacktrace'], {
258
- dest: 'longStacktrace',
259
- defaultValue: false,
260
- required: false,
261
- action: 'storeTrue',
262
- help: 'Add long stack traces to log entries. Recommended for debugging only.',
263
- }],
264
-
265
- [['--webkit-debug-proxy-port'], {
266
- defaultValue: 27753,
267
- dest: 'webkitDebugProxyPort',
268
- required: false,
269
- type: 'int',
270
- example: '27753',
271
- help: '(IOS-only) Local port used for communication with ios-webkit-debug-proxy'
272
- }],
273
-
274
- [['--webdriveragent-port'], {
275
- defaultValue: 8100,
276
- dest: 'wdaLocalPort',
277
- required: false,
278
- type: 'int',
279
- example: '8100',
280
- help: '(IOS-only, XCUITest-only) Local port used for communication with WebDriverAgent'
281
- }],
282
-
283
- [['-dc', '--default-capabilities'], {
284
- dest: 'defaultCapabilities',
285
- defaultValue: {},
286
- type: parseDefaultCaps,
287
- required: false,
288
- example: '[ \'{"app": "myapp.app", "deviceName": "iPhone Simulator"}\' ' +
289
- '| /path/to/caps.json ]',
290
- help: 'Set the default desired capabilities, which will be set on each ' +
291
- 'session unless overridden by received capabilities.'
292
- }],
293
15
 
294
- [['--relaxed-security'], {
295
- defaultValue: false,
296
- dest: 'relaxedSecurityEnabled',
297
- action: 'storeTrue',
298
- required: false,
299
- help: 'Disable additional security checks, so it is possible to use some advanced features, provided ' +
300
- 'by drivers supporting this option. Only enable it if all the ' +
301
- 'clients are in the trusted network and it\'s not the case if a client could potentially ' +
302
- 'break out of the session sandbox. Specific features can be overridden by ' +
303
- 'using the --deny-insecure flag',
304
- nargs: 0
305
- }],
16
+ /**
17
+ * This is necessary because we pass the array into `argparse`. `argparse` is bad and mutates things. We don't want that.
18
+ * Bad `argparse`! Bad!
19
+ */
20
+ const INSTALL_TYPES_ARRAY = [...INSTALL_TYPES];
306
21
 
307
- [['--allow-insecure'], {
308
- dest: 'allowInsecure',
309
- defaultValue: [],
310
- type: parseSecurityFeatures,
311
- required: false,
312
- example: 'execute_driver_script,adb_shell',
313
- help: 'Set which insecure features are allowed to run in this server\'s sessions. ' +
314
- 'Features are defined on a driver level; see documentation for more details. ' +
315
- 'This should be either a comma-separated list of feature names, or a path to ' +
316
- 'a file where each feature name is on a line. Note that features defined via ' +
317
- '--deny-insecure will be disabled, even if also listed here.',
318
- }],
319
-
320
- [['--deny-insecure'], {
321
- dest: 'denyInsecure',
322
- defaultValue: [],
323
- type: parseSecurityFeatures,
324
- required: false,
325
- example: 'execute_driver_script,adb_shell',
326
- help: 'Set which insecure features are not allowed to run in this server\'s sessions. ' +
327
- 'Features are defined on a driver level; see documentation for more details. ' +
328
- 'This should be either a comma-separated list of feature names, or a path to ' +
329
- 'a file where each feature name is on a line. Features listed here will not be ' +
330
- 'enabled even if also listed in --allow-insecure, and even if --relaxed-security ' +
331
- 'is turned on.',
332
- }],
333
- ];
22
+ /** @type {Set<ExtensionType>} */
23
+ const EXTENSION_TYPES = new Set([DRIVER_TYPE, PLUGIN_TYPE]);
334
24
 
335
25
  // this set of args works for both drivers and plugins ('extensions')
336
- const globalExtensionArgs = [
337
- [['--json'], {
338
- required: false,
339
- defaultValue: false,
340
- action: 'storeTrue',
341
- help: 'Use JSON for output format',
342
- nargs: 0,
343
- dest: 'json'
344
- }]
345
- ];
346
-
347
- const extensionArgs = {[DRIVER_TYPE]: {}, [PLUGIN_TYPE]: {}};
348
-
349
- function makeListArgs (type) {
350
- return [
351
- ...globalExtensionArgs,
352
- [['--installed'], {
353
- required: false,
354
- defaultValue: false,
355
- action: 'storeTrue',
356
- help: `List only installed ${type}s`,
357
- nargs: 0,
358
- dest: 'showInstalled'
359
- }],
360
- [['--updates'], {
26
+ /** @type {ArgumentDefinitions} */
27
+ const globalExtensionArgs = new Map([
28
+ [
29
+ ['--json'],
30
+ {
361
31
  required: false,
362
- defaultValue: false,
363
- action: 'storeTrue',
364
- help: 'Show information about newer versions',
365
- nargs: 0,
366
- dest: 'showUpdates'
367
- }]
368
- ];
32
+ default: false,
33
+ action: 'store_true',
34
+ help: 'Use JSON for output format',
35
+ dest: 'json',
36
+ },
37
+ ],
38
+ ]);
39
+
40
+ /**
41
+ * Builds a Record of extension types to a Record of subcommands to their argument definitions
42
+ */
43
+ const getExtensionArgs = _.memoize(function getExtensionArgs() {
44
+ const extensionArgs = {};
45
+ for (const type of EXTENSION_TYPES) {
46
+ extensionArgs[type] = {
47
+ [EXT_SUBCOMMAND_LIST]: makeListArgs(type),
48
+ [EXT_SUBCOMMAND_INSTALL]: makeInstallArgs(type),
49
+ [EXT_SUBCOMMAND_UNINSTALL]: makeUninstallArgs(type),
50
+ [EXT_SUBCOMMAND_UPDATE]: makeUpdateArgs(type),
51
+ [EXT_SUBCOMMAND_RUN]: makeRunArgs(type),
52
+ };
53
+ }
54
+ return /** @type {Record<ExtensionType, Record<import('appium/types').CliExtensionSubcommand,ArgumentDefinitions>>} */ (
55
+ extensionArgs
56
+ );
57
+ });
58
+
59
+ /**
60
+ * Makes the opts for the `list` subcommand for each extension type.
61
+ * @param {ExtensionType} type
62
+ * @returns {ArgumentDefinitions}
63
+ */
64
+ function makeListArgs(type) {
65
+ return new Map([
66
+ ...globalExtensionArgs,
67
+ [
68
+ ['--installed'],
69
+ {
70
+ required: false,
71
+ default: false,
72
+ action: 'store_true',
73
+ help: `List only installed ${type}s`,
74
+ dest: 'showInstalled',
75
+ },
76
+ ],
77
+ [
78
+ ['--updates'],
79
+ {
80
+ required: false,
81
+ default: false,
82
+ action: 'store_true',
83
+ help: 'Show information about newer versions',
84
+ dest: 'showUpdates',
85
+ },
86
+ ],
87
+ ]);
369
88
  }
370
89
 
90
+ /**
91
+ * Makes the opts for the `install` subcommand for each extension type
92
+ * @param {ExtensionType} type
93
+ * @returns {ArgumentDefinitions}
94
+ */
95
+ function makeInstallArgs(type) {
96
+ return new Map([
97
+ ...globalExtensionArgs,
98
+ [
99
+ [type],
100
+ {
101
+ type: 'str',
102
+ help:
103
+ `Name of the ${type} to install, for example: ` + type === DRIVER_TYPE
104
+ ? DRIVER_EXAMPLE
105
+ : PLUGIN_EXAMPLE,
106
+ },
107
+ ],
108
+ [
109
+ ['--source'],
110
+ {
111
+ required: false,
112
+ default: null,
113
+ choices: INSTALL_TYPES_ARRAY,
114
+ help:
115
+ `Where to look for the ${type} if it is not one of Appium's verified ` +
116
+ `${type}s. Possible values: ${INSTALL_TYPES_ARRAY.join(', ')}`,
117
+ dest: 'installType',
118
+ },
119
+ ],
120
+ [
121
+ ['--package'],
122
+ {
123
+ required: false,
124
+ default: null,
125
+ type: 'str',
126
+ help:
127
+ `If installing from Git or GitHub, the package name, as defined in the plugin's ` +
128
+ `package.json file in the "name" field, cannot be determined automatically, and ` +
129
+ `should be reported here, otherwise the install will probably fail.`,
130
+ dest: 'packageName',
131
+ },
132
+ ],
133
+ ]);
134
+ }
371
135
 
372
- function makeInstallArgs (type) {
373
- return [
136
+ /**
137
+ * Makes the opts for the `uninstall` subcommand for each extension type
138
+ * @param {ExtensionType} type
139
+ * @returns {ArgumentDefinitions}
140
+ */
141
+ function makeUninstallArgs(type) {
142
+ return new Map([
374
143
  ...globalExtensionArgs,
375
- [[type], {
376
- type: 'string',
377
- example: type === DRIVER_TYPE ? DRIVER_EXAMPLE : PLUGIN_EXAMPLE,
378
- help: `Name of the ${type} to install`,
379
- }],
380
- [['--source'], {
381
- required: false,
382
- defaultValue: null,
383
- type: parseInstallTypes,
384
- help: `Where to look for the ${type} if it is not one of Appium's verified ` +
385
- `${type}s. Possible values: ${JSON.stringify(INSTALL_TYPES)}`,
386
- dest: 'installType'
387
- }],
388
- [['--package'], {
389
- required: false,
390
- defaultValue: null,
391
- type: 'string',
392
- help: `If installing from Git or GitHub, the package name, as defined in the plugin's ` +
393
- `package.json file in the "name" field, cannot be determined automatically, and ` +
394
- `should be reported here, otherwise the install will probably fail.`,
395
- dest: 'packageName',
396
- }],
397
- ];
144
+ [
145
+ [type],
146
+ {
147
+ type: 'str',
148
+ help:
149
+ 'Name of the driver to uninstall, for example: ' + type === DRIVER_TYPE
150
+ ? DRIVER_EXAMPLE
151
+ : PLUGIN_EXAMPLE,
152
+ },
153
+ ],
154
+ ]);
398
155
  }
399
156
 
400
- function makeUninstallArgs (type) {
401
- return [
157
+ /**
158
+ * Makes the opts for the `update` subcommand for each extension type
159
+ * @param {ExtensionType} type
160
+ * @returns {ArgumentDefinitions}
161
+ */
162
+ function makeUpdateArgs(type) {
163
+ return new Map([
402
164
  ...globalExtensionArgs,
403
- [[type], {
404
- type: 'string',
405
- example: type === DRIVER_TYPE ? DRIVER_EXAMPLE : PLUGIN_EXAMPLE,
406
- help: 'Name of the driver to uninstall',
407
- }],
408
- ];
165
+ [
166
+ [type],
167
+ {
168
+ type: 'str',
169
+ help:
170
+ `Name of the ${type} to update, or the word "installed" to update all installed ` +
171
+ `${type}s. To see available updates, run "appium ${type} list --installed --updates". ` +
172
+ 'For example: ' +
173
+ type ===
174
+ DRIVER_TYPE
175
+ ? DRIVER_EXAMPLE
176
+ : PLUGIN_EXAMPLE,
177
+ },
178
+ ],
179
+ [
180
+ ['--unsafe'],
181
+ {
182
+ required: false,
183
+ default: false,
184
+ action: 'store_true',
185
+ help:
186
+ `Include updates that might have a new major revision, and potentially include ` +
187
+ `breaking changes`,
188
+ },
189
+ ],
190
+ ]);
409
191
  }
410
192
 
411
- function makeUpdateArgs (type) {
412
- return [
193
+ /**
194
+ * Makes the opts for the `run` subcommand for each extension type
195
+ * @param {ExtensionType} type
196
+ * @returns {ArgumentDefinitions}
197
+ */
198
+ function makeRunArgs(type) {
199
+ return new Map([
413
200
  ...globalExtensionArgs,
414
- [[type], {
415
- type: 'string',
416
- example: type === DRIVER_TYPE ? DRIVER_EXAMPLE : PLUGIN_EXAMPLE,
417
- help: `Name of the ${type} to update, or the word "installed" to update all installed ` +
418
- `${type}s. To see available updates, run "appium ${type} list --installed --updates"`,
419
- }],
420
- [['--unsafe'], {
421
- required: false,
422
- defaultValue: false,
423
- action: 'storeTrue',
424
- nargs: 0,
425
- help: `Include updates that might have a new major revision, and potentially include ` +
426
- `breaking changes`,
427
- }],
428
- ];
201
+ [
202
+ [type],
203
+ {
204
+ type: 'str',
205
+ help:
206
+ `Name of the ${type} to run a script from, for example: ` + type === DRIVER_TYPE
207
+ ? DRIVER_EXAMPLE
208
+ : PLUGIN_EXAMPLE,
209
+ },
210
+ ],
211
+ [
212
+ ['scriptName'],
213
+ {
214
+ default: null,
215
+ type: 'str',
216
+ help:
217
+ `Name of the script to run from the ${type}. The script name must be a key ` +
218
+ `inside the "appium.scripts" field inside the ${type}'s "package.json" file`,
219
+ },
220
+ ],
221
+ ]);
429
222
  }
430
223
 
431
- for (const type of [DRIVER_TYPE, PLUGIN_TYPE]) {
432
- extensionArgs[type].list = makeListArgs(type);
433
- extensionArgs[type].install = makeInstallArgs(type);
434
- extensionArgs[type].uninstall = makeUninstallArgs(type);
435
- extensionArgs[type].update = makeUpdateArgs(type);
224
+ /**
225
+ * Derives the options for the `server` command from the schema, and adds the arguments
226
+ * which are disallowed in the config file.
227
+ * @returns {ArgumentDefinitions}
228
+ */
229
+ function getServerArgs() {
230
+ return new Map([...toParserArgs(), ...serverArgsDisallowedInConfig]);
436
231
  }
437
232
 
438
- export {
439
- sharedArgs,
440
- serverArgs,
441
- extensionArgs,
442
- USE_ALL_PLUGINS,
443
- };
233
+ /**
234
+ * These don't make sense in the context of a config file for obvious reasons.
235
+ * @type {ArgumentDefinitions}
236
+ */
237
+ const serverArgsDisallowedInConfig = new Map([
238
+ [
239
+ ['--shell'],
240
+ {
241
+ required: false,
242
+ help: 'Enter REPL mode',
243
+ action: 'store_const',
244
+ const: true,
245
+ dest: 'shell',
246
+ },
247
+ ],
248
+ [
249
+ ['--show-build-info'],
250
+ {
251
+ dest: 'showBuildInfo',
252
+ action: 'store_const',
253
+ const: true,
254
+ required: false,
255
+ help: 'Show info about the Appium build and exit',
256
+ },
257
+ ],
258
+ [
259
+ ['--show-config'],
260
+ {
261
+ dest: 'showConfig',
262
+ action: 'store_const',
263
+ const: true,
264
+ required: false,
265
+ help: 'Show the current Appium configuration and exit',
266
+ },
267
+ ],
268
+ [
269
+ ['--config'],
270
+ {
271
+ dest: 'configFile',
272
+ type: 'string',
273
+ required: false,
274
+ help: 'Explicit path to Appium configuration file',
275
+ },
276
+ ],
277
+ ]);
278
+
279
+ export {getServerArgs, getExtensionArgs};
280
+
281
+ /**
282
+ * @typedef {import('@appium/types').ExtensionType} ExtensionType
283
+ */
284
+
285
+ /**
286
+ * A tuple of argument aliases and argument options
287
+ * @typedef {Map<string[],import('argparse').ArgumentOptions>} ArgumentDefinitions
288
+ */