appium 3.2.2 → 3.3.0
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/build/lib/cli/args.d.ts +16 -12
- package/build/lib/cli/args.d.ts.map +1 -1
- package/build/lib/cli/args.js +15 -35
- package/build/lib/cli/args.js.map +1 -1
- package/build/lib/cli/driver-command.d.ts +51 -93
- package/build/lib/cli/driver-command.d.ts.map +1 -1
- package/build/lib/cli/driver-command.js +11 -66
- package/build/lib/cli/driver-command.js.map +1 -1
- package/build/lib/cli/extension-command.d.ts +211 -415
- package/build/lib/cli/extension-command.d.ts.map +1 -1
- package/build/lib/cli/extension-command.js +384 -653
- package/build/lib/cli/extension-command.js.map +1 -1
- package/build/lib/cli/extension.d.ts +11 -16
- package/build/lib/cli/extension.d.ts.map +1 -1
- package/build/lib/cli/extension.js +10 -28
- package/build/lib/cli/extension.js.map +1 -1
- package/build/lib/cli/parser.d.ts +40 -69
- package/build/lib/cli/parser.d.ts.map +1 -1
- package/build/lib/cli/parser.js +24 -59
- package/build/lib/cli/parser.js.map +1 -1
- package/build/lib/cli/plugin-command.d.ts +50 -90
- package/build/lib/cli/plugin-command.d.ts.map +1 -1
- package/build/lib/cli/plugin-command.js +11 -63
- package/build/lib/cli/plugin-command.js.map +1 -1
- package/build/lib/cli/setup-command.d.ts +21 -26
- package/build/lib/cli/setup-command.d.ts.map +1 -1
- package/build/lib/cli/setup-command.js +13 -55
- package/build/lib/cli/setup-command.js.map +1 -1
- package/build/lib/cli/utils.d.ts +27 -29
- package/build/lib/cli/utils.d.ts.map +1 -1
- package/build/lib/cli/utils.js +29 -31
- package/build/lib/cli/utils.js.map +1 -1
- package/build/lib/config-file.d.ts +24 -67
- package/build/lib/config-file.d.ts.map +1 -1
- package/build/lib/config-file.js +56 -115
- package/build/lib/config-file.js.map +1 -1
- package/build/lib/config.d.ts +42 -44
- package/build/lib/config.d.ts.map +1 -1
- package/build/lib/config.js +75 -107
- package/build/lib/config.js.map +1 -1
- package/build/lib/constants.d.ts +23 -23
- package/build/lib/constants.d.ts.map +1 -1
- package/build/lib/constants.js +10 -15
- package/build/lib/constants.js.map +1 -1
- package/build/lib/doctor/doctor.d.ts +40 -57
- package/build/lib/doctor/doctor.d.ts.map +1 -1
- package/build/lib/doctor/doctor.js +29 -60
- package/build/lib/doctor/doctor.js.map +1 -1
- package/build/lib/grid-register.d.ts +32 -7
- package/build/lib/grid-register.d.ts.map +1 -1
- package/build/lib/grid-register.js +84 -48
- package/build/lib/grid-register.js.map +1 -1
- package/build/lib/logsink.d.ts +13 -22
- package/build/lib/logsink.d.ts.map +1 -1
- package/build/lib/logsink.js +48 -103
- package/build/lib/logsink.js.map +1 -1
- package/build/lib/main.js +1 -1
- package/build/lib/main.js.map +1 -1
- package/build/lib/schema/arg-spec.d.ts +32 -107
- package/build/lib/schema/arg-spec.d.ts.map +1 -1
- package/build/lib/schema/arg-spec.js +11 -107
- package/build/lib/schema/arg-spec.js.map +1 -1
- package/build/lib/schema/cli-args.d.ts +3 -15
- package/build/lib/schema/cli-args.d.ts.map +1 -1
- package/build/lib/schema/cli-args.js +15 -105
- package/build/lib/schema/cli-args.js.map +1 -1
- package/build/lib/schema/cli-transformers.d.ts +15 -12
- package/build/lib/schema/cli-transformers.d.ts.map +1 -1
- package/build/lib/schema/cli-transformers.js +15 -45
- package/build/lib/schema/cli-transformers.js.map +1 -1
- package/build/lib/schema/index.d.ts +2 -2
- package/build/lib/schema/index.d.ts.map +1 -1
- package/build/lib/schema/index.js.map +1 -1
- package/build/lib/schema/keywords.d.ts +12 -20
- package/build/lib/schema/keywords.d.ts.map +1 -1
- package/build/lib/schema/keywords.js +6 -51
- package/build/lib/schema/keywords.js.map +1 -1
- package/build/lib/schema/schema.d.ts +106 -231
- package/build/lib/schema/schema.d.ts.map +1 -1
- package/build/lib/schema/schema.js +75 -345
- package/build/lib/schema/schema.js.map +1 -1
- package/build/lib/utils.d.ts +59 -238
- package/build/lib/utils.d.ts.map +1 -1
- package/build/lib/utils.js +55 -207
- package/build/lib/utils.js.map +1 -1
- package/lib/cli/{args.js → args.ts} +40 -51
- package/lib/cli/driver-command.ts +122 -0
- package/lib/cli/{extension-command.js → extension-command.ts} +610 -689
- package/lib/cli/extension.ts +65 -0
- package/lib/cli/{parser.js → parser.ts} +48 -71
- package/lib/cli/plugin-command.ts +117 -0
- package/lib/cli/{setup-command.js → setup-command.ts} +57 -72
- package/lib/cli/utils.ts +97 -0
- package/lib/config-file.ts +212 -0
- package/lib/{config.js → config.ts} +129 -141
- package/lib/{constants.js → constants.ts} +30 -41
- package/lib/doctor/{doctor.js → doctor.ts} +81 -91
- package/lib/grid-register.ts +250 -0
- package/lib/{logsink.js → logsink.ts} +91 -137
- package/lib/main.js +1 -1
- package/lib/schema/arg-spec.ts +131 -0
- package/lib/schema/cli-args.ts +171 -0
- package/lib/schema/cli-transformers.ts +83 -0
- package/lib/schema/keywords.ts +96 -0
- package/lib/schema/schema.ts +449 -0
- package/lib/utils.ts +404 -0
- package/package.json +16 -16
- package/lib/cli/driver-command.js +0 -174
- package/lib/cli/extension.js +0 -74
- package/lib/cli/plugin-command.js +0 -164
- package/lib/cli/utils.js +0 -91
- package/lib/config-file.js +0 -228
- package/lib/grid-register.js +0 -146
- package/lib/schema/arg-spec.js +0 -229
- package/lib/schema/cli-args.js +0 -254
- package/lib/schema/cli-transformers.js +0 -113
- package/lib/schema/keywords.js +0 -136
- package/lib/schema/schema.js +0 -725
- package/lib/utils.js +0 -512
- /package/lib/schema/{index.js → index.ts} +0 -0
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
import _ from 'lodash';
|
|
2
|
+
import type {ArgumentOptions} from 'argparse';
|
|
3
|
+
import type {ExtensionType} from '@appium/types';
|
|
4
|
+
import type {CliExtensionSubcommand} from 'appium/types';
|
|
2
5
|
import {
|
|
3
6
|
DRIVER_TYPE,
|
|
4
7
|
PLUGIN_TYPE,
|
|
@@ -14,18 +17,21 @@ import {toParserArgs} from '../schema/cli-args';
|
|
|
14
17
|
const DRIVER_EXAMPLE = 'xcuitest';
|
|
15
18
|
const PLUGIN_EXAMPLE = 'images';
|
|
16
19
|
|
|
20
|
+
export type ArgumentDefinitions = Map<
|
|
21
|
+
[name: string] | [name: string, alias: string],
|
|
22
|
+
ArgumentOptions
|
|
23
|
+
>;
|
|
24
|
+
|
|
17
25
|
/**
|
|
18
26
|
* This is necessary because we pass the array into `argparse`. `argparse` is bad and mutates things. We don't want that.
|
|
19
27
|
* Bad `argparse`! Bad!
|
|
20
28
|
*/
|
|
21
29
|
const INSTALL_TYPES_ARRAY = [...INSTALL_TYPES];
|
|
22
30
|
|
|
23
|
-
|
|
24
|
-
const EXTENSION_TYPES = new Set([DRIVER_TYPE, PLUGIN_TYPE]);
|
|
31
|
+
const EXTENSION_TYPES = new Set<ExtensionType>([DRIVER_TYPE, PLUGIN_TYPE]);
|
|
25
32
|
|
|
26
33
|
// this set of args works for both drivers and plugins ('extensions')
|
|
27
|
-
|
|
28
|
-
const globalExtensionArgs = new Map([
|
|
34
|
+
const globalExtensionArgs: ArgumentDefinitions = new Map([
|
|
29
35
|
[
|
|
30
36
|
['--json'],
|
|
31
37
|
{
|
|
@@ -39,10 +45,18 @@ const globalExtensionArgs = new Map([
|
|
|
39
45
|
]);
|
|
40
46
|
|
|
41
47
|
/**
|
|
42
|
-
*
|
|
48
|
+
* Returns CLI argument definitions for extension commands by extension type.
|
|
49
|
+
*
|
|
50
|
+
* The result is memoized because parser setup is static across process lifetime.
|
|
43
51
|
*/
|
|
44
|
-
const getExtensionArgs = _.memoize(function getExtensionArgs()
|
|
45
|
-
|
|
52
|
+
export const getExtensionArgs = _.memoize(function getExtensionArgs(): Record<
|
|
53
|
+
ExtensionType,
|
|
54
|
+
Record<CliExtensionSubcommand, ArgumentDefinitions>
|
|
55
|
+
> {
|
|
56
|
+
const extensionArgs = {} as Record<
|
|
57
|
+
ExtensionType,
|
|
58
|
+
Record<CliExtensionSubcommand, ArgumentDefinitions>
|
|
59
|
+
>;
|
|
46
60
|
for (const type of EXTENSION_TYPES) {
|
|
47
61
|
extensionArgs[type] = {
|
|
48
62
|
[EXT_SUBCOMMAND_LIST]: makeListArgs(type),
|
|
@@ -53,17 +67,13 @@ const getExtensionArgs = _.memoize(function getExtensionArgs() {
|
|
|
53
67
|
[EXT_SUBCOMMAND_DOCTOR]: makeDoctorArgs(type),
|
|
54
68
|
};
|
|
55
69
|
}
|
|
56
|
-
return
|
|
57
|
-
extensionArgs
|
|
58
|
-
);
|
|
70
|
+
return extensionArgs;
|
|
59
71
|
});
|
|
60
72
|
|
|
61
73
|
/**
|
|
62
|
-
*
|
|
63
|
-
* @param {ExtensionType} type
|
|
64
|
-
* @returns {ArgumentDefinitions}
|
|
74
|
+
* Builds options for the `list` subcommand for an extension type.
|
|
65
75
|
*/
|
|
66
|
-
function makeListArgs(type) {
|
|
76
|
+
function makeListArgs(type: ExtensionType): ArgumentDefinitions {
|
|
67
77
|
return new Map([
|
|
68
78
|
...globalExtensionArgs,
|
|
69
79
|
[
|
|
@@ -100,11 +110,9 @@ function makeListArgs(type) {
|
|
|
100
110
|
}
|
|
101
111
|
|
|
102
112
|
/**
|
|
103
|
-
*
|
|
104
|
-
* @param {ExtensionType} type
|
|
105
|
-
* @returns {ArgumentDefinitions}
|
|
113
|
+
* Builds options for the `install` subcommand for an extension type.
|
|
106
114
|
*/
|
|
107
|
-
function makeInstallArgs(type) {
|
|
115
|
+
function makeInstallArgs(type: ExtensionType): ArgumentDefinitions {
|
|
108
116
|
return new Map([
|
|
109
117
|
...globalExtensionArgs,
|
|
110
118
|
[
|
|
@@ -144,11 +152,9 @@ function makeInstallArgs(type) {
|
|
|
144
152
|
}
|
|
145
153
|
|
|
146
154
|
/**
|
|
147
|
-
*
|
|
148
|
-
* @param {ExtensionType} type
|
|
149
|
-
* @returns {ArgumentDefinitions}
|
|
155
|
+
* Builds options for the `uninstall` subcommand for an extension type.
|
|
150
156
|
*/
|
|
151
|
-
function makeUninstallArgs(type) {
|
|
157
|
+
function makeUninstallArgs(type: ExtensionType): ArgumentDefinitions {
|
|
152
158
|
return new Map([
|
|
153
159
|
...globalExtensionArgs,
|
|
154
160
|
[
|
|
@@ -164,11 +170,9 @@ function makeUninstallArgs(type) {
|
|
|
164
170
|
}
|
|
165
171
|
|
|
166
172
|
/**
|
|
167
|
-
*
|
|
168
|
-
* @param {ExtensionType} type
|
|
169
|
-
* @returns {ArgumentDefinitions}
|
|
173
|
+
* Builds options for the `doctor` subcommand for an extension type.
|
|
170
174
|
*/
|
|
171
|
-
function makeDoctorArgs(type) {
|
|
175
|
+
function makeDoctorArgs(type: ExtensionType): ArgumentDefinitions {
|
|
172
176
|
return new Map([
|
|
173
177
|
...globalExtensionArgs,
|
|
174
178
|
[
|
|
@@ -184,11 +188,9 @@ function makeDoctorArgs(type) {
|
|
|
184
188
|
}
|
|
185
189
|
|
|
186
190
|
/**
|
|
187
|
-
*
|
|
188
|
-
* @param {ExtensionType} type
|
|
189
|
-
* @returns {ArgumentDefinitions}
|
|
191
|
+
* Builds options for the `update` subcommand for an extension type.
|
|
190
192
|
*/
|
|
191
|
-
function makeUpdateArgs(type) {
|
|
193
|
+
function makeUpdateArgs(type: ExtensionType): ArgumentDefinitions {
|
|
192
194
|
return new Map([
|
|
193
195
|
...globalExtensionArgs,
|
|
194
196
|
[
|
|
@@ -216,11 +218,9 @@ function makeUpdateArgs(type) {
|
|
|
216
218
|
}
|
|
217
219
|
|
|
218
220
|
/**
|
|
219
|
-
*
|
|
220
|
-
* @param {ExtensionType} type
|
|
221
|
-
* @returns {ArgumentDefinitions}
|
|
221
|
+
* Builds options for the `run` subcommand for an extension type.
|
|
222
222
|
*/
|
|
223
|
-
function makeRunArgs(type) {
|
|
223
|
+
function makeRunArgs(type: ExtensionType): ArgumentDefinitions {
|
|
224
224
|
return new Map([
|
|
225
225
|
...globalExtensionArgs,
|
|
226
226
|
[
|
|
@@ -247,19 +247,19 @@ function makeRunArgs(type) {
|
|
|
247
247
|
}
|
|
248
248
|
|
|
249
249
|
/**
|
|
250
|
-
*
|
|
251
|
-
*
|
|
252
|
-
*
|
|
250
|
+
* Returns CLI argument definitions for the `server` command.
|
|
251
|
+
*
|
|
252
|
+
* This includes schema-derived options and additional CLI-only options which
|
|
253
|
+
* are intentionally disallowed in config files.
|
|
253
254
|
*/
|
|
254
|
-
function getServerArgs() {
|
|
255
|
+
export function getServerArgs(): ArgumentDefinitions {
|
|
255
256
|
return new Map([...toParserArgs(), ...serverArgsDisallowedInConfig]);
|
|
256
257
|
}
|
|
257
258
|
|
|
258
259
|
/**
|
|
259
260
|
* These don't make sense in the context of a config file for obvious reasons.
|
|
260
|
-
* @type {ArgumentDefinitions}
|
|
261
261
|
*/
|
|
262
|
-
const serverArgsDisallowedInConfig = new Map([
|
|
262
|
+
const serverArgsDisallowedInConfig: ArgumentDefinitions = new Map([
|
|
263
263
|
[
|
|
264
264
|
['--shell'],
|
|
265
265
|
{
|
|
@@ -310,14 +310,3 @@ const serverArgsDisallowedInConfig = new Map([
|
|
|
310
310
|
},
|
|
311
311
|
],
|
|
312
312
|
]);
|
|
313
|
-
|
|
314
|
-
export {getServerArgs, getExtensionArgs};
|
|
315
|
-
|
|
316
|
-
/**
|
|
317
|
-
* @typedef {import('@appium/types').ExtensionType} ExtensionType
|
|
318
|
-
*/
|
|
319
|
-
|
|
320
|
-
/**
|
|
321
|
-
* A tuple of argument aliases and argument options
|
|
322
|
-
* @typedef {Map<[name: string]|[name: string, alias: string],import('argparse').ArgumentOptions>} ArgumentDefinitions
|
|
323
|
-
*/
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
import _ from 'lodash';
|
|
2
|
+
import type {ExtMetadata, ExtRecord, InstallType} from 'appium/types';
|
|
3
|
+
import ExtensionCliCommand from './extension-command';
|
|
4
|
+
import type {
|
|
5
|
+
ExtensionArgs,
|
|
6
|
+
ExtensionCommandOptions,
|
|
7
|
+
ExtensionUpdateResult,
|
|
8
|
+
PostInstallText,
|
|
9
|
+
RunOutput,
|
|
10
|
+
} from './extension-command';
|
|
11
|
+
import {KNOWN_DRIVERS} from '../constants';
|
|
12
|
+
import '@colors/colors';
|
|
13
|
+
|
|
14
|
+
const REQ_DRIVER_FIELDS = ['driverName', 'automationName', 'platformNames', 'mainClass'];
|
|
15
|
+
type DriverInstallOpts = {driver: string; installType: InstallType; packageName?: string};
|
|
16
|
+
type DriverUninstallOpts = {driver: string};
|
|
17
|
+
type DriverUpdateOpts = {driver: string; unsafe: boolean};
|
|
18
|
+
type DriverRunOptions = {driver: string; scriptName: string; extraArgs?: string[]};
|
|
19
|
+
type DriverDoctorOptions = {driver: string};
|
|
20
|
+
|
|
21
|
+
export default class DriverCliCommand extends ExtensionCliCommand<'driver'> {
|
|
22
|
+
constructor({config, json}: ExtensionCommandOptions<'driver'>) {
|
|
23
|
+
super({config, json});
|
|
24
|
+
this.knownExtensions = KNOWN_DRIVERS;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Install a driver
|
|
29
|
+
*
|
|
30
|
+
* @param opts - install options
|
|
31
|
+
*/
|
|
32
|
+
async install({driver, installType, packageName}: DriverInstallOpts): Promise<ExtRecord<'driver'>> {
|
|
33
|
+
return await super._install({
|
|
34
|
+
installSpec: driver,
|
|
35
|
+
installType,
|
|
36
|
+
packageName,
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Uninstall a driver
|
|
42
|
+
*
|
|
43
|
+
* @param opts - uninstall options
|
|
44
|
+
*/
|
|
45
|
+
async uninstall({driver}: DriverUninstallOpts): Promise<ExtRecord<'driver'>> {
|
|
46
|
+
return await super._uninstall({installSpec: driver});
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* Update a driver
|
|
51
|
+
*
|
|
52
|
+
* @param opts - update options
|
|
53
|
+
*/
|
|
54
|
+
async update({driver, unsafe}: DriverUpdateOpts): Promise<ExtensionUpdateResult> {
|
|
55
|
+
return await super._update({installSpec: driver, unsafe});
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* Run a script from a driver
|
|
60
|
+
*
|
|
61
|
+
* @param opts - script execution options
|
|
62
|
+
* @throws {Error} if the script fails to run
|
|
63
|
+
*/
|
|
64
|
+
async run({driver, scriptName, extraArgs}: DriverRunOptions): Promise<RunOutput> {
|
|
65
|
+
return await super._run({
|
|
66
|
+
installSpec: driver,
|
|
67
|
+
scriptName,
|
|
68
|
+
extraArgs,
|
|
69
|
+
bufferOutput: this.isJsonOutput,
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* Runs doctor checks for the given driver.
|
|
75
|
+
*
|
|
76
|
+
* @param opts - doctor command options
|
|
77
|
+
* @returns The amount of executed doctor checks.
|
|
78
|
+
* @throws {Error} If any of the mandatory Doctor checks fails.
|
|
79
|
+
*/
|
|
80
|
+
async doctor({driver}: DriverDoctorOptions): Promise<number> {
|
|
81
|
+
return await super._doctor({
|
|
82
|
+
installSpec: driver,
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* Builds the success message displayed after a driver installation.
|
|
88
|
+
*
|
|
89
|
+
* @param args - installed extension name and metadata
|
|
90
|
+
* @returns formatted success text
|
|
91
|
+
*/
|
|
92
|
+
override getPostInstallText({extName, extData}: ExtensionArgs<'driver'>): PostInstallText {
|
|
93
|
+
return (
|
|
94
|
+
`Driver ${extName}@${extData.version} successfully installed\n`.green +
|
|
95
|
+
`- automationName: ${extData.automationName.green}\n` +
|
|
96
|
+
`- platformNames: ${JSON.stringify(extData.platformNames).green}`
|
|
97
|
+
);
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
* Validates fields in `appium` field of `driverMetadata`
|
|
102
|
+
*
|
|
103
|
+
* For any `package.json` fields which a driver requires, validate the type of
|
|
104
|
+
* those fields on the `package.json` data, throwing an error if anything is
|
|
105
|
+
* amiss.
|
|
106
|
+
* @param driverMetadata - `appium` metadata from extension package
|
|
107
|
+
* @param installSpec - install spec from CLI
|
|
108
|
+
*/
|
|
109
|
+
override validateExtensionFields(driverMetadata: ExtMetadata<'driver'>, installSpec: string): void {
|
|
110
|
+
const missingFields = REQ_DRIVER_FIELDS.reduce(
|
|
111
|
+
(acc, field) => (driverMetadata[field] ? acc : [...acc, field]),
|
|
112
|
+
[]
|
|
113
|
+
);
|
|
114
|
+
|
|
115
|
+
if (!_.isEmpty(missingFields)) {
|
|
116
|
+
throw new Error(
|
|
117
|
+
`Driver "${installSpec}" did not expose correct fields for compatibility ` +
|
|
118
|
+
`with Appium. Missing fields: ${JSON.stringify(missingFields)}`
|
|
119
|
+
);
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
}
|