appium 3.2.2 → 3.3.1
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 +147 -205
- package/build/lib/appium.d.ts.map +1 -1
- package/build/lib/appium.js +169 -282
- package/build/lib/appium.js.map +1 -1
- package/build/lib/bidi-commands.d.ts.map +1 -1
- package/build/lib/bidi-commands.js +11 -11
- package/build/lib/bidi-commands.js.map +1 -1
- package/build/lib/bootstrap/appium-initializer.d.ts +21 -0
- package/build/lib/bootstrap/appium-initializer.d.ts.map +1 -0
- package/build/lib/bootstrap/appium-initializer.js +146 -0
- package/build/lib/bootstrap/appium-initializer.js.map +1 -0
- package/build/lib/bootstrap/appium-main-runner.d.ts +22 -0
- package/build/lib/bootstrap/appium-main-runner.d.ts.map +1 -0
- package/build/lib/bootstrap/appium-main-runner.js +109 -0
- package/build/lib/bootstrap/appium-main-runner.js.map +1 -0
- package/build/lib/bootstrap/config-file.d.ts +37 -0
- package/build/lib/bootstrap/config-file.d.ts.map +1 -0
- package/build/lib/{config-file.js → bootstrap/config-file.js} +62 -138
- package/build/lib/bootstrap/config-file.js.map +1 -0
- package/build/lib/bootstrap/grid-v3-register.d.ts +20 -0
- package/build/lib/bootstrap/grid-v3-register.d.ts.map +1 -0
- package/build/lib/bootstrap/grid-v3-register.js +185 -0
- package/build/lib/bootstrap/grid-v3-register.js.map +1 -0
- package/build/lib/bootstrap/init-types.d.ts +16 -0
- package/build/lib/bootstrap/init-types.d.ts.map +1 -0
- package/build/lib/bootstrap/init-types.js +3 -0
- package/build/lib/bootstrap/init-types.js.map +1 -0
- package/build/lib/bootstrap/main-helpers.d.ts +55 -0
- package/build/lib/bootstrap/main-helpers.d.ts.map +1 -0
- package/build/lib/bootstrap/main-helpers.js +187 -0
- package/build/lib/bootstrap/main-helpers.js.map +1 -0
- package/build/lib/bootstrap/node-helpers.d.ts +32 -0
- package/build/lib/bootstrap/node-helpers.d.ts.map +1 -0
- package/build/lib/bootstrap/node-helpers.js +201 -0
- package/build/lib/bootstrap/node-helpers.js.map +1 -0
- package/build/lib/bootstrap/startup-config.d.ts +22 -0
- package/build/lib/bootstrap/startup-config.d.ts.map +1 -0
- package/build/lib/bootstrap/startup-config.js +111 -0
- package/build/lib/bootstrap/startup-config.js.map +1 -0
- package/build/lib/cli/args.d.ts +16 -12
- package/build/lib/cli/args.d.ts.map +1 -1
- package/build/lib/cli/args.js +20 -40
- package/build/lib/cli/args.js.map +1 -1
- package/build/lib/cli/driver-command.d.ts +51 -93
- package/build/lib/cli/driver-command.d.ts.map +1 -1
- package/build/lib/cli/driver-command.js +11 -66
- package/build/lib/cli/driver-command.js.map +1 -1
- package/build/lib/cli/extension-command.d.ts +173 -377
- package/build/lib/cli/extension-command.d.ts.map +1 -1
- package/build/lib/cli/extension-command.js +387 -656
- package/build/lib/cli/extension-command.js.map +1 -1
- package/build/lib/cli/extension.d.ts +10 -15
- package/build/lib/cli/extension.d.ts.map +1 -1
- package/build/lib/cli/extension.js +15 -33
- package/build/lib/cli/extension.js.map +1 -1
- package/build/lib/cli/parser.d.ts +37 -66
- package/build/lib/cli/parser.d.ts.map +1 -1
- package/build/lib/cli/parser.js +69 -104
- package/build/lib/cli/parser.js.map +1 -1
- package/build/lib/cli/plugin-command.d.ts +50 -90
- package/build/lib/cli/plugin-command.d.ts.map +1 -1
- package/build/lib/cli/plugin-command.js +11 -63
- package/build/lib/cli/plugin-command.js.map +1 -1
- package/build/lib/cli/setup-command.d.ts +21 -26
- package/build/lib/cli/setup-command.d.ts.map +1 -1
- package/build/lib/cli/setup-command.js +19 -61
- package/build/lib/cli/setup-command.js.map +1 -1
- package/build/lib/cli/utils.d.ts +33 -35
- package/build/lib/cli/utils.d.ts.map +1 -1
- package/build/lib/cli/utils.js +48 -50
- package/build/lib/cli/utils.js.map +1 -1
- package/build/lib/constants.d.ts +23 -23
- package/build/lib/constants.d.ts.map +1 -1
- package/build/lib/constants.js +10 -15
- package/build/lib/constants.js.map +1 -1
- package/build/lib/doctor/doctor.d.ts +40 -57
- package/build/lib/doctor/doctor.d.ts.map +1 -1
- package/build/lib/doctor/doctor.js +31 -62
- package/build/lib/doctor/doctor.js.map +1 -1
- package/build/lib/extension/driver-config.d.ts +18 -77
- package/build/lib/extension/driver-config.d.ts.map +1 -1
- package/build/lib/extension/driver-config.js +37 -125
- package/build/lib/extension/driver-config.js.map +1 -1
- package/build/lib/extension/extension-config.d.ts +103 -210
- package/build/lib/extension/extension-config.d.ts.map +1 -1
- package/build/lib/extension/extension-config.js +180 -342
- package/build/lib/extension/extension-config.js.map +1 -1
- package/build/lib/extension/index.d.ts +12 -29
- package/build/lib/extension/index.d.ts.map +1 -1
- package/build/lib/extension/index.js +33 -75
- package/build/lib/extension/index.js.map +1 -1
- package/build/lib/extension/manifest-migrations.d.ts +3 -20
- package/build/lib/extension/manifest-migrations.d.ts.map +1 -1
- package/build/lib/extension/manifest-migrations.js +20 -101
- package/build/lib/extension/manifest-migrations.js.map +1 -1
- package/build/lib/extension/manifest.d.ts +61 -107
- package/build/lib/extension/manifest.d.ts.map +1 -1
- package/build/lib/extension/manifest.js +181 -356
- package/build/lib/extension/manifest.js.map +1 -1
- package/build/lib/extension/package-changed.d.ts +1 -3
- package/build/lib/extension/package-changed.d.ts.map +1 -1
- package/build/lib/extension/package-changed.js +8 -15
- package/build/lib/extension/package-changed.js.map +1 -1
- package/build/lib/extension/plugin-config.d.ts +10 -52
- package/build/lib/extension/plugin-config.d.ts.map +1 -1
- package/build/lib/extension/plugin-config.js +11 -63
- package/build/lib/extension/plugin-config.js.map +1 -1
- package/build/lib/helpers/build.d.ts +22 -0
- package/build/lib/helpers/build.d.ts.map +1 -0
- package/build/lib/helpers/build.js +109 -0
- package/build/lib/helpers/build.js.map +1 -0
- package/build/lib/helpers/capability.d.ts +38 -0
- package/build/lib/helpers/capability.d.ts.map +1 -0
- package/build/lib/helpers/capability.js +128 -0
- package/build/lib/helpers/capability.js.map +1 -0
- package/build/lib/helpers/network.d.ts +14 -0
- package/build/lib/helpers/network.d.ts.map +1 -0
- package/build/lib/helpers/network.js +35 -0
- package/build/lib/helpers/network.js.map +1 -0
- package/build/lib/insecure-features.js +6 -6
- package/build/lib/insecure-features.js.map +1 -1
- package/build/lib/inspector-commands.d.ts +6 -0
- package/build/lib/inspector-commands.d.ts.map +1 -1
- package/build/lib/inspector-commands.js +6 -0
- package/build/lib/inspector-commands.js.map +1 -1
- package/build/lib/logger.d.ts +2 -3
- package/build/lib/logger.d.ts.map +1 -1
- package/build/lib/logger.js +2 -3
- package/build/lib/logger.js.map +1 -1
- package/build/lib/logsink.d.ts +13 -22
- package/build/lib/logsink.d.ts.map +1 -1
- package/build/lib/logsink.js +48 -103
- package/build/lib/logsink.js.map +1 -1
- package/build/lib/main.d.ts +15 -58
- package/build/lib/main.d.ts.map +1 -1
- package/build/lib/main.js +25 -425
- package/build/lib/main.js.map +1 -1
- package/build/lib/schema/arg-spec.d.ts +32 -107
- package/build/lib/schema/arg-spec.d.ts.map +1 -1
- package/build/lib/schema/arg-spec.js +11 -107
- package/build/lib/schema/arg-spec.js.map +1 -1
- package/build/lib/schema/cli-args-guards.d.ts +34 -0
- package/build/lib/schema/cli-args-guards.d.ts.map +1 -0
- package/build/lib/schema/cli-args-guards.js +49 -0
- package/build/lib/schema/cli-args-guards.js.map +1 -0
- package/build/lib/schema/cli-args.d.ts +3 -15
- package/build/lib/schema/cli-args.d.ts.map +1 -1
- package/build/lib/schema/cli-args.js +17 -107
- package/build/lib/schema/cli-args.js.map +1 -1
- package/build/lib/schema/cli-transformers.d.ts +15 -12
- package/build/lib/schema/cli-transformers.d.ts.map +1 -1
- package/build/lib/schema/cli-transformers.js +15 -45
- package/build/lib/schema/cli-transformers.js.map +1 -1
- package/build/lib/schema/format-errors.d.ts +28 -0
- package/build/lib/schema/format-errors.d.ts.map +1 -0
- package/build/lib/schema/format-errors.js +29 -0
- package/build/lib/schema/format-errors.js.map +1 -0
- package/build/lib/schema/index.d.ts +4 -2
- package/build/lib/schema/index.d.ts.map +1 -1
- package/build/lib/schema/index.js +2 -0
- package/build/lib/schema/index.js.map +1 -1
- package/build/lib/schema/keywords.d.ts +12 -20
- package/build/lib/schema/keywords.d.ts.map +1 -1
- package/build/lib/schema/keywords.js +6 -51
- package/build/lib/schema/keywords.js.map +1 -1
- package/build/lib/schema/schema.d.ts +106 -231
- package/build/lib/schema/schema.d.ts.map +1 -1
- package/build/lib/schema/schema.js +88 -358
- package/build/lib/schema/schema.js.map +1 -1
- package/build/lib/utils.d.ts +7 -267
- package/build/lib/utils.d.ts.map +1 -1
- package/build/lib/utils.js +10 -409
- package/build/lib/utils.js.map +1 -1
- package/lib/{appium.js → appium.ts} +297 -341
- package/lib/bidi-commands.ts +10 -14
- package/lib/bootstrap/appium-initializer.ts +212 -0
- package/lib/bootstrap/appium-main-runner.ts +172 -0
- package/lib/bootstrap/config-file.ts +178 -0
- package/lib/bootstrap/grid-v3-register.ts +250 -0
- package/lib/bootstrap/init-types.ts +31 -0
- package/lib/bootstrap/main-helpers.ts +223 -0
- package/lib/bootstrap/node-helpers.ts +180 -0
- package/lib/bootstrap/startup-config.ts +143 -0
- package/lib/cli/{args.js → args.ts} +45 -56
- package/lib/cli/driver-command.ts +122 -0
- package/lib/cli/{extension-command.js → extension-command.ts} +827 -906
- package/lib/cli/extension.ts +65 -0
- package/lib/cli/{parser.js → parser.ts} +93 -116
- package/lib/cli/plugin-command.ts +117 -0
- package/lib/cli/{setup-command.js → setup-command.ts} +59 -74
- package/lib/cli/utils.ts +97 -0
- package/lib/{constants.js → constants.ts} +30 -41
- package/lib/doctor/{doctor.js → doctor.ts} +82 -92
- package/lib/extension/driver-config.ts +165 -0
- package/lib/extension/{extension-config.js → extension-config.ts} +291 -405
- package/lib/extension/index.ts +143 -0
- package/lib/extension/manifest-migrations.ts +57 -0
- package/lib/extension/manifest.ts +369 -0
- package/lib/extension/{package-changed.js → package-changed.ts} +9 -18
- package/lib/extension/plugin-config.ts +62 -0
- package/lib/helpers/build.ts +111 -0
- package/lib/helpers/capability.ts +171 -0
- package/lib/helpers/network.ts +30 -0
- package/lib/insecure-features.ts +1 -1
- package/lib/inspector-commands.ts +6 -1
- package/lib/{logger.js → logger.ts} +1 -2
- package/lib/{logsink.js → logsink.ts} +91 -137
- package/lib/main.ts +60 -0
- package/lib/schema/arg-spec.ts +131 -0
- package/lib/schema/cli-args-guards.ts +67 -0
- package/lib/schema/cli-args.ts +171 -0
- package/lib/schema/cli-transformers.ts +83 -0
- package/lib/schema/format-errors.ts +43 -0
- package/lib/schema/index.ts +4 -0
- package/lib/schema/keywords.ts +96 -0
- package/lib/schema/schema.ts +448 -0
- package/lib/utils.ts +73 -0
- package/package.json +17 -18
- package/scripts/autoinstall-extensions.js +3 -0
- package/build/lib/config-file.d.ts +0 -100
- package/build/lib/config-file.d.ts.map +0 -1
- package/build/lib/config-file.js.map +0 -1
- package/build/lib/config.d.ts +0 -70
- package/build/lib/config.d.ts.map +0 -1
- package/build/lib/config.js +0 -390
- package/build/lib/config.js.map +0 -1
- package/build/lib/grid-register.d.ts +0 -10
- package/build/lib/grid-register.d.ts.map +0 -1
- package/build/lib/grid-register.js +0 -134
- package/build/lib/grid-register.js.map +0 -1
- package/lib/cli/driver-command.js +0 -174
- package/lib/cli/extension.js +0 -74
- package/lib/cli/plugin-command.js +0 -164
- package/lib/cli/utils.js +0 -91
- package/lib/config-file.js +0 -228
- package/lib/config.js +0 -389
- package/lib/extension/driver-config.js +0 -245
- package/lib/extension/index.js +0 -169
- package/lib/extension/manifest-migrations.js +0 -136
- package/lib/extension/manifest.js +0 -550
- package/lib/extension/plugin-config.js +0 -112
- package/lib/grid-register.js +0 -146
- package/lib/main.js +0 -545
- package/lib/schema/arg-spec.js +0 -229
- package/lib/schema/cli-args.js +0 -254
- package/lib/schema/cli-transformers.js +0 -113
- package/lib/schema/index.js +0 -2
- package/lib/schema/keywords.js +0 -136
- package/lib/schema/schema.js +0 -725
- package/lib/utils.js +0 -512
|
@@ -1,4 +1,11 @@
|
|
|
1
1
|
import _ from 'lodash';
|
|
2
|
+
import type {
|
|
3
|
+
Args,
|
|
4
|
+
CliCommandSetup,
|
|
5
|
+
CliCommandSetupSubcommand,
|
|
6
|
+
CliExtensionCommand,
|
|
7
|
+
CliExtensionSubcommand,
|
|
8
|
+
} from 'appium/types';
|
|
2
9
|
import {
|
|
3
10
|
DESKTOP_BROWSERS,
|
|
4
11
|
DESKTOP_DRIVERS,
|
|
@@ -6,7 +13,8 @@ import {
|
|
|
6
13
|
} from '../constants';
|
|
7
14
|
import {runExtensionCommand} from './extension';
|
|
8
15
|
import { system, fs } from '@appium/support';
|
|
9
|
-
import log from '../logger';
|
|
16
|
+
import {log} from '../logger';
|
|
17
|
+
import type {ExtensionConfig} from '../extension/extension-config';
|
|
10
18
|
|
|
11
19
|
/**
|
|
12
20
|
* Subcommands of preset for setup
|
|
@@ -20,13 +28,11 @@ export const SUBCOMMAND_RESET = 'reset';
|
|
|
20
28
|
* Pairs of preset subcommand and driver candidates.
|
|
21
29
|
* Driver names listed in KNOWN_DRIVERS to install by default
|
|
22
30
|
*/
|
|
23
|
-
const PRESET_PAIRS = Object.freeze(
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
}),
|
|
29
|
-
);
|
|
31
|
+
const PRESET_PAIRS = Object.freeze({
|
|
32
|
+
mobile: _.keys(MOBILE_DRIVERS),
|
|
33
|
+
desktop: _.keys(DESKTOP_DRIVERS),
|
|
34
|
+
browser: _.keys(DESKTOP_BROWSERS),
|
|
35
|
+
} as const);
|
|
30
36
|
const DRIVERS_ONLY_MACOS = ['xcuitest', 'safari', 'mac2'];
|
|
31
37
|
|
|
32
38
|
const DRIVERS_ONLY_WINDOWS = ['windows'];
|
|
@@ -36,12 +42,14 @@ const DRIVERS_ONLY_WINDOWS = ['windows'];
|
|
|
36
42
|
*/
|
|
37
43
|
export const DEFAULT_PLUGINS = ['images', 'inspector'];
|
|
38
44
|
|
|
45
|
+
type DriverConfig = ExtensionConfig<'driver'>;
|
|
46
|
+
type PluginConfig = ExtensionConfig<'plugin'>;
|
|
47
|
+
type CliExtArgs = Args<CliExtensionCommand, CliExtensionSubcommand>;
|
|
48
|
+
|
|
39
49
|
/**
|
|
40
50
|
* Return a list of drivers available for current host platform.
|
|
41
|
-
* @param {import('appium/types').CliCommandSetupSubcommand} presetName
|
|
42
|
-
* @returns {Array<string>}
|
|
43
51
|
*/
|
|
44
|
-
export function getPresetDrivers(presetName) {
|
|
52
|
+
export function getPresetDrivers(presetName: CliCommandSetupSubcommand): string[] {
|
|
45
53
|
return _.filter(PRESET_PAIRS[presetName], (driver) => {
|
|
46
54
|
if (_.includes(DRIVERS_ONLY_MACOS, driver)) {
|
|
47
55
|
return system.isMac();
|
|
@@ -58,9 +66,8 @@ export function getPresetDrivers(presetName) {
|
|
|
58
66
|
|
|
59
67
|
/**
|
|
60
68
|
* Return desktop platform name for setup command description.
|
|
61
|
-
* @returns {string}
|
|
62
69
|
*/
|
|
63
|
-
export function determinePlatformName() {
|
|
70
|
+
export function determinePlatformName(): string {
|
|
64
71
|
if (system.isMac()) {
|
|
65
72
|
return 'macOS';
|
|
66
73
|
} else if (system.isWindows()) {
|
|
@@ -70,14 +77,16 @@ export function determinePlatformName() {
|
|
|
70
77
|
}
|
|
71
78
|
|
|
72
79
|
/**
|
|
73
|
-
*
|
|
74
|
-
*
|
|
75
|
-
*
|
|
76
|
-
*
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
80
|
+
* Runs the `setup` command and applies the selected preset.
|
|
81
|
+
*
|
|
82
|
+
* Depending on the subcommand, this installs mobile/desktop/browser presets or
|
|
83
|
+
* removes all installed extensions and manifests via `reset`.
|
|
84
|
+
*/
|
|
85
|
+
export async function runSetupCommand(
|
|
86
|
+
preConfigArgs: Args<CliCommandSetup>,
|
|
87
|
+
driverConfig: DriverConfig,
|
|
88
|
+
pluginConfig: PluginConfig
|
|
89
|
+
): Promise<void> {
|
|
81
90
|
switch (preConfigArgs.setupCommand) {
|
|
82
91
|
case SUBCOMMAND_DESKTOP:
|
|
83
92
|
await setupDesktopAppDrivers(driverConfig);
|
|
@@ -99,22 +108,19 @@ export async function runSetupCommand(preConfigArgs, driverConfig, pluginConfig)
|
|
|
99
108
|
|
|
100
109
|
/**
|
|
101
110
|
* Resets all installed drivers and extensions
|
|
102
|
-
*
|
|
103
|
-
* @param {DriverConfig} driverConfig
|
|
104
|
-
* @param {PluginConfig} pluginConfig
|
|
105
|
-
* @returns {Promise<void>}
|
|
106
111
|
*/
|
|
107
|
-
async function resetAllExtensions(driverConfig, pluginConfig) {
|
|
108
|
-
|
|
112
|
+
async function resetAllExtensions(driverConfig: DriverConfig, pluginConfig: PluginConfig): Promise<void> {
|
|
113
|
+
const commandConfigs: [CliExtensionCommand, DriverConfig | PluginConfig][] = [
|
|
109
114
|
['driver', driverConfig],
|
|
110
115
|
['plugin', pluginConfig],
|
|
111
|
-
]
|
|
112
|
-
|
|
116
|
+
];
|
|
117
|
+
for (const [command, config] of commandConfigs) {
|
|
118
|
+
for (const extensionName of _.keys(config.installedExtensions)) {
|
|
113
119
|
try {
|
|
114
120
|
await uninstallExtension(
|
|
115
121
|
extensionName,
|
|
116
|
-
extensionCommandArgs(
|
|
117
|
-
|
|
122
|
+
extensionCommandArgs(command, extensionName, 'uninstall'),
|
|
123
|
+
config
|
|
118
124
|
);
|
|
119
125
|
} catch (e) {
|
|
120
126
|
log.warn(
|
|
@@ -124,8 +130,8 @@ async function resetAllExtensions(driverConfig, pluginConfig) {
|
|
|
124
130
|
}
|
|
125
131
|
}
|
|
126
132
|
|
|
127
|
-
const manifestPath =
|
|
128
|
-
if (!await fs.exists(manifestPath)) {
|
|
133
|
+
const manifestPath = config.manifestPath;
|
|
134
|
+
if (!manifestPath || !await fs.exists(manifestPath)) {
|
|
129
135
|
continue;
|
|
130
136
|
}
|
|
131
137
|
|
|
@@ -140,38 +146,29 @@ async function resetAllExtensions(driverConfig, pluginConfig) {
|
|
|
140
146
|
|
|
141
147
|
/**
|
|
142
148
|
* Install drivers listed in DEFAULT_DRIVERS.
|
|
143
|
-
* @param {DriverConfig} driverConfig
|
|
144
|
-
* @returns {Promise<void>}
|
|
145
149
|
*/
|
|
146
|
-
async function setupMobileDrivers(driverConfig) {
|
|
150
|
+
async function setupMobileDrivers(driverConfig: DriverConfig): Promise<void> {
|
|
147
151
|
await installDrivers(SUBCOMMAND_MOBILE, driverConfig);
|
|
148
152
|
}
|
|
149
153
|
|
|
150
154
|
/**
|
|
151
155
|
* Install all of known drivers listed in BROWSER_DRIVERS.
|
|
152
|
-
* @param {DriverConfig} driverConfig
|
|
153
|
-
* @returns {Promise<void>}
|
|
154
156
|
*/
|
|
155
|
-
async function setupBrowserDrivers(driverConfig) {
|
|
157
|
+
async function setupBrowserDrivers(driverConfig: DriverConfig): Promise<void> {
|
|
156
158
|
await installDrivers(SUBCOMMAND_BROWSER, driverConfig);
|
|
157
159
|
}
|
|
158
160
|
|
|
159
161
|
/**
|
|
160
162
|
* Install all of known drivers listed in DESKTOP_APP_DRIVERS.
|
|
161
|
-
* @param {DriverConfig} driverConfig
|
|
162
|
-
* @returns {Promise<void>}
|
|
163
163
|
*/
|
|
164
|
-
async function setupDesktopAppDrivers(driverConfig) {
|
|
164
|
+
async function setupDesktopAppDrivers(driverConfig: DriverConfig): Promise<void> {
|
|
165
165
|
await installDrivers(SUBCOMMAND_DESKTOP, driverConfig);
|
|
166
166
|
}
|
|
167
167
|
|
|
168
168
|
/**
|
|
169
169
|
* Install the given driver name. It skips the installation if the given driver name was already installed.
|
|
170
|
-
* @param {import('appium/types').CliCommandSetupSubcommand} subcommand
|
|
171
|
-
* @param {DriverConfig} driverConfig
|
|
172
|
-
* @returns {Promise<void>}
|
|
173
170
|
*/
|
|
174
|
-
async function installDrivers(subcommand, driverConfig) {
|
|
171
|
+
async function installDrivers(subcommand: CliCommandSetupSubcommand, driverConfig: DriverConfig): Promise<void> {
|
|
175
172
|
for (const driverName of getPresetDrivers(subcommand)) {
|
|
176
173
|
await installExtension(driverName, extensionCommandArgs('driver', driverName, 'install'), driverConfig);
|
|
177
174
|
}
|
|
@@ -179,10 +176,8 @@ async function installDrivers(subcommand, driverConfig) {
|
|
|
179
176
|
|
|
180
177
|
/**
|
|
181
178
|
* Install plugins listed in DEFAULT_PLUGINS.
|
|
182
|
-
* @param {PluginConfig} pluginConfig
|
|
183
|
-
* @returns {Promise<void>}
|
|
184
179
|
*/
|
|
185
|
-
async function setupDefaultPlugins(pluginConfig) {
|
|
180
|
+
async function setupDefaultPlugins(pluginConfig: PluginConfig): Promise<void> {
|
|
186
181
|
for (const pluginName of DEFAULT_PLUGINS) {
|
|
187
182
|
await installExtension(pluginName, extensionCommandArgs('plugin', pluginName, 'install'), pluginConfig);
|
|
188
183
|
}
|
|
@@ -190,12 +185,12 @@ async function setupDefaultPlugins(pluginConfig) {
|
|
|
190
185
|
|
|
191
186
|
/**
|
|
192
187
|
* Run the given extensionConfigArgs command after checking if the given extensionName was already installed.
|
|
193
|
-
* @param {string} extensionName
|
|
194
|
-
* @param {Args} extensionConfigArgs
|
|
195
|
-
* @param {DriverConfig|PluginConfig} extensionConfig
|
|
196
|
-
* @returns {Promise<void>}
|
|
197
188
|
*/
|
|
198
|
-
async function installExtension(
|
|
189
|
+
async function installExtension(
|
|
190
|
+
extensionName: string,
|
|
191
|
+
extensionConfigArgs: CliExtArgs,
|
|
192
|
+
extensionConfig: DriverConfig | PluginConfig
|
|
193
|
+
): Promise<void> {
|
|
199
194
|
if (_.keys(extensionConfig.installedExtensions).includes(extensionName)) {
|
|
200
195
|
log.info(`${extensionName} (${extensionConfig.installedExtensions[extensionName].version}) is already installed. ` +
|
|
201
196
|
`Skipping the installation.`);
|
|
@@ -206,12 +201,12 @@ async function installExtension(extensionName, extensionConfigArgs, extensionCon
|
|
|
206
201
|
|
|
207
202
|
/**
|
|
208
203
|
* Run the given extensionConfigArgs command after checking if the given extensionName was already installed.
|
|
209
|
-
* @param {string} extensionName
|
|
210
|
-
* @param {Args} extensionConfigArgs
|
|
211
|
-
* @param {DriverConfig|PluginConfig} extensionConfig
|
|
212
|
-
* @returns {Promise<void>}
|
|
213
204
|
*/
|
|
214
|
-
async function uninstallExtension(
|
|
205
|
+
async function uninstallExtension(
|
|
206
|
+
extensionName: string,
|
|
207
|
+
extensionConfigArgs: CliExtArgs,
|
|
208
|
+
extensionConfig: DriverConfig | PluginConfig
|
|
209
|
+
): Promise<void> {
|
|
215
210
|
if (!_.keys(extensionConfig.installedExtensions).includes(extensionName)) {
|
|
216
211
|
log.info(`${extensionName} (${extensionConfig.installedExtensions[extensionName].version}) is not installed. ` +
|
|
217
212
|
`Skipping its uninstall.`);
|
|
@@ -222,24 +217,14 @@ async function uninstallExtension(extensionName, extensionConfigArgs, extensionC
|
|
|
222
217
|
|
|
223
218
|
/**
|
|
224
219
|
* Return the command config for driver or plugin.
|
|
225
|
-
* @param {CliExtensionCommand} extensionCommand
|
|
226
|
-
* @param {string} extensionName
|
|
227
|
-
* @param {CliExtensionSubcommand} command
|
|
228
|
-
* @returns {Args}
|
|
229
220
|
*/
|
|
230
|
-
function extensionCommandArgs(
|
|
221
|
+
function extensionCommandArgs(
|
|
222
|
+
extensionCommand: CliExtensionCommand,
|
|
223
|
+
extensionName: string,
|
|
224
|
+
command: CliExtensionSubcommand
|
|
225
|
+
): CliExtArgs {
|
|
231
226
|
return (extensionCommand === 'plugin')
|
|
232
227
|
? {'subcommand': 'plugin', 'pluginCommand': command, 'plugin': extensionName}
|
|
233
228
|
: {'subcommand': 'driver', 'driverCommand': command, 'driver': extensionName};
|
|
234
229
|
}
|
|
235
230
|
|
|
236
|
-
/**
|
|
237
|
-
* @typedef {import('appium/types').CliExtensionCommand} CliExtensionCommand
|
|
238
|
-
* @typedef {import('appium/types').CliExtensionSubcommand} CliExtensionSubcommand
|
|
239
|
-
* @typedef {import('../extension/extension-config').ExtensionConfig<CliExtensionCommand>} PluginConfig
|
|
240
|
-
* @typedef {import('../extension/extension-config').ExtensionConfig<CliExtensionCommand>} DriverConfig
|
|
241
|
-
*/
|
|
242
|
-
|
|
243
|
-
/**
|
|
244
|
-
* @typedef {import('appium/types').Args<CliExtensionCommand, CliExtensionSubcommand>} Args
|
|
245
|
-
*/
|
package/lib/cli/utils.ts
ADDED
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
/* eslint-disable no-console */
|
|
2
|
+
|
|
3
|
+
import ora from 'ora';
|
|
4
|
+
|
|
5
|
+
export const JSON_SPACES = 4;
|
|
6
|
+
|
|
7
|
+
type ErrorLike = Error & {stderr?: unknown};
|
|
8
|
+
|
|
9
|
+
export class RingBuffer<T = any> {
|
|
10
|
+
private readonly size: number;
|
|
11
|
+
private readonly buffer: T[] = [];
|
|
12
|
+
|
|
13
|
+
constructor(size = 50) {
|
|
14
|
+
this.size = size;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Get the current buffer contents.
|
|
19
|
+
*/
|
|
20
|
+
getBuff(): T[] {
|
|
21
|
+
return this.buffer;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Add an item to the buffer.
|
|
26
|
+
*/
|
|
27
|
+
enqueue(item: T): void {
|
|
28
|
+
if (this.buffer.length >= this.size) {
|
|
29
|
+
this.dequeue();
|
|
30
|
+
}
|
|
31
|
+
this.buffer.push(item);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Remove the oldest item from the buffer.
|
|
36
|
+
*/
|
|
37
|
+
dequeue(): void {
|
|
38
|
+
this.buffer.shift();
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Log an error to the console and exit the process.
|
|
44
|
+
*
|
|
45
|
+
* @param json - whether we should log json or text
|
|
46
|
+
* @param msg - error message, object, Error instance, etc.
|
|
47
|
+
*/
|
|
48
|
+
export function errAndQuit(json: boolean, msg: unknown): never {
|
|
49
|
+
if (json) {
|
|
50
|
+
console.log(JSON.stringify({error: String(msg)}, null, JSON_SPACES));
|
|
51
|
+
} else {
|
|
52
|
+
console.error((String(msg) as any).red);
|
|
53
|
+
if ((msg as ErrorLike)?.stderr) {
|
|
54
|
+
console.error((String((msg as ErrorLike).stderr) as any).red);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
process.exit(1);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* Conditionally log something to the console.
|
|
62
|
+
*
|
|
63
|
+
* @param json - whether we are in json mode (and should therefore not log)
|
|
64
|
+
* @param msg - string to log
|
|
65
|
+
*/
|
|
66
|
+
export function log(json: boolean, msg: string): void {
|
|
67
|
+
if (!json) {
|
|
68
|
+
console.log(msg);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* Start a spinner, execute an async function, and then stop the spinner.
|
|
74
|
+
*
|
|
75
|
+
* @param json - whether we are in json mode (and should therefore not log)
|
|
76
|
+
* @param msg - string to log
|
|
77
|
+
* @param fn - function to wrap with spinning
|
|
78
|
+
* @returns result of `fn`
|
|
79
|
+
*/
|
|
80
|
+
export async function spinWith<T>(
|
|
81
|
+
json: boolean,
|
|
82
|
+
msg: string,
|
|
83
|
+
fn: () => T | Promise<T>
|
|
84
|
+
): Promise<T> {
|
|
85
|
+
if (json) {
|
|
86
|
+
return await fn();
|
|
87
|
+
}
|
|
88
|
+
const spinner = ora(msg).start();
|
|
89
|
+
try {
|
|
90
|
+
const res = await fn();
|
|
91
|
+
spinner.succeed();
|
|
92
|
+
return res;
|
|
93
|
+
} catch (err) {
|
|
94
|
+
spinner.fail();
|
|
95
|
+
throw err;
|
|
96
|
+
}
|
|
97
|
+
}
|
|
@@ -20,7 +20,6 @@ export const SERVER_SUBCOMMAND = 'server';
|
|
|
20
20
|
*/
|
|
21
21
|
export const SETUP_SUBCOMMAND = 'setup';
|
|
22
22
|
|
|
23
|
-
|
|
24
23
|
/**
|
|
25
24
|
* The value of `--use-plugins` if _all_ plugins should be loaded
|
|
26
25
|
*/
|
|
@@ -30,51 +29,41 @@ export const USE_ALL_PLUGINS = 'all';
|
|
|
30
29
|
// The plugins in this list will be available to the CLI so users can just
|
|
31
30
|
// type 'appium plugin install 'name'', rather than having to specify the full
|
|
32
31
|
// npm package. I.e., these are the officially recognized plugins.
|
|
33
|
-
export const KNOWN_PLUGINS = Object.freeze(
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
);
|
|
58
|
-
|
|
59
|
-
export const DESKTOP_BROWSERS = Object.freeze(
|
|
60
|
-
/** @type {const} */ ({
|
|
61
|
-
safari: 'appium-safari-driver',
|
|
62
|
-
gecko: 'appium-geckodriver',
|
|
63
|
-
chromium: 'appium-chromium-driver',
|
|
64
|
-
}),
|
|
65
|
-
);
|
|
32
|
+
export const KNOWN_PLUGINS = Object.freeze({
|
|
33
|
+
'execute-driver': '@appium/execute-driver-plugin',
|
|
34
|
+
images: '@appium/images-plugin',
|
|
35
|
+
inspector: 'appium-inspector-plugin',
|
|
36
|
+
'relaxed-caps': '@appium/relaxed-caps-plugin',
|
|
37
|
+
storage: '@appium/storage-plugin',
|
|
38
|
+
'universal-xml': '@appium/universal-xml-plugin',
|
|
39
|
+
} as const);
|
|
40
|
+
|
|
41
|
+
export const MOBILE_DRIVERS = Object.freeze({
|
|
42
|
+
uiautomator2: 'appium-uiautomator2-driver',
|
|
43
|
+
xcuitest: 'appium-xcuitest-driver',
|
|
44
|
+
espresso: 'appium-espresso-driver',
|
|
45
|
+
} as const);
|
|
46
|
+
|
|
47
|
+
export const DESKTOP_DRIVERS = Object.freeze({
|
|
48
|
+
mac2: 'appium-mac2-driver',
|
|
49
|
+
windows: 'appium-windows-driver',
|
|
50
|
+
} as const);
|
|
51
|
+
|
|
52
|
+
export const DESKTOP_BROWSERS = Object.freeze({
|
|
53
|
+
safari: 'appium-safari-driver',
|
|
54
|
+
gecko: 'appium-geckodriver',
|
|
55
|
+
chromium: 'appium-chromium-driver',
|
|
56
|
+
} as const);
|
|
66
57
|
|
|
67
58
|
// This is a map of driver names to npm packages representing those drivers.
|
|
68
59
|
// The drivers in this list will be available to the CLI so users can just
|
|
69
60
|
// type 'appium driver install 'name'', rather than having to specify the full
|
|
70
61
|
// npm package. I.e., these are the officially recognized drivers.
|
|
71
|
-
export const KNOWN_DRIVERS = Object.freeze(
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
}),
|
|
77
|
-
);
|
|
62
|
+
export const KNOWN_DRIVERS = Object.freeze({
|
|
63
|
+
...MOBILE_DRIVERS,
|
|
64
|
+
...DESKTOP_DRIVERS,
|
|
65
|
+
...DESKTOP_BROWSERS,
|
|
66
|
+
} as const);
|
|
78
67
|
|
|
79
68
|
/**
|
|
80
69
|
* Relative path to directory containing any Appium internal files
|