appium 2.0.0-beta.2 → 2.0.0-beta.23
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/README.md +9 -9
- package/build/check-npm-pack-files.js +23 -0
- package/build/commands-yml/parse.js +319 -0
- package/build/commands-yml/validator.js +130 -0
- package/build/index.js +19 -0
- package/build/lib/appium-config.schema.json +0 -0
- package/build/lib/appium.js +160 -53
- package/build/lib/cli/args.js +115 -279
- package/build/lib/cli/driver-command.js +11 -1
- package/build/lib/cli/extension-command.js +60 -8
- package/build/lib/cli/extension.js +30 -7
- package/build/lib/cli/npm.js +43 -29
- package/build/lib/cli/parser.js +156 -89
- package/build/lib/cli/plugin-command.js +11 -1
- package/build/lib/cli/utils.js +29 -3
- package/build/lib/config-file.js +141 -0
- package/build/lib/config.js +53 -65
- package/build/lib/driver-config.js +42 -19
- package/build/lib/drivers.js +8 -4
- package/build/lib/ext-config-io.js +165 -0
- package/build/lib/extension-config.js +130 -61
- package/build/lib/grid-register.js +22 -24
- package/build/lib/logger.js +3 -3
- package/build/lib/logsink.js +11 -13
- package/build/lib/main.js +197 -77
- package/build/lib/plugin-config.js +21 -11
- package/build/lib/plugins.js +4 -2
- package/build/lib/schema/appium-config-schema.js +253 -0
- package/build/lib/schema/arg-spec.js +120 -0
- package/build/lib/schema/cli-args.js +188 -0
- package/build/lib/schema/cli-transformers.js +76 -0
- package/build/lib/schema/index.js +36 -0
- package/build/lib/schema/keywords.js +72 -0
- package/build/lib/schema/schema.js +357 -0
- package/build/lib/utils.js +44 -99
- package/build/postinstall.js +90 -0
- package/build/test/cli/cli-e2e-specs.js +221 -0
- package/build/test/cli/cli-helpers.js +86 -0
- package/build/test/cli/cli-specs.js +71 -0
- package/build/test/cli/fixtures/test-driver/package.json +27 -0
- package/build/test/cli/schema-args-specs.js +48 -0
- package/build/test/cli/schema-e2e-specs.js +47 -0
- package/build/test/config-e2e-specs.js +112 -0
- package/build/test/config-file-e2e-specs.js +209 -0
- package/build/test/config-file-specs.js +281 -0
- package/build/test/config-specs.js +159 -0
- package/build/test/driver-e2e-specs.js +435 -0
- package/build/test/driver-specs.js +321 -0
- package/build/test/ext-config-io-specs.js +181 -0
- package/build/test/extension-config-specs.js +365 -0
- package/build/test/fixtures/allow-feat.txt +5 -0
- package/build/test/fixtures/caps.json +3 -0
- package/build/test/fixtures/config/allow-insecure.txt +3 -0
- package/build/test/fixtures/config/appium.config.bad-nodeconfig.json +5 -0
- package/build/test/fixtures/config/appium.config.bad.json +32 -0
- package/build/test/fixtures/config/appium.config.ext-good.json +9 -0
- package/build/test/fixtures/config/appium.config.ext-unknown-props.json +10 -0
- package/build/test/fixtures/config/appium.config.good.js +40 -0
- package/build/test/fixtures/config/appium.config.good.json +33 -0
- package/build/test/fixtures/config/appium.config.good.yaml +30 -0
- package/build/test/fixtures/config/appium.config.invalid.json +31 -0
- package/build/test/fixtures/config/appium.config.security-array.json +5 -0
- package/build/test/fixtures/config/appium.config.security-delimited.json +5 -0
- package/build/test/fixtures/config/appium.config.security-path.json +5 -0
- package/build/test/fixtures/config/driver-fake.config.json +8 -0
- package/build/test/fixtures/config/nodeconfig.json +3 -0
- package/build/test/fixtures/config/plugin-fake.config.json +0 -0
- package/build/test/fixtures/default-args.js +35 -0
- package/build/test/fixtures/deny-feat.txt +5 -0
- package/build/test/fixtures/driver.schema.js +20 -0
- package/build/test/fixtures/extensions.yaml +27 -0
- package/build/test/fixtures/flattened-schema.js +504 -0
- package/build/test/fixtures/plugin.schema.js +20 -0
- package/build/test/fixtures/schema-with-extensions.js +28 -0
- package/build/test/grid-register-specs.js +74 -0
- package/build/test/helpers.js +75 -0
- package/build/test/logger-specs.js +76 -0
- package/build/test/npm-specs.js +20 -0
- package/build/test/parser-specs.js +314 -0
- package/build/test/plugin-e2e-specs.js +316 -0
- package/build/test/schema/arg-spec-specs.js +70 -0
- package/build/test/schema/cli-args-specs.js +431 -0
- package/build/test/schema/schema-specs.js +389 -0
- package/build/test/utils-specs.js +266 -0
- package/index.js +11 -0
- package/lib/appium-config.schema.json +278 -0
- package/lib/appium.js +207 -65
- package/lib/cli/args.js +174 -375
- package/lib/cli/driver-command.js +4 -0
- package/lib/cli/extension-command.js +70 -5
- package/lib/cli/extension.js +25 -5
- package/lib/cli/npm.js +86 -18
- package/lib/cli/parser.js +257 -79
- package/lib/cli/plugin-command.js +4 -0
- package/lib/cli/utils.js +21 -1
- package/lib/config-file.js +227 -0
- package/lib/config.js +84 -63
- package/lib/driver-config.js +66 -11
- package/lib/drivers.js +4 -1
- package/lib/ext-config-io.js +287 -0
- package/lib/extension-config.js +225 -67
- package/lib/grid-register.js +27 -24
- package/lib/logger.js +1 -1
- package/lib/logsink.js +10 -7
- package/lib/main.js +214 -77
- package/lib/plugin-config.js +35 -6
- package/lib/plugins.js +1 -0
- package/lib/schema/appium-config-schema.js +287 -0
- package/lib/schema/arg-spec.js +222 -0
- package/lib/schema/cli-args.js +285 -0
- package/lib/schema/cli-transformers.js +123 -0
- package/lib/schema/index.js +2 -0
- package/lib/schema/keywords.js +135 -0
- package/lib/schema/schema.js +577 -0
- package/lib/utils.js +42 -88
- package/package.json +55 -84
- package/postinstall.js +71 -0
- package/types/appium-config.d.ts +197 -0
- package/types/types.d.ts +201 -0
- package/CHANGELOG.md +0 -3515
- package/build/lib/cli/parser-helpers.js +0 -82
- package/lib/cli/parser-helpers.js +0 -79
package/lib/cli/args.js
CHANGED
|
@@ -1,443 +1,242 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
// @ts-check
|
|
2
|
+
|
|
3
|
+
// @ts-ignore
|
|
4
|
+
import { DEFAULT_BASE_PATH } from '@appium/base-driver';
|
|
5
|
+
import _ from 'lodash';
|
|
6
|
+
import DriverConfig from '../driver-config';
|
|
7
|
+
import { APPIUM_HOME, DRIVER_TYPE, INSTALL_TYPES, PLUGIN_TYPE } from '../extension-config';
|
|
8
|
+
import PluginConfig from '../plugin-config';
|
|
9
|
+
import { toParserArgs } from '../schema/cli-args';
|
|
4
10
|
|
|
5
11
|
const DRIVER_EXAMPLE = 'xcuitest';
|
|
6
12
|
const PLUGIN_EXAMPLE = 'find_by_image';
|
|
7
13
|
const USE_ALL_PLUGINS = 'all';
|
|
8
14
|
|
|
9
|
-
|
|
10
|
-
const
|
|
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
|
-
}],
|
|
15
|
+
/** @type {Set<ExtensionType>} */
|
|
16
|
+
const EXTENSION_TYPES = new Set([DRIVER_TYPE, PLUGIN_TYPE]);
|
|
247
17
|
|
|
248
|
-
|
|
249
|
-
|
|
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
|
-
|
|
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
|
-
}],
|
|
306
|
-
|
|
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
|
-
];
|
|
18
|
+
const driverConfig = DriverConfig.getInstance(APPIUM_HOME);
|
|
19
|
+
const pluginConfig = PluginConfig.getInstance(APPIUM_HOME);
|
|
334
20
|
|
|
335
21
|
// this set of args works for both drivers and plugins ('extensions')
|
|
336
|
-
|
|
22
|
+
/** @type {ArgumentDefinitions} */
|
|
23
|
+
const globalExtensionArgs = new Map([
|
|
337
24
|
[['--json'], {
|
|
338
25
|
required: false,
|
|
339
|
-
|
|
340
|
-
action: '
|
|
26
|
+
default: false,
|
|
27
|
+
action: 'store_true',
|
|
341
28
|
help: 'Use JSON for output format',
|
|
342
|
-
nargs: 0,
|
|
343
29
|
dest: 'json'
|
|
344
30
|
}]
|
|
345
|
-
];
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
31
|
+
]);
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Builds a Record of extension types to a Record of subcommands to their argument definitions
|
|
35
|
+
*/
|
|
36
|
+
const getExtensionArgs = _.once(function getExtensionArgs () {
|
|
37
|
+
const extensionArgs = {};
|
|
38
|
+
for (const type of EXTENSION_TYPES) {
|
|
39
|
+
extensionArgs[type] = {
|
|
40
|
+
list: makeListArgs(type),
|
|
41
|
+
install: makeInstallArgs(type),
|
|
42
|
+
uninstall: makeUninstallArgs(type),
|
|
43
|
+
update: makeUpdateArgs(type),
|
|
44
|
+
run: makeRunArgs(type),
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
return /** @type {Record<ExtensionType, Record<string,ArgumentDefinitions[]>>} */ (extensionArgs);
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Makes the opts for the `list` subcommand for each extension type.
|
|
52
|
+
* @param {ExtensionType} type
|
|
53
|
+
* @returns {ArgumentDefinitions}
|
|
54
|
+
*/
|
|
349
55
|
function makeListArgs (type) {
|
|
350
|
-
return [
|
|
56
|
+
return new Map([
|
|
351
57
|
...globalExtensionArgs,
|
|
352
58
|
[['--installed'], {
|
|
353
59
|
required: false,
|
|
354
|
-
|
|
355
|
-
action: '
|
|
60
|
+
default: false,
|
|
61
|
+
action: 'store_true',
|
|
356
62
|
help: `List only installed ${type}s`,
|
|
357
|
-
nargs: 0,
|
|
358
63
|
dest: 'showInstalled'
|
|
359
64
|
}],
|
|
360
65
|
[['--updates'], {
|
|
361
66
|
required: false,
|
|
362
|
-
|
|
363
|
-
action: '
|
|
67
|
+
default: false,
|
|
68
|
+
action: 'store_true',
|
|
364
69
|
help: 'Show information about newer versions',
|
|
365
|
-
nargs: 0,
|
|
366
70
|
dest: 'showUpdates'
|
|
367
71
|
}]
|
|
368
|
-
];
|
|
72
|
+
]);
|
|
369
73
|
}
|
|
370
74
|
|
|
371
|
-
|
|
75
|
+
/**
|
|
76
|
+
* Makes the opts for the `install` subcommand for each extension type
|
|
77
|
+
* @param {ExtensionType} type
|
|
78
|
+
* @returns {ArgumentDefinitions}
|
|
79
|
+
*/
|
|
372
80
|
function makeInstallArgs (type) {
|
|
373
|
-
return [
|
|
81
|
+
return new Map([
|
|
374
82
|
...globalExtensionArgs,
|
|
375
83
|
[[type], {
|
|
376
|
-
type: '
|
|
377
|
-
|
|
378
|
-
|
|
84
|
+
type: 'str',
|
|
85
|
+
help: `Name of the ${type} to install, for example: ` +
|
|
86
|
+
type === DRIVER_TYPE ? DRIVER_EXAMPLE : PLUGIN_EXAMPLE,
|
|
379
87
|
}],
|
|
380
88
|
[['--source'], {
|
|
381
89
|
required: false,
|
|
382
|
-
|
|
383
|
-
|
|
90
|
+
default: null,
|
|
91
|
+
choices: INSTALL_TYPES,
|
|
384
92
|
help: `Where to look for the ${type} if it is not one of Appium's verified ` +
|
|
385
|
-
`${type}s. Possible values: ${
|
|
93
|
+
`${type}s. Possible values: ${INSTALL_TYPES.join(', ')}`,
|
|
386
94
|
dest: 'installType'
|
|
387
95
|
}],
|
|
388
96
|
[['--package'], {
|
|
389
97
|
required: false,
|
|
390
|
-
|
|
391
|
-
type: '
|
|
98
|
+
default: null,
|
|
99
|
+
type: 'str',
|
|
392
100
|
help: `If installing from Git or GitHub, the package name, as defined in the plugin's ` +
|
|
393
101
|
`package.json file in the "name" field, cannot be determined automatically, and ` +
|
|
394
102
|
`should be reported here, otherwise the install will probably fail.`,
|
|
395
103
|
dest: 'packageName',
|
|
396
104
|
}],
|
|
397
|
-
];
|
|
105
|
+
]);
|
|
398
106
|
}
|
|
399
107
|
|
|
108
|
+
|
|
109
|
+
/**
|
|
110
|
+
* Makes the opts for the `uninstall` subcommand for each extension type
|
|
111
|
+
* @param {ExtensionType} type
|
|
112
|
+
* @returns {ArgumentDefinitions}
|
|
113
|
+
*/
|
|
400
114
|
function makeUninstallArgs (type) {
|
|
401
|
-
return [
|
|
115
|
+
return new Map([
|
|
402
116
|
...globalExtensionArgs,
|
|
403
117
|
[[type], {
|
|
404
|
-
type: '
|
|
405
|
-
|
|
406
|
-
|
|
118
|
+
type: 'str',
|
|
119
|
+
help: 'Name of the driver to uninstall, for example: ' +
|
|
120
|
+
type === DRIVER_TYPE ? DRIVER_EXAMPLE : PLUGIN_EXAMPLE
|
|
407
121
|
}],
|
|
408
|
-
];
|
|
122
|
+
]);
|
|
409
123
|
}
|
|
410
124
|
|
|
125
|
+
/**
|
|
126
|
+
* Makes the opts for the `update` subcommand for each extension type
|
|
127
|
+
* @param {ExtensionType} type
|
|
128
|
+
* @returns {ArgumentDefinitions}
|
|
129
|
+
*/
|
|
411
130
|
function makeUpdateArgs (type) {
|
|
412
|
-
return [
|
|
131
|
+
return new Map([
|
|
413
132
|
...globalExtensionArgs,
|
|
414
133
|
[[type], {
|
|
415
|
-
type: '
|
|
416
|
-
example: type === DRIVER_TYPE ? DRIVER_EXAMPLE : PLUGIN_EXAMPLE,
|
|
134
|
+
type: 'str',
|
|
417
135
|
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"
|
|
136
|
+
`${type}s. To see available updates, run "appium ${type} list --installed --updates". ` +
|
|
137
|
+
'For example: ' + type === DRIVER_TYPE ? DRIVER_EXAMPLE : PLUGIN_EXAMPLE,
|
|
419
138
|
}],
|
|
420
139
|
[['--unsafe'], {
|
|
421
140
|
required: false,
|
|
422
|
-
|
|
423
|
-
action: '
|
|
424
|
-
nargs: 0,
|
|
141
|
+
default: false,
|
|
142
|
+
action: 'store_true',
|
|
425
143
|
help: `Include updates that might have a new major revision, and potentially include ` +
|
|
426
144
|
`breaking changes`,
|
|
427
145
|
}],
|
|
428
|
-
];
|
|
146
|
+
]);
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
/**
|
|
150
|
+
* Makes the opts for the `run` subcommand for each extension type
|
|
151
|
+
* @param {ExtensionType} type
|
|
152
|
+
* @returns {ArgumentDefinitions}
|
|
153
|
+
*/
|
|
154
|
+
function makeRunArgs (type) {
|
|
155
|
+
return new Map([
|
|
156
|
+
...globalExtensionArgs,
|
|
157
|
+
[[type], {
|
|
158
|
+
type: 'str',
|
|
159
|
+
help: `Name of the ${type} to run a script from, for example: ` +
|
|
160
|
+
type === DRIVER_TYPE ? DRIVER_EXAMPLE : PLUGIN_EXAMPLE,
|
|
161
|
+
}],
|
|
162
|
+
[['scriptName'], {
|
|
163
|
+
default: null,
|
|
164
|
+
type: 'str',
|
|
165
|
+
help: `Name of the script to run from the ${type}. The script name must be cached ` +
|
|
166
|
+
`inside the "scripts" field under "appium" inside the ${type}'s "package.json" file`
|
|
167
|
+
}],
|
|
168
|
+
]);
|
|
429
169
|
}
|
|
430
170
|
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
171
|
+
/**
|
|
172
|
+
* Derives the options for the `server` command from the schema, and adds the arguments
|
|
173
|
+
* which are disallowed in the config file.
|
|
174
|
+
* @returns {ArgumentDefinitions}
|
|
175
|
+
*/
|
|
176
|
+
function getServerArgs () {
|
|
177
|
+
return new Map([
|
|
178
|
+
...toParserArgs({
|
|
179
|
+
overrides: {
|
|
180
|
+
basePath: {
|
|
181
|
+
default: DEFAULT_BASE_PATH
|
|
182
|
+
},
|
|
183
|
+
}
|
|
184
|
+
}),
|
|
185
|
+
...serverArgsDisallowedInConfig,
|
|
186
|
+
]);
|
|
436
187
|
}
|
|
437
188
|
|
|
189
|
+
/**
|
|
190
|
+
* These don't make sense in the context of a config file for obvious reasons.
|
|
191
|
+
* @type {ArgumentDefinitions}
|
|
192
|
+
*/
|
|
193
|
+
const serverArgsDisallowedInConfig = new Map([
|
|
194
|
+
[
|
|
195
|
+
['--shell'],
|
|
196
|
+
{
|
|
197
|
+
required: false,
|
|
198
|
+
default: null,
|
|
199
|
+
help: 'Enter REPL mode',
|
|
200
|
+
action: 'store_true',
|
|
201
|
+
dest: 'shell',
|
|
202
|
+
},
|
|
203
|
+
],
|
|
204
|
+
[
|
|
205
|
+
['--show-config'],
|
|
206
|
+
{
|
|
207
|
+
default: false,
|
|
208
|
+
dest: 'showConfig',
|
|
209
|
+
action: 'store_true',
|
|
210
|
+
required: false,
|
|
211
|
+
help: 'Show info about the appium server configuration and exit',
|
|
212
|
+
},
|
|
213
|
+
],
|
|
214
|
+
[
|
|
215
|
+
['--config'],
|
|
216
|
+
{
|
|
217
|
+
dest: 'configFile',
|
|
218
|
+
type: 'string',
|
|
219
|
+
required: false,
|
|
220
|
+
help: 'Explicit path to Appium configuration file',
|
|
221
|
+
},
|
|
222
|
+
],
|
|
223
|
+
]);
|
|
224
|
+
|
|
438
225
|
export {
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
extensionArgs,
|
|
226
|
+
getServerArgs,
|
|
227
|
+
getExtensionArgs,
|
|
442
228
|
USE_ALL_PLUGINS,
|
|
229
|
+
driverConfig,
|
|
230
|
+
pluginConfig,
|
|
231
|
+
APPIUM_HOME
|
|
443
232
|
};
|
|
233
|
+
|
|
234
|
+
/**
|
|
235
|
+
* Alias
|
|
236
|
+
* @typedef {import('../ext-config-io').ExtensionType} ExtensionType
|
|
237
|
+
*/
|
|
238
|
+
|
|
239
|
+
/**
|
|
240
|
+
* A tuple of argument aliases and argument options
|
|
241
|
+
* @typedef {Map<string[],import('argparse').ArgumentOptions>} ArgumentDefinitions
|
|
242
|
+
*/
|
|
@@ -24,6 +24,10 @@ export default class DriverCommand extends ExtensionCommand {
|
|
|
24
24
|
return await super.update({ext: driver, unsafe});
|
|
25
25
|
}
|
|
26
26
|
|
|
27
|
+
async run ({driver, scriptName}) {
|
|
28
|
+
return await super.run({ext: driver, scriptName});
|
|
29
|
+
}
|
|
30
|
+
|
|
27
31
|
getPostInstallText ({extName, extData}) {
|
|
28
32
|
return `Driver ${extName}@${extData.version} successfully installed\n`.green +
|
|
29
33
|
`- automationName: ${extData.automationName.green}\n` +
|