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
|
@@ -1,12 +1,13 @@
|
|
|
1
|
+
import {util} from '@appium/support';
|
|
2
|
+
import type {AppiumConfig, NormalizedAppiumConfig} from '@appium/types';
|
|
1
3
|
import type {IOutputError} from '@sidvind/better-ajv-errors';
|
|
2
4
|
import type {ErrorObject, SchemaObject} from 'ajv';
|
|
3
|
-
import {lilconfig, type
|
|
4
|
-
import {util} from '@appium/support';
|
|
5
|
+
import {lilconfig, type LilconfigResult, type LoaderSync} from 'lilconfig';
|
|
5
6
|
import * as yaml from 'yaml';
|
|
6
|
-
|
|
7
|
-
import type {AppiumConfig, NormalizedAppiumConfig} from '@appium/types';
|
|
8
|
-
import {getSchema, validate} from '../schema/schema';
|
|
7
|
+
|
|
9
8
|
import {formatErrors} from '../schema/format-errors';
|
|
9
|
+
import {getSchema, validate} from '../schema/schema';
|
|
10
|
+
import {camelCase, getPath, mapKeys, mapValues} from '../utils';
|
|
10
11
|
|
|
11
12
|
/**
|
|
12
13
|
* A cache of the raw config file (a JSON string) at a filepath.
|
|
@@ -99,35 +100,22 @@ export async function readConfigFile(
|
|
|
99
100
|
export function normalizeConfig(config: AppiumConfig): NormalizedAppiumConfig {
|
|
100
101
|
const schema = getSchema();
|
|
101
102
|
|
|
102
|
-
const isSchemaTypeObject = (
|
|
103
|
-
schemaObj: SchemaObject | Record<string, unknown> | undefined,
|
|
104
|
-
): boolean =>
|
|
103
|
+
const isSchemaTypeObject = (schemaObj: SchemaObject | Record<string, unknown> | undefined): boolean =>
|
|
105
104
|
Boolean(
|
|
106
|
-
(schemaObj as SchemaObject | undefined)?.properties ||
|
|
107
|
-
(schemaObj as SchemaObject | undefined)?.type === 'object',
|
|
105
|
+
(schemaObj as SchemaObject | undefined)?.properties || (schemaObj as SchemaObject | undefined)?.type === 'object',
|
|
108
106
|
);
|
|
109
107
|
|
|
110
108
|
const normalize = (rootConfig: AppiumConfig, section?: string): Record<string, unknown> => {
|
|
111
109
|
const obj =
|
|
112
|
-
section === undefined
|
|
113
|
-
? rootConfig
|
|
114
|
-
: (getPath(rootConfig, section, rootConfig) as Record<string, unknown>);
|
|
110
|
+
section === undefined ? rootConfig : (getPath(rootConfig, section, rootConfig) as Record<string, unknown>);
|
|
115
111
|
|
|
116
112
|
const mappedObj = mapKeys(obj as Record<string, unknown>, (_v, prop) =>
|
|
117
|
-
String(
|
|
118
|
-
getPath(
|
|
119
|
-
schema,
|
|
120
|
-
`properties.server.properties.${prop}.appiumCliDest`,
|
|
121
|
-
camelCase(String(prop)),
|
|
122
|
-
),
|
|
123
|
-
),
|
|
113
|
+
String(getPath(schema, `properties.server.properties.${prop}.appiumCliDest`, camelCase(String(prop)))),
|
|
124
114
|
);
|
|
125
115
|
|
|
126
116
|
return mapValues(mappedObj, (value, property) => {
|
|
127
117
|
const nextSection = section ? `${section}.${property}` : property;
|
|
128
|
-
return isSchemaTypeObject((schema as any).properties?.[property])
|
|
129
|
-
? normalize(rootConfig, nextSection)
|
|
130
|
-
: value;
|
|
118
|
+
return isSchemaTypeObject((schema as any).properties?.[property]) ? normalize(rootConfig, nextSection) : value;
|
|
131
119
|
});
|
|
132
120
|
};
|
|
133
121
|
|
|
@@ -141,10 +129,9 @@ function yamlLoader(filepath: string, content: string): unknown {
|
|
|
141
129
|
try {
|
|
142
130
|
return yaml.parse(content);
|
|
143
131
|
} catch (e) {
|
|
144
|
-
throw new Error(
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
);
|
|
132
|
+
throw new Error(`The YAML config at '${filepath}' cannot be loaded. Original error: ${(e as Error).message}`, {
|
|
133
|
+
cause: e,
|
|
134
|
+
});
|
|
148
135
|
}
|
|
149
136
|
}
|
|
150
137
|
|
|
@@ -158,27 +145,22 @@ function jsonLoader(filepath: string, content: string): unknown {
|
|
|
158
145
|
return JSON.parse(content);
|
|
159
146
|
} catch (e) {
|
|
160
147
|
rawConfig.delete(filepath);
|
|
161
|
-
throw new Error(
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
);
|
|
148
|
+
throw new Error(`The JSON config at '${filepath}' cannot be loaded. Original error: ${(e as Error).message}`, {
|
|
149
|
+
cause: e,
|
|
150
|
+
});
|
|
165
151
|
}
|
|
166
152
|
}
|
|
167
153
|
|
|
168
154
|
/**
|
|
169
155
|
* Loads a config file from an explicit path
|
|
170
156
|
*/
|
|
171
|
-
async function loadConfigFile(
|
|
172
|
-
lc: LilconfigAsyncSearcher,
|
|
173
|
-
filepath: string,
|
|
174
|
-
): Promise<LilconfigResult> {
|
|
157
|
+
async function loadConfigFile(lc: LilconfigAsyncSearcher, filepath: string): Promise<LilconfigResult> {
|
|
175
158
|
try {
|
|
176
159
|
// removing "await" will cause any rejection to _not_ be caught in this block!
|
|
177
160
|
return await lc.load(filepath);
|
|
178
161
|
} catch (err) {
|
|
179
162
|
if ((err as NodeJS.ErrnoException).code === 'ENOENT') {
|
|
180
|
-
(err as NodeJS.ErrnoException).message =
|
|
181
|
-
`Config file not found at user-provided path: ${filepath}`;
|
|
163
|
+
(err as NodeJS.ErrnoException).message = `Config file not found at user-provided path: ${filepath}`;
|
|
182
164
|
throw err;
|
|
183
165
|
} else if (err instanceof SyntaxError) {
|
|
184
166
|
// generally invalid JSON
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import axios from 'axios';
|
|
2
1
|
import {fs} from '@appium/support';
|
|
3
2
|
import type {StringRecord} from '@appium/types';
|
|
3
|
+
import axios from 'axios';
|
|
4
|
+
|
|
4
5
|
import {log as logger} from '../logger';
|
|
5
6
|
|
|
6
7
|
/**
|
|
@@ -39,12 +40,7 @@ interface Grid3ProxyApiResponse {
|
|
|
39
40
|
msg?: string;
|
|
40
41
|
}
|
|
41
42
|
|
|
42
|
-
export default async function registerNode(
|
|
43
|
-
data: string,
|
|
44
|
-
addr: string,
|
|
45
|
-
port: number,
|
|
46
|
-
basePath: string,
|
|
47
|
-
): Promise<void>;
|
|
43
|
+
export default async function registerNode(data: string, addr: string, port: number, basePath: string): Promise<void>;
|
|
48
44
|
export default async function registerNode(
|
|
49
45
|
data: Grid3NodeConfig,
|
|
50
46
|
addr?: string,
|
|
@@ -80,9 +76,7 @@ export default async function registerNode(
|
|
|
80
76
|
);
|
|
81
77
|
}
|
|
82
78
|
if (typeof port !== 'number' || !Number.isFinite(port)) {
|
|
83
|
-
throw logger.errorWithException(
|
|
84
|
-
'When registering from a node config file path, port must be a finite number.',
|
|
85
|
-
);
|
|
79
|
+
throw logger.errorWithException('When registering from a node config file path, port must be a finite number.');
|
|
86
80
|
}
|
|
87
81
|
}
|
|
88
82
|
|
|
@@ -103,8 +97,7 @@ export default async function registerNode(
|
|
|
103
97
|
configHolder = JSON.parse(fileContent) as Grid3NodeConfig;
|
|
104
98
|
} catch (err) {
|
|
105
99
|
throw logger.errorWithException(
|
|
106
|
-
`Syntax error in Selenium Grid 3 node configuration file ${configFilePath}: ` +
|
|
107
|
-
(err as Error).message,
|
|
100
|
+
`Syntax error in Selenium Grid 3 node configuration file ${configFilePath}: ` + (err as Error).message,
|
|
108
101
|
);
|
|
109
102
|
}
|
|
110
103
|
} else {
|
|
@@ -134,29 +127,15 @@ async function registerToGrid(
|
|
|
134
127
|
if (status !== 200) {
|
|
135
128
|
throw new Error(`Request failed with code ${status}`);
|
|
136
129
|
}
|
|
137
|
-
logger.debug(
|
|
138
|
-
`Appium successfully registered with the Selenium Grid 3 hub at ` + hubUri(hubCfg),
|
|
139
|
-
);
|
|
130
|
+
logger.debug(`Appium successfully registered with the Selenium Grid 3 hub at ` + hubUri(hubCfg));
|
|
140
131
|
} catch (err) {
|
|
141
|
-
logger.error(
|
|
142
|
-
`An attempt to register with the Selenium Grid 3 hub was unsuccessful: ` +
|
|
143
|
-
(err as Error).message,
|
|
144
|
-
);
|
|
132
|
+
logger.error(`An attempt to register with the Selenium Grid 3 hub was unsuccessful: ` + (err as Error).message);
|
|
145
133
|
}
|
|
146
134
|
}
|
|
147
135
|
|
|
148
|
-
function postRequest(
|
|
149
|
-
configHolder: Grid3NodeConfig,
|
|
150
|
-
addr?: string,
|
|
151
|
-
port?: number,
|
|
152
|
-
basePath?: string,
|
|
153
|
-
): void {
|
|
136
|
+
function postRequest(configHolder: Grid3NodeConfig, addr?: string, port?: number, basePath?: string): void {
|
|
154
137
|
// Move Selenium Grid 3 (flat) configuration properties into `configuration`
|
|
155
|
-
if (
|
|
156
|
-
configHolder != null &&
|
|
157
|
-
typeof configHolder === 'object' &&
|
|
158
|
-
!Object.hasOwn(configHolder, 'configuration')
|
|
159
|
-
) {
|
|
138
|
+
if (configHolder != null && typeof configHolder === 'object' && !Object.hasOwn(configHolder, 'configuration')) {
|
|
160
139
|
const configuration: StringRecord = {};
|
|
161
140
|
const holder = configHolder as StringRecord;
|
|
162
141
|
for (const property of Object.keys(holder)) {
|
|
@@ -201,11 +180,7 @@ function postRequest(
|
|
|
201
180
|
}
|
|
202
181
|
|
|
203
182
|
const registerCycleInterval = cfg.registerCycle;
|
|
204
|
-
if (
|
|
205
|
-
registerCycleInterval === undefined ||
|
|
206
|
-
isNaN(registerCycleInterval) ||
|
|
207
|
-
registerCycleInterval <= 0
|
|
208
|
-
) {
|
|
183
|
+
if (registerCycleInterval === undefined || isNaN(registerCycleInterval) || registerCycleInterval <= 0) {
|
|
209
184
|
logger.warn(
|
|
210
185
|
`'registerCycle' is not a valid positive number. ` +
|
|
211
186
|
`No registration request will be sent to the Selenium Grid 3 hub.`,
|
|
@@ -215,8 +190,7 @@ function postRequest(
|
|
|
215
190
|
// initiate a new Thread
|
|
216
191
|
let first = true;
|
|
217
192
|
logger.debug(
|
|
218
|
-
`Starting auto-register thread for Selenium Grid 3. ` +
|
|
219
|
-
`Will try to register every ${registerCycleInterval} ms.`,
|
|
193
|
+
`Starting auto-register thread for Selenium Grid 3. ` + `Will try to register every ${registerCycleInterval} ms.`,
|
|
220
194
|
);
|
|
221
195
|
setInterval(async function registerRetry() {
|
|
222
196
|
if (first) {
|
|
@@ -231,7 +205,7 @@ function postRequest(
|
|
|
231
205
|
|
|
232
206
|
/** Query the Selenium Grid 3 hub to see if this node id is already registered. */
|
|
233
207
|
async function isAlreadyRegistered(configHolder: Grid3NodeConfig): Promise<boolean | undefined> {
|
|
234
|
-
//check if node is already registered
|
|
208
|
+
// check if node is already registered
|
|
235
209
|
const hubCfg = configHolder.configuration;
|
|
236
210
|
if (!hubCfg?.id) {
|
|
237
211
|
return;
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import type {AppiumDriver} from '../appium';
|
|
2
1
|
import type {
|
|
3
2
|
Args,
|
|
4
3
|
CliCommand,
|
|
@@ -7,6 +6,8 @@ import type {
|
|
|
7
6
|
CliExtensionSubcommand,
|
|
8
7
|
ParsedArgs,
|
|
9
8
|
} from 'appium/types';
|
|
9
|
+
|
|
10
|
+
import type {AppiumDriver} from '../appium';
|
|
10
11
|
import type {ExtensionConfigs} from '../extension';
|
|
11
12
|
|
|
12
13
|
/** Empty object returned when `init` completes for non-server CLI flows (extension/setup). */
|
|
@@ -25,7 +26,4 @@ export type InitResult<Cmd extends CliCommand = CliCommandServer> = Cmd extends
|
|
|
25
26
|
: ExtCommandInitResult;
|
|
26
27
|
|
|
27
28
|
/** CLI + programmatic args before `init` narrows by `subcommand`. */
|
|
28
|
-
export type PreConfigArgs = Args<
|
|
29
|
-
CliCommand,
|
|
30
|
-
CliExtensionSubcommand | CliCommandSetupSubcommand | void
|
|
31
|
-
>;
|
|
29
|
+
export type PreConfigArgs = Args<CliCommand, CliExtensionSubcommand | CliCommandSetupSubcommand | void>;
|
|
@@ -1,24 +1,26 @@
|
|
|
1
|
+
import type {NetworkInterfaceInfo} from 'node:os';
|
|
1
2
|
import {inspect as dump, type InspectOptions} from 'node:util';
|
|
2
|
-
|
|
3
|
+
|
|
3
4
|
import {
|
|
4
|
-
routeConfiguringFunction as makeRouter,
|
|
5
5
|
normalizeBasePath,
|
|
6
|
+
routeConfiguringFunction as makeRouter,
|
|
6
7
|
server as baseServer,
|
|
7
8
|
type ServerOpts,
|
|
8
9
|
} from '@appium/base-driver';
|
|
9
10
|
import {console as supportConsole, util} from '@appium/support';
|
|
10
11
|
import type {AppiumServer, Driver, MethodMap, UpdateServerCallback} from '@appium/types';
|
|
12
|
+
import type {Args, CliCommandServer, ParsedArgs} from 'appium/types';
|
|
11
13
|
import {WebSocketServer} from 'ws';
|
|
12
|
-
|
|
14
|
+
|
|
13
15
|
import type {AppiumDriver} from '../appium';
|
|
16
|
+
import {BIDI_BASE_PATH, LONG_STACKTRACE_LIMIT} from '../constants';
|
|
17
|
+
import type {DriverNameMap, PluginNameMap} from '../extension';
|
|
14
18
|
import {APPIUM_VER, getBuildInfo, getGitRev, updateBuildInfo} from '../helpers/build';
|
|
19
|
+
import {fetchInterfaces, isBroadcastIp, V4_BROADCAST_IP} from '../helpers/network';
|
|
20
|
+
import {log as logger} from '../logger';
|
|
21
|
+
import {validate as validateSchema} from '../schema/schema';
|
|
15
22
|
import {checkNodeOk, requireDir} from './node-helpers';
|
|
16
23
|
import {getNonDefaultServerArgs} from './startup-config';
|
|
17
|
-
import {validate as validateSchema} from '../schema/schema';
|
|
18
|
-
import {fetchInterfaces, V4_BROADCAST_IP, isBroadcastIp} from '../helpers/network';
|
|
19
|
-
import {LONG_STACKTRACE_LIMIT, BIDI_BASE_PATH} from '../constants';
|
|
20
|
-
import type {Args, ParsedArgs, CliCommandServer} from 'appium/types';
|
|
21
|
-
import type {DriverNameMap, PluginNameMap} from '../extension';
|
|
22
24
|
|
|
23
25
|
const isStdoutTTY = process.stdout.isTTY;
|
|
24
26
|
|
|
@@ -88,10 +90,7 @@ export function logServerAddress(url: string): void {
|
|
|
88
90
|
* @param args - Parsed server CLI args
|
|
89
91
|
* @param throwInsteadOfExit - When true, rethrows failures instead of calling `process.exit(1)`
|
|
90
92
|
*/
|
|
91
|
-
export async function preflightChecks(
|
|
92
|
-
args: ParsedArgs<CliCommandServer>,
|
|
93
|
-
throwInsteadOfExit = false,
|
|
94
|
-
): Promise<void> {
|
|
93
|
+
export async function preflightChecks(args: ParsedArgs<CliCommandServer>, throwInsteadOfExit = false): Promise<void> {
|
|
95
94
|
try {
|
|
96
95
|
checkNodeOk();
|
|
97
96
|
if (args.longStacktrace) {
|
|
@@ -141,10 +140,7 @@ export async function logStartupInfo(args: ParsedArgs<CliCommandServer>): Promis
|
|
|
141
140
|
/**
|
|
142
141
|
* Collects `updateServer` hooks from active driver and plugin classes for HTTP server customization.
|
|
143
142
|
*/
|
|
144
|
-
export function getServerUpdaters(
|
|
145
|
-
driverClasses: DriverNameMap,
|
|
146
|
-
pluginClasses: PluginNameMap,
|
|
147
|
-
): UpdateServerCallback[] {
|
|
143
|
+
export function getServerUpdaters(driverClasses: DriverNameMap, pluginClasses: PluginNameMap): UpdateServerCallback[] {
|
|
148
144
|
return [...driverClasses.keys(), ...pluginClasses.keys()]
|
|
149
145
|
.map((klass) => klass.updateServer)
|
|
150
146
|
.filter(Boolean) as UpdateServerCallback[];
|
|
@@ -153,10 +149,7 @@ export function getServerUpdaters(
|
|
|
153
149
|
/**
|
|
154
150
|
* Merges `newMethodMap` contributions from all active drivers and plugins into one method map.
|
|
155
151
|
*/
|
|
156
|
-
export function getExtraMethodMap(
|
|
157
|
-
driverClasses: DriverNameMap,
|
|
158
|
-
pluginClasses: PluginNameMap,
|
|
159
|
-
): MethodMap<Driver> {
|
|
152
|
+
export function getExtraMethodMap(driverClasses: DriverNameMap, pluginClasses: PluginNameMap): MethodMap<Driver> {
|
|
160
153
|
return [...driverClasses.keys(), ...pluginClasses.keys()].reduce<MethodMap<Driver>>(
|
|
161
154
|
(map, klass) => ({
|
|
162
155
|
...map,
|
|
@@ -218,12 +211,9 @@ function logNonDefaultArgsWarning(args: Args): void {
|
|
|
218
211
|
inspect(args);
|
|
219
212
|
}
|
|
220
213
|
|
|
221
|
-
function logDefaultCapabilitiesWarning(
|
|
222
|
-
caps: ParsedArgs<CliCommandServer>['defaultCapabilities'],
|
|
223
|
-
): void {
|
|
214
|
+
function logDefaultCapabilitiesWarning(caps: ParsedArgs<CliCommandServer>['defaultCapabilities']): void {
|
|
224
215
|
logger.info(
|
|
225
|
-
'Default capabilities, which will be added to each request ' +
|
|
226
|
-
'unless overridden by desired capabilities:',
|
|
216
|
+
'Default capabilities, which will be added to each request ' + 'unless overridden by desired capabilities:',
|
|
227
217
|
);
|
|
228
218
|
inspect(caps);
|
|
229
219
|
}
|
|
@@ -1,10 +1,12 @@
|
|
|
1
|
-
/* eslint-disable no-console */
|
|
2
|
-
import path from 'node:path';
|
|
3
1
|
import os from 'node:os';
|
|
2
|
+
import path from 'node:path';
|
|
3
|
+
|
|
4
|
+
/* eslint-disable no-console */
|
|
5
|
+
import {fs, npm, system} from '@appium/support';
|
|
4
6
|
import * as semver from 'semver';
|
|
5
|
-
|
|
7
|
+
|
|
8
|
+
import {getBuildInfo, updateBuildInfo} from '../helpers/build';
|
|
6
9
|
import {appiumPackageRoot, npmPackage} from '../utils';
|
|
7
|
-
import {updateBuildInfo, getBuildInfo} from '../helpers/build';
|
|
8
10
|
|
|
9
11
|
const MIN_NODE_VERSION = (npmPackage.engines as Record<string, string>).node;
|
|
10
12
|
|
|
@@ -24,9 +26,7 @@ interface DebugInfoInput {
|
|
|
24
26
|
export function checkNodeOk(): void {
|
|
25
27
|
const version = getNodeVersion();
|
|
26
28
|
if (!semver.satisfies(version, MIN_NODE_VERSION)) {
|
|
27
|
-
throw new Error(
|
|
28
|
-
`Node version must be at least ${MIN_NODE_VERSION}; current is ${version.version}`,
|
|
29
|
-
);
|
|
29
|
+
throw new Error(`Node version must be at least ${MIN_NODE_VERSION}; current is ${version.version}`);
|
|
30
30
|
}
|
|
31
31
|
}
|
|
32
32
|
|
|
@@ -67,9 +67,7 @@ export function adjustNodePath(): void {
|
|
|
67
67
|
if (refreshRequirePaths()) {
|
|
68
68
|
process.env.APPIUM_OMIT_PEER_DEPS = '1';
|
|
69
69
|
} else {
|
|
70
|
-
process.env.NODE_PATH = nodePathParts
|
|
71
|
-
.filter((p) => p !== appiumModuleSearchRoot)
|
|
72
|
-
.join(path.delimiter);
|
|
70
|
+
process.env.NODE_PATH = nodePathParts.filter((p) => p !== appiumModuleSearchRoot).join(path.delimiter);
|
|
73
71
|
}
|
|
74
72
|
}
|
|
75
73
|
|
|
@@ -77,17 +75,12 @@ export function adjustNodePath(): void {
|
|
|
77
75
|
* Prints JSON debug info (OS, Node/npm, Appium build, installed drivers/plugins) to stdout.
|
|
78
76
|
* Input combines extension config snapshots with the resolved Appium home path.
|
|
79
77
|
*/
|
|
80
|
-
export async function showDebugInfo({
|
|
81
|
-
driverConfig,
|
|
82
|
-
pluginConfig,
|
|
83
|
-
appiumHome,
|
|
84
|
-
}: DebugInfoInput): Promise<void> {
|
|
78
|
+
export async function showDebugInfo({driverConfig, pluginConfig, appiumHome}: DebugInfoInput): Promise<void> {
|
|
85
79
|
const getNpmVersion = async (): Promise<string> => {
|
|
86
80
|
const {stdout} = await npm.exec('--version', [], {cwd: process.cwd()});
|
|
87
81
|
return stdout.trim();
|
|
88
82
|
};
|
|
89
|
-
const findNpmLocation = async (): Promise<string> =>
|
|
90
|
-
await fs.which(system.isWindows() ? 'npm.cmd' : 'npm');
|
|
83
|
+
const findNpmLocation = async (): Promise<string> => await fs.which(system.isWindows() ? 'npm.cmd' : 'npm');
|
|
91
84
|
|
|
92
85
|
const [npmVersion, npmLocation] = await Promise.all([
|
|
93
86
|
...[getNpmVersion, findNpmLocation].map((f) => getSafeResult(f, 'unknown')),
|
|
@@ -131,11 +124,7 @@ export async function showDebugInfo({
|
|
|
131
124
|
*
|
|
132
125
|
* @throws {Error}
|
|
133
126
|
*/
|
|
134
|
-
export async function requireDir(
|
|
135
|
-
root: string,
|
|
136
|
-
requireWriteable = true,
|
|
137
|
-
displayName = 'folder path',
|
|
138
|
-
): Promise<void> {
|
|
127
|
+
export async function requireDir(root: string, requireWriteable = true, displayName = 'folder path'): Promise<void> {
|
|
139
128
|
let stat;
|
|
140
129
|
try {
|
|
141
130
|
stat = await fs.stat(root);
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
/* eslint-disable no-console */
|
|
2
2
|
import {util} from '@appium/support';
|
|
3
|
-
import {getDefaultsForSchema, getAllArgSpecs} from '../schema/schema';
|
|
4
3
|
import type {Args} from 'appium/types';
|
|
5
|
-
|
|
4
|
+
|
|
5
|
+
import {getAllArgSpecs, getDefaultsForSchema} from '../schema/schema';
|
|
6
6
|
import {difference, getPath, pickBy, setPath} from '../utils';
|
|
7
|
+
import type {ReadConfigFileResult} from './config-file';
|
|
7
8
|
|
|
8
9
|
interface FlattenedArg {
|
|
9
10
|
value: unknown;
|
|
@@ -22,16 +23,13 @@ export function getNonDefaultServerArgs(parsedArgs: Args): Args {
|
|
|
22
23
|
*/
|
|
23
24
|
const flatten = (args: Args): Record<string, FlattenedArg> => {
|
|
24
25
|
const argSpecs = getAllArgSpecs();
|
|
25
|
-
const flattened = [...argSpecs.values()].reduce<Record<string, FlattenedArg>>(
|
|
26
|
-
(
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
},
|
|
33
|
-
{},
|
|
34
|
-
);
|
|
26
|
+
const flattened = [...argSpecs.values()].reduce<Record<string, FlattenedArg>>((acc, argSpec: {dest: string}) => {
|
|
27
|
+
const value = getPath(args, argSpec.dest);
|
|
28
|
+
if (value !== undefined) {
|
|
29
|
+
acc[argSpec.dest] = {value, argSpec};
|
|
30
|
+
}
|
|
31
|
+
return acc;
|
|
32
|
+
}, {});
|
|
35
33
|
|
|
36
34
|
return flattened;
|
|
37
35
|
};
|
|
@@ -39,8 +37,7 @@ export function getNonDefaultServerArgs(parsedArgs: Args): Args {
|
|
|
39
37
|
const args = flatten(parsedArgs);
|
|
40
38
|
|
|
41
39
|
// hopefully these function names are descriptive enough
|
|
42
|
-
const typesDiffer = (dest: string): boolean =>
|
|
43
|
-
typeof args[dest].value !== typeof defaultsFromSchema[dest];
|
|
40
|
+
const typesDiffer = (dest: string): boolean => typeof args[dest].value !== typeof defaultsFromSchema[dest];
|
|
44
41
|
|
|
45
42
|
const defaultValueIsArray = (dest: string): boolean => Array.isArray(defaultsFromSchema[dest]);
|
|
46
43
|
|
|
@@ -53,11 +50,9 @@ export function getNonDefaultServerArgs(parsedArgs: Args): Args {
|
|
|
53
50
|
|
|
54
51
|
const defaultIsDefined = (dest: string): boolean => defaultsFromSchema[dest] !== undefined;
|
|
55
52
|
|
|
56
|
-
const argValueNotArrayOrArraysDiffer = (dest: string) =>
|
|
57
|
-
!argsValueIsArray(dest) || arraysDiffer(dest);
|
|
53
|
+
const argValueNotArrayOrArraysDiffer = (dest: string) => !argsValueIsArray(dest) || arraysDiffer(dest);
|
|
58
54
|
|
|
59
|
-
const defaultValueNotArrayAndValuesDiffer = (dest: string) =>
|
|
60
|
-
!defaultValueIsArray(dest) && valuesDiffer(dest);
|
|
55
|
+
const defaultValueNotArrayAndValuesDiffer = (dest: string) => !defaultValueIsArray(dest) && valuesDiffer(dest);
|
|
61
56
|
|
|
62
57
|
/**
|
|
63
58
|
* This used to be a hideous conditional, but it's broken up into a hideous function instead.
|
package/lib/cli/args.ts
CHANGED
|
@@ -1,26 +1,24 @@
|
|
|
1
1
|
import {util} from '@appium/support';
|
|
2
|
-
import type {ArgumentOptions} from 'argparse';
|
|
3
2
|
import type {ExtensionType} from '@appium/types';
|
|
4
3
|
import type {CliExtensionSubcommand} from 'appium/types';
|
|
4
|
+
import type {ArgumentOptions} from 'argparse';
|
|
5
|
+
|
|
5
6
|
import {
|
|
6
7
|
DRIVER_TYPE,
|
|
7
|
-
|
|
8
|
+
EXT_SUBCOMMAND_DOCTOR,
|
|
8
9
|
EXT_SUBCOMMAND_INSTALL,
|
|
9
10
|
EXT_SUBCOMMAND_LIST,
|
|
10
11
|
EXT_SUBCOMMAND_RUN,
|
|
11
12
|
EXT_SUBCOMMAND_UNINSTALL,
|
|
12
13
|
EXT_SUBCOMMAND_UPDATE,
|
|
13
|
-
|
|
14
|
+
PLUGIN_TYPE,
|
|
14
15
|
} from '../constants';
|
|
15
16
|
import {INSTALL_TYPES} from '../extension/extension-config';
|
|
16
17
|
import {toParserArgs} from '../schema/cli-args';
|
|
17
18
|
const DRIVER_EXAMPLE = 'xcuitest';
|
|
18
19
|
const PLUGIN_EXAMPLE = 'images';
|
|
19
20
|
|
|
20
|
-
export type ArgumentDefinitions = Map<
|
|
21
|
-
[name: string] | [name: string, alias: string],
|
|
22
|
-
ArgumentOptions
|
|
23
|
-
>;
|
|
21
|
+
export type ArgumentDefinitions = Map<[name: string] | [name: string, alias: string], ArgumentOptions>;
|
|
24
22
|
|
|
25
23
|
/**
|
|
26
24
|
* This is necessary because we pass the array into `argparse`. `argparse` is bad and mutates things. We don't want that.
|
|
@@ -53,10 +51,7 @@ export const getExtensionArgs = util.memoize(function getExtensionArgs(): Record
|
|
|
53
51
|
ExtensionType,
|
|
54
52
|
Record<CliExtensionSubcommand, ArgumentDefinitions>
|
|
55
53
|
> {
|
|
56
|
-
const extensionArgs = {} as Record<
|
|
57
|
-
ExtensionType,
|
|
58
|
-
Record<CliExtensionSubcommand, ArgumentDefinitions>
|
|
59
|
-
>;
|
|
54
|
+
const extensionArgs = {} as Record<ExtensionType, Record<CliExtensionSubcommand, ArgumentDefinitions>>;
|
|
60
55
|
for (const type of EXTENSION_TYPES) {
|
|
61
56
|
extensionArgs[type] = {
|
|
62
57
|
[EXT_SUBCOMMAND_LIST]: makeListArgs(type),
|
|
@@ -130,8 +125,7 @@ function makeInstallArgs(type: ExtensionType): ArgumentDefinitions {
|
|
|
130
125
|
{
|
|
131
126
|
type: 'str',
|
|
132
127
|
help:
|
|
133
|
-
`Name of the ${type} to install, for example: ` +
|
|
134
|
-
(type === DRIVER_TYPE ? DRIVER_EXAMPLE : PLUGIN_EXAMPLE),
|
|
128
|
+
`Name of the ${type} to install, for example: ` + (type === DRIVER_TYPE ? DRIVER_EXAMPLE : PLUGIN_EXAMPLE),
|
|
135
129
|
},
|
|
136
130
|
],
|
|
137
131
|
[
|
|
@@ -152,9 +146,7 @@ function makeInstallArgs(type: ExtensionType): ArgumentDefinitions {
|
|
|
152
146
|
required: false,
|
|
153
147
|
default: null,
|
|
154
148
|
type: 'str',
|
|
155
|
-
help:
|
|
156
|
-
`The Node.js package name of the ${type}. ` +
|
|
157
|
-
`Required if "source" is set to "git" or "github".`,
|
|
149
|
+
help: `The Node.js package name of the ${type}. ` + `Required if "source" is set to "git" or "github".`,
|
|
158
150
|
dest: 'packageName',
|
|
159
151
|
},
|
|
160
152
|
],
|
|
@@ -172,8 +164,7 @@ function makeUninstallArgs(type: ExtensionType): ArgumentDefinitions {
|
|
|
172
164
|
{
|
|
173
165
|
type: 'str',
|
|
174
166
|
help:
|
|
175
|
-
`Name of the ${type} to uninstall, for example: ` +
|
|
176
|
-
(type === DRIVER_TYPE ? DRIVER_EXAMPLE : PLUGIN_EXAMPLE),
|
|
167
|
+
`Name of the ${type} to uninstall, for example: ` + (type === DRIVER_TYPE ? DRIVER_EXAMPLE : PLUGIN_EXAMPLE),
|
|
177
168
|
},
|
|
178
169
|
],
|
|
179
170
|
]);
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import {console, util} from '@appium/support';
|
|
2
2
|
import type {ExtMetadata, ExtRecord, InstallType} from 'appium/types';
|
|
3
|
-
|
|
3
|
+
|
|
4
|
+
import {KNOWN_DRIVERS} from '../constants';
|
|
5
|
+
import {ExtensionCliCommand} from './extension-command';
|
|
4
6
|
import type {
|
|
5
7
|
ExtensionArgs,
|
|
6
8
|
ExtensionCommandOptions,
|
|
@@ -8,7 +10,6 @@ import type {
|
|
|
8
10
|
PostInstallText,
|
|
9
11
|
RunOutput,
|
|
10
12
|
} from './extension-command';
|
|
11
|
-
import {KNOWN_DRIVERS} from '../constants';
|
|
12
13
|
const REQ_DRIVER_FIELDS = ['driverName', 'automationName', 'platformNames', 'mainClass'];
|
|
13
14
|
type DriverInstallOpts = {driver: string; installType: InstallType; packageName?: string};
|
|
14
15
|
type DriverUninstallOpts = {driver: string};
|
|
@@ -27,11 +28,7 @@ export default class DriverCliCommand extends ExtensionCliCommand<'driver'> {
|
|
|
27
28
|
*
|
|
28
29
|
* @param opts - install options
|
|
29
30
|
*/
|
|
30
|
-
async install({
|
|
31
|
-
driver,
|
|
32
|
-
installType,
|
|
33
|
-
packageName,
|
|
34
|
-
}: DriverInstallOpts): Promise<ExtRecord<'driver'>> {
|
|
31
|
+
async install({driver, installType, packageName}: DriverInstallOpts): Promise<ExtRecord<'driver'>> {
|
|
35
32
|
return await super._install({
|
|
36
33
|
installSpec: driver,
|
|
37
34
|
installType,
|
|
@@ -108,13 +105,9 @@ export default class DriverCliCommand extends ExtensionCliCommand<'driver'> {
|
|
|
108
105
|
* @param driverMetadata - `appium` metadata from extension package
|
|
109
106
|
* @param installSpec - install spec from CLI
|
|
110
107
|
*/
|
|
111
|
-
override validateExtensionFields(
|
|
112
|
-
driverMetadata: ExtMetadata<'driver'>,
|
|
113
|
-
installSpec: string,
|
|
114
|
-
): void {
|
|
108
|
+
override validateExtensionFields(driverMetadata: ExtMetadata<'driver'>, installSpec: string): void {
|
|
115
109
|
const missingFields = REQ_DRIVER_FIELDS.reduce<string[]>(
|
|
116
|
-
(acc, field) =>
|
|
117
|
-
driverMetadata[field as keyof typeof driverMetadata] ? acc : [...acc, field],
|
|
110
|
+
(acc, field) => (driverMetadata[field as keyof typeof driverMetadata] ? acc : [...acc, field]),
|
|
118
111
|
[],
|
|
119
112
|
);
|
|
120
113
|
|