appium 3.5.1 → 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/helpers/build.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
+
import {fs, system, util} from '@appium/support';
|
|
2
|
+
import type {BuildInfo} from 'appium/types';
|
|
1
3
|
import axios from 'axios';
|
|
2
4
|
import {exec} from 'teen_process';
|
|
3
|
-
|
|
4
|
-
import type {BuildInfo} from 'appium/types';
|
|
5
|
+
|
|
5
6
|
import {npmPackage} from '../utils';
|
|
6
7
|
|
|
7
8
|
export const APPIUM_VER = npmPackage.version;
|
|
@@ -52,10 +53,7 @@ export async function getGitRev(useGithubApiFallback = false): Promise<string |
|
|
|
52
53
|
return null;
|
|
53
54
|
}
|
|
54
55
|
|
|
55
|
-
async function getGitTimestamp(
|
|
56
|
-
commitSha: string,
|
|
57
|
-
useGithubApiFallback = false,
|
|
58
|
-
): Promise<string | null> {
|
|
56
|
+
async function getGitTimestamp(commitSha: string, useGithubApiFallback = false): Promise<string | null> {
|
|
59
57
|
const fullGitPath = await getFullGitPath();
|
|
60
58
|
if (fullGitPath) {
|
|
61
59
|
try {
|
|
@@ -1,13 +1,8 @@
|
|
|
1
|
-
import
|
|
2
|
-
BaseDriverCapConstraints,
|
|
3
|
-
Capabilities,
|
|
4
|
-
Constraints,
|
|
5
|
-
NSCapabilities,
|
|
6
|
-
W3CCapabilities,
|
|
7
|
-
} from '@appium/types';
|
|
1
|
+
import {errors, isW3cCaps, processCapabilities, STANDARD_CAPS} from '@appium/base-driver';
|
|
8
2
|
import {util} from '@appium/support';
|
|
3
|
+
import type {BaseDriverCapConstraints, Capabilities, Constraints, NSCapabilities, W3CCapabilities} from '@appium/types';
|
|
4
|
+
|
|
9
5
|
import {log as logger} from '../logger';
|
|
10
|
-
import {processCapabilities, STANDARD_CAPS, errors, isW3cCaps} from '@appium/base-driver';
|
|
11
6
|
import {mapKeys} from '../utils';
|
|
12
7
|
|
|
13
8
|
const W3C_APPIUM_PREFIX = 'appium';
|
|
@@ -78,9 +73,7 @@ export function parseCapsForInnerDriver<C extends Constraints = BaseDriverCapCon
|
|
|
78
73
|
}
|
|
79
74
|
|
|
80
75
|
if (util.isEmpty(w3cCapabilities.firstMatch)) {
|
|
81
|
-
w3cCapabilities.firstMatch = [
|
|
82
|
-
{[defaultCapKey]: defaultCapValue},
|
|
83
|
-
] as W3CCapabilities<C>['firstMatch'];
|
|
76
|
+
w3cCapabilities.firstMatch = [{[defaultCapKey]: defaultCapValue}] as W3CCapabilities<C>['firstMatch'];
|
|
84
77
|
} else {
|
|
85
78
|
(w3cCapabilities.firstMatch[0] as Record<string, unknown>)[defaultCapKey] = defaultCapValue;
|
|
86
79
|
}
|
|
@@ -128,9 +121,7 @@ export function insertAppiumPrefixes<C extends Constraints = BaseDriverCapConstr
|
|
|
128
121
|
export function removeAppiumPrefixes<C extends Constraints = BaseDriverCapConstraints>(
|
|
129
122
|
caps: NSCapabilities<C>,
|
|
130
123
|
): Capabilities<C> {
|
|
131
|
-
return mapKeys(caps as Record<string, unknown>, (_, key) =>
|
|
132
|
-
removeAppiumPrefix(String(key)),
|
|
133
|
-
) as Capabilities<C>;
|
|
124
|
+
return mapKeys(caps as Record<string, unknown>, (_, key) => removeAppiumPrefix(String(key))) as Capabilities<C>;
|
|
134
125
|
}
|
|
135
126
|
|
|
136
127
|
/**
|
|
@@ -139,9 +130,7 @@ export function removeAppiumPrefixes<C extends Constraints = BaseDriverCapConstr
|
|
|
139
130
|
*
|
|
140
131
|
* @returns Parsed settings object; empty if none found.
|
|
141
132
|
*/
|
|
142
|
-
export function pullSettings(
|
|
143
|
-
caps: Record<string, unknown> | null | undefined,
|
|
144
|
-
): Record<string, unknown> {
|
|
133
|
+
export function pullSettings(caps: Record<string, unknown> | null | undefined): Record<string, unknown> {
|
|
145
134
|
if (!util.isPlainObject(caps) || util.isEmpty(caps)) {
|
|
146
135
|
return {};
|
|
147
136
|
}
|
package/lib/helpers/network.ts
CHANGED
|
@@ -15,12 +15,8 @@ export function fetchInterfaces(family: 4 | 6 | null = null): os.NetworkInterfac
|
|
|
15
15
|
} else if (family === 6) {
|
|
16
16
|
familyValue = [6, 'IPv6'];
|
|
17
17
|
}
|
|
18
|
-
const ifaces = Object.values(os.networkInterfaces()).filter(
|
|
19
|
-
|
|
20
|
-
) as os.NetworkInterfaceInfo[][];
|
|
21
|
-
return ifaces
|
|
22
|
-
.flat()
|
|
23
|
-
.filter((info) => !familyValue || familyValue.includes(info.family as 4 | 6 | string));
|
|
18
|
+
const ifaces = Object.values(os.networkInterfaces()).filter(Boolean) as os.NetworkInterfaceInfo[][];
|
|
19
|
+
return ifaces.flat().filter((info) => !familyValue || familyValue.includes(info.family as 4 | 6 | string));
|
|
24
20
|
}
|
|
25
21
|
|
|
26
22
|
/**
|
package/lib/insecure-features.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import {util} from '@appium/support';
|
|
2
|
-
import {
|
|
2
|
+
import type {ExternalDriver} from '@appium/types';
|
|
3
3
|
|
|
4
4
|
import type {AppiumDriver} from './appium';
|
|
5
|
-
import
|
|
5
|
+
import {log as logger} from './logger';
|
|
6
6
|
|
|
7
7
|
const ALL_DRIVERS_MATCH = '*';
|
|
8
8
|
const FEATURE_NAME_SEPARATOR = ':';
|
|
@@ -47,11 +47,7 @@ export function configureGlobalFeatures(this: AppiumDriver) {
|
|
|
47
47
|
* @param driver
|
|
48
48
|
* @param driverName
|
|
49
49
|
*/
|
|
50
|
-
export function configureDriverFeatures(
|
|
51
|
-
this: AppiumDriver,
|
|
52
|
-
driver: ExternalDriver,
|
|
53
|
-
driverName: string,
|
|
54
|
-
) {
|
|
50
|
+
export function configureDriverFeatures(this: AppiumDriver, driver: ExternalDriver, driverName: string) {
|
|
55
51
|
if (this.relaxedSecurityEnabled) {
|
|
56
52
|
this.log.info(
|
|
57
53
|
`Enabling relaxed security for this session as per the server configuration. ` +
|
|
@@ -61,10 +57,7 @@ export function configureDriverFeatures(
|
|
|
61
57
|
}
|
|
62
58
|
const allowedDriverFeatures = filterInsecureFeatures(this.allowInsecure, driverName);
|
|
63
59
|
if (!util.isEmpty(allowedDriverFeatures)) {
|
|
64
|
-
this.log.info(
|
|
65
|
-
'Explicitly enabling insecure features for this session ' +
|
|
66
|
-
'as per the server configuration:',
|
|
67
|
-
);
|
|
60
|
+
this.log.info('Explicitly enabling insecure features for this session ' + 'as per the server configuration:');
|
|
68
61
|
allowedDriverFeatures.forEach((a) => this.log.info(` ${a}`));
|
|
69
62
|
driver.allowInsecure = allowedDriverFeatures;
|
|
70
63
|
}
|
|
@@ -72,9 +65,7 @@ export function configureDriverFeatures(
|
|
|
72
65
|
if (util.isEmpty(deniedDriverFeatures)) {
|
|
73
66
|
return;
|
|
74
67
|
}
|
|
75
|
-
this.log.info(
|
|
76
|
-
'Explicitly disabling insecure features for this session ' + 'as per the server configuration:',
|
|
77
|
-
);
|
|
68
|
+
this.log.info('Explicitly disabling insecure features for this session ' + 'as per the server configuration:');
|
|
78
69
|
deniedDriverFeatures.forEach((a) => this.log.info(` ${a}`));
|
|
79
70
|
driver.denyInsecure = deniedDriverFeatures;
|
|
80
71
|
}
|
|
@@ -95,10 +86,7 @@ function validateFeatures(features: string[]): string[] {
|
|
|
95
86
|
if (separatorPos < 0) {
|
|
96
87
|
throw new Error(errMsg);
|
|
97
88
|
}
|
|
98
|
-
const [automationName, featureName] = [
|
|
99
|
-
fullName.substring(0, separatorPos),
|
|
100
|
-
fullName.substring(separatorPos + 1),
|
|
101
|
-
];
|
|
89
|
+
const [automationName, featureName] = [fullName.substring(0, separatorPos), fullName.substring(separatorPos + 1)];
|
|
102
90
|
if (!automationName || !featureName) {
|
|
103
91
|
throw new Error(errMsg);
|
|
104
92
|
}
|
|
@@ -115,10 +103,7 @@ function validateFeatures(features: string[]): string[] {
|
|
|
115
103
|
* @param features
|
|
116
104
|
* @param driverName
|
|
117
105
|
*/
|
|
118
|
-
function filterInsecureFeatures(
|
|
119
|
-
features: string[],
|
|
120
|
-
driverName: string = ALL_DRIVERS_MATCH,
|
|
121
|
-
): string[] {
|
|
106
|
+
function filterInsecureFeatures(features: string[], driverName: string = ALL_DRIVERS_MATCH): string[] {
|
|
122
107
|
const filterFn = (fullName: string) => {
|
|
123
108
|
const separatorPos = fullName.indexOf(FEATURE_NAME_SEPARATOR);
|
|
124
109
|
if (separatorPos <= 0) {
|
|
@@ -1,33 +1,28 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
METHOD_MAP as BASE_METHOD_MAP,
|
|
4
|
-
BIDI_COMMANDS as BASE_BIDI_COMMANDS,
|
|
5
|
-
} from '@appium/base-driver';
|
|
1
|
+
import {BIDI_COMMANDS as BASE_BIDI_COMMANDS, METHOD_MAP as BASE_METHOD_MAP} from '@appium/base-driver';
|
|
6
2
|
import type {
|
|
7
|
-
|
|
8
|
-
|
|
3
|
+
BiDiCommandItemParam,
|
|
4
|
+
BiDiCommandNamesToInfosMap,
|
|
5
|
+
BiDiCommandsMap,
|
|
6
|
+
BidiMethodParams,
|
|
9
7
|
BidiModuleMap,
|
|
10
8
|
DriverClass,
|
|
11
|
-
|
|
9
|
+
ExecuteMethodMap,
|
|
10
|
+
ListCommandsResponse,
|
|
12
11
|
ListExtensionsResponse,
|
|
12
|
+
MethodMap,
|
|
13
13
|
PayloadParams,
|
|
14
|
+
PluginClass,
|
|
14
15
|
RestCommandItemParam,
|
|
15
16
|
RestMethodsToCommandsMap,
|
|
16
|
-
BiDiCommandsMap,
|
|
17
|
-
BidiMethodParams,
|
|
18
|
-
BiDiCommandItemParam,
|
|
19
|
-
BiDiCommandNamesToInfosMap,
|
|
20
|
-
ExecuteMethodMap,
|
|
21
17
|
} from '@appium/types';
|
|
18
|
+
|
|
22
19
|
import type {AppiumDriver} from './appium';
|
|
20
|
+
import {mapValues} from './utils';
|
|
23
21
|
|
|
24
22
|
/**
|
|
25
23
|
* Returns available REST and BiDi commands for base, driver and plugins.
|
|
26
24
|
*/
|
|
27
|
-
export async function listCommands(
|
|
28
|
-
this: AppiumDriver,
|
|
29
|
-
sessionId?: string,
|
|
30
|
-
): Promise<ListCommandsResponse> {
|
|
25
|
+
export async function listCommands(this: AppiumDriver, sessionId?: string): Promise<ListCommandsResponse> {
|
|
31
26
|
let driverRestMethodMap: MethodMap<any> = {};
|
|
32
27
|
let driverBiDiCommands: BidiModuleMap = {};
|
|
33
28
|
let pluginRestMethodMaps: Record<string, MethodMap<any>> = {};
|
|
@@ -36,23 +31,15 @@ export async function listCommands(
|
|
|
36
31
|
const driverClass = this.driverForSession(sessionId)?.constructor as DriverClass | undefined;
|
|
37
32
|
driverRestMethodMap = driverClass?.newMethodMap ?? {};
|
|
38
33
|
driverBiDiCommands = driverClass?.newBidiCommands ?? {};
|
|
39
|
-
const pluginClasses = this.pluginsForSession(sessionId).map(
|
|
40
|
-
|
|
41
|
-
);
|
|
42
|
-
pluginRestMethodMaps = Object.fromEntries(
|
|
43
|
-
pluginClasses.map((c) => [c.name, c.newMethodMap ?? {}]),
|
|
44
|
-
);
|
|
45
|
-
pluginBiDiCommands = Object.fromEntries(
|
|
46
|
-
pluginClasses.map((c) => [c.name, c.newBidiCommands ?? {}]),
|
|
47
|
-
);
|
|
34
|
+
const pluginClasses = this.pluginsForSession(sessionId).map((p) => p.constructor as PluginClass);
|
|
35
|
+
pluginRestMethodMaps = Object.fromEntries(pluginClasses.map((c) => [c.name, c.newMethodMap ?? {}]));
|
|
36
|
+
pluginBiDiCommands = Object.fromEntries(pluginClasses.map((c) => [c.name, c.newBidiCommands ?? {}]));
|
|
48
37
|
}
|
|
49
38
|
return {
|
|
50
39
|
rest: {
|
|
51
40
|
base: methodMapToRestCommandsInfo(BASE_METHOD_MAP),
|
|
52
41
|
driver: methodMapToRestCommandsInfo(driverRestMethodMap),
|
|
53
|
-
plugins: pluginRestMethodMaps
|
|
54
|
-
? mapValues(pluginRestMethodMaps, methodMapToRestCommandsInfo)
|
|
55
|
-
: undefined,
|
|
42
|
+
plugins: pluginRestMethodMaps ? mapValues(pluginRestMethodMaps, methodMapToRestCommandsInfo) : undefined,
|
|
56
43
|
},
|
|
57
44
|
bidi: toBiDiCommandsMap(BASE_BIDI_COMMANDS, driverBiDiCommands, pluginBiDiCommands),
|
|
58
45
|
};
|
|
@@ -61,43 +48,29 @@ export async function listCommands(
|
|
|
61
48
|
/**
|
|
62
49
|
* Returns available execute methods exposed by driver and plugins.
|
|
63
50
|
*/
|
|
64
|
-
export async function listExtensions(
|
|
65
|
-
this: AppiumDriver,
|
|
66
|
-
sessionId?: string,
|
|
67
|
-
): Promise<ListExtensionsResponse> {
|
|
51
|
+
export async function listExtensions(this: AppiumDriver, sessionId?: string): Promise<ListExtensionsResponse> {
|
|
68
52
|
let driverExecuteMethodMap: ExecuteMethodMap<any> = {};
|
|
69
53
|
let pluginExecuteMethodMaps: Record<string, ExecuteMethodMap<any>> = {};
|
|
70
54
|
if (sessionId) {
|
|
71
55
|
const driverClass = this.driverForSession(sessionId)?.constructor as DriverClass | undefined;
|
|
72
56
|
driverExecuteMethodMap = driverClass?.executeMethodMap ?? {};
|
|
73
|
-
const pluginClasses = this.pluginsForSession(sessionId).map(
|
|
74
|
-
|
|
75
|
-
);
|
|
76
|
-
pluginExecuteMethodMaps = Object.fromEntries(
|
|
77
|
-
pluginClasses.map((c) => [c.name, c.executeMethodMap ?? {}]),
|
|
78
|
-
);
|
|
57
|
+
const pluginClasses = this.pluginsForSession(sessionId).map((p) => p.constructor as PluginClass);
|
|
58
|
+
pluginExecuteMethodMaps = Object.fromEntries(pluginClasses.map((c) => [c.name, c.executeMethodMap ?? {}]));
|
|
79
59
|
}
|
|
80
60
|
return {
|
|
81
61
|
rest: {
|
|
82
62
|
driver: executeMethodMapToCommandsInfo(driverExecuteMethodMap),
|
|
83
|
-
plugins: pluginExecuteMethodMaps
|
|
84
|
-
? mapValues(pluginExecuteMethodMaps, executeMethodMapToCommandsInfo)
|
|
85
|
-
: undefined,
|
|
63
|
+
plugins: pluginExecuteMethodMaps ? mapValues(pluginExecuteMethodMaps, executeMethodMapToCommandsInfo) : undefined,
|
|
86
64
|
},
|
|
87
65
|
};
|
|
88
66
|
}
|
|
89
67
|
|
|
90
|
-
function toRestCommandParams(
|
|
91
|
-
params: PayloadParams | undefined,
|
|
92
|
-
): RestCommandItemParam[] | undefined {
|
|
68
|
+
function toRestCommandParams(params: PayloadParams | undefined): RestCommandItemParam[] | undefined {
|
|
93
69
|
if (!params) {
|
|
94
70
|
return;
|
|
95
71
|
}
|
|
96
72
|
|
|
97
|
-
const toRestCommandItemParam = (
|
|
98
|
-
x: any,
|
|
99
|
-
isRequired: boolean,
|
|
100
|
-
): RestCommandItemParam | undefined => {
|
|
73
|
+
const toRestCommandItemParam = (x: any, isRequired: boolean): RestCommandItemParam | undefined => {
|
|
101
74
|
const isNameAnArray = Array.isArray(x);
|
|
102
75
|
const name = isNameAnArray ? x[0] : x;
|
|
103
76
|
if (typeof name !== 'string') {
|
|
@@ -120,9 +93,7 @@ function toRestCommandParams(
|
|
|
120
93
|
const optionalParams: RestCommandItemParam[] = (params.optional ?? [])
|
|
121
94
|
.map((name: any) => toRestCommandItemParam(name, false))
|
|
122
95
|
.filter((x): x is RestCommandItemParam => x !== undefined);
|
|
123
|
-
return requiredParams.length || optionalParams.length
|
|
124
|
-
? [...requiredParams, ...optionalParams]
|
|
125
|
-
: undefined;
|
|
96
|
+
return requiredParams.length || optionalParams.length ? [...requiredParams, ...optionalParams] : undefined;
|
|
126
97
|
}
|
|
127
98
|
|
|
128
99
|
function methodMapToRestCommandsInfo(mm: MethodMap<any>): Record<string, RestMethodsToCommandsMap> {
|
|
@@ -160,17 +131,12 @@ function toBiDiCommandsMap(
|
|
|
160
131
|
driverModuleMap: BidiModuleMap,
|
|
161
132
|
pluginModuleMaps: Record<string, BidiModuleMap>,
|
|
162
133
|
): BiDiCommandsMap {
|
|
163
|
-
const toBiDiCommandParams = (
|
|
164
|
-
params: BidiMethodParams | undefined,
|
|
165
|
-
): BiDiCommandItemParam[] | undefined => {
|
|
134
|
+
const toBiDiCommandParams = (params: BidiMethodParams | undefined): BiDiCommandItemParam[] | undefined => {
|
|
166
135
|
if (!params) {
|
|
167
136
|
return;
|
|
168
137
|
}
|
|
169
138
|
|
|
170
|
-
const toBiDiCommandItemParam = (
|
|
171
|
-
x: any,
|
|
172
|
-
isRequired: boolean,
|
|
173
|
-
): BiDiCommandItemParam | undefined => {
|
|
139
|
+
const toBiDiCommandItemParam = (x: any, isRequired: boolean): BiDiCommandItemParam | undefined => {
|
|
174
140
|
const isNameAnArray = Array.isArray(x);
|
|
175
141
|
const name = isNameAnArray ? x[0] : x;
|
|
176
142
|
if (typeof name !== 'string') {
|
|
@@ -193,14 +159,10 @@ function toBiDiCommandsMap(
|
|
|
193
159
|
const optionalParams: BiDiCommandItemParam[] = (params.optional ?? [])
|
|
194
160
|
.map((name) => toBiDiCommandItemParam(name, false))
|
|
195
161
|
.filter((x): x is BiDiCommandItemParam => x !== undefined);
|
|
196
|
-
return requiredParams.length || optionalParams.length
|
|
197
|
-
? [...requiredParams, ...optionalParams]
|
|
198
|
-
: undefined;
|
|
162
|
+
return requiredParams.length || optionalParams.length ? [...requiredParams, ...optionalParams] : undefined;
|
|
199
163
|
};
|
|
200
164
|
|
|
201
|
-
const moduleMapToBiDiCommandsInfo = (
|
|
202
|
-
mm: BidiModuleMap,
|
|
203
|
-
): Record<string, BiDiCommandNamesToInfosMap> => {
|
|
165
|
+
const moduleMapToBiDiCommandsInfo = (mm: BidiModuleMap): Record<string, BiDiCommandNamesToInfosMap> => {
|
|
204
166
|
const res: Record<string, BiDiCommandNamesToInfosMap> = {};
|
|
205
167
|
for (const [domain, commands] of Object.entries(mm)) {
|
|
206
168
|
const commandsMap: BiDiCommandNamesToInfosMap = {};
|
|
@@ -220,8 +182,6 @@ function toBiDiCommandsMap(
|
|
|
220
182
|
return {
|
|
221
183
|
base: moduleMapToBiDiCommandsInfo(baseModuleMap),
|
|
222
184
|
driver: moduleMapToBiDiCommandsInfo(driverModuleMap),
|
|
223
|
-
plugins: pluginModuleMaps
|
|
224
|
-
? mapValues(pluginModuleMaps, moduleMapToBiDiCommandsInfo)
|
|
225
|
-
: undefined,
|
|
185
|
+
plugins: pluginModuleMaps ? mapValues(pluginModuleMaps, moduleMapToBiDiCommandsInfo) : undefined,
|
|
226
186
|
};
|
|
227
187
|
}
|
package/lib/logsink.ts
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
|
-
import type {ParsedArgs} from 'appium/types';
|
|
2
1
|
import type {MessageObject} from '@appium/logger';
|
|
3
|
-
import type {Logger, Logform} from 'winston';
|
|
4
|
-
import type Transport from 'winston-transport';
|
|
5
2
|
import globalLog from '@appium/logger';
|
|
6
|
-
import {createLogger, format, transports} from 'winston';
|
|
7
3
|
import {fs, util} from '@appium/support';
|
|
8
|
-
import {
|
|
4
|
+
import type {ParsedArgs} from 'appium/types';
|
|
9
5
|
import {LRUCache} from 'lru-cache';
|
|
6
|
+
import type {Logform, Logger} from 'winston';
|
|
7
|
+
import {createLogger, format, transports} from 'winston';
|
|
8
|
+
import type Transport from 'winston-transport';
|
|
9
|
+
|
|
10
|
+
import {adler32} from './utils';
|
|
10
11
|
|
|
11
12
|
const LEVELS_MAP = {
|
|
12
13
|
debug: 4,
|
|
@@ -85,9 +86,7 @@ export async function init(args: ParsedArgs): Promise<void> {
|
|
|
85
86
|
msg = `${finalPrefix} ${msg}`;
|
|
86
87
|
}
|
|
87
88
|
const winstonLevel =
|
|
88
|
-
level in TO_WINSTON_LEVELS_MAP
|
|
89
|
-
? TO_WINSTON_LEVELS_MAP[level as keyof typeof TO_WINSTON_LEVELS_MAP]
|
|
90
|
-
: 'info';
|
|
89
|
+
level in TO_WINSTON_LEVELS_MAP ? TO_WINSTON_LEVELS_MAP[level as keyof typeof TO_WINSTON_LEVELS_MAP] : 'info';
|
|
91
90
|
try {
|
|
92
91
|
(log as Logger)[winstonLevel as keyof Logger](msg);
|
|
93
92
|
if (typeof args.logHandler === 'function') {
|
|
@@ -121,10 +120,7 @@ export function clear(): void {
|
|
|
121
120
|
|
|
122
121
|
// #region private helpers
|
|
123
122
|
|
|
124
|
-
function createConsoleTransport(
|
|
125
|
-
args: ParsedArgs,
|
|
126
|
-
logLvl: string,
|
|
127
|
-
): transports.ConsoleTransportInstance {
|
|
123
|
+
function createConsoleTransport(args: ParsedArgs, logLvl: string): transports.ConsoleTransportInstance {
|
|
128
124
|
const opt: transports.ConsoleTransportOptions = {
|
|
129
125
|
level: logLvl,
|
|
130
126
|
stderrLevels: ['error'],
|
|
@@ -199,10 +195,7 @@ async function createTransports(args: ParsedArgs): Promise<Transport[]> {
|
|
|
199
195
|
} catch (e) {
|
|
200
196
|
const err = e as Error;
|
|
201
197
|
// eslint-disable-next-line no-console
|
|
202
|
-
console.log(
|
|
203
|
-
`Tried to attach logging to file '${args.logFile}' but an error ` +
|
|
204
|
-
`occurred: ${err.message}`,
|
|
205
|
-
);
|
|
198
|
+
console.log(`Tried to attach logging to file '${args.logFile}' but an error ` + `occurred: ${err.message}`);
|
|
206
199
|
}
|
|
207
200
|
}
|
|
208
201
|
|
|
@@ -212,10 +205,7 @@ async function createTransports(args: ParsedArgs): Promise<Transport[]> {
|
|
|
212
205
|
} catch (e) {
|
|
213
206
|
const err = e as Error;
|
|
214
207
|
// eslint-disable-next-line no-console
|
|
215
|
-
console.log(
|
|
216
|
-
`Tried to attach logging to Http at ${args.webhook} but ` +
|
|
217
|
-
`an error occurred: ${err.message}`,
|
|
218
|
-
);
|
|
208
|
+
console.log(`Tried to attach logging to Http at ${args.webhook} but ` + `an error occurred: ${err.message}`);
|
|
219
209
|
}
|
|
220
210
|
}
|
|
221
211
|
|
|
@@ -300,11 +290,7 @@ export function stripColorCodes(text: string): string {
|
|
|
300
290
|
}
|
|
301
291
|
|
|
302
292
|
// Strip the color marking within messages (depends on stripColorCodes)
|
|
303
|
-
const stripColorFormat = format(function stripColor(info: {
|
|
304
|
-
level: string;
|
|
305
|
-
message: unknown;
|
|
306
|
-
[key: string]: unknown;
|
|
307
|
-
}) {
|
|
293
|
+
const stripColorFormat = format(function stripColor(info: {level: string; message: unknown; [key: string]: unknown}) {
|
|
308
294
|
return {
|
|
309
295
|
...info,
|
|
310
296
|
level: stripColorCodes(info.level),
|
package/lib/main.ts
CHANGED
|
@@ -4,13 +4,8 @@ import './logsink'; // must run first: global npmlog / log sink setup (see logsi
|
|
|
4
4
|
import './logger'; // load Appium logger immediately after logsink (order matters for log wiring)
|
|
5
5
|
import {env} from '@appium/support';
|
|
6
6
|
import type {AppiumServer} from '@appium/types';
|
|
7
|
-
import type {
|
|
8
|
-
|
|
9
|
-
CliCommand,
|
|
10
|
-
CliCommandServer,
|
|
11
|
-
CliCommandSetupSubcommand,
|
|
12
|
-
CliExtensionSubcommand,
|
|
13
|
-
} from 'appium/types';
|
|
7
|
+
import type {Args, CliCommand, CliCommandServer, CliCommandSetupSubcommand, CliExtensionSubcommand} from 'appium/types';
|
|
8
|
+
|
|
14
9
|
import {AppiumInitializer} from './bootstrap/appium-initializer';
|
|
15
10
|
import {AppiumMainRunner} from './bootstrap/appium-main-runner';
|
|
16
11
|
import type {ExtCommandInitResult, InitResult, ServerInitData} from './bootstrap/init-types';
|
package/lib/schema/arg-spec.ts
CHANGED
|
@@ -5,11 +5,12 @@ import type {
|
|
|
5
5
|
CliCommandPlugin,
|
|
6
6
|
CliCommandServer,
|
|
7
7
|
CliCommandSetup,
|
|
8
|
+
CliCommandSetupSubcommand,
|
|
8
9
|
CliExtensionCommand,
|
|
9
10
|
CliExtensionSubcommand,
|
|
10
|
-
CliCommandSetupSubcommand,
|
|
11
11
|
} from 'appium/types';
|
|
12
|
-
|
|
12
|
+
|
|
13
|
+
import {DRIVER_TYPE, PLUGIN_TYPE, SERVER_SUBCOMMAND, SETUP_SUBCOMMAND} from '../constants';
|
|
13
14
|
|
|
14
15
|
type AnyArgs = Args<CliCommand, CliExtensionSubcommand | CliCommandSetupSubcommand | void>;
|
|
15
16
|
|
|
@@ -27,9 +28,7 @@ export function isServerCommandArgs(args: AnyArgs): args is Args<CliCommandServe
|
|
|
27
28
|
*
|
|
28
29
|
* @param args - Parsed args before full subcommand-specific narrowing
|
|
29
30
|
*/
|
|
30
|
-
export function isSetupCommandArgs(
|
|
31
|
-
args: AnyArgs,
|
|
32
|
-
): args is Args<CliCommandSetup, CliCommandSetupSubcommand> {
|
|
31
|
+
export function isSetupCommandArgs(args: AnyArgs): args is Args<CliCommandSetup, CliCommandSetupSubcommand> {
|
|
33
32
|
return args.subcommand === SETUP_SUBCOMMAND;
|
|
34
33
|
}
|
|
35
34
|
|
|
@@ -38,9 +37,7 @@ export function isSetupCommandArgs(
|
|
|
38
37
|
*
|
|
39
38
|
* @param args - Parsed args before full subcommand-specific narrowing
|
|
40
39
|
*/
|
|
41
|
-
export function isExtensionCommandArgs(
|
|
42
|
-
args: AnyArgs,
|
|
43
|
-
): args is Args<CliExtensionCommand, CliExtensionSubcommand> {
|
|
40
|
+
export function isExtensionCommandArgs(args: AnyArgs): args is Args<CliExtensionCommand, CliExtensionSubcommand> {
|
|
44
41
|
return args.subcommand === DRIVER_TYPE || args.subcommand === PLUGIN_TYPE;
|
|
45
42
|
}
|
|
46
43
|
|
|
@@ -49,9 +46,7 @@ export function isExtensionCommandArgs(
|
|
|
49
46
|
*
|
|
50
47
|
* @param args - Parsed args before full subcommand-specific narrowing
|
|
51
48
|
*/
|
|
52
|
-
export function isDriverCommandArgs(
|
|
53
|
-
args: AnyArgs,
|
|
54
|
-
): args is Args<CliCommandDriver, CliExtensionSubcommand> {
|
|
49
|
+
export function isDriverCommandArgs(args: AnyArgs): args is Args<CliCommandDriver, CliExtensionSubcommand> {
|
|
55
50
|
return args.subcommand === DRIVER_TYPE;
|
|
56
51
|
}
|
|
57
52
|
|
|
@@ -60,8 +55,6 @@ export function isDriverCommandArgs(
|
|
|
60
55
|
*
|
|
61
56
|
* @param args - Parsed args before full subcommand-specific narrowing
|
|
62
57
|
*/
|
|
63
|
-
export function isPluginCommandArgs(
|
|
64
|
-
args: AnyArgs,
|
|
65
|
-
): args is Args<CliCommandPlugin, CliExtensionSubcommand> {
|
|
58
|
+
export function isPluginCommandArgs(args: AnyArgs): args is Args<CliCommandPlugin, CliExtensionSubcommand> {
|
|
66
59
|
return args.subcommand === PLUGIN_TYPE;
|
|
67
60
|
}
|
package/lib/schema/cli-args.ts
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
|
-
import {ArgumentTypeError, type ArgumentOptions} from 'argparse';
|
|
2
1
|
import {util} from '@appium/support';
|
|
2
|
+
import {type ArgumentOptions, ArgumentTypeError} from 'argparse';
|
|
3
3
|
import type {JSONSchema7, JSONSchema7TypeName} from 'json-schema';
|
|
4
|
+
|
|
5
|
+
import type {ArgumentDefinitions} from '../cli/args';
|
|
4
6
|
import {kebabCase} from '../utils';
|
|
7
|
+
import type {ArgSpec} from './arg-spec';
|
|
8
|
+
import {parseCsvLine, transformers} from './cli-transformers';
|
|
5
9
|
import {formatErrors} from './format-errors';
|
|
10
|
+
import type {AppiumCliTransformerName, AppiumJSONSchemaKeywords} from './keywords';
|
|
6
11
|
import {flattenSchema, validate} from './schema';
|
|
7
|
-
import {transformers, parseCsvLine} from './cli-transformers';
|
|
8
|
-
import type {ArgSpec} from './arg-spec';
|
|
9
|
-
import type {AppiumJSONSchemaKeywords, AppiumCliTransformerName} from './keywords';
|
|
10
|
-
import type {ArgumentDefinitions} from '../cli/args';
|
|
11
12
|
|
|
12
13
|
type AppiumJSONSchema = AppiumJSONSchemaKeywords & JSONSchema7;
|
|
13
14
|
type ArgDef = [[string] | [string, string], ArgumentOptions];
|
|
@@ -30,9 +31,7 @@ const SHORT_ARG_CUTOFF = 3;
|
|
|
30
31
|
*/
|
|
31
32
|
export function toParserArgs(): ArgumentDefinitions {
|
|
32
33
|
const flattened = flattenSchema().filter(({schema}) => !schema.appiumCliIgnored);
|
|
33
|
-
return new Map(
|
|
34
|
-
flattened.map(({schema, argSpec}) => subSchemaToArgDef(schema as AppiumJSONSchema, argSpec)),
|
|
35
|
-
);
|
|
34
|
+
return new Map(flattened.map(({schema, argSpec}) => subSchemaToArgDef(schema as AppiumJSONSchema, argSpec)));
|
|
36
35
|
}
|
|
37
36
|
|
|
38
37
|
/**
|
|
@@ -108,9 +107,7 @@ function subSchemaToArgDef(subSchema: AppiumJSONSchema, argSpec: ArgSpec): ArgDe
|
|
|
108
107
|
argTypeFunction = (value: string) => {
|
|
109
108
|
const o = transformers.json(value);
|
|
110
109
|
if (!util.isPlainObject(o)) {
|
|
111
|
-
throw new ArgumentTypeError(
|
|
112
|
-
`'${util.truncateString(String(o), {length: 100})}' must be a plain object`,
|
|
113
|
-
);
|
|
110
|
+
throw new ArgumentTypeError(`'${util.truncateString(String(o), {length: 100})}' must be a plain object`);
|
|
114
111
|
}
|
|
115
112
|
return o;
|
|
116
113
|
};
|
|
@@ -146,9 +143,7 @@ function subSchemaToArgDef(subSchema: AppiumJSONSchema, argSpec: ArgSpec): ArgDe
|
|
|
146
143
|
if (type === TYPENAMES.ARRAY) {
|
|
147
144
|
const csvTransformer = argTypeFunction as (x: string) => string[];
|
|
148
145
|
argTypeFunction = (val) =>
|
|
149
|
-
csvTransformer(val).flatMap((item) =>
|
|
150
|
-
transformers[appiumCliTransformer as AppiumCliTransformerName](item),
|
|
151
|
-
);
|
|
146
|
+
csvTransformer(val).flatMap((item) => transformers[appiumCliTransformer as AppiumCliTransformerName](item));
|
|
152
147
|
} else {
|
|
153
148
|
const baseFn = argTypeFunction ?? ((value: string) => value);
|
|
154
149
|
const transformer = transformers[appiumCliTransformer as AppiumCliTransformerName];
|
|
@@ -164,9 +159,7 @@ function subSchemaToArgDef(subSchema: AppiumJSONSchema, argSpec: ArgSpec): ArgDe
|
|
|
164
159
|
if (type === TYPENAMES.STRING) {
|
|
165
160
|
argOpts.choices = enumValues.map(String);
|
|
166
161
|
} else {
|
|
167
|
-
throw new TypeError(
|
|
168
|
-
`Problem with schema for ${arg}; \`enum\` is only supported for \`type: 'string'\``,
|
|
169
|
-
);
|
|
162
|
+
throw new TypeError(`Problem with schema for ${arg}; \`enum\` is only supported for \`type: 'string'\``);
|
|
170
163
|
}
|
|
171
164
|
}
|
|
172
165
|
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
+
import {existsSync, readFileSync} from 'node:fs';
|
|
2
|
+
|
|
1
3
|
import {ArgumentTypeError} from 'argparse';
|
|
2
|
-
import {readFileSync, existsSync} from 'node:fs';
|
|
3
4
|
|
|
4
5
|
/**
|
|
5
6
|
* This module provides transformer functions for CLI arguments.
|
|
@@ -31,9 +32,7 @@ export const transformers = {
|
|
|
31
32
|
try {
|
|
32
33
|
csv = readFileSync(csvOrPath, 'utf8');
|
|
33
34
|
} catch (err) {
|
|
34
|
-
throw new ArgumentTypeError(
|
|
35
|
-
`Could not read file '${csvOrPath}': ${(err as Error).message}`,
|
|
36
|
-
);
|
|
35
|
+
throw new ArgumentTypeError(`Could not read file '${csvOrPath}': ${(err as Error).message}`);
|
|
37
36
|
}
|
|
38
37
|
loadedFromFile = true;
|
|
39
38
|
}
|
|
@@ -58,18 +57,14 @@ export const transformers = {
|
|
|
58
57
|
// Intentionally sync: argparse type hooks are synchronous.
|
|
59
58
|
json = readFileSync(jsonOrPath, 'utf8');
|
|
60
59
|
} catch (err) {
|
|
61
|
-
throw new ArgumentTypeError(
|
|
62
|
-
`Could not read file '${jsonOrPath}': ${(err as Error).message}`,
|
|
63
|
-
);
|
|
60
|
+
throw new ArgumentTypeError(`Could not read file '${jsonOrPath}': ${(err as Error).message}`);
|
|
64
61
|
}
|
|
65
62
|
loadedFromFile = true;
|
|
66
63
|
}
|
|
67
64
|
try {
|
|
68
65
|
return JSON.parse(json);
|
|
69
66
|
} catch (e) {
|
|
70
|
-
const msg = loadedFromFile
|
|
71
|
-
? `'${jsonOrPath}' must be a valid JSON`
|
|
72
|
-
: `The provided value must be a valid JSON`;
|
|
67
|
+
const msg = loadedFromFile ? `'${jsonOrPath}' must be a valid JSON` : `The provided value must be a valid JSON`;
|
|
73
68
|
throw new TypeError(`${msg}. Original error: ${(e as Error).message}`, {cause: e});
|
|
74
69
|
}
|
|
75
70
|
},
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
+
import type {NormalizedAppiumConfig} from '@appium/types';
|
|
1
2
|
import betterAjvErrors, {type IOutputError} from '@sidvind/better-ajv-errors';
|
|
2
3
|
import type {ErrorObject} from 'ajv';
|
|
3
|
-
|
|
4
|
+
|
|
4
5
|
import {getSchema} from './schema';
|
|
5
6
|
|
|
6
7
|
/**
|
package/lib/schema/index.ts
CHANGED
package/lib/schema/keywords.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type {KeywordDefinition} from 'ajv';
|
|
2
|
+
|
|
2
3
|
import {transformers} from './cli-transformers';
|
|
3
4
|
|
|
4
5
|
export type AppiumCliTransformerName = keyof typeof transformers;
|
|
@@ -64,8 +65,7 @@ export const keywords: Record<string, KeywordDefinition> = {
|
|
|
64
65
|
metaSchema: {
|
|
65
66
|
type: 'string',
|
|
66
67
|
enum: Object.keys(transformers) as AppiumCliTransformerName[],
|
|
67
|
-
description:
|
|
68
|
-
'The name of a custom transformer to run against the value as provided via the CLI.',
|
|
68
|
+
description: 'The name of a custom transformer to run against the value as provided via the CLI.',
|
|
69
69
|
},
|
|
70
70
|
},
|
|
71
71
|
/**
|