appium 3.5.2 → 3.6.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/appium.d.ts +3 -4
- package/build/lib/appium.d.ts.map +1 -1
- package/build/lib/appium.js +10 -19
- package/build/lib/appium.js.map +1 -1
- package/build/lib/bidi-commands.d.ts +2 -2
- package/build/lib/bidi-commands.d.ts.map +1 -1
- package/build/lib/bidi-commands.js +4 -4
- package/build/lib/bidi-commands.js.map +1 -1
- package/build/lib/bootstrap/appium-initializer.d.ts.map +1 -1
- package/build/lib/bootstrap/appium-initializer.js +12 -16
- package/build/lib/bootstrap/appium-initializer.js.map +1 -1
- package/build/lib/bootstrap/appium-main-runner.d.ts +1 -1
- package/build/lib/bootstrap/appium-main-runner.d.ts.map +1 -1
- package/build/lib/bootstrap/appium-main-runner.js +2 -2
- package/build/lib/bootstrap/appium-main-runner.js.map +1 -1
- package/build/lib/bootstrap/config-file.d.ts +1 -1
- package/build/lib/bootstrap/config-file.d.ts.map +1 -1
- package/build/lib/bootstrap/config-file.js +13 -15
- package/build/lib/bootstrap/config-file.js.map +1 -1
- package/build/lib/bootstrap/grid-v3-register.d.ts.map +1 -1
- package/build/lib/bootstrap/grid-v3-register.js +7 -14
- package/build/lib/bootstrap/grid-v3-register.js.map +1 -1
- package/build/lib/bootstrap/init-types.d.ts +1 -1
- package/build/lib/bootstrap/init-types.d.ts.map +1 -1
- package/build/lib/bootstrap/main-helpers.d.ts +1 -1
- package/build/lib/bootstrap/main-helpers.d.ts.map +1 -1
- package/build/lib/bootstrap/main-helpers.js +5 -6
- package/build/lib/bootstrap/main-helpers.js.map +1 -1
- package/build/lib/bootstrap/node-helpers.d.ts +1 -1
- package/build/lib/bootstrap/node-helpers.d.ts.map +1 -1
- package/build/lib/bootstrap/node-helpers.js +6 -8
- package/build/lib/bootstrap/node-helpers.js.map +1 -1
- package/build/lib/bootstrap/startup-config.d.ts.map +1 -1
- package/build/lib/bootstrap/startup-config.js.map +1 -1
- package/build/lib/cli/args.d.ts +2 -4
- package/build/lib/cli/args.d.ts.map +1 -1
- package/build/lib/cli/args.js +3 -6
- package/build/lib/cli/args.js.map +1 -1
- package/build/lib/cli/driver-command.d.ts +2 -2
- package/build/lib/cli/driver-command.d.ts.map +1 -1
- package/build/lib/cli/driver-command.js +4 -7
- package/build/lib/cli/driver-command.js.map +1 -1
- package/build/lib/cli/extension-command.d.ts +3 -20
- package/build/lib/cli/extension-command.d.ts.map +1 -1
- package/build/lib/cli/extension-command.js +32 -56
- package/build/lib/cli/extension-command.js.map +1 -1
- package/build/lib/cli/extension.d.ts.map +1 -1
- package/build/lib/cli/extension.js.map +1 -1
- package/build/lib/cli/parser.d.ts.map +1 -1
- package/build/lib/cli/parser.js +10 -15
- package/build/lib/cli/parser.js.map +1 -1
- package/build/lib/cli/plugin-command.d.ts +2 -2
- package/build/lib/cli/plugin-command.d.ts.map +1 -1
- package/build/lib/cli/plugin-command.js +4 -7
- package/build/lib/cli/plugin-command.js.map +1 -1
- package/build/lib/cli/setup-command.d.ts.map +1 -1
- package/build/lib/cli/setup-command.js +2 -2
- package/build/lib/cli/setup-command.js.map +1 -1
- package/build/lib/cli/utils.d.ts.map +1 -1
- package/build/lib/cli/utils.js.map +1 -1
- package/build/lib/doctor/doctor.d.ts.map +1 -1
- package/build/lib/doctor/doctor.js +1 -4
- package/build/lib/doctor/doctor.js.map +1 -1
- package/build/lib/extension/driver-config.d.ts +1 -1
- package/build/lib/extension/driver-config.d.ts.map +1 -1
- package/build/lib/extension/driver-config.js +2 -4
- package/build/lib/extension/driver-config.js.map +1 -1
- package/build/lib/extension/extension-config.d.ts +1 -1
- package/build/lib/extension/extension-config.d.ts.map +1 -1
- package/build/lib/extension/extension-config.js +10 -10
- package/build/lib/extension/extension-config.js.map +1 -1
- package/build/lib/extension/index.d.ts.map +1 -1
- package/build/lib/extension/index.js +3 -5
- package/build/lib/extension/index.js.map +1 -1
- package/build/lib/extension/manifest-migrations.d.ts.map +1 -1
- package/build/lib/extension/manifest-migrations.js.map +1 -1
- package/build/lib/extension/manifest.d.ts.map +1 -1
- package/build/lib/extension/manifest.js +2 -2
- package/build/lib/extension/manifest.js.map +1 -1
- package/build/lib/extension/plugin-config.d.ts.map +1 -1
- package/build/lib/extension/plugin-config.js +1 -2
- package/build/lib/extension/plugin-config.js.map +1 -1
- package/build/lib/helpers/build.d.ts.map +1 -1
- package/build/lib/helpers/build.js +1 -1
- package/build/lib/helpers/build.js.map +1 -1
- package/build/lib/helpers/capability.d.ts.map +1 -1
- package/build/lib/helpers/capability.js +2 -4
- package/build/lib/helpers/capability.js.map +1 -1
- package/build/lib/helpers/network.d.ts.map +1 -1
- package/build/lib/helpers/network.js +1 -3
- package/build/lib/helpers/network.js.map +1 -1
- package/build/lib/insecure-features.d.ts +1 -1
- package/build/lib/insecure-features.d.ts.map +1 -1
- package/build/lib/insecure-features.js +2 -6
- package/build/lib/insecure-features.js.map +1 -1
- package/build/lib/inspector-commands.d.ts.map +1 -1
- package/build/lib/inspector-commands.js +6 -16
- package/build/lib/inspector-commands.js.map +1 -1
- package/build/lib/logsink.d.ts.map +1 -1
- package/build/lib/logsink.js +5 -9
- package/build/lib/logsink.js.map +1 -1
- package/build/lib/main.d.ts.map +1 -1
- package/build/lib/main.js.map +1 -1
- package/build/lib/schema/arg-spec.d.ts.map +1 -1
- package/build/lib/schema/arg-spec.js.map +1 -1
- package/build/lib/schema/cli-args-guards.d.ts +1 -1
- package/build/lib/schema/cli-args-guards.d.ts.map +1 -1
- package/build/lib/schema/cli-args-guards.js.map +1 -1
- package/build/lib/schema/cli-args.d.ts.map +1 -1
- package/build/lib/schema/cli-args.js +2 -2
- package/build/lib/schema/cli-args.js.map +1 -1
- package/build/lib/schema/cli-transformers.d.ts.map +1 -1
- package/build/lib/schema/cli-transformers.js +2 -4
- package/build/lib/schema/cli-transformers.js.map +1 -1
- package/build/lib/schema/format-errors.d.ts +1 -1
- package/build/lib/schema/format-errors.d.ts.map +1 -1
- package/build/lib/schema/format-errors.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 +2 -2
- package/build/lib/schema/index.js.map +1 -1
- package/build/lib/schema/keywords.d.ts.map +1 -1
- package/build/lib/schema/keywords.js.map +1 -1
- package/build/lib/schema/schema.d.ts +1 -1
- package/build/lib/schema/schema.d.ts.map +1 -1
- package/build/lib/schema/schema.js +5 -7
- package/build/lib/schema/schema.js.map +1 -1
- package/build/lib/utils/index.d.ts +2 -2
- package/build/lib/utils/index.d.ts.map +1 -1
- package/build/lib/utils/index.js +8 -8
- package/build/lib/utils/index.js.map +1 -1
- package/build/lib/utils/is-package-changed.d.ts.map +1 -1
- package/build/lib/utils/is-package-changed.js +2 -4
- package/build/lib/utils/is-package-changed.js.map +1 -1
- package/build/lib/utils/object.d.ts.map +1 -1
- package/build/lib/utils/object.js +1 -3
- package/build/lib/utils/object.js.map +1 -1
- package/build/lib/utils/package-changed.d.ts +0 -1
- package/build/lib/utils/package-changed.d.ts.map +1 -1
- package/build/lib/utils/package-changed.js +4 -3
- package/build/lib/utils/package-changed.js.map +1 -1
- package/build/lib/utils/package-json.d.ts.map +1 -1
- package/build/lib/utils/package-json.js.map +1 -1
- package/build/lib/utils/resolve-from.d.ts.map +1 -1
- package/build/lib/utils/resolve-from.js.map +1 -1
- package/build/types/cli.d.ts.map +1 -1
- package/build/types/index.d.ts +2 -2
- package/build/types/index.d.ts.map +1 -1
- package/build/types/index.js +1 -1
- package/build/types/index.js.map +1 -1
- package/build/types/manifest/base.d.ts.map +1 -1
- package/build/types/manifest/v3.d.ts.map +1 -1
- package/build/types/manifest/v4.d.ts.map +1 -1
- package/lib/appium.ts +46 -94
- package/lib/bidi-commands.ts +28 -63
- package/lib/bootstrap/appium-initializer.ts +26 -38
- package/lib/bootstrap/appium-main-runner.ts +14 -32
- package/lib/bootstrap/config-file.ts +19 -37
- package/lib/bootstrap/grid-v3-register.ts +12 -38
- package/lib/bootstrap/init-types.ts +3 -5
- package/lib/bootstrap/main-helpers.ts +15 -25
- package/lib/bootstrap/node-helpers.ts +11 -22
- package/lib/bootstrap/startup-config.ts +13 -18
- package/lib/cli/args.ts +9 -18
- package/lib/cli/driver-command.ts +6 -13
- package/lib/cli/extension-command.ts +55 -156
- package/lib/cli/extension.ts +6 -5
- package/lib/cli/parser.ts +23 -29
- package/lib/cli/plugin-command.ts +7 -17
- package/lib/cli/setup-command.ts +10 -28
- package/lib/cli/utils.ts +1 -5
- package/lib/doctor/doctor.ts +1 -4
- package/lib/extension/driver-config.ts +5 -15
- package/lib/extension/extension-config.ts +36 -80
- package/lib/extension/index.ts +16 -31
- package/lib/extension/manifest-migrations.ts +1 -0
- package/lib/extension/manifest.ts +9 -19
- package/lib/extension/plugin-config.ts +5 -12
- package/lib/helpers/build.ts +4 -6
- package/lib/helpers/capability.ts +6 -17
- package/lib/helpers/network.ts +2 -6
- package/lib/insecure-features.ts +7 -22
- package/lib/inspector-commands.ts +28 -68
- package/lib/logsink.ts +11 -25
- package/lib/main.ts +2 -7
- package/lib/schema/arg-spec.ts +1 -0
- package/lib/schema/cli-args-guards.ts +7 -14
- package/lib/schema/cli-args.ts +10 -17
- package/lib/schema/cli-transformers.ts +5 -10
- package/lib/schema/format-errors.ts +2 -1
- package/lib/schema/index.ts +2 -2
- package/lib/schema/keywords.ts +2 -2
- package/lib/schema/schema.ts +14 -33
- package/lib/utils/index.ts +3 -3
- package/lib/utils/is-package-changed.ts +4 -7
- package/lib/utils/object.ts +4 -13
- package/lib/utils/package-changed.ts +7 -9
- package/lib/utils/package-json.ts +2 -3
- package/lib/utils/resolve-from.ts +1 -4
- package/package.json +32 -31
- package/scripts/autoinstall-extensions.js +1 -4
- package/tsconfig.json +7 -11
- package/types/cli.ts +2 -3
- package/types/index.ts +2 -2
- package/types/manifest/base.ts +3 -10
- package/types/manifest/v3.ts +3 -10
- package/types/manifest/v4.ts +3 -10
- package/LICENSE +0 -201
package/lib/appium.ts
CHANGED
|
@@ -1,52 +1,48 @@
|
|
|
1
|
-
import
|
|
1
|
+
import {
|
|
2
|
+
AppiumIpc,
|
|
3
|
+
BaseDriver,
|
|
4
|
+
CREATE_SESSION_COMMAND,
|
|
5
|
+
DELETE_SESSION_COMMAND,
|
|
6
|
+
DriverCore,
|
|
7
|
+
errors,
|
|
8
|
+
type ExtensionCore,
|
|
9
|
+
generateDriverLogPrefix,
|
|
10
|
+
GET_STATUS_COMMAND,
|
|
11
|
+
isSessionCommand,
|
|
12
|
+
isW3cCaps,
|
|
13
|
+
LIST_DRIVER_COMMANDS_COMMAND,
|
|
14
|
+
LIST_DRIVER_EXTENSIONS_COMMAND,
|
|
15
|
+
promoteAppiumOptions,
|
|
16
|
+
promoteAppiumOptionsForObject,
|
|
17
|
+
PROTOCOLS,
|
|
18
|
+
} from '@appium/base-driver';
|
|
19
|
+
import {util} from '@appium/support';
|
|
2
20
|
import type {
|
|
3
21
|
AppiumServer,
|
|
4
22
|
DriverCaps,
|
|
5
23
|
DriverData,
|
|
6
24
|
DriverOpts,
|
|
7
25
|
ExternalDriver,
|
|
26
|
+
IAppiumIpc,
|
|
8
27
|
Plugin,
|
|
9
28
|
PluginClass,
|
|
10
29
|
PluginCommand,
|
|
11
30
|
Protocol,
|
|
12
31
|
RouteMatcher,
|
|
13
|
-
IAppiumIpc,
|
|
14
32
|
StringRecord,
|
|
15
33
|
TimestampedMultiSessionData,
|
|
16
34
|
W3CDriverCaps,
|
|
17
35
|
} from '@appium/types';
|
|
18
|
-
import
|
|
19
|
-
|
|
20
|
-
DriverCore,
|
|
21
|
-
type ExtensionCore,
|
|
22
|
-
errors,
|
|
23
|
-
isSessionCommand,
|
|
24
|
-
PROTOCOLS,
|
|
25
|
-
CREATE_SESSION_COMMAND,
|
|
26
|
-
DELETE_SESSION_COMMAND,
|
|
27
|
-
GET_STATUS_COMMAND,
|
|
28
|
-
LIST_DRIVER_COMMANDS_COMMAND,
|
|
29
|
-
LIST_DRIVER_EXTENSIONS_COMMAND,
|
|
30
|
-
promoteAppiumOptions,
|
|
31
|
-
promoteAppiumOptionsForObject,
|
|
32
|
-
generateDriverLogPrefix,
|
|
33
|
-
isW3cCaps,
|
|
34
|
-
} from '@appium/base-driver';
|
|
35
|
-
import {APPIUM_VER, getBuildInfo, updateBuildInfo} from './helpers/build';
|
|
36
|
-
import {
|
|
37
|
-
makeNonW3cCapsError,
|
|
38
|
-
parseCapsForInnerDriver,
|
|
39
|
-
pullSettings,
|
|
40
|
-
type ParsedDriverCaps,
|
|
41
|
-
} from './helpers/capability';
|
|
42
|
-
import {util} from '@appium/support';
|
|
43
|
-
import {getDefaultsForExtension} from './schema';
|
|
44
|
-
import {DRIVER_TYPE, BIDI_BASE_PATH, SESSION_DISCOVERY_FEATURE} from './constants';
|
|
36
|
+
import type WebSocket from 'ws';
|
|
37
|
+
|
|
45
38
|
import * as bidiCommands from './bidi-commands';
|
|
39
|
+
import {BIDI_BASE_PATH, DRIVER_TYPE, SESSION_DISCOVERY_FEATURE} from './constants';
|
|
40
|
+
import type {DriverConfig} from './extension/driver-config';
|
|
41
|
+
import {APPIUM_VER, getBuildInfo, updateBuildInfo} from './helpers/build';
|
|
42
|
+
import {makeNonW3cCapsError, parseCapsForInnerDriver, type ParsedDriverCaps, pullSettings} from './helpers/capability';
|
|
46
43
|
import * as insecureFeatures from './insecure-features';
|
|
47
44
|
import * as inspectorCommands from './inspector-commands';
|
|
48
|
-
import
|
|
49
|
-
import {AppiumIpc} from '@appium/base-driver';
|
|
45
|
+
import {getDefaultsForExtension} from './schema';
|
|
50
46
|
import {compact, pickBy, pull} from './utils';
|
|
51
47
|
|
|
52
48
|
const desiredCapabilityConstraints = {
|
|
@@ -218,11 +214,7 @@ export class AppiumDriver extends DriverCore<AppiumDriverConstraints> {
|
|
|
218
214
|
}
|
|
219
215
|
|
|
220
216
|
/** Logs BaseDriver version lines when starting a new inner-driver session. */
|
|
221
|
-
printNewSessionAnnouncement(
|
|
222
|
-
driverName: string,
|
|
223
|
-
driverVersion?: string,
|
|
224
|
-
driverBaseVersion?: string,
|
|
225
|
-
): void {
|
|
217
|
+
printNewSessionAnnouncement(driverName: string, driverVersion?: string, driverBaseVersion?: string): void {
|
|
226
218
|
this.log.info(
|
|
227
219
|
driverVersion
|
|
228
220
|
? `Appium v${APPIUM_VER} creating new ${driverName} (v${driverVersion}) session`
|
|
@@ -281,9 +273,7 @@ export class AppiumDriver extends DriverCore<AppiumDriverConstraints> {
|
|
|
281
273
|
): Promise<SessionHandlerCreateResult> {
|
|
282
274
|
const defaultCapabilities = structuredClone(this.args.defaultCapabilities);
|
|
283
275
|
const defaultSettings = pullSettings((defaultCapabilities ?? {}) as StringRecord);
|
|
284
|
-
const w3cCapabilities = structuredClone(
|
|
285
|
-
[w3cCapabilities3, w3cCapabilities2, w3cCapabilities1].find(isW3cCaps),
|
|
286
|
-
);
|
|
276
|
+
const w3cCapabilities = structuredClone([w3cCapabilities3, w3cCapabilities2, w3cCapabilities1].find(isW3cCaps));
|
|
287
277
|
if (!w3cCapabilities) {
|
|
288
278
|
throw makeNonW3cCapsError();
|
|
289
279
|
}
|
|
@@ -309,8 +299,7 @@ export class AppiumDriver extends DriverCore<AppiumDriverConstraints> {
|
|
|
309
299
|
if ('error' in parsedCaps && parsedCaps.error) {
|
|
310
300
|
throw parsedCaps.error;
|
|
311
301
|
}
|
|
312
|
-
const {desiredCaps, processedW3CCapabilities} =
|
|
313
|
-
parsedCaps as ParsedDriverCaps<AppiumDriverConstraints>;
|
|
302
|
+
const {desiredCaps, processedW3CCapabilities} = parsedCaps as ParsedDriverCaps<AppiumDriverConstraints>;
|
|
314
303
|
|
|
315
304
|
const {
|
|
316
305
|
driver: InnerDriver,
|
|
@@ -360,9 +349,7 @@ export class AppiumDriver extends DriverCore<AppiumDriverConstraints> {
|
|
|
360
349
|
throw new errors.SessionNotCreatedError(msg);
|
|
361
350
|
}
|
|
362
351
|
this.pendingDrivers[InnerDriver.name] = this.pendingDrivers[InnerDriver.name] || [];
|
|
363
|
-
otherPendingDriversData = compact(
|
|
364
|
-
this.pendingDrivers[InnerDriver.name].map((drv) => drv.driverData),
|
|
365
|
-
);
|
|
352
|
+
otherPendingDriversData = compact(this.pendingDrivers[InnerDriver.name].map((drv) => drv.driverData));
|
|
366
353
|
this.pendingDrivers[InnerDriver.name].push(driverInstance);
|
|
367
354
|
|
|
368
355
|
try {
|
|
@@ -401,8 +388,7 @@ export class AppiumDriver extends DriverCore<AppiumDriverConstraints> {
|
|
|
401
388
|
// apply initial values to Appium settings (if provided)
|
|
402
389
|
if (driverInstance.isW3CProtocol() && !util.isEmpty(w3cSettings)) {
|
|
403
390
|
this.log.info(
|
|
404
|
-
`Applying the initial values to Appium settings parsed from W3C caps: ` +
|
|
405
|
-
JSON.stringify(w3cSettings),
|
|
391
|
+
`Applying the initial values to Appium settings parsed from W3C caps: ` + JSON.stringify(w3cSettings),
|
|
406
392
|
);
|
|
407
393
|
await driverInstance.updateSettings(w3cSettings);
|
|
408
394
|
}
|
|
@@ -448,15 +434,11 @@ export class AppiumDriver extends DriverCore<AppiumDriverConstraints> {
|
|
|
448
434
|
if (this.sessionPlugins[innerSessionId]) {
|
|
449
435
|
for (const plugin of this.sessionPlugins[innerSessionId]) {
|
|
450
436
|
if (typeof plugin.onUnexpectedShutdown === 'function') {
|
|
451
|
-
this.log.debug(
|
|
452
|
-
`Plugin ${plugin.name} defines an unexpected shutdown handler; calling it now`,
|
|
453
|
-
);
|
|
437
|
+
this.log.debug(`Plugin ${plugin.name} defines an unexpected shutdown handler; calling it now`);
|
|
454
438
|
try {
|
|
455
439
|
await plugin.onUnexpectedShutdown(driver, cause);
|
|
456
440
|
} catch (e) {
|
|
457
|
-
this.log.warn(
|
|
458
|
-
`Got an error when running plugin ${plugin.name} shutdown handler: ${e}`,
|
|
459
|
-
);
|
|
441
|
+
this.log.warn(`Got an error when running plugin ${plugin.name} shutdown handler: ${e}`);
|
|
460
442
|
}
|
|
461
443
|
} else {
|
|
462
444
|
this.log.debug(`Plugin ${plugin.name} does not define an unexpected shutdown handler`);
|
|
@@ -492,8 +474,7 @@ export class AppiumDriver extends DriverCore<AppiumDriverConstraints> {
|
|
|
492
474
|
for (const datum of data) {
|
|
493
475
|
if (!datum) {
|
|
494
476
|
throw new Error(
|
|
495
|
-
`Problem getting session data for driver type ` +
|
|
496
|
-
`${InnerDriver.name}; does it implement 'get driverData'?`,
|
|
477
|
+
`Problem getting session data for driver type ` + `${InnerDriver.name}; does it implement 'get driverData'?`,
|
|
497
478
|
);
|
|
498
479
|
}
|
|
499
480
|
}
|
|
@@ -512,9 +493,7 @@ export class AppiumDriver extends DriverCore<AppiumDriverConstraints> {
|
|
|
512
493
|
if (this.sessions[sessionId]) {
|
|
513
494
|
const curConstructorName = this.sessions[sessionId].constructor.name;
|
|
514
495
|
otherSessionsData = Object.entries(this.sessions)
|
|
515
|
-
.filter(
|
|
516
|
-
([key, value]) => value.constructor.name === curConstructorName && key !== sessionId,
|
|
517
|
-
)
|
|
496
|
+
.filter(([key, value]) => value.constructor.name === curConstructorName && key !== sessionId)
|
|
518
497
|
.map(([, value]) => value.driverData);
|
|
519
498
|
dstSession = this.sessions[sessionId];
|
|
520
499
|
protocol = dstSession.protocol;
|
|
@@ -560,9 +539,7 @@ export class AppiumDriver extends DriverCore<AppiumDriverConstraints> {
|
|
|
560
539
|
const {force = false, reason} = opts;
|
|
561
540
|
this.log.debug(`Cleaning up ${util.pluralize('active session', sessionsCount, true)}`);
|
|
562
541
|
const cleanupPromises = force
|
|
563
|
-
? Object.values(this.sessions).map((drv) =>
|
|
564
|
-
drv.startUnexpectedShutdown(reason ? new Error(reason) : undefined),
|
|
565
|
-
)
|
|
542
|
+
? Object.values(this.sessions).map((drv) => drv.startUnexpectedShutdown(reason ? new Error(reason) : undefined))
|
|
566
543
|
: Object.keys(this.sessions).map((id) => this.deleteSession(id));
|
|
567
544
|
for (const cleanupPromise of cleanupPromises) {
|
|
568
545
|
try {
|
|
@@ -587,9 +564,7 @@ export class AppiumDriver extends DriverCore<AppiumDriverConstraints> {
|
|
|
587
564
|
if (!driver) {
|
|
588
565
|
return [];
|
|
589
566
|
}
|
|
590
|
-
return (this.sessionPlugins[sessionId] = this.createPluginInstances(
|
|
591
|
-
generateDriverLogPrefix(driver),
|
|
592
|
-
));
|
|
567
|
+
return (this.sessionPlugins[sessionId] = this.createPluginInstances(generateDriverLogPrefix(driver)));
|
|
593
568
|
}
|
|
594
569
|
|
|
595
570
|
if (util.isEmpty(this.sessionlessPlugins)) {
|
|
@@ -682,9 +657,7 @@ export class AppiumDriver extends DriverCore<AppiumDriverConstraints> {
|
|
|
682
657
|
// driver's executeCommand method will be called, which means we can't guarantee that the
|
|
683
658
|
// newCommandTimeout will be cleared. So we do it here as well.
|
|
684
659
|
if (plugins.length && dstSession) {
|
|
685
|
-
this.log.debug(
|
|
686
|
-
'Clearing new command timeout pre-emptively since plugin(s) will handle this command',
|
|
687
|
-
);
|
|
660
|
+
this.log.debug('Clearing new command timeout pre-emptively since plugin(s) will handle this command');
|
|
688
661
|
await dstSession.clearNewCommandTimeout();
|
|
689
662
|
}
|
|
690
663
|
|
|
@@ -719,11 +692,7 @@ export class AppiumDriver extends DriverCore<AppiumDriverConstraints> {
|
|
|
719
692
|
if (!dstSession?.proxyCommand) {
|
|
720
693
|
throw new NoDriverProxyCommandError();
|
|
721
694
|
}
|
|
722
|
-
return await dstSession.proxyCommand(
|
|
723
|
-
reqForProxy.originalUrl,
|
|
724
|
-
reqForProxy.method,
|
|
725
|
-
reqForProxy.body,
|
|
726
|
-
);
|
|
695
|
+
return await dstSession.proxyCommand(reqForProxy.originalUrl, reqForProxy.method, reqForProxy.body);
|
|
727
696
|
}
|
|
728
697
|
|
|
729
698
|
if (isGetStatus) {
|
|
@@ -760,15 +729,9 @@ export class AppiumDriver extends DriverCore<AppiumDriverConstraints> {
|
|
|
760
729
|
// if we had plugins, and if they did not ultimately call the default handler, this means our
|
|
761
730
|
// new command timeout was not restarted by the default handler's executeCommand call, so
|
|
762
731
|
// restart it here using the same logic as in BaseDriver's executeCommand
|
|
763
|
-
if (
|
|
764
|
-
dstSession &&
|
|
765
|
-
!cmdHandledBy.default &&
|
|
766
|
-
dstSession.isCommandsQueueEnabled &&
|
|
767
|
-
cmd !== DELETE_SESSION_COMMAND
|
|
768
|
-
) {
|
|
732
|
+
if (dstSession && !cmdHandledBy.default && dstSession.isCommandsQueueEnabled && cmd !== DELETE_SESSION_COMMAND) {
|
|
769
733
|
this.log.debug(
|
|
770
|
-
'Restarting new command timeout via umbrella driver since plugin did not ' +
|
|
771
|
-
'allow default handler to execute',
|
|
734
|
+
'Restarting new command timeout via umbrella driver since plugin did not ' + 'allow default handler to execute',
|
|
772
735
|
);
|
|
773
736
|
await dstSession.startNewCommandTimeout();
|
|
774
737
|
}
|
|
@@ -786,9 +749,7 @@ export class AppiumDriver extends DriverCore<AppiumDriverConstraints> {
|
|
|
786
749
|
const promoted = this.sessionPlugins[newSessionId] as (Plugin & ExtensionCore)[];
|
|
787
750
|
for (const p of promoted) {
|
|
788
751
|
if (typeof p.updateLogPrefix === 'function') {
|
|
789
|
-
p.updateLogPrefix(
|
|
790
|
-
`${generateDriverLogPrefix(p)} <${generateDriverLogPrefix(this.sessions[newSessionId])}>`,
|
|
791
|
-
);
|
|
752
|
+
p.updateLogPrefix(`${generateDriverLogPrefix(p)} <${generateDriverLogPrefix(this.sessions[newSessionId])}>`);
|
|
792
753
|
}
|
|
793
754
|
// we also want to assign the IPC channel for this session to the plugins
|
|
794
755
|
const extPlugin = p as unknown as IpcAssignable;
|
|
@@ -837,12 +798,7 @@ export class AppiumDriver extends DriverCore<AppiumDriverConstraints> {
|
|
|
837
798
|
const cmdHandler = (plugin as Plugin & Record<string, unknown>)[cmd];
|
|
838
799
|
if (typeof cmdHandler === 'function') {
|
|
839
800
|
// Command methods must run with plugin as `this` (detached property access drops binding).
|
|
840
|
-
return await (cmdHandler as PluginCommand).call(
|
|
841
|
-
plugin,
|
|
842
|
-
_next,
|
|
843
|
-
driver as ExternalDriver,
|
|
844
|
-
...args,
|
|
845
|
-
);
|
|
801
|
+
return await (cmdHandler as PluginCommand).call(plugin, _next, driver as ExternalDriver, ...args);
|
|
846
802
|
}
|
|
847
803
|
if (typeof plugin.handle !== 'function') {
|
|
848
804
|
throw new Error(`Plugin ${plugin.name} cannot handle command '${cmd}'`);
|
|
@@ -922,9 +878,7 @@ export class AppiumDriver extends DriverCore<AppiumDriverConstraints> {
|
|
|
922
878
|
/** URL patterns the session driver does not want proxied; empty if no session or no list. */
|
|
923
879
|
override getProxyAvoidList(sessionId: string): RouteMatcher[] {
|
|
924
880
|
const dstSession = this.sessions[sessionId];
|
|
925
|
-
return typeof dstSession?.getProxyAvoidList === 'function'
|
|
926
|
-
? dstSession.getProxyAvoidList()
|
|
927
|
-
: [];
|
|
881
|
+
return typeof dstSession?.getProxyAvoidList === 'function' ? dstSession.getProxyAvoidList() : [];
|
|
928
882
|
}
|
|
929
883
|
|
|
930
884
|
/** Whether the session driver supports proxying for this session. */
|
|
@@ -961,8 +915,6 @@ export class NoDriverProxyCommandError extends Error {
|
|
|
961
915
|
function isAppiumDriverCommand(cmd: string): boolean {
|
|
962
916
|
return (
|
|
963
917
|
!isSessionCommand(cmd) ||
|
|
964
|
-
[DELETE_SESSION_COMMAND, LIST_DRIVER_COMMANDS_COMMAND, LIST_DRIVER_EXTENSIONS_COMMAND].includes(
|
|
965
|
-
cmd,
|
|
966
|
-
)
|
|
918
|
+
[DELETE_SESSION_COMMAND, LIST_DRIVER_COMMANDS_COMMAND, LIST_DRIVER_EXTENSIONS_COMMAND].includes(cmd)
|
|
967
919
|
);
|
|
968
920
|
}
|
package/lib/bidi-commands.ts
CHANGED
|
@@ -1,22 +1,24 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type {IncomingMessage} from 'node:http';
|
|
2
|
+
import os from 'node:os';
|
|
2
3
|
import {promisify} from 'node:util';
|
|
3
|
-
|
|
4
|
+
|
|
4
5
|
import type {ExtensionCore} from '@appium/base-driver';
|
|
5
6
|
import {errors} from '@appium/base-driver';
|
|
6
|
-
import {
|
|
7
|
-
import WebSocket from 'ws';
|
|
8
|
-
import os from 'node:os';
|
|
9
|
-
import {isBroadcastIp, fetchInterfaces, V4_BROADCAST_IP} from './helpers/network';
|
|
10
|
-
import type {IncomingMessage} from 'node:http';
|
|
11
|
-
import type {AppiumDriver} from './appium';
|
|
7
|
+
import {util} from '@appium/support';
|
|
12
8
|
import type {
|
|
9
|
+
BiDiResultData,
|
|
13
10
|
ErrorBiDiCommandResponse,
|
|
14
|
-
SuccessBiDiCommandResponse,
|
|
15
11
|
ExternalDriver,
|
|
16
|
-
StringRecord,
|
|
17
12
|
Plugin,
|
|
18
|
-
|
|
13
|
+
StringRecord,
|
|
14
|
+
SuccessBiDiCommandResponse,
|
|
19
15
|
} from '@appium/types';
|
|
16
|
+
import WebSocket from 'ws';
|
|
17
|
+
|
|
18
|
+
import type {AppiumDriver} from './appium';
|
|
19
|
+
import {BIDI_BASE_PATH, BIDI_EVENT_NAME} from './constants';
|
|
20
|
+
import {fetchInterfaces, isBroadcastIp, V4_BROADCAST_IP} from './helpers/network';
|
|
21
|
+
import {capitalize} from './utils';
|
|
20
22
|
|
|
21
23
|
type ExtensionPlugin = Plugin & ExtensionCore;
|
|
22
24
|
type AnyDriver = ExternalDriver | AppiumDriver;
|
|
@@ -50,9 +52,7 @@ export function determineBiDiHost(address: string): string {
|
|
|
50
52
|
return address;
|
|
51
53
|
}
|
|
52
54
|
|
|
53
|
-
const nonLocalInterfaces = fetchInterfaces(address === V4_BROADCAST_IP ? 4 : 6).filter(
|
|
54
|
-
(iface) => !iface.internal,
|
|
55
|
-
);
|
|
55
|
+
const nonLocalInterfaces = fetchInterfaces(address === V4_BROADCAST_IP ? 4 : 6).filter((iface) => !iface.internal);
|
|
56
56
|
return nonLocalInterfaces.length === 1 ? nonLocalInterfaces[0].address : os.hostname();
|
|
57
57
|
}
|
|
58
58
|
|
|
@@ -64,20 +64,14 @@ export function determineBiDiHost(address: string): string {
|
|
|
64
64
|
export function onBidiConnection(this: AppiumDriver, ws: WebSocket, req: IncomingMessage): void {
|
|
65
65
|
try {
|
|
66
66
|
const initBiDiSocketFunc: OmitThisParameter<typeof initBidiSocket> = initBidiSocket.bind(this);
|
|
67
|
-
const {bidiHandlerDriver, bidiHandlerPlugins, proxyClient, send, sendToProxy, logSocketErr} =
|
|
68
|
-
|
|
67
|
+
const {bidiHandlerDriver, bidiHandlerPlugins, proxyClient, send, sendToProxy, logSocketErr} = initBiDiSocketFunc(
|
|
68
|
+
ws,
|
|
69
|
+
req,
|
|
70
|
+
);
|
|
69
71
|
|
|
70
72
|
const initBidiSocketHandlersFunc: OmitThisParameter<typeof initBidiSocketHandlers> =
|
|
71
73
|
initBidiSocketHandlers.bind(this);
|
|
72
|
-
initBidiSocketHandlersFunc(
|
|
73
|
-
ws,
|
|
74
|
-
proxyClient,
|
|
75
|
-
send,
|
|
76
|
-
sendToProxy,
|
|
77
|
-
bidiHandlerDriver,
|
|
78
|
-
bidiHandlerPlugins,
|
|
79
|
-
logSocketErr,
|
|
80
|
-
);
|
|
74
|
+
initBidiSocketHandlersFunc(ws, proxyClient, send, sendToProxy, bidiHandlerDriver, bidiHandlerPlugins, logSocketErr);
|
|
81
75
|
if (proxyClient) {
|
|
82
76
|
const initBidiProxyHandlersFunc: OmitThisParameter<typeof initBidiProxyHandlers> =
|
|
83
77
|
initBidiProxyHandlers.bind(bidiHandlerDriver);
|
|
@@ -116,27 +110,16 @@ export async function onBidiMessage(
|
|
|
116
110
|
({id, method, params} = JSON.parse(data.toString('utf8')));
|
|
117
111
|
} catch (err) {
|
|
118
112
|
const message = err instanceof Error ? err.message : String(err);
|
|
119
|
-
throw new errors.InvalidArgumentError(
|
|
120
|
-
`Could not parse Bidi command '${dataTruncated}': ${message}`,
|
|
121
|
-
);
|
|
113
|
+
throw new errors.InvalidArgumentError(`Could not parse Bidi command '${dataTruncated}': ${message}`);
|
|
122
114
|
}
|
|
123
115
|
driverLog.info(`--> BIDI message #${id}`);
|
|
124
116
|
if (!method) {
|
|
125
|
-
throw new errors.InvalidArgumentError(
|
|
126
|
-
`Missing method for BiDi operation in '${dataTruncated}'`,
|
|
127
|
-
);
|
|
117
|
+
throw new errors.InvalidArgumentError(`Missing method for BiDi operation in '${dataTruncated}'`);
|
|
128
118
|
}
|
|
129
119
|
if (!params) {
|
|
130
|
-
throw new errors.InvalidArgumentError(
|
|
131
|
-
`Missing params for BiDi operation in '${dataTruncated}`,
|
|
132
|
-
);
|
|
120
|
+
throw new errors.InvalidArgumentError(`Missing params for BiDi operation in '${dataTruncated}`);
|
|
133
121
|
}
|
|
134
|
-
const executeWrappedCommand = wrapCommandWithPlugins(
|
|
135
|
-
driver as ExtensionCore,
|
|
136
|
-
plugins,
|
|
137
|
-
method,
|
|
138
|
-
params,
|
|
139
|
-
);
|
|
122
|
+
const executeWrappedCommand = wrapCommandWithPlugins(driver as ExtensionCore, plugins, method, params);
|
|
140
123
|
const result = await executeWrappedCommand();
|
|
141
124
|
resMessage = {
|
|
142
125
|
id,
|
|
@@ -150,9 +133,7 @@ export async function onBidiMessage(
|
|
|
150
133
|
'bidiErrObject' in err &&
|
|
151
134
|
typeof (err as {bidiErrObject: unknown}).bidiErrObject === 'function'
|
|
152
135
|
) {
|
|
153
|
-
resMessage = (
|
|
154
|
-
err as {bidiErrObject: (msgId: number) => ErrorBiDiCommandResponse}
|
|
155
|
-
).bidiErrObject(id);
|
|
136
|
+
resMessage = (err as {bidiErrObject: (msgId: number) => ErrorBiDiCommandResponse}).bidiErrObject(id);
|
|
156
137
|
} else {
|
|
157
138
|
resMessage = {
|
|
158
139
|
id,
|
|
@@ -229,11 +210,7 @@ function wrapCommandWithPlugins(
|
|
|
229
210
|
* @param ws The websocket connection object
|
|
230
211
|
* @param req The connection pathname, which might include the session id
|
|
231
212
|
*/
|
|
232
|
-
function initBidiSocket(
|
|
233
|
-
this: AppiumDriver,
|
|
234
|
-
ws: WebSocket,
|
|
235
|
-
req: IncomingMessage,
|
|
236
|
-
): InitBiDiSocketResult {
|
|
213
|
+
function initBidiSocket(this: AppiumDriver, ws: WebSocket, req: IncomingMessage): InitBiDiSocketResult {
|
|
237
214
|
const pathname = req.url;
|
|
238
215
|
if (!pathname) {
|
|
239
216
|
throw new Error('Invalid connection request: pathname missing from request');
|
|
@@ -315,9 +292,7 @@ function initBidiSocket(
|
|
|
315
292
|
// 1. Make it async-await friendly
|
|
316
293
|
// 2. Do some logging if there's a send error
|
|
317
294
|
const sendFactory = (socket: WebSocket) => {
|
|
318
|
-
const socketSend = promisify(socket.send.bind(socket)) as (
|
|
319
|
-
data: string | Buffer,
|
|
320
|
-
) => Promise<void>;
|
|
295
|
+
const socketSend = promisify(socket.send.bind(socket)) as (data: string | Buffer) => Promise<void>;
|
|
321
296
|
return async (data: string | Buffer) => {
|
|
322
297
|
try {
|
|
323
298
|
await assertIsOpen(socket);
|
|
@@ -347,12 +322,7 @@ function initBidiSocket(
|
|
|
347
322
|
* @param send - a method used to send data to the
|
|
348
323
|
* client
|
|
349
324
|
*/
|
|
350
|
-
function initBidiProxyHandlers(
|
|
351
|
-
this: AnyDriver,
|
|
352
|
-
proxyClient: WebSocket,
|
|
353
|
-
ws: WebSocket,
|
|
354
|
-
send: SendData,
|
|
355
|
-
): void {
|
|
325
|
+
function initBidiProxyHandlers(this: AnyDriver, proxyClient: WebSocket, ws: WebSocket, send: SendData): void {
|
|
356
326
|
// Set up handlers for events that might come from the upstream bidi socket connection if
|
|
357
327
|
// we're in proxy mode
|
|
358
328
|
const driverLog = this.log;
|
|
@@ -557,12 +527,7 @@ async function assertIsOpen(ws: WebSocket, timeoutMs: number = 5000): Promise<We
|
|
|
557
527
|
try {
|
|
558
528
|
await new Promise((resolve, reject) => {
|
|
559
529
|
setTimeout(
|
|
560
|
-
() =>
|
|
561
|
-
reject(
|
|
562
|
-
new Error(
|
|
563
|
-
`The BiDi web socket at ${ws.url} did not ` + `open after ${timeoutMs}ms timeout`,
|
|
564
|
-
),
|
|
565
|
-
),
|
|
530
|
+
() => reject(new Error(`The BiDi web socket at ${ws.url} did not ` + `open after ${timeoutMs}ms timeout`)),
|
|
566
531
|
timeoutMs,
|
|
567
532
|
);
|
|
568
533
|
ws.once('error', reject);
|
|
@@ -1,19 +1,23 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {log as logger} from '../logger';
|
|
3
|
-
import {util, env} from '@appium/support';
|
|
1
|
+
import {env, util} from '@appium/support';
|
|
4
2
|
import type {DriverOpts} from '@appium/types';
|
|
5
|
-
import {
|
|
3
|
+
import type {
|
|
4
|
+
Args,
|
|
5
|
+
CliCommand,
|
|
6
|
+
CliCommandServer,
|
|
7
|
+
CliCommandSetupSubcommand,
|
|
8
|
+
CliExtensionSubcommand,
|
|
9
|
+
ParsedArgs,
|
|
10
|
+
} from 'appium/types';
|
|
11
|
+
|
|
6
12
|
import {AppiumDriver, type AppiumDriverConstraints} from '../appium';
|
|
7
13
|
import {runExtensionCommand} from '../cli/extension';
|
|
14
|
+
import {injectAppiumSymlinks} from '../cli/extension-command';
|
|
15
|
+
import {ArgParser, getParser} from '../cli/parser';
|
|
8
16
|
import {runSetupCommand} from '../cli/setup-command';
|
|
9
|
-
import {getParser, ArgParser} from '../cli/parser';
|
|
10
|
-
import {readConfigFile} from './config-file';
|
|
11
|
-
import {getNonDefaultServerArgs, showConfig} from './startup-config';
|
|
12
|
-
import {adjustNodePath, requireDir, showDebugInfo} from './node-helpers';
|
|
13
|
-
import {loadExtensions, type ExtensionConfigs} from '../extension';
|
|
14
17
|
import {SERVER_SUBCOMMAND} from '../constants';
|
|
15
|
-
import {
|
|
16
|
-
import {
|
|
18
|
+
import {type ExtensionConfigs, loadExtensions} from '../extension';
|
|
19
|
+
import {log as logger} from '../logger';
|
|
20
|
+
import {init as logsinkInit} from '../logsink';
|
|
17
21
|
import {
|
|
18
22
|
isDriverCommandArgs,
|
|
19
23
|
isExtensionCommandArgs,
|
|
@@ -21,16 +25,13 @@ import {
|
|
|
21
25
|
isServerCommandArgs,
|
|
22
26
|
isSetupCommandArgs,
|
|
23
27
|
} from '../schema/cli-args-guards';
|
|
24
|
-
import
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
CliCommandServer,
|
|
28
|
-
CliCommandSetupSubcommand,
|
|
29
|
-
CliExtensionSubcommand,
|
|
30
|
-
ParsedArgs,
|
|
31
|
-
} from 'appium/types';
|
|
32
|
-
import {determineAppiumHomeSource, preflightChecks} from './main-helpers';
|
|
28
|
+
import {getDefaultsForSchema} from '../schema/schema';
|
|
29
|
+
import {defaultsDeep} from '../utils';
|
|
30
|
+
import {readConfigFile} from './config-file';
|
|
33
31
|
import type {InitResult, PreConfigArgs} from './init-types';
|
|
32
|
+
import {determineAppiumHomeSource, preflightChecks} from './main-helpers';
|
|
33
|
+
import {adjustNodePath, requireDir, showDebugInfo} from './node-helpers';
|
|
34
|
+
import {getNonDefaultServerArgs, showConfig} from './startup-config';
|
|
34
35
|
|
|
35
36
|
/**
|
|
36
37
|
* Parses CLI/programmatic args, loads config and extensions, and returns server-ready state or runs extension/setup flows.
|
|
@@ -88,9 +89,7 @@ export class AppiumInitializer {
|
|
|
88
89
|
private async parsePreConfigArgs<
|
|
89
90
|
Cmd extends CliCommand,
|
|
90
91
|
SubCmd extends CliExtensionSubcommand | CliCommandSetupSubcommand | void,
|
|
91
|
-
>(
|
|
92
|
-
args?: Args<Cmd, SubCmd>,
|
|
93
|
-
): Promise<{preConfigArgs: PreConfigArgs; throwInsteadOfExit: boolean}> {
|
|
92
|
+
>(args?: Args<Cmd, SubCmd>): Promise<{preConfigArgs: PreConfigArgs; throwInsteadOfExit: boolean}> {
|
|
94
93
|
const parser = await getParser();
|
|
95
94
|
let throwInsteadOfExit = false;
|
|
96
95
|
|
|
@@ -135,12 +134,7 @@ export class AppiumInitializer {
|
|
|
135
134
|
) as unknown as ParsedArgs<CliCommandServer>;
|
|
136
135
|
|
|
137
136
|
if (preConfigArgs.showConfig) {
|
|
138
|
-
showConfig(
|
|
139
|
-
getNonDefaultServerArgs(preConfigArgs as Args),
|
|
140
|
-
configResult,
|
|
141
|
-
defaults,
|
|
142
|
-
serverArgs,
|
|
143
|
-
);
|
|
137
|
+
showConfig(getNonDefaultServerArgs(preConfigArgs as Args), configResult, defaults, serverArgs);
|
|
144
138
|
return {} as InitResult<Cmd>;
|
|
145
139
|
}
|
|
146
140
|
|
|
@@ -177,14 +171,10 @@ export class AppiumInitializer {
|
|
|
177
171
|
if (!serverArgs.logFilters) {
|
|
178
172
|
return;
|
|
179
173
|
}
|
|
180
|
-
const {issues, rules} = await logger
|
|
181
|
-
.unwrap()
|
|
182
|
-
.loadSecureValuesPreprocessingRules(serverArgs.logFilters);
|
|
174
|
+
const {issues, rules} = await logger.unwrap().loadSecureValuesPreprocessingRules(serverArgs.logFilters);
|
|
183
175
|
const argToLog = util.truncateString(JSON.stringify(serverArgs.logFilters), {length: 150});
|
|
184
176
|
if (!util.isEmpty(issues)) {
|
|
185
|
-
throw new Error(
|
|
186
|
-
`The log filtering rules config ${argToLog} has issues: ` + JSON.stringify(issues, null, 2),
|
|
187
|
-
);
|
|
177
|
+
throw new Error(`The log filtering rules config ${argToLog} has issues: ` + JSON.stringify(issues, null, 2));
|
|
188
178
|
}
|
|
189
179
|
if (util.isEmpty(rules)) {
|
|
190
180
|
logger.warn(`Found no log filtering rules in the ${argToLog} config. ` + `Is that expected?`);
|
|
@@ -209,9 +199,7 @@ export class AppiumInitializer {
|
|
|
209
199
|
}
|
|
210
200
|
|
|
211
201
|
if (isDriverCommandArgs(preConfigArgs) || isPluginCommandArgs(preConfigArgs)) {
|
|
212
|
-
const cmd = isDriverCommandArgs(preConfigArgs)
|
|
213
|
-
? preConfigArgs.driverCommand
|
|
214
|
-
: preConfigArgs.pluginCommand;
|
|
202
|
+
const cmd = isDriverCommandArgs(preConfigArgs) ? preConfigArgs.driverCommand : preConfigArgs.pluginCommand;
|
|
215
203
|
if (cmd === 'install') {
|
|
216
204
|
await injectAppiumSymlinks(driverConfig, pluginConfig, logger);
|
|
217
205
|
}
|
|
@@ -1,25 +1,21 @@
|
|
|
1
|
-
import
|
|
1
|
+
import net from 'node:net';
|
|
2
|
+
|
|
3
|
+
import type {ServerOpts} from '@appium/base-driver';
|
|
2
4
|
import {util} from '@appium/support';
|
|
3
5
|
import type {AppiumServer} from '@appium/types';
|
|
4
|
-
import {
|
|
6
|
+
import type {Args, CliCommand, CliCommandServer, CliCommandSetupSubcommand, CliExtensionSubcommand} from 'appium/types';
|
|
7
|
+
|
|
8
|
+
import {getActiveDrivers, getActivePlugins} from '../extension';
|
|
9
|
+
import {log as logger} from '../logger';
|
|
5
10
|
import registerNode from './grid-v3-register';
|
|
11
|
+
import type {InitResult, ServerInitData} from './init-types';
|
|
6
12
|
import {
|
|
7
|
-
determineAppiumHomeSource,
|
|
8
|
-
logStartupInfo,
|
|
9
13
|
buildServerOpts,
|
|
10
14
|
createAppiumServer,
|
|
15
|
+
determineAppiumHomeSource,
|
|
11
16
|
logServerAddress,
|
|
17
|
+
logStartupInfo,
|
|
12
18
|
} from './main-helpers';
|
|
13
|
-
import type {InitResult, ServerInitData} from './init-types';
|
|
14
|
-
import type {
|
|
15
|
-
Args,
|
|
16
|
-
CliCommand,
|
|
17
|
-
CliCommandServer,
|
|
18
|
-
CliCommandSetupSubcommand,
|
|
19
|
-
CliExtensionSubcommand,
|
|
20
|
-
} from 'appium/types';
|
|
21
|
-
import type {ServerOpts} from '@appium/base-driver';
|
|
22
|
-
import net from 'node:net';
|
|
23
19
|
|
|
24
20
|
const MAX_SERVER_PROCESS_LISTENERS = 100;
|
|
25
21
|
|
|
@@ -45,8 +41,7 @@ export class AppiumMainRunner {
|
|
|
45
41
|
return undefined as Cmd extends CliCommandServer ? AppiumServer : void;
|
|
46
42
|
}
|
|
47
43
|
|
|
48
|
-
const {appiumDriver, pluginConfig, driverConfig, parsedArgs, appiumHome} =
|
|
49
|
-
initResult as ServerInitData;
|
|
44
|
+
const {appiumDriver, pluginConfig, driverConfig, parsedArgs, appiumHome} = initResult as ServerInitData;
|
|
50
45
|
|
|
51
46
|
const pluginClasses = await getActivePlugins(
|
|
52
47
|
pluginConfig,
|
|
@@ -69,12 +64,7 @@ export class AppiumMainRunner {
|
|
|
69
64
|
parsedArgs.driversImportChunkSize,
|
|
70
65
|
parsedArgs.useDrivers,
|
|
71
66
|
);
|
|
72
|
-
const {serverOpts, normalizedBasePath} = buildServerOpts(
|
|
73
|
-
appiumDriver,
|
|
74
|
-
parsedArgs,
|
|
75
|
-
driverClasses,
|
|
76
|
-
pluginClasses,
|
|
77
|
-
);
|
|
67
|
+
const {serverOpts, normalizedBasePath} = buildServerOpts(appiumDriver, parsedArgs, driverClasses, pluginClasses);
|
|
78
68
|
|
|
79
69
|
const server = await this.startHttpServer(serverOpts, appiumDriver, normalizedBasePath);
|
|
80
70
|
if (!server) {
|
|
@@ -131,12 +121,7 @@ export class AppiumMainRunner {
|
|
|
131
121
|
): Promise<void> {
|
|
132
122
|
try {
|
|
133
123
|
if (parsedArgs.nodeconfig) {
|
|
134
|
-
await registerNode(
|
|
135
|
-
parsedArgs.nodeconfig,
|
|
136
|
-
parsedArgs.address,
|
|
137
|
-
parsedArgs.port,
|
|
138
|
-
normalizedBasePath,
|
|
139
|
-
);
|
|
124
|
+
await registerNode(parsedArgs.nodeconfig, parsedArgs.address, parsedArgs.port, normalizedBasePath);
|
|
140
125
|
}
|
|
141
126
|
} catch (err: unknown) {
|
|
142
127
|
await server.close();
|
|
@@ -144,10 +129,7 @@ export class AppiumMainRunner {
|
|
|
144
129
|
}
|
|
145
130
|
}
|
|
146
131
|
|
|
147
|
-
private attachSignalHandlers(
|
|
148
|
-
appiumDriver: ServerInitData['appiumDriver'],
|
|
149
|
-
server: AppiumServer,
|
|
150
|
-
): void {
|
|
132
|
+
private attachSignalHandlers(appiumDriver: ServerInitData['appiumDriver'], server: AppiumServer): void {
|
|
151
133
|
process.setMaxListeners(MAX_SERVER_PROCESS_LISTENERS);
|
|
152
134
|
for (const signal of ['SIGINT', 'SIGTERM'] as const) {
|
|
153
135
|
process.once(signal, async function onSignal() {
|