appium 3.2.1 → 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 +19 -20
- package/tsconfig.json +1 -1
- package/build/package.json +0 -99
- 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
package/lib/utils.js
DELETED
|
@@ -1,512 +0,0 @@
|
|
|
1
|
-
import _ from 'lodash';
|
|
2
|
-
import logger from './logger';
|
|
3
|
-
import {
|
|
4
|
-
processCapabilities,
|
|
5
|
-
STANDARD_CAPS,
|
|
6
|
-
errors,
|
|
7
|
-
isW3cCaps,
|
|
8
|
-
} from '@appium/base-driver';
|
|
9
|
-
import {inspect as dump} from 'node:util';
|
|
10
|
-
import {node, fs} from '@appium/support';
|
|
11
|
-
import path from 'node:path';
|
|
12
|
-
import {SERVER_SUBCOMMAND, DRIVER_TYPE, PLUGIN_TYPE, SETUP_SUBCOMMAND} from './constants';
|
|
13
|
-
import os from 'node:os';
|
|
14
|
-
|
|
15
|
-
const W3C_APPIUM_PREFIX = 'appium';
|
|
16
|
-
const STANDARD_CAPS_LOWERCASE = new Set([...STANDARD_CAPS].map((cap) => cap.toLowerCase()));
|
|
17
|
-
export const V4_BROADCAST_IP = '0.0.0.0';
|
|
18
|
-
export const V6_BROADCAST_IP = '::';
|
|
19
|
-
export const npmPackage = fs.readPackageJsonFrom(__dirname);
|
|
20
|
-
|
|
21
|
-
/**
|
|
22
|
-
*
|
|
23
|
-
* If `stdout` is a TTY, this is `true`.
|
|
24
|
-
*
|
|
25
|
-
* Used for tighter control over log output.
|
|
26
|
-
* @type {boolean}
|
|
27
|
-
*/
|
|
28
|
-
const isStdoutTTY = process.stdout.isTTY;
|
|
29
|
-
|
|
30
|
-
/**
|
|
31
|
-
* Creates an error object in case a session gets incompatible capabilities as the input.
|
|
32
|
-
*
|
|
33
|
-
* @returns {Error}
|
|
34
|
-
*/
|
|
35
|
-
export function makeNonW3cCapsError() {
|
|
36
|
-
return new errors.SessionNotCreatedError(
|
|
37
|
-
'Session capabilities format must comply to the W3C standard. Make sure your client is up to date. ' +
|
|
38
|
-
'See https://www.w3.org/TR/webdriver/#new-session for more details.'
|
|
39
|
-
);
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
/**
|
|
43
|
-
* Dumps to value to the console using `info` logger.
|
|
44
|
-
*
|
|
45
|
-
* @todo May want to force color to be `false` if {@link isStdoutTTY} is `false`.
|
|
46
|
-
*/
|
|
47
|
-
export const inspect = _.flow(
|
|
48
|
-
_.partialRight(
|
|
49
|
-
/** @type {(object: any, options: import('util').InspectOptions) => string} */ (dump),
|
|
50
|
-
{colors: true, depth: null, compact: !isStdoutTTY}
|
|
51
|
-
),
|
|
52
|
-
(...args) => {
|
|
53
|
-
logger.info(...args);
|
|
54
|
-
}
|
|
55
|
-
);
|
|
56
|
-
|
|
57
|
-
/**
|
|
58
|
-
* Takes the caps that were provided in the request and translates them
|
|
59
|
-
* into caps that can be used by the inner drivers.
|
|
60
|
-
*
|
|
61
|
-
* @template {Constraints} C
|
|
62
|
-
* @param {W3CCapabilities<C>} w3cCapabilities
|
|
63
|
-
* @param {C} constraints
|
|
64
|
-
* @param {NSCapabilities<C>} [defaultCapabilities]
|
|
65
|
-
* @returns {ParsedDriverCaps<C>|InvalidCaps<C>}
|
|
66
|
-
*/
|
|
67
|
-
export function parseCapsForInnerDriver(
|
|
68
|
-
w3cCapabilities,
|
|
69
|
-
constraints = /** @type {C} */ ({}),
|
|
70
|
-
defaultCapabilities = {}
|
|
71
|
-
) {
|
|
72
|
-
if (!isW3cCaps(w3cCapabilities)) {
|
|
73
|
-
return /** @type {InvalidCaps<C>} */ ({
|
|
74
|
-
error: makeNonW3cCapsError(),
|
|
75
|
-
});
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
let desiredCaps = /** @type {ParsedDriverCaps<C>['desiredCaps']} */ ({});
|
|
79
|
-
/** @type {ParsedDriverCaps<C>['processedW3CCapabilities'] | undefined} */
|
|
80
|
-
let processedW3CCapabilities;
|
|
81
|
-
|
|
82
|
-
// Make sure we don't mutate the original arguments
|
|
83
|
-
w3cCapabilities = _.cloneDeep(w3cCapabilities);
|
|
84
|
-
defaultCapabilities = _.cloneDeep(defaultCapabilities);
|
|
85
|
-
|
|
86
|
-
if (!_.isEmpty(defaultCapabilities)) {
|
|
87
|
-
for (const [defaultCapKey, defaultCapValue] of _.toPairs(defaultCapabilities)) {
|
|
88
|
-
let isCapAlreadySet = false;
|
|
89
|
-
// Check if the key is already present in firstMatch entries
|
|
90
|
-
for (const firstMatchEntry of w3cCapabilities.firstMatch ?? []) {
|
|
91
|
-
if (
|
|
92
|
-
_.isPlainObject(firstMatchEntry) &&
|
|
93
|
-
_.has(removeAppiumPrefixes(firstMatchEntry), removeAppiumPrefix(defaultCapKey))
|
|
94
|
-
) {
|
|
95
|
-
isCapAlreadySet = true;
|
|
96
|
-
break;
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
// Check if the key is already present in alwaysMatch entries
|
|
100
|
-
isCapAlreadySet =
|
|
101
|
-
isCapAlreadySet ||
|
|
102
|
-
(_.isPlainObject(w3cCapabilities.alwaysMatch) &&
|
|
103
|
-
_.has(
|
|
104
|
-
removeAppiumPrefixes(w3cCapabilities.alwaysMatch),
|
|
105
|
-
removeAppiumPrefix(defaultCapKey)
|
|
106
|
-
));
|
|
107
|
-
if (isCapAlreadySet) {
|
|
108
|
-
// Skip if the key is already present in the provided caps
|
|
109
|
-
continue;
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
// Only add the default capability if it is not overridden
|
|
113
|
-
if (_.isEmpty(w3cCapabilities.firstMatch)) {
|
|
114
|
-
w3cCapabilities.firstMatch = /** @type {W3CCapabilities<C>['firstMatch']} */ ([
|
|
115
|
-
{[defaultCapKey]: defaultCapValue},
|
|
116
|
-
]);
|
|
117
|
-
} else {
|
|
118
|
-
w3cCapabilities.firstMatch[0][defaultCapKey] = defaultCapValue;
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
// Call the process capabilities algorithm to find matching caps on the W3C
|
|
124
|
-
// (see: https://github.com/jlipps/simple-wd-spec#processing-capabilities)
|
|
125
|
-
try {
|
|
126
|
-
desiredCaps = processCapabilities(w3cCapabilities, constraints, true);
|
|
127
|
-
} catch (error) {
|
|
128
|
-
logger.info(`Could not parse W3C capabilities: ${error.message}`);
|
|
129
|
-
return /** @type {InvalidCaps<C>} */ ({
|
|
130
|
-
desiredCaps,
|
|
131
|
-
processedW3CCapabilities,
|
|
132
|
-
error,
|
|
133
|
-
});
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
// Create a new w3c capabilities payload that contains only the matching caps in `alwaysMatch`
|
|
137
|
-
processedW3CCapabilities = {
|
|
138
|
-
alwaysMatch: {...insertAppiumPrefixes(desiredCaps)},
|
|
139
|
-
firstMatch: [{}],
|
|
140
|
-
};
|
|
141
|
-
|
|
142
|
-
return /** @type {ParsedDriverCaps<C>} */ ({
|
|
143
|
-
desiredCaps,
|
|
144
|
-
processedW3CCapabilities,
|
|
145
|
-
});
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
/**
|
|
149
|
-
* Takes a capabilities objects and prefixes capabilities with `appium:`
|
|
150
|
-
* @template {Constraints} [C={}]
|
|
151
|
-
* @param {Capabilities<C>} caps - Desired capabilities object
|
|
152
|
-
* @returns {NSCapabilities<C>}
|
|
153
|
-
*/
|
|
154
|
-
export function insertAppiumPrefixes(caps) {
|
|
155
|
-
return /** @type {NSCapabilities<C>} */ (
|
|
156
|
-
_.mapKeys(caps, (_, key) =>
|
|
157
|
-
STANDARD_CAPS_LOWERCASE.has(key.toLowerCase()) || key.includes(':')
|
|
158
|
-
? key
|
|
159
|
-
: `${W3C_APPIUM_PREFIX}:${key}`
|
|
160
|
-
)
|
|
161
|
-
);
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
/**
|
|
165
|
-
* @template {Constraints} [C={}]
|
|
166
|
-
* @param {NSCapabilities<C>} caps
|
|
167
|
-
* @returns {Capabilities<C>}
|
|
168
|
-
*/
|
|
169
|
-
export function removeAppiumPrefixes(caps) {
|
|
170
|
-
return /** @type {Capabilities<C>} */ (_.mapKeys(caps, (_, key) => removeAppiumPrefix(key)));
|
|
171
|
-
}
|
|
172
|
-
|
|
173
|
-
/**
|
|
174
|
-
* @param {string} key
|
|
175
|
-
* @returns {string}
|
|
176
|
-
*/
|
|
177
|
-
function removeAppiumPrefix(key) {
|
|
178
|
-
const prefix = `${W3C_APPIUM_PREFIX}:`;
|
|
179
|
-
return _.startsWith(key, prefix) ? key.substring(prefix.length) : key;
|
|
180
|
-
}
|
|
181
|
-
|
|
182
|
-
/**
|
|
183
|
-
*
|
|
184
|
-
* @param {string} pkgName
|
|
185
|
-
* @returns {string|undefined}
|
|
186
|
-
*/
|
|
187
|
-
export function getPackageVersion(pkgName) {
|
|
188
|
-
const pkgInfo = require(`${pkgName}/package.json`) || {};
|
|
189
|
-
return pkgInfo.version;
|
|
190
|
-
}
|
|
191
|
-
|
|
192
|
-
/**
|
|
193
|
-
* Returns the root directory of the Appium module.
|
|
194
|
-
*
|
|
195
|
-
* @returns {string} - The absolute path to the Appium module root directory.
|
|
196
|
-
* @throws {Error} - If the Appium module root cannot be determined.
|
|
197
|
-
*/
|
|
198
|
-
export const getAppiumModuleRoot = _.memoize(function getAppiumModuleRoot() {
|
|
199
|
-
const selfRoot = node.getModuleRootSync('appium', __filename);
|
|
200
|
-
if (!selfRoot) {
|
|
201
|
-
throw new Error('Cannot find the appium module root. This is likely a bug in Appium.');
|
|
202
|
-
}
|
|
203
|
-
return selfRoot;
|
|
204
|
-
});
|
|
205
|
-
|
|
206
|
-
/**
|
|
207
|
-
* Adjusts NODE_PATH environment variable,
|
|
208
|
-
* so CJS drivers and plugins could load their peer dependencies.
|
|
209
|
-
* Read https://nodejs.org/api/modules.html#loading-from-the-global-folders
|
|
210
|
-
* for more details.
|
|
211
|
-
*
|
|
212
|
-
* Unfortunately this hack does not work with ESM modules,
|
|
213
|
-
* @returns {void}
|
|
214
|
-
*/
|
|
215
|
-
export function adjustNodePath() {
|
|
216
|
-
let appiumModuleSearchRoot;
|
|
217
|
-
try {
|
|
218
|
-
appiumModuleSearchRoot = path.dirname(getAppiumModuleRoot());
|
|
219
|
-
} catch (error) {
|
|
220
|
-
logger.warn(error.message);
|
|
221
|
-
return;
|
|
222
|
-
}
|
|
223
|
-
|
|
224
|
-
const refreshRequirePaths = () => {
|
|
225
|
-
try {
|
|
226
|
-
// ! This hack allows us to avoid modification of import
|
|
227
|
-
// ! statements in client modules. It uses a private API though,
|
|
228
|
-
// ! so it could break (maybe, eventually).
|
|
229
|
-
// See https://gist.github.com/branneman/8048520#7-the-hack
|
|
230
|
-
// @ts-ignore see above comment
|
|
231
|
-
|
|
232
|
-
require('node:module').Module._initPaths();
|
|
233
|
-
return true;
|
|
234
|
-
} catch {
|
|
235
|
-
return false;
|
|
236
|
-
}
|
|
237
|
-
};
|
|
238
|
-
|
|
239
|
-
if (!process.env.NODE_PATH) {
|
|
240
|
-
process.env.NODE_PATH = appiumModuleSearchRoot;
|
|
241
|
-
if (refreshRequirePaths()) {
|
|
242
|
-
process.env.APPIUM_OMIT_PEER_DEPS = '1';
|
|
243
|
-
} else {
|
|
244
|
-
delete process.env.NODE_PATH;
|
|
245
|
-
}
|
|
246
|
-
return;
|
|
247
|
-
}
|
|
248
|
-
|
|
249
|
-
const nodePathParts = process.env.NODE_PATH.split(path.delimiter);
|
|
250
|
-
if (nodePathParts.includes(appiumModuleSearchRoot)) {
|
|
251
|
-
process.env.APPIUM_OMIT_PEER_DEPS = '1';
|
|
252
|
-
return;
|
|
253
|
-
}
|
|
254
|
-
|
|
255
|
-
nodePathParts.push(appiumModuleSearchRoot);
|
|
256
|
-
process.env.NODE_PATH = nodePathParts.join(path.delimiter);
|
|
257
|
-
if (refreshRequirePaths()) {
|
|
258
|
-
process.env.APPIUM_OMIT_PEER_DEPS = '1';
|
|
259
|
-
} else {
|
|
260
|
-
process.env.NODE_PATH = _.without(nodePathParts, appiumModuleSearchRoot).join(path.delimiter);
|
|
261
|
-
}
|
|
262
|
-
}
|
|
263
|
-
|
|
264
|
-
/**
|
|
265
|
-
* Pulls the initial values of Appium settings from the given capabilities argument.
|
|
266
|
-
* Each setting item must satisfy the following format:
|
|
267
|
-
* `settings[setting_name]: setting_value`
|
|
268
|
-
* or
|
|
269
|
-
* ```
|
|
270
|
-
* settings = {
|
|
271
|
-
* setting_name1: 'setting_value1',
|
|
272
|
-
* setting_name2: 'setting_value2',
|
|
273
|
-
* }
|
|
274
|
-
* ```
|
|
275
|
-
* The capabilities argument itself gets mutated, so it does not contain parsed
|
|
276
|
-
* settings anymore to avoid further parsing issues.
|
|
277
|
-
* Check
|
|
278
|
-
* https://appium.io/docs/en/latest/guides/settings/
|
|
279
|
-
* for more details on the available settings.
|
|
280
|
-
*
|
|
281
|
-
* @param {?Object} caps - Capabilities dictionary. It is mutated if
|
|
282
|
-
* one or more settings have been pulled from it
|
|
283
|
-
* @return {Object} - An empty dictionary if the given caps contains no
|
|
284
|
-
* setting items or a dictionary containing parsed Appium setting names along with
|
|
285
|
-
* their values.
|
|
286
|
-
*/
|
|
287
|
-
export function pullSettings(caps) {
|
|
288
|
-
if (!_.isPlainObject(caps) || _.isEmpty(caps)) {
|
|
289
|
-
return {};
|
|
290
|
-
}
|
|
291
|
-
|
|
292
|
-
const result = {};
|
|
293
|
-
const singleSettings = {};
|
|
294
|
-
for (const [key, value] of _.toPairs(caps)) {
|
|
295
|
-
let match;
|
|
296
|
-
if (/^(s|appium:s)ettings$/.test(key) && _.isPlainObject(value)) {
|
|
297
|
-
Object.assign(result, value);
|
|
298
|
-
delete caps[key];
|
|
299
|
-
} else if ((match = /^(s|appium:s)ettings\[(\S+)\]$/.exec(key))) {
|
|
300
|
-
singleSettings[match[2]] = value;
|
|
301
|
-
delete caps[key];
|
|
302
|
-
}
|
|
303
|
-
}
|
|
304
|
-
if (!_.isEmpty(singleSettings)) {
|
|
305
|
-
Object.assign(result, singleSettings);
|
|
306
|
-
}
|
|
307
|
-
return result;
|
|
308
|
-
}
|
|
309
|
-
|
|
310
|
-
/**
|
|
311
|
-
* @template {CliCommand} [Cmd=ServerCommand]
|
|
312
|
-
* @template {CliExtensionSubcommand|void} [SubCmd=void]
|
|
313
|
-
* @param {Args<Cmd, SubCmd>} args
|
|
314
|
-
* @returns {args is Args<ServerCommand>}
|
|
315
|
-
*/
|
|
316
|
-
export function isServerCommandArgs(args) {
|
|
317
|
-
return args.subcommand === SERVER_SUBCOMMAND;
|
|
318
|
-
}
|
|
319
|
-
|
|
320
|
-
/**
|
|
321
|
-
* @template {CliCommand} Cmd
|
|
322
|
-
* @template {CliExtensionSubcommand|CliCommandSetupSubcommand|void} [SubCmd=void]
|
|
323
|
-
* @param {Args<Cmd, SubCmd>} args
|
|
324
|
-
* @returns {args is Args<SetupCommand>}
|
|
325
|
-
*/
|
|
326
|
-
export function isSetupCommandArgs(args) {
|
|
327
|
-
return args.subcommand === SETUP_SUBCOMMAND;
|
|
328
|
-
}
|
|
329
|
-
|
|
330
|
-
/**
|
|
331
|
-
* @template {CliCommand} [Cmd=ServerCommand]
|
|
332
|
-
* @template {CliExtensionSubcommand|void} [SubCmd=void]
|
|
333
|
-
* @param {Args<Cmd, SubCmd>} args
|
|
334
|
-
* @returns {args is Args<CliExtensionCommand, SubCmd>}
|
|
335
|
-
*/
|
|
336
|
-
export function isExtensionCommandArgs(args) {
|
|
337
|
-
return args.subcommand === DRIVER_TYPE || args.subcommand === PLUGIN_TYPE;
|
|
338
|
-
}
|
|
339
|
-
|
|
340
|
-
/**
|
|
341
|
-
* @template {CliCommand} Cmd
|
|
342
|
-
* @template {CliExtensionSubcommand} SubCmd
|
|
343
|
-
* @param {Args<Cmd, SubCmd>} args
|
|
344
|
-
* @returns {args is Args<DriverCommand, SubCmd>}
|
|
345
|
-
*/
|
|
346
|
-
export function isDriverCommandArgs(args) {
|
|
347
|
-
return args.subcommand === DRIVER_TYPE;
|
|
348
|
-
}
|
|
349
|
-
|
|
350
|
-
/**
|
|
351
|
-
* @template {CliCommand} Cmd
|
|
352
|
-
* @template {CliExtensionSubcommand} SubCmd
|
|
353
|
-
* @param {Args<Cmd, SubCmd>} args
|
|
354
|
-
* @returns {args is Args<PluginCommand, SubCmd>}
|
|
355
|
-
*/
|
|
356
|
-
export function isPluginCommandArgs(args) {
|
|
357
|
-
return args.subcommand === PLUGIN_TYPE;
|
|
358
|
-
}
|
|
359
|
-
|
|
360
|
-
/**
|
|
361
|
-
* Fetches the list of matched network interfaces of the current host.
|
|
362
|
-
*
|
|
363
|
-
* @param {4|6|null} family Either 4 to include ipv4 addresses only,
|
|
364
|
-
* 6 to include ipv6 addresses only, or null to include all of them
|
|
365
|
-
* @returns {os.NetworkInterfaceInfo[]} The list of matched interfaces
|
|
366
|
-
*/
|
|
367
|
-
export function fetchInterfaces (family = null) {
|
|
368
|
-
let familyValue = null;
|
|
369
|
-
// 'IPv4' is in Node <= 17, from 18 it's a number 4 or 6
|
|
370
|
-
if (family === 4) {
|
|
371
|
-
familyValue = [4, 'IPv4'];
|
|
372
|
-
} else if (family === 6) {
|
|
373
|
-
familyValue = [6, 'IPv6'];
|
|
374
|
-
}
|
|
375
|
-
// @ts-ignore The linter does not understand the below filter
|
|
376
|
-
return _.flatMap(_.values(os.networkInterfaces()).filter(Boolean))
|
|
377
|
-
// @ts-ignore The linter does not understand the above filter
|
|
378
|
-
.filter(({family}) => !familyValue || familyValue && familyValue.includes(family));
|
|
379
|
-
}
|
|
380
|
-
|
|
381
|
-
/**
|
|
382
|
-
* https://github.com/SheetJS/js-adler32
|
|
383
|
-
*
|
|
384
|
-
* @param {string} str
|
|
385
|
-
* @param {number?} [seed]
|
|
386
|
-
* @returns {number}
|
|
387
|
-
*/
|
|
388
|
-
export function adler32(str, seed = null) {
|
|
389
|
-
let a = 1, b = 0, L = str.length, M = 0, c = 0, d = 0;
|
|
390
|
-
if (typeof seed === 'number') {
|
|
391
|
-
a = seed & 0xFFFF;
|
|
392
|
-
b = seed >>> 16;
|
|
393
|
-
}
|
|
394
|
-
for (let i = 0; i < L;) {
|
|
395
|
-
M = Math.min(L - i, 2918);
|
|
396
|
-
while (M > 0) {
|
|
397
|
-
c = str.charCodeAt(i++);
|
|
398
|
-
if (c < 0x80) {
|
|
399
|
-
a += c;
|
|
400
|
-
} else if (c < 0x800) {
|
|
401
|
-
a += 192 | ((c >> 6) & 31);
|
|
402
|
-
b += a;
|
|
403
|
-
--M;
|
|
404
|
-
a += 128 | (c & 63);
|
|
405
|
-
} else if (c >= 0xD800 && c < 0xE000) {
|
|
406
|
-
c = (c & 1023) + 64;
|
|
407
|
-
d = str.charCodeAt(i++) & 1023;
|
|
408
|
-
a += 240 | ((c >> 8) & 7);
|
|
409
|
-
b += a;
|
|
410
|
-
--M;
|
|
411
|
-
a += 128 | ((c >> 2) & 63);
|
|
412
|
-
b += a;
|
|
413
|
-
--M;
|
|
414
|
-
a += 128 | ((d >> 6) & 15) | ((c & 3) << 4);
|
|
415
|
-
b += a;
|
|
416
|
-
--M;
|
|
417
|
-
a += 128 | (d & 63);
|
|
418
|
-
} else {
|
|
419
|
-
a += 224 | ((c >> 12) & 15);
|
|
420
|
-
b += a;
|
|
421
|
-
--M;
|
|
422
|
-
a += 128 | ((c >> 6) & 63);
|
|
423
|
-
b += a;
|
|
424
|
-
--M;
|
|
425
|
-
a += 128 | (c & 63);
|
|
426
|
-
}
|
|
427
|
-
b += a;
|
|
428
|
-
--M;
|
|
429
|
-
}
|
|
430
|
-
a = (15 * (a >>> 16) + (a & 65535));
|
|
431
|
-
b = (15 * (b >>> 16) + (b & 65535));
|
|
432
|
-
}
|
|
433
|
-
return ((b % 65521) << 16) | (a % 65521);
|
|
434
|
-
}
|
|
435
|
-
|
|
436
|
-
/**
|
|
437
|
-
* Checks if the provided address is a broadcast one.
|
|
438
|
-
*
|
|
439
|
-
* @param {string} address
|
|
440
|
-
* @returns {boolean}
|
|
441
|
-
*/
|
|
442
|
-
export function isBroadcastIp(address) {
|
|
443
|
-
return [V4_BROADCAST_IP, V6_BROADCAST_IP, `[${V6_BROADCAST_IP}]`].includes(address);
|
|
444
|
-
}
|
|
445
|
-
|
|
446
|
-
/**
|
|
447
|
-
* @typedef {import('@appium/types').StringRecord} StringRecord
|
|
448
|
-
* @typedef {import('@appium/types').BaseDriverCapConstraints} BaseDriverCapConstraints
|
|
449
|
-
*/
|
|
450
|
-
|
|
451
|
-
/**
|
|
452
|
-
* @template {Constraints} [C=BaseDriverCapConstraints]
|
|
453
|
-
* @typedef ParsedDriverCaps
|
|
454
|
-
* @property {Capabilities<C>} desiredCaps
|
|
455
|
-
* @property {W3CCapabilities<C>} processedW3CCapabilities
|
|
456
|
-
*/
|
|
457
|
-
|
|
458
|
-
/**
|
|
459
|
-
* @todo protocol is more specific
|
|
460
|
-
* @template {Constraints} [C=BaseDriverCapConstraints]
|
|
461
|
-
* @typedef InvalidCaps
|
|
462
|
-
* @property {Error} error
|
|
463
|
-
* @property {Capabilities<C>} [desiredCaps]
|
|
464
|
-
* @property {W3CCapabilities<C>} [processedW3CCapabilities]
|
|
465
|
-
*/
|
|
466
|
-
|
|
467
|
-
/**
|
|
468
|
-
* @template {Constraints} C
|
|
469
|
-
* @typedef {import('@appium/types').Capabilities<C>} Capabilities
|
|
470
|
-
*/
|
|
471
|
-
|
|
472
|
-
/**
|
|
473
|
-
* @template {Constraints} C
|
|
474
|
-
* @typedef {import('@appium/types').W3CCapabilities<C>} W3CCapabilities
|
|
475
|
-
*/
|
|
476
|
-
|
|
477
|
-
/**
|
|
478
|
-
* @template {Constraints} C
|
|
479
|
-
* @typedef {import('@appium/types').NSCapabilities<C>} NSCapabilities
|
|
480
|
-
*/
|
|
481
|
-
|
|
482
|
-
/**
|
|
483
|
-
* @template {Constraints} C
|
|
484
|
-
* @typedef {import('@appium/types').ConstraintsToCaps<C>} ConstraintsToCaps
|
|
485
|
-
*/
|
|
486
|
-
|
|
487
|
-
/**
|
|
488
|
-
* @typedef {import('@appium/types').Constraints} Constraints
|
|
489
|
-
*/
|
|
490
|
-
|
|
491
|
-
/**
|
|
492
|
-
* @typedef {import('appium/types').CliCommand} CliCommand
|
|
493
|
-
* @typedef {import('appium/types').CliExtensionSubcommand} CliExtensionSubcommand
|
|
494
|
-
* @typedef {import('appium/types').CliExtensionCommand} CliExtensionCommand
|
|
495
|
-
* @typedef {import('appium/types').CliCommandSetupSubcommand} CliCommandSetupSubcommand
|
|
496
|
-
* @typedef {import('appium/types').CliCommandServer} ServerCommand
|
|
497
|
-
* @typedef {import('appium/types').CliCommandDriver} DriverCommand
|
|
498
|
-
* @typedef {import('appium/types').CliCommandPlugin} PluginCommand
|
|
499
|
-
* @typedef {import('appium/types').CliCommandSetup} SetupCommand
|
|
500
|
-
*/
|
|
501
|
-
|
|
502
|
-
/**
|
|
503
|
-
* @template {CliCommand} [Cmd=ServerCommand]
|
|
504
|
-
* @template {CliExtensionSubcommand|CliCommandSetupSubcommand|void} [SubCmd=void]
|
|
505
|
-
* @typedef {import('appium/types').Args<Cmd, SubCmd>} Args
|
|
506
|
-
*/
|
|
507
|
-
|
|
508
|
-
/**
|
|
509
|
-
* @template {CliCommand} [Cmd=ServerCommand]
|
|
510
|
-
* @template {CliExtensionSubcommand|CliCommandSetupSubcommand|void} [SubCmd=void]
|
|
511
|
-
* @typedef {import('appium/types').ParsedArgs<Cmd, SubCmd>} ParsedArgs
|
|
512
|
-
*/
|
|
File without changes
|