appium 2.5.4 → 2.7.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/README.md +23 -0
- package/build/lib/appium.d.ts.map +1 -1
- package/build/lib/appium.js +12 -1
- package/build/lib/appium.js.map +1 -1
- package/build/lib/cli/args.d.ts.map +1 -1
- package/build/lib/cli/args.js +10 -0
- package/build/lib/cli/args.js.map +1 -1
- package/build/lib/cli/parser.d.ts +5 -0
- package/build/lib/cli/parser.d.ts.map +1 -1
- package/build/lib/cli/parser.js +38 -1
- package/build/lib/cli/parser.js.map +1 -1
- package/build/lib/cli/setup-command.d.ts +37 -0
- package/build/lib/cli/setup-command.d.ts.map +1 -0
- package/build/lib/cli/setup-command.js +173 -0
- package/build/lib/cli/setup-command.js.map +1 -0
- package/build/lib/config.d.ts +38 -18
- package/build/lib/config.d.ts.map +1 -1
- package/build/lib/config.js +75 -3
- package/build/lib/config.js.map +1 -1
- package/build/lib/constants.d.ts +21 -2
- package/build/lib/constants.d.ts.map +1 -1
- package/build/lib/constants.js +24 -7
- package/build/lib/constants.js.map +1 -1
- package/build/lib/grid-register.js +2 -2
- package/build/lib/grid-register.js.map +1 -1
- package/build/lib/logsink.d.ts.map +1 -1
- package/build/lib/logsink.js +32 -14
- package/build/lib/logsink.js.map +1 -1
- package/build/lib/main.d.ts +1 -0
- package/build/lib/main.d.ts.map +1 -1
- package/build/lib/main.js +15 -1
- package/build/lib/main.js.map +1 -1
- package/build/lib/utils.d.ts +13 -3
- package/build/lib/utils.d.ts.map +1 -1
- package/build/lib/utils.js +15 -3
- package/build/lib/utils.js.map +1 -1
- package/build/types/cli.d.ts +23 -6
- package/build/types/cli.d.ts.map +1 -1
- package/lib/appium.js +15 -1
- package/lib/cli/args.js +10 -0
- package/lib/cli/parser.js +52 -2
- package/lib/cli/setup-command.js +185 -0
- package/lib/config.js +81 -20
- package/lib/constants.js +31 -6
- package/lib/grid-register.js +2 -2
- package/lib/logsink.js +31 -12
- package/lib/main.js +17 -1
- package/lib/utils.js +15 -3
- package/package.json +14 -15
- package/types/cli.ts +33 -8
package/lib/config.js
CHANGED
|
@@ -1,16 +1,18 @@
|
|
|
1
1
|
/* eslint-disable no-console */
|
|
2
2
|
import _ from 'lodash';
|
|
3
|
-
import {system, fs} from '@appium/support';
|
|
3
|
+
import {system, fs, npm} from '@appium/support';
|
|
4
4
|
import axios from 'axios';
|
|
5
5
|
import {exec} from 'teen_process';
|
|
6
6
|
import semver from 'semver';
|
|
7
7
|
import os from 'node:os';
|
|
8
8
|
import {npmPackage} from './utils';
|
|
9
|
+
import B from 'bluebird';
|
|
9
10
|
import {getDefaultsForSchema, getAllArgSpecs} from './schema/schema';
|
|
10
11
|
|
|
11
12
|
export const APPIUM_VER = npmPackage.version;
|
|
12
13
|
const ENGINES = /** @type {Record<string,string>} */ (npmPackage.engines);
|
|
13
14
|
const MIN_NODE_VERSION = ENGINES.node;
|
|
15
|
+
export const rootDir = fs.findRoot(__dirname);
|
|
14
16
|
|
|
15
17
|
const GIT_BINARY = `git${system.isWindows() ? '.exe' : ''}`;
|
|
16
18
|
const GITHUB_API = 'https://api.github.com/repos/appium/appium';
|
|
@@ -28,8 +30,9 @@ function getNodeVersion() {
|
|
|
28
30
|
|
|
29
31
|
/**
|
|
30
32
|
* @param {boolean} [useGithubApiFallback]
|
|
33
|
+
* @returns {Promise<void>}
|
|
31
34
|
*/
|
|
32
|
-
async function updateBuildInfo(useGithubApiFallback = false) {
|
|
35
|
+
export async function updateBuildInfo(useGithubApiFallback = false) {
|
|
33
36
|
const sha = await getGitRev(useGithubApiFallback);
|
|
34
37
|
if (!sha) {
|
|
35
38
|
return;
|
|
@@ -50,11 +53,61 @@ const getFullGitPath = _.memoize(async function getFullGitPath() {
|
|
|
50
53
|
}
|
|
51
54
|
});
|
|
52
55
|
|
|
56
|
+
/**
|
|
57
|
+
* Prints server debug into into the console.
|
|
58
|
+
*
|
|
59
|
+
* @param {{
|
|
60
|
+
* driverConfig: import('./extension/driver-config').DriverConfig,
|
|
61
|
+
* pluginConfig: import('./extension/plugin-config').PluginConfig,
|
|
62
|
+
* appiumHome: string
|
|
63
|
+
* }} info
|
|
64
|
+
* @returns {Promise<void>}
|
|
65
|
+
*/
|
|
66
|
+
export async function showDebugInfo({driverConfig, pluginConfig, appiumHome}) {
|
|
67
|
+
const getNpmVersion = async () => {
|
|
68
|
+
const {stdout} = await npm.exec('--version', [], {cwd: process.cwd()});
|
|
69
|
+
return _.trim(stdout);
|
|
70
|
+
};
|
|
71
|
+
const findNpmLocation = async () => await fs.which(system.isWindows() ? 'npm.cmd' : 'npm');
|
|
72
|
+
const [npmVersion, npmLocation] = await B.all([
|
|
73
|
+
...([getNpmVersion, findNpmLocation].map((f) => getSafeResult(f, 'unknown'))),
|
|
74
|
+
/** @type {any} */ (updateBuildInfo()),
|
|
75
|
+
]);
|
|
76
|
+
const debugInfo = {
|
|
77
|
+
os: {
|
|
78
|
+
platform: os.platform(),
|
|
79
|
+
release: os.release(),
|
|
80
|
+
arch: os.arch(),
|
|
81
|
+
homedir: os.homedir(),
|
|
82
|
+
username: os.userInfo().username,
|
|
83
|
+
},
|
|
84
|
+
node: {
|
|
85
|
+
version: process.version,
|
|
86
|
+
arch: process.arch,
|
|
87
|
+
cwd: process.cwd(),
|
|
88
|
+
argv: process.argv,
|
|
89
|
+
env: process.env,
|
|
90
|
+
npm: {
|
|
91
|
+
location: npmLocation,
|
|
92
|
+
version: npmVersion,
|
|
93
|
+
},
|
|
94
|
+
},
|
|
95
|
+
appium: {
|
|
96
|
+
location: rootDir,
|
|
97
|
+
homedir: appiumHome,
|
|
98
|
+
build: getBuildInfo(),
|
|
99
|
+
drivers: driverConfig.installedExtensions,
|
|
100
|
+
plugins: pluginConfig.installedExtensions,
|
|
101
|
+
},
|
|
102
|
+
};
|
|
103
|
+
console.log(JSON.stringify(debugInfo, null, 2));
|
|
104
|
+
}
|
|
105
|
+
|
|
53
106
|
/**
|
|
54
107
|
* @param {boolean} [useGithubApiFallback]
|
|
55
108
|
* @returns {Promise<string?>}
|
|
56
109
|
*/
|
|
57
|
-
async function getGitRev(useGithubApiFallback = false) {
|
|
110
|
+
export async function getGitRev(useGithubApiFallback = false) {
|
|
58
111
|
const fullGitPath = await getFullGitPath();
|
|
59
112
|
if (fullGitPath) {
|
|
60
113
|
try {
|
|
@@ -122,11 +175,15 @@ async function getGitTimestamp(commitSha, useGithubApiFallback = false) {
|
|
|
122
175
|
* and succeeds.
|
|
123
176
|
* @returns {import('appium/types').BuildInfo}
|
|
124
177
|
*/
|
|
125
|
-
function getBuildInfo() {
|
|
178
|
+
export function getBuildInfo() {
|
|
126
179
|
return BUILD_INFO;
|
|
127
180
|
}
|
|
128
181
|
|
|
129
|
-
|
|
182
|
+
/**
|
|
183
|
+
* @returns {void}
|
|
184
|
+
* @throws {Error} If Node version is outside of the supported range
|
|
185
|
+
*/
|
|
186
|
+
export function checkNodeOk() {
|
|
130
187
|
const version = getNodeVersion();
|
|
131
188
|
if (!semver.satisfies(version, MIN_NODE_VERSION)) {
|
|
132
189
|
throw new Error(
|
|
@@ -135,7 +192,7 @@ function checkNodeOk() {
|
|
|
135
192
|
}
|
|
136
193
|
}
|
|
137
194
|
|
|
138
|
-
async function showBuildInfo() {
|
|
195
|
+
export async function showBuildInfo() {
|
|
139
196
|
await updateBuildInfo(true);
|
|
140
197
|
console.log(JSON.stringify(getBuildInfo())); // eslint-disable-line no-console
|
|
141
198
|
}
|
|
@@ -145,7 +202,7 @@ async function showBuildInfo() {
|
|
|
145
202
|
* @param {Args} parsedArgs
|
|
146
203
|
* @returns {Args}
|
|
147
204
|
*/
|
|
148
|
-
function getNonDefaultServerArgs(parsedArgs) {
|
|
205
|
+
export function getNonDefaultServerArgs(parsedArgs) {
|
|
149
206
|
/**
|
|
150
207
|
* Flattens parsed args into a single level object for comparison with
|
|
151
208
|
* flattened defaults across server args and extension args.
|
|
@@ -253,7 +310,7 @@ const compactConfig = _.partial(
|
|
|
253
310
|
* @param {Partial<ParsedArgs>} defaults - Configuration defaults from schemas
|
|
254
311
|
* @param {ParsedArgs} parsedArgs - Entire parsed args object
|
|
255
312
|
*/
|
|
256
|
-
function showConfig(nonDefaultPreConfigParsedArgs, configResult, defaults, parsedArgs) {
|
|
313
|
+
export function showConfig(nonDefaultPreConfigParsedArgs, configResult, defaults, parsedArgs) {
|
|
257
314
|
console.log('Appium Configuration\n');
|
|
258
315
|
console.log('from defaults:\n');
|
|
259
316
|
console.dir(compactConfig(defaults));
|
|
@@ -308,18 +365,22 @@ export async function requireDir(root, requireWriteable = true, displayName = 'f
|
|
|
308
365
|
}
|
|
309
366
|
}
|
|
310
367
|
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
368
|
+
/**
|
|
369
|
+
* Calculates the result of the given function and return its value
|
|
370
|
+
* or the default one if there was an exception.
|
|
371
|
+
*
|
|
372
|
+
* @template T
|
|
373
|
+
* @param {() => Promise<T>} f
|
|
374
|
+
* @param {T} defaultValue
|
|
375
|
+
* @returns {Promise<T>}
|
|
376
|
+
*/
|
|
377
|
+
async function getSafeResult(f, defaultValue) {
|
|
378
|
+
try {
|
|
379
|
+
return await f();
|
|
380
|
+
} catch {
|
|
381
|
+
return defaultValue;
|
|
382
|
+
}
|
|
383
|
+
}
|
|
323
384
|
|
|
324
385
|
/**
|
|
325
386
|
* @typedef {import('appium/types').ParsedArgs} ParsedArgs
|
package/lib/constants.js
CHANGED
|
@@ -15,6 +15,12 @@ export const PLUGIN_TYPE = 'plugin';
|
|
|
15
15
|
*/
|
|
16
16
|
export const SERVER_SUBCOMMAND = 'server';
|
|
17
17
|
|
|
18
|
+
/**
|
|
19
|
+
* The `setup` command of the `appium` CLI
|
|
20
|
+
*/
|
|
21
|
+
export const SETUP_SUBCOMMAND = 'setup';
|
|
22
|
+
|
|
23
|
+
|
|
18
24
|
/**
|
|
19
25
|
* The value of `--use-plugins` if _all_ plugins should be loaded
|
|
20
26
|
*/
|
|
@@ -33,22 +39,41 @@ export const KNOWN_PLUGINS = Object.freeze(
|
|
|
33
39
|
}),
|
|
34
40
|
);
|
|
35
41
|
|
|
36
|
-
|
|
37
|
-
// The drivers in this list will be available to the CLI so users can just
|
|
38
|
-
// type 'appium driver install 'name'', rather than having to specify the full
|
|
39
|
-
// npm package. I.e., these are the officially recognized drivers.
|
|
40
|
-
export const KNOWN_DRIVERS = Object.freeze(
|
|
42
|
+
export const MOBILE_DRIVERS = Object.freeze(
|
|
41
43
|
/** @type {const} */ ({
|
|
42
44
|
uiautomator2: 'appium-uiautomator2-driver',
|
|
43
45
|
xcuitest: 'appium-xcuitest-driver',
|
|
44
|
-
mac2: 'appium-mac2-driver',
|
|
45
46
|
espresso: 'appium-espresso-driver',
|
|
47
|
+
}),
|
|
48
|
+
);
|
|
49
|
+
|
|
50
|
+
export const DESKTOP_DRIVERS = Object.freeze(
|
|
51
|
+
/** @type {const} */ ({
|
|
52
|
+
mac2: 'appium-mac2-driver',
|
|
53
|
+
windows: 'appium-windows-driver',
|
|
54
|
+
}),
|
|
55
|
+
);
|
|
56
|
+
|
|
57
|
+
export const DESKTOP_BROWSERS = Object.freeze(
|
|
58
|
+
/** @type {const} */ ({
|
|
46
59
|
safari: 'appium-safari-driver',
|
|
47
60
|
gecko: 'appium-geckodriver',
|
|
48
61
|
chromium: 'appium-chromium-driver',
|
|
49
62
|
}),
|
|
50
63
|
);
|
|
51
64
|
|
|
65
|
+
// This is a map of driver names to npm packages representing those drivers.
|
|
66
|
+
// The drivers in this list will be available to the CLI so users can just
|
|
67
|
+
// type 'appium driver install 'name'', rather than having to specify the full
|
|
68
|
+
// npm package. I.e., these are the officially recognized drivers.
|
|
69
|
+
export const KNOWN_DRIVERS = Object.freeze(
|
|
70
|
+
/** @type {const} */ ({
|
|
71
|
+
...MOBILE_DRIVERS,
|
|
72
|
+
...DESKTOP_DRIVERS,
|
|
73
|
+
...DESKTOP_BROWSERS,
|
|
74
|
+
}),
|
|
75
|
+
);
|
|
76
|
+
|
|
52
77
|
/**
|
|
53
78
|
* Relative path to directory containing any Appium internal files
|
|
54
79
|
*/
|
package/lib/grid-register.js
CHANGED
|
@@ -57,13 +57,13 @@ function postRequest(configHolder, addr, port, basePath) {
|
|
|
57
57
|
// Move Selenium 3 configuration properties to configuration object
|
|
58
58
|
if (!_.has(configHolder, 'configuration')) {
|
|
59
59
|
let configuration = {};
|
|
60
|
-
for (const property in configHolder) {
|
|
60
|
+
for (const property in /** @type {import('@appium/types').StringRecord} */ (configHolder)) {
|
|
61
61
|
if (_.has(configHolder, property) && property !== 'capabilities') {
|
|
62
62
|
configuration[property] = configHolder[property];
|
|
63
63
|
delete configHolder[property];
|
|
64
64
|
}
|
|
65
65
|
}
|
|
66
|
-
configHolder.configuration = configuration;
|
|
66
|
+
/** @type {import('@appium/types').StringRecord} */ (configHolder).configuration = configuration;
|
|
67
67
|
}
|
|
68
68
|
|
|
69
69
|
// if the node config does not have the appium/webdriver url, host, and port,
|
package/lib/logsink.js
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import
|
|
1
|
+
import globalLog from '@appium/logger';
|
|
2
2
|
import {createLogger, format, transports} from 'winston';
|
|
3
3
|
import {fs, logger} from '@appium/support';
|
|
4
4
|
import { APPIUM_LOGGER_NAME } from './logger';
|
|
5
5
|
import _ from 'lodash';
|
|
6
6
|
|
|
7
7
|
// set up distributed logging before everything else
|
|
8
|
-
logger.patchLogger(
|
|
9
|
-
global._global_npmlog =
|
|
8
|
+
logger.patchLogger(globalLog);
|
|
9
|
+
global._global_npmlog = globalLog;
|
|
10
10
|
|
|
11
11
|
// npmlog is used only for emitting, we use winston for output
|
|
12
|
-
|
|
12
|
+
globalLog.level = 'info';
|
|
13
13
|
const levels = {
|
|
14
14
|
debug: 4,
|
|
15
15
|
info: 3,
|
|
@@ -131,8 +131,13 @@ function createHttpTransport(args, logLvl) {
|
|
|
131
131
|
});
|
|
132
132
|
}
|
|
133
133
|
|
|
134
|
+
/**
|
|
135
|
+
*
|
|
136
|
+
* @param {import('@appium/types').StringRecord} args
|
|
137
|
+
* @returns {Promise<import('winston-transport')[]>}
|
|
138
|
+
*/
|
|
134
139
|
async function createTransports(args) {
|
|
135
|
-
|
|
140
|
+
const transports = [];
|
|
136
141
|
let consoleLogLevel = null;
|
|
137
142
|
let fileLogLevel = null;
|
|
138
143
|
|
|
@@ -193,7 +198,7 @@ function getColorizedPrefix(prefix) {
|
|
|
193
198
|
}
|
|
194
199
|
|
|
195
200
|
async function init(args) {
|
|
196
|
-
|
|
201
|
+
globalLog.level = 'silent';
|
|
197
202
|
|
|
198
203
|
// set de facto param passed to timestamp function
|
|
199
204
|
useLocalTimeZone = args.localTimezone;
|
|
@@ -201,13 +206,16 @@ async function init(args) {
|
|
|
201
206
|
// clean up in case we have initiated before since npmlog is a global object
|
|
202
207
|
clear();
|
|
203
208
|
|
|
209
|
+
const transports = await createTransports(args);
|
|
210
|
+
const transportNames = new Set(transports.map((tr) => tr.constructor.name));
|
|
204
211
|
log = createLogger({
|
|
205
|
-
transports
|
|
212
|
+
transports,
|
|
206
213
|
levels,
|
|
207
214
|
});
|
|
208
215
|
|
|
216
|
+
const reportedLoggerErrors = new Set();
|
|
209
217
|
// Capture logs emitted via npmlog and pass them through winston
|
|
210
|
-
|
|
218
|
+
globalLog.on('log', ({level, message, prefix}) => {
|
|
211
219
|
const winstonLevel = npmToWinstonLevels[level] || 'info';
|
|
212
220
|
let msg = message;
|
|
213
221
|
if (prefix) {
|
|
@@ -217,9 +225,20 @@ async function init(args) {
|
|
|
217
225
|
: getColorizedPrefix(decoratedPrefix);
|
|
218
226
|
msg = `${args.logNoColors ? decoratedPrefix : toColorizedDecoratedPrefix()} ${msg}`;
|
|
219
227
|
}
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
args.logHandler
|
|
228
|
+
try {
|
|
229
|
+
log[winstonLevel](msg);
|
|
230
|
+
if (_.isFunction(args.logHandler)) {
|
|
231
|
+
args.logHandler(level, msg);
|
|
232
|
+
}
|
|
233
|
+
} catch (e) {
|
|
234
|
+
if (!reportedLoggerErrors.has(e.message) && process.stderr.writable) {
|
|
235
|
+
// eslint-disable-next-line no-console
|
|
236
|
+
console.error(
|
|
237
|
+
`The log message '${_.truncate(msg, {length: 30})}' cannot be written into ` +
|
|
238
|
+
`one or more requested destinations: ${transportNames}. Original error: ${e.message}`
|
|
239
|
+
);
|
|
240
|
+
reportedLoggerErrors.add(e.message);
|
|
241
|
+
}
|
|
223
242
|
}
|
|
224
243
|
});
|
|
225
244
|
}
|
|
@@ -230,7 +249,7 @@ function clear() {
|
|
|
230
249
|
log.remove(transport);
|
|
231
250
|
}
|
|
232
251
|
}
|
|
233
|
-
|
|
252
|
+
globalLog.removeAllListeners('log');
|
|
234
253
|
}
|
|
235
254
|
|
|
236
255
|
export {init, clear};
|
package/lib/main.js
CHANGED
|
@@ -13,6 +13,7 @@ import {asyncify} from 'asyncbox';
|
|
|
13
13
|
import _ from 'lodash';
|
|
14
14
|
import {AppiumDriver} from './appium';
|
|
15
15
|
import {runExtensionCommand} from './cli/extension';
|
|
16
|
+
import { runSetupCommand } from './cli/setup-command';
|
|
16
17
|
import {getParser} from './cli/parser';
|
|
17
18
|
import {
|
|
18
19
|
APPIUM_VER,
|
|
@@ -21,6 +22,7 @@ import {
|
|
|
21
22
|
getNonDefaultServerArgs,
|
|
22
23
|
showConfig,
|
|
23
24
|
showBuildInfo,
|
|
25
|
+
showDebugInfo,
|
|
24
26
|
requireDir,
|
|
25
27
|
} from './config';
|
|
26
28
|
import {readConfigFile} from './config-file';
|
|
@@ -38,6 +40,7 @@ import {
|
|
|
38
40
|
fetchInterfaces,
|
|
39
41
|
V4_BROADCAST_IP,
|
|
40
42
|
V6_BROADCAST_IP,
|
|
43
|
+
isSetupCommandArgs,
|
|
41
44
|
} from './utils';
|
|
42
45
|
import net from 'node:net';
|
|
43
46
|
|
|
@@ -216,7 +219,7 @@ async function init(args) {
|
|
|
216
219
|
}
|
|
217
220
|
|
|
218
221
|
// merge config and apply defaults.
|
|
219
|
-
// the order of
|
|
222
|
+
// the order of precedence is:
|
|
220
223
|
// 1. command line args
|
|
221
224
|
// 2. config file
|
|
222
225
|
// 3. defaults from config file.
|
|
@@ -231,6 +234,15 @@ async function init(args) {
|
|
|
231
234
|
return /** @type {InitResult<Cmd>} */ ({});
|
|
232
235
|
}
|
|
233
236
|
|
|
237
|
+
if (preConfigArgs.showDebugInfo) {
|
|
238
|
+
await showDebugInfo({
|
|
239
|
+
driverConfig,
|
|
240
|
+
pluginConfig,
|
|
241
|
+
appiumHome,
|
|
242
|
+
});
|
|
243
|
+
return /** @type {InitResult<Cmd>} */ ({});
|
|
244
|
+
}
|
|
245
|
+
|
|
234
246
|
await logsinkInit(serverArgs);
|
|
235
247
|
|
|
236
248
|
if (serverArgs.logFilters) {
|
|
@@ -276,6 +288,9 @@ async function init(args) {
|
|
|
276
288
|
pluginConfig,
|
|
277
289
|
appiumHome,
|
|
278
290
|
});
|
|
291
|
+
} else if (isSetupCommandArgs(preConfigArgs)) {
|
|
292
|
+
await runSetupCommand(appiumHome, preConfigArgs, driverConfig, pluginConfig);
|
|
293
|
+
return /** @type {InitResult<Cmd>} */ ({});
|
|
279
294
|
} else {
|
|
280
295
|
await requireDir(appiumHome, true, appiumHomeSourceName);
|
|
281
296
|
if (isExtensionCommandArgs(preConfigArgs)) {
|
|
@@ -465,6 +480,7 @@ export {main, init, resolveAppiumHome};
|
|
|
465
480
|
* @typedef {import('appium/types').CliCommandServer} ServerCommand
|
|
466
481
|
* @typedef {import('appium/types').CliCommandDriver} DriverCommand
|
|
467
482
|
* @typedef {import('appium/types').CliCommandPlugin} PluginCommand
|
|
483
|
+
* @typedef {import('appium/types').CliCommandSetup} SetupCommand
|
|
468
484
|
* @typedef {import('./extension').DriverNameMap} DriverNameMap
|
|
469
485
|
* @typedef {import('./extension').PluginNameMap} PluginNameMap
|
|
470
486
|
*/
|
package/lib/utils.js
CHANGED
|
@@ -4,7 +4,7 @@ import {processCapabilities, PROTOCOLS, STANDARD_CAPS, errors} from '@appium/bas
|
|
|
4
4
|
import {inspect as dump} from 'util';
|
|
5
5
|
import {node, fs} from '@appium/support';
|
|
6
6
|
import path from 'path';
|
|
7
|
-
import {SERVER_SUBCOMMAND, DRIVER_TYPE, PLUGIN_TYPE} from './constants';
|
|
7
|
+
import {SERVER_SUBCOMMAND, DRIVER_TYPE, PLUGIN_TYPE, SETUP_SUBCOMMAND} from './constants';
|
|
8
8
|
import os from 'node:os';
|
|
9
9
|
|
|
10
10
|
const W3C_APPIUM_PREFIX = 'appium';
|
|
@@ -330,6 +330,16 @@ export function isServerCommandArgs(args) {
|
|
|
330
330
|
return args.subcommand === SERVER_SUBCOMMAND;
|
|
331
331
|
}
|
|
332
332
|
|
|
333
|
+
/**
|
|
334
|
+
* @template {CliCommand} Cmd
|
|
335
|
+
* @template {CliExtensionSubcommand|CliCommandSetupSubcommand|void} [SubCmd=void]
|
|
336
|
+
* @param {Args<Cmd, SubCmd>} args
|
|
337
|
+
* @returns {args is Args<SetupCommand>}
|
|
338
|
+
*/
|
|
339
|
+
export function isSetupCommandArgs(args) {
|
|
340
|
+
return args.subcommand === SETUP_SUBCOMMAND;
|
|
341
|
+
}
|
|
342
|
+
|
|
333
343
|
/**
|
|
334
344
|
* @template {CliCommand} [Cmd=ServerCommand]
|
|
335
345
|
* @template {CliExtensionSubcommand|void} [SubCmd=void]
|
|
@@ -451,19 +461,21 @@ export {
|
|
|
451
461
|
* @typedef {import('appium/types').CliCommand} CliCommand
|
|
452
462
|
* @typedef {import('appium/types').CliExtensionSubcommand} CliExtensionSubcommand
|
|
453
463
|
* @typedef {import('appium/types').CliExtensionCommand} CliExtensionCommand
|
|
464
|
+
* @typedef {import('appium/types').CliCommandSetupSubcommand} CliCommandSetupSubcommand
|
|
454
465
|
* @typedef {import('appium/types').CliCommandServer} ServerCommand
|
|
455
466
|
* @typedef {import('appium/types').CliCommandDriver} DriverCommand
|
|
456
467
|
* @typedef {import('appium/types').CliCommandPlugin} PluginCommand
|
|
468
|
+
* @typedef {import('appium/types').CliCommandSetup} SetupCommand
|
|
457
469
|
*/
|
|
458
470
|
|
|
459
471
|
/**
|
|
460
472
|
* @template {CliCommand} [Cmd=ServerCommand]
|
|
461
|
-
* @template {CliExtensionSubcommand|void} [SubCmd=void]
|
|
473
|
+
* @template {CliExtensionSubcommand|CliCommandSetupSubcommand|void} [SubCmd=void]
|
|
462
474
|
* @typedef {import('appium/types').Args<Cmd, SubCmd>} Args
|
|
463
475
|
*/
|
|
464
476
|
|
|
465
477
|
/**
|
|
466
478
|
* @template {CliCommand} [Cmd=ServerCommand]
|
|
467
|
-
* @template {CliExtensionSubcommand|void} [SubCmd=void]
|
|
479
|
+
* @template {CliExtensionSubcommand|CliCommandSetupSubcommand|void} [SubCmd=void]
|
|
468
480
|
* @typedef {import('appium/types').ParsedArgs<Cmd, SubCmd>} ParsedArgs
|
|
469
481
|
*/
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "appium",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.7.0",
|
|
4
4
|
"description": "Automation for Apps.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"automation",
|
|
@@ -60,12 +60,12 @@
|
|
|
60
60
|
"test:unit": "mocha \"./test/unit/**/*.spec.js\""
|
|
61
61
|
},
|
|
62
62
|
"dependencies": {
|
|
63
|
-
"@appium/base-driver": "^9.
|
|
64
|
-
"@appium/base-plugin": "^2.2.
|
|
65
|
-
"@appium/docutils": "^1.0.
|
|
63
|
+
"@appium/base-driver": "^9.8.0",
|
|
64
|
+
"@appium/base-plugin": "^2.2.33",
|
|
65
|
+
"@appium/docutils": "^1.0.9",
|
|
66
66
|
"@appium/schema": "~0.5.0",
|
|
67
|
-
"@appium/support": "^4.
|
|
68
|
-
"@appium/types": "^0.
|
|
67
|
+
"@appium/support": "^4.3.0",
|
|
68
|
+
"@appium/types": "^0.19.0",
|
|
69
69
|
"@sidvind/better-ajv-errors": "2.1.3",
|
|
70
70
|
"@types/argparse": "2.0.16",
|
|
71
71
|
"@types/bluebird": "3.5.42",
|
|
@@ -73,28 +73,27 @@
|
|
|
73
73
|
"@types/semver": "7.5.8",
|
|
74
74
|
"@types/teen_process": "2.0.4",
|
|
75
75
|
"@types/wrap-ansi": "3.0.0",
|
|
76
|
-
"ajv": "8.
|
|
76
|
+
"ajv": "8.16.0",
|
|
77
77
|
"ajv-formats": "3.0.1",
|
|
78
78
|
"argparse": "2.0.1",
|
|
79
79
|
"async-lock": "1.4.1",
|
|
80
80
|
"asyncbox": "3.0.0",
|
|
81
|
-
"axios": "1.
|
|
81
|
+
"axios": "1.7.2",
|
|
82
82
|
"bluebird": "3.7.2",
|
|
83
83
|
"cross-env": "7.0.3",
|
|
84
84
|
"lilconfig": "3.1.1",
|
|
85
85
|
"lodash": "4.17.21",
|
|
86
|
-
"npmlog": "7.0.1",
|
|
87
86
|
"ora": "5.4.1",
|
|
88
87
|
"package-changed": "3.0.0",
|
|
89
88
|
"resolve-from": "5.0.0",
|
|
90
|
-
"semver": "7.6.
|
|
89
|
+
"semver": "7.6.2",
|
|
91
90
|
"source-map-support": "0.5.21",
|
|
92
|
-
"teen_process": "2.1.
|
|
93
|
-
"type-fest": "4.
|
|
91
|
+
"teen_process": "2.1.4",
|
|
92
|
+
"type-fest": "4.19.0",
|
|
94
93
|
"winston": "3.13.0",
|
|
95
94
|
"wrap-ansi": "7.0.0",
|
|
96
|
-
"ws": "8.
|
|
97
|
-
"yaml": "2.4.
|
|
95
|
+
"ws": "8.17.0",
|
|
96
|
+
"yaml": "2.4.3"
|
|
98
97
|
},
|
|
99
98
|
"engines": {
|
|
100
99
|
"node": "^14.17.0 || ^16.13.0 || >=18.0.0",
|
|
@@ -103,5 +102,5 @@
|
|
|
103
102
|
"publishConfig": {
|
|
104
103
|
"access": "public"
|
|
105
104
|
},
|
|
106
|
-
"gitHead": "
|
|
105
|
+
"gitHead": "339acd345fafa1292c8d286261553fcc6b440e46"
|
|
107
106
|
}
|
package/types/cli.ts
CHANGED
|
@@ -2,6 +2,7 @@ import {DriverType, PluginType, ServerArgs} from '@appium/types';
|
|
|
2
2
|
import {SetOptional} from 'type-fest';
|
|
3
3
|
import {InstallType} from './manifest';
|
|
4
4
|
export type CliCommandServer = 'server';
|
|
5
|
+
export type CliCommandSetup = 'setup';
|
|
5
6
|
export type CliCommandDriver = DriverType;
|
|
6
7
|
export type CliCommandPlugin = PluginType;
|
|
7
8
|
|
|
@@ -13,7 +14,13 @@ export type CliExtensionCommand = CliCommandDriver | CliCommandPlugin;
|
|
|
13
14
|
/**
|
|
14
15
|
* Possible commands for the `appium` CLI.
|
|
15
16
|
*/
|
|
16
|
-
export type CliCommand = CliCommandServer | CliExtensionCommand;
|
|
17
|
+
export type CliCommand = CliCommandServer | CliExtensionCommand | CliCommandSetup;
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Possible subcommands of {@linkcode CliCommandSetup}.
|
|
21
|
+
* The command name will be preset name to get drivers/plugins to be installed.
|
|
22
|
+
*/
|
|
23
|
+
export type CliCommandSetupSubcommand = 'mobile' | 'browser' | 'desktop';
|
|
17
24
|
|
|
18
25
|
/**
|
|
19
26
|
* Possible subcommands of {@linkcode CliCommandDriver} or
|
|
@@ -55,6 +62,11 @@ export interface MoreArgs {
|
|
|
55
62
|
*/
|
|
56
63
|
showConfig?: boolean;
|
|
57
64
|
|
|
65
|
+
/**
|
|
66
|
+
* If true, show the server debug info and exit
|
|
67
|
+
*/
|
|
68
|
+
showDebugInfo?: boolean;
|
|
69
|
+
|
|
58
70
|
/**
|
|
59
71
|
* If true, open a REPL
|
|
60
72
|
*/
|
|
@@ -62,7 +74,7 @@ export interface MoreArgs {
|
|
|
62
74
|
}
|
|
63
75
|
|
|
64
76
|
/**
|
|
65
|
-
* These arguments are
|
|
77
|
+
* These arguments are not necessarily supported by the CLI, but via programmatic usage / tests.
|
|
66
78
|
*/
|
|
67
79
|
export interface ProgrammaticArgs {
|
|
68
80
|
/**
|
|
@@ -93,6 +105,11 @@ export interface ProgrammaticArgs {
|
|
|
93
105
|
* If true, show config and exit
|
|
94
106
|
*/
|
|
95
107
|
showConfig?: boolean;
|
|
108
|
+
|
|
109
|
+
/**
|
|
110
|
+
* If true, show debug info and exit
|
|
111
|
+
*/
|
|
112
|
+
showDebugInfo?: boolean;
|
|
96
113
|
}
|
|
97
114
|
|
|
98
115
|
export interface DriverExtArgs {
|
|
@@ -105,6 +122,10 @@ export interface PluginExtArgs {
|
|
|
105
122
|
plugin?: string;
|
|
106
123
|
}
|
|
107
124
|
|
|
125
|
+
export interface SetupArgs {
|
|
126
|
+
setupCommand?: CliCommandSetupSubcommand;
|
|
127
|
+
}
|
|
128
|
+
|
|
108
129
|
/**
|
|
109
130
|
* These are args which the user will specify if using an extension command
|
|
110
131
|
*/
|
|
@@ -132,9 +153,11 @@ export interface BaseExtArgs<Cmd extends CliExtensionCommand> {
|
|
|
132
153
|
*/
|
|
133
154
|
export type ExtArgs<
|
|
134
155
|
Cmd extends CliExtensionCommand,
|
|
135
|
-
SubCmd extends CliExtensionSubcommand
|
|
156
|
+
SubCmd extends CliExtensionSubcommand | CliCommandSetupSubcommand
|
|
136
157
|
> = BaseExtArgs<Cmd> &
|
|
137
|
-
(Cmd extends
|
|
158
|
+
(Cmd extends CliCommandSetup
|
|
159
|
+
? SetupArgs
|
|
160
|
+
: Cmd extends CliCommandDriver
|
|
138
161
|
? DriverExtArgs
|
|
139
162
|
: Cmd extends CliCommandPlugin
|
|
140
163
|
? PluginExtArgs
|
|
@@ -152,13 +175,15 @@ export type ExtArgs<
|
|
|
152
175
|
*/
|
|
153
176
|
export type CommonArgs<
|
|
154
177
|
Cmd extends CliCommand = CliCommandServer,
|
|
155
|
-
SubCmd extends CliExtensionSubcommand | void = void
|
|
178
|
+
SubCmd extends CliExtensionSubcommand | CliCommandSetupSubcommand | void = void
|
|
156
179
|
> = MoreArgs &
|
|
157
180
|
ProgrammaticArgs &
|
|
158
181
|
(Cmd extends CliCommandServer
|
|
159
182
|
? ServerArgs
|
|
183
|
+
: Cmd extends CliCommandSetup
|
|
184
|
+
? SetupArgs
|
|
160
185
|
: Cmd extends CliExtensionCommand
|
|
161
|
-
? SubCmd extends CliExtensionSubcommand
|
|
186
|
+
? SubCmd extends CliExtensionSubcommand | CliCommandSetupSubcommand
|
|
162
187
|
? ExtArgs<Cmd, SubCmd>
|
|
163
188
|
: never
|
|
164
189
|
: never);
|
|
@@ -168,7 +193,7 @@ export type CommonArgs<
|
|
|
168
193
|
*/
|
|
169
194
|
export type ParsedArgs<
|
|
170
195
|
Cmd extends CliCommand = CliCommandServer,
|
|
171
|
-
SubCmd extends CliExtensionSubcommand | void = void
|
|
196
|
+
SubCmd extends CliExtensionSubcommand | CliCommandSetupSubcommand | void = void
|
|
172
197
|
> = CommonArgs<Cmd, SubCmd>;
|
|
173
198
|
|
|
174
199
|
/**
|
|
@@ -178,7 +203,7 @@ export type ParsedArgs<
|
|
|
178
203
|
*/
|
|
179
204
|
export type Args<
|
|
180
205
|
Cmd extends CliCommand = CliCommandServer,
|
|
181
|
-
SubCmd extends CliExtensionSubcommand | void = void
|
|
206
|
+
SubCmd extends CliExtensionSubcommand | CliCommandSetupSubcommand | void = void
|
|
182
207
|
> = Cmd extends CliCommandServer
|
|
183
208
|
? SetOptional<CommonArgs<Cmd>, keyof ServerArgs>
|
|
184
209
|
: ParsedArgs<Cmd, SubCmd>;
|