appium 2.0.0-beta.35 → 2.0.0-beta.39
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/appium.d.ts +41 -52
- package/build/lib/appium.d.ts.map +1 -1
- package/build/lib/appium.js +32 -15
- package/build/lib/cli/args.d.ts +1 -1
- package/build/lib/cli/args.d.ts.map +1 -1
- package/build/lib/cli/args.js +1 -1
- package/build/lib/cli/driver-command.d.ts +3 -3
- package/build/lib/cli/driver-command.d.ts.map +1 -1
- package/build/lib/cli/driver-command.js +1 -1
- package/build/lib/cli/extension-command.d.ts +60 -38
- package/build/lib/cli/extension-command.d.ts.map +1 -1
- package/build/lib/cli/extension-command.js +115 -59
- package/build/lib/cli/extension.d.ts +9 -5
- package/build/lib/cli/extension.d.ts.map +1 -1
- package/build/lib/cli/extension.js +5 -7
- package/build/lib/cli/parser.d.ts +3 -3
- package/build/lib/cli/parser.d.ts.map +1 -1
- package/build/lib/cli/parser.js +1 -1
- package/build/lib/cli/plugin-command.d.ts +1 -1
- package/build/lib/cli/plugin-command.d.ts.map +1 -1
- package/build/lib/cli/plugin-command.js +1 -1
- package/build/lib/cli/utils.js +1 -1
- package/build/lib/config-file.d.ts.map +1 -1
- package/build/lib/config-file.js +1 -1
- package/build/lib/config.d.ts +4 -4
- package/build/lib/config.d.ts.map +1 -1
- package/build/lib/config.js +1 -1
- package/build/lib/constants.d.ts.map +1 -1
- package/build/lib/constants.js +1 -1
- package/build/lib/extension/driver-config.d.ts +29 -32
- package/build/lib/extension/driver-config.d.ts.map +1 -1
- package/build/lib/extension/driver-config.js +7 -20
- package/build/lib/extension/extension-config.d.ts +108 -36
- package/build/lib/extension/extension-config.d.ts.map +1 -1
- package/build/lib/extension/extension-config.js +199 -60
- package/build/lib/extension/index.d.ts +16 -7
- package/build/lib/extension/index.d.ts.map +1 -1
- package/build/lib/extension/index.js +15 -18
- package/build/lib/extension/manifest.d.ts +12 -12
- package/build/lib/extension/manifest.d.ts.map +1 -1
- package/build/lib/extension/manifest.js +13 -3
- package/build/lib/extension/package-changed.d.ts.map +1 -1
- package/build/lib/extension/package-changed.js +1 -1
- package/build/lib/extension/plugin-config.d.ts +19 -24
- package/build/lib/extension/plugin-config.d.ts.map +1 -1
- package/build/lib/extension/plugin-config.js +9 -18
- package/build/lib/grid-register.d.ts.map +1 -1
- package/build/lib/grid-register.js +1 -1
- package/build/lib/logger.d.ts +1 -1
- package/build/lib/logger.d.ts.map +1 -1
- package/build/lib/logger.js +1 -1
- package/build/lib/logsink.d.ts.map +1 -1
- package/build/lib/logsink.js +3 -2
- package/build/lib/main.d.ts +13 -12
- package/build/lib/main.d.ts.map +1 -1
- package/build/lib/main.js +4 -4
- package/build/lib/schema/arg-spec.d.ts +4 -4
- package/build/lib/schema/arg-spec.d.ts.map +1 -1
- package/build/lib/schema/arg-spec.js +1 -1
- package/build/lib/schema/cli-args.d.ts.map +1 -1
- package/build/lib/schema/cli-args.js +1 -1
- package/build/lib/schema/cli-transformers.d.ts.map +1 -1
- package/build/lib/schema/cli-transformers.js +1 -1
- package/build/lib/schema/keywords.d.ts.map +1 -1
- package/build/lib/schema/keywords.js +1 -1
- package/build/lib/schema/schema.d.ts +2 -2
- package/build/lib/schema/schema.d.ts.map +1 -1
- package/build/lib/schema/schema.js +1 -1
- package/build/lib/utils.d.ts.map +1 -1
- package/build/lib/utils.js +1 -1
- package/build/tsconfig.tsbuildinfo +1 -1
- package/build/types/appium-manifest.d.ts +23 -4
- package/build/types/appium-manifest.d.ts.map +1 -1
- package/build/types/cli.d.ts.map +1 -1
- package/build/types/{external-manifest.d.ts → extension-manifest.d.ts} +15 -7
- package/build/types/extension-manifest.d.ts.map +1 -0
- package/build/types/index.d.ts +6 -5
- package/build/types/index.d.ts.map +1 -1
- package/driver.d.ts +1 -0
- package/driver.js +14 -0
- package/lib/appium.js +208 -124
- package/lib/cli/args.js +143 -93
- package/lib/cli/driver-command.js +10 -15
- package/lib/cli/extension-command.js +226 -175
- package/lib/cli/extension.js +15 -19
- package/lib/cli/parser.js +19 -31
- package/lib/cli/plugin-command.js +8 -8
- package/lib/cli/utils.js +8 -14
- package/lib/config-file.js +21 -25
- package/lib/config.js +82 -64
- package/lib/constants.js +4 -13
- package/lib/extension/driver-config.js +171 -171
- package/lib/extension/extension-config.js +347 -126
- package/lib/extension/index.js +72 -58
- package/lib/extension/manifest.js +48 -57
- package/lib/extension/package-changed.js +9 -8
- package/lib/extension/plugin-config.js +62 -62
- package/lib/grid-register.js +29 -18
- package/lib/logger.js +1 -2
- package/lib/logsink.js +29 -31
- package/lib/main.js +111 -73
- package/lib/schema/arg-spec.js +10 -13
- package/lib/schema/cli-args.js +14 -37
- package/lib/schema/cli-transformers.js +7 -14
- package/lib/schema/keywords.js +15 -13
- package/lib/schema/schema.js +58 -75
- package/lib/utils.js +50 -25
- package/package.json +25 -18
- package/plugin.d.ts +1 -0
- package/plugin.js +13 -0
- package/scripts/autoinstall-extensions.js +177 -0
- package/support.d.ts +1 -0
- package/support.js +13 -0
- package/types/appium-manifest.ts +27 -15
- package/types/cli.ts +2 -9
- package/types/{external-manifest.ts → extension-manifest.ts} +21 -15
- package/types/index.ts +12 -5
- package/build/types/extension.d.ts +0 -43
- package/build/types/extension.d.ts.map +0 -1
- package/build/types/external-manifest.d.ts.map +0 -1
- package/scripts/postinstall.js +0 -71
- package/types/extension.ts +0 -56
|
@@ -1,14 +1,12 @@
|
|
|
1
|
-
|
|
2
1
|
import _ from 'lodash';
|
|
3
|
-
import {
|
|
2
|
+
import {DRIVER_TYPE} from '../constants';
|
|
4
3
|
import log from '../logger';
|
|
5
|
-
import {
|
|
4
|
+
import {ExtensionConfig} from './extension-config';
|
|
6
5
|
|
|
7
6
|
/**
|
|
8
7
|
* @extends {ExtensionConfig<DriverType>}
|
|
9
8
|
*/
|
|
10
9
|
export class DriverConfig extends ExtensionConfig {
|
|
11
|
-
|
|
12
10
|
/**
|
|
13
11
|
* A set of unique automation names used by drivers.
|
|
14
12
|
* @type {Set<string>}
|
|
@@ -25,221 +23,223 @@ export class DriverConfig extends ExtensionConfig {
|
|
|
25
23
|
* @type {WeakMap<Manifest,DriverConfig>}
|
|
26
24
|
* @private
|
|
27
25
|
*/
|
|
28
|
-
|
|
26
|
+
static _instances = new WeakMap();
|
|
29
27
|
|
|
30
|
-
|
|
28
|
+
/**
|
|
31
29
|
* Call {@link DriverConfig.create} instead.
|
|
32
30
|
* @private
|
|
33
31
|
* @param {import('./manifest').Manifest} manifest - Manifest instance
|
|
34
|
-
* @param {DriverConfigOptions} [opts]
|
|
35
32
|
*/
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
/**
|
|
33
|
+
constructor(manifest) {
|
|
34
|
+
super(DRIVER_TYPE, manifest);
|
|
35
|
+
|
|
36
|
+
this.knownAutomationNames = new Set();
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Creates a new {@link DriverConfig} instance for a {@link Manifest} instance.
|
|
41
|
+
*
|
|
42
|
+
* @param {Manifest} manifest
|
|
43
|
+
* @throws If `manifest` already associated with a `DriverConfig`
|
|
44
|
+
* @returns {DriverConfig}
|
|
45
|
+
*/
|
|
46
|
+
static create(manifest) {
|
|
47
|
+
const instance = new DriverConfig(manifest);
|
|
48
|
+
if (DriverConfig.getInstance(manifest)) {
|
|
49
|
+
throw new Error(
|
|
50
|
+
`Manifest with APPIUM_HOME ${manifest.appiumHome} already has a DriverConfig; use DriverConfig.getInstance() to retrieve it.`
|
|
51
|
+
);
|
|
52
|
+
}
|
|
53
|
+
DriverConfig._instances.set(manifest, instance);
|
|
54
|
+
return instance;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* Returns a DriverConfig associated with a Manifest
|
|
59
|
+
* @param {Manifest} manifest
|
|
60
|
+
* @returns {DriverConfig|undefined}
|
|
61
|
+
*/
|
|
62
|
+
static getInstance(manifest) {
|
|
63
|
+
return DriverConfig._instances.get(manifest);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/**
|
|
73
67
|
* Checks extensions for problems
|
|
74
|
-
* @param {ExtRecord<DriverType>} exts
|
|
75
68
|
*/
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
69
|
+
async validate() {
|
|
70
|
+
this.knownAutomationNames.clear();
|
|
71
|
+
return await super._validate(this.manifest.getExtensionData(DRIVER_TYPE));
|
|
72
|
+
}
|
|
80
73
|
|
|
81
|
-
|
|
74
|
+
/**
|
|
82
75
|
* @param {ExtManifest<DriverType>} extData
|
|
83
|
-
* @returns {import('./extension-config').
|
|
76
|
+
* @returns {import('./extension-config').ExtManifestProblem[]}
|
|
84
77
|
*/
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
78
|
+
getConfigProblems(extData) {
|
|
79
|
+
const problems = [];
|
|
80
|
+
const {platformNames, automationName} = extData;
|
|
81
|
+
|
|
82
|
+
if (!_.isArray(platformNames)) {
|
|
83
|
+
problems.push({
|
|
84
|
+
err: 'Missing or incorrect supported platformNames list.',
|
|
85
|
+
val: platformNames,
|
|
86
|
+
});
|
|
87
|
+
} else {
|
|
88
|
+
if (_.isEmpty(platformNames)) {
|
|
89
|
+
problems.push({
|
|
90
|
+
err: 'Empty platformNames list.',
|
|
91
|
+
val: platformNames,
|
|
92
|
+
});
|
|
93
|
+
} else {
|
|
94
|
+
for (const pName of platformNames) {
|
|
95
|
+
if (!_.isString(pName)) {
|
|
96
|
+
problems.push({
|
|
97
|
+
err: 'Incorrectly formatted platformName.',
|
|
98
|
+
val: pName,
|
|
99
|
+
});
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
if (!_.isString(automationName)) {
|
|
106
|
+
problems.push({
|
|
107
|
+
err: 'Missing or incorrect automationName',
|
|
108
|
+
val: automationName,
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
if (this.knownAutomationNames.has(automationName)) {
|
|
113
|
+
problems.push({
|
|
114
|
+
err: 'Multiple drivers claim support for the same automationName',
|
|
115
|
+
val: automationName,
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
// should we retain the name at the end of this function, once we've checked there are no problems?
|
|
120
|
+
this.knownAutomationNames.add(automationName);
|
|
121
|
+
|
|
122
|
+
return problems;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
/**
|
|
127
126
|
* @param {ExtName<DriverType>} driverName
|
|
128
127
|
* @param {ExtManifest<DriverType>} extData
|
|
129
128
|
* @returns {string}
|
|
130
129
|
*/
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
130
|
+
extensionDesc(driverName, {version, automationName}) {
|
|
131
|
+
return `${driverName}@${version} (automationName '${automationName}')`;
|
|
132
|
+
}
|
|
134
133
|
|
|
135
|
-
|
|
134
|
+
/**
|
|
136
135
|
* Given capabilities, find a matching driver within the config. Load its class and return it along with version and driver name.
|
|
137
136
|
* @param {Capabilities} caps
|
|
138
137
|
* @returns {MatchedDriver}
|
|
139
138
|
*/
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
139
|
+
findMatchingDriver({automationName, platformName}) {
|
|
140
|
+
if (!_.isString(platformName)) {
|
|
141
|
+
throw new Error('You must include a platformName capability');
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
if (!_.isString(automationName)) {
|
|
145
|
+
throw new Error('You must include an automationName capability');
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
log.info(
|
|
149
|
+
`Attempting to find matching driver for automationName ` +
|
|
150
|
+
`'${automationName}' and platformName '${platformName}'`
|
|
151
|
+
);
|
|
152
|
+
|
|
153
|
+
try {
|
|
154
|
+
const {driverName, mainClass, version} = this._getDriverBySupport(
|
|
155
|
+
automationName,
|
|
156
|
+
platformName
|
|
157
|
+
);
|
|
158
|
+
log.info(`The '${driverName}' driver was installed and matched caps.`);
|
|
159
|
+
log.info(`Will require it at ${this.getInstallPath(driverName)}`);
|
|
160
|
+
const driver = this.require(driverName);
|
|
161
|
+
if (!driver) {
|
|
162
|
+
throw new Error(
|
|
163
|
+
`Driver '${driverName}' did not export a class with name '${mainClass}'. Contact the author of the driver!`
|
|
164
|
+
);
|
|
165
|
+
}
|
|
166
|
+
return {driver, version, driverName};
|
|
167
|
+
} catch (err) {
|
|
168
|
+
const msg =
|
|
169
|
+
`Could not find a driver for automationName ` +
|
|
170
|
+
`'${automationName}' and platformName ${platformName}'. ` +
|
|
171
|
+
`Have you installed a driver that supports those ` +
|
|
172
|
+
`capabilities? Run 'appium driver list --installed' to see. ` +
|
|
173
|
+
`(Lower-level error: ${err.message})`;
|
|
174
|
+
throw new Error(msg);
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
/**
|
|
176
179
|
* Given an automation name and platform name, find a suitable driver and return its extension data.
|
|
177
180
|
* @param {string} matchAutomationName
|
|
178
181
|
* @param {string} matchPlatformName
|
|
179
|
-
* @returns {ExtMetadata<DriverType> & import('
|
|
182
|
+
* @returns {ExtMetadata<DriverType> & import('appium/types').InternalMetadata & import('appium/types').CommonExtMetadata}
|
|
180
183
|
*/
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
184
|
+
_getDriverBySupport(matchAutomationName, matchPlatformName) {
|
|
185
|
+
const drivers = this.installedExtensions;
|
|
186
|
+
for (const [driverName, driverData] of _.toPairs(drivers)) {
|
|
187
|
+
const {automationName, platformNames} = driverData;
|
|
188
|
+
const aNameMatches = automationName.toLowerCase() === matchAutomationName.toLowerCase();
|
|
189
|
+
const pNameMatches = _.includes(
|
|
190
|
+
platformNames.map(_.toLower),
|
|
191
|
+
matchPlatformName.toLowerCase()
|
|
192
|
+
);
|
|
193
|
+
|
|
194
|
+
if (aNameMatches && pNameMatches) {
|
|
195
|
+
return {driverName, ...driverData};
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
if (aNameMatches) {
|
|
199
|
+
throw new Error(
|
|
200
|
+
`Driver '${driverName}' supports automationName ` +
|
|
201
|
+
`'${automationName}', but Appium could not find ` +
|
|
202
|
+
`support for platformName '${matchPlatformName}'. Supported ` +
|
|
203
|
+
`platformNames are: ` +
|
|
204
|
+
JSON.stringify(platformNames)
|
|
205
|
+
);
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
throw new Error(`Could not find installed driver to support given caps`);
|
|
210
|
+
}
|
|
204
211
|
}
|
|
205
212
|
|
|
206
|
-
/**
|
|
207
|
-
* @typedef DriverConfigOptions
|
|
208
|
-
* @property {import('./extension-config').ExtensionLogFn} [logFn] - Optional logging function
|
|
209
|
-
* @property {ManifestData['drivers']} [extData] - Extension data
|
|
210
|
-
*/
|
|
211
|
-
|
|
212
213
|
/**
|
|
213
214
|
* @template T
|
|
214
|
-
* @typedef {import('
|
|
215
|
+
* @typedef {import('appium/types').ExtMetadata<T>} ExtMetadata
|
|
215
216
|
*/
|
|
216
217
|
|
|
217
218
|
/**
|
|
218
219
|
* @template T
|
|
219
|
-
* @typedef {import('
|
|
220
|
+
* @typedef {import('appium/types').ExtManifest<T>} ExtManifest
|
|
220
221
|
*/
|
|
221
222
|
|
|
222
223
|
/**
|
|
223
|
-
* @typedef {import('
|
|
224
|
-
* @typedef {import('
|
|
224
|
+
* @typedef {import('appium/types').ManifestData} ManifestData
|
|
225
|
+
* @typedef {import('@appium/types').DriverType} DriverType
|
|
225
226
|
* @typedef {import('./manifest').Manifest} Manifest
|
|
226
227
|
*/
|
|
227
228
|
|
|
228
229
|
/**
|
|
229
230
|
* @template T
|
|
230
|
-
* @typedef {import('
|
|
231
|
+
* @typedef {import('appium/types').ExtRecord<T>} ExtRecord
|
|
231
232
|
*/
|
|
232
233
|
|
|
233
234
|
/**
|
|
234
235
|
* @template T
|
|
235
|
-
* @typedef {import('
|
|
236
|
+
* @typedef {import('appium/types').ExtName<T>} ExtName
|
|
236
237
|
*/
|
|
237
238
|
|
|
238
|
-
|
|
239
239
|
/**
|
|
240
240
|
* Return value of {@linkcode DriverConfig.findMatchingDriver}
|
|
241
241
|
* @typedef MatchedDriver
|
|
242
|
-
* @property {import('
|
|
242
|
+
* @property {import('@appium/types').DriverClass} driver
|
|
243
243
|
* @property {string} version
|
|
244
244
|
* @property {string} driverName
|
|
245
245
|
*/
|